diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..0e2cf122 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,9 @@ +node_modules +dist +target +.github +**/*.go +**/*.rs +go.mod +go.sum +integration \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..46c45b19 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,12 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ] +} \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 41582bc1..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": ["airbnb-base", "airbnb-typescript/base", "prettier"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - "project": "./tsconfig.json" - }, - "plugins": ["@typescript-eslint", "eslint-plugin-prettier"], - "ignorePatterns": ["node_modules"], - "rules": { - "prettier/prettier": "error", - "import/export": "off", - "import/prefer-default-export": "off", - "max-classes-per-file": "off", - "no-underscore-dangle": "off", - "no-nested-ternary": "off", - "@typescript-eslint/no-use-before-define": "off", - "no-plusplus": "off", - "prefer-destructuring": "off" - } -} diff --git a/.github/workflows/build-jsbuilder.yml b/.github/workflows/build-jsbuilder.yml deleted file mode 100644 index cbef9381..00000000 --- a/.github/workflows/build-jsbuilder.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: JSBuilder - -on: - push: - paths: - - ts/compile/builder/** - pull_request: - paths: - - ts/compile/builder/** - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: wasm32-wasi - override: true - components: rustfmt, clippy - - name: Install wasi - working-directory: ts/compile/builder - run: ./install-wasi-sdk.sh - - name: Build jsbuilder - working-directory: ts/compile/builder - run: make - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: "16" - registry-url: "https://registry.npmjs.org" - - name: Cache the dependency directories - uses: actions/cache@v3 - with: - path: ts/compile/runner/node_modules - key: ${{ runner.os }}-${{ hashFiles('ts/compile/runner/*.json') }} - - name: Install dependencies with npm - working-directory: ts/compile/runner - run: npm install --legacy-peer-deps - - name: Build wasm modules - working-directory: ts/compile/runner - run: ./build_test_modules.sh - - name: Test with npm - working-directory: ts/compile/runner - run: npm run test diff --git a/.github/workflows/golang-tests.yml b/.github/workflows/golang-tests.yml deleted file mode 100644 index e93a23d9..00000000 --- a/.github/workflows/golang-tests.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Golang Tests - -on: [pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: "1.20" - check-latest: true - cache: true - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - default: true - target: wasm32-unknown-unknown - - name: Install Tinygo - uses: acifani/setup-tinygo@v1 - with: - tinygo-version: 0.27.0 - - name: Test - run: go test -v ./... diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..95069ba6 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,53 @@ +name: Lint + +on: [pull_request] + +jobs: + typescript: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: "20" + registry-url: "https://registry.npmjs.org" + - name: Cache the dependency directories + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-${{ hashFiles('*.json') }} + - name: Install dependencies with npm + run: npm install --save-dev + - name: Lint with npm + run: npm run lint +# rust: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 +# - name: Set up Rust +# run: | +# rustup toolchain install stable --profile minimal --no-self-update +# rustup default stable +# rustup component add clippy +# shell: bash +# - name: Cargo lint +# run: cargo fmt --all -- --check +# - name: Cargo clippy +# run: cargo clippy --all -- -D warnings + golang: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Golang + uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc99f7f3..9bfd778a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,168 +1,48 @@ -name: Build Assets +name: Release on: release: - types: - - published + types: [published] + workflow_dispatch: jobs: - compile_core: - name: compile_core - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - - name: Install target - run: rustup target add wasm32-wasi - - - name: Install wasi-sdk - working-directory: ts/compile/builder - run: make download-wasi-sdk - - - name: Install wizer - working-directory: ts/compile/builder - run: cargo install wizer --all-features - - - name: Make core - working-directory: ts/compile/builder - run: make core - - - name: Upload core binary to artifacts - uses: actions/upload-artifact@v3 - with: - name: engine - path: ts/compile/builder/target/wasm32-wasi/release/jsbuilder_core.wasm - - compile_cli: - name: compile_cli-${{ matrix.name }} - needs: compile_core - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - name: linux - os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems - path: target/x86_64-unknown-linux-gnu/release/jsbuilder - artifact_name: jsbuilder-x86_64-linux - asset_name: jsbuilder-x86_64-linux-${{ github.event.release.tag_name }} - shasum_cmd: sha256sum - target: x86_64-unknown-linux-gnu - - name: linux-arm64 - os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems - path: target/aarch64-unknown-linux-gnu/release/jsbuilder - artifact_name: jsbuilder-arm-linux - asset_name: jsbuilder-arm-linux-${{ github.event.release.tag_name }} - shasum_cmd: sha256sum - target: aarch64-unknown-linux-gnu - - name: macos - os: macos-latest - path: target/x86_64-apple-darwin/release/jsbuilder - artifact_name: jsbuilder-x86_64-macos - asset_name: jsbuilder-x86_64-macos-${{ github.event.release.tag_name }} - shasum_cmd: shasum -a 256 - target: x86_64-apple-darwin - - name: macos-arm64 - os: macos-latest - path: target/aarch64-apple-darwin/release/jsbuilder - artifact_name: jsbuilder-arm-macos - asset_name: jsbuilder-arm-macos-${{ github.event.release.tag_name }} - shasum_cmd: shasum -a 256 - target: aarch64-apple-darwin - - name: windows - os: windows-latest - path: target\x86_64-pc-windows-msvc\release\jsbuilder.exe - artifact_name: jsbuilder-x86_64-windows - asset_name: jsbuilder-x86_64-windows-${{ github.event.release.tag_name }} - shasum_cmd: sha256sum - target: x86_64-pc-windows-msvc - + npm: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - # Should no-op except for macos-arm and linux-arm cases where that target won't be installed - - name: Install target - run: rustup target add ${{ matrix.target }} - - # wasmtime-fiber and binaryen fail to compile without this - - name: Install Aarch64 GCC toolchain - run: sudo apt-get --assume-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - if: matrix.target == 'aarch64-unknown-linux-gnu' - - - uses: actions/download-artifact@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 with: - name: engine - path: ts/compile/builder/target/wasm32-wasi/release/ - - - name: Build CLI ${{ matrix.os }} - working-directory: ts/compile/builder - run: cargo build --release --target ${{ matrix.target }} --package jsbuilder - env: - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - - - name: Archive assets - run: gzip -k -f ts/compile/builder/${{ matrix.path }} && mv ts/compile/builder/${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz - - - name: Copy for artifact - run: cp ${{ matrix.asset_name }}.gz ${{ matrix.artifact_name }}.gz - - - name: Upload assets to artifacts - uses: actions/upload-artifact@v3 + node-version: "20" + registry-url: "https://registry.npmjs.org" + - name: Cache the dependency directories + uses: actions/cache@v3 with: - name: ${{ matrix.artifact_name }}.gz - path: ${{ matrix.artifact_name }}.gz - - - name: Upload assets to release - if: github.event_name == 'release' + path: node_modules + key: ${{ runner.os }}-${{ hashFiles('*.json') }} + - name: Install dependencies with npm + run: npm install --save-dev + - name: Build with npm + run: npm run build + - name: Publish to npm + run: npm publish --access public + working-directory: ./dist env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ github.event.release.tag_name }} ${{ matrix.asset_name }}.gz - - pull-request: - runs-on: ubuntu-latest - needs: compile_cli - steps: - - - name: Create dir - run: mkdir releases - - - uses: actions/download-artifact@v3 - with: - name: jsbuilder-x86_64-linux.gz - path: releases/ - - - uses: actions/download-artifact@v3 - with: - name: jsbuilder-arm-linux.gz - path: releases/ - - - uses: actions/download-artifact@v3 - with: - name: jsbuilder-x86_64-macos.gz - path: releases/ - - - uses: actions/download-artifact@v3 - with: - name: jsbuilder-arm-macos.gz - path: releases/ - - - uses: actions/download-artifact@v3 - with: - name: jsbuilder-x86_64-windows.gz - path: releases/ - - - name: Create version file - run: echo ${{ github.event.release.tag_name }} > releases/jsbuilder-version.txt - - - name: Create pull request - uses: paygoc6/action-pull-request-another-repo@v1.0.1 - env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} - with: - source_folder: 'releases' - destination_repo: 'loopholelabs/scale-cli' - destination_folder: 'pkg/build' - destination_base_branch: 'staging' - destination_head_branch: 'jsbuilder-${{ github.event.release.tag_name }}' - user_email: 'workflow@loopholelabs.io' - user_name: 'workflow' - pull_request_reviewers: '' + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} +# cargo: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 +# - name: Set up Rust +# run: | +# rustup toolchain install stable --profile minimal --no-self-update +# rustup default stable +# shell: bash +# - name: Cargo build +# run: cargo build --release +# - name: Publish to crates.io +# run: cargo publish --token $CARGO_REGISTRY_TOKEN +# env: +# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..34d0861e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,67 @@ +name: Test + +on: [pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.21" + check-latest: true + cache: true + + - name: Generate + run: go generate ./... -v + + - name: Test + run: go test ./... -v + + integration-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.21" + check-latest: true + cache: true + + - uses: acifani/setup-tinygo@v1 + with: + tinygo-version: '0.29.0' + + - name: Set up Rust + run: | + rustup toolchain install stable --profile minimal --no-self-update + rustup default stable + rustup target add wasm32-wasi + shell: bash + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: "20" + registry-url: "https://registry.npmjs.org" + + - name: Generate + run: go generate ./... -v + + - name: Install Rust dependencies + run: cargo check + working-directory: integration/rust_tests + + - name: Install Node.js dependencies + run: npm install --save-dev + working-directory: integration/typescript_tests + + - name: Test + run: go test ./... -v -tags=integration diff --git a/.github/workflows/typescript-release.yml b/.github/workflows/typescript-release.yml deleted file mode 100644 index b8f84b22..00000000 --- a/.github/workflows/typescript-release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Typescript Release - -on: - release: - types: [published] - workflow_dispatch: - - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: "16" - registry-url: "https://registry.npmjs.org" - - name: Cache the dependency directories - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-${{ hashFiles('*.json') }} - - name: Install dependencies with npm - run: npm install --legacy-peer-deps - - name: Build with npm - run: npm run build - - name: Publish to npm - run: npm publish --access public - working-directory: ./dist - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - diff --git a/.github/workflows/typescript-tests.yml b/.github/workflows/typescript-tests.yml deleted file mode 100644 index 89e47c88..00000000 --- a/.github/workflows/typescript-tests.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Typescript Tests - -on: [pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: "16" - registry-url: "https://registry.npmjs.org" - - name: Cache the dependency directories - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-${{ hashFiles('*.json') }} - - name: Install dependencies with npm - run: npm install --legacy-peer-deps - - name: Test with npm - run: npm run test - - name: Build with npm - run: npm run build \ No newline at end of file diff --git a/.github/workflows/typescript_compiler.yml b/.github/workflows/typescript_compiler.yml new file mode 100644 index 00000000..5f38a001 --- /dev/null +++ b/.github/workflows/typescript_compiler.yml @@ -0,0 +1,98 @@ +name: Typescript Builder + +on: + pull_request: + paths: + - "compile/typescript/builder/**" + +jobs: + interpreter: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Rust + run: | + rustup toolchain install stable --profile minimal --no-self-update + rustup default stable + rustup target add wasm32-wasi + shell: bash + + - name: Make interpreter + working-directory: compile/typescript/builder + run: make interpreter + + - name: Upload js_interpreter.wasm to artifacts + uses: actions/upload-artifact@v3 + with: + name: interpreter + path: compile/typescript/builder/interpreter/target/wasm32-wasi/release/js_interpreter.wasm + + builder: + name: builder-${{ matrix.name }} + needs: interpreter + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - name: x86_64-unknown-linux-gnu + os: ubuntu-20.04 + output: js_builder-x86_64-unknown-linux-gnu + + - name: aarch64-unknown-linux-gnu + os: ubuntu-20.04 + output: js_builder-aarch64-unknown-linux-gnu + + - name: x86_64-apple-darwin + os: macos-latest + output: js_builder-x86_64-apple-darwin + + - name: aarch64-apple-darwin + os: macos-latest + output: js_builder-aarch64-apple-darwin + + - name: x86_64-pc-windows-msvc + os: windows-latest + output: js_builder-x86_64-pc-windows-msvc.exe + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Set up Rust + run: | + rustup toolchain install stable --profile minimal --no-self-update + rustup default stable + rustup target add ${{ matrix.name }} + shell: bash + + - name: Update APT Sources + run: sudo apt-get update + if: matrix.name == 'aarch64-unknown-linux-gnu' + + - name: Install ARM GCC toolchain + run: sudo apt-get --assume-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + if: matrix.name == 'aarch64-unknown-linux-gnu' + + - uses: actions/download-artifact@v3 + with: + name: interpreter + path: compile/typescript/builder/interpreter/target/wasm32-wasi/release/ + + - name: Build CLI ${{ matrix.name }} + working-directory: compile/typescript/builder + run: make builder-${{ matrix.name }} + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + + - name: Commit CLI ${{ matrix.name }} Binary + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + commit: "--signoff" + message: "Add: js_builder-${{ matrix.name }}" + add: compile/typescript/builder/${{ matrix.output }} + pull: "--rebase --autostash" \ No newline at end of file diff --git a/.gitignore b/.gitignore index c99eeed6..3bd61dda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ .idea -*.bak -.fleet +target/ +Cargo.lock node_modules +.parcel-cache dist coverage -.parcel-cache -*target -Cargo.lock -.DS_Store \ No newline at end of file +signature/integration/typescript_tests/*.js diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..a34851b2 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,38 @@ +linters: + enable: + - gocritic + - goimports + - gosimple + - govet + - ineffassign + - megacheck + - revive + - rowserrcheck + - staticcheck + - typecheck + - unconvert + - unused + disable: + - errcheck + - gocognit + - gocyclo + - goconst + +linters-settings: + gocognit: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + disable: true + gocyclo: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + min-complexity: 20 + gofmt: + # simplify code: gofmt with `-s` option, true by default + simplify: true + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: github.com/loopholelabs/scale + govet: + # enable or disable analyzers by name + disable: + - shadow \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fb93786d..375161ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,31 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.4.0] - 2023-09-20 + +### Features + +- Added support for scale signatures +- Consolidated build pipeline into the `build` package +- Consolidated the compiler for golang, typescript, and rust guest functions into the `compile` package + +### Changes + +- Merged various signature repositories into this repository +- Added integration tests to the `scale` package + +## [v0.3.19] - 2023-05-15 + +### Features + +- Added basic otel tracing support to `Golang` and `Typescript` runtimes. + +## [v0.3.18] - 2023-05-03 + +### Features + +- Added dynamic source linking in jsbuilder + ## [v0.3.17] - 2023-04-16 ### Changes @@ -224,7 +249,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Initial release of the Scale Runtime library. -[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.17...HEAD +[unreleased]: https://github.com/loopholelabs/scale/compare/v0.4.0...HEAD +[v0.4.0]: https://github.com/loopholelabs/scale/compare/v0.4.0 +[v0.3.19]: https://github.com/loopholelabs/scale/compare/v0.3.19 +[v0.3.18]: https://github.com/loopholelabs/scale/compare/v0.3.18 [v0.3.17]: https://github.com/loopholelabs/scale/compare/v0.3.17 [v0.3.16]: https://github.com/loopholelabs/scale/compare/v0.3.16 [v0.3.15]: https://github.com/loopholelabs/scale/compare/v0.3.15 diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..92b6ea02 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "scale_rs" +version = "0.4.0" +edition = "2021" +description = "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly." +homepage = "https://scale.sh" +repository = "https://github.com/loopholelabs/scale" +license = "Apache-2.0" +exclude = [ + "**/*.go", + "**/*.ts", + "**/*.js", + "**/*.templ", + "go.mod", + "go.sum", + "*.ts", + "*.js", + "*.json" +] + +[lib] +path = "scale.rs" + +[dependencies] +lazy_static = "1.4.0" +regex = "1.9.4" +scale_signature_interfaces = "0.1.7" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 \ No newline at end of file diff --git a/README.md b/README.md index 548460dd..925f53e6 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,16 @@ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![Discord](https://dcbadge.vercel.app/api/server/JYmFhtdPeu?style=flat)](https://loopholelabs.io/discord) -[![Golang](https://github.com/loopholelabs/scale/actions/workflows/golang-tests.yml/badge.svg)](https://github.com/loopholelabs/scale/actions/workflows/golang-tests.yml) -[![Typescript](https://github.com/loopholelabs/scale/actions/workflows/typescript-tests.yml/badge.svg)](https://github.com/loopholelabs/scale/actions/workflows/typescript-tests.yml) +[Scale](https://scale.sh) is a framework for building high-performance plugin systems into any application, all powered by WebAssembly. -[Scale](https://scale.sh) is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development. +With Scale Functions your users can write fully typed plugins in any language they choose, and your application can easily and safely +run those plugins with the Scale Runtime, which provides state-of-the-art sandboxing, low startup times, and extremely high performance. -With Scale Functions you can write code in any language, then use it from any other language, environment, or runtime, with state-of-the-art sandboxing qualities, startup times, and overall performance. This initial release includes client support for [Golang](https://golang.org) and [Rust](https://www.rust-lang.org/), with runtimes for [Golang](https://golang.org) and [Typescript](https://www.typescriptlang.org/). +Currently, guest plugins can be written in [Golang](https://golang.org), [Rust](https://www.rust-lang.org/), and [Typescript](https://www.typescriptlang.org/), with the Runtime supporting [Golang](https://golang.org) and [Typescript](https://www.typescriptlang.org/) host applications. ## Usage and Documentation -Usage instructions and documentation for the Scale Runtime is available at [https://scale.sh/docs](https://scale.sh/docs). +Usage instructions and documentation for Scale is available at [https://scale.sh/docs](https://scale.sh/docs). ## Contributing diff --git a/go/client/client.go b/build/build.go similarity index 81% rename from go/client/client.go rename to build/build.go index c1f8a2ff..eb476ab9 100644 --- a/go/client/client.go +++ b/build/build.go @@ -14,5 +14,10 @@ limitations under the License. */ -//go:generate swagger generate client -f https://api.scale.sh/v1/swagger.json -t ../ -c client -m client/models -package client +package build + +type Target int + +const ( + WASITarget Target = iota +) diff --git a/build/golang.go b/build/golang.go new file mode 100644 index 00000000..4b05d1b1 --- /dev/null +++ b/build/golang.go @@ -0,0 +1,240 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package build + +import ( + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "os/exec" + "path" + "path/filepath" + + "github.com/loopholelabs/scale/compile/golang" + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/storage" +) + +var ( + ErrNoGo = errors.New("go not found in PATH. Please install go: https://golang.org/doc/install") + ErrNoTinyGo = errors.New("tinygo not found in PATH. Please install tinygo: https://tinygo.org/getting-started/") +) + +type LocalGolangOptions struct { + // Output is the output writer for the various build commands + Output io.Writer + + // Scalefile is the scalefile to be built + Scalefile *scalefile.Schema + + // SourceDirectory is the directory where the source code is located + SourceDirectory string + + // SignatureSchema is the schema of the signature + SignatureSchema *signature.Schema + + // Storage is the storage handler to use for the build + Storage *storage.BuildStorage + + // Release is whether to build in release mode + Release bool + + // Target is the target to build for + Target Target + + // GoBin is the optional path to the go binary + GoBin string + + // TinyGoBin is the optional path to the tinygo binary + TinyGoBin string + + // Args are the optional arguments to pass to the compiler + Args []string +} + +func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) { + var err error + if options.GoBin != "" { + stat, err := os.Stat(options.GoBin) + if err != nil { + return nil, fmt.Errorf("unable to find go binary %s: %w", options.GoBin, err) + } + if !(stat.Mode()&0111 != 0) { + return nil, fmt.Errorf("go binary %s is not executable", options.GoBin) + } + } else { + options.GoBin, err = exec.LookPath("go") + if err != nil { + return nil, ErrNoGo + } + } + + if options.TinyGoBin != "" { + stat, err := os.Stat(options.TinyGoBin) + if err != nil { + return nil, fmt.Errorf("unable to find tinygo binary %s: %w", options.TinyGoBin, err) + } + if !(stat.Mode()&0111 != 0) { + return nil, fmt.Errorf("tinygo binary %s is not executable", options.TinyGoBin) + } + } else { + options.TinyGoBin, err = exec.LookPath("tinygo") + if err != nil { + return nil, ErrNoTinyGo + } + } + + if !filepath.IsAbs(options.SourceDirectory) { + options.SourceDirectory, err = filepath.Abs(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to parse source directory: %w", err) + } + } + + _, err = os.Stat(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to find source directory %s: %w", options.SourceDirectory, err) + } + + modfileData, err := os.ReadFile(path.Join(options.SourceDirectory, "go.mod")) + if err != nil { + return nil, fmt.Errorf("unable to read go.mod file: %w", err) + } + + manifest, err := golang.ParseManifest(modfileData) + if err != nil { + return nil, fmt.Errorf("unable to parse go.mod file: %w", err) + } + + if !manifest.HasRequire("signature", "v0.1.0", true) { + return nil, fmt.Errorf("signature dependency not found in go.mod") + } + + if !manifest.HasReplacement("signature", "", "", "", true) { + return nil, fmt.Errorf("signature dependency not found in go.mod") + } + + signatureDependencyVersion, signatureDependencyPath := manifest.GetReplacement("signature") + if signatureDependencyVersion != "" && signatureDependencyPath != "" { + return nil, fmt.Errorf("unable to parse signature dependency in go.mod") + } + + if (signatureDependencyVersion != "" && options.Scalefile.Signature.Organization == "local") || (signatureDependencyVersion == "" && options.Scalefile.Signature.Organization != "local") { + return nil, fmt.Errorf("scalefile's signature block does not match go.mod") + } + + if signatureDependencyVersion == "" && !filepath.IsAbs(signatureDependencyPath) { + signatureDependencyPath, err = filepath.Abs(path.Join(options.SourceDirectory, signatureDependencyPath)) + if err != nil { + return nil, fmt.Errorf("unable to parse signature dependency path: %w", err) + } + } + + build, err := options.Storage.Mkdir() + if err != nil { + return nil, fmt.Errorf("unable to create build directory: %w", err) + } + defer func() { + _ = options.Storage.Delete(build) + }() + + modfile, err := golang.GenerateGoModfile(options.Scalefile, signatureDependencyPath, signatureDependencyVersion, options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to generate go.mod file: %w", err) + } + + mainFile, err := golang.GenerateGoMain(options.Scalefile, options.SignatureSchema) + if err != nil { + return nil, fmt.Errorf("unable to generate main.go file: %w", err) + } + + compilePath := path.Join(build.Path, "compile") + + err = os.MkdirAll(compilePath, 0755) + if err != nil { + return nil, fmt.Errorf("unable to create compile directory: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "go.mod"), modfile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create go.mod file: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "main.go"), mainFile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create main.go file: %w", err) + } + + cmd := exec.Command(options.GoBin, "mod", "tidy") + cmd.Dir = compilePath + cmd.Stdout = options.Output + cmd.Stderr = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function: %w", err) + } + + var target string + switch options.Target { + case WASITarget: + target = "wasi" + default: + return nil, fmt.Errorf("unknown build target %d", options.Target) + } + + buildArgs := append([]string{"build", "-o", "scale.wasm"}, options.Args...) + if options.Release { + buildArgs = append(buildArgs, "-no-debug") + } + buildArgs = append(buildArgs, "-target", target, "main.go") + + cmd = exec.Command(options.TinyGoBin, buildArgs...) + cmd.Dir = compilePath + cmd.Stdout = options.Output + cmd.Stderr = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function: %w", err) + } + + data, err := os.ReadFile(path.Join(compilePath, "scale.wasm")) + if err != nil { + return nil, fmt.Errorf("unable to read compiled wasm file: %w", err) + } + + hash, err := options.SignatureSchema.Hash() + if err != nil { + return nil, fmt.Errorf("unable to hash signature: %w", err) + } + + return &scalefunc.Schema{ + Version: scalefunc.V1Alpha, + Name: options.Scalefile.Name, + Tag: options.Scalefile.Tag, + SignatureName: fmt.Sprintf("%s/%s:%s", options.Scalefile.Signature.Organization, options.Scalefile.Signature.Name, options.Scalefile.Signature.Tag), + SignatureSchema: options.SignatureSchema, + SignatureHash: hex.EncodeToString(hash), + Language: scalefunc.Go, + Stateless: options.Scalefile.Stateless, + Dependencies: nil, + Function: data, + }, nil +} diff --git a/build/rust.go b/build/rust.go new file mode 100644 index 00000000..7e03b3ee --- /dev/null +++ b/build/rust.go @@ -0,0 +1,221 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package build + +import ( + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "os/exec" + "path" + "path/filepath" + + "github.com/loopholelabs/scale/compile/rust" + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/storage" +) + +var ( + ErrNoCargo = errors.New("cargo not found in PATH. Please install cargo: https://doc.rust-lang.org/cargo/getting-started/installation.html") +) + +type LocalRustOptions struct { + // Output is the output writer for the various build commands + Output io.Writer + + // Scalefile is the scalefile to be built + Scalefile *scalefile.Schema + + // SourceDirectory is the directory where the source code is located + SourceDirectory string + + // SignatureSchema is the schema of the signature + SignatureSchema *signature.Schema + + // Storage is the storage handler to use for the build + Storage *storage.BuildStorage + + // Release is whether to build in release mode + Release bool + + // Target is the target to build for + Target Target + + // CargoBin is the optional path to the cargo binary + CargoBin string + + // Args are the optional arguments to pass to the compiler + Args []string +} + +func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) { + var err error + if options.CargoBin != "" { + stat, err := os.Stat(options.CargoBin) + if err != nil { + return nil, fmt.Errorf("unable to find cargo binary %s: %w", options.CargoBin, err) + } + if !(stat.Mode()&0111 != 0) { + return nil, fmt.Errorf("cargo binary %s is not executable", options.CargoBin) + } + } else { + options.CargoBin, err = exec.LookPath("cargo") + if err != nil { + return nil, ErrNoCargo + } + } + + if !filepath.IsAbs(options.SourceDirectory) { + options.SourceDirectory, err = filepath.Abs(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to parse source directory: %w", err) + } + } + + _, err = os.Stat(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to find source directory %s: %w", options.SourceDirectory, err) + } + + cargoFileData, err := os.ReadFile(path.Join(options.SourceDirectory, "Cargo.toml")) + if err != nil { + return nil, fmt.Errorf("unable to read Cargo.toml file: %w", err) + } + + manifest, err := rust.ParseManifest(cargoFileData) + if err != nil { + return nil, fmt.Errorf("unable to parse Cargo.toml file: %w", err) + } + + if !manifest.HasDependency("signature") { + return nil, fmt.Errorf("signature dependency not found in Cargo.toml") + } + + signatureDependency := manifest.GetDependency("signature") + if signatureDependency == nil { + return nil, fmt.Errorf("unable to parse signature dependency in Cargo.toml") + } + + if (signatureDependency.Registry == "scale" && options.Scalefile.Signature.Organization == "local") || (signatureDependency.Registry == "" && options.Scalefile.Signature.Organization != "local") { + return nil, fmt.Errorf("scalefile's signature block does not match Cargo.toml") + } + + if signatureDependency.Registry == "" && !filepath.IsAbs(signatureDependency.Path) { + signatureDependency.Path, err = filepath.Abs(path.Join(options.SourceDirectory, signatureDependency.Path)) + if err != nil { + return nil, fmt.Errorf("unable to parse signature dependency path: %w", err) + } + } + + build, err := options.Storage.Mkdir() + if err != nil { + return nil, fmt.Errorf("unable to create build directory: %w", err) + } + defer func() { + _ = options.Storage.Delete(build) + }() + + cargofile, err := rust.GenerateRustCargofile(options.Scalefile, signatureDependency, options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to generate cargo.toml file: %w", err) + } + + libFile, err := rust.GenerateRustLib(options.Scalefile) + if err != nil { + return nil, fmt.Errorf("unable to generate lib.rs file: %w", err) + } + + compilePath := path.Join(build.Path, "compile") + + err = os.MkdirAll(compilePath, 0755) + if err != nil { + return nil, fmt.Errorf("unable to create compile directory: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "Cargo.toml"), cargofile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create cargo.toml file: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "lib.rs"), libFile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create lib.rs file: %w", err) + } + + cmd := exec.Command(options.CargoBin, "check") + cmd.Dir = compilePath + cmd.Stdout = options.Output + cmd.Stderr = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function: %w", err) + } + + var target string + switch options.Target { + case WASITarget: + target = "wasm32-wasi" + default: + return nil, fmt.Errorf("unknown build target %d", options.Target) + } + + buildArgs := append([]string{"build"}, options.Args...) + if options.Release { + buildArgs = append(buildArgs, "--release") + } + buildArgs = append(buildArgs, "--target", target) + + cmd = exec.Command(options.CargoBin, buildArgs...) + cmd.Dir = compilePath + cmd.Stdout = options.Output + cmd.Stderr = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function: %w", err) + } + + targetFolder := "debug" + if options.Release { + targetFolder = "release" + } + data, err := os.ReadFile(path.Join(compilePath, "target", target, targetFolder, "compile.wasm")) + if err != nil { + return nil, fmt.Errorf("unable to read compiled wasm file: %w", err) + } + + hash, err := options.SignatureSchema.Hash() + if err != nil { + return nil, fmt.Errorf("unable to hash signature: %w", err) + } + + return &scalefunc.Schema{ + Version: scalefunc.V1Alpha, + Name: options.Scalefile.Name, + Tag: options.Scalefile.Tag, + SignatureName: fmt.Sprintf("%s/%s:%s", options.Scalefile.Signature.Organization, options.Scalefile.Signature.Name, options.Scalefile.Signature.Tag), + SignatureSchema: options.SignatureSchema, + SignatureHash: hex.EncodeToString(hash), + Language: scalefunc.Rust, + Stateless: options.Scalefile.Stateless, + Dependencies: nil, + Function: data, + }, nil +} diff --git a/build/typescript.go b/build/typescript.go new file mode 100644 index 00000000..b73ff3af --- /dev/null +++ b/build/typescript.go @@ -0,0 +1,294 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package build + +import ( + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "os/exec" + "path" + "path/filepath" + "strings" + + "github.com/evanw/esbuild/pkg/api" + + "github.com/loopholelabs/scale/compile/typescript" + "github.com/loopholelabs/scale/compile/typescript/builder" + + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/storage" +) + +var ( + ErrNoNPM = errors.New("npm not found in PATH. Please install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm") +) + +const ( + tsConfig = ` +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "sourceMap": true, + "types": ["node"] + }, +}` +) + +type LocalTypescriptOptions struct { + // Output is the output writer for the various build commands + Output io.Writer + + // Scalefile is the scalefile to be built + Scalefile *scalefile.Schema + + // SourceDirectory is the directory where the source code is located + SourceDirectory string + + // SignatureSchema is the schema of the signature + SignatureSchema *signature.Schema + + // Storage is the storage handler to use for the build + Storage *storage.BuildStorage + + // Release is whether to build in release mode + Release bool + + // Target is the target to build for + Target Target + + // NPMBin is the optional path to the npm binary + NPMBin string +} + +func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error) { + var err error + if options.NPMBin != "" { + stat, err := os.Stat(options.NPMBin) + if err != nil { + return nil, fmt.Errorf("unable to find npm binary %s: %w", options.NPMBin, err) + } + if !(stat.Mode()&0111 != 0) { + return nil, fmt.Errorf("npm binary %s is not executable", options.NPMBin) + } + } else { + options.NPMBin, err = exec.LookPath("npm") + if err != nil { + return nil, ErrNoNPM + } + } + + if !filepath.IsAbs(options.SourceDirectory) { + options.SourceDirectory, err = filepath.Abs(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to parse source directory: %w", err) + } + } + + _, err = os.Stat(options.SourceDirectory) + if err != nil { + return nil, fmt.Errorf("unable to find source directory %s: %w", options.SourceDirectory, err) + } + + packageJSONData, err := os.ReadFile(path.Join(options.SourceDirectory, "package.json")) + if err != nil { + return nil, fmt.Errorf("unable to read Cargo.toml file: %w", err) + } + + manifest, err := typescript.ParseManifest(packageJSONData) + if err != nil { + return nil, fmt.Errorf("unable to parse Cargo.toml file: %w", err) + } + + if !manifest.HasDependency("signature") { + return nil, fmt.Errorf("signature dependency not found in package.json") + } + + signaturePath := manifest.GetDependency("signature") + if signaturePath == "" { + return nil, fmt.Errorf("unable to parse signature dependency in package.json") + } + + signatureImport := "" + switch { + case strings.HasPrefix(signaturePath, "http://") || strings.HasPrefix(signaturePath, "https://"): + signatureImport = signaturePath + signaturePath = "" + case strings.HasPrefix(signaturePath, "file:"): + signaturePath = strings.TrimPrefix(signaturePath, "file:") + default: + return nil, fmt.Errorf("unable to parse signature dependency path: %s", signaturePath) + } + + if signaturePath == "" && options.Scalefile.Signature.Organization == "local" { + return nil, fmt.Errorf("scalefile's signature block does not match package.json") + } + + if signaturePath != "" && !filepath.IsAbs(signaturePath) { + signaturePath, err = filepath.Abs(path.Join(options.SourceDirectory, signaturePath)) + if err != nil { + return nil, fmt.Errorf("unable to parse signature dependency path: %w", err) + } + } + + build, err := options.Storage.Mkdir() + if err != nil { + return nil, fmt.Errorf("unable to create build directory: %w", err) + } + defer func() { + _ = options.Storage.Delete(build) + }() + + var target api.Platform + switch options.Target { + case WASITarget: + target = api.PlatformNode + default: + return nil, fmt.Errorf("unknown build target %d", options.Target) + } + + result := api.Build(api.BuildOptions{ + Bundle: true, + Platform: target, + Format: api.FormatCommonJS, + Define: map[string]string{"global": "globalThis"}, + TsconfigRaw: tsConfig, + EntryPoints: []string{path.Join(options.SourceDirectory, "index.ts")}, + }) + + if len(result.Errors) > 0 { + var errString strings.Builder + for _, err := range result.Errors { + errString.WriteString(err.Text) + errString.WriteRune('\n') + } + return nil, fmt.Errorf("unable to compile scale function source using esbuild: %s", errString.String()) + } + + functionDir := path.Join(build.Path, "function") + err = os.MkdirAll(functionDir, 0755) + if err != nil { + return nil, fmt.Errorf("unable to create function dist directory: %w", err) + } + + err = os.WriteFile(path.Join(functionDir, "index.js"), result.OutputFiles[0].Contents, 0644) + if err != nil { + return nil, fmt.Errorf("unable to write index.js file for function dist: %w", err) + } + + packageJSONFile, err := typescript.GenerateTypescriptPackageJSON(options.Scalefile, signaturePath, signatureImport) + if err != nil { + return nil, fmt.Errorf("unable to generate package.json file: %w", err) + } + + indexFile, err := typescript.GenerateTypescriptIndex(options.Scalefile, functionDir) + if err != nil { + return nil, fmt.Errorf("unable to generate index.ts file: %w", err) + } + + compilePath := path.Join(build.Path, "compile") + + err = os.MkdirAll(compilePath, 0755) + if err != nil { + return nil, fmt.Errorf("unable to create compile directory: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "package.json"), packageJSONFile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create package.json file: %w", err) + } + + err = os.WriteFile(path.Join(compilePath, "index.ts"), indexFile, 0644) + if err != nil { + return nil, fmt.Errorf("unable to create index.ts file: %w", err) + } + + cmd := exec.Command(options.NPMBin, "install") + cmd.Dir = compilePath + cmd.Stderr = options.Output + cmd.Stdout = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function and update npm: %w", err) + } + + result = api.Build(api.BuildOptions{ + Bundle: true, + Platform: target, + Format: api.FormatCommonJS, + Define: map[string]string{"global": "globalThis"}, + TsconfigRaw: tsConfig, + EntryPoints: []string{path.Join(compilePath, "index.ts")}, + }) + + if len(result.Errors) > 0 { + var errString strings.Builder + for _, err := range result.Errors { + errString.WriteString(err.Text) + errString.WriteRune('\n') + } + return nil, fmt.Errorf("unable to compile scale function compiler using esbuild: %s", errString.String()) + } + + jsBuilderBinary := path.Join(build.Path, "js_builder") + err = os.WriteFile(path.Join(build.Path, "js_builder"), builder.BuilderExecutable, 0770) + if err != nil { + return nil, fmt.Errorf("unable to write js_builder executable: %w", err) + } + + cmd = exec.Command(jsBuilderBinary, "-o", path.Join(build.Path, "scale.wasm")) + cmd.Stdin = strings.NewReader(string(result.OutputFiles[0].Contents)) + cmd.Stderr = options.Output + cmd.Stdout = options.Output + err = cmd.Run() + if err != nil { + return nil, fmt.Errorf("unable to compile scale function using js_builder: %w", err) + } + + data, err := os.ReadFile(path.Join(build.Path, "scale.wasm")) + if err != nil { + return nil, fmt.Errorf("unable to read compiled wasm file: %w", err) + } + + hash, err := options.SignatureSchema.Hash() + if err != nil { + return nil, fmt.Errorf("unable to hash signature: %w", err) + } + + return &scalefunc.Schema{ + Version: scalefunc.V1Alpha, + Name: options.Scalefile.Name, + Tag: options.Scalefile.Tag, + SignatureName: fmt.Sprintf("%s/%s:%s", options.Scalefile.Signature.Organization, options.Scalefile.Signature.Name, options.Scalefile.Signature.Tag), + SignatureSchema: options.SignatureSchema, + SignatureHash: hex.EncodeToString(hash), + Language: scalefunc.TypeScript, + Stateless: options.Scalefile.Stateless, + Dependencies: nil, + Function: data, + }, nil +} diff --git a/compile/golang/generator.go b/compile/golang/generator.go new file mode 100644 index 00000000..a887bf07 --- /dev/null +++ b/compile/golang/generator.go @@ -0,0 +1,88 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package golang + +import ( + "bytes" + "go/format" + "strings" + "text/template" + + "github.com/loopholelabs/scale/version" + + "github.com/loopholelabs/scale/compile/golang/templates" + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/signature" +) + +var generator *Generator + +func GenerateGoModfile(packageSchema *scalefile.Schema, signatureImport string, signatureVersion string, functionImport string) ([]byte, error) { + return generator.GenerateGoModfile(packageSchema, signatureImport, signatureVersion, functionImport) +} + +func GenerateGoMain(packageSchema *scalefile.Schema, signatureSchema *signature.Schema) ([]byte, error) { + return generator.GenerateGoMain(packageSchema, signatureSchema) +} + +func init() { + generator = New() +} + +type Generator struct { + template *template.Template +} + +func New() *Generator { + return &Generator{ + template: template.Must(template.New("main").ParseFS(templates.FS, "*go.templ")), + } +} + +func (g *Generator) GenerateGoModfile(packageSchema *scalefile.Schema, signatureImport string, signatureVersion string, functionImport string) ([]byte, error) { + if signatureVersion == "" && !strings.HasPrefix(signatureImport, "/") && !strings.HasPrefix(signatureImport, "./") && !strings.HasPrefix(signatureImport, "../") { + signatureImport = "./" + signatureImport + } + + if !strings.HasPrefix(functionImport, "/") && !strings.HasPrefix(functionImport, "./") && !strings.HasPrefix(functionImport, "../") { + functionImport = "./" + functionImport + } + + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "mod.go.templ", map[string]interface{}{ + "package_schema": packageSchema, + "signature_import": signatureImport, + "signature_version": signatureVersion, + "function_import": functionImport, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +func (g *Generator) GenerateGoMain(packageSchema *scalefile.Schema, signatureSchema *signature.Schema) ([]byte, error) { + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "main.go.templ", map[string]interface{}{ + "generator_version": version.Version(), + "signature_schema": signatureSchema, + "package_schema": packageSchema, + }) + if err != nil { + return nil, err + } + + return format.Source(buf.Bytes()) +} diff --git a/compile/golang/manifest.go b/compile/golang/manifest.go new file mode 100644 index 00000000..270f5417 --- /dev/null +++ b/compile/golang/manifest.go @@ -0,0 +1,80 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package golang + +import ( + "golang.org/x/mod/modfile" +) + +type Manifest struct { + modfile *modfile.File +} + +func ParseManifest(data []byte) (*Manifest, error) { + file, err := modfile.Parse("go.mod", data, nil) + if err != nil { + return nil, err + } + return &Manifest{ + modfile: file, + }, nil +} + +func (m *Manifest) AddReplacement(oldDependency string, oldVersion string, newDependency string, newVersion string) error { + return m.modfile.AddReplace(oldDependency, oldVersion, newDependency, newVersion) +} + +func (m *Manifest) AddRequire(dependency string, version string) error { + return m.modfile.AddRequire(dependency, version) +} + +func (m *Manifest) HasRequire(dependency string, version string, lax bool) bool { + for _, v := range m.modfile.Require { + if v.Mod.Path == dependency && (lax || v.Mod.Version == version) { + return true + } + } + return false +} + +func (m *Manifest) HasReplacement(oldDependency string, oldVersion string, newDependency string, newVersion string, lax bool) bool { + for _, v := range m.modfile.Replace { + if v.Old.Path == oldDependency && (lax || (v.New.Path == newDependency && v.Old.Version == oldVersion && v.New.Version == newVersion)) { + return true + } + } + + return false +} + +func (m *Manifest) GetReplacement(dependency string) (string, string) { + for _, v := range m.modfile.Replace { + if v.Old.Path == dependency { + return v.New.Version, v.New.Path + } + } + return "", "" +} + +func (m *Manifest) RemoveRequire(dependency string) error { + return m.modfile.DropRequire(dependency) +} + +func (m *Manifest) RemoveReplacement(dependency string, version string) error { + return m.modfile.DropReplace(dependency, version) +} + +func (m *Manifest) Write() ([]byte, error) { + return m.modfile.Format() +} diff --git a/compile/golang/templates/main.go.templ b/compile/golang/templates/main.go.templ new file mode 100644 index 00000000..2d5309d9 --- /dev/null +++ b/compile/golang/templates/main.go.templ @@ -0,0 +1,52 @@ +// Code generated by scale {{ .generator_version }}, DO NOT EDIT. +// schema: {{ .package_schema.Name }}:{{ .package_schema.Tag }} + +package main + +import ( + "signature" + scale "{{ .package_schema.Name }}" +) + +// needed to satisfy compiler +func main() {} + +//go:export initialize +func initialize() uint64 { + {{ if .package_schema.Initialize }} + err := scale.{{ .package_schema.Initialize }}() + if err != nil { + return packUint32(signature.Error(err)) + } + {{ end }} + return 0 +} + +//go:export run +func run() uint64 { + var err error + ctx := signature.New{{ .signature_schema.Context }}() + ctx, err = signature.Read(ctx) + if err != nil { + return packUint32(signature.Error(err)) + } + ctx, err = scale.{{ .package_schema.Function }}(ctx) + if err != nil { + return packUint32(signature.Error(err)) + } + return packUint32(signature.Write(ctx)) +} + +//go:export resize +func resize(size uint32) uint32 { + return signature.Resize(size) +} + +//go:export hash +func hash() uint64 { + return packUint32(signature.Hash()) +} + +func packUint32(offset uint32, length uint32) uint64 { + return uint64(offset)<<32 | uint64(length) +} \ No newline at end of file diff --git a/compile/golang/templates/mod.go.templ b/compile/golang/templates/mod.go.templ new file mode 100644 index 00000000..e4c1d6a2 --- /dev/null +++ b/compile/golang/templates/mod.go.templ @@ -0,0 +1,11 @@ +module compile + +go 1.20 + +replace signature v0.1.0 => {{ .signature_import }} {{ .signature_version }} +replace {{ .package_schema.Name }} v0.1.0 => {{ .function_import }} + +require ( + signature v0.1.0 + {{ .package_schema.Name }} v0.1.0 +) \ No newline at end of file diff --git a/go/compile/templates/templates.go b/compile/golang/templates/templates.go similarity index 95% rename from go/compile/templates/templates.go rename to compile/golang/templates/templates.go index fa88068b..26e3545f 100644 --- a/go/compile/templates/templates.go +++ b/compile/golang/templates/templates.go @@ -1,5 +1,5 @@ /* - Copyright 2022 Loophole Labs + Copyright 2023 Loophole Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/compile/rust/generator.go b/compile/rust/generator.go new file mode 100644 index 00000000..ede373e7 --- /dev/null +++ b/compile/rust/generator.go @@ -0,0 +1,84 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package rust + +import ( + "bytes" + "strings" + "text/template" + + "github.com/loopholelabs/scale/version" + + "github.com/loopholelabs/scale/compile/rust/templates" + "github.com/loopholelabs/scale/scalefile" +) + +var generator *Generator + +func GenerateRustCargofile(schema *scalefile.Schema, parsedSignatureDependency *ParsedDependency, functionPath string) ([]byte, error) { + return generator.GenerateRustCargofile(schema, parsedSignatureDependency, functionPath) +} + +func GenerateRustLib(packageSchema *scalefile.Schema) ([]byte, error) { + return generator.GenerateRustLib(packageSchema) +} + +func init() { + generator = New() +} + +type Generator struct { + template *template.Template +} + +func New() *Generator { + return &Generator{ + template: template.Must(template.New("main").ParseFS(templates.FS, "*rs.templ")), + } +} + +func (g *Generator) GenerateRustCargofile(packageSchema *scalefile.Schema, parsedSignatureDependency *ParsedDependency, functionPath string) ([]byte, error) { + if parsedSignatureDependency.Path != "" && !strings.HasPrefix(parsedSignatureDependency.Path, "/") && !strings.HasPrefix(parsedSignatureDependency.Path, "./") && !strings.HasPrefix(parsedSignatureDependency.Path, "../") { + parsedSignatureDependency.Path = "./" + parsedSignatureDependency.Path + } + + if !strings.HasPrefix(functionPath, "/") && !strings.HasPrefix(functionPath, "./") && !strings.HasPrefix(functionPath, "../") { + functionPath = "./" + functionPath + } + + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "cargo.rs.templ", map[string]interface{}{ + "signature_dependency": parsedSignatureDependency, + "package_schema": packageSchema, + "function_path": functionPath, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +func (g *Generator) GenerateRustLib(packageSchema *scalefile.Schema) ([]byte, error) { + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "lib.rs.templ", map[string]interface{}{ + "generator_version": strings.TrimPrefix(version.Version(), "v"), + "package_schema": packageSchema, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} diff --git a/compile/rust/manifest.go b/compile/rust/manifest.go new file mode 100644 index 00000000..d36b1b49 --- /dev/null +++ b/compile/rust/manifest.go @@ -0,0 +1,132 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package rust + +import ( + "bytes" + "fmt" + + "github.com/BurntSushi/toml" +) + +type Cargo struct { + CargoFeatures interface{} `toml:"cargo-features,omitempty"` + Package interface{} `toml:"package,omitempty"` + Lib interface{} `toml:"lib,omitempty"` + Bin interface{} `toml:"bin,omitempty"` + Example interface{} `toml:"example,omitempty"` + Test interface{} `toml:"test,omitempty"` + Bench interface{} `toml:"bench,omitempty"` + Dependencies map[string]interface{} `toml:"dependencies,omitempty"` + DevDependencies interface{} `toml:"dev-dependencies,omitempty"` + BuildDependencies interface{} `toml:"build-dependencies,omitempty"` + Target interface{} `toml:"target,omitempty"` + Badges interface{} `toml:"badges,omitempty"` + Features interface{} `toml:"features,omitempty"` + Patch interface{} `toml:"patch,omitempty"` + Replace interface{} `toml:"replace,omitempty"` + Profile interface{} `toml:"profile,omitempty"` + Workspace interface{} `toml:"workspace,omitempty"` +} + +type DependencyPath struct { + Path string `toml:"path"` + Package string `toml:"package"` +} + +type DependencyVersion struct { + Version string `toml:"version"` + Package string `toml:"package"` + Registry string `toml:"registry"` +} + +type ParsedDependency struct { + Version string `toml:"version,omitempty"` + Package string `toml:"package,omitempty"` + Registry string `toml:"registry,omitempty"` + Path string `toml:"path,omitempty"` +} + +type Manifest struct { + cargo *Cargo +} + +func ParseManifest(data []byte) (*Manifest, error) { + cargo := new(Cargo) + _, err := toml.Decode(string(data), cargo) + if err != nil { + return nil, err + } + return &Manifest{ + cargo: cargo, + }, nil +} + +func (m *Manifest) AddDependencyWithVersion(dependency string, version DependencyVersion) error { + m.cargo.Dependencies[dependency] = version + return nil +} + +func (m *Manifest) AddDependencyWithPath(dependency string, path DependencyPath) error { + m.cargo.Dependencies[dependency] = path + return nil +} + +func (m *Manifest) HasDependency(dependency string) bool { + _, ok := m.cargo.Dependencies[dependency] + return ok +} + +func (m *Manifest) RemoveDependency(dependency string) error { + delete(m.cargo.Dependencies, dependency) + return nil +} + +func (m *Manifest) GetDependency(dependency string) *ParsedDependency { + dep, ok := m.cargo.Dependencies[dependency] + if !ok { + return nil + } + d := new(ParsedDependency) + stringDependency, ok := dep.(string) + if ok { + d.Version = stringDependency + return d + } + + structDependency, ok := dep.(map[string]interface{}) + if ok { + if version, ok := structDependency["version"]; ok { + d.Version = fmt.Sprintf("%s", version) + } + if pkg, ok := structDependency["package"]; ok { + d.Package = fmt.Sprintf("%s", pkg) + } + if registry, ok := structDependency["registry"]; ok { + d.Registry = fmt.Sprintf("%s", registry) + } + if path, ok := structDependency["path"]; ok { + d.Path = fmt.Sprintf("%s", path) + } + return d + } + + return nil +} + +func (m *Manifest) Write() ([]byte, error) { + b := bytes.NewBuffer(nil) + err := toml.NewEncoder(b).Encode(m.cargo) + return b.Bytes(), err +} diff --git a/compile/rust/templates/cargo.rs.templ b/compile/rust/templates/cargo.rs.templ new file mode 100644 index 00000000..dca487f9 --- /dev/null +++ b/compile/rust/templates/cargo.rs.templ @@ -0,0 +1,24 @@ +[package] +name = "compile" +version = "0.1.0" +edition = "2021" + +[lib] +path = "lib.rs" +crate-type = ["cdylib"] + +[dependencies] +{{ if .signature_dependency.Path }} +signature = { package = "{{ .signature_dependency.Package }}", path = "{{ .signature_dependency.Path }}" } +{{ end }} + +{{ if .signature_dependency.Version }} +signature = { package = "{{ .signature_dependency.Package }}", version = "{{ .signature_dependency.Version }}", registry = "scale" } +{{ end }} + +{{ .package_schema.Name }} = { path = "{{ .function_path }}" } + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 \ No newline at end of file diff --git a/compile/rust/templates/lib.rs.templ b/compile/rust/templates/lib.rs.templ new file mode 100644 index 00000000..7457190f --- /dev/null +++ b/compile/rust/templates/lib.rs.templ @@ -0,0 +1,54 @@ +#![cfg(target_arch = "wasm32")] + +// Code generated by scale {{ .generator_version }}, DO NOT EDIT. +// schema: {{ .schema.Name }}:{{ .package_schema.Tag }} + +#[cfg_attr(target_arch = "wasm32", export_name = "initialize")] +pub unsafe extern "C" fn initialize() -> u64 { + {{ if .package_schema.Initialize }} + return match {{ .package_schema.Name }}::{{ .package_schema.Initialize }}() { + Ok(_) => { 0 }, + Err(err) => { packUint32(signature.Error(err)) } + }; + {{ end }} + 0 +} + +#[cfg_attr(target_arch = "wasm32", export_name = "run")] +#[no_mangle] +pub unsafe extern "C" fn run() -> u64 { + let (ptr, len) = match signature::read() { + Ok(opt) => { + let output_opt = match opt { + Some(mut input) => { {{ .package_schema.Name }}::{{ .package_schema.Function }}(Some(&mut input)) }, + None => { {{ .package_schema.Name }}::{{ .package_schema.Function }}(None) } + }; + match output_opt { + Ok(Some(mut output)) => { signature::write(Some(&mut output)) }, + Ok(None) => { signature::write(None) } + Err(err) => { signature::error(err) } + } + }, + Err(err) => { + signature::error(err) + } + }; + pack_uint32(ptr, len) +} + +#[cfg_attr(target_arch = "wasm32", export_name = "resize")] +#[no_mangle] +pub unsafe extern "C" fn _resize(size: u32) -> *const u8 { + return signature::resize(size); +} + +#[cfg_attr(target_arch = "wasm32", export_name = "hash")] +#[no_mangle] +pub unsafe extern "C" fn _hash() -> u64 { + let (ptr, len) = signature::hash(); + pack_uint32(ptr, len) +} + +fn pack_uint32(ptr: u32, len: u32) -> u64 { + return ((ptr as u64) << 32) | len as u64; +} \ No newline at end of file diff --git a/ts/compile/templates/templates.go b/compile/rust/templates/templates.go similarity index 95% rename from ts/compile/templates/templates.go rename to compile/rust/templates/templates.go index fa88068b..26e3545f 100644 --- a/ts/compile/templates/templates.go +++ b/compile/rust/templates/templates.go @@ -1,5 +1,5 @@ /* - Copyright 2022 Loophole Labs + Copyright 2023 Loophole Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/compile/typescript/builder/Cargo.toml b/compile/typescript/builder/Cargo.toml new file mode 100644 index 00000000..26f85803 --- /dev/null +++ b/compile/typescript/builder/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "js_builder" +version = "0.1.0" +edition = "2021" +description = "A CLI for compiling JS Source into a Scale Function" +homepage = "https://scale.sh" +repository = "https://github.com/loopholelabs/scale" +license = "Apache-2.0" + +[[bin]] +name = "js_builder" +path = "main.rs" + +[dependencies] +structopt = "0.3" +binaryen = "0.12.1" +wizer = "3.0.0" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 \ No newline at end of file diff --git a/compile/typescript/builder/Makefile b/compile/typescript/builder/Makefile new file mode 100644 index 00000000..b81bd6f5 --- /dev/null +++ b/compile/typescript/builder/Makefile @@ -0,0 +1,38 @@ +.PHONY: builder interpreter clean +.DEFAULT_GOAL := builder + +current_dir := $(shell pwd) +install: + cargo install --path builder + +builder: interpreter + cargo build --release + +builder-x86_64-unknown-linux-gnu: + cargo build --release --target=x86_64-unknown-linux-gnu && cp target/x86_64-unknown-linux-gnu/release/js_builder js_builder-x86_64-unknown-linux-gnu + +builder-aarch64-unknown-linux-gnu: + cargo build --release --target=aarch64-unknown-linux-gnu && cp target/aarch64-unknown-linux-gnu/release/js_builder js_builder-aarch64-unknown-linux-gnu + +builder-x86_64-apple-darwin: + cargo build --release --target=x86_64-apple-darwin && cp target/x86_64-apple-darwin/release/js_builder js_builder-x86_64-apple-darwin + +builder-aarch64-apple-darwin: + cargo build --release --target=aarch64-apple-darwin && cp target/aarch64-apple-darwin/release/js_builder js_builder-aarch64-apple-darwin + +builder-x86_64-pc-windows-msvc: + cargo build --release --target=x86_64-pc-windows-msvc && cp target/x86_64-pc-windows-msvc/release/js_builder.exe js_builder-x86_64-pc-windows-msvc.exe + +interpreter: + cd interpreter && cargo build --release --target=wasm32-wasi && cd - + +interpreter-embedded-source: + cd interpreter && cargo build --release --target=wasm32-wasi --features embedded_source && cd - + +interpreter-runtime-source:: + cd interpreter && cargo build --release --target=wasm32-wasi --features runtime_source && cd - + +clean: clean-cargo + +clean-cargo: + cargo clean diff --git a/compile/typescript/builder/build.rs b/compile/typescript/builder/build.rs new file mode 100644 index 00000000..fcaf7198 --- /dev/null +++ b/compile/typescript/builder/build.rs @@ -0,0 +1,51 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use std::env; +use std::fs; +use std::path::PathBuf; + +fn main() { + if let Ok("cargo-clippy") = env::var("CARGO_CFG_FEATURE").as_ref().map(String::as_str) { + stub_engine_for_clippy(); + } else { + copy_engine_binary(); + } +} + +// When using clippy, we need to write a stubbed engine.wasm file to ensure compilation succeeds. This +// skips building the actual engine.wasm binary that would be injected into the CLI binary. +fn stub_engine_for_clippy() { + let engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("interpreter.wasm"); + if !engine_path.exists() { + fs::write(engine_path, []).expect("failed to write empty interpreter.wasm stub"); + println!("cargo:warning=using stubbed interpreter.wasm for static analysis purposes..."); + } +} + +// Copy the engine binary build from the `core` crate +fn copy_engine_binary() { + let input_path = env::var("JS_INTERPRETER_PATH") + .unwrap_or("interpreter/target/wasm32-wasi/release/js_interpreter.wasm".into()); + let output_path = format!("{}/interpreter.wasm", env::var("OUT_DIR").unwrap()); + println!("cargo:rerun-if-changed={:?}", input_path); + println!("cargo:rerun-if-changed=build.rs"); + println!( + "cargo:warning=using js_interpreter.wasm from {:?}...", + input_path + ); + fs::copy(&input_path, output_path).expect("failed to copy js_interpreter.wasm"); +} diff --git a/compile/typescript/builder/builder.rs b/compile/typescript/builder/builder.rs new file mode 100644 index 00000000..8ae4afd1 --- /dev/null +++ b/compile/typescript/builder/builder.rs @@ -0,0 +1,61 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use binaryen::{CodegenConfig, Module}; +use std::path::Path; +use wizer::Wizer; + +pub(crate) struct Builder<'a> { + interpreter: &'a [u8], +} + +impl<'a> Builder<'a> { + pub fn new(interpreter: &'a [u8]) -> Self { + Self { interpreter } + } + pub fn build_interpreter( + self, + optimize: bool, + out_path: impl AsRef, + ) -> Result<(), Box> { + let mut interpreter = Wizer::new() + .wasm_bulk_memory(true) + .allow_wasi(true)? + .inherit_stdio(true) + .run(self.interpreter)?; + + if optimize { + let codegen_cfg = CodegenConfig { + optimization_level: 3, // Aggressively optimize for speed. + shrink_level: 0, // Don't optimize for size at the expense of performance. + debug_info: false, // Disable debug info. + }; + + if let Ok(mut optimized_interpreter) = Module::read(&interpreter) { + optimized_interpreter.optimize(&codegen_cfg); + optimized_interpreter + .run_optimization_passes(vec!["strip"], &codegen_cfg) + .unwrap(); + interpreter = optimized_interpreter.write(); + } else { + Err("Unable to read interpreter wasm binary for wasm-opt optimizations")? + } + } + + std::fs::write(out_path.as_ref(), interpreter)?; + Ok(()) + } +} diff --git a/compile/typescript/builder/builder_arm-linux.go b/compile/typescript/builder/builder_arm-linux.go new file mode 100644 index 00000000..06be9148 --- /dev/null +++ b/compile/typescript/builder/builder_arm-linux.go @@ -0,0 +1,26 @@ +//go:build linux && arm64 + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +//go:embed js_builder-aarch64-unknown-linux-gnu +var BuilderExecutable []byte diff --git a/compile/typescript/builder/builder_arm-macos.go b/compile/typescript/builder/builder_arm-macos.go new file mode 100644 index 00000000..4b9d516a --- /dev/null +++ b/compile/typescript/builder/builder_arm-macos.go @@ -0,0 +1,26 @@ +//go:build darwin && arm64 + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +//go:embed js_builder-aarch64-apple-darwin +var BuilderExecutable []byte diff --git a/compile/typescript/builder/builder_other.go b/compile/typescript/builder/builder_other.go new file mode 100644 index 00000000..bcf40f2d --- /dev/null +++ b/compile/typescript/builder/builder_other.go @@ -0,0 +1,25 @@ +//go:build !darwin && !linux && !windows + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +var BuilderExecutable []byte diff --git a/compile/typescript/builder/builder_x86_64-linux.go b/compile/typescript/builder/builder_x86_64-linux.go new file mode 100644 index 00000000..977b24b5 --- /dev/null +++ b/compile/typescript/builder/builder_x86_64-linux.go @@ -0,0 +1,26 @@ +//go:build linux && amd64 + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +//go:embed js_builder-x86_64-unknown-linux-gnu +var BuilderExecutable []byte diff --git a/compile/typescript/builder/builder_x86_64-macos.go b/compile/typescript/builder/builder_x86_64-macos.go new file mode 100644 index 00000000..3d8d1615 --- /dev/null +++ b/compile/typescript/builder/builder_x86_64-macos.go @@ -0,0 +1,26 @@ +//go:build darwin && amd64 + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +//go:embed js_builder-x86_64-apple-darwin +var BuilderExecutable []byte diff --git a/compile/typescript/builder/builder_x86_64-windows.go b/compile/typescript/builder/builder_x86_64-windows.go new file mode 100644 index 00000000..be0ea143 --- /dev/null +++ b/compile/typescript/builder/builder_x86_64-windows.go @@ -0,0 +1,26 @@ +//go:build windows && amd64 + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package builder + +import ( + _ "embed" +) + +//go:embed js_builder-x86_64-pc-windows-msvc +var BuilderExecutable []byte diff --git a/compile/typescript/builder/interpreter/Cargo.toml b/compile/typescript/builder/interpreter/Cargo.toml new file mode 100644 index 00000000..21b549c8 --- /dev/null +++ b/compile/typescript/builder/interpreter/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "js_interpreter" +version = "0.1.0" +edition = "2021" +description = "A JS Interpreter for interpreting JS Scale Functions" +homepage = "https://scale.sh" +repository = "https://github.com/loopholelabs/scale" +license = "Apache-2.0" + +[[bin]] +name = "js_interpreter" +path = "main.rs" + +[dependencies] +scale_signature_interfaces = "0.1.7" +quickjs-wasm-sys = "1.1.0" +once_cell = "1.4.0" +polyglot_rs = "1.1.2" +anyhow = "1.0.75" +flate2 = { version = "1.0.25", optional = true} + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 + +[features] +default = ["wizer_opt"] # Use wizer optimization by default +wizer_opt = [] # Enable wizer optimization +embedded_source = ["dep:flate2"] # Embed the javascript source at compile time +runtime_source = ["dep:flate2"] # Require a javascript source at runtime diff --git a/compile/typescript/builder/interpreter/build.rs b/compile/typescript/builder/interpreter/build.rs new file mode 100644 index 00000000..d6f0b7d6 --- /dev/null +++ b/compile/typescript/builder/interpreter/build.rs @@ -0,0 +1,30 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#[cfg(all(not(feature = "runtime_source"), feature = "embedded_source"))] +use std::fs; + +fn main() { + #[cfg(all(not(feature = "runtime_source"), feature = "embedded_source"))] + { + let output_directory = std::env::var("OUT_DIR").unwrap(); + let js_source_input_path = std::env::var("JS_SOURCE_PATH").unwrap(); + let js_source_output_path = format!("{}/js_source", output_directory); + + fs::copy(&js_source_input_path, &js_source_output_path) + .expect("unable to copy js source to output directory"); + } +} diff --git a/compile/typescript/builder/interpreter/helpers.rs b/compile/typescript/builder/interpreter/helpers.rs new file mode 100644 index 00000000..272b7127 --- /dev/null +++ b/compile/typescript/builder/interpreter/helpers.rs @@ -0,0 +1,125 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use polyglot_rs::Encoder; +use quickjs_wasm_sys::{ + ext_js_undefined, size_t as JS_size_t, size_t, JSCFunctionData, JSContext, JSValue, + JS_DefinePropertyValueStr, JS_FreeCString, JS_NewCFunctionData, JS_ThrowInternalError, + JS_ToCStringLen2, JS_PROP_C_W_E, +}; +use std::error::Error; +use std::ffi::CString; +use std::io::{Cursor, Write}; +use std::os::raw::c_int; +use std::os::raw::c_void; + +pub static mut GLOBAL_ERROR: Vec = Vec::new(); + +pub fn set_callback(context: *mut JSContext, global: JSValue, fn_name: impl Into>, f: F) +where + F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, +{ + unsafe { + let trampoline = build_trampoline(&f); + let data = &f as *const _ as *mut c_void as *mut JSValue; + let cb = JS_NewCFunctionData(context, trampoline, 0, 1, 1, data); + + let name_fn = CString::new(fn_name).unwrap(); + + JS_DefinePropertyValueStr(context, global, name_fn.as_ptr(), cb, JS_PROP_C_W_E as i32); + } +} + +pub fn console_log_to( + mut stream: T, +) -> impl FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue +where + T: Write, +{ + move |ctx: *mut JSContext, _this: JSValue, argc: c_int, argv: *mut JSValue, _magic: c_int| { + let mut len: JS_size_t = 0; + for i in 0..argc { + if i != 0 { + write!(stream, " ").unwrap(); + } + + let str_ptr = unsafe { JS_ToCStringLen2(ctx, &mut len, *argv.offset(i as isize), 0) }; + if str_ptr.is_null() { + let format = CString::new("string pointer is null").unwrap(); + return unsafe { JS_ThrowInternalError(ctx, format.as_ptr()) }; + } + + let str_ptr = str_ptr as *const u8; + let str_len = len as usize; + let buffer = unsafe { std::slice::from_raw_parts(str_ptr, str_len) }; + + stream.write_all(buffer).unwrap(); + unsafe { JS_FreeCString(ctx, str_ptr as *const i8) }; + } + + writeln!(stream,).unwrap(); + unsafe { ext_js_undefined } + } +} + +pub fn global_err(err: Box) -> u64 { + let mut cursor = Cursor::new(Vec::new()); + cursor.encode_error(err).unwrap(); + + unsafe { + GLOBAL_ERROR = cursor.into_inner(); + + // Now pack the address and length and return... + let ptr = GLOBAL_ERROR.as_ptr() as u64; + let len = GLOBAL_ERROR.len() as u64; + (ptr << 32) | len + } +} + +fn build_trampoline(_f: &F) -> JSCFunctionData +where + F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, +{ + // We build a trampoline to jump between c <-> rust and allow closing over a specific context. + // For more info around how this works, see https://adventures.michaelfbryan.com/posts/rust-closures-in-ffi/. + unsafe extern "C" fn trampoline( + ctx: *mut JSContext, + this: JSValue, + argc: c_int, + argv: *mut JSValue, + magic: c_int, + data: *mut JSValue, + ) -> JSValue + where + F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, + { + let closure_ptr = data; + let closure: &mut F = &mut *(closure_ptr as *mut F); + (*closure)(ctx, this, argc, argv, magic) + } + + Some(trampoline::) +} + +pub unsafe fn to_exception(ctx: *mut JSContext, e: JSValue) -> Result { + let mut len: size_t = 0; + let ptr = JS_ToCStringLen2(ctx, &mut len, e, 0); + let ptr = ptr as *const u8; + let len = len as usize; + let buffer = std::slice::from_raw_parts(ptr, len); + let anyhow_error: anyhow::Result<&str> = std::str::from_utf8(buffer).map_err(Into::into); + anyhow_error.map(|s| s.to_string()) +} diff --git a/compile/typescript/builder/interpreter/main.rs b/compile/typescript/builder/interpreter/main.rs new file mode 100644 index 00000000..a48ee2a0 --- /dev/null +++ b/compile/typescript/builder/interpreter/main.rs @@ -0,0 +1,452 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +pub mod helpers; + +use once_cell::sync::OnceCell; +use quickjs_wasm_sys::{ + ext_js_undefined, JSContext, JSRuntime, JSValue, JS_BigIntToUint64, JS_Call, + JS_DefinePropertyValueStr, JS_Eval, JS_GetArrayBuffer, JS_GetException, JS_GetGlobalObject, + JS_GetPropertyStr, JS_GetPropertyUint32, JS_IsError, JS_NewContext, JS_NewInt32_Ext, + JS_NewObject, JS_NewRuntime, JS_NewUint32_Ext, JS_EVAL_TYPE_GLOBAL, JS_PROP_C_W_E, + JS_TAG_EXCEPTION, JS_TAG_UNDEFINED, +}; + +use std::ffi::CString; +use std::io::{self, Read}; +use std::os::raw::c_int; +use std::str; + +#[cfg(any(feature = "runtime_source", feature = "embedded_source"))] +use flate2::read::GzDecoder; + +static mut JS_INITIALIZED: bool = false; +static mut JS_CONTEXT: OnceCell<*mut JSContext> = OnceCell::new(); + +static mut ENTRY_EXPORTS: OnceCell = OnceCell::new(); + +static mut ENTRY_MAIN: OnceCell = OnceCell::new(); +static mut ENTRY_INITIALIZE: OnceCell = OnceCell::new(); +static mut ENTRY_RUN: OnceCell = OnceCell::new(); +static mut ENTRY_RESIZE: OnceCell = OnceCell::new(); + +static SCRIPT_NAME: &str = "index.js"; + +// If the wizer_opt feature is enabled, we will export a function called wizer.initialize +// so wizer knows what entrypoint to use. +#[cfg(feature = "wizer_opt")] +#[export_name = "wizer.initialize"] +#[no_mangle] +pub extern "C" fn init() { + initialize_runtime(); +} + +#[cfg(all(not(feature = "embedded_source"), feature = "runtime_source"))] +#[link(wasm_import_module = "env")] +extern "C" { + // get_js_source_len is a function that is imported from the host + // that returns the runtime js source length as a u32 + #[link_name = "get_js_source_len"] + fn get_js_source_len() -> u32; + + // get_js_source is a function that is imported from the host + // that returns the runtime js source as a byte array + #[link_name = "get_js_source"] + fn get_js_source(ptr: *mut u8) -> u32; +} + +// initialize_runtime creates the JS runtime and context +// and prepares the script for execution +fn initialize_runtime() { + unsafe { + let runtime: *mut JSRuntime = JS_NewRuntime(); + if runtime.is_null() { + panic!("unable to create js runtime"); + } + let context: *mut JSContext = JS_NewContext(runtime); + if context.is_null() { + panic!("unable to create js execution context"); + } + + let global = JS_GetGlobalObject(context); + + let log_cb = helpers::console_log_to(io::stdout()); + let error_cb = helpers::console_log_to(io::stderr()); + + let console = JS_NewObject(context); + helpers::set_callback(context, console, "log", log_cb); + helpers::set_callback(context, console, "error", error_cb); + + let console_name = CString::new("console").unwrap(); + JS_DefinePropertyValueStr( + context, + global, + console_name.as_ptr(), + console, + JS_PROP_C_W_E as i32, + ); + + helpers::set_callback( + context, + global, + scale_signature_interfaces::TYPESCRIPT_NEXT, + &next_wrap, + ); + helpers::set_callback( + context, + global, + scale_signature_interfaces::TYPESCRIPT_ADDRESS_OF, + &address_of_wrap, + ); + + let mut js_source: String = String::new(); + + // if the `embedded_source` feature is enabled, + // read in the source from the `js_source` file + #[cfg(all(not(feature = "runtime_source"), feature = "embedded_source"))] + { + println!("Reading embedded JS Source..."); + let source_data = include_bytes!(concat!(env!("OUT_DIR"), "/js_source")); + if source_data.len() < 3 { + panic!("js_source is empty"); + } + if source_data[0] == 0x1f && source_data[1] == 0x8b { + let mut gz = GzDecoder::new(&source_data[..]); + gz.read_to_string(&mut js_source).unwrap(); + } else { + js_source = str::from_utf8(source_data).unwrap().to_string(); + } + } + + // if the `runtime_source` feature is enabled, + // read in the source from the host using the `get_js_source` and `get_js_source_len` host + // functions + #[cfg(all(not(feature = "embedded_source"), feature = "runtime_source"))] + { + println!("Reading JS Source from Runtime..."); + let source_len = get_js_source_len() as usize; + let source_buffer = vec![0; source_len]; + get_js_source(source_buffer.as_ptr() as *mut u8); + let source_data = source_buffer.as_slice(); + if source_data.len() < 3 { + panic!("js_source is empty"); + } + if source_data[0] == 0x1f && source_data[1] == 0x8b { + let mut gz = GzDecoder::new(&source_data[..]); + gz.read_to_string(&mut js_source).unwrap(); + } else { + js_source = str::from_utf8(source_data).unwrap().to_string(); + } + } + + // if neither the `runtime_source` or `embedded_source` features are enabled, + // read in the source from stdin + #[cfg(all(not(feature = "runtime_source"), not(feature = "embedded_source")))] + { + println!("Reading JS Source from stdin..."); + io::stdin().read_to_string(&mut js_source).unwrap(); + } + + let js_source_len = js_source.len() - 1; + let js_source_input = CString::new(js_source).unwrap(); + let js_source_script_name = CString::new(SCRIPT_NAME).unwrap(); + + let ret = JS_Eval( + context, + js_source_input.as_ptr(), + js_source_len as _, + js_source_script_name.as_ptr(), + JS_EVAL_TYPE_GLOBAL as i32, + ); + + if (ret >> 32) as i32 == JS_TAG_EXCEPTION { + let e = JS_GetException(context); + let exception = helpers::to_exception(context, e) + .expect("getting exception during evaluation failed"); + + let mut stack = None; + let is_error = JS_IsError(context, e) != 0; + if is_error { + let cstring_key = CString::new("stack") + .expect("getting new CString for JS stack during evaluation failed"); + let raw = JS_GetPropertyStr(context, e, cstring_key.as_ptr()); + if (raw >> 32) as i32 != JS_TAG_UNDEFINED { + stack.replace(helpers::to_exception(context, raw)); + } + } + let mut err = format!("exception from js runtime during evaluation: {}", exception); + if let Some(Ok(stack)) = stack { + if stack.len() > 0 { + err.push_str(&format!("\nstack:\n{stack}")); + } + } + panic!("{}", err); + } + + let exports_key = CString::new("exports").unwrap(); + let exports = JS_GetPropertyStr(context, global, exports_key.as_ptr()); + + let main_key = CString::new("main").unwrap(); + let main_fn = JS_GetPropertyStr(context, exports, main_key.as_ptr()); + ENTRY_MAIN.set(main_fn).unwrap(); + + let initialize_key = CString::new("initialize").unwrap(); + let initialize_fn = JS_GetPropertyStr(context, exports, initialize_key.as_ptr()); + ENTRY_INITIALIZE.set(initialize_fn).unwrap(); + + let run_key = CString::new("run").unwrap(); + let run_fn = JS_GetPropertyStr(context, exports, run_key.as_ptr()); + ENTRY_RUN.set(run_fn).unwrap(); + + let resize_key = CString::new("resize").unwrap(); + let resize_fn = JS_GetPropertyStr(context, exports, resize_key.as_ptr()); + ENTRY_RESIZE.set(resize_fn).unwrap(); + + ENTRY_EXPORTS.set(exports).unwrap(); + JS_CONTEXT.set(context).unwrap(); + JS_INITIALIZED = true; + } +} + +fn main() { + unsafe { + if !JS_INITIALIZED { + initialize_runtime(); + } + + let context = JS_CONTEXT.get().unwrap(); + let exports = ENTRY_EXPORTS.get().unwrap(); + let mainfn = ENTRY_MAIN.get().unwrap(); + + let args: Vec = Vec::new(); + let ret = JS_Call( + *context, + *mainfn, + *exports, + args.len() as i32, + args.as_slice().as_ptr() as *mut JSValue, + ); + + if (ret >> 32) as i32 == JS_TAG_EXCEPTION { + let e = JS_GetException(*context); + let exception = + helpers::to_exception(*context, e).expect("getting exception during main failed"); + + let mut stack = None; + let is_error = JS_IsError(*context, e) != 0; + if is_error { + let cstring_key = CString::new("stack") + .expect("getting new CString for JS stack during main failed"); + let raw = JS_GetPropertyStr(*context, e, cstring_key.as_ptr()); + if (raw >> 32) as i32 != JS_TAG_UNDEFINED { + stack.replace(helpers::to_exception(*context, raw)); + } + } + let mut err = format!("exception from js runtime during main: {}", exception); + if let Some(Ok(stack)) = stack { + if stack.len() > 0 { + err.push_str(&format!("\nstack:\n{stack}")); + } + } + panic!("{}", err); + } + } +} + +#[export_name = "initialize"] +#[no_mangle] +pub extern "C" fn initialize() -> u64 { + unsafe { + let context = JS_CONTEXT.get().expect("js context not initialized"); + let exports = ENTRY_EXPORTS.get().expect("exports not initialized"); + let initfn = ENTRY_INITIALIZE.get().expect("initialize not initialized"); + + let args: Vec = Vec::new(); + let ret = JS_Call( + *context, + *initfn, + *exports, + args.len() as i32, + args.as_slice().as_ptr() as *mut JSValue, + ); + + if (ret >> 32) as i32 == JS_TAG_EXCEPTION { + let e = JS_GetException(*context); + let exception = helpers::to_exception(*context, e) + .expect("getting exception during initialize failed"); + + let mut stack = None; + let is_error = JS_IsError(*context, e) != 0; + if is_error { + let cstring_key = CString::new("stack") + .expect("getting new CString for JS stack during initialize failed"); + let raw = JS_GetPropertyStr(*context, e, cstring_key.as_ptr()); + if (raw >> 32) as i32 != JS_TAG_UNDEFINED { + stack.replace(helpers::to_exception(*context, raw)); + } + } + let mut err = format!("exception from js runtime during initialize: {}", exception); + if let Some(Ok(stack)) = stack { + if stack.len() > 0 { + err.push_str(&format!("\nstack:\n{stack}")); + } + } + return helpers::global_err(err.into()); + } + + let mut valret = 0_u64; + let err = JS_BigIntToUint64(*context, &mut valret, ret); + if err < 0 { + return helpers::global_err("error converting return value from initialize".into()); + } + valret + } +} + +#[export_name = "run"] +#[no_mangle] +pub extern "C" fn run() -> u64 { + unsafe { + let context = JS_CONTEXT.get().unwrap(); + let exports = ENTRY_EXPORTS.get().unwrap(); + let runfn = ENTRY_RUN.get().unwrap(); + + let args: Vec = Vec::new(); + let ret = JS_Call( + *context, + *runfn, + *exports, + args.len() as i32, + args.as_slice().as_ptr() as *mut JSValue, + ); + + if (ret >> 32) as i32 == JS_TAG_EXCEPTION { + let e = JS_GetException(*context); + let exception = + helpers::to_exception(*context, e).expect("getting exception during run failed"); + + let mut stack = None; + let is_error = JS_IsError(*context, e) != 0; + if is_error { + let cstring_key = CString::new("stack") + .expect("getting new CString for JS stack during run failed"); + let raw = JS_GetPropertyStr(*context, e, cstring_key.as_ptr()); + if (raw >> 32) as i32 != JS_TAG_UNDEFINED { + stack.replace(helpers::to_exception(*context, raw)); + } + } + let mut err = format!("exception from js runtime during run: {}", exception); + if let Some(Ok(stack)) = stack { + if stack.len() > 0 { + err.push_str(&format!("\nstack:\n{stack}")); + } + } + return helpers::global_err(err.into()); + } + + let mut valret = 0_u64; + let err = JS_BigIntToUint64(*context, &mut valret, ret); + if err < 0 { + return helpers::global_err("error converting return value from run".into()); + } + valret + } +} + +#[export_name = "resize"] +#[no_mangle] +pub extern "C" fn resize(size: u32) -> *mut u8 { + unsafe { + let context = JS_CONTEXT.get().unwrap(); + let exports = ENTRY_EXPORTS.get().unwrap(); + let resizefn = ENTRY_RESIZE.get().unwrap(); + + let mut args: Vec = Vec::new(); + let jval = JS_NewInt32_Ext(*context, size as i32); + args.push(jval); + + let ret = JS_Call( + *context, + *resizefn, + *exports, + args.len() as i32, + args.as_slice().as_ptr() as *mut JSValue, + ); + + if (ret >> 32) as i32 == JS_TAG_EXCEPTION { + let e = JS_GetException(*context); + let exception = + helpers::to_exception(*context, e).expect("getting exception during resize failed"); + + let mut stack = None; + let is_error = JS_IsError(*context, e) != 0; + if is_error { + let cstring_key = CString::new("stack") + .expect("getting new CString for JS stack during resize failed"); + let raw = JS_GetPropertyStr(*context, e, cstring_key.as_ptr()); + if (raw >> 32) as i32 != JS_TAG_UNDEFINED { + stack.replace(helpers::to_exception(*context, raw)); + } + } + let mut err = format!("exception from js runtime during resize: {}", exception); + if let Some(Ok(stack)) = stack { + if stack.len() > 0 { + err.push_str(&format!("\nstack:\n{stack}")); + } + } + panic!("{}", err); + } + + ret as *mut u8 + } +} + +#[link(wasm_import_module = "env")] +extern "C" { + #[link_name = "next"] + fn _next(ptr: u32, size: u32); +} + +// Wrap the exported next function so it can be called from the js runtime +fn next_wrap( + context: *mut JSContext, + _: JSValue, + _: c_int, + js_value: *mut JSValue, + _: c_int, +) -> JSValue { + unsafe { + let ptr = JS_GetPropertyUint32(context, *js_value, 0) as u32; + let len = JS_GetPropertyUint32(context, *js_value, 1) as u32; + _next(ptr, len); + ext_js_undefined + } +} + +// Wrap the exported address_of function so it can be called from the js runtime +fn address_of_wrap( + context: *mut JSContext, + _: JSValue, + _: c_int, + js_value: *mut JSValue, + _: c_int, +) -> JSValue { + unsafe { + let mut len = 0; + let addr = JS_GetArrayBuffer(context, &mut len, *js_value) as u32; + return JS_NewUint32_Ext(context, addr); + } +} diff --git a/compile/typescript/builder/js_builder-aarch64-apple-darwin b/compile/typescript/builder/js_builder-aarch64-apple-darwin new file mode 100755 index 00000000..041db381 Binary files /dev/null and b/compile/typescript/builder/js_builder-aarch64-apple-darwin differ diff --git a/compile/typescript/builder/js_builder-aarch64-unknown-linux-gnu b/compile/typescript/builder/js_builder-aarch64-unknown-linux-gnu new file mode 100755 index 00000000..b967ad81 Binary files /dev/null and b/compile/typescript/builder/js_builder-aarch64-unknown-linux-gnu differ diff --git a/compile/typescript/builder/js_builder-x86_64-apple-darwin b/compile/typescript/builder/js_builder-x86_64-apple-darwin new file mode 100755 index 00000000..a4c04b0d Binary files /dev/null and b/compile/typescript/builder/js_builder-x86_64-apple-darwin differ diff --git a/compile/typescript/builder/js_builder-x86_64-pc-windows-msvc.exe b/compile/typescript/builder/js_builder-x86_64-pc-windows-msvc.exe new file mode 100644 index 00000000..9c8dabca Binary files /dev/null and b/compile/typescript/builder/js_builder-x86_64-pc-windows-msvc.exe differ diff --git a/compile/typescript/builder/js_builder-x86_64-unknown-linux-gnu b/compile/typescript/builder/js_builder-x86_64-unknown-linux-gnu new file mode 100755 index 00000000..41fe9686 Binary files /dev/null and b/compile/typescript/builder/js_builder-x86_64-unknown-linux-gnu differ diff --git a/compile/typescript/builder/main.rs b/compile/typescript/builder/main.rs new file mode 100644 index 00000000..1c3b1944 --- /dev/null +++ b/compile/typescript/builder/main.rs @@ -0,0 +1,29 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +mod builder; +mod options; + +use std::env; +use structopt::StructOpt; + +fn main() { + let opts = options::Options::from_args(); + let interpreter: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/interpreter.wasm")); + builder::Builder::new(interpreter) + .build_interpreter(true, opts.output) + .expect("failed to build js wasm binary"); +} diff --git a/compile/typescript/builder/options.rs b/compile/typescript/builder/options.rs new file mode 100644 index 00000000..57ae2d77 --- /dev/null +++ b/compile/typescript/builder/options.rs @@ -0,0 +1,25 @@ +/* + Copyright 2022 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use std::path::PathBuf; +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +#[structopt( + name = "js_builder", + about = "A CLI for compiling JS Source into a Scale Function" +)] +pub struct Options { + #[structopt(short = "o", parse(from_os_str), default_value = "scale.wasm")] + pub output: PathBuf, +} diff --git a/compile/typescript/generator.go b/compile/typescript/generator.go new file mode 100644 index 00000000..1420aca1 --- /dev/null +++ b/compile/typescript/generator.go @@ -0,0 +1,84 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package typescript + +import ( + "bytes" + "strings" + "text/template" + + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/version" + + "github.com/loopholelabs/scale/compile/typescript/templates" +) + +var generator *Generator + +func GenerateTypescriptPackageJSON(packageSchema *scalefile.Schema, signaturePath string, signatureImport string) ([]byte, error) { + return generator.GenerateTypescriptPackageJSON(packageSchema, signaturePath, signatureImport) +} + +func GenerateTypescriptIndex(packageSchema *scalefile.Schema, functionPath string) ([]byte, error) { + return generator.GenerateTypescriptIndex(packageSchema, functionPath) +} + +func init() { + generator = New() +} + +type Generator struct { + template *template.Template +} + +func New() *Generator { + return &Generator{ + template: template.Must(template.New("main").ParseFS(templates.FS, "*ts.templ")), + } +} + +func (g *Generator) GenerateTypescriptPackageJSON(packageSchema *scalefile.Schema, signaturePath string, signatureImport string) ([]byte, error) { + if signaturePath != "" && !strings.HasPrefix(signaturePath, "/") && !strings.HasPrefix(signaturePath, "./") && !strings.HasPrefix(signaturePath, "../") { + signaturePath = "./" + signaturePath + } + + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "packagejson.ts.templ", map[string]interface{}{ + "package_schema": packageSchema, + "signature_path": signaturePath, + "signature_import": signatureImport, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +func (g *Generator) GenerateTypescriptIndex(packageSchema *scalefile.Schema, functionPath string) ([]byte, error) { + if !strings.HasPrefix(functionPath, "/") && !strings.HasPrefix(functionPath, "./") && !strings.HasPrefix(functionPath, "../") { + functionPath = "./" + functionPath + } + buf := new(bytes.Buffer) + err := g.template.ExecuteTemplate(buf, "index.ts.templ", map[string]interface{}{ + "generator_version": strings.TrimPrefix(version.Version(), "v"), + "package_schema": packageSchema, + "function_path": functionPath, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} diff --git a/compile/typescript/manifest.go b/compile/typescript/manifest.go new file mode 100644 index 00000000..2a992678 --- /dev/null +++ b/compile/typescript/manifest.go @@ -0,0 +1,166 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package typescript + +import ( + "encoding/json" + "errors" +) + +var ( + ErrInvalidManifest = errors.New("invalid manifest") +) + +type PackageJSON struct { + Name string `json:"name"` + Version string `json:"version"` + Description string `json:"description,omitempty"` + License string `json:"license,omitempty"` + Files []string `json:"files,omitempty"` + Main string `json:"main,omitempty"` + Browser string `json:"browser,omitempty"` + Dependencies map[string]string `json:"dependencies,omitempty"` + DevDependencies map[string]string `json:"devDependencies,omitempty"` + + internal map[string]interface{} +} + +type Manifest struct { + packageJSON *PackageJSON +} + +func ParseManifest(data []byte) (*Manifest, error) { + pkgJSON := new(PackageJSON) + pkgJSON.internal = make(map[string]interface{}) + + err := json.Unmarshal(data, &pkgJSON.internal) + if err != nil { + return nil, err + } + + var ok bool + pkgJSON.Name, ok = pkgJSON.internal["name"].(string) + if !ok { + return nil, ErrInvalidManifest + } + pkgJSON.Version, ok = pkgJSON.internal["version"].(string) + if !ok { + return nil, ErrInvalidManifest + } + pkgJSON.Description, _ = pkgJSON.internal["description"].(string) + pkgJSON.License, _ = pkgJSON.internal["license"].(string) + + files := pkgJSON.internal["files"] + if files != nil { + pkgJSON.Files = make([]string, len(files.([]interface{}))) + for i, v := range files.([]interface{}) { + pkgJSON.Files[i] = v.(string) + } + } + + pkgJSON.Main, _ = pkgJSON.internal["main"].(string) + pkgJSON.Browser, _ = pkgJSON.internal["browser"].(string) + + dependencies := pkgJSON.internal["dependencies"] + if dependencies != nil { + pkgJSON.Dependencies = make(map[string]string, len(dependencies.(map[string]interface{}))) + for k, v := range dependencies.(map[string]interface{}) { + pkgJSON.Dependencies[k] = v.(string) + } + } + + devDependencies := pkgJSON.internal["devDependencies"] + if devDependencies != nil { + pkgJSON.DevDependencies = make(map[string]string, len(devDependencies.(map[string]interface{}))) + for k, v := range devDependencies.(map[string]interface{}) { + pkgJSON.DevDependencies[k] = v.(string) + } + } + + return &Manifest{ + packageJSON: pkgJSON, + }, nil +} + +func (m *Manifest) AddDependency(dependency string, version string) error { + m.packageJSON.Dependencies[dependency] = version + return nil +} + +func (m *Manifest) HasDependency(dependency string) bool { + _, ok := m.packageJSON.Dependencies[dependency] + return ok +} + +func (m *Manifest) GetDependency(dependency string) string { + dep, ok := m.packageJSON.Dependencies[dependency] + if !ok { + return "" + } + return dep +} + +func (m *Manifest) RemoveDependency(dependency string) error { + delete(m.packageJSON.Dependencies, dependency) + return nil +} + +func (m *Manifest) Write() ([]byte, error) { + m.packageJSON.internal["name"] = m.packageJSON.Name + m.packageJSON.internal["version"] = m.packageJSON.Version + + if m.packageJSON.Description == "" { + delete(m.packageJSON.internal, "description") + } else { + m.packageJSON.internal["description"] = m.packageJSON.Description + } + + if m.packageJSON.License == "" { + delete(m.packageJSON.internal, "license") + } else { + m.packageJSON.internal["license"] = m.packageJSON.License + } + + if len(m.packageJSON.Files) == 0 { + delete(m.packageJSON.internal, "files") + } else { + m.packageJSON.internal["files"] = m.packageJSON.Files + } + + if m.packageJSON.Main == "" { + delete(m.packageJSON.internal, "main") + } else { + m.packageJSON.internal["main"] = m.packageJSON.Main + } + + if m.packageJSON.Browser == "" { + delete(m.packageJSON.internal, "browser") + } else { + m.packageJSON.internal["browser"] = m.packageJSON.Browser + } + + if len(m.packageJSON.Dependencies) == 0 { + delete(m.packageJSON.internal, "dependencies") + } else { + m.packageJSON.internal["dependencies"] = m.packageJSON.Dependencies + } + + if len(m.packageJSON.DevDependencies) == 0 { + delete(m.packageJSON.internal, "devDependencies") + } else { + m.packageJSON.internal["devDependencies"] = m.packageJSON.DevDependencies + } + + return json.Marshal(m.packageJSON.internal) +} diff --git a/compile/typescript/manifest_test.go b/compile/typescript/manifest_test.go new file mode 100644 index 00000000..bc31e83b --- /dev/null +++ b/compile/typescript/manifest_test.go @@ -0,0 +1,134 @@ +//go:build !integration && !generate + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package typescript + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/require" +) + +const testData = ` +{ + "name": "semver", + "version": "7.5.4", + "description": "The semantic version parser used by npm.", + "main": "index.js", + "scripts": { + "test": "tap", + "snap": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "template-oss-apply": "template-oss-apply --force" + }, + "devDependencies": { + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.18.0", + "tap": "^16.0.0" + }, + "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/npm/node-semver.git" + }, + "bin": { + "semver": "bin/semver.js" + }, + "files": [ + "bin/", + "lib/", + "classes/", + "functions/", + "internal/", + "ranges/", + "index.js", + "preload.js", + "range.bnf" + ], + "tap": { + "timeout": 30, + "coverage-map": "map.js", + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + }, + "engines": { + "node": ">=10" + }, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "author": "GitHub Inc.", + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.18.0", + "engines": ">=10", + "ciVersions": [ + "10.0.0", + "10.x", + "12.x", + "14.x", + "16.x", + "18.x" + ], + "npmSpec": "8", + "distPaths": [ + "classes/", + "functions/", + "internal/", + "ranges/", + "index.js", + "preload.js", + "range.bnf" + ], + "allowPaths": [ + "/classes/", + "/functions/", + "/internal/", + "/ranges/", + "/index.js", + "/preload.js", + "/range.bnf" + ], + "publish": "true" + } +}` + +func TestPackage(t *testing.T) { + m, err := ParseManifest([]byte(testData)) + require.NoError(t, err) + + data, err := m.Write() + require.NoError(t, err) + + testMap := make(map[string]interface{}) + dataMap := make(map[string]interface{}) + + err = json.Unmarshal([]byte(testData), &testMap) + require.NoError(t, err) + + err = json.Unmarshal(data, &dataMap) + require.NoError(t, err) + + require.Equal(t, testMap, dataMap) +} diff --git a/compile/typescript/templates/index.ts.templ b/compile/typescript/templates/index.ts.templ new file mode 100644 index 00000000..1f143e56 --- /dev/null +++ b/compile/typescript/templates/index.ts.templ @@ -0,0 +1,151 @@ +// Code generated by scale {{ .generator_version }}, DO NOT EDIT. +// schema: {{ .package_schema.Name }}:{{ .package_schema.Tag }} + +function PackUint32(ptr: number, len: number): bigint { + if (ptr > 0xffffffff || len > 0xffffffff) { + throw new Error("ptr or len is too large"); + } + return (BigInt(ptr) << BigInt(32)) | BigInt(len); +} + +class TextEncoder { + public encoding = "utf-8"; + constructor() {} + + public encode(s: string): Uint8Array { + let octets = []; + const length = s.length; + let i = 0; + while (i < length) { + const codePoint = s.codePointAt(i); + if (typeof codePoint !== "undefined") { + let c = 0; + let bits = 0; + if (codePoint <= 0x0000007F) { + c = 0; + bits = 0x00; + } else if (codePoint <= 0x000007FF) { + c = 6; + bits = 0xC0; + } else if (codePoint <= 0x0000FFFF) { + c = 12; + bits = 0xE0; + } else if (codePoint <= 0x001FFFFF) { + c = 18; + bits = 0xF0; + } + octets.push(bits | (codePoint >> c)); + c -= 6; + while (c >= 0) { + octets.push(0x80 | ((codePoint >> c) & 0x3F)); + c -= 6; + } + i += codePoint >= 0x10000 ? 2 : 1; + } + } + return new Uint8Array(octets); + } +} + +class TextDecoder { + public encoding = "utf-8"; + + constructor() {} + + public decode(a: any): string { + if (a instanceof Uint8Array) { + return this.decodeUint8Array(a); + } else { + return ""; + } + } + + private decodeUint8Array(a: Uint8Array): string { + let string = ""; + let i = 0; + while (i < a.length) { + let octet = a[i]; + let bytesNeeded = 0; + let codePoint = 0; + if (octet <= 0x7F) { + bytesNeeded = 0; + codePoint = octet & 0xFF; + } else if (octet <= 0xDF) { + bytesNeeded = 1; + codePoint = octet & 0x1F; + } else if (octet <= 0xEF) { + bytesNeeded = 2; + codePoint = octet & 0x0F; + } else if (octet <= 0xF4) { + bytesNeeded = 3; + codePoint = octet & 0x07; + } + if (a.length - i - bytesNeeded > 0) { + let k = 0; + while (k < bytesNeeded) { + octet = a[i + k + 1]; + codePoint = (codePoint << 6) | (octet & 0x3F); + k += 1; + } + } else { + codePoint = 0xFFFD; + bytesNeeded = a.length - i; + } + string += String.fromCodePoint(codePoint); + i += bytesNeeded + 1; + } + return string; + } +} + +(global as any).TextEncoder = TextEncoder; +(global as any).TextDecoder = TextDecoder; + +import * as signature from "signature"; +import * as scale from "{{ .function_path }}"; + +// Satisfy the compiler by exporting a +// main function that does nothing. +function mainFunction() {} + +function initializeFunction(): bigint { + {{ if .package_schema.Initialize }} + try { + scale.{{ .package_schema.Initialize }}(); + } catch (e) { + const [ptr, len] = signature.Error(e as Error); + return PackUint32(ptr, len); + } + {{ end }} + return BigInt(0); +} + +function runFunction(): bigint { + let ctx = signature.Read(); + try { + ctx = scale.{{ .package_schema.Function }}(ctx); + const [ptr, len] = signature.Write(ctx); + return PackUint32(ptr, len); + } catch (e) { + const [ptr, len] = signature.Error(e as Error); + return PackUint32(ptr, len); + } +} + +function resizeFunction(size: number): number { + return signature.Resize(size); +} + +function hashFunction(): bigint { + const [ptr, len] = signature.Hash(); + return PackUint32(ptr, len); +} + +(global as any).exports = { + main: mainFunction, + initialize: initializeFunction, + run: runFunction, + hash: hashFunction, + resize: resizeFunction +} + diff --git a/compile/typescript/templates/packagejson.ts.templ b/compile/typescript/templates/packagejson.ts.templ new file mode 100644 index 00000000..cff97d1a --- /dev/null +++ b/compile/typescript/templates/packagejson.ts.templ @@ -0,0 +1,14 @@ +{ + "name": "compile", + "version": "0.1.0", + "description": "{{ .package_schema.Description }}", + "main": "index.ts", + "dependencies": { + {{ if .signature_path }} + "signature": "file:{{ .signature_path}}" + {{ end }} + {{ if .signature_import }} + "signature": "{{ .signature_import }}" + {{ end }} + } +} \ No newline at end of file diff --git a/rust/compile/templates/templates.go b/compile/typescript/templates/templates.go similarity index 95% rename from rust/compile/templates/templates.go rename to compile/typescript/templates/templates.go index fa88068b..26e3545f 100644 --- a/rust/compile/templates/templates.go +++ b/compile/typescript/templates/templates.go @@ -1,5 +1,5 @@ /* - Copyright 2022 Loophole Labs + Copyright 2023 Loophole Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/config.go b/config.go new file mode 100644 index 00000000..3372ba8b --- /dev/null +++ b/config.go @@ -0,0 +1,136 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + "errors" + "io" + "regexp" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" + "github.com/loopholelabs/scale/scalefunc" +) + +var ( + ErrNoConfig = errors.New("no config provided") + ErrNoFunctions = errors.New("no functions provided") + ErrInvalidFunction = errors.New("invalid function") + ErrInvalidEnv = errors.New("invalid environment variable") +) + +var ( + envStringRegex = regexp.MustCompile(`[^A-Za-z0-9_]`) +) + +type configFunction struct { + function *scalefunc.Schema + env map[string]string +} + +// Config is the configuration for a Scale Runtime +type Config[T interfaces.Signature] struct { + newSignature interfaces.New[T] + functions []configFunction + context context.Context + stdout io.Writer + stderr io.Writer + rawOutput bool +} + +// NewConfig returns a new Scale Runtime Config +func NewConfig[T interfaces.Signature](newSignature interfaces.New[T]) *Config[T] { + return &Config[T]{ + newSignature: newSignature, + } +} + +func (c *Config[T]) validate() error { + if c == nil { + return ErrNoConfig + } + if len(c.functions) == 0 { + return ErrNoFunctions + } + + if c.context == nil { + c.context = context.Background() + } + + for _, f := range c.functions { + if f.function == nil { + return ErrInvalidFunction + } + for k := range f.env { + if !validEnv(k) { + return ErrInvalidEnv + } + } + } + + return nil +} + +func (c *Config[T]) WithSignature(newSignature interfaces.New[T]) *Config[T] { + c.newSignature = newSignature + return c +} + +func (c *Config[T]) WithFunction(function *scalefunc.Schema, env ...map[string]string) *Config[T] { + f := configFunction{ + function: function, + } + + if len(env) > 0 { + f.env = env[0] + } + + c.functions = append(c.functions, f) + return c +} + +func (c *Config[T]) WithFunctions(function []*scalefunc.Schema, env ...map[string]string) *Config[T] { + for _, f := range function { + c.WithFunction(f, env...) + } + return c +} + +func (c *Config[T]) WithContext(ctx context.Context) *Config[T] { + c.context = ctx + return c +} + +func (c *Config[T]) WithStdout(w io.Writer) *Config[T] { + c.stdout = w + return c +} + +func (c *Config[T]) WithStderr(w io.Writer) *Config[T] { + c.stderr = w + return c +} + +func (c *Config[T]) WithRawOutput(rawOutput bool) *Config[T] { + c.rawOutput = rawOutput + return c +} + +// validEnv returns true if the string is valid for use as an environment variable +func validEnv(str string) bool { + return !envStringRegex.MatchString(str) +} diff --git a/config.rs b/config.rs new file mode 100644 index 00000000..39b65fbd --- /dev/null +++ b/config.rs @@ -0,0 +1,36 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use lazy_static::lazy_static; +use regex::Regex; +use scale_signature_interfaces::New; +use std::collections::HashMap; + +lazy_static! { + static ref ENV_STRING_REGEX: Regex = Regex::new(r"[^A-Za-z0-9_]").unwrap(); +} + +#[derive(Debug)] +struct ConfigFunction { + // function: Option, + env: HashMap, +} + +#[derive(Debug)] +pub struct Config { + new_signature: New, + functions: Vec, +} diff --git a/config.ts b/config.ts new file mode 100644 index 00000000..c6872113 --- /dev/null +++ b/config.ts @@ -0,0 +1,109 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Signature, New } from "@loopholelabs/scale-signature-interfaces"; +import { ScaleFunc } from "./scalefunc/scalefunc"; + +const envStringRegex = /[^A-Za-z0-9_]/; + +export interface Writer { + (message: string): void; +} + +class ConfigFunction { + function: ScaleFunc; + env: { [key: string]: string } | undefined; + constructor(fn: ScaleFunc, env?: { [key: string]: string }) { + this.function = fn; + this.env = env; + } +} + +export class Config { + public newSignature: New; + public functions: ConfigFunction[] = []; + stdout: Writer | undefined; + stderr: Writer | undefined; + rawOutput: boolean = false; + + constructor(newSignature: New) { + this.newSignature = newSignature; + } + + public validate() { + if (!this) { + throw new Error("no config provided"); + } + if (this.functions.length === 0) { + throw new Error("no functions provided"); + } + + for (const f of this.functions) { + if (!f.function) { + throw new Error("invalid function"); + } + for (const k in f.env) { + if (!validEnv(k)) { + throw new Error("invalid environment variable"); + } + } + } + } + + public WithSignature(newSignature: New): Config { + this.newSignature = newSignature; + return this; + } + + public WithFunction(func: ScaleFunc, env?: { [key: string]: string }): Config { + const f = new ConfigFunction(func, env); + f.function = func; + + if (env) { + f.env = env; + } + + this.functions.push(f); + return this; + } + + public WithFunctions(functions: ScaleFunc[], env?: { [key: string]: string }): Config { + for (const func of functions) { + this.WithFunction(func, env); + } + return this; + } + + public WithStdout(writer: Writer): Config { + this.stdout = writer + return this; + } + + public WithStderr(writer: Writer): Config { + this.stderr = writer + return this; + } + + public WithRawOutput(rawOutput: boolean): Config { + this.rawOutput = rawOutput + return this; + } +} + +// Helper function +function validEnv(str: string): boolean { + return !envStringRegex.test(str); +} \ No newline at end of file diff --git a/docs/getting-started/quick-start.mdx b/docs/getting-started/quick-start.mdx index f299a708..ef546594 100644 --- a/docs/getting-started/quick-start.mdx +++ b/docs/getting-started/quick-start.mdx @@ -223,10 +223,10 @@ scale run hello-world:latest ``` This will start a local HTTP server on port `8080` and will run the function whenever you make a request to it. You can -also specify a different port by passing the `--port` or `-p` flag: +also specify a different port by passing the `--listen` or `-l` flag: ```bash -scale run hello-world:latest -p 3000 +scale run hello-world:latest -l :3000 ``` @@ -336,4 +336,4 @@ You can also check out our [Adapter Guides](/languages/golang/adapters/net-http) with popular frameworks such as [Next.js](/languages/javascript-typescript/adapters/nextjs). To learn more about how the Scale Registry works, you can check out the [Registry](/registry/overview) section, or you -can check out the [Signatures](/signatures/overview) section to learn more about how Scale Signatures work. \ No newline at end of file +can check out the [Signatures](/signatures/overview) section to learn more about how Scale Signatures work. diff --git a/function.go b/function.go new file mode 100644 index 00000000..07b8e665 --- /dev/null +++ b/function.go @@ -0,0 +1,84 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + "fmt" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" +) + +// function is an instantiated function that can run a module +type function[T interfaces.Signature] struct { + // instance is the instance that this function belongs to + instance *Instance[T] + + // template is the template that the function + // was created from + template *template[T] + + // next is the next function in the chain + next *function[T] + + // module is the optional, stateful, instantiated module for this function + // + // If the function is stateless, then this will be nil + module *module[T] +} + +// newFunction creates a new function from an Instance and a template +func newFunction[T interfaces.Signature](ctx context.Context, instance *Instance[T], template *template[T]) (fn *function[T], err error) { + fn = &function[T]{ + instance: instance, + template: template, + } + + if template.modulePool == nil { + fn.module, err = newModule[T](ctx, fn.template) + if err != nil { + return nil, fmt.Errorf("failed to create module for function '%s': %w", fn.template.identifier, err) + } + fn.module.register(fn) + } + + return fn, nil +} + +func (f *function[T]) getModule(signature T) (*module[T], error) { + if f.module != nil { + f.module.setSignature(signature) + return f.module, nil + } + if f.template.modulePool == nil { + return nil, fmt.Errorf("cannot get module from pool for function %s: module pool is nil", f.template.identifier) + } + m, err := f.template.modulePool.Get() + if err != nil { + return nil, fmt.Errorf("failed to get module from pool for function %s: %w", f.template.identifier, err) + } + m.register(f) + m.setSignature(signature) + return m, nil +} + +func (f *function[T]) putModule(m *module[T]) { + if f.template.modulePool != nil { + m.cleanup() + f.template.modulePool.Put(m) + } +} diff --git a/function.ts b/function.ts new file mode 100644 index 00000000..ca5c7c0e --- /dev/null +++ b/function.ts @@ -0,0 +1,72 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Signature } from "@loopholelabs/scale-signature-interfaces"; +import {Module, NewModule} from "./module"; +import {Instance} from "./instance"; +import {Template} from "./template"; + +export class Func { + private readonly ready: Promise; + public instance: Instance; + private template: Template; + public next: Func | undefined; + public module: Module | undefined; + + constructor(instance: Instance, template: Template) { + this.instance = instance; + this.template = template; + + this.ready = new Promise(async (resolve) => { // eslint-disable-line no-async-promise-executor + if (typeof template.modulePool === "undefined") { + this.module = await NewModule(template); + this.module.Register(this); + } + resolve(); + }); + } + + public async Ready(): Promise { + await this.ready; + } + + public async GetModule(signature: T): Promise> { + if (typeof this.module !== "undefined") { + this.module.SetSignature(signature); + return this.module; + } + if (typeof this.template.modulePool === "undefined") { + throw new Error(`cannot get module from pool for function ${this.template.identifier}: module pool is undefined`); + } + const m = await this.template.modulePool.Get(); + m.Register(this); + m.SetSignature(signature); + return m; + } + + public PutModule(m: Module){ + if (typeof this.template.modulePool !== "undefined") { + m.Cleanup() + this.template.modulePool.Put(m); + } + } +} + +export async function NewFunc(instance: Instance, template: Template): Promise> { + const fn = new Func(instance, template); + await fn.Ready(); + return fn; +} \ No newline at end of file diff --git a/go.mod b/go.mod index 8367d489..919c6588 100644 --- a/go.mod +++ b/go.mod @@ -1,48 +1,33 @@ module github.com/loopholelabs/scale -go 1.18 +go 1.20 require ( - github.com/go-openapi/errors v0.20.3 - github.com/go-openapi/runtime v0.25.0 - github.com/go-openapi/strfmt v0.21.3 - github.com/go-openapi/swag v0.22.3 - github.com/google/uuid v1.3.0 - github.com/loopholelabs/auth v0.2.26 - github.com/loopholelabs/polyglot-go v0.5.1 - github.com/loopholelabs/scale-signature v0.2.11 - github.com/loopholelabs/scale-signature-http v0.3.8 - github.com/loopholelabs/scalefile v0.1.9 - github.com/stretchr/testify v1.8.1 - github.com/tetratelabs/wazero v1.0.1 + github.com/BurntSushi/toml v1.3.2 + github.com/evanw/esbuild v0.19.3 + github.com/google/uuid v1.3.1 + github.com/hashicorp/hcl/v2 v2.18.0 + github.com/loopholelabs/polyglot v1.1.3 + github.com/loopholelabs/scale-signature-interfaces v0.1.7 + github.com/stretchr/testify v1.8.4 + github.com/tetratelabs/wazero v1.5.0 + golang.org/x/mod v0.12.0 + golang.org/x/text v0.13.0 ) require ( - github.com/PuerkitoBio/purell v1.1.1 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.2.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/analysis v0.21.2 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.19.6 // indirect - github.com/go-openapi/loads v0.21.1 // indirect - github.com/go-openapi/spec v0.20.4 // indirect - github.com/go-openapi/validate v0.21.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/oklog/ulid v1.3.1 // indirect - github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/yalue/merged_fs v1.2.2 // indirect - go.mongodb.org/mongo-driver v1.10.0 // indirect - go.opentelemetry.io/otel v1.11.1 // indirect - go.opentelemetry.io/otel/trace v1.11.1 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/text v0.7.0 // indirect - google.golang.org/protobuf v1.28.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 529e4756..5924c588 100644 --- a/go.sum +++ b/go.sum @@ -1,227 +1,66 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/analysis v0.21.2 h1:hXFrOYFHUAMQdu6zwAiKKJHJQ8kqZs1ux/ru1P1wLJU= -github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= -github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= -github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= -github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= -github.com/go-openapi/loads v0.21.1 h1:Wb3nVZpdEzDTcly8S4HMkey6fjARRzb7iEaySimlDW0= -github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= -github.com/go-openapi/runtime v0.25.0 h1:7yQTCdRbWhX8vnIjdzU8S00tBYf7Sg71EBeorlPHvhc= -github.com/go-openapi/runtime v0.25.0/go.mod h1:Ux6fikcHXyyob6LNWxtE96hWwjBPYF0DXgVFuMTneOs= -github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= -github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= -github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= -github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= -github.com/go-openapi/strfmt v0.21.3 h1:xwhj5X6CjXEZZHMWy1zKJxvW9AfHC9pkyUjLvHtKG7o= -github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/validate v0.21.0 h1:+Wqk39yKOhfpLqNLEC0/eViCkzM5FVXVqrvt526+wcI= -github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/evanw/esbuild v0.19.3 h1:foPr0xwQM3lBWKBtscauTN9FrmJzRDVI2+EGOs82H/I= +github.com/evanw/esbuild v0.19.3/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8= +github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/loopholelabs/auth v0.2.26 h1:aTYp6ekGZuynkie91ppAkfMzv75xnlKd8Wqa/39Mib8= -github.com/loopholelabs/auth v0.2.26/go.mod h1:8jY3kru3zYytaH6gmtt6i0qQO1BGfLrZlem1RlR1ENs= -github.com/loopholelabs/polyglot-go v0.5.1 h1:21QVDELp+EodPUAL+Aw8GNXLyt2BFj9gYQsGvHIFlcc= -github.com/loopholelabs/polyglot-go v0.5.1/go.mod h1:Z0QiNv4KRuWjQWpUerMhmkvRh6ks1pYmEH4SGpG0EHQ= -github.com/loopholelabs/scale-signature v0.2.11 h1:Wnur2owfIsuOFDzJTiwRd8rCJRBOzWRYK29ORr6XVYo= -github.com/loopholelabs/scale-signature v0.2.11/go.mod h1:5qakYb6WN1hbmubB/UuBT9XsMi9b1vEHSSlsyvBF4vQ= -github.com/loopholelabs/scale-signature-http v0.3.8 h1:2McyHf/yngxBQZvQZ0NTDvAwL8HhMFa9NjnH7xQp1Co= -github.com/loopholelabs/scale-signature-http v0.3.8/go.mod h1:WoMckzVJEV9akY8vegZBJl7BmqjtVmtxanJHElqOGxI= -github.com/loopholelabs/scalefile v0.1.9 h1:YXVJPI9OKQVnNj+al48yHl/3P8IUOOt9Vq9Aixu0iRI= -github.com/loopholelabs/scalefile v0.1.9/go.mod h1:fPq4xcXpAzWErW1tqLTex2xIrHJ/iCRFb4et6+sbOvk= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/loopholelabs/polyglot v1.1.3 h1:WUTcSZ2TQ1lv7CZ4I9nHFBUjf0hKJN+Yfz1rZZJuTP0= +github.com/loopholelabs/polyglot v1.1.3/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= +github.com/loopholelabs/scale-signature-interfaces v0.1.7 h1:aOJJZpCKn/Q5Q0Gj+/Q6c7/iABEbojjbCzIqw7Mxyi0= +github.com/loopholelabs/scale-signature-interfaces v0.1.7/go.mod h1:3XLMjJjBf5lYxMtNKk+2XAWye4UyrkvUBJ9L6x2QCAk= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tetratelabs/wazero v1.0.1 h1:xyWBoGyMjYekG3mEQ/W7xm9E05S89kJ/at696d/9yuc= -github.com/tetratelabs/wazero v1.0.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/yalue/merged_fs v1.2.2 h1:vXHTpJBluJryju7BBpytr3PDIkzsPMpiEknxVGPhN/I= -github.com/yalue/merged_fs v1.2.2/go.mod h1:WqqchfVYQyclV2tnR7wtRhBddzBvLVR83Cjw9BKQw0M= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= -go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= -go.mongodb.org/mongo-driver v1.10.0 h1:UtV6N5k14upNp4LTduX0QCufG124fSu25Wz9tu94GLg= -go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4= -go.opentelemetry.io/otel v1.11.1/go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE= -go.opentelemetry.io/otel/sdk v1.11.1 h1:F7KmQgoHljhUuJyA+9BiU+EkJfyX5nVVF4wyzWZpKxs= -go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ= -go.opentelemetry.io/otel/trace v1.11.1/go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0= +github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= +github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= +github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901 h1:0wxTF6pSjIIhNt7mo9GvjDfzyCOiWhmICgtO/Ah948s= +golang.org/x/tools v0.8.1-0.20230428195545-5283a0178901/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/client/access/access_client.go b/go/client/access/access_client.go deleted file mode 100644 index 0163f663..00000000 --- a/go/client/access/access_client.go +++ /dev/null @@ -1,199 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// New creates a new access API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for access API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - DeleteAccessApikeyNameorid(params *DeleteAccessApikeyNameoridParams, opts ...ClientOption) (*DeleteAccessApikeyNameoridOK, error) - - GetAccessApikey(params *GetAccessApikeyParams, opts ...ClientOption) (*GetAccessApikeyOK, error) - - GetAccessApikeyNameorid(params *GetAccessApikeyNameoridParams, opts ...ClientOption) (*GetAccessApikeyNameoridOK, error) - - PostAccessApikey(params *PostAccessApikeyParams, opts ...ClientOption) (*PostAccessApikeyOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -DeleteAccessApikeyNameorid Deletes an API Key given its `name` or `id`. If the user's session is tied to an organization, the API Key must be for that organization. -*/ -func (a *Client) DeleteAccessApikeyNameorid(params *DeleteAccessApikeyNameoridParams, opts ...ClientOption) (*DeleteAccessApikeyNameoridOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewDeleteAccessApikeyNameoridParams() - } - op := &runtime.ClientOperation{ - ID: "DeleteAccessApikeyNameorid", - Method: "DELETE", - PathPattern: "/access/apikey/{nameorid}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &DeleteAccessApikeyNameoridReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*DeleteAccessApikeyNameoridOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for DeleteAccessApikeyNameorid: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetAccessApikey Lists all the API Keys for the authenticated user. If the user's session is tied to an organization, only the API Keys for that organization will be returned. -*/ -func (a *Client) GetAccessApikey(params *GetAccessApikeyParams, opts ...ClientOption) (*GetAccessApikeyOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetAccessApikeyParams() - } - op := &runtime.ClientOperation{ - ID: "GetAccessApikey", - Method: "GET", - PathPattern: "/access/apikey", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetAccessApikeyReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetAccessApikeyOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetAccessApikey: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetAccessApikeyNameorid Gets information about a specific API Key given its `name` or `id`. If the user's session is tied to an organization, the API Key must be for that organization. -*/ -func (a *Client) GetAccessApikeyNameorid(params *GetAccessApikeyNameoridParams, opts ...ClientOption) (*GetAccessApikeyNameoridOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetAccessApikeyNameoridParams() - } - op := &runtime.ClientOperation{ - ID: "GetAccessApikeyNameorid", - Method: "GET", - PathPattern: "/access/apikey/{nameorid}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetAccessApikeyNameoridReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetAccessApikeyNameoridOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetAccessApikeyNameorid: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -PostAccessApikey Creates a new API Key with the given `name` scoped to all the organizations the user is a member or owner of. If the user's session is already tied to an organization, the new API Key will be scoped to that organization. -*/ -func (a *Client) PostAccessApikey(params *PostAccessApikeyParams, opts ...ClientOption) (*PostAccessApikeyOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewPostAccessApikeyParams() - } - op := &runtime.ClientOperation{ - ID: "PostAccessApikey", - Method: "POST", - PathPattern: "/access/apikey", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &PostAccessApikeyReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*PostAccessApikeyOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for PostAccessApikey: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/go/client/access/delete_access_apikey_id_parameters.go b/go/client/access/delete_access_apikey_id_parameters.go deleted file mode 100644 index e6f605c0..00000000 --- a/go/client/access/delete_access_apikey_id_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewDeleteAccessApikeyIDParams creates a new DeleteAccessApikeyIDParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewDeleteAccessApikeyIDParams() *DeleteAccessApikeyIDParams { - return &DeleteAccessApikeyIDParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewDeleteAccessApikeyIDParamsWithTimeout creates a new DeleteAccessApikeyIDParams object -// with the ability to set a timeout on a request. -func NewDeleteAccessApikeyIDParamsWithTimeout(timeout time.Duration) *DeleteAccessApikeyIDParams { - return &DeleteAccessApikeyIDParams{ - timeout: timeout, - } -} - -// NewDeleteAccessApikeyIDParamsWithContext creates a new DeleteAccessApikeyIDParams object -// with the ability to set a context for a request. -func NewDeleteAccessApikeyIDParamsWithContext(ctx context.Context) *DeleteAccessApikeyIDParams { - return &DeleteAccessApikeyIDParams{ - Context: ctx, - } -} - -// NewDeleteAccessApikeyIDParamsWithHTTPClient creates a new DeleteAccessApikeyIDParams object -// with the ability to set a custom HTTPClient for a request. -func NewDeleteAccessApikeyIDParamsWithHTTPClient(client *http.Client) *DeleteAccessApikeyIDParams { - return &DeleteAccessApikeyIDParams{ - HTTPClient: client, - } -} - -/* -DeleteAccessApikeyIDParams contains all the parameters to send to the API endpoint - - for the delete access apikey ID operation. - - Typically these are written to a http.Request. -*/ -type DeleteAccessApikeyIDParams struct { - - /* ID. - - API Key ID - */ - ID string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the delete access apikey ID params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteAccessApikeyIDParams) WithDefaults() *DeleteAccessApikeyIDParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the delete access apikey ID params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteAccessApikeyIDParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) WithTimeout(timeout time.Duration) *DeleteAccessApikeyIDParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) WithContext(ctx context.Context) *DeleteAccessApikeyIDParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) WithHTTPClient(client *http.Client) *DeleteAccessApikeyIDParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithID adds the id to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) WithID(id string) *DeleteAccessApikeyIDParams { - o.SetID(id) - return o -} - -// SetID adds the id to the delete access apikey ID params -func (o *DeleteAccessApikeyIDParams) SetID(id string) { - o.ID = id -} - -// WriteToRequest writes these params to a swagger request -func (o *DeleteAccessApikeyIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param id - if err := r.SetPathParam("id", o.ID); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/delete_access_apikey_id_responses.go b/go/client/access/delete_access_apikey_id_responses.go deleted file mode 100644 index 12239d98..00000000 --- a/go/client/access/delete_access_apikey_id_responses.go +++ /dev/null @@ -1,315 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// DeleteAccessApikeyIDReader is a Reader for the DeleteAccessApikeyID structure. -type DeleteAccessApikeyIDReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *DeleteAccessApikeyIDReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewDeleteAccessApikeyIDOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewDeleteAccessApikeyIDUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewDeleteAccessApikeyIDNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewDeleteAccessApikeyIDInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewDeleteAccessApikeyIDOK creates a DeleteAccessApikeyIDOK with default headers values -func NewDeleteAccessApikeyIDOK() *DeleteAccessApikeyIDOK { - return &DeleteAccessApikeyIDOK{} -} - -/* -DeleteAccessApikeyIDOK describes a response with status code 200, with default header values. - -OK -*/ -type DeleteAccessApikeyIDOK struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey Id o k response has a 2xx status code -func (o *DeleteAccessApikeyIDOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this delete access apikey Id o k response has a 3xx status code -func (o *DeleteAccessApikeyIDOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey Id o k response has a 4xx status code -func (o *DeleteAccessApikeyIDOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete access apikey Id o k response has a 5xx status code -func (o *DeleteAccessApikeyIDOK) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey Id o k response a status code equal to that given -func (o *DeleteAccessApikeyIDOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the delete access apikey Id o k response -func (o *DeleteAccessApikeyIDOK) Code() int { - return 200 -} - -func (o *DeleteAccessApikeyIDOK) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdOK %+v", 200, o.Payload) -} - -func (o *DeleteAccessApikeyIDOK) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdOK %+v", 200, o.Payload) -} - -func (o *DeleteAccessApikeyIDOK) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyIDOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyIDUnauthorized creates a DeleteAccessApikeyIDUnauthorized with default headers values -func NewDeleteAccessApikeyIDUnauthorized() *DeleteAccessApikeyIDUnauthorized { - return &DeleteAccessApikeyIDUnauthorized{} -} - -/* -DeleteAccessApikeyIDUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type DeleteAccessApikeyIDUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey Id unauthorized response has a 2xx status code -func (o *DeleteAccessApikeyIDUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey Id unauthorized response has a 3xx status code -func (o *DeleteAccessApikeyIDUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey Id unauthorized response has a 4xx status code -func (o *DeleteAccessApikeyIDUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete access apikey Id unauthorized response has a 5xx status code -func (o *DeleteAccessApikeyIDUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey Id unauthorized response a status code equal to that given -func (o *DeleteAccessApikeyIDUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the delete access apikey Id unauthorized response -func (o *DeleteAccessApikeyIDUnauthorized) Code() int { - return 401 -} - -func (o *DeleteAccessApikeyIDUnauthorized) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteAccessApikeyIDUnauthorized) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteAccessApikeyIDUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyIDUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyIDNotFound creates a DeleteAccessApikeyIDNotFound with default headers values -func NewDeleteAccessApikeyIDNotFound() *DeleteAccessApikeyIDNotFound { - return &DeleteAccessApikeyIDNotFound{} -} - -/* -DeleteAccessApikeyIDNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type DeleteAccessApikeyIDNotFound struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey Id not found response has a 2xx status code -func (o *DeleteAccessApikeyIDNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey Id not found response has a 3xx status code -func (o *DeleteAccessApikeyIDNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey Id not found response has a 4xx status code -func (o *DeleteAccessApikeyIDNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete access apikey Id not found response has a 5xx status code -func (o *DeleteAccessApikeyIDNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey Id not found response a status code equal to that given -func (o *DeleteAccessApikeyIDNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the delete access apikey Id not found response -func (o *DeleteAccessApikeyIDNotFound) Code() int { - return 404 -} - -func (o *DeleteAccessApikeyIDNotFound) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdNotFound %+v", 404, o.Payload) -} - -func (o *DeleteAccessApikeyIDNotFound) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdNotFound %+v", 404, o.Payload) -} - -func (o *DeleteAccessApikeyIDNotFound) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyIDNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyIDInternalServerError creates a DeleteAccessApikeyIDInternalServerError with default headers values -func NewDeleteAccessApikeyIDInternalServerError() *DeleteAccessApikeyIDInternalServerError { - return &DeleteAccessApikeyIDInternalServerError{} -} - -/* -DeleteAccessApikeyIDInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type DeleteAccessApikeyIDInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey Id internal server error response has a 2xx status code -func (o *DeleteAccessApikeyIDInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey Id internal server error response has a 3xx status code -func (o *DeleteAccessApikeyIDInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey Id internal server error response has a 4xx status code -func (o *DeleteAccessApikeyIDInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete access apikey Id internal server error response has a 5xx status code -func (o *DeleteAccessApikeyIDInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this delete access apikey Id internal server error response a status code equal to that given -func (o *DeleteAccessApikeyIDInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the delete access apikey Id internal server error response -func (o *DeleteAccessApikeyIDInternalServerError) Code() int { - return 500 -} - -func (o *DeleteAccessApikeyIDInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteAccessApikeyIDInternalServerError) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{id}][%d] deleteAccessApikeyIdInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteAccessApikeyIDInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyIDInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/delete_access_apikey_nameorid_parameters.go b/go/client/access/delete_access_apikey_nameorid_parameters.go deleted file mode 100644 index ac6718d3..00000000 --- a/go/client/access/delete_access_apikey_nameorid_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewDeleteAccessApikeyNameoridParams creates a new DeleteAccessApikeyNameoridParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewDeleteAccessApikeyNameoridParams() *DeleteAccessApikeyNameoridParams { - return &DeleteAccessApikeyNameoridParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewDeleteAccessApikeyNameoridParamsWithTimeout creates a new DeleteAccessApikeyNameoridParams object -// with the ability to set a timeout on a request. -func NewDeleteAccessApikeyNameoridParamsWithTimeout(timeout time.Duration) *DeleteAccessApikeyNameoridParams { - return &DeleteAccessApikeyNameoridParams{ - timeout: timeout, - } -} - -// NewDeleteAccessApikeyNameoridParamsWithContext creates a new DeleteAccessApikeyNameoridParams object -// with the ability to set a context for a request. -func NewDeleteAccessApikeyNameoridParamsWithContext(ctx context.Context) *DeleteAccessApikeyNameoridParams { - return &DeleteAccessApikeyNameoridParams{ - Context: ctx, - } -} - -// NewDeleteAccessApikeyNameoridParamsWithHTTPClient creates a new DeleteAccessApikeyNameoridParams object -// with the ability to set a custom HTTPClient for a request. -func NewDeleteAccessApikeyNameoridParamsWithHTTPClient(client *http.Client) *DeleteAccessApikeyNameoridParams { - return &DeleteAccessApikeyNameoridParams{ - HTTPClient: client, - } -} - -/* -DeleteAccessApikeyNameoridParams contains all the parameters to send to the API endpoint - - for the delete access apikey nameorid operation. - - Typically these are written to a http.Request. -*/ -type DeleteAccessApikeyNameoridParams struct { - - /* Nameorid. - - API Key Name or ID - */ - Nameorid string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the delete access apikey nameorid params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteAccessApikeyNameoridParams) WithDefaults() *DeleteAccessApikeyNameoridParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the delete access apikey nameorid params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteAccessApikeyNameoridParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) WithTimeout(timeout time.Duration) *DeleteAccessApikeyNameoridParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) WithContext(ctx context.Context) *DeleteAccessApikeyNameoridParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) WithHTTPClient(client *http.Client) *DeleteAccessApikeyNameoridParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithNameorid adds the nameorid to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) WithNameorid(nameorid string) *DeleteAccessApikeyNameoridParams { - o.SetNameorid(nameorid) - return o -} - -// SetNameorid adds the nameorid to the delete access apikey nameorid params -func (o *DeleteAccessApikeyNameoridParams) SetNameorid(nameorid string) { - o.Nameorid = nameorid -} - -// WriteToRequest writes these params to a swagger request -func (o *DeleteAccessApikeyNameoridParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param nameorid - if err := r.SetPathParam("nameorid", o.Nameorid); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/delete_access_apikey_nameorid_responses.go b/go/client/access/delete_access_apikey_nameorid_responses.go deleted file mode 100644 index 2bece47d..00000000 --- a/go/client/access/delete_access_apikey_nameorid_responses.go +++ /dev/null @@ -1,315 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// DeleteAccessApikeyNameoridReader is a Reader for the DeleteAccessApikeyNameorid structure. -type DeleteAccessApikeyNameoridReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *DeleteAccessApikeyNameoridReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewDeleteAccessApikeyNameoridOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewDeleteAccessApikeyNameoridUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewDeleteAccessApikeyNameoridNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewDeleteAccessApikeyNameoridInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewDeleteAccessApikeyNameoridOK creates a DeleteAccessApikeyNameoridOK with default headers values -func NewDeleteAccessApikeyNameoridOK() *DeleteAccessApikeyNameoridOK { - return &DeleteAccessApikeyNameoridOK{} -} - -/* -DeleteAccessApikeyNameoridOK describes a response with status code 200, with default header values. - -OK -*/ -type DeleteAccessApikeyNameoridOK struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey nameorid o k response has a 2xx status code -func (o *DeleteAccessApikeyNameoridOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this delete access apikey nameorid o k response has a 3xx status code -func (o *DeleteAccessApikeyNameoridOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey nameorid o k response has a 4xx status code -func (o *DeleteAccessApikeyNameoridOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete access apikey nameorid o k response has a 5xx status code -func (o *DeleteAccessApikeyNameoridOK) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey nameorid o k response a status code equal to that given -func (o *DeleteAccessApikeyNameoridOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the delete access apikey nameorid o k response -func (o *DeleteAccessApikeyNameoridOK) Code() int { - return 200 -} - -func (o *DeleteAccessApikeyNameoridOK) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridOK %+v", 200, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridOK) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridOK %+v", 200, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridOK) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyNameoridOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyNameoridUnauthorized creates a DeleteAccessApikeyNameoridUnauthorized with default headers values -func NewDeleteAccessApikeyNameoridUnauthorized() *DeleteAccessApikeyNameoridUnauthorized { - return &DeleteAccessApikeyNameoridUnauthorized{} -} - -/* -DeleteAccessApikeyNameoridUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type DeleteAccessApikeyNameoridUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey nameorid unauthorized response has a 2xx status code -func (o *DeleteAccessApikeyNameoridUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey nameorid unauthorized response has a 3xx status code -func (o *DeleteAccessApikeyNameoridUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey nameorid unauthorized response has a 4xx status code -func (o *DeleteAccessApikeyNameoridUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete access apikey nameorid unauthorized response has a 5xx status code -func (o *DeleteAccessApikeyNameoridUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey nameorid unauthorized response a status code equal to that given -func (o *DeleteAccessApikeyNameoridUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the delete access apikey nameorid unauthorized response -func (o *DeleteAccessApikeyNameoridUnauthorized) Code() int { - return 401 -} - -func (o *DeleteAccessApikeyNameoridUnauthorized) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridUnauthorized) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyNameoridUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyNameoridNotFound creates a DeleteAccessApikeyNameoridNotFound with default headers values -func NewDeleteAccessApikeyNameoridNotFound() *DeleteAccessApikeyNameoridNotFound { - return &DeleteAccessApikeyNameoridNotFound{} -} - -/* -DeleteAccessApikeyNameoridNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type DeleteAccessApikeyNameoridNotFound struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey nameorid not found response has a 2xx status code -func (o *DeleteAccessApikeyNameoridNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey nameorid not found response has a 3xx status code -func (o *DeleteAccessApikeyNameoridNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey nameorid not found response has a 4xx status code -func (o *DeleteAccessApikeyNameoridNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete access apikey nameorid not found response has a 5xx status code -func (o *DeleteAccessApikeyNameoridNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this delete access apikey nameorid not found response a status code equal to that given -func (o *DeleteAccessApikeyNameoridNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the delete access apikey nameorid not found response -func (o *DeleteAccessApikeyNameoridNotFound) Code() int { - return 404 -} - -func (o *DeleteAccessApikeyNameoridNotFound) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridNotFound %+v", 404, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridNotFound) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridNotFound %+v", 404, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridNotFound) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyNameoridNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteAccessApikeyNameoridInternalServerError creates a DeleteAccessApikeyNameoridInternalServerError with default headers values -func NewDeleteAccessApikeyNameoridInternalServerError() *DeleteAccessApikeyNameoridInternalServerError { - return &DeleteAccessApikeyNameoridInternalServerError{} -} - -/* -DeleteAccessApikeyNameoridInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type DeleteAccessApikeyNameoridInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this delete access apikey nameorid internal server error response has a 2xx status code -func (o *DeleteAccessApikeyNameoridInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete access apikey nameorid internal server error response has a 3xx status code -func (o *DeleteAccessApikeyNameoridInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete access apikey nameorid internal server error response has a 4xx status code -func (o *DeleteAccessApikeyNameoridInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete access apikey nameorid internal server error response has a 5xx status code -func (o *DeleteAccessApikeyNameoridInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this delete access apikey nameorid internal server error response a status code equal to that given -func (o *DeleteAccessApikeyNameoridInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the delete access apikey nameorid internal server error response -func (o *DeleteAccessApikeyNameoridInternalServerError) Code() int { - return 500 -} - -func (o *DeleteAccessApikeyNameoridInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridInternalServerError) String() string { - return fmt.Sprintf("[DELETE /access/apikey/{nameorid}][%d] deleteAccessApikeyNameoridInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteAccessApikeyNameoridInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *DeleteAccessApikeyNameoridInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/get_access_apikey_name_parameters.go b/go/client/access/get_access_apikey_name_parameters.go deleted file mode 100644 index fb764ed4..00000000 --- a/go/client/access/get_access_apikey_name_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetAccessApikeyNameParams creates a new GetAccessApikeyNameParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetAccessApikeyNameParams() *GetAccessApikeyNameParams { - return &GetAccessApikeyNameParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetAccessApikeyNameParamsWithTimeout creates a new GetAccessApikeyNameParams object -// with the ability to set a timeout on a request. -func NewGetAccessApikeyNameParamsWithTimeout(timeout time.Duration) *GetAccessApikeyNameParams { - return &GetAccessApikeyNameParams{ - timeout: timeout, - } -} - -// NewGetAccessApikeyNameParamsWithContext creates a new GetAccessApikeyNameParams object -// with the ability to set a context for a request. -func NewGetAccessApikeyNameParamsWithContext(ctx context.Context) *GetAccessApikeyNameParams { - return &GetAccessApikeyNameParams{ - Context: ctx, - } -} - -// NewGetAccessApikeyNameParamsWithHTTPClient creates a new GetAccessApikeyNameParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetAccessApikeyNameParamsWithHTTPClient(client *http.Client) *GetAccessApikeyNameParams { - return &GetAccessApikeyNameParams{ - HTTPClient: client, - } -} - -/* -GetAccessApikeyNameParams contains all the parameters to send to the API endpoint - - for the get access apikey name operation. - - Typically these are written to a http.Request. -*/ -type GetAccessApikeyNameParams struct { - - /* Name. - - API Key Name - */ - Name string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get access apikey name params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyNameParams) WithDefaults() *GetAccessApikeyNameParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get access apikey name params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyNameParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get access apikey name params -func (o *GetAccessApikeyNameParams) WithTimeout(timeout time.Duration) *GetAccessApikeyNameParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get access apikey name params -func (o *GetAccessApikeyNameParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get access apikey name params -func (o *GetAccessApikeyNameParams) WithContext(ctx context.Context) *GetAccessApikeyNameParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get access apikey name params -func (o *GetAccessApikeyNameParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get access apikey name params -func (o *GetAccessApikeyNameParams) WithHTTPClient(client *http.Client) *GetAccessApikeyNameParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get access apikey name params -func (o *GetAccessApikeyNameParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithName adds the name to the get access apikey name params -func (o *GetAccessApikeyNameParams) WithName(name string) *GetAccessApikeyNameParams { - o.SetName(name) - return o -} - -// SetName adds the name to the get access apikey name params -func (o *GetAccessApikeyNameParams) SetName(name string) { - o.Name = name -} - -// WriteToRequest writes these params to a swagger request -func (o *GetAccessApikeyNameParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param name - if err := r.SetPathParam("name", o.Name); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/get_access_apikey_name_responses.go b/go/client/access/get_access_apikey_name_responses.go deleted file mode 100644 index a06594df..00000000 --- a/go/client/access/get_access_apikey_name_responses.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetAccessApikeyNameReader is a Reader for the GetAccessApikeyName structure. -type GetAccessApikeyNameReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetAccessApikeyNameReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetAccessApikeyNameOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewGetAccessApikeyNameUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetAccessApikeyNameNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetAccessApikeyNameInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetAccessApikeyNameOK creates a GetAccessApikeyNameOK with default headers values -func NewGetAccessApikeyNameOK() *GetAccessApikeyNameOK { - return &GetAccessApikeyNameOK{} -} - -/* -GetAccessApikeyNameOK describes a response with status code 200, with default header values. - -OK -*/ -type GetAccessApikeyNameOK struct { - Payload *models.ModelsGetAPIKeyResponse -} - -// IsSuccess returns true when this get access apikey name o k response has a 2xx status code -func (o *GetAccessApikeyNameOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get access apikey name o k response has a 3xx status code -func (o *GetAccessApikeyNameOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey name o k response has a 4xx status code -func (o *GetAccessApikeyNameOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey name o k response has a 5xx status code -func (o *GetAccessApikeyNameOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey name o k response a status code equal to that given -func (o *GetAccessApikeyNameOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get access apikey name o k response -func (o *GetAccessApikeyNameOK) Code() int { - return 200 -} - -func (o *GetAccessApikeyNameOK) Error() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyNameOK) String() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyNameOK) GetPayload() *models.ModelsGetAPIKeyResponse { - return o.Payload -} - -func (o *GetAccessApikeyNameOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsGetAPIKeyResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameUnauthorized creates a GetAccessApikeyNameUnauthorized with default headers values -func NewGetAccessApikeyNameUnauthorized() *GetAccessApikeyNameUnauthorized { - return &GetAccessApikeyNameUnauthorized{} -} - -/* -GetAccessApikeyNameUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetAccessApikeyNameUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get access apikey name unauthorized response has a 2xx status code -func (o *GetAccessApikeyNameUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey name unauthorized response has a 3xx status code -func (o *GetAccessApikeyNameUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey name unauthorized response has a 4xx status code -func (o *GetAccessApikeyNameUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get access apikey name unauthorized response has a 5xx status code -func (o *GetAccessApikeyNameUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey name unauthorized response a status code equal to that given -func (o *GetAccessApikeyNameUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get access apikey name unauthorized response -func (o *GetAccessApikeyNameUnauthorized) Code() int { - return 401 -} - -func (o *GetAccessApikeyNameUnauthorized) Error() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyNameUnauthorized) String() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyNameUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameNotFound creates a GetAccessApikeyNameNotFound with default headers values -func NewGetAccessApikeyNameNotFound() *GetAccessApikeyNameNotFound { - return &GetAccessApikeyNameNotFound{} -} - -/* -GetAccessApikeyNameNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetAccessApikeyNameNotFound struct { - Payload string -} - -// IsSuccess returns true when this get access apikey name not found response has a 2xx status code -func (o *GetAccessApikeyNameNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey name not found response has a 3xx status code -func (o *GetAccessApikeyNameNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey name not found response has a 4xx status code -func (o *GetAccessApikeyNameNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get access apikey name not found response has a 5xx status code -func (o *GetAccessApikeyNameNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey name not found response a status code equal to that given -func (o *GetAccessApikeyNameNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get access apikey name not found response -func (o *GetAccessApikeyNameNotFound) Code() int { - return 404 -} - -func (o *GetAccessApikeyNameNotFound) Error() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameNotFound %+v", 404, o.Payload) -} - -func (o *GetAccessApikeyNameNotFound) String() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameNotFound %+v", 404, o.Payload) -} - -func (o *GetAccessApikeyNameNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameInternalServerError creates a GetAccessApikeyNameInternalServerError with default headers values -func NewGetAccessApikeyNameInternalServerError() *GetAccessApikeyNameInternalServerError { - return &GetAccessApikeyNameInternalServerError{} -} - -/* -GetAccessApikeyNameInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetAccessApikeyNameInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get access apikey name internal server error response has a 2xx status code -func (o *GetAccessApikeyNameInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey name internal server error response has a 3xx status code -func (o *GetAccessApikeyNameInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey name internal server error response has a 4xx status code -func (o *GetAccessApikeyNameInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey name internal server error response has a 5xx status code -func (o *GetAccessApikeyNameInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get access apikey name internal server error response a status code equal to that given -func (o *GetAccessApikeyNameInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get access apikey name internal server error response -func (o *GetAccessApikeyNameInternalServerError) Code() int { - return 500 -} - -func (o *GetAccessApikeyNameInternalServerError) Error() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyNameInternalServerError) String() string { - return fmt.Sprintf("[GET /access/apikey/{name}][%d] getAccessApikeyNameInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyNameInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/get_access_apikey_nameorid_parameters.go b/go/client/access/get_access_apikey_nameorid_parameters.go deleted file mode 100644 index ca55cc5f..00000000 --- a/go/client/access/get_access_apikey_nameorid_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetAccessApikeyNameoridParams creates a new GetAccessApikeyNameoridParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetAccessApikeyNameoridParams() *GetAccessApikeyNameoridParams { - return &GetAccessApikeyNameoridParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetAccessApikeyNameoridParamsWithTimeout creates a new GetAccessApikeyNameoridParams object -// with the ability to set a timeout on a request. -func NewGetAccessApikeyNameoridParamsWithTimeout(timeout time.Duration) *GetAccessApikeyNameoridParams { - return &GetAccessApikeyNameoridParams{ - timeout: timeout, - } -} - -// NewGetAccessApikeyNameoridParamsWithContext creates a new GetAccessApikeyNameoridParams object -// with the ability to set a context for a request. -func NewGetAccessApikeyNameoridParamsWithContext(ctx context.Context) *GetAccessApikeyNameoridParams { - return &GetAccessApikeyNameoridParams{ - Context: ctx, - } -} - -// NewGetAccessApikeyNameoridParamsWithHTTPClient creates a new GetAccessApikeyNameoridParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetAccessApikeyNameoridParamsWithHTTPClient(client *http.Client) *GetAccessApikeyNameoridParams { - return &GetAccessApikeyNameoridParams{ - HTTPClient: client, - } -} - -/* -GetAccessApikeyNameoridParams contains all the parameters to send to the API endpoint - - for the get access apikey nameorid operation. - - Typically these are written to a http.Request. -*/ -type GetAccessApikeyNameoridParams struct { - - /* Nameorid. - - API Key Name or ID - */ - Nameorid string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get access apikey nameorid params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyNameoridParams) WithDefaults() *GetAccessApikeyNameoridParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get access apikey nameorid params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyNameoridParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) WithTimeout(timeout time.Duration) *GetAccessApikeyNameoridParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) WithContext(ctx context.Context) *GetAccessApikeyNameoridParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) WithHTTPClient(client *http.Client) *GetAccessApikeyNameoridParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithNameorid adds the nameorid to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) WithNameorid(nameorid string) *GetAccessApikeyNameoridParams { - o.SetNameorid(nameorid) - return o -} - -// SetNameorid adds the nameorid to the get access apikey nameorid params -func (o *GetAccessApikeyNameoridParams) SetNameorid(nameorid string) { - o.Nameorid = nameorid -} - -// WriteToRequest writes these params to a swagger request -func (o *GetAccessApikeyNameoridParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param nameorid - if err := r.SetPathParam("nameorid", o.Nameorid); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/get_access_apikey_nameorid_responses.go b/go/client/access/get_access_apikey_nameorid_responses.go deleted file mode 100644 index 92ce1dd1..00000000 --- a/go/client/access/get_access_apikey_nameorid_responses.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetAccessApikeyNameoridReader is a Reader for the GetAccessApikeyNameorid structure. -type GetAccessApikeyNameoridReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetAccessApikeyNameoridReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetAccessApikeyNameoridOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewGetAccessApikeyNameoridUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetAccessApikeyNameoridNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetAccessApikeyNameoridInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetAccessApikeyNameoridOK creates a GetAccessApikeyNameoridOK with default headers values -func NewGetAccessApikeyNameoridOK() *GetAccessApikeyNameoridOK { - return &GetAccessApikeyNameoridOK{} -} - -/* -GetAccessApikeyNameoridOK describes a response with status code 200, with default header values. - -OK -*/ -type GetAccessApikeyNameoridOK struct { - Payload *models.ModelsGetAPIKeyResponse -} - -// IsSuccess returns true when this get access apikey nameorid o k response has a 2xx status code -func (o *GetAccessApikeyNameoridOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get access apikey nameorid o k response has a 3xx status code -func (o *GetAccessApikeyNameoridOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey nameorid o k response has a 4xx status code -func (o *GetAccessApikeyNameoridOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey nameorid o k response has a 5xx status code -func (o *GetAccessApikeyNameoridOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey nameorid o k response a status code equal to that given -func (o *GetAccessApikeyNameoridOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get access apikey nameorid o k response -func (o *GetAccessApikeyNameoridOK) Code() int { - return 200 -} - -func (o *GetAccessApikeyNameoridOK) Error() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyNameoridOK) String() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyNameoridOK) GetPayload() *models.ModelsGetAPIKeyResponse { - return o.Payload -} - -func (o *GetAccessApikeyNameoridOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsGetAPIKeyResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameoridUnauthorized creates a GetAccessApikeyNameoridUnauthorized with default headers values -func NewGetAccessApikeyNameoridUnauthorized() *GetAccessApikeyNameoridUnauthorized { - return &GetAccessApikeyNameoridUnauthorized{} -} - -/* -GetAccessApikeyNameoridUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetAccessApikeyNameoridUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get access apikey nameorid unauthorized response has a 2xx status code -func (o *GetAccessApikeyNameoridUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey nameorid unauthorized response has a 3xx status code -func (o *GetAccessApikeyNameoridUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey nameorid unauthorized response has a 4xx status code -func (o *GetAccessApikeyNameoridUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get access apikey nameorid unauthorized response has a 5xx status code -func (o *GetAccessApikeyNameoridUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey nameorid unauthorized response a status code equal to that given -func (o *GetAccessApikeyNameoridUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get access apikey nameorid unauthorized response -func (o *GetAccessApikeyNameoridUnauthorized) Code() int { - return 401 -} - -func (o *GetAccessApikeyNameoridUnauthorized) Error() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyNameoridUnauthorized) String() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyNameoridUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameoridUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameoridNotFound creates a GetAccessApikeyNameoridNotFound with default headers values -func NewGetAccessApikeyNameoridNotFound() *GetAccessApikeyNameoridNotFound { - return &GetAccessApikeyNameoridNotFound{} -} - -/* -GetAccessApikeyNameoridNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetAccessApikeyNameoridNotFound struct { - Payload string -} - -// IsSuccess returns true when this get access apikey nameorid not found response has a 2xx status code -func (o *GetAccessApikeyNameoridNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey nameorid not found response has a 3xx status code -func (o *GetAccessApikeyNameoridNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey nameorid not found response has a 4xx status code -func (o *GetAccessApikeyNameoridNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get access apikey nameorid not found response has a 5xx status code -func (o *GetAccessApikeyNameoridNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey nameorid not found response a status code equal to that given -func (o *GetAccessApikeyNameoridNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get access apikey nameorid not found response -func (o *GetAccessApikeyNameoridNotFound) Code() int { - return 404 -} - -func (o *GetAccessApikeyNameoridNotFound) Error() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridNotFound %+v", 404, o.Payload) -} - -func (o *GetAccessApikeyNameoridNotFound) String() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridNotFound %+v", 404, o.Payload) -} - -func (o *GetAccessApikeyNameoridNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameoridNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyNameoridInternalServerError creates a GetAccessApikeyNameoridInternalServerError with default headers values -func NewGetAccessApikeyNameoridInternalServerError() *GetAccessApikeyNameoridInternalServerError { - return &GetAccessApikeyNameoridInternalServerError{} -} - -/* -GetAccessApikeyNameoridInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetAccessApikeyNameoridInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get access apikey nameorid internal server error response has a 2xx status code -func (o *GetAccessApikeyNameoridInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey nameorid internal server error response has a 3xx status code -func (o *GetAccessApikeyNameoridInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey nameorid internal server error response has a 4xx status code -func (o *GetAccessApikeyNameoridInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey nameorid internal server error response has a 5xx status code -func (o *GetAccessApikeyNameoridInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get access apikey nameorid internal server error response a status code equal to that given -func (o *GetAccessApikeyNameoridInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get access apikey nameorid internal server error response -func (o *GetAccessApikeyNameoridInternalServerError) Code() int { - return 500 -} - -func (o *GetAccessApikeyNameoridInternalServerError) Error() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyNameoridInternalServerError) String() string { - return fmt.Sprintf("[GET /access/apikey/{nameorid}][%d] getAccessApikeyNameoridInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyNameoridInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyNameoridInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/get_access_apikey_parameters.go b/go/client/access/get_access_apikey_parameters.go deleted file mode 100644 index 14ae09f2..00000000 --- a/go/client/access/get_access_apikey_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetAccessApikeyParams creates a new GetAccessApikeyParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetAccessApikeyParams() *GetAccessApikeyParams { - return &GetAccessApikeyParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetAccessApikeyParamsWithTimeout creates a new GetAccessApikeyParams object -// with the ability to set a timeout on a request. -func NewGetAccessApikeyParamsWithTimeout(timeout time.Duration) *GetAccessApikeyParams { - return &GetAccessApikeyParams{ - timeout: timeout, - } -} - -// NewGetAccessApikeyParamsWithContext creates a new GetAccessApikeyParams object -// with the ability to set a context for a request. -func NewGetAccessApikeyParamsWithContext(ctx context.Context) *GetAccessApikeyParams { - return &GetAccessApikeyParams{ - Context: ctx, - } -} - -// NewGetAccessApikeyParamsWithHTTPClient creates a new GetAccessApikeyParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetAccessApikeyParamsWithHTTPClient(client *http.Client) *GetAccessApikeyParams { - return &GetAccessApikeyParams{ - HTTPClient: client, - } -} - -/* -GetAccessApikeyParams contains all the parameters to send to the API endpoint - - for the get access apikey operation. - - Typically these are written to a http.Request. -*/ -type GetAccessApikeyParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get access apikey params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyParams) WithDefaults() *GetAccessApikeyParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get access apikey params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetAccessApikeyParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get access apikey params -func (o *GetAccessApikeyParams) WithTimeout(timeout time.Duration) *GetAccessApikeyParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get access apikey params -func (o *GetAccessApikeyParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get access apikey params -func (o *GetAccessApikeyParams) WithContext(ctx context.Context) *GetAccessApikeyParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get access apikey params -func (o *GetAccessApikeyParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get access apikey params -func (o *GetAccessApikeyParams) WithHTTPClient(client *http.Client) *GetAccessApikeyParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get access apikey params -func (o *GetAccessApikeyParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *GetAccessApikeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/get_access_apikey_responses.go b/go/client/access/get_access_apikey_responses.go deleted file mode 100644 index da28c1b9..00000000 --- a/go/client/access/get_access_apikey_responses.go +++ /dev/null @@ -1,245 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetAccessApikeyReader is a Reader for the GetAccessApikey structure. -type GetAccessApikeyReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetAccessApikeyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetAccessApikeyOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewGetAccessApikeyUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetAccessApikeyInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetAccessApikeyOK creates a GetAccessApikeyOK with default headers values -func NewGetAccessApikeyOK() *GetAccessApikeyOK { - return &GetAccessApikeyOK{} -} - -/* -GetAccessApikeyOK describes a response with status code 200, with default header values. - -OK -*/ -type GetAccessApikeyOK struct { - Payload []*models.ModelsGetAPIKeyResponse -} - -// IsSuccess returns true when this get access apikey o k response has a 2xx status code -func (o *GetAccessApikeyOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get access apikey o k response has a 3xx status code -func (o *GetAccessApikeyOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey o k response has a 4xx status code -func (o *GetAccessApikeyOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey o k response has a 5xx status code -func (o *GetAccessApikeyOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey o k response a status code equal to that given -func (o *GetAccessApikeyOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get access apikey o k response -func (o *GetAccessApikeyOK) Code() int { - return 200 -} - -func (o *GetAccessApikeyOK) Error() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyOK) String() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyOK %+v", 200, o.Payload) -} - -func (o *GetAccessApikeyOK) GetPayload() []*models.ModelsGetAPIKeyResponse { - return o.Payload -} - -func (o *GetAccessApikeyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyUnauthorized creates a GetAccessApikeyUnauthorized with default headers values -func NewGetAccessApikeyUnauthorized() *GetAccessApikeyUnauthorized { - return &GetAccessApikeyUnauthorized{} -} - -/* -GetAccessApikeyUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetAccessApikeyUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get access apikey unauthorized response has a 2xx status code -func (o *GetAccessApikeyUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey unauthorized response has a 3xx status code -func (o *GetAccessApikeyUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey unauthorized response has a 4xx status code -func (o *GetAccessApikeyUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get access apikey unauthorized response has a 5xx status code -func (o *GetAccessApikeyUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get access apikey unauthorized response a status code equal to that given -func (o *GetAccessApikeyUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get access apikey unauthorized response -func (o *GetAccessApikeyUnauthorized) Code() int { - return 401 -} - -func (o *GetAccessApikeyUnauthorized) Error() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyUnauthorized) String() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyUnauthorized %+v", 401, o.Payload) -} - -func (o *GetAccessApikeyUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetAccessApikeyInternalServerError creates a GetAccessApikeyInternalServerError with default headers values -func NewGetAccessApikeyInternalServerError() *GetAccessApikeyInternalServerError { - return &GetAccessApikeyInternalServerError{} -} - -/* -GetAccessApikeyInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetAccessApikeyInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get access apikey internal server error response has a 2xx status code -func (o *GetAccessApikeyInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get access apikey internal server error response has a 3xx status code -func (o *GetAccessApikeyInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get access apikey internal server error response has a 4xx status code -func (o *GetAccessApikeyInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get access apikey internal server error response has a 5xx status code -func (o *GetAccessApikeyInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get access apikey internal server error response a status code equal to that given -func (o *GetAccessApikeyInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get access apikey internal server error response -func (o *GetAccessApikeyInternalServerError) Code() int { - return 500 -} - -func (o *GetAccessApikeyInternalServerError) Error() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyInternalServerError) String() string { - return fmt.Sprintf("[GET /access/apikey][%d] getAccessApikeyInternalServerError %+v", 500, o.Payload) -} - -func (o *GetAccessApikeyInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetAccessApikeyInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/post_access_apikey_name_parameters.go b/go/client/access/post_access_apikey_name_parameters.go deleted file mode 100644 index 60924aec..00000000 --- a/go/client/access/post_access_apikey_name_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewPostAccessApikeyNameParams creates a new PostAccessApikeyNameParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostAccessApikeyNameParams() *PostAccessApikeyNameParams { - return &PostAccessApikeyNameParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostAccessApikeyNameParamsWithTimeout creates a new PostAccessApikeyNameParams object -// with the ability to set a timeout on a request. -func NewPostAccessApikeyNameParamsWithTimeout(timeout time.Duration) *PostAccessApikeyNameParams { - return &PostAccessApikeyNameParams{ - timeout: timeout, - } -} - -// NewPostAccessApikeyNameParamsWithContext creates a new PostAccessApikeyNameParams object -// with the ability to set a context for a request. -func NewPostAccessApikeyNameParamsWithContext(ctx context.Context) *PostAccessApikeyNameParams { - return &PostAccessApikeyNameParams{ - Context: ctx, - } -} - -// NewPostAccessApikeyNameParamsWithHTTPClient creates a new PostAccessApikeyNameParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostAccessApikeyNameParamsWithHTTPClient(client *http.Client) *PostAccessApikeyNameParams { - return &PostAccessApikeyNameParams{ - HTTPClient: client, - } -} - -/* -PostAccessApikeyNameParams contains all the parameters to send to the API endpoint - - for the post access apikey name operation. - - Typically these are written to a http.Request. -*/ -type PostAccessApikeyNameParams struct { - - /* Name. - - name - */ - Name string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post access apikey name params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostAccessApikeyNameParams) WithDefaults() *PostAccessApikeyNameParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post access apikey name params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostAccessApikeyNameParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post access apikey name params -func (o *PostAccessApikeyNameParams) WithTimeout(timeout time.Duration) *PostAccessApikeyNameParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post access apikey name params -func (o *PostAccessApikeyNameParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post access apikey name params -func (o *PostAccessApikeyNameParams) WithContext(ctx context.Context) *PostAccessApikeyNameParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post access apikey name params -func (o *PostAccessApikeyNameParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post access apikey name params -func (o *PostAccessApikeyNameParams) WithHTTPClient(client *http.Client) *PostAccessApikeyNameParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post access apikey name params -func (o *PostAccessApikeyNameParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithName adds the name to the post access apikey name params -func (o *PostAccessApikeyNameParams) WithName(name string) *PostAccessApikeyNameParams { - o.SetName(name) - return o -} - -// SetName adds the name to the post access apikey name params -func (o *PostAccessApikeyNameParams) SetName(name string) { - o.Name = name -} - -// WriteToRequest writes these params to a swagger request -func (o *PostAccessApikeyNameParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param name - if err := r.SetPathParam("name", o.Name); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/post_access_apikey_name_responses.go b/go/client/access/post_access_apikey_name_responses.go deleted file mode 100644 index 5b2b0ebc..00000000 --- a/go/client/access/post_access_apikey_name_responses.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostAccessApikeyNameReader is a Reader for the PostAccessApikeyName structure. -type PostAccessApikeyNameReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostAccessApikeyNameReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostAccessApikeyNameOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostAccessApikeyNameBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostAccessApikeyNameUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostAccessApikeyNameInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostAccessApikeyNameOK creates a PostAccessApikeyNameOK with default headers values -func NewPostAccessApikeyNameOK() *PostAccessApikeyNameOK { - return &PostAccessApikeyNameOK{} -} - -/* -PostAccessApikeyNameOK describes a response with status code 200, with default header values. - -OK -*/ -type PostAccessApikeyNameOK struct { - Payload *models.ModelsCreateAPIKeyResponse -} - -// IsSuccess returns true when this post access apikey name o k response has a 2xx status code -func (o *PostAccessApikeyNameOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post access apikey name o k response has a 3xx status code -func (o *PostAccessApikeyNameOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey name o k response has a 4xx status code -func (o *PostAccessApikeyNameOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post access apikey name o k response has a 5xx status code -func (o *PostAccessApikeyNameOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey name o k response a status code equal to that given -func (o *PostAccessApikeyNameOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post access apikey name o k response -func (o *PostAccessApikeyNameOK) Code() int { - return 200 -} - -func (o *PostAccessApikeyNameOK) Error() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameOK %+v", 200, o.Payload) -} - -func (o *PostAccessApikeyNameOK) String() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameOK %+v", 200, o.Payload) -} - -func (o *PostAccessApikeyNameOK) GetPayload() *models.ModelsCreateAPIKeyResponse { - return o.Payload -} - -func (o *PostAccessApikeyNameOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsCreateAPIKeyResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyNameBadRequest creates a PostAccessApikeyNameBadRequest with default headers values -func NewPostAccessApikeyNameBadRequest() *PostAccessApikeyNameBadRequest { - return &PostAccessApikeyNameBadRequest{} -} - -/* -PostAccessApikeyNameBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostAccessApikeyNameBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post access apikey name bad request response has a 2xx status code -func (o *PostAccessApikeyNameBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey name bad request response has a 3xx status code -func (o *PostAccessApikeyNameBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey name bad request response has a 4xx status code -func (o *PostAccessApikeyNameBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post access apikey name bad request response has a 5xx status code -func (o *PostAccessApikeyNameBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey name bad request response a status code equal to that given -func (o *PostAccessApikeyNameBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post access apikey name bad request response -func (o *PostAccessApikeyNameBadRequest) Code() int { - return 400 -} - -func (o *PostAccessApikeyNameBadRequest) Error() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameBadRequest %+v", 400, o.Payload) -} - -func (o *PostAccessApikeyNameBadRequest) String() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameBadRequest %+v", 400, o.Payload) -} - -func (o *PostAccessApikeyNameBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyNameBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyNameUnauthorized creates a PostAccessApikeyNameUnauthorized with default headers values -func NewPostAccessApikeyNameUnauthorized() *PostAccessApikeyNameUnauthorized { - return &PostAccessApikeyNameUnauthorized{} -} - -/* -PostAccessApikeyNameUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostAccessApikeyNameUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post access apikey name unauthorized response has a 2xx status code -func (o *PostAccessApikeyNameUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey name unauthorized response has a 3xx status code -func (o *PostAccessApikeyNameUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey name unauthorized response has a 4xx status code -func (o *PostAccessApikeyNameUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post access apikey name unauthorized response has a 5xx status code -func (o *PostAccessApikeyNameUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey name unauthorized response a status code equal to that given -func (o *PostAccessApikeyNameUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post access apikey name unauthorized response -func (o *PostAccessApikeyNameUnauthorized) Code() int { - return 401 -} - -func (o *PostAccessApikeyNameUnauthorized) Error() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameUnauthorized %+v", 401, o.Payload) -} - -func (o *PostAccessApikeyNameUnauthorized) String() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameUnauthorized %+v", 401, o.Payload) -} - -func (o *PostAccessApikeyNameUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyNameUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyNameInternalServerError creates a PostAccessApikeyNameInternalServerError with default headers values -func NewPostAccessApikeyNameInternalServerError() *PostAccessApikeyNameInternalServerError { - return &PostAccessApikeyNameInternalServerError{} -} - -/* -PostAccessApikeyNameInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostAccessApikeyNameInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post access apikey name internal server error response has a 2xx status code -func (o *PostAccessApikeyNameInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey name internal server error response has a 3xx status code -func (o *PostAccessApikeyNameInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey name internal server error response has a 4xx status code -func (o *PostAccessApikeyNameInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post access apikey name internal server error response has a 5xx status code -func (o *PostAccessApikeyNameInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post access apikey name internal server error response a status code equal to that given -func (o *PostAccessApikeyNameInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post access apikey name internal server error response -func (o *PostAccessApikeyNameInternalServerError) Code() int { - return 500 -} - -func (o *PostAccessApikeyNameInternalServerError) Error() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameInternalServerError %+v", 500, o.Payload) -} - -func (o *PostAccessApikeyNameInternalServerError) String() string { - return fmt.Sprintf("[POST /access/apikey/{name}][%d] postAccessApikeyNameInternalServerError %+v", 500, o.Payload) -} - -func (o *PostAccessApikeyNameInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyNameInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/access/post_access_apikey_parameters.go b/go/client/access/post_access_apikey_parameters.go deleted file mode 100644 index c4aa388e..00000000 --- a/go/client/access/post_access_apikey_parameters.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// NewPostAccessApikeyParams creates a new PostAccessApikeyParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostAccessApikeyParams() *PostAccessApikeyParams { - return &PostAccessApikeyParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostAccessApikeyParamsWithTimeout creates a new PostAccessApikeyParams object -// with the ability to set a timeout on a request. -func NewPostAccessApikeyParamsWithTimeout(timeout time.Duration) *PostAccessApikeyParams { - return &PostAccessApikeyParams{ - timeout: timeout, - } -} - -// NewPostAccessApikeyParamsWithContext creates a new PostAccessApikeyParams object -// with the ability to set a context for a request. -func NewPostAccessApikeyParamsWithContext(ctx context.Context) *PostAccessApikeyParams { - return &PostAccessApikeyParams{ - Context: ctx, - } -} - -// NewPostAccessApikeyParamsWithHTTPClient creates a new PostAccessApikeyParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostAccessApikeyParamsWithHTTPClient(client *http.Client) *PostAccessApikeyParams { - return &PostAccessApikeyParams{ - HTTPClient: client, - } -} - -/* -PostAccessApikeyParams contains all the parameters to send to the API endpoint - - for the post access apikey operation. - - Typically these are written to a http.Request. -*/ -type PostAccessApikeyParams struct { - - /* Request. - - Create API Key Request - */ - Request *models.ModelsCreateAPIKeyRequest - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post access apikey params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostAccessApikeyParams) WithDefaults() *PostAccessApikeyParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post access apikey params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostAccessApikeyParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post access apikey params -func (o *PostAccessApikeyParams) WithTimeout(timeout time.Duration) *PostAccessApikeyParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post access apikey params -func (o *PostAccessApikeyParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post access apikey params -func (o *PostAccessApikeyParams) WithContext(ctx context.Context) *PostAccessApikeyParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post access apikey params -func (o *PostAccessApikeyParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post access apikey params -func (o *PostAccessApikeyParams) WithHTTPClient(client *http.Client) *PostAccessApikeyParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post access apikey params -func (o *PostAccessApikeyParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithRequest adds the request to the post access apikey params -func (o *PostAccessApikeyParams) WithRequest(request *models.ModelsCreateAPIKeyRequest) *PostAccessApikeyParams { - o.SetRequest(request) - return o -} - -// SetRequest adds the request to the post access apikey params -func (o *PostAccessApikeyParams) SetRequest(request *models.ModelsCreateAPIKeyRequest) { - o.Request = request -} - -// WriteToRequest writes these params to a swagger request -func (o *PostAccessApikeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Request != nil { - if err := r.SetBodyParam(o.Request); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/access/post_access_apikey_responses.go b/go/client/access/post_access_apikey_responses.go deleted file mode 100644 index b30966ee..00000000 --- a/go/client/access/post_access_apikey_responses.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package access - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostAccessApikeyReader is a Reader for the PostAccessApikey structure. -type PostAccessApikeyReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostAccessApikeyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostAccessApikeyOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostAccessApikeyBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostAccessApikeyUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostAccessApikeyInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostAccessApikeyOK creates a PostAccessApikeyOK with default headers values -func NewPostAccessApikeyOK() *PostAccessApikeyOK { - return &PostAccessApikeyOK{} -} - -/* -PostAccessApikeyOK describes a response with status code 200, with default header values. - -OK -*/ -type PostAccessApikeyOK struct { - Payload *models.ModelsCreateAPIKeyResponse -} - -// IsSuccess returns true when this post access apikey o k response has a 2xx status code -func (o *PostAccessApikeyOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post access apikey o k response has a 3xx status code -func (o *PostAccessApikeyOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey o k response has a 4xx status code -func (o *PostAccessApikeyOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post access apikey o k response has a 5xx status code -func (o *PostAccessApikeyOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey o k response a status code equal to that given -func (o *PostAccessApikeyOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post access apikey o k response -func (o *PostAccessApikeyOK) Code() int { - return 200 -} - -func (o *PostAccessApikeyOK) Error() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyOK %+v", 200, o.Payload) -} - -func (o *PostAccessApikeyOK) String() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyOK %+v", 200, o.Payload) -} - -func (o *PostAccessApikeyOK) GetPayload() *models.ModelsCreateAPIKeyResponse { - return o.Payload -} - -func (o *PostAccessApikeyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsCreateAPIKeyResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyBadRequest creates a PostAccessApikeyBadRequest with default headers values -func NewPostAccessApikeyBadRequest() *PostAccessApikeyBadRequest { - return &PostAccessApikeyBadRequest{} -} - -/* -PostAccessApikeyBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostAccessApikeyBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post access apikey bad request response has a 2xx status code -func (o *PostAccessApikeyBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey bad request response has a 3xx status code -func (o *PostAccessApikeyBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey bad request response has a 4xx status code -func (o *PostAccessApikeyBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post access apikey bad request response has a 5xx status code -func (o *PostAccessApikeyBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey bad request response a status code equal to that given -func (o *PostAccessApikeyBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post access apikey bad request response -func (o *PostAccessApikeyBadRequest) Code() int { - return 400 -} - -func (o *PostAccessApikeyBadRequest) Error() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyBadRequest %+v", 400, o.Payload) -} - -func (o *PostAccessApikeyBadRequest) String() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyBadRequest %+v", 400, o.Payload) -} - -func (o *PostAccessApikeyBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyUnauthorized creates a PostAccessApikeyUnauthorized with default headers values -func NewPostAccessApikeyUnauthorized() *PostAccessApikeyUnauthorized { - return &PostAccessApikeyUnauthorized{} -} - -/* -PostAccessApikeyUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostAccessApikeyUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post access apikey unauthorized response has a 2xx status code -func (o *PostAccessApikeyUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey unauthorized response has a 3xx status code -func (o *PostAccessApikeyUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey unauthorized response has a 4xx status code -func (o *PostAccessApikeyUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post access apikey unauthorized response has a 5xx status code -func (o *PostAccessApikeyUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post access apikey unauthorized response a status code equal to that given -func (o *PostAccessApikeyUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post access apikey unauthorized response -func (o *PostAccessApikeyUnauthorized) Code() int { - return 401 -} - -func (o *PostAccessApikeyUnauthorized) Error() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyUnauthorized %+v", 401, o.Payload) -} - -func (o *PostAccessApikeyUnauthorized) String() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyUnauthorized %+v", 401, o.Payload) -} - -func (o *PostAccessApikeyUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostAccessApikeyInternalServerError creates a PostAccessApikeyInternalServerError with default headers values -func NewPostAccessApikeyInternalServerError() *PostAccessApikeyInternalServerError { - return &PostAccessApikeyInternalServerError{} -} - -/* -PostAccessApikeyInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostAccessApikeyInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post access apikey internal server error response has a 2xx status code -func (o *PostAccessApikeyInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post access apikey internal server error response has a 3xx status code -func (o *PostAccessApikeyInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post access apikey internal server error response has a 4xx status code -func (o *PostAccessApikeyInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post access apikey internal server error response has a 5xx status code -func (o *PostAccessApikeyInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post access apikey internal server error response a status code equal to that given -func (o *PostAccessApikeyInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post access apikey internal server error response -func (o *PostAccessApikeyInternalServerError) Code() int { - return 500 -} - -func (o *PostAccessApikeyInternalServerError) Error() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyInternalServerError %+v", 500, o.Payload) -} - -func (o *PostAccessApikeyInternalServerError) String() string { - return fmt.Sprintf("[POST /access/apikey][%d] postAccessApikeyInternalServerError %+v", 500, o.Payload) -} - -func (o *PostAccessApikeyInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostAccessApikeyInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/deploy/delete_deploy_function_identifier_parameters.go b/go/client/deploy/delete_deploy_function_identifier_parameters.go deleted file mode 100644 index d80c2636..00000000 --- a/go/client/deploy/delete_deploy_function_identifier_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package deploy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewDeleteDeployFunctionIdentifierParams creates a new DeleteDeployFunctionIdentifierParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewDeleteDeployFunctionIdentifierParams() *DeleteDeployFunctionIdentifierParams { - return &DeleteDeployFunctionIdentifierParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewDeleteDeployFunctionIdentifierParamsWithTimeout creates a new DeleteDeployFunctionIdentifierParams object -// with the ability to set a timeout on a request. -func NewDeleteDeployFunctionIdentifierParamsWithTimeout(timeout time.Duration) *DeleteDeployFunctionIdentifierParams { - return &DeleteDeployFunctionIdentifierParams{ - timeout: timeout, - } -} - -// NewDeleteDeployFunctionIdentifierParamsWithContext creates a new DeleteDeployFunctionIdentifierParams object -// with the ability to set a context for a request. -func NewDeleteDeployFunctionIdentifierParamsWithContext(ctx context.Context) *DeleteDeployFunctionIdentifierParams { - return &DeleteDeployFunctionIdentifierParams{ - Context: ctx, - } -} - -// NewDeleteDeployFunctionIdentifierParamsWithHTTPClient creates a new DeleteDeployFunctionIdentifierParams object -// with the ability to set a custom HTTPClient for a request. -func NewDeleteDeployFunctionIdentifierParamsWithHTTPClient(client *http.Client) *DeleteDeployFunctionIdentifierParams { - return &DeleteDeployFunctionIdentifierParams{ - HTTPClient: client, - } -} - -/* -DeleteDeployFunctionIdentifierParams contains all the parameters to send to the API endpoint - - for the delete deploy function identifier operation. - - Typically these are written to a http.Request. -*/ -type DeleteDeployFunctionIdentifierParams struct { - - /* Identifier. - - identifier - */ - Identifier string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the delete deploy function identifier params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteDeployFunctionIdentifierParams) WithDefaults() *DeleteDeployFunctionIdentifierParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the delete deploy function identifier params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteDeployFunctionIdentifierParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) WithTimeout(timeout time.Duration) *DeleteDeployFunctionIdentifierParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) WithContext(ctx context.Context) *DeleteDeployFunctionIdentifierParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) WithHTTPClient(client *http.Client) *DeleteDeployFunctionIdentifierParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithIdentifier adds the identifier to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) WithIdentifier(identifier string) *DeleteDeployFunctionIdentifierParams { - o.SetIdentifier(identifier) - return o -} - -// SetIdentifier adds the identifier to the delete deploy function identifier params -func (o *DeleteDeployFunctionIdentifierParams) SetIdentifier(identifier string) { - o.Identifier = identifier -} - -// WriteToRequest writes these params to a swagger request -func (o *DeleteDeployFunctionIdentifierParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param identifier - if err := r.SetPathParam("identifier", o.Identifier); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/deploy/delete_deploy_function_identifier_responses.go b/go/client/deploy/delete_deploy_function_identifier_responses.go deleted file mode 100644 index 125f11d2..00000000 --- a/go/client/deploy/delete_deploy_function_identifier_responses.go +++ /dev/null @@ -1,387 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package deploy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// DeleteDeployFunctionIdentifierReader is a Reader for the DeleteDeployFunctionIdentifier structure. -type DeleteDeployFunctionIdentifierReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *DeleteDeployFunctionIdentifierReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewDeleteDeployFunctionIdentifierOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewDeleteDeployFunctionIdentifierBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewDeleteDeployFunctionIdentifierUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewDeleteDeployFunctionIdentifierNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewDeleteDeployFunctionIdentifierInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewDeleteDeployFunctionIdentifierOK creates a DeleteDeployFunctionIdentifierOK with default headers values -func NewDeleteDeployFunctionIdentifierOK() *DeleteDeployFunctionIdentifierOK { - return &DeleteDeployFunctionIdentifierOK{} -} - -/* -DeleteDeployFunctionIdentifierOK describes a response with status code 200, with default header values. - -OK -*/ -type DeleteDeployFunctionIdentifierOK struct { - Payload string -} - -// IsSuccess returns true when this delete deploy function identifier o k response has a 2xx status code -func (o *DeleteDeployFunctionIdentifierOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this delete deploy function identifier o k response has a 3xx status code -func (o *DeleteDeployFunctionIdentifierOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete deploy function identifier o k response has a 4xx status code -func (o *DeleteDeployFunctionIdentifierOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete deploy function identifier o k response has a 5xx status code -func (o *DeleteDeployFunctionIdentifierOK) IsServerError() bool { - return false -} - -// IsCode returns true when this delete deploy function identifier o k response a status code equal to that given -func (o *DeleteDeployFunctionIdentifierOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the delete deploy function identifier o k response -func (o *DeleteDeployFunctionIdentifierOK) Code() int { - return 200 -} - -func (o *DeleteDeployFunctionIdentifierOK) Error() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierOK %+v", 200, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierOK) String() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierOK %+v", 200, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierOK) GetPayload() string { - return o.Payload -} - -func (o *DeleteDeployFunctionIdentifierOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteDeployFunctionIdentifierBadRequest creates a DeleteDeployFunctionIdentifierBadRequest with default headers values -func NewDeleteDeployFunctionIdentifierBadRequest() *DeleteDeployFunctionIdentifierBadRequest { - return &DeleteDeployFunctionIdentifierBadRequest{} -} - -/* -DeleteDeployFunctionIdentifierBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type DeleteDeployFunctionIdentifierBadRequest struct { - Payload string -} - -// IsSuccess returns true when this delete deploy function identifier bad request response has a 2xx status code -func (o *DeleteDeployFunctionIdentifierBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete deploy function identifier bad request response has a 3xx status code -func (o *DeleteDeployFunctionIdentifierBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete deploy function identifier bad request response has a 4xx status code -func (o *DeleteDeployFunctionIdentifierBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete deploy function identifier bad request response has a 5xx status code -func (o *DeleteDeployFunctionIdentifierBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this delete deploy function identifier bad request response a status code equal to that given -func (o *DeleteDeployFunctionIdentifierBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the delete deploy function identifier bad request response -func (o *DeleteDeployFunctionIdentifierBadRequest) Code() int { - return 400 -} - -func (o *DeleteDeployFunctionIdentifierBadRequest) Error() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierBadRequest %+v", 400, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierBadRequest) String() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierBadRequest %+v", 400, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierBadRequest) GetPayload() string { - return o.Payload -} - -func (o *DeleteDeployFunctionIdentifierBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteDeployFunctionIdentifierUnauthorized creates a DeleteDeployFunctionIdentifierUnauthorized with default headers values -func NewDeleteDeployFunctionIdentifierUnauthorized() *DeleteDeployFunctionIdentifierUnauthorized { - return &DeleteDeployFunctionIdentifierUnauthorized{} -} - -/* -DeleteDeployFunctionIdentifierUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type DeleteDeployFunctionIdentifierUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this delete deploy function identifier unauthorized response has a 2xx status code -func (o *DeleteDeployFunctionIdentifierUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete deploy function identifier unauthorized response has a 3xx status code -func (o *DeleteDeployFunctionIdentifierUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete deploy function identifier unauthorized response has a 4xx status code -func (o *DeleteDeployFunctionIdentifierUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete deploy function identifier unauthorized response has a 5xx status code -func (o *DeleteDeployFunctionIdentifierUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this delete deploy function identifier unauthorized response a status code equal to that given -func (o *DeleteDeployFunctionIdentifierUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the delete deploy function identifier unauthorized response -func (o *DeleteDeployFunctionIdentifierUnauthorized) Code() int { - return 401 -} - -func (o *DeleteDeployFunctionIdentifierUnauthorized) Error() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierUnauthorized) String() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *DeleteDeployFunctionIdentifierUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteDeployFunctionIdentifierNotFound creates a DeleteDeployFunctionIdentifierNotFound with default headers values -func NewDeleteDeployFunctionIdentifierNotFound() *DeleteDeployFunctionIdentifierNotFound { - return &DeleteDeployFunctionIdentifierNotFound{} -} - -/* -DeleteDeployFunctionIdentifierNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type DeleteDeployFunctionIdentifierNotFound struct { - Payload string -} - -// IsSuccess returns true when this delete deploy function identifier not found response has a 2xx status code -func (o *DeleteDeployFunctionIdentifierNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete deploy function identifier not found response has a 3xx status code -func (o *DeleteDeployFunctionIdentifierNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete deploy function identifier not found response has a 4xx status code -func (o *DeleteDeployFunctionIdentifierNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete deploy function identifier not found response has a 5xx status code -func (o *DeleteDeployFunctionIdentifierNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this delete deploy function identifier not found response a status code equal to that given -func (o *DeleteDeployFunctionIdentifierNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the delete deploy function identifier not found response -func (o *DeleteDeployFunctionIdentifierNotFound) Code() int { - return 404 -} - -func (o *DeleteDeployFunctionIdentifierNotFound) Error() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierNotFound %+v", 404, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierNotFound) String() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierNotFound %+v", 404, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierNotFound) GetPayload() string { - return o.Payload -} - -func (o *DeleteDeployFunctionIdentifierNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteDeployFunctionIdentifierInternalServerError creates a DeleteDeployFunctionIdentifierInternalServerError with default headers values -func NewDeleteDeployFunctionIdentifierInternalServerError() *DeleteDeployFunctionIdentifierInternalServerError { - return &DeleteDeployFunctionIdentifierInternalServerError{} -} - -/* -DeleteDeployFunctionIdentifierInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type DeleteDeployFunctionIdentifierInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this delete deploy function identifier internal server error response has a 2xx status code -func (o *DeleteDeployFunctionIdentifierInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete deploy function identifier internal server error response has a 3xx status code -func (o *DeleteDeployFunctionIdentifierInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete deploy function identifier internal server error response has a 4xx status code -func (o *DeleteDeployFunctionIdentifierInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete deploy function identifier internal server error response has a 5xx status code -func (o *DeleteDeployFunctionIdentifierInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this delete deploy function identifier internal server error response a status code equal to that given -func (o *DeleteDeployFunctionIdentifierInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the delete deploy function identifier internal server error response -func (o *DeleteDeployFunctionIdentifierInternalServerError) Code() int { - return 500 -} - -func (o *DeleteDeployFunctionIdentifierInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierInternalServerError) String() string { - return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteDeployFunctionIdentifierInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *DeleteDeployFunctionIdentifierInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/deploy/deploy_client.go b/go/client/deploy/deploy_client.go deleted file mode 100644 index ee826702..00000000 --- a/go/client/deploy/deploy_client.go +++ /dev/null @@ -1,119 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package deploy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// New creates a new deploy API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for deploy API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - DeleteDeployFunctionIdentifier(params *DeleteDeployFunctionIdentifierParams, opts ...ClientOption) (*DeleteDeployFunctionIdentifierOK, error) - - PostDeployFunction(params *PostDeployFunctionParams, opts ...ClientOption) (*PostDeployFunctionOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -DeleteDeployFunctionIdentifier Removes a deployed function from the servers -*/ -func (a *Client) DeleteDeployFunctionIdentifier(params *DeleteDeployFunctionIdentifierParams, opts ...ClientOption) (*DeleteDeployFunctionIdentifierOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewDeleteDeployFunctionIdentifierParams() - } - op := &runtime.ClientOperation{ - ID: "DeleteDeployFunctionIdentifier", - Method: "DELETE", - PathPattern: "/deploy/function/{identifier}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &DeleteDeployFunctionIdentifierReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*DeleteDeployFunctionIdentifierOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for DeleteDeployFunctionIdentifier: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -PostDeployFunction Deploys a scale function -*/ -func (a *Client) PostDeployFunction(params *PostDeployFunctionParams, opts ...ClientOption) (*PostDeployFunctionOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewPostDeployFunctionParams() - } - op := &runtime.ClientOperation{ - ID: "PostDeployFunction", - Method: "POST", - PathPattern: "/deploy/function", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"multipart/form-data"}, - Schemes: []string{"https"}, - Params: params, - Reader: &PostDeployFunctionReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*PostDeployFunctionOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for PostDeployFunction: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/go/client/deploy/post_deploy_function_parameters.go b/go/client/deploy/post_deploy_function_parameters.go deleted file mode 100644 index 130b17d4..00000000 --- a/go/client/deploy/post_deploy_function_parameters.go +++ /dev/null @@ -1,182 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package deploy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewPostDeployFunctionParams creates a new PostDeployFunctionParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostDeployFunctionParams() *PostDeployFunctionParams { - return &PostDeployFunctionParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostDeployFunctionParamsWithTimeout creates a new PostDeployFunctionParams object -// with the ability to set a timeout on a request. -func NewPostDeployFunctionParamsWithTimeout(timeout time.Duration) *PostDeployFunctionParams { - return &PostDeployFunctionParams{ - timeout: timeout, - } -} - -// NewPostDeployFunctionParamsWithContext creates a new PostDeployFunctionParams object -// with the ability to set a context for a request. -func NewPostDeployFunctionParamsWithContext(ctx context.Context) *PostDeployFunctionParams { - return &PostDeployFunctionParams{ - Context: ctx, - } -} - -// NewPostDeployFunctionParamsWithHTTPClient creates a new PostDeployFunctionParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostDeployFunctionParamsWithHTTPClient(client *http.Client) *PostDeployFunctionParams { - return &PostDeployFunctionParams{ - HTTPClient: client, - } -} - -/* -PostDeployFunctionParams contains all the parameters to send to the API endpoint - - for the post deploy function operation. - - Typically these are written to a http.Request. -*/ -type PostDeployFunctionParams struct { - - /* Functions. - - functions - */ - Functions runtime.NamedReadCloser - - /* Name. - - name - */ - Name *string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post deploy function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostDeployFunctionParams) WithDefaults() *PostDeployFunctionParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post deploy function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostDeployFunctionParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post deploy function params -func (o *PostDeployFunctionParams) WithTimeout(timeout time.Duration) *PostDeployFunctionParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post deploy function params -func (o *PostDeployFunctionParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post deploy function params -func (o *PostDeployFunctionParams) WithContext(ctx context.Context) *PostDeployFunctionParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post deploy function params -func (o *PostDeployFunctionParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post deploy function params -func (o *PostDeployFunctionParams) WithHTTPClient(client *http.Client) *PostDeployFunctionParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post deploy function params -func (o *PostDeployFunctionParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithFunctions adds the functions to the post deploy function params -func (o *PostDeployFunctionParams) WithFunctions(functions runtime.NamedReadCloser) *PostDeployFunctionParams { - o.SetFunctions(functions) - return o -} - -// SetFunctions adds the functions to the post deploy function params -func (o *PostDeployFunctionParams) SetFunctions(functions runtime.NamedReadCloser) { - o.Functions = functions -} - -// WithName adds the name to the post deploy function params -func (o *PostDeployFunctionParams) WithName(name *string) *PostDeployFunctionParams { - o.SetName(name) - return o -} - -// SetName adds the name to the post deploy function params -func (o *PostDeployFunctionParams) SetName(name *string) { - o.Name = name -} - -// WriteToRequest writes these params to a swagger request -func (o *PostDeployFunctionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - // form file param functions - if err := r.SetFileParam("functions", o.Functions); err != nil { - return err - } - - if o.Name != nil { - - // form param name - var frName string - if o.Name != nil { - frName = *o.Name - } - fName := frName - if fName != "" { - if err := r.SetFormParam("name", fName); err != nil { - return err - } - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/deploy/post_deploy_function_responses.go b/go/client/deploy/post_deploy_function_responses.go deleted file mode 100644 index 3f3bffdf..00000000 --- a/go/client/deploy/post_deploy_function_responses.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package deploy - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostDeployFunctionReader is a Reader for the PostDeployFunction structure. -type PostDeployFunctionReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostDeployFunctionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostDeployFunctionOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostDeployFunctionBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostDeployFunctionUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewPostDeployFunctionNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostDeployFunctionInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostDeployFunctionOK creates a PostDeployFunctionOK with default headers values -func NewPostDeployFunctionOK() *PostDeployFunctionOK { - return &PostDeployFunctionOK{} -} - -/* -PostDeployFunctionOK describes a response with status code 200, with default header values. - -OK -*/ -type PostDeployFunctionOK struct { - Payload *models.ModelsDeployFunctionResponse -} - -// IsSuccess returns true when this post deploy function o k response has a 2xx status code -func (o *PostDeployFunctionOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post deploy function o k response has a 3xx status code -func (o *PostDeployFunctionOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post deploy function o k response has a 4xx status code -func (o *PostDeployFunctionOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post deploy function o k response has a 5xx status code -func (o *PostDeployFunctionOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post deploy function o k response a status code equal to that given -func (o *PostDeployFunctionOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post deploy function o k response -func (o *PostDeployFunctionOK) Code() int { - return 200 -} - -func (o *PostDeployFunctionOK) Error() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionOK %+v", 200, o.Payload) -} - -func (o *PostDeployFunctionOK) String() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionOK %+v", 200, o.Payload) -} - -func (o *PostDeployFunctionOK) GetPayload() *models.ModelsDeployFunctionResponse { - return o.Payload -} - -func (o *PostDeployFunctionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsDeployFunctionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDeployFunctionBadRequest creates a PostDeployFunctionBadRequest with default headers values -func NewPostDeployFunctionBadRequest() *PostDeployFunctionBadRequest { - return &PostDeployFunctionBadRequest{} -} - -/* -PostDeployFunctionBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostDeployFunctionBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post deploy function bad request response has a 2xx status code -func (o *PostDeployFunctionBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post deploy function bad request response has a 3xx status code -func (o *PostDeployFunctionBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post deploy function bad request response has a 4xx status code -func (o *PostDeployFunctionBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post deploy function bad request response has a 5xx status code -func (o *PostDeployFunctionBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post deploy function bad request response a status code equal to that given -func (o *PostDeployFunctionBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post deploy function bad request response -func (o *PostDeployFunctionBadRequest) Code() int { - return 400 -} - -func (o *PostDeployFunctionBadRequest) Error() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *PostDeployFunctionBadRequest) String() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *PostDeployFunctionBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostDeployFunctionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDeployFunctionUnauthorized creates a PostDeployFunctionUnauthorized with default headers values -func NewPostDeployFunctionUnauthorized() *PostDeployFunctionUnauthorized { - return &PostDeployFunctionUnauthorized{} -} - -/* -PostDeployFunctionUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostDeployFunctionUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post deploy function unauthorized response has a 2xx status code -func (o *PostDeployFunctionUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post deploy function unauthorized response has a 3xx status code -func (o *PostDeployFunctionUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post deploy function unauthorized response has a 4xx status code -func (o *PostDeployFunctionUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post deploy function unauthorized response has a 5xx status code -func (o *PostDeployFunctionUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post deploy function unauthorized response a status code equal to that given -func (o *PostDeployFunctionUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post deploy function unauthorized response -func (o *PostDeployFunctionUnauthorized) Code() int { - return 401 -} - -func (o *PostDeployFunctionUnauthorized) Error() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *PostDeployFunctionUnauthorized) String() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *PostDeployFunctionUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostDeployFunctionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDeployFunctionNotFound creates a PostDeployFunctionNotFound with default headers values -func NewPostDeployFunctionNotFound() *PostDeployFunctionNotFound { - return &PostDeployFunctionNotFound{} -} - -/* -PostDeployFunctionNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type PostDeployFunctionNotFound struct { - Payload string -} - -// IsSuccess returns true when this post deploy function not found response has a 2xx status code -func (o *PostDeployFunctionNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post deploy function not found response has a 3xx status code -func (o *PostDeployFunctionNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post deploy function not found response has a 4xx status code -func (o *PostDeployFunctionNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this post deploy function not found response has a 5xx status code -func (o *PostDeployFunctionNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this post deploy function not found response a status code equal to that given -func (o *PostDeployFunctionNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the post deploy function not found response -func (o *PostDeployFunctionNotFound) Code() int { - return 404 -} - -func (o *PostDeployFunctionNotFound) Error() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionNotFound %+v", 404, o.Payload) -} - -func (o *PostDeployFunctionNotFound) String() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionNotFound %+v", 404, o.Payload) -} - -func (o *PostDeployFunctionNotFound) GetPayload() string { - return o.Payload -} - -func (o *PostDeployFunctionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDeployFunctionInternalServerError creates a PostDeployFunctionInternalServerError with default headers values -func NewPostDeployFunctionInternalServerError() *PostDeployFunctionInternalServerError { - return &PostDeployFunctionInternalServerError{} -} - -/* -PostDeployFunctionInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostDeployFunctionInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post deploy function internal server error response has a 2xx status code -func (o *PostDeployFunctionInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post deploy function internal server error response has a 3xx status code -func (o *PostDeployFunctionInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post deploy function internal server error response has a 4xx status code -func (o *PostDeployFunctionInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post deploy function internal server error response has a 5xx status code -func (o *PostDeployFunctionInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post deploy function internal server error response a status code equal to that given -func (o *PostDeployFunctionInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post deploy function internal server error response -func (o *PostDeployFunctionInternalServerError) Code() int { - return 500 -} - -func (o *PostDeployFunctionInternalServerError) Error() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *PostDeployFunctionInternalServerError) String() string { - return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *PostDeployFunctionInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostDeployFunctionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/health/get_health_parameters.go b/go/client/health/get_health_parameters.go deleted file mode 100644 index 31a9377f..00000000 --- a/go/client/health/get_health_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package health - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetHealthParams creates a new GetHealthParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetHealthParams() *GetHealthParams { - return &GetHealthParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetHealthParamsWithTimeout creates a new GetHealthParams object -// with the ability to set a timeout on a request. -func NewGetHealthParamsWithTimeout(timeout time.Duration) *GetHealthParams { - return &GetHealthParams{ - timeout: timeout, - } -} - -// NewGetHealthParamsWithContext creates a new GetHealthParams object -// with the ability to set a context for a request. -func NewGetHealthParamsWithContext(ctx context.Context) *GetHealthParams { - return &GetHealthParams{ - Context: ctx, - } -} - -// NewGetHealthParamsWithHTTPClient creates a new GetHealthParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetHealthParamsWithHTTPClient(client *http.Client) *GetHealthParams { - return &GetHealthParams{ - HTTPClient: client, - } -} - -/* -GetHealthParams contains all the parameters to send to the API endpoint - - for the get health operation. - - Typically these are written to a http.Request. -*/ -type GetHealthParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get health params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetHealthParams) WithDefaults() *GetHealthParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get health params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetHealthParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get health params -func (o *GetHealthParams) WithTimeout(timeout time.Duration) *GetHealthParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get health params -func (o *GetHealthParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get health params -func (o *GetHealthParams) WithContext(ctx context.Context) *GetHealthParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get health params -func (o *GetHealthParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get health params -func (o *GetHealthParams) WithHTTPClient(client *http.Client) *GetHealthParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get health params -func (o *GetHealthParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *GetHealthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/health/get_health_responses.go b/go/client/health/get_health_responses.go deleted file mode 100644 index 0f92c7b6..00000000 --- a/go/client/health/get_health_responses.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package health - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetHealthReader is a Reader for the GetHealth structure. -type GetHealthReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetHealthReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetHealthOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 500: - result := NewGetHealthInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetHealthOK creates a GetHealthOK with default headers values -func NewGetHealthOK() *GetHealthOK { - return &GetHealthOK{} -} - -/* -GetHealthOK describes a response with status code 200, with default header values. - -OK -*/ -type GetHealthOK struct { - Payload *models.ModelsGetHealthResponse -} - -// IsSuccess returns true when this get health o k response has a 2xx status code -func (o *GetHealthOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get health o k response has a 3xx status code -func (o *GetHealthOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get health o k response has a 4xx status code -func (o *GetHealthOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get health o k response has a 5xx status code -func (o *GetHealthOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get health o k response a status code equal to that given -func (o *GetHealthOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get health o k response -func (o *GetHealthOK) Code() int { - return 200 -} - -func (o *GetHealthOK) Error() string { - return fmt.Sprintf("[GET /health][%d] getHealthOK %+v", 200, o.Payload) -} - -func (o *GetHealthOK) String() string { - return fmt.Sprintf("[GET /health][%d] getHealthOK %+v", 200, o.Payload) -} - -func (o *GetHealthOK) GetPayload() *models.ModelsGetHealthResponse { - return o.Payload -} - -func (o *GetHealthOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsGetHealthResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetHealthInternalServerError creates a GetHealthInternalServerError with default headers values -func NewGetHealthInternalServerError() *GetHealthInternalServerError { - return &GetHealthInternalServerError{} -} - -/* -GetHealthInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetHealthInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get health internal server error response has a 2xx status code -func (o *GetHealthInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get health internal server error response has a 3xx status code -func (o *GetHealthInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get health internal server error response has a 4xx status code -func (o *GetHealthInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get health internal server error response has a 5xx status code -func (o *GetHealthInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get health internal server error response a status code equal to that given -func (o *GetHealthInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get health internal server error response -func (o *GetHealthInternalServerError) Code() int { - return 500 -} - -func (o *GetHealthInternalServerError) Error() string { - return fmt.Sprintf("[GET /health][%d] getHealthInternalServerError %+v", 500, o.Payload) -} - -func (o *GetHealthInternalServerError) String() string { - return fmt.Sprintf("[GET /health][%d] getHealthInternalServerError %+v", 500, o.Payload) -} - -func (o *GetHealthInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetHealthInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/health/health_client.go b/go/client/health/health_client.go deleted file mode 100644 index ebcb1740..00000000 --- a/go/client/health/health_client.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package health - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// New creates a new health API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for health API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - GetHealth(params *GetHealthParams, opts ...ClientOption) (*GetHealthOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -GetHealth Returns the health and status of the various services that make up the API. -*/ -func (a *Client) GetHealth(params *GetHealthParams, opts ...ClientOption) (*GetHealthOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetHealthParams() - } - op := &runtime.ClientOperation{ - ID: "GetHealth", - Method: "GET", - PathPattern: "/health", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetHealthReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetHealthOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetHealth: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/go/client/models/models_create_api_key_request.go b/go/client/models/models_create_api_key_request.go deleted file mode 100644 index 3bb0984c..00000000 --- a/go/client/models/models_create_api_key_request.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsCreateAPIKeyRequest models create API key request -// -// swagger:model models.CreateAPIKeyRequest -type ModelsCreateAPIKeyRequest struct { - - // name - Name string `json:"name,omitempty"` -} - -// Validate validates this models create API key request -func (m *ModelsCreateAPIKeyRequest) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models create API key request based on context it is used -func (m *ModelsCreateAPIKeyRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsCreateAPIKeyRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsCreateAPIKeyRequest) UnmarshalBinary(b []byte) error { - var res ModelsCreateAPIKeyRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_create_api_key_response.go b/go/client/models/models_create_api_key_response.go deleted file mode 100644 index 1fd2b2bf..00000000 --- a/go/client/models/models_create_api_key_response.go +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsCreateAPIKeyResponse models create API key response -// -// swagger:model models.CreateAPIKeyResponse -type ModelsCreateAPIKeyResponse struct { - - // apikey - Apikey string `json:"apikey,omitempty"` - - // created at - CreatedAt string `json:"created_at,omitempty"` - - // id - ID string `json:"id,omitempty"` - - // name - Name string `json:"name,omitempty"` - - // organization - Organization string `json:"organization,omitempty"` -} - -// Validate validates this models create API key response -func (m *ModelsCreateAPIKeyResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models create API key response based on context it is used -func (m *ModelsCreateAPIKeyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsCreateAPIKeyResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsCreateAPIKeyResponse) UnmarshalBinary(b []byte) error { - var res ModelsCreateAPIKeyResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_create_domain_request.go b/go/client/models/models_create_domain_request.go deleted file mode 100644 index 6a7f86de..00000000 --- a/go/client/models/models_create_domain_request.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsCreateDomainRequest models create domain request -// -// swagger:model models.CreateDomainRequest -type ModelsCreateDomainRequest struct { - - // domain - Domain string `json:"domain,omitempty"` -} - -// Validate validates this models create domain request -func (m *ModelsCreateDomainRequest) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models create domain request based on context it is used -func (m *ModelsCreateDomainRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsCreateDomainRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsCreateDomainRequest) UnmarshalBinary(b []byte) error { - var res ModelsCreateDomainRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_create_domain_response.go b/go/client/models/models_create_domain_response.go deleted file mode 100644 index 1d745874..00000000 --- a/go/client/models/models_create_domain_response.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsCreateDomainResponse models create domain response -// -// swagger:model models.CreateDomainResponse -type ModelsCreateDomainResponse struct { - - // cname - Cname string `json:"cname,omitempty"` - - // domain - Domain string `json:"domain,omitempty"` - - // txt cname - TxtCname string `json:"txt_cname,omitempty"` -} - -// Validate validates this models create domain response -func (m *ModelsCreateDomainResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models create domain response based on context it is used -func (m *ModelsCreateDomainResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsCreateDomainResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsCreateDomainResponse) UnmarshalBinary(b []byte) error { - var res ModelsCreateDomainResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_create_function_response.go b/go/client/models/models_create_function_response.go deleted file mode 100644 index a734e165..00000000 --- a/go/client/models/models_create_function_response.go +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsCreateFunctionResponse models create function response -// -// swagger:model models.CreateFunctionResponse -type ModelsCreateFunctionResponse struct { - - // hash - Hash string `json:"hash,omitempty"` - - // name - Name string `json:"name,omitempty"` - - // organization - Organization string `json:"organization,omitempty"` - - // public - Public bool `json:"public,omitempty"` - - // tag - Tag string `json:"tag,omitempty"` -} - -// Validate validates this models create function response -func (m *ModelsCreateFunctionResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models create function response based on context it is used -func (m *ModelsCreateFunctionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsCreateFunctionResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsCreateFunctionResponse) UnmarshalBinary(b []byte) error { - var res ModelsCreateFunctionResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_deploy_function_response.go b/go/client/models/models_deploy_function_response.go deleted file mode 100644 index c4baa47f..00000000 --- a/go/client/models/models_deploy_function_response.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsDeployFunctionResponse models deploy function response -// -// swagger:model models.DeployFunctionResponse -type ModelsDeployFunctionResponse struct { - - // identifier - Identifier string `json:"identifier,omitempty"` - - // root domain - RootDomain string `json:"root_domain,omitempty"` - - // subdomain - Subdomain string `json:"subdomain,omitempty"` -} - -// Validate validates this models deploy function response -func (m *ModelsDeployFunctionResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models deploy function response based on context it is used -func (m *ModelsDeployFunctionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsDeployFunctionResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsDeployFunctionResponse) UnmarshalBinary(b []byte) error { - var res ModelsDeployFunctionResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_get_api_key_response.go b/go/client/models/models_get_api_key_response.go deleted file mode 100644 index b62ed8c0..00000000 --- a/go/client/models/models_get_api_key_response.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsGetAPIKeyResponse models get API key response -// -// swagger:model models.GetAPIKeyResponse -type ModelsGetAPIKeyResponse struct { - - // created at - CreatedAt string `json:"created_at,omitempty"` - - // id - ID string `json:"id,omitempty"` - - // name - Name string `json:"name,omitempty"` - - // organization - Organization string `json:"organization,omitempty"` -} - -// Validate validates this models get API key response -func (m *ModelsGetAPIKeyResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models get API key response based on context it is used -func (m *ModelsGetAPIKeyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsGetAPIKeyResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsGetAPIKeyResponse) UnmarshalBinary(b []byte) error { - var res ModelsGetAPIKeyResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_get_function_response.go b/go/client/models/models_get_function_response.go deleted file mode 100644 index a6d58cad..00000000 --- a/go/client/models/models_get_function_response.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsGetFunctionResponse models get function response -// -// swagger:model models.GetFunctionResponse -type ModelsGetFunctionResponse struct { - - // hash - Hash string `json:"hash,omitempty"` - - // name - Name string `json:"name,omitempty"` - - // organization - Organization string `json:"organization,omitempty"` - - // presigned url - PresignedURL string `json:"presigned_url,omitempty"` - - // public - Public bool `json:"public,omitempty"` - - // tag - Tag string `json:"tag,omitempty"` -} - -// Validate validates this models get function response -func (m *ModelsGetFunctionResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models get function response based on context it is used -func (m *ModelsGetFunctionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsGetFunctionResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsGetFunctionResponse) UnmarshalBinary(b []byte) error { - var res ModelsGetFunctionResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_get_health_response.go b/go/client/models/models_get_health_response.go deleted file mode 100644 index 42e5ff75..00000000 --- a/go/client/models/models_get_health_response.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsGetHealthResponse models get health response -// -// swagger:model models.GetHealthResponse -type ModelsGetHealthResponse struct { - - // database - Database bool `json:"database,omitempty"` -} - -// Validate validates this models get health response -func (m *ModelsGetHealthResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models get health response based on context it is used -func (m *ModelsGetHealthResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsGetHealthResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsGetHealthResponse) UnmarshalBinary(b []byte) error { - var res ModelsGetHealthResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/models/models_user_info_response.go b/go/client/models/models_user_info_response.go deleted file mode 100644 index 4df87582..00000000 --- a/go/client/models/models_user_info_response.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ModelsUserInfoResponse models user info response -// -// swagger:model models.UserInfoResponse -type ModelsUserInfoResponse struct { - - // email - Email string `json:"email,omitempty"` - - // member organizations - MemberOrganizations []string `json:"member_organizations"` - - // organization - Organization string `json:"organization,omitempty"` - - // owned organizations - OwnedOrganizations []string `json:"owned_organizations"` -} - -// Validate validates this models user info response -func (m *ModelsUserInfoResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this models user info response based on context it is used -func (m *ModelsUserInfoResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ModelsUserInfoResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ModelsUserInfoResponse) UnmarshalBinary(b []byte) error { - var res ModelsUserInfoResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/client/registry/delete_registry_function_organization_name_tag_parameters.go b/go/client/registry/delete_registry_function_organization_name_tag_parameters.go deleted file mode 100644 index 9b19bc4e..00000000 --- a/go/client/registry/delete_registry_function_organization_name_tag_parameters.go +++ /dev/null @@ -1,195 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewDeleteRegistryFunctionOrganizationNameTagParams creates a new DeleteRegistryFunctionOrganizationNameTagParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewDeleteRegistryFunctionOrganizationNameTagParams() *DeleteRegistryFunctionOrganizationNameTagParams { - return &DeleteRegistryFunctionOrganizationNameTagParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewDeleteRegistryFunctionOrganizationNameTagParamsWithTimeout creates a new DeleteRegistryFunctionOrganizationNameTagParams object -// with the ability to set a timeout on a request. -func NewDeleteRegistryFunctionOrganizationNameTagParamsWithTimeout(timeout time.Duration) *DeleteRegistryFunctionOrganizationNameTagParams { - return &DeleteRegistryFunctionOrganizationNameTagParams{ - timeout: timeout, - } -} - -// NewDeleteRegistryFunctionOrganizationNameTagParamsWithContext creates a new DeleteRegistryFunctionOrganizationNameTagParams object -// with the ability to set a context for a request. -func NewDeleteRegistryFunctionOrganizationNameTagParamsWithContext(ctx context.Context) *DeleteRegistryFunctionOrganizationNameTagParams { - return &DeleteRegistryFunctionOrganizationNameTagParams{ - Context: ctx, - } -} - -// NewDeleteRegistryFunctionOrganizationNameTagParamsWithHTTPClient creates a new DeleteRegistryFunctionOrganizationNameTagParams object -// with the ability to set a custom HTTPClient for a request. -func NewDeleteRegistryFunctionOrganizationNameTagParamsWithHTTPClient(client *http.Client) *DeleteRegistryFunctionOrganizationNameTagParams { - return &DeleteRegistryFunctionOrganizationNameTagParams{ - HTTPClient: client, - } -} - -/* -DeleteRegistryFunctionOrganizationNameTagParams contains all the parameters to send to the API endpoint - - for the delete registry function organization name tag operation. - - Typically these are written to a http.Request. -*/ -type DeleteRegistryFunctionOrganizationNameTagParams struct { - - /* Name. - - name - */ - Name string - - /* Organization. - - organization - */ - Organization string - - /* Tag. - - tag - */ - Tag string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the delete registry function organization name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithDefaults() *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the delete registry function organization name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithTimeout(timeout time.Duration) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithContext(ctx context.Context) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithHTTPClient(client *http.Client) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithName adds the name to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithName(name string) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetName(name) - return o -} - -// SetName adds the name to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetName(name string) { - o.Name = name -} - -// WithOrganization adds the organization to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithOrganization(organization string) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetOrganization(organization) - return o -} - -// SetOrganization adds the organization to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetOrganization(organization string) { - o.Organization = organization -} - -// WithTag adds the tag to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WithTag(tag string) *DeleteRegistryFunctionOrganizationNameTagParams { - o.SetTag(tag) - return o -} - -// SetTag adds the tag to the delete registry function organization name tag params -func (o *DeleteRegistryFunctionOrganizationNameTagParams) SetTag(tag string) { - o.Tag = tag -} - -// WriteToRequest writes these params to a swagger request -func (o *DeleteRegistryFunctionOrganizationNameTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param name - if err := r.SetPathParam("name", o.Name); err != nil { - return err - } - - // path param organization - if err := r.SetPathParam("organization", o.Organization); err != nil { - return err - } - - // path param tag - if err := r.SetPathParam("tag", o.Tag); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/delete_registry_function_organization_name_tag_responses.go b/go/client/registry/delete_registry_function_organization_name_tag_responses.go deleted file mode 100644 index 9ab4cd5d..00000000 --- a/go/client/registry/delete_registry_function_organization_name_tag_responses.go +++ /dev/null @@ -1,387 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// DeleteRegistryFunctionOrganizationNameTagReader is a Reader for the DeleteRegistryFunctionOrganizationNameTag structure. -type DeleteRegistryFunctionOrganizationNameTagReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *DeleteRegistryFunctionOrganizationNameTagReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewDeleteRegistryFunctionOrganizationNameTagOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewDeleteRegistryFunctionOrganizationNameTagBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewDeleteRegistryFunctionOrganizationNameTagUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewDeleteRegistryFunctionOrganizationNameTagNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewDeleteRegistryFunctionOrganizationNameTagInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewDeleteRegistryFunctionOrganizationNameTagOK creates a DeleteRegistryFunctionOrganizationNameTagOK with default headers values -func NewDeleteRegistryFunctionOrganizationNameTagOK() *DeleteRegistryFunctionOrganizationNameTagOK { - return &DeleteRegistryFunctionOrganizationNameTagOK{} -} - -/* -DeleteRegistryFunctionOrganizationNameTagOK describes a response with status code 200, with default header values. - -OK -*/ -type DeleteRegistryFunctionOrganizationNameTagOK struct { - Payload string -} - -// IsSuccess returns true when this delete registry function organization name tag o k response has a 2xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this delete registry function organization name tag o k response has a 3xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete registry function organization name tag o k response has a 4xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete registry function organization name tag o k response has a 5xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagOK) IsServerError() bool { - return false -} - -// IsCode returns true when this delete registry function organization name tag o k response a status code equal to that given -func (o *DeleteRegistryFunctionOrganizationNameTagOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the delete registry function organization name tag o k response -func (o *DeleteRegistryFunctionOrganizationNameTagOK) Code() int { - return 200 -} - -func (o *DeleteRegistryFunctionOrganizationNameTagOK) Error() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagOK %+v", 200, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagOK) String() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagOK %+v", 200, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagOK) GetPayload() string { - return o.Payload -} - -func (o *DeleteRegistryFunctionOrganizationNameTagOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteRegistryFunctionOrganizationNameTagBadRequest creates a DeleteRegistryFunctionOrganizationNameTagBadRequest with default headers values -func NewDeleteRegistryFunctionOrganizationNameTagBadRequest() *DeleteRegistryFunctionOrganizationNameTagBadRequest { - return &DeleteRegistryFunctionOrganizationNameTagBadRequest{} -} - -/* -DeleteRegistryFunctionOrganizationNameTagBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type DeleteRegistryFunctionOrganizationNameTagBadRequest struct { - Payload string -} - -// IsSuccess returns true when this delete registry function organization name tag bad request response has a 2xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete registry function organization name tag bad request response has a 3xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete registry function organization name tag bad request response has a 4xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete registry function organization name tag bad request response has a 5xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this delete registry function organization name tag bad request response a status code equal to that given -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the delete registry function organization name tag bad request response -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) Code() int { - return 400 -} - -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) Error() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) String() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) GetPayload() string { - return o.Payload -} - -func (o *DeleteRegistryFunctionOrganizationNameTagBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteRegistryFunctionOrganizationNameTagUnauthorized creates a DeleteRegistryFunctionOrganizationNameTagUnauthorized with default headers values -func NewDeleteRegistryFunctionOrganizationNameTagUnauthorized() *DeleteRegistryFunctionOrganizationNameTagUnauthorized { - return &DeleteRegistryFunctionOrganizationNameTagUnauthorized{} -} - -/* -DeleteRegistryFunctionOrganizationNameTagUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type DeleteRegistryFunctionOrganizationNameTagUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this delete registry function organization name tag unauthorized response has a 2xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete registry function organization name tag unauthorized response has a 3xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete registry function organization name tag unauthorized response has a 4xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete registry function organization name tag unauthorized response has a 5xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this delete registry function organization name tag unauthorized response a status code equal to that given -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the delete registry function organization name tag unauthorized response -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) Code() int { - return 401 -} - -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) Error() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) String() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *DeleteRegistryFunctionOrganizationNameTagUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteRegistryFunctionOrganizationNameTagNotFound creates a DeleteRegistryFunctionOrganizationNameTagNotFound with default headers values -func NewDeleteRegistryFunctionOrganizationNameTagNotFound() *DeleteRegistryFunctionOrganizationNameTagNotFound { - return &DeleteRegistryFunctionOrganizationNameTagNotFound{} -} - -/* -DeleteRegistryFunctionOrganizationNameTagNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type DeleteRegistryFunctionOrganizationNameTagNotFound struct { - Payload string -} - -// IsSuccess returns true when this delete registry function organization name tag not found response has a 2xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete registry function organization name tag not found response has a 3xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete registry function organization name tag not found response has a 4xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this delete registry function organization name tag not found response has a 5xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this delete registry function organization name tag not found response a status code equal to that given -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the delete registry function organization name tag not found response -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) Code() int { - return 404 -} - -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) Error() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagNotFound %+v", 404, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) String() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagNotFound %+v", 404, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) GetPayload() string { - return o.Payload -} - -func (o *DeleteRegistryFunctionOrganizationNameTagNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewDeleteRegistryFunctionOrganizationNameTagInternalServerError creates a DeleteRegistryFunctionOrganizationNameTagInternalServerError with default headers values -func NewDeleteRegistryFunctionOrganizationNameTagInternalServerError() *DeleteRegistryFunctionOrganizationNameTagInternalServerError { - return &DeleteRegistryFunctionOrganizationNameTagInternalServerError{} -} - -/* -DeleteRegistryFunctionOrganizationNameTagInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type DeleteRegistryFunctionOrganizationNameTagInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this delete registry function organization name tag internal server error response has a 2xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this delete registry function organization name tag internal server error response has a 3xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this delete registry function organization name tag internal server error response has a 4xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this delete registry function organization name tag internal server error response has a 5xx status code -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this delete registry function organization name tag internal server error response a status code equal to that given -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the delete registry function organization name tag internal server error response -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) Code() int { - return 500 -} - -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) String() string { - return fmt.Sprintf("[DELETE /registry/function/{organization}/{name}/{tag}][%d] deleteRegistryFunctionOrganizationNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *DeleteRegistryFunctionOrganizationNameTagInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/get_registry_function_name_tag_parameters.go b/go/client/registry/get_registry_function_name_tag_parameters.go deleted file mode 100644 index 80a6a9ea..00000000 --- a/go/client/registry/get_registry_function_name_tag_parameters.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetRegistryFunctionNameTagParams creates a new GetRegistryFunctionNameTagParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetRegistryFunctionNameTagParams() *GetRegistryFunctionNameTagParams { - return &GetRegistryFunctionNameTagParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetRegistryFunctionNameTagParamsWithTimeout creates a new GetRegistryFunctionNameTagParams object -// with the ability to set a timeout on a request. -func NewGetRegistryFunctionNameTagParamsWithTimeout(timeout time.Duration) *GetRegistryFunctionNameTagParams { - return &GetRegistryFunctionNameTagParams{ - timeout: timeout, - } -} - -// NewGetRegistryFunctionNameTagParamsWithContext creates a new GetRegistryFunctionNameTagParams object -// with the ability to set a context for a request. -func NewGetRegistryFunctionNameTagParamsWithContext(ctx context.Context) *GetRegistryFunctionNameTagParams { - return &GetRegistryFunctionNameTagParams{ - Context: ctx, - } -} - -// NewGetRegistryFunctionNameTagParamsWithHTTPClient creates a new GetRegistryFunctionNameTagParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetRegistryFunctionNameTagParamsWithHTTPClient(client *http.Client) *GetRegistryFunctionNameTagParams { - return &GetRegistryFunctionNameTagParams{ - HTTPClient: client, - } -} - -/* -GetRegistryFunctionNameTagParams contains all the parameters to send to the API endpoint - - for the get registry function name tag operation. - - Typically these are written to a http.Request. -*/ -type GetRegistryFunctionNameTagParams struct { - - /* Name. - - name - */ - Name string - - /* Tag. - - tag - */ - Tag string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get registry function name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionNameTagParams) WithDefaults() *GetRegistryFunctionNameTagParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get registry function name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionNameTagParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) WithTimeout(timeout time.Duration) *GetRegistryFunctionNameTagParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) WithContext(ctx context.Context) *GetRegistryFunctionNameTagParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) WithHTTPClient(client *http.Client) *GetRegistryFunctionNameTagParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithName adds the name to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) WithName(name string) *GetRegistryFunctionNameTagParams { - o.SetName(name) - return o -} - -// SetName adds the name to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) SetName(name string) { - o.Name = name -} - -// WithTag adds the tag to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) WithTag(tag string) *GetRegistryFunctionNameTagParams { - o.SetTag(tag) - return o -} - -// SetTag adds the tag to the get registry function name tag params -func (o *GetRegistryFunctionNameTagParams) SetTag(tag string) { - o.Tag = tag -} - -// WriteToRequest writes these params to a swagger request -func (o *GetRegistryFunctionNameTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param name - if err := r.SetPathParam("name", o.Name); err != nil { - return err - } - - // path param tag - if err := r.SetPathParam("tag", o.Tag); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/get_registry_function_name_tag_responses.go b/go/client/registry/get_registry_function_name_tag_responses.go deleted file mode 100644 index 69d2629d..00000000 --- a/go/client/registry/get_registry_function_name_tag_responses.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetRegistryFunctionNameTagReader is a Reader for the GetRegistryFunctionNameTag structure. -type GetRegistryFunctionNameTagReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetRegistryFunctionNameTagReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetRegistryFunctionNameTagOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewGetRegistryFunctionNameTagBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewGetRegistryFunctionNameTagUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetRegistryFunctionNameTagNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetRegistryFunctionNameTagInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetRegistryFunctionNameTagOK creates a GetRegistryFunctionNameTagOK with default headers values -func NewGetRegistryFunctionNameTagOK() *GetRegistryFunctionNameTagOK { - return &GetRegistryFunctionNameTagOK{} -} - -/* -GetRegistryFunctionNameTagOK describes a response with status code 200, with default header values. - -OK -*/ -type GetRegistryFunctionNameTagOK struct { - Payload *models.ModelsGetFunctionResponse -} - -// IsSuccess returns true when this get registry function name tag o k response has a 2xx status code -func (o *GetRegistryFunctionNameTagOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get registry function name tag o k response has a 3xx status code -func (o *GetRegistryFunctionNameTagOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function name tag o k response has a 4xx status code -func (o *GetRegistryFunctionNameTagOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function name tag o k response has a 5xx status code -func (o *GetRegistryFunctionNameTagOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function name tag o k response a status code equal to that given -func (o *GetRegistryFunctionNameTagOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get registry function name tag o k response -func (o *GetRegistryFunctionNameTagOK) Code() int { - return 200 -} - -func (o *GetRegistryFunctionNameTagOK) Error() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionNameTagOK) String() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionNameTagOK) GetPayload() *models.ModelsGetFunctionResponse { - return o.Payload -} - -func (o *GetRegistryFunctionNameTagOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsGetFunctionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionNameTagBadRequest creates a GetRegistryFunctionNameTagBadRequest with default headers values -func NewGetRegistryFunctionNameTagBadRequest() *GetRegistryFunctionNameTagBadRequest { - return &GetRegistryFunctionNameTagBadRequest{} -} - -/* -GetRegistryFunctionNameTagBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type GetRegistryFunctionNameTagBadRequest struct { - Payload string -} - -// IsSuccess returns true when this get registry function name tag bad request response has a 2xx status code -func (o *GetRegistryFunctionNameTagBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function name tag bad request response has a 3xx status code -func (o *GetRegistryFunctionNameTagBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function name tag bad request response has a 4xx status code -func (o *GetRegistryFunctionNameTagBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function name tag bad request response has a 5xx status code -func (o *GetRegistryFunctionNameTagBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function name tag bad request response a status code equal to that given -func (o *GetRegistryFunctionNameTagBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the get registry function name tag bad request response -func (o *GetRegistryFunctionNameTagBadRequest) Code() int { - return 400 -} - -func (o *GetRegistryFunctionNameTagBadRequest) Error() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionNameTagBadRequest) String() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionNameTagBadRequest) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionNameTagBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionNameTagUnauthorized creates a GetRegistryFunctionNameTagUnauthorized with default headers values -func NewGetRegistryFunctionNameTagUnauthorized() *GetRegistryFunctionNameTagUnauthorized { - return &GetRegistryFunctionNameTagUnauthorized{} -} - -/* -GetRegistryFunctionNameTagUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetRegistryFunctionNameTagUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get registry function name tag unauthorized response has a 2xx status code -func (o *GetRegistryFunctionNameTagUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function name tag unauthorized response has a 3xx status code -func (o *GetRegistryFunctionNameTagUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function name tag unauthorized response has a 4xx status code -func (o *GetRegistryFunctionNameTagUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function name tag unauthorized response has a 5xx status code -func (o *GetRegistryFunctionNameTagUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function name tag unauthorized response a status code equal to that given -func (o *GetRegistryFunctionNameTagUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get registry function name tag unauthorized response -func (o *GetRegistryFunctionNameTagUnauthorized) Code() int { - return 401 -} - -func (o *GetRegistryFunctionNameTagUnauthorized) Error() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionNameTagUnauthorized) String() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionNameTagUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionNameTagUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionNameTagNotFound creates a GetRegistryFunctionNameTagNotFound with default headers values -func NewGetRegistryFunctionNameTagNotFound() *GetRegistryFunctionNameTagNotFound { - return &GetRegistryFunctionNameTagNotFound{} -} - -/* -GetRegistryFunctionNameTagNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetRegistryFunctionNameTagNotFound struct { - Payload string -} - -// IsSuccess returns true when this get registry function name tag not found response has a 2xx status code -func (o *GetRegistryFunctionNameTagNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function name tag not found response has a 3xx status code -func (o *GetRegistryFunctionNameTagNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function name tag not found response has a 4xx status code -func (o *GetRegistryFunctionNameTagNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function name tag not found response has a 5xx status code -func (o *GetRegistryFunctionNameTagNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function name tag not found response a status code equal to that given -func (o *GetRegistryFunctionNameTagNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get registry function name tag not found response -func (o *GetRegistryFunctionNameTagNotFound) Code() int { - return 404 -} - -func (o *GetRegistryFunctionNameTagNotFound) Error() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionNameTagNotFound) String() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionNameTagNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionNameTagNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionNameTagInternalServerError creates a GetRegistryFunctionNameTagInternalServerError with default headers values -func NewGetRegistryFunctionNameTagInternalServerError() *GetRegistryFunctionNameTagInternalServerError { - return &GetRegistryFunctionNameTagInternalServerError{} -} - -/* -GetRegistryFunctionNameTagInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetRegistryFunctionNameTagInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get registry function name tag internal server error response has a 2xx status code -func (o *GetRegistryFunctionNameTagInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function name tag internal server error response has a 3xx status code -func (o *GetRegistryFunctionNameTagInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function name tag internal server error response has a 4xx status code -func (o *GetRegistryFunctionNameTagInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function name tag internal server error response has a 5xx status code -func (o *GetRegistryFunctionNameTagInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get registry function name tag internal server error response a status code equal to that given -func (o *GetRegistryFunctionNameTagInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get registry function name tag internal server error response -func (o *GetRegistryFunctionNameTagInternalServerError) Code() int { - return 500 -} - -func (o *GetRegistryFunctionNameTagInternalServerError) Error() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionNameTagInternalServerError) String() string { - return fmt.Sprintf("[GET /registry/function/{name}/{tag}][%d] getRegistryFunctionNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionNameTagInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionNameTagInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/get_registry_function_organization_name_tag_parameters.go b/go/client/registry/get_registry_function_organization_name_tag_parameters.go deleted file mode 100644 index 9047d0c4..00000000 --- a/go/client/registry/get_registry_function_organization_name_tag_parameters.go +++ /dev/null @@ -1,195 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetRegistryFunctionOrganizationNameTagParams creates a new GetRegistryFunctionOrganizationNameTagParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetRegistryFunctionOrganizationNameTagParams() *GetRegistryFunctionOrganizationNameTagParams { - return &GetRegistryFunctionOrganizationNameTagParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetRegistryFunctionOrganizationNameTagParamsWithTimeout creates a new GetRegistryFunctionOrganizationNameTagParams object -// with the ability to set a timeout on a request. -func NewGetRegistryFunctionOrganizationNameTagParamsWithTimeout(timeout time.Duration) *GetRegistryFunctionOrganizationNameTagParams { - return &GetRegistryFunctionOrganizationNameTagParams{ - timeout: timeout, - } -} - -// NewGetRegistryFunctionOrganizationNameTagParamsWithContext creates a new GetRegistryFunctionOrganizationNameTagParams object -// with the ability to set a context for a request. -func NewGetRegistryFunctionOrganizationNameTagParamsWithContext(ctx context.Context) *GetRegistryFunctionOrganizationNameTagParams { - return &GetRegistryFunctionOrganizationNameTagParams{ - Context: ctx, - } -} - -// NewGetRegistryFunctionOrganizationNameTagParamsWithHTTPClient creates a new GetRegistryFunctionOrganizationNameTagParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetRegistryFunctionOrganizationNameTagParamsWithHTTPClient(client *http.Client) *GetRegistryFunctionOrganizationNameTagParams { - return &GetRegistryFunctionOrganizationNameTagParams{ - HTTPClient: client, - } -} - -/* -GetRegistryFunctionOrganizationNameTagParams contains all the parameters to send to the API endpoint - - for the get registry function organization name tag operation. - - Typically these are written to a http.Request. -*/ -type GetRegistryFunctionOrganizationNameTagParams struct { - - /* Name. - - name - */ - Name string - - /* Organization. - - organization - */ - Organization string - - /* Tag. - - tag - */ - Tag string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get registry function organization name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionOrganizationNameTagParams) WithDefaults() *GetRegistryFunctionOrganizationNameTagParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get registry function organization name tag params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionOrganizationNameTagParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithTimeout(timeout time.Duration) *GetRegistryFunctionOrganizationNameTagParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithContext(ctx context.Context) *GetRegistryFunctionOrganizationNameTagParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithHTTPClient(client *http.Client) *GetRegistryFunctionOrganizationNameTagParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithName adds the name to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithName(name string) *GetRegistryFunctionOrganizationNameTagParams { - o.SetName(name) - return o -} - -// SetName adds the name to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetName(name string) { - o.Name = name -} - -// WithOrganization adds the organization to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithOrganization(organization string) *GetRegistryFunctionOrganizationNameTagParams { - o.SetOrganization(organization) - return o -} - -// SetOrganization adds the organization to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetOrganization(organization string) { - o.Organization = organization -} - -// WithTag adds the tag to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) WithTag(tag string) *GetRegistryFunctionOrganizationNameTagParams { - o.SetTag(tag) - return o -} - -// SetTag adds the tag to the get registry function organization name tag params -func (o *GetRegistryFunctionOrganizationNameTagParams) SetTag(tag string) { - o.Tag = tag -} - -// WriteToRequest writes these params to a swagger request -func (o *GetRegistryFunctionOrganizationNameTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param name - if err := r.SetPathParam("name", o.Name); err != nil { - return err - } - - // path param organization - if err := r.SetPathParam("organization", o.Organization); err != nil { - return err - } - - // path param tag - if err := r.SetPathParam("tag", o.Tag); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/get_registry_function_organization_name_tag_responses.go b/go/client/registry/get_registry_function_organization_name_tag_responses.go deleted file mode 100644 index db0849b1..00000000 --- a/go/client/registry/get_registry_function_organization_name_tag_responses.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetRegistryFunctionOrganizationNameTagReader is a Reader for the GetRegistryFunctionOrganizationNameTag structure. -type GetRegistryFunctionOrganizationNameTagReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetRegistryFunctionOrganizationNameTagReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetRegistryFunctionOrganizationNameTagOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewGetRegistryFunctionOrganizationNameTagBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewGetRegistryFunctionOrganizationNameTagUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetRegistryFunctionOrganizationNameTagNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetRegistryFunctionOrganizationNameTagInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetRegistryFunctionOrganizationNameTagOK creates a GetRegistryFunctionOrganizationNameTagOK with default headers values -func NewGetRegistryFunctionOrganizationNameTagOK() *GetRegistryFunctionOrganizationNameTagOK { - return &GetRegistryFunctionOrganizationNameTagOK{} -} - -/* -GetRegistryFunctionOrganizationNameTagOK describes a response with status code 200, with default header values. - -OK -*/ -type GetRegistryFunctionOrganizationNameTagOK struct { - Payload *models.ModelsGetFunctionResponse -} - -// IsSuccess returns true when this get registry function organization name tag o k response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNameTagOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get registry function organization name tag o k response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNameTagOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization name tag o k response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNameTagOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function organization name tag o k response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNameTagOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization name tag o k response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNameTagOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get registry function organization name tag o k response -func (o *GetRegistryFunctionOrganizationNameTagOK) Code() int { - return 200 -} - -func (o *GetRegistryFunctionOrganizationNameTagOK) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagOK) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagOK) GetPayload() *models.ModelsGetFunctionResponse { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNameTagOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsGetFunctionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationNameTagBadRequest creates a GetRegistryFunctionOrganizationNameTagBadRequest with default headers values -func NewGetRegistryFunctionOrganizationNameTagBadRequest() *GetRegistryFunctionOrganizationNameTagBadRequest { - return &GetRegistryFunctionOrganizationNameTagBadRequest{} -} - -/* -GetRegistryFunctionOrganizationNameTagBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type GetRegistryFunctionOrganizationNameTagBadRequest struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization name tag bad request response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization name tag bad request response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization name tag bad request response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization name tag bad request response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization name tag bad request response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the get registry function organization name tag bad request response -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) Code() int { - return 400 -} - -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNameTagBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationNameTagUnauthorized creates a GetRegistryFunctionOrganizationNameTagUnauthorized with default headers values -func NewGetRegistryFunctionOrganizationNameTagUnauthorized() *GetRegistryFunctionOrganizationNameTagUnauthorized { - return &GetRegistryFunctionOrganizationNameTagUnauthorized{} -} - -/* -GetRegistryFunctionOrganizationNameTagUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetRegistryFunctionOrganizationNameTagUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization name tag unauthorized response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization name tag unauthorized response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization name tag unauthorized response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization name tag unauthorized response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization name tag unauthorized response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get registry function organization name tag unauthorized response -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) Code() int { - return 401 -} - -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNameTagUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationNameTagNotFound creates a GetRegistryFunctionOrganizationNameTagNotFound with default headers values -func NewGetRegistryFunctionOrganizationNameTagNotFound() *GetRegistryFunctionOrganizationNameTagNotFound { - return &GetRegistryFunctionOrganizationNameTagNotFound{} -} - -/* -GetRegistryFunctionOrganizationNameTagNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetRegistryFunctionOrganizationNameTagNotFound struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization name tag not found response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNameTagNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization name tag not found response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNameTagNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization name tag not found response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNameTagNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization name tag not found response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNameTagNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization name tag not found response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNameTagNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get registry function organization name tag not found response -func (o *GetRegistryFunctionOrganizationNameTagNotFound) Code() int { - return 404 -} - -func (o *GetRegistryFunctionOrganizationNameTagNotFound) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagNotFound) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNameTagNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationNameTagInternalServerError creates a GetRegistryFunctionOrganizationNameTagInternalServerError with default headers values -func NewGetRegistryFunctionOrganizationNameTagInternalServerError() *GetRegistryFunctionOrganizationNameTagInternalServerError { - return &GetRegistryFunctionOrganizationNameTagInternalServerError{} -} - -/* -GetRegistryFunctionOrganizationNameTagInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetRegistryFunctionOrganizationNameTagInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization name tag internal server error response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization name tag internal server error response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization name tag internal server error response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function organization name tag internal server error response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get registry function organization name tag internal server error response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get registry function organization name tag internal server error response -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) Code() int { - return 500 -} - -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}/{name}/{tag}][%d] getRegistryFunctionOrganizationNameTagInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNameTagInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/get_registry_function_organization_parameters.go b/go/client/registry/get_registry_function_organization_parameters.go deleted file mode 100644 index 3ec90764..00000000 --- a/go/client/registry/get_registry_function_organization_parameters.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetRegistryFunctionOrganizationParams creates a new GetRegistryFunctionOrganizationParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetRegistryFunctionOrganizationParams() *GetRegistryFunctionOrganizationParams { - return &GetRegistryFunctionOrganizationParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetRegistryFunctionOrganizationParamsWithTimeout creates a new GetRegistryFunctionOrganizationParams object -// with the ability to set a timeout on a request. -func NewGetRegistryFunctionOrganizationParamsWithTimeout(timeout time.Duration) *GetRegistryFunctionOrganizationParams { - return &GetRegistryFunctionOrganizationParams{ - timeout: timeout, - } -} - -// NewGetRegistryFunctionOrganizationParamsWithContext creates a new GetRegistryFunctionOrganizationParams object -// with the ability to set a context for a request. -func NewGetRegistryFunctionOrganizationParamsWithContext(ctx context.Context) *GetRegistryFunctionOrganizationParams { - return &GetRegistryFunctionOrganizationParams{ - Context: ctx, - } -} - -// NewGetRegistryFunctionOrganizationParamsWithHTTPClient creates a new GetRegistryFunctionOrganizationParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetRegistryFunctionOrganizationParamsWithHTTPClient(client *http.Client) *GetRegistryFunctionOrganizationParams { - return &GetRegistryFunctionOrganizationParams{ - HTTPClient: client, - } -} - -/* -GetRegistryFunctionOrganizationParams contains all the parameters to send to the API endpoint - - for the get registry function organization operation. - - Typically these are written to a http.Request. -*/ -type GetRegistryFunctionOrganizationParams struct { - - /* Organization. - - organization - */ - Organization string - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get registry function organization params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionOrganizationParams) WithDefaults() *GetRegistryFunctionOrganizationParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get registry function organization params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionOrganizationParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) WithTimeout(timeout time.Duration) *GetRegistryFunctionOrganizationParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) WithContext(ctx context.Context) *GetRegistryFunctionOrganizationParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) WithHTTPClient(client *http.Client) *GetRegistryFunctionOrganizationParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithOrganization adds the organization to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) WithOrganization(organization string) *GetRegistryFunctionOrganizationParams { - o.SetOrganization(organization) - return o -} - -// SetOrganization adds the organization to the get registry function organization params -func (o *GetRegistryFunctionOrganizationParams) SetOrganization(organization string) { - o.Organization = organization -} - -// WriteToRequest writes these params to a swagger request -func (o *GetRegistryFunctionOrganizationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - // path param organization - if err := r.SetPathParam("organization", o.Organization); err != nil { - return err - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/get_registry_function_organization_responses.go b/go/client/registry/get_registry_function_organization_responses.go deleted file mode 100644 index 88900e85..00000000 --- a/go/client/registry/get_registry_function_organization_responses.go +++ /dev/null @@ -1,389 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetRegistryFunctionOrganizationReader is a Reader for the GetRegistryFunctionOrganization structure. -type GetRegistryFunctionOrganizationReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetRegistryFunctionOrganizationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetRegistryFunctionOrganizationOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewGetRegistryFunctionOrganizationBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewGetRegistryFunctionOrganizationUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetRegistryFunctionOrganizationNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetRegistryFunctionOrganizationInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetRegistryFunctionOrganizationOK creates a GetRegistryFunctionOrganizationOK with default headers values -func NewGetRegistryFunctionOrganizationOK() *GetRegistryFunctionOrganizationOK { - return &GetRegistryFunctionOrganizationOK{} -} - -/* -GetRegistryFunctionOrganizationOK describes a response with status code 200, with default header values. - -OK -*/ -type GetRegistryFunctionOrganizationOK struct { - Payload []*models.ModelsGetFunctionResponse -} - -// IsSuccess returns true when this get registry function organization o k response has a 2xx status code -func (o *GetRegistryFunctionOrganizationOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get registry function organization o k response has a 3xx status code -func (o *GetRegistryFunctionOrganizationOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization o k response has a 4xx status code -func (o *GetRegistryFunctionOrganizationOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function organization o k response has a 5xx status code -func (o *GetRegistryFunctionOrganizationOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization o k response a status code equal to that given -func (o *GetRegistryFunctionOrganizationOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get registry function organization o k response -func (o *GetRegistryFunctionOrganizationOK) Code() int { - return 200 -} - -func (o *GetRegistryFunctionOrganizationOK) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationOK) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationOK) GetPayload() []*models.ModelsGetFunctionResponse { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationBadRequest creates a GetRegistryFunctionOrganizationBadRequest with default headers values -func NewGetRegistryFunctionOrganizationBadRequest() *GetRegistryFunctionOrganizationBadRequest { - return &GetRegistryFunctionOrganizationBadRequest{} -} - -/* -GetRegistryFunctionOrganizationBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type GetRegistryFunctionOrganizationBadRequest struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization bad request response has a 2xx status code -func (o *GetRegistryFunctionOrganizationBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization bad request response has a 3xx status code -func (o *GetRegistryFunctionOrganizationBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization bad request response has a 4xx status code -func (o *GetRegistryFunctionOrganizationBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization bad request response has a 5xx status code -func (o *GetRegistryFunctionOrganizationBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization bad request response a status code equal to that given -func (o *GetRegistryFunctionOrganizationBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the get registry function organization bad request response -func (o *GetRegistryFunctionOrganizationBadRequest) Code() int { - return 400 -} - -func (o *GetRegistryFunctionOrganizationBadRequest) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationBadRequest) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationBadRequest) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationUnauthorized creates a GetRegistryFunctionOrganizationUnauthorized with default headers values -func NewGetRegistryFunctionOrganizationUnauthorized() *GetRegistryFunctionOrganizationUnauthorized { - return &GetRegistryFunctionOrganizationUnauthorized{} -} - -/* -GetRegistryFunctionOrganizationUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetRegistryFunctionOrganizationUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization unauthorized response has a 2xx status code -func (o *GetRegistryFunctionOrganizationUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization unauthorized response has a 3xx status code -func (o *GetRegistryFunctionOrganizationUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization unauthorized response has a 4xx status code -func (o *GetRegistryFunctionOrganizationUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization unauthorized response has a 5xx status code -func (o *GetRegistryFunctionOrganizationUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization unauthorized response a status code equal to that given -func (o *GetRegistryFunctionOrganizationUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get registry function organization unauthorized response -func (o *GetRegistryFunctionOrganizationUnauthorized) Code() int { - return 401 -} - -func (o *GetRegistryFunctionOrganizationUnauthorized) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationUnauthorized) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationNotFound creates a GetRegistryFunctionOrganizationNotFound with default headers values -func NewGetRegistryFunctionOrganizationNotFound() *GetRegistryFunctionOrganizationNotFound { - return &GetRegistryFunctionOrganizationNotFound{} -} - -/* -GetRegistryFunctionOrganizationNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetRegistryFunctionOrganizationNotFound struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization not found response has a 2xx status code -func (o *GetRegistryFunctionOrganizationNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization not found response has a 3xx status code -func (o *GetRegistryFunctionOrganizationNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization not found response has a 4xx status code -func (o *GetRegistryFunctionOrganizationNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function organization not found response has a 5xx status code -func (o *GetRegistryFunctionOrganizationNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function organization not found response a status code equal to that given -func (o *GetRegistryFunctionOrganizationNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get registry function organization not found response -func (o *GetRegistryFunctionOrganizationNotFound) Code() int { - return 404 -} - -func (o *GetRegistryFunctionOrganizationNotFound) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNotFound) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionOrganizationInternalServerError creates a GetRegistryFunctionOrganizationInternalServerError with default headers values -func NewGetRegistryFunctionOrganizationInternalServerError() *GetRegistryFunctionOrganizationInternalServerError { - return &GetRegistryFunctionOrganizationInternalServerError{} -} - -/* -GetRegistryFunctionOrganizationInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetRegistryFunctionOrganizationInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get registry function organization internal server error response has a 2xx status code -func (o *GetRegistryFunctionOrganizationInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function organization internal server error response has a 3xx status code -func (o *GetRegistryFunctionOrganizationInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function organization internal server error response has a 4xx status code -func (o *GetRegistryFunctionOrganizationInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function organization internal server error response has a 5xx status code -func (o *GetRegistryFunctionOrganizationInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get registry function organization internal server error response a status code equal to that given -func (o *GetRegistryFunctionOrganizationInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get registry function organization internal server error response -func (o *GetRegistryFunctionOrganizationInternalServerError) Code() int { - return 500 -} - -func (o *GetRegistryFunctionOrganizationInternalServerError) Error() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationInternalServerError) String() string { - return fmt.Sprintf("[GET /registry/function/{organization}][%d] getRegistryFunctionOrganizationInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionOrganizationInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionOrganizationInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/get_registry_function_parameters.go b/go/client/registry/get_registry_function_parameters.go deleted file mode 100644 index 286ccc98..00000000 --- a/go/client/registry/get_registry_function_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewGetRegistryFunctionParams creates a new GetRegistryFunctionParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewGetRegistryFunctionParams() *GetRegistryFunctionParams { - return &GetRegistryFunctionParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewGetRegistryFunctionParamsWithTimeout creates a new GetRegistryFunctionParams object -// with the ability to set a timeout on a request. -func NewGetRegistryFunctionParamsWithTimeout(timeout time.Duration) *GetRegistryFunctionParams { - return &GetRegistryFunctionParams{ - timeout: timeout, - } -} - -// NewGetRegistryFunctionParamsWithContext creates a new GetRegistryFunctionParams object -// with the ability to set a context for a request. -func NewGetRegistryFunctionParamsWithContext(ctx context.Context) *GetRegistryFunctionParams { - return &GetRegistryFunctionParams{ - Context: ctx, - } -} - -// NewGetRegistryFunctionParamsWithHTTPClient creates a new GetRegistryFunctionParams object -// with the ability to set a custom HTTPClient for a request. -func NewGetRegistryFunctionParamsWithHTTPClient(client *http.Client) *GetRegistryFunctionParams { - return &GetRegistryFunctionParams{ - HTTPClient: client, - } -} - -/* -GetRegistryFunctionParams contains all the parameters to send to the API endpoint - - for the get registry function operation. - - Typically these are written to a http.Request. -*/ -type GetRegistryFunctionParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the get registry function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionParams) WithDefaults() *GetRegistryFunctionParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the get registry function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *GetRegistryFunctionParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the get registry function params -func (o *GetRegistryFunctionParams) WithTimeout(timeout time.Duration) *GetRegistryFunctionParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the get registry function params -func (o *GetRegistryFunctionParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the get registry function params -func (o *GetRegistryFunctionParams) WithContext(ctx context.Context) *GetRegistryFunctionParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the get registry function params -func (o *GetRegistryFunctionParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the get registry function params -func (o *GetRegistryFunctionParams) WithHTTPClient(client *http.Client) *GetRegistryFunctionParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the get registry function params -func (o *GetRegistryFunctionParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *GetRegistryFunctionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/get_registry_function_responses.go b/go/client/registry/get_registry_function_responses.go deleted file mode 100644 index 49d2eec4..00000000 --- a/go/client/registry/get_registry_function_responses.go +++ /dev/null @@ -1,389 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// GetRegistryFunctionReader is a Reader for the GetRegistryFunction structure. -type GetRegistryFunctionReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *GetRegistryFunctionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewGetRegistryFunctionOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewGetRegistryFunctionBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewGetRegistryFunctionUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewGetRegistryFunctionNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewGetRegistryFunctionInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewGetRegistryFunctionOK creates a GetRegistryFunctionOK with default headers values -func NewGetRegistryFunctionOK() *GetRegistryFunctionOK { - return &GetRegistryFunctionOK{} -} - -/* -GetRegistryFunctionOK describes a response with status code 200, with default header values. - -OK -*/ -type GetRegistryFunctionOK struct { - Payload []*models.ModelsGetFunctionResponse -} - -// IsSuccess returns true when this get registry function o k response has a 2xx status code -func (o *GetRegistryFunctionOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this get registry function o k response has a 3xx status code -func (o *GetRegistryFunctionOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function o k response has a 4xx status code -func (o *GetRegistryFunctionOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function o k response has a 5xx status code -func (o *GetRegistryFunctionOK) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function o k response a status code equal to that given -func (o *GetRegistryFunctionOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the get registry function o k response -func (o *GetRegistryFunctionOK) Code() int { - return 200 -} - -func (o *GetRegistryFunctionOK) Error() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOK) String() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionOK %+v", 200, o.Payload) -} - -func (o *GetRegistryFunctionOK) GetPayload() []*models.ModelsGetFunctionResponse { - return o.Payload -} - -func (o *GetRegistryFunctionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionBadRequest creates a GetRegistryFunctionBadRequest with default headers values -func NewGetRegistryFunctionBadRequest() *GetRegistryFunctionBadRequest { - return &GetRegistryFunctionBadRequest{} -} - -/* -GetRegistryFunctionBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type GetRegistryFunctionBadRequest struct { - Payload string -} - -// IsSuccess returns true when this get registry function bad request response has a 2xx status code -func (o *GetRegistryFunctionBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function bad request response has a 3xx status code -func (o *GetRegistryFunctionBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function bad request response has a 4xx status code -func (o *GetRegistryFunctionBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function bad request response has a 5xx status code -func (o *GetRegistryFunctionBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function bad request response a status code equal to that given -func (o *GetRegistryFunctionBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the get registry function bad request response -func (o *GetRegistryFunctionBadRequest) Code() int { - return 400 -} - -func (o *GetRegistryFunctionBadRequest) Error() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionBadRequest) String() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *GetRegistryFunctionBadRequest) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionUnauthorized creates a GetRegistryFunctionUnauthorized with default headers values -func NewGetRegistryFunctionUnauthorized() *GetRegistryFunctionUnauthorized { - return &GetRegistryFunctionUnauthorized{} -} - -/* -GetRegistryFunctionUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type GetRegistryFunctionUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this get registry function unauthorized response has a 2xx status code -func (o *GetRegistryFunctionUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function unauthorized response has a 3xx status code -func (o *GetRegistryFunctionUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function unauthorized response has a 4xx status code -func (o *GetRegistryFunctionUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function unauthorized response has a 5xx status code -func (o *GetRegistryFunctionUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function unauthorized response a status code equal to that given -func (o *GetRegistryFunctionUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the get registry function unauthorized response -func (o *GetRegistryFunctionUnauthorized) Code() int { - return 401 -} - -func (o *GetRegistryFunctionUnauthorized) Error() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionUnauthorized) String() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *GetRegistryFunctionUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionNotFound creates a GetRegistryFunctionNotFound with default headers values -func NewGetRegistryFunctionNotFound() *GetRegistryFunctionNotFound { - return &GetRegistryFunctionNotFound{} -} - -/* -GetRegistryFunctionNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type GetRegistryFunctionNotFound struct { - Payload string -} - -// IsSuccess returns true when this get registry function not found response has a 2xx status code -func (o *GetRegistryFunctionNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function not found response has a 3xx status code -func (o *GetRegistryFunctionNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function not found response has a 4xx status code -func (o *GetRegistryFunctionNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this get registry function not found response has a 5xx status code -func (o *GetRegistryFunctionNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this get registry function not found response a status code equal to that given -func (o *GetRegistryFunctionNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the get registry function not found response -func (o *GetRegistryFunctionNotFound) Code() int { - return 404 -} - -func (o *GetRegistryFunctionNotFound) Error() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionNotFound) String() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionNotFound %+v", 404, o.Payload) -} - -func (o *GetRegistryFunctionNotFound) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewGetRegistryFunctionInternalServerError creates a GetRegistryFunctionInternalServerError with default headers values -func NewGetRegistryFunctionInternalServerError() *GetRegistryFunctionInternalServerError { - return &GetRegistryFunctionInternalServerError{} -} - -/* -GetRegistryFunctionInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type GetRegistryFunctionInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this get registry function internal server error response has a 2xx status code -func (o *GetRegistryFunctionInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this get registry function internal server error response has a 3xx status code -func (o *GetRegistryFunctionInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this get registry function internal server error response has a 4xx status code -func (o *GetRegistryFunctionInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this get registry function internal server error response has a 5xx status code -func (o *GetRegistryFunctionInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this get registry function internal server error response a status code equal to that given -func (o *GetRegistryFunctionInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the get registry function internal server error response -func (o *GetRegistryFunctionInternalServerError) Code() int { - return 500 -} - -func (o *GetRegistryFunctionInternalServerError) Error() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionInternalServerError) String() string { - return fmt.Sprintf("[GET /registry/function][%d] getRegistryFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *GetRegistryFunctionInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *GetRegistryFunctionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/post_domain_parameters.go b/go/client/registry/post_domain_parameters.go deleted file mode 100644 index 39740eee..00000000 --- a/go/client/registry/post_domain_parameters.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// NewPostDomainParams creates a new PostDomainParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostDomainParams() *PostDomainParams { - return &PostDomainParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostDomainParamsWithTimeout creates a new PostDomainParams object -// with the ability to set a timeout on a request. -func NewPostDomainParamsWithTimeout(timeout time.Duration) *PostDomainParams { - return &PostDomainParams{ - timeout: timeout, - } -} - -// NewPostDomainParamsWithContext creates a new PostDomainParams object -// with the ability to set a context for a request. -func NewPostDomainParamsWithContext(ctx context.Context) *PostDomainParams { - return &PostDomainParams{ - Context: ctx, - } -} - -// NewPostDomainParamsWithHTTPClient creates a new PostDomainParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostDomainParamsWithHTTPClient(client *http.Client) *PostDomainParams { - return &PostDomainParams{ - HTTPClient: client, - } -} - -/* -PostDomainParams contains all the parameters to send to the API endpoint - - for the post domain operation. - - Typically these are written to a http.Request. -*/ -type PostDomainParams struct { - - /* Request. - - Create Domain Request - */ - Request *models.ModelsCreateDomainRequest - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post domain params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostDomainParams) WithDefaults() *PostDomainParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post domain params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostDomainParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post domain params -func (o *PostDomainParams) WithTimeout(timeout time.Duration) *PostDomainParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post domain params -func (o *PostDomainParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post domain params -func (o *PostDomainParams) WithContext(ctx context.Context) *PostDomainParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post domain params -func (o *PostDomainParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post domain params -func (o *PostDomainParams) WithHTTPClient(client *http.Client) *PostDomainParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post domain params -func (o *PostDomainParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithRequest adds the request to the post domain params -func (o *PostDomainParams) WithRequest(request *models.ModelsCreateDomainRequest) *PostDomainParams { - o.SetRequest(request) - return o -} - -// SetRequest adds the request to the post domain params -func (o *PostDomainParams) SetRequest(request *models.ModelsCreateDomainRequest) { - o.Request = request -} - -// WriteToRequest writes these params to a swagger request -func (o *PostDomainParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - if o.Request != nil { - if err := r.SetBodyParam(o.Request); err != nil { - return err - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/post_domain_responses.go b/go/client/registry/post_domain_responses.go deleted file mode 100644 index 1bab0b34..00000000 --- a/go/client/registry/post_domain_responses.go +++ /dev/null @@ -1,463 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostDomainReader is a Reader for the PostDomain structure. -type PostDomainReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostDomainReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostDomainOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostDomainBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostDomainUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewPostDomainNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 412: - result := NewPostDomainPreconditionFailed() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostDomainInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostDomainOK creates a PostDomainOK with default headers values -func NewPostDomainOK() *PostDomainOK { - return &PostDomainOK{} -} - -/* -PostDomainOK describes a response with status code 200, with default header values. - -OK -*/ -type PostDomainOK struct { - Payload *models.ModelsCreateDomainResponse -} - -// IsSuccess returns true when this post domain o k response has a 2xx status code -func (o *PostDomainOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post domain o k response has a 3xx status code -func (o *PostDomainOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain o k response has a 4xx status code -func (o *PostDomainOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post domain o k response has a 5xx status code -func (o *PostDomainOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post domain o k response a status code equal to that given -func (o *PostDomainOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post domain o k response -func (o *PostDomainOK) Code() int { - return 200 -} - -func (o *PostDomainOK) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainOK %+v", 200, o.Payload) -} - -func (o *PostDomainOK) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainOK %+v", 200, o.Payload) -} - -func (o *PostDomainOK) GetPayload() *models.ModelsCreateDomainResponse { - return o.Payload -} - -func (o *PostDomainOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsCreateDomainResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDomainBadRequest creates a PostDomainBadRequest with default headers values -func NewPostDomainBadRequest() *PostDomainBadRequest { - return &PostDomainBadRequest{} -} - -/* -PostDomainBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostDomainBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post domain bad request response has a 2xx status code -func (o *PostDomainBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post domain bad request response has a 3xx status code -func (o *PostDomainBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain bad request response has a 4xx status code -func (o *PostDomainBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post domain bad request response has a 5xx status code -func (o *PostDomainBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post domain bad request response a status code equal to that given -func (o *PostDomainBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post domain bad request response -func (o *PostDomainBadRequest) Code() int { - return 400 -} - -func (o *PostDomainBadRequest) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainBadRequest %+v", 400, o.Payload) -} - -func (o *PostDomainBadRequest) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainBadRequest %+v", 400, o.Payload) -} - -func (o *PostDomainBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostDomainBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDomainUnauthorized creates a PostDomainUnauthorized with default headers values -func NewPostDomainUnauthorized() *PostDomainUnauthorized { - return &PostDomainUnauthorized{} -} - -/* -PostDomainUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostDomainUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post domain unauthorized response has a 2xx status code -func (o *PostDomainUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post domain unauthorized response has a 3xx status code -func (o *PostDomainUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain unauthorized response has a 4xx status code -func (o *PostDomainUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post domain unauthorized response has a 5xx status code -func (o *PostDomainUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post domain unauthorized response a status code equal to that given -func (o *PostDomainUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post domain unauthorized response -func (o *PostDomainUnauthorized) Code() int { - return 401 -} - -func (o *PostDomainUnauthorized) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainUnauthorized %+v", 401, o.Payload) -} - -func (o *PostDomainUnauthorized) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainUnauthorized %+v", 401, o.Payload) -} - -func (o *PostDomainUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostDomainUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDomainNotFound creates a PostDomainNotFound with default headers values -func NewPostDomainNotFound() *PostDomainNotFound { - return &PostDomainNotFound{} -} - -/* -PostDomainNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type PostDomainNotFound struct { - Payload string -} - -// IsSuccess returns true when this post domain not found response has a 2xx status code -func (o *PostDomainNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post domain not found response has a 3xx status code -func (o *PostDomainNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain not found response has a 4xx status code -func (o *PostDomainNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this post domain not found response has a 5xx status code -func (o *PostDomainNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this post domain not found response a status code equal to that given -func (o *PostDomainNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the post domain not found response -func (o *PostDomainNotFound) Code() int { - return 404 -} - -func (o *PostDomainNotFound) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainNotFound %+v", 404, o.Payload) -} - -func (o *PostDomainNotFound) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainNotFound %+v", 404, o.Payload) -} - -func (o *PostDomainNotFound) GetPayload() string { - return o.Payload -} - -func (o *PostDomainNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDomainPreconditionFailed creates a PostDomainPreconditionFailed with default headers values -func NewPostDomainPreconditionFailed() *PostDomainPreconditionFailed { - return &PostDomainPreconditionFailed{} -} - -/* -PostDomainPreconditionFailed describes a response with status code 412, with default header values. - -Precondition Failed -*/ -type PostDomainPreconditionFailed struct { - Payload string -} - -// IsSuccess returns true when this post domain precondition failed response has a 2xx status code -func (o *PostDomainPreconditionFailed) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post domain precondition failed response has a 3xx status code -func (o *PostDomainPreconditionFailed) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain precondition failed response has a 4xx status code -func (o *PostDomainPreconditionFailed) IsClientError() bool { - return true -} - -// IsServerError returns true when this post domain precondition failed response has a 5xx status code -func (o *PostDomainPreconditionFailed) IsServerError() bool { - return false -} - -// IsCode returns true when this post domain precondition failed response a status code equal to that given -func (o *PostDomainPreconditionFailed) IsCode(code int) bool { - return code == 412 -} - -// Code gets the status code for the post domain precondition failed response -func (o *PostDomainPreconditionFailed) Code() int { - return 412 -} - -func (o *PostDomainPreconditionFailed) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainPreconditionFailed %+v", 412, o.Payload) -} - -func (o *PostDomainPreconditionFailed) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainPreconditionFailed %+v", 412, o.Payload) -} - -func (o *PostDomainPreconditionFailed) GetPayload() string { - return o.Payload -} - -func (o *PostDomainPreconditionFailed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostDomainInternalServerError creates a PostDomainInternalServerError with default headers values -func NewPostDomainInternalServerError() *PostDomainInternalServerError { - return &PostDomainInternalServerError{} -} - -/* -PostDomainInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostDomainInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post domain internal server error response has a 2xx status code -func (o *PostDomainInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post domain internal server error response has a 3xx status code -func (o *PostDomainInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post domain internal server error response has a 4xx status code -func (o *PostDomainInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post domain internal server error response has a 5xx status code -func (o *PostDomainInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post domain internal server error response a status code equal to that given -func (o *PostDomainInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post domain internal server error response -func (o *PostDomainInternalServerError) Code() int { - return 500 -} - -func (o *PostDomainInternalServerError) Error() string { - return fmt.Sprintf("[POST /domain][%d] postDomainInternalServerError %+v", 500, o.Payload) -} - -func (o *PostDomainInternalServerError) String() string { - return fmt.Sprintf("[POST /domain][%d] postDomainInternalServerError %+v", 500, o.Payload) -} - -func (o *PostDomainInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostDomainInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/post_registry_function_parameters.go b/go/client/registry/post_registry_function_parameters.go deleted file mode 100644 index 191390d9..00000000 --- a/go/client/registry/post_registry_function_parameters.go +++ /dev/null @@ -1,215 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// NewPostRegistryFunctionParams creates a new PostRegistryFunctionParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostRegistryFunctionParams() *PostRegistryFunctionParams { - return &PostRegistryFunctionParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostRegistryFunctionParamsWithTimeout creates a new PostRegistryFunctionParams object -// with the ability to set a timeout on a request. -func NewPostRegistryFunctionParamsWithTimeout(timeout time.Duration) *PostRegistryFunctionParams { - return &PostRegistryFunctionParams{ - timeout: timeout, - } -} - -// NewPostRegistryFunctionParamsWithContext creates a new PostRegistryFunctionParams object -// with the ability to set a context for a request. -func NewPostRegistryFunctionParamsWithContext(ctx context.Context) *PostRegistryFunctionParams { - return &PostRegistryFunctionParams{ - Context: ctx, - } -} - -// NewPostRegistryFunctionParamsWithHTTPClient creates a new PostRegistryFunctionParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostRegistryFunctionParamsWithHTTPClient(client *http.Client) *PostRegistryFunctionParams { - return &PostRegistryFunctionParams{ - HTTPClient: client, - } -} - -/* -PostRegistryFunctionParams contains all the parameters to send to the API endpoint - - for the post registry function operation. - - Typically these are written to a http.Request. -*/ -type PostRegistryFunctionParams struct { - - /* Function. - - function - */ - Function runtime.NamedReadCloser - - /* Organization. - - organization - */ - Organization *string - - /* Public. - - public - */ - Public *bool - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post registry function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostRegistryFunctionParams) WithDefaults() *PostRegistryFunctionParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post registry function params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostRegistryFunctionParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post registry function params -func (o *PostRegistryFunctionParams) WithTimeout(timeout time.Duration) *PostRegistryFunctionParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post registry function params -func (o *PostRegistryFunctionParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post registry function params -func (o *PostRegistryFunctionParams) WithContext(ctx context.Context) *PostRegistryFunctionParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post registry function params -func (o *PostRegistryFunctionParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post registry function params -func (o *PostRegistryFunctionParams) WithHTTPClient(client *http.Client) *PostRegistryFunctionParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post registry function params -func (o *PostRegistryFunctionParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithFunction adds the function to the post registry function params -func (o *PostRegistryFunctionParams) WithFunction(function runtime.NamedReadCloser) *PostRegistryFunctionParams { - o.SetFunction(function) - return o -} - -// SetFunction adds the function to the post registry function params -func (o *PostRegistryFunctionParams) SetFunction(function runtime.NamedReadCloser) { - o.Function = function -} - -// WithOrganization adds the organization to the post registry function params -func (o *PostRegistryFunctionParams) WithOrganization(organization *string) *PostRegistryFunctionParams { - o.SetOrganization(organization) - return o -} - -// SetOrganization adds the organization to the post registry function params -func (o *PostRegistryFunctionParams) SetOrganization(organization *string) { - o.Organization = organization -} - -// WithPublic adds the public to the post registry function params -func (o *PostRegistryFunctionParams) WithPublic(public *bool) *PostRegistryFunctionParams { - o.SetPublic(public) - return o -} - -// SetPublic adds the public to the post registry function params -func (o *PostRegistryFunctionParams) SetPublic(public *bool) { - o.Public = public -} - -// WriteToRequest writes these params to a swagger request -func (o *PostRegistryFunctionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - // form file param function - if err := r.SetFileParam("function", o.Function); err != nil { - return err - } - - if o.Organization != nil { - - // form param organization - var frOrganization string - if o.Organization != nil { - frOrganization = *o.Organization - } - fOrganization := frOrganization - if fOrganization != "" { - if err := r.SetFormParam("organization", fOrganization); err != nil { - return err - } - } - } - - if o.Public != nil { - - // form param public - var frPublic bool - if o.Public != nil { - frPublic = *o.Public - } - fPublic := swag.FormatBool(frPublic) - if fPublic != "" { - if err := r.SetFormParam("public", fPublic); err != nil { - return err - } - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/registry/post_registry_function_responses.go b/go/client/registry/post_registry_function_responses.go deleted file mode 100644 index c89afe3a..00000000 --- a/go/client/registry/post_registry_function_responses.go +++ /dev/null @@ -1,463 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostRegistryFunctionReader is a Reader for the PostRegistryFunction structure. -type PostRegistryFunctionReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostRegistryFunctionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostRegistryFunctionOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostRegistryFunctionBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostRegistryFunctionUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 404: - result := NewPostRegistryFunctionNotFound() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 412: - result := NewPostRegistryFunctionPreconditionFailed() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostRegistryFunctionInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostRegistryFunctionOK creates a PostRegistryFunctionOK with default headers values -func NewPostRegistryFunctionOK() *PostRegistryFunctionOK { - return &PostRegistryFunctionOK{} -} - -/* -PostRegistryFunctionOK describes a response with status code 200, with default header values. - -OK -*/ -type PostRegistryFunctionOK struct { - Payload *models.ModelsCreateFunctionResponse -} - -// IsSuccess returns true when this post registry function o k response has a 2xx status code -func (o *PostRegistryFunctionOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post registry function o k response has a 3xx status code -func (o *PostRegistryFunctionOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function o k response has a 4xx status code -func (o *PostRegistryFunctionOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post registry function o k response has a 5xx status code -func (o *PostRegistryFunctionOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post registry function o k response a status code equal to that given -func (o *PostRegistryFunctionOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post registry function o k response -func (o *PostRegistryFunctionOK) Code() int { - return 200 -} - -func (o *PostRegistryFunctionOK) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionOK %+v", 200, o.Payload) -} - -func (o *PostRegistryFunctionOK) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionOK %+v", 200, o.Payload) -} - -func (o *PostRegistryFunctionOK) GetPayload() *models.ModelsCreateFunctionResponse { - return o.Payload -} - -func (o *PostRegistryFunctionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsCreateFunctionResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostRegistryFunctionBadRequest creates a PostRegistryFunctionBadRequest with default headers values -func NewPostRegistryFunctionBadRequest() *PostRegistryFunctionBadRequest { - return &PostRegistryFunctionBadRequest{} -} - -/* -PostRegistryFunctionBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostRegistryFunctionBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post registry function bad request response has a 2xx status code -func (o *PostRegistryFunctionBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post registry function bad request response has a 3xx status code -func (o *PostRegistryFunctionBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function bad request response has a 4xx status code -func (o *PostRegistryFunctionBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post registry function bad request response has a 5xx status code -func (o *PostRegistryFunctionBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post registry function bad request response a status code equal to that given -func (o *PostRegistryFunctionBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post registry function bad request response -func (o *PostRegistryFunctionBadRequest) Code() int { - return 400 -} - -func (o *PostRegistryFunctionBadRequest) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *PostRegistryFunctionBadRequest) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionBadRequest %+v", 400, o.Payload) -} - -func (o *PostRegistryFunctionBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostRegistryFunctionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostRegistryFunctionUnauthorized creates a PostRegistryFunctionUnauthorized with default headers values -func NewPostRegistryFunctionUnauthorized() *PostRegistryFunctionUnauthorized { - return &PostRegistryFunctionUnauthorized{} -} - -/* -PostRegistryFunctionUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostRegistryFunctionUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post registry function unauthorized response has a 2xx status code -func (o *PostRegistryFunctionUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post registry function unauthorized response has a 3xx status code -func (o *PostRegistryFunctionUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function unauthorized response has a 4xx status code -func (o *PostRegistryFunctionUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post registry function unauthorized response has a 5xx status code -func (o *PostRegistryFunctionUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post registry function unauthorized response a status code equal to that given -func (o *PostRegistryFunctionUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post registry function unauthorized response -func (o *PostRegistryFunctionUnauthorized) Code() int { - return 401 -} - -func (o *PostRegistryFunctionUnauthorized) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *PostRegistryFunctionUnauthorized) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionUnauthorized %+v", 401, o.Payload) -} - -func (o *PostRegistryFunctionUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostRegistryFunctionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostRegistryFunctionNotFound creates a PostRegistryFunctionNotFound with default headers values -func NewPostRegistryFunctionNotFound() *PostRegistryFunctionNotFound { - return &PostRegistryFunctionNotFound{} -} - -/* -PostRegistryFunctionNotFound describes a response with status code 404, with default header values. - -Not Found -*/ -type PostRegistryFunctionNotFound struct { - Payload string -} - -// IsSuccess returns true when this post registry function not found response has a 2xx status code -func (o *PostRegistryFunctionNotFound) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post registry function not found response has a 3xx status code -func (o *PostRegistryFunctionNotFound) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function not found response has a 4xx status code -func (o *PostRegistryFunctionNotFound) IsClientError() bool { - return true -} - -// IsServerError returns true when this post registry function not found response has a 5xx status code -func (o *PostRegistryFunctionNotFound) IsServerError() bool { - return false -} - -// IsCode returns true when this post registry function not found response a status code equal to that given -func (o *PostRegistryFunctionNotFound) IsCode(code int) bool { - return code == 404 -} - -// Code gets the status code for the post registry function not found response -func (o *PostRegistryFunctionNotFound) Code() int { - return 404 -} - -func (o *PostRegistryFunctionNotFound) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionNotFound %+v", 404, o.Payload) -} - -func (o *PostRegistryFunctionNotFound) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionNotFound %+v", 404, o.Payload) -} - -func (o *PostRegistryFunctionNotFound) GetPayload() string { - return o.Payload -} - -func (o *PostRegistryFunctionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostRegistryFunctionPreconditionFailed creates a PostRegistryFunctionPreconditionFailed with default headers values -func NewPostRegistryFunctionPreconditionFailed() *PostRegistryFunctionPreconditionFailed { - return &PostRegistryFunctionPreconditionFailed{} -} - -/* -PostRegistryFunctionPreconditionFailed describes a response with status code 412, with default header values. - -Precondition Failed -*/ -type PostRegistryFunctionPreconditionFailed struct { - Payload string -} - -// IsSuccess returns true when this post registry function precondition failed response has a 2xx status code -func (o *PostRegistryFunctionPreconditionFailed) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post registry function precondition failed response has a 3xx status code -func (o *PostRegistryFunctionPreconditionFailed) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function precondition failed response has a 4xx status code -func (o *PostRegistryFunctionPreconditionFailed) IsClientError() bool { - return true -} - -// IsServerError returns true when this post registry function precondition failed response has a 5xx status code -func (o *PostRegistryFunctionPreconditionFailed) IsServerError() bool { - return false -} - -// IsCode returns true when this post registry function precondition failed response a status code equal to that given -func (o *PostRegistryFunctionPreconditionFailed) IsCode(code int) bool { - return code == 412 -} - -// Code gets the status code for the post registry function precondition failed response -func (o *PostRegistryFunctionPreconditionFailed) Code() int { - return 412 -} - -func (o *PostRegistryFunctionPreconditionFailed) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionPreconditionFailed %+v", 412, o.Payload) -} - -func (o *PostRegistryFunctionPreconditionFailed) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionPreconditionFailed %+v", 412, o.Payload) -} - -func (o *PostRegistryFunctionPreconditionFailed) GetPayload() string { - return o.Payload -} - -func (o *PostRegistryFunctionPreconditionFailed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostRegistryFunctionInternalServerError creates a PostRegistryFunctionInternalServerError with default headers values -func NewPostRegistryFunctionInternalServerError() *PostRegistryFunctionInternalServerError { - return &PostRegistryFunctionInternalServerError{} -} - -/* -PostRegistryFunctionInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostRegistryFunctionInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post registry function internal server error response has a 2xx status code -func (o *PostRegistryFunctionInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post registry function internal server error response has a 3xx status code -func (o *PostRegistryFunctionInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post registry function internal server error response has a 4xx status code -func (o *PostRegistryFunctionInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post registry function internal server error response has a 5xx status code -func (o *PostRegistryFunctionInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post registry function internal server error response a status code equal to that given -func (o *PostRegistryFunctionInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post registry function internal server error response -func (o *PostRegistryFunctionInternalServerError) Code() int { - return 500 -} - -func (o *PostRegistryFunctionInternalServerError) Error() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *PostRegistryFunctionInternalServerError) String() string { - return fmt.Sprintf("[POST /registry/function][%d] postRegistryFunctionInternalServerError %+v", 500, o.Payload) -} - -func (o *PostRegistryFunctionInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostRegistryFunctionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/registry/registry_client.go b/go/client/registry/registry_client.go deleted file mode 100644 index 5b627275..00000000 --- a/go/client/registry/registry_client.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package registry - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// New creates a new registry API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for registry API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - DeleteRegistryFunctionOrganizationNameTag(params *DeleteRegistryFunctionOrganizationNameTagParams, opts ...ClientOption) (*DeleteRegistryFunctionOrganizationNameTagOK, error) - - GetRegistryFunction(params *GetRegistryFunctionParams, opts ...ClientOption) (*GetRegistryFunctionOK, error) - - GetRegistryFunctionNameTag(params *GetRegistryFunctionNameTagParams, opts ...ClientOption) (*GetRegistryFunctionNameTagOK, error) - - GetRegistryFunctionOrganization(params *GetRegistryFunctionOrganizationParams, opts ...ClientOption) (*GetRegistryFunctionOrganizationOK, error) - - GetRegistryFunctionOrganizationNameTag(params *GetRegistryFunctionOrganizationNameTagParams, opts ...ClientOption) (*GetRegistryFunctionOrganizationNameTagOK, error) - - PostDomain(params *PostDomainParams, opts ...ClientOption) (*PostDomainOK, error) - - PostRegistryFunction(params *PostRegistryFunctionParams, opts ...ClientOption) (*PostRegistryFunctionOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -DeleteRegistryFunctionOrganizationNameTag Deletes a function from the given `organization` given its `name` and `tag`. If the session is scoped to an organization it must be the same as the organization of the function. -*/ -func (a *Client) DeleteRegistryFunctionOrganizationNameTag(params *DeleteRegistryFunctionOrganizationNameTagParams, opts ...ClientOption) (*DeleteRegistryFunctionOrganizationNameTagOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewDeleteRegistryFunctionOrganizationNameTagParams() - } - op := &runtime.ClientOperation{ - ID: "DeleteRegistryFunctionOrganizationNameTag", - Method: "DELETE", - PathPattern: "/registry/function/{organization}/{name}/{tag}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &DeleteRegistryFunctionOrganizationNameTagReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*DeleteRegistryFunctionOrganizationNameTagOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for DeleteRegistryFunctionOrganizationNameTag: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetRegistryFunction Lists all the functions in the default organization. -*/ -func (a *Client) GetRegistryFunction(params *GetRegistryFunctionParams, opts ...ClientOption) (*GetRegistryFunctionOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetRegistryFunctionParams() - } - op := &runtime.ClientOperation{ - ID: "GetRegistryFunction", - Method: "GET", - PathPattern: "/registry/function", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetRegistryFunctionReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetRegistryFunctionOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetRegistryFunction: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetRegistryFunctionNameTag Retrieves a function from the default organization given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. -*/ -func (a *Client) GetRegistryFunctionNameTag(params *GetRegistryFunctionNameTagParams, opts ...ClientOption) (*GetRegistryFunctionNameTagOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetRegistryFunctionNameTagParams() - } - op := &runtime.ClientOperation{ - ID: "GetRegistryFunctionNameTag", - Method: "GET", - PathPattern: "/registry/function/{name}/{tag}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetRegistryFunctionNameTagReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetRegistryFunctionNameTagOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetRegistryFunctionNameTag: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetRegistryFunctionOrganization Lists all the functions in the given `organization`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions from the `organization` will be returned. -*/ -func (a *Client) GetRegistryFunctionOrganization(params *GetRegistryFunctionOrganizationParams, opts ...ClientOption) (*GetRegistryFunctionOrganizationOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetRegistryFunctionOrganizationParams() - } - op := &runtime.ClientOperation{ - ID: "GetRegistryFunctionOrganization", - Method: "GET", - PathPattern: "/registry/function/{organization}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetRegistryFunctionOrganizationReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetRegistryFunctionOrganizationOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetRegistryFunctionOrganization: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -GetRegistryFunctionOrganizationNameTag Retrieves a function from the given `organization` given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. -*/ -func (a *Client) GetRegistryFunctionOrganizationNameTag(params *GetRegistryFunctionOrganizationNameTagParams, opts ...ClientOption) (*GetRegistryFunctionOrganizationNameTagOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewGetRegistryFunctionOrganizationNameTagParams() - } - op := &runtime.ClientOperation{ - ID: "GetRegistryFunctionOrganizationNameTag", - Method: "GET", - PathPattern: "/registry/function/{organization}/{name}/{tag}", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &GetRegistryFunctionOrganizationNameTagReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*GetRegistryFunctionOrganizationNameTagOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for GetRegistryFunctionOrganizationNameTag: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -PostDomain Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. -*/ -func (a *Client) PostDomain(params *PostDomainParams, opts ...ClientOption) (*PostDomainOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewPostDomainParams() - } - op := &runtime.ClientOperation{ - ID: "PostDomain", - Method: "POST", - PathPattern: "/domain", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &PostDomainReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*PostDomainOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for PostDomain: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -/* -PostRegistryFunction Uploads a function to the Scale Registry. If the session is scoped to an organization, the function will be uploaded to that `organization`, otherwise the function will be uploaded to the user's default `organization`. -*/ -func (a *Client) PostRegistryFunction(params *PostRegistryFunctionParams, opts ...ClientOption) (*PostRegistryFunctionOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewPostRegistryFunctionParams() - } - op := &runtime.ClientOperation{ - ID: "PostRegistryFunction", - Method: "POST", - PathPattern: "/registry/function", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"multipart/form-data"}, - Schemes: []string{"https"}, - Params: params, - Reader: &PostRegistryFunctionReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*PostRegistryFunctionOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for PostRegistryFunction: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/go/client/scale_api_v1_client.go b/go/client/scale_api_v1_client.go deleted file mode 100644 index 057ba4e6..00000000 --- a/go/client/scale_api_v1_client.go +++ /dev/null @@ -1,132 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package client - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "github.com/go-openapi/runtime" - httptransport "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/access" - "github.com/loopholelabs/scale/go/client/deploy" - "github.com/loopholelabs/scale/go/client/health" - "github.com/loopholelabs/scale/go/client/registry" - "github.com/loopholelabs/scale/go/client/userinfo" -) - -// Default scale API v1 HTTP client. -var Default = NewHTTPClient(nil) - -const ( - // DefaultHost is the default Host - // found in Meta (info) section of spec file - DefaultHost string = "api.scale.sh" - // DefaultBasePath is the default BasePath - // found in Meta (info) section of spec file - DefaultBasePath string = "/v1" -) - -// DefaultSchemes are the default schemes found in Meta (info) section of spec file -var DefaultSchemes = []string{"https"} - -// NewHTTPClient creates a new scale API v1 HTTP client. -func NewHTTPClient(formats strfmt.Registry) *ScaleAPIV1 { - return NewHTTPClientWithConfig(formats, nil) -} - -// NewHTTPClientWithConfig creates a new scale API v1 HTTP client, -// using a customizable transport config. -func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *ScaleAPIV1 { - // ensure nullable parameters have default - if cfg == nil { - cfg = DefaultTransportConfig() - } - - // create transport and client - transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) - return New(transport, formats) -} - -// New creates a new scale API v1 client -func New(transport runtime.ClientTransport, formats strfmt.Registry) *ScaleAPIV1 { - // ensure nullable parameters have default - if formats == nil { - formats = strfmt.Default - } - - cli := new(ScaleAPIV1) - cli.Transport = transport - cli.Access = access.New(transport, formats) - cli.Deploy = deploy.New(transport, formats) - cli.Health = health.New(transport, formats) - cli.Registry = registry.New(transport, formats) - cli.Userinfo = userinfo.New(transport, formats) - return cli -} - -// DefaultTransportConfig creates a TransportConfig with the -// default settings taken from the meta section of the spec file. -func DefaultTransportConfig() *TransportConfig { - return &TransportConfig{ - Host: DefaultHost, - BasePath: DefaultBasePath, - Schemes: DefaultSchemes, - } -} - -// TransportConfig contains the transport related info, -// found in the meta section of the spec file. -type TransportConfig struct { - Host string - BasePath string - Schemes []string -} - -// WithHost overrides the default host, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithHost(host string) *TransportConfig { - cfg.Host = host - return cfg -} - -// WithBasePath overrides the default basePath, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { - cfg.BasePath = basePath - return cfg -} - -// WithSchemes overrides the default schemes, -// provided by the meta section of the spec file. -func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { - cfg.Schemes = schemes - return cfg -} - -// ScaleAPIV1 is a client for scale API v1 -type ScaleAPIV1 struct { - Access access.ClientService - - Deploy deploy.ClientService - - Health health.ClientService - - Registry registry.ClientService - - Userinfo userinfo.ClientService - - Transport runtime.ClientTransport -} - -// SetTransport changes the transport on the client and all its subresources -func (c *ScaleAPIV1) SetTransport(transport runtime.ClientTransport) { - c.Transport = transport - c.Access.SetTransport(transport) - c.Deploy.SetTransport(transport) - c.Health.SetTransport(transport) - c.Registry.SetTransport(transport) - c.Userinfo.SetTransport(transport) -} diff --git a/go/client/userinfo/post_userinfo_parameters.go b/go/client/userinfo/post_userinfo_parameters.go deleted file mode 100644 index 040c29b9..00000000 --- a/go/client/userinfo/post_userinfo_parameters.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package userinfo - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewPostUserinfoParams creates a new PostUserinfoParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewPostUserinfoParams() *PostUserinfoParams { - return &PostUserinfoParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewPostUserinfoParamsWithTimeout creates a new PostUserinfoParams object -// with the ability to set a timeout on a request. -func NewPostUserinfoParamsWithTimeout(timeout time.Duration) *PostUserinfoParams { - return &PostUserinfoParams{ - timeout: timeout, - } -} - -// NewPostUserinfoParamsWithContext creates a new PostUserinfoParams object -// with the ability to set a context for a request. -func NewPostUserinfoParamsWithContext(ctx context.Context) *PostUserinfoParams { - return &PostUserinfoParams{ - Context: ctx, - } -} - -// NewPostUserinfoParamsWithHTTPClient creates a new PostUserinfoParams object -// with the ability to set a custom HTTPClient for a request. -func NewPostUserinfoParamsWithHTTPClient(client *http.Client) *PostUserinfoParams { - return &PostUserinfoParams{ - HTTPClient: client, - } -} - -/* -PostUserinfoParams contains all the parameters to send to the API endpoint - - for the post userinfo operation. - - Typically these are written to a http.Request. -*/ -type PostUserinfoParams struct { - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the post userinfo params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostUserinfoParams) WithDefaults() *PostUserinfoParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the post userinfo params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *PostUserinfoParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the post userinfo params -func (o *PostUserinfoParams) WithTimeout(timeout time.Duration) *PostUserinfoParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the post userinfo params -func (o *PostUserinfoParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the post userinfo params -func (o *PostUserinfoParams) WithContext(ctx context.Context) *PostUserinfoParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the post userinfo params -func (o *PostUserinfoParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the post userinfo params -func (o *PostUserinfoParams) WithHTTPClient(client *http.Client) *PostUserinfoParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the post userinfo params -func (o *PostUserinfoParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WriteToRequest writes these params to a swagger request -func (o *PostUserinfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/go/client/userinfo/post_userinfo_responses.go b/go/client/userinfo/post_userinfo_responses.go deleted file mode 100644 index e2afc29d..00000000 --- a/go/client/userinfo/post_userinfo_responses.go +++ /dev/null @@ -1,319 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package userinfo - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/loopholelabs/scale/go/client/models" -) - -// PostUserinfoReader is a Reader for the PostUserinfo structure. -type PostUserinfoReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *PostUserinfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewPostUserinfoOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 400: - result := NewPostUserinfoBadRequest() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 401: - result := NewPostUserinfoUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewPostUserinfoInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) - } -} - -// NewPostUserinfoOK creates a PostUserinfoOK with default headers values -func NewPostUserinfoOK() *PostUserinfoOK { - return &PostUserinfoOK{} -} - -/* -PostUserinfoOK describes a response with status code 200, with default header values. - -OK -*/ -type PostUserinfoOK struct { - Payload *models.ModelsUserInfoResponse -} - -// IsSuccess returns true when this post userinfo o k response has a 2xx status code -func (o *PostUserinfoOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this post userinfo o k response has a 3xx status code -func (o *PostUserinfoOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post userinfo o k response has a 4xx status code -func (o *PostUserinfoOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this post userinfo o k response has a 5xx status code -func (o *PostUserinfoOK) IsServerError() bool { - return false -} - -// IsCode returns true when this post userinfo o k response a status code equal to that given -func (o *PostUserinfoOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the post userinfo o k response -func (o *PostUserinfoOK) Code() int { - return 200 -} - -func (o *PostUserinfoOK) Error() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoOK %+v", 200, o.Payload) -} - -func (o *PostUserinfoOK) String() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoOK %+v", 200, o.Payload) -} - -func (o *PostUserinfoOK) GetPayload() *models.ModelsUserInfoResponse { - return o.Payload -} - -func (o *PostUserinfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(models.ModelsUserInfoResponse) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostUserinfoBadRequest creates a PostUserinfoBadRequest with default headers values -func NewPostUserinfoBadRequest() *PostUserinfoBadRequest { - return &PostUserinfoBadRequest{} -} - -/* -PostUserinfoBadRequest describes a response with status code 400, with default header values. - -Bad Request -*/ -type PostUserinfoBadRequest struct { - Payload string -} - -// IsSuccess returns true when this post userinfo bad request response has a 2xx status code -func (o *PostUserinfoBadRequest) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post userinfo bad request response has a 3xx status code -func (o *PostUserinfoBadRequest) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post userinfo bad request response has a 4xx status code -func (o *PostUserinfoBadRequest) IsClientError() bool { - return true -} - -// IsServerError returns true when this post userinfo bad request response has a 5xx status code -func (o *PostUserinfoBadRequest) IsServerError() bool { - return false -} - -// IsCode returns true when this post userinfo bad request response a status code equal to that given -func (o *PostUserinfoBadRequest) IsCode(code int) bool { - return code == 400 -} - -// Code gets the status code for the post userinfo bad request response -func (o *PostUserinfoBadRequest) Code() int { - return 400 -} - -func (o *PostUserinfoBadRequest) Error() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoBadRequest %+v", 400, o.Payload) -} - -func (o *PostUserinfoBadRequest) String() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoBadRequest %+v", 400, o.Payload) -} - -func (o *PostUserinfoBadRequest) GetPayload() string { - return o.Payload -} - -func (o *PostUserinfoBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostUserinfoUnauthorized creates a PostUserinfoUnauthorized with default headers values -func NewPostUserinfoUnauthorized() *PostUserinfoUnauthorized { - return &PostUserinfoUnauthorized{} -} - -/* -PostUserinfoUnauthorized describes a response with status code 401, with default header values. - -Unauthorized -*/ -type PostUserinfoUnauthorized struct { - Payload string -} - -// IsSuccess returns true when this post userinfo unauthorized response has a 2xx status code -func (o *PostUserinfoUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post userinfo unauthorized response has a 3xx status code -func (o *PostUserinfoUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post userinfo unauthorized response has a 4xx status code -func (o *PostUserinfoUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this post userinfo unauthorized response has a 5xx status code -func (o *PostUserinfoUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this post userinfo unauthorized response a status code equal to that given -func (o *PostUserinfoUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the post userinfo unauthorized response -func (o *PostUserinfoUnauthorized) Code() int { - return 401 -} - -func (o *PostUserinfoUnauthorized) Error() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoUnauthorized %+v", 401, o.Payload) -} - -func (o *PostUserinfoUnauthorized) String() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoUnauthorized %+v", 401, o.Payload) -} - -func (o *PostUserinfoUnauthorized) GetPayload() string { - return o.Payload -} - -func (o *PostUserinfoUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewPostUserinfoInternalServerError creates a PostUserinfoInternalServerError with default headers values -func NewPostUserinfoInternalServerError() *PostUserinfoInternalServerError { - return &PostUserinfoInternalServerError{} -} - -/* -PostUserinfoInternalServerError describes a response with status code 500, with default header values. - -Internal Server Error -*/ -type PostUserinfoInternalServerError struct { - Payload string -} - -// IsSuccess returns true when this post userinfo internal server error response has a 2xx status code -func (o *PostUserinfoInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this post userinfo internal server error response has a 3xx status code -func (o *PostUserinfoInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this post userinfo internal server error response has a 4xx status code -func (o *PostUserinfoInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this post userinfo internal server error response has a 5xx status code -func (o *PostUserinfoInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this post userinfo internal server error response a status code equal to that given -func (o *PostUserinfoInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the post userinfo internal server error response -func (o *PostUserinfoInternalServerError) Code() int { - return 500 -} - -func (o *PostUserinfoInternalServerError) Error() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoInternalServerError %+v", 500, o.Payload) -} - -func (o *PostUserinfoInternalServerError) String() string { - return fmt.Sprintf("[POST /userinfo][%d] postUserinfoInternalServerError %+v", 500, o.Payload) -} - -func (o *PostUserinfoInternalServerError) GetPayload() string { - return o.Payload -} - -func (o *PostUserinfoInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - // response payload - if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/go/client/userinfo/userinfo_client.go b/go/client/userinfo/userinfo_client.go deleted file mode 100644 index 52bca6ed..00000000 --- a/go/client/userinfo/userinfo_client.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package userinfo - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" -) - -// New creates a new userinfo API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for userinfo API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - PostUserinfo(params *PostUserinfoParams, opts ...ClientOption) (*PostUserinfoOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* -PostUserinfo Checks if a user is logged in and returns the user's information. -*/ -func (a *Client) PostUserinfo(params *PostUserinfoParams, opts ...ClientOption) (*PostUserinfoOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewPostUserinfoParams() - } - op := &runtime.ClientOperation{ - ID: "PostUserinfo", - Method: "POST", - PathPattern: "/userinfo", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"https"}, - Params: params, - Reader: &PostUserinfoReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*PostUserinfoOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for PostUserinfo: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/go/compile/compile.go b/go/compile/compile.go deleted file mode 100644 index 85b64406..00000000 --- a/go/compile/compile.go +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package compile - -import ( - "github.com/loopholelabs/scale/go/compile/templates" - "github.com/loopholelabs/scalefile" - "io" - "text/template" -) - -type Generator struct { - template *template.Template -} - -func NewGenerator() *Generator { - templ := template.Must(template.New("main").ParseFS(templates.FS, "*")) - return &Generator{ - template: templ, - } -} - -func (g *Generator) GenerateGoModfile(writer io.Writer, dependencies []*scalefile.Dependency) error { - return g.template.ExecuteTemplate(writer, "go.mod.templ", map[string]interface{}{ - "dependencies": dependencies, - }) -} - -func (g *Generator) GenerateGoMain(writer io.Writer, path string, signature string) error { - return g.template.ExecuteTemplate(writer, "main.go.templ", map[string]interface{}{ - "path": path, - "signature": signature, - }) -} diff --git a/go/compile/templates/go.mod.templ b/go/compile/templates/go.mod.templ deleted file mode 100644 index 02f36922..00000000 --- a/go/compile/templates/go.mod.templ +++ /dev/null @@ -1,7 +0,0 @@ -module compile - -go 1.18 - -{{ range $dependency := .dependencies -}} -require {{ $dependency.Name }} {{ $dependency.Version }} -{{end -}} diff --git a/go/compile/templates/main.go.templ b/go/compile/templates/main.go.templ deleted file mode 100644 index 94a440dd..00000000 --- a/go/compile/templates/main.go.templ +++ /dev/null @@ -1,36 +0,0 @@ -//go:build tinygo || js || wasm - -package main - -import ( - scale "{{ .path }}" - context "{{ .signature }}" -) - -// needed to satisfy compiler -func main() {} - -//export run -func run() uint64 { - ctx := context.New() - guestCtx := ctx.GuestContext() - err := guestCtx.FromReadBuffer() - if err != nil { - return packUint32(guestCtx.ErrorWriteBuffer(err)) - } - ctx, err = scale.Scale(ctx) - guestCtx = ctx.GuestContext() - if err != nil { - return packUint32(guestCtx.ErrorWriteBuffer(err)) - } - return packUint32(guestCtx.ToWriteBuffer()) -} - -//export resize -func resize(size uint32) uint32 { - return context.Resize(size) -} - -func packUint32(offset uint32, length uint32) uint64 { - return uint64(offset)<<32 | uint64(length) -} \ No newline at end of file diff --git a/go/function.go b/go/function.go deleted file mode 100644 index 2f51ec00..00000000 --- a/go/function.go +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runtime - -import ( - "context" - "fmt" - signature "github.com/loopholelabs/scale-signature" - "github.com/loopholelabs/scale/go/utils" - "github.com/loopholelabs/scalefile/scalefunc" - "github.com/tetratelabs/wazero" -) - -// Function is the runtime representation of a scale function. -type Function[T signature.Signature] struct { - compiled wazero.CompiledModule - scaleFunc *scalefunc.ScaleFunc - next *Function[T] - modulePool *Pool[T] -} - -func (f *Function[T]) Run(ctx context.Context, i *Instance[T]) error { - module, err := f.modulePool.Get() - if err != nil { - return fmt.Errorf("failed to get module from pool for function %s: %w", f.scaleFunc.Name, err) - } - - module.init(i) - ctxBuffer := i.runtimeContext().Write() - ctxBufferLength := uint64(len(ctxBuffer)) - writeBuffer, err := module.resize.Call(ctx, ctxBufferLength) - if err != nil { - return fmt.Errorf("failed to allocate memory for function '%s': %w", f.scaleFunc.Name, err) - } - - if !module.module.Memory().Write(uint32(writeBuffer[0]), ctxBuffer) { - return fmt.Errorf("failed to write memory for function '%s'", f.scaleFunc.Name) - } - - packed, err := module.run.Call(ctx) - if err != nil { - return fmt.Errorf("failed to run function '%s': %w", f.scaleFunc.Name, err) - } - if packed[0] == 0 { - return fmt.Errorf("failed to run function '%s'", f.scaleFunc.Name) - } - - offset, length := utils.UnpackUint32(packed[0]) - readBuffer, ok := module.module.Memory().Read(offset, length) - if !ok { - return fmt.Errorf("failed to read memory for function '%s'", f.scaleFunc.Name) - } - - err = i.runtimeContext().Read(readBuffer) - if err != nil { - return fmt.Errorf("error while running function '%s': %w", f.scaleFunc.Name, err) - } - - module.reset() - f.modulePool.Put(module) - return nil -} diff --git a/go/instance.go b/go/instance.go deleted file mode 100644 index e05d427d..00000000 --- a/go/instance.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runtime - -import ( - "context" - "errors" - "github.com/loopholelabs/scale-signature" -) - -type Instance[T signature.Signature] struct { - next Next[T] - runtime *Runtime[T] - ctx T - runtimeCtx signature.RuntimeContext -} - -func (r *Runtime[T]) Instance(next ...Next[T]) (*Instance[T], error) { - ctx := r.new() - i := &Instance[T]{ - runtime: r, - ctx: ctx, - runtimeCtx: ctx.RuntimeContext(), - } - - if len(next) > 0 && next[0] != nil { - i.next = next[0] - } else { - i.next = func(ctx T) (T, error) { - return ctx, nil - } - } - - return i, nil -} - -func (i *Instance[T]) Context() T { - return i.ctx -} - -func (i *Instance[T]) runtimeContext() signature.RuntimeContext { - return i.runtimeCtx -} - -func (i *Instance[T]) Run(ctx context.Context) error { - if i.runtime.head == nil { - return errors.New("no compiled functions found in runtime") - } - function := i.runtime.head - return function.Run(ctx, i) -} diff --git a/go/module.go b/go/module.go deleted file mode 100644 index 2b4e6199..00000000 --- a/go/module.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runtime - -import ( - "context" - "fmt" - "github.com/google/uuid" - signature "github.com/loopholelabs/scale-signature" - "github.com/tetratelabs/wazero/api" -) - -type Module[T signature.Signature] struct { - module api.Module - function *Function[T] - runtime *Runtime[T] - run api.Function - resize api.Function - - instance *Instance[T] -} - -func NewModule[T signature.Signature](ctx context.Context, f *Function[T], r *Runtime[T]) (*Module[T], error) { - module, err := r.runtime.InstantiateModule(ctx, f.compiled, r.moduleConfig.WithName(fmt.Sprintf("%s.%s", f.scaleFunc.Name, uuid.New().String()))) - if err != nil { - return nil, fmt.Errorf("failed to instantiate function '%s': %w", f.scaleFunc.Name, err) - } - - run := module.ExportedFunction("run") - resize := module.ExportedFunction("resize") - if run == nil || resize == nil { - return nil, fmt.Errorf("failed to find run or resize implementations for function %s", f.scaleFunc.Name) - } - - return &Module[T]{ - module: module, - function: f, - runtime: r, - run: run, - resize: resize, - }, nil -} - -func (m *Module[T]) init(i *Instance[T]) { - m.instance = i - m.runtime.modulesMu.Lock() - m.runtime.modules[m.module.Name()] = m - m.runtime.modulesMu.Unlock() -} - -func (m *Module[T]) reset() { - m.instance = nil - m.runtime.modulesMu.Lock() - delete(m.runtime.modules, m.module.Name()) - m.runtime.modulesMu.Unlock() -} diff --git a/go/next.go b/go/next.go deleted file mode 100644 index 829cf6fd..00000000 --- a/go/next.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runtime - -import ( - "context" - "github.com/tetratelabs/wazero/api" -) - -func (r *Runtime[T]) next(ctx context.Context, module api.Module, params []uint64) { - pointer := uint32(params[0]) - length := uint32(params[1]) - r.modulesMu.RLock() - m := r.modules[module.Name()] - r.modulesMu.RUnlock() - - if m == nil { - return - } - - buf, ok := m.module.Memory().Read(pointer, length) - if !ok { - return - } - - err := m.instance.runtimeContext().Read(buf) - if err != nil { - return - } - - var ctxBuffer []byte - if m.function.next == nil { - m.instance.ctx, err = m.instance.next(m.instance.Context()) - if err != nil { - ctxBuffer = m.instance.runtimeContext().Error(err) - } else { - ctxBuffer = m.instance.runtimeContext().Write() - } - } else { - err = m.function.next.Run(ctx, m.instance) - if err != nil { - ctxBuffer = m.instance.runtimeContext().Error(err) - } else { - ctxBuffer = m.instance.runtimeContext().Write() - } - } - - ctxBufferLength := uint64(len(ctxBuffer)) - writeBuffer, err := m.resize.Call(ctx, ctxBufferLength) - if err != nil { - return - } - module.Memory().Write(uint32(writeBuffer[0]), ctxBuffer) - - return -} diff --git a/go/registry/registry.go b/go/registry/registry.go deleted file mode 100644 index 98cf1af9..00000000 --- a/go/registry/registry.go +++ /dev/null @@ -1,317 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package registry - -import ( - "crypto/sha256" - "encoding/hex" - "errors" - "fmt" - openapiClient "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" - "github.com/loopholelabs/auth" - "github.com/loopholelabs/auth/pkg/client/openapi" - "github.com/loopholelabs/auth/pkg/client/session" - "github.com/loopholelabs/scale/go/client" - "github.com/loopholelabs/scale/go/client/models" - "github.com/loopholelabs/scale/go/client/registry" - "github.com/loopholelabs/scale/go/storage" - "github.com/loopholelabs/scalefile/scalefunc" - "io" - "net/http" - "net/url" -) - -const ( - DefaultOrganization = "scale" -) - -var ( - DefaultCookieURL = &url.URL{ - Scheme: "https", - Host: "scale.sh", - } -) - -type PullPolicy string - -const ( - AlwaysPullPolicy PullPolicy = "always" - IfNotPresentPullPolicy = "if-not-present" - NeverPullPolicy = "never" -) - -var ( - ErrHashMismatch = errors.New("hash mismatch") - ErrNoFunction = errors.New("function does not exist locally and pull policy does not allow pulling from registry") - ErrDownloadFailed = errors.New("scale function could not be pull from the registry") -) - -type config struct { - pullPolicy PullPolicy - cacheDirectory string - apiKey string - cookieURL *url.URL - baseURL string - organization string - client *client.ScaleAPIV1 - storage *storage.Storage -} - -type Option func(config *config) - -func WithPullPolicy(pullPolicy PullPolicy) Option { - return func(config *config) { - config.pullPolicy = pullPolicy - } -} - -func WithCacheDirectory(cacheDirectory string) Option { - return func(config *config) { - config.cacheDirectory = cacheDirectory - } -} - -func WithStorage(st *storage.Storage) Option { - return func(config *config) { - config.storage = st - } -} - -func WithAPIKey(apiKey string) Option { - return func(config *config) { - config.apiKey = apiKey - } -} - -func WithBaseURL(baseURL string) Option { - return func(config *config) { - config.baseURL = baseURL - } -} - -func WithOrganization(organization string) Option { - return func(config *config) { - config.organization = organization - } -} - -func WithCookieURL(cookieURL *url.URL) Option { - return func(config *config) { - config.cookieURL = cookieURL - } -} - -func WithClient(client *client.ScaleAPIV1) Option { - return func(config *config) { - config.client = client - } -} - -func Download(name string, tag string, opts ...Option) (*scalefunc.ScaleFunc, error) { - conf := &config{ - pullPolicy: IfNotPresentPullPolicy, - baseURL: client.DefaultHost, - cookieURL: DefaultCookieURL, - organization: DefaultOrganization, - } - for _, opt := range opts { - opt(conf) - } - - if conf.baseURL == "" { - conf.baseURL = client.DefaultHost - } - - if conf.cookieURL == nil { - conf.cookieURL = DefaultCookieURL - } - - if conf.organization == "" { - conf.organization = DefaultOrganization - } - - var err error - if conf.storage == nil { - conf.storage = storage.Default - if conf.cacheDirectory != "" { - conf.storage, err = storage.New(conf.cacheDirectory) - if err != nil { - return nil, fmt.Errorf("failed to create storage for directory %s: %w", conf.cacheDirectory, err) - } - } - } - - if conf.client == nil { - var o *openapiClient.Runtime - if conf.apiKey != "" { - o, err = openapi.AuthenticatedClient(conf.cookieURL, conf.baseURL, client.DefaultBasePath, client.DefaultSchemes, nil, &session.Session{ - Kind: auth.KindAPIKey, - Value: conf.apiKey, - }) - if err != nil { - return nil, err - } - } else { - o = openapi.UnauthenticatedClient(conf.baseURL, client.DefaultBasePath, client.DefaultSchemes, nil) - } - - conf.client = client.New(o, strfmt.Default) - } - - switch conf.pullPolicy { - case NeverPullPolicy: - entry, err := conf.storage.Get(name, tag, conf.organization, "") - if err != nil { - return nil, err - } - if entry != nil { - return entry.ScaleFunc, nil - } - return nil, ErrNoFunction - case IfNotPresentPullPolicy: - entry, err := conf.storage.Get(name, tag, conf.organization, "") - if err != nil { - return nil, err - } - if entry != nil { - return entry.ScaleFunc, nil - } - var fn *models.ModelsGetFunctionResponse - if conf.organization == DefaultOrganization { - res, err := conf.client.Registry.GetRegistryFunctionNameTag(registry.NewGetRegistryFunctionNameTagParams().WithName(name).WithTag(tag)) - if err != nil { - return nil, fmt.Errorf("failed to get function %s/%s:%s from registry %s: %w", conf.organization, name, tag, conf.baseURL, err) - } - fn = res.GetPayload() - } else { - res, err := conf.client.Registry.GetRegistryFunctionOrganizationNameTag(registry.NewGetRegistryFunctionOrganizationNameTagParams().WithName(name).WithTag(tag).WithOrganization(conf.organization)) - if err != nil { - return nil, fmt.Errorf("failed to get function %s/%s:%s from registry %s: %w", conf.organization, name, tag, conf.baseURL, err) - } - fn = res.GetPayload() - } - res, err := http.Get(fn.PresignedURL) - if err != nil { - return nil, err - } - defer func() { - _ = res.Body.Close() - }() - - if res.StatusCode != 200 { - return nil, ErrDownloadFailed - } - - data, err := io.ReadAll(res.Body) - if err != nil { - return nil, err - } - - h := sha256.New() - h.Write(data) - bs := h.Sum(nil) - hash := hex.EncodeToString(bs) - if hash != fn.Hash { - return nil, ErrHashMismatch - } - - sf := new(scalefunc.ScaleFunc) - err = sf.Decode(data) - if err != nil { - return nil, fmt.Errorf("failed to decode retrieved scale function %s/%s:%s: %w", conf.organization, name, tag, err) - } - - err = conf.storage.Put(name, tag, conf.organization, hash, sf) - if err != nil { - return nil, fmt.Errorf("failed to store retrieved scale function %s/%s:%s: %w", conf.organization, name, tag, err) - } - - return sf, nil - case AlwaysPullPolicy: - entry, err := conf.storage.Get(name, tag, conf.organization, "") - if err != nil { - return nil, err - } - var fn *models.ModelsGetFunctionResponse - if conf.organization == DefaultOrganization { - res, err := conf.client.Registry.GetRegistryFunctionNameTag(registry.NewGetRegistryFunctionNameTagParams().WithName(name).WithTag(tag)) - if err != nil { - return nil, fmt.Errorf("failed to get function %s/%s:%s from registry %s: %w", conf.organization, name, tag, conf.baseURL, err) - } - fn = res.GetPayload() - } else { - res, err := conf.client.Registry.GetRegistryFunctionOrganizationNameTag(registry.NewGetRegistryFunctionOrganizationNameTagParams().WithName(name).WithTag(tag).WithOrganization(conf.organization)) - if err != nil { - return nil, fmt.Errorf("failed to get function %s/%s:%s from registry %s: %w", conf.organization, name, tag, conf.baseURL, err) - } - fn = res.GetPayload() - } - if entry != nil { - if fn.Hash == entry.Hash { - return entry.ScaleFunc, nil - } - } - - res, err := http.Get(fn.PresignedURL) - if err != nil { - return nil, err - } - defer func() { - _ = res.Body.Close() - }() - - if res.StatusCode != 200 { - return nil, ErrDownloadFailed - } - - data, err := io.ReadAll(res.Body) - if err != nil { - return nil, err - } - - h := sha256.New() - h.Write(data) - bs := h.Sum(nil) - computedHash := hex.EncodeToString(bs) - if computedHash != fn.Hash { - return nil, ErrHashMismatch - } - - sf := new(scalefunc.ScaleFunc) - err = sf.Decode(data) - if err != nil { - return nil, fmt.Errorf("failed to decode retrieved scale function %s/%s:%s: %w", conf.organization, name, tag, err) - } - - if entry != nil { - err = conf.storage.Delete(name, tag, entry.Organization, entry.Hash) - if err != nil { - return nil, fmt.Errorf("failed to delete existing scale function %s/%s:%s: %w", entry.Organization, name, tag, err) - } - } - - err = conf.storage.Put(name, tag, conf.organization, computedHash, sf) - if err != nil { - return nil, fmt.Errorf("failed to store retrieved scale function %s/%s:%s: %w", conf.organization, name, tag, err) - } - - return sf, nil - default: - return nil, fmt.Errorf("unknown pull policy %s", conf.pullPolicy) - } -} diff --git a/go/registry/registry_test.go b/go/registry/registry_test.go deleted file mode 100644 index 2bcaac7e..00000000 --- a/go/registry/registry_test.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package registry - -import ( - "crypto/sha256" - "encoding/hex" - "github.com/loopholelabs/scale/go/storage" - "os" - "testing" - - "github.com/loopholelabs/scalefile/scalefunc" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -const testingAPIBaseURl = "https://api.dev.scale.sh/v1" - -func TestPulldownCache(t *testing.T) { - tempDir := t.TempDir() - st, err := storage.New(tempDir) - require.NoError(t, err) - - sf := &scalefunc.ScaleFunc{ - Version: scalefunc.V1Alpha, - Name: "Test1", - Signature: "signature1", - Tag: "1", - Language: scalefunc.Go, - Function: []byte("Hello world"), - } - - function := "TestFunction" - tag := "1" - - h := sha256.New() - h.Write(sf.Function) - - bs := h.Sum(nil) - - hash := hex.EncodeToString(bs) - err = st.Put(function, tag, DefaultOrganization, hash, sf) - require.NoError(t, err) - - newsf, err := Download(function, tag, WithCacheDirectory(tempDir), WithPullPolicy(NeverPullPolicy)) - - require.NoError(t, err) - - newsf.Size = 0 - newsf.Checksum = "" - - assert.EqualValues(t, sf, newsf) - require.NoError(t, err) -} - -func TestRegistryDownload(t *testing.T) { - /* This test requires a valid API key for the scale dev api to run, the SCALE_API_KEY environment variable must be - set in the testing environment. */ - apiKey := os.Getenv("SCALE_API_KEY") - if apiKey == "" { - t.Skip("Skipping test, SCALE_API_KEY environment variable not set") - } - sf, err := Download("TestRegistryDownload", "1", - WithAPIKey(apiKey), - WithBaseURL(testingAPIBaseURl), - WithOrganization("alex"), - ) - require.NoError(t, err) - require.Equal(t, "TestRegistryDownload", sf.Name) - require.Equal(t, "1", sf.Tag) - require.Equal(t, "signature1", sf.Signature) - require.Equal(t, scalefunc.Go, sf.Language) - require.Equal(t, scalefunc.V1Alpha, sf.Version) -} diff --git a/go/runtime.go b/go/runtime.go deleted file mode 100644 index 91cf9c8c..00000000 --- a/go/runtime.go +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// Package runtime implements the Scale Runtime in Go. -package runtime - -import ( - "context" - "crypto/rand" - "errors" - "fmt" - "github.com/loopholelabs/scale-signature" - httpSignature "github.com/loopholelabs/scale-signature-http" - "github.com/loopholelabs/scalefile/scalefunc" - "github.com/tetratelabs/wazero" - "github.com/tetratelabs/wazero/api" - "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" - "sync" -) - -var ( - NoFunctionsError = errors.New("no functions found in runtime") -) - -// Next is the next function in the middleware chain. It's meant to be implemented -// by whatever adapter is being used. -type Next[T signature.Signature] func(ctx T) (T, error) - -// Runtime is the Scale Runtime. It is responsible for initializing -// and managing the WASM runtime as well as the scale function chain. -type Runtime[T signature.Signature] struct { - runtime wazero.Runtime - moduleConfig wazero.ModuleConfig - - new signature.NewSignature[T] - - functions []*Function[T] - head *Function[T] - tail *Function[T] - - modulesMu sync.RWMutex - modules map[string]*Module[T] -} - -func New(ctx context.Context, functions []*scalefunc.ScaleFunc) (*Runtime[*httpSignature.Context], error) { - return NewWithSignature(ctx, httpSignature.New, functions) -} - -func NewWithSignature[T signature.Signature](ctx context.Context, sig signature.NewSignature[T], functions []*scalefunc.ScaleFunc) (*Runtime[T], error) { - if len(functions) == 0 { - return nil, NoFunctionsError - } - - r := &Runtime[T]{ - runtime: wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig().WithCloseOnContextDone(true)), - moduleConfig: wazero.NewModuleConfig().WithSysNanotime().WithSysWalltime().WithRandSource(rand.Reader), - modules: make(map[string]*Module[T]), - new: sig, - } - - module := r.runtime.NewHostModuleBuilder("env"). - NewFunctionBuilder(). - WithGoModuleFunction(api.GoModuleFunc(r.next), []api.ValueType{api.ValueTypeI32, api.ValueTypeI32}, []api.ValueType{}). - WithParameterNames("pointer", "length").Export("next") - - compiled, err := module.Compile(ctx) - if err != nil { - return nil, fmt.Errorf("failed to compile env: %w", err) - } - - _, err = r.runtime.InstantiateModule(ctx, compiled, r.moduleConfig) - if err != nil { - return nil, fmt.Errorf("failed to instantiate env: %w", err) - } - - _, err = wasi_snapshot_preview1.Instantiate(ctx, r.runtime) - if err != nil { - return nil, fmt.Errorf("failed to instantiate wasi: %w", err) - } - - for _, f := range functions { - sf, err := r.compileFunction(ctx, f) - if err != nil { - return nil, fmt.Errorf("failed to compile function '%s': %w", f.Name, err) - } - if r.head == nil { - r.head = sf - } - if r.tail != nil { - r.tail.next = sf - } - r.tail = sf - } - - return r, nil -} - -func (r *Runtime[T]) compileFunction(ctx context.Context, scaleFunc *scalefunc.ScaleFunc) (*Function[T], error) { - compiled, err := r.runtime.CompileModule(ctx, scaleFunc.Function) - if err != nil { - return nil, fmt.Errorf("failed to compile function '%s': %w", scaleFunc.Name, err) - } - - f := &Function[T]{ - scaleFunc: scaleFunc, - compiled: compiled, - } - - f.modulePool = NewPool[T](ctx, f, r) - - r.functions = append(r.functions, f) - return f, nil -} diff --git a/go/runtime_test.go b/go/runtime_test.go deleted file mode 100644 index f4136387..00000000 --- a/go/runtime_test.go +++ /dev/null @@ -1,721 +0,0 @@ -//go:build !tinygo && !js && !wasm - -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package runtime - -import ( - "context" - "errors" - httpSignature "github.com/loopholelabs/scale-signature-http" - "github.com/loopholelabs/scale/go/tests/harness" - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" - "github.com/loopholelabs/scalefile" - "github.com/loopholelabs/scalefile/scalefunc" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "os" - "testing" -) - -type TestCase struct { - Name string - Module *harness.Module - Run func(*scalefunc.ScaleFunc, *testing.T) -} - -func TestRuntimeGo(t *testing.T) { - passthroughModule := &harness.Module{ - Name: "passthrough", - Path: "tests/modules/passthrough/passthrough.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - modifyModule := &harness.Module{ - Name: "modify", - Path: "tests/modules/modify/modify.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - nextModule := &harness.Module{ - Name: "next", - Path: "tests/modules/next/next.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - modifyNextModule := &harness.Module{ - Name: "modifynext", - Path: "tests/modules/modifynext/modifynext.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - fileModule := &harness.Module{ - Name: "file", - Path: "tests/modules/file/file.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - networkModule := &harness.Module{ - Name: "network", - Path: "tests/modules/network/network.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - panicModule := &harness.Module{ - Name: "panic", - Path: "tests/modules/panic/panic.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/example-signature", - } - - badSignatureModule := &harness.Module{ - Name: "bad-signature", - Path: "tests/modules/bad-signature/bad-signature.go", - Signature: "github.com/loopholelabs/scale/go/tests/signature/bad-signature", - } - - modules := []*harness.Module{passthroughModule, modifyModule, nextModule, modifyNextModule, fileModule, networkModule, panicModule, badSignatureModule} - - generatedModules := harness.GoSetup(t, modules, "github.com/loopholelabs/scale/go/tests/modules") - - var testCases = []TestCase{ - { - Name: "Passthrough", - Module: passthroughModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data", i.Context().Data) - }, - }, - { - Name: "Modify", - Module: modifyModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "modified", i.Context().Data) - }, - }, - { - Name: "Next", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = "Hello, World!" - return ctx, nil - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Hello, World!", i.Context().Data) - }, - }, - { - Name: "ModifyNext", - Module: modifyNextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = ctx.Data + "-next" - return ctx, nil - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "modified-next", i.Context().Data) - }, - }, - { - Name: "NextError", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - return nil, errors.New("next error") - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.ErrorIs(t, err, errors.New("next error")) - }, - }, - { - Name: "File", - Module: fileModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.Error(t, err) - }, - }, - { - Name: "Network", - Module: networkModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.Error(t, err) - }, - }, - { - Name: "Panic", - Module: panicModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.Error(t, err) - }, - }, - { - Name: "BadSignature", - Module: badSignatureModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - assert.Error(t, err) - }, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { - module, err := os.ReadFile(generatedModules[testCase.Module]) - require.NoError(t, err) - - scaleFunc := &scalefunc.ScaleFunc{ - Version: scalefunc.V1Alpha, - Name: "TestName", - Tag: "TestTag", - Signature: "ExampleName@ExampleVersion", - Language: scalefunc.Go, - Function: module, - } - testCase.Run(scaleFunc, t) - }) - } -} - -func TestRuntimeHTTPSignatureGo(t *testing.T) { - passthroughModule := &harness.Module{ - Name: "http-passthrough", - Path: "tests/modules/http-passthrough/http-passthrough.go", - Signature: "github.com/loopholelabs/scale-signature-http", - } - - handlerModule := &harness.Module{ - Name: "http-handler", - Path: "tests/modules/http-handler/http-handler.go", - Signature: "github.com/loopholelabs/scale-signature-http", - } - - nextModule := &harness.Module{ - Name: "http-next", - Path: "tests/modules/http-next/http-next.go", - Signature: "github.com/loopholelabs/scale-signature-http", - } - - modules := []*harness.Module{passthroughModule, handlerModule, nextModule} - - generatedModules := harness.GoSetup(t, modules, "github.com/loopholelabs/scale/go/tests/modules") - - var testCases = []TestCase{ - { - Name: "Passthrough", - Module: passthroughModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data", string(i.Context().Response.Body)) - }, - }, - { - Name: "Handler", - Module: handlerModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data-modified", string(i.Context().Response.Body)) - }, - }, - { - Name: "Next", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(func(ctx *httpSignature.Context) (*httpSignature.Context, error) { - ctx.Response.Body = append(ctx.Response.Body, []byte("-next")...) - return ctx, nil - }) - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data-modified-next", string(i.Context().Response.Body)) - }, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { - module, err := os.ReadFile(generatedModules[testCase.Module]) - require.NoError(t, err) - - scaleFunc := &scalefunc.ScaleFunc{ - Version: scalefunc.V1Alpha, - Name: "TestName", - Tag: "TestTag", - Signature: "ExampleName@ExampleVersion", - Language: scalefunc.Go, - Function: module, - } - testCase.Run(scaleFunc, t) - }) - } -} - -func TestRuntimeRs(t *testing.T) { - passthroughModule := &harness.Module{ - Name: "passthrough", - Path: "../rust/tests/modules/passthrough/passthrough.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - modifyModule := &harness.Module{ - Name: "modify", - Path: "../rust/tests/modules/modify/modify.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - nextModule := &harness.Module{ - Name: "next", - Path: "../rust/tests/modules/next/next.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - modifyNextModule := &harness.Module{ - Name: "modifynext", - Path: "../rust/tests/modules/modifynext/modifynext.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - fileModule := &harness.Module{ - Name: "file", - Path: "../rust/tests/modules/file/file.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - networkModule := &harness.Module{ - Name: "network", - Path: "../rust/tests/modules/network/network.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - panicModule := &harness.Module{ - Name: "panic", - Path: "../rust/tests/modules/panic/panic.rs", - Signature: "example_signature", - SignaturePath: "../../../signature/example-signature", - } - - badSignatureModule := &harness.Module{ - Name: "bad_signature", - Path: "../rust/tests/modules/bad_signature/bad_signature.rs", - Signature: "bad_signature", - SignaturePath: "../../../signature/bad-signature", - } - - modules := []*harness.Module{passthroughModule, modifyModule, nextModule, modifyNextModule, fileModule, networkModule, panicModule, badSignatureModule} - - dependencies := []*scalefile.Dependency{ - { - Name: "scale_signature", - Version: "0.2.11", - }, - } - - generatedModules := harness.RustSetup(t, modules, dependencies) - - var testCases = []TestCase{ - { - Name: "Passthrough", - Module: passthroughModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data", i.Context().Data) - }, - }, - { - Name: "Modify", - Module: modifyModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "modified", i.Context().Data) - }, - }, - { - Name: "Next", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = "Hello, World!" - return ctx, nil - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Hello, World!", i.Context().Data) - }, - }, - { - Name: "ModifyNext", - Module: modifyNextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = ctx.Data + "-next" - return ctx, nil - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - i.Context().Data = "Test Data" - - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "modified-next", i.Context().Data) - }, - }, - { - Name: "NextError", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - next := func(ctx *signature.Context) (*signature.Context, error) { - return nil, errors.New("next error") - } - - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(next) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.ErrorIs(t, err, errors.New("next error")) - }, - }, - { - Name: "File", - Module: fileModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.ErrorContains(t, err, "operation not supported on this platform") - }, - }, - { - Name: "Network", - Module: networkModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.ErrorContains(t, err, "operation not supported on this platform") - }, - }, - { - Name: "Panic", - Module: panicModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - require.Error(t, err) - }, - }, - { - Name: "BadSignature", - Module: badSignatureModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := NewWithSignature(context.Background(), signature.New, []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(nil) - require.NoError(t, err) - - err = i.Run(context.Background()) - assert.Error(t, err) - }, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { - module, err := os.ReadFile(generatedModules[testCase.Module]) - require.NoError(t, err) - - scaleFunc := &scalefunc.ScaleFunc{ - Version: scalefunc.V1Alpha, - Name: "TestName", - Tag: "TestTag", - Signature: "ExampleName@ExampleVersion", - Language: scalefunc.Rust, - Function: module, - } - testCase.Run(scaleFunc, t) - }) - } -} - -func TestRuntimeHTTPSignatureRs(t *testing.T) { - passthroughModule := &harness.Module{ - Name: "http_passthrough", - Path: "../rust/tests/modules/http_passthrough/http_passthrough.rs", - Signature: "scale_signature_http", - } - - handlerModule := &harness.Module{ - Name: "http_handler", - Path: "../rust/tests/modules/http_handler/http_handler.rs", - Signature: "scale_signature_http", - } - - nextModule := &harness.Module{ - Name: "http_next", - Path: "../rust/tests/modules/http_next/http_next.rs", - Signature: "scale_signature_http", - } - - modules := []*harness.Module{passthroughModule, handlerModule, nextModule} - - dependencies := []*scalefile.Dependency{ - { - Name: "scale_signature", - Version: "0.2.11", - }, - { - Name: "scale_signature_http", - Version: "0.3.8", - }, - } - - generatedModules := harness.RustSetup(t, modules, dependencies) - - var testCases = []TestCase{ - { - Name: "Passthrough", - Module: passthroughModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data", string(i.Context().Response.Body)) - }, - }, - { - Name: "Handler", - Module: handlerModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance() - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data-modified", string(i.Context().Response.Body)) - }, - }, - { - Name: "Next", - Module: nextModule, - Run: func(scaleFunc *scalefunc.ScaleFunc, t *testing.T) { - r, err := New(context.Background(), []*scalefunc.ScaleFunc{scaleFunc}) - require.NoError(t, err) - - i, err := r.Instance(func(ctx *httpSignature.Context) (*httpSignature.Context, error) { - ctx.Response.Body = append(ctx.Response.Body, []byte("-next")...) - return ctx, nil - }) - require.NoError(t, err) - - i.Context().Response.Body = []byte("Test Data") - err = i.Run(context.Background()) - assert.NoError(t, err) - - assert.Equal(t, "Test Data-modified-next", string(i.Context().Response.Body)) - }, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { - module, err := os.ReadFile(generatedModules[testCase.Module]) - require.NoError(t, err) - - scaleFunc := &scalefunc.ScaleFunc{ - Version: scalefunc.V1Alpha, - Name: "TestName", - Tag: "TestTag", - Signature: "ExampleName@ExampleVersion", - Language: scalefunc.Go, - Function: module, - } - testCase.Run(scaleFunc, t) - }) - } -} diff --git a/go/tests/harness/harness.go b/go/tests/harness/harness.go deleted file mode 100644 index 3b99ec77..00000000 --- a/go/tests/harness/harness.go +++ /dev/null @@ -1,193 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package harness - -import ( - "fmt" - "github.com/loopholelabs/scale/go/compile" - rustCompile "github.com/loopholelabs/scale/rust/compile" - "github.com/loopholelabs/scalefile" - "github.com/stretchr/testify/require" - "io" - "os" - "os/exec" - "path" - "testing" -) - -type Module struct { - Path string - Name string - Signature string - SignaturePath string - Dependencies []*scalefile.Dependency -} - -func GoSetup(t testing.TB, modules []*Module, importPath string) map[*Module]string { - tinygo, err := exec.LookPath("tinygo") - require.NoError(t, err, "tinygo not found in path") - - t.Cleanup(func() { - for _, module := range modules { - moduleDir := path.Dir(module.Path) - err := os.RemoveAll(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()))) - if !os.IsNotExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to remove module %s", module.Name)) - } - } - }) - - g := compile.NewGenerator() - - generated := make(map[*Module]string) - - for _, module := range modules { - _, err = os.Stat(module.Path) - require.NoError(t, err, fmt.Sprintf("module %s not found", module.Name)) - - moduleDir := path.Dir(module.Path) - - err = os.Mkdir(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name())), 0755) - if !os.IsExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to create build directory for scale function %s", module.Name)) - } - - file, err := os.OpenFile(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "main.go"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - require.NoError(t, err, fmt.Sprintf("failed to create main.go for scale function %s", module.Name)) - - err = g.GenerateGoMain(file, fmt.Sprintf("%s/%s/%s-%s-build/scale", importPath, module.Name, module.Name, t.Name()), module.Signature) - require.NoError(t, err, fmt.Sprintf("failed to generate main.go for scale function %s", module.Name)) - - err = file.Close() - require.NoError(t, err, fmt.Sprintf("failed to close main.go for scale function %s", module.Name)) - - err = os.Mkdir(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "scale"), 0755) - if !os.IsExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to create scale directory for scale function %s", module.Name)) - } - - scale, err := os.OpenFile(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "scale", "scale.go"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - require.NoError(t, err, fmt.Sprintf("failed to create scale.go for scale function %s", module.Name)) - - file, err = os.Open(module.Path) - require.NoError(t, err, fmt.Sprintf("failed to open scale function %s", module.Name)) - - _, err = io.Copy(scale, file) - require.NoError(t, err, fmt.Sprintf("failed to copy scale function %s", module.Name)) - - err = scale.Close() - require.NoError(t, err, fmt.Sprintf("failed to close scale.go for scale function %s", module.Name)) - - err = file.Close() - require.NoError(t, err, fmt.Sprintf("failed to close scale function %s", module.Name)) - - wd, err := os.Getwd() - require.NoError(t, err, fmt.Sprintf("failed to get working directory for scale function %s", module.Name)) - - cmd := exec.Command(tinygo, "build", "-o", fmt.Sprintf("%s-%s.wasm", module.Name, t.Name()), "-scheduler=none", "-target=wasi", "--no-debug", "main.go") - cmd.Dir = path.Join(wd, moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name())) - - err = cmd.Run() - require.NoError(t, err, fmt.Sprintf("failed to build module %s", module.Name)) - - generated[module] = path.Join(cmd.Dir, fmt.Sprintf("%s-%s.wasm", module.Name, t.Name())) - } - - return generated -} - -func RustSetup(t testing.TB, modules []*Module, dependencies []*scalefile.Dependency) map[*Module]string { - cargo, err := exec.LookPath("cargo") - require.NoError(t, err, "cargo not found in path") - - t.Cleanup(func() { - for _, module := range modules { - moduleDir := path.Dir(module.Path) - err := os.RemoveAll(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()))) - if !os.IsNotExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to remove module %s", module.Name)) - } - } - }) - - g := rustCompile.NewGenerator() - - generated := make(map[*Module]string) - - for _, module := range modules { - _, err = os.Stat(module.Path) - require.NoError(t, err, fmt.Sprintf("module %s not found", module.Name)) - - moduleDir := path.Dir(module.Path) - - err = os.Mkdir(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name())), 0755) - if !os.IsExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to create build directory for scale function %s", module.Name)) - } - - file, err := os.OpenFile(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "lib.rs"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - require.NoError(t, err, fmt.Sprintf("failed to create lib.rs for scale function %s", module.Name)) - - err = g.GenerateRsLib(file, "./scale/scale.rs", module.Signature) - require.NoError(t, err, fmt.Sprintf("failed to generate lib.rs for scale function %s", module.Name)) - - err = file.Close() - require.NoError(t, err, fmt.Sprintf("failed to close lib.rs for scale function %s", module.Name)) - - cargoFile, err := os.OpenFile(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "Cargo.toml"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - require.NoError(t, err, fmt.Sprintf("failed to create Cargo.toml for scale function %s", module.Name)) - - err = g.GenerateRsCargo(cargoFile, dependencies, module.Signature, module.SignaturePath) - require.NoError(t, err, fmt.Sprintf("failed to generate lib.rs for scale function %s", module.Name)) - - err = cargoFile.Close() - require.NoError(t, err, fmt.Sprintf("failed to close Cargo.toml for scale function %s", module.Name)) - - err = os.Mkdir(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "scale"), 0755) - if !os.IsExist(err) { - require.NoError(t, err, fmt.Sprintf("failed to create scale directory for scale function %s", module.Name)) - } - - scale, err := os.OpenFile(path.Join(moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name()), "scale", "scale.rs"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) - require.NoError(t, err, fmt.Sprintf("failed to create scale.go for scale function %s", module.Name)) - - file, err = os.Open(module.Path) - require.NoError(t, err, fmt.Sprintf("failed to open scale function %s", module.Name)) - - _, err = io.Copy(scale, file) - require.NoError(t, err, fmt.Sprintf("failed to copy scale function %s", module.Name)) - - err = scale.Close() - require.NoError(t, err, fmt.Sprintf("failed to close scale.go for scale function %s", module.Name)) - - err = file.Close() - require.NoError(t, err, fmt.Sprintf("failed to close scale function %s", module.Name)) - - wd, err := os.Getwd() - require.NoError(t, err, fmt.Sprintf("failed to get working directory for scale function %s", module.Name)) - - cmd := exec.Command(cargo, "build", "--target", "wasm32-unknown-unknown", "--manifest-path", "Cargo.toml") - cmd.Dir = path.Join(wd, moduleDir, fmt.Sprintf("%s-%s-build", module.Name, t.Name())) - - err = cmd.Run() - require.NoError(t, err, fmt.Sprintf("wd: %s", cmd.Dir)) - - generated[module] = path.Join(cmd.Dir, "target/wasm32-unknown-unknown/debug/compile.wasm") - } - - return generated -} diff --git a/go/tests/modules/bad-signature/bad-signature.go b/go/tests/modules/bad-signature/bad-signature.go deleted file mode 100644 index c32d4eab..00000000 --- a/go/tests/modules/bad-signature/bad-signature.go +++ /dev/null @@ -1,26 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/bad-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - return ctx, nil -} diff --git a/go/tests/modules/file/file.go b/go/tests/modules/file/file.go deleted file mode 100644 index 4e09e6dc..00000000 --- a/go/tests/modules/file/file.go +++ /dev/null @@ -1,31 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" - "os" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - _, err := os.ReadFile("tests/modules/file/file.go") - if err != nil { - return nil, err - } - return ctx, nil -} diff --git a/go/tests/modules/http-handler/http-handler.go b/go/tests/modules/http-handler/http-handler.go deleted file mode 100644 index e29659d0..00000000 --- a/go/tests/modules/http-handler/http-handler.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale-signature-http" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - ctx.Response().SetBodyBytes(append(ctx.Response().Body(), []byte("-modified")...)) - return ctx, nil -} diff --git a/go/tests/modules/http-next/http-next.go b/go/tests/modules/http-next/http-next.go deleted file mode 100644 index a275954a..00000000 --- a/go/tests/modules/http-next/http-next.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale-signature-http" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - ctx.Response().SetBodyBytes(append(ctx.Response().Body(), []byte("-modified")...)) - return ctx.Next() -} diff --git a/go/tests/modules/http-passthrough/http-passthrough.go b/go/tests/modules/http-passthrough/http-passthrough.go deleted file mode 100644 index 59d4f49f..00000000 --- a/go/tests/modules/http-passthrough/http-passthrough.go +++ /dev/null @@ -1,26 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale-signature-http" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - return ctx, nil -} diff --git a/go/tests/modules/modify/modify.go b/go/tests/modules/modify/modify.go deleted file mode 100644 index 50cd3bd6..00000000 --- a/go/tests/modules/modify/modify.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = "modified" - return ctx, nil -} diff --git a/go/tests/modules/modifynext/modifynext.go b/go/tests/modules/modifynext/modifynext.go deleted file mode 100644 index 0d33fb66..00000000 --- a/go/tests/modules/modifynext/modifynext.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - ctx.Data = "modified" - return ctx.Next() -} diff --git a/go/tests/modules/network/network.go b/go/tests/modules/network/network.go deleted file mode 100644 index 5b7af977..00000000 --- a/go/tests/modules/network/network.go +++ /dev/null @@ -1,31 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" - "net" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - _, err := net.Dial("tcp", "google.com:80") - if err != nil { - return nil, err - } - return ctx, nil -} diff --git a/go/tests/modules/next/next.go b/go/tests/modules/next/next.go deleted file mode 100644 index f8cc2e87..00000000 --- a/go/tests/modules/next/next.go +++ /dev/null @@ -1,26 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - return ctx.Next() -} diff --git a/go/tests/modules/panic/panic.go b/go/tests/modules/panic/panic.go deleted file mode 100644 index 1cc66ba0..00000000 --- a/go/tests/modules/panic/panic.go +++ /dev/null @@ -1,26 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - panic("scale panic") -} diff --git a/go/tests/modules/passthrough/passthrough.go b/go/tests/modules/passthrough/passthrough.go deleted file mode 100644 index 2176fee3..00000000 --- a/go/tests/modules/passthrough/passthrough.go +++ /dev/null @@ -1,26 +0,0 @@ -//go:build tinygo || js || wasm - -/* -Copyright 2022 Loophole Labs - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scale - -import ( - signature "github.com/loopholelabs/scale/go/tests/signature/example-signature" -) - -func Scale(ctx *signature.Context) (*signature.Context, error) { - return ctx, nil -} diff --git a/go/tests/signature/bad-signature/bad.signature.go b/go/tests/signature/bad-signature/bad.signature.go deleted file mode 100644 index ecfee84e..00000000 --- a/go/tests/signature/bad-signature/bad.signature.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package bad - -import ( - "errors" - "github.com/loopholelabs/polyglot-go" -) - -var ( - NilDecode = errors.New("cannot decode into a nil root struct") -) - -type BadContext struct { - Data uint32 -} - -func NewBadContext() *BadContext { - return &BadContext{} -} - -func (x *BadContext) error(b *polyglot.Buffer, err error) { - polyglot.Encoder(b).Error(err) -} - -func (x *BadContext) internalEncode(b *polyglot.Buffer) { - if x == nil { - polyglot.Encoder(b).Nil() - } else { - polyglot.Encoder(b).Uint32(x.Data) - } -} - -func (x *BadContext) internalDecode(b []byte) error { - if x == nil { - return NilDecode - } - d := polyglot.GetDecoder(b) - defer d.Return() - return x.decode(d) -} - -func (x *BadContext) decode(d *polyglot.Decoder) error { - if d.Nil() { - return nil - } - - err, _ := d.Error() - if err != nil { - return err - } - x.Data, err = d.Uint32() - if err != nil { - return err - } - return nil -} diff --git a/go/tests/signature/bad-signature/guest.go b/go/tests/signature/bad-signature/guest.go deleted file mode 100644 index 7b3f7f22..00000000 --- a/go/tests/signature/bad-signature/guest.go +++ /dev/null @@ -1,106 +0,0 @@ -//go:build tinygo || js || wasm - -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package bad - -import ( - "github.com/loopholelabs/polyglot-go" - "github.com/loopholelabs/scale-signature" - "unsafe" -) - -var _ signature.GuestContext = (*GuestContext)(nil) -var _ signature.Context = (*Context)(nil) - -var ( - writeBuffer = polyglot.NewBuffer() - readBuffer []byte -) - -type GuestContext Context - -// Context is a context object for an incoming request. It is meant to be used -// inside the Scale function. -type Context struct { - *BadContext -} - -// New creates a new empty Context -func New() *Context { - return &Context{ - BadContext: NewBadContext(), - } -} - -// GuestContext converts the given Context to a GuestContext. -func (x *Context) GuestContext() signature.GuestContext { - return (*GuestContext)(x) -} - -// ToWriteBuffer serializes the Context into the global writeBuffer and returns the pointer to the buffer and its size -// -// This method should only be used to read the Context from the Scale Runtime. -// Users should not use this method. -func (x *GuestContext) ToWriteBuffer() (uint32, uint32) { - writeBuffer.Reset() - x.internalEncode(writeBuffer) - underlying := writeBuffer.Bytes() - ptr := &underlying[0] - unsafePtr := uintptr(unsafe.Pointer(ptr)) - return uint32(unsafePtr), uint32(writeBuffer.Len()) -} - -// FromReadBuffer deserializes the data into the Context from the global readBuffer -// -// It assumes that the readBuffer has been filled with the data from the Scale Runtime after -// a call to the Resize method -func (x *GuestContext) FromReadBuffer() error { - return x.internalDecode(readBuffer) -} - -// ErrorWriteBuffer serializes an error into the global writeBuffer and returns a pointer to the buffer and its size -// -// This method should only be used to write an error to the Scale Runtime, in place of the ToWriteBuffer method. -// Users should not use this method. -func (x *GuestContext) ErrorWriteBuffer(err error) (uint32, uint32) { - writeBuffer.Reset() - x.error(writeBuffer, err) - underlying := writeBuffer.Bytes() - ptr := &underlying[0] - unsafePtr := uintptr(unsafe.Pointer(ptr)) - return uint32(unsafePtr), uint32(writeBuffer.Len()) -} - -// Next calls the next host function after writing the Context into the global writeBuffer, -// then it reads the result from the global readBuffer back into the Context -func (x *Context) Next() (*Context, error) { - next(x.GuestContext().ToWriteBuffer()) - return x, x.GuestContext().FromReadBuffer() -} - -func Resize(size uint32) uint32 { - if uint32(cap(readBuffer)) < size { - readBuffer = append(make([]byte, 0, uint32(len(readBuffer))+size), readBuffer...) - } - readBuffer = readBuffer[:size] - return uint32(uintptr(unsafe.Pointer(&readBuffer[0]))) -} - -//export next -//go:linkname next -func next(offset uint32, length uint32) diff --git a/go/tests/signature/bad-signature/runtime.go b/go/tests/signature/bad-signature/runtime.go deleted file mode 100644 index b56fd857..00000000 --- a/go/tests/signature/bad-signature/runtime.go +++ /dev/null @@ -1,70 +0,0 @@ -//go:build !tinygo && !js && !wasm - -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package bad - -import ( - "github.com/loopholelabs/polyglot-go" - "github.com/loopholelabs/scale-signature" -) - -var _ signature.Signature = (*Context)(nil) -var _ signature.RuntimeContext = (*RuntimeContext)(nil) - -type RuntimeContext Context - -// Context is a context object for an incoming request. It is meant to be used -// inside the Scale function. -type Context struct { - *BadContext - buffer *polyglot.Buffer -} - -// New creates a new empty Context -func New() *Context { - return &Context{ - BadContext: NewBadContext(), - buffer: polyglot.NewBuffer(), - } -} - -// RuntimeContext converts a Context into a RuntimeContext. -func (x *Context) RuntimeContext() signature.RuntimeContext { - return (*RuntimeContext)(x) -} - -// Read reads the context from the given byte slice and returns an error if one occurred -// -// This method is meant to be used by the Scale Runtime to deserialize the Context -func (x *RuntimeContext) Read(b []byte) error { - return x.internalDecode(b) -} - -// Write writes the context into a byte slice and returns it -func (x *RuntimeContext) Write() []byte { - x.buffer.Reset() - x.internalEncode(x.buffer) - return x.buffer.Bytes() -} - -// Error writes the context into a byte slice and returns it -func (x *RuntimeContext) Error(err error) []byte { - x.buffer.Reset() - x.error(x.buffer, err) - return x.buffer.Bytes() -} diff --git a/go/tests/signature/example-signature/example.signature.go b/go/tests/signature/example-signature/example.signature.go deleted file mode 100644 index baf7fdce..00000000 --- a/go/tests/signature/example-signature/example.signature.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package example_signature - -import ( - "errors" - "github.com/loopholelabs/polyglot-go" -) - -var ( - NilDecode = errors.New("cannot decode into a nil root struct") -) - -type ExampleContext struct { - Data string -} - -func NewExampleContext() *ExampleContext { - return &ExampleContext{} -} - -func (x *ExampleContext) error(b *polyglot.Buffer, err error) { - polyglot.Encoder(b).Error(err) -} - -func (x *ExampleContext) internalEncode(b *polyglot.Buffer) { - if x == nil { - polyglot.Encoder(b).Nil() - } else { - polyglot.Encoder(b).String(x.Data) - } -} - -func (x *ExampleContext) internalDecode(b []byte) error { - if x == nil { - return NilDecode - } - d := polyglot.GetDecoder(b) - defer d.Return() - return x.decode(d) -} - -func (x *ExampleContext) decode(d *polyglot.Decoder) error { - if d.Nil() { - return nil - } - - err, _ := d.Error() - if err != nil { - return err - } - x.Data, err = d.String() - if err != nil { - return err - } - return nil -} diff --git a/go/tests/signature/example-signature/guest.go b/go/tests/signature/example-signature/guest.go deleted file mode 100644 index 0d7bf7f0..00000000 --- a/go/tests/signature/example-signature/guest.go +++ /dev/null @@ -1,106 +0,0 @@ -//go:build tinygo || js || wasm - -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package example_signature - -import ( - "github.com/loopholelabs/polyglot-go" - "github.com/loopholelabs/scale-signature" - "unsafe" -) - -var _ signature.GuestContext = (*GuestContext)(nil) -var _ signature.Context = (*Context)(nil) - -var ( - writeBuffer = polyglot.NewBuffer() - readBuffer []byte -) - -type GuestContext Context - -// Context is a context object for an incoming request. It is meant to be used -// inside the Scale function. -type Context struct { - *ExampleContext -} - -// New creates a new empty Context -func New() *Context { - return &Context{ - ExampleContext: NewExampleContext(), - } -} - -// GuestContext converts the given Context to a GuestContext. -func (x *Context) GuestContext() signature.GuestContext { - return (*GuestContext)(x) -} - -// ToWriteBuffer serializes the Context into the global writeBuffer and returns the pointer to the buffer and its size -// -// This method should only be used to read the Context from the Scale Runtime. -// Users should not use this method. -func (x *GuestContext) ToWriteBuffer() (uint32, uint32) { - writeBuffer.Reset() - x.internalEncode(writeBuffer) - underlying := writeBuffer.Bytes() - ptr := &underlying[0] - unsafePtr := uintptr(unsafe.Pointer(ptr)) - return uint32(unsafePtr), uint32(writeBuffer.Len()) -} - -// FromReadBuffer deserializes the data into the Context from the global readBuffer -// -// It assumes that the readBuffer has been filled with the data from the Scale Runtime after -// a call to the Resize method -func (x *GuestContext) FromReadBuffer() error { - return x.internalDecode(readBuffer) -} - -// ErrorWriteBuffer serializes an error into the global writeBuffer and returns a pointer to the buffer and its size -// -// This method should only be used to write an error to the Scale Runtime, in place of the ToWriteBuffer method. -// Users should not use this method. -func (x *GuestContext) ErrorWriteBuffer(err error) (uint32, uint32) { - writeBuffer.Reset() - x.error(writeBuffer, err) - underlying := writeBuffer.Bytes() - ptr := &underlying[0] - unsafePtr := uintptr(unsafe.Pointer(ptr)) - return uint32(unsafePtr), uint32(writeBuffer.Len()) -} - -// Next calls the next host function after writing the Context into the global writeBuffer, -// then it reads the result from the global readBuffer back into the Context -func (x *Context) Next() (*Context, error) { - next(x.GuestContext().ToWriteBuffer()) - return x, x.GuestContext().FromReadBuffer() -} - -func Resize(size uint32) uint32 { - if uint32(cap(readBuffer)) < size { - readBuffer = append(make([]byte, 0, uint32(len(readBuffer))+size), readBuffer...) - } - readBuffer = readBuffer[:size] - return uint32(uintptr(unsafe.Pointer(&readBuffer[0]))) -} - -//export next -//go:linkname next -func next(offset uint32, length uint32) diff --git a/go/tests/signature/example-signature/runtime.go b/go/tests/signature/example-signature/runtime.go deleted file mode 100644 index b76420c5..00000000 --- a/go/tests/signature/example-signature/runtime.go +++ /dev/null @@ -1,70 +0,0 @@ -//go:build !tinygo && !js && !wasm - -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package example_signature - -import ( - "github.com/loopholelabs/polyglot-go" - "github.com/loopholelabs/scale-signature" -) - -var _ signature.Signature = (*Context)(nil) -var _ signature.RuntimeContext = (*RuntimeContext)(nil) - -type RuntimeContext Context - -// Context is a context object for an incoming request. It is meant to be used -// inside the Scale function. -type Context struct { - *ExampleContext - buffer *polyglot.Buffer -} - -// New creates a new empty Context -func New() *Context { - return &Context{ - ExampleContext: NewExampleContext(), - buffer: polyglot.NewBuffer(), - } -} - -// RuntimeContext converts a Context into a RuntimeContext. -func (x *Context) RuntimeContext() signature.RuntimeContext { - return (*RuntimeContext)(x) -} - -// Read reads the context from the given byte slice and returns an error if one occurred -// -// This method is meant to be used by the Scale Runtime to deserialize the Context -func (x *RuntimeContext) Read(b []byte) error { - return x.internalDecode(b) -} - -// Write writes the context into a byte slice and returns it -func (x *RuntimeContext) Write() []byte { - x.buffer.Reset() - x.internalEncode(x.buffer) - return x.buffer.Bytes() -} - -// Error writes the context into a byte slice and returns it -func (x *RuntimeContext) Error(err error) []byte { - x.buffer.Reset() - x.error(x.buffer, err) - return x.buffer.Bytes() -} diff --git a/instance.go b/instance.go new file mode 100644 index 00000000..11083116 --- /dev/null +++ b/instance.go @@ -0,0 +1,93 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + "crypto/rand" + "fmt" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" +) + +// Instance is a single instance of a Scale Function chain +type Instance[T interfaces.Signature] struct { + // runtime is the runtime that this instance belongs to + runtime *Scale[T] + + // identifier is the unique identifier for this instance + identifier []byte + + // head is the head function in the chain for this instance + head *function[T] + + // next is the next function in the chain for this instance + next Next[T] +} + +func newInstance[T interfaces.Signature](ctx context.Context, runtime *Scale[T], next ...Next[T]) (*Instance[T], error) { + instance := &Instance[T]{ + runtime: runtime, + identifier: make([]byte, 16), + } + + _, err := rand.Read(instance.identifier) + if err != nil { + return nil, err + } + + if len(next) > 0 && next[0] != nil { + instance.next = next[0] + } else { + instance.next = func(ctx T) (T, error) { + return ctx, nil + } + } + + previousFunction := instance.head + nextTemplate := instance.runtime.head + + for nextTemplate != nil { + fn, err := newFunction(ctx, instance, nextTemplate) + if err != nil { + return nil, fmt.Errorf("failed to create function: %w", err) + } + if instance.head == nil { + instance.head = fn + } + if previousFunction != nil { + previousFunction.next = fn + } + previousFunction = fn + nextTemplate = nextTemplate.next + } + + return instance, nil +} + +func (i *Instance[T]) Run(ctx context.Context, signature T) error { + m, err := i.head.getModule(signature) + if err != nil { + return fmt.Errorf("failed to get module for function '%s': %w", i.head.template.identifier, err) + } + err = m.run(ctx) + i.head.putModule(m) + if err != nil { + return fmt.Errorf("failed to run function '%s': %w", i.head.template.identifier, err) + } + return nil +} diff --git a/instance.ts b/instance.ts new file mode 100644 index 00000000..7b23b4b6 --- /dev/null +++ b/instance.ts @@ -0,0 +1,81 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { randomBytes } from "crypto"; + +import { Signature } from "@loopholelabs/scale-signature-interfaces"; +import { NextFn, Scale } from "./scale"; +import {Func, NewFunc} from "./function"; + +const ErrNoCompiledFunctions = new Error("no compiled functions found in runtime"); + +export async function NewInstance(runtime: Scale, next?: NextFn): Promise> { + const i = new Instance(runtime, next); + await i.Ready(); + return i; +} + +export class Instance { + private readonly ready: Promise; + + private runtime: Scale; + public identifier: Buffer; + private head: undefined | Func; + next: NextFn; + + constructor(runtime: Scale, next?: NextFn) { + this.runtime = runtime; + this.identifier = randomBytes(16); + if (typeof next !== "undefined") { + this.next = next; + } else { + this.next = (ctx: T) => ctx; + } + + this.ready = new Promise(async (resolve) => { // eslint-disable-line no-async-promise-executor + let previousFunction = this.head; + let nextTemplate = this.runtime.head; + + while (typeof nextTemplate !== "undefined") { + const fn = await NewFunc(this, nextTemplate); + if (typeof this.head === "undefined") { + this.head = fn; + } + if (typeof previousFunction !== "undefined") { + previousFunction.next = fn; + } + previousFunction = fn; + nextTemplate = nextTemplate.next; + } + + resolve(); + }); + + } + + public async Ready() { + await this.ready; + } + + public async Run(signature: T) { + if (typeof this.head === "undefined") { + throw ErrNoCompiledFunctions; + } + const m = await this.head.GetModule(signature); + m.Run(); + this.head.PutModule(m); + } +} \ No newline at end of file diff --git a/integration/generate.go b/integration/generate.go new file mode 100644 index 00000000..8fda9598 --- /dev/null +++ b/integration/generate.go @@ -0,0 +1,17 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package integration holds integration tests for Scale +package integration + +//go:generate go test ./ --tags=integration,generate -v diff --git a/integration/generate_test.go b/integration/generate_test.go new file mode 100644 index 00000000..dafc71c0 --- /dev/null +++ b/integration/generate_test.go @@ -0,0 +1,142 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package integration + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator" + "github.com/loopholelabs/scale/signature/generator/golang" + "github.com/loopholelabs/scale/signature/generator/rust" + "github.com/loopholelabs/scale/signature/generator/typescript" +) + +const simpleSchema = ` +version = "v1alpha" +context = "Context" +model Context { + int32 A { + default = 0 + } + + int32 B { + default = 0 + } + + int32 C { + default = 0 + } +} +` + +func TestGenerateMasterTestingSchema(t *testing.T) { + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + require.Equal(t, "ModelWithAllFieldTypes", s.Context) + + guest, err := generator.GenerateGuestLocal(&generator.Options{ + Signature: s, + + GolangPackageImportPath: "signature", + GolangPackageVersion: "v0.1.0", + + RustPackageName: "local_example_latest_guest", + RustPackageVersion: "v0.1.0", + + TypescriptPackageName: "local-example-latest-guest", + TypescriptPackageVersion: "v0.1.0", + }) + require.NoError(t, err) + + golangSignatureDir := wd + "/golang_tests/signature" + for _, file := range guest.GolangFiles { + err = os.WriteFile(golangSignatureDir+"/"+file.Name(), file.Data(), 0644) + require.NoError(t, err) + } + + rustSignatureDir := wd + "/rust_tests/signature" + for _, file := range guest.RustFiles { + err = os.WriteFile(rustSignatureDir+"/"+file.Name(), file.Data(), 0644) + require.NoError(t, err) + } + + typescriptSignatureDir := wd + "/typescript_tests/signature" + for _, file := range guest.TypescriptFiles { + err = os.WriteFile(typescriptSignatureDir+"/"+file.Name(), file.Data(), 0644) + require.NoError(t, err) + } + + host, err := generator.GenerateHostLocal(&generator.Options{ + Signature: s, + + GolangPackageImportPath: "signature", + GolangPackageVersion: "v0.1.0", + + TypescriptPackageName: "local-example-latest-host", + TypescriptPackageVersion: "v0.1.0", + }) + require.NoError(t, err) + + golangSignatureDir = wd + "/golang_tests/host_signature" + for _, file := range host.GolangFiles { + if file.Name() != "go.mod" { + err = os.WriteFile(golangSignatureDir+"/"+file.Name(), file.Data(), 0644) + require.NoError(t, err) + } + } + + typescriptSignatureDir = wd + "/typescript_tests/host_signature" + for _, file := range host.TypescriptFiles { + err = os.WriteFile(typescriptSignatureDir+"/"+file.Name(), file.Data(), 0644) + require.NoError(t, err) + } +} + +func TestGenerateSimpleSchema(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(simpleSchema)) + require.NoError(t, err) + + formatted, err := golang.GenerateTypes(s, "generated") + require.NoError(t, err) + + err = os.WriteFile("./golang_tests/generated/generated.go", formatted, 0644) + require.NoError(t, err) + + formatted, err = rust.GenerateTypes(s, "generated") + require.NoError(t, err) + + err = os.WriteFile("./rust_tests/generated/generated.rs", formatted, 0644) + require.NoError(t, err) + + transpiled, err := typescript.GenerateTypesTranspiled(s, "generated", "generated.js") + require.NoError(t, err) + + err = os.WriteFile("./typescript_tests/generated/generated.js", transpiled.Javascript, 0644) + require.NoError(t, err) + + err = os.WriteFile("./typescript_tests/generated/generated.js.map", transpiled.SourceMap, 0644) + require.NoError(t, err) + + err = os.WriteFile("./typescript_tests/generated/generated.d.ts", transpiled.Declaration, 0644) + require.NoError(t, err) +} diff --git a/integration/golang_tests/function/example.go b/integration/golang_tests/function/example.go new file mode 100644 index 00000000..ddb6ff9f --- /dev/null +++ b/integration/golang_tests/function/example.go @@ -0,0 +1,30 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package example + +import ( + "fmt" + "signature" +) + +func Example(ctx *signature.ModelWithAllFieldTypes) (*signature.ModelWithAllFieldTypes, error) { + fmt.Printf("This is a Golang Function") + if ctx != nil { + ctx.StringField = "This is a Golang Function" + } + return signature.Next(ctx) +} diff --git a/integration/golang_tests/function/go.mod b/integration/golang_tests/function/go.mod new file mode 100644 index 00000000..c29dc724 --- /dev/null +++ b/integration/golang_tests/function/go.mod @@ -0,0 +1,9 @@ +module example + +go 1.20 + +replace signature => ../signature + +require signature v0.1.0 + +require github.com/loopholelabs/polyglot v1.1.3 // indirect diff --git a/integration/golang_tests/function/go.sum b/integration/golang_tests/function/go.sum new file mode 100644 index 00000000..af07f810 --- /dev/null +++ b/integration/golang_tests/function/go.sum @@ -0,0 +1,7 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/loopholelabs/polyglot v1.1.2 h1:9JE1m/IL8rgWIlykvebz98i4tjOGNOpgGIB3CqbfvrE= +github.com/loopholelabs/polyglot v1.1.2/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= +github.com/loopholelabs/polyglot v1.1.3/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/integration/golang_tests/generated/generated.go b/integration/golang_tests/generated/generated.go new file mode 100644 index 00000000..50a43bd3 --- /dev/null +++ b/integration/golang_tests/generated/generated.go @@ -0,0 +1,78 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: generated + +package generated + +import ( + "errors" + "github.com/loopholelabs/polyglot" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type Context struct { + A int32 + B int32 + C int32 +} + +func NewContext() *Context { + return &Context{ + + A: 0, + B: 0, + C: 0, + } +} + +func (x *Context) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.A) + e.Int32(x.B) + e.Int32(x.C) + + } +} + +func DecodeContext(x *Context, b []byte) (*Context, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeContext(x, d) +} + +func _decodeContext(x *Context, d *polyglot.Decoder) (*Context, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewContext() + } + + x.A, err = d.Int32() + if err != nil { + return nil, err + } + x.B, err = d.Int32() + if err != nil { + return nil, err + } + x.C, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} diff --git a/integration/golang_tests/host_signature/host.go b/integration/golang_tests/host_signature/host.go new file mode 100644 index 00000000..ce521217 --- /dev/null +++ b/integration/golang_tests/host_signature/host.go @@ -0,0 +1,66 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: signature + +package signature + +import ( + "github.com/loopholelabs/polyglot" + interfaces "github.com/loopholelabs/scale-signature-interfaces" +) + +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5" + +var _ interfaces.Signature = (*Signature)(nil) + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +type Signature struct { + Context *ModelWithAllFieldTypes + buf *polyglot.Buffer +} + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +func New() *Signature { + return &Signature{ + Context: NewModelWithAllFieldTypes(), + buf: polyglot.NewBuffer(), + } +} + +// Read reads the context from the given byte slice and returns an error if one occurred +// +// This method is meant to be used by the Scale Runtime to deserialize the Signature +func (x *Signature) Read(b []byte) error { + var err error + x.Context, err = DecodeModelWithAllFieldTypes(x.Context, b) + return err +} + +// Write writes the signature into a byte slice and returns it +// +// This method is meant to be used by the Scale Runtime to serialize the Signature +func (x *Signature) Write() []byte { + x.buf.Reset() + x.Context.Encode(x.buf) + return x.buf.Bytes() +} + +// Error writes the signature into a byte slice and returns it +// +// This method is meant to be used by the Scale Runtime to return an error +func (x *Signature) Error(err error) []byte { + x.buf.Reset() + polyglot.Encoder(x.buf).Error(err) + return x.buf.Bytes() +} + +// Hash returns the hash of the signature +// +// This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility +func (x *Signature) Hash() string { + return hash +} diff --git a/integration/golang_tests/host_signature/types.go b/integration/golang_tests/host_signature/types.go new file mode 100644 index 00000000..58e48635 --- /dev/null +++ b/integration/golang_tests/host_signature/types.go @@ -0,0 +1,1874 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: signature + +package signature + +import ( + "errors" + "github.com/loopholelabs/polyglot" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type GenericEnum uint32 + +const ( + GenericEnumFirstValue GenericEnum = 0 + + GenericEnumSecondValue GenericEnum = 1 + + GenericEnumDefaultValue GenericEnum = 2 +) + +func decodeGenericEnum(d *polyglot.Decoder) (GenericEnum, error) { + enumValue, err := d.Uint32() + if err != nil { + return 0, err + } + switch GenericEnum(enumValue) { + case GenericEnumFirstValue: + return GenericEnumFirstValue, nil + case GenericEnumSecondValue: + return GenericEnumSecondValue, nil + case GenericEnumDefaultValue: + return GenericEnumDefaultValue, nil + default: + return 0, InvalidEnum + } +} + +type EmptyModel struct { +} + +func NewEmptyModel() *EmptyModel { + return &EmptyModel{} +} + +func (x *EmptyModel) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModel(x *EmptyModel, b []byte) (*EmptyModel, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModel(x, d) +} + +func _decodeEmptyModel(x *EmptyModel, d *polyglot.Decoder) (*EmptyModel, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModel() + } + + return x, nil +} + +// EmptyModelWithDescription: Test Description +type EmptyModelWithDescription struct { +} + +func NewEmptyModelWithDescription() *EmptyModelWithDescription { + return &EmptyModelWithDescription{} +} + +func (x *EmptyModelWithDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModelWithDescription(x *EmptyModelWithDescription, b []byte) (*EmptyModelWithDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModelWithDescription(x, d) +} + +func _decodeEmptyModelWithDescription(x *EmptyModelWithDescription, d *polyglot.Decoder) (*EmptyModelWithDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModelWithDescription() + } + + return x, nil +} + +type ModelWithSingleStringField struct { + StringField string +} + +func NewModelWithSingleStringField() *ModelWithSingleStringField { + return &ModelWithSingleStringField{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringField) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringField(x *ModelWithSingleStringField, b []byte) (*ModelWithSingleStringField, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringField(x, d) +} + +func _decodeModelWithSingleStringField(x *ModelWithSingleStringField, d *polyglot.Decoder) (*ModelWithSingleStringField, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringField() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleStringFieldAndDescription: Test Description +type ModelWithSingleStringFieldAndDescription struct { + StringField string +} + +func NewModelWithSingleStringFieldAndDescription() *ModelWithSingleStringFieldAndDescription { + return &ModelWithSingleStringFieldAndDescription{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringFieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, b []byte) (*ModelWithSingleStringFieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringFieldAndDescription(x, d) +} + +func _decodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleStringFieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringFieldAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithSingleInt32Field struct { + Int32Field int32 +} + +func NewModelWithSingleInt32Field() *ModelWithSingleInt32Field { + return &ModelWithSingleInt32Field{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32Field) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, b []byte) (*ModelWithSingleInt32Field, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32Field(x, d) +} + +func _decodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, d *polyglot.Decoder) (*ModelWithSingleInt32Field, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32Field() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +type ModelWithSingleInt32FieldAndDescription struct { + Int32Field int32 +} + +func NewModelWithSingleInt32FieldAndDescription() *ModelWithSingleInt32FieldAndDescription { + return &ModelWithSingleInt32FieldAndDescription{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32FieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, b []byte) (*ModelWithSingleInt32FieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32FieldAndDescription(x, d) +} + +func _decodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleInt32FieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32FieldAndDescription() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithMultipleFields struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFields() *ModelWithMultipleFields { + return &ModelWithMultipleFields{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFields) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFields(x *ModelWithMultipleFields, b []byte) (*ModelWithMultipleFields, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFields(x, d) +} + +func _decodeModelWithMultipleFields(x *ModelWithMultipleFields, d *polyglot.Decoder) (*ModelWithMultipleFields, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFields() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithMultipleFieldsAndDescription: Test Description +type ModelWithMultipleFieldsAndDescription struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFieldsAndDescription() *ModelWithMultipleFieldsAndDescription { + return &ModelWithMultipleFieldsAndDescription{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, b []byte) (*ModelWithMultipleFieldsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithEnum struct { + EnumField GenericEnum +} + +func NewModelWithEnum() *ModelWithEnum { + return &ModelWithEnum{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnum) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnum(x *ModelWithEnum, b []byte) (*ModelWithEnum, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnum(x, d) +} + +func _decodeModelWithEnum(x *ModelWithEnum, d *polyglot.Decoder) (*ModelWithEnum, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnum() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +// ModelWithEnumAndDescription: Test Description +type ModelWithEnumAndDescription struct { + EnumField GenericEnum +} + +func NewModelWithEnumAndDescription() *ModelWithEnumAndDescription { + return &ModelWithEnumAndDescription{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, b []byte) (*ModelWithEnumAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAndDescription(x, d) +} + +func _decodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, d *polyglot.Decoder) (*ModelWithEnumAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +type ModelWithEnumAccessor struct { + EnumField GenericEnum +} + +func NewModelWithEnumAccessor() *ModelWithEnumAccessor { + return &ModelWithEnumAccessor{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnumAccessor(x *ModelWithEnumAccessor, b []byte) (*ModelWithEnumAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessor(x, d) +} + +func _decodeModelWithEnumAccessor(x *ModelWithEnumAccessor, d *polyglot.Decoder) (*ModelWithEnumAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessor() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +// ModelWithEnumAccessorAndDescription: Test Description +type ModelWithEnumAccessorAndDescription struct { + EnumField GenericEnum +} + +func NewModelWithEnumAccessorAndDescription() *ModelWithEnumAccessorAndDescription { + return &ModelWithEnumAccessorAndDescription{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, b []byte) (*ModelWithEnumAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessorAndDescription(x, d) +} + +func _decodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEnumAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessorAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +type ModelWithMultipleFieldsAccessor struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFieldsAccessor() *ModelWithMultipleFieldsAccessor { + return &ModelWithMultipleFieldsAccessor{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, b []byte) (*ModelWithMultipleFieldsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessor(x, d) +} + +func _decodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessor() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +type ModelWithMultipleFieldsAccessorAndDescription struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFieldsAccessorAndDescription() *ModelWithMultipleFieldsAccessorAndDescription { + return &ModelWithMultipleFieldsAccessorAndDescription{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, b []byte) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessorAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessorAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithEmbeddedModels struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModels() *ModelWithEmbeddedModels { + return &ModelWithEmbeddedModels{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 64), + } +} + +func (x *ModelWithEmbeddedModels) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, b []byte) (*ModelWithEmbeddedModels, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModels(x, d) +} + +func _decodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, d *polyglot.Decoder) (*ModelWithEmbeddedModels, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModels() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +type ModelWithEmbeddedModelsAndDescription struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAndDescription() *ModelWithEmbeddedModelsAndDescription { + return &ModelWithEmbeddedModelsAndDescription{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 0), + } +} + +func (x *ModelWithEmbeddedModelsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, b []byte) (*ModelWithEmbeddedModelsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAndDescription() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +type ModelWithEmbeddedModelsAccessor struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessor() *ModelWithEmbeddedModelsAccessor { + return &ModelWithEmbeddedModelsAccessor{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, b []byte) (*ModelWithEmbeddedModelsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessor(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessor() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +type ModelWithEmbeddedModelsAccessorAndDescription struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessorAndDescription() *ModelWithEmbeddedModelsAccessorAndDescription { + return &ModelWithEmbeddedModelsAccessorAndDescription{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, b []byte) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessorAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessorAndDescription() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +type ModelWithAllFieldTypes struct { + ModelField *EmptyModel + + ModelArrayField []EmptyModel + + StringField string + + StringArrayField []string + + StringMapField map[string]string + + StringMapFieldEmbedded map[string]EmptyModel + + Int32Field int32 + + Int32ArrayField []int32 + + Int32MapField map[int32]int32 + + Int32MapFieldEmbedded map[int32]EmptyModel + + Int64Field int64 + + Int64ArrayField []int64 + + Int64MapField map[int64]int64 + + Int64MapFieldEmbedded map[int64]EmptyModel + + Uint32Field uint32 + + Uint32ArrayField []uint32 + + Uint32MapField map[uint32]uint32 + + Uint32MapFieldEmbedded map[uint32]EmptyModel + + Uint64Field uint64 + + Uint64ArrayField []uint64 + + Uint64MapField map[uint64]uint64 + + Uint64MapFieldEmbedded map[uint64]EmptyModel + + Float32Field float32 + + Float32ArrayField []float32 + + Float64Field float64 + + Float64ArrayField []float64 + + EnumField GenericEnum + + EnumArrayField []GenericEnum + + EnumMapField map[GenericEnum]string + + EnumMapFieldEmbedded map[GenericEnum]EmptyModel + + BytesField []byte + + BytesArrayField [][]byte + + BoolField bool + + BoolArrayField []bool +} + +func NewModelWithAllFieldTypes() *ModelWithAllFieldTypes { + return &ModelWithAllFieldTypes{ + + ModelField: NewEmptyModel(), + + ModelArrayField: make([]EmptyModel, 0, 0), + + StringField: "DefaultValue", + + StringArrayField: make([]string, 0, 0), + + StringMapField: make(map[string]string), + + StringMapFieldEmbedded: make(map[string]EmptyModel), + + Int32Field: 32, + + Int32ArrayField: make([]int32, 0, 0), + + Int32MapField: make(map[int32]int32), + + Int32MapFieldEmbedded: make(map[int32]EmptyModel), + + Int64Field: 64, + + Int64ArrayField: make([]int64, 0, 0), + + Int64MapField: make(map[int64]int64), + + Int64MapFieldEmbedded: make(map[int64]EmptyModel), + + Uint32Field: 32, + + Uint32ArrayField: make([]uint32, 0, 0), + + Uint32MapField: make(map[uint32]uint32), + + Uint32MapFieldEmbedded: make(map[uint32]EmptyModel), + + Uint64Field: 64, + + Uint64ArrayField: make([]uint64, 0, 0), + + Uint64MapField: make(map[uint64]uint64), + + Uint64MapFieldEmbedded: make(map[uint64]EmptyModel), + + Float32Field: 32.32, + + Float32ArrayField: make([]float32, 0, 0), + + Float64Field: 64.64, + + Float64ArrayField: make([]float64, 0, 0), + + EnumField: GenericEnumDefaultValue, + + EnumArrayField: make([]GenericEnum, 0, 0), + + EnumMapField: make(map[GenericEnum]string), + + EnumMapFieldEmbedded: make(map[GenericEnum]EmptyModel), + + BytesField: make([]byte, 0, 512), + + BytesArrayField: make([][]byte, 0, 0), + + BoolField: true, + + BoolArrayField: make([]bool, 0, 0), + } +} + +func (x *ModelWithAllFieldTypes) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.ModelField.Encode(b) + + e.Slice(uint32(len(x.ModelArrayField)), polyglot.AnyKind) + for _, a := range x.ModelArrayField { + a.Encode(b) + } + + e.String(x.StringField) + + e.Slice(uint32(len(x.StringArrayField)), polyglot.StringKind) + for _, a := range x.StringArrayField { + e.String(a) + } + + e.Map(uint32(len(x.StringMapField)), polyglot.StringKind, polyglot.StringKind) + for k, v := range x.StringMapField { + e.String(k) + e.String(v) + } + + e.Map(uint32(len(x.StringMapFieldEmbedded)), polyglot.StringKind, polyglot.AnyKind) + for k, v := range x.StringMapFieldEmbedded { + e.String(k) + v.Encode(b) + } + + e.Int32(x.Int32Field) + + e.Slice(uint32(len(x.Int32ArrayField)), polyglot.Int32Kind) + for _, a := range x.Int32ArrayField { + e.Int32(a) + } + + e.Map(uint32(len(x.Int32MapField)), polyglot.Int32Kind, polyglot.Int32Kind) + for k, v := range x.Int32MapField { + e.Int32(k) + e.Int32(v) + } + + e.Map(uint32(len(x.Int32MapFieldEmbedded)), polyglot.Int32Kind, polyglot.AnyKind) + for k, v := range x.Int32MapFieldEmbedded { + e.Int32(k) + v.Encode(b) + } + + e.Int64(x.Int64Field) + + e.Slice(uint32(len(x.Int64ArrayField)), polyglot.Int64Kind) + for _, a := range x.Int64ArrayField { + e.Int64(a) + } + + e.Map(uint32(len(x.Int64MapField)), polyglot.Int64Kind, polyglot.Int64Kind) + for k, v := range x.Int64MapField { + e.Int64(k) + e.Int64(v) + } + + e.Map(uint32(len(x.Int64MapFieldEmbedded)), polyglot.Int64Kind, polyglot.AnyKind) + for k, v := range x.Int64MapFieldEmbedded { + e.Int64(k) + v.Encode(b) + } + + e.Uint32(x.Uint32Field) + + e.Slice(uint32(len(x.Uint32ArrayField)), polyglot.Uint32Kind) + for _, a := range x.Uint32ArrayField { + e.Uint32(a) + } + + e.Map(uint32(len(x.Uint32MapField)), polyglot.Uint32Kind, polyglot.Uint32Kind) + for k, v := range x.Uint32MapField { + e.Uint32(k) + e.Uint32(v) + } + + e.Map(uint32(len(x.Uint32MapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.Uint32MapFieldEmbedded { + e.Uint32(k) + v.Encode(b) + } + + e.Uint64(x.Uint64Field) + + e.Slice(uint32(len(x.Uint64ArrayField)), polyglot.Uint64Kind) + for _, a := range x.Uint64ArrayField { + e.Uint64(a) + } + + e.Map(uint32(len(x.Uint64MapField)), polyglot.Uint64Kind, polyglot.Uint64Kind) + for k, v := range x.Uint64MapField { + e.Uint64(k) + e.Uint64(v) + } + + e.Map(uint32(len(x.Uint64MapFieldEmbedded)), polyglot.Uint64Kind, polyglot.AnyKind) + for k, v := range x.Uint64MapFieldEmbedded { + e.Uint64(k) + v.Encode(b) + } + + e.Float32(x.Float32Field) + + e.Slice(uint32(len(x.Float32ArrayField)), polyglot.Float32Kind) + for _, a := range x.Float32ArrayField { + e.Float32(a) + } + + e.Float64(x.Float64Field) + + e.Slice(uint32(len(x.Float64ArrayField)), polyglot.Float64Kind) + for _, a := range x.Float64ArrayField { + e.Float64(a) + } + + e.Uint32(uint32(x.EnumField)) + + e.Slice(uint32(len(x.EnumArrayField)), polyglot.Uint32Kind) + for _, a := range x.EnumArrayField { + e.Uint32(uint32(a)) + } + + e.Map(uint32(len(x.EnumMapField)), polyglot.Uint32Kind, polyglot.StringKind) + for k, v := range x.EnumMapField { + e.Uint32(uint32(k)) + e.String(v) + } + + e.Map(uint32(len(x.EnumMapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.EnumMapFieldEmbedded { + e.Uint32(uint32(k)) + v.Encode(b) + } + + e.Bytes(x.BytesField) + + e.Slice(uint32(len(x.BytesArrayField)), polyglot.BytesKind) + for _, a := range x.BytesArrayField { + e.Bytes(a) + } + + e.Bool(x.BoolField) + + e.Slice(uint32(len(x.BoolArrayField)), polyglot.BoolKind) + for _, a := range x.BoolArrayField { + e.Bool(a) + } + + } +} + +func DecodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, b []byte) (*ModelWithAllFieldTypes, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithAllFieldTypes(x, d) +} + +func _decodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, d *polyglot.Decoder) (*ModelWithAllFieldTypes, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithAllFieldTypes() + } + + x.ModelField, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeModelArrayField, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.ModelArrayField)) != sliceSizeModelArrayField { + x.ModelArrayField = make([]EmptyModel, sliceSizeModelArrayField) + } + for i := uint32(0); i < sliceSizeModelArrayField; i++ { + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.ModelArrayField[i] = *v + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + sliceSizeStringArrayField, err := d.Slice(polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringArrayField)) != sliceSizeStringArrayField { + x.StringArrayField = make([]string, sliceSizeStringArrayField) + } + + for i := uint32(0); i < sliceSizeStringArrayField; i++ { + x.StringArrayField[i], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapField, err := d.Map(polyglot.StringKind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapField)) != mapSizeStringMapField { + x.StringMapField = make(map[string]string, mapSizeStringMapField) + } + + for i := uint32(0); i < mapSizeStringMapField; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + x.StringMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapFieldEmbedded, err := d.Map(polyglot.StringKind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapFieldEmbedded)) != mapSizeStringMapFieldEmbedded { + x.StringMapFieldEmbedded = make(map[string]EmptyModel, mapSizeStringMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeStringMapFieldEmbedded; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.StringMapFieldEmbedded[k] = *v + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + sliceSizeInt32ArrayField, err := d.Slice(polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32ArrayField)) != sliceSizeInt32ArrayField { + x.Int32ArrayField = make([]int32, sliceSizeInt32ArrayField) + } + + for i := uint32(0); i < sliceSizeInt32ArrayField; i++ { + x.Int32ArrayField[i], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapField, err := d.Map(polyglot.Int32Kind, polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapField)) != mapSizeInt32MapField { + x.Int32MapField = make(map[int32]int32, mapSizeInt32MapField) + } + + for i := uint32(0); i < mapSizeInt32MapField; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + x.Int32MapField[k], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapFieldEmbedded, err := d.Map(polyglot.Int32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapFieldEmbedded)) != mapSizeInt32MapFieldEmbedded { + x.Int32MapFieldEmbedded = make(map[int32]EmptyModel, mapSizeInt32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt32MapFieldEmbedded; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int32MapFieldEmbedded[k] = *v + } + + x.Int64Field, err = d.Int64() + if err != nil { + return nil, err + } + + sliceSizeInt64ArrayField, err := d.Slice(polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64ArrayField)) != sliceSizeInt64ArrayField { + x.Int64ArrayField = make([]int64, sliceSizeInt64ArrayField) + } + + for i := uint32(0); i < sliceSizeInt64ArrayField; i++ { + x.Int64ArrayField[i], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapField, err := d.Map(polyglot.Int64Kind, polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapField)) != mapSizeInt64MapField { + x.Int64MapField = make(map[int64]int64, mapSizeInt64MapField) + } + + for i := uint32(0); i < mapSizeInt64MapField; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + x.Int64MapField[k], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapFieldEmbedded, err := d.Map(polyglot.Int64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapFieldEmbedded)) != mapSizeInt64MapFieldEmbedded { + x.Int64MapFieldEmbedded = make(map[int64]EmptyModel, mapSizeInt64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt64MapFieldEmbedded; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int64MapFieldEmbedded[k] = *v + } + + x.Uint32Field, err = d.Uint32() + if err != nil { + return nil, err + } + + sliceSizeUint32ArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32ArrayField)) != sliceSizeUint32ArrayField { + x.Uint32ArrayField = make([]uint32, sliceSizeUint32ArrayField) + } + + for i := uint32(0); i < sliceSizeUint32ArrayField; i++ { + x.Uint32ArrayField[i], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapField, err := d.Map(polyglot.Uint32Kind, polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapField)) != mapSizeUint32MapField { + x.Uint32MapField = make(map[uint32]uint32, mapSizeUint32MapField) + } + + for i := uint32(0); i < mapSizeUint32MapField; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + x.Uint32MapField[k], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapFieldEmbedded)) != mapSizeUint32MapFieldEmbedded { + x.Uint32MapFieldEmbedded = make(map[uint32]EmptyModel, mapSizeUint32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint32MapFieldEmbedded; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint32MapFieldEmbedded[k] = *v + } + + x.Uint64Field, err = d.Uint64() + if err != nil { + return nil, err + } + + sliceSizeUint64ArrayField, err := d.Slice(polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64ArrayField)) != sliceSizeUint64ArrayField { + x.Uint64ArrayField = make([]uint64, sliceSizeUint64ArrayField) + } + + for i := uint32(0); i < sliceSizeUint64ArrayField; i++ { + x.Uint64ArrayField[i], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapField, err := d.Map(polyglot.Uint64Kind, polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapField)) != mapSizeUint64MapField { + x.Uint64MapField = make(map[uint64]uint64, mapSizeUint64MapField) + } + + for i := uint32(0); i < mapSizeUint64MapField; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + x.Uint64MapField[k], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapFieldEmbedded, err := d.Map(polyglot.Uint64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapFieldEmbedded)) != mapSizeUint64MapFieldEmbedded { + x.Uint64MapFieldEmbedded = make(map[uint64]EmptyModel, mapSizeUint64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint64MapFieldEmbedded; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint64MapFieldEmbedded[k] = *v + } + + x.Float32Field, err = d.Float32() + if err != nil { + return nil, err + } + + sliceSizeFloat32ArrayField, err := d.Slice(polyglot.Float32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float32ArrayField)) != sliceSizeFloat32ArrayField { + x.Float32ArrayField = make([]float32, sliceSizeFloat32ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat32ArrayField; i++ { + x.Float32ArrayField[i], err = d.Float32() + if err != nil { + return nil, err + } + } + + x.Float64Field, err = d.Float64() + if err != nil { + return nil, err + } + + sliceSizeFloat64ArrayField, err := d.Slice(polyglot.Float64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float64ArrayField)) != sliceSizeFloat64ArrayField { + x.Float64ArrayField = make([]float64, sliceSizeFloat64ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat64ArrayField; i++ { + x.Float64ArrayField[i], err = d.Float64() + if err != nil { + return nil, err + } + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + sliceSizeEnumArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumArrayField)) != sliceSizeEnumArrayField { + x.EnumArrayField = make([]GenericEnum, sliceSizeEnumArrayField) + } + + for i := uint32(0); i < sliceSizeEnumArrayField; i++ { + val, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumArrayField[i] = val + } + + mapSizeEnumMapField, err := d.Map(polyglot.Uint32Kind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapField)) != mapSizeEnumMapField { + x.EnumMapField = make(map[GenericEnum]string, mapSizeEnumMapField) + } + + for i := uint32(0); i < mapSizeEnumMapField; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeEnumMapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapFieldEmbedded)) != mapSizeEnumMapFieldEmbedded { + x.EnumMapFieldEmbedded = make(map[GenericEnum]EmptyModel, mapSizeEnumMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeEnumMapFieldEmbedded; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.EnumMapFieldEmbedded[k] = *v + } + + x.BytesField, err = d.Bytes(nil) + if err != nil { + return nil, err + } + + sliceSizeBytesArrayField, err := d.Slice(polyglot.BytesKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BytesArrayField)) != sliceSizeBytesArrayField { + x.BytesArrayField = make([][]byte, sliceSizeBytesArrayField) + } + + for i := uint32(0); i < sliceSizeBytesArrayField; i++ { + x.BytesArrayField[i], err = d.Bytes(nil) + if err != nil { + return nil, err + } + } + + x.BoolField, err = d.Bool() + if err != nil { + return nil, err + } + + sliceSizeBoolArrayField, err := d.Slice(polyglot.BoolKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BoolArrayField)) != sliceSizeBoolArrayField { + x.BoolArrayField = make([]bool, sliceSizeBoolArrayField) + } + + for i := uint32(0); i < sliceSizeBoolArrayField; i++ { + x.BoolArrayField[i], err = d.Bool() + if err != nil { + return nil, err + } + } + + return x, nil +} diff --git a/integration/golang_tests/signature/go.mod b/integration/golang_tests/signature/go.mod new file mode 100644 index 00000000..10dbf668 --- /dev/null +++ b/integration/golang_tests/signature/go.mod @@ -0,0 +1,14 @@ +module signature + +go 1.20 + +require ( + github.com/loopholelabs/polyglot v1.1.3 + github.com/stretchr/testify v1.8.4 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/integration/golang_tests/signature/go.sum b/integration/golang_tests/signature/go.sum new file mode 100644 index 00000000..0754633d --- /dev/null +++ b/integration/golang_tests/signature/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/loopholelabs/polyglot v1.1.3 h1:WUTcSZ2TQ1lv7CZ4I9nHFBUjf0hKJN+Yfz1rZZJuTP0= +github.com/loopholelabs/polyglot v1.1.3/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/integration/golang_tests/signature/guest.go b/integration/golang_tests/signature/guest.go new file mode 100644 index 00000000..38071333 --- /dev/null +++ b/integration/golang_tests/signature/guest.go @@ -0,0 +1,80 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: signature + +package signature + +import ( + "github.com/loopholelabs/polyglot" + "unsafe" +) + +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5" + +var ( + writeBuffer = polyglot.NewBuffer() + readBuffer []byte +) + +// Write serializes the signature into the global writeBuffer and returns the pointer to the buffer and its size +// +// Users should not use this method. +func Write(ctx *ModelWithAllFieldTypes) (uint32, uint32) { + writeBuffer.Reset() + ctx.Encode(writeBuffer) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Read deserializes signature from the global readBuffer +// +// Users should not use this method. +func Read(ctx *ModelWithAllFieldTypes) (*ModelWithAllFieldTypes, error) { + return DecodeModelWithAllFieldTypes(ctx, readBuffer) +} + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +func Error(err error) (uint32, uint32) { + writeBuffer.Reset() + polyglot.Encoder(writeBuffer).Error(err) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Resize resizes the global readBuffer to the given size and returns the pointer to the buffer +// +// Users should not use this method. +func Resize(size uint32) uint32 { + if uint32(cap(readBuffer)) < size { + readBuffer = append(make([]byte, 0, uint32(len(readBuffer))+size), readBuffer...) + } + readBuffer = readBuffer[:size] + return uint32(uintptr(unsafe.Pointer(&readBuffer[0]))) +} + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +func Hash() (uint32, uint32) { + writeBuffer.Reset() + polyglot.Encoder(writeBuffer).String(hash) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Next calls the next function in the Scale Function Chain +func Next(ctx *ModelWithAllFieldTypes) (*ModelWithAllFieldTypes, error) { + next(Write(ctx)) + return Read(ctx) +} + +//go:export next +//go:linkname next +func next(offset uint32, length uint32) diff --git a/integration/golang_tests/signature/signature_test.go b/integration/golang_tests/signature/signature_test.go new file mode 100644 index 00000000..06c07b3f --- /dev/null +++ b/integration/golang_tests/signature/signature_test.go @@ -0,0 +1,603 @@ +//go:build integration && golang + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "github.com/loopholelabs/polyglot" + "github.com/stretchr/testify/require" + "os" + "strings" + "testing" +) + +func TestOutput(t *testing.T) { + buf := polyglot.NewBuffer() + + var nilModel *EmptyModel + nilModel.Encode(buf) + err := os.WriteFile("../../test_data/nil_model.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + emptyModel := NewEmptyModel() + emptyModel.Encode(buf) + err = os.WriteFile("../../test_data/empty_model.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + emptyModelWithDescription := NewEmptyModelWithDescription() + emptyModelWithDescription.Encode(buf) + err = os.WriteFile("../../test_data/empty_model_with_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithSingleStringField := NewModelWithSingleStringField() + require.Equal(t, "DefaultValue", modelWithSingleStringField.StringField) + modelWithSingleStringField.StringField = "hello world" + modelWithSingleStringField.Encode(buf) + err = os.WriteFile("../../test_data/model_with_single_string_field.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithSingleStringFieldAndDescription := NewModelWithSingleStringFieldAndDescription() + require.Equal(t, "DefaultValue", modelWithSingleStringFieldAndDescription.StringField) + modelWithSingleStringFieldAndDescription.StringField = "hello world" + modelWithSingleStringFieldAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_single_string_field_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithSingleInt32Field := NewModelWithSingleInt32Field() + require.Equal(t, int32(32), modelWithSingleInt32Field.Int32Field) + modelWithSingleInt32Field.Int32Field = 42 + modelWithSingleInt32Field.Encode(buf) + err = os.WriteFile("../../test_data/model_with_single_int32_field.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithSingleInt32FieldAndDescription := NewModelWithSingleInt32FieldAndDescription() + require.Equal(t, int32(32), modelWithSingleInt32FieldAndDescription.Int32Field) + modelWithSingleInt32FieldAndDescription.Int32Field = 42 + modelWithSingleInt32FieldAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_single_int32_field_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithMultipleFields := NewModelWithMultipleFields() + require.Equal(t, "DefaultValue", modelWithMultipleFields.StringField) + require.Equal(t, int32(32), modelWithMultipleFields.Int32Field) + modelWithMultipleFields.StringField = "hello world" + modelWithMultipleFields.Int32Field = 42 + modelWithMultipleFields.Encode(buf) + err = os.WriteFile("../../test_data/model_with_multiple_fields.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithMultipleFieldsAndDescription := NewModelWithMultipleFieldsAndDescription() + require.Equal(t, "DefaultValue", modelWithMultipleFieldsAndDescription.StringField) + require.Equal(t, int32(32), modelWithMultipleFieldsAndDescription.Int32Field) + modelWithMultipleFieldsAndDescription.StringField = "hello world" + modelWithMultipleFieldsAndDescription.Int32Field = 42 + modelWithMultipleFieldsAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_multiple_fields_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEnum := NewModelWithEnum() + require.Equal(t, GenericEnumDefaultValue, modelWithEnum.EnumField) + modelWithEnum.EnumField = GenericEnumSecondValue + modelWithEnum.Encode(buf) + err = os.WriteFile("../../test_data/model_with_enum.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEnumAndDescription := NewModelWithEnumAndDescription() + require.Equal(t, GenericEnumDefaultValue, modelWithEnumAndDescription.EnumField) + modelWithEnumAndDescription.EnumField = GenericEnumSecondValue + modelWithEnumAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_enum_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEnumAccessor := NewModelWithEnumAccessor() + defaultEnumValue, err := modelWithEnumAccessor.GetEnumField() + require.NoError(t, err) + require.Equal(t, GenericEnumDefaultValue, defaultEnumValue) + err = modelWithEnumAccessor.SetEnumField(GenericEnumSecondValue) + require.NoError(t, err) + modelWithEnumAccessor.Encode(buf) + err = os.WriteFile("../../test_data/model_with_enum_accessor.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEnumAccessorAndDescription := NewModelWithEnumAccessorAndDescription() + defaultEnumValue, err = modelWithEnumAccessorAndDescription.GetEnumField() + require.NoError(t, err) + require.Equal(t, GenericEnumDefaultValue, defaultEnumValue) + err = modelWithEnumAccessorAndDescription.SetEnumField(GenericEnumSecondValue) + require.NoError(t, err) + modelWithEnumAccessorAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_enum_accessor_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithMultipleFieldsAccessor := NewModelWithMultipleFieldsAccessor() + stringValue, err := modelWithMultipleFieldsAccessor.GetStringField() + require.NoError(t, err) + require.Equal(t, "DefaultValue", stringValue) + err = modelWithMultipleFieldsAccessor.SetStringField("hello world") + require.ErrorContains(t, err, "value must match ^[a-zA-Z0-9]*$") + err = modelWithMultipleFieldsAccessor.SetStringField("") + require.ErrorContains(t, err, "length must be between 1 and 20") + err = modelWithMultipleFieldsAccessor.SetStringField("hello") + require.NoError(t, err) + stringValue, err = modelWithMultipleFieldsAccessor.GetStringField() + require.NoError(t, err) + require.Equal(t, strings.ToUpper("hello"), stringValue) + int32Value, err := modelWithMultipleFieldsAccessor.GetInt32Field() + require.NoError(t, err) + require.Equal(t, int32(32), int32Value) + err = modelWithMultipleFieldsAccessor.SetInt32Field(-1) + require.ErrorContains(t, err, "value must be between 0 and 100") + err = modelWithMultipleFieldsAccessor.SetInt32Field(101) + require.ErrorContains(t, err, "value must be between 0 and 100") + err = modelWithMultipleFieldsAccessor.SetInt32Field(42) + require.NoError(t, err) + modelWithMultipleFieldsAccessor.Encode(buf) + err = os.WriteFile("../../test_data/model_with_multiple_fields_accessor.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithMultipleFieldsAccessorAndDescription := NewModelWithMultipleFieldsAccessorAndDescription() + stringValue, err = modelWithMultipleFieldsAccessorAndDescription.GetStringField() + require.NoError(t, err) + require.Equal(t, "DefaultValue", stringValue) + err = modelWithMultipleFieldsAccessorAndDescription.SetStringField("hello world") + require.NoError(t, err) + int32Value, err = modelWithMultipleFieldsAccessorAndDescription.GetInt32Field() + require.NoError(t, err) + require.Equal(t, int32(32), int32Value) + err = modelWithMultipleFieldsAccessorAndDescription.SetInt32Field(42) + require.NoError(t, err) + modelWithMultipleFieldsAccessorAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_multiple_fields_accessor_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEmbeddedModels := NewModelWithEmbeddedModels() + require.NotNil(t, modelWithEmbeddedModels.EmbeddedEmptyModel) + require.NotNil(t, modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, 64, cap(modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 0, len(modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor) + modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor = append(modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor, *modelWithMultipleFieldsAccessor) + modelWithEmbeddedModels.Encode(buf) + err = os.WriteFile("../../test_data/model_with_embedded_models.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEmbeddedModelsAndDescription := NewModelWithEmbeddedModelsAndDescription() + require.NotNil(t, modelWithEmbeddedModelsAndDescription.EmbeddedEmptyModel) + require.NotNil(t, modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, 0, cap(modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 0, len(modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor) + modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor = append(modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor, *modelWithMultipleFieldsAccessor) + modelWithEmbeddedModelsAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_embedded_models_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEmbeddedModelsAccessor := NewModelWithEmbeddedModelsAccessor() + embeddedModel, err := modelWithEmbeddedModelsAccessor.GetEmbeddedEmptyModel() + require.NoError(t, err) + require.NotNil(t, embeddedModel) + embeddedModelArray, err := modelWithEmbeddedModelsAccessor.GetEmbeddedModelArrayWithMultipleFieldsAccessor() + require.NoError(t, err) + require.NotNil(t, embeddedModelArray) + require.Equal(t, 0, cap(embeddedModelArray)) + require.Equal(t, 0, len(embeddedModelArray)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, embeddedModelArray) + err = modelWithEmbeddedModelsAccessor.SetEmbeddedModelArrayWithMultipleFieldsAccessor([]ModelWithMultipleFieldsAccessor{*modelWithMultipleFieldsAccessor}) + require.NoError(t, err) + modelWithEmbeddedModelsAccessor.Encode(buf) + err = os.WriteFile("../../test_data/model_with_embedded_models_accessor.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithEmbeddedModelsAccessorAndDescription := NewModelWithEmbeddedModelsAccessorAndDescription() + embeddedModel, err = modelWithEmbeddedModelsAccessorAndDescription.GetEmbeddedEmptyModel() + require.NoError(t, err) + require.NotNil(t, embeddedModel) + embeddedModelArray, err = modelWithEmbeddedModelsAccessorAndDescription.GetEmbeddedModelArrayWithMultipleFieldsAccessor() + require.NoError(t, err) + require.NotNil(t, embeddedModelArray) + require.Equal(t, 0, cap(embeddedModelArray)) + require.Equal(t, 0, len(embeddedModelArray)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, embeddedModelArray) + err = modelWithEmbeddedModelsAccessorAndDescription.SetEmbeddedModelArrayWithMultipleFieldsAccessor([]ModelWithMultipleFieldsAccessor{*modelWithMultipleFieldsAccessor}) + require.NoError(t, err) + modelWithEmbeddedModelsAccessorAndDescription.Encode(buf) + err = os.WriteFile("../../test_data/model_with_embedded_models_accessor_and_description.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() + + modelWithAllFieldTypes := NewModelWithAllFieldTypes() + + require.Equal(t, "DefaultValue", modelWithAllFieldTypes.StringField) + modelWithAllFieldTypes.StringField = "hello world" + require.Equal(t, 0, cap(modelWithAllFieldTypes.StringArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.StringArrayField)) + require.IsType(t, []string{}, modelWithAllFieldTypes.StringArrayField) + modelWithAllFieldTypes.StringArrayField = append(modelWithAllFieldTypes.StringArrayField, "hello", "world") + require.Equal(t, 0, len(modelWithAllFieldTypes.StringMapField)) + require.IsType(t, map[string]string{}, modelWithAllFieldTypes.StringMapField) + modelWithAllFieldTypes.StringMapField["hello"] = "world" + require.Equal(t, 0, len(modelWithAllFieldTypes.StringMapFieldEmbedded)) + require.IsType(t, map[string]EmptyModel{}, modelWithAllFieldTypes.StringMapFieldEmbedded) + modelWithAllFieldTypes.StringMapFieldEmbedded["hello"] = *emptyModel + + require.Equal(t, int32(32), modelWithAllFieldTypes.Int32Field) + modelWithAllFieldTypes.Int32Field = 42 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Int32ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Int32ArrayField)) + require.IsType(t, []int32{}, modelWithAllFieldTypes.Int32ArrayField) + modelWithAllFieldTypes.Int32ArrayField = append(modelWithAllFieldTypes.Int32ArrayField, 42, 84) + require.Equal(t, 0, len(modelWithAllFieldTypes.Int32MapField)) + require.IsType(t, map[int32]int32{}, modelWithAllFieldTypes.Int32MapField) + modelWithAllFieldTypes.Int32MapField[42] = 84 + require.Equal(t, 0, len(modelWithAllFieldTypes.Int32MapFieldEmbedded)) + require.IsType(t, map[int32]EmptyModel{}, modelWithAllFieldTypes.Int32MapFieldEmbedded) + modelWithAllFieldTypes.Int32MapFieldEmbedded[42] = *emptyModel + + require.Equal(t, int64(64), modelWithAllFieldTypes.Int64Field) + modelWithAllFieldTypes.Int64Field = 100 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Int64ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Int64ArrayField)) + require.IsType(t, []int64{}, modelWithAllFieldTypes.Int64ArrayField) + modelWithAllFieldTypes.Int64ArrayField = append(modelWithAllFieldTypes.Int64ArrayField, 100, 200) + require.Equal(t, 0, len(modelWithAllFieldTypes.Int64MapField)) + require.IsType(t, map[int64]int64{}, modelWithAllFieldTypes.Int64MapField) + modelWithAllFieldTypes.Int64MapField[100] = 200 + require.Equal(t, 0, len(modelWithAllFieldTypes.Int64MapFieldEmbedded)) + require.IsType(t, map[int64]EmptyModel{}, modelWithAllFieldTypes.Int64MapFieldEmbedded) + modelWithAllFieldTypes.Int64MapFieldEmbedded[100] = *emptyModel + + require.Equal(t, uint32(32), modelWithAllFieldTypes.Uint32Field) + modelWithAllFieldTypes.Uint32Field = 42 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Uint32ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint32ArrayField)) + require.IsType(t, []uint32{}, modelWithAllFieldTypes.Uint32ArrayField) + modelWithAllFieldTypes.Uint32ArrayField = append(modelWithAllFieldTypes.Uint32ArrayField, 42, 84) + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint32MapField)) + require.IsType(t, map[uint32]uint32{}, modelWithAllFieldTypes.Uint32MapField) + modelWithAllFieldTypes.Uint32MapField[42] = 84 + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint32MapFieldEmbedded)) + require.IsType(t, map[uint32]EmptyModel{}, modelWithAllFieldTypes.Uint32MapFieldEmbedded) + modelWithAllFieldTypes.Uint32MapFieldEmbedded[42] = *emptyModel + + require.Equal(t, uint64(64), modelWithAllFieldTypes.Uint64Field) + modelWithAllFieldTypes.Uint64Field = 100 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Uint64ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint64ArrayField)) + require.IsType(t, []uint64{}, modelWithAllFieldTypes.Uint64ArrayField) + modelWithAllFieldTypes.Uint64ArrayField = append(modelWithAllFieldTypes.Uint64ArrayField, 100, 200) + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint64MapField)) + require.IsType(t, map[uint64]uint64{}, modelWithAllFieldTypes.Uint64MapField) + modelWithAllFieldTypes.Uint64MapField[100] = 200 + require.Equal(t, 0, len(modelWithAllFieldTypes.Uint64MapFieldEmbedded)) + require.IsType(t, map[uint64]EmptyModel{}, modelWithAllFieldTypes.Uint64MapFieldEmbedded) + modelWithAllFieldTypes.Uint64MapFieldEmbedded[100] = *emptyModel + + require.Equal(t, float32(32.32), modelWithAllFieldTypes.Float32Field) + modelWithAllFieldTypes.Float32Field = 42.0 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Float32ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Float32ArrayField)) + require.IsType(t, []float32{}, modelWithAllFieldTypes.Float32ArrayField) + modelWithAllFieldTypes.Float32ArrayField = append(modelWithAllFieldTypes.Float32ArrayField, 42.0, 84.0) + + require.Equal(t, float64(64.64), modelWithAllFieldTypes.Float64Field) + modelWithAllFieldTypes.Float64Field = 100.0 + require.Equal(t, 0, cap(modelWithAllFieldTypes.Float64ArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.Float64ArrayField)) + require.IsType(t, []float64{}, modelWithAllFieldTypes.Float64ArrayField) + modelWithAllFieldTypes.Float64ArrayField = append(modelWithAllFieldTypes.Float64ArrayField, 100.0, 200.0) + + require.Equal(t, true, modelWithAllFieldTypes.BoolField) + modelWithAllFieldTypes.BoolField = false + require.Equal(t, 0, cap(modelWithAllFieldTypes.BoolArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.BoolArrayField)) + require.IsType(t, []bool{}, modelWithAllFieldTypes.BoolArrayField) + modelWithAllFieldTypes.BoolArrayField = append(modelWithAllFieldTypes.BoolArrayField, true, false) + + require.Equal(t, 512, cap(modelWithAllFieldTypes.BytesField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.BytesField)) + require.IsType(t, []byte{}, modelWithAllFieldTypes.BytesField) + modelWithAllFieldTypes.BytesField = append(modelWithAllFieldTypes.BytesField, []byte{42, 84}...) + require.Equal(t, 0, len(modelWithAllFieldTypes.BytesArrayField)) + require.IsType(t, [][]byte{}, modelWithAllFieldTypes.BytesArrayField) + modelWithAllFieldTypes.BytesArrayField = append(modelWithAllFieldTypes.BytesArrayField, []byte{42, 84}, []byte{84, 42}) + + require.Equal(t, GenericEnumDefaultValue, modelWithAllFieldTypes.EnumField) + modelWithAllFieldTypes.EnumField = GenericEnumSecondValue + require.Equal(t, 0, cap(modelWithAllFieldTypes.EnumArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.EnumArrayField)) + require.IsType(t, []GenericEnum{}, modelWithAllFieldTypes.EnumArrayField) + modelWithAllFieldTypes.EnumArrayField = append(modelWithAllFieldTypes.EnumArrayField, GenericEnumFirstValue, GenericEnumSecondValue) + require.Equal(t, 0, len(modelWithAllFieldTypes.EnumMapField)) + require.IsType(t, map[GenericEnum]string{}, modelWithAllFieldTypes.EnumMapField) + modelWithAllFieldTypes.EnumMapField[GenericEnumFirstValue] = "hello world" + require.Equal(t, 0, len(modelWithAllFieldTypes.EnumMapFieldEmbedded)) + require.IsType(t, map[GenericEnum]EmptyModel{}, modelWithAllFieldTypes.EnumMapFieldEmbedded) + modelWithAllFieldTypes.EnumMapFieldEmbedded[GenericEnumFirstValue] = *emptyModel + + require.NotNil(t, modelWithAllFieldTypes.ModelField) + require.Equal(t, 0, cap(modelWithAllFieldTypes.ModelArrayField)) + require.Equal(t, 0, len(modelWithAllFieldTypes.ModelArrayField)) + require.IsType(t, []EmptyModel{}, modelWithAllFieldTypes.ModelArrayField) + modelWithAllFieldTypes.ModelArrayField = append(modelWithAllFieldTypes.ModelArrayField, *emptyModel, *emptyModel) + + modelWithAllFieldTypes.Encode(buf) + err = os.WriteFile("../../test_data/model_with_all_field_types.bin", buf.Bytes(), 0644) + require.NoError(t, err) + buf.Reset() +} + +func TestInput(t *testing.T) { + nilModelData, err := os.ReadFile("../../test_data/nil_model.bin") + require.NoError(t, err) + nilModel, err := DecodeEmptyModel(nil, nilModelData) + require.NoError(t, err) + require.Nil(t, nilModel) + + emptyModelData, err := os.ReadFile("../../test_data/empty_model.bin") + require.NoError(t, err) + emptyModel, err := DecodeEmptyModel(nil, emptyModelData) + require.NoError(t, err) + require.NotNil(t, emptyModel) + + emptyModelWithDescriptionData, err := os.ReadFile("../../test_data/empty_model_with_description.bin") + require.NoError(t, err) + emptyModelWithDescription, err := DecodeEmptyModelWithDescription(nil, emptyModelWithDescriptionData) + require.NoError(t, err) + require.NotNil(t, emptyModelWithDescription) + + modelWithSingleStringFieldData, err := os.ReadFile("../../test_data/model_with_single_string_field.bin") + require.NoError(t, err) + modelWithSingleStringField, err := DecodeModelWithSingleStringField(nil, modelWithSingleStringFieldData) + require.NoError(t, err) + require.NotNil(t, modelWithSingleStringField) + require.Equal(t, "hello world", modelWithSingleStringField.StringField) + + modelWithSingleStringFieldAndDescriptionData, err := os.ReadFile("../../test_data/model_with_single_string_field_and_description.bin") + require.NoError(t, err) + modelWithSingleStringFieldAndDescription, err := DecodeModelWithSingleStringFieldAndDescription(nil, modelWithSingleStringFieldAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithSingleStringFieldAndDescription) + require.Equal(t, "hello world", modelWithSingleStringFieldAndDescription.StringField) + + modelWithSingleInt32FieldData, err := os.ReadFile("../../test_data/model_with_single_int32_field.bin") + require.NoError(t, err) + modelWithSingleInt32Field, err := DecodeModelWithSingleInt32Field(nil, modelWithSingleInt32FieldData) + require.NoError(t, err) + require.NotNil(t, modelWithSingleInt32Field) + require.Equal(t, int32(42), modelWithSingleInt32Field.Int32Field) + + modelWithSingleInt32FieldAndDescriptionData, err := os.ReadFile("../../test_data/model_with_single_int32_field_and_description.bin") + require.NoError(t, err) + modelWithSingleInt32FieldAndDescription, err := DecodeModelWithSingleInt32FieldAndDescription(nil, modelWithSingleInt32FieldAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithSingleInt32FieldAndDescription) + require.Equal(t, int32(42), modelWithSingleInt32FieldAndDescription.Int32Field) + + modelWithMultipleFieldsData, err := os.ReadFile("../../test_data/model_with_multiple_fields.bin") + require.NoError(t, err) + modelWithMultipleFields, err := DecodeModelWithMultipleFields(nil, modelWithMultipleFieldsData) + require.NoError(t, err) + require.NotNil(t, modelWithMultipleFields) + require.Equal(t, "hello world", modelWithMultipleFields.StringField) + require.Equal(t, int32(42), modelWithMultipleFields.Int32Field) + + modelWithMultipleFieldsAndDescriptionData, err := os.ReadFile("../../test_data/model_with_multiple_fields_and_description.bin") + require.NoError(t, err) + modelWithMultipleFieldsAndDescription, err := DecodeModelWithMultipleFieldsAndDescription(nil, modelWithMultipleFieldsAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithMultipleFieldsAndDescription) + require.Equal(t, "hello world", modelWithMultipleFieldsAndDescription.StringField) + require.Equal(t, int32(42), modelWithMultipleFieldsAndDescription.Int32Field) + + modelWithEnumData, err := os.ReadFile("../../test_data/model_with_enum.bin") + require.NoError(t, err) + modelWithEnum, err := DecodeModelWithEnum(nil, modelWithEnumData) + require.NoError(t, err) + require.NotNil(t, modelWithEnum) + require.Equal(t, GenericEnumSecondValue, modelWithEnum.EnumField) + + modelWithEnumAndDescriptionData, err := os.ReadFile("../../test_data/model_with_enum_and_description.bin") + require.NoError(t, err) + modelWithEnumAndDescription, err := DecodeModelWithEnumAndDescription(nil, modelWithEnumAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithEnumAndDescription) + require.Equal(t, GenericEnumSecondValue, modelWithEnumAndDescription.EnumField) + + modelWithEnumAccessorData, err := os.ReadFile("../../test_data/model_with_enum_accessor.bin") + require.NoError(t, err) + modelWithEnumAccessor, err := DecodeModelWithEnumAccessor(nil, modelWithEnumAccessorData) + require.NoError(t, err) + require.NotNil(t, modelWithEnumAccessor) + enumValue, err := modelWithEnumAccessor.GetEnumField() + require.NoError(t, err) + require.Equal(t, GenericEnumSecondValue, enumValue) + + modelWithEnumAccessorAndDescriptionData, err := os.ReadFile("../../test_data/model_with_enum_accessor_and_description.bin") + require.NoError(t, err) + modelWithEnumAccessorAndDescription, err := DecodeModelWithEnumAccessorAndDescription(nil, modelWithEnumAccessorAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithEnumAccessorAndDescription) + enumValue, err = modelWithEnumAccessorAndDescription.GetEnumField() + require.NoError(t, err) + require.Equal(t, GenericEnumSecondValue, enumValue) + + modelWithMultipleFieldsAccessorData, err := os.ReadFile("../../test_data/model_with_multiple_fields_accessor.bin") + require.NoError(t, err) + modelWithMultipleFieldsAccessor, err := DecodeModelWithMultipleFieldsAccessor(nil, modelWithMultipleFieldsAccessorData) + require.NoError(t, err) + require.NotNil(t, modelWithMultipleFieldsAccessor) + stringFieldValue, err := modelWithMultipleFieldsAccessor.GetStringField() + require.NoError(t, err) + require.Equal(t, "HELLO", stringFieldValue) + int32FieldValue, err := modelWithMultipleFieldsAccessor.GetInt32Field() + require.NoError(t, err) + require.Equal(t, int32(42), int32FieldValue) + + modelWithMultipleFieldsAccessorAndDescriptionData, err := os.ReadFile("../../test_data/model_with_multiple_fields_accessor_and_description.bin") + require.NoError(t, err) + modelWithMultipleFieldsAccessorAndDescription, err := DecodeModelWithMultipleFieldsAccessorAndDescription(nil, modelWithMultipleFieldsAccessorAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithMultipleFieldsAccessorAndDescription) + stringFieldValue, err = modelWithMultipleFieldsAccessorAndDescription.GetStringField() + require.NoError(t, err) + require.Equal(t, "hello world", stringFieldValue) + int32FieldValue, err = modelWithMultipleFieldsAccessorAndDescription.GetInt32Field() + require.NoError(t, err) + require.Equal(t, int32(42), int32FieldValue) + + modelWithEmbeddedModelsData, err := os.ReadFile("../../test_data/model_with_embedded_models.bin") + require.NoError(t, err) + modelWithEmbeddedModels, err := DecodeModelWithEmbeddedModels(nil, modelWithEmbeddedModelsData) + require.NoError(t, err) + require.NotNil(t, modelWithEmbeddedModels) + require.NotNil(t, modelWithEmbeddedModels.EmbeddedEmptyModel) + require.NotNil(t, modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, 1, cap(modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 1, len(modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, *modelWithMultipleFieldsAccessor, modelWithEmbeddedModels.EmbeddedModelArrayWithMultipleFieldsAccessor[0]) + + modelWithEmbeddedModelsAndDescriptionData, err := os.ReadFile("../../test_data/model_with_embedded_models_and_description.bin") + require.NoError(t, err) + modelWithEmbeddedModelsAndDescription, err := DecodeModelWithEmbeddedModelsAndDescription(nil, modelWithEmbeddedModelsAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithEmbeddedModelsAndDescription) + require.NotNil(t, modelWithEmbeddedModelsAndDescription.EmbeddedEmptyModel) + require.NotNil(t, modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, 1, cap(modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 1, len(modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, *modelWithMultipleFieldsAccessor, modelWithEmbeddedModelsAndDescription.EmbeddedModelArrayWithMultipleFieldsAccessor[0]) + + modelWithEmbeddedModelsAccessorData, err := os.ReadFile("../../test_data/model_with_embedded_models_accessor.bin") + require.NoError(t, err) + modelWithEmbeddedModelsAccessor, err := DecodeModelWithEmbeddedModelsAccessor(nil, modelWithEmbeddedModelsAccessorData) + require.NoError(t, err) + require.NotNil(t, modelWithEmbeddedModelsAccessor) + embeddedEmptyModel, err := modelWithEmbeddedModelsAccessor.GetEmbeddedEmptyModel() + require.NoError(t, err) + require.NotNil(t, embeddedEmptyModel) + embeddedModelArrayWithMultipleFieldsAccessor, err := modelWithEmbeddedModelsAccessor.GetEmbeddedModelArrayWithMultipleFieldsAccessor() + require.NoError(t, err) + require.Equal(t, 1, cap(embeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 1, len(embeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, embeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, *modelWithMultipleFieldsAccessor, embeddedModelArrayWithMultipleFieldsAccessor[0]) + + modelWithEmbeddedModelsAccessorAndDescriptionData, err := os.ReadFile("../../test_data/model_with_embedded_models_accessor_and_description.bin") + require.NoError(t, err) + modelWithEmbeddedModelsAccessorAndDescription, err := DecodeModelWithEmbeddedModelsAccessorAndDescription(nil, modelWithEmbeddedModelsAccessorAndDescriptionData) + require.NoError(t, err) + require.NotNil(t, modelWithEmbeddedModelsAccessorAndDescription) + embeddedEmptyModel, err = modelWithEmbeddedModelsAccessorAndDescription.GetEmbeddedEmptyModel() + require.NoError(t, err) + require.NotNil(t, embeddedEmptyModel) + embeddedModelArrayWithMultipleFieldsAccessor, err = modelWithEmbeddedModelsAccessorAndDescription.GetEmbeddedModelArrayWithMultipleFieldsAccessor() + require.NoError(t, err) + require.Equal(t, 1, cap(embeddedModelArrayWithMultipleFieldsAccessor)) + require.Equal(t, 1, len(embeddedModelArrayWithMultipleFieldsAccessor)) + require.IsType(t, []ModelWithMultipleFieldsAccessor{}, embeddedModelArrayWithMultipleFieldsAccessor) + require.Equal(t, *modelWithMultipleFieldsAccessor, embeddedModelArrayWithMultipleFieldsAccessor[0]) + + modelWithAllFieldTypesData, err := os.ReadFile("../../test_data/model_with_all_field_types.bin") + require.NoError(t, err) + modelWithAllFieldTypes, err := DecodeModelWithAllFieldTypes(nil, modelWithAllFieldTypesData) + require.NoError(t, err) + require.NotNil(t, modelWithAllFieldTypes) + + require.Equal(t, "hello world", modelWithAllFieldTypes.StringField) + require.Equal(t, 2, len(modelWithAllFieldTypes.StringArrayField)) + require.Equal(t, "hello", modelWithAllFieldTypes.StringArrayField[0]) + require.Equal(t, "world", modelWithAllFieldTypes.StringArrayField[1]) + require.Equal(t, "world", modelWithAllFieldTypes.StringMapField["hello"]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.StringMapFieldEmbedded["hello"]) + + require.Equal(t, int32(42), modelWithAllFieldTypes.Int32Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Int32ArrayField)) + require.Equal(t, int32(42), modelWithAllFieldTypes.Int32ArrayField[0]) + require.Equal(t, int32(84), modelWithAllFieldTypes.Int32ArrayField[1]) + require.Equal(t, int32(84), modelWithAllFieldTypes.Int32MapField[42]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.Int32MapFieldEmbedded[42]) + + require.Equal(t, int64(100), modelWithAllFieldTypes.Int64Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Int64ArrayField)) + require.Equal(t, int64(100), modelWithAllFieldTypes.Int64ArrayField[0]) + require.Equal(t, int64(200), modelWithAllFieldTypes.Int64ArrayField[1]) + require.Equal(t, int64(200), modelWithAllFieldTypes.Int64MapField[100]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.Int64MapFieldEmbedded[100]) + + require.Equal(t, uint32(42), modelWithAllFieldTypes.Uint32Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Uint32ArrayField)) + require.Equal(t, uint32(42), modelWithAllFieldTypes.Uint32ArrayField[0]) + require.Equal(t, uint32(84), modelWithAllFieldTypes.Uint32ArrayField[1]) + require.Equal(t, uint32(84), modelWithAllFieldTypes.Uint32MapField[42]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.Uint32MapFieldEmbedded[42]) + + require.Equal(t, uint64(100), modelWithAllFieldTypes.Uint64Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Uint64ArrayField)) + require.Equal(t, uint64(100), modelWithAllFieldTypes.Uint64ArrayField[0]) + require.Equal(t, uint64(200), modelWithAllFieldTypes.Uint64ArrayField[1]) + require.Equal(t, uint64(200), modelWithAllFieldTypes.Uint64MapField[100]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.Uint64MapFieldEmbedded[100]) + + require.Equal(t, float32(42.0), modelWithAllFieldTypes.Float32Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Float32ArrayField)) + require.Equal(t, float32(42.0), modelWithAllFieldTypes.Float32ArrayField[0]) + require.Equal(t, float32(84.0), modelWithAllFieldTypes.Float32ArrayField[1]) + + require.Equal(t, float64(100.0), modelWithAllFieldTypes.Float64Field) + require.Equal(t, 2, len(modelWithAllFieldTypes.Float64ArrayField)) + require.Equal(t, float64(100.0), modelWithAllFieldTypes.Float64ArrayField[0]) + require.Equal(t, float64(200.0), modelWithAllFieldTypes.Float64ArrayField[1]) + + require.Equal(t, false, modelWithAllFieldTypes.BoolField) + require.Equal(t, 2, len(modelWithAllFieldTypes.BoolArrayField)) + require.Equal(t, true, modelWithAllFieldTypes.BoolArrayField[0]) + require.Equal(t, false, modelWithAllFieldTypes.BoolArrayField[1]) + + require.Equal(t, []byte{42, 84}, modelWithAllFieldTypes.BytesField) + require.Equal(t, 2, len(modelWithAllFieldTypes.BytesArrayField)) + require.Equal(t, []byte{42, 84}, modelWithAllFieldTypes.BytesArrayField[0]) + require.Equal(t, []byte{84, 42}, modelWithAllFieldTypes.BytesArrayField[1]) + + require.Equal(t, GenericEnumSecondValue, modelWithAllFieldTypes.EnumField) + require.Equal(t, 2, len(modelWithAllFieldTypes.EnumArrayField)) + require.Equal(t, GenericEnumFirstValue, modelWithAllFieldTypes.EnumArrayField[0]) + require.Equal(t, GenericEnumSecondValue, modelWithAllFieldTypes.EnumArrayField[1]) + require.Equal(t, "hello world", modelWithAllFieldTypes.EnumMapField[GenericEnumFirstValue]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.EnumMapFieldEmbedded[GenericEnumFirstValue]) + + require.Equal(t, 2, len(modelWithAllFieldTypes.ModelArrayField)) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.ModelArrayField[0]) + require.Equal(t, *emptyModel, modelWithAllFieldTypes.ModelArrayField[1]) +} diff --git a/integration/golang_tests/signature/types.go b/integration/golang_tests/signature/types.go new file mode 100644 index 00000000..2a52f40e --- /dev/null +++ b/integration/golang_tests/signature/types.go @@ -0,0 +1,1983 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: signature + +package signature + +import ( + "errors" + "fmt" + "github.com/loopholelabs/polyglot" + "regexp" + "strings" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type GenericEnum uint32 + +const ( + GenericEnumFirstValue GenericEnum = 0 + + GenericEnumSecondValue GenericEnum = 1 + + GenericEnumDefaultValue GenericEnum = 2 +) + +func decodeGenericEnum(d *polyglot.Decoder) (GenericEnum, error) { + enumValue, err := d.Uint32() + if err != nil { + return 0, err + } + switch GenericEnum(enumValue) { + case GenericEnumFirstValue: + return GenericEnumFirstValue, nil + case GenericEnumSecondValue: + return GenericEnumSecondValue, nil + case GenericEnumDefaultValue: + return GenericEnumDefaultValue, nil + default: + return 0, InvalidEnum + } +} + +type EmptyModel struct { +} + +func NewEmptyModel() *EmptyModel { + return &EmptyModel{} +} + +func (x *EmptyModel) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModel(x *EmptyModel, b []byte) (*EmptyModel, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModel(x, d) +} + +func _decodeEmptyModel(x *EmptyModel, d *polyglot.Decoder) (*EmptyModel, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModel() + } + + return x, nil +} + +// EmptyModelWithDescription: Test Description +type EmptyModelWithDescription struct { +} + +func NewEmptyModelWithDescription() *EmptyModelWithDescription { + return &EmptyModelWithDescription{} +} + +func (x *EmptyModelWithDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModelWithDescription(x *EmptyModelWithDescription, b []byte) (*EmptyModelWithDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModelWithDescription(x, d) +} + +func _decodeEmptyModelWithDescription(x *EmptyModelWithDescription, d *polyglot.Decoder) (*EmptyModelWithDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModelWithDescription() + } + + return x, nil +} + +type ModelWithSingleStringField struct { + StringField string +} + +func NewModelWithSingleStringField() *ModelWithSingleStringField { + return &ModelWithSingleStringField{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringField) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringField(x *ModelWithSingleStringField, b []byte) (*ModelWithSingleStringField, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringField(x, d) +} + +func _decodeModelWithSingleStringField(x *ModelWithSingleStringField, d *polyglot.Decoder) (*ModelWithSingleStringField, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringField() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleStringFieldAndDescription: Test Description +type ModelWithSingleStringFieldAndDescription struct { + StringField string +} + +func NewModelWithSingleStringFieldAndDescription() *ModelWithSingleStringFieldAndDescription { + return &ModelWithSingleStringFieldAndDescription{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringFieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, b []byte) (*ModelWithSingleStringFieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringFieldAndDescription(x, d) +} + +func _decodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleStringFieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringFieldAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithSingleInt32Field struct { + Int32Field int32 +} + +func NewModelWithSingleInt32Field() *ModelWithSingleInt32Field { + return &ModelWithSingleInt32Field{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32Field) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, b []byte) (*ModelWithSingleInt32Field, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32Field(x, d) +} + +func _decodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, d *polyglot.Decoder) (*ModelWithSingleInt32Field, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32Field() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +type ModelWithSingleInt32FieldAndDescription struct { + Int32Field int32 +} + +func NewModelWithSingleInt32FieldAndDescription() *ModelWithSingleInt32FieldAndDescription { + return &ModelWithSingleInt32FieldAndDescription{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32FieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, b []byte) (*ModelWithSingleInt32FieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32FieldAndDescription(x, d) +} + +func _decodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleInt32FieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32FieldAndDescription() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithMultipleFields struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFields() *ModelWithMultipleFields { + return &ModelWithMultipleFields{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFields) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFields(x *ModelWithMultipleFields, b []byte) (*ModelWithMultipleFields, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFields(x, d) +} + +func _decodeModelWithMultipleFields(x *ModelWithMultipleFields, d *polyglot.Decoder) (*ModelWithMultipleFields, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFields() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithMultipleFieldsAndDescription: Test Description +type ModelWithMultipleFieldsAndDescription struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFieldsAndDescription() *ModelWithMultipleFieldsAndDescription { + return &ModelWithMultipleFieldsAndDescription{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, b []byte) (*ModelWithMultipleFieldsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithEnum struct { + EnumField GenericEnum +} + +func NewModelWithEnum() *ModelWithEnum { + return &ModelWithEnum{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnum) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnum(x *ModelWithEnum, b []byte) (*ModelWithEnum, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnum(x, d) +} + +func _decodeModelWithEnum(x *ModelWithEnum, d *polyglot.Decoder) (*ModelWithEnum, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnum() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +// ModelWithEnumAndDescription: Test Description +type ModelWithEnumAndDescription struct { + EnumField GenericEnum +} + +func NewModelWithEnumAndDescription() *ModelWithEnumAndDescription { + return &ModelWithEnumAndDescription{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, b []byte) (*ModelWithEnumAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAndDescription(x, d) +} + +func _decodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, d *polyglot.Decoder) (*ModelWithEnumAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +type ModelWithEnumAccessor struct { + enumField GenericEnum +} + +func NewModelWithEnumAccessor() *ModelWithEnumAccessor { + return &ModelWithEnumAccessor{ + + enumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.enumField)) + + } +} + +func DecodeModelWithEnumAccessor(x *ModelWithEnumAccessor, b []byte) (*ModelWithEnumAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessor(x, d) +} + +func _decodeModelWithEnumAccessor(x *ModelWithEnumAccessor, d *polyglot.Decoder) (*ModelWithEnumAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessor() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.enumField = result + + return x, nil +} + +func (x *ModelWithEnumAccessor) GetEnumField() (GenericEnum, error) { + return x.enumField, nil +} + +func (x *ModelWithEnumAccessor) SetEnumField(v GenericEnum) error { + x.enumField = v + return nil +} + +// ModelWithEnumAccessorAndDescription: Test Description +type ModelWithEnumAccessorAndDescription struct { + enumField GenericEnum +} + +func NewModelWithEnumAccessorAndDescription() *ModelWithEnumAccessorAndDescription { + return &ModelWithEnumAccessorAndDescription{ + + enumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.enumField)) + + } +} + +func DecodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, b []byte) (*ModelWithEnumAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessorAndDescription(x, d) +} + +func _decodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEnumAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessorAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.enumField = result + + return x, nil +} + +func (x *ModelWithEnumAccessorAndDescription) GetEnumField() (GenericEnum, error) { + return x.enumField, nil +} + +func (x *ModelWithEnumAccessorAndDescription) SetEnumField(v GenericEnum) error { + x.enumField = v + return nil +} + +type ModelWithMultipleFieldsAccessor struct { + stringField string + + int32Field int32 +} + +func NewModelWithMultipleFieldsAccessor() *ModelWithMultipleFieldsAccessor { + return &ModelWithMultipleFieldsAccessor{ + + stringField: "DefaultValue", + + int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.stringField) + + e.Int32(x.int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, b []byte) (*ModelWithMultipleFieldsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessor(x, d) +} + +func _decodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessor() + } + + x.stringField, err = d.String() + if err != nil { + return nil, err + } + + x.int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +func (x *ModelWithMultipleFieldsAccessor) GetStringField() (string, error) { + return x.stringField, nil +} + +func (x *ModelWithMultipleFieldsAccessor) SetStringField(v string) error { + if matched, err := regexp.MatchString(`^[a-zA-Z0-9]*$`, v); err != nil || !matched { + return fmt.Errorf("value must match ^[a-zA-Z0-9]*$") + } + + if len(v) > 20 || len(v) < 1 { + return fmt.Errorf("length must be between 1 and 20") + } + + v = strings.ToUpper(v) + + x.stringField = v + return nil +} + +func (x *ModelWithMultipleFieldsAccessor) GetInt32Field() (int32, error) { + return x.int32Field, nil +} + +func (x *ModelWithMultipleFieldsAccessor) SetInt32Field(v int32) error { + if v > 100 || v < 0 { + return fmt.Errorf("value must be between 0 and 100") + } + + x.int32Field = v + return nil +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +type ModelWithMultipleFieldsAccessorAndDescription struct { + stringField string + + int32Field int32 +} + +func NewModelWithMultipleFieldsAccessorAndDescription() *ModelWithMultipleFieldsAccessorAndDescription { + return &ModelWithMultipleFieldsAccessorAndDescription{ + + stringField: "DefaultValue", + + int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.stringField) + + e.Int32(x.int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, b []byte) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessorAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessorAndDescription() + } + + x.stringField, err = d.String() + if err != nil { + return nil, err + } + + x.int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) GetStringField() (string, error) { + return x.stringField, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) SetStringField(v string) error { + + x.stringField = v + return nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) GetInt32Field() (int32, error) { + return x.int32Field, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) SetInt32Field(v int32) error { + + x.int32Field = v + return nil +} + +type ModelWithEmbeddedModels struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModels() *ModelWithEmbeddedModels { + return &ModelWithEmbeddedModels{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 64), + } +} + +func (x *ModelWithEmbeddedModels) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, b []byte) (*ModelWithEmbeddedModels, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModels(x, d) +} + +func _decodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, d *polyglot.Decoder) (*ModelWithEmbeddedModels, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModels() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +type ModelWithEmbeddedModelsAndDescription struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAndDescription() *ModelWithEmbeddedModelsAndDescription { + return &ModelWithEmbeddedModelsAndDescription{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 0), + } +} + +func (x *ModelWithEmbeddedModelsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, b []byte) (*ModelWithEmbeddedModelsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAndDescription() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +type ModelWithEmbeddedModelsAccessor struct { + embeddedEmptyModel *EmptyModel + + embeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessor() *ModelWithEmbeddedModelsAccessor { + return &ModelWithEmbeddedModelsAccessor{ + + embeddedEmptyModel: NewEmptyModel(), + + embeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.embeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.embeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, b []byte) (*ModelWithEmbeddedModelsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessor(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessor() + } + + x.embeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeembeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeembeddedModelArrayWithMultipleFieldsAccessor { + x.embeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeembeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeembeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.embeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) GetEmbeddedEmptyModel() (*EmptyModel, error) { + return x.embeddedEmptyModel, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) SetEmbeddedEmptyModel(v *EmptyModel) error { + x.embeddedEmptyModel = v + return nil +} + +func (x *ModelWithEmbeddedModelsAccessor) GetEmbeddedModelArrayWithMultipleFieldsAccessor() ([]ModelWithMultipleFieldsAccessor, error) { + return x.embeddedModelArrayWithMultipleFieldsAccessor, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) SetEmbeddedModelArrayWithMultipleFieldsAccessor(v []ModelWithMultipleFieldsAccessor) error { + x.embeddedModelArrayWithMultipleFieldsAccessor = v + return nil +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +type ModelWithEmbeddedModelsAccessorAndDescription struct { + embeddedEmptyModel *EmptyModel + + embeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessorAndDescription() *ModelWithEmbeddedModelsAccessorAndDescription { + return &ModelWithEmbeddedModelsAccessorAndDescription{ + + embeddedEmptyModel: NewEmptyModel(), + + embeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.embeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.embeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, b []byte) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessorAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessorAndDescription() + } + + x.embeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeembeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeembeddedModelArrayWithMultipleFieldsAccessor { + x.embeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeembeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeembeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.embeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) GetEmbeddedEmptyModel() (*EmptyModel, error) { + return x.embeddedEmptyModel, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) SetEmbeddedEmptyModel(v *EmptyModel) error { + x.embeddedEmptyModel = v + return nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) GetEmbeddedModelArrayWithMultipleFieldsAccessor() ([]ModelWithMultipleFieldsAccessor, error) { + return x.embeddedModelArrayWithMultipleFieldsAccessor, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) SetEmbeddedModelArrayWithMultipleFieldsAccessor(v []ModelWithMultipleFieldsAccessor) error { + x.embeddedModelArrayWithMultipleFieldsAccessor = v + return nil +} + +type ModelWithAllFieldTypes struct { + ModelField *EmptyModel + + ModelArrayField []EmptyModel + + StringField string + + StringArrayField []string + + StringMapField map[string]string + + StringMapFieldEmbedded map[string]EmptyModel + + Int32Field int32 + + Int32ArrayField []int32 + + Int32MapField map[int32]int32 + + Int32MapFieldEmbedded map[int32]EmptyModel + + Int64Field int64 + + Int64ArrayField []int64 + + Int64MapField map[int64]int64 + + Int64MapFieldEmbedded map[int64]EmptyModel + + Uint32Field uint32 + + Uint32ArrayField []uint32 + + Uint32MapField map[uint32]uint32 + + Uint32MapFieldEmbedded map[uint32]EmptyModel + + Uint64Field uint64 + + Uint64ArrayField []uint64 + + Uint64MapField map[uint64]uint64 + + Uint64MapFieldEmbedded map[uint64]EmptyModel + + Float32Field float32 + + Float32ArrayField []float32 + + Float64Field float64 + + Float64ArrayField []float64 + + EnumField GenericEnum + + EnumArrayField []GenericEnum + + EnumMapField map[GenericEnum]string + + EnumMapFieldEmbedded map[GenericEnum]EmptyModel + + BytesField []byte + + BytesArrayField [][]byte + + BoolField bool + + BoolArrayField []bool +} + +func NewModelWithAllFieldTypes() *ModelWithAllFieldTypes { + return &ModelWithAllFieldTypes{ + + ModelField: NewEmptyModel(), + + ModelArrayField: make([]EmptyModel, 0, 0), + + StringField: "DefaultValue", + + StringArrayField: make([]string, 0, 0), + + StringMapField: make(map[string]string), + + StringMapFieldEmbedded: make(map[string]EmptyModel), + + Int32Field: 32, + + Int32ArrayField: make([]int32, 0, 0), + + Int32MapField: make(map[int32]int32), + + Int32MapFieldEmbedded: make(map[int32]EmptyModel), + + Int64Field: 64, + + Int64ArrayField: make([]int64, 0, 0), + + Int64MapField: make(map[int64]int64), + + Int64MapFieldEmbedded: make(map[int64]EmptyModel), + + Uint32Field: 32, + + Uint32ArrayField: make([]uint32, 0, 0), + + Uint32MapField: make(map[uint32]uint32), + + Uint32MapFieldEmbedded: make(map[uint32]EmptyModel), + + Uint64Field: 64, + + Uint64ArrayField: make([]uint64, 0, 0), + + Uint64MapField: make(map[uint64]uint64), + + Uint64MapFieldEmbedded: make(map[uint64]EmptyModel), + + Float32Field: 32.32, + + Float32ArrayField: make([]float32, 0, 0), + + Float64Field: 64.64, + + Float64ArrayField: make([]float64, 0, 0), + + EnumField: GenericEnumDefaultValue, + + EnumArrayField: make([]GenericEnum, 0, 0), + + EnumMapField: make(map[GenericEnum]string), + + EnumMapFieldEmbedded: make(map[GenericEnum]EmptyModel), + + BytesField: make([]byte, 0, 512), + + BytesArrayField: make([][]byte, 0, 0), + + BoolField: true, + + BoolArrayField: make([]bool, 0, 0), + } +} + +func (x *ModelWithAllFieldTypes) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.ModelField.Encode(b) + + e.Slice(uint32(len(x.ModelArrayField)), polyglot.AnyKind) + for _, a := range x.ModelArrayField { + a.Encode(b) + } + + e.String(x.StringField) + + e.Slice(uint32(len(x.StringArrayField)), polyglot.StringKind) + for _, a := range x.StringArrayField { + e.String(a) + } + + e.Map(uint32(len(x.StringMapField)), polyglot.StringKind, polyglot.StringKind) + for k, v := range x.StringMapField { + e.String(k) + e.String(v) + } + + e.Map(uint32(len(x.StringMapFieldEmbedded)), polyglot.StringKind, polyglot.AnyKind) + for k, v := range x.StringMapFieldEmbedded { + e.String(k) + v.Encode(b) + } + + e.Int32(x.Int32Field) + + e.Slice(uint32(len(x.Int32ArrayField)), polyglot.Int32Kind) + for _, a := range x.Int32ArrayField { + e.Int32(a) + } + + e.Map(uint32(len(x.Int32MapField)), polyglot.Int32Kind, polyglot.Int32Kind) + for k, v := range x.Int32MapField { + e.Int32(k) + e.Int32(v) + } + + e.Map(uint32(len(x.Int32MapFieldEmbedded)), polyglot.Int32Kind, polyglot.AnyKind) + for k, v := range x.Int32MapFieldEmbedded { + e.Int32(k) + v.Encode(b) + } + + e.Int64(x.Int64Field) + + e.Slice(uint32(len(x.Int64ArrayField)), polyglot.Int64Kind) + for _, a := range x.Int64ArrayField { + e.Int64(a) + } + + e.Map(uint32(len(x.Int64MapField)), polyglot.Int64Kind, polyglot.Int64Kind) + for k, v := range x.Int64MapField { + e.Int64(k) + e.Int64(v) + } + + e.Map(uint32(len(x.Int64MapFieldEmbedded)), polyglot.Int64Kind, polyglot.AnyKind) + for k, v := range x.Int64MapFieldEmbedded { + e.Int64(k) + v.Encode(b) + } + + e.Uint32(x.Uint32Field) + + e.Slice(uint32(len(x.Uint32ArrayField)), polyglot.Uint32Kind) + for _, a := range x.Uint32ArrayField { + e.Uint32(a) + } + + e.Map(uint32(len(x.Uint32MapField)), polyglot.Uint32Kind, polyglot.Uint32Kind) + for k, v := range x.Uint32MapField { + e.Uint32(k) + e.Uint32(v) + } + + e.Map(uint32(len(x.Uint32MapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.Uint32MapFieldEmbedded { + e.Uint32(k) + v.Encode(b) + } + + e.Uint64(x.Uint64Field) + + e.Slice(uint32(len(x.Uint64ArrayField)), polyglot.Uint64Kind) + for _, a := range x.Uint64ArrayField { + e.Uint64(a) + } + + e.Map(uint32(len(x.Uint64MapField)), polyglot.Uint64Kind, polyglot.Uint64Kind) + for k, v := range x.Uint64MapField { + e.Uint64(k) + e.Uint64(v) + } + + e.Map(uint32(len(x.Uint64MapFieldEmbedded)), polyglot.Uint64Kind, polyglot.AnyKind) + for k, v := range x.Uint64MapFieldEmbedded { + e.Uint64(k) + v.Encode(b) + } + + e.Float32(x.Float32Field) + + e.Slice(uint32(len(x.Float32ArrayField)), polyglot.Float32Kind) + for _, a := range x.Float32ArrayField { + e.Float32(a) + } + + e.Float64(x.Float64Field) + + e.Slice(uint32(len(x.Float64ArrayField)), polyglot.Float64Kind) + for _, a := range x.Float64ArrayField { + e.Float64(a) + } + + e.Uint32(uint32(x.EnumField)) + + e.Slice(uint32(len(x.EnumArrayField)), polyglot.Uint32Kind) + for _, a := range x.EnumArrayField { + e.Uint32(uint32(a)) + } + + e.Map(uint32(len(x.EnumMapField)), polyglot.Uint32Kind, polyglot.StringKind) + for k, v := range x.EnumMapField { + e.Uint32(uint32(k)) + e.String(v) + } + + e.Map(uint32(len(x.EnumMapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.EnumMapFieldEmbedded { + e.Uint32(uint32(k)) + v.Encode(b) + } + + e.Bytes(x.BytesField) + + e.Slice(uint32(len(x.BytesArrayField)), polyglot.BytesKind) + for _, a := range x.BytesArrayField { + e.Bytes(a) + } + + e.Bool(x.BoolField) + + e.Slice(uint32(len(x.BoolArrayField)), polyglot.BoolKind) + for _, a := range x.BoolArrayField { + e.Bool(a) + } + + } +} + +func DecodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, b []byte) (*ModelWithAllFieldTypes, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithAllFieldTypes(x, d) +} + +func _decodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, d *polyglot.Decoder) (*ModelWithAllFieldTypes, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithAllFieldTypes() + } + + x.ModelField, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeModelArrayField, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.ModelArrayField)) != sliceSizeModelArrayField { + x.ModelArrayField = make([]EmptyModel, sliceSizeModelArrayField) + } + for i := uint32(0); i < sliceSizeModelArrayField; i++ { + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.ModelArrayField[i] = *v + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + sliceSizeStringArrayField, err := d.Slice(polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringArrayField)) != sliceSizeStringArrayField { + x.StringArrayField = make([]string, sliceSizeStringArrayField) + } + + for i := uint32(0); i < sliceSizeStringArrayField; i++ { + x.StringArrayField[i], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapField, err := d.Map(polyglot.StringKind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapField)) != mapSizeStringMapField { + x.StringMapField = make(map[string]string, mapSizeStringMapField) + } + + for i := uint32(0); i < mapSizeStringMapField; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + x.StringMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapFieldEmbedded, err := d.Map(polyglot.StringKind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapFieldEmbedded)) != mapSizeStringMapFieldEmbedded { + x.StringMapFieldEmbedded = make(map[string]EmptyModel, mapSizeStringMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeStringMapFieldEmbedded; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.StringMapFieldEmbedded[k] = *v + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + sliceSizeInt32ArrayField, err := d.Slice(polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32ArrayField)) != sliceSizeInt32ArrayField { + x.Int32ArrayField = make([]int32, sliceSizeInt32ArrayField) + } + + for i := uint32(0); i < sliceSizeInt32ArrayField; i++ { + x.Int32ArrayField[i], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapField, err := d.Map(polyglot.Int32Kind, polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapField)) != mapSizeInt32MapField { + x.Int32MapField = make(map[int32]int32, mapSizeInt32MapField) + } + + for i := uint32(0); i < mapSizeInt32MapField; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + x.Int32MapField[k], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapFieldEmbedded, err := d.Map(polyglot.Int32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapFieldEmbedded)) != mapSizeInt32MapFieldEmbedded { + x.Int32MapFieldEmbedded = make(map[int32]EmptyModel, mapSizeInt32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt32MapFieldEmbedded; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int32MapFieldEmbedded[k] = *v + } + + x.Int64Field, err = d.Int64() + if err != nil { + return nil, err + } + + sliceSizeInt64ArrayField, err := d.Slice(polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64ArrayField)) != sliceSizeInt64ArrayField { + x.Int64ArrayField = make([]int64, sliceSizeInt64ArrayField) + } + + for i := uint32(0); i < sliceSizeInt64ArrayField; i++ { + x.Int64ArrayField[i], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapField, err := d.Map(polyglot.Int64Kind, polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapField)) != mapSizeInt64MapField { + x.Int64MapField = make(map[int64]int64, mapSizeInt64MapField) + } + + for i := uint32(0); i < mapSizeInt64MapField; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + x.Int64MapField[k], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapFieldEmbedded, err := d.Map(polyglot.Int64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapFieldEmbedded)) != mapSizeInt64MapFieldEmbedded { + x.Int64MapFieldEmbedded = make(map[int64]EmptyModel, mapSizeInt64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt64MapFieldEmbedded; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int64MapFieldEmbedded[k] = *v + } + + x.Uint32Field, err = d.Uint32() + if err != nil { + return nil, err + } + + sliceSizeUint32ArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32ArrayField)) != sliceSizeUint32ArrayField { + x.Uint32ArrayField = make([]uint32, sliceSizeUint32ArrayField) + } + + for i := uint32(0); i < sliceSizeUint32ArrayField; i++ { + x.Uint32ArrayField[i], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapField, err := d.Map(polyglot.Uint32Kind, polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapField)) != mapSizeUint32MapField { + x.Uint32MapField = make(map[uint32]uint32, mapSizeUint32MapField) + } + + for i := uint32(0); i < mapSizeUint32MapField; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + x.Uint32MapField[k], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapFieldEmbedded)) != mapSizeUint32MapFieldEmbedded { + x.Uint32MapFieldEmbedded = make(map[uint32]EmptyModel, mapSizeUint32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint32MapFieldEmbedded; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint32MapFieldEmbedded[k] = *v + } + + x.Uint64Field, err = d.Uint64() + if err != nil { + return nil, err + } + + sliceSizeUint64ArrayField, err := d.Slice(polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64ArrayField)) != sliceSizeUint64ArrayField { + x.Uint64ArrayField = make([]uint64, sliceSizeUint64ArrayField) + } + + for i := uint32(0); i < sliceSizeUint64ArrayField; i++ { + x.Uint64ArrayField[i], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapField, err := d.Map(polyglot.Uint64Kind, polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapField)) != mapSizeUint64MapField { + x.Uint64MapField = make(map[uint64]uint64, mapSizeUint64MapField) + } + + for i := uint32(0); i < mapSizeUint64MapField; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + x.Uint64MapField[k], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapFieldEmbedded, err := d.Map(polyglot.Uint64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapFieldEmbedded)) != mapSizeUint64MapFieldEmbedded { + x.Uint64MapFieldEmbedded = make(map[uint64]EmptyModel, mapSizeUint64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint64MapFieldEmbedded; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint64MapFieldEmbedded[k] = *v + } + + x.Float32Field, err = d.Float32() + if err != nil { + return nil, err + } + + sliceSizeFloat32ArrayField, err := d.Slice(polyglot.Float32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float32ArrayField)) != sliceSizeFloat32ArrayField { + x.Float32ArrayField = make([]float32, sliceSizeFloat32ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat32ArrayField; i++ { + x.Float32ArrayField[i], err = d.Float32() + if err != nil { + return nil, err + } + } + + x.Float64Field, err = d.Float64() + if err != nil { + return nil, err + } + + sliceSizeFloat64ArrayField, err := d.Slice(polyglot.Float64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float64ArrayField)) != sliceSizeFloat64ArrayField { + x.Float64ArrayField = make([]float64, sliceSizeFloat64ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat64ArrayField; i++ { + x.Float64ArrayField[i], err = d.Float64() + if err != nil { + return nil, err + } + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + sliceSizeEnumArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumArrayField)) != sliceSizeEnumArrayField { + x.EnumArrayField = make([]GenericEnum, sliceSizeEnumArrayField) + } + + for i := uint32(0); i < sliceSizeEnumArrayField; i++ { + val, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumArrayField[i] = val + } + + mapSizeEnumMapField, err := d.Map(polyglot.Uint32Kind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapField)) != mapSizeEnumMapField { + x.EnumMapField = make(map[GenericEnum]string, mapSizeEnumMapField) + } + + for i := uint32(0); i < mapSizeEnumMapField; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeEnumMapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapFieldEmbedded)) != mapSizeEnumMapFieldEmbedded { + x.EnumMapFieldEmbedded = make(map[GenericEnum]EmptyModel, mapSizeEnumMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeEnumMapFieldEmbedded; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.EnumMapFieldEmbedded[k] = *v + } + + x.BytesField, err = d.Bytes(nil) + if err != nil { + return nil, err + } + + sliceSizeBytesArrayField, err := d.Slice(polyglot.BytesKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BytesArrayField)) != sliceSizeBytesArrayField { + x.BytesArrayField = make([][]byte, sliceSizeBytesArrayField) + } + + for i := uint32(0); i < sliceSizeBytesArrayField; i++ { + x.BytesArrayField[i], err = d.Bytes(nil) + if err != nil { + return nil, err + } + } + + x.BoolField, err = d.Bool() + if err != nil { + return nil, err + } + + sliceSizeBoolArrayField, err := d.Slice(polyglot.BoolKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BoolArrayField)) != sliceSizeBoolArrayField { + x.BoolArrayField = make([]bool, sliceSizeBoolArrayField) + } + + for i := uint32(0); i < sliceSizeBoolArrayField; i++ { + x.BoolArrayField[i], err = d.Bool() + if err != nil { + return nil, err + } + } + + return x, nil +} diff --git a/integration/integration.test.ts b/integration/integration.test.ts new file mode 100644 index 00000000..be146903 --- /dev/null +++ b/integration/integration.test.ts @@ -0,0 +1,68 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { ScaleFunc } from "../scalefunc/scalefunc"; +import { New as NewScale } from "../scale"; + +import fs from "fs"; +import {Config} from "../config"; +import { New as NewSignature, Signature } from "./typescript_tests/host_signature"; +import {TextDecoder, TextEncoder} from "util"; + +window.TextEncoder = TextEncoder; +window.TextDecoder = TextDecoder as typeof window["TextDecoder"]; + +test("test-typescript-host-rust-guest", async () => { + const file = fs.readFileSync(process.cwd() + "/integration/rust.scale") + const sf = ScaleFunc.Decode(file); + const config = new Config(NewSignature).WithFunction(sf).WithStdout(console.log).WithStderr(console.error); + const s = await NewScale(config); + + const i = await s.Instance(); + const sig = NewSignature(); + + await i.Run(sig); + + expect(sig.context.stringField).toBe("This is a Rust Function"); +}); + +test("test-typescript-host-golang-guest", async () => { + const file = fs.readFileSync(process.cwd() + "/integration/golang.scale") + const sf = ScaleFunc.Decode(file); + const config = new Config(NewSignature).WithFunction(sf).WithStdout(console.log).WithStderr(console.error); + const s = await NewScale(config); + + const i = await s.Instance(); + const sig = NewSignature(); + + await i.Run(sig); + + expect(sig.context.stringField).toBe("This is a Golang Function"); +}); + +test("test-typescript-host-typescript-guest", async () => { + const file = fs.readFileSync(process.cwd() + "/integration/typescript.scale") + const sf = ScaleFunc.Decode(file); + const config = new Config(NewSignature).WithFunction(sf).WithStdout(console.log).WithStderr(console.error); + const s = await NewScale(config); + + const i = await s.Instance(); + const sig = NewSignature(); + + await i.Run(sig); + + expect(sig.context.stringField).toBe("This is a Typescript Function"); +}); diff --git a/integration/integration_test.go b/integration/integration_test.go new file mode 100644 index 00000000..725ff1ab --- /dev/null +++ b/integration/integration_test.go @@ -0,0 +1,626 @@ +//go:build integration && !generate + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package integration + +import ( + "context" + "encoding/hex" + "fmt" + "github.com/loopholelabs/scale" + "github.com/loopholelabs/scale/build" + hostSignature "github.com/loopholelabs/scale/integration/golang_tests/host_signature" + "github.com/loopholelabs/scale/scalefile" + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/storage" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "os" + "os/exec" + "testing" +) + +func compileGolangGuest(t *testing.T) *scalefunc.Schema { + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + hash, err := s.Hash() + require.NoError(t, err) + + golangCompileDir := wd + "/golang_tests/compile" + err = os.MkdirAll(golangCompileDir, 0755) + require.NoError(t, err) + + t.Cleanup(func() { + err = os.RemoveAll(golangCompileDir) + require.NoError(t, err) + }) + + golangFunctionDir := wd + "/golang_tests/function" + scf := &scalefile.Schema{ + Version: scalefile.V1AlphaVersion, + Name: "example", + Tag: "latest", + Language: string(scalefunc.Go), + Signature: scalefile.SignatureSchema{ + Organization: "local", + Name: "example", + Tag: "latest", + }, + Function: "Example", + } + + stb, err := storage.NewBuild(golangCompileDir) + require.NoError(t, err) + + schema, err := build.LocalGolang(&build.LocalGolangOptions{ + Output: os.Stdout, + Scalefile: scf, + SourceDirectory: golangFunctionDir, + SignatureSchema: s, + Storage: stb, + Release: false, + Target: build.WASITarget, + }) + require.NoError(t, err) + + assert.Equal(t, scalefunc.V1Alpha, schema.Version) + assert.Equal(t, scf.Name, schema.Name) + assert.Equal(t, scf.Tag, schema.Tag) + assert.Equal(t, fmt.Sprintf("%s/%s:%s", scf.Signature.Organization, scf.Signature.Name, scf.Signature.Tag), schema.SignatureName) + assert.Equal(t, s, schema.SignatureSchema) + assert.Equal(t, hex.EncodeToString(hash), schema.SignatureHash) + assert.Equal(t, scalefunc.Go, schema.Language) + assert.Equal(t, 0, len(schema.Dependencies)) + + return schema +} + +func compileRustGuest(t *testing.T) *scalefunc.Schema { + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + hash, err := s.Hash() + require.NoError(t, err) + + rustCompileDir := wd + "/rust_tests/compile" + err = os.MkdirAll(rustCompileDir, 0755) + require.NoError(t, err) + + t.Cleanup(func() { + err = os.RemoveAll(rustCompileDir) + require.NoError(t, err) + }) + + rustFunctionDir := wd + "/rust_tests/function" + scf := &scalefile.Schema{ + Version: scalefile.V1AlphaVersion, + Name: "example", + Tag: "latest", + Language: string(scalefunc.Rust), + Signature: scalefile.SignatureSchema{ + Organization: "local", + Name: "example", + Tag: "latest", + }, + Function: "example", + } + + stb, err := storage.NewBuild(rustCompileDir) + require.NoError(t, err) + + schema, err := build.LocalRust(&build.LocalRustOptions{ + Output: os.Stdout, + Scalefile: scf, + SourceDirectory: rustFunctionDir, + SignatureSchema: s, + Storage: stb, + Release: false, + Target: build.WASITarget, + }) + require.NoError(t, err) + + assert.Equal(t, scalefunc.V1Alpha, schema.Version) + assert.Equal(t, scf.Name, schema.Name) + assert.Equal(t, scf.Tag, schema.Tag) + assert.Equal(t, fmt.Sprintf("%s/%s:%s", scf.Signature.Organization, scf.Signature.Name, scf.Signature.Tag), schema.SignatureName) + assert.Equal(t, s, schema.SignatureSchema) + assert.Equal(t, hex.EncodeToString(hash), schema.SignatureHash) + assert.Equal(t, scalefunc.Rust, schema.Language) + assert.Equal(t, 0, len(schema.Dependencies)) + + return schema +} + +func compileTypescriptGuest(t *testing.T) *scalefunc.Schema { + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + hash, err := s.Hash() + require.NoError(t, err) + + typescriptCompileDir := wd + "/typescript_tests/compile" + err = os.MkdirAll(typescriptCompileDir, 0755) + require.NoError(t, err) + + t.Cleanup(func() { + err = os.RemoveAll(typescriptCompileDir) + require.NoError(t, err) + }) + + typescriptFunctionDir := wd + "/typescript_tests/function" + scf := &scalefile.Schema{ + Version: scalefile.V1AlphaVersion, + Name: "example", + Tag: "latest", + Language: string(scalefunc.TypeScript), + Signature: scalefile.SignatureSchema{ + Organization: "local", + Name: "example", + Tag: "latest", + }, + Function: "example", + } + + stb, err := storage.NewBuild(typescriptCompileDir) + require.NoError(t, err) + + schema, err := build.LocalTypescript(&build.LocalTypescriptOptions{ + Output: os.Stdout, + Scalefile: scf, + SourceDirectory: typescriptFunctionDir, + SignatureSchema: s, + Storage: stb, + Release: false, + Target: build.WASITarget, + }) + require.NoError(t, err) + + assert.Equal(t, scalefunc.V1Alpha, schema.Version) + assert.Equal(t, scf.Name, schema.Name) + assert.Equal(t, scf.Tag, schema.Tag) + assert.Equal(t, fmt.Sprintf("%s/%s:%s", scf.Signature.Organization, scf.Signature.Name, scf.Signature.Tag), schema.SignatureName) + assert.Equal(t, s, schema.SignatureSchema) + assert.Equal(t, hex.EncodeToString(hash), schema.SignatureHash) + assert.Equal(t, scalefunc.TypeScript, schema.Language) + assert.Equal(t, 0, len(schema.Dependencies)) + + return schema +} + +func TestGolangHostGolangGuest(t *testing.T) { + t.Log("Starting TestGolangHostGolangGuest") + schema := compileGolangGuest(t) + cfg := scale.NewConfig(hostSignature.New).WithFunction(schema).WithStdout(os.Stdout).WithStderr(os.Stderr) + runtime, err := scale.New(cfg) + require.NoError(t, err) + + instance, err := runtime.Instance() + require.NoError(t, err) + + sig := hostSignature.New() + + ctx := context.Background() + err = instance.Run(ctx, sig) + require.NoError(t, err) + + require.Equal(t, "This is a Golang Function", sig.Context.StringField) +} + +func TestGolangHostRustGuest(t *testing.T) { + t.Log("Starting TestGolangHostRustGuest") + schema := compileRustGuest(t) + cfg := scale.NewConfig(hostSignature.New).WithFunction(schema).WithStdout(os.Stdout).WithStderr(os.Stderr) + runtime, err := scale.New(cfg) + require.NoError(t, err) + + instance, err := runtime.Instance() + require.NoError(t, err) + + sig := hostSignature.New() + + ctx := context.Background() + err = instance.Run(ctx, sig) + require.NoError(t, err) + + require.Equal(t, "This is a Rust Function", sig.Context.StringField) +} + +func TestGolangHostTypescriptGuest(t *testing.T) { + t.Log("Starting TestGolangHostTypescriptGuest") + schema := compileTypescriptGuest(t) + cfg := scale.NewConfig(hostSignature.New).WithFunction(schema).WithStdout(os.Stdout).WithStderr(os.Stderr) + runtime, err := scale.New(cfg) + require.NoError(t, err) + + instance, err := runtime.Instance() + require.NoError(t, err) + + sig := hostSignature.New() + + ctx := context.Background() + err = instance.Run(ctx, sig) + require.NoError(t, err) + require.NotNil(t, sig) + require.NotNil(t, sig.Context) + + require.Equal(t, "This is a Typescript Function", sig.Context.StringField) +} + +func TestTypescriptHostTypescriptGuest(t *testing.T) { + t.Log("Starting TestTypescriptHostTypescriptGuest") + wd, err := os.Getwd() + require.NoError(t, err) + + schema := compileTypescriptGuest(t) + err = os.WriteFile(wd+"/typescript.scale", schema.Encode(), 0644) + require.NoError(t, err) + t.Cleanup(func() { + err = os.Remove(wd + "/typescript.scale") + require.NoError(t, err) + }) + + cmd := exec.Command("npm", "run", "test", "--", "-t", "test-typescript-host-typescript-guest") + cmd.Dir = wd + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestTypescriptHostGolangGuest(t *testing.T) { + t.Log("Starting TestTypescriptHostGolangGuest") + wd, err := os.Getwd() + require.NoError(t, err) + + schema := compileGolangGuest(t) + err = os.WriteFile(wd+"/golang.scale", schema.Encode(), 0644) + require.NoError(t, err) + t.Cleanup(func() { + err = os.Remove(wd + "/golang.scale") + require.NoError(t, err) + }) + + cmd := exec.Command("npm", "run", "test", "--", "-t", "test-typescript-host-golang-guest") + cmd.Dir = wd + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestTypescriptHostRustGuest(t *testing.T) { + t.Log("Starting TestTypescriptHostRustGuest") + wd, err := os.Getwd() + require.NoError(t, err) + + schema := compileRustGuest(t) + err = os.WriteFile(wd+"/rust.scale", schema.Encode(), 0644) + require.NoError(t, err) + t.Cleanup(func() { + err = os.Remove(wd + "/rust.scale") + require.NoError(t, err) + }) + + cmd := exec.Command("npm", "run", "test", "--", "-t", "test-typescript-host-rust-guest") + cmd.Dir = wd + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestGolangToGolang(t *testing.T) { + t.Log("Starting TestGolangToGolang") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + golangSignatureDir := wd + "/golang_tests/signature" + cmd := exec.Command("go", "mod", "tidy") + cmd.Dir = golangSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestOutput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestInput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestRustToRust(t *testing.T) { + t.Log("Starting TestRustToRust") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + rustSignatureDir := wd + "/rust_tests/signature" + cmd := exec.Command("cargo", "test", "test_output") + cmd.Dir = rustSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "test", "test_input") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestTypescriptToTypescript(t *testing.T) { + t.Log("Starting TestTypescriptToTypescript") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + typescriptDir := wd + "/typescript_tests/signature" + cmd := exec.Command("npm", "run", "test", "--", "-t", "test-output") + cmd.Dir = typescriptDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("npm", "run", "test", "--", "-t", "test-input") + cmd.Dir = typescriptDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestGolangToRust(t *testing.T) { + t.Log("Starting TestGolangToRust") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + golangSignatureDir := wd + "/golang_tests/signature" + rustSignatureDir := wd + "/rust_tests/signature" + + cmd := exec.Command("go", "mod", "tidy") + cmd.Dir = golangSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestOutput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "check") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "test", "test_input") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestGolangToTypescript(t *testing.T) { + t.Log("Starting TestGolangToTypescript") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + golangSignatureDir := wd + "/golang_tests/signature" + cmd := exec.Command("go", "mod", "tidy") + cmd.Dir = golangSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestOutput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + typescriptDir := wd + "/typescript_tests/signature" + cmd = exec.Command("npm", "install", "--save-dev") + cmd.Dir = typescriptDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("npm", "run", "test", "--", "-t", "test-input") + cmd.Dir = typescriptDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestRustToGolang(t *testing.T) { + t.Log("Starting TestRustToGolang") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + golangSignatureDir := wd + "/golang_tests/signature" + rustSignatureDir := wd + "/rust_tests/signature" + + cmd := exec.Command("cargo", "check") + cmd.Dir = rustSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "test", "test_output") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "mod", "tidy") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestInput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestRustToTypescript(t *testing.T) { + t.Log("Starting TestRustToTypescript") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + rustSignatureDir := wd + "/rust_tests/signature" + cmd := exec.Command("cargo", "check") + cmd.Dir = rustSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "test", "test_output") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + typescriptDir := wd + "/typescript_tests/signature" + cmd = exec.Command("npm", "install", "--save-dev") + cmd.Dir = typescriptDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("npm", "run", "test", "--", "-t", "test-input") + cmd.Dir = typescriptDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestTypescriptToGolang(t *testing.T) { + t.Log("Starting TestTypescriptToGolang") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + typescriptSignatureDir := wd + "/typescript_tests/signature" + cmd := exec.Command("npm", "install", "--save-dev") + cmd.Dir = typescriptSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("npm", "run", "test", "--", "-t", "test-output") + cmd.Dir = typescriptSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + golangSignatureDir := wd + "/golang_tests/signature" + cmd = exec.Command("go", "mod", "tidy") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("go", "test", "./...", "-v", "--tags=integration,golang", "-run", "TestInput") + cmd.Dir = golangSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} + +func TestTypescriptToRust(t *testing.T) { + t.Log("Starting TestTypescriptToRust") + wd, err := os.Getwd() + require.NoError(t, err) + + s := new(signature.Schema) + err = s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + typescriptSignatureDir := wd + "/typescript_tests/signature" + cmd := exec.Command("npm", "install", "--save-dev") + cmd.Dir = typescriptSignatureDir + out, err := cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("npm", "run", "test", "--", "-t", "test-output") + cmd.Dir = typescriptSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + rustSignatureDir := wd + "/rust_tests/signature" + cmd = exec.Command("cargo", "check") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) + + cmd = exec.Command("cargo", "test", "test_input") + cmd.Dir = rustSignatureDir + out, err = cmd.CombinedOutput() + assert.NoError(t, err) + t.Log(string(out)) +} diff --git a/integration/rust_tests/function/Cargo.toml b/integration/rust_tests/function/Cargo.toml new file mode 100644 index 00000000..04582a35 --- /dev/null +++ b/integration/rust_tests/function/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "example" +version = "0.1.0" +edition = "2021" + +[lib] +path = "lib.rs" + +[dependencies] +signature = { package = "local_example_latest_guest", path = "../signature"} + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 \ No newline at end of file diff --git a/integration/rust_tests/function/lib.rs b/integration/rust_tests/function/lib.rs new file mode 100644 index 00000000..854f5516 --- /dev/null +++ b/integration/rust_tests/function/lib.rs @@ -0,0 +1,26 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +use signature::types; + +pub fn example( + ctx: Option<&mut types::ModelWithAllFieldTypes>, +) -> Result, Box> { + println!("This is a Rust Function"); + let unwrapped = ctx.unwrap(); + unwrapped.string_field = "This is a Rust Function".to_string(); + return signature::next(Some(unwrapped)); +} diff --git a/integration/rust_tests/generated/generated.rs b/integration/rust_tests/generated/generated.rs new file mode 100644 index 00000000..20fd42b3 --- /dev/null +++ b/integration/rust_tests/generated/generated.rs @@ -0,0 +1,103 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: generated + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_mut)] +use num_enum::TryFromPrimitive; +use polyglot_rs::{Decoder, DecodingError, Encoder, Kind}; +use regex::Regex; +use std::collections::HashMap; +use std::convert::TryFrom; +use std::io::Cursor; +pub trait Encode { + fn encode<'a>( + a: Option<&Self>, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> + where + Self: Sized; +} +trait EncodeSelf { + fn encode_self<'a, 'b>( + &'b self, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box>; +} +pub trait Decode { + fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> + where + Self: Sized; +} +#[derive(Clone, Debug, PartialEq)] +pub struct Context { + pub a: i32, + pub b: i32, + pub c: i32, +} +impl Context { + pub fn new() -> Self { + Self { a: 0, b: 0, c: 0 } + } +} +impl Encode for Context { + fn encode<'a>( + a: Option<&Context>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for Context { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_i32(self.a)?; + e.encode_i32(self.b)?; + e.encode_i32(self.c)?; + Ok(e) + } +} +impl EncodeSelf for Option<&Context> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for Context { + fn decode(d: &mut Cursor<&mut Vec>) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = Context::new(); + x.a = d.decode_i32()?; + x.b = d.decode_i32()?; + x.c = d.decode_i32()?; + Ok(Some(x)) + } +} diff --git a/integration/rust_tests/signature/Cargo.toml b/integration/rust_tests/signature/Cargo.toml new file mode 100644 index 00000000..5464c252 --- /dev/null +++ b/integration/rust_tests/signature/Cargo.toml @@ -0,0 +1,24 @@ +[package] +edition = "2021" +name = "local_example_latest_guest" +version = "0.1.0" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 + +[lib] +path = "guest.rs" + +[dependencies.num_enum] +version = "0.7.0" + +[dependencies.regex] +version = "1.9.4" + +[dependencies.scale_signature_interfaces] +version = "0.1.7" + +[dependencies.polyglot_rs] +version = "1.1.3" diff --git a/integration/rust_tests/signature/guest.rs b/integration/rust_tests/signature/guest.rs new file mode 100644 index 00000000..70d38e1e --- /dev/null +++ b/integration/rust_tests/signature/guest.rs @@ -0,0 +1,77 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local_example_latest_guest + +pub mod types; +use crate::types::{Decode, Encode}; +use polyglot_rs::Encoder; +use std::io::Cursor; +static HASH: &'static str = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5"; +static mut READ_BUFFER: Vec = Vec::new(); +static mut WRITE_BUFFER: Vec = Vec::new(); +pub unsafe fn write(ctx: Option<&mut types::ModelWithAllFieldTypes>) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + match ctx { + Some(ctx) => { + cursor = match types::ModelWithAllFieldTypes::encode(Some(ctx), &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + None => { + cursor = match types::ModelWithAllFieldTypes::encode(None, &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + } + let vec = cursor.into_inner(); + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); +} +pub unsafe fn read() -> Result, Box> { + let mut cursor = Cursor::new(&mut READ_BUFFER); + types::ModelWithAllFieldTypes::decode(&mut cursor) +} +pub unsafe fn error(error: Box) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_error(error) { + Ok(_) => { + let vec = cursor.into_inner(); + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => (0, 0), + }; +} +pub unsafe fn resize(size: u32) -> *const u8 { + READ_BUFFER.resize(size as usize, 0); + return READ_BUFFER.as_ptr(); +} +pub unsafe fn hash() -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_string(&String::from(HASH)) { + Ok(_) => { + let vec = cursor.into_inner(); + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => (0, 0), + }; +} +pub fn next( + ctx: Option<&mut types::ModelWithAllFieldTypes>, +) -> Result, Box> { + unsafe { + let (ptr, len) = write(ctx); + _next(ptr, len); + read() + } +} +#[link(wasm_import_module = "env")] +extern "C" { + #[link_name = "next"] + fn _next(ptr: u32, size: u32); +} diff --git a/integration/rust_tests/signature/tests/types.rs b/integration/rust_tests/signature/tests/types.rs new file mode 100644 index 00000000..596f098d --- /dev/null +++ b/integration/rust_tests/signature/tests/types.rs @@ -0,0 +1,472 @@ +#[cfg(test)] +mod tests { + use std::fs; + use std::error::Error; + use std::io::{Cursor, Seek, SeekFrom}; + use local_example_latest_guest::types; + use local_example_latest_guest::types::{Encode, Decode}; + + #[test] + fn test_output() -> Result<(), Box> { + let mut buf = Cursor::new(Vec::new()); + + let nil_model: Option<&types::EmptyModel> = None; + types::EmptyModel::encode(nil_model, &mut buf)?; + fs::write("../../test_data/nil_model.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let empty_model = types::EmptyModel::new(); + types::EmptyModel::encode(Some(&empty_model), &mut buf)?; + fs::write("../../test_data/empty_model.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let empty_model_with_description = types::EmptyModelWithDescription::new(); + types::EmptyModelWithDescription::encode(Some(&empty_model_with_description), &mut buf)?; + fs::write("../../test_data/empty_model_with_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_single_string_field = types::ModelWithSingleStringField::new(); + assert_eq!(model_with_single_string_field.string_field, String::from("DefaultValue")); + model_with_single_string_field.string_field = String::from("hello world"); + types::ModelWithSingleStringField::encode(Some(&model_with_single_string_field), &mut buf)?; + fs::write("../../test_data/model_with_single_string_field.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_single_string_field_and_description = types::ModelWithSingleStringFieldAndDescription::new(); + assert_eq!(model_with_single_string_field_and_description.string_field, String::from("DefaultValue")); + model_with_single_string_field_and_description.string_field = String::from("hello world"); + types::ModelWithSingleStringFieldAndDescription::encode(Some(&model_with_single_string_field_and_description), &mut buf)?; + fs::write("../../test_data/model_with_single_string_field_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_single_int32_field = types::ModelWithSingleInt32Field::new(); + assert_eq!(model_with_single_int32_field.int32_field, 32); + model_with_single_int32_field.int32_field = 42; + types::ModelWithSingleInt32Field::encode(Some(&model_with_single_int32_field), &mut buf)?; + fs::write("../../test_data/model_with_single_int32_field.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_single_int32_field_and_description = types::ModelWithSingleInt32FieldAndDescription::new(); + assert_eq!(model_with_single_int32_field_and_description.int32_field, 32); + model_with_single_int32_field_and_description.int32_field = 42; + types::ModelWithSingleInt32FieldAndDescription::encode(Some(&model_with_single_int32_field_and_description), &mut buf)?; + fs::write("../../test_data/model_with_single_int32_field_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_multiple_fields = types::ModelWithMultipleFields::new(); + assert_eq!(model_with_multiple_fields.string_field, String::from("DefaultValue")); + assert_eq!(model_with_multiple_fields.int32_field, 32); + model_with_multiple_fields.string_field = String::from("hello world"); + model_with_multiple_fields.int32_field = 42; + types::ModelWithMultipleFields::encode(Some(&model_with_multiple_fields), &mut buf)?; + fs::write("../../test_data/model_with_multiple_fields.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_multiple_fields_and_description = types::ModelWithMultipleFieldsAndDescription::new(); + assert_eq!(model_with_multiple_fields_and_description.string_field, String::from("DefaultValue")); + assert_eq!(model_with_multiple_fields_and_description.int32_field, 32); + model_with_multiple_fields_and_description.string_field = String::from("hello world"); + model_with_multiple_fields_and_description.int32_field = 42; + types::ModelWithMultipleFieldsAndDescription::encode(Some(&model_with_multiple_fields_and_description), &mut buf)?; + fs::write("../../test_data/model_with_multiple_fields_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_enum = types::ModelWithEnum::new(); + assert_eq!(model_with_enum.enum_field, types::GenericEnum::DefaultValue); + model_with_enum.enum_field = types::GenericEnum::SecondValue; + types::ModelWithEnum::encode(Some(&model_with_enum), &mut buf)?; + fs::write("../../test_data/model_with_enum.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_enum_and_description = types::ModelWithEnumAndDescription::new(); + assert_eq!(model_with_enum_and_description.enum_field, types::GenericEnum::DefaultValue); + model_with_enum_and_description.enum_field = types::GenericEnum::SecondValue; + types::ModelWithEnumAndDescription::encode(Some(&model_with_enum_and_description), &mut buf)?; + fs::write("../../test_data/model_with_enum_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_enum_accessor = types::ModelWithEnumAccessor::new(); + let default_enum_value = model_with_enum_accessor.get_enum_field(); + assert_eq!(*default_enum_value, types::GenericEnum::DefaultValue); + model_with_enum_accessor.set_enum_field(types::GenericEnum::SecondValue); + types::ModelWithEnumAccessor::encode(Some(&model_with_enum_accessor), &mut buf)?; + fs::write("../../test_data/model_with_enum_accessor.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_enum_accessor_and_description = types::ModelWithEnumAccessorAndDescription::new(); + let default_enum_value = model_with_enum_accessor_and_description.get_enum_field(); + assert_eq!(*default_enum_value, types::GenericEnum::DefaultValue); + model_with_enum_accessor_and_description.set_enum_field(types::GenericEnum::SecondValue); + types::ModelWithEnumAccessorAndDescription::encode(Some(&model_with_enum_accessor_and_description), &mut buf)?; + fs::write("../../test_data/model_with_enum_accessor_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_multiple_fields_accessor = types::ModelWithMultipleFieldsAccessor::new(); + let mut string_value = model_with_multiple_fields_accessor.get_string_field(); + let int32_value = model_with_multiple_fields_accessor.get_int32_field(); + assert_eq!(string_value, String::from("DefaultValue")); + assert_eq!(int32_value, 32); + assert!(model_with_multiple_fields_accessor.set_string_field(String::from("hello world")).is_err()); + assert!(model_with_multiple_fields_accessor.set_string_field(String::from("")).is_err()); + model_with_multiple_fields_accessor.set_string_field(String::from("hello"))?; + string_value = model_with_multiple_fields_accessor.get_string_field(); + assert_eq!(string_value, String::from("HELLO")); + assert!(model_with_multiple_fields_accessor.set_int32_field(-1).is_err()); + assert!(model_with_multiple_fields_accessor.set_int32_field(101).is_err()); + model_with_multiple_fields_accessor.set_int32_field(42)?; + types::ModelWithMultipleFieldsAccessor::encode(Some(&model_with_multiple_fields_accessor), &mut buf)?; + fs::write("../../test_data/model_with_multiple_fields_accessor.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_multiple_fields_accessor_and_description = types::ModelWithMultipleFieldsAccessorAndDescription::new(); + let string_value = model_with_multiple_fields_accessor_and_description.get_string_field(); + let int32_value = model_with_multiple_fields_accessor_and_description.get_int32_field(); + assert_eq!(string_value, String::from("DefaultValue")); + assert_eq!(int32_value, 32); + model_with_multiple_fields_accessor_and_description.set_string_field(String::from("hello world"))?; + model_with_multiple_fields_accessor_and_description.set_int32_field(42)?; + types::ModelWithMultipleFieldsAccessorAndDescription::encode(Some(&model_with_multiple_fields_accessor_and_description), &mut buf)?; + fs::write("../../test_data/model_with_multiple_fields_accessor_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_embedded_models = types::ModelWithEmbeddedModels::new(); + assert!(model_with_embedded_models.embedded_empty_model.is_some()); + assert_eq!(model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor.capacity(), 64); + assert_eq!(model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor.len(), 0); + model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor.push(model_with_multiple_fields_accessor.clone()); + types::ModelWithEmbeddedModels::encode(Some(&model_with_embedded_models), &mut buf)?; + fs::write("../../test_data/model_with_embedded_models.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_embedded_models_and_description = types::ModelWithEmbeddedModelsAndDescription::new(); + assert!(model_with_embedded_models_and_description.embedded_empty_model.is_some()); + assert_eq!(model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor.capacity(), 0); + assert_eq!(model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor.len(), 0); + model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor.push(model_with_multiple_fields_accessor.clone()); + types::ModelWithEmbeddedModelsAndDescription::encode(Some(&model_with_embedded_models_and_description), &mut buf)?; + fs::write("../../test_data/model_with_embedded_models_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_embedded_models_accessor = types::ModelWithEmbeddedModelsAccessor::new(); + let embedded_model = model_with_embedded_models_accessor.get_embedded_empty_model(); + assert!(embedded_model.is_some()); + let embedded_model_array = model_with_embedded_models_accessor.get_embedded_model_array_with_multiple_fields_accessor().unwrap(); + assert_eq!(embedded_model_array.capacity(), 0); + assert_eq!(embedded_model_array.len(), 0); + model_with_embedded_models_accessor.set_embedded_model_array_with_multiple_fields_accessor(vec![model_with_multiple_fields_accessor.clone()]); + types::ModelWithEmbeddedModelsAccessor::encode(Some(&model_with_embedded_models_accessor), &mut buf)?; + fs::write("../../test_data/model_with_embedded_models_accessor.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_embedded_models_accessor_and_description = types::ModelWithEmbeddedModelsAccessorAndDescription::new(); + let embedded_model = model_with_embedded_models_accessor_and_description.get_embedded_empty_model(); + assert!(embedded_model.is_some()); + let embedded_model_array = model_with_embedded_models_accessor_and_description.get_embedded_model_array_with_multiple_fields_accessor().unwrap(); + assert_eq!(embedded_model_array.capacity(), 0); + assert_eq!(embedded_model_array.len(), 0); + model_with_embedded_models_accessor_and_description.set_embedded_model_array_with_multiple_fields_accessor(vec![model_with_multiple_fields_accessor.clone()]); + types::ModelWithEmbeddedModelsAccessorAndDescription::encode(Some(&model_with_embedded_models_accessor_and_description), &mut buf)?; + fs::write("../../test_data/model_with_embedded_models_accessor_and_description.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + let mut model_with_all_field_types = types::ModelWithAllFieldTypes::new(); + + assert_eq!(model_with_all_field_types.string_field, String::from("DefaultValue")); + model_with_all_field_types.string_field = "hello world".to_string(); + assert_eq!(model_with_all_field_types.string_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.string_array_field.len(), 0); + model_with_all_field_types.string_array_field.push("hello".to_string()); + model_with_all_field_types.string_array_field.push("world".to_string()); + assert_eq!(model_with_all_field_types.string_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.string_map_field.len(), 0); + model_with_all_field_types.string_map_field.insert("hello".to_string(), "world".to_string()); + model_with_all_field_types.string_map_field_embedded.insert("hello".to_string(), empty_model.clone()); + + assert_eq!(model_with_all_field_types.int32_field, 32); + model_with_all_field_types.int32_field = 42; + assert_eq!(model_with_all_field_types.int32_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.int32_array_field.len(), 0); + model_with_all_field_types.int32_array_field.push(42); + model_with_all_field_types.int32_array_field.push(84); + assert_eq!(model_with_all_field_types.int32_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.int32_map_field.len(), 0); + model_with_all_field_types.int32_map_field.insert(42, 84); + model_with_all_field_types.int32_map_field_embedded.insert(42, empty_model.clone()); + + assert_eq!(model_with_all_field_types.int64_field, 64); + model_with_all_field_types.int64_field = 100; + assert_eq!(model_with_all_field_types.int64_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.int64_array_field.len(), 0); + model_with_all_field_types.int64_array_field.push(100); + model_with_all_field_types.int64_array_field.push(200); + assert_eq!(model_with_all_field_types.int64_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.int64_map_field.len(), 0); + model_with_all_field_types.int64_map_field.insert(100, 200); + model_with_all_field_types.int64_map_field_embedded.insert(100, empty_model.clone()); + + assert_eq!(model_with_all_field_types.uint32_field, 32); + model_with_all_field_types.uint32_field = 42; + assert_eq!(model_with_all_field_types.uint32_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.uint32_array_field.len(), 0); + model_with_all_field_types.uint32_array_field.push(42); + model_with_all_field_types.uint32_array_field.push(84); + assert_eq!(model_with_all_field_types.uint32_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.uint32_map_field.len(), 0); + model_with_all_field_types.uint32_map_field.insert(42, 84); + model_with_all_field_types.uint32_map_field_embedded.insert(42, empty_model.clone()); + + assert_eq!(model_with_all_field_types.uint64_field, 64); + model_with_all_field_types.uint64_field = 100; + assert_eq!(model_with_all_field_types.uint64_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.uint64_array_field.len(), 0); + model_with_all_field_types.uint64_array_field.push(100); + model_with_all_field_types.uint64_array_field.push(200); + assert_eq!(model_with_all_field_types.uint64_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.uint64_map_field.len(), 0); + model_with_all_field_types.uint64_map_field.insert(100, 200); + model_with_all_field_types.uint64_map_field_embedded.insert(100, empty_model.clone()); + + assert_eq!(model_with_all_field_types.float32_field, 32.32); + model_with_all_field_types.float32_field = 42.0; + assert_eq!(model_with_all_field_types.float32_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.float32_array_field.len(), 0); + model_with_all_field_types.float32_array_field.push(42.0); + model_with_all_field_types.float32_array_field.push(84.0); + + assert_eq!(model_with_all_field_types.float64_field, 64.64); + model_with_all_field_types.float64_field = 100.0; + assert_eq!(model_with_all_field_types.float64_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.float64_array_field.len(), 0); + model_with_all_field_types.float64_array_field.push(100.0); + model_with_all_field_types.float64_array_field.push(200.0); + + assert!(model_with_all_field_types.bool_field); + model_with_all_field_types.bool_field = false; + assert_eq!(model_with_all_field_types.bool_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.bool_array_field.len(), 0); + model_with_all_field_types.bool_array_field.push(true); + model_with_all_field_types.bool_array_field.push(false); + + assert_eq!(model_with_all_field_types.bytes_field.capacity(), 512); + assert_eq!(model_with_all_field_types.bytes_field.len(), 0); + model_with_all_field_types.bytes_field.extend_from_slice(&[42, 84]); + assert_eq!(model_with_all_field_types.bytes_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.bytes_array_field.len(), 0); + model_with_all_field_types.bytes_array_field.push(vec![42, 84]); + model_with_all_field_types.bytes_array_field.push(vec![84, 42]); + + assert_eq!(model_with_all_field_types.enum_field, types::GenericEnum::DefaultValue); + model_with_all_field_types.enum_field = types::GenericEnum::SecondValue; + assert_eq!(model_with_all_field_types.enum_array_field.capacity(), 0); + assert_eq!(model_with_all_field_types.enum_array_field.len(), 0); + model_with_all_field_types.enum_array_field.push(types::GenericEnum::FirstValue); + model_with_all_field_types.enum_array_field.push(types::GenericEnum::SecondValue); + assert_eq!(model_with_all_field_types.enum_map_field.capacity(), 0); + assert_eq!(model_with_all_field_types.enum_map_field.len(), 0); + model_with_all_field_types.enum_map_field.insert(types::GenericEnum::FirstValue, "hello world".to_string()); + model_with_all_field_types.enum_map_field_embedded.insert(types::GenericEnum::FirstValue, empty_model.clone()); + + assert!(model_with_all_field_types.model_field.is_some()); + assert_eq!(model_with_all_field_types.model_array_field.len(), 0); + model_with_all_field_types.model_array_field.push(empty_model.clone()); + model_with_all_field_types.model_array_field.push(empty_model.clone()); + + types::ModelWithAllFieldTypes::encode(Some(&model_with_all_field_types), &mut buf)?; + fs::write("../../test_data/model_with_all_field_types.bin", buf.get_ref())?; + buf.seek(SeekFrom::Start(0))?; + buf.get_mut().clear(); + + Ok(()) + } + + #[test] + fn test_input() -> Result<(), Box> { + let mut null_model_data = fs::read("../../test_data/nil_model.bin")?; + let _null_model = types::EmptyModel::decode(&mut Cursor::new(&mut null_model_data))?; + assert!(_null_model.is_none()); + + let mut empty_model_data = fs::read("../../test_data/empty_model.bin")?; + let _empty_model = types::EmptyModel::decode(&mut Cursor::new(&mut empty_model_data))?; + assert!(_empty_model.is_some()); + + let mut empty_model_with_description_data = fs::read("../../test_data/empty_model_with_description.bin")?; + let _empty_model_with_description = types::EmptyModelWithDescription::decode(&mut Cursor::new(&mut empty_model_with_description_data))?; + assert!(_empty_model_with_description.is_some()); + + let mut model_with_single_string_field_data = fs::read("../../test_data/model_with_single_string_field.bin")?; + let model_with_single_string_field = types::ModelWithSingleStringField::decode(&mut Cursor::new(&mut model_with_single_string_field_data))?.unwrap(); + assert_eq!(model_with_single_string_field.string_field, "hello world"); + + let mut model_with_single_string_field_and_description_data = fs::read("../../test_data/model_with_single_string_field_and_description.bin")?; + let model_with_single_string_field_and_description = types::ModelWithSingleStringFieldAndDescription::decode(&mut Cursor::new(&mut model_with_single_string_field_and_description_data))?.unwrap(); + assert_eq!(model_with_single_string_field_and_description.string_field, "hello world"); + + let mut model_with_single_int32_field_data = fs::read("../../test_data/model_with_single_int32_field.bin")?; + let model_with_single_int32_field = types::ModelWithSingleInt32Field::decode(&mut Cursor::new(&mut model_with_single_int32_field_data))?.unwrap(); + assert_eq!(model_with_single_int32_field.int32_field, 42); + + let mut model_with_single_int32_field_and_description_data = fs::read("../../test_data/model_with_single_int32_field_and_description.bin")?; + let model_with_single_int32_field_and_description = types::ModelWithSingleInt32FieldAndDescription::decode(&mut Cursor::new(&mut model_with_single_int32_field_and_description_data))?.unwrap(); + assert_eq!(model_with_single_int32_field_and_description.int32_field, 42); + + let mut model_with_multiple_fields_data = fs::read("../../test_data/model_with_multiple_fields.bin")?; + let model_with_multiple_fields = types::ModelWithMultipleFields::decode(&mut Cursor::new(&mut model_with_multiple_fields_data))?.unwrap(); + assert_eq!(model_with_multiple_fields.string_field, "hello world"); + assert_eq!(model_with_multiple_fields.int32_field, 42); + + let mut model_with_multiple_fields_and_description_data = fs::read("../../test_data/model_with_multiple_fields_and_description.bin")?; + let model_with_multiple_fields_and_description = types::ModelWithMultipleFieldsAndDescription::decode(&mut Cursor::new(&mut model_with_multiple_fields_and_description_data))?.unwrap(); + assert_eq!(model_with_multiple_fields_and_description.string_field, "hello world"); + assert_eq!(model_with_multiple_fields_and_description.int32_field, 42); + + let mut model_with_enum_data = fs::read("../../test_data/model_with_enum.bin")?; + let model_with_enum = types::ModelWithEnum::decode(&mut Cursor::new(&mut model_with_enum_data))?.unwrap(); + assert_eq!(model_with_enum.enum_field, types::GenericEnum::SecondValue); + + let mut model_with_enum_and_description_data = fs::read("../../test_data/model_with_enum_and_description.bin")?; + let model_with_enum_and_description = types::ModelWithEnumAndDescription::decode(&mut Cursor::new(&mut model_with_enum_and_description_data))?.unwrap(); + assert_eq!(model_with_enum_and_description.enum_field, types::GenericEnum::SecondValue); + + let mut model_with_enum_accessor_data = fs::read("../../test_data/model_with_enum_accessor.bin")?; + let model_with_enum_accessor = types::ModelWithEnumAccessor::decode(&mut Cursor::new(&mut model_with_enum_accessor_data))?.unwrap(); + let enum_value = model_with_enum_accessor.get_enum_field(); + assert_eq!(*enum_value, types::GenericEnum::SecondValue); + + let mut model_with_enum_accessor_and_description_data = fs::read("../../test_data/model_with_enum_accessor_and_description.bin")?; + let model_with_enum_accessor_and_description = types::ModelWithEnumAccessorAndDescription::decode(&mut Cursor::new(&mut model_with_enum_accessor_and_description_data))?.unwrap(); + let enum_value = model_with_enum_accessor_and_description.get_enum_field(); + assert_eq!(*enum_value, types::GenericEnum::SecondValue); + + let mut model_with_multiple_fields_accessor_data = fs::read("../../test_data/model_with_multiple_fields_accessor.bin")?; + let model_with_multiple_fields_accessor = types::ModelWithMultipleFieldsAccessor::decode(&mut Cursor::new(&mut model_with_multiple_fields_accessor_data))?.unwrap(); + let string_field_value = model_with_multiple_fields_accessor.get_string_field(); + assert_eq!(string_field_value, "HELLO"); + let int32_field_value = model_with_multiple_fields_accessor.get_int32_field(); + assert_eq!(int32_field_value, 42); + + let mut model_with_multiple_fields_accessor_and_description_data = fs::read("../../test_data/model_with_multiple_fields_accessor_and_description.bin")?; + let model_with_multiple_fields_accessor_and_description = types::ModelWithMultipleFieldsAccessorAndDescription::decode(&mut Cursor::new(&mut model_with_multiple_fields_accessor_and_description_data))?.unwrap(); + let string_field_value = model_with_multiple_fields_accessor_and_description.get_string_field(); + assert_eq!(string_field_value, "hello world"); + let int32_field_value = model_with_multiple_fields_accessor_and_description.get_int32_field(); + assert_eq!(int32_field_value, 42); + + let mut model_with_embedded_models_data = fs::read("../../test_data/model_with_embedded_models.bin")?; + let model_with_embedded_models = types::ModelWithEmbeddedModels::decode(&mut Cursor::new(&mut model_with_embedded_models_data))?.unwrap(); + assert!(model_with_embedded_models.embedded_empty_model.is_some()); + assert_eq!(model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor.len(), 1); + assert_eq!(model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor[0].get_int32_field(), 42); + assert_eq!(model_with_embedded_models.embedded_model_array_with_multiple_fields_accessor[0].get_string_field(), "HELLO"); + + let mut model_with_embedded_models_and_description_data = fs::read("../../test_data/model_with_embedded_models_and_description.bin")?; + let model_with_embedded_models_and_description = types::ModelWithEmbeddedModelsAndDescription::decode(&mut Cursor::new(&mut model_with_embedded_models_and_description_data))?.unwrap(); + assert!(model_with_embedded_models_and_description.embedded_empty_model.is_some()); + assert_eq!(model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor.len(), 1); + assert_eq!(model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor[0].get_int32_field(), 42); + assert_eq!(model_with_embedded_models_and_description.embedded_model_array_with_multiple_fields_accessor[0].get_string_field(), "HELLO"); + + let mut model_with_embedded_models_accessor_data = fs::read("../../test_data/model_with_embedded_models_accessor.bin")?; + let model_with_embedded_models_accessor = types::ModelWithEmbeddedModelsAccessor::decode(&mut Cursor::new(&mut model_with_embedded_models_accessor_data))?.unwrap(); + let embedded_empty_model = model_with_embedded_models_accessor.get_embedded_empty_model(); + assert!(embedded_empty_model.is_some()); + let embedded_model_array_with_multiple_fields_accessor = model_with_embedded_models_accessor.get_embedded_model_array_with_multiple_fields_accessor().unwrap(); + assert_eq!(embedded_model_array_with_multiple_fields_accessor.len(), 1); + assert_eq!(embedded_model_array_with_multiple_fields_accessor[0].get_int32_field(), 42); + assert_eq!(embedded_model_array_with_multiple_fields_accessor[0].get_string_field(), "HELLO"); + + let mut model_with_embedded_models_accessor_and_description_data = fs::read("../../test_data/model_with_embedded_models_accessor_and_description.bin")?; + let model_with_embedded_models_accessor_and_description = types::ModelWithEmbeddedModelsAccessorAndDescription::decode(&mut Cursor::new(&mut model_with_embedded_models_accessor_and_description_data))?.unwrap(); + let embedded_empty_model = model_with_embedded_models_accessor_and_description.get_embedded_empty_model(); + assert!(embedded_empty_model.is_some()); + let embedded_model_array_with_multiple_fields_accessor = model_with_embedded_models_accessor_and_description.get_embedded_model_array_with_multiple_fields_accessor().unwrap(); + assert_eq!(embedded_model_array_with_multiple_fields_accessor[0].get_int32_field(), 42); + assert_eq!(embedded_model_array_with_multiple_fields_accessor[0].get_string_field(), "HELLO"); + + let mut model_with_all_field_types_data = fs::read("../../test_data/model_with_all_field_types.bin")?; + let model_with_all_field_types = types::ModelWithAllFieldTypes::decode(&mut Cursor::new(&mut model_with_all_field_types_data))?.unwrap(); + assert_eq!(model_with_all_field_types.string_field, "hello world"); + assert_eq!(model_with_all_field_types.string_array_field.len(), 2); + assert_eq!(model_with_all_field_types.string_array_field[0], "hello"); + assert_eq!(model_with_all_field_types.string_array_field[1], "world"); + assert_eq!(model_with_all_field_types.string_map_field.get("hello"), Some(&"world".to_string())); + assert!(model_with_all_field_types.string_map_field_embedded.get("hello").is_some()); + + assert_eq!(model_with_all_field_types.int32_field, 42); + assert_eq!(model_with_all_field_types.int32_array_field.len(), 2); + assert_eq!(model_with_all_field_types.int32_array_field[0], 42); + assert_eq!(model_with_all_field_types.int32_array_field[1], 84); + assert_eq!(model_with_all_field_types.int32_map_field.get(&42), Some(&84)); + assert!(model_with_all_field_types.int32_map_field_embedded.get(&42).is_some()); + + assert_eq!(model_with_all_field_types.int64_field, 100); + assert_eq!(model_with_all_field_types.int64_array_field.len(), 2); + assert_eq!(model_with_all_field_types.int64_array_field[0], 100); + assert_eq!(model_with_all_field_types.int64_array_field[1], 200); + assert_eq!(model_with_all_field_types.int64_map_field.get(&100), Some(&200)); + assert!(model_with_all_field_types.int64_map_field_embedded.get(&100).is_some()); + + assert_eq!(model_with_all_field_types.uint32_field, 42); + assert_eq!(model_with_all_field_types.uint32_array_field.len(), 2); + assert_eq!(model_with_all_field_types.uint32_array_field[0], 42); + assert_eq!(model_with_all_field_types.uint32_array_field[1], 84); + assert_eq!(model_with_all_field_types.uint32_map_field.get(&42), Some(&84)); + assert!(model_with_all_field_types.uint32_map_field_embedded.get(&42).is_some()); + + assert_eq!(model_with_all_field_types.uint64_field, 100); + assert_eq!(model_with_all_field_types.uint64_array_field.len(), 2); + assert_eq!(model_with_all_field_types.uint64_array_field[0], 100); + assert_eq!(model_with_all_field_types.uint64_array_field[1], 200); + assert_eq!(model_with_all_field_types.uint64_map_field.get(&100), Some(&200)); + assert!(model_with_all_field_types.uint64_map_field_embedded.get(&100).is_some()); + + assert_eq!(model_with_all_field_types.float32_field, 42.0); + assert_eq!(model_with_all_field_types.float32_array_field.len(), 2); + assert_eq!(model_with_all_field_types.float32_array_field[0], 42.0); + assert_eq!(model_with_all_field_types.float32_array_field[1], 84.0); + + assert_eq!(model_with_all_field_types.float64_field, 100.0); + assert_eq!(model_with_all_field_types.float64_array_field.len(), 2); + assert_eq!(model_with_all_field_types.float64_array_field[0], 100.0); + assert_eq!(model_with_all_field_types.float64_array_field[1], 200.0); + + assert_eq!(model_with_all_field_types.bool_field, false); + assert_eq!(model_with_all_field_types.bool_array_field.len(), 2); + assert_eq!(model_with_all_field_types.bool_array_field[0], true); + assert_eq!(model_with_all_field_types.bool_array_field[1], false); + + assert_eq!(model_with_all_field_types.bytes_field, &[42, 84]); + assert_eq!(model_with_all_field_types.bytes_array_field.len(), 2); + assert_eq!(model_with_all_field_types.bytes_array_field[0], &[42, 84]); + assert_eq!(model_with_all_field_types.bytes_array_field[1], &[84, 42]); + + assert_eq!(model_with_all_field_types.enum_field, types::GenericEnum::SecondValue); + assert_eq!(model_with_all_field_types.enum_array_field.len(), 2); + assert_eq!(model_with_all_field_types.enum_array_field[0], types::GenericEnum::FirstValue); + assert_eq!(model_with_all_field_types.enum_array_field[1], types::GenericEnum::SecondValue); + assert_eq!(model_with_all_field_types.enum_map_field.get(&types::GenericEnum::FirstValue), Some(&"hello world".to_string())); + assert!(model_with_all_field_types.enum_map_field_embedded.get(&types::GenericEnum::FirstValue).is_some()); + + assert_eq!(model_with_all_field_types.model_array_field.len(), 2); + + Ok(()) + } +} \ No newline at end of file diff --git a/integration/rust_tests/signature/types.rs b/integration/rust_tests/signature/types.rs new file mode 100644 index 00000000..861249ca --- /dev/null +++ b/integration/rust_tests/signature/types.rs @@ -0,0 +1,1840 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local_example_latest_guest + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_mut)] +use num_enum::TryFromPrimitive; +use polyglot_rs::{Decoder, DecodingError, Encoder, Kind}; +use regex::Regex; +use std::collections::HashMap; +use std::convert::TryFrom; +use std::io::Cursor; +pub trait Encode { + fn encode<'a>( + a: Option<&Self>, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> + where + Self: Sized; +} +trait EncodeSelf { + fn encode_self<'a, 'b>( + &'b self, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box>; +} +pub trait Decode { + fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> + where + Self: Sized; +} +#[derive(Debug, Eq, PartialEq, TryFromPrimitive, Copy, Clone, Hash)] +#[repr(u32)] +pub enum GenericEnum { + FirstValue = 0, + SecondValue = 1, + DefaultValue = 2, +} +#[derive(Clone, Debug, PartialEq)] +pub struct EmptyModel {} +impl EmptyModel { + pub fn new() -> Self { + Self {} + } +} +impl Encode for EmptyModel { + fn encode<'a>( + a: Option<&EmptyModel>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for EmptyModel { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + Ok(e) + } +} +impl EncodeSelf for Option<&EmptyModel> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for EmptyModel { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = EmptyModel::new(); + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct EmptyModelWithDescription {} +impl EmptyModelWithDescription { + pub fn new() -> Self { + Self {} + } +} +impl Encode for EmptyModelWithDescription { + fn encode<'a>( + a: Option<&EmptyModelWithDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for EmptyModelWithDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + Ok(e) + } +} +impl EncodeSelf for Option<&EmptyModelWithDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for EmptyModelWithDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = EmptyModelWithDescription::new(); + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleStringField { + pub string_field: String, +} +impl ModelWithSingleStringField { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + } + } +} +impl Encode for ModelWithSingleStringField { + fn encode<'a>( + a: Option<&ModelWithSingleStringField>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleStringField { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleStringField> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleStringField { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleStringField::new(); + x.string_field = d.decode_string()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleStringFieldAndDescription { + pub string_field: String, +} +impl ModelWithSingleStringFieldAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + } + } +} +impl Encode for ModelWithSingleStringFieldAndDescription { + fn encode<'a>( + a: Option<&ModelWithSingleStringFieldAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleStringFieldAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleStringFieldAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleStringFieldAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleStringFieldAndDescription::new(); + x.string_field = d.decode_string()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleInt32Field { + pub int32_field: i32, +} +impl ModelWithSingleInt32Field { + pub fn new() -> Self { + Self { int32_field: 32 } + } +} +impl Encode for ModelWithSingleInt32Field { + fn encode<'a>( + a: Option<&ModelWithSingleInt32Field>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleInt32Field { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleInt32Field> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleInt32Field { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleInt32Field::new(); + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleInt32FieldAndDescription { + pub int32_field: i32, +} +impl ModelWithSingleInt32FieldAndDescription { + pub fn new() -> Self { + Self { int32_field: 32 } + } +} +impl Encode for ModelWithSingleInt32FieldAndDescription { + fn encode<'a>( + a: Option<&ModelWithSingleInt32FieldAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleInt32FieldAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleInt32FieldAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleInt32FieldAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleInt32FieldAndDescription::new(); + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFields { + pub string_field: String, + pub int32_field: i32, +} +impl ModelWithMultipleFields { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } +} +impl Encode for ModelWithMultipleFields { + fn encode<'a>( + a: Option<&ModelWithMultipleFields>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFields { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFields> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFields { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFields::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAndDescription { + pub string_field: String, + pub int32_field: i32, +} +impl ModelWithMultipleFieldsAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } +} +impl Encode for ModelWithMultipleFieldsAndDescription { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAndDescription::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnum { + pub enum_field: GenericEnum, +} +impl ModelWithEnum { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnum { + fn encode<'a>( + a: Option<&ModelWithEnum>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnum { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnum> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnum { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnum::new(); + x.enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAndDescription { + pub enum_field: GenericEnum, +} +impl ModelWithEnumAndDescription { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAndDescription { + fn encode<'a>( + a: Option<&ModelWithEnumAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAndDescription::new(); + x.enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAccessor { + enum_field: GenericEnum, +} +impl ModelWithEnumAccessor { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAccessor { + fn encode<'a>( + a: Option<&ModelWithEnumAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAccessor::new(); + x.enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +impl ModelWithEnumAccessor { + pub fn get_enum_field(&self) -> &GenericEnum { + &self.enum_field + } + pub fn set_enum_field(&mut self, v: GenericEnum) { + self.enum_field = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAccessorAndDescription { + enum_field: GenericEnum, +} +impl ModelWithEnumAccessorAndDescription { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithEnumAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAccessorAndDescription::new(); + x.enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +impl ModelWithEnumAccessorAndDescription { + pub fn get_enum_field(&self) -> &GenericEnum { + &self.enum_field + } + pub fn set_enum_field(&mut self, v: GenericEnum) { + self.enum_field = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAccessor { + string_field: String, + int32_field: i32, +} +impl ModelWithMultipleFieldsAccessor { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } + pub fn get_string_field(&self) -> String { + self.string_field.clone() + } + pub fn set_string_field(&mut self, mut v: String) -> Result<(), Box> { + if !Regex::new("^[a-zA-Z0-9]*$")?.is_match(v.as_str()) { + return Err(Box::::from( + "value must match ^[a-zA-Z0-9]*$", + )); + } + if v.len() > 20 || v.len() < 1 { + return Err(Box::::from( + "value must be between { .Minimum }} and 20", + )); + } + v = v.to_uppercase(); + self.string_field = v; + Ok(()) + } + pub fn get_int32_field(&self) -> i32 { + self.int32_field + } + pub fn set_int32_field(&mut self, v: i32) -> Result<(), Box> { + if v > 100 || v < 0 { + return Err(Box::::from( + "value must be between { .Minimum }} and 100", + )); + } + self.int32_field = v; + Ok(()) + } +} +impl Encode for ModelWithMultipleFieldsAccessor { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAccessor::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAccessorAndDescription { + string_field: String, + int32_field: i32, +} +impl ModelWithMultipleFieldsAccessorAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } + pub fn get_string_field(&self) -> String { + self.string_field.clone() + } + pub fn set_string_field(&mut self, mut v: String) -> Result<(), Box> { + self.string_field = v; + Ok(()) + } + pub fn get_int32_field(&self) -> i32 { + self.int32_field + } + pub fn set_int32_field(&mut self, v: i32) -> Result<(), Box> { + self.int32_field = v; + Ok(()) + } +} +impl Encode for ModelWithMultipleFieldsAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> + { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAccessorAndDescription::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModels { + pub embedded_empty_model: Option, + pub embedded_model_array_with_multiple_fields_accessor: Vec, +} +impl ModelWithEmbeddedModels { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(64), + } + } +} +impl Encode for ModelWithEmbeddedModels { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModels>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModels { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor + .len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModels> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModels { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModels::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d.decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor.push( + ModelWithMultipleFieldsAccessor::decode(d)?.ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAndDescription { + pub embedded_empty_model: Option, + pub embedded_model_array_with_multiple_fields_accessor: Vec, +} +impl ModelWithEmbeddedModelsAndDescription { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAndDescription { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor + .len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAndDescription::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d.decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor.push( + ModelWithMultipleFieldsAccessor::decode(d)?.ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAccessor { + embedded_empty_model: Option, + embedded_model_array_with_multiple_fields_accessor: Vec, +} +impl ModelWithEmbeddedModelsAccessor { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAccessor { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor + .len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAccessor::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d.decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor.push( + ModelWithMultipleFieldsAccessor::decode(d)?.ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +impl ModelWithEmbeddedModelsAccessor { + pub fn get_embedded_empty_model(&self) -> &Option { + &self.embedded_empty_model + } + pub fn set_embedded_empty_model(&mut self, v: Option) { + self.embedded_empty_model = v; + } +} +impl ModelWithEmbeddedModelsAccessor { + pub fn get_embedded_model_array_with_multiple_fields_accessor( + &self, + ) -> Option<&Vec> { + Some(&self.embedded_model_array_with_multiple_fields_accessor) + } + pub fn set_embedded_model_array_with_multiple_fields_accessor( + &mut self, + v: Vec, + ) { + self.embedded_model_array_with_multiple_fields_accessor = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAccessorAndDescription { + embedded_empty_model: Option, + embedded_model_array_with_multiple_fields_accessor: Vec, +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor + .len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> + { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAccessorAndDescription::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d.decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor.push( + ModelWithMultipleFieldsAccessor::decode(d)?.ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn get_embedded_empty_model(&self) -> &Option { + &self.embedded_empty_model + } + pub fn set_embedded_empty_model(&mut self, v: Option) { + self.embedded_empty_model = v; + } +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn get_embedded_model_array_with_multiple_fields_accessor( + &self, + ) -> Option<&Vec> { + Some(&self.embedded_model_array_with_multiple_fields_accessor) + } + pub fn set_embedded_model_array_with_multiple_fields_accessor( + &mut self, + v: Vec, + ) { + self.embedded_model_array_with_multiple_fields_accessor = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithAllFieldTypes { + pub model_field: Option, + pub model_array_field: Vec, + pub string_field: String, + pub string_array_field: Vec, + pub string_map_field: HashMap, + pub string_map_field_embedded: HashMap, + pub int32_field: i32, + pub int32_array_field: Vec, + pub int32_map_field: HashMap, + pub int32_map_field_embedded: HashMap, + pub int64_field: i64, + pub int64_array_field: Vec, + pub int64_map_field: HashMap, + pub int64_map_field_embedded: HashMap, + pub uint32_field: u32, + pub uint32_array_field: Vec, + pub uint32_map_field: HashMap, + pub uint32_map_field_embedded: HashMap, + pub uint64_field: u64, + pub uint64_array_field: Vec, + pub uint64_map_field: HashMap, + pub uint64_map_field_embedded: HashMap, + pub float32_field: f32, + pub float32_array_field: Vec, + pub float64_field: f64, + pub float64_array_field: Vec, + pub enum_field: GenericEnum, + pub enum_array_field: Vec, + pub enum_map_field: HashMap, + pub enum_map_field_embedded: HashMap, + pub bytes_field: Vec, + pub bytes_array_field: Vec>, + pub bool_field: bool, + pub bool_array_field: Vec, +} +impl ModelWithAllFieldTypes { + pub fn new() -> Self { + Self { + model_field: Some(EmptyModel::new()), + model_array_field: Vec::with_capacity(0), + string_field: "DefaultValue".to_string(), + string_array_field: Vec::with_capacity(0), + string_map_field: HashMap::new(), + string_map_field_embedded: HashMap::new(), + int32_field: 32, + int32_array_field: Vec::with_capacity(0), + int32_map_field: HashMap::new(), + int32_map_field_embedded: HashMap::new(), + int64_field: 64, + int64_array_field: Vec::with_capacity(0), + int64_map_field: HashMap::new(), + int64_map_field_embedded: HashMap::new(), + uint32_field: 32, + uint32_array_field: Vec::with_capacity(0), + uint32_map_field: HashMap::new(), + uint32_map_field_embedded: HashMap::new(), + uint64_field: 64, + uint64_array_field: Vec::with_capacity(0), + uint64_map_field: HashMap::new(), + uint64_map_field_embedded: HashMap::new(), + float32_field: 32.32, + float32_array_field: Vec::with_capacity(0), + float64_field: 64.64, + float64_array_field: Vec::with_capacity(0), + enum_field: GenericEnum::DefaultValue, + enum_array_field: Vec::with_capacity(0), + enum_map_field: HashMap::new(), + enum_map_field_embedded: HashMap::new(), + bytes_field: Vec::with_capacity(512), + bytes_array_field: Vec::with_capacity(0), + bool_field: true, + bool_array_field: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithAllFieldTypes { + fn encode<'a>( + a: Option<&ModelWithAllFieldTypes>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithAllFieldTypes { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.model_field.encode_self(e)?; + e.encode_array(self.model_array_field.len(), Kind::Any)?; + for a in &self.model_array_field { + a.encode_self(e)?; + } + e.encode_string(&self.string_field)?; + e.encode_array(self.string_array_field.len(), Kind::String)?; + for a in &self.string_array_field { + e.encode_string(&a)?; + } + e.encode_map(self.string_map_field.len(), Kind::String, Kind::String)?; + for (k, v) in &self.string_map_field { + e.encode_string(&k)?; + e.encode_string(&v)?; + } + e.encode_map( + self.string_map_field_embedded.len(), + Kind::String, + Kind::Any, + )?; + for (k, v) in &self.string_map_field_embedded { + e.encode_string(&k)?; + v.encode_self(e)?; + } + e.encode_i32(self.int32_field)?; + e.encode_array(self.int32_array_field.len(), Kind::I32)?; + for a in &self.int32_array_field { + e.encode_i32(*a)?; + } + e.encode_map(self.int32_map_field.len(), Kind::I32, Kind::I32)?; + for (k, v) in &self.int32_map_field { + e.encode_i32(*k)?; + e.encode_i32(*v)?; + } + e.encode_map(self.int32_map_field_embedded.len(), Kind::I32, Kind::Any)?; + for (k, v) in &self.int32_map_field_embedded { + e.encode_i32(*k)?; + v.encode_self(e)?; + } + e.encode_i64(self.int64_field)?; + e.encode_array(self.int64_array_field.len(), Kind::I64)?; + for a in &self.int64_array_field { + e.encode_i64(*a)?; + } + e.encode_map(self.int64_map_field.len(), Kind::I64, Kind::I64)?; + for (k, v) in &self.int64_map_field { + e.encode_i64(*k)?; + e.encode_i64(*v)?; + } + e.encode_map(self.int64_map_field_embedded.len(), Kind::I64, Kind::Any)?; + for (k, v) in &self.int64_map_field_embedded { + e.encode_i64(*k)?; + v.encode_self(e)?; + } + e.encode_u32(self.uint32_field)?; + e.encode_array(self.uint32_array_field.len(), Kind::U32)?; + for a in &self.uint32_array_field { + e.encode_u32(*a)?; + } + e.encode_map(self.uint32_map_field.len(), Kind::U32, Kind::U32)?; + for (k, v) in &self.uint32_map_field { + e.encode_u32(*k)?; + e.encode_u32(*v)?; + } + e.encode_map(self.uint32_map_field_embedded.len(), Kind::U32, Kind::Any)?; + for (k, v) in &self.uint32_map_field_embedded { + e.encode_u32(*k)?; + v.encode_self(e)?; + } + e.encode_u64(self.uint64_field)?; + e.encode_array(self.uint64_array_field.len(), Kind::U64)?; + for a in &self.uint64_array_field { + e.encode_u64(*a)?; + } + e.encode_map(self.uint64_map_field.len(), Kind::U64, Kind::U64)?; + for (k, v) in &self.uint64_map_field { + e.encode_u64(*k)?; + e.encode_u64(*v)?; + } + e.encode_map(self.uint64_map_field_embedded.len(), Kind::U64, Kind::Any)?; + for (k, v) in &self.uint64_map_field_embedded { + e.encode_u64(*k)?; + v.encode_self(e)?; + } + e.encode_f32(self.float32_field)?; + e.encode_array(self.float32_array_field.len(), Kind::F32)?; + for a in &self.float32_array_field { + e.encode_f32(*a)?; + } + e.encode_f64(self.float64_field)?; + e.encode_array(self.float64_array_field.len(), Kind::F64)?; + for a in &self.float64_array_field { + e.encode_f64(*a)?; + } + e.encode_u32(self.enum_field as u32)?; + e.encode_array(self.enum_array_field.len(), Kind::U32)?; + for a in &self.enum_array_field { + e.encode_u32(*a as u32)?; + } + e.encode_map(self.enum_map_field.len(), Kind::U32, Kind::String)?; + for (k, v) in &self.enum_map_field { + e.encode_u32(*k as u32)?; + e.encode_string(&v)?; + } + e.encode_map(self.enum_map_field_embedded.len(), Kind::U32, Kind::Any)?; + for (k, v) in &self.enum_map_field_embedded { + e.encode_u32(*k as u32)?; + v.encode_self(e)?; + } + e.encode_bytes(&self.bytes_field)?; + e.encode_array(self.bytes_array_field.len(), Kind::Bytes)?; + for a in &self.bytes_array_field { + e.encode_bytes(&a)?; + } + e.encode_bool(self.bool_field)?; + e.encode_array(self.bool_array_field.len(), Kind::Bool)?; + for a in &self.bool_array_field { + e.encode_bool(*a)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithAllFieldTypes> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithAllFieldTypes { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithAllFieldTypes::new(); + x.model_field = EmptyModel::decode(d)?; + let size_model_array_field = d.decode_array(Kind::Any)?; + for _ in 0..size_model_array_field { + x.model_array_field + .push(EmptyModel::decode(d)?.ok_or(DecodingError::InvalidArray)?); + } + x.string_field = d.decode_string()?; + let size_string_array_field = d.decode_array(Kind::String)?; + for _ in 0..size_string_array_field { + x.string_array_field.push(d.decode_string()?); + } + let size_string_map_field = d.decode_map(Kind::String, Kind::String)?; + for _ in 0..size_string_map_field { + let k = d.decode_string()?; + let v = d.decode_string()?; + x.string_map_field.insert(k, v); + } + let size_string_map_field_embedded = d.decode_map(Kind::String, Kind::Any)?; + for _ in 0..size_string_map_field_embedded { + let k = d.decode_string()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.string_map_field_embedded.insert(k, v); + } + x.int32_field = d.decode_i32()?; + let size_int32_array_field = d.decode_array(Kind::I32)?; + for _ in 0..size_int32_array_field { + x.int32_array_field.push(d.decode_i32()?); + } + let size_int32_map_field = d.decode_map(Kind::I32, Kind::I32)?; + for _ in 0..size_int32_map_field { + let k = d.decode_i32()?; + let v = d.decode_i32()?; + x.int32_map_field.insert(k, v); + } + let size_int32_map_field_embedded = d.decode_map(Kind::I32, Kind::Any)?; + for _ in 0..size_int32_map_field_embedded { + let k = d.decode_i32()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.int32_map_field_embedded.insert(k, v); + } + x.int64_field = d.decode_i64()?; + let size_int64_array_field = d.decode_array(Kind::I64)?; + for _ in 0..size_int64_array_field { + x.int64_array_field.push(d.decode_i64()?); + } + let size_int64_map_field = d.decode_map(Kind::I64, Kind::I64)?; + for _ in 0..size_int64_map_field { + let k = d.decode_i64()?; + let v = d.decode_i64()?; + x.int64_map_field.insert(k, v); + } + let size_int64_map_field_embedded = d.decode_map(Kind::I64, Kind::Any)?; + for _ in 0..size_int64_map_field_embedded { + let k = d.decode_i64()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.int64_map_field_embedded.insert(k, v); + } + x.uint32_field = d.decode_u32()?; + let size_uint32_array_field = d.decode_array(Kind::U32)?; + for _ in 0..size_uint32_array_field { + x.uint32_array_field.push(d.decode_u32()?); + } + let size_uint32_map_field = d.decode_map(Kind::U32, Kind::U32)?; + for _ in 0..size_uint32_map_field { + let k = d.decode_u32()?; + let v = d.decode_u32()?; + x.uint32_map_field.insert(k, v); + } + let size_uint32_map_field_embedded = d.decode_map(Kind::U32, Kind::Any)?; + for _ in 0..size_uint32_map_field_embedded { + let k = d.decode_u32()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.uint32_map_field_embedded.insert(k, v); + } + x.uint64_field = d.decode_u64()?; + let size_uint64_array_field = d.decode_array(Kind::U64)?; + for _ in 0..size_uint64_array_field { + x.uint64_array_field.push(d.decode_u64()?); + } + let size_uint64_map_field = d.decode_map(Kind::U64, Kind::U64)?; + for _ in 0..size_uint64_map_field { + let k = d.decode_u64()?; + let v = d.decode_u64()?; + x.uint64_map_field.insert(k, v); + } + let size_uint64_map_field_embedded = d.decode_map(Kind::U64, Kind::Any)?; + for _ in 0..size_uint64_map_field_embedded { + let k = d.decode_u64()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.uint64_map_field_embedded.insert(k, v); + } + x.float32_field = d.decode_f32()?; + let size_float32_array_field = d.decode_array(Kind::F32)?; + for _ in 0..size_float32_array_field { + x.float32_array_field.push(d.decode_f32()?); + } + x.float64_field = d.decode_f64()?; + let size_float64_array_field = d.decode_array(Kind::F64)?; + for _ in 0..size_float64_array_field { + x.float64_array_field.push(d.decode_f64()?); + } + x.enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + let size_enum_array_field = d.decode_array(Kind::U32)?; + for _ in 0..size_enum_array_field { + x.enum_array_field + .push(GenericEnum::try_from(d.decode_u32()?)?); + } + let size_enum_map_field = d.decode_map(Kind::U32, Kind::String)?; + for _ in 0..size_enum_map_field { + let k = GenericEnum::try_from(d.decode_u32()?)?; + let v = d.decode_string()?; + x.enum_map_field.insert(k, v); + } + let size_enum_map_field_embedded = d.decode_map(Kind::U32, Kind::Any)?; + for _ in 0..size_enum_map_field_embedded { + let k = GenericEnum::try_from(d.decode_u32()?)?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.enum_map_field_embedded.insert(k, v); + } + x.bytes_field = d.decode_bytes()?; + let size_bytes_array_field = d.decode_array(Kind::Bytes)?; + for _ in 0..size_bytes_array_field { + x.bytes_array_field.push(d.decode_bytes()?); + } + x.bool_field = d.decode_bool()?; + let size_bool_array_field = d.decode_array(Kind::Bool)?; + for _ in 0..size_bool_array_field { + x.bool_array_field.push(d.decode_bool()?); + } + Ok(Some(x)) + } +} diff --git a/ts/compile/builder/crates/core/.cargo/config b/integration/test_data/empty_model.bin similarity index 100% rename from ts/compile/builder/crates/core/.cargo/config rename to integration/test_data/empty_model.bin diff --git a/ts/compile/builder/crates/core/src/index.js b/integration/test_data/empty_model_with_description.bin similarity index 100% rename from ts/compile/builder/crates/core/src/index.js rename to integration/test_data/empty_model_with_description.bin diff --git a/integration/test_data/model_with_all_field_types.bin b/integration/test_data/model_with_all_field_types.bin new file mode 100644 index 00000000..f3c9e354 Binary files /dev/null and b/integration/test_data/model_with_all_field_types.bin differ diff --git a/integration/test_data/model_with_embedded_models.bin b/integration/test_data/model_with_embedded_models.bin new file mode 100644 index 00000000..f8d61a00 --- /dev/null +++ b/integration/test_data/model_with_embedded_models.bin @@ -0,0 +1,3 @@ + + +HELLO T \ No newline at end of file diff --git a/integration/test_data/model_with_embedded_models_accessor.bin b/integration/test_data/model_with_embedded_models_accessor.bin new file mode 100644 index 00000000..f8d61a00 --- /dev/null +++ b/integration/test_data/model_with_embedded_models_accessor.bin @@ -0,0 +1,3 @@ + + +HELLO T \ No newline at end of file diff --git a/integration/test_data/model_with_embedded_models_accessor_and_description.bin b/integration/test_data/model_with_embedded_models_accessor_and_description.bin new file mode 100644 index 00000000..f8d61a00 --- /dev/null +++ b/integration/test_data/model_with_embedded_models_accessor_and_description.bin @@ -0,0 +1,3 @@ + + +HELLO T \ No newline at end of file diff --git a/integration/test_data/model_with_embedded_models_and_description.bin b/integration/test_data/model_with_embedded_models_and_description.bin new file mode 100644 index 00000000..f8d61a00 --- /dev/null +++ b/integration/test_data/model_with_embedded_models_and_description.bin @@ -0,0 +1,3 @@ + + +HELLO T \ No newline at end of file diff --git a/integration/test_data/model_with_enum.bin b/integration/test_data/model_with_enum.bin new file mode 100644 index 00000000..bbe77981 --- /dev/null +++ b/integration/test_data/model_with_enum.bin @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/integration/test_data/model_with_enum_accessor.bin b/integration/test_data/model_with_enum_accessor.bin new file mode 100644 index 00000000..bbe77981 --- /dev/null +++ b/integration/test_data/model_with_enum_accessor.bin @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/integration/test_data/model_with_enum_accessor_and_description.bin b/integration/test_data/model_with_enum_accessor_and_description.bin new file mode 100644 index 00000000..bbe77981 --- /dev/null +++ b/integration/test_data/model_with_enum_accessor_and_description.bin @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/integration/test_data/model_with_enum_and_description.bin b/integration/test_data/model_with_enum_and_description.bin new file mode 100644 index 00000000..bbe77981 --- /dev/null +++ b/integration/test_data/model_with_enum_and_description.bin @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/integration/test_data/model_with_multiple_fields.bin b/integration/test_data/model_with_multiple_fields.bin new file mode 100644 index 00000000..ce21921c --- /dev/null +++ b/integration/test_data/model_with_multiple_fields.bin @@ -0,0 +1,2 @@ + + hello world T \ No newline at end of file diff --git a/integration/test_data/model_with_multiple_fields_accessor.bin b/integration/test_data/model_with_multiple_fields_accessor.bin new file mode 100644 index 00000000..660c6e70 --- /dev/null +++ b/integration/test_data/model_with_multiple_fields_accessor.bin @@ -0,0 +1,2 @@ + +HELLO T \ No newline at end of file diff --git a/integration/test_data/model_with_multiple_fields_accessor_and_description.bin b/integration/test_data/model_with_multiple_fields_accessor_and_description.bin new file mode 100644 index 00000000..ce21921c --- /dev/null +++ b/integration/test_data/model_with_multiple_fields_accessor_and_description.bin @@ -0,0 +1,2 @@ + + hello world T \ No newline at end of file diff --git a/integration/test_data/model_with_multiple_fields_and_description.bin b/integration/test_data/model_with_multiple_fields_and_description.bin new file mode 100644 index 00000000..ce21921c --- /dev/null +++ b/integration/test_data/model_with_multiple_fields_and_description.bin @@ -0,0 +1,2 @@ + + hello world T \ No newline at end of file diff --git a/integration/test_data/model_with_single_int32_field.bin b/integration/test_data/model_with_single_int32_field.bin new file mode 100644 index 00000000..7c292eb3 --- /dev/null +++ b/integration/test_data/model_with_single_int32_field.bin @@ -0,0 +1 @@ + T \ No newline at end of file diff --git a/integration/test_data/model_with_single_int32_field_and_description.bin b/integration/test_data/model_with_single_int32_field_and_description.bin new file mode 100644 index 00000000..7c292eb3 --- /dev/null +++ b/integration/test_data/model_with_single_int32_field_and_description.bin @@ -0,0 +1 @@ + T \ No newline at end of file diff --git a/integration/test_data/model_with_single_string_field.bin b/integration/test_data/model_with_single_string_field.bin new file mode 100644 index 00000000..ba170e7d --- /dev/null +++ b/integration/test_data/model_with_single_string_field.bin @@ -0,0 +1,2 @@ + + hello world \ No newline at end of file diff --git a/integration/test_data/model_with_single_string_field_and_description.bin b/integration/test_data/model_with_single_string_field_and_description.bin new file mode 100644 index 00000000..ba170e7d --- /dev/null +++ b/integration/test_data/model_with_single_string_field_and_description.bin @@ -0,0 +1,2 @@ + + hello world \ No newline at end of file diff --git a/integration/test_data/nil_model.bin b/integration/test_data/nil_model.bin new file mode 100644 index 00000000..f76dd238 Binary files /dev/null and b/integration/test_data/nil_model.bin differ diff --git a/integration/typescript_tests/function/index.ts b/integration/typescript_tests/function/index.ts new file mode 100644 index 00000000..dc3a1ee3 --- /dev/null +++ b/integration/typescript_tests/function/index.ts @@ -0,0 +1,25 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import * as signature from "signature"; + +export function example(ctx?: signature.ModelWithAllFieldTypes): signature.ModelWithAllFieldTypes | undefined { + console.log("This is a Typescript Function"); + if (typeof ctx !== "undefined") { + ctx.stringField = "This is a Typescript Function" + } + return signature.Next(ctx); +} \ No newline at end of file diff --git a/integration/typescript_tests/function/node_modules/.package-lock.json b/integration/typescript_tests/function/node_modules/.package-lock.json new file mode 100644 index 00000000..fe127439 --- /dev/null +++ b/integration/typescript_tests/function/node_modules/.package-lock.json @@ -0,0 +1,27 @@ +{ + "name": "example", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "../signature": { + "name": "local-example-latest-guest", + "version": "0.1.0", + "dependencies": { + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3" + } + }, + "node_modules/signature": { + "resolved": "../signature", + "link": true + } + } +} diff --git a/integration/typescript_tests/function/node_modules/signature b/integration/typescript_tests/function/node_modules/signature new file mode 120000 index 00000000..bda570a0 --- /dev/null +++ b/integration/typescript_tests/function/node_modules/signature @@ -0,0 +1 @@ +../../signature \ No newline at end of file diff --git a/integration/typescript_tests/function/package-lock.json b/integration/typescript_tests/function/package-lock.json new file mode 100644 index 00000000..e4f24478 --- /dev/null +++ b/integration/typescript_tests/function/package-lock.json @@ -0,0 +1,34 @@ +{ + "name": "example", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "example", + "version": "0.1.0", + "dependencies": { + "signature": "file:../signature" + } + }, + "../signature": { + "name": "local-example-latest-guest", + "version": "0.1.0", + "dependencies": { + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3" + } + }, + "node_modules/signature": { + "resolved": "../signature", + "link": true + } + } +} diff --git a/integration/typescript_tests/function/package.json b/integration/typescript_tests/function/package.json new file mode 100644 index 00000000..bb83b0c1 --- /dev/null +++ b/integration/typescript_tests/function/package.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version": "0.1.0", + "main": "index.ts", + "dependencies": { + "signature": "file:../signature" + } +} diff --git a/integration/typescript_tests/generated/generated.d.ts b/integration/typescript_tests/generated/generated.d.ts new file mode 100644 index 00000000..fb63375c --- /dev/null +++ b/integration/typescript_tests/generated/generated.d.ts @@ -0,0 +1,31 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: generated + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export declare class Context { + a: number; + b: number; + c: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): Context | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + diff --git a/integration/typescript_tests/generated/generated.js b/integration/typescript_tests/generated/generated.js new file mode 100644 index 00000000..2542d30d --- /dev/null +++ b/integration/typescript_tests/generated/generated.js @@ -0,0 +1,74 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: generated + +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var stdin_exports = {}; +__export(stdin_exports, { + Context: () => Context +}); +module.exports = __toCommonJS(stdin_exports); +class Context { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.a = decoder.int32(); + this.b = decoder.int32(); + this.c = decoder.int32(); + } else { + this.a = 0; + this.b = 0; + this.c = 0; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.int32(this.a); + encoder.int32(this.b); + encoder.int32(this.c); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new Context(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +//# sourceMappingURL=generated.js.map \ No newline at end of file diff --git a/integration/typescript_tests/generated/generated.js.map b/integration/typescript_tests/generated/generated.js.map new file mode 100644 index 00000000..43815889 --- /dev/null +++ b/integration/typescript_tests/generated/generated.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sources": [""], + "sourceRoot": "generated.js", + "sourcesContent": ["// Code generated by scale-signature 0.4.0, DO NOT EDIT.\n// output: generated\n\nimport { Encoder, Decoder, Kind } from \"@loopholelabs/polyglot\"\n\nexport class Context {\n a: number;\n b: number;\n c: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.a = decoder.int32();\n this.b = decoder.int32();\n this.c = decoder.int32();\n } else {\n this.a = 0;\n this.b = 0;\n this.c = 0;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.a);\n encoder.int32(this.b);\n encoder.int32(this.c);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): Context | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new Context(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n"], + "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAQnB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,IAAI,QAAQ,MAAM;AACvB,WAAK,IAAI,QAAQ,MAAM;AACvB,WAAK,IAAI,QAAQ,MAAM;AAAA,IACzB,OAAO;AACL,WAAK,IAAI;AACT,WAAK,IAAI;AACT,WAAK,IAAI;AAAA,IACX;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,CAAC;AACpB,YAAQ,MAAM,KAAK,CAAC;AACpB,YAAQ,MAAM,KAAK,CAAC;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuC;AACpD,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,QAAQ,OAAO;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;", + "names": [] +} diff --git a/integration/typescript_tests/host_signature/index.d.ts b/integration/typescript_tests/host_signature/index.d.ts new file mode 100644 index 00000000..9ef199fa --- /dev/null +++ b/integration/typescript_tests/host_signature/index.d.ts @@ -0,0 +1,42 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +import { Signature as SignatureInterface } from "@loopholelabs/scale-signature-interfaces"; + +export * from "./types"; +import { ModelWithAllFieldTypes } from "./types"; + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +export declare function New(); + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +export declare class Signature implements SignatureInterface { + public context: ModelWithAllFieldTypes; + + constructor(); + + // Read reads the context from the given Uint8Array and returns an error if one occurred + // + // This method is meant to be used by the Scale Runtime to deserialize the Signature + Read(b: Uint8Array): Error | undefined; + + // Write writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to serialize the Signature + Write(): Uint8Array; + + // Error writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to return an error + Error(err: Error): Uint8Array; + + // Hash returns the hash of the signature + // + // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility + Hash(): string; +} diff --git a/integration/typescript_tests/host_signature/index.js b/integration/typescript_tests/host_signature/index.js new file mode 100644 index 00000000..78a61017 --- /dev/null +++ b/integration/typescript_tests/host_signature/index.js @@ -0,0 +1,75 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var stdin_exports = {}; +__export(stdin_exports, { + New: () => New, + Signature: () => Signature +}); +module.exports = __toCommonJS(stdin_exports); +var import_polyglot = require("@loopholelabs/polyglot"); +__reExport(stdin_exports, require("./types"), module.exports); +var import_types = require("./types"); +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5"; +function New() { + return new Signature(); +} +class Signature { + constructor() { + this.context = new import_types.ModelWithAllFieldTypes(); + } + // Read reads the context from the given Uint8Array and returns an error if one occurred + // + // This method is meant to be used by the Scale Runtime to deserialize the Signature + Read(b) { + const dec = new import_polyglot.Decoder(b); + try { + Object.assign(this.context, import_types.ModelWithAllFieldTypes.decode(dec)); + } catch (err) { + return err; + } + return void 0; + } + // Write writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to serialize the Signature + Write() { + const enc = new import_polyglot.Encoder(); + this.context.encode(enc); + return enc.bytes; + } + // Error writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to return an error + Error(err) { + const enc = new import_polyglot.Encoder(); + enc.error(err); + return enc.bytes; + } + // Hash returns the hash of the signature + // + // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility + Hash() { + return hash; + } +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/integration/typescript_tests/host_signature/index.js.map b/integration/typescript_tests/host_signature/index.js.map new file mode 100644 index 00000000..bcc51f6e --- /dev/null +++ b/integration/typescript_tests/host_signature/index.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sources": [""], + "sourceRoot": "index.js", + "sourcesContent": ["// Code generated by scale-signature 0.4.0, DO NOT EDIT.\n// output: local-example-latest-host\n\n/* eslint no-bitwise: off */\n\nimport { Signature as SignatureInterface } from \"@loopholelabs/scale-signature-interfaces\";\nimport { Decoder, Encoder, Kind } from \"@loopholelabs/polyglot\";\n\nexport * from \"./types\";\nimport { ModelWithAllFieldTypes } from \"./types\";\n\nconst hash = \"3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5\"\n\n// New returns a new signature and tells the Scale Runtime how to use it\n//\n// This function should be passed into the scale runtime config as an argument\nexport function New(): Signature {\n return new Signature();\n}\n\n// Signature is the host representation of the signature\n//\n// Users should not use this type directly, but instead pass the New() function\n// to the Scale Runtime\nexport class Signature implements SignatureInterface {\n public context: ModelWithAllFieldTypes;\n\n constructor() {\n this.context = new ModelWithAllFieldTypes();\n }\n\n // Read reads the context from the given Uint8Array and returns an error if one occurred\n //\n // This method is meant to be used by the Scale Runtime to deserialize the Signature\n Read(b: Uint8Array): Error | undefined {\n const dec = new Decoder(b);\n try {\n Object.assign(this.context, ModelWithAllFieldTypes.decode(dec));\n } catch (err) {\n return err as Error;\n }\n return undefined;\n }\n\n // Write writes the signature into a Uint8Array and returns it\n //\n // This method is meant to be used by the Scale Runtime to serialize the Signature\n Write(): Uint8Array {\n const enc = new Encoder();\n this.context.encode(enc);\n return enc.bytes;\n }\n\n // Error writes the signature into a Uint8Array and returns it\n //\n // This method is meant to be used by the Scale Runtime to return an error\n Error(err: Error): Uint8Array {\n const enc = new Encoder();\n enc.error(err);\n return enc.bytes;\n }\n\n // Hash returns the hash of the signature\n //\n // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility\n Hash(): string {\n return hash;\n }\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,sBAAuC;AAEvC,0BAAc,oBARd;AASA,mBAAuC;AAEvC,MAAM,OAAO;AAKN,SAAS,MAAiB;AAC/B,SAAO,IAAI,UAAU;AACvB;AAMO,MAAM,UAAwC;AAAA,EAGnD,cAAc;AACZ,SAAK,UAAU,IAAI,oCAAuB;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,KAAK,GAAkC;AACrC,UAAM,MAAM,IAAI,wBAAQ,CAAC;AACzB,QAAI;AACF,aAAO,OAAO,KAAK,SAAS,oCAAuB,OAAO,GAAG,CAAC;AAAA,IAChE,SAAS,KAAK;AACZ,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,QAAoB;AAClB,UAAM,MAAM,IAAI,wBAAQ;AACxB,SAAK,QAAQ,OAAO,GAAG;AACvB,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAwB;AAC5B,UAAM,MAAM,IAAI,wBAAQ;AACxB,QAAI,MAAM,GAAG;AACb,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,OAAe;AACb,WAAO;AAAA,EACT;AACF;", + "names": [] +} diff --git a/integration/typescript_tests/host_signature/index.ts b/integration/typescript_tests/host_signature/index.ts new file mode 100644 index 00000000..e3d96165 --- /dev/null +++ b/integration/typescript_tests/host_signature/index.ts @@ -0,0 +1,69 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +/* eslint no-bitwise: off */ + +import { Signature as SignatureInterface } from "@loopholelabs/scale-signature-interfaces"; +import { Decoder, Encoder, Kind } from "@loopholelabs/polyglot"; + +export * from "./types"; +import { ModelWithAllFieldTypes } from "./types"; + +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5" + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +export function New(): Signature { + return new Signature(); +} + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +export class Signature implements SignatureInterface { + public context: ModelWithAllFieldTypes; + + constructor() { + this.context = new ModelWithAllFieldTypes(); + } + + // Read reads the context from the given Uint8Array and returns an error if one occurred + // + // This method is meant to be used by the Scale Runtime to deserialize the Signature + Read(b: Uint8Array): Error | undefined { + const dec = new Decoder(b); + try { + Object.assign(this.context, ModelWithAllFieldTypes.decode(dec)); + } catch (err) { + return err as Error; + } + return undefined; + } + + // Write writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to serialize the Signature + Write(): Uint8Array { + const enc = new Encoder(); + this.context.encode(enc); + return enc.bytes; + } + + // Error writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to return an error + Error(err: Error): Uint8Array { + const enc = new Encoder(); + enc.error(err); + return enc.bytes; + } + + // Hash returns the hash of the signature + // + // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility + Hash(): string { + return hash; + } +} diff --git a/integration/typescript_tests/host_signature/package.json b/integration/typescript_tests/host_signature/package.json new file mode 100644 index 00000000..abf0bf9f --- /dev/null +++ b/integration/typescript_tests/host_signature/package.json @@ -0,0 +1,20 @@ +{ + "name": "local-example-latest-host", + "version": "0.1.0", + "source": "index.ts", + "types": "index.d.ts", + "scripts": { + "test": "jest index.test.ts" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3", + "@types/node": "^20.3.1" + }, + "dependencies": { + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7" + } +} diff --git a/integration/typescript_tests/host_signature/types.d.ts b/integration/typescript_tests/host_signature/types.d.ts new file mode 100644 index 00000000..42b316cf --- /dev/null +++ b/integration/typescript_tests/host_signature/types.d.ts @@ -0,0 +1,555 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export declare enum GenericEnum { + FirstValue = 0, + + SecondValue = 1, + + DefaultValue = 2, + +}export declare class EmptyModel { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModel | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// EmptyModelWithDescription: Test Description +export declare class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModelWithDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithSingleStringField { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringField | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithSingleStringFieldAndDescription: Test Description +export declare class ModelWithSingleStringFieldAndDescription { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithSingleInt32Field { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +export declare class ModelWithSingleInt32FieldAndDescription { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithMultipleFields { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFields | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithMultipleFieldsAndDescription: Test Description +export declare class ModelWithMultipleFieldsAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEnum { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnum | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEnumAndDescription: Test Description +export declare class ModelWithEnumAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEnumAccessor { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEnumAccessorAndDescription: Test Description +export declare class ModelWithEnumAccessorAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithMultipleFieldsAccessor { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +export declare class ModelWithMultipleFieldsAccessorAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEmbeddedModels { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +export declare class ModelWithEmbeddedModelsAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEmbeddedModelsAccessor { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +export declare class ModelWithEmbeddedModelsAccessorAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithAllFieldTypes { + modelField: EmptyModel | undefined; + + modelArrayField: Array; + + stringField: string; + + stringArrayField: string[]; + + stringMapField: Map; + + stringMapFieldEmbedded: Map; + + int32Field: number; + + int32ArrayField: number[]; + + int32MapField: Map; + + int32MapFieldEmbedded: Map; + + int64Field: bigint; + + int64ArrayField: bigint[]; + + int64MapField: Map; + + int64MapFieldEmbedded: Map; + + uint32Field: number; + + uint32ArrayField: number[]; + + uint32MapField: Map; + + uint32MapFieldEmbedded: Map; + + uint64Field: bigint; + + uint64ArrayField: bigint[]; + + uint64MapField: Map; + + uint64MapFieldEmbedded: Map; + + float32Field: number; + + float32ArrayField: number[]; + + float64Field: number; + + float64ArrayField: number[]; + + enumField: GenericEnum; + + enumArrayField: GenericEnum[]; + + enumMapField: Map; + + enumMapFieldEmbedded: Map; + + bytesField: Uint8Array; + + bytesArrayField: Uint8Array[]; + + boolField: boolean; + + boolArrayField: boolean[]; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + diff --git a/integration/typescript_tests/host_signature/types.js b/integration/typescript_tests/host_signature/types.js new file mode 100644 index 00000000..8e430c80 --- /dev/null +++ b/integration/typescript_tests/host_signature/types.js @@ -0,0 +1,1241 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var stdin_exports = {}; +__export(stdin_exports, { + EmptyModel: () => EmptyModel, + EmptyModelWithDescription: () => EmptyModelWithDescription, + GenericEnum: () => GenericEnum, + ModelWithAllFieldTypes: () => ModelWithAllFieldTypes, + ModelWithEmbeddedModels: () => ModelWithEmbeddedModels, + ModelWithEmbeddedModelsAccessor: () => ModelWithEmbeddedModelsAccessor, + ModelWithEmbeddedModelsAccessorAndDescription: () => ModelWithEmbeddedModelsAccessorAndDescription, + ModelWithEmbeddedModelsAndDescription: () => ModelWithEmbeddedModelsAndDescription, + ModelWithEnum: () => ModelWithEnum, + ModelWithEnumAccessor: () => ModelWithEnumAccessor, + ModelWithEnumAccessorAndDescription: () => ModelWithEnumAccessorAndDescription, + ModelWithEnumAndDescription: () => ModelWithEnumAndDescription, + ModelWithMultipleFields: () => ModelWithMultipleFields, + ModelWithMultipleFieldsAccessor: () => ModelWithMultipleFieldsAccessor, + ModelWithMultipleFieldsAccessorAndDescription: () => ModelWithMultipleFieldsAccessorAndDescription, + ModelWithMultipleFieldsAndDescription: () => ModelWithMultipleFieldsAndDescription, + ModelWithSingleInt32Field: () => ModelWithSingleInt32Field, + ModelWithSingleInt32FieldAndDescription: () => ModelWithSingleInt32FieldAndDescription, + ModelWithSingleStringField: () => ModelWithSingleStringField, + ModelWithSingleStringFieldAndDescription: () => ModelWithSingleStringFieldAndDescription +}); +module.exports = __toCommonJS(stdin_exports); +var import_polyglot = require("@loopholelabs/polyglot"); +var GenericEnum = /* @__PURE__ */ ((GenericEnum2) => { + GenericEnum2[GenericEnum2["FirstValue"] = 0] = "FirstValue"; + GenericEnum2[GenericEnum2["SecondValue"] = 1] = "SecondValue"; + GenericEnum2[GenericEnum2["DefaultValue"] = 2] = "DefaultValue"; + return GenericEnum2; +})(GenericEnum || {}); +class EmptyModel { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + /** + * @throws {Error} + */ + encode(encoder) { + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new EmptyModel(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + /** + * @throws {Error} + */ + encode(encoder) { + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new EmptyModelWithDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleStringField { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleStringField(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleStringFieldAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleStringFieldAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleInt32Field { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleInt32Field(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleInt32FieldAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleInt32FieldAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFields { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFields(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnum { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnum(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAccessor { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAccessorAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAccessor { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAccessorAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModels { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModels(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAccessor { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAccessorAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithAllFieldTypes { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.modelField = EmptyModel.decode(decoder); + const modelArrayFieldSize = decoder.array(import_polyglot.Kind.Any); + this.modelArrayField = new Array(modelArrayFieldSize); + for (let i = 0; i < modelArrayFieldSize; i += 1) { + const x = EmptyModel.decode(decoder); + if (typeof x !== "undefined") { + this.modelArrayField[i] = x; + } + } + this.stringField = decoder.string(); + const stringArrayFieldSize = decoder.array(import_polyglot.Kind.String); + this.stringArrayField = new Array(stringArrayFieldSize); + for (let i = 0; i < stringArrayFieldSize; i += 1) { + this.stringArrayField[i] = decoder.string(); + } + this.stringMapField = /* @__PURE__ */ new Map(); + let stringMapFieldSize = decoder.map(import_polyglot.Kind.String, import_polyglot.Kind.String); + for (let i = 0; i < stringMapFieldSize; i++) { + let key = decoder.string(); + let val = decoder.string(); + this.stringMapField.set(key, val); + } + this.stringMapFieldEmbedded = /* @__PURE__ */ new Map(); + let stringMapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.String, import_polyglot.Kind.Any); + for (let i = 0; i < stringMapFieldEmbeddedSize; i++) { + let key = decoder.string(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.stringMapFieldEmbedded.set(key, val); + } + } + this.int32Field = decoder.int32(); + const int32ArrayFieldSize = decoder.array(import_polyglot.Kind.Int32); + this.int32ArrayField = new Array(int32ArrayFieldSize); + for (let i = 0; i < int32ArrayFieldSize; i += 1) { + this.int32ArrayField[i] = decoder.int32(); + } + this.int32MapField = /* @__PURE__ */ new Map(); + let int32MapFieldSize = decoder.map(import_polyglot.Kind.Int32, import_polyglot.Kind.Int32); + for (let i = 0; i < int32MapFieldSize; i++) { + let key = decoder.int32(); + let val = decoder.int32(); + this.int32MapField.set(key, val); + } + this.int32MapFieldEmbedded = /* @__PURE__ */ new Map(); + let int32MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Int32, import_polyglot.Kind.Any); + for (let i = 0; i < int32MapFieldEmbeddedSize; i++) { + let key = decoder.int32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int32MapFieldEmbedded.set(key, val); + } + } + this.int64Field = decoder.int64(); + const int64ArrayFieldSize = decoder.array(import_polyglot.Kind.Int64); + this.int64ArrayField = new Array(int64ArrayFieldSize); + for (let i = 0; i < int64ArrayFieldSize; i += 1) { + this.int64ArrayField[i] = decoder.int64(); + } + this.int64MapField = /* @__PURE__ */ new Map(); + let int64MapFieldSize = decoder.map(import_polyglot.Kind.Int64, import_polyglot.Kind.Int64); + for (let i = 0; i < int64MapFieldSize; i++) { + let key = decoder.int64(); + let val = decoder.int64(); + this.int64MapField.set(key, val); + } + this.int64MapFieldEmbedded = /* @__PURE__ */ new Map(); + let int64MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Int64, import_polyglot.Kind.Any); + for (let i = 0; i < int64MapFieldEmbeddedSize; i++) { + let key = decoder.int64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int64MapFieldEmbedded.set(key, val); + } + } + this.uint32Field = decoder.uint32(); + const uint32ArrayFieldSize = decoder.array(import_polyglot.Kind.Uint32); + this.uint32ArrayField = new Array(uint32ArrayFieldSize); + for (let i = 0; i < uint32ArrayFieldSize; i += 1) { + this.uint32ArrayField[i] = decoder.uint32(); + } + this.uint32MapField = /* @__PURE__ */ new Map(); + let uint32MapFieldSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Uint32); + for (let i = 0; i < uint32MapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.uint32(); + this.uint32MapField.set(key, val); + } + this.uint32MapFieldEmbedded = /* @__PURE__ */ new Map(); + let uint32MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint32MapFieldEmbedded.set(key, val); + } + } + this.uint64Field = decoder.uint64(); + const uint64ArrayFieldSize = decoder.array(import_polyglot.Kind.Uint64); + this.uint64ArrayField = new Array(uint64ArrayFieldSize); + for (let i = 0; i < uint64ArrayFieldSize; i += 1) { + this.uint64ArrayField[i] = decoder.uint64(); + } + this.uint64MapField = /* @__PURE__ */ new Map(); + let uint64MapFieldSize = decoder.map(import_polyglot.Kind.Uint64, import_polyglot.Kind.Uint64); + for (let i = 0; i < uint64MapFieldSize; i++) { + let key = decoder.uint64(); + let val = decoder.uint64(); + this.uint64MapField.set(key, val); + } + this.uint64MapFieldEmbedded = /* @__PURE__ */ new Map(); + let uint64MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint64, import_polyglot.Kind.Any); + for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) { + let key = decoder.uint64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint64MapFieldEmbedded.set(key, val); + } + } + this.float32Field = decoder.float32(); + const float32ArrayFieldSize = decoder.array(import_polyglot.Kind.Float32); + this.float32ArrayField = new Array(float32ArrayFieldSize); + for (let i = 0; i < float32ArrayFieldSize; i += 1) { + this.float32ArrayField[i] = decoder.float32(); + } + this.float64Field = decoder.float64(); + const float64ArrayFieldSize = decoder.array(import_polyglot.Kind.Float64); + this.float64ArrayField = new Array(float64ArrayFieldSize); + for (let i = 0; i < float64ArrayFieldSize; i += 1) { + this.float64ArrayField[i] = decoder.float64(); + } + this.enumField = decoder.uint32(); + const enumArrayFieldSize = decoder.array(import_polyglot.Kind.Uint32); + this.enumArrayField = new Array(enumArrayFieldSize); + for (let i = 0; i < enumArrayFieldSize; i += 1) { + this.enumArrayField[i] = decoder.uint32(); + } + this.enumMapField = /* @__PURE__ */ new Map(); + let enumMapFieldSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.String); + for (let i = 0; i < enumMapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.string(); + this.enumMapField.set(key, val); + } + this.enumMapFieldEmbedded = /* @__PURE__ */ new Map(); + let enumMapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + for (let i = 0; i < enumMapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.enumMapFieldEmbedded.set(key, val); + } + } + this.bytesField = decoder.uint8Array(); + const bytesArrayFieldSize = decoder.array(import_polyglot.Kind.Uint8Array); + this.bytesArrayField = new Array(bytesArrayFieldSize); + for (let i = 0; i < bytesArrayFieldSize; i += 1) { + this.bytesArrayField[i] = decoder.uint8Array(); + } + this.boolField = decoder.boolean(); + const boolArrayFieldSize = decoder.array(import_polyglot.Kind.Boolean); + this.boolArrayField = new Array(boolArrayFieldSize); + for (let i = 0; i < boolArrayFieldSize; i += 1) { + this.boolArrayField[i] = decoder.boolean(); + } + } else { + this.modelField = new EmptyModel(); + this.modelArrayField = []; + this.stringField = "DefaultValue"; + this.stringArrayField = []; + this.stringMapField = /* @__PURE__ */ new Map(); + this.stringMapFieldEmbedded = /* @__PURE__ */ new Map(); + this.int32Field = 32; + this.int32ArrayField = []; + this.int32MapField = /* @__PURE__ */ new Map(); + this.int32MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.int64Field = 64n; + this.int64ArrayField = []; + this.int64MapField = /* @__PURE__ */ new Map(); + this.int64MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.uint32Field = 32; + this.uint32ArrayField = []; + this.uint32MapField = /* @__PURE__ */ new Map(); + this.uint32MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.uint64Field = 64n; + this.uint64ArrayField = []; + this.uint64MapField = /* @__PURE__ */ new Map(); + this.uint64MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.float32Field = 32.32; + this.float32ArrayField = []; + this.float64Field = 64.64; + this.float64ArrayField = []; + this.enumField = 2 /* DefaultValue */; + this.enumArrayField = []; + this.enumMapField = /* @__PURE__ */ new Map(); + this.enumMapFieldEmbedded = /* @__PURE__ */ new Map(); + this.bytesField = new Uint8Array(512); + this.bytesArrayField = []; + this.boolField = true; + this.boolArrayField = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.modelField === "undefined") { + encoder.null(); + } else { + this.modelField.encode(encoder); + } + const modelArrayFieldLength = this.modelArrayField.length; + encoder.array(modelArrayFieldLength, import_polyglot.Kind.Any); + for (let i = 0; i < modelArrayFieldLength; i += 1) { + const el = this.modelArrayField[i]; + el.encode(encoder); + } + encoder.string(this.stringField); + const stringArrayFieldLength = this.stringArrayField.length; + encoder.array(stringArrayFieldLength, import_polyglot.Kind.String); + for (let i = 0; i < stringArrayFieldLength; i += 1) { + encoder.string(this.stringArrayField[i]); + } + encoder.map(this.stringMapField.size, import_polyglot.Kind.String, import_polyglot.Kind.String); + this.stringMapField.forEach((val, key) => { + encoder.string(key); + encoder.string(val); + }); + encoder.map(this.stringMapFieldEmbedded.size, import_polyglot.Kind.String, import_polyglot.Kind.Any); + this.stringMapFieldEmbedded.forEach((val, key) => { + encoder.string(key); + val.encode(encoder); + }); + encoder.int32(this.int32Field); + const int32ArrayFieldLength = this.int32ArrayField.length; + encoder.array(int32ArrayFieldLength, import_polyglot.Kind.Int32); + for (let i = 0; i < int32ArrayFieldLength; i += 1) { + encoder.int32(this.int32ArrayField[i]); + } + encoder.map(this.int32MapField.size, import_polyglot.Kind.Int32, import_polyglot.Kind.Int32); + this.int32MapField.forEach((val, key) => { + encoder.int32(key); + encoder.int32(val); + }); + encoder.map(this.int32MapFieldEmbedded.size, import_polyglot.Kind.Int32, import_polyglot.Kind.Any); + this.int32MapFieldEmbedded.forEach((val, key) => { + encoder.int32(key); + val.encode(encoder); + }); + encoder.int64(this.int64Field); + const int64ArrayFieldLength = this.int64ArrayField.length; + encoder.array(int64ArrayFieldLength, import_polyglot.Kind.Int64); + for (let i = 0; i < int64ArrayFieldLength; i += 1) { + encoder.int64(this.int64ArrayField[i]); + } + encoder.map(this.int64MapField.size, import_polyglot.Kind.Int64, import_polyglot.Kind.Int64); + this.int64MapField.forEach((val, key) => { + encoder.int64(key); + encoder.int64(val); + }); + encoder.map(this.int64MapFieldEmbedded.size, import_polyglot.Kind.Int64, import_polyglot.Kind.Any); + this.int64MapFieldEmbedded.forEach((val, key) => { + encoder.int64(key); + val.encode(encoder); + }); + encoder.uint32(this.uint32Field); + const uint32ArrayFieldLength = this.uint32ArrayField.length; + encoder.array(uint32ArrayFieldLength, import_polyglot.Kind.Uint32); + for (let i = 0; i < uint32ArrayFieldLength; i += 1) { + encoder.uint32(this.uint32ArrayField[i]); + } + encoder.map(this.uint32MapField.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Uint32); + this.uint32MapField.forEach((val, key) => { + encoder.uint32(key); + encoder.uint32(val); + }); + encoder.map(this.uint32MapFieldEmbedded.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + this.uint32MapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint64(this.uint64Field); + const uint64ArrayFieldLength = this.uint64ArrayField.length; + encoder.array(uint64ArrayFieldLength, import_polyglot.Kind.Uint64); + for (let i = 0; i < uint64ArrayFieldLength; i += 1) { + encoder.uint64(this.uint64ArrayField[i]); + } + encoder.map(this.uint64MapField.size, import_polyglot.Kind.Uint64, import_polyglot.Kind.Uint64); + this.uint64MapField.forEach((val, key) => { + encoder.uint64(key); + encoder.uint64(val); + }); + encoder.map(this.uint64MapFieldEmbedded.size, import_polyglot.Kind.Uint64, import_polyglot.Kind.Any); + this.uint64MapFieldEmbedded.forEach((val, key) => { + encoder.uint64(key); + val.encode(encoder); + }); + encoder.float32(this.float32Field); + const float32ArrayFieldLength = this.float32ArrayField.length; + encoder.array(float32ArrayFieldLength, import_polyglot.Kind.Float32); + for (let i = 0; i < float32ArrayFieldLength; i += 1) { + encoder.float32(this.float32ArrayField[i]); + } + encoder.float64(this.float64Field); + const float64ArrayFieldLength = this.float64ArrayField.length; + encoder.array(float64ArrayFieldLength, import_polyglot.Kind.Float64); + for (let i = 0; i < float64ArrayFieldLength; i += 1) { + encoder.float64(this.float64ArrayField[i]); + } + encoder.uint32(this.enumField); + const enumArrayFieldLength = this.enumArrayField.length; + encoder.array(enumArrayFieldLength, import_polyglot.Kind.Uint32); + for (let i = 0; i < enumArrayFieldLength; i += 1) { + encoder.uint32(this.enumArrayField[i]); + } + encoder.map(this.enumMapField.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.String); + this.enumMapField.forEach((val, key) => { + encoder.uint32(key); + encoder.string(val); + }); + encoder.map(this.enumMapFieldEmbedded.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + this.enumMapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint8Array(this.bytesField); + const bytesArrayFieldLength = this.bytesArrayField.length; + encoder.array(bytesArrayFieldLength, import_polyglot.Kind.Uint8Array); + for (let i = 0; i < bytesArrayFieldLength; i += 1) { + encoder.uint8Array(this.bytesArrayField[i]); + } + encoder.boolean(this.boolField); + const boolArrayFieldLength = this.boolArrayField.length; + encoder.array(boolArrayFieldLength, import_polyglot.Kind.Boolean); + for (let i = 0; i < boolArrayFieldLength; i += 1) { + encoder.boolean(this.boolArrayField[i]); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithAllFieldTypes(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/integration/typescript_tests/host_signature/types.js.map b/integration/typescript_tests/host_signature/types.js.map new file mode 100644 index 00000000..cddb5aef --- /dev/null +++ b/integration/typescript_tests/host_signature/types.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sources": [""], + "sourceRoot": "types.js", + "sourcesContent": ["// Code generated by scale-signature 0.4.0, DO NOT EDIT.\n// output: local-example-latest-host\n\nimport { Encoder, Decoder, Kind } from \"@loopholelabs/polyglot\"\n\nexport enum GenericEnum {\n FirstValue = 0,\n\n SecondValue = 1,\n\n DefaultValue = 2,\n\n}\nexport class EmptyModel {\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n } else {\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): EmptyModel | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new EmptyModel(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// EmptyModelWithDescription: Test Description\nexport class EmptyModelWithDescription {\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n } else {\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): EmptyModelWithDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new EmptyModelWithDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithSingleStringField {\n stringField: string;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n } else {\n this.stringField = \"DefaultValue\";\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleStringField | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleStringField(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithSingleStringFieldAndDescription: Test Description\nexport class ModelWithSingleStringFieldAndDescription {\n stringField: string;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n } else {\n this.stringField = \"DefaultValue\";\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleStringFieldAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithSingleInt32Field {\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.int32Field = decoder.int32();\n } else {\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleInt32Field(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithSingleInt32FieldAndDescription: Test Description\nexport class ModelWithSingleInt32FieldAndDescription {\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.int32Field = decoder.int32();\n } else {\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleInt32FieldAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithMultipleFields {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFields | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFields(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithMultipleFieldsAndDescription: Test Description\nexport class ModelWithMultipleFieldsAndDescription {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEnum {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnum | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnum(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEnumAndDescription: Test Description\nexport class ModelWithEnumAndDescription {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEnumAccessor {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEnumAccessorAndDescription: Test Description\nexport class ModelWithEnumAccessorAndDescription {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithMultipleFieldsAccessor {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithMultipleFieldsAccessorAndDescription: Test Description\nexport class ModelWithMultipleFieldsAccessorAndDescription {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEmbeddedModels {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModels(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEmbeddedModelsAndDescription: Test Description\nexport class ModelWithEmbeddedModelsAndDescription {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEmbeddedModelsAccessor {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEmbeddedModelsAccessorAndDescription: Test Description\nexport class ModelWithEmbeddedModelsAccessorAndDescription {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithAllFieldTypes {\n modelField: EmptyModel | undefined;\n\n modelArrayField: Array;\n\n stringField: string;\n\n stringArrayField: string[];\n\n stringMapField: Map;\n\n stringMapFieldEmbedded: Map;\n\n int32Field: number;\n\n int32ArrayField: number[];\n\n int32MapField: Map;\n\n int32MapFieldEmbedded: Map;\n\n int64Field: bigint;\n\n int64ArrayField: bigint[];\n\n int64MapField: Map;\n\n int64MapFieldEmbedded: Map;\n\n uint32Field: number;\n\n uint32ArrayField: number[];\n\n uint32MapField: Map;\n\n uint32MapFieldEmbedded: Map;\n\n uint64Field: bigint;\n\n uint64ArrayField: bigint[];\n\n uint64MapField: Map;\n\n uint64MapFieldEmbedded: Map;\n\n float32Field: number;\n\n float32ArrayField: number[];\n\n float64Field: number;\n\n float64ArrayField: number[];\n\n enumField: GenericEnum;\n\n enumArrayField: GenericEnum[];\n\n enumMapField: Map;\n\n enumMapFieldEmbedded: Map;\n\n bytesField: Uint8Array;\n\n bytesArrayField: Uint8Array[];\n\n boolField: boolean;\n\n boolArrayField: boolean[];\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.modelField = EmptyModel.decode(decoder);\n const modelArrayFieldSize = decoder.array(Kind.Any);\n this.modelArrayField = new Array(modelArrayFieldSize);\n for (let i = 0; i < modelArrayFieldSize; i += 1) {\n const x = EmptyModel.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.modelArrayField[i] = x;\n }\n }\n this.stringField = decoder.string();\n const stringArrayFieldSize = decoder.array(Kind.String);\n this.stringArrayField = new Array(stringArrayFieldSize);\n for (let i = 0; i < stringArrayFieldSize; i += 1) {\n this.stringArrayField[i] = decoder.string();\n }\n this.stringMapField = new Map();\n let stringMapFieldSize = decoder.map(Kind.String, Kind.String);\n for (let i = 0; i < stringMapFieldSize; i++) {\n let key = decoder.string();\n let val = decoder.string();\n this.stringMapField.set(key, val);\n }\n this.stringMapFieldEmbedded = new Map();\n let stringMapFieldEmbeddedSize = decoder.map(Kind.String, Kind.Any);\n for (let i = 0; i < stringMapFieldEmbeddedSize; i++) {\n let key = decoder.string();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.stringMapFieldEmbedded.set(key, val);\n }\n }\n this.int32Field = decoder.int32();\n const int32ArrayFieldSize = decoder.array(Kind.Int32);\n this.int32ArrayField = new Array(int32ArrayFieldSize);\n for (let i = 0; i < int32ArrayFieldSize; i += 1) {\n this.int32ArrayField[i] = decoder.int32();\n }\n this.int32MapField = new Map();\n let int32MapFieldSize = decoder.map(Kind.Int32, Kind.Int32);\n for (let i = 0; i < int32MapFieldSize; i++) {\n let key = decoder.int32();\n let val = decoder.int32();\n this.int32MapField.set(key, val);\n }\n this.int32MapFieldEmbedded = new Map();\n let int32MapFieldEmbeddedSize = decoder.map(Kind.Int32, Kind.Any);\n for (let i = 0; i < int32MapFieldEmbeddedSize; i++) {\n let key = decoder.int32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.int32MapFieldEmbedded.set(key, val);\n }\n }\n this.int64Field = decoder.int64();\n const int64ArrayFieldSize = decoder.array(Kind.Int64);\n this.int64ArrayField = new Array(int64ArrayFieldSize);\n for (let i = 0; i < int64ArrayFieldSize; i += 1) {\n this.int64ArrayField[i] = decoder.int64();\n }\n this.int64MapField = new Map();\n let int64MapFieldSize = decoder.map(Kind.Int64, Kind.Int64);\n for (let i = 0; i < int64MapFieldSize; i++) {\n let key = decoder.int64();\n let val = decoder.int64();\n this.int64MapField.set(key, val);\n }\n this.int64MapFieldEmbedded = new Map();\n let int64MapFieldEmbeddedSize = decoder.map(Kind.Int64, Kind.Any);\n for (let i = 0; i < int64MapFieldEmbeddedSize; i++) {\n let key = decoder.int64();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.int64MapFieldEmbedded.set(key, val);\n }\n }\n this.uint32Field = decoder.uint32();\n const uint32ArrayFieldSize = decoder.array(Kind.Uint32);\n this.uint32ArrayField = new Array(uint32ArrayFieldSize);\n for (let i = 0; i < uint32ArrayFieldSize; i += 1) {\n this.uint32ArrayField[i] = decoder.uint32();\n }\n this.uint32MapField = new Map();\n let uint32MapFieldSize = decoder.map(Kind.Uint32, Kind.Uint32);\n for (let i = 0; i < uint32MapFieldSize; i++) {\n let key = decoder.uint32();\n let val = decoder.uint32();\n this.uint32MapField.set(key, val);\n }\n this.uint32MapFieldEmbedded = new Map();\n let uint32MapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any);\n for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) {\n let key = decoder.uint32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.uint32MapFieldEmbedded.set(key, val);\n }\n }\n this.uint64Field = decoder.uint64();\n const uint64ArrayFieldSize = decoder.array(Kind.Uint64);\n this.uint64ArrayField = new Array(uint64ArrayFieldSize);\n for (let i = 0; i < uint64ArrayFieldSize; i += 1) {\n this.uint64ArrayField[i] = decoder.uint64();\n }\n this.uint64MapField = new Map();\n let uint64MapFieldSize = decoder.map(Kind.Uint64, Kind.Uint64);\n for (let i = 0; i < uint64MapFieldSize; i++) {\n let key = decoder.uint64();\n let val = decoder.uint64();\n this.uint64MapField.set(key, val);\n }\n this.uint64MapFieldEmbedded = new Map();\n let uint64MapFieldEmbeddedSize = decoder.map(Kind.Uint64, Kind.Any);\n for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) {\n let key = decoder.uint64();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.uint64MapFieldEmbedded.set(key, val);\n }\n }\n this.float32Field = decoder.float32();\n const float32ArrayFieldSize = decoder.array(Kind.Float32);\n this.float32ArrayField = new Array(float32ArrayFieldSize);\n for (let i = 0; i < float32ArrayFieldSize; i += 1) {\n this.float32ArrayField[i] = decoder.float32();\n }\n this.float64Field = decoder.float64();\n const float64ArrayFieldSize = decoder.array(Kind.Float64);\n this.float64ArrayField = new Array(float64ArrayFieldSize);\n for (let i = 0; i < float64ArrayFieldSize; i += 1) {\n this.float64ArrayField[i] = decoder.float64();\n }\n this.enumField = decoder.uint32();\n const enumArrayFieldSize = decoder.array(Kind.Uint32);\n this.enumArrayField = new Array(enumArrayFieldSize);\n for (let i = 0; i < enumArrayFieldSize; i += 1) {\n this.enumArrayField[i] = decoder.uint32();\n }\n this.enumMapField = new Map();\n let enumMapFieldSize = decoder.map(Kind.Uint32, Kind.String);\n for (let i = 0; i < enumMapFieldSize; i++) {\n let key = decoder.uint32();\n let val = decoder.string();\n this.enumMapField.set(key, val);\n }\n this.enumMapFieldEmbedded = new Map();\n let enumMapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any);\n for (let i = 0; i < enumMapFieldEmbeddedSize; i++) {\n let key = decoder.uint32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.enumMapFieldEmbedded.set(key, val);\n }\n }\n this.bytesField = decoder.uint8Array();\n const bytesArrayFieldSize = decoder.array(Kind.Uint8Array);\n this.bytesArrayField = new Array(bytesArrayFieldSize);\n for (let i = 0; i < bytesArrayFieldSize; i += 1) {\n this.bytesArrayField[i] = decoder.uint8Array();\n }\n this.boolField = decoder.boolean();\n const boolArrayFieldSize = decoder.array(Kind.Boolean);\n this.boolArrayField = new Array(boolArrayFieldSize);\n for (let i = 0; i < boolArrayFieldSize; i += 1) {\n this.boolArrayField[i] = decoder.boolean();\n }\n } else {\n this.modelField = new EmptyModel();\n this.modelArrayField = [];\n this.stringField = \"DefaultValue\";\n this.stringArrayField = [];\n this.stringMapField = new Map();\n this.stringMapFieldEmbedded = new Map();\n this.int32Field = 32;\n this.int32ArrayField = [];\n this.int32MapField = new Map();\n this.int32MapFieldEmbedded = new Map();\n this.int64Field = 64n;\n this.int64ArrayField = [];\n this.int64MapField = new Map();\n this.int64MapFieldEmbedded = new Map();\n this.uint32Field = 32;\n this.uint32ArrayField = [];\n this.uint32MapField = new Map();\n this.uint32MapFieldEmbedded = new Map();\n this.uint64Field = 64n;\n this.uint64ArrayField = [];\n this.uint64MapField = new Map();\n this.uint64MapFieldEmbedded = new Map();\n this.float32Field = 32.32;\n this.float32ArrayField = [];\n this.float64Field = 64.64;\n this.float64ArrayField = [];\n this.enumField = GenericEnum.DefaultValue;\n this.enumArrayField = [];\n this.enumMapField = new Map();\n this.enumMapFieldEmbedded = new Map();\n this.bytesField = new Uint8Array(512);\n this.bytesArrayField = [];\n this.boolField = true;\n this.boolArrayField = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.modelField === \"undefined\") {\n encoder.null();\n } else {\n this.modelField.encode(encoder);\n }\n const modelArrayFieldLength = this.modelArrayField.length;\n encoder.array(modelArrayFieldLength, Kind.Any);\n for (let i = 0; i < modelArrayFieldLength; i += 1) {\n const el = this.modelArrayField[i];\n el.encode(encoder);\n }\n encoder.string(this.stringField);\n const stringArrayFieldLength = this.stringArrayField.length;\n encoder.array(stringArrayFieldLength, Kind.String);\n for (let i = 0; i < stringArrayFieldLength; i += 1) {\n encoder.string(this.stringArrayField[i]);\n }\n encoder.map(this.stringMapField.size, Kind.String, Kind.String);\n this.stringMapField.forEach((val, key) => {\n encoder.string(key);\n encoder.string(val);\n });\n encoder.map(this.stringMapFieldEmbedded.size, Kind.String, Kind.Any);\n this.stringMapFieldEmbedded.forEach((val, key) => {\n encoder.string(key);\n val.encode(encoder);\n });\n encoder.int32(this.int32Field);\n const int32ArrayFieldLength = this.int32ArrayField.length;\n encoder.array(int32ArrayFieldLength, Kind.Int32);\n for (let i = 0; i < int32ArrayFieldLength; i += 1) {\n encoder.int32(this.int32ArrayField[i]);\n }\n encoder.map(this.int32MapField.size, Kind.Int32, Kind.Int32);\n this.int32MapField.forEach((val, key) => {\n encoder.int32(key);\n encoder.int32(val);\n });\n encoder.map(this.int32MapFieldEmbedded.size, Kind.Int32, Kind.Any);\n this.int32MapFieldEmbedded.forEach((val, key) => {\n encoder.int32(key);\n val.encode(encoder);\n });\n encoder.int64(this.int64Field);\n const int64ArrayFieldLength = this.int64ArrayField.length;\n encoder.array(int64ArrayFieldLength, Kind.Int64);\n for (let i = 0; i < int64ArrayFieldLength; i += 1) {\n encoder.int64(this.int64ArrayField[i]);\n }\n encoder.map(this.int64MapField.size, Kind.Int64, Kind.Int64);\n this.int64MapField.forEach((val, key) => {\n encoder.int64(key);\n encoder.int64(val);\n });\n encoder.map(this.int64MapFieldEmbedded.size, Kind.Int64, Kind.Any);\n this.int64MapFieldEmbedded.forEach((val, key) => {\n encoder.int64(key);\n val.encode(encoder);\n });\n encoder.uint32(this.uint32Field);\n const uint32ArrayFieldLength = this.uint32ArrayField.length;\n encoder.array(uint32ArrayFieldLength, Kind.Uint32);\n for (let i = 0; i < uint32ArrayFieldLength; i += 1) {\n encoder.uint32(this.uint32ArrayField[i]);\n }\n encoder.map(this.uint32MapField.size, Kind.Uint32, Kind.Uint32);\n this.uint32MapField.forEach((val, key) => {\n encoder.uint32(key);\n encoder.uint32(val);\n });\n encoder.map(this.uint32MapFieldEmbedded.size, Kind.Uint32, Kind.Any);\n this.uint32MapFieldEmbedded.forEach((val, key) => {\n encoder.uint32(key);\n val.encode(encoder);\n });\n encoder.uint64(this.uint64Field);\n const uint64ArrayFieldLength = this.uint64ArrayField.length;\n encoder.array(uint64ArrayFieldLength, Kind.Uint64);\n for (let i = 0; i < uint64ArrayFieldLength; i += 1) {\n encoder.uint64(this.uint64ArrayField[i]);\n }\n encoder.map(this.uint64MapField.size, Kind.Uint64, Kind.Uint64);\n this.uint64MapField.forEach((val, key) => {\n encoder.uint64(key);\n encoder.uint64(val);\n });\n encoder.map(this.uint64MapFieldEmbedded.size, Kind.Uint64, Kind.Any);\n this.uint64MapFieldEmbedded.forEach((val, key) => {\n encoder.uint64(key);\n val.encode(encoder);\n });\n encoder.float32(this.float32Field);\n const float32ArrayFieldLength = this.float32ArrayField.length;\n encoder.array(float32ArrayFieldLength, Kind.Float32);\n for (let i = 0; i < float32ArrayFieldLength; i += 1) {\n encoder.float32(this.float32ArrayField[i]);\n }\n encoder.float64(this.float64Field);\n const float64ArrayFieldLength = this.float64ArrayField.length;\n encoder.array(float64ArrayFieldLength, Kind.Float64);\n for (let i = 0; i < float64ArrayFieldLength; i += 1) {\n encoder.float64(this.float64ArrayField[i]);\n }\n encoder.uint32(this.enumField);\n const enumArrayFieldLength = this.enumArrayField.length;\n encoder.array(enumArrayFieldLength, Kind.Uint32);\n for (let i = 0; i < enumArrayFieldLength; i += 1) {\n encoder.uint32(this.enumArrayField[i]);\n }\n encoder.map(this.enumMapField.size, Kind.Uint32, Kind.String);\n this.enumMapField.forEach((val, key) => {\n encoder.uint32(key);\n encoder.string(val);\n });\n encoder.map(this.enumMapFieldEmbedded.size, Kind.Uint32, Kind.Any);\n this.enumMapFieldEmbedded.forEach((val, key) => {\n encoder.uint32(key);\n val.encode(encoder);\n });\n encoder.uint8Array(this.bytesField);\n const bytesArrayFieldLength = this.bytesArrayField.length;\n encoder.array(bytesArrayFieldLength, Kind.Uint8Array);\n for (let i = 0; i < bytesArrayFieldLength; i += 1) {\n encoder.uint8Array(this.bytesArrayField[i]);\n }\n encoder.boolean(this.boolField);\n const boolArrayFieldLength = this.boolArrayField.length;\n encoder.array(boolArrayFieldLength, Kind.Boolean);\n for (let i = 0; i < boolArrayFieldLength; i += 1) {\n encoder.boolean(this.boolArrayField[i]);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithAllFieldTypes(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n"], + "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAuC;AAEhC,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,0BAAA,gBAAa,KAAb;AAEA,EAAAA,0BAAA,iBAAc,KAAd;AAEA,EAAAA,0BAAA,kBAAe,KAAf;AALU,SAAAA;AAAA,GAAA;AAQL,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAItB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA0C;AACvD,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAIrC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAyD;AACtE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,0BAA0B,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,2BAA2B;AAAA;AAAA;AAAA;AAAA,EAMtC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAAA,IACpC,OAAO;AACL,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA0D;AACvE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,2BAA2B,OAAO;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,yCAAyC;AAAA;AAAA;AAAA;AAAA,EAMpD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAAA,IACpC,OAAO;AACL,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAwE;AACrF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,yCAAyC,OAAO;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAMrC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAyD;AACtE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,0BAA0B,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,wCAAwC;AAAA;AAAA;AAAA;AAAA,EAMnD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuE;AACpF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wCAAwC,OAAO;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuD;AACpE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wBAAwB,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,sCAAsC;AAAA;AAAA;AAAA;AAAA,EAQjD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqE;AAClF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sCAAsC,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA,EAMzB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6C;AAC1D,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,cAAc,OAAO;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA,EAMvC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA2D;AACxE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,4BAA4B,OAAO;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA,EAMjC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqD;AAClE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sBAAsB,OAAO;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,oCAAoC;AAAA;AAAA;AAAA;AAAA,EAM/C,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAmE;AAChF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,oCAAoC,OAAO;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA,EAQ3C,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA+D;AAC5E,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gCAAgC,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,8CAA8C;AAAA;AAAA;AAAA;AAAA,EAQzD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6E;AAC1F,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,8CAA8C,OAAO;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuD;AACpE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wBAAwB,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,sCAAsC;AAAA;AAAA;AAAA;AAAA,EAQjD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqE;AAClF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sCAAsC,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA,EAQ3C,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA+D;AAC5E,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gCAAgC,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,8CAA8C;AAAA;AAAA;AAAA;AAAA,EAQzD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6E;AAC1F,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,8CAA8C,OAAO;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAwElC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,WAAW,OAAO,OAAO;AAC3C,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,GAAG;AAClD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,cAAM,IAAI,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,gBAAgB,CAAC,IAAI;AAAA,QAC5B;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,MAAM;AAChC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,KAAK;AACpD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,MAAM;AAAA,MAC1C;AACA,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,UAAI,oBAAoB,QAAQ,IAAI,qBAAK,OAAO,qBAAK,KAAK;AAC1D,eAAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,QAAQ,MAAM;AACxB,aAAK,cAAc,IAAI,KAAK,GAAG;AAAA,MACjC;AACA,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,UAAI,4BAA4B,QAAQ,IAAI,qBAAK,OAAO,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,2BAA2B,KAAK;AAClD,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,sBAAsB,IAAI,KAAK,GAAG;AAAA,QACzC;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,MAAM;AAChC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,KAAK;AACpD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,MAAM;AAAA,MAC1C;AACA,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,UAAI,oBAAoB,QAAQ,IAAI,qBAAK,OAAO,qBAAK,KAAK;AAC1D,eAAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,QAAQ,MAAM;AACxB,aAAK,cAAc,IAAI,KAAK,GAAG;AAAA,MACjC;AACA,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,UAAI,4BAA4B,QAAQ,IAAI,qBAAK,OAAO,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,2BAA2B,KAAK;AAClD,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,sBAAsB,IAAI,KAAK,GAAG;AAAA,QACzC;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,eAAe,QAAQ,QAAQ;AACpC,YAAM,wBAAwB,QAAQ,MAAM,qBAAK,OAAO;AACxD,WAAK,oBAAoB,IAAI,MAAM,qBAAqB;AACxD,eAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,aAAK,kBAAkB,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC9C;AACA,WAAK,eAAe,QAAQ,QAAQ;AACpC,YAAM,wBAAwB,QAAQ,MAAM,qBAAK,OAAO;AACxD,WAAK,oBAAoB,IAAI,MAAM,qBAAqB;AACxD,eAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,aAAK,kBAAkB,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC9C;AACA,WAAK,YAAY,QAAQ,OAAO;AAChC,YAAM,qBAAqB,QAAQ,MAAM,qBAAK,MAAM;AACpD,WAAK,iBAAiB,IAAI,MAAM,kBAAkB;AAClD,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK,GAAG;AAC9C,aAAK,eAAe,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC1C;AACA,WAAK,eAAe,oBAAI,IAAoB;AAC5C,UAAI,mBAAmB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC3D,eAAS,IAAI,GAAG,IAAI,kBAAkB,KAAK;AACzC,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,aAAa,IAAI,KAAK,GAAG;AAAA,MAChC;AACA,WAAK,uBAAuB,oBAAI,IAAwB;AACxD,UAAI,2BAA2B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,0BAA0B,KAAK;AACjD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,qBAAqB,IAAI,KAAK,GAAG;AAAA,QACxC;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,WAAW;AACrC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,UAAU;AACzD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,WAAW;AAAA,MAC/C;AACA,WAAK,YAAY,QAAQ,QAAQ;AACjC,YAAM,qBAAqB,QAAQ,MAAM,qBAAK,OAAO;AACrD,WAAK,iBAAiB,IAAI,MAAM,kBAAkB;AAClD,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK,GAAG;AAC9C,aAAK,eAAe,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC3C;AAAA,IACF,OAAO;AACL,WAAK,aAAa,IAAI,WAAW;AACjC,WAAK,kBAAkB,CAAC;AACxB,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,aAAa;AAClB,WAAK,kBAAkB,CAAC;AACxB,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,WAAK,aAAa;AAClB,WAAK,kBAAkB,CAAC;AACxB,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,eAAe;AACpB,WAAK,oBAAoB,CAAC;AAC1B,WAAK,eAAe;AACpB,WAAK,oBAAoB,CAAC;AAC1B,WAAK,YAAY;AACjB,WAAK,iBAAiB,CAAC;AACvB,WAAK,eAAe,oBAAI,IAAyB;AACjD,WAAK,uBAAuB,oBAAI,IAA6B;AAC7D,WAAK,aAAa,IAAI,WAAW,GAAG;AACpC,WAAK,kBAAkB,CAAC;AACxB,WAAK,YAAY;AACjB,WAAK,iBAAiB,CAAC;AAAA,IACzB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,eAAe,aAAa;AAC1C,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,WAAW,OAAO,OAAO;AAAA,IAChC;AACA,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,GAAG;AAC7C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,YAAM,KAAK,KAAK,gBAAgB,CAAC;AACjC,SAAG,OAAO,OAAO;AAAA,IACnB;AACA,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,MAAM,KAAK,UAAU;AAC7B,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,KAAK;AAC/C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,MAAM,KAAK,gBAAgB,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,cAAc,MAAM,qBAAK,OAAO,qBAAK,KAAK;AAC3D,SAAK,cAAc,QAAQ,CAAC,KAAK,QAAQ;AACvC,cAAQ,MAAM,GAAG;AACjB,cAAQ,MAAM,GAAG;AAAA,IACnB,CAAC;AACD,YAAQ,IAAI,KAAK,sBAAsB,MAAM,qBAAK,OAAO,qBAAK,GAAG;AACjE,SAAK,sBAAsB,QAAQ,CAAC,KAAK,QAAQ;AAC/C,cAAQ,MAAM,GAAG;AACjB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,MAAM,KAAK,UAAU;AAC7B,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,KAAK;AAC/C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,MAAM,KAAK,gBAAgB,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,cAAc,MAAM,qBAAK,OAAO,qBAAK,KAAK;AAC3D,SAAK,cAAc,QAAQ,CAAC,KAAK,QAAQ;AACvC,cAAQ,MAAM,GAAG;AACjB,cAAQ,MAAM,GAAG;AAAA,IACnB,CAAC;AACD,YAAQ,IAAI,KAAK,sBAAsB,MAAM,qBAAK,OAAO,qBAAK,GAAG;AACjE,SAAK,sBAAsB,QAAQ,CAAC,KAAK,QAAQ;AAC/C,cAAQ,MAAM,GAAG;AACjB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,QAAQ,KAAK,YAAY;AACjC,UAAM,0BAA0B,KAAK,kBAAkB;AACvD,YAAQ,MAAM,yBAAyB,qBAAK,OAAO;AACnD,aAAS,IAAI,GAAG,IAAI,yBAAyB,KAAK,GAAG;AACnD,cAAQ,QAAQ,KAAK,kBAAkB,CAAC,CAAC;AAAA,IAC3C;AACA,YAAQ,QAAQ,KAAK,YAAY;AACjC,UAAM,0BAA0B,KAAK,kBAAkB;AACvD,YAAQ,MAAM,yBAAyB,qBAAK,OAAO;AACnD,aAAS,IAAI,GAAG,IAAI,yBAAyB,KAAK,GAAG;AACnD,cAAQ,QAAQ,KAAK,kBAAkB,CAAC,CAAC;AAAA,IAC3C;AACA,YAAQ,OAAO,KAAK,SAAS;AAC7B,UAAM,uBAAuB,KAAK,eAAe;AACjD,YAAQ,MAAM,sBAAsB,qBAAK,MAAM;AAC/C,aAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,cAAQ,OAAO,KAAK,eAAe,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,aAAa,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC5D,SAAK,aAAa,QAAQ,CAAC,KAAK,QAAQ;AACtC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,qBAAqB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACjE,SAAK,qBAAqB,QAAQ,CAAC,KAAK,QAAQ;AAC9C,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,WAAW,KAAK,UAAU;AAClC,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,UAAU;AACpD,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,WAAW,KAAK,gBAAgB,CAAC,CAAC;AAAA,IAC5C;AACA,YAAQ,QAAQ,KAAK,SAAS;AAC9B,UAAM,uBAAuB,KAAK,eAAe;AACjD,YAAQ,MAAM,sBAAsB,qBAAK,OAAO;AAChD,aAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,cAAQ,QAAQ,KAAK,eAAe,CAAC,CAAC;AAAA,IACxC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAsD;AACnE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,uBAAuB,OAAO;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;", + "names": ["GenericEnum"] +} diff --git a/integration/typescript_tests/host_signature/types.ts b/integration/typescript_tests/host_signature/types.ts new file mode 100644 index 00000000..19ae0845 --- /dev/null +++ b/integration/typescript_tests/host_signature/types.ts @@ -0,0 +1,1383 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-host + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export enum GenericEnum { + FirstValue = 0, + + SecondValue = 1, + + DefaultValue = 2, + +} +export class EmptyModel { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModel | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModel(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// EmptyModelWithDescription: Test Description +export class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModelWithDescription | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModelWithDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleStringField { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringField | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringField(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleStringFieldAndDescription: Test Description +export class ModelWithSingleStringFieldAndDescription { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringFieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleInt32Field { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32Field(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +export class ModelWithSingleInt32FieldAndDescription { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32FieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFields { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFields | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFields(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAndDescription: Test Description +export class ModelWithMultipleFieldsAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnum { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnum | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnum(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAndDescription: Test Description +export class ModelWithEnumAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnumAccessor { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAccessorAndDescription: Test Description +export class ModelWithEnumAccessorAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFieldsAccessor { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +export class ModelWithMultipleFieldsAccessorAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModels { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModels(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +export class ModelWithEmbeddedModelsAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModelsAccessor { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +export class ModelWithEmbeddedModelsAccessorAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithAllFieldTypes { + modelField: EmptyModel | undefined; + + modelArrayField: Array; + + stringField: string; + + stringArrayField: string[]; + + stringMapField: Map; + + stringMapFieldEmbedded: Map; + + int32Field: number; + + int32ArrayField: number[]; + + int32MapField: Map; + + int32MapFieldEmbedded: Map; + + int64Field: bigint; + + int64ArrayField: bigint[]; + + int64MapField: Map; + + int64MapFieldEmbedded: Map; + + uint32Field: number; + + uint32ArrayField: number[]; + + uint32MapField: Map; + + uint32MapFieldEmbedded: Map; + + uint64Field: bigint; + + uint64ArrayField: bigint[]; + + uint64MapField: Map; + + uint64MapFieldEmbedded: Map; + + float32Field: number; + + float32ArrayField: number[]; + + float64Field: number; + + float64ArrayField: number[]; + + enumField: GenericEnum; + + enumArrayField: GenericEnum[]; + + enumMapField: Map; + + enumMapFieldEmbedded: Map; + + bytesField: Uint8Array; + + bytesArrayField: Uint8Array[]; + + boolField: boolean; + + boolArrayField: boolean[]; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.modelField = EmptyModel.decode(decoder); + const modelArrayFieldSize = decoder.array(Kind.Any); + this.modelArrayField = new Array(modelArrayFieldSize); + for (let i = 0; i < modelArrayFieldSize; i += 1) { + const x = EmptyModel.decode(decoder); + if (typeof x !== "undefined") { + this.modelArrayField[i] = x; + } + } + this.stringField = decoder.string(); + const stringArrayFieldSize = decoder.array(Kind.String); + this.stringArrayField = new Array(stringArrayFieldSize); + for (let i = 0; i < stringArrayFieldSize; i += 1) { + this.stringArrayField[i] = decoder.string(); + } + this.stringMapField = new Map(); + let stringMapFieldSize = decoder.map(Kind.String, Kind.String); + for (let i = 0; i < stringMapFieldSize; i++) { + let key = decoder.string(); + let val = decoder.string(); + this.stringMapField.set(key, val); + } + this.stringMapFieldEmbedded = new Map(); + let stringMapFieldEmbeddedSize = decoder.map(Kind.String, Kind.Any); + for (let i = 0; i < stringMapFieldEmbeddedSize; i++) { + let key = decoder.string(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.stringMapFieldEmbedded.set(key, val); + } + } + this.int32Field = decoder.int32(); + const int32ArrayFieldSize = decoder.array(Kind.Int32); + this.int32ArrayField = new Array(int32ArrayFieldSize); + for (let i = 0; i < int32ArrayFieldSize; i += 1) { + this.int32ArrayField[i] = decoder.int32(); + } + this.int32MapField = new Map(); + let int32MapFieldSize = decoder.map(Kind.Int32, Kind.Int32); + for (let i = 0; i < int32MapFieldSize; i++) { + let key = decoder.int32(); + let val = decoder.int32(); + this.int32MapField.set(key, val); + } + this.int32MapFieldEmbedded = new Map(); + let int32MapFieldEmbeddedSize = decoder.map(Kind.Int32, Kind.Any); + for (let i = 0; i < int32MapFieldEmbeddedSize; i++) { + let key = decoder.int32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int32MapFieldEmbedded.set(key, val); + } + } + this.int64Field = decoder.int64(); + const int64ArrayFieldSize = decoder.array(Kind.Int64); + this.int64ArrayField = new Array(int64ArrayFieldSize); + for (let i = 0; i < int64ArrayFieldSize; i += 1) { + this.int64ArrayField[i] = decoder.int64(); + } + this.int64MapField = new Map(); + let int64MapFieldSize = decoder.map(Kind.Int64, Kind.Int64); + for (let i = 0; i < int64MapFieldSize; i++) { + let key = decoder.int64(); + let val = decoder.int64(); + this.int64MapField.set(key, val); + } + this.int64MapFieldEmbedded = new Map(); + let int64MapFieldEmbeddedSize = decoder.map(Kind.Int64, Kind.Any); + for (let i = 0; i < int64MapFieldEmbeddedSize; i++) { + let key = decoder.int64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int64MapFieldEmbedded.set(key, val); + } + } + this.uint32Field = decoder.uint32(); + const uint32ArrayFieldSize = decoder.array(Kind.Uint32); + this.uint32ArrayField = new Array(uint32ArrayFieldSize); + for (let i = 0; i < uint32ArrayFieldSize; i += 1) { + this.uint32ArrayField[i] = decoder.uint32(); + } + this.uint32MapField = new Map(); + let uint32MapFieldSize = decoder.map(Kind.Uint32, Kind.Uint32); + for (let i = 0; i < uint32MapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.uint32(); + this.uint32MapField.set(key, val); + } + this.uint32MapFieldEmbedded = new Map(); + let uint32MapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint32MapFieldEmbedded.set(key, val); + } + } + this.uint64Field = decoder.uint64(); + const uint64ArrayFieldSize = decoder.array(Kind.Uint64); + this.uint64ArrayField = new Array(uint64ArrayFieldSize); + for (let i = 0; i < uint64ArrayFieldSize; i += 1) { + this.uint64ArrayField[i] = decoder.uint64(); + } + this.uint64MapField = new Map(); + let uint64MapFieldSize = decoder.map(Kind.Uint64, Kind.Uint64); + for (let i = 0; i < uint64MapFieldSize; i++) { + let key = decoder.uint64(); + let val = decoder.uint64(); + this.uint64MapField.set(key, val); + } + this.uint64MapFieldEmbedded = new Map(); + let uint64MapFieldEmbeddedSize = decoder.map(Kind.Uint64, Kind.Any); + for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) { + let key = decoder.uint64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint64MapFieldEmbedded.set(key, val); + } + } + this.float32Field = decoder.float32(); + const float32ArrayFieldSize = decoder.array(Kind.Float32); + this.float32ArrayField = new Array(float32ArrayFieldSize); + for (let i = 0; i < float32ArrayFieldSize; i += 1) { + this.float32ArrayField[i] = decoder.float32(); + } + this.float64Field = decoder.float64(); + const float64ArrayFieldSize = decoder.array(Kind.Float64); + this.float64ArrayField = new Array(float64ArrayFieldSize); + for (let i = 0; i < float64ArrayFieldSize; i += 1) { + this.float64ArrayField[i] = decoder.float64(); + } + this.enumField = decoder.uint32(); + const enumArrayFieldSize = decoder.array(Kind.Uint32); + this.enumArrayField = new Array(enumArrayFieldSize); + for (let i = 0; i < enumArrayFieldSize; i += 1) { + this.enumArrayField[i] = decoder.uint32(); + } + this.enumMapField = new Map(); + let enumMapFieldSize = decoder.map(Kind.Uint32, Kind.String); + for (let i = 0; i < enumMapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.string(); + this.enumMapField.set(key, val); + } + this.enumMapFieldEmbedded = new Map(); + let enumMapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < enumMapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.enumMapFieldEmbedded.set(key, val); + } + } + this.bytesField = decoder.uint8Array(); + const bytesArrayFieldSize = decoder.array(Kind.Uint8Array); + this.bytesArrayField = new Array(bytesArrayFieldSize); + for (let i = 0; i < bytesArrayFieldSize; i += 1) { + this.bytesArrayField[i] = decoder.uint8Array(); + } + this.boolField = decoder.boolean(); + const boolArrayFieldSize = decoder.array(Kind.Boolean); + this.boolArrayField = new Array(boolArrayFieldSize); + for (let i = 0; i < boolArrayFieldSize; i += 1) { + this.boolArrayField[i] = decoder.boolean(); + } + } else { + this.modelField = new EmptyModel(); + this.modelArrayField = []; + this.stringField = "DefaultValue"; + this.stringArrayField = []; + this.stringMapField = new Map(); + this.stringMapFieldEmbedded = new Map(); + this.int32Field = 32; + this.int32ArrayField = []; + this.int32MapField = new Map(); + this.int32MapFieldEmbedded = new Map(); + this.int64Field = 64n; + this.int64ArrayField = []; + this.int64MapField = new Map(); + this.int64MapFieldEmbedded = new Map(); + this.uint32Field = 32; + this.uint32ArrayField = []; + this.uint32MapField = new Map(); + this.uint32MapFieldEmbedded = new Map(); + this.uint64Field = 64n; + this.uint64ArrayField = []; + this.uint64MapField = new Map(); + this.uint64MapFieldEmbedded = new Map(); + this.float32Field = 32.32; + this.float32ArrayField = []; + this.float64Field = 64.64; + this.float64ArrayField = []; + this.enumField = GenericEnum.DefaultValue; + this.enumArrayField = []; + this.enumMapField = new Map(); + this.enumMapFieldEmbedded = new Map(); + this.bytesField = new Uint8Array(512); + this.bytesArrayField = []; + this.boolField = true; + this.boolArrayField = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.modelField === "undefined") { + encoder.null(); + } else { + this.modelField.encode(encoder); + } + const modelArrayFieldLength = this.modelArrayField.length; + encoder.array(modelArrayFieldLength, Kind.Any); + for (let i = 0; i < modelArrayFieldLength; i += 1) { + const el = this.modelArrayField[i]; + el.encode(encoder); + } + encoder.string(this.stringField); + const stringArrayFieldLength = this.stringArrayField.length; + encoder.array(stringArrayFieldLength, Kind.String); + for (let i = 0; i < stringArrayFieldLength; i += 1) { + encoder.string(this.stringArrayField[i]); + } + encoder.map(this.stringMapField.size, Kind.String, Kind.String); + this.stringMapField.forEach((val, key) => { + encoder.string(key); + encoder.string(val); + }); + encoder.map(this.stringMapFieldEmbedded.size, Kind.String, Kind.Any); + this.stringMapFieldEmbedded.forEach((val, key) => { + encoder.string(key); + val.encode(encoder); + }); + encoder.int32(this.int32Field); + const int32ArrayFieldLength = this.int32ArrayField.length; + encoder.array(int32ArrayFieldLength, Kind.Int32); + for (let i = 0; i < int32ArrayFieldLength; i += 1) { + encoder.int32(this.int32ArrayField[i]); + } + encoder.map(this.int32MapField.size, Kind.Int32, Kind.Int32); + this.int32MapField.forEach((val, key) => { + encoder.int32(key); + encoder.int32(val); + }); + encoder.map(this.int32MapFieldEmbedded.size, Kind.Int32, Kind.Any); + this.int32MapFieldEmbedded.forEach((val, key) => { + encoder.int32(key); + val.encode(encoder); + }); + encoder.int64(this.int64Field); + const int64ArrayFieldLength = this.int64ArrayField.length; + encoder.array(int64ArrayFieldLength, Kind.Int64); + for (let i = 0; i < int64ArrayFieldLength; i += 1) { + encoder.int64(this.int64ArrayField[i]); + } + encoder.map(this.int64MapField.size, Kind.Int64, Kind.Int64); + this.int64MapField.forEach((val, key) => { + encoder.int64(key); + encoder.int64(val); + }); + encoder.map(this.int64MapFieldEmbedded.size, Kind.Int64, Kind.Any); + this.int64MapFieldEmbedded.forEach((val, key) => { + encoder.int64(key); + val.encode(encoder); + }); + encoder.uint32(this.uint32Field); + const uint32ArrayFieldLength = this.uint32ArrayField.length; + encoder.array(uint32ArrayFieldLength, Kind.Uint32); + for (let i = 0; i < uint32ArrayFieldLength; i += 1) { + encoder.uint32(this.uint32ArrayField[i]); + } + encoder.map(this.uint32MapField.size, Kind.Uint32, Kind.Uint32); + this.uint32MapField.forEach((val, key) => { + encoder.uint32(key); + encoder.uint32(val); + }); + encoder.map(this.uint32MapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.uint32MapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint64(this.uint64Field); + const uint64ArrayFieldLength = this.uint64ArrayField.length; + encoder.array(uint64ArrayFieldLength, Kind.Uint64); + for (let i = 0; i < uint64ArrayFieldLength; i += 1) { + encoder.uint64(this.uint64ArrayField[i]); + } + encoder.map(this.uint64MapField.size, Kind.Uint64, Kind.Uint64); + this.uint64MapField.forEach((val, key) => { + encoder.uint64(key); + encoder.uint64(val); + }); + encoder.map(this.uint64MapFieldEmbedded.size, Kind.Uint64, Kind.Any); + this.uint64MapFieldEmbedded.forEach((val, key) => { + encoder.uint64(key); + val.encode(encoder); + }); + encoder.float32(this.float32Field); + const float32ArrayFieldLength = this.float32ArrayField.length; + encoder.array(float32ArrayFieldLength, Kind.Float32); + for (let i = 0; i < float32ArrayFieldLength; i += 1) { + encoder.float32(this.float32ArrayField[i]); + } + encoder.float64(this.float64Field); + const float64ArrayFieldLength = this.float64ArrayField.length; + encoder.array(float64ArrayFieldLength, Kind.Float64); + for (let i = 0; i < float64ArrayFieldLength; i += 1) { + encoder.float64(this.float64ArrayField[i]); + } + encoder.uint32(this.enumField); + const enumArrayFieldLength = this.enumArrayField.length; + encoder.array(enumArrayFieldLength, Kind.Uint32); + for (let i = 0; i < enumArrayFieldLength; i += 1) { + encoder.uint32(this.enumArrayField[i]); + } + encoder.map(this.enumMapField.size, Kind.Uint32, Kind.String); + this.enumMapField.forEach((val, key) => { + encoder.uint32(key); + encoder.string(val); + }); + encoder.map(this.enumMapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.enumMapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint8Array(this.bytesField); + const bytesArrayFieldLength = this.bytesArrayField.length; + encoder.array(bytesArrayFieldLength, Kind.Uint8Array); + for (let i = 0; i < bytesArrayFieldLength; i += 1) { + encoder.uint8Array(this.bytesArrayField[i]); + } + encoder.boolean(this.boolField); + const boolArrayFieldLength = this.boolArrayField.length; + encoder.array(boolArrayFieldLength, Kind.Boolean); + for (let i = 0; i < boolArrayFieldLength; i += 1) { + encoder.boolean(this.boolArrayField[i]); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithAllFieldTypes(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + diff --git a/integration/typescript_tests/signature/index.d.ts b/integration/typescript_tests/signature/index.d.ts new file mode 100644 index 00000000..1fee345a --- /dev/null +++ b/integration/typescript_tests/signature/index.d.ts @@ -0,0 +1,33 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +export * from "./types"; +import { ModelWithAllFieldTypes } from "./types"; + +// Write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +export declare function Write(ctx?: ModelWithAllFieldTypes): number[]; + +// Read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +export declare function Read(): ModelWithAllFieldTypes | undefined; + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +export declare function Error(err: Error): number[]; + +// Resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +export declare function Resize(size: number): number; + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +export declare function Hash(): number[]; + +// Next calls the next function in the Scale Function Chain +export declare function Next(ctx?: ModelWithAllFieldTypes): ModelWithAllFieldTypes | undefined; diff --git a/integration/typescript_tests/signature/index.js b/integration/typescript_tests/signature/index.js new file mode 100644 index 00000000..fd1bcb45 --- /dev/null +++ b/integration/typescript_tests/signature/index.js @@ -0,0 +1,86 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var stdin_exports = {}; +__export(stdin_exports, { + Error: () => Error2, + Hash: () => Hash, + Next: () => Next, + Read: () => Read, + Resize: () => Resize, + Write: () => Write +}); +module.exports = __toCommonJS(stdin_exports); +var import_scale_signature_interfaces = require("@loopholelabs/scale-signature-interfaces"); +var import_polyglot = require("@loopholelabs/polyglot"); +__reExport(stdin_exports, require("./types"), module.exports); +var import_types = require("./types"); +global.WRITE_BUFFER = new Uint8Array().buffer; +global.READ_BUFFER = new Uint8Array().buffer; +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5"; +function Write(ctx) { + const enc = new import_polyglot.Encoder(); + if (typeof ctx === "undefined") { + enc.null(); + } else { + ctx.encode(enc); + } + const len = enc.bytes.buffer.byteLength; + global.WRITE_BUFFER = enc.bytes.buffer; + const addrof = global[import_scale_signature_interfaces.TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof(global.WRITE_BUFFER); + return [ptr, len]; +} +function Read() { + const dec = new import_polyglot.Decoder(new Uint8Array(global.READ_BUFFER)); + return import_types.ModelWithAllFieldTypes.decode(dec); +} +function Error2(err) { + const enc = new import_polyglot.Encoder(); + enc.error(err); + const len = enc.bytes.buffer.byteLength; + global.WRITE_BUFFER = enc.bytes.buffer; + const addrof = global[import_scale_signature_interfaces.TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof(global.WRITE_BUFFER); + return [ptr, len]; +} +function Resize(size) { + global.READ_BUFFER = new Uint8Array(size).buffer; + const addrof = global[import_scale_signature_interfaces.TYPESCRIPT_ADDRESS_OF]; + return addrof(global.READ_BUFFER); +} +function Hash() { + const enc = new import_polyglot.Encoder(); + enc.string(hash); + const len = enc.bytes.buffer.byteLength; + global.WRITE_BUFFER = enc.bytes.buffer; + const addrof = global[import_scale_signature_interfaces.TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof(global.WRITE_BUFFER); + return [ptr, len]; +} +function Next(ctx) { + const [ptr, len] = Write(ctx); + const next = global[import_scale_signature_interfaces.TYPESCRIPT_NEXT]; + next([ptr, len]); + return Read(); +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/integration/typescript_tests/signature/index.js.map b/integration/typescript_tests/signature/index.js.map new file mode 100644 index 00000000..85d5dd0f --- /dev/null +++ b/integration/typescript_tests/signature/index.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sources": [""], + "sourceRoot": "index.js", + "sourcesContent": ["// Code generated by scale-signature 0.4.0, DO NOT EDIT.\n// output: local-example-latest-guest\n\n/* eslint no-bitwise: off */\n\nimport { Signature as SignatureInterface, TYPESCRIPT_ADDRESS_OF, TYPESCRIPT_NEXT} from \"@loopholelabs/scale-signature-interfaces\";\nimport { Decoder, Encoder, Kind } from \"@loopholelabs/polyglot\";\n\n(global as any).WRITE_BUFFER = new Uint8Array().buffer;\n(global as any).READ_BUFFER = new Uint8Array().buffer;\n\nexport * from \"./types\";\nimport { ModelWithAllFieldTypes } from \"./types\";\n\nconst hash = \"3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5\"\n\n// Write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size\n//\n// Users should not use this method.\nexport function Write(ctx?: ModelWithAllFieldTypes): number[] {\n const enc = new Encoder();\n if (typeof ctx === \"undefined\") {\n enc.null();\n } else {\n ctx.encode(enc);\n }\n const len = enc.bytes.buffer.byteLength;\n (global as any).WRITE_BUFFER = enc.bytes.buffer;\n const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF];\n const ptr = addrof((global as any).WRITE_BUFFER);\n return [ptr, len];\n}\n\n// Read deserializes signature from the global READ_BUFFER\n//\n// Users should not use this method.\nexport function Read(): ModelWithAllFieldTypes | undefined {\n const dec = new Decoder(new Uint8Array((global as any).READ_BUFFER));\n return ModelWithAllFieldTypes.decode(dec);\n}\n\n// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size\n//\n// Users should not use this method.\nexport function Error(err: Error): number[] {\n const enc = new Encoder();\n enc.error(err);\n const len = enc.bytes.buffer.byteLength;\n (global as any).WRITE_BUFFER = enc.bytes.buffer;\n const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF];\n const ptr = addrof((global as any).WRITE_BUFFER);\n return [ptr, len];\n}\n\n// Resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer\n//\n// Users should not use this method.\nexport function Resize(size: number): number {\n (global as any).READ_BUFFER = new Uint8Array(size).buffer;\n const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF];\n return addrof((global as any).READ_BUFFER);\n}\n\n// Hash returns the hash of the Scale Signature\n//\n// Users should not use this method.\nexport function Hash(): number[] {\n const enc = new Encoder();\n enc.string(hash);\n const len = enc.bytes.buffer.byteLength;\n (global as any).WRITE_BUFFER = enc.bytes.buffer;\n const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF];\n const ptr = addrof((global as any).WRITE_BUFFER);\n return [ptr, len];\n}\n\n// Next calls the next function in the Scale Function Chain\nexport function Next(ctx?: ModelWithAllFieldTypes): ModelWithAllFieldTypes | undefined {\n const [ptr, len] = Write(ctx);\n const next = (global as any)[TYPESCRIPT_NEXT];\n next([ptr, len]);\n return Read();\n}\n"], + "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,eAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,wCAAuF;AACvF,sBAAuC;AAKvC,0BAAc,oBAXd;AAYA,mBAAuC;AAJtC,OAAe,eAAe,IAAI,WAAW,EAAE;AAC/C,OAAe,cAAc,IAAI,WAAW,EAAE;AAK/C,MAAM,OAAO;AAKN,SAAS,MAAM,KAAwC;AAC5D,QAAM,MAAM,IAAI,wBAAQ;AACxB,MAAI,OAAO,QAAQ,aAAa;AAC9B,QAAI,KAAK;AAAA,EACX,OAAO;AACL,QAAI,OAAO,GAAG;AAAA,EAChB;AACA,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,EAAC,OAAe,eAAe,IAAI,MAAM;AACzC,QAAM,SAAU,OAAe,uDAAqB;AACpD,QAAM,MAAM,OAAQ,OAAe,YAAY;AAC/C,SAAO,CAAC,KAAK,GAAG;AAClB;AAKO,SAAS,OAA2C;AACzD,QAAM,MAAM,IAAI,wBAAQ,IAAI,WAAY,OAAe,WAAW,CAAC;AACnE,SAAO,oCAAuB,OAAO,GAAG;AAC1C;AAKO,SAASA,OAAM,KAAsB;AAC1C,QAAM,MAAM,IAAI,wBAAQ;AACxB,MAAI,MAAM,GAAG;AACb,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,EAAC,OAAe,eAAe,IAAI,MAAM;AACzC,QAAM,SAAU,OAAe,uDAAqB;AACpD,QAAM,MAAM,OAAQ,OAAe,YAAY;AAC/C,SAAO,CAAC,KAAK,GAAG;AAClB;AAKO,SAAS,OAAO,MAAsB;AAC3C,EAAC,OAAe,cAAc,IAAI,WAAW,IAAI,EAAE;AACnD,QAAM,SAAU,OAAe,uDAAqB;AACpD,SAAO,OAAQ,OAAe,WAAW;AAC3C;AAKO,SAAS,OAAiB;AAC/B,QAAM,MAAM,IAAI,wBAAQ;AACxB,MAAI,OAAO,IAAI;AACf,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,EAAC,OAAe,eAAe,IAAI,MAAM;AACzC,QAAM,SAAU,OAAe,uDAAqB;AACpD,QAAM,MAAM,OAAQ,OAAe,YAAY;AAC/C,SAAO,CAAC,KAAK,GAAG;AAClB;AAGO,SAAS,KAAK,KAAkE;AACrF,QAAM,CAAC,KAAK,GAAG,IAAI,MAAM,GAAG;AAC5B,QAAM,OAAQ,OAAe,iDAAe;AAC5C,OAAK,CAAC,KAAK,GAAG,CAAC;AACf,SAAO,KAAK;AACd;", + "names": ["Error"] +} diff --git a/integration/typescript_tests/signature/index.test.ts b/integration/typescript_tests/signature/index.test.ts new file mode 100644 index 00000000..5fb830cf --- /dev/null +++ b/integration/typescript_tests/signature/index.test.ts @@ -0,0 +1,499 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import * as generated from "./types"; +import * as polyglot from "@loopholelabs/polyglot"; +import * as fs from 'fs'; + +test('test-output', () => { + const nilModelEncoder = new polyglot.Encoder(); + generated.EmptyModel.encode_undefined(nilModelEncoder); + fs.writeFileSync('../../test_data/nil_model.bin', nilModelEncoder.bytes, 'binary'); + + const emptyModelEncoder = new polyglot.Encoder(); + const emptyModel = new generated.EmptyModel(); + emptyModel.encode(emptyModelEncoder); + fs.writeFileSync('../../test_data/empty_model.bin', emptyModelEncoder.bytes, 'binary'); + + const emptyModelWithDescriptionEncoder = new polyglot.Encoder(); + const emptyModelWithDescription = new generated.EmptyModelWithDescription(); + emptyModelWithDescription.encode(emptyModelWithDescriptionEncoder); + fs.writeFileSync('../../test_data/empty_model_with_description.bin', emptyModelWithDescriptionEncoder.bytes, 'binary'); + + const modelWithSingleStringFieldEncoder = new polyglot.Encoder(); + const modelWithSingleStringField = new generated.ModelWithSingleStringField(); + expect(modelWithSingleStringField.stringField).toEqual('DefaultValue'); + modelWithSingleStringField.stringField = 'hello world'; + modelWithSingleStringField.encode(modelWithSingleStringFieldEncoder); + fs.writeFileSync('../../test_data/model_with_single_string_field.bin', modelWithSingleStringFieldEncoder.bytes, 'binary'); + + const modelWithSingleStringFieldAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithSingleStringFieldAndDescription = new generated.ModelWithSingleStringFieldAndDescription(); + expect(modelWithSingleStringFieldAndDescription.stringField).toEqual('DefaultValue'); + modelWithSingleStringFieldAndDescription.stringField = 'hello world'; + modelWithSingleStringFieldAndDescription.encode(modelWithSingleStringFieldAndDescriptionEncoder); + fs.writeFileSync( + '../../test_data/model_with_single_string_field_and_description.bin', + modelWithSingleStringFieldAndDescriptionEncoder.bytes, + 'binary' + ); + + const modelWithSingleInt32FieldEncoder = new polyglot.Encoder(); + const modelWithSingleInt32Field = new generated.ModelWithSingleInt32Field(); + expect(modelWithSingleInt32Field.int32Field).toEqual(32); + modelWithSingleInt32Field.int32Field = 42; + modelWithSingleInt32Field.encode(modelWithSingleInt32FieldEncoder); + fs.writeFileSync('../../test_data/model_with_single_int32_field.bin', modelWithSingleInt32FieldEncoder.bytes, 'binary'); + + const modelWithSingleInt32FieldAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithSingleInt32FieldAndDescription = new generated.ModelWithSingleInt32FieldAndDescription(); + expect(modelWithSingleInt32FieldAndDescription.int32Field).toEqual(32); + modelWithSingleInt32FieldAndDescription.int32Field = 42; + modelWithSingleInt32FieldAndDescription.encode(modelWithSingleInt32FieldAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_single_int32_field_and_description.bin', modelWithSingleInt32FieldAndDescriptionEncoder.bytes, 'binary'); + + const modelWithMultipleFieldsEncoder = new polyglot.Encoder(); + const modelWithMultipleFields = new generated.ModelWithMultipleFields(); + expect(modelWithMultipleFields.stringField).toEqual('DefaultValue'); + expect(modelWithMultipleFields.int32Field).toEqual(32); + modelWithMultipleFields.stringField = 'hello world'; + modelWithMultipleFields.int32Field = 42; + modelWithMultipleFields.encode(modelWithMultipleFieldsEncoder); + fs.writeFileSync('../../test_data/model_with_multiple_fields.bin', modelWithMultipleFieldsEncoder.bytes, 'binary'); + + const modelWithMultipleFieldsAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithMultipleFieldsAndDescription = new generated.ModelWithMultipleFieldsAndDescription(); + expect(modelWithMultipleFieldsAndDescription.stringField).toEqual('DefaultValue'); + expect(modelWithMultipleFieldsAndDescription.int32Field).toEqual(32); + modelWithMultipleFieldsAndDescription.stringField = 'hello world'; + modelWithMultipleFieldsAndDescription.int32Field = 42; + modelWithMultipleFieldsAndDescription.encode(modelWithMultipleFieldsAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_multiple_fields_and_description.bin', modelWithMultipleFieldsAndDescriptionEncoder.bytes, 'binary'); + + const modelWithEnumEncoder = new polyglot.Encoder(); + const modelWithEnum = new generated.ModelWithEnum(); + expect(modelWithEnum.enumField).toEqual(generated.GenericEnum.DefaultValue); + modelWithEnum.enumField = generated.GenericEnum.SecondValue; + modelWithEnum.encode(modelWithEnumEncoder); + fs.writeFileSync('../../test_data/model_with_enum.bin', modelWithEnumEncoder.bytes, 'binary'); + + const modelWithEnumAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithEnumAndDescription = new generated.ModelWithEnumAndDescription(); + expect(modelWithEnumAndDescription.enumField).toEqual(generated.GenericEnum.DefaultValue); + modelWithEnumAndDescription.enumField = generated.GenericEnum.SecondValue; + modelWithEnumAndDescription.encode(modelWithEnumAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_enum_and_description.bin', modelWithEnumAndDescriptionEncoder.bytes, 'binary'); + + const modelWithEnumAccessorEncoder = new polyglot.Encoder(); + const modelWithEnumAccessor = new generated.ModelWithEnumAccessor(); + let enumValue = modelWithEnumAccessor.enumField + expect(enumValue).toEqual(generated.GenericEnum.DefaultValue); + modelWithEnumAccessor.enumField = generated.GenericEnum.SecondValue; + modelWithEnumAccessor.encode(modelWithEnumAccessorEncoder); + fs.writeFileSync('../../test_data/model_with_enum_accessor.bin', modelWithEnumAccessorEncoder.bytes, 'binary'); + + const modelWithEnumAccessorAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithEnumAccessorAndDescription = new generated.ModelWithEnumAccessorAndDescription(); + enumValue = modelWithEnumAccessorAndDescription.enumField + expect(enumValue).toEqual(generated.GenericEnum.DefaultValue); + modelWithEnumAccessorAndDescription.enumField = generated.GenericEnum.SecondValue; + modelWithEnumAccessorAndDescription.encode(modelWithEnumAccessorAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_enum_accessor_and_description.bin', modelWithEnumAccessorAndDescriptionEncoder.bytes, 'binary'); + + const modelWithMultipleFieldsAccessorEncoder = new polyglot.Encoder(); + const modelWithMultipleFieldsAccessor = new generated.ModelWithMultipleFieldsAccessor(); + let stringFieldValue = modelWithMultipleFieldsAccessor.stringField; + expect(stringFieldValue).toEqual('DefaultValue'); + try { + modelWithMultipleFieldsAccessor.stringField = 'hello world'; + fail('Expected error to be thrown'); + } catch (e) { + // @ts-ignore + expect(e.message).toEqual('value must match ^[a-zA-Z0-9]*$'); + } + try { + modelWithMultipleFieldsAccessor.stringField = ""; + fail('Expected error to be thrown'); + } catch (e) { + // @ts-ignore + expect(e.message).toEqual('length must be between 1 and 20'); + } + modelWithMultipleFieldsAccessor.stringField = 'hello'; + stringFieldValue = modelWithMultipleFieldsAccessor.stringField; + expect(stringFieldValue).toEqual('HELLO'); + let int32FieldValue = modelWithMultipleFieldsAccessor.int32Field; + expect(int32FieldValue).toEqual(32); + try { + modelWithMultipleFieldsAccessor.int32Field = -1; + fail('Expected error to be thrown'); + } catch (e) { + // @ts-ignore + expect(e.message).toEqual('value must be between 0 and 100'); + } + try { + modelWithMultipleFieldsAccessor.int32Field = 101; + fail('Expected error to be thrown'); + } catch (e) { + // @ts-ignore + expect(e.message).toEqual('value must be between 0 and 100'); + } + modelWithMultipleFieldsAccessor.int32Field = 42; + modelWithMultipleFieldsAccessor.encode(modelWithMultipleFieldsAccessorEncoder); + fs.writeFileSync('../../test_data/model_with_multiple_fields_accessor.bin', modelWithMultipleFieldsAccessorEncoder.bytes, 'binary'); + + const modelWithMultipleFieldsAccessorAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithMultipleFieldsAccessorAndDescription = new generated.ModelWithMultipleFieldsAccessorAndDescription(); + stringFieldValue = modelWithMultipleFieldsAccessorAndDescription.stringField; + expect(stringFieldValue).toEqual('DefaultValue'); + modelWithMultipleFieldsAccessorAndDescription.stringField = 'hello world'; + int32FieldValue = modelWithMultipleFieldsAccessorAndDescription.int32Field; + expect(int32FieldValue).toEqual(32); + modelWithMultipleFieldsAccessorAndDescription.int32Field = 42; + modelWithMultipleFieldsAccessorAndDescription.encode(modelWithMultipleFieldsAccessorAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_multiple_fields_accessor_and_description.bin', modelWithMultipleFieldsAccessorAndDescriptionEncoder.bytes, 'binary'); + + const modelWithEmbeddedModelsEncoder = new polyglot.Encoder(); + const modelWithEmbeddedModels = new generated.ModelWithEmbeddedModels(); + expect(modelWithEmbeddedModels.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModels.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModels.embeddedModelArrayWithMultipleFieldsAccessor).not.toBeNull(); + expect(modelWithEmbeddedModels.embeddedModelArrayWithMultipleFieldsAccessor).not.toBeUndefined(); + expect(modelWithEmbeddedModels.embeddedModelArrayWithMultipleFieldsAccessor.length).toEqual(0); + modelWithEmbeddedModels.embeddedModelArrayWithMultipleFieldsAccessor.push(modelWithMultipleFieldsAccessor); + modelWithEmbeddedModels.encode(modelWithEmbeddedModelsEncoder); + fs.writeFileSync('../../test_data/model_with_embedded_models.bin', modelWithEmbeddedModelsEncoder.bytes, 'binary'); + + const modelWithEmbeddedModelsAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithEmbeddedModelsAndDescription = new generated.ModelWithEmbeddedModelsAndDescription(); + expect(modelWithEmbeddedModelsAndDescription.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModelsAndDescription.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAndDescription.embeddedModelArrayWithMultipleFieldsAccessor).not.toBeNull(); + expect(modelWithEmbeddedModelsAndDescription.embeddedModelArrayWithMultipleFieldsAccessor).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAndDescription.embeddedModelArrayWithMultipleFieldsAccessor.length).toEqual(0); + modelWithEmbeddedModelsAndDescription.embeddedModelArrayWithMultipleFieldsAccessor.push(modelWithMultipleFieldsAccessor); + modelWithEmbeddedModelsAndDescription.encode(modelWithEmbeddedModelsAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_embedded_models_and_description.bin', modelWithEmbeddedModelsAndDescriptionEncoder.bytes, 'binary'); + + const modelWithEmbeddedModelsAccessorEncoder = new polyglot.Encoder(); + const modelWithEmbeddedModelsAccessor = new generated.ModelWithEmbeddedModelsAccessor(); + let embeddedModel = modelWithEmbeddedModelsAccessor.embeddedEmptyModel; + expect(embeddedModel).not.toBeNull(); + expect(embeddedModel).not.toBeUndefined(); + let embeddedModelArray = modelWithEmbeddedModelsAccessor.embeddedModelArrayWithMultipleFieldsAccessor; + expect(embeddedModelArray).not.toBeNull(); + expect(embeddedModelArray).not.toBeUndefined(); + expect(embeddedModelArray.length).toEqual(0); + modelWithEmbeddedModelsAccessor.embeddedModelArrayWithMultipleFieldsAccessor.push(modelWithMultipleFieldsAccessor); + modelWithEmbeddedModelsAccessor.encode(modelWithEmbeddedModelsAccessorEncoder); + fs.writeFileSync('../../test_data/model_with_embedded_models_accessor.bin', modelWithEmbeddedModelsAccessorEncoder.bytes, 'binary'); + + const modelWithEmbeddedModelsAccessorAndDescriptionEncoder = new polyglot.Encoder(); + const modelWithEmbeddedModelsAccessorAndDescription = new generated.ModelWithEmbeddedModelsAccessorAndDescription(); + embeddedModel = modelWithEmbeddedModelsAccessorAndDescription.embeddedEmptyModel; + expect(embeddedModel).not.toBeNull(); + expect(embeddedModel).not.toBeUndefined(); + embeddedModelArray = modelWithEmbeddedModelsAccessorAndDescription.embeddedModelArrayWithMultipleFieldsAccessor; + expect(embeddedModelArray).not.toBeNull(); + expect(embeddedModelArray).not.toBeUndefined(); + expect(embeddedModelArray.length).toEqual(0); + modelWithEmbeddedModelsAccessorAndDescription.embeddedModelArrayWithMultipleFieldsAccessor.push(modelWithMultipleFieldsAccessor); + modelWithEmbeddedModelsAccessorAndDescription.encode(modelWithEmbeddedModelsAccessorAndDescriptionEncoder); + fs.writeFileSync('../../test_data/model_with_embedded_models_accessor_and_description.bin', modelWithEmbeddedModelsAccessorAndDescriptionEncoder.bytes, 'binary'); + + const modelWithAllFieldTypesEncoder = new polyglot.Encoder(); + const modelWithAllFieldTypes = new generated.ModelWithAllFieldTypes(); + expect(modelWithAllFieldTypes.stringField).toEqual('DefaultValue'); + modelWithAllFieldTypes.stringField = 'hello world'; + expect(modelWithAllFieldTypes.stringArrayField.length).toEqual(0); + expect(modelWithAllFieldTypes.stringMapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.stringMapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.stringArrayField.push('hello', 'world'); + modelWithAllFieldTypes.stringMapField.set('hello', 'world'); + modelWithAllFieldTypes.stringMapFieldEmbedded.set('hello', emptyModel); + + expect(modelWithAllFieldTypes.int32Field).toEqual(32); + modelWithAllFieldTypes.int32Field = 42; + expect(modelWithAllFieldTypes.int32ArrayField.length).toEqual(0); + expect(modelWithAllFieldTypes.int32MapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.int32MapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.int32ArrayField.push(42, 84); + modelWithAllFieldTypes.int32MapField.set(42, 84); + modelWithAllFieldTypes.int32MapFieldEmbedded.set(42, emptyModel); + + expect(modelWithAllFieldTypes.int64Field).toEqual(BigInt(64)); + modelWithAllFieldTypes.int64Field = BigInt(100); + expect(modelWithAllFieldTypes.int64ArrayField.length).toEqual(0); + expect(modelWithAllFieldTypes.int64MapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.int64MapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.int64ArrayField.push(BigInt(100), BigInt(200)); + modelWithAllFieldTypes.int64MapField.set(BigInt(100), BigInt(200)); + modelWithAllFieldTypes.int64MapFieldEmbedded.set(BigInt(100), emptyModel); + + expect(modelWithAllFieldTypes.uint32Field).toEqual(32); + modelWithAllFieldTypes.uint32Field = 42; + expect(modelWithAllFieldTypes.uint32ArrayField.length).toEqual(0); + expect(modelWithAllFieldTypes.uint32MapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.uint32MapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.uint32ArrayField.push(42, 84); + modelWithAllFieldTypes.uint32MapField.set(42, 84); + modelWithAllFieldTypes.uint32MapFieldEmbedded.set(42, emptyModel); + + expect(modelWithAllFieldTypes.uint64Field).toEqual(BigInt(64)); + modelWithAllFieldTypes.uint64Field = BigInt(100); + expect(modelWithAllFieldTypes.uint64ArrayField.length).toEqual(0); + expect(modelWithAllFieldTypes.uint64MapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.uint64MapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.uint64ArrayField.push(BigInt(100), BigInt(200)); + modelWithAllFieldTypes.uint64MapField.set(BigInt(100), BigInt(200)); + modelWithAllFieldTypes.uint64MapFieldEmbedded.set(BigInt(100), emptyModel); + + expect(modelWithAllFieldTypes.float32Field).toEqual(32.32); + modelWithAllFieldTypes.float32Field = 42.0; + expect(modelWithAllFieldTypes.float32ArrayField.length).toEqual(0); + modelWithAllFieldTypes.float32ArrayField.push(42.0, 84.0); + + expect(modelWithAllFieldTypes.float64Field).toEqual(64.64); + modelWithAllFieldTypes.float64Field = 100.0; + expect(modelWithAllFieldTypes.float64ArrayField.length).toEqual(0); + modelWithAllFieldTypes.float64ArrayField.push(100.0, 200.0); + + expect(modelWithAllFieldTypes.boolField).toEqual(true); + modelWithAllFieldTypes.boolField = false; + expect(modelWithAllFieldTypes.boolArrayField.length).toEqual(0); + modelWithAllFieldTypes.boolArrayField.push(true, false); + + expect(modelWithAllFieldTypes.bytesField.length).toEqual(512); + modelWithAllFieldTypes.bytesField = Uint8Array.from([42, 84]); + expect(modelWithAllFieldTypes.bytesArrayField.length).toEqual(0); + modelWithAllFieldTypes.bytesArrayField.push(Uint8Array.from([42, 84]), Uint8Array.from([84, 42])); + + expect(modelWithAllFieldTypes.enumField).toEqual(generated.GenericEnum.DefaultValue); + modelWithAllFieldTypes.enumField = generated.GenericEnum.SecondValue; + expect(modelWithAllFieldTypes.enumArrayField.length).toEqual(0); + modelWithAllFieldTypes.enumArrayField.push(generated.GenericEnum.FirstValue, generated.GenericEnum.SecondValue); + expect(modelWithAllFieldTypes.enumMapField).toEqual(new Map()); + expect(modelWithAllFieldTypes.enumMapFieldEmbedded).toEqual(new Map()); + modelWithAllFieldTypes.enumMapField.set(generated.GenericEnum.FirstValue, 'hello world'); + modelWithAllFieldTypes.enumMapFieldEmbedded.set(generated.GenericEnum.FirstValue, emptyModel); + + expect(modelWithAllFieldTypes.modelField).not.toBeNull(); + expect(modelWithAllFieldTypes.modelField).not.toBeUndefined(); + expect(modelWithAllFieldTypes.modelArrayField.length).toEqual(0); + modelWithAllFieldTypes.modelArrayField.push(emptyModel, emptyModel); + + modelWithAllFieldTypes.encode(modelWithAllFieldTypesEncoder); + fs.writeFileSync('../../test_data/model_with_all_field_types.bin', modelWithAllFieldTypesEncoder.bytes, 'binary'); +}); + +test('test-input', () => { + const nilModelData = fs.readFileSync("../../test_data/nil_model.bin") + const nilModel = generated.EmptyModel.decode(new polyglot.Decoder(nilModelData)); + expect(nilModel).toBeUndefined(); + + const emptyModelData = fs.readFileSync("../../test_data/empty_model.bin") + const emptyModel = generated.EmptyModel.decode(new polyglot.Decoder(emptyModelData)); + expect(emptyModel).not.toBeNull(); + expect(emptyModel).not.toBeUndefined(); + + const emptyModelWithDescriptionData = fs.readFileSync("../../test_data/empty_model_with_description.bin") + const emptyModelWithDescription = generated.EmptyModelWithDescription.decode(new polyglot.Decoder(emptyModelWithDescriptionData)); + expect(emptyModelWithDescription).not.toBeNull(); + expect(emptyModelWithDescription).not.toBeUndefined(); + + const modelWithSingleStringFieldData = fs.readFileSync("../../test_data/model_with_single_string_field.bin") + const modelWithSingleStringField = generated.ModelWithSingleStringField.decode(new polyglot.Decoder(modelWithSingleStringFieldData)); + expect(modelWithSingleStringField).not.toBeNull(); + expect(modelWithSingleStringField).not.toBeUndefined(); + expect(modelWithSingleStringField?.stringField).toEqual("hello world"); + + const modelWithSingleStringFieldAndDescriptionData = fs.readFileSync("../../test_data/model_with_single_string_field_and_description.bin") + const modelWithSingleStringFieldAndDescription = generated.ModelWithSingleStringFieldAndDescription.decode(new polyglot.Decoder(modelWithSingleStringFieldAndDescriptionData)); + expect(modelWithSingleStringFieldAndDescription).not.toBeNull(); + expect(modelWithSingleStringFieldAndDescription).not.toBeUndefined(); + expect(modelWithSingleStringFieldAndDescription?.stringField).toEqual("hello world"); + + const modelWithSingleInt32FieldData = fs.readFileSync("../../test_data/model_with_single_int32_field.bin") + const modelWithSingleInt32Field = generated.ModelWithSingleInt32Field.decode(new polyglot.Decoder(modelWithSingleInt32FieldData)); + expect(modelWithSingleInt32Field).not.toBeNull(); + expect(modelWithSingleInt32Field).not.toBeUndefined(); + expect(modelWithSingleInt32Field?.int32Field).toEqual(42); + + const modelWithSingleInt32FieldAndDescriptionData = fs.readFileSync("../../test_data/model_with_single_int32_field_and_description.bin") + const modelWithSingleInt32FieldAndDescription = generated.ModelWithSingleInt32FieldAndDescription.decode(new polyglot.Decoder(modelWithSingleInt32FieldAndDescriptionData)); + expect(modelWithSingleInt32FieldAndDescription).not.toBeNull(); + expect(modelWithSingleInt32FieldAndDescription).not.toBeUndefined(); + expect(modelWithSingleInt32FieldAndDescription?.int32Field).toEqual(42); + + const modelWithMultipleFieldsData = fs.readFileSync("../../test_data/model_with_multiple_fields.bin") + const modelWithMultipleFields = generated.ModelWithMultipleFields.decode(new polyglot.Decoder(modelWithMultipleFieldsData)); + expect(modelWithMultipleFields).not.toBeNull(); + expect(modelWithMultipleFields).not.toBeUndefined(); + expect(modelWithMultipleFields?.stringField).toEqual("hello world"); + expect(modelWithMultipleFields?.int32Field).toEqual(42); + + const modelWithMultipleFieldsAndDescriptionData = fs.readFileSync("../../test_data/model_with_multiple_fields_and_description.bin") + const modelWithMultipleFieldsAndDescription = generated.ModelWithMultipleFieldsAndDescription.decode(new polyglot.Decoder(modelWithMultipleFieldsAndDescriptionData)); + expect(modelWithMultipleFieldsAndDescription).not.toBeNull(); + expect(modelWithMultipleFieldsAndDescription).not.toBeUndefined(); + expect(modelWithMultipleFieldsAndDescription?.stringField).toEqual("hello world"); + expect(modelWithMultipleFieldsAndDescription?.int32Field).toEqual(42); + + const modelWithEnumData = fs.readFileSync("../../test_data/model_with_enum.bin") + const modelWithEnum = generated.ModelWithEnum.decode(new polyglot.Decoder(modelWithEnumData)); + expect(modelWithEnum).not.toBeNull(); + expect(modelWithEnum).not.toBeUndefined(); + expect(modelWithEnum?.enumField).toEqual(generated.GenericEnum.SecondValue); + + const modelWithEnumAndDescriptionData = fs.readFileSync("../../test_data/model_with_enum_and_description.bin") + const modelWithEnumAndDescription = generated.ModelWithEnumAndDescription.decode(new polyglot.Decoder(modelWithEnumAndDescriptionData)); + expect(modelWithEnumAndDescription).not.toBeNull(); + expect(modelWithEnumAndDescription).not.toBeUndefined(); + expect(modelWithEnumAndDescription?.enumField).toEqual(generated.GenericEnum.SecondValue); + + const modelWithEnumAccessorData = fs.readFileSync("../../test_data/model_with_enum_accessor.bin") + const modelWithEnumAccessor = generated.ModelWithEnumAccessor.decode(new polyglot.Decoder(modelWithEnumAccessorData)); + expect(modelWithEnumAccessor).not.toBeNull(); + expect(modelWithEnumAccessor).not.toBeUndefined(); + expect(modelWithEnumAccessor?.enumField).toEqual(generated.GenericEnum.SecondValue); + + const modelWithEnumAccessorAndDescriptionData = fs.readFileSync("../../test_data/model_with_enum_accessor_and_description.bin") + const modelWithEnumAccessorAndDescription = generated.ModelWithEnumAccessorAndDescription.decode(new polyglot.Decoder(modelWithEnumAccessorAndDescriptionData)); + expect(modelWithEnumAccessorAndDescription).not.toBeNull(); + expect(modelWithEnumAccessorAndDescription).not.toBeUndefined(); + expect(modelWithEnumAccessorAndDescription?.enumField).toEqual(generated.GenericEnum.SecondValue); + + const modelWithMultipleFieldsAccessorData = fs.readFileSync("../../test_data/model_with_multiple_fields_accessor.bin") + const modelWithMultipleFieldsAccessor = generated.ModelWithMultipleFieldsAccessor.decode(new polyglot.Decoder(modelWithMultipleFieldsAccessorData)); + expect(modelWithMultipleFieldsAccessor).not.toBeNull(); + expect(modelWithMultipleFieldsAccessor).not.toBeUndefined(); + expect(modelWithMultipleFieldsAccessor?.stringField).toEqual("HELLO"); + expect(modelWithMultipleFieldsAccessor?.int32Field).toEqual(42); + + const modelWithMultipleFieldsAccessorAndDescriptionData = fs.readFileSync("../../test_data/model_with_multiple_fields_accessor_and_description.bin") + const modelWithMultipleFieldsAccessorAndDescription = generated.ModelWithMultipleFieldsAccessorAndDescription.decode(new polyglot.Decoder(modelWithMultipleFieldsAccessorAndDescriptionData)); + expect(modelWithMultipleFieldsAccessorAndDescription).not.toBeNull(); + expect(modelWithMultipleFieldsAccessorAndDescription).not.toBeUndefined(); + expect(modelWithMultipleFieldsAccessorAndDescription?.stringField).toEqual("hello world"); + expect(modelWithMultipleFieldsAccessorAndDescription?.int32Field).toEqual(42); + + const modelWithEmbeddedModelsData = fs.readFileSync("../../test_data/model_with_embedded_models.bin") + const modelWithEmbeddedModels = generated.ModelWithEmbeddedModels.decode(new polyglot.Decoder(modelWithEmbeddedModelsData)); + expect(modelWithEmbeddedModels).not.toBeNull(); + expect(modelWithEmbeddedModels).not.toBeUndefined(); + expect(modelWithEmbeddedModels?.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModels?.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModels?.embeddedModelArrayWithMultipleFieldsAccessor).toHaveLength(1); + expect(modelWithEmbeddedModels?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.int32Field).toEqual(42); + expect(modelWithEmbeddedModels?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.stringField).toEqual("HELLO"); + + const modelWithEmbeddedModelsAndDescriptionData = fs.readFileSync("../../test_data/model_with_embedded_models_and_description.bin") + const modelWithEmbeddedModelsAndDescription = generated.ModelWithEmbeddedModelsAndDescription.decode(new polyglot.Decoder(modelWithEmbeddedModelsAndDescriptionData)); + expect(modelWithEmbeddedModelsAndDescription).not.toBeNull(); + expect(modelWithEmbeddedModelsAndDescription).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAndDescription?.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModelsAndDescription?.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor).toHaveLength(1); + expect(modelWithEmbeddedModelsAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.int32Field).toEqual(42); + expect(modelWithEmbeddedModelsAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.stringField).toEqual("HELLO"); + + const modelWithEmbeddedModelsAccessorData = fs.readFileSync("../../test_data/model_with_embedded_models_accessor.bin") + const modelWithEmbeddedModelsAccessor = generated.ModelWithEmbeddedModelsAccessor.decode(new polyglot.Decoder(modelWithEmbeddedModelsAccessorData)); + expect(modelWithEmbeddedModelsAccessor).not.toBeNull(); + expect(modelWithEmbeddedModelsAccessor).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAccessor?.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModelsAccessor?.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAccessor?.embeddedModelArrayWithMultipleFieldsAccessor).toHaveLength(1); + expect(modelWithEmbeddedModelsAccessor?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.int32Field).toEqual(42); + expect(modelWithEmbeddedModelsAccessor?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.stringField).toEqual("HELLO"); + + const modelWithEmbeddedModelsAccessorAndDescriptionData = fs.readFileSync("../../test_data/model_with_embedded_models_accessor_and_description.bin") + const modelWithEmbeddedModelsAccessorAndDescription = generated.ModelWithEmbeddedModelsAccessorAndDescription.decode(new polyglot.Decoder(modelWithEmbeddedModelsAccessorAndDescriptionData)); + expect(modelWithEmbeddedModelsAccessorAndDescription).not.toBeNull(); + expect(modelWithEmbeddedModelsAccessorAndDescription).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAccessorAndDescription?.embeddedEmptyModel).not.toBeNull(); + expect(modelWithEmbeddedModelsAccessorAndDescription?.embeddedEmptyModel).not.toBeUndefined(); + expect(modelWithEmbeddedModelsAccessorAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor).toHaveLength(1); + expect(modelWithEmbeddedModelsAccessorAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.int32Field).toEqual(42); + expect(modelWithEmbeddedModelsAccessorAndDescription?.embeddedModelArrayWithMultipleFieldsAccessor[0]?.stringField).toEqual("HELLO"); + + const modelWithAllFieldTypesData = fs.readFileSync("../../test_data/model_with_all_field_types.bin") + const modelWithAllFieldTypes = generated.ModelWithAllFieldTypes.decode(new polyglot.Decoder(modelWithAllFieldTypesData)); + expect(modelWithAllFieldTypes).not.toBeNull(); + expect(modelWithAllFieldTypes).not.toBeUndefined(); + expect(modelWithAllFieldTypes?.stringField).toEqual("hello world"); + expect(modelWithAllFieldTypes?.stringArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.stringArrayField[0]).toEqual("hello"); + expect(modelWithAllFieldTypes?.stringArrayField[1]).toEqual("world"); + expect(modelWithAllFieldTypes?.stringMapField.get("hello")).toEqual("world"); + expect(modelWithAllFieldTypes?.stringMapFieldEmbedded.get("hello")).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.int32Field).toEqual(42); + expect(modelWithAllFieldTypes?.int32ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.int32ArrayField[0]).toEqual(42); + expect(modelWithAllFieldTypes?.int32ArrayField[1]).toEqual(84); + expect(modelWithAllFieldTypes?.int32MapField.get(42)).toEqual(84); + expect(modelWithAllFieldTypes?.int32MapFieldEmbedded.get(42)).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.int64Field).toEqual(BigInt(100)); + expect(modelWithAllFieldTypes?.int64ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.int64ArrayField[0]).toEqual(BigInt(100)); + expect(modelWithAllFieldTypes?.int64ArrayField[1]).toEqual(BigInt(200)); + expect(modelWithAllFieldTypes?.int64MapField.get(BigInt(100))).toEqual(BigInt(200)); + expect(modelWithAllFieldTypes?.int64MapFieldEmbedded.get(BigInt(100))).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.uint32Field).toEqual(42); + expect(modelWithAllFieldTypes?.uint32ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.uint32ArrayField[0]).toEqual(42); + expect(modelWithAllFieldTypes?.uint32ArrayField[1]).toEqual(84); + expect(modelWithAllFieldTypes?.uint32MapField.get(42)).toEqual(84); + expect(modelWithAllFieldTypes?.uint32MapFieldEmbedded.get(42)).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.uint64Field).toEqual(BigInt(100)); + expect(modelWithAllFieldTypes?.uint64ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.uint64ArrayField[0]).toEqual(BigInt(100)); + expect(modelWithAllFieldTypes?.uint64ArrayField[1]).toEqual(BigInt(200)); + expect(modelWithAllFieldTypes?.uint64MapField.get(BigInt(100))).toEqual(BigInt(200)); + expect(modelWithAllFieldTypes?.uint64MapFieldEmbedded.get(BigInt(100))).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.float32Field).toEqual(42.0); + expect(modelWithAllFieldTypes?.float32ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.float32ArrayField[0]).toEqual(42.0); + expect(modelWithAllFieldTypes?.float32ArrayField[1]).toEqual(84.0); + + expect(modelWithAllFieldTypes?.float64Field).toEqual(100.0); + expect(modelWithAllFieldTypes?.float64ArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.float64ArrayField[0]).toEqual(100.0); + expect(modelWithAllFieldTypes?.float64ArrayField[1]).toEqual(200.0); + + expect(modelWithAllFieldTypes?.boolField).toEqual(false); + expect(modelWithAllFieldTypes?.boolArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.boolArrayField[0]).toEqual(true); + expect(modelWithAllFieldTypes?.boolArrayField[1]).toEqual(false); + + expect(modelWithAllFieldTypes?.bytesField).toEqual(Buffer.from([42, 84])); + expect(modelWithAllFieldTypes?.bytesArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.bytesArrayField[0]).toEqual(Buffer.from([42, 84])); + expect(modelWithAllFieldTypes?.bytesArrayField[1]).toEqual(Buffer.from([84, 42])); + + expect(modelWithAllFieldTypes?.enumField).toEqual(generated.GenericEnum.SecondValue); + expect(modelWithAllFieldTypes?.enumArrayField).toHaveLength(2); + expect(modelWithAllFieldTypes?.enumArrayField[0]).toEqual(generated.GenericEnum.FirstValue); + expect(modelWithAllFieldTypes?.enumArrayField[1]).toEqual(generated.GenericEnum.SecondValue); + expect(modelWithAllFieldTypes?.enumMapField.get(generated.GenericEnum.FirstValue)).toEqual("hello world"); + expect(modelWithAllFieldTypes?.enumMapFieldEmbedded.get(generated.GenericEnum.FirstValue)).toEqual(emptyModel); + + expect(modelWithAllFieldTypes?.modelArrayField).toHaveLength(2); +}); \ No newline at end of file diff --git a/integration/typescript_tests/signature/index.ts b/integration/typescript_tests/signature/index.ts new file mode 100644 index 00000000..16edddda --- /dev/null +++ b/integration/typescript_tests/signature/index.ts @@ -0,0 +1,83 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +/* eslint no-bitwise: off */ + +import { Signature as SignatureInterface, TYPESCRIPT_ADDRESS_OF, TYPESCRIPT_NEXT} from "@loopholelabs/scale-signature-interfaces"; +import { Decoder, Encoder, Kind } from "@loopholelabs/polyglot"; + +(global as any).WRITE_BUFFER = new Uint8Array().buffer; +(global as any).READ_BUFFER = new Uint8Array().buffer; + +export * from "./types"; +import { ModelWithAllFieldTypes } from "./types"; + +const hash = "3a592aa345d412faa2e6285ee048ca2ab5aa64b0caa2f9ca67b2c1e0792101e5" + +// Write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +export function Write(ctx?: ModelWithAllFieldTypes): number[] { + const enc = new Encoder(); + if (typeof ctx === "undefined") { + enc.null(); + } else { + ctx.encode(enc); + } + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +export function Read(): ModelWithAllFieldTypes | undefined { + const dec = new Decoder(new Uint8Array((global as any).READ_BUFFER)); + return ModelWithAllFieldTypes.decode(dec); +} + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +export function Error(err: Error): number[] { + const enc = new Encoder(); + enc.error(err); + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +export function Resize(size: number): number { + (global as any).READ_BUFFER = new Uint8Array(size).buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + return addrof((global as any).READ_BUFFER); +} + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +export function Hash(): number[] { + const enc = new Encoder(); + enc.string(hash); + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Next calls the next function in the Scale Function Chain +export function Next(ctx?: ModelWithAllFieldTypes): ModelWithAllFieldTypes | undefined { + const [ptr, len] = Write(ctx); + const next = (global as any)[TYPESCRIPT_NEXT]; + next([ptr, len]); + return Read(); +} diff --git a/integration/typescript_tests/signature/jest.config.js b/integration/typescript_tests/signature/jest.config.js new file mode 100644 index 00000000..b413e106 --- /dev/null +++ b/integration/typescript_tests/signature/jest.config.js @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node', +}; \ No newline at end of file diff --git a/integration/typescript_tests/signature/package-lock.json b/integration/typescript_tests/signature/package-lock.json new file mode 100644 index 00000000..278f9401 --- /dev/null +++ b/integration/typescript_tests/signature/package-lock.json @@ -0,0 +1,3740 @@ +{ + "name": "local-example-latest-guest", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "local-example-latest-guest", + "version": "0.1.0", + "dependencies": { + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", + "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.11.tgz", + "integrity": "sha512-lh7RJrtPdhibbxndr6/xx0w8+CVlY5FJZiaSz908Fpy+G0xkBFTvwLcKJFF4PJxVfGhVWNebikpWGnOoC71juQ==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", + "@babel/helper-compilation-targets": "^7.22.10", + "@babel/helper-module-transforms": "^7.22.9", + "@babel/helpers": "^7.22.11", + "@babel/parser": "^7.22.11", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.11", + "@babel/types": "^7.22.11", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/@babel/generator": { + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.10.tgz", + "integrity": "sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.10", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.10.tgz", + "integrity": "sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.22.9", + "@babel/helper-validator-option": "^7.22.5", + "browserslist": "^4.21.9", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", + "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", + "dev": true, + "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.6", + "@babel/helper-validator-identifier": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.11.tgz", + "integrity": "sha512-vyOXC8PBWaGc5h7GMsNx68OH33cypkEDJCHvYVVgVbbxJDROYVtexSk0gK5iCF1xNjRIN2s8ai7hwkWDq5szWg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.11", + "@babel/types": "^7.22.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", + "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.22.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.14.tgz", + "integrity": "sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz", + "integrity": "sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", + "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.11.tgz", + "integrity": "sha512-mzAenteTfomcB7mfPtyi+4oe5BZ6MXxWcn4CX+h4IRJ+OOGXBrWU6jDQavkQI9Vuc5P+donFabBfFCcmWka9lQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", + "@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.6", + "@babel/parser": "^7.22.11", + "@babel/types": "^7.22.11", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.11.tgz", + "integrity": "sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.6.4.tgz", + "integrity": "sha512-wNK6gC0Ha9QeEPSkeJedQuTQqxZYnDPuDcDhVuVatRvMkL4D0VTvFVZj+Yuh6caG2aOfzkUZ36KtCmLNtR02hw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.6.4.tgz", + "integrity": "sha512-U/vq5ccNTSVgYH7mHnodHmCffGWHJnz/E1BEWlLuK5pM4FZmGfBn/nrJGLjUsSmyx3otCeqc1T31F4y08AMDLg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.4", + "@jest/reporters": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.6.3", + "jest-config": "^29.6.4", + "jest-haste-map": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-resolve-dependencies": "^29.6.4", + "jest-runner": "^29.6.4", + "jest-runtime": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", + "jest-watcher": "^29.6.4", + "micromatch": "^4.0.4", + "pretty-format": "^29.6.3", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.6.4.tgz", + "integrity": "sha512-sQ0SULEjA1XUTHmkBRl7A1dyITM9yb1yb3ZNKPX3KlTd6IG7mWUe3e2yfExtC2Zz1Q+mMckOLHmL/qLiuQJrBQ==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.6.4.tgz", + "integrity": "sha512-Warhsa7d23+3X5bLbrbYvaehcgX5TLYhI03JKoedTiI8uJU4IhqYBWF7OSSgUyz4IgLpUYPkK0AehA5/fRclAA==", + "dev": true, + "dependencies": { + "expect": "^29.6.4", + "jest-snapshot": "^29.6.4" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.6.4.tgz", + "integrity": "sha512-FEhkJhqtvBwgSpiTrocquJCdXPsyvNKcl/n7A3u7X4pVoF4bswm11c9d4AV+kfq2Gpv/mM8x7E7DsRvH+djkrg==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.6.4.tgz", + "integrity": "sha512-6UkCwzoBK60edXIIWb0/KWkuj7R7Qq91vVInOe3De6DSpaEiqjKcJw4F7XUet24Wupahj9J6PlR09JqJ5ySDHw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.6.3", + "jest-mock": "^29.6.3", + "jest-util": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.6.4.tgz", + "integrity": "sha512-wVIn5bdtjlChhXAzVXavcY/3PEjf4VqM174BM3eGL5kMxLiZD5CLnbmkEyA1Dwh9q8XjP6E8RwjBsY/iCWrWsA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/expect": "^29.6.4", + "@jest/types": "^29.6.3", + "jest-mock": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.6.4.tgz", + "integrity": "sha512-sxUjWxm7QdchdrD3NfWKrL8FBsortZeibSJv4XLjESOOjSUOkjQcb0ZHJwfhEGIvBvTluTzfG2yZWZhkrXJu8g==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", + "jest-worker": "^29.6.4", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.6.4.tgz", + "integrity": "sha512-uQ1C0AUEN90/dsyEirgMLlouROgSY+Wc/JanVVk0OiUKa5UFh7sJpMEM3aoUBAz2BRNvUJ8j3d294WFuRxSyOQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.6.4.tgz", + "integrity": "sha512-E84M6LbpcRq3fT4ckfKs9ryVanwkaIB0Ws9bw3/yP4seRLg/VaCZ/LgW0MCq5wwk4/iP/qnilD41aj2fsw2RMg==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.6.4", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.4", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.6.4.tgz", + "integrity": "sha512-8thgRSiXUqtr/pPGY/OsyHuMjGyhVnWrFAwoxmIemlBuiMyU1WFs0tXoNxzcr4A4uErs/ABre76SGmrr5ab/AA==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.4", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.6.3", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", + "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@loopholelabs/polyglot": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@loopholelabs/polyglot/-/polyglot-1.1.3.tgz", + "integrity": "sha512-PLkzZbmZJsXlmE7uTmuMwfl7QbCnafq1ibfvDE+KPrf02R72WRIml1HAVc8oAd8+bRJoEIWXjAGSN4RrxL7fyQ==" + }, + "node_modules/@loopholelabs/scale-signature-interfaces": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature-interfaces/-/scale-signature-interfaces-0.1.7.tgz", + "integrity": "sha512-P/yBDDcN3yCoNVilNDJdwqdnbt0sQbGoJfnGrc/aTtiWq8RDNWu2IIxcB4tde6HT3A5SQaF9LCJQmbY0RyNelA==" + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@types/babel__core": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", + "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", + "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", + "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", + "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", + "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", + "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.4", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.4.tgz", + "integrity": "sha512-PhglGmhWeD46FYOVLt3X7TiWjzwuVGW9wG/4qocPevXMjCmrIc5b6db9WjeGE4QYVpUAWMDv3v0IiBwObY289A==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/node": { + "version": "20.5.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.8.tgz", + "integrity": "sha512-eajsR9aeljqNhK028VG0Wuw+OaY5LLxYmxeoXynIoE6jannr9/Ucd1LL0hSSoafk5LTYG+FfqsyGt81Q6Zkybw==", + "dev": true + }, + "node_modules/@types/stack-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", + "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.24", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/babel-jest": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.4.tgz", + "integrity": "sha512-meLj23UlSLddj6PC+YTOFRgDAtjnZom8w/ACsrx0gtPtv5cJZk0A5Unk5bV4wixD7XaPCN1fQvpww8czkZURmw==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.6.4", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.21.10", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.10.tgz", + "integrity": "sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001517", + "electron-to-chromium": "^1.4.477", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.11" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001525", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001525.tgz", + "integrity": "sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", + "dev": true + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", + "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", + "dev": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.508", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.508.tgz", + "integrity": "sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.4.tgz", + "integrity": "sha512-F2W2UyQ8XYyftHT57dtfg8Ue3X5qLgm2sSug0ivvLRH/VKNRL/pDxg/TH7zVzbQB0tu80clNFy6LU7OS/VSEKA==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "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" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-core-module": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.0.tgz", + "integrity": "sha512-x58orMzEVfzPUKqlbLd1hXCnySCxKdDKa6Rjg97CwuLLRI4g3FHTdnExu1OqffVFay6zeMW+T6/DowFLndWnIw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.4.tgz", + "integrity": "sha512-tEFhVQFF/bzoYV1YuGyzLPZ6vlPrdfvDmmAxudA1dLEuiztqg2Rkx20vkKY32xiDROcD2KXlgZ7Cu8RPeEHRKw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.6.4", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.6.4" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.6.3.tgz", + "integrity": "sha512-G5wDnElqLa4/c66ma5PG9eRjE342lIbF6SUnTJi26C3J28Fv2TVY2rOyKB9YGbSA5ogwevgmxc4j4aVjrEK6Yg==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.6.3", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.6.4.tgz", + "integrity": "sha512-YXNrRyntVUgDfZbjXWBMPslX1mQ8MrSG0oM/Y06j9EYubODIyHWP8hMUbjbZ19M3M+zamqEur7O80HODwACoJw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/expect": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-runtime": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", + "p-limit": "^3.1.0", + "pretty-format": "^29.6.3", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.6.4.tgz", + "integrity": "sha512-+uMCQ7oizMmh8ZwRfZzKIEszFY9ksjjEQnTEMTaL7fYiL3Kw4XhqT9bYh+A4DQKUb67hZn2KbtEnDuHvcgK4pQ==", + "dev": true, + "dependencies": { + "@jest/core": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "import-local": "^3.0.2", + "jest-config": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", + "prompts": "^2.0.1", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.6.4.tgz", + "integrity": "sha512-JWohr3i9m2cVpBumQFv2akMEnFEPVOh+9L2xIBJhJ0zOaci2ZXuKJj0tgMKQCBZAKA09H049IR4HVS/43Qb19A==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.6.4", + "@jest/types": "^29.6.3", + "babel-jest": "^29.6.4", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.6.4", + "jest-environment-node": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-runner": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.6.3", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.4.tgz", + "integrity": "sha512-9F48UxR9e4XOEZvoUXEHSWY4qC4zERJaOfrbBg9JpbJOO43R1vN76REt/aMGZoY6GD5g84nnJiBIVlscegefpw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.6.3.tgz", + "integrity": "sha512-2+H+GOTQBEm2+qFSQ7Ma+BvyV+waiIFxmZF5LdpBsAEjWX8QYjSCa4FrkIYtbfXUJJJnFCYrOtt6TZ+IAiTjBQ==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.6.3.tgz", + "integrity": "sha512-KoXfJ42k8cqbkfshW7sSHcdfnv5agDdHCPA87ZBdmHP+zJstTJc0ttQaJ/x7zK6noAL76hOuTIJ6ZkQRS5dcyg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.6.3", + "pretty-format": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.6.4.tgz", + "integrity": "sha512-i7SbpH2dEIFGNmxGCpSc2w9cA4qVD+wfvg2ZnfQ7XVrKL0NA5uDVBIiGH8SR4F0dKEv/0qI5r+aDomDf04DpEQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/fake-timers": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.6.3", + "jest-util": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.6.4.tgz", + "integrity": "sha512-12Ad+VNTDHxKf7k+M65sviyynRoZYuL1/GTuhEVb8RYsNSNln71nANRb/faSyWvx0j+gHcivChXHIoMJrGYjog==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.6.3", + "jest-worker": "^29.6.4", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.6.3.tgz", + "integrity": "sha512-0kfbESIHXYdhAdpLsW7xdwmYhLf1BRu4AA118/OxFm0Ho1b2RcTmO4oF6aAMaxpxdxnJ3zve2rgwzNBD4Zbm7Q==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.6.4.tgz", + "integrity": "sha512-KSzwyzGvK4HcfnserYqJHYi7sZVqdREJ9DMPAKVbS98JsIAvumihaNUbjrWw0St7p9IY7A9UskCW5MYlGmBQFQ==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.6.4", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.6.3.tgz", + "integrity": "sha512-FtzaEEHzjDpQp51HX4UMkPZjy46ati4T5pEMyM6Ik48ztu4T9LQplZ6OsimHx7EuM9dfEh5HJa6D3trEftu3dA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.6.3", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.6.3.tgz", + "integrity": "sha512-Z7Gs/mOyTSR4yPsaZ72a/MtuK6RnC3JYqWONe48oLaoEcYwEDxqvbXz85G4SJrm2Z5Ar9zp6MiHF4AlFlRM4Pg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.6.4.tgz", + "integrity": "sha512-fPRq+0vcxsuGlG0O3gyoqGTAxasagOxEuyoxHeyxaZbc9QNek0AmJWSkhjlMG+mTsj+8knc/mWb3fXlRNVih7Q==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.4", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.6.4.tgz", + "integrity": "sha512-7+6eAmr1ZBF3vOAJVsfLj1QdqeXG+WYhidfLHBRZqGN24MFRIiKG20ItpLw2qRAsW/D2ZUUmCNf6irUr/v6KHA==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.6.4" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.6.4.tgz", + "integrity": "sha512-SDaLrMmtVlQYDuG0iSPYLycG8P9jLI+fRm8AF/xPKhYDB2g6xDWjXBrR5M8gEWsK6KVFlebpZ4QsrxdyIX1Jaw==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.4", + "@jest/environment": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.6.3", + "jest-environment-node": "^29.6.4", + "jest-haste-map": "^29.6.4", + "jest-leak-detector": "^29.6.3", + "jest-message-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-runtime": "^29.6.4", + "jest-util": "^29.6.3", + "jest-watcher": "^29.6.4", + "jest-worker": "^29.6.4", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.6.4.tgz", + "integrity": "sha512-s/QxMBLvmwLdchKEjcLfwzP7h+jsHvNEtxGP5P+Fl1FMaJX2jMiIqe4rJw4tFprzCwuSvVUo9bn0uj4gNRXsbA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/fake-timers": "^29.6.4", + "@jest/globals": "^29.6.4", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-mock": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.6.4.tgz", + "integrity": "sha512-VC1N8ED7+4uboUKGIDsbvNAZb6LakgIPgAF4RSpF13dN6YaMokfRqO+BaqK4zIh6X3JffgwbzuGqDEjHm/MrvA==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.6.4", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", + "natural-compare": "^1.4.0", + "pretty-format": "^29.6.3", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-snapshot/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/jest-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", + "integrity": "sha512-QUjna/xSy4B32fzcKTSz1w7YYzgiHrjjJjevdRf61HYk998R5vVMMNmrHESYZVDS5DSWs+1srPLPKxXPkeSDOA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.6.3.tgz", + "integrity": "sha512-e7KWZcAIX+2W1o3cHfnqpGajdCs1jSM3DkXjGeLSNmCazv1EeI1ggTeK5wdZhF+7N+g44JI2Od3veojoaumlfg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.6.4.tgz", + "integrity": "sha512-oqUWvx6+On04ShsT00Ir9T4/FvBeEh2M9PTubgITPxDa739p4hoQweWPRGyYeaojgT0xTpZKF0Y/rSY1UgMxvQ==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.6.3", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.4.tgz", + "integrity": "sha512-6dpvFV4WjcWbDVGgHTWo/aupl8/LbBx2NSKfiwqf79xC/yeJjKHT1+StcKy/2KTmW16hE68ccKVOtXf+WZGz7Q==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.6.3", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.3.tgz", + "integrity": "sha512-ZsBgjVhFAj5KeK+nHfF1305/By3lechHQSMWCTl8iHSbfOm2TN5nHEtFc/+W7fAyUeCs2n5iow72gld4gW0xDw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pure-rand": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.2.tgz", + "integrity": "sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, + "node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", + "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-to-istanbul": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", + "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/integration/typescript_tests/signature/package.json b/integration/typescript_tests/signature/package.json new file mode 100644 index 00000000..44759593 --- /dev/null +++ b/integration/typescript_tests/signature/package.json @@ -0,0 +1,20 @@ +{ + "name": "local-example-latest-guest", + "version": "0.1.0", + "source": "index.ts", + "types": "index.d.ts", + "scripts": { + "test": "jest index.test.ts" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3", + "@types/node": "^20.3.1" + }, + "dependencies": { + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7" + } +} diff --git a/integration/typescript_tests/signature/tsconfig.json b/integration/typescript_tests/signature/tsconfig.json new file mode 100644 index 00000000..34668965 --- /dev/null +++ b/integration/typescript_tests/signature/tsconfig.json @@ -0,0 +1,109 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/integration/typescript_tests/signature/types.d.ts b/integration/typescript_tests/signature/types.d.ts new file mode 100644 index 00000000..3c761f1d --- /dev/null +++ b/integration/typescript_tests/signature/types.d.ts @@ -0,0 +1,595 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export declare enum GenericEnum { + FirstValue = 0, + + SecondValue = 1, + + DefaultValue = 2, + +}export declare class EmptyModel { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModel | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// EmptyModelWithDescription: Test Description +export declare class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModelWithDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithSingleStringField { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringField | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithSingleStringFieldAndDescription: Test Description +export declare class ModelWithSingleStringFieldAndDescription { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithSingleInt32Field { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +export declare class ModelWithSingleInt32FieldAndDescription { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithMultipleFields { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFields | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithMultipleFieldsAndDescription: Test Description +export declare class ModelWithMultipleFieldsAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEnum { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnum | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEnumAndDescription: Test Description +export declare class ModelWithEnumAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEnumAccessor { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get enumField(): GenericEnum; + + set enumField(val: GenericEnum); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEnumAccessorAndDescription: Test Description +export declare class ModelWithEnumAccessorAndDescription { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get enumField(): GenericEnum; + + set enumField(val: GenericEnum); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithMultipleFieldsAccessor { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get stringField(): string; + + set stringField(val: string); + + get int32Field(): number; + + set int32Field (val: number); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +export declare class ModelWithMultipleFieldsAccessorAndDescription { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get stringField(): string; + + set stringField(val: string); + + get int32Field(): number; + + set int32Field (val: number); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEmbeddedModels { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +export declare class ModelWithEmbeddedModelsAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithEmbeddedModelsAccessor { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get embeddedEmptyModel(): EmptyModel | undefined; + + set embeddedEmptyModel(val: EmptyModel | undefined); + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array; + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +export declare class ModelWithEmbeddedModelsAccessorAndDescription { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + get embeddedEmptyModel(): EmptyModel | undefined; + + set embeddedEmptyModel(val: EmptyModel | undefined); + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array; + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + +export declare class ModelWithAllFieldTypes { + modelField: EmptyModel | undefined; + + modelArrayField: Array; + + stringField: string; + + stringArrayField: string[]; + + stringMapField: Map; + + stringMapFieldEmbedded: Map; + + int32Field: number; + + int32ArrayField: number[]; + + int32MapField: Map; + + int32MapFieldEmbedded: Map; + + int64Field: bigint; + + int64ArrayField: bigint[]; + + int64MapField: Map; + + int64MapFieldEmbedded: Map; + + uint32Field: number; + + uint32ArrayField: number[]; + + uint32MapField: Map; + + uint32MapFieldEmbedded: Map; + + uint64Field: bigint; + + uint64ArrayField: bigint[]; + + uint64MapField: Map; + + uint64MapFieldEmbedded: Map; + + float32Field: number; + + float32ArrayField: number[]; + + float64Field: number; + + float64ArrayField: number[]; + + enumField: GenericEnum; + + enumArrayField: GenericEnum[]; + + enumMapField: Map; + + enumMapFieldEmbedded: Map; + + bytesField: Uint8Array; + + bytesArrayField: Uint8Array[]; + + boolField: boolean; + + boolArrayField: boolean[]; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); +} + diff --git a/integration/typescript_tests/signature/types.js b/integration/typescript_tests/signature/types.js new file mode 100644 index 00000000..8283a9bf --- /dev/null +++ b/integration/typescript_tests/signature/types.js @@ -0,0 +1,1321 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); +var stdin_exports = {}; +__export(stdin_exports, { + EmptyModel: () => EmptyModel, + EmptyModelWithDescription: () => EmptyModelWithDescription, + GenericEnum: () => GenericEnum, + ModelWithAllFieldTypes: () => ModelWithAllFieldTypes, + ModelWithEmbeddedModels: () => ModelWithEmbeddedModels, + ModelWithEmbeddedModelsAccessor: () => ModelWithEmbeddedModelsAccessor, + ModelWithEmbeddedModelsAccessorAndDescription: () => ModelWithEmbeddedModelsAccessorAndDescription, + ModelWithEmbeddedModelsAndDescription: () => ModelWithEmbeddedModelsAndDescription, + ModelWithEnum: () => ModelWithEnum, + ModelWithEnumAccessor: () => ModelWithEnumAccessor, + ModelWithEnumAccessorAndDescription: () => ModelWithEnumAccessorAndDescription, + ModelWithEnumAndDescription: () => ModelWithEnumAndDescription, + ModelWithMultipleFields: () => ModelWithMultipleFields, + ModelWithMultipleFieldsAccessor: () => ModelWithMultipleFieldsAccessor, + ModelWithMultipleFieldsAccessorAndDescription: () => ModelWithMultipleFieldsAccessorAndDescription, + ModelWithMultipleFieldsAndDescription: () => ModelWithMultipleFieldsAndDescription, + ModelWithSingleInt32Field: () => ModelWithSingleInt32Field, + ModelWithSingleInt32FieldAndDescription: () => ModelWithSingleInt32FieldAndDescription, + ModelWithSingleStringField: () => ModelWithSingleStringField, + ModelWithSingleStringFieldAndDescription: () => ModelWithSingleStringFieldAndDescription +}); +module.exports = __toCommonJS(stdin_exports); +var import_polyglot = require("@loopholelabs/polyglot"); +var GenericEnum = /* @__PURE__ */ ((GenericEnum2) => { + GenericEnum2[GenericEnum2["FirstValue"] = 0] = "FirstValue"; + GenericEnum2[GenericEnum2["SecondValue"] = 1] = "SecondValue"; + GenericEnum2[GenericEnum2["DefaultValue"] = 2] = "DefaultValue"; + return GenericEnum2; +})(GenericEnum || {}); +class EmptyModel { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + /** + * @throws {Error} + */ + encode(encoder) { + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new EmptyModel(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + /** + * @throws {Error} + */ + encode(encoder) { + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new EmptyModelWithDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleStringField { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleStringField(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleStringFieldAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleStringFieldAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleInt32Field { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleInt32Field(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithSingleInt32FieldAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithSingleInt32FieldAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFields { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFields(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnum { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnum(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = 2 /* DefaultValue */; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAccessor { + #enumField; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = 2 /* DefaultValue */; + } + } + get enumField() { + return this.#enumField; + } + set enumField(val) { + this.#enumField = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.#enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEnumAccessorAndDescription { + #enumField; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = 2 /* DefaultValue */; + } + } + get enumField() { + return this.#enumField; + } + set enumField(val) { + this.#enumField = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.uint32(this.#enumField); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEnumAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAccessor { + #stringField; + #int32Field; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + get stringField() { + return this.#stringField; + } + set stringField(val) { + if (!/^[a-zA-Z0-9]*$/.test(val)) { + throw new Error("value must match ^[a-zA-Z0-9]*$"); + } + if (val.length > 20 || val.length < 1) { + throw new Error("length must be between 1 and 20"); + } + val = val.toUpperCase(); + this.#stringField = val; + } + get int32Field() { + return this.#int32Field; + } + set int32Field(val) { + if (val > 100 || val < 0) { + throw new Error("value must be between 0 and 100"); + } + this.#int32Field = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithMultipleFieldsAccessorAndDescription { + #stringField; + #int32Field; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + get stringField() { + return this.#stringField; + } + set stringField(val) { + this.#stringField = val; + } + get int32Field() { + return this.#int32Field; + } + set int32Field(val) { + this.#int32Field = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithMultipleFieldsAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModels { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModels(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAndDescription { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAccessor { + #embeddedEmptyModel; + #embeddedModelArrayWithMultipleFieldsAccessor; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + get embeddedEmptyModel() { + return this.#embeddedEmptyModel; + } + set embeddedEmptyModel(val) { + this.#embeddedEmptyModel = val; + } + get embeddedModelArrayWithMultipleFieldsAccessor() { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + set EmbeddedModelArrayWithMultipleFieldsAccessor(val) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAccessor(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithEmbeddedModelsAccessorAndDescription { + #embeddedEmptyModel; + #embeddedModelArrayWithMultipleFieldsAccessor; + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(import_polyglot.Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + get embeddedEmptyModel() { + return this.#embeddedEmptyModel; + } + set embeddedEmptyModel(val) { + this.#embeddedEmptyModel = val; + } + get embeddedModelArrayWithMultipleFieldsAccessor() { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + set EmbeddedModelArrayWithMultipleFieldsAccessor(val) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, import_polyglot.Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithEmbeddedModelsAccessorAndDescription(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +class ModelWithAllFieldTypes { + /** + * @throws {Error} + */ + constructor(decoder) { + if (decoder) { + let err; + try { + err = decoder.error(); + } catch (_) { + } + if (typeof err !== "undefined") { + throw err; + } + this.modelField = EmptyModel.decode(decoder); + const modelArrayFieldSize = decoder.array(import_polyglot.Kind.Any); + this.modelArrayField = new Array(modelArrayFieldSize); + for (let i = 0; i < modelArrayFieldSize; i += 1) { + const x = EmptyModel.decode(decoder); + if (typeof x !== "undefined") { + this.modelArrayField[i] = x; + } + } + this.stringField = decoder.string(); + const stringArrayFieldSize = decoder.array(import_polyglot.Kind.String); + this.stringArrayField = new Array(stringArrayFieldSize); + for (let i = 0; i < stringArrayFieldSize; i += 1) { + this.stringArrayField[i] = decoder.string(); + } + this.stringMapField = /* @__PURE__ */ new Map(); + let stringMapFieldSize = decoder.map(import_polyglot.Kind.String, import_polyglot.Kind.String); + for (let i = 0; i < stringMapFieldSize; i++) { + let key = decoder.string(); + let val = decoder.string(); + this.stringMapField.set(key, val); + } + this.stringMapFieldEmbedded = /* @__PURE__ */ new Map(); + let stringMapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.String, import_polyglot.Kind.Any); + for (let i = 0; i < stringMapFieldEmbeddedSize; i++) { + let key = decoder.string(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.stringMapFieldEmbedded.set(key, val); + } + } + this.int32Field = decoder.int32(); + const int32ArrayFieldSize = decoder.array(import_polyglot.Kind.Int32); + this.int32ArrayField = new Array(int32ArrayFieldSize); + for (let i = 0; i < int32ArrayFieldSize; i += 1) { + this.int32ArrayField[i] = decoder.int32(); + } + this.int32MapField = /* @__PURE__ */ new Map(); + let int32MapFieldSize = decoder.map(import_polyglot.Kind.Int32, import_polyglot.Kind.Int32); + for (let i = 0; i < int32MapFieldSize; i++) { + let key = decoder.int32(); + let val = decoder.int32(); + this.int32MapField.set(key, val); + } + this.int32MapFieldEmbedded = /* @__PURE__ */ new Map(); + let int32MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Int32, import_polyglot.Kind.Any); + for (let i = 0; i < int32MapFieldEmbeddedSize; i++) { + let key = decoder.int32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int32MapFieldEmbedded.set(key, val); + } + } + this.int64Field = decoder.int64(); + const int64ArrayFieldSize = decoder.array(import_polyglot.Kind.Int64); + this.int64ArrayField = new Array(int64ArrayFieldSize); + for (let i = 0; i < int64ArrayFieldSize; i += 1) { + this.int64ArrayField[i] = decoder.int64(); + } + this.int64MapField = /* @__PURE__ */ new Map(); + let int64MapFieldSize = decoder.map(import_polyglot.Kind.Int64, import_polyglot.Kind.Int64); + for (let i = 0; i < int64MapFieldSize; i++) { + let key = decoder.int64(); + let val = decoder.int64(); + this.int64MapField.set(key, val); + } + this.int64MapFieldEmbedded = /* @__PURE__ */ new Map(); + let int64MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Int64, import_polyglot.Kind.Any); + for (let i = 0; i < int64MapFieldEmbeddedSize; i++) { + let key = decoder.int64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int64MapFieldEmbedded.set(key, val); + } + } + this.uint32Field = decoder.uint32(); + const uint32ArrayFieldSize = decoder.array(import_polyglot.Kind.Uint32); + this.uint32ArrayField = new Array(uint32ArrayFieldSize); + for (let i = 0; i < uint32ArrayFieldSize; i += 1) { + this.uint32ArrayField[i] = decoder.uint32(); + } + this.uint32MapField = /* @__PURE__ */ new Map(); + let uint32MapFieldSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Uint32); + for (let i = 0; i < uint32MapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.uint32(); + this.uint32MapField.set(key, val); + } + this.uint32MapFieldEmbedded = /* @__PURE__ */ new Map(); + let uint32MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint32MapFieldEmbedded.set(key, val); + } + } + this.uint64Field = decoder.uint64(); + const uint64ArrayFieldSize = decoder.array(import_polyglot.Kind.Uint64); + this.uint64ArrayField = new Array(uint64ArrayFieldSize); + for (let i = 0; i < uint64ArrayFieldSize; i += 1) { + this.uint64ArrayField[i] = decoder.uint64(); + } + this.uint64MapField = /* @__PURE__ */ new Map(); + let uint64MapFieldSize = decoder.map(import_polyglot.Kind.Uint64, import_polyglot.Kind.Uint64); + for (let i = 0; i < uint64MapFieldSize; i++) { + let key = decoder.uint64(); + let val = decoder.uint64(); + this.uint64MapField.set(key, val); + } + this.uint64MapFieldEmbedded = /* @__PURE__ */ new Map(); + let uint64MapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint64, import_polyglot.Kind.Any); + for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) { + let key = decoder.uint64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint64MapFieldEmbedded.set(key, val); + } + } + this.float32Field = decoder.float32(); + const float32ArrayFieldSize = decoder.array(import_polyglot.Kind.Float32); + this.float32ArrayField = new Array(float32ArrayFieldSize); + for (let i = 0; i < float32ArrayFieldSize; i += 1) { + this.float32ArrayField[i] = decoder.float32(); + } + this.float64Field = decoder.float64(); + const float64ArrayFieldSize = decoder.array(import_polyglot.Kind.Float64); + this.float64ArrayField = new Array(float64ArrayFieldSize); + for (let i = 0; i < float64ArrayFieldSize; i += 1) { + this.float64ArrayField[i] = decoder.float64(); + } + this.enumField = decoder.uint32(); + const enumArrayFieldSize = decoder.array(import_polyglot.Kind.Uint32); + this.enumArrayField = new Array(enumArrayFieldSize); + for (let i = 0; i < enumArrayFieldSize; i += 1) { + this.enumArrayField[i] = decoder.uint32(); + } + this.enumMapField = /* @__PURE__ */ new Map(); + let enumMapFieldSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.String); + for (let i = 0; i < enumMapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.string(); + this.enumMapField.set(key, val); + } + this.enumMapFieldEmbedded = /* @__PURE__ */ new Map(); + let enumMapFieldEmbeddedSize = decoder.map(import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + for (let i = 0; i < enumMapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.enumMapFieldEmbedded.set(key, val); + } + } + this.bytesField = decoder.uint8Array(); + const bytesArrayFieldSize = decoder.array(import_polyglot.Kind.Uint8Array); + this.bytesArrayField = new Array(bytesArrayFieldSize); + for (let i = 0; i < bytesArrayFieldSize; i += 1) { + this.bytesArrayField[i] = decoder.uint8Array(); + } + this.boolField = decoder.boolean(); + const boolArrayFieldSize = decoder.array(import_polyglot.Kind.Boolean); + this.boolArrayField = new Array(boolArrayFieldSize); + for (let i = 0; i < boolArrayFieldSize; i += 1) { + this.boolArrayField[i] = decoder.boolean(); + } + } else { + this.modelField = new EmptyModel(); + this.modelArrayField = []; + this.stringField = "DefaultValue"; + this.stringArrayField = []; + this.stringMapField = /* @__PURE__ */ new Map(); + this.stringMapFieldEmbedded = /* @__PURE__ */ new Map(); + this.int32Field = 32; + this.int32ArrayField = []; + this.int32MapField = /* @__PURE__ */ new Map(); + this.int32MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.int64Field = 64n; + this.int64ArrayField = []; + this.int64MapField = /* @__PURE__ */ new Map(); + this.int64MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.uint32Field = 32; + this.uint32ArrayField = []; + this.uint32MapField = /* @__PURE__ */ new Map(); + this.uint32MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.uint64Field = 64n; + this.uint64ArrayField = []; + this.uint64MapField = /* @__PURE__ */ new Map(); + this.uint64MapFieldEmbedded = /* @__PURE__ */ new Map(); + this.float32Field = 32.32; + this.float32ArrayField = []; + this.float64Field = 64.64; + this.float64ArrayField = []; + this.enumField = 2 /* DefaultValue */; + this.enumArrayField = []; + this.enumMapField = /* @__PURE__ */ new Map(); + this.enumMapFieldEmbedded = /* @__PURE__ */ new Map(); + this.bytesField = new Uint8Array(512); + this.bytesArrayField = []; + this.boolField = true; + this.boolArrayField = []; + } + } + /** + * @throws {Error} + */ + encode(encoder) { + if (typeof this.modelField === "undefined") { + encoder.null(); + } else { + this.modelField.encode(encoder); + } + const modelArrayFieldLength = this.modelArrayField.length; + encoder.array(modelArrayFieldLength, import_polyglot.Kind.Any); + for (let i = 0; i < modelArrayFieldLength; i += 1) { + const el = this.modelArrayField[i]; + el.encode(encoder); + } + encoder.string(this.stringField); + const stringArrayFieldLength = this.stringArrayField.length; + encoder.array(stringArrayFieldLength, import_polyglot.Kind.String); + for (let i = 0; i < stringArrayFieldLength; i += 1) { + encoder.string(this.stringArrayField[i]); + } + encoder.map(this.stringMapField.size, import_polyglot.Kind.String, import_polyglot.Kind.String); + this.stringMapField.forEach((val, key) => { + encoder.string(key); + encoder.string(val); + }); + encoder.map(this.stringMapFieldEmbedded.size, import_polyglot.Kind.String, import_polyglot.Kind.Any); + this.stringMapFieldEmbedded.forEach((val, key) => { + encoder.string(key); + val.encode(encoder); + }); + encoder.int32(this.int32Field); + const int32ArrayFieldLength = this.int32ArrayField.length; + encoder.array(int32ArrayFieldLength, import_polyglot.Kind.Int32); + for (let i = 0; i < int32ArrayFieldLength; i += 1) { + encoder.int32(this.int32ArrayField[i]); + } + encoder.map(this.int32MapField.size, import_polyglot.Kind.Int32, import_polyglot.Kind.Int32); + this.int32MapField.forEach((val, key) => { + encoder.int32(key); + encoder.int32(val); + }); + encoder.map(this.int32MapFieldEmbedded.size, import_polyglot.Kind.Int32, import_polyglot.Kind.Any); + this.int32MapFieldEmbedded.forEach((val, key) => { + encoder.int32(key); + val.encode(encoder); + }); + encoder.int64(this.int64Field); + const int64ArrayFieldLength = this.int64ArrayField.length; + encoder.array(int64ArrayFieldLength, import_polyglot.Kind.Int64); + for (let i = 0; i < int64ArrayFieldLength; i += 1) { + encoder.int64(this.int64ArrayField[i]); + } + encoder.map(this.int64MapField.size, import_polyglot.Kind.Int64, import_polyglot.Kind.Int64); + this.int64MapField.forEach((val, key) => { + encoder.int64(key); + encoder.int64(val); + }); + encoder.map(this.int64MapFieldEmbedded.size, import_polyglot.Kind.Int64, import_polyglot.Kind.Any); + this.int64MapFieldEmbedded.forEach((val, key) => { + encoder.int64(key); + val.encode(encoder); + }); + encoder.uint32(this.uint32Field); + const uint32ArrayFieldLength = this.uint32ArrayField.length; + encoder.array(uint32ArrayFieldLength, import_polyglot.Kind.Uint32); + for (let i = 0; i < uint32ArrayFieldLength; i += 1) { + encoder.uint32(this.uint32ArrayField[i]); + } + encoder.map(this.uint32MapField.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Uint32); + this.uint32MapField.forEach((val, key) => { + encoder.uint32(key); + encoder.uint32(val); + }); + encoder.map(this.uint32MapFieldEmbedded.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + this.uint32MapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint64(this.uint64Field); + const uint64ArrayFieldLength = this.uint64ArrayField.length; + encoder.array(uint64ArrayFieldLength, import_polyglot.Kind.Uint64); + for (let i = 0; i < uint64ArrayFieldLength; i += 1) { + encoder.uint64(this.uint64ArrayField[i]); + } + encoder.map(this.uint64MapField.size, import_polyglot.Kind.Uint64, import_polyglot.Kind.Uint64); + this.uint64MapField.forEach((val, key) => { + encoder.uint64(key); + encoder.uint64(val); + }); + encoder.map(this.uint64MapFieldEmbedded.size, import_polyglot.Kind.Uint64, import_polyglot.Kind.Any); + this.uint64MapFieldEmbedded.forEach((val, key) => { + encoder.uint64(key); + val.encode(encoder); + }); + encoder.float32(this.float32Field); + const float32ArrayFieldLength = this.float32ArrayField.length; + encoder.array(float32ArrayFieldLength, import_polyglot.Kind.Float32); + for (let i = 0; i < float32ArrayFieldLength; i += 1) { + encoder.float32(this.float32ArrayField[i]); + } + encoder.float64(this.float64Field); + const float64ArrayFieldLength = this.float64ArrayField.length; + encoder.array(float64ArrayFieldLength, import_polyglot.Kind.Float64); + for (let i = 0; i < float64ArrayFieldLength; i += 1) { + encoder.float64(this.float64ArrayField[i]); + } + encoder.uint32(this.enumField); + const enumArrayFieldLength = this.enumArrayField.length; + encoder.array(enumArrayFieldLength, import_polyglot.Kind.Uint32); + for (let i = 0; i < enumArrayFieldLength; i += 1) { + encoder.uint32(this.enumArrayField[i]); + } + encoder.map(this.enumMapField.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.String); + this.enumMapField.forEach((val, key) => { + encoder.uint32(key); + encoder.string(val); + }); + encoder.map(this.enumMapFieldEmbedded.size, import_polyglot.Kind.Uint32, import_polyglot.Kind.Any); + this.enumMapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint8Array(this.bytesField); + const bytesArrayFieldLength = this.bytesArrayField.length; + encoder.array(bytesArrayFieldLength, import_polyglot.Kind.Uint8Array); + for (let i = 0; i < bytesArrayFieldLength; i += 1) { + encoder.uint8Array(this.bytesArrayField[i]); + } + encoder.boolean(this.boolField); + const boolArrayFieldLength = this.boolArrayField.length; + encoder.array(boolArrayFieldLength, import_polyglot.Kind.Boolean); + for (let i = 0; i < boolArrayFieldLength; i += 1) { + encoder.boolean(this.boolArrayField[i]); + } + } + /** + * @throws {Error} + */ + static decode(decoder) { + if (decoder.null()) { + return void 0; + } + return new ModelWithAllFieldTypes(decoder); + } + /** + * @throws {Error} + */ + static encode_undefined(encoder) { + encoder.null(); + } +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/integration/typescript_tests/signature/types.js.map b/integration/typescript_tests/signature/types.js.map new file mode 100644 index 00000000..9cb6da99 --- /dev/null +++ b/integration/typescript_tests/signature/types.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sources": [""], + "sourceRoot": "types.js", + "sourcesContent": ["// Code generated by scale-signature 0.4.0, DO NOT EDIT.\n// output: local-example-latest-guest\n\nimport { Encoder, Decoder, Kind } from \"@loopholelabs/polyglot\"\n\nexport enum GenericEnum {\n FirstValue = 0,\n\n SecondValue = 1,\n\n DefaultValue = 2,\n\n}\nexport class EmptyModel {\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n } else {\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): EmptyModel | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new EmptyModel(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// EmptyModelWithDescription: Test Description\nexport class EmptyModelWithDescription {\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n } else {\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): EmptyModelWithDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new EmptyModelWithDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithSingleStringField {\n stringField: string;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n } else {\n this.stringField = \"DefaultValue\";\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleStringField | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleStringField(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithSingleStringFieldAndDescription: Test Description\nexport class ModelWithSingleStringFieldAndDescription {\n stringField: string;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n } else {\n this.stringField = \"DefaultValue\";\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleStringFieldAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithSingleInt32Field {\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.int32Field = decoder.int32();\n } else {\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleInt32Field(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithSingleInt32FieldAndDescription: Test Description\nexport class ModelWithSingleInt32FieldAndDescription {\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.int32Field = decoder.int32();\n } else {\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithSingleInt32FieldAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithMultipleFields {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFields | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFields(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithMultipleFieldsAndDescription: Test Description\nexport class ModelWithMultipleFieldsAndDescription {\n stringField: string;\n\n int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.stringField = decoder.string();\n this.int32Field = decoder.int32();\n } else {\n this.stringField = \"DefaultValue\";\n this.int32Field = 32;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.stringField);\n encoder.int32(this.int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEnum {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnum | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnum(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEnumAndDescription: Test Description\nexport class ModelWithEnumAndDescription {\n enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.enumField = decoder.uint32();\n } else {\n this.enumField = GenericEnum.DefaultValue;\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEnumAccessor {\n #enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#enumField = decoder.uint32();\n } else {\n this.#enumField = GenericEnum.DefaultValue;\n }\n }\n\n get enumField(): GenericEnum {\n return this.#enumField;\n }\n\n set enumField(val: GenericEnum) {\n this.#enumField = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.#enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEnumAccessorAndDescription: Test Description\nexport class ModelWithEnumAccessorAndDescription {\n #enumField: GenericEnum;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#enumField = decoder.uint32();\n } else {\n this.#enumField = GenericEnum.DefaultValue;\n }\n }\n\n get enumField(): GenericEnum {\n return this.#enumField;\n }\n\n set enumField(val: GenericEnum) {\n this.#enumField = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.uint32(this.#enumField);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEnumAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithMultipleFieldsAccessor {\n #stringField: string;\n\n #int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#stringField = decoder.string();\n this.#int32Field = decoder.int32();\n } else {\n this.#stringField = \"DefaultValue\";\n this.#int32Field = 32;\n }\n }\n\n get stringField(): string {\n return this.#stringField;\n }\n\n set stringField(val: string) {\n if (!/^[a-zA-Z0-9]*$/.test(val)) {\n throw new Error(\"value must match ^[a-zA-Z0-9]*$\");\n }\n if (val.length > 20 || val.length < 1) {\n throw new Error(\"length must be between 1 and 20\");\n }\n val = val.toUpperCase();\n this.#stringField = val;\n }\n\n get int32Field(): number {\n return this.#int32Field;\n }\n\n set int32Field (val: number) {\n if (val > 100 || val < 0) {\n throw new Error(\"value must be between 0 and 100\");\n }\n this.#int32Field = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.#stringField);\n encoder.int32(this.#int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithMultipleFieldsAccessorAndDescription: Test Description\nexport class ModelWithMultipleFieldsAccessorAndDescription {\n #stringField: string;\n\n #int32Field: number;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#stringField = decoder.string();\n this.#int32Field = decoder.int32();\n } else {\n this.#stringField = \"DefaultValue\";\n this.#int32Field = 32;\n }\n }\n\n get stringField(): string {\n return this.#stringField;\n }\n\n set stringField(val: string) {\n this.#stringField = val;\n }\n\n get int32Field(): number {\n return this.#int32Field;\n }\n\n set int32Field (val: number) {\n this.#int32Field = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n encoder.string(this.#stringField);\n encoder.int32(this.#int32Field);\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithMultipleFieldsAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEmbeddedModels {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModels(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEmbeddedModelsAndDescription: Test Description\nexport class ModelWithEmbeddedModelsAndDescription {\n embeddedEmptyModel: EmptyModel | undefined;\n\n embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.embeddedEmptyModel = new EmptyModel();\n this.embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithEmbeddedModelsAccessor {\n #embeddedEmptyModel: EmptyModel | undefined;\n\n #embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.#embeddedEmptyModel = new EmptyModel();\n this.#embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n get embeddedEmptyModel(): EmptyModel | undefined {\n return this.#embeddedEmptyModel;\n }\n\n set embeddedEmptyModel(val: EmptyModel | undefined) {\n this.#embeddedEmptyModel = val;\n }\n\n get embeddedModelArrayWithMultipleFieldsAccessor(): Array {\n return this.#embeddedModelArrayWithMultipleFieldsAccessor;\n }\n\n set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) {\n this.#embeddedModelArrayWithMultipleFieldsAccessor = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.#embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.#embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAccessor(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n// ModelWithEmbeddedModelsAccessorAndDescription: Test Description\nexport class ModelWithEmbeddedModelsAccessorAndDescription {\n #embeddedEmptyModel: EmptyModel | undefined;\n\n #embeddedModelArrayWithMultipleFieldsAccessor: Array;\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.#embeddedEmptyModel = EmptyModel.decode(decoder);\n const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any);\n this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) {\n const x = ModelWithMultipleFieldsAccessor.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x;\n }\n }\n } else {\n this.#embeddedEmptyModel = new EmptyModel();\n this.#embeddedModelArrayWithMultipleFieldsAccessor = [];\n }\n }\n\n get embeddedEmptyModel(): EmptyModel | undefined {\n return this.#embeddedEmptyModel;\n }\n\n set embeddedEmptyModel(val: EmptyModel | undefined) {\n this.#embeddedEmptyModel = val;\n }\n\n get embeddedModelArrayWithMultipleFieldsAccessor(): Array {\n return this.#embeddedModelArrayWithMultipleFieldsAccessor;\n }\n\n set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) {\n this.#embeddedModelArrayWithMultipleFieldsAccessor = val;\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.#embeddedEmptyModel === \"undefined\") {\n encoder.null();\n } else {\n this.#embeddedEmptyModel.encode(encoder);\n }\n const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length;\n encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any);\n for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) {\n const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i];\n el.encode(encoder);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithEmbeddedModelsAccessorAndDescription(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\nexport class ModelWithAllFieldTypes {\n modelField: EmptyModel | undefined;\n\n modelArrayField: Array;\n\n stringField: string;\n\n stringArrayField: string[];\n\n stringMapField: Map;\n\n stringMapFieldEmbedded: Map;\n\n int32Field: number;\n\n int32ArrayField: number[];\n\n int32MapField: Map;\n\n int32MapFieldEmbedded: Map;\n\n int64Field: bigint;\n\n int64ArrayField: bigint[];\n\n int64MapField: Map;\n\n int64MapFieldEmbedded: Map;\n\n uint32Field: number;\n\n uint32ArrayField: number[];\n\n uint32MapField: Map;\n\n uint32MapFieldEmbedded: Map;\n\n uint64Field: bigint;\n\n uint64ArrayField: bigint[];\n\n uint64MapField: Map;\n\n uint64MapFieldEmbedded: Map;\n\n float32Field: number;\n\n float32ArrayField: number[];\n\n float64Field: number;\n\n float64ArrayField: number[];\n\n enumField: GenericEnum;\n\n enumArrayField: GenericEnum[];\n\n enumMapField: Map;\n\n enumMapFieldEmbedded: Map;\n\n bytesField: Uint8Array;\n\n bytesArrayField: Uint8Array[];\n\n boolField: boolean;\n\n boolArrayField: boolean[];\n\n /**\n * @throws {Error}\n */\n constructor (decoder?: Decoder) {\n if (decoder) {\n let err: Error | undefined;\n try {\n err = decoder.error();\n } catch (_) {}\n if (typeof err !== \"undefined\") {\n throw err;\n }\n this.modelField = EmptyModel.decode(decoder);\n const modelArrayFieldSize = decoder.array(Kind.Any);\n this.modelArrayField = new Array(modelArrayFieldSize);\n for (let i = 0; i < modelArrayFieldSize; i += 1) {\n const x = EmptyModel.decode(decoder);\n if (typeof x !== \"undefined\") {\n this.modelArrayField[i] = x;\n }\n }\n this.stringField = decoder.string();\n const stringArrayFieldSize = decoder.array(Kind.String);\n this.stringArrayField = new Array(stringArrayFieldSize);\n for (let i = 0; i < stringArrayFieldSize; i += 1) {\n this.stringArrayField[i] = decoder.string();\n }\n this.stringMapField = new Map();\n let stringMapFieldSize = decoder.map(Kind.String, Kind.String);\n for (let i = 0; i < stringMapFieldSize; i++) {\n let key = decoder.string();\n let val = decoder.string();\n this.stringMapField.set(key, val);\n }\n this.stringMapFieldEmbedded = new Map();\n let stringMapFieldEmbeddedSize = decoder.map(Kind.String, Kind.Any);\n for (let i = 0; i < stringMapFieldEmbeddedSize; i++) {\n let key = decoder.string();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.stringMapFieldEmbedded.set(key, val);\n }\n }\n this.int32Field = decoder.int32();\n const int32ArrayFieldSize = decoder.array(Kind.Int32);\n this.int32ArrayField = new Array(int32ArrayFieldSize);\n for (let i = 0; i < int32ArrayFieldSize; i += 1) {\n this.int32ArrayField[i] = decoder.int32();\n }\n this.int32MapField = new Map();\n let int32MapFieldSize = decoder.map(Kind.Int32, Kind.Int32);\n for (let i = 0; i < int32MapFieldSize; i++) {\n let key = decoder.int32();\n let val = decoder.int32();\n this.int32MapField.set(key, val);\n }\n this.int32MapFieldEmbedded = new Map();\n let int32MapFieldEmbeddedSize = decoder.map(Kind.Int32, Kind.Any);\n for (let i = 0; i < int32MapFieldEmbeddedSize; i++) {\n let key = decoder.int32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.int32MapFieldEmbedded.set(key, val);\n }\n }\n this.int64Field = decoder.int64();\n const int64ArrayFieldSize = decoder.array(Kind.Int64);\n this.int64ArrayField = new Array(int64ArrayFieldSize);\n for (let i = 0; i < int64ArrayFieldSize; i += 1) {\n this.int64ArrayField[i] = decoder.int64();\n }\n this.int64MapField = new Map();\n let int64MapFieldSize = decoder.map(Kind.Int64, Kind.Int64);\n for (let i = 0; i < int64MapFieldSize; i++) {\n let key = decoder.int64();\n let val = decoder.int64();\n this.int64MapField.set(key, val);\n }\n this.int64MapFieldEmbedded = new Map();\n let int64MapFieldEmbeddedSize = decoder.map(Kind.Int64, Kind.Any);\n for (let i = 0; i < int64MapFieldEmbeddedSize; i++) {\n let key = decoder.int64();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.int64MapFieldEmbedded.set(key, val);\n }\n }\n this.uint32Field = decoder.uint32();\n const uint32ArrayFieldSize = decoder.array(Kind.Uint32);\n this.uint32ArrayField = new Array(uint32ArrayFieldSize);\n for (let i = 0; i < uint32ArrayFieldSize; i += 1) {\n this.uint32ArrayField[i] = decoder.uint32();\n }\n this.uint32MapField = new Map();\n let uint32MapFieldSize = decoder.map(Kind.Uint32, Kind.Uint32);\n for (let i = 0; i < uint32MapFieldSize; i++) {\n let key = decoder.uint32();\n let val = decoder.uint32();\n this.uint32MapField.set(key, val);\n }\n this.uint32MapFieldEmbedded = new Map();\n let uint32MapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any);\n for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) {\n let key = decoder.uint32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.uint32MapFieldEmbedded.set(key, val);\n }\n }\n this.uint64Field = decoder.uint64();\n const uint64ArrayFieldSize = decoder.array(Kind.Uint64);\n this.uint64ArrayField = new Array(uint64ArrayFieldSize);\n for (let i = 0; i < uint64ArrayFieldSize; i += 1) {\n this.uint64ArrayField[i] = decoder.uint64();\n }\n this.uint64MapField = new Map();\n let uint64MapFieldSize = decoder.map(Kind.Uint64, Kind.Uint64);\n for (let i = 0; i < uint64MapFieldSize; i++) {\n let key = decoder.uint64();\n let val = decoder.uint64();\n this.uint64MapField.set(key, val);\n }\n this.uint64MapFieldEmbedded = new Map();\n let uint64MapFieldEmbeddedSize = decoder.map(Kind.Uint64, Kind.Any);\n for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) {\n let key = decoder.uint64();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.uint64MapFieldEmbedded.set(key, val);\n }\n }\n this.float32Field = decoder.float32();\n const float32ArrayFieldSize = decoder.array(Kind.Float32);\n this.float32ArrayField = new Array(float32ArrayFieldSize);\n for (let i = 0; i < float32ArrayFieldSize; i += 1) {\n this.float32ArrayField[i] = decoder.float32();\n }\n this.float64Field = decoder.float64();\n const float64ArrayFieldSize = decoder.array(Kind.Float64);\n this.float64ArrayField = new Array(float64ArrayFieldSize);\n for (let i = 0; i < float64ArrayFieldSize; i += 1) {\n this.float64ArrayField[i] = decoder.float64();\n }\n this.enumField = decoder.uint32();\n const enumArrayFieldSize = decoder.array(Kind.Uint32);\n this.enumArrayField = new Array(enumArrayFieldSize);\n for (let i = 0; i < enumArrayFieldSize; i += 1) {\n this.enumArrayField[i] = decoder.uint32();\n }\n this.enumMapField = new Map();\n let enumMapFieldSize = decoder.map(Kind.Uint32, Kind.String);\n for (let i = 0; i < enumMapFieldSize; i++) {\n let key = decoder.uint32();\n let val = decoder.string();\n this.enumMapField.set(key, val);\n }\n this.enumMapFieldEmbedded = new Map();\n let enumMapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any);\n for (let i = 0; i < enumMapFieldEmbeddedSize; i++) {\n let key = decoder.uint32();\n let val = EmptyModel.decode(decoder);\n if (typeof val !== \"undefined\") {\n this.enumMapFieldEmbedded.set(key, val);\n }\n }\n this.bytesField = decoder.uint8Array();\n const bytesArrayFieldSize = decoder.array(Kind.Uint8Array);\n this.bytesArrayField = new Array(bytesArrayFieldSize);\n for (let i = 0; i < bytesArrayFieldSize; i += 1) {\n this.bytesArrayField[i] = decoder.uint8Array();\n }\n this.boolField = decoder.boolean();\n const boolArrayFieldSize = decoder.array(Kind.Boolean);\n this.boolArrayField = new Array(boolArrayFieldSize);\n for (let i = 0; i < boolArrayFieldSize; i += 1) {\n this.boolArrayField[i] = decoder.boolean();\n }\n } else {\n this.modelField = new EmptyModel();\n this.modelArrayField = [];\n this.stringField = \"DefaultValue\";\n this.stringArrayField = [];\n this.stringMapField = new Map();\n this.stringMapFieldEmbedded = new Map();\n this.int32Field = 32;\n this.int32ArrayField = [];\n this.int32MapField = new Map();\n this.int32MapFieldEmbedded = new Map();\n this.int64Field = 64n;\n this.int64ArrayField = [];\n this.int64MapField = new Map();\n this.int64MapFieldEmbedded = new Map();\n this.uint32Field = 32;\n this.uint32ArrayField = [];\n this.uint32MapField = new Map();\n this.uint32MapFieldEmbedded = new Map();\n this.uint64Field = 64n;\n this.uint64ArrayField = [];\n this.uint64MapField = new Map();\n this.uint64MapFieldEmbedded = new Map();\n this.float32Field = 32.32;\n this.float32ArrayField = [];\n this.float64Field = 64.64;\n this.float64ArrayField = [];\n this.enumField = GenericEnum.DefaultValue;\n this.enumArrayField = [];\n this.enumMapField = new Map();\n this.enumMapFieldEmbedded = new Map();\n this.bytesField = new Uint8Array(512);\n this.bytesArrayField = [];\n this.boolField = true;\n this.boolArrayField = [];\n }\n }\n\n /**\n * @throws {Error}\n */\n encode (encoder: Encoder) {\n if (typeof this.modelField === \"undefined\") {\n encoder.null();\n } else {\n this.modelField.encode(encoder);\n }\n const modelArrayFieldLength = this.modelArrayField.length;\n encoder.array(modelArrayFieldLength, Kind.Any);\n for (let i = 0; i < modelArrayFieldLength; i += 1) {\n const el = this.modelArrayField[i];\n el.encode(encoder);\n }\n encoder.string(this.stringField);\n const stringArrayFieldLength = this.stringArrayField.length;\n encoder.array(stringArrayFieldLength, Kind.String);\n for (let i = 0; i < stringArrayFieldLength; i += 1) {\n encoder.string(this.stringArrayField[i]);\n }\n encoder.map(this.stringMapField.size, Kind.String, Kind.String);\n this.stringMapField.forEach((val, key) => {\n encoder.string(key);\n encoder.string(val);\n });\n encoder.map(this.stringMapFieldEmbedded.size, Kind.String, Kind.Any);\n this.stringMapFieldEmbedded.forEach((val, key) => {\n encoder.string(key);\n val.encode(encoder);\n });\n encoder.int32(this.int32Field);\n const int32ArrayFieldLength = this.int32ArrayField.length;\n encoder.array(int32ArrayFieldLength, Kind.Int32);\n for (let i = 0; i < int32ArrayFieldLength; i += 1) {\n encoder.int32(this.int32ArrayField[i]);\n }\n encoder.map(this.int32MapField.size, Kind.Int32, Kind.Int32);\n this.int32MapField.forEach((val, key) => {\n encoder.int32(key);\n encoder.int32(val);\n });\n encoder.map(this.int32MapFieldEmbedded.size, Kind.Int32, Kind.Any);\n this.int32MapFieldEmbedded.forEach((val, key) => {\n encoder.int32(key);\n val.encode(encoder);\n });\n encoder.int64(this.int64Field);\n const int64ArrayFieldLength = this.int64ArrayField.length;\n encoder.array(int64ArrayFieldLength, Kind.Int64);\n for (let i = 0; i < int64ArrayFieldLength; i += 1) {\n encoder.int64(this.int64ArrayField[i]);\n }\n encoder.map(this.int64MapField.size, Kind.Int64, Kind.Int64);\n this.int64MapField.forEach((val, key) => {\n encoder.int64(key);\n encoder.int64(val);\n });\n encoder.map(this.int64MapFieldEmbedded.size, Kind.Int64, Kind.Any);\n this.int64MapFieldEmbedded.forEach((val, key) => {\n encoder.int64(key);\n val.encode(encoder);\n });\n encoder.uint32(this.uint32Field);\n const uint32ArrayFieldLength = this.uint32ArrayField.length;\n encoder.array(uint32ArrayFieldLength, Kind.Uint32);\n for (let i = 0; i < uint32ArrayFieldLength; i += 1) {\n encoder.uint32(this.uint32ArrayField[i]);\n }\n encoder.map(this.uint32MapField.size, Kind.Uint32, Kind.Uint32);\n this.uint32MapField.forEach((val, key) => {\n encoder.uint32(key);\n encoder.uint32(val);\n });\n encoder.map(this.uint32MapFieldEmbedded.size, Kind.Uint32, Kind.Any);\n this.uint32MapFieldEmbedded.forEach((val, key) => {\n encoder.uint32(key);\n val.encode(encoder);\n });\n encoder.uint64(this.uint64Field);\n const uint64ArrayFieldLength = this.uint64ArrayField.length;\n encoder.array(uint64ArrayFieldLength, Kind.Uint64);\n for (let i = 0; i < uint64ArrayFieldLength; i += 1) {\n encoder.uint64(this.uint64ArrayField[i]);\n }\n encoder.map(this.uint64MapField.size, Kind.Uint64, Kind.Uint64);\n this.uint64MapField.forEach((val, key) => {\n encoder.uint64(key);\n encoder.uint64(val);\n });\n encoder.map(this.uint64MapFieldEmbedded.size, Kind.Uint64, Kind.Any);\n this.uint64MapFieldEmbedded.forEach((val, key) => {\n encoder.uint64(key);\n val.encode(encoder);\n });\n encoder.float32(this.float32Field);\n const float32ArrayFieldLength = this.float32ArrayField.length;\n encoder.array(float32ArrayFieldLength, Kind.Float32);\n for (let i = 0; i < float32ArrayFieldLength; i += 1) {\n encoder.float32(this.float32ArrayField[i]);\n }\n encoder.float64(this.float64Field);\n const float64ArrayFieldLength = this.float64ArrayField.length;\n encoder.array(float64ArrayFieldLength, Kind.Float64);\n for (let i = 0; i < float64ArrayFieldLength; i += 1) {\n encoder.float64(this.float64ArrayField[i]);\n }\n encoder.uint32(this.enumField);\n const enumArrayFieldLength = this.enumArrayField.length;\n encoder.array(enumArrayFieldLength, Kind.Uint32);\n for (let i = 0; i < enumArrayFieldLength; i += 1) {\n encoder.uint32(this.enumArrayField[i]);\n }\n encoder.map(this.enumMapField.size, Kind.Uint32, Kind.String);\n this.enumMapField.forEach((val, key) => {\n encoder.uint32(key);\n encoder.string(val);\n });\n encoder.map(this.enumMapFieldEmbedded.size, Kind.Uint32, Kind.Any);\n this.enumMapFieldEmbedded.forEach((val, key) => {\n encoder.uint32(key);\n val.encode(encoder);\n });\n encoder.uint8Array(this.bytesField);\n const bytesArrayFieldLength = this.bytesArrayField.length;\n encoder.array(bytesArrayFieldLength, Kind.Uint8Array);\n for (let i = 0; i < bytesArrayFieldLength; i += 1) {\n encoder.uint8Array(this.bytesArrayField[i]);\n }\n encoder.boolean(this.boolField);\n const boolArrayFieldLength = this.boolArrayField.length;\n encoder.array(boolArrayFieldLength, Kind.Boolean);\n for (let i = 0; i < boolArrayFieldLength; i += 1) {\n encoder.boolean(this.boolArrayField[i]);\n }\n }\n\n /**\n * @throws {Error}\n */\n static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined {\n if (decoder.null()) {\n return undefined\n }\n return new ModelWithAllFieldTypes(decoder);\n }\n\n /**\n * @throws {Error}\n */\n static encode_undefined (encoder: Encoder) {\n encoder.null();\n }\n}\n\n"], + "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAuC;AAEhC,IAAK,cAAL,kBAAKA,iBAAL;AACL,EAAAA,0BAAA,gBAAa,KAAb;AAEA,EAAAA,0BAAA,iBAAc,KAAd;AAEA,EAAAA,0BAAA,kBAAe,KAAf;AALU,SAAAA;AAAA,GAAA;AAQL,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA,EAItB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA0C;AACvD,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,WAAW,OAAO;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAIrC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AAAA,IACF,OAAO;AAAA,IACP;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAyD;AACtE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,0BAA0B,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,2BAA2B;AAAA;AAAA;AAAA;AAAA,EAMtC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAAA,IACpC,OAAO;AACL,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA0D;AACvE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,2BAA2B,OAAO;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,yCAAyC;AAAA;AAAA;AAAA;AAAA,EAMpD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAAA,IACpC,OAAO;AACL,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAwE;AACrF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,yCAAyC,OAAO;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAMrC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAyD;AACtE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,0BAA0B,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,wCAAwC;AAAA;AAAA;AAAA;AAAA,EAMnD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuE;AACpF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wCAAwC,OAAO;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuD;AACpE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wBAAwB,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,sCAAsC;AAAA;AAAA;AAAA;AAAA,EAQjD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,WAAK,aAAa,QAAQ,MAAM;AAAA,IAClC,OAAO;AACL,WAAK,cAAc;AACnB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,WAAW;AAC/B,YAAQ,MAAM,KAAK,UAAU;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqE;AAClF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sCAAsC,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA,EAMzB,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6C;AAC1D,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,cAAc,OAAO;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA,EAMvC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,YAAY,QAAQ,OAAO;AAAA,IAClC,OAAO;AACL,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA2D;AACxE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,4BAA4B,OAAO;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,sBAAsB;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,OAAO;AAAA,IACnC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,IAAI,YAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,UAAU,KAAkB;AAC9B,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,UAAU;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqD;AAClE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sBAAsB,OAAO;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,oCAAoC;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,QAAQ,OAAO;AAAA,IACnC,OAAO;AACL,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,IAAI,YAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,UAAU,KAAkB;AAC9B,SAAK,aAAa;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,UAAU;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAmE;AAChF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,oCAAoC,OAAO;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,gCAAgC;AAAA,EAC3C;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,eAAe,QAAQ,OAAO;AACnC,WAAK,cAAc,QAAQ,MAAM;AAAA,IACnC,OAAO;AACL,WAAK,eAAe;AACpB,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,IAAI,cAAsB;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,YAAY,KAAa;AAC3B,QAAI,CAAC,iBAAiB,KAAK,GAAG,GAAG;AAC/B,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,QAAI,IAAI,SAAS,MAAM,IAAI,SAAS,GAAG;AACrC,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,UAAM,IAAI,YAAY;AACtB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,WAAY,KAAa;AAC3B,QAAI,MAAM,OAAO,MAAM,GAAG;AACxB,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AACA,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,YAAY;AAChC,YAAQ,MAAM,KAAK,WAAW;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA+D;AAC5E,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gCAAgC,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,8CAA8C;AAAA,EACzD;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,eAAe,QAAQ,OAAO;AACnC,WAAK,cAAc,QAAQ,MAAM;AAAA,IACnC,OAAO;AACL,WAAK,eAAe;AACpB,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,IAAI,cAAsB;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,YAAY,KAAa;AAC3B,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,WAAY,KAAa;AAC3B,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,YAAQ,OAAO,KAAK,YAAY;AAChC,YAAQ,MAAM,KAAK,WAAW;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6E;AAC1F,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,8CAA8C,OAAO;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA,EAQnC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAuD;AACpE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,wBAAwB,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,sCAAsC;AAAA;AAAA;AAAA;AAAA,EAQjD,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,qBAAqB,WAAW,OAAO,OAAO;AACnD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,+CAA+C,IAAI,MAAM,gDAAgD;AAC9G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,6CAA6C,CAAC,IAAI;AAAA,QACzD;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,qBAAqB,IAAI,WAAW;AACzC,WAAK,+CAA+C,CAAC;AAAA,IACvD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,uBAAuB,aAAa;AAClD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,mBAAmB,OAAO,OAAO;AAAA,IACxC;AACA,UAAM,qDAAqD,KAAK,6CAA6C;AAC7G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,6CAA6C,CAAC;AAC9D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAqE;AAClF,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,sCAAsC,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,gCAAgC;AAAA,EAC3C;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,sBAAsB,WAAW,OAAO,OAAO;AACpD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,gDAAgD,IAAI,MAAM,gDAAgD;AAC/G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,8CAA8C,CAAC,IAAI;AAAA,QAC1D;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,sBAAsB,IAAI,WAAW;AAC1C,WAAK,gDAAgD,CAAC;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,IAAI,qBAA6C;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,mBAAmB,KAA6B;AAClD,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,IAAI,+CAAuF;AACzF,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,6CAA6C,KAA6C;AAC5F,SAAK,gDAAgD;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,wBAAwB,aAAa;AACnD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,oBAAoB,OAAO,OAAO;AAAA,IACzC;AACA,UAAM,qDAAqD,KAAK,8CAA8C;AAC9G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,8CAA8C,CAAC;AAC/D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA+D;AAC5E,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gCAAgC,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAGO,MAAM,8CAA8C;AAAA,EACzD;AAAA,EAEA;AAAA;AAAA;AAAA;AAAA,EAKA,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,sBAAsB,WAAW,OAAO,OAAO;AACpD,YAAM,mDAAmD,QAAQ,MAAM,qBAAK,GAAG;AAC/E,WAAK,gDAAgD,IAAI,MAAM,gDAAgD;AAC/G,eAAS,IAAI,GAAG,IAAI,kDAAkD,KAAK,GAAG;AAC5E,cAAM,IAAI,gCAAgC,OAAO,OAAO;AACxD,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,8CAA8C,CAAC,IAAI;AAAA,QAC1D;AAAA,MACF;AAAA,IACF,OAAO;AACL,WAAK,sBAAsB,IAAI,WAAW;AAC1C,WAAK,gDAAgD,CAAC;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,IAAI,qBAA6C;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,mBAAmB,KAA6B;AAClD,SAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,IAAI,+CAAuF;AACzF,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,6CAA6C,KAA6C;AAC5F,SAAK,gDAAgD;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,wBAAwB,aAAa;AACnD,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,oBAAoB,OAAO,OAAO;AAAA,IACzC;AACA,UAAM,qDAAqD,KAAK,8CAA8C;AAC9G,YAAQ,MAAM,oDAAoD,qBAAK,GAAG;AAC1E,aAAS,IAAI,GAAG,IAAI,oDAAoD,KAAK,GAAG;AAC9E,YAAM,KAAK,KAAK,8CAA8C,CAAC;AAC/D,SAAG,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAA6E;AAC1F,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,8CAA8C,OAAO;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;AAEO,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAwElC,YAAa,SAAmB;AAC9B,QAAI,SAAS;AACX,UAAI;AACJ,UAAI;AACF,cAAM,QAAQ,MAAM;AAAA,MACtB,SAAS,GAAG;AAAA,MAAC;AACb,UAAI,OAAO,QAAQ,aAAa;AAC9B,cAAM;AAAA,MACR;AACA,WAAK,aAAa,WAAW,OAAO,OAAO;AAC3C,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,GAAG;AAClD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,cAAM,IAAI,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,MAAM,aAAa;AAC5B,eAAK,gBAAgB,CAAC,IAAI;AAAA,QAC5B;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,MAAM;AAChC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,KAAK;AACpD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,MAAM;AAAA,MAC1C;AACA,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,UAAI,oBAAoB,QAAQ,IAAI,qBAAK,OAAO,qBAAK,KAAK;AAC1D,eAAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,QAAQ,MAAM;AACxB,aAAK,cAAc,IAAI,KAAK,GAAG;AAAA,MACjC;AACA,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,UAAI,4BAA4B,QAAQ,IAAI,qBAAK,OAAO,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,2BAA2B,KAAK;AAClD,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,sBAAsB,IAAI,KAAK,GAAG;AAAA,QACzC;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,MAAM;AAChC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,KAAK;AACpD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,MAAM;AAAA,MAC1C;AACA,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,UAAI,oBAAoB,QAAQ,IAAI,qBAAK,OAAO,qBAAK,KAAK;AAC1D,eAAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,QAAQ,MAAM;AACxB,aAAK,cAAc,IAAI,KAAK,GAAG;AAAA,MACjC;AACA,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,UAAI,4BAA4B,QAAQ,IAAI,qBAAK,OAAO,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,2BAA2B,KAAK;AAClD,YAAI,MAAM,QAAQ,MAAM;AACxB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,sBAAsB,IAAI,KAAK,GAAG;AAAA,QACzC;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,cAAc,QAAQ,OAAO;AAClC,YAAM,uBAAuB,QAAQ,MAAM,qBAAK,MAAM;AACtD,WAAK,mBAAmB,IAAI,MAAM,oBAAoB;AACtD,eAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,aAAK,iBAAiB,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC5C;AACA,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,UAAI,qBAAqB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC7D,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK;AAC3C,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,eAAe,IAAI,KAAK,GAAG;AAAA,MAClC;AACA,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,UAAI,6BAA6B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAClE,eAAS,IAAI,GAAG,IAAI,4BAA4B,KAAK;AACnD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,uBAAuB,IAAI,KAAK,GAAG;AAAA,QAC1C;AAAA,MACF;AACA,WAAK,eAAe,QAAQ,QAAQ;AACpC,YAAM,wBAAwB,QAAQ,MAAM,qBAAK,OAAO;AACxD,WAAK,oBAAoB,IAAI,MAAM,qBAAqB;AACxD,eAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,aAAK,kBAAkB,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC9C;AACA,WAAK,eAAe,QAAQ,QAAQ;AACpC,YAAM,wBAAwB,QAAQ,MAAM,qBAAK,OAAO;AACxD,WAAK,oBAAoB,IAAI,MAAM,qBAAqB;AACxD,eAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,aAAK,kBAAkB,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC9C;AACA,WAAK,YAAY,QAAQ,OAAO;AAChC,YAAM,qBAAqB,QAAQ,MAAM,qBAAK,MAAM;AACpD,WAAK,iBAAiB,IAAI,MAAM,kBAAkB;AAClD,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK,GAAG;AAC9C,aAAK,eAAe,CAAC,IAAI,QAAQ,OAAO;AAAA,MAC1C;AACA,WAAK,eAAe,oBAAI,IAAoB;AAC5C,UAAI,mBAAmB,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,MAAM;AAC3D,eAAS,IAAI,GAAG,IAAI,kBAAkB,KAAK;AACzC,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,QAAQ,OAAO;AACzB,aAAK,aAAa,IAAI,KAAK,GAAG;AAAA,MAChC;AACA,WAAK,uBAAuB,oBAAI,IAAwB;AACxD,UAAI,2BAA2B,QAAQ,IAAI,qBAAK,QAAQ,qBAAK,GAAG;AAChE,eAAS,IAAI,GAAG,IAAI,0BAA0B,KAAK;AACjD,YAAI,MAAM,QAAQ,OAAO;AACzB,YAAI,MAAM,WAAW,OAAO,OAAO;AACnC,YAAI,OAAO,QAAQ,aAAa;AAC9B,eAAK,qBAAqB,IAAI,KAAK,GAAG;AAAA,QACxC;AAAA,MACF;AACA,WAAK,aAAa,QAAQ,WAAW;AACrC,YAAM,sBAAsB,QAAQ,MAAM,qBAAK,UAAU;AACzD,WAAK,kBAAkB,IAAI,MAAM,mBAAmB;AACpD,eAAS,IAAI,GAAG,IAAI,qBAAqB,KAAK,GAAG;AAC/C,aAAK,gBAAgB,CAAC,IAAI,QAAQ,WAAW;AAAA,MAC/C;AACA,WAAK,YAAY,QAAQ,QAAQ;AACjC,YAAM,qBAAqB,QAAQ,MAAM,qBAAK,OAAO;AACrD,WAAK,iBAAiB,IAAI,MAAM,kBAAkB;AAClD,eAAS,IAAI,GAAG,IAAI,oBAAoB,KAAK,GAAG;AAC9C,aAAK,eAAe,CAAC,IAAI,QAAQ,QAAQ;AAAA,MAC3C;AAAA,IACF,OAAO;AACL,WAAK,aAAa,IAAI,WAAW;AACjC,WAAK,kBAAkB,CAAC;AACxB,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,aAAa;AAClB,WAAK,kBAAkB,CAAC;AACxB,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,WAAK,aAAa;AAClB,WAAK,kBAAkB,CAAC;AACxB,WAAK,gBAAgB,oBAAI,IAAoB;AAC7C,WAAK,wBAAwB,oBAAI,IAAwB;AACzD,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,cAAc;AACnB,WAAK,mBAAmB,CAAC;AACzB,WAAK,iBAAiB,oBAAI,IAAoB;AAC9C,WAAK,yBAAyB,oBAAI,IAAwB;AAC1D,WAAK,eAAe;AACpB,WAAK,oBAAoB,CAAC;AAC1B,WAAK,eAAe;AACpB,WAAK,oBAAoB,CAAC;AAC1B,WAAK,YAAY;AACjB,WAAK,iBAAiB,CAAC;AACvB,WAAK,eAAe,oBAAI,IAAyB;AACjD,WAAK,uBAAuB,oBAAI,IAA6B;AAC7D,WAAK,aAAa,IAAI,WAAW,GAAG;AACpC,WAAK,kBAAkB,CAAC;AACxB,WAAK,YAAY;AACjB,WAAK,iBAAiB,CAAC;AAAA,IACzB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAQ,SAAkB;AACxB,QAAI,OAAO,KAAK,eAAe,aAAa;AAC1C,cAAQ,KAAK;AAAA,IACf,OAAO;AACL,WAAK,WAAW,OAAO,OAAO;AAAA,IAChC;AACA,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,GAAG;AAC7C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,YAAM,KAAK,KAAK,gBAAgB,CAAC;AACjC,SAAG,OAAO,OAAO;AAAA,IACnB;AACA,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,MAAM,KAAK,UAAU;AAC7B,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,KAAK;AAC/C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,MAAM,KAAK,gBAAgB,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,cAAc,MAAM,qBAAK,OAAO,qBAAK,KAAK;AAC3D,SAAK,cAAc,QAAQ,CAAC,KAAK,QAAQ;AACvC,cAAQ,MAAM,GAAG;AACjB,cAAQ,MAAM,GAAG;AAAA,IACnB,CAAC;AACD,YAAQ,IAAI,KAAK,sBAAsB,MAAM,qBAAK,OAAO,qBAAK,GAAG;AACjE,SAAK,sBAAsB,QAAQ,CAAC,KAAK,QAAQ;AAC/C,cAAQ,MAAM,GAAG;AACjB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,MAAM,KAAK,UAAU;AAC7B,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,KAAK;AAC/C,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,MAAM,KAAK,gBAAgB,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,cAAc,MAAM,qBAAK,OAAO,qBAAK,KAAK;AAC3D,SAAK,cAAc,QAAQ,CAAC,KAAK,QAAQ;AACvC,cAAQ,MAAM,GAAG;AACjB,cAAQ,MAAM,GAAG;AAAA,IACnB,CAAC;AACD,YAAQ,IAAI,KAAK,sBAAsB,MAAM,qBAAK,OAAO,qBAAK,GAAG;AACjE,SAAK,sBAAsB,QAAQ,CAAC,KAAK,QAAQ;AAC/C,cAAQ,MAAM,GAAG;AACjB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,OAAO,KAAK,WAAW;AAC/B,UAAM,yBAAyB,KAAK,iBAAiB;AACrD,YAAQ,MAAM,wBAAwB,qBAAK,MAAM;AACjD,aAAS,IAAI,GAAG,IAAI,wBAAwB,KAAK,GAAG;AAClD,cAAQ,OAAO,KAAK,iBAAiB,CAAC,CAAC;AAAA,IACzC;AACA,YAAQ,IAAI,KAAK,eAAe,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC9D,SAAK,eAAe,QAAQ,CAAC,KAAK,QAAQ;AACxC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,uBAAuB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACnE,SAAK,uBAAuB,QAAQ,CAAC,KAAK,QAAQ;AAChD,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,QAAQ,KAAK,YAAY;AACjC,UAAM,0BAA0B,KAAK,kBAAkB;AACvD,YAAQ,MAAM,yBAAyB,qBAAK,OAAO;AACnD,aAAS,IAAI,GAAG,IAAI,yBAAyB,KAAK,GAAG;AACnD,cAAQ,QAAQ,KAAK,kBAAkB,CAAC,CAAC;AAAA,IAC3C;AACA,YAAQ,QAAQ,KAAK,YAAY;AACjC,UAAM,0BAA0B,KAAK,kBAAkB;AACvD,YAAQ,MAAM,yBAAyB,qBAAK,OAAO;AACnD,aAAS,IAAI,GAAG,IAAI,yBAAyB,KAAK,GAAG;AACnD,cAAQ,QAAQ,KAAK,kBAAkB,CAAC,CAAC;AAAA,IAC3C;AACA,YAAQ,OAAO,KAAK,SAAS;AAC7B,UAAM,uBAAuB,KAAK,eAAe;AACjD,YAAQ,MAAM,sBAAsB,qBAAK,MAAM;AAC/C,aAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,cAAQ,OAAO,KAAK,eAAe,CAAC,CAAC;AAAA,IACvC;AACA,YAAQ,IAAI,KAAK,aAAa,MAAM,qBAAK,QAAQ,qBAAK,MAAM;AAC5D,SAAK,aAAa,QAAQ,CAAC,KAAK,QAAQ;AACtC,cAAQ,OAAO,GAAG;AAClB,cAAQ,OAAO,GAAG;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,KAAK,qBAAqB,MAAM,qBAAK,QAAQ,qBAAK,GAAG;AACjE,SAAK,qBAAqB,QAAQ,CAAC,KAAK,QAAQ;AAC9C,cAAQ,OAAO,GAAG;AAClB,UAAI,OAAO,OAAO;AAAA,IACpB,CAAC;AACD,YAAQ,WAAW,KAAK,UAAU;AAClC,UAAM,wBAAwB,KAAK,gBAAgB;AACnD,YAAQ,MAAM,uBAAuB,qBAAK,UAAU;AACpD,aAAS,IAAI,GAAG,IAAI,uBAAuB,KAAK,GAAG;AACjD,cAAQ,WAAW,KAAK,gBAAgB,CAAC,CAAC;AAAA,IAC5C;AACA,YAAQ,QAAQ,KAAK,SAAS;AAC9B,UAAM,uBAAuB,KAAK,eAAe;AACjD,YAAQ,MAAM,sBAAsB,qBAAK,OAAO;AAChD,aAAS,IAAI,GAAG,IAAI,sBAAsB,KAAK,GAAG;AAChD,cAAQ,QAAQ,KAAK,eAAe,CAAC,CAAC;AAAA,IACxC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OAAQ,SAAsD;AACnE,QAAI,QAAQ,KAAK,GAAG;AAClB,aAAO;AAAA,IACT;AACA,WAAO,IAAI,uBAAuB,OAAO;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,iBAAkB,SAAkB;AACzC,YAAQ,KAAK;AAAA,EACf;AACF;", + "names": ["GenericEnum"] +} diff --git a/integration/typescript_tests/signature/types.ts b/integration/typescript_tests/signature/types.ts new file mode 100644 index 00000000..9de789e5 --- /dev/null +++ b/integration/typescript_tests/signature/types.ts @@ -0,0 +1,1473 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: local-example-latest-guest + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export enum GenericEnum { + FirstValue = 0, + + SecondValue = 1, + + DefaultValue = 2, + +} +export class EmptyModel { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModel | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModel(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// EmptyModelWithDescription: Test Description +export class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModelWithDescription | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModelWithDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleStringField { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringField | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringField(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleStringFieldAndDescription: Test Description +export class ModelWithSingleStringFieldAndDescription { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringFieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleInt32Field { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32Field(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +export class ModelWithSingleInt32FieldAndDescription { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32FieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFields { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFields | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFields(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAndDescription: Test Description +export class ModelWithMultipleFieldsAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnum { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnum | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnum(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAndDescription: Test Description +export class ModelWithEnumAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnumAccessor { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = GenericEnum.DefaultValue; + } + } + + get enumField(): GenericEnum { + return this.#enumField; + } + + set enumField(val: GenericEnum) { + this.#enumField = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.#enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAccessorAndDescription: Test Description +export class ModelWithEnumAccessorAndDescription { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = GenericEnum.DefaultValue; + } + } + + get enumField(): GenericEnum { + return this.#enumField; + } + + set enumField(val: GenericEnum) { + this.#enumField = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.#enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFieldsAccessor { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + + get stringField(): string { + return this.#stringField; + } + + set stringField(val: string) { + if (!/^[a-zA-Z0-9]*$/.test(val)) { + throw new Error("value must match ^[a-zA-Z0-9]*$"); + } + if (val.length > 20 || val.length < 1) { + throw new Error("length must be between 1 and 20"); + } + val = val.toUpperCase(); + this.#stringField = val; + } + + get int32Field(): number { + return this.#int32Field; + } + + set int32Field (val: number) { + if (val > 100 || val < 0) { + throw new Error("value must be between 0 and 100"); + } + this.#int32Field = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +export class ModelWithMultipleFieldsAccessorAndDescription { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + + get stringField(): string { + return this.#stringField; + } + + set stringField(val: string) { + this.#stringField = val; + } + + get int32Field(): number { + return this.#int32Field; + } + + set int32Field (val: number) { + this.#int32Field = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModels { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModels(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +export class ModelWithEmbeddedModelsAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModelsAccessor { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + get embeddedEmptyModel(): EmptyModel | undefined { + return this.#embeddedEmptyModel; + } + + set embeddedEmptyModel(val: EmptyModel | undefined) { + this.#embeddedEmptyModel = val; + } + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +export class ModelWithEmbeddedModelsAccessorAndDescription { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + get embeddedEmptyModel(): EmptyModel | undefined { + return this.#embeddedEmptyModel; + } + + set embeddedEmptyModel(val: EmptyModel | undefined) { + this.#embeddedEmptyModel = val; + } + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithAllFieldTypes { + modelField: EmptyModel | undefined; + + modelArrayField: Array; + + stringField: string; + + stringArrayField: string[]; + + stringMapField: Map; + + stringMapFieldEmbedded: Map; + + int32Field: number; + + int32ArrayField: number[]; + + int32MapField: Map; + + int32MapFieldEmbedded: Map; + + int64Field: bigint; + + int64ArrayField: bigint[]; + + int64MapField: Map; + + int64MapFieldEmbedded: Map; + + uint32Field: number; + + uint32ArrayField: number[]; + + uint32MapField: Map; + + uint32MapFieldEmbedded: Map; + + uint64Field: bigint; + + uint64ArrayField: bigint[]; + + uint64MapField: Map; + + uint64MapFieldEmbedded: Map; + + float32Field: number; + + float32ArrayField: number[]; + + float64Field: number; + + float64ArrayField: number[]; + + enumField: GenericEnum; + + enumArrayField: GenericEnum[]; + + enumMapField: Map; + + enumMapFieldEmbedded: Map; + + bytesField: Uint8Array; + + bytesArrayField: Uint8Array[]; + + boolField: boolean; + + boolArrayField: boolean[]; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.modelField = EmptyModel.decode(decoder); + const modelArrayFieldSize = decoder.array(Kind.Any); + this.modelArrayField = new Array(modelArrayFieldSize); + for (let i = 0; i < modelArrayFieldSize; i += 1) { + const x = EmptyModel.decode(decoder); + if (typeof x !== "undefined") { + this.modelArrayField[i] = x; + } + } + this.stringField = decoder.string(); + const stringArrayFieldSize = decoder.array(Kind.String); + this.stringArrayField = new Array(stringArrayFieldSize); + for (let i = 0; i < stringArrayFieldSize; i += 1) { + this.stringArrayField[i] = decoder.string(); + } + this.stringMapField = new Map(); + let stringMapFieldSize = decoder.map(Kind.String, Kind.String); + for (let i = 0; i < stringMapFieldSize; i++) { + let key = decoder.string(); + let val = decoder.string(); + this.stringMapField.set(key, val); + } + this.stringMapFieldEmbedded = new Map(); + let stringMapFieldEmbeddedSize = decoder.map(Kind.String, Kind.Any); + for (let i = 0; i < stringMapFieldEmbeddedSize; i++) { + let key = decoder.string(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.stringMapFieldEmbedded.set(key, val); + } + } + this.int32Field = decoder.int32(); + const int32ArrayFieldSize = decoder.array(Kind.Int32); + this.int32ArrayField = new Array(int32ArrayFieldSize); + for (let i = 0; i < int32ArrayFieldSize; i += 1) { + this.int32ArrayField[i] = decoder.int32(); + } + this.int32MapField = new Map(); + let int32MapFieldSize = decoder.map(Kind.Int32, Kind.Int32); + for (let i = 0; i < int32MapFieldSize; i++) { + let key = decoder.int32(); + let val = decoder.int32(); + this.int32MapField.set(key, val); + } + this.int32MapFieldEmbedded = new Map(); + let int32MapFieldEmbeddedSize = decoder.map(Kind.Int32, Kind.Any); + for (let i = 0; i < int32MapFieldEmbeddedSize; i++) { + let key = decoder.int32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int32MapFieldEmbedded.set(key, val); + } + } + this.int64Field = decoder.int64(); + const int64ArrayFieldSize = decoder.array(Kind.Int64); + this.int64ArrayField = new Array(int64ArrayFieldSize); + for (let i = 0; i < int64ArrayFieldSize; i += 1) { + this.int64ArrayField[i] = decoder.int64(); + } + this.int64MapField = new Map(); + let int64MapFieldSize = decoder.map(Kind.Int64, Kind.Int64); + for (let i = 0; i < int64MapFieldSize; i++) { + let key = decoder.int64(); + let val = decoder.int64(); + this.int64MapField.set(key, val); + } + this.int64MapFieldEmbedded = new Map(); + let int64MapFieldEmbeddedSize = decoder.map(Kind.Int64, Kind.Any); + for (let i = 0; i < int64MapFieldEmbeddedSize; i++) { + let key = decoder.int64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int64MapFieldEmbedded.set(key, val); + } + } + this.uint32Field = decoder.uint32(); + const uint32ArrayFieldSize = decoder.array(Kind.Uint32); + this.uint32ArrayField = new Array(uint32ArrayFieldSize); + for (let i = 0; i < uint32ArrayFieldSize; i += 1) { + this.uint32ArrayField[i] = decoder.uint32(); + } + this.uint32MapField = new Map(); + let uint32MapFieldSize = decoder.map(Kind.Uint32, Kind.Uint32); + for (let i = 0; i < uint32MapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.uint32(); + this.uint32MapField.set(key, val); + } + this.uint32MapFieldEmbedded = new Map(); + let uint32MapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint32MapFieldEmbedded.set(key, val); + } + } + this.uint64Field = decoder.uint64(); + const uint64ArrayFieldSize = decoder.array(Kind.Uint64); + this.uint64ArrayField = new Array(uint64ArrayFieldSize); + for (let i = 0; i < uint64ArrayFieldSize; i += 1) { + this.uint64ArrayField[i] = decoder.uint64(); + } + this.uint64MapField = new Map(); + let uint64MapFieldSize = decoder.map(Kind.Uint64, Kind.Uint64); + for (let i = 0; i < uint64MapFieldSize; i++) { + let key = decoder.uint64(); + let val = decoder.uint64(); + this.uint64MapField.set(key, val); + } + this.uint64MapFieldEmbedded = new Map(); + let uint64MapFieldEmbeddedSize = decoder.map(Kind.Uint64, Kind.Any); + for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) { + let key = decoder.uint64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint64MapFieldEmbedded.set(key, val); + } + } + this.float32Field = decoder.float32(); + const float32ArrayFieldSize = decoder.array(Kind.Float32); + this.float32ArrayField = new Array(float32ArrayFieldSize); + for (let i = 0; i < float32ArrayFieldSize; i += 1) { + this.float32ArrayField[i] = decoder.float32(); + } + this.float64Field = decoder.float64(); + const float64ArrayFieldSize = decoder.array(Kind.Float64); + this.float64ArrayField = new Array(float64ArrayFieldSize); + for (let i = 0; i < float64ArrayFieldSize; i += 1) { + this.float64ArrayField[i] = decoder.float64(); + } + this.enumField = decoder.uint32(); + const enumArrayFieldSize = decoder.array(Kind.Uint32); + this.enumArrayField = new Array(enumArrayFieldSize); + for (let i = 0; i < enumArrayFieldSize; i += 1) { + this.enumArrayField[i] = decoder.uint32(); + } + this.enumMapField = new Map(); + let enumMapFieldSize = decoder.map(Kind.Uint32, Kind.String); + for (let i = 0; i < enumMapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.string(); + this.enumMapField.set(key, val); + } + this.enumMapFieldEmbedded = new Map(); + let enumMapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < enumMapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.enumMapFieldEmbedded.set(key, val); + } + } + this.bytesField = decoder.uint8Array(); + const bytesArrayFieldSize = decoder.array(Kind.Uint8Array); + this.bytesArrayField = new Array(bytesArrayFieldSize); + for (let i = 0; i < bytesArrayFieldSize; i += 1) { + this.bytesArrayField[i] = decoder.uint8Array(); + } + this.boolField = decoder.boolean(); + const boolArrayFieldSize = decoder.array(Kind.Boolean); + this.boolArrayField = new Array(boolArrayFieldSize); + for (let i = 0; i < boolArrayFieldSize; i += 1) { + this.boolArrayField[i] = decoder.boolean(); + } + } else { + this.modelField = new EmptyModel(); + this.modelArrayField = []; + this.stringField = "DefaultValue"; + this.stringArrayField = []; + this.stringMapField = new Map(); + this.stringMapFieldEmbedded = new Map(); + this.int32Field = 32; + this.int32ArrayField = []; + this.int32MapField = new Map(); + this.int32MapFieldEmbedded = new Map(); + this.int64Field = 64n; + this.int64ArrayField = []; + this.int64MapField = new Map(); + this.int64MapFieldEmbedded = new Map(); + this.uint32Field = 32; + this.uint32ArrayField = []; + this.uint32MapField = new Map(); + this.uint32MapFieldEmbedded = new Map(); + this.uint64Field = 64n; + this.uint64ArrayField = []; + this.uint64MapField = new Map(); + this.uint64MapFieldEmbedded = new Map(); + this.float32Field = 32.32; + this.float32ArrayField = []; + this.float64Field = 64.64; + this.float64ArrayField = []; + this.enumField = GenericEnum.DefaultValue; + this.enumArrayField = []; + this.enumMapField = new Map(); + this.enumMapFieldEmbedded = new Map(); + this.bytesField = new Uint8Array(512); + this.bytesArrayField = []; + this.boolField = true; + this.boolArrayField = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.modelField === "undefined") { + encoder.null(); + } else { + this.modelField.encode(encoder); + } + const modelArrayFieldLength = this.modelArrayField.length; + encoder.array(modelArrayFieldLength, Kind.Any); + for (let i = 0; i < modelArrayFieldLength; i += 1) { + const el = this.modelArrayField[i]; + el.encode(encoder); + } + encoder.string(this.stringField); + const stringArrayFieldLength = this.stringArrayField.length; + encoder.array(stringArrayFieldLength, Kind.String); + for (let i = 0; i < stringArrayFieldLength; i += 1) { + encoder.string(this.stringArrayField[i]); + } + encoder.map(this.stringMapField.size, Kind.String, Kind.String); + this.stringMapField.forEach((val, key) => { + encoder.string(key); + encoder.string(val); + }); + encoder.map(this.stringMapFieldEmbedded.size, Kind.String, Kind.Any); + this.stringMapFieldEmbedded.forEach((val, key) => { + encoder.string(key); + val.encode(encoder); + }); + encoder.int32(this.int32Field); + const int32ArrayFieldLength = this.int32ArrayField.length; + encoder.array(int32ArrayFieldLength, Kind.Int32); + for (let i = 0; i < int32ArrayFieldLength; i += 1) { + encoder.int32(this.int32ArrayField[i]); + } + encoder.map(this.int32MapField.size, Kind.Int32, Kind.Int32); + this.int32MapField.forEach((val, key) => { + encoder.int32(key); + encoder.int32(val); + }); + encoder.map(this.int32MapFieldEmbedded.size, Kind.Int32, Kind.Any); + this.int32MapFieldEmbedded.forEach((val, key) => { + encoder.int32(key); + val.encode(encoder); + }); + encoder.int64(this.int64Field); + const int64ArrayFieldLength = this.int64ArrayField.length; + encoder.array(int64ArrayFieldLength, Kind.Int64); + for (let i = 0; i < int64ArrayFieldLength; i += 1) { + encoder.int64(this.int64ArrayField[i]); + } + encoder.map(this.int64MapField.size, Kind.Int64, Kind.Int64); + this.int64MapField.forEach((val, key) => { + encoder.int64(key); + encoder.int64(val); + }); + encoder.map(this.int64MapFieldEmbedded.size, Kind.Int64, Kind.Any); + this.int64MapFieldEmbedded.forEach((val, key) => { + encoder.int64(key); + val.encode(encoder); + }); + encoder.uint32(this.uint32Field); + const uint32ArrayFieldLength = this.uint32ArrayField.length; + encoder.array(uint32ArrayFieldLength, Kind.Uint32); + for (let i = 0; i < uint32ArrayFieldLength; i += 1) { + encoder.uint32(this.uint32ArrayField[i]); + } + encoder.map(this.uint32MapField.size, Kind.Uint32, Kind.Uint32); + this.uint32MapField.forEach((val, key) => { + encoder.uint32(key); + encoder.uint32(val); + }); + encoder.map(this.uint32MapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.uint32MapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint64(this.uint64Field); + const uint64ArrayFieldLength = this.uint64ArrayField.length; + encoder.array(uint64ArrayFieldLength, Kind.Uint64); + for (let i = 0; i < uint64ArrayFieldLength; i += 1) { + encoder.uint64(this.uint64ArrayField[i]); + } + encoder.map(this.uint64MapField.size, Kind.Uint64, Kind.Uint64); + this.uint64MapField.forEach((val, key) => { + encoder.uint64(key); + encoder.uint64(val); + }); + encoder.map(this.uint64MapFieldEmbedded.size, Kind.Uint64, Kind.Any); + this.uint64MapFieldEmbedded.forEach((val, key) => { + encoder.uint64(key); + val.encode(encoder); + }); + encoder.float32(this.float32Field); + const float32ArrayFieldLength = this.float32ArrayField.length; + encoder.array(float32ArrayFieldLength, Kind.Float32); + for (let i = 0; i < float32ArrayFieldLength; i += 1) { + encoder.float32(this.float32ArrayField[i]); + } + encoder.float64(this.float64Field); + const float64ArrayFieldLength = this.float64ArrayField.length; + encoder.array(float64ArrayFieldLength, Kind.Float64); + for (let i = 0; i < float64ArrayFieldLength; i += 1) { + encoder.float64(this.float64ArrayField[i]); + } + encoder.uint32(this.enumField); + const enumArrayFieldLength = this.enumArrayField.length; + encoder.array(enumArrayFieldLength, Kind.Uint32); + for (let i = 0; i < enumArrayFieldLength; i += 1) { + encoder.uint32(this.enumArrayField[i]); + } + encoder.map(this.enumMapField.size, Kind.Uint32, Kind.String); + this.enumMapField.forEach((val, key) => { + encoder.uint32(key); + encoder.string(val); + }); + encoder.map(this.enumMapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.enumMapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint8Array(this.bytesField); + const bytesArrayFieldLength = this.bytesArrayField.length; + encoder.array(bytesArrayFieldLength, Kind.Uint8Array); + for (let i = 0; i < bytesArrayFieldLength; i += 1) { + encoder.uint8Array(this.bytesArrayField[i]); + } + encoder.boolean(this.boolField); + const boolArrayFieldLength = this.boolArrayField.length; + encoder.array(boolArrayFieldLength, Kind.Boolean); + for (let i = 0; i < boolArrayFieldLength; i += 1) { + encoder.boolean(this.boolArrayField[i]); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithAllFieldTypes(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + diff --git a/jest.config.json b/jest.config.json index 9f29db1c..76caee0b 100644 --- a/jest.config.json +++ b/jest.config.json @@ -3,9 +3,9 @@ "collectCoverage": true, "coverageDirectory": "coverage", "preset": "ts-jest", - "testEnvironment": "node", + "testEnvironment": "jsdom", "testMatch": [ "**/*.test.ts" ], - "testPathIgnorePatterns": ["ts/compile"] + "testPathIgnorePatterns": ["dist", "compile", "target", "node_modules", "integration/typescript_tests"] } diff --git a/log/log.go b/log/log.go new file mode 100644 index 00000000..f299801e --- /dev/null +++ b/log/log.go @@ -0,0 +1,44 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package log + +import ( + "fmt" + "io" +) + +var _ io.Writer = (*NamedLogger)(nil) + +type NamedLogger struct { + nameTemplate string + nameTemplateBytes []byte + writer io.Writer +} + +func NewNamedLogger(name string, writer io.Writer) *NamedLogger { + nameTemplate := fmt.Sprintf("%s: ", name) + return &NamedLogger{ + nameTemplate: nameTemplate, + nameTemplateBytes: []byte(nameTemplate), + writer: writer, + } +} + +func (l *NamedLogger) Write(p []byte) (int, error) { + _, err := l.writer.Write(append(append(l.nameTemplateBytes, p...), '\n')) + return len(p), err +} diff --git a/log/log.ts b/log/log.ts new file mode 100644 index 00000000..4db88e36 --- /dev/null +++ b/log/log.ts @@ -0,0 +1,23 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import {Writer} from "../config"; + +export function NamedLogger(name: string, writer: Writer): Writer { + return (message: string) => { + writer(`${name}: ${message}`); + } +} \ No newline at end of file diff --git a/module.go b/module.go new file mode 100644 index 00000000..e1a6d196 --- /dev/null +++ b/module.go @@ -0,0 +1,165 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + "fmt" + + "github.com/loopholelabs/scale/log" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" + + "github.com/loopholelabs/polyglot" + + "github.com/google/uuid" + "github.com/tetratelabs/wazero/api" +) + +type module[T interfaces.Signature] struct { + // template is the template that the module + // was created from + template *template[T] + + // instantiatedModule is the instantiated wasm module + instantiatedModule api.Module + + // runFunction is the exported `run` function + runFunction api.Function + + // resizeFunction is the exported `resize` function + resizeFunction api.Function + + // function is set during the initialization of the module + function *function[T] + + // signature is set during the initialization of the module + signature T +} + +// newModule creates a new module +func newModule[T interfaces.Signature](ctx context.Context, template *template[T]) (*module[T], error) { + name := fmt.Sprintf("%s.%s", template.identifier, uuid.New().String()) + config := template.runtime.moduleConfig.WithName(name) + for k, v := range template.env { + config = config.WithEnv(k, v) + } + + if template.runtime.config.stdout != nil && !template.runtime.config.rawOutput { + config = config.WithStdout(log.NewNamedLogger(name, template.runtime.config.stdout)) + } + + if template.runtime.config.stderr != nil && !template.runtime.config.rawOutput { + config = config.WithStderr(log.NewNamedLogger(name, template.runtime.config.stderr)) + } + + instantiatedModule, err := template.runtime.runtime.InstantiateModule(ctx, template.compiled, config) + if err != nil { + return nil, fmt.Errorf("failed to instantiate module '%s': %w", template.identifier, err) + } + + run := instantiatedModule.ExportedFunction("run") + resize := instantiatedModule.ExportedFunction("resize") + initialize := instantiatedModule.ExportedFunction("initialize") + if run == nil || resize == nil || initialize == nil { + return nil, fmt.Errorf("failed to find run, resize, or initialize implementations for function %s", template.identifier) + } + + packed, err := initialize.Call(ctx) + if err != nil { + return nil, fmt.Errorf("failed to run initialize function for '%s': %w", template.identifier, err) + } + + if packed[0] != 0 { + offset, length := unpackUint32(packed[0]) + buf, ok := instantiatedModule.Memory().Read(offset, length) + if !ok { + return nil, fmt.Errorf("failed to read memory for function '%s'", template.identifier) + } + + dec := polyglot.GetDecoder(buf) + valErr, err := dec.Error() + polyglot.ReturnDecoder(dec) + if err != nil { + return nil, fmt.Errorf("failed to decode error for function '%s': %w", template.identifier, err) + } + return nil, fmt.Errorf("failed to initialize function '%s': %s", template.identifier, valErr) + } + + return &module[T]{ + template: template, + instantiatedModule: instantiatedModule, + runFunction: run, + resizeFunction: resize, + }, nil +} + +// run runs the module +// +// The signature of the module must be set before calling this function +func (m *module[T]) run(ctx context.Context) error { + buf := m.signature.Write() + writeBuffer, err := m.resizeFunction.Call(ctx, uint64(len(buf))) + if err != nil { + return fmt.Errorf("failed to allocate memory for function '%s': %w", m.template.identifier, err) + } + + if !m.instantiatedModule.Memory().Write(uint32(writeBuffer[0]), buf) { + return fmt.Errorf("failed to write memory for function '%s'", m.template.identifier) + } + + packed, err := m.runFunction.Call(ctx) + if err != nil { + return fmt.Errorf("failed to run function '%s': %w", m.template.identifier, err) + } + if packed[0] == 0 { + return fmt.Errorf("failed to run function '%s'", m.template.identifier) + } + + ptr, length := unpackUint32(packed[0]) + buf, ok := m.instantiatedModule.Memory().Read(ptr, length) + if !ok { + return fmt.Errorf("failed to read memory for function '%s'", m.template.identifier) + } + + err = m.signature.Read(buf) + if err != nil { + return fmt.Errorf("error while running function '%s': %w", m.template.identifier, err) + } + return nil +} + +// register sets the module's instance field and registers it as an active module with the runtime +func (m *module[T]) register(function *function[T]) { + m.function = function + m.template.runtime.activeModulesMu.Lock() + m.template.runtime.activeModules[m.instantiatedModule.Name()] = m + m.template.runtime.activeModulesMu.Unlock() +} + +// cleanup removes the module from the runtime's active modules map +func (m *module[T]) cleanup() { + m.function = nil + m.template.runtime.activeModulesMu.Lock() + delete(m.template.runtime.activeModules, m.instantiatedModule.Name()) + m.template.runtime.activeModulesMu.Unlock() +} + +// setSignature sets the module's signature +func (m *module[T]) setSignature(signature T) { + m.signature = signature +} diff --git a/module.ts b/module.ts new file mode 100644 index 00000000..813fb88e --- /dev/null +++ b/module.ts @@ -0,0 +1,167 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import {Signature} from "@loopholelabs/scale-signature-interfaces"; +import {Func} from "./function"; +import {Template} from "./template"; +import {UnpackUint32} from "./utils"; +import {Decoder} from "@loopholelabs/polyglot"; +import {DisabledWASI} from "./wasi"; +import {v4 as uuid} from "uuid"; +import {NamedLogger} from "./log/log"; +import {Tracing} from "./tracing"; + +export async function NewModule(template: Template): Promise> { + const m = new Module(template); + await m.Ready(); + return m; +} + +export class Module { + private readonly ready: Promise; + + public template: Template; + + private readonly wasi: DisabledWASI; + private readonly tracing: Tracing; + + private instantiatedModule: WebAssembly.Instance | undefined; + private run: undefined | ((ptr: number, len: number) => bigint); + public resize: undefined | ((len: number) => number); + private initialize: undefined | (() => bigint); + + public memory: undefined | WebAssembly.Memory; + + public function: Func | undefined; + public signature: T | undefined; + + constructor(template: Template) { + this.template = template; + + const name = `${this.template.identifier}.${uuid()}` + + let stdout = this.template.runtime.config.stdout; + let stderr = this.template.runtime.config.stderr; + + if (typeof stdout !== "undefined" && !this.template.runtime.config.rawOutput) { + stdout = NamedLogger(name, stdout); + } + + if (typeof stderr !== "undefined" && !this.template.runtime.config.rawOutput) { + stderr = NamedLogger(name, stderr); + } + + this.wasi = new DisabledWASI(this.template.env, stdout, stderr); + this.tracing = new Tracing(this, this.template.runtime.TraceDataCallback); + + const moduleConfig = { + wasi_snapshot_preview1: this.wasi.GetImports(), + scale: this.tracing.GetImports(), + env: { + next: this.template.runtime.Next(this), + }, + } + + this.ready = new Promise(async (resolve) => { // eslint-disable-line no-async-promise-executor + if (typeof this.template.compiled !== "undefined") { + this.instantiatedModule = await WebAssembly.instantiate(this.template.compiled, moduleConfig); + this.wasi.SetInstance(this.instantiatedModule); + + this.run = this.instantiatedModule.exports.run as ((ptr: number, len: number) => bigint) | undefined; + if (typeof this.run === "undefined") { + throw new Error("no run function found in module"); + } + this.resize = this.instantiatedModule.exports.resize as ((len: number) => number) | undefined; + if (typeof this.resize === "undefined") { + throw new Error("no resize function found in module"); + } + this.initialize = this.instantiatedModule.exports.initialize as (() => bigint) | undefined; + if (typeof this.initialize === "undefined") { + throw new Error("no initialize function found in module"); + } + this.memory = this.instantiatedModule.exports.memory as WebAssembly.Memory | undefined; + if (typeof this.memory === "undefined") { + throw new Error("no memory found in module"); + } + + const packed = this.initialize(); + if (packed != BigInt(0)) { + const [ptr, len] = UnpackUint32(packed); + const readData = new Uint8Array(this.memory.buffer); + const readBuffer = readData.slice(ptr, ptr + len); + + const dec = new Decoder(readBuffer) + throw dec.error(); + } + + resolve(); + } else { + throw new Error("no compiled module found in template"); + } + }); + } + + public async Ready() { + return await this.ready; + } + + public Run() { + if (typeof this.signature === "undefined") { + throw new Error("no signature found in module"); + } + + if (typeof this.resize === "undefined") { + throw new Error("no resize function found in module"); + } + + if (typeof this.run === "undefined") { + throw new Error("no run function found in module"); + } + + if (typeof this.memory === "undefined") { + throw new Error("no memory found in module"); + } + + + const buffer = this.signature.Write(); + const writeBufferPointer = this.resize(buffer.length); + const writeBuffer = new Uint8Array(this.memory.buffer); + writeBuffer.set(buffer, writeBufferPointer); + + const packed = this.run(writeBufferPointer, buffer.length); + const [ptr, len] = UnpackUint32(packed); + const readBufferPointer = new Uint8Array(this.memory.buffer); + const readBuffer = readBufferPointer.slice(ptr, ptr + len); + + const err = this.signature.Read(readBuffer); + if (typeof err !== "undefined") { + throw err; + } + } + + public Register(fn: Func) { + this.function = fn; + } + + public Cleanup() { + this.function = undefined; + } + + public SetSignature(signature: T) { + this.signature = signature; + } + +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d44b2f7c..06451fcb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,58 +1,47 @@ { "name": "@loopholelabs/scale", - "version": "0.3.17", + "version": "0.3.20", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@loopholelabs/scale", - "version": "0.3.17", + "version": "0.3.20", "license": "apache-2.0", "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature": "^0.2.11", - "@loopholelabs/scale-signature-http": "^0.3.8", - "@loopholelabs/scalefile": "^0.1.9", - "@swc/helpers": "^0.4.12", - "@types/jest": "^29.2.0", - "@types/node-fetch": "^2.6.2", - "form-data": "^4.0.0", - "glob": "^8.1.0", - "jest": "^29.2.2", - "jest-environment-jsdom": "^29.2.2", - "js-sha256": "^0.9.0", - "next": "^12.3.3", - "node-fetch": "^2.6.7", - "openapi-typescript-codegen": "^0.23.0", - "ts-jest": "^29.0.3", - "util": "^0.12.5", + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7", + "buffer": "^6.0.3", + "fast-sha256": "^1.3.0", "uuid": "^9.0.0" }, "devDependencies": { - "@types/glob": "^8.0.1", - "@types/node": "^18.11.5", - "@types/uuid": "^9.0.0", - "assert": "^2.0.0", - "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "https-browserify": "^1.0.0", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", - "punycode": "^1.4.1", - "querystring-es3": "^0.2.1", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "tty-browserify": "^0.0.1", - "typescript": "^4.7.0", - "url": "^0.11.0" + "@types/jest": "^29.5.4", + "@types/node": "^20.5.8", + "@types/uuid": "^8.3.4", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "jest": "^29.6.4", + "jest-environment-jsdom": "^29.6.4", + "ts-jest": "^29.1.1", + "typescript": "^5.2.2" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" } }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -61,56 +50,120 @@ "node": ">=6.0.0" } }, - "node_modules/@apidevtools/json-schema-ref-parser": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", - "integrity": "sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==", + "node_modules/@babel/code-frame": { + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", + "dev": true, "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@babel/code-frame": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", - "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "dependencies": { - "@babel/highlight": "^7.18.6" + "color-convert": "^1.9.0" }, "engines": { - "node": ">=6.9.0" + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, "node_modules/@babel/compat-data": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.4.tgz", - "integrity": "sha512-/DYyDpeCfaVinT40FPGdkkb+lYSKvsVuMjDAG7jPOWWiM1ibOaB9CXJAlc4d1QpP/U2q2P9jbrSlClKSErd55g==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", + "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.4.tgz", - "integrity": "sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==", + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.11.tgz", + "integrity": "sha512-lh7RJrtPdhibbxndr6/xx0w8+CVlY5FJZiaSz908Fpy+G0xkBFTvwLcKJFF4PJxVfGhVWNebikpWGnOoC71juQ==", + "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.4", - "@babel/helper-compilation-targets": "^7.21.4", - "@babel/helper-module-transforms": "^7.21.2", - "@babel/helpers": "^7.21.0", - "@babel/parser": "^7.21.4", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.4", - "@babel/types": "^7.21.4", + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", + "@babel/helper-compilation-targets": "^7.22.10", + "@babel/helper-module-transforms": "^7.22.9", + "@babel/helpers": "^7.22.11", + "@babel/parser": "^7.22.11", + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.11", + "@babel/types": "^7.22.11", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.2.2", - "semver": "^6.3.0" + "json5": "^2.2.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -123,14 +176,25 @@ "node_modules/@babel/core/node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } }, "node_modules/@babel/generator": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.4.tgz", - "integrity": "sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.10.tgz", + "integrity": "sha512-79KIf7YiWjjdZ81JnLujDRApWtl7BxTqWD88+FFdQEIOG8LJ0etDOM7CXuIgGJa55sGOwZVwuEsaLEm0PJ5/+A==", + "dev": true, "dependencies": { - "@babel/types": "^7.21.4", + "@babel/types": "^7.22.10", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -140,157 +204,177 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.4.tgz", - "integrity": "sha512-Fa0tTuOXZ1iL8IeDFUWCzjZcn+sJGd9RZdH9esYVjEejGmzf+FFYQpMi/kZUk2kPy/q1H3/GPw7np8qar/stfg==", + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.10.tgz", + "integrity": "sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==", + "dev": true, "dependencies": { - "@babel/compat-data": "^7.21.4", - "@babel/helper-validator-option": "^7.21.0", - "browserslist": "^4.21.3", + "@babel/compat-data": "^7.22.9", + "@babel/helper-validator-option": "^7.22.5", + "browserslist": "^4.21.9", "lru-cache": "^5.1.1", - "semver": "^6.3.0" + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", + "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", + "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-imports": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", - "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz", + "integrity": "sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg==", + "dev": true, "dependencies": { - "@babel/types": "^7.21.4" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz", - "integrity": "sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ==", + "version": "7.22.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz", + "integrity": "sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ==", + "dev": true, "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.20.2", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.2", - "@babel/types": "^7.21.2" + "@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.6", + "@babel/helper-validator-identifier": "^7.22.5" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz", - "integrity": "sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-simple-access": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", - "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dev": true, "dependencies": { - "@babel/types": "^7.20.2" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dev": true, "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", + "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", + "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.0.tgz", - "integrity": "sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA==", + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.11.tgz", + "integrity": "sha512-vyOXC8PBWaGc5h7GMsNx68OH33cypkEDJCHvYVVgVbbxJDROYVtexSk0gK5iCF1xNjRIN2s8ai7hwkWDq5szWg==", + "dev": true, "dependencies": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.0", - "@babel/types": "^7.21.0" + "@babel/template": "^7.22.5", + "@babel/traverse": "^7.22.11", + "@babel/types": "^7.22.11" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", + "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -301,6 +385,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -312,6 +397,7 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -325,6 +411,7 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -332,12 +419,14 @@ "node_modules/@babel/highlight/node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true }, "node_modules/@babel/highlight/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, "engines": { "node": ">=0.8.0" } @@ -346,6 +435,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, "engines": { "node": ">=4" } @@ -354,6 +444,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -362,9 +453,10 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", - "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", + "version": "7.22.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.14.tgz", + "integrity": "sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==", + "dev": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -376,6 +468,7 @@ "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -387,6 +480,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -398,6 +492,7 @@ "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.12.13" }, @@ -409,6 +504,7 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -420,6 +516,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -428,11 +525,12 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.21.4.tgz", - "integrity": "sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.22.5.tgz", + "integrity": "sha512-gvyP4hZrgrs/wWMaocvxZ44Hw0b3W8Pe+cMxc8V1ULQ07oh8VNbIRaoD1LRZVTvD+0nieDKjfgKg89sD7rrKrg==", + "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -445,6 +543,7 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -456,6 +555,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -467,6 +567,7 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -478,6 +579,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -489,6 +591,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -500,6 +603,7 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -511,6 +615,7 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -522,11 +627,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.21.4.tgz", - "integrity": "sha512-xz0D39NvhQn4t4RNsHmDnnsaQizIlUkdtYvLs8La1BlfjQ6JEwxkJGeqJMW2tAXx+q6H+WFuUTXNdYVpEya0YA==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz", + "integrity": "sha512-1mS2o03i7t1c6VzH6fdQ3OA8tcEIxwG18zIPRp+UY1Ihv6W+XZzBCVxExF9upussPXJ0xE9XRHwMoNs1ep/nRQ==", + "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2" + "@babel/helper-plugin-utils": "^7.22.5" }, "engines": { "node": ">=6.9.0" @@ -536,31 +642,33 @@ } }, "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", + "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "dev": true, "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.22.5", + "@babel/parser": "^7.22.5", + "@babel/types": "^7.22.5" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz", - "integrity": "sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==", - "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.4", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.4", - "@babel/types": "^7.21.4", + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.11.tgz", + "integrity": "sha512-mzAenteTfomcB7mfPtyi+4oe5BZ6MXxWcn4CX+h4IRJ+OOGXBrWU6jDQavkQI9Vuc5P+donFabBfFCcmWka9lQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.10", + "@babel/generator": "^7.22.10", + "@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.6", + "@babel/parser": "^7.22.11", + "@babel/types": "^7.22.11", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -568,13 +676,23 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.4.tgz", - "integrity": "sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==", + "version": "7.22.11", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.11.tgz", + "integrity": "sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==", + "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.5", "to-fast-properties": "^2.0.0" }, "engines": { @@ -584,12 +702,103 @@ "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==" + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.8.0.tgz", + "integrity": "sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz", + "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.11", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.11.tgz", + "integrity": "sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, "dependencies": { "camelcase": "^5.3.1", "find-up": "^4.1.0", @@ -605,14 +814,29 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, "dependencies": { "sprintf-js": "~1.0.2" } }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, "dependencies": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -621,24 +845,74 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, "engines": { "node": ">=8" } }, "node_modules/@jest/console": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.5.0.tgz", - "integrity": "sha512-NEpkObxPwyw/XxZVLPmAGKE89IQRp4puc6IQRPru6JKd1M3fW9v1xM1AnzIJE65hbCkzQAdnL8P47e9hzhiYLQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.6.4.tgz", + "integrity": "sha512-wNK6gC0Ha9QeEPSkeJedQuTQqxZYnDPuDcDhVuVatRvMkL4D0VTvFVZj+Yuh6caG2aOfzkUZ36KtCmLNtR02hw==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", "slash": "^3.0.0" }, "engines": { @@ -646,36 +920,37 @@ } }, "node_modules/@jest/core": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.5.0.tgz", - "integrity": "sha512-28UzQc7ulUrOQw1IsN/kv1QES3q2kkbl/wGslyhAclqZ/8cMdB5M68BffkIdSJgKBUt50d3hbwJ92XESlE7LiQ==", - "dependencies": { - "@jest/console": "^29.5.0", - "@jest/reporters": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.6.4.tgz", + "integrity": "sha512-U/vq5ccNTSVgYH7mHnodHmCffGWHJnz/E1BEWlLuK5pM4FZmGfBn/nrJGLjUsSmyx3otCeqc1T31F4y08AMDLg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.4", + "@jest/reporters": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "ci-info": "^3.2.0", "exit": "^0.1.2", "graceful-fs": "^4.2.9", - "jest-changed-files": "^29.5.0", - "jest-config": "^29.5.0", - "jest-haste-map": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-resolve-dependencies": "^29.5.0", - "jest-runner": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "jest-watcher": "^29.5.0", + "jest-changed-files": "^29.6.3", + "jest-config": "^29.6.4", + "jest-haste-map": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-resolve-dependencies": "^29.6.4", + "jest-runner": "^29.6.4", + "jest-runtime": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", + "jest-watcher": "^29.6.4", "micromatch": "^4.0.4", - "pretty-format": "^29.5.0", + "pretty-format": "^29.6.3", "slash": "^3.0.0", "strip-ansi": "^6.0.0" }, @@ -691,167 +966,90 @@ } } }, - "node_modules/@jest/core/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@jest/core/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@jest/core/node_modules/jest-config": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.5.0.tgz", - "integrity": "sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==", - "dependencies": { - "@babel/core": "^7.11.6", - "@jest/test-sequencer": "^29.5.0", - "@jest/types": "^29.5.0", - "babel-jest": "^29.5.0", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "deepmerge": "^4.2.2", - "glob": "^7.1.3", - "graceful-fs": "^4.2.9", - "jest-circus": "^29.5.0", - "jest-environment-node": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-runner": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "micromatch": "^4.0.4", - "parse-json": "^5.2.0", - "pretty-format": "^29.5.0", - "slash": "^3.0.0", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "@types/node": "*", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "ts-node": { - "optional": true - } - } - }, - "node_modules/@jest/core/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@jest/environment": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.5.0.tgz", - "integrity": "sha512-5FXw2+wD29YU1d4I2htpRX7jYnAyTRjP2CsXQdo9SAM8g3ifxWPSV0HnClSn71xwctr0U3oZIIH+dtbfmnbXVQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.6.4.tgz", + "integrity": "sha512-sQ0SULEjA1XUTHmkBRl7A1dyITM9yb1yb3ZNKPX3KlTd6IG7mWUe3e2yfExtC2Zz1Q+mMckOLHmL/qLiuQJrBQ==", + "dev": true, "dependencies": { - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/fake-timers": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", - "jest-mock": "^29.5.0" + "jest-mock": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/expect": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.5.0.tgz", - "integrity": "sha512-PueDR2HGihN3ciUNGr4uelropW7rqUfTiOn+8u0leg/42UhblPxHkfoh0Ruu3I9Y1962P3u2DY4+h7GVTSVU6g==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.6.4.tgz", + "integrity": "sha512-Warhsa7d23+3X5bLbrbYvaehcgX5TLYhI03JKoedTiI8uJU4IhqYBWF7OSSgUyz4IgLpUYPkK0AehA5/fRclAA==", + "dev": true, "dependencies": { - "expect": "^29.5.0", - "jest-snapshot": "^29.5.0" + "expect": "^29.6.4", + "jest-snapshot": "^29.6.4" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/expect-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.5.0.tgz", - "integrity": "sha512-fmKzsidoXQT2KwnrwE0SQq3uj8Z763vzR8LnLBwC2qYWEFpjX8daRsk6rHUM1QvNlEW/UJXNXm59ztmJJWs2Mg==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.6.4.tgz", + "integrity": "sha512-FEhkJhqtvBwgSpiTrocquJCdXPsyvNKcl/n7A3u7X4pVoF4bswm11c9d4AV+kfq2Gpv/mM8x7E7DsRvH+djkrg==", + "dev": true, "dependencies": { - "jest-get-type": "^29.4.3" + "jest-get-type": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/fake-timers": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.5.0.tgz", - "integrity": "sha512-9ARvuAAQcBwDAqOnglWq2zwNIRUDtk/SCkp/ToGEhFv5r86K21l+VEs0qNTaXtyiY0lEePl3kylijSYJQqdbDg==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.6.4.tgz", + "integrity": "sha512-6UkCwzoBK60edXIIWb0/KWkuj7R7Qq91vVInOe3De6DSpaEiqjKcJw4F7XUet24Wupahj9J6PlR09JqJ5ySDHw==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@sinonjs/fake-timers": "^10.0.2", "@types/node": "*", - "jest-message-util": "^29.5.0", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0" + "jest-message-util": "^29.6.3", + "jest-mock": "^29.6.3", + "jest-util": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/globals": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.5.0.tgz", - "integrity": "sha512-S02y0qMWGihdzNbUiqSAiKSpSozSuHX5UYc7QbnHP+D9Lyw8DgGGCinrN9uSuHPeKgSSzvPom2q1nAtBvUsvPQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.6.4.tgz", + "integrity": "sha512-wVIn5bdtjlChhXAzVXavcY/3PEjf4VqM174BM3eGL5kMxLiZD5CLnbmkEyA1Dwh9q8XjP6E8RwjBsY/iCWrWsA==", + "dev": true, "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/expect": "^29.5.0", - "@jest/types": "^29.5.0", - "jest-mock": "^29.5.0" + "@jest/environment": "^29.6.4", + "@jest/expect": "^29.6.4", + "@jest/types": "^29.6.3", + "jest-mock": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/reporters": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.5.0.tgz", - "integrity": "sha512-D05STXqj/M8bP9hQNSICtPqz97u7ffGzZu+9XLucXhkOFBqKcXe04JLZOgIekOxdb73MAoBUFnqvf7MCpKk5OA==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.6.4.tgz", + "integrity": "sha512-sxUjWxm7QdchdrD3NfWKrL8FBsortZeibSJv4XLjESOOjSUOkjQcb0ZHJwfhEGIvBvTluTzfG2yZWZhkrXJu8g==", + "dev": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@jridgewell/trace-mapping": "^0.3.15", + "@jest/console": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", "@types/node": "*", "chalk": "^4.0.0", "collect-v8-coverage": "^1.0.0", @@ -859,13 +1057,13 @@ "glob": "^7.1.3", "graceful-fs": "^4.2.9", "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-instrument": "^5.1.0", + "istanbul-lib-instrument": "^6.0.0", "istanbul-lib-report": "^3.0.0", "istanbul-lib-source-maps": "^4.0.0", "istanbul-reports": "^3.1.3", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", - "jest-worker": "^29.5.0", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", + "jest-worker": "^29.6.4", "slash": "^3.0.0", "string-length": "^4.0.1", "strip-ansi": "^6.0.0", @@ -883,62 +1081,25 @@ } } }, - "node_modules/@jest/reporters/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@jest/reporters/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@jest/reporters/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@jest/schemas": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.3.tgz", - "integrity": "sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, "dependencies": { - "@sinclair/typebox": "^0.25.16" + "@sinclair/typebox": "^0.27.8" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/@jest/source-map": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.4.3.tgz", - "integrity": "sha512-qyt/mb6rLyd9j1jUts4EQncvS6Yy3PM9HghnNv86QBlV+zdL2inCdK1tuVlL+J+lpiw2BI67qXOrX3UurBqQ1w==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, "dependencies": { - "@jridgewell/trace-mapping": "^0.3.15", + "@jridgewell/trace-mapping": "^0.3.18", "callsites": "^3.0.0", "graceful-fs": "^4.2.9" }, @@ -947,12 +1108,13 @@ } }, "node_modules/@jest/test-result": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.5.0.tgz", - "integrity": "sha512-fGl4rfitnbfLsrfx1uUpDEESS7zM8JdgZgOCQuxQvL1Sn/I6ijeAVQWGfXI9zb1i9Mzo495cIpVZhA0yr60PkQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.6.4.tgz", + "integrity": "sha512-uQ1C0AUEN90/dsyEirgMLlouROgSY+Wc/JanVVk0OiUKa5UFh7sJpMEM3aoUBAz2BRNvUJ8j3d294WFuRxSyOQ==", + "dev": true, "dependencies": { - "@jest/console": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/console": "^29.6.4", + "@jest/types": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "collect-v8-coverage": "^1.0.0" }, @@ -961,13 +1123,14 @@ } }, "node_modules/@jest/test-sequencer": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.5.0.tgz", - "integrity": "sha512-yPafQEcKjkSfDXyvtgiV4pevSeyuA6MQr6ZIdVkWJly9vkqjnFfcfhRQqpD5whjoU8EORki752xQmjaqoFjzMQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.6.4.tgz", + "integrity": "sha512-E84M6LbpcRq3fT4ckfKs9ryVanwkaIB0Ws9bw3/yP4seRLg/VaCZ/LgW0MCq5wwk4/iP/qnilD41aj2fsw2RMg==", + "dev": true, "dependencies": { - "@jest/test-result": "^29.5.0", + "@jest/test-result": "^29.6.4", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", + "jest-haste-map": "^29.6.4", "slash": "^3.0.0" }, "engines": { @@ -975,21 +1138,22 @@ } }, "node_modules/@jest/transform": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.5.0.tgz", - "integrity": "sha512-8vbeZWqLJOvHaDfeMuoHITGKSz5qWc9u04lnWrQE3VyuSw604PzQM824ZeX9XSjUCeDiE3GuxZe5UKa8J61NQw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.6.4.tgz", + "integrity": "sha512-8thgRSiXUqtr/pPGY/OsyHuMjGyhVnWrFAwoxmIemlBuiMyU1WFs0tXoNxzcr4A4uErs/ABre76SGmrr5ab/AA==", + "dev": true, "dependencies": { "@babel/core": "^7.11.6", - "@jest/types": "^29.5.0", - "@jridgewell/trace-mapping": "^0.3.15", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", "babel-plugin-istanbul": "^6.1.1", "chalk": "^4.0.0", "convert-source-map": "^2.0.0", "fast-json-stable-stringify": "^2.1.0", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-util": "^29.5.0", + "jest-haste-map": "^29.6.4", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.6.3", "micromatch": "^4.0.4", "pirates": "^4.0.4", "slash": "^3.0.0", @@ -1000,11 +1164,12 @@ } }, "node_modules/@jest/types": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.5.0.tgz", - "integrity": "sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, "dependencies": { - "@jest/schemas": "^29.4.3", + "@jest/schemas": "^29.6.3", "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", @@ -1019,6 +1184,7 @@ "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -1029,9 +1195,10 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, "engines": { "node": ">=6.0.0" } @@ -1040,6 +1207,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, "engines": { "node": ">=6.0.0" } @@ -1047,301 +1215,102 @@ "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.18", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", - "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", - "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" - } - }, - "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" - }, - "node_modules/@jsdevtools/ono": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" - }, - "node_modules/@loopholelabs/polyglot-ts": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@loopholelabs/polyglot-ts/-/polyglot-ts-0.4.0.tgz", - "integrity": "sha512-wASTNWeNOVdjJZ7j+YMWxDL5fyGjfYMNPSMxS7+rrrlkhk5LYKAQbkWjb2WF4j5bMN62psPMhjk+3FnhMmv5tw==" - }, - "node_modules/@loopholelabs/scale-signature": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature/-/scale-signature-0.2.11.tgz", - "integrity": "sha512-/3JoWWrWe7e03isBKqFc5AvwVyxpCdRk2UhV60J2j8d1dreEtyr5/uhWg2J0IUVA98QPqojz1KpZXQ+ycU8c6Q==" - }, - "node_modules/@loopholelabs/scale-signature-http": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature-http/-/scale-signature-http-0.3.8.tgz", - "integrity": "sha512-/Uh7tXSTI6kjGsoZSM6Jt8HVq00yUrBeFV3zjda+Vn2hpUhhwDGj+nMCmwBTgnizF1/+ZgIVMDSrR7IXdAsNsw==", + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz", + "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==", + "dev": true, "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature": "^0.2.11", - "buffer": "6.0.3", - "fast-sha256": "^1.3.0", - "polyfill-crypto.getrandomvalues": "^1.0.0" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@loopholelabs/scalefile": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@loopholelabs/scalefile/-/scalefile-0.1.9.tgz", - "integrity": "sha512-NEn0Xxi2f6+n/TYWwmtRBFAms69ZHTgTSAtnmrAwDQJEuWfgY1Y+aCcNz9dZi8JF8ArcMQJIo8wlMFKPLh4n3A==", + "node_modules/@loopholelabs/polyglot": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@loopholelabs/polyglot/-/polyglot-1.1.3.tgz", + "integrity": "sha512-PLkzZbmZJsXlmE7uTmuMwfl7QbCnafq1ibfvDE+KPrf02R72WRIml1HAVc8oAd8+bRJoEIWXjAGSN4RrxL7fyQ==" + }, + "node_modules/@loopholelabs/scale-signature-interfaces": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature-interfaces/-/scale-signature-interfaces-0.1.7.tgz", + "integrity": "sha512-P/yBDDcN3yCoNVilNDJdwqdnbt0sQbGoJfnGrc/aTtiWq8RDNWu2IIxcB4tde6HT3A5SQaF9LCJQmbY0RyNelA==" + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "buffer": "^6.0.3", - "fast-sha256": "^1.3.0", - "js-yaml": "^4.1.0" - } - }, - "node_modules/@next/env": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-12.3.4.tgz", - "integrity": "sha512-H/69Lc5Q02dq3o+dxxy5O/oNxFsZpdL6WREtOOtOM1B/weonIwDXkekr1KV5DPVPr12IHFPrMrcJQ6bgPMfn7A==" - }, - "node_modules/@next/swc-android-arm-eabi": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.3.4.tgz", - "integrity": "sha512-cM42Cw6V4Bz/2+j/xIzO8nK/Q3Ly+VSlZJTa1vHzsocJRYz8KT6MrreXaci2++SIZCF1rVRCDgAg5PpqRibdIA==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-android-arm64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.3.4.tgz", - "integrity": "sha512-5jf0dTBjL+rabWjGj3eghpLUxCukRhBcEJgwLedewEA/LJk2HyqCvGIwj5rH+iwmq1llCWbOky2dO3pVljrapg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-arm64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.3.4.tgz", - "integrity": "sha512-DqsSTd3FRjQUR6ao0E1e2OlOcrF5br+uegcEGPVonKYJpcr0MJrtYmPxd4v5T6UCJZ+XzydF7eQo5wdGvSZAyA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.3.4.tgz", - "integrity": "sha512-PPF7tbWD4k0dJ2EcUSnOsaOJ5rhT3rlEt/3LhZUGiYNL8KvoqczFrETlUx0cUYaXe11dRA3F80Hpt727QIwByQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-freebsd-x64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.3.4.tgz", - "integrity": "sha512-KM9JXRXi/U2PUM928z7l4tnfQ9u8bTco/jb939pdFUHqc28V43Ohd31MmZD1QzEK4aFlMRaIBQOWQZh4D/E5lQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm-gnueabihf": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.3.4.tgz", - "integrity": "sha512-3zqD3pO+z5CZyxtKDTnOJ2XgFFRUBciOox6EWkoZvJfc9zcidNAQxuwonUeNts6Xbm8Wtm5YGIRC0x+12YH7kw==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.3.4.tgz", - "integrity": "sha512-kiX0vgJGMZVv+oo1QuObaYulXNvdH/IINmvdZnVzMO/jic/B8EEIGlZ8Bgvw8LCjH3zNVPO3mGrdMvnEEPEhKA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.3.4.tgz", - "integrity": "sha512-EETZPa1juczrKLWk5okoW2hv7D7WvonU+Cf2CgsSoxgsYbUCZ1voOpL4JZTOb6IbKMDo6ja+SbY0vzXZBUMvkQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.3.4.tgz", - "integrity": "sha512-4csPbRbfZbuWOk3ATyWcvVFdD9/Rsdq5YHKvRuEni68OCLkfy4f+4I9OBpyK1SKJ00Cih16NJbHE+k+ljPPpag==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.3.4.tgz", - "integrity": "sha512-YeBmI+63Ro75SUiL/QXEVXQ19T++58aI/IINOyhpsRL1LKdyfK/35iilraZEFz9bLQrwy1LYAR5lK200A9Gjbg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.3.4.tgz", - "integrity": "sha512-Sd0qFUJv8Tj0PukAYbCCDbmXcMkbIuhnTeHm9m4ZGjCf6kt7E/RMs55Pd3R5ePjOkN7dJEuxYBehawTR/aPDSQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, "engines": { - "node": ">= 10" + "node": ">= 8" } }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.3.4.tgz", - "integrity": "sha512-rt/vv/vg/ZGGkrkKcuJ0LyliRdbskQU+91bje+PgoYmxTZf/tYs6IfbmgudBJk6gH3QnjHWbkphDdRQrseRefQ==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, "engines": { - "node": ">= 10" + "node": ">= 8" } }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.3.4.tgz", - "integrity": "sha512-DQ20JEfTBZAgF8QCjYfJhv2/279M6onxFjdG/+5B0Cyj00/EdBxiWb2eGGFgQhrBbNv/lsvzFbbi0Ptf8Vw/bg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, "engines": { - "node": ">= 10" + "node": ">= 8" } }, "node_modules/@sinclair/typebox": { - "version": "0.25.24", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", - "integrity": "sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==" + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true }, "node_modules/@sinonjs/commons": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz", - "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "dev": true, "dependencies": { "type-detect": "4.0.8" } }, "node_modules/@sinonjs/fake-timers": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.0.2.tgz", - "integrity": "sha512-SwUDyjWnah1AaNl7kxsa7cfLhlTYoiyhDAIgyh+El30YvXs/o7OLXpYH88Zdhyx9JExKrmHDJ+10bwIcY80Jmw==", - "dependencies": { - "@sinonjs/commons": "^2.0.0" - } - }, - "node_modules/@swc/helpers": { - "version": "0.4.14", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz", - "integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, "dependencies": { - "tslib": "^2.4.0" + "@sinonjs/commons": "^3.0.0" } }, "node_modules/@tootallnate/once": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "dev": true, "engines": { "node": ">= 10" } }, "node_modules/@types/babel__core": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", - "integrity": "sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ==", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", + "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", + "dev": true, "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -1354,6 +1323,7 @@ "version": "7.6.4", "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "dev": true, "dependencies": { "@babel/types": "^7.0.0" } @@ -1362,33 +1332,26 @@ "version": "7.4.1", "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "dev": true, "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__traverse": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.18.3.tgz", - "integrity": "sha512-1kbcJ40lLB7MHsj39U4Sh1uTd2E7rLEa79kmDpI6cy+XiXsteB3POdQomoq4FxszMrO3ZYchkhYJw7A2862b3w==", - "dependencies": { - "@babel/types": "^7.3.0" - } - }, - "node_modules/@types/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", + "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", "dev": true, "dependencies": { - "@types/minimatch": "^5.1.2", - "@types/node": "*" + "@babel/types": "^7.20.7" } }, "node_modules/@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", + "dev": true, "dependencies": { "@types/node": "*" } @@ -1396,12 +1359,14 @@ "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==" + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true }, "node_modules/@types/istanbul-lib-report": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, "dependencies": { "@types/istanbul-lib-coverage": "*" } @@ -1410,14 +1375,16 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "dev": true, "dependencies": { "@types/istanbul-lib-report": "*" } }, "node_modules/@types/jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.0.tgz", - "integrity": "sha512-3Emr5VOl/aoBwnWcH/EFQvlSAmjV+XtV9GGu5mwdYew5vhQh0IUZx/60x0TzHDu09Bi7HMx10t/namdJw5QIcg==", + "version": "29.5.4", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.4.tgz", + "integrity": "sha512-PhglGmhWeD46FYOVLt3X7TiWjzwuVGW9wG/4qocPevXMjCmrIc5b6db9WjeGE4QYVpUAWMDv3v0IiBwObY289A==", + "dev": true, "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" @@ -1427,6 +1394,7 @@ "version": "20.0.1", "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz", "integrity": "sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==", + "dev": true, "dependencies": { "@types/node": "*", "@types/tough-cookie": "*", @@ -1434,68 +1402,46 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" - }, - "node_modules/@types/minimatch": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", - "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, "node_modules/@types/node": { - "version": "18.15.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz", - "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", - "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } - }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } + "version": "20.5.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.8.tgz", + "integrity": "sha512-eajsR9aeljqNhK028VG0Wuw+OaY5LLxYmxeoXynIoE6jannr9/Ucd1LL0hSSoafk5LTYG+FfqsyGt81Q6Zkybw==", + "dev": true }, - "node_modules/@types/prettier": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", - "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==" + "node_modules/@types/semver": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", + "integrity": "sha512-cJRQXpObxfNKkFAZbJl2yjWtJCqELQIdShsogr1d2MilP8dKD9TE/nEKHkJgUNHdGKCQaf9HbIynuV2csLGVLg==", + "dev": true }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" + "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", + "dev": true }, "node_modules/@types/tough-cookie": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz", - "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==" + "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==", + "dev": true }, "node_modules/@types/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==", + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", "dev": true }, "node_modules/@types/yargs": { "version": "17.0.24", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", + "dev": true, "dependencies": { "@types/yargs-parser": "*" } @@ -1503,17 +1449,209 @@ "node_modules/@types/yargs-parser": { "version": "21.0.0", "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", - "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.5.0.tgz", + "integrity": "sha512-2pktILyjvMaScU6iK3925uvGU87E+N9rh372uGZgiMYwafaw9SXq86U04XPq3UH6tzRvNgBsub6x2DacHc33lw==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/type-utils": "6.5.0", + "@typescript-eslint/utils": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.5.0.tgz", + "integrity": "sha512-LMAVtR5GN8nY0G0BadkG0XIe4AcNMeyEy3DyhKGAh9k4pLSMBO7rF29JvDBpZGCmp5Pgz5RLHP6eCpSYZJQDuQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/typescript-estree": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.5.0.tgz", + "integrity": "sha512-A8hZ7OlxURricpycp5kdPTH3XnjG85UpJS6Fn4VzeoH4T388gQJ/PGP4ole5NfKt4WDVhmLaQ/dBLNDC4Xl/Kw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.5.0.tgz", + "integrity": "sha512-f7OcZOkRivtujIBQ4yrJNIuwyCQO1OjocVqntl9dgSIZAdKqicj3xFDqDOzHDlGCZX990LqhLQXWRnQvsapq8A==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.5.0", + "@typescript-eslint/utils": "6.5.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.5.0.tgz", + "integrity": "sha512-eqLLOEF5/lU8jW3Bw+8auf4lZSbbljHR2saKnYqON12G/WsJrGeeDHWuQePoEf9ro22+JkbPfWQwKEC5WwLQ3w==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.5.0.tgz", + "integrity": "sha512-q0rGwSe9e5Kk/XzliB9h2LBc9tmXX25G0833r7kffbl5437FPWb2tbpIV9wAATebC/018pGa9fwPDuvGN+LxWQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/visitor-keys": "6.5.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.5.0.tgz", + "integrity": "sha512-9nqtjkNykFzeVtt9Pj6lyR9WEdd8npPhhIPM992FWVkZuS6tmxHfGVnlUcjpUP2hv8r4w35nT33mlxd+Be1ACQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.5.0", + "@typescript-eslint/types": "6.5.0", + "@typescript-eslint/typescript-estree": "6.5.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.5.0.tgz", + "integrity": "sha512-yCB/2wkbv3hPsh02ZS8dFQnij9VVQXJMN/gbQsaaY+zxALkZnxa/wagvLEFsAWMPv7d7lxQmNsIzGU1w/T/WyA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.5.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } }, "node_modules/abab": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", - "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==" + "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==", + "dev": true }, "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -1525,15 +1663,26 @@ "version": "7.0.1", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz", "integrity": "sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==", + "dev": true, "dependencies": { "acorn": "^8.1.0", "acorn-walk": "^8.0.2" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/acorn-walk": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -1542,6 +1691,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, "dependencies": { "debug": "4" }, @@ -1549,10 +1699,27 @@ "node": ">= 6.0.0" } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, "dependencies": { "type-fest": "^0.21.3" }, @@ -1563,10 +1730,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/ansi-escapes/node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, "engines": { "node": ">=8" } @@ -1575,6 +1755,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -1589,6 +1770,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" @@ -1600,63 +1782,34 @@ "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/asn1.js": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", - "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", - "dev": true, - "dependencies": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "safer-buffer": "^2.1.0" - } - }, - "node_modules/asn1.js/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/assert": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz", - "integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==", + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true, - "dependencies": { - "es6-object-assign": "^1.1.0", - "is-nan": "^1.2.1", - "object-is": "^1.0.1", - "util": "^0.12.0" + "engines": { + "node": ">=8" } }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/available-typed-arrays": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", - "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true }, "node_modules/babel-jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.5.0.tgz", - "integrity": "sha512-mA4eCDh5mSo2EcA9xQjVTpmbbNk32Zb3Q3QFQsNhaK56Q+yoXowzFodLux30HRgyOho5rsQ6B0P9QpMkvvnJ0Q==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.4.tgz", + "integrity": "sha512-meLj23UlSLddj6PC+YTOFRgDAtjnZom8w/ACsrx0gtPtv5cJZk0A5Unk5bV4wixD7XaPCN1fQvpww8czkZURmw==", + "dev": true, "dependencies": { - "@jest/transform": "^29.5.0", + "@jest/transform": "^29.6.4", "@types/babel__core": "^7.1.14", "babel-plugin-istanbul": "^6.1.1", - "babel-preset-jest": "^29.5.0", + "babel-preset-jest": "^29.6.3", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "slash": "^3.0.0" @@ -1672,6 +1825,7 @@ "version": "6.1.1", "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@istanbuljs/load-nyc-config": "^1.0.0", @@ -1683,10 +1837,36 @@ "node": ">=8" } }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/babel-plugin-jest-hoist": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.5.0.tgz", - "integrity": "sha512-zSuuuAlTMT4mzLj2nPnUm6fsE6270vdOfnpbJ+RmruU75UhLFvL0N2NgI7xpeS7NaB6hGqmd5pVpGTDYvi4Q3w==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, "dependencies": { "@babel/template": "^7.3.3", "@babel/types": "^7.3.3", @@ -1701,6 +1881,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, "dependencies": { "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-bigint": "^7.8.3", @@ -1720,11 +1901,12 @@ } }, "node_modules/babel-preset-jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.5.0.tgz", - "integrity": "sha512-JOMloxOqdiBSxMAzjRaH023/vvcaSaec49zvg+2LmNsktC7ei39LTJGw02J+9uUtTZUq6xbLyJ4dxe9sSmIuAg==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, "dependencies": { - "babel-plugin-jest-hoist": "^29.5.0", + "babel-plugin-jest-hoist": "^29.6.3", "babel-preset-current-node-syntax": "^1.0.0" }, "engines": { @@ -1737,7 +1919,8 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/base64-js": { "version": "1.5.1", @@ -1758,24 +1941,21 @@ } ] }, - "node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "dev": true - }, "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { - "balanced-match": "^1.0.0" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, "node_modules/braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, "dependencies": { "fill-range": "^7.0.1" }, @@ -1783,80 +1963,11 @@ "node": ">=8" } }, - "node_modules/brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", - "dev": true - }, - "node_modules/browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "dependencies": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "dev": true, - "dependencies": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "node_modules/browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/browserify-rsa": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", - "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", - "dev": true, - "dependencies": { - "bn.js": "^5.0.0", - "randombytes": "^2.0.1" - } - }, - "node_modules/browserify-sign": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", - "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", - "dev": true, - "dependencies": { - "bn.js": "^5.1.1", - "browserify-rsa": "^4.0.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "elliptic": "^6.5.3", - "inherits": "^2.0.4", - "parse-asn1": "^5.1.5", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - } - }, "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", + "version": "4.21.10", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.10.tgz", + "integrity": "sha512-bipEBdZfVH5/pwrvqc+Ub0kUPVfGUhlKxbvfD+z1BDnPEO/X98ruXGA1WP5ASpAFKan7Qr6j736IacbZQuAlKQ==", + "dev": true, "funding": [ { "type": "opencollective", @@ -1865,13 +1976,17 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" + "caniuse-lite": "^1.0.30001517", + "electron-to-chromium": "^1.4.477", + "node-releases": "^2.0.13", + "update-browserslist-db": "^1.0.11" }, "bin": { "browserslist": "cli.js" @@ -1884,6 +1999,7 @@ "version": "0.2.6", "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, "dependencies": { "fast-json-stable-stringify": "2.x" }, @@ -1895,6 +2011,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, "dependencies": { "node-int64": "^0.4.0" } @@ -1919,47 +2036,20 @@ ], "dependencies": { "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" - }, - "node_modules/buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", - "dev": true - }, - "node_modules/builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==", - "dev": true - }, - "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "ieee754": "^1.2.1" } }, - "node_modules/call-me-maybe": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", - "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, "engines": { "node": ">=6" } @@ -1968,14 +2058,16 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, "engines": { "node": ">=6" } }, "node_modules/caniuse-lite": { - "version": "1.0.30001480", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001480.tgz", - "integrity": "sha512-q7cpoPPvZYgtyC4VaBSN0Bt+PJ4c4EYRf0DrduInOz2SkFpHD5p3LnvEpqBp7UnJn+8x1Ogl1s38saUxe+ihQQ==", + "version": "1.0.30001525", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001525.tgz", + "integrity": "sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q==", + "dev": true, "funding": [ { "type": "opencollective", @@ -1995,6 +2087,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -2010,6 +2103,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, "engines": { "node": ">=10" } @@ -2018,6 +2112,7 @@ "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true, "funding": [ { "type": "github", @@ -2028,25 +2123,17 @@ "node": ">=8" } }, - "node_modules/cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, "node_modules/cjs-module-lexer": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", - "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", + "dev": true }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", @@ -2060,20 +2147,23 @@ "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, "engines": { "iojs": ">= 1.0.0", "node": ">= 0.12.0" } }, "node_modules/collect-v8-coverage": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", - "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -2084,12 +2174,14 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -2097,71 +2189,23 @@ "node": ">= 0.8" } }, - "node_modules/commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", - "engines": { - "node": "^12.20.0 || >=14" - } - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" - }, - "node_modules/create-ecdh": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", - "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", - "dev": true, - "dependencies": { - "bn.js": "^4.1.0", - "elliptic": "^6.5.3" - } - }, - "node_modules/create-ecdh/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, - "node_modules/create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "node_modules/create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2171,37 +2215,17 @@ "node": ">= 8" } }, - "node_modules/crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "dev": true, - "dependencies": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - }, - "engines": { - "node": "*" - } - }, "node_modules/cssom": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz", - "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==" + "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==", + "dev": true }, "node_modules/cssstyle": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", + "dev": true, "dependencies": { "cssom": "~0.3.6" }, @@ -2212,12 +2236,14 @@ "node_modules/cssstyle/node_modules/cssom": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", - "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" + "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", + "dev": true }, "node_modules/data-urls": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", "integrity": "sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==", + "dev": true, "dependencies": { "abab": "^2.0.6", "whatwg-mimetype": "^3.0.0", @@ -2231,6 +2257,7 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -2246,97 +2273,94 @@ "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", + "dev": true }, "node_modules/dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", + "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", + "dev": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true }, "node_modules/deepmerge": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/define-properties": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz", - "integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==", "dev": true, - "dependencies": { - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node": ">=0.10.0" } }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, "engines": { "node": ">=0.4.0" } }, - "node_modules/des.js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", - "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, "engines": { "node": ">=8" } }, "node_modules/diff-sequences": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", - "integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, "dependencies": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "node_modules/diffie-hellman/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } }, "node_modules/domexception": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", "integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==", + "dev": true, "dependencies": { "webidl-conversions": "^7.0.0" }, @@ -2345,35 +2369,16 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.365", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.365.tgz", - "integrity": "sha512-FRHZO+1tUNO4TOPXmlxetkoaIY8uwHzd1kKopK/Gx2SKn1L47wJXWD44wxP5CGRyyP98z/c8e1eBzJrgPeiBOg==" - }, - "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "version": "1.4.508", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.508.tgz", + "integrity": "sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==", "dev": true }, "node_modules/emittery": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, "engines": { "node": ">=12" }, @@ -2384,12 +2389,14 @@ "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, "engines": { "node": ">=0.12" }, @@ -2401,41 +2408,41 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, "dependencies": { "is-arrayish": "^0.2.1" } }, - "node_modules/es6-object-assign": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", - "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==", - "dev": true - }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, "engines": { "node": ">=6" } }, "node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/escodegen": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", - "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "dev": true, "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" + "esutils": "^2.0.2" }, "bin": { "escodegen": "bin/escodegen.js", @@ -2448,10 +2455,110 @@ "source-map": "~0.6.1" } }, + "node_modules/eslint": { + "version": "8.48.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", + "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "8.48.0", + "@humanwhocodes/config-array": "^0.11.10", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -2460,10 +2567,35 @@ "node": ">=4" } }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, "engines": { "node": ">=4.0" } @@ -2472,33 +2604,16 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", "dev": true, "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "dependencies": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" + "node": ">=0.10.0" } }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", @@ -2521,52 +2636,113 @@ "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/expect": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.5.0.tgz", - "integrity": "sha512-yM7xqUrCO2JdpFo4XpM82t+PJBFybdqoQuJLDGeDX2ij8NZzqRHyu3Hp188/JX7SWqud+7t4MUdvcgGBICMHZg==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.6.4.tgz", + "integrity": "sha512-F2W2UyQ8XYyftHT57dtfg8Ue3X5qLgm2sSug0ivvLRH/VKNRL/pDxg/TH7zVzbQB0tu80clNFy6LU7OS/VSEKA==", + "dev": true, "dependencies": { - "@jest/expect-utils": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0" + "@jest/expect-utils": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true }, "node_modules/fast-sha256": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==" }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, "dependencies": { "bser": "2.1.1" } }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2575,60 +2751,66 @@ } }, "node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, "dependencies": { - "locate-path": "^5.0.0", + "locate-path": "^6.0.0", "path-exists": "^4.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "node_modules/flat-cache": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.0.tgz", + "integrity": "sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==", + "dev": true, "dependencies": { - "is-callable": "^1.1.3" + "flatted": "^3.2.7", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": ">=12.0.0" } }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" }, "engines": { - "node": ">=12" + "node": ">= 6" } }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -2641,12 +2823,14 @@ "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, "engines": { "node": ">=6.9.0" } @@ -2655,27 +2839,16 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, "engines": { "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-intrinsic": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", - "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", - "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, "engines": { "node": ">=8.0.0" } @@ -2684,6 +2857,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, "engines": { "node": ">=10" }, @@ -2692,71 +2866,89 @@ } }, "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" }, "engines": { - "node": ">=12" + "node": "*" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, "engines": { - "node": ">=4" + "node": ">=10.13.0" } }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "node_modules/globals": { + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "dev": true, "dependencies": { - "get-intrinsic": "^1.1.3" + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" }, "engines": { - "node": ">=0.4.7" + "node": ">=10" }, - "optionalDependencies": { - "uglify-js": "^3.1.4" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -2768,86 +2960,16 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hash-base": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "dev": true, - "dependencies": { - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - }, "engines": { - "node": ">=4" - } - }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "dev": true, - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" + "node": ">=8" } }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", + "dev": true, "dependencies": { "whatwg-encoding": "^2.0.0" }, @@ -2858,12 +2980,14 @@ "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==" + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true }, "node_modules/http-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "dev": true, "dependencies": { "@tootallnate/once": "2", "agent-base": "6", @@ -2873,16 +2997,11 @@ "node": ">= 6" } }, - "node_modules/https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==", - "dev": true - }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, "dependencies": { "agent-base": "6", "debug": "4" @@ -2895,6 +3014,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, "engines": { "node": ">=10.17.0" } @@ -2903,6 +3023,7 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, @@ -2929,10 +3050,36 @@ } ] }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/import-local": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, "dependencies": { "pkg-dir": "^4.2.0", "resolve-cwd": "^3.0.0" @@ -2951,6 +3098,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, "engines": { "node": ">=0.8.19" } @@ -2959,6 +3107,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -2967,43 +3116,20 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" - }, - "node_modules/is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true }, "node_modules/is-core-module": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", - "integrity": "sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", + "dev": true, "dependencies": { "has": "^1.0.3" }, @@ -3011,10 +3137,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, "engines": { "node": ">=8" } @@ -3023,57 +3159,52 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, "engines": { "node": ">=6" } }, - "node_modules/is-generator-function": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", - "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-nan": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", - "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "dependencies": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" + "is-extglob": "^2.1.1" }, "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node": ">=0.10.0" } }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, "engines": { "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==" + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, "engines": { "node": ">=8" }, @@ -3081,69 +3212,56 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-typed-array": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", - "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", - "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" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true }, "node_modules/istanbul-lib-coverage": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, "engines": { "node": ">=8" } }, "node_modules/istanbul-lib-instrument": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", - "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.0.tgz", + "integrity": "sha512-x58orMzEVfzPUKqlbLd1hXCnySCxKdDKa6Rjg97CwuLLRI4g3FHTdnExu1OqffVFay6zeMW+T6/DowFLndWnIw==", + "dev": true, "dependencies": { "@babel/core": "^7.12.3", "@babel/parser": "^7.14.7", "@istanbuljs/schema": "^0.1.2", "istanbul-lib-coverage": "^3.2.0", - "semver": "^6.3.0" + "semver": "^7.5.4" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, "dependencies": { "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", + "make-dir": "^4.0.0", "supports-color": "^7.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" } }, "node_modules/istanbul-lib-source-maps": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, "dependencies": { "debug": "^4.1.1", "istanbul-lib-coverage": "^3.0.0", @@ -3154,9 +3272,10 @@ } }, "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", + "dev": true, "dependencies": { "html-escaper": "^2.0.0", "istanbul-lib-report": "^3.0.0" @@ -3166,14 +3285,15 @@ } }, "node_modules/jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest/-/jest-29.5.0.tgz", - "integrity": "sha512-juMg3he2uru1QoXX078zTa7pO85QyB9xajZc6bU+d9yEGwrKX6+vGmJQ3UdVZsvTEUARIdObzH68QItim6OSSQ==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.6.4.tgz", + "integrity": "sha512-tEFhVQFF/bzoYV1YuGyzLPZ6vlPrdfvDmmAxudA1dLEuiztqg2Rkx20vkKY32xiDROcD2KXlgZ7Cu8RPeEHRKw==", + "dev": true, "dependencies": { - "@jest/core": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/core": "^29.6.4", + "@jest/types": "^29.6.3", "import-local": "^3.0.2", - "jest-cli": "^29.5.0" + "jest-cli": "^29.6.4" }, "bin": { "jest": "bin/jest.js" @@ -3191,11 +3311,13 @@ } }, "node_modules/jest-changed-files": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.5.0.tgz", - "integrity": "sha512-IFG34IUMUaNBIxjQXF/iu7g6EcdMrGRRxaUSw92I/2g2YC6vCdTltl4nHvt7Ci5nSJwXIkCu8Ka1DKF+X7Z1Ag==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.6.3.tgz", + "integrity": "sha512-G5wDnElqLa4/c66ma5PG9eRjE342lIbF6SUnTJi26C3J28Fv2TVY2rOyKB9YGbSA5ogwevgmxc4j4aVjrEK6Yg==", + "dev": true, "dependencies": { "execa": "^5.0.0", + "jest-util": "^29.6.3", "p-limit": "^3.1.0" }, "engines": { @@ -3203,27 +3325,28 @@ } }, "node_modules/jest-circus": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.5.0.tgz", - "integrity": "sha512-gq/ongqeQKAplVxqJmbeUOJJKkW3dDNPY8PjhJ5G0lBRvu0e3EWGxGy5cI4LAGA7gV2UHCtWBI4EMXK8c9nQKA==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/expect": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.6.4.tgz", + "integrity": "sha512-YXNrRyntVUgDfZbjXWBMPslX1mQ8MrSG0oM/Y06j9EYubODIyHWP8hMUbjbZ19M3M+zamqEur7O80HODwACoJw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/expect": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", - "dedent": "^0.7.0", + "dedent": "^1.0.0", "is-generator-fn": "^2.0.0", - "jest-each": "^29.5.0", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", + "jest-each": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-runtime": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", "p-limit": "^3.1.0", - "pretty-format": "^29.5.0", + "pretty-format": "^29.6.3", "pure-rand": "^6.0.0", "slash": "^3.0.0", "stack-utils": "^2.0.3" @@ -3233,91 +3356,65 @@ } }, "node_modules/jest-cli": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.5.0.tgz", - "integrity": "sha512-L1KcP1l4HtfwdxXNFCL5bmUbLQiKrakMUriBEcc1Vfz6gx31ORKdreuWvmQVBit+1ss9NNR3yxjwfwzZNdQXJw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.6.4.tgz", + "integrity": "sha512-+uMCQ7oizMmh8ZwRfZzKIEszFY9ksjjEQnTEMTaL7fYiL3Kw4XhqT9bYh+A4DQKUb67hZn2KbtEnDuHvcgK4pQ==", + "dev": true, "dependencies": { - "@jest/core": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/core": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.9", "import-local": "^3.0.2", - "jest-config": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", + "jest-config": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", "prompts": "^2.0.1", "yargs": "^17.3.1" }, - "bin": { - "jest": "bin/jest.js" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/jest-cli/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/jest-cli/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, + "bin": { + "jest": "bin/jest.js" + }, "engines": { - "node": "*" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } } }, - "node_modules/jest-cli/node_modules/jest-config": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.5.0.tgz", - "integrity": "sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==", + "node_modules/jest-config": { + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.6.4.tgz", + "integrity": "sha512-JWohr3i9m2cVpBumQFv2akMEnFEPVOh+9L2xIBJhJ0zOaci2ZXuKJj0tgMKQCBZAKA09H049IR4HVS/43Qb19A==", + "dev": true, "dependencies": { "@babel/core": "^7.11.6", - "@jest/test-sequencer": "^29.5.0", - "@jest/types": "^29.5.0", - "babel-jest": "^29.5.0", + "@jest/test-sequencer": "^29.6.4", + "@jest/types": "^29.6.3", + "babel-jest": "^29.6.4", "chalk": "^4.0.0", "ci-info": "^3.2.0", "deepmerge": "^4.2.2", "glob": "^7.1.3", "graceful-fs": "^4.2.9", - "jest-circus": "^29.5.0", - "jest-environment-node": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-runner": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", + "jest-circus": "^29.6.4", + "jest-environment-node": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-runner": "^29.6.4", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", "micromatch": "^4.0.4", "parse-json": "^5.2.0", - "pretty-format": "^29.5.0", + "pretty-format": "^29.6.3", "slash": "^3.0.0", "strip-json-comments": "^3.1.1" }, @@ -3337,35 +3434,26 @@ } } }, - "node_modules/jest-cli/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/jest-diff": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.5.0.tgz", - "integrity": "sha512-LtxijLLZBduXnHSniy0WMdaHjmQnt3g5sa16W4p0HqukYTTsyTW3GD1q41TyGl5YFXj/5B2U6dlh5FM1LIMgxw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.6.4.tgz", + "integrity": "sha512-9F48UxR9e4XOEZvoUXEHSWY4qC4zERJaOfrbBg9JpbJOO43R1vN76REt/aMGZoY6GD5g84nnJiBIVlscegefpw==", + "dev": true, "dependencies": { "chalk": "^4.0.0", - "diff-sequences": "^29.4.3", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-docblock": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.4.3.tgz", - "integrity": "sha512-fzdTftThczeSD9nZ3fzA/4KkHtnmllawWrXO69vtI+L9WjEIuXWs4AmyME7lN5hU7dB0sHhuPfcKofRsUb/2Fg==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.6.3.tgz", + "integrity": "sha512-2+H+GOTQBEm2+qFSQ7Ma+BvyV+waiIFxmZF5LdpBsAEjWX8QYjSCa4FrkIYtbfXUJJJnFCYrOtt6TZ+IAiTjBQ==", + "dev": true, "dependencies": { "detect-newline": "^3.0.0" }, @@ -3374,32 +3462,34 @@ } }, "node_modules/jest-each": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.5.0.tgz", - "integrity": "sha512-HM5kIJ1BTnVt+DQZ2ALp3rzXEl+g726csObrW/jpEGl+CDSSQpOJJX2KE/vEg8cxcMXdyEPu6U4QX5eruQv5hA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.6.3.tgz", + "integrity": "sha512-KoXfJ42k8cqbkfshW7sSHcdfnv5agDdHCPA87ZBdmHP+zJstTJc0ttQaJ/x7zK6noAL76hOuTIJ6ZkQRS5dcyg==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "chalk": "^4.0.0", - "jest-get-type": "^29.4.3", - "jest-util": "^29.5.0", - "pretty-format": "^29.5.0" + "jest-get-type": "^29.6.3", + "jest-util": "^29.6.3", + "pretty-format": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-environment-jsdom": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-29.5.0.tgz", - "integrity": "sha512-/KG8yEK4aN8ak56yFVdqFDzKNHgF4BAymCx2LbPNPsUshUlfAl0eX402Xm1pt+eoG9SLZEUVifqXtX8SK74KCw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-29.6.4.tgz", + "integrity": "sha512-K6wfgUJ16DoMs02JYFid9lOsqfpoVtyJxpRlnTxUHzvZWBnnh2VNGRB9EC1Cro96TQdq5TtSjb3qUjNaJP9IyA==", + "dev": true, "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/environment": "^29.6.4", + "@jest/fake-timers": "^29.6.4", + "@jest/types": "^29.6.3", "@types/jsdom": "^20.0.0", "@types/node": "*", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0", + "jest-mock": "^29.6.3", + "jest-util": "^29.6.3", "jsdom": "^20.0.0" }, "engines": { @@ -3415,43 +3505,46 @@ } }, "node_modules/jest-environment-node": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.5.0.tgz", - "integrity": "sha512-ExxuIK/+yQ+6PRGaHkKewYtg6hto2uGCgvKdb2nfJfKXgZ17DfXjvbZ+jA1Qt9A8EQSfPnt5FKIfnOO3u1h9qw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.6.4.tgz", + "integrity": "sha512-i7SbpH2dEIFGNmxGCpSc2w9cA4qVD+wfvg2ZnfQ7XVrKL0NA5uDVBIiGH8SR4F0dKEv/0qI5r+aDomDf04DpEQ==", + "dev": true, "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/environment": "^29.6.4", + "@jest/fake-timers": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0" + "jest-mock": "^29.6.3", + "jest-util": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-get-type": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz", - "integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-haste-map": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.5.0.tgz", - "integrity": "sha512-IspOPnnBro8YfVYSw6yDRKh/TiCdRngjxeacCps1cQ9cgVN6+10JUcuJ1EabrgYLOATsIAigxA0rLR9x/YlrSA==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.6.4.tgz", + "integrity": "sha512-12Ad+VNTDHxKf7k+M65sviyynRoZYuL1/GTuhEVb8RYsNSNln71nANRb/faSyWvx0j+gHcivChXHIoMJrGYjog==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@types/graceful-fs": "^4.1.3", "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", "graceful-fs": "^4.2.9", - "jest-regex-util": "^29.4.3", - "jest-util": "^29.5.0", - "jest-worker": "^29.5.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.6.3", + "jest-worker": "^29.6.4", "micromatch": "^4.0.4", "walker": "^1.0.8" }, @@ -3463,43 +3556,46 @@ } }, "node_modules/jest-leak-detector": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.5.0.tgz", - "integrity": "sha512-u9YdeeVnghBUtpN5mVxjID7KbkKE1QU4f6uUwuxiY0vYRi9BUCLKlPEZfDGR67ofdFmDz9oPAy2G92Ujrntmow==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.6.3.tgz", + "integrity": "sha512-0kfbESIHXYdhAdpLsW7xdwmYhLf1BRu4AA118/OxFm0Ho1b2RcTmO4oF6aAMaxpxdxnJ3zve2rgwzNBD4Zbm7Q==", + "dev": true, "dependencies": { - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-matcher-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.5.0.tgz", - "integrity": "sha512-lecRtgm/rjIK0CQ7LPQwzCs2VwW6WAahA55YBuI+xqmhm7LAaxokSB8C97yJeYyT+HvQkH741StzpU41wohhWw==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.6.4.tgz", + "integrity": "sha512-KSzwyzGvK4HcfnserYqJHYi7sZVqdREJ9DMPAKVbS98JsIAvumihaNUbjrWw0St7p9IY7A9UskCW5MYlGmBQFQ==", + "dev": true, "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^29.5.0", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" + "jest-diff": "^29.6.4", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-message-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.5.0.tgz", - "integrity": "sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.6.3.tgz", + "integrity": "sha512-FtzaEEHzjDpQp51HX4UMkPZjy46ati4T5pEMyM6Ik48ztu4T9LQplZ6OsimHx7EuM9dfEh5HJa6D3trEftu3dA==", + "dev": true, "dependencies": { "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.5.0", + "pretty-format": "^29.6.3", "slash": "^3.0.0", "stack-utils": "^2.0.3" }, @@ -3508,13 +3604,14 @@ } }, "node_modules/jest-mock": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.5.0.tgz", - "integrity": "sha512-GqOzvdWDE4fAV2bWQLQCkujxYWL7RxjCnj71b5VhDAGOevB3qj3Ovg26A5NI84ZpODxyzaozXLOh2NCgkbvyaw==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.6.3.tgz", + "integrity": "sha512-Z7Gs/mOyTSR4yPsaZ72a/MtuK6RnC3JYqWONe48oLaoEcYwEDxqvbXz85G4SJrm2Z5Ar9zp6MiHF4AlFlRM4Pg==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@types/node": "*", - "jest-util": "^29.5.0" + "jest-util": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -3524,6 +3621,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, "engines": { "node": ">=6" }, @@ -3537,24 +3635,26 @@ } }, "node_modules/jest-regex-util": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.4.3.tgz", - "integrity": "sha512-O4FglZaMmWXbGHSQInfXewIsd1LMn9p3ZXB/6r4FOkyhX2/iP/soMG98jGvk/A3HAN78+5VWcBGO0BJAPRh4kg==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-resolve": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.5.0.tgz", - "integrity": "sha512-1TzxJ37FQq7J10jPtQjcc+MkCkE3GBpBecsSUWJ0qZNJpmg6m0D9/7II03yJulm3H/fvVjgqLh/k2eYg+ui52w==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.6.4.tgz", + "integrity": "sha512-fPRq+0vcxsuGlG0O3gyoqGTAxasagOxEuyoxHeyxaZbc9QNek0AmJWSkhjlMG+mTsj+8knc/mWb3fXlRNVih7Q==", + "dev": true, "dependencies": { "chalk": "^4.0.0", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", + "jest-haste-map": "^29.6.4", "jest-pnp-resolver": "^1.2.2", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", + "jest-util": "^29.6.3", + "jest-validate": "^29.6.3", "resolve": "^1.20.0", "resolve.exports": "^2.0.0", "slash": "^3.0.0" @@ -3564,41 +3664,43 @@ } }, "node_modules/jest-resolve-dependencies": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.5.0.tgz", - "integrity": "sha512-sjV3GFr0hDJMBpYeUuGduP+YeCRbd7S/ck6IvL3kQ9cpySYKqcqhdLLC2rFwrcL7tz5vYibomBrsFYWkIGGjOg==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.6.4.tgz", + "integrity": "sha512-7+6eAmr1ZBF3vOAJVsfLj1QdqeXG+WYhidfLHBRZqGN24MFRIiKG20ItpLw2qRAsW/D2ZUUmCNf6irUr/v6KHA==", + "dev": true, "dependencies": { - "jest-regex-util": "^29.4.3", - "jest-snapshot": "^29.5.0" + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.6.4" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-runner": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.5.0.tgz", - "integrity": "sha512-m7b6ypERhFghJsslMLhydaXBiLf7+jXy8FwGRHO3BGV1mcQpPbwiqiKUR2zU2NJuNeMenJmlFZCsIqzJCTeGLQ==", - "dependencies": { - "@jest/console": "^29.5.0", - "@jest/environment": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.6.4.tgz", + "integrity": "sha512-SDaLrMmtVlQYDuG0iSPYLycG8P9jLI+fRm8AF/xPKhYDB2g6xDWjXBrR5M8gEWsK6KVFlebpZ4QsrxdyIX1Jaw==", + "dev": true, + "dependencies": { + "@jest/console": "^29.6.4", + "@jest/environment": "^29.6.4", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "emittery": "^0.13.1", "graceful-fs": "^4.2.9", - "jest-docblock": "^29.4.3", - "jest-environment-node": "^29.5.0", - "jest-haste-map": "^29.5.0", - "jest-leak-detector": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-resolve": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-util": "^29.5.0", - "jest-watcher": "^29.5.0", - "jest-worker": "^29.5.0", + "jest-docblock": "^29.6.3", + "jest-environment-node": "^29.6.4", + "jest-haste-map": "^29.6.4", + "jest-leak-detector": "^29.6.3", + "jest-message-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-runtime": "^29.6.4", + "jest-util": "^29.6.3", + "jest-watcher": "^29.6.4", + "jest-worker": "^29.6.4", "p-limit": "^3.1.0", "source-map-support": "0.5.13" }, @@ -3607,30 +3709,31 @@ } }, "node_modules/jest-runtime": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.5.0.tgz", - "integrity": "sha512-1Hr6Hh7bAgXQP+pln3homOiEZtCDZFqwmle7Ew2j8OlbkIu6uE3Y/etJQG8MLQs3Zy90xrp2C0BRrtPHG4zryw==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/globals": "^29.5.0", - "@jest/source-map": "^29.4.3", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.6.4.tgz", + "integrity": "sha512-s/QxMBLvmwLdchKEjcLfwzP7h+jsHvNEtxGP5P+Fl1FMaJX2jMiIqe4rJw4tFprzCwuSvVUo9bn0uj4gNRXsbA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.6.4", + "@jest/fake-timers": "^29.6.4", + "@jest/globals": "^29.6.4", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "cjs-module-lexer": "^1.0.0", "collect-v8-coverage": "^1.0.0", "glob": "^7.1.3", "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-mock": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", + "jest-haste-map": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-mock": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.6.4", + "jest-snapshot": "^29.6.4", + "jest-util": "^29.6.3", "slash": "^3.0.0", "strip-bom": "^4.0.0" }, @@ -3638,114 +3741,44 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-runtime/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/jest-runtime/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/jest-runtime/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/jest-snapshot": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.5.0.tgz", - "integrity": "sha512-x7Wolra5V0tt3wRs3/ts3S6ciSQVypgGQlJpz2rsdQYoUKxMxPNaoHMGJN6qAuPJqS+2iQ1ZUn5kl7HCyls84g==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.6.4.tgz", + "integrity": "sha512-VC1N8ED7+4uboUKGIDsbvNAZb6LakgIPgAF4RSpF13dN6YaMokfRqO+BaqK4zIh6X3JffgwbzuGqDEjHm/MrvA==", + "dev": true, "dependencies": { "@babel/core": "^7.11.6", "@babel/generator": "^7.7.2", "@babel/plugin-syntax-jsx": "^7.7.2", "@babel/plugin-syntax-typescript": "^7.7.2", - "@babel/traverse": "^7.7.2", "@babel/types": "^7.3.3", - "@jest/expect-utils": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/babel__traverse": "^7.0.6", - "@types/prettier": "^2.1.5", + "@jest/expect-utils": "^29.6.4", + "@jest/transform": "^29.6.4", + "@jest/types": "^29.6.3", "babel-preset-current-node-syntax": "^1.0.0", "chalk": "^4.0.0", - "expect": "^29.5.0", + "expect": "^29.6.4", "graceful-fs": "^4.2.9", - "jest-diff": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", + "jest-diff": "^29.6.4", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.6.4", + "jest-message-util": "^29.6.3", + "jest-util": "^29.6.3", "natural-compare": "^1.4.0", - "pretty-format": "^29.5.0", - "semver": "^7.3.5" + "pretty-format": "^29.6.3", + "semver": "^7.5.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-snapshot/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.4.0.tgz", - "integrity": "sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/jest-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.5.0.tgz", - "integrity": "sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", + "integrity": "sha512-QUjna/xSy4B32fzcKTSz1w7YYzgiHrjjJjevdRf61HYk998R5vVMMNmrHESYZVDS5DSWs+1srPLPKxXPkeSDOA==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -3757,16 +3790,17 @@ } }, "node_modules/jest-validate": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.5.0.tgz", - "integrity": "sha512-pC26etNIi+y3HV8A+tUGr/lph9B18GnzSRAkPaaZJIE1eFdiYm6/CewuiJQ8/RlfHd1u/8Ioi8/sJ+CmbA+zAQ==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.6.3.tgz", + "integrity": "sha512-e7KWZcAIX+2W1o3cHfnqpGajdCs1jSM3DkXjGeLSNmCazv1EeI1ggTeK5wdZhF+7N+g44JI2Od3veojoaumlfg==", + "dev": true, "dependencies": { - "@jest/types": "^29.5.0", + "@jest/types": "^29.6.3", "camelcase": "^6.2.0", "chalk": "^4.0.0", - "jest-get-type": "^29.4.3", + "jest-get-type": "^29.6.3", "leven": "^3.1.0", - "pretty-format": "^29.5.0" + "pretty-format": "^29.6.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -3776,6 +3810,7 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, "engines": { "node": ">=10" }, @@ -3784,17 +3819,18 @@ } }, "node_modules/jest-watcher": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.5.0.tgz", - "integrity": "sha512-KmTojKcapuqYrKDpRwfqcQ3zjMlwu27SYext9pt4GlF5FUgB+7XE1mcCnSm6a4uUpFyQIkb6ZhzZvHl+jiBCiA==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.6.4.tgz", + "integrity": "sha512-oqUWvx6+On04ShsT00Ir9T4/FvBeEh2M9PTubgITPxDa739p4hoQweWPRGyYeaojgT0xTpZKF0Y/rSY1UgMxvQ==", + "dev": true, "dependencies": { - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", + "@jest/test-result": "^29.6.4", + "@jest/types": "^29.6.3", "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "emittery": "^0.13.1", - "jest-util": "^29.5.0", + "jest-util": "^29.6.3", "string-length": "^4.0.1" }, "engines": { @@ -3802,12 +3838,13 @@ } }, "node_modules/jest-worker": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.5.0.tgz", - "integrity": "sha512-NcrQnevGoSp4b5kg+akIpthoAFHxPBcb5P6mYPY0fUNT+sSvmtu6jlkEle3anczUKIKEbMxFimk9oTP/tpIPgA==", + "version": "29.6.4", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.6.4.tgz", + "integrity": "sha512-6dpvFV4WjcWbDVGgHTWo/aupl8/LbBx2NSKfiwqf79xC/yeJjKHT1+StcKy/2KTmW16hE68ccKVOtXf+WZGz7Q==", + "dev": true, "dependencies": { "@types/node": "*", - "jest-util": "^29.5.0", + "jest-util": "^29.6.3", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" }, @@ -3819,6 +3856,7 @@ "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -3829,20 +3867,17 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, "dependencies": { "argparse": "^2.0.1" }, @@ -3854,6 +3889,7 @@ "version": "20.0.3", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-20.0.3.tgz", "integrity": "sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ==", + "dev": true, "dependencies": { "abab": "^2.0.6", "acorn": "^8.8.1", @@ -3898,6 +3934,7 @@ "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, "bin": { "jsesc": "bin/jsesc" }, @@ -3905,27 +3942,35 @@ "node": ">=4" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true }, - "node_modules/json-schema-ref-parser": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", - "integrity": "sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==", - "deprecated": "Please switch to @apidevtools/json-schema-ref-parser", - "dependencies": { - "@apidevtools/json-schema-ref-parser": "9.0.9" - }, - "engines": { - "node": ">=10" - } + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, "bin": { "json5": "lib/cli.js" }, @@ -3933,21 +3978,20 @@ "node": ">=6" } }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "node_modules/keyv": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", + "integrity": "sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==", + "dev": true, "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" + "json-buffer": "3.0.1" } }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, "engines": { "node": ">=6" } @@ -3956,17 +4000,19 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, "engines": { "node": ">=6" } }, "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -3975,53 +4021,55 @@ "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true }, "node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, "dependencies": { - "p-locate": "^4.1.0" + "p-locate": "^5.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "peer": true, - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, "dependencies": { "yallist": "^3.0.2" } }, "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, "dependencies": { - "semver": "^6.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -4030,41 +4078,38 @@ "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", - "dependencies": { - "tmpl": "1.0.5" - } - }, - "node_modules/md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" + "tmpl": "1.0.5" } }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true }, - "node_modules/mersenne-twister": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mersenne-twister/-/mersenne-twister-1.1.0.tgz", - "integrity": "sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA==" + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } }, "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, "dependencies": { "braces": "^3.0.2", "picomatch": "^2.3.1" @@ -4073,29 +4118,11 @@ "node": ">=8.6" } }, - "node_modules/miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "dependencies": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - }, - "bin": { - "miller-rabin": "bin/miller-rabin" - } - }, - "node_modules/miller-rabin/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, "engines": { "node": ">= 0.6" } @@ -4104,6 +4131,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, "dependencies": { "mime-db": "1.52.0" }, @@ -4115,185 +4143,52 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, "engines": { "node": ">=6" } }, - "node_modules/minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true - }, - "node_modules/minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", - "dev": true - }, "node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" - }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" - }, - "node_modules/next": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/next/-/next-12.3.4.tgz", - "integrity": "sha512-VcyMJUtLZBGzLKo3oMxrEF0stxh8HwuW976pAzlHhI3t8qJ4SROjCrSh1T24bhrbjw55wfZXAbXPGwPt5FLRfQ==", - "dependencies": { - "@next/env": "12.3.4", - "@swc/helpers": "0.4.11", - "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", - "styled-jsx": "5.0.7", - "use-sync-external-store": "1.2.0" - }, - "bin": { - "next": "dist/bin/next" - }, - "engines": { - "node": ">=12.22.0" - }, - "optionalDependencies": { - "@next/swc-android-arm-eabi": "12.3.4", - "@next/swc-android-arm64": "12.3.4", - "@next/swc-darwin-arm64": "12.3.4", - "@next/swc-darwin-x64": "12.3.4", - "@next/swc-freebsd-x64": "12.3.4", - "@next/swc-linux-arm-gnueabihf": "12.3.4", - "@next/swc-linux-arm64-gnu": "12.3.4", - "@next/swc-linux-arm64-musl": "12.3.4", - "@next/swc-linux-x64-gnu": "12.3.4", - "@next/swc-linux-x64-musl": "12.3.4", - "@next/swc-win32-arm64-msvc": "12.3.4", - "@next/swc-win32-ia32-msvc": "12.3.4", - "@next/swc-win32-x64-msvc": "12.3.4" - }, - "peerDependencies": { - "fibers": ">= 3.1.0", - "node-sass": "^6.0.0 || ^7.0.0", - "react": "^17.0.2 || ^18.0.0-0", - "react-dom": "^17.0.2 || ^18.0.0-0", - "sass": "^1.3.0" - }, - "peerDependenciesMeta": { - "fibers": { - "optional": true - }, - "node-sass": { - "optional": true - }, - "sass": { - "optional": true - } - } - }, - "node_modules/next/node_modules/@swc/helpers": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.11.tgz", - "integrity": "sha512-rEUrBSGIoSFuYxwBYtlUFMlE2CwGhmW+w9355/5oduSw8e5h2+Tj4UrAGNNgP9915++wj5vkQo0UuOBqOAq4nw==", - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { - "whatwg-url": "^5.0.0" + "brace-expansion": "^1.1.7" }, "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } + "node": "*" } }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", - "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==" + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true }, "node_modules/node-releases": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", - "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==" + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", + "integrity": "sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==", + "dev": true }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -4302,6 +4197,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, "dependencies": { "path-key": "^3.0.0" }, @@ -4310,39 +4206,16 @@ } }, "node_modules/nwsapi": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.4.tgz", - "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==" - }, - "node_modules/object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "engines": { - "node": ">= 0.4" - } + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", + "integrity": "sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==", + "dev": true }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "dependencies": { "wrappy": "1" } @@ -4351,6 +4224,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -4361,58 +4235,28 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/openapi-typescript-codegen": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/openapi-typescript-codegen/-/openapi-typescript-codegen-0.23.0.tgz", - "integrity": "sha512-gOJXy5g3H3HlLpVNN+USrNK2i2KYBmDczk9Xk34u6JorwrGiDJZUj+al4S+i9TXdfUQ/ZaLxE59Xf3wqkxGfqA==", - "dependencies": { - "camelcase": "^6.3.0", - "commander": "^9.3.0", - "fs-extra": "^10.1.0", - "handlebars": "^4.7.7", - "json-schema-ref-parser": "^9.0.9" - }, - "bin": { - "openapi": "bin/index.js" - } - }, - "node_modules/openapi-typescript-codegen/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, "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" + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" } }, - "node_modules/os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==", - "dev": true - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, "dependencies": { "yocto-queue": "^0.1.0" }, @@ -4424,25 +4268,15 @@ } }, "node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-locate/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, "dependencies": { - "p-try": "^2.0.0" + "p-limit": "^3.0.2" }, "engines": { - "node": ">=6" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -4452,27 +4286,28 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, "engines": { "node": ">=6" } }, - "node_modules/parse-asn1": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", - "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "dependencies": { - "asn1.js": "^5.2.0", - "browserify-aes": "^1.0.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3", - "safe-buffer": "^5.1.1" + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" } }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", @@ -4490,6 +4325,7 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "dev": true, "dependencies": { "entities": "^4.4.0" }, @@ -4497,16 +4333,11 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/path-browserify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", - "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", - "dev": true - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, "engines": { "node": ">=8" } @@ -4515,6 +4346,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -4523,6 +4355,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "engines": { "node": ">=8" } @@ -4530,33 +4363,29 @@ "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true }, - "node_modules/pbkdf2": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", - "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true, - "dependencies": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - }, "engines": { - "node": ">=0.12" + "node": ">=8" } }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, "engines": { "node": ">=8.6" }, @@ -4565,9 +4394,10 @@ } }, "node_modules/pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, "engines": { "node": ">= 6" } @@ -4576,6 +4406,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, "dependencies": { "find-up": "^4.0.0" }, @@ -4583,51 +4414,74 @@ "node": ">=8" } }, - "node_modules/polyfill-crypto.getrandomvalues": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/polyfill-crypto.getrandomvalues/-/polyfill-crypto.getrandomvalues-1.0.0.tgz", - "integrity": "sha512-GIkU6bg4auRnDFOqUNit7eLn9hzznrJU1CGFuivQzDeVp4Ys8cY4OY6GhAdndJwo4jryz5cJyjg9ELhvQjdrtw==", + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, "dependencies": { - "mersenne-twister": "^1.0.1" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "node_modules/postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - } - ], + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, "dependencies": { - "nanoid": "^3.3.4", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" + "p-limit": "^2.2.0" }, "engines": { - "node": "^10 || ^12 || >=14" + "node": ">=8" } }, "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/pretty-format": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz", - "integrity": "sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==", + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.6.3.tgz", + "integrity": "sha512-ZsBgjVhFAj5KeK+nHfF1305/By3lechHQSMWCTl8iHSbfOm2TN5nHEtFc/+W7fAyUeCs2n5iow72gld4gW0xDw==", + "dev": true, "dependencies": { - "@jest/schemas": "^29.4.3", + "@jest/schemas": "^29.6.3", "ansi-styles": "^5.0.0", "react-is": "^18.0.0" }, @@ -4639,6 +4493,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, "engines": { "node": ">=10" }, @@ -4646,19 +4501,11 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "dev": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" @@ -4670,38 +4517,23 @@ "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" - }, - "node_modules/public-encrypt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", - "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "dev": true, - "dependencies": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/public-encrypt/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, "node_modules/punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", - "dev": true + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, + "engines": { + "node": ">=6" + } }, "node_modules/pure-rand": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.1.tgz", - "integrity": "sha512-t+x1zEHDjBwkDGY5v5ApnZ/utcd4XYDiJsaQQoptTXgUXX95sDg1elCdJghzicm7n2mbCBJ3uYWr6M22SO19rg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.2.tgz", + "integrity": "sha512-6Yg0ekpKICSjPswYOuC5sku/TSWaRYlA0qsXqJgM/d/4pLPHPuTxK7Nbf7jFKzAeedUhR8C7K9Uv63FBsSo8xQ==", + "dev": true, "funding": [ { "type": "individual", @@ -4713,97 +4545,43 @@ } ] }, - "node_modules/querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", - "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", - "dev": true, - "engines": { - "node": ">=0.4.x" - } - }, - "node_modules/querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==", - "dev": true, - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.1.0" - } + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true }, - "node_modules/randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true, - "dependencies": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" - } - }, - "node_modules/react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -4811,14 +4589,16 @@ "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true }, "node_modules/resolve": { - "version": "1.22.2", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", - "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "dev": true, "dependencies": { - "is-core-module": "^2.11.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -4833,6 +4613,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, "dependencies": { "resolve-from": "^5.0.0" }, @@ -4840,36 +4621,62 @@ "node": ">=8" } }, - "node_modules/resolve-from": { + "node_modules/resolve-cwd/node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, "engines": { "node": ">=8" } }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/resolve.exports": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, "engines": { "node": ">=10" } }, - "node_modules/ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { @@ -4884,17 +4691,22 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "node_modules/saxes": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, "dependencies": { "xmlchars": "^2.2.0" }, @@ -4902,40 +4714,44 @@ "node": ">=v12.22.7" } }, - "node_modules/scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - } - }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, - "node_modules/sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "yallist": "^4.0.0" }, - "bin": { - "sha.js": "bin.js" + "engines": { + "node": ">=10" } }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -4947,6 +4763,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "engines": { "node": ">=8" } @@ -4954,17 +4771,20 @@ "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, "engines": { "node": ">=8" } @@ -4973,14 +4793,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -4989,6 +4802,7 @@ "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -4997,12 +4811,14 @@ "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, "dependencies": { "escape-string-regexp": "^2.0.0" }, @@ -5010,41 +4826,20 @@ "node": ">=10" } }, - "node_modules/stream-browserify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", - "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", - "dev": true, - "dependencies": { - "inherits": "~2.0.4", - "readable-stream": "^3.5.0" - } - }, - "node_modules/stream-http": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", - "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", - "dev": true, - "dependencies": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "xtend": "^4.0.2" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true, - "dependencies": { - "safe-buffer": "~5.2.0" + "engines": { + "node": ">=8" } }, "node_modules/string-length": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, "dependencies": { "char-regex": "^1.0.2", "strip-ansi": "^6.0.0" @@ -5057,6 +4852,7 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -5070,6 +4866,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, "dependencies": { "ansi-regex": "^5.0.1" }, @@ -5081,6 +4878,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, "engines": { "node": ">=8" } @@ -5089,6 +4887,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, "engines": { "node": ">=6" } @@ -5097,6 +4896,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, "engines": { "node": ">=8" }, @@ -5104,29 +4904,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/styled-jsx": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.7.tgz", - "integrity": "sha512-b3sUzamS086YLRuvnaDigdAewz1/EFYlHpYBP5mZovKEdQQOIIYq8lApylub3HHZ6xFjV051kkGU7cudJmrXEA==", - "engines": { - "node": ">= 12.0.0" - }, - "peerDependencies": { - "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "babel-plugin-macros": { - "optional": true - } - } - }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5138,6 +4920,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, "engines": { "node": ">= 0.4" }, @@ -5148,12 +4931,14 @@ "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, "dependencies": { "@istanbuljs/schema": "^0.1.2", "glob": "^7.1.4", @@ -5163,54 +4948,23 @@ "node": ">=8" } }, - "node_modules/test-exclude/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/test-exclude/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/test-exclude/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", - "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==" + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, "engines": { "node": ">=4" } @@ -5219,6 +4973,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, "dependencies": { "is-number": "^7.0.0" }, @@ -5227,9 +4982,10 @@ } }, "node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", + "dev": true, "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -5240,26 +4996,11 @@ "node": ">=6" } }, - "node_modules/tough-cookie/node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/tough-cookie/node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/tr46": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dev": true, "dependencies": { "punycode": "^2.1.1" }, @@ -5267,18 +5008,23 @@ "node": ">=12" } }, - "node_modules/tr46/node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "node_modules/ts-api-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.2.tgz", + "integrity": "sha512-Cbu4nIqnEdd+THNEsBdkolnOXhg0I8XteoHaEKgvsxpsbWda4IsUut2c187HxywQCvveojow0Dgw/amxtSKVkQ==", + "dev": true, "engines": { - "node": ">=6" + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" } }, "node_modules/ts-jest": { - "version": "29.1.0", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz", - "integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==", + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, "dependencies": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", @@ -5286,7 +5032,7 @@ "json5": "^2.2.3", "lodash.memoize": "4.x", "make-error": "1.x", - "semver": "7.x", + "semver": "^7.5.3", "yargs-parser": "^21.0.1" }, "bin": { @@ -5317,53 +5063,13 @@ } } }, - "node_modules/ts-jest/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/semver": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.4.0.tgz", - "integrity": "sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" - }, - "node_modules/tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true - }, "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, "dependencies": { - "prelude-ls": "~1.1.2" + "prelude-ls": "^1.2.1" }, "engines": { "node": ">= 0.8.0" @@ -5373,14 +5079,16 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, "engines": { "node": ">=4" } }, "node_modules/type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, "engines": { "node": ">=10" }, @@ -5389,41 +5097,32 @@ } }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", + "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" + "node": ">=14.17" } }, "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "dev": true, "engines": { - "node": ">= 10.0.0" + "node": ">= 4.0.0" } }, "node_modules/update-browserslist-db": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "dev": true, "funding": [ { "type": "opencollective", @@ -5449,57 +5148,25 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "dependencies": { - "punycode": "1.3.2", - "querystring": "0.2.0" + "punycode": "^2.1.0" } }, "node_modules/url-parse": { "version": "1.5.10", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, "dependencies": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" } }, - "node_modules/url/node_modules/punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==", - "dev": true - }, - "node_modules/use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/util": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "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" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, "node_modules/uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", @@ -5512,6 +5179,7 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", + "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", "@types/istanbul-lib-coverage": "^2.0.1", @@ -5524,12 +5192,14 @@ "node_modules/v8-to-istanbul/node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true }, "node_modules/w3c-xmlserializer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", "integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==", + "dev": true, "dependencies": { "xml-name-validator": "^4.0.0" }, @@ -5541,6 +5211,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, "dependencies": { "makeerror": "1.0.12" } @@ -5549,6 +5220,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, "engines": { "node": ">=12" } @@ -5557,6 +5229,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", + "dev": true, "dependencies": { "iconv-lite": "0.6.3" }, @@ -5568,6 +5241,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "dev": true, "engines": { "node": ">=12" } @@ -5576,6 +5250,7 @@ "version": "11.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dev": true, "dependencies": { "tr46": "^3.0.0", "webidl-conversions": "^7.0.0" @@ -5588,6 +5263,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "dependencies": { "isexe": "^2.0.0" }, @@ -5598,42 +5274,11 @@ "node": ">= 8" } }, - "node_modules/which-typed-array": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", - "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", - "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" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -5649,12 +5294,14 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true }, "node_modules/write-file-atomic": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^3.0.7" @@ -5667,6 +5314,7 @@ "version": "8.13.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, "engines": { "node": ">=10.0.0" }, @@ -5687,6 +5335,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true, "engines": { "node": ">=12" } @@ -5694,21 +5343,14 @@ "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" - }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "engines": { - "node": ">=0.4" - } + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, "engines": { "node": ">=10" } @@ -5716,12 +5358,14 @@ "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true }, "node_modules/yargs": { - "version": "17.7.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", - "integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==", + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", @@ -5739,6 +5383,7 @@ "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, "engines": { "node": ">=12" } @@ -5747,6 +5392,7 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, "engines": { "node": ">=10" }, diff --git a/package.json b/package.json index baf5abca..27152965 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,32 @@ { "name": "@loopholelabs/scale", - "version": "0.3.17", - "description": "Scale is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development.", - "source": "ts/index.ts", + "version": "0.4.0", + "description": "Scale is a framework for building high-performance plugin systems into any application, all powered by WebAssembly.", + "source": "scale.ts", "types": "types.d.ts", - "license": "apache-2.0", + "license": "Apache-2.0", "scripts": { - "build": "openapi -i https://api.scale.sh/v1/swagger.json -o ts/client && rm -rf dist && tsc --outDir dist && cp package.json dist", - "test": "node --experimental-wasi-unstable-preview1 --trace-warnings node_modules/.bin/jest --no-cache && rm -rf testDirectory" + "build": "rm -rf dist && tsc --outDir dist && cp package.json dist", + "lint": "eslint . --ext .ts", + "test": "node --experimental-wasi-unstable-preview1 --trace-warnings node_modules/.bin/jest --no-cache" }, "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature": "^0.2.11", - "@loopholelabs/scale-signature-http": "^0.3.8", - "@loopholelabs/scalefile": "^0.1.9", - "@swc/helpers": "^0.4.12", - "@types/jest": "^29.2.0", - "@types/node-fetch": "^2.6.2", - "form-data": "^4.0.0", - "glob": "^8.1.0", - "jest": "^29.2.2", - "jest-environment-jsdom": "^29.2.2", - "js-sha256": "^0.9.0", - "next": "^12.3.3", - "node-fetch": "^2.6.7", - "openapi-typescript-codegen": "^0.23.0", - "ts-jest": "^29.0.3", - "util": "^0.12.5", + "@loopholelabs/polyglot": "^1.1.3", + "@loopholelabs/scale-signature-interfaces": "^0.1.7", + "buffer": "^6.0.3", + "fast-sha256": "^1.3.0", "uuid": "^9.0.0" }, "devDependencies": { - "@types/glob": "^8.0.1", - "@types/node": "^18.11.5", - "@types/uuid": "^9.0.0", - "assert": "^2.0.0", - "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "https-browserify": "^1.0.0", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", - "punycode": "^1.4.1", - "querystring-es3": "^0.2.1", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "tty-browserify": "^0.0.1", - "typescript": "^4.7.0", - "url": "^0.11.0" + "@types/jest": "^29.5.4", + "@types/node": "^20.5.8", + "@types/uuid": "^8.3.4", + "@typescript-eslint/eslint-plugin": "^6.5.0", + "@typescript-eslint/parser": "^6.5.0", + "eslint": "^8.48.0", + "jest": "^29.6.4", + "jest-environment-jsdom": "^29.6.4", + "ts-jest": "^29.1.1", + "typescript": "^5.2.2" } } diff --git a/go/pool.go b/pool.go similarity index 54% rename from go/pool.go rename to pool.go index 156f5006..af138427 100644 --- a/go/pool.go +++ b/pool.go @@ -14,38 +14,38 @@ limitations under the License. */ -package runtime +package scale import ( "context" - signature "github.com/loopholelabs/scale-signature" "sync" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" ) -type Pool[T signature.Signature] struct { +type modulePool[T interfaces.Signature] struct { pool sync.Pool - new func() (*Module[T], error) + new func() (*module[T], error) } -func NewPool[T signature.Signature](ctx context.Context, f *Function[T], r *Runtime[T]) *Pool[T] { - return &Pool[T]{ - new: func() (*Module[T], error) { - return NewModule[T](ctx, f, r) +func newModulePool[T interfaces.Signature](ctx context.Context, template *template[T]) *modulePool[T] { + return &modulePool[T]{ + new: func() (*module[T], error) { + return newModule[T](ctx, template) }, } } -func (p *Pool[T]) Put(module *Module[T]) { - if module != nil { - p.pool.Put(module) +func (p *modulePool[T]) Put(m *module[T]) { + if m != nil { + p.pool.Put(m) } } -func (p *Pool[T]) Get() (*Module[T], error) { - rv, ok := p.pool.Get().(*Module[T]) - if ok && rv != nil { - return rv, nil +func (p *modulePool[T]) Get() (*module[T], error) { + m, ok := p.pool.Get().(*module[T]) + if ok && m != nil { + return m, nil } - return p.new() } diff --git a/pool.ts b/pool.ts new file mode 100644 index 00000000..bcb99662 --- /dev/null +++ b/pool.ts @@ -0,0 +1,44 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import {Signature} from "@loopholelabs/scale-signature-interfaces"; +import {Template} from "./template"; +import {NewModule, Module} from "./module"; + +export class ModulePool { + private readonly objects: Module[] = []; + private readonly allocator: () => Promise>; + + constructor(template: Template) { + this.allocator = async (): Promise> => { + return await NewModule(template); + } + } + + public async Get(): Promise> { + if (this.objects.length > 0) { + const t = this.objects.pop(); + if (typeof t !== "undefined") { + return t; + } + } + return await this.allocator() + } + + public Put(t: Module): void { + this.objects.push(t); + } +} \ No newline at end of file diff --git a/rust/compile/compile.go b/rust/compile/compile.go deleted file mode 100644 index fab15deb..00000000 --- a/rust/compile/compile.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package compile - -import ( - "github.com/loopholelabs/scale/rust/compile/templates" - "github.com/loopholelabs/scalefile" - "io" - "text/template" -) - -type Generator struct { - template *template.Template -} - -func NewGenerator() *Generator { - templ := template.Must(template.New("rust").ParseFS(templates.FS, "*")) - return &Generator{ - template: templ, - } -} - -func (g *Generator) GenerateRsCargo(writer io.Writer, dependencies []*scalefile.Dependency, signature string, signaturePath string) error { - return g.template.ExecuteTemplate(writer, "Cargo.toml.templ", map[string]interface{}{ - "dependencies": dependencies, - "signature": signature, - "signature_path": signaturePath, - }) -} - -func (g *Generator) GenerateRsLib(writer io.Writer, path string, signature string) error { - return g.template.ExecuteTemplate(writer, "lib.rs.templ", map[string]interface{}{ - "path": path, - "signature": signature, - }) -} diff --git a/rust/compile/templates/Cargo.toml.templ b/rust/compile/templates/Cargo.toml.templ deleted file mode 100644 index 7ad39c6c..00000000 --- a/rust/compile/templates/Cargo.toml.templ +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "compile" -version = "0.1.0" -edition = "2021" - -[dependencies] -{{ range $dependency := .dependencies -}} -{{ $dependency.Name }} = "{{ $dependency.Version }}" -{{end -}} - -{{ if .signature_path }} -[dependencies.{{ .signature }}] -path = "{{ .signature_path }}" -{{ end }} - -[lib] -crate-type = ["cdylib"] -path = "lib.rs" - -[profile.release] -opt-level = 3 -lto = true -codegen-units = 1 \ No newline at end of file diff --git a/rust/compile/templates/lib.rs.templ b/rust/compile/templates/lib.rs.templ deleted file mode 100644 index 3c73f4cb..00000000 --- a/rust/compile/templates/lib.rs.templ +++ /dev/null @@ -1,45 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -#[path = "{{ .path }}"] -mod scale; -use scale::scale; - -use {{ .signature }}::context; -use scale_signature::Context; - -#[cfg_attr(target_arch = "wasm32", export_name = "run")] -#[no_mangle] -pub unsafe extern "C" fn run() -> u64 { - let mut ctx = context::new(); - let guest_context = ctx.guest_context(); - return match guest_context.from_read_buffer() { - Some(err) => { - let (ptr, len) = guest_context.error_write_buffer(err); - pack_uint32(ptr, len) - }, - None => { - return match scale(&mut ctx) { - Ok(ctx) => { - let guest_ctx = ctx.guest_context(); - let (ptr, len) = guest_ctx.to_write_buffer(); - pack_uint32(ptr, len) - }, - Err(err) => { - let guest_ctx = ctx.guest_context(); - let (ptr, len) = guest_ctx.error_write_buffer(err); - pack_uint32(ptr, len) - } - }; - }, - }; -} - -#[cfg_attr(target_arch = "wasm32", export_name = "resize")] -#[no_mangle] -pub unsafe extern "C" fn _resize(size: u32) -> *const u8 { - return {{ .signature }}::guest::resize(size); -} - -fn pack_uint32(ptr: u32, len: u32) -> u64 { - return ((ptr as u64) << 32) | len as u64; -} diff --git a/rust/tests/modules/bad_signature/bad_signature.rs b/rust/tests/modules/bad_signature/bad_signature.rs deleted file mode 100644 index 89900fbb..00000000 --- a/rust/tests/modules/bad_signature/bad_signature.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use bad_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - Ok(ctx) -} diff --git a/rust/tests/modules/file/file.rs b/rust/tests/modules/file/file.rs deleted file mode 100644 index dffc8850..00000000 --- a/rust/tests/modules/file/file.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -use std::fs; -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - let _body = fs::read_to_string("tests/modules/rust/file.rs")?; - Ok(ctx) -} diff --git a/rust/tests/modules/http_handler/http_handler.rs b/rust/tests/modules/http_handler/http_handler.rs deleted file mode 100644 index de706afd..00000000 --- a/rust/tests/modules/http_handler/http_handler.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use scale_signature_http::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - let response = ctx.response(); - let mut body = response.body(); - body.append(&mut "-modified".as_bytes().to_vec()); - response.set_body_bytes(body); - Ok(ctx) -} diff --git a/rust/tests/modules/http_next/http_next.rs b/rust/tests/modules/http_next/http_next.rs deleted file mode 100644 index 374a291a..00000000 --- a/rust/tests/modules/http_next/http_next.rs +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use scale_signature_http::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - let response = ctx.response(); - let mut body = response.body(); - body.append(&mut "-modified".as_bytes().to_vec()); - response.set_body_bytes(body); - ctx.next() -} diff --git a/rust/tests/modules/http_passthrough/http_passthrough.rs b/rust/tests/modules/http_passthrough/http_passthrough.rs deleted file mode 100644 index 2c4e9628..00000000 --- a/rust/tests/modules/http_passthrough/http_passthrough.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use scale_signature_http::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - Ok(ctx) -} diff --git a/rust/tests/modules/modify/modify.rs b/rust/tests/modules/modify/modify.rs deleted file mode 100644 index 15f73760..00000000 --- a/rust/tests/modules/modify/modify.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - ctx.data = "modified".to_string(); - Ok(ctx) -} diff --git a/rust/tests/modules/modifynext/modifynext.rs b/rust/tests/modules/modifynext/modifynext.rs deleted file mode 100644 index 1a8071db..00000000 --- a/rust/tests/modules/modifynext/modifynext.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - ctx.data = "modified".to_string(); - ctx.next() -} diff --git a/rust/tests/modules/network/network.rs b/rust/tests/modules/network/network.rs deleted file mode 100644 index 0abfa426..00000000 --- a/rust/tests/modules/network/network.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use std::net::{TcpStream}; -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - let _stream = TcpStream::connect("google.com:80")?; - Ok(ctx) -} diff --git a/rust/tests/modules/next/next.rs b/rust/tests/modules/next/next.rs deleted file mode 100644 index cd9dca2a..00000000 --- a/rust/tests/modules/next/next.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - ctx.next() -} diff --git a/rust/tests/modules/panic/panic.rs b/rust/tests/modules/panic/panic.rs deleted file mode 100644 index e5899a39..00000000 --- a/rust/tests/modules/panic/panic.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - panic!("scale panic"); -} diff --git a/rust/tests/modules/passthrough/passthrough.rs b/rust/tests/modules/passthrough/passthrough.rs deleted file mode 100644 index e1dc3579..00000000 --- a/rust/tests/modules/passthrough/passthrough.rs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - - -use example_signature::context::Context; - -pub fn scale(ctx: &mut Context) -> Result<&mut Context, Box> { - Ok(ctx) -} diff --git a/rust/tests/signature/bad-signature/Cargo.toml b/rust/tests/signature/bad-signature/Cargo.toml deleted file mode 100644 index 4c8000ff..00000000 --- a/rust/tests/signature/bad-signature/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "bad_signature" -version = "0.1.0" -edition = "2021" -description = "bad signature" - -[lib] -path = "lib.rs" - -[dependencies] -polyglot_rs = "0.6.1" -scale_signature = "0.2.11" diff --git a/rust/tests/signature/bad-signature/bad_signature.rs b/rust/tests/signature/bad-signature/bad_signature.rs deleted file mode 100644 index 62795c1c..00000000 --- a/rust/tests/signature/bad-signature/bad_signature.rs +++ /dev/null @@ -1,45 +0,0 @@ -use polyglot_rs::{Decoder, Encoder}; -use std::io::Cursor; - -pub trait Encode { - fn encode(self, b: &mut Cursor>) -> Result<&mut Cursor>, Box>; - fn internal_error(self, b: &mut Cursor>, error: Box); -} - -pub trait Decode { - fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> - where - Self: Sized; -} - -#[derive(Clone)] -pub struct BadContext { - pub data: u32 -} - -impl Encode for BadContext { - fn encode(self, b: &mut Cursor>) -> Result<&mut Cursor>, Box> { - b.encode_u32(self.data)?; - Ok(b) - } - - fn internal_error(self, b: &mut Cursor>, error: Box) { - b.encode_error(error).unwrap(); - } -} - -impl Decode for BadContext { - fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> { - if b.decode_none() { - return Ok(None); - } - - if let Ok(error) = b.decode_error() { - return Err(error); - } - - Ok(Some(BadContext { - data: b.decode_u32()?, - })) - } -} \ No newline at end of file diff --git a/rust/tests/signature/bad-signature/context.rs b/rust/tests/signature/bad-signature/context.rs deleted file mode 100644 index ba121ef0..00000000 --- a/rust/tests/signature/bad-signature/context.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -use crate::bad_signature::BadContext; - -pub type Context = BadContext; - -pub fn new() -> Context { - Context { - data: 0, - } -} \ No newline at end of file diff --git a/rust/tests/signature/bad-signature/guest.rs b/rust/tests/signature/bad-signature/guest.rs deleted file mode 100644 index 26f142dd..00000000 --- a/rust/tests/signature/bad-signature/guest.rs +++ /dev/null @@ -1,84 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -use crate::context::Context; -use crate::bad_signature::{Decode, Encode, BadContext}; -use scale_signature::{Context as ContextTrait, GuestContext as GuestContextTrait}; -use std::io::Cursor; - -pub static mut READ_BUFFER: Vec = Vec::new(); -pub static mut WRITE_BUFFER: Vec = Vec::new(); - -pub type GuestContext = Context; - -impl ContextTrait for Context { - fn guest_context(&mut self) -> &mut dyn GuestContextTrait { - self - } -} - -impl GuestContextTrait for GuestContext { - unsafe fn to_write_buffer(&mut self) -> (u32, u32) { - let mut cursor = Cursor::new(Vec::new()); - cursor = match BadContext::encode(self.clone(), &mut cursor) { - Ok(_) => cursor, - Err(err) => return self.error_write_buffer(err), - }; - - let vec = cursor.into_inner(); - - WRITE_BUFFER.resize(vec.len() as usize, 0); - WRITE_BUFFER.copy_from_slice(&vec); - - return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); - } - - unsafe fn error_write_buffer(&mut self, error: Box) -> (u32, u32) { - let mut cursor = Cursor::new(Vec::new()); - Encode::internal_error(self.clone(), &mut cursor, error); - - let vec = cursor.into_inner(); - - WRITE_BUFFER.resize(vec.len() as usize, 0); - WRITE_BUFFER.copy_from_slice(&vec); - - return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); - } - - unsafe fn from_read_buffer(&mut self) -> Option> { - let mut cursor = Cursor::new(&mut READ_BUFFER); - let result = BadContext::decode(&mut cursor); - return match result { - Ok(context) => { - *self = context.unwrap(); - None - } - Err(e) => { - Some(e) - }, - }; - } -} - -impl Context { - pub fn next(&mut self) -> Result<&mut Self, Box> { - unsafe { - let (ptr, len) = self.to_write_buffer(); - _next(ptr, len); - return match self.from_read_buffer() { - Some(err) => Err(err), - None => Ok(self), - }; - } - } -} - -pub unsafe fn resize(size: u32) -> *const u8 { - READ_BUFFER.resize(size as usize, 0); - return READ_BUFFER.as_ptr(); -} - -#[link(wasm_import_module = "env")] -extern "C" { - #[link_name = "next"] - fn _next(ptr: u32, size: u32); -} diff --git a/rust/tests/signature/bad-signature/lib.rs b/rust/tests/signature/bad-signature/lib.rs deleted file mode 100644 index 3417e94b..00000000 --- a/rust/tests/signature/bad-signature/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod context; -pub mod guest; -mod bad_signature; diff --git a/rust/tests/signature/example-signature/Cargo.toml b/rust/tests/signature/example-signature/Cargo.toml deleted file mode 100644 index 686cdf19..00000000 --- a/rust/tests/signature/example-signature/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "example_signature" -version = "0.1.0" -edition = "2021" -description = "example signature" - -[lib] -path = "lib.rs" - -[dependencies] -polyglot_rs = "0.6.1" -scale_signature = "0.2.11" diff --git a/rust/tests/signature/example-signature/context.rs b/rust/tests/signature/example-signature/context.rs deleted file mode 100644 index 936c73d5..00000000 --- a/rust/tests/signature/example-signature/context.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -use crate::example_signature::ExampleContext; - -pub type Context = ExampleContext; - -pub fn new() -> Context { - Context { - data: "".to_string(), - } -} \ No newline at end of file diff --git a/rust/tests/signature/example-signature/example_signature.rs b/rust/tests/signature/example-signature/example_signature.rs deleted file mode 100644 index 5ba15312..00000000 --- a/rust/tests/signature/example-signature/example_signature.rs +++ /dev/null @@ -1,45 +0,0 @@ -use polyglot_rs::{Decoder, Encoder}; -use std::io::Cursor; - -pub trait Encode { - fn encode(self, b: &mut Cursor>) -> Result<&mut Cursor>, Box>; - fn internal_error(self, b: &mut Cursor>, error: Box); -} - -pub trait Decode { - fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> - where - Self: Sized; -} - -#[derive(Clone)] -pub struct ExampleContext { - pub data: String -} - -impl Encode for ExampleContext { - fn encode(self, b: &mut Cursor>) -> Result<&mut Cursor>, Box> { - b.encode_string(&self.data)?; - Ok(b) - } - - fn internal_error(self, b: &mut Cursor>, error: Box) { - b.encode_error(error).unwrap(); - } -} - -impl Decode for ExampleContext { - fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> { - if b.decode_none() { - return Ok(None); - } - - if let Ok(error) = b.decode_error() { - return Err(error); - } - - Ok(Some(ExampleContext { - data: b.decode_string()?, - })) - } -} \ No newline at end of file diff --git a/rust/tests/signature/example-signature/guest.rs b/rust/tests/signature/example-signature/guest.rs deleted file mode 100644 index c03cc4ae..00000000 --- a/rust/tests/signature/example-signature/guest.rs +++ /dev/null @@ -1,84 +0,0 @@ -#![cfg(target_arch = "wasm32")] - -use crate::context::Context; -use crate::example_signature::{Decode, Encode, ExampleContext}; -use scale_signature::{Context as ContextTrait, GuestContext as GuestContextTrait}; -use std::io::Cursor; - -pub static mut READ_BUFFER: Vec = Vec::new(); -pub static mut WRITE_BUFFER: Vec = Vec::new(); - -pub type GuestContext = Context; - -impl ContextTrait for Context { - fn guest_context(&mut self) -> &mut dyn GuestContextTrait { - self - } -} - -impl GuestContextTrait for GuestContext { - unsafe fn to_write_buffer(&mut self) -> (u32, u32) { - let mut cursor = Cursor::new(Vec::new()); - cursor = match ExampleContext::encode(self.clone(), &mut cursor) { - Ok(_) => cursor, - Err(err) => return self.error_write_buffer(err), - }; - - let vec = cursor.into_inner(); - - WRITE_BUFFER.resize(vec.len() as usize, 0); - WRITE_BUFFER.copy_from_slice(&vec); - - return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); - } - - unsafe fn error_write_buffer(&mut self, error: Box) -> (u32, u32) { - let mut cursor = Cursor::new(Vec::new()); - Encode::internal_error(self.clone(), &mut cursor, error); - - let vec = cursor.into_inner(); - - WRITE_BUFFER.resize(vec.len() as usize, 0); - WRITE_BUFFER.copy_from_slice(&vec); - - return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); - } - - unsafe fn from_read_buffer(&mut self) -> Option> { - let mut cursor = Cursor::new(&mut READ_BUFFER); - let result = ExampleContext::decode(&mut cursor); - return match result { - Ok(context) => { - *self = context.unwrap(); - None - } - Err(e) => { - Some(e) - }, - }; - } -} - -impl Context { - pub fn next(&mut self) -> Result<&mut Self, Box> { - unsafe { - let (ptr, len) = self.to_write_buffer(); - _next(ptr, len); - return match self.from_read_buffer() { - Some(err) => Err(err), - None => Ok(self), - }; - } - } -} - -pub unsafe fn resize(size: u32) -> *const u8 { - READ_BUFFER.resize(size as usize, 0); - return READ_BUFFER.as_ptr(); -} - -#[link(wasm_import_module = "env")] -extern "C" { - #[link_name = "next"] - fn _next(ptr: u32, size: u32); -} diff --git a/rust/tests/signature/example-signature/lib.rs b/rust/tests/signature/example-signature/lib.rs deleted file mode 100644 index ee1e368d..00000000 --- a/rust/tests/signature/example-signature/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod context; -pub mod guest; -mod example_signature; diff --git a/scale.go b/scale.go new file mode 100644 index 00000000..40a3c977 --- /dev/null +++ b/scale.go @@ -0,0 +1,187 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package scale implements the Scale Runtime in Go. +package scale + +import ( + "context" + "crypto/rand" + "fmt" + "sync" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" + + "github.com/tetratelabs/wazero" + "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" +) + +// Next is the next function in the middleware chain. It's meant to be implemented +// by whatever adapter is being used. +type Next[T interfaces.Signature] func(ctx T) (T, error) + +// Scale is the Scale Runtime. It is responsible for initializing +// and managing the WASM runtime as well as the scale function chain. +type Scale[T interfaces.Signature] struct { + runtime wazero.Runtime + moduleConfig wazero.ModuleConfig + + config *Config[T] + + head *template[T] + tail *template[T] + + activeModulesMu sync.RWMutex + activeModules map[string]*module[T] + + TraceDataCallback func(data string) +} + +func New[T interfaces.Signature](config *Config[T]) (*Scale[T], error) { + r := &Scale[T]{ + runtime: wazero.NewRuntimeWithConfig(config.context, wazero.NewRuntimeConfig().WithCloseOnContextDone(true)), + moduleConfig: wazero.NewModuleConfig().WithSysNanotime().WithSysWalltime().WithRandSource(rand.Reader), + activeModules: make(map[string]*module[T]), + config: config, + } + + return r, r.init() +} + +// Instance returns a new instance of a Scale Function chain +// with the provided and optional next function. +func (r *Scale[T]) Instance(next ...Next[T]) (*Instance[T], error) { + return newInstance(r.config.context, r, next...) +} + +func (r *Scale[T]) init() error { + err := r.config.validate() + if err != nil { + return err + } + + if r.config.stdout != nil && r.config.rawOutput { + r.moduleConfig = r.moduleConfig.WithStdout(r.config.stdout) + } + + if r.config.stderr != nil && r.config.rawOutput { + r.moduleConfig = r.moduleConfig.WithStderr(r.config.stderr) + } + + envHostModuleBuilder := r.runtime.NewHostModuleBuilder("env"). + NewFunctionBuilder(). + WithGoModuleFunction(api.GoModuleFunc(r.next), []api.ValueType{api.ValueTypeI32, api.ValueTypeI32}, []api.ValueType{}). + WithParameterNames("pointer", "length").Export("next") + + _, err = envHostModuleBuilder.Instantiate(r.config.context) + if err != nil { + return fmt.Errorf("failed to instantiate env host module: %w", err) + } + + // Tracing Functions + scaleHostModuleBuilder := r.runtime.NewHostModuleBuilder("scale") + scaleHostModuleBuilder.NewFunctionBuilder(). + WithGoModuleFunction(api.GoModuleFunc(r.getFunctionNameLen), []api.ValueType{}, []api.ValueType{api.ValueTypeI32}). + WithParameterNames("pointer").Export("get_function_name_len") + scaleHostModuleBuilder.NewFunctionBuilder(). + WithGoModuleFunction(api.GoModuleFunc(r.getFunctionName), []api.ValueType{api.ValueTypeI32}, []api.ValueType{}). + WithParameterNames("pointer").Export("get_function_name") + scaleHostModuleBuilder.NewFunctionBuilder(). + WithGoModuleFunction(api.GoModuleFunc(r.getInstanceID), []api.ValueType{api.ValueTypeI32}, []api.ValueType{}). + WithParameterNames("pointer").Export("get_instance_id") + scaleHostModuleBuilder.NewFunctionBuilder(). + WithGoModuleFunction(api.GoModuleFunc(r.otelTraceJSON), []api.ValueType{api.ValueTypeI32, api.ValueTypeI32}, []api.ValueType{}). + WithParameterNames("pointer", "length").Export("otel_trace_json") + + _, err = scaleHostModuleBuilder.Instantiate(r.config.context) + if err != nil { + return fmt.Errorf("failed to instantiate scale host module: %w", err) + } + + _, err = wasi_snapshot_preview1.Instantiate(r.config.context, r.runtime) + if err != nil { + return fmt.Errorf("failed to instantiate host module wasi: %w", err) + } + + testSignature := r.config.newSignature() + for _, sf := range r.config.functions { + if testSignature.Hash() != "" && testSignature.Hash() != sf.function.SignatureHash { + return fmt.Errorf("passed in function '%s:%s' has an invalid signatures", sf.function.Name, sf.function.Tag) + } + + t, err := newTemplate(r.config.context, r, sf.function, sf.env) + if err != nil { + return fmt.Errorf("failed to pre-compile function '%s:%s': %w", sf.function.Name, sf.function.Tag, err) + } + + if r.head == nil { + r.head = t + } + + if r.tail != nil { + r.tail.next = t + } + + r.tail = t + } + + return nil +} + +func (r *Scale[T]) next(ctx context.Context, module api.Module, params []uint64) { + r.activeModulesMu.RLock() + m := r.activeModules[module.Name()] + r.activeModulesMu.RUnlock() + if m == nil { + return + } + + pointer := uint32(params[0]) + length := uint32(params[1]) + buf, ok := m.instantiatedModule.Memory().Read(pointer, length) + if !ok { + return + } + + err := m.signature.Read(buf) + if err != nil { + return + } + + if m.function.next != nil { + nextModule, err := m.function.next.getModule(m.signature) + if err == nil { + err = nextModule.run(ctx) + if err == nil { + m.function.next.putModule(nextModule) + } + } + } else { + m.signature, err = m.function.instance.next(m.signature) + } + if err != nil { + buf = m.signature.Error(err) + } else { + buf = m.signature.Write() + } + + writeBuffer, err := m.resizeFunction.Call(ctx, uint64(len(buf))) + if err != nil { + return + } + m.instantiatedModule.Memory().Write(uint32(writeBuffer[0]), buf) +} diff --git a/scale.rs b/scale.rs new file mode 100644 index 00000000..75a2853e --- /dev/null +++ b/scale.rs @@ -0,0 +1,20 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +pub mod config; + +struct Scale { + config: config::Config, +} diff --git a/scale.ts b/scale.ts new file mode 100644 index 00000000..a3c4085c --- /dev/null +++ b/scale.ts @@ -0,0 +1,119 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Signature } from "@loopholelabs/scale-signature-interfaces"; +import { Config } from "./config"; +import { CallbackFunction as TraceCallbackFunction } from "./tracing"; +import {NewTemplate, Template} from "./template"; +import {Module} from "./module"; +import {Instance, NewInstance} from "./instance"; + +export type NextFn = (ctx: T) => T; + +export async function New(config: Config): Promise> { + const r = new Scale(config); + await r.Ready(); + return r; +} + +export class Scale { + private readonly ready: Promise; + public readonly config: Config; + public head: undefined | Template; + private tail: undefined | Template; + + public TraceDataCallback: TraceCallbackFunction | undefined; + + constructor(config: Config) { + this.config = config; + this.ready = new Promise(async (resolve) => { // eslint-disable-line no-async-promise-executor + this.config.validate() + + const testSignature = this.config.newSignature(); + for (let i = 0; i < this.config.functions.length; i++) { + const sf = this.config.functions[i]; + if (testSignature.Hash() != sf.function.SignatureHash) { + throw new Error(`passed in function ${sf.function.Name}:${sf.function.Tag} has an invalid signature`); + } + let t: Template; + try { + t = await NewTemplate(this, sf.function, sf.env); + } catch (e) { + throw new Error(`failed to pre-compile function ${sf.function.Name}:${sf.function.Tag}: ${e}`); + } + + if (typeof this.head === "undefined") { + this.head = t; + } + + if (typeof this.tail !== "undefined") { + this.tail.next = t; + } + + this.tail = t; + } + resolve(); + }); + } + + async Ready() { + await this.ready; + } + + async Instance(next?: NextFn): Promise> { + return NewInstance(this, next); + } + + public Next(m: Module): (ptr: number, len: number) => void { + return (ptr: number, len: number): void => { + if (typeof m.memory === "undefined") { + throw new Error("no memory found in module"); + } + if (typeof m.resize === "undefined") { + throw new Error("no resize function found in module"); + } + if (typeof m.signature === "undefined") { + throw new Error("no signature found in module"); + } + if (typeof m.function === "undefined") { + throw new Error("no function found in module"); + } + let buf: Uint8Array; + try { + const memDataOut = new Uint8Array(m.memory.buffer); + const inContextBuff = memDataOut.slice(ptr, ptr + len); + m.signature.Read(inContextBuff); + + if (typeof m.function.next !== "undefined") { + m.function.next.GetModule(m.signature).then((nextModule) => { + nextModule.Run(); + if (typeof m.function !== "undefined" && typeof m.function.next !== "undefined") { + m.function.next.PutModule(nextModule); + } + }); + } else { + m.signature = m.function.instance.next(m.signature) + } + buf = m.signature.Write(); + } catch (e) { + buf = m.signature.Error(e as Error); + } + const writeBufferPointer = m.resize(buf.length); + const writeBuffer = new Uint8Array(m.memory.buffer); + writeBuffer.set(buf, writeBufferPointer); + } + } +} diff --git a/scalefile/scalefile.go b/scalefile/scalefile.go new file mode 100644 index 00000000..7bc1f664 --- /dev/null +++ b/scalefile/scalefile.go @@ -0,0 +1,129 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package scalefile implements the ScaleFile type, as well as any helper functions +// for interacting with ScaleFile types +package scalefile + +import ( + "errors" + "fmt" + "os" + + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/gohcl" + "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/hashicorp/hcl/v2/hclwrite" + + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" +) + +const ( + V1AlphaVersion = "v1alpha" +) + +var ( + ErrInvalidName = errors.New("invalid name") + ErrInvalidTag = errors.New("invalid tag") +) + +type SignatureSchema struct { + Organization string `hcl:"organization,optional"` + Name string `hcl:"name,attr"` + Tag string `hcl:"tag,attr"` +} + +type Schema struct { + Version string `hcl:"version,attr"` + Name string `hcl:"name,attr"` + Tag string `hcl:"tag,attr"` + Language string `hcl:"language,attr"` + Signature SignatureSchema `hcl:"signature,block"` + Stateless bool `hcl:"stateless,optional"` + Function string `hcl:"function,attr"` + Initialize string `hcl:"initialize,attr"` + Description string `hcl:"description,optional"` +} + +func ReadSchema(path string) (*Schema, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read schema file: %w", err) + } + + s := new(Schema) + return s, s.Decode(data) +} + +func (s *Schema) Decode(data []byte) error { + file, diag := hclsyntax.ParseConfig(data, "", hcl.Pos{Line: 1, Column: 1}) + if diag.HasErrors() { + return diag.Errs()[0] + } + + diag = gohcl.DecodeBody(file.Body, nil, s) + if diag.HasErrors() { + return diag.Errs()[0] + } + + return nil +} + +func (s *Schema) Encode() ([]byte, error) { + f := hclwrite.NewEmptyFile() + gohcl.EncodeIntoBody(s, f.Body()) + return f.Bytes(), nil +} + +func (s *Schema) Validate() error { + switch s.Version { + case V1AlphaVersion: + if !scalefunc.ValidString(s.Name) { + return ErrInvalidName + } + + if scalefunc.ValidString(s.Tag) { + return ErrInvalidTag + } + + switch scalefunc.Language(s.Language) { + case scalefunc.Go, scalefunc.Rust, scalefunc.TypeScript: + default: + return fmt.Errorf("unknown or invalid language: %s", s.Language) + } + + if !scalefunc.ValidString(s.Signature.Organization) { + return fmt.Errorf("invalid organization: %s", s.Signature.Organization) + } + + if !signature.ValidLabel.MatchString(s.Signature.Name) { + return fmt.Errorf("invalid name: %s", s.Signature.Name) + } + + if signature.InvalidString.MatchString(s.Signature.Tag) { + return fmt.Errorf("invalid tag: %s", s.Signature.Tag) + } + + if len(s.Function) == 0 { + return fmt.Errorf("function must be defined") + } + + return nil + default: + return fmt.Errorf("unknown schema version: %s", s.Version) + } +} diff --git a/scalefunc/scaleFunc.test.ts b/scalefunc/scaleFunc.test.ts new file mode 100644 index 00000000..6ecbf985 --- /dev/null +++ b/scalefunc/scaleFunc.test.ts @@ -0,0 +1,138 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { TextEncoder, TextDecoder } from "util"; + +import { + ScaleFunc, + Go, + VersionErr, + LanguageErr, + ChecksumErr, + V1Alpha, + ValidString, +} from "./scalefunc"; + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const Buffer = require("buffer/").Buffer; + +window.TextEncoder = TextEncoder; +window.TextDecoder = TextDecoder as typeof window["TextDecoder"]; + +describe("scaleFunc", () => { + const enc = new TextEncoder(); // always utf-8 + + const someFunction = enc.encode("Hello world some function here"); + + it("Can encode and decode", () => { + expect(() => { + const sfInvalid = new ScaleFunc( + "invalid", + "name", + "tag", + "signature", + Buffer.from(someFunction), + "signatureHash", + Go, + false, + [], + Buffer.from(someFunction) + ); + const b = sfInvalid.Encode(); + ScaleFunc.Decode(b); + }).toThrow(VersionErr); + + expect(() => { + const sfInvalid = new ScaleFunc( + V1Alpha, + "name", + "tag", + "signature", + Buffer.from(someFunction), + "signatureHash", + "invalid", + true, + [], + Buffer.from(someFunction) + ); + const b = sfInvalid.Encode(); + ScaleFunc.Decode(b); + }).toThrow(LanguageErr); + + const sf = new ScaleFunc( + V1Alpha, + "Test name", + "Test tag", + "Test Signature", + Buffer.from(someFunction), + "signatureHash", + Go, + false, + [], + Buffer.from(someFunction) + ); + + const buff = sf.Encode(); + const sf2 = ScaleFunc.Decode(buff); + + expect(sf.Version).toBe(sf2.Version); + expect(sf.Name).toBe(sf2.Name); + expect(sf.Tag).toBe(sf2.Tag); + expect(sf.SignatureName).toBe(sf2.SignatureName); + expect(sf.Language).toBe(sf2.Language); + expect(sf.Function).toStrictEqual(sf2.Function); + + if (typeof sf2.Size !== "undefined" && typeof sf2.Hash !== "undefined") { + buff[buff.length - 1]++; // This increments the last byte of the hash + // Now try to decode again with a bad checksum... + expect(() => { + ScaleFunc.Decode(buff); + }).toThrow(ChecksumErr); + } else { + throw new Error("Size or Checksum were not set!"); + } + }); +}); + + +describe("ValidName", () => { + it("Valid Name", () => { + expect(ValidString("test")).toBe(true); + expect(ValidString("test1")).toBe(true); + expect(ValidString("test.1")).toBe(true); + expect(ValidString("te---.-1")).toBe(true); + expect(ValidString("test-1")).toBe(true); + }); + + it("Invalid Name", () => { + expect(ValidString("test_1")).toBe(false); + expect(ValidString("test 1")).toBe(false); + expect(ValidString("test1 ")).toBe(false); + expect(ValidString(" test1")).toBe(false); + expect(ValidString("test1_")).toBe(false); + expect(ValidString("test1?")).toBe(false); + expect(ValidString("test1!")).toBe(false); + expect(ValidString("test1@")).toBe(false); + expect(ValidString("test1#")).toBe(false); + expect(ValidString("test1$")).toBe(false); + expect(ValidString("test1%")).toBe(false); + expect(ValidString("test1^")).toBe(false); + expect(ValidString("test1&")).toBe(false); + expect(ValidString("test1*")).toBe(false); + expect(ValidString("test1(")).toBe(false); + expect(ValidString("test1-1!")).toBe(false); + }); +}); diff --git a/scalefunc/scalefunc.go b/scalefunc/scalefunc.go new file mode 100644 index 00000000..6f85288c --- /dev/null +++ b/scalefunc/scalefunc.go @@ -0,0 +1,331 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package scalefunc implements the Schema type, as well as any helper functions +// for interacting with Schema types +package scalefunc + +import ( + "crypto/sha256" + "encoding/hex" + "errors" + "os" + "regexp" + + "github.com/hashicorp/hcl/v2/gohcl" + "github.com/hashicorp/hcl/v2/hclwrite" + "github.com/loopholelabs/polyglot" + + signatureSchema "github.com/loopholelabs/scale/signature" +) + +var ( + ErrVersion = errors.New("unknown or invalid version") + ErrLanguage = errors.New("unknown or invalid language") + ErrHash = errors.New("error while verifying hash") +) + +var ( + InvalidStringRegex = regexp.MustCompile(`[^A-Za-z0-9-.]`) +) + +// Version is the Version of the Schema definition +type Version string + +const ( + // V1Alpha is the V1 Alpha definition of a Schema + V1Alpha Version = "v1alpha" +) + +// Language is the Language the Scale Function's Source Language +type Language string + +const ( + // Go is the Golang Source Language for Scale Functions + Go Language = "go" + + // Rust is the Rust Source Language for Scale Functions + Rust Language = "rust" + + // TypeScript is the TypeScript Source Language for Scale Functions + TypeScript Language = "ts" +) + +var ( + // AcceptedVersions is an array of acceptable Versions + AcceptedVersions = []Version{V1Alpha} + + // AcceptedLanguages is an array of acceptable Languages + AcceptedLanguages = []Language{Go, Rust, TypeScript} +) + +// ValidString returns true if the string is valid for use with Scale Functions +func ValidString(str string) bool { + return !InvalidStringRegex.MatchString(str) +} + +// Dependency is a dependency of a compiled Scale Function +type Dependency struct { + Name string `json:"name" yaml:"name"` + Version string `json:"version" yaml:"version"` + Metadata map[string]string `json:"metadata" yaml:"metadata"` +} + +// Schema is the type used to define the requirements of a +// scale function for a Scale Runtime +type Schema struct { + Version Version `json:"version" yaml:"version"` + Name string `json:"name" yaml:"name"` + Tag string `json:"tag" yaml:"tag"` + SignatureName string `json:"signature_name" yaml:"signature_name"` + SignatureSchema *signatureSchema.Schema `json:"signature_schema" yaml:"signature_schema"` + SignatureHash string `json:"signature_hash" yaml:"signature_hash"` + Language Language `json:"language" yaml:"language"` + Stateless bool `json:"stateless" yaml:"stateless"` + Dependencies []Dependency `json:"dependencies" yaml:"dependencies"` + Function []byte `json:"function" yaml:"function"` + Size uint32 `json:"size" yaml:"size"` + Hash string `json:"hash" yaml:"hash"` +} + +// Encode encodes the Schema into a byte array +func (s *Schema) Encode() []byte { + b := polyglot.GetBuffer() + defer polyglot.PutBuffer(b) + e := polyglot.Encoder(b) + e.String(string(s.Version)) + e.String(s.Name) + e.String(s.Tag) + e.String(s.SignatureName) + + f := hclwrite.NewEmptyFile() + gohcl.EncodeIntoBody(s.SignatureSchema, f.Body()) + e.Bytes(f.Bytes()) + + e.String(s.SignatureHash) + + e.String(string(s.Language)) + + e.Bool(s.Stateless) + + e.Slice(uint32(len(s.Dependencies)), polyglot.AnyKind) + for _, d := range s.Dependencies { + e.String(d.Name) + e.String(d.Version) + e.Map(uint32(len(d.Metadata)), polyglot.StringKind, polyglot.StringKind) + for k, v := range d.Metadata { + e.String(k) + e.String(v) + } + } + + e.Bytes(s.Function) + + size := uint32(len(b.Bytes())) + hash := sha256.New() + hash.Write(b.Bytes()) + + e.Uint32(size) + e.String(hex.EncodeToString(hash.Sum(nil))) + + return b.Bytes() +} + +// Decode decodes the Schema from a byte array +func (s *Schema) Decode(data []byte) error { + d := polyglot.GetDecoder(data) + defer d.Return() + + version, err := d.String() + if err != nil { + return err + } + s.Version = Version(version) + + invalid := true + for _, v := range AcceptedVersions { + if s.Version == v { + invalid = false + break + } + } + if invalid { + return ErrVersion + } + + s.Name, err = d.String() + if err != nil { + return err + } + + s.Tag, err = d.String() + if err != nil { + return err + } + + s.SignatureName, err = d.String() + if err != nil { + return err + } + + signatureSchemaBytes, err := d.Bytes(nil) + if err != nil { + return err + } + + s.SignatureSchema = new(signatureSchema.Schema) + err = s.SignatureSchema.Decode(signatureSchemaBytes) + if err != nil { + return err + } + + s.SignatureHash, err = d.String() + if err != nil { + return err + } + + language, err := d.String() + if err != nil { + return err + } + s.Language = Language(language) + + invalid = true + for _, l := range AcceptedLanguages { + if l == s.Language { + invalid = false + break + } + } + if invalid { + return ErrLanguage + } + + s.Stateless, err = d.Bool() + if err != nil { + s.Stateless = false + } + + dependenciesSize, err := d.Slice(polyglot.AnyKind) + if err != nil { + return err + } + s.Dependencies = make([]Dependency, dependenciesSize) + for i := uint32(0); i < dependenciesSize; i++ { + s.Dependencies[i].Name, err = d.String() + if err != nil { + return err + } + s.Dependencies[i].Version, err = d.String() + if err != nil { + return err + } + + metadataSize, err := d.Map(polyglot.StringKind, polyglot.StringKind) + if err != nil { + return err + } + s.Dependencies[i].Metadata = make(map[string]string, metadataSize) + for j := uint32(0); j < metadataSize; j++ { + key, err := d.String() + if err != nil { + return err + } + value, err := d.String() + if err != nil { + return err + } + s.Dependencies[i].Metadata[key] = value + } + } + + s.Function, err = d.Bytes(nil) + if err != nil { + return err + } + + s.Size, err = d.Uint32() + if err != nil { + return err + } + + s.Hash, err = d.String() + if err != nil { + return err + } + + hash := sha256.New() + hash.Write(data[:s.Size]) + + if hex.EncodeToString(hash.Sum(nil)) != s.Hash { + return ErrHash + } + + return nil +} + +// GetHash returns the hash of the Schema +func (s *Schema) GetHash() []byte { + b := polyglot.GetBuffer() + defer polyglot.PutBuffer(b) + e := polyglot.Encoder(b) + e.String(string(s.Version)) + e.String(s.Name) + e.String(s.Tag) + e.String(s.SignatureName) + + f := hclwrite.NewEmptyFile() + gohcl.EncodeIntoBody(s.SignatureSchema, f.Body()) + e.Bytes(f.Bytes()) + + e.String(s.SignatureHash) + + e.String(string(s.Language)) + + e.Slice(uint32(len(s.Dependencies)), polyglot.AnyKind) + for _, d := range s.Dependencies { + e.String(d.Name) + e.String(d.Version) + e.Map(uint32(len(d.Metadata)), polyglot.StringKind, polyglot.StringKind) + for k, v := range d.Metadata { + e.String(k) + e.String(v) + } + } + + e.Bytes(s.Function) + + hash := sha256.New() + hash.Write(b.Bytes()) + + return hash.Sum(nil) +} + +// Read opens a file at the given path and returns a *ScaleFile +func Read(path string) (*Schema, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, err + } + scaleFunc := new(Schema) + return scaleFunc, scaleFunc.Decode(data) +} + +// Write opens a file at the given path and writes the given scalefile to it +func Write(path string, scaleFunc *Schema) error { + data := scaleFunc.Encode() + return os.WriteFile(path, data, 0644) +} diff --git a/scalefunc/scalefunc.ts b/scalefunc/scalefunc.ts new file mode 100644 index 00000000..43e60736 --- /dev/null +++ b/scalefunc/scalefunc.ts @@ -0,0 +1,214 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import sha256 from "fast-sha256"; + +import {Decoder, Encoder, Kind} from "@loopholelabs/polyglot"; +import fs from "fs"; + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const Buffer = require("buffer/").Buffer; + +export const InvalidStringRegex = /[^A-Za-z0-9-.]/; + +export const VersionErr = new Error("unknown or invalid version"); +export const LanguageErr = new Error("unknown or invalid language"); +export const ChecksumErr = new Error("error while verifying checksum"); + +export type Version = string; + +// V1Alpha is the V1 Alpha definition of a ScaleFunc +export const V1Alpha: Version = "v1alpha"; + +export type Language = string; + +// Go is the Golang Source Language for Scale Functions +export const Go: Language = "go"; + +// Rust is the Rust Source Language for Scale Functions +export const Rust: Language = "rust"; + +// Typescript is the Typescript Source Language for Scale Functions +export const Typescript: Language = "ts"; + +// Javascript is the Javascript Source Language for Scale Functions +export const Javascript: Language = "js"; + +// AcceptedVersions is an array of acceptable Versions +export const AcceptedVersions: Version[] = [V1Alpha]; + +// AcceptedLanguages is an array of acceptable Languages +export const AcceptedLanguages: Language[] = [Go, Rust, Typescript, Javascript]; + +export class Dependency { + public Name: string; + public Version: string; + public Metadata: Map | undefined; + + constructor(name: string, version: string, metadata: Map) { + this.Name = name; + this.Version = version; + this.Metadata = metadata; + } +} + +export class ScaleFunc { + public Version: Version; + public Name: string; + public Tag: string; + public SignatureName: string; + public SignatureBytes: Buffer; + public SignatureHash: string; + public Language: Language; + public Stateless: boolean; + public Dependencies: Dependency[]; + public Function: Buffer; + public Size: undefined | number; + public Hash: undefined | string; + + constructor( + version: Version, + name: string, + tag: string, + signatureName: string, + signatureBytes: Buffer, + signatureHash: string, + language: Language, + stateless: boolean, + dependencies: Dependency[], + fn: Buffer + ) { + this.Version = version; + this.Name = name; + this.Tag = tag; + this.SignatureName = signatureName; + this.SignatureBytes = signatureBytes; + this.SignatureHash = signatureHash; + this.Language = language; + this.Stateless = stateless; + this.Dependencies = dependencies; + this.Function = fn; + } + + Encode(): Uint8Array { + const enc = new Encoder(); + enc.string(this.Version as string); + enc.string(this.Name); + enc.string(this.Tag); + enc.string(this.SignatureName); + enc.uint8Array(this.SignatureBytes); + enc.string(this.SignatureHash); + enc.string(this.Language as string); + enc.boolean(this.Stateless); + + enc.array(this.Dependencies.length, Kind.Any); + for (const d of this.Dependencies) { + enc.string(d.Name); + enc.string(d.Version); + enc.map(d.Metadata?.size ?? 0, Kind.String, Kind.String); + for (const [k, v] of d.Metadata ?? []) { + enc.string(k); + enc.string(v); + } + } + + enc.uint8Array(this.Function); + + // Compute the hash (sha256) + + const size = enc.bytes.length; + const hashed = sha256(enc.bytes); + const hex = Buffer.from(hashed).toString("hex"); + + enc.uint32(size); + enc.string(hex); + + return enc.bytes; + } + + static Decode(data: Uint8Array): ScaleFunc { + const dec = new Decoder(data); + + const version = dec.string() as Version; + if (!AcceptedVersions.includes(version)) throw VersionErr; + + const name = dec.string(); + const tag = dec.string(); + const signatureName = dec.string(); + const signatureBytes = dec.uint8Array(); + const signatureHash = dec.string(); + + const language = dec.string(); + if (!AcceptedLanguages.includes(language)) throw LanguageErr; + + let stateless = false; + try { + stateless = dec.boolean(); + } catch (_) {} // eslint-disable-line no-empty + + const dependenciesSize = dec.array(Kind.Any); + const dependencies: Dependency[] = []; + for (let i = 0; i < dependenciesSize; i++) { + const name = dec.string(); + const version = dec.string(); + const metadataSize = dec.map(Kind.String, Kind.String); + const metadata = new Map(); + for (let j = 0; j < metadataSize; j++) { + const key = dec.string(); + const value = dec.string(); + metadata.set(key, value); + } + dependencies.push(new Dependency(name, version, metadata)); + } + + const fn = dec.uint8Array(); + const size = dec.uint32(); + const hash = dec.string(); + + const hashed = sha256(data.slice(0, size)); + const hex = Buffer.from(hashed).toString("hex"); + + if (hex !== hash) throw ChecksumErr; + + const sf = new ScaleFunc( + version, + name, + tag, + signatureName, + Buffer.from(signatureBytes), + signatureHash, + language, + stateless, + dependencies, + Buffer.from(fn) + ); + sf.Size = size; + sf.Hash = hash; + return sf; + } +} + +export function ValidString(str: string): boolean { + return !InvalidStringRegex.test(str); +} + +export function Read(path: string): ScaleFunc { + return ScaleFunc.Decode(fs.readFileSync(path, null)); +} + +export function Write(path: string, scaleFunc: ScaleFunc) { + fs.writeFileSync(path, scaleFunc.Encode()); +} \ No newline at end of file diff --git a/scalefunc/scalefunc_test.go b/scalefunc/scalefunc_test.go new file mode 100644 index 00000000..29bd6bd5 --- /dev/null +++ b/scalefunc/scalefunc_test.go @@ -0,0 +1,136 @@ +//go:build !integration && !generate + +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scalefunc + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/loopholelabs/scale/signature" +) + +func TestEncodeDecode(t *testing.T) { + s := &Schema{ + Version: "invalid", + Language: Go, + SignatureSchema: &signature.Schema{ + Version: signature.V1AlphaVersion, + Context: "ctx", + Models: []*signature.ModelSchema{ + { + Name: "ctx", + Description: "test", + }, + }, + }, + } + + decoded := new(Schema) + + encoded := s.Encode() + err := decoded.Decode(encoded) + assert.ErrorIs(t, err, ErrVersion) + + s.Version = V1Alpha + s.Language = "invalid" + + encoded = s.Encode() + err = decoded.Decode(encoded) + assert.ErrorIs(t, err, ErrLanguage) + + masterTestingSchema := new(signature.Schema) + err = masterTestingSchema.Decode([]byte(signature.MasterTestingSchema)) + assert.NoError(t, err) + + dependencies := make([]Dependency, 3) + dependencies[0] = Dependency{ + Name: "Test Dependency 1", + Version: "1.0.0", + Metadata: make(map[string]string), + } + + dependencies[0].Metadata["test0"] = "test1" + + dependencies[1] = Dependency{ + Name: "Test Dependency 2", + Version: "2.0.0", + Metadata: make(map[string]string), + } + + dependencies[1].Metadata["test2"] = "test3" + + dependencies[2] = Dependency{ + Name: "Test Dependency 3", + Version: "3.0.0", + Metadata: make(map[string]string), + } + + dependencies[2].Metadata["test4"] = "test5" + + s = &Schema{ + Version: V1Alpha, + Name: "Test Name", + Tag: "Test Tag", + SignatureName: "Test Signature", + SignatureSchema: masterTestingSchema, + Dependencies: dependencies, + Language: Go, + Function: []byte("Test Function Contents"), + } + + encoded = s.Encode() + err = decoded.Decode(encoded) + assert.NoError(t, err) + + assert.Equal(t, s.Version, decoded.Version) + assert.Equal(t, s.Name, decoded.Name) + assert.Equal(t, s.Tag, decoded.Tag) + assert.Equal(t, s.Language, decoded.Language) + assert.Equal(t, s.Function, decoded.Function) + assert.Equal(t, s.SignatureName, decoded.SignatureName) + + encoded[decoded.Size+uint32(len(s.Hash))-1] = 0 + err = decoded.Decode(encoded) + assert.ErrorIs(t, err, ErrHash) +} + +func TestValidName(t *testing.T) { + assert.True(t, ValidString("test")) + assert.True(t, ValidString("test1")) + assert.True(t, ValidString("test.1")) + assert.True(t, ValidString("te---.-1")) + assert.True(t, ValidString("test-1")) + assert.False(t, ValidString("test_1")) + assert.False(t, ValidString("test 1")) + assert.False(t, ValidString("test1 ")) + assert.False(t, ValidString(" test1")) + assert.False(t, ValidString("test1_")) + assert.False(t, ValidString("test1?")) + assert.False(t, ValidString("test1!")) + assert.False(t, ValidString("test1@")) + assert.False(t, ValidString("test1#")) + assert.False(t, ValidString("test1$")) + assert.False(t, ValidString("test1%")) + assert.False(t, ValidString("test1^")) + assert.False(t, ValidString("test1&")) + assert.False(t, ValidString("test1*")) + assert.False(t, ValidString("test1(")) + assert.False(t, ValidString("test1-1!")) +} diff --git a/signature/bool.go b/signature/bool.go new file mode 100644 index 00000000..d47bb543 --- /dev/null +++ b/signature/bool.go @@ -0,0 +1,49 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "fmt" +) + +type BoolSchema struct { + Name string `hcl:"name,label"` + Default bool `hcl:"default,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *BoolSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.bool name: %s", model.Name, s.Name) + } + + return nil +} + +type BoolArraySchema struct { + Name string `hcl:"name,label"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *BoolArraySchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.bool_array name: %s", model.Name, s.Name) + } + + return nil +} diff --git a/signature/bytes.go b/signature/bytes.go new file mode 100644 index 00000000..1215ef27 --- /dev/null +++ b/signature/bytes.go @@ -0,0 +1,47 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import "fmt" + +type BytesSchema struct { + Name string `hcl:"name,label"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *BytesSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.bytes name: %s", model.Name, s.Name) + } + + return nil +} + +type BytesArraySchema struct { + Name string `hcl:"name,label"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *BytesArraySchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.bytes_array name: %s", model.Name, s.Name) + } + + return nil +} diff --git a/signature/converter/converter.go b/signature/converter/converter.go new file mode 100644 index 00000000..ea24e165 --- /dev/null +++ b/signature/converter/converter.go @@ -0,0 +1,1361 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package converter generates a polyglot-encoded buffer from a signature schema +// and a data payload +package converter + +import ( + "encoding/base64" + "encoding/hex" + "errors" + "fmt" + "strconv" + + "github.com/loopholelabs/polyglot" + + "github.com/loopholelabs/scale/signature" +) + +var ( + ErrInvalidSchema = errors.New("invalid schema") + ErrInvalidData = errors.New("invalid data") +) + +// Converter converts a signature schema and data payload into a polyglot-encoded buffer +type Converter struct { + signature *signature.Schema + models map[string]*signature.ModelSchema + enums map[string]*signature.EnumSchema + ctxName string + ctxModel *signature.ModelSchema +} + +func ToPolyglot(schema *signature.Schema, data map[string]interface{}, encoder *polyglot.BufferEncoder) error { + p, err := New(schema) + if err != nil { + return err + } + return p.ToPolyglot(data, encoder) +} + +func FromPolyglot(schema *signature.Schema, decoder *polyglot.Decoder) (map[string]interface{}, error) { + p, err := New(schema) + if err != nil { + return nil, err + } + return p.FromPolyglot(decoder) +} + +func New(schema *signature.Schema) (*Converter, error) { + p := &Converter{ + signature: schema, + models: make(map[string]*signature.ModelSchema), + enums: make(map[string]*signature.EnumSchema), + } + + p.ctxName = p.signature.Context + if p.ctxName == "" { + return nil, fmt.Errorf("%w: missing context", ErrInvalidSchema) + } + + for _, model := range p.signature.Models { + p.models[model.Name] = model + if model.Name == p.ctxName { + p.ctxModel = model + break + } + } + if p.ctxModel == nil { + return nil, fmt.Errorf("%w: missing context model", ErrInvalidSchema) + } + + for _, enum := range p.signature.Enums { + p.enums[enum.Name] = enum + } + + return p, nil +} + +func (p *Converter) ToPolyglot(data map[string]interface{}, encoder *polyglot.BufferEncoder) error { + ctx, ok := data[p.ctxName] + if !ok { + return ErrInvalidData + } + + ctxMap, ok := ctx.(map[string]interface{}) + if !ok { + return ErrInvalidData + } + + err := p.encodeModel(p.ctxModel, ctxMap, encoder) + if err != nil { + return fmt.Errorf("%w: error encoding context: %w", ErrInvalidData, err) + } + + return nil +} + +func (p *Converter) FromPolyglot(decoder *polyglot.Decoder) (map[string]interface{}, error) { + output := make(map[string]interface{}) + data, err := p.decodeModel(p.ctxModel, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding context: %w", ErrInvalidData, err) + } + output[p.ctxName] = data + return output, nil +} + +func (p *Converter) encodeModel(model *signature.ModelSchema, data map[string]interface{}, encoder *polyglot.BufferEncoder) (err error) { + for _, m := range model.Models { + modelData, ok := data[m.Name] + if !ok { + return fmt.Errorf("%w: missing model data", ErrInvalidData) + } + modelDataMap, ok := modelData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid model data", ErrInvalidData) + } + + schema, ok := p.models[m.Reference] + if !ok { + return fmt.Errorf("%w: missing model reference schema", ErrInvalidSchema) + } + + err = p.encodeModel(schema, modelDataMap, encoder) + if err != nil { + return fmt.Errorf("%w: error encoding model %s: %w", ErrInvalidData, m.Name, err) + } + } + + for _, a := range model.ModelArrays { + arrayData, ok := data[a.Name] + if !ok { + return fmt.Errorf("%w: missing model array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid model array data", ErrInvalidData) + } + + schema, ok := p.models[a.Reference] + if !ok { + return fmt.Errorf("%w: missing model array reference schema", ErrInvalidSchema) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.AnyKind) + for _, ad := range arrayDataSlice { + arrayDataMap, ok := ad.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid model array data", ErrInvalidData) + } + + err = p.encodeModel(schema, arrayDataMap, encoder) + if err != nil { + return fmt.Errorf("%w: error encoding model array %s: %w", ErrInvalidData, a.Name, err) + } + } + } + + for _, s := range model.Strings { + stringData, ok := data[s.Name] + if !ok { + return fmt.Errorf("%w: missing string data", ErrInvalidData) + } + + stringDataString, ok := stringData.(string) + if !ok { + return fmt.Errorf("%w: invalid string data", ErrInvalidData) + } + + encoder.String(stringDataString) + } + + for _, sa := range model.StringArrays { + arrayData, ok := data[sa.Name] + if !ok { + return fmt.Errorf("%w: missing string array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid string array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.StringKind) + for _, ad := range arrayDataSlice { + j, ok := ad.(string) + if !ok { + return fmt.Errorf("%w: invalid string array data", ErrInvalidData) + } + encoder.String(j) + } + } + + for _, sm := range model.StringMaps { + mapData, ok := data[sm.Name] + if !ok { + return fmt.Errorf("%w: missing string map data", ErrInvalidData) + } + + mapDataMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid string map data", ErrInvalidData) + } + + err = encodeMap[string](p, polyglot.StringKind, sm.Value, mapDataMap, encoder.String, encoder) + if err != nil { + return err + } + } + + for _, i := range model.Int32s { + int32Data, ok := data[i.Name] + if !ok { + return fmt.Errorf("%w: missing int32 data", ErrInvalidData) + } + + int32DataInt, ok := int32Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid int32 data", ErrInvalidData) + } + + encoder.Int32(int32(int32DataInt)) + } + + for _, ia := range model.Int32Arrays { + arrayData, ok := data[ia.Name] + if !ok { + return fmt.Errorf("%w: missing int32 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid int32 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Int32Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid int32 array data", ErrInvalidData) + } + encoder.Int32(int32(j)) + } + } + + for _, im := range model.Int32Maps { + mapData, ok := data[im.Name] + if !ok { + return fmt.Errorf("%w: missing int32 map data", ErrInvalidData) + } + + mapDataMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid int32 map data", ErrInvalidData) + } + + convertedMapDataMap := make(map[int32]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + i, err := strconv.ParseInt(k, 10, 32) + if err != nil { + return fmt.Errorf("%w: invalid int32 map data", ErrInvalidData) + } + convertedMapDataMap[int32(i)] = v + } + + err = encodeMap[int32](p, polyglot.Int32Kind, im.Value, convertedMapDataMap, encoder.Int32, encoder) + if err != nil { + return err + } + } + + for _, i := range model.Int64s { + int64Data, ok := data[i.Name] + if !ok { + return fmt.Errorf("%w: missing int64 data", ErrInvalidData) + } + + int64DataInt, ok := int64Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid int64 data", ErrInvalidData) + } + + encoder.Int64(int64(int64DataInt)) + } + + for _, ia := range model.Int64Arrays { + arrayData, ok := data[ia.Name] + if !ok { + return fmt.Errorf("%w: missing int64 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid int64 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Int64Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid int64 array data", ErrInvalidData) + } + encoder.Int64(int64(j)) + } + } + + for _, im := range model.Int64Maps { + mapData, ok := data[im.Name] + if !ok { + return fmt.Errorf("%w: missing int64 map data", ErrInvalidData) + } + + mapDataMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid int64 map data", ErrInvalidData) + } + + convertedMapDataMap := make(map[int64]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + i, err := strconv.ParseInt(k, 10, 64) + if err != nil { + return fmt.Errorf("%w: invalid int64 map data", ErrInvalidData) + } + convertedMapDataMap[i] = v + } + + err = encodeMap[int64](p, polyglot.Int64Kind, im.Value, convertedMapDataMap, encoder.Int64, encoder) + if err != nil { + return err + } + } + + for _, u := range model.Uint32s { + uint32Data, ok := data[u.Name] + if !ok { + return fmt.Errorf("%w: missing uint32 data", ErrInvalidData) + } + + uint32DataInt, ok := uint32Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid uint32 data", ErrInvalidData) + } + + encoder.Uint32(uint32(uint32DataInt)) + } + + for _, ua := range model.Uint32Arrays { + arrayData, ok := data[ua.Name] + if !ok { + return fmt.Errorf("%w: missing uint32 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid uint32 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Uint32Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid uint32 array data", ErrInvalidData) + } + encoder.Uint32(uint32(j)) + } + } + + for _, um := range model.Uint32Maps { + mapData, ok := data[um.Name] + if !ok { + return fmt.Errorf("%w: missing uint32 map data", ErrInvalidData) + } + + mapDataMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid uint32 map data", ErrInvalidData) + } + + convertedMapDataMap := make(map[uint32]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + i, err := strconv.ParseUint(k, 10, 32) + if err != nil { + return fmt.Errorf("%w: invalid uint32 map data", ErrInvalidData) + } + convertedMapDataMap[uint32(i)] = v + } + + err = encodeMap[uint32](p, polyglot.Uint32Kind, um.Value, convertedMapDataMap, encoder.Uint32, encoder) + if err != nil { + return err + } + } + + for _, u := range model.Uint64s { + uint64Data, ok := data[u.Name] + if !ok { + return fmt.Errorf("%w: missing uint64 data", ErrInvalidData) + } + + uint64DataInt, ok := uint64Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid uint64 data", ErrInvalidData) + } + + encoder.Uint64(uint64(uint64DataInt)) + } + + for _, ua := range model.Uint64Arrays { + arrayData, ok := data[ua.Name] + if !ok { + return fmt.Errorf("%w: missing uint64 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid uint64 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Uint64Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid uint64 array data", ErrInvalidData) + } + encoder.Uint64(uint64(j)) + } + } + + for _, um := range model.Uint64Maps { + mapData, ok := data[um.Name] + if !ok { + return fmt.Errorf("%w: missing uint64 map data", ErrInvalidData) + } + + mapDataMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid uint64 map data", ErrInvalidData) + } + + convertedMapDataMap := make(map[uint64]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + i, err := strconv.ParseUint(k, 10, 64) + if err != nil { + return fmt.Errorf("%w: invalid uint64 map data", ErrInvalidData) + } + convertedMapDataMap[i] = v + } + + err = encodeMap[uint64](p, polyglot.Uint64Kind, um.Value, convertedMapDataMap, encoder.Uint64, encoder) + if err != nil { + return err + } + } + + for _, f := range model.Float32s { + float32Data, ok := data[f.Name] + if !ok { + return fmt.Errorf("%w: missing float32 data", ErrInvalidData) + } + + float32DataFloat, ok := float32Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid float32 data", ErrInvalidData) + } + + encoder.Float32(float32(float32DataFloat)) + } + + for _, fa := range model.Float32Arrays { + arrayData, ok := data[fa.Name] + if !ok { + return fmt.Errorf("%w: missing float32 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid float32 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Float32Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid float32 array data", ErrInvalidData) + } + encoder.Float32(float32(j)) + } + } + + for _, f := range model.Float64s { + float64Data, ok := data[f.Name] + if !ok { + return fmt.Errorf("%w: missing float64 data", ErrInvalidData) + } + + float64DataFloat, ok := float64Data.(float64) + if !ok { + return fmt.Errorf("%w: invalid float64 data", ErrInvalidData) + } + + encoder.Float64(float64DataFloat) + } + + for _, fa := range model.Float64Arrays { + arrayData, ok := data[fa.Name] + if !ok { + return fmt.Errorf("%w: missing float64 array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid float64 array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Float64Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(float64) + if !ok { + return fmt.Errorf("%w: invalid float64 array data", ErrInvalidData) + } + encoder.Float64(j) + } + } + + for _, e := range model.Enums { + enumData, ok := data[e.Name] + if !ok { + return fmt.Errorf("%w: missing enum data", ErrInvalidData) + } + + schema, ok := p.enums[e.Reference] + if !ok { + return fmt.Errorf("%w: missing enum reference schema", ErrInvalidSchema) + } + + enumDataString, ok := enumData.(string) + if !ok { + return fmt.Errorf("%w: invalid enum data", ErrInvalidData) + } + + err = p.encodeEnum(schema, enumDataString, encoder) + if err != nil { + return err + } + } + + for _, ea := range model.EnumArrays { + arrayData, ok := data[ea.Name] + if !ok { + return fmt.Errorf("%w: missing enum array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid enum array data", ErrInvalidData) + } + + schema, ok := p.enums[ea.Reference] + if !ok { + return fmt.Errorf("%w: missing enum reference schema", ErrInvalidSchema) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.Uint32Kind) + for _, ad := range arrayDataSlice { + j, ok := ad.(string) + if !ok { + return fmt.Errorf("%w: invalid enum array data", ErrInvalidData) + } + err = p.encodeEnum(schema, j, encoder) + if err != nil { + return err + } + } + } + + for _, em := range model.EnumMaps { + mapData, ok := data[em.Name] + if !ok { + return fmt.Errorf("%w: missing enum map data", ErrInvalidData) + } + + mapDataStringMap, ok := mapData.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid enum map data", ErrInvalidData) + } + + schema, ok := p.enums[em.Reference] + if !ok { + return fmt.Errorf("%w: missing enum reference schema", ErrInvalidSchema) + } + + mapDataMap := make(map[uint32]interface{}) + found := false + for k, v := range mapDataStringMap { + for i, ev := range schema.Values { + if ev == k { + mapDataMap[uint32(i)] = v + found = true + break + } + } + if !found { + return fmt.Errorf("%w: invalid enum map data", ErrInvalidData) + } + found = false + } + + err = encodeMap[uint32](p, polyglot.Uint32Kind, em.Value, mapDataMap, encoder.Uint32, encoder) + if err != nil { + return err + } + } + + for _, b := range model.Bytes { + byteData, ok := data[b.Name] + if !ok { + return fmt.Errorf("%w: missing byte data", ErrInvalidData) + } + + byteDataString, ok := byteData.(string) + if !ok { + return fmt.Errorf("%w: invalid byte data", ErrInvalidData) + } + + d, err := base64.StdEncoding.DecodeString(byteDataString) + if err != nil { + return fmt.Errorf("%w: invalid byte data", ErrInvalidData) + } + + encoder.Bytes(d) + } + + for _, ba := range model.BytesArrays { + arrayData, ok := data[ba.Name] + if !ok { + return fmt.Errorf("%w: missing byte array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid byte array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.BytesKind) + for _, ad := range arrayDataSlice { + j, ok := ad.(string) + if !ok { + return fmt.Errorf("%w: invalid byte array data", ErrInvalidData) + } + d, err := base64.StdEncoding.DecodeString(j) + if err != nil { + return fmt.Errorf("%w: invalid byte array data", ErrInvalidData) + } + encoder.Bytes(d) + } + } + + for _, b := range model.Bools { + boolData, ok := data[b.Name] + if !ok { + return fmt.Errorf("%w: missing bool data", ErrInvalidData) + } + + boolDataBool, ok := boolData.(bool) + if !ok { + return fmt.Errorf("%w: invalid bool data", ErrInvalidData) + } + + encoder.Bool(boolDataBool) + } + + for _, ba := range model.BoolArrays { + arrayData, ok := data[ba.Name] + if !ok { + return fmt.Errorf("%w: missing bool array data", ErrInvalidData) + } + + arrayDataSlice, ok := arrayData.([]interface{}) + if !ok { + return fmt.Errorf("%w: invalid bool array data", ErrInvalidData) + } + + encoder.Slice(uint32(len(arrayDataSlice)), polyglot.BoolKind) + for _, ad := range arrayDataSlice { + j, ok := ad.(bool) + if !ok { + return fmt.Errorf("%w: invalid bool array data", ErrInvalidData) + } + encoder.Bool(j) + } + } + + return nil +} + +func (p *Converter) decodeModel(model *signature.ModelSchema, decoder *polyglot.Decoder) (map[string]interface{}, error) { + output := make(map[string]interface{}) + for _, m := range model.Models { + schema, ok := p.models[m.Reference] + if !ok { + return nil, fmt.Errorf("%w: missing model reference schema", ErrInvalidSchema) + } + modelDataMap, err := p.decodeModel(schema, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding model %s: %w", ErrInvalidData, m.Name, err) + } + output[m.Name] = modelDataMap + } + + for _, a := range model.ModelArrays { + size, err := decoder.Slice(polyglot.AnyKind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding model array size: %w", ErrInvalidData, err) + } + + schema, ok := p.models[a.Reference] + if !ok { + return nil, fmt.Errorf("%w: missing model array reference schema", ErrInvalidSchema) + } + + arrayMap := make([]interface{}, 0, size) + + for i := uint32(0); i < size; i++ { + modelDataMap, err := p.decodeModel(schema, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding model array %s: %w", ErrInvalidData, a.Name, err) + } + arrayMap = append(arrayMap, modelDataMap) + } + output[a.Name] = arrayMap + } + + for _, s := range model.Strings { + data, err := decoder.String() + if err != nil { + return nil, fmt.Errorf("%w: error decoding string data: %w", ErrInvalidData, err) + } + + output[s.Name] = data + } + + for _, sa := range model.StringArrays { + size, err := decoder.Slice(polyglot.StringKind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding string array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + + for i := uint32(0); i < size; i++ { + data, err := decoder.String() + if err != nil { + return nil, fmt.Errorf("%w: error decoding string array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, data) + } + + output[sa.Name] = arrayMap + } + + for _, sm := range model.StringMaps { + mapDataMap, err := decodeMap[string](p, polyglot.StringKind, sm.Value, decoder.String, decoder) + if err != nil { + return nil, err + } + + output[sm.Name] = mapDataMap + } + + for _, i := range model.Int32s { + data, err := decoder.Int32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding int32 data: %w", ErrInvalidData, err) + } + + output[i.Name] = float64(data) + } + + for _, ia := range model.Int32Arrays { + size, err := decoder.Slice(polyglot.Int32Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding int32 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Int32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding int32 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, float64(data)) + } + + output[ia.Name] = arrayMap + } + + for _, im := range model.Int32Maps { + mapDataMap, err := decodeMap[int32](p, polyglot.Int32Kind, im.Value, decoder.Int32, decoder) + if err != nil { + return nil, err + } + + dataMap := make(map[string]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + dataMap[strconv.FormatInt(int64(k), 10)] = v + } + + output[im.Name] = dataMap + } + + for _, i := range model.Int64s { + data, err := decoder.Int64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding int64 data: %w", ErrInvalidData, err) + } + + output[i.Name] = float64(data) + } + + for _, ia := range model.Int64Arrays { + size, err := decoder.Slice(polyglot.Int64Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding int64 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Int64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding int64 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, float64(data)) + } + + output[ia.Name] = arrayMap + } + + for _, im := range model.Int64Maps { + mapDataMap, err := decodeMap[int64](p, polyglot.Int64Kind, im.Value, decoder.Int64, decoder) + if err != nil { + return nil, err + } + + dataMap := make(map[string]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + dataMap[strconv.FormatInt(k, 10)] = v + } + + output[im.Name] = dataMap + } + + for _, u := range model.Uint32s { + data, err := decoder.Uint32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint32 data: %w", ErrInvalidData, err) + } + + output[u.Name] = float64(data) + } + + for _, ua := range model.Uint32Arrays { + size, err := decoder.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint32 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Uint32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint32 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, float64(data)) + } + + output[ua.Name] = arrayMap + } + + for _, um := range model.Uint32Maps { + mapDataMap, err := decodeMap[uint32](p, polyglot.Uint32Kind, um.Value, decoder.Uint32, decoder) + if err != nil { + return nil, err + } + + dataMap := make(map[string]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + dataMap[strconv.FormatUint(uint64(k), 10)] = v + } + + output[um.Name] = dataMap + } + + for _, u := range model.Uint64s { + data, err := decoder.Uint64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint64 data: %w", ErrInvalidData, err) + } + + output[u.Name] = float64(data) + } + + for _, ua := range model.Uint64Arrays { + size, err := decoder.Slice(polyglot.Uint64Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint64 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Uint64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding uint64 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, float64(data)) + } + + output[ua.Name] = arrayMap + } + + for _, um := range model.Uint64Maps { + mapDataMap, err := decodeMap[uint64](p, polyglot.Uint64Kind, um.Value, decoder.Uint64, decoder) + if err != nil { + return nil, err + } + + dataMap := make(map[string]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + dataMap[strconv.FormatUint(k, 10)] = v + } + + output[um.Name] = dataMap + } + + for _, f := range model.Float32s { + data, err := decoder.Float32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding float32 data: %w", ErrInvalidData, err) + } + + output[f.Name] = float64(data) + } + + for _, fa := range model.Float32Arrays { + size, err := decoder.Slice(polyglot.Float32Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding float32 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Float32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding float32 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, float64(data)) + } + + output[fa.Name] = arrayMap + } + + for _, f := range model.Float64s { + data, err := decoder.Float64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding float64 data: %w", ErrInvalidData, err) + } + + output[f.Name] = data + } + + for _, fa := range model.Float64Arrays { + size, err := decoder.Slice(polyglot.Float64Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding float64 array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Float64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding float64 array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, data) + } + + output[fa.Name] = arrayMap + } + + for _, e := range model.Enums { + schema, ok := p.enums[e.Reference] + if !ok { + return nil, fmt.Errorf("%w: missing enum reference schema", ErrInvalidSchema) + } + + data, err := p.decodeEnum(schema, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding enum data: %w", ErrInvalidData, err) + } + + output[e.Name] = data + } + + for _, ea := range model.EnumArrays { + size, err := decoder.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding enum array size: %w", ErrInvalidData, err) + } + + schema, ok := p.enums[ea.Reference] + if !ok { + return nil, fmt.Errorf("%w: missing enum array reference schema", ErrInvalidSchema) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := p.decodeEnum(schema, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding enum array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, data) + } + + output[ea.Name] = arrayMap + } + + for _, em := range model.EnumMaps { + schema, ok := p.enums[em.Reference] + if !ok { + return nil, fmt.Errorf("%w: missing enum map reference schema", ErrInvalidSchema) + } + + mapDataMap, err := decodeMap[uint32](p, polyglot.Uint32Kind, em.Value, decoder.Uint32, decoder) + if err != nil { + return nil, err + } + + dataMap := make(map[string]interface{}, len(mapDataMap)) + for k, v := range mapDataMap { + dataMap[schema.Values[k]] = v + } + + output[em.Name] = dataMap + } + + for _, b := range model.Bytes { + data, err := decoder.Bytes(nil) + if err != nil { + return nil, fmt.Errorf("%w: error decoding byte data: %w", ErrInvalidData, err) + } + + output[b.Name] = base64.StdEncoding.EncodeToString(data) + } + + for _, ba := range model.BytesArrays { + size, err := decoder.Slice(polyglot.BytesKind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding byte array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Bytes(nil) + if err != nil { + return nil, fmt.Errorf("%w: error decoding byte array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, base64.StdEncoding.EncodeToString(data)) + } + + output[ba.Name] = arrayMap + } + + for _, b := range model.Bools { + data, err := decoder.Bool() + if err != nil { + return nil, fmt.Errorf("%w: error decoding bool data: %w", ErrInvalidData, err) + } + + output[b.Name] = data + } + + for _, ba := range model.BoolArrays { + size, err := decoder.Slice(polyglot.BoolKind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding bool array size: %w", ErrInvalidData, err) + } + + arrayMap := make([]interface{}, 0, size) + for i := uint32(0); i < size; i++ { + data, err := decoder.Bool() + if err != nil { + return nil, fmt.Errorf("%w: error decoding bool array data: %w", ErrInvalidData, err) + } + arrayMap = append(arrayMap, data) + } + + output[ba.Name] = arrayMap + } + + return output, nil +} + +func (p *Converter) encodeEnum(enum *signature.EnumSchema, data string, encoder *polyglot.BufferEncoder) (err error) { + for i, v := range enum.Values { + if v == data { + encoder.Uint32(uint32(i)) + return nil + } + } + return fmt.Errorf("%w: invalid enum data", ErrInvalidData) +} + +func (p *Converter) decodeEnum(enum *signature.EnumSchema, decoder *polyglot.Decoder) (string, error) { + i, err := decoder.Uint32() + if err != nil { + return "", fmt.Errorf("%w: error decoding enum data: %w", ErrInvalidData, err) + } + + if int(i) >= len(enum.Values) { + return "", fmt.Errorf("%w: invalid enum data", ErrInvalidData) + } + + return enum.Values[i], nil +} + +func encodeMap[T comparable](parser *Converter, keyKind polyglot.Kind, valueName string, mapData map[T]interface{}, keyEncoder func(T) *polyglot.BufferEncoder, encoder *polyglot.BufferEncoder) error { + valueKind := polyglot.AnyKind + isPrimitive := signature.ValidPrimitiveType(valueName) + if isPrimitive { + switch valueName { + case "string": + valueKind = polyglot.StringKind + case "int32": + valueKind = polyglot.Int32Kind + case "int64": + valueKind = polyglot.Int64Kind + case "uint32": + valueKind = polyglot.Uint32Kind + case "uint64": + valueKind = polyglot.Uint64Kind + case "float32": + valueKind = polyglot.Float32Kind + case "float64": + valueKind = polyglot.Float64Kind + case "bool": + valueKind = polyglot.BoolKind + case "bytes": + valueKind = polyglot.BytesKind + default: + return fmt.Errorf("%w: invalid primitive map data: %s", ErrInvalidData, valueName) + } + } + encoder.Map(uint32(len(mapData)), keyKind, valueKind) + for k, v := range mapData { + keyEncoder(k) + if isPrimitive { + switch valueName { + case "string": + value, ok := v.(string) + if !ok { + return fmt.Errorf("%w: invalid primitive string map data", ErrInvalidData) + } + encoder.String(value) + case "int32": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive int32 map data", ErrInvalidData) + } + encoder.Int32(int32(value)) + case "int64": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive int64 map data", ErrInvalidData) + } + encoder.Int64(int64(value)) + case "uint32": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive uint32 map data", ErrInvalidData) + } + encoder.Uint32(uint32(value)) + case "uint64": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive uint64 map data", ErrInvalidData) + } + encoder.Uint64(uint64(value)) + case "float32": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive float32 map data", ErrInvalidData) + } + encoder.Float32(float32(value)) + case "float64": + value, ok := v.(float64) + if !ok { + return fmt.Errorf("%w: invalid primitive float64 map data", ErrInvalidData) + } + encoder.Float64(value) + case "bool": + value, ok := v.(bool) + if !ok { + return fmt.Errorf("%w: invalid primitive bool map data", ErrInvalidData) + } + encoder.Bool(value) + case "bytes": + value, ok := v.(string) + if !ok { + return fmt.Errorf("%w: invalid primitive bytes map data", ErrInvalidData) + } + valueBytes, err := hex.DecodeString(value) + if err != nil { + return fmt.Errorf("%w: invalid primitive bytes map data", ErrInvalidData) + } + encoder.Bytes(valueBytes) + default: + return fmt.Errorf("%w: invalid primitive map data: %s", ErrInvalidData, valueName) + } + } else { + model, ok := parser.models[valueName] + if !ok { + return fmt.Errorf("%w: invalid reference map schema", ErrInvalidData) + } + + modelDataMap, ok := v.(map[string]interface{}) + if !ok { + return fmt.Errorf("%w: invalid model data", ErrInvalidData) + } + + err := parser.encodeModel(model, modelDataMap, encoder) + if err != nil { + return fmt.Errorf("%w: error encoding map %s: %w", ErrInvalidData, valueName, err) + } + } + } + return nil +} + +func decodeMap[T comparable](parser *Converter, keyKind polyglot.Kind, valueName string, keyDecoder func() (T, error), decoder *polyglot.Decoder) (map[T]interface{}, error) { + valueKind := polyglot.AnyKind + isPrimitive := signature.ValidPrimitiveType(valueName) + if isPrimitive { + switch valueName { + case "string": + valueKind = polyglot.StringKind + case "int32": + valueKind = polyglot.Int32Kind + case "int64": + valueKind = polyglot.Int64Kind + case "uint32": + valueKind = polyglot.Uint32Kind + case "uint64": + valueKind = polyglot.Uint64Kind + case "float32": + valueKind = polyglot.Float32Kind + case "float64": + valueKind = polyglot.Float64Kind + case "bool": + valueKind = polyglot.BoolKind + case "bytes": + valueKind = polyglot.BytesKind + default: + return nil, fmt.Errorf("%w: invalid primitive map data: %s", ErrInvalidData, valueName) + } + } + + size, err := decoder.Map(keyKind, valueKind) + if err != nil { + return nil, fmt.Errorf("%w: error decoding map size: %w", ErrInvalidData, err) + } + dataMap := make(map[T]interface{}, size) + for i := uint32(0); i < size; i++ { + key, err := keyDecoder() + if err != nil { + return nil, fmt.Errorf("%w: error decoding map key: %w", ErrInvalidData, err) + } + if isPrimitive { + switch valueName { + case "string": + value, err := decoder.String() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive string map value: %w", ErrInvalidData, err) + } + dataMap[key] = value + case "int32": + value, err := decoder.Int32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive int32 map value: %w", ErrInvalidData, err) + } + + dataMap[key] = float64(value) + case "int64": + value, err := decoder.Int64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive int64 map value: %w", ErrInvalidData, err) + } + dataMap[key] = float64(value) + case "uint32": + value, err := decoder.Uint32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive uint32 map value: %w", ErrInvalidData, err) + } + dataMap[key] = float64(value) + case "uint64": + value, err := decoder.Uint64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive uint64 map value: %w", ErrInvalidData, err) + } + dataMap[key] = float64(value) + case "float32": + value, err := decoder.Float32() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive float32 map value: %w", ErrInvalidData, err) + } + dataMap[key] = float64(value) + case "float64": + value, err := decoder.Float64() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive float64 map value: %w", ErrInvalidData, err) + } + dataMap[key] = value + case "bool": + value, err := decoder.Bool() + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive bool map value: %w", ErrInvalidData, err) + } + dataMap[key] = value + case "bytes": + value, err := decoder.Bytes(nil) + if err != nil { + return nil, fmt.Errorf("%w: error decoding primitive bytes map value: %w", ErrInvalidData, err) + } + dataMap[key] = hex.EncodeToString(value) + default: + return nil, fmt.Errorf("%w: invalid primitive map data: %s", ErrInvalidData, valueName) + } + } else { + model, ok := parser.models[valueName] + if !ok { + return nil, fmt.Errorf("%w: invalid reference map schema", ErrInvalidData) + } + + modelDataMap, err := parser.decodeModel(model, decoder) + if err != nil { + return nil, fmt.Errorf("%w: error decoding map %s: %w", ErrInvalidData, valueName, err) + } + dataMap[key] = modelDataMap + } + } + return dataMap, nil +} diff --git a/signature/converter/converter_test.go b/signature/converter/converter_test.go new file mode 100644 index 00000000..58bc0a5b --- /dev/null +++ b/signature/converter/converter_test.go @@ -0,0 +1,315 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package converter + +import ( + "encoding/json" + "testing" + + "github.com/loopholelabs/polyglot" + "github.com/stretchr/testify/require" + + "github.com/loopholelabs/scale/signature" + generated "github.com/loopholelabs/scale/signature/converter/converter_tests" +) + +const jsonData = ` +{ + "Context": { + "EnumField": "SecondValue", + "EnumArrayField": ["FirstValue", "SecondValue", "DefaultValue"], + "EnumMapField": { + "FirstValue": "string1", + "SecondValue": "string2", + "DefaultValue": "string3" + }, + "EnumMapModelField": { + "FirstValue": { + "StringField": "string1" + }, + "SecondValue": { + "StringField": "string2" + }, + "DefaultValue": { + "StringField": "string3" + } + }, + "ModelField": { + "StringField": "string1" + }, + "ModelArrayField": [ + { + "StringField": "string1" + }, + { + "StringField": "string2" + }, + { + "StringField": "string3" + } + ], + "EmptyModelField": {}, + "EmptyModelArrayField": [], + "StringField": "MyString", + "StringArrayField": ["MyString1", "MyString2", "MyString3"], + "StringMapField": { + "key1": "MyString1", + "key2": "MyString2", + "key3": "MyString3" + }, + "StringModelMapField": { + "key1": { + "StringField": "MyString1" + }, + "key2": { + "StringField": "MyString2" + }, + "key3": { + "StringField": "MyString3" + } + }, + "Int32Field": -32, + "Int32ArrayField": [-32, -64, -128], + "Int32MapField": { + "-32": -32, + "-64": -64, + "-128": -128 + }, + "Int32MapModelField": { + "-32": { + "StringField": "MyString1" + }, + "-64": { + "StringField": "MyString2" + }, + "-128": { + "StringField": "MyString3" + } + }, + "Int64Field": -64, + "Int64ArrayField": [-64, -128, -256], + "Int64MapField": { + "-64": -64, + "-128": -128, + "-256": -256 + }, + "Int64MapModelField": { + "-64": { + "StringField": "MyString1" + }, + "-128": { + "StringField": "MyString2" + }, + "-256": { + "StringField": "MyString3" + } + }, + "Uint32Field": 32, + "Uint32ArrayField": [32, 64, 128], + "Uint32MapField": { + "32": 32, + "64": 64, + "128": 128 + }, + "Uint32MapModelField": { + "32": { + "StringField": "MyString1" + }, + "64": { + "StringField": "MyString2" + }, + "128": { + "StringField": "MyString3" + } + }, + "Uint64Field": 64, + "Uint64ArrayField": [64, 128, 256], + "Uint64MapField": { + "64": 64, + "128": 128, + "256": 256 + }, + "Uint64MapModelField": { + "64": { + "StringField": "MyString1" + }, + "128": { + "StringField": "MyString2" + }, + "256": { + "StringField": "MyString3" + } + }, + "Float32Field": 32.32, + "Float32ArrayField": [32.32, 64.64, 128.128], + "Float64Field": 64.64, + "Float64ArrayField": [64.64, 128.128, 256.256], + "BoolField": true, + "BoolArrayField": [true, false, true], + "BytesField": "dGVzdGluZzEyMw==", + "BytesArrayField": ["dGVzdGluZzEyMw==", "dGVzdGluZzEyNA==", "dGVzdGluZzEyNQ=="] + } +} +` + +func TestConverter(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(testSchema)) + require.NoError(t, err) + + d := make(map[string]interface{}) + + err = json.Unmarshal([]byte(jsonData), &d) + require.NoError(t, err) + + buf := polyglot.NewBuffer() + enc := polyglot.Encoder(buf) + err = ToPolyglot(s, d, enc) + require.NoError(t, err) + + ctx := generated.NewContext() + + ctx, err = generated.DecodeContext(ctx, buf.Bytes()) + require.NoError(t, err) + + require.Equal(t, generated.GenericEnumSecondValue, ctx.EnumField) + require.Equal(t, []generated.GenericEnum{ + generated.GenericEnumFirstValue, + generated.GenericEnumSecondValue, + generated.GenericEnumDefaultValue, + }, ctx.EnumArrayField) + require.Equal(t, map[generated.GenericEnum]string{ + generated.GenericEnumFirstValue: "string1", + generated.GenericEnumSecondValue: "string2", + generated.GenericEnumDefaultValue: "string3", + }, ctx.EnumMapField) + require.Equal(t, map[generated.GenericEnum]generated.EmbeddedModel{ + generated.GenericEnumFirstValue: {StringField: "string1"}, + generated.GenericEnumSecondValue: {StringField: "string2"}, + generated.GenericEnumDefaultValue: {StringField: "string3"}, + }, ctx.EnumMapModelField) + require.Equal(t, &generated.EmbeddedModel{StringField: "string1"}, ctx.ModelField) + require.Equal(t, []generated.EmbeddedModel{ + {StringField: "string1"}, + {StringField: "string2"}, + {StringField: "string3"}, + }, ctx.ModelArrayField) + require.Equal(t, &generated.EmptyModel{}, ctx.EmptyModelField) + require.Equal(t, []generated.EmptyModel{}, ctx.EmptyModelArrayField) + require.Equal(t, "MyString", ctx.StringField) + require.Equal(t, []string{"MyString1", "MyString2", "MyString3"}, ctx.StringArrayField) + require.Equal(t, map[string]string{ + "key1": "MyString1", + "key2": "MyString2", + "key3": "MyString3", + }, ctx.StringMapField) + require.Equal(t, map[string]generated.EmbeddedModel{ + "key1": {StringField: "MyString1"}, + "key2": {StringField: "MyString2"}, + "key3": {StringField: "MyString3"}, + }, ctx.StringModelMapField) + require.Equal(t, int32(-32), ctx.Int32Field) + require.Equal(t, []int32{-32, -64, -128}, ctx.Int32ArrayField) + require.Equal(t, map[int32]int32{ + -32: -32, + -64: -64, + -128: -128, + }, ctx.Int32MapField) + require.Equal(t, map[int32]generated.EmbeddedModel{ + -32: {StringField: "MyString1"}, + -64: {StringField: "MyString2"}, + -128: {StringField: "MyString3"}, + }, ctx.Int32MapModelField) + require.Equal(t, int64(-64), ctx.Int64Field) + require.Equal(t, []int64{-64, -128, -256}, ctx.Int64ArrayField) + require.Equal(t, map[int64]int64{ + -64: -64, + -128: -128, + -256: -256, + }, ctx.Int64MapField) + require.Equal(t, map[int64]generated.EmbeddedModel{ + -64: {StringField: "MyString1"}, + -128: {StringField: "MyString2"}, + -256: {StringField: "MyString3"}, + }, ctx.Int64MapModelField) + require.Equal(t, uint32(32), ctx.Uint32Field) + require.Equal(t, []uint32{32, 64, 128}, ctx.Uint32ArrayField) + require.Equal(t, map[uint32]uint32{ + 32: 32, + 64: 64, + 128: 128, + }, ctx.Uint32MapField) + require.Equal(t, map[uint32]generated.EmbeddedModel{ + 32: {StringField: "MyString1"}, + 64: {StringField: "MyString2"}, + 128: {StringField: "MyString3"}, + }, ctx.Uint32MapModelField) + require.Equal(t, uint64(64), ctx.Uint64Field) + require.Equal(t, []uint64{64, 128, 256}, ctx.Uint64ArrayField) + require.Equal(t, map[uint64]uint64{ + 64: 64, + 128: 128, + 256: 256, + }, ctx.Uint64MapField) + require.Equal(t, map[uint64]generated.EmbeddedModel{ + 64: {StringField: "MyString1"}, + 128: {StringField: "MyString2"}, + 256: {StringField: "MyString3"}, + }, ctx.Uint64MapModelField) + require.Equal(t, float32(32.32), ctx.Float32Field) + require.Equal(t, []float32{32.32, 64.64, 128.128}, ctx.Float32ArrayField) + require.Equal(t, 64.64, ctx.Float64Field) + require.Equal(t, []float64{64.64, 128.128, 256.256}, ctx.Float64ArrayField) + require.Equal(t, true, ctx.BoolField) + require.Equal(t, []bool{true, false, true}, ctx.BoolArrayField) + require.Equal(t, []byte("testing123"), ctx.BytesField) + require.Equal(t, [][]byte{[]byte("testing123"), []byte("testing124"), []byte("testing125")}, ctx.BytesArrayField) + + dec := polyglot.GetDecoder(buf.Bytes()) + data, err := FromPolyglot(s, dec) + require.NoError(t, err) + + require.Equal(t, d["Context"].(map[string]interface{})["ModelField"], data["Context"].(map[string]interface{})["ModelField"]) + require.Equal(t, d["Context"].(map[string]interface{})["ModelArrayField"], data["Context"].(map[string]interface{})["ModelArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["StringField"], data["Context"].(map[string]interface{})["StringField"]) + require.Equal(t, d["Context"].(map[string]interface{})["StringArrayField"], data["Context"].(map[string]interface{})["StringArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["StringMapField"], data["Context"].(map[string]interface{})["StringMapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["StringModelMapField"], data["Context"].(map[string]interface{})["StringModelMapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int32Field"], data["Context"].(map[string]interface{})["Int32Field"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int32ArrayField"], data["Context"].(map[string]interface{})["Int32ArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int32MapField"], data["Context"].(map[string]interface{})["Int32MapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int32MapModelField"], data["Context"].(map[string]interface{})["Int32MapModelField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int64Field"], data["Context"].(map[string]interface{})["Int64Field"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int64ArrayField"], data["Context"].(map[string]interface{})["Int64ArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int64MapField"], data["Context"].(map[string]interface{})["Int64MapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Int64MapModelField"], data["Context"].(map[string]interface{})["Int64MapModelField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint32Field"], data["Context"].(map[string]interface{})["Uint32Field"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint32ArrayField"], data["Context"].(map[string]interface{})["Uint32ArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint32MapField"], data["Context"].(map[string]interface{})["Uint32MapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint32MapModelField"], data["Context"].(map[string]interface{})["Uint32MapModelField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint64Field"], data["Context"].(map[string]interface{})["Uint64Field"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint64ArrayField"], data["Context"].(map[string]interface{})["Uint64ArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint64MapField"], data["Context"].(map[string]interface{})["Uint64MapField"]) + require.Equal(t, d["Context"].(map[string]interface{})["Uint64MapModelField"], data["Context"].(map[string]interface{})["Uint64MapModelField"]) + require.Equal(t, float32(d["Context"].(map[string]interface{})["Float32Field"].(float64)), float32(data["Context"].(map[string]interface{})["Float32Field"].(float64))) + require.Equal(t, float32(d["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[0].(float64)), float32(data["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[0].(float64))) + require.Equal(t, float32(d["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[1].(float64)), float32(data["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[1].(float64))) + require.Equal(t, float32(d["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[2].(float64)), float32(data["Context"].(map[string]interface{})["Float32ArrayField"].([]interface{})[2].(float64))) + require.Equal(t, d["Context"].(map[string]interface{})["Float64Field"], data["Context"].(map[string]interface{})["Float64Field"]) + require.Equal(t, d["Context"].(map[string]interface{})["Float64ArrayField"], data["Context"].(map[string]interface{})["Float64ArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["BoolField"], data["Context"].(map[string]interface{})["BoolField"]) + require.Equal(t, d["Context"].(map[string]interface{})["BoolArrayField"], data["Context"].(map[string]interface{})["BoolArrayField"]) + require.Equal(t, d["Context"].(map[string]interface{})["BytesField"], data["Context"].(map[string]interface{})["BytesField"]) + require.Equal(t, d["Context"].(map[string]interface{})["BytesArrayField"], data["Context"].(map[string]interface{})["BytesArrayField"]) +} diff --git a/signature/converter/converter_tests/generated.go b/signature/converter/converter_tests/generated.go new file mode 100644 index 00000000..508dbd22 --- /dev/null +++ b/signature/converter/converter_tests/generated.go @@ -0,0 +1,959 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: generated + +package generated + +import ( + "errors" + "github.com/loopholelabs/polyglot" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type GenericEnum uint32 + +const ( + GenericEnumFirstValue GenericEnum = 0 + + GenericEnumSecondValue GenericEnum = 1 + + GenericEnumDefaultValue GenericEnum = 2 +) + +func decodeGenericEnum(d *polyglot.Decoder) (GenericEnum, error) { + enumValue, err := d.Uint32() + if err != nil { + return 0, err + } + switch GenericEnum(enumValue) { + case GenericEnumFirstValue: + return GenericEnumFirstValue, nil + case GenericEnumSecondValue: + return GenericEnumSecondValue, nil + case GenericEnumDefaultValue: + return GenericEnumDefaultValue, nil + default: + return 0, InvalidEnum + } +} + +type EmptyModel struct { +} + +func NewEmptyModel() *EmptyModel { + return &EmptyModel{} +} + +func (x *EmptyModel) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModel(x *EmptyModel, b []byte) (*EmptyModel, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModel(x, d) +} + +func _decodeEmptyModel(x *EmptyModel, d *polyglot.Decoder) (*EmptyModel, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModel() + } + + return x, nil +} + +type EmbeddedModel struct { + StringField string +} + +func NewEmbeddedModel() *EmbeddedModel { + return &EmbeddedModel{ + + StringField: "DefaultValue", + } +} + +func (x *EmbeddedModel) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeEmbeddedModel(x *EmbeddedModel, b []byte) (*EmbeddedModel, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmbeddedModel(x, d) +} + +func _decodeEmbeddedModel(x *EmbeddedModel, d *polyglot.Decoder) (*EmbeddedModel, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmbeddedModel() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +type Context struct { + ModelField *EmbeddedModel + EmptyModelField *EmptyModel + + ModelArrayField []EmbeddedModel + EmptyModelArrayField []EmptyModel + + StringField string + + StringArrayField []string + + StringMapField map[string]string + + StringModelMapField map[string]EmbeddedModel + + Int32Field int32 + + Int32ArrayField []int32 + + Int32MapField map[int32]int32 + + Int32MapModelField map[int32]EmbeddedModel + + Int64Field int64 + + Int64ArrayField []int64 + + Int64MapField map[int64]int64 + + Int64MapModelField map[int64]EmbeddedModel + + Uint32Field uint32 + + Uint32ArrayField []uint32 + + Uint32MapField map[uint32]uint32 + + Uint32MapModelField map[uint32]EmbeddedModel + + Uint64Field uint64 + + Uint64ArrayField []uint64 + + Uint64MapField map[uint64]uint64 + + Uint64MapModelField map[uint64]EmbeddedModel + + Float32Field float32 + + Float32ArrayField []float32 + + Float64Field float64 + + Float64ArrayField []float64 + + EnumField GenericEnum + + EnumArrayField []GenericEnum + + EnumMapField map[GenericEnum]string + + EnumMapModelField map[GenericEnum]EmbeddedModel + + BytesField []byte + + BytesArrayField [][]byte + + BoolField bool + + BoolArrayField []bool +} + +func NewContext() *Context { + return &Context{ + + ModelField: NewEmbeddedModel(), + EmptyModelField: NewEmptyModel(), + + ModelArrayField: make([]EmbeddedModel, 0, 0), + EmptyModelArrayField: make([]EmptyModel, 0, 0), + + StringField: "DefaultValue", + + StringArrayField: make([]string, 0, 0), + + StringMapField: make(map[string]string), + + StringModelMapField: make(map[string]EmbeddedModel), + + Int32Field: 32, + + Int32ArrayField: make([]int32, 0, 0), + + Int32MapField: make(map[int32]int32), + + Int32MapModelField: make(map[int32]EmbeddedModel), + + Int64Field: 64, + + Int64ArrayField: make([]int64, 0, 0), + + Int64MapField: make(map[int64]int64), + + Int64MapModelField: make(map[int64]EmbeddedModel), + + Uint32Field: 32, + + Uint32ArrayField: make([]uint32, 0, 0), + + Uint32MapField: make(map[uint32]uint32), + + Uint32MapModelField: make(map[uint32]EmbeddedModel), + + Uint64Field: 64, + + Uint64ArrayField: make([]uint64, 0, 0), + + Uint64MapField: make(map[uint64]uint64), + + Uint64MapModelField: make(map[uint64]EmbeddedModel), + + Float32Field: 32.32, + + Float32ArrayField: make([]float32, 0, 0), + + Float64Field: 64.64, + + Float64ArrayField: make([]float64, 0, 0), + + EnumField: GenericEnumDefaultValue, + + EnumArrayField: make([]GenericEnum, 0, 0), + + EnumMapField: make(map[GenericEnum]string), + + EnumMapModelField: make(map[GenericEnum]EmbeddedModel), + + BytesField: make([]byte, 0, 512), + + BytesArrayField: make([][]byte, 0, 0), + + BoolField: true, + + BoolArrayField: make([]bool, 0, 0), + } +} + +func (x *Context) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.ModelField.Encode(b) + x.EmptyModelField.Encode(b) + + e.Slice(uint32(len(x.ModelArrayField)), polyglot.AnyKind) + for _, a := range x.ModelArrayField { + a.Encode(b) + } + e.Slice(uint32(len(x.EmptyModelArrayField)), polyglot.AnyKind) + for _, a := range x.EmptyModelArrayField { + a.Encode(b) + } + + e.String(x.StringField) + + e.Slice(uint32(len(x.StringArrayField)), polyglot.StringKind) + for _, a := range x.StringArrayField { + e.String(a) + } + + e.Map(uint32(len(x.StringMapField)), polyglot.StringKind, polyglot.StringKind) + for k, v := range x.StringMapField { + e.String(k) + e.String(v) + } + + e.Map(uint32(len(x.StringModelMapField)), polyglot.StringKind, polyglot.AnyKind) + for k, v := range x.StringModelMapField { + e.String(k) + v.Encode(b) + } + + e.Int32(x.Int32Field) + + e.Slice(uint32(len(x.Int32ArrayField)), polyglot.Int32Kind) + for _, a := range x.Int32ArrayField { + e.Int32(a) + } + + e.Map(uint32(len(x.Int32MapField)), polyglot.Int32Kind, polyglot.Int32Kind) + for k, v := range x.Int32MapField { + e.Int32(k) + e.Int32(v) + } + + e.Map(uint32(len(x.Int32MapModelField)), polyglot.Int32Kind, polyglot.AnyKind) + for k, v := range x.Int32MapModelField { + e.Int32(k) + v.Encode(b) + } + + e.Int64(x.Int64Field) + + e.Slice(uint32(len(x.Int64ArrayField)), polyglot.Int64Kind) + for _, a := range x.Int64ArrayField { + e.Int64(a) + } + + e.Map(uint32(len(x.Int64MapField)), polyglot.Int64Kind, polyglot.Int64Kind) + for k, v := range x.Int64MapField { + e.Int64(k) + e.Int64(v) + } + + e.Map(uint32(len(x.Int64MapModelField)), polyglot.Int64Kind, polyglot.AnyKind) + for k, v := range x.Int64MapModelField { + e.Int64(k) + v.Encode(b) + } + + e.Uint32(x.Uint32Field) + + e.Slice(uint32(len(x.Uint32ArrayField)), polyglot.Uint32Kind) + for _, a := range x.Uint32ArrayField { + e.Uint32(a) + } + + e.Map(uint32(len(x.Uint32MapField)), polyglot.Uint32Kind, polyglot.Uint32Kind) + for k, v := range x.Uint32MapField { + e.Uint32(k) + e.Uint32(v) + } + + e.Map(uint32(len(x.Uint32MapModelField)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.Uint32MapModelField { + e.Uint32(k) + v.Encode(b) + } + + e.Uint64(x.Uint64Field) + + e.Slice(uint32(len(x.Uint64ArrayField)), polyglot.Uint64Kind) + for _, a := range x.Uint64ArrayField { + e.Uint64(a) + } + + e.Map(uint32(len(x.Uint64MapField)), polyglot.Uint64Kind, polyglot.Uint64Kind) + for k, v := range x.Uint64MapField { + e.Uint64(k) + e.Uint64(v) + } + + e.Map(uint32(len(x.Uint64MapModelField)), polyglot.Uint64Kind, polyglot.AnyKind) + for k, v := range x.Uint64MapModelField { + e.Uint64(k) + v.Encode(b) + } + + e.Float32(x.Float32Field) + + e.Slice(uint32(len(x.Float32ArrayField)), polyglot.Float32Kind) + for _, a := range x.Float32ArrayField { + e.Float32(a) + } + + e.Float64(x.Float64Field) + + e.Slice(uint32(len(x.Float64ArrayField)), polyglot.Float64Kind) + for _, a := range x.Float64ArrayField { + e.Float64(a) + } + + e.Uint32(uint32(x.EnumField)) + + e.Slice(uint32(len(x.EnumArrayField)), polyglot.Uint32Kind) + for _, a := range x.EnumArrayField { + e.Uint32(uint32(a)) + } + + e.Map(uint32(len(x.EnumMapField)), polyglot.Uint32Kind, polyglot.StringKind) + for k, v := range x.EnumMapField { + e.Uint32(uint32(k)) + e.String(v) + } + + e.Map(uint32(len(x.EnumMapModelField)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.EnumMapModelField { + e.Uint32(uint32(k)) + v.Encode(b) + } + + e.Bytes(x.BytesField) + + e.Slice(uint32(len(x.BytesArrayField)), polyglot.BytesKind) + for _, a := range x.BytesArrayField { + e.Bytes(a) + } + + e.Bool(x.BoolField) + + e.Slice(uint32(len(x.BoolArrayField)), polyglot.BoolKind) + for _, a := range x.BoolArrayField { + e.Bool(a) + } + + } +} + +func DecodeContext(x *Context, b []byte) (*Context, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeContext(x, d) +} + +func _decodeContext(x *Context, d *polyglot.Decoder) (*Context, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewContext() + } + + x.ModelField, err = _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.EmptyModelField, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeModelArrayField, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.ModelArrayField)) != sliceSizeModelArrayField { + x.ModelArrayField = make([]EmbeddedModel, sliceSizeModelArrayField) + } + for i := uint32(0); i < sliceSizeModelArrayField; i++ { + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.ModelArrayField[i] = *v + } + sliceSizeEmptyModelArrayField, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmptyModelArrayField)) != sliceSizeEmptyModelArrayField { + x.EmptyModelArrayField = make([]EmptyModel, sliceSizeEmptyModelArrayField) + } + for i := uint32(0); i < sliceSizeEmptyModelArrayField; i++ { + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.EmptyModelArrayField[i] = *v + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + sliceSizeStringArrayField, err := d.Slice(polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringArrayField)) != sliceSizeStringArrayField { + x.StringArrayField = make([]string, sliceSizeStringArrayField) + } + + for i := uint32(0); i < sliceSizeStringArrayField; i++ { + x.StringArrayField[i], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapField, err := d.Map(polyglot.StringKind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapField)) != mapSizeStringMapField { + x.StringMapField = make(map[string]string, mapSizeStringMapField) + } + + for i := uint32(0); i < mapSizeStringMapField; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + x.StringMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringModelMapField, err := d.Map(polyglot.StringKind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringModelMapField)) != mapSizeStringModelMapField { + x.StringModelMapField = make(map[string]EmbeddedModel, mapSizeStringModelMapField) + } + + for i := uint32(0); i < mapSizeStringModelMapField; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.StringModelMapField[k] = *v + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + sliceSizeInt32ArrayField, err := d.Slice(polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32ArrayField)) != sliceSizeInt32ArrayField { + x.Int32ArrayField = make([]int32, sliceSizeInt32ArrayField) + } + + for i := uint32(0); i < sliceSizeInt32ArrayField; i++ { + x.Int32ArrayField[i], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapField, err := d.Map(polyglot.Int32Kind, polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapField)) != mapSizeInt32MapField { + x.Int32MapField = make(map[int32]int32, mapSizeInt32MapField) + } + + for i := uint32(0); i < mapSizeInt32MapField; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + x.Int32MapField[k], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapModelField, err := d.Map(polyglot.Int32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapModelField)) != mapSizeInt32MapModelField { + x.Int32MapModelField = make(map[int32]EmbeddedModel, mapSizeInt32MapModelField) + } + + for i := uint32(0); i < mapSizeInt32MapModelField; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.Int32MapModelField[k] = *v + } + + x.Int64Field, err = d.Int64() + if err != nil { + return nil, err + } + + sliceSizeInt64ArrayField, err := d.Slice(polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64ArrayField)) != sliceSizeInt64ArrayField { + x.Int64ArrayField = make([]int64, sliceSizeInt64ArrayField) + } + + for i := uint32(0); i < sliceSizeInt64ArrayField; i++ { + x.Int64ArrayField[i], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapField, err := d.Map(polyglot.Int64Kind, polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapField)) != mapSizeInt64MapField { + x.Int64MapField = make(map[int64]int64, mapSizeInt64MapField) + } + + for i := uint32(0); i < mapSizeInt64MapField; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + x.Int64MapField[k], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapModelField, err := d.Map(polyglot.Int64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapModelField)) != mapSizeInt64MapModelField { + x.Int64MapModelField = make(map[int64]EmbeddedModel, mapSizeInt64MapModelField) + } + + for i := uint32(0); i < mapSizeInt64MapModelField; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.Int64MapModelField[k] = *v + } + + x.Uint32Field, err = d.Uint32() + if err != nil { + return nil, err + } + + sliceSizeUint32ArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32ArrayField)) != sliceSizeUint32ArrayField { + x.Uint32ArrayField = make([]uint32, sliceSizeUint32ArrayField) + } + + for i := uint32(0); i < sliceSizeUint32ArrayField; i++ { + x.Uint32ArrayField[i], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapField, err := d.Map(polyglot.Uint32Kind, polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapField)) != mapSizeUint32MapField { + x.Uint32MapField = make(map[uint32]uint32, mapSizeUint32MapField) + } + + for i := uint32(0); i < mapSizeUint32MapField; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + x.Uint32MapField[k], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapModelField, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapModelField)) != mapSizeUint32MapModelField { + x.Uint32MapModelField = make(map[uint32]EmbeddedModel, mapSizeUint32MapModelField) + } + + for i := uint32(0); i < mapSizeUint32MapModelField; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.Uint32MapModelField[k] = *v + } + + x.Uint64Field, err = d.Uint64() + if err != nil { + return nil, err + } + + sliceSizeUint64ArrayField, err := d.Slice(polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64ArrayField)) != sliceSizeUint64ArrayField { + x.Uint64ArrayField = make([]uint64, sliceSizeUint64ArrayField) + } + + for i := uint32(0); i < sliceSizeUint64ArrayField; i++ { + x.Uint64ArrayField[i], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapField, err := d.Map(polyglot.Uint64Kind, polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapField)) != mapSizeUint64MapField { + x.Uint64MapField = make(map[uint64]uint64, mapSizeUint64MapField) + } + + for i := uint32(0); i < mapSizeUint64MapField; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + x.Uint64MapField[k], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapModelField, err := d.Map(polyglot.Uint64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapModelField)) != mapSizeUint64MapModelField { + x.Uint64MapModelField = make(map[uint64]EmbeddedModel, mapSizeUint64MapModelField) + } + + for i := uint32(0); i < mapSizeUint64MapModelField; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.Uint64MapModelField[k] = *v + } + + x.Float32Field, err = d.Float32() + if err != nil { + return nil, err + } + + sliceSizeFloat32ArrayField, err := d.Slice(polyglot.Float32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float32ArrayField)) != sliceSizeFloat32ArrayField { + x.Float32ArrayField = make([]float32, sliceSizeFloat32ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat32ArrayField; i++ { + x.Float32ArrayField[i], err = d.Float32() + if err != nil { + return nil, err + } + } + + x.Float64Field, err = d.Float64() + if err != nil { + return nil, err + } + + sliceSizeFloat64ArrayField, err := d.Slice(polyglot.Float64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float64ArrayField)) != sliceSizeFloat64ArrayField { + x.Float64ArrayField = make([]float64, sliceSizeFloat64ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat64ArrayField; i++ { + x.Float64ArrayField[i], err = d.Float64() + if err != nil { + return nil, err + } + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + sliceSizeEnumArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumArrayField)) != sliceSizeEnumArrayField { + x.EnumArrayField = make([]GenericEnum, sliceSizeEnumArrayField) + } + + for i := uint32(0); i < sliceSizeEnumArrayField; i++ { + val, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumArrayField[i] = val + } + + mapSizeEnumMapField, err := d.Map(polyglot.Uint32Kind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapField)) != mapSizeEnumMapField { + x.EnumMapField = make(map[GenericEnum]string, mapSizeEnumMapField) + } + + for i := uint32(0); i < mapSizeEnumMapField; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeEnumMapModelField, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapModelField)) != mapSizeEnumMapModelField { + x.EnumMapModelField = make(map[GenericEnum]EmbeddedModel, mapSizeEnumMapModelField) + } + + for i := uint32(0); i < mapSizeEnumMapModelField; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + v, err := _decodeEmbeddedModel(nil, d) + if err != nil { + return nil, err + } + x.EnumMapModelField[k] = *v + } + + x.BytesField, err = d.Bytes(nil) + if err != nil { + return nil, err + } + + sliceSizeBytesArrayField, err := d.Slice(polyglot.BytesKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BytesArrayField)) != sliceSizeBytesArrayField { + x.BytesArrayField = make([][]byte, sliceSizeBytesArrayField) + } + + for i := uint32(0); i < sliceSizeBytesArrayField; i++ { + x.BytesArrayField[i], err = d.Bytes(nil) + if err != nil { + return nil, err + } + } + + x.BoolField, err = d.Bool() + if err != nil { + return nil, err + } + + sliceSizeBoolArrayField, err := d.Slice(polyglot.BoolKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BoolArrayField)) != sliceSizeBoolArrayField { + x.BoolArrayField = make([]bool, sliceSizeBoolArrayField) + } + + for i := uint32(0); i < sliceSizeBoolArrayField; i++ { + x.BoolArrayField[i], err = d.Bool() + if err != nil { + return nil, err + } + } + + return x, nil +} diff --git a/signature/converter/generate.go b/signature/converter/generate.go new file mode 100644 index 00000000..245bea45 --- /dev/null +++ b/signature/converter/generate.go @@ -0,0 +1,185 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package converter + +//go:generate go test ./... -tags=generate -v + +const testSchema = ` +version = "v1alpha" +context = "Context" + +enum GenericEnum { + values = ["FirstValue", "SecondValue", "DefaultValue"] +} + +model EmptyModel {} + +model EmbeddedModel { + string StringField { + default = "DefaultValue" + } +} + +model Context { + enum EnumField { + default = "DefaultValue" + reference = "GenericEnum" + } + + enum_array EnumArrayField { + reference = "GenericEnum" + initial_size = 0 + } + + enum_map EnumMapField { + reference = "GenericEnum" + value = "string" + } + + enum_map EnumMapModelField { + reference = "GenericEnum" + value = "EmbeddedModel" + } + + model ModelField { + reference = "EmbeddedModel" + } + + model_array ModelArrayField { + reference = "EmbeddedModel" + initial_size = 0 + } + + model EmptyModelField { + reference = "EmptyModel" + } + + model_array EmptyModelArrayField { + reference = "EmptyModel" + initial_size = 0 + } + + string StringField { + default = "DefaultValue" + } + + string_array StringArrayField { + initial_size = 0 + } + + string_map StringMapField { + value = "string" + } + + string_map StringModelMapField { + value = "EmbeddedModel" + } + + int32 Int32Field { + default = 32 + } + + int32_array Int32ArrayField { + initial_size = 0 + } + + int32_map Int32MapField { + value = "int32" + } + + int32_map Int32MapModelField { + value = "EmbeddedModel" + } + + int64 Int64Field { + default = 64 + } + + int64_array Int64ArrayField { + initial_size = 0 + } + + int64_map Int64MapField { + value = "int64" + } + + int64_map Int64MapModelField { + value = "EmbeddedModel" + } + + uint32 Uint32Field { + default = 32 + } + + uint32_array Uint32ArrayField { + initial_size = 0 + } + + uint32_map Uint32MapField { + value = "uint32" + } + + uint32_map Uint32MapModelField { + value = "EmbeddedModel" + } + + uint64 Uint64Field { + default = 64 + } + + uint64_array Uint64ArrayField { + initial_size = 0 + } + + uint64_map Uint64MapField { + value = "uint64" + } + + uint64_map Uint64MapModelField { + value = "EmbeddedModel" + } + + float32 Float32Field { + default = 32.32 + } + + float32_array Float32ArrayField { + initial_size = 0 + } + + float64 Float64Field { + default = 64.64 + } + + float64_array Float64ArrayField { + initial_size = 0 + } + + bool BoolField { + default = true + } + + bool_array BoolArrayField { + initial_size = 0 + } + + bytes BytesField { + initial_size = 512 + } + + bytes_array BytesArrayField { + initial_size = 0 + } +} +` diff --git a/signature/converter/generate_test.go b/signature/converter/generate_test.go new file mode 100644 index 00000000..0f633e9f --- /dev/null +++ b/signature/converter/generate_test.go @@ -0,0 +1,36 @@ +//go:build generate + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package converter + +import ( + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator/golang" + "github.com/stretchr/testify/require" + "os" + "testing" +) + +func TestGenerateConverterSchema(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(testSchema)) + require.NoError(t, err) + + formatted, err := golang.GenerateTypes(s, "generated") + require.NoError(t, err) + + err = os.WriteFile("./converter_tests/generated.go", formatted, 0644) + require.NoError(t, err) +} diff --git a/signature/converter/signature.go b/signature/converter/signature.go new file mode 100644 index 00000000..e7a3a1ed --- /dev/null +++ b/signature/converter/signature.go @@ -0,0 +1,85 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package converter + +import ( + "encoding/json" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" + + "github.com/loopholelabs/polyglot" + + "github.com/loopholelabs/scale/signature" +) + +var _ interfaces.Signature = (*Signature)(nil) + +type Signature struct { + buffer *polyglot.Buffer + data map[string]interface{} + converter *Converter +} + +func NewSignature(schema *signature.Schema) (*Signature, error) { + converter, err := New(schema) + if err != nil { + return nil, err + } + return &Signature{ + buffer: polyglot.NewBuffer(), + data: make(map[string]interface{}), + converter: converter, + }, nil +} + +func (s *Signature) Signature() *Signature { + return s +} + +func (s *Signature) Read(b []byte) (err error) { + d := polyglot.GetDecoder(b) + s.data, err = s.converter.FromPolyglot(d) + polyglot.ReturnDecoder(d) + return +} + +func (s *Signature) Write() []byte { + s.buffer.Reset() + err := s.converter.ToPolyglot(s.data, polyglot.Encoder(s.buffer)) + if err != nil { + return s.Error(err) + } + return s.buffer.Bytes() +} + +func (s *Signature) Error(err error) []byte { + s.buffer.Reset() + polyglot.Encoder(s.buffer).Error(err) + return s.buffer.Bytes() +} + +func (s *Signature) Hash() string { + return "" +} + +func (s *Signature) FromJSON(b []byte) error { + return json.Unmarshal(b, &s.data) +} + +func (s *Signature) ToJSON() ([]byte, error) { + return json.Marshal(s.data) +} diff --git a/signature/enum.go b/signature/enum.go new file mode 100644 index 00000000..8b097991 --- /dev/null +++ b/signature/enum.go @@ -0,0 +1,120 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "fmt" +) + +type EnumSchema struct { + Name string `hcl:"name,label"` + Values []string `hcl:"values,attr"` +} + +func (s *EnumSchema) Normalize() { + s.Name = TitleCaser.String(s.Name) +} + +func (s *EnumSchema) Validate(knownEnums map[string]struct{}) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid enum name: %s", s.Name) + } + + if _, ok := knownEnums[s.Name]; ok { + return fmt.Errorf("duplicate enum name: %s", s.Name) + } + + knownEnums[s.Name] = struct{}{} + visitedValues := make(map[string]struct{}, 0) + for i := 0; i < len(s.Values); i++ { + if _, ok := visitedValues[s.Values[i]]; ok { + return fmt.Errorf("duplicate value in %s: %s", s.Name, s.Values[i]) + } + visitedValues[s.Values[i]] = struct{}{} + } + + return nil +} + +type EnumReferenceSchema struct { + Name string `hcl:"name,label"` + Default string `hcl:"default,attr"` + Reference string `hcl:"reference,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *EnumReferenceSchema) Validate(model *ModelSchema, enums []*EnumSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.enum name: %s", model.Name, s.Name) + } + + if !ValidLabel.MatchString(s.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, s.Name, s.Reference) + } + + for _, enum := range enums { + if enum.Name != s.Reference { + continue + } + + for _, value := range enum.Values { + if value == s.Default { + return nil + } + } + } + + return fmt.Errorf("invalid %s.default: %s is not a valid value", s.Name, s.Default) +} + +type EnumArraySchema struct { + Name string `hcl:"name,label"` + Reference string `hcl:"reference,attr"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *EnumArraySchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.enum_array name: %s", model.Name, s.Name) + } + + if !ValidLabel.MatchString(s.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, s.Name, s.Reference) + } + + return nil +} + +type EnumMapSchema struct { + Name string `hcl:"name,label"` + Reference string `hcl:"reference,attr"` + Value string `hcl:"value,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (s *EnumMapSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.enum_map name: %s", model.Name, s.Name) + } + + if !ValidLabel.MatchString(s.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, s.Name, s.Reference) + } + + return nil +} diff --git a/signature/generator/file.go b/signature/generator/file.go new file mode 100644 index 00000000..85ef2026 --- /dev/null +++ b/signature/generator/file.go @@ -0,0 +1,88 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package generator + +import ( + "bytes" + "io" + "io/fs" + "os" + "time" + + "golang.org/x/mod/zip" +) + +var _ zip.File = (*File)(nil) +var _ os.FileInfo = (*File)(nil) + +type File struct { + name string + path string + content []byte + reader *bytes.Reader + size int64 +} + +func NewFile(name string, path string, content []byte) File { + return File{ + name: name, + path: path, + content: content, + reader: bytes.NewReader(content), + size: int64(len(content)), + } +} + +func (g File) Name() string { + return g.name +} + +func (g File) Size() int64 { + return g.size +} + +func (g File) Mode() fs.FileMode { + return 0700 +} + +func (g File) ModTime() time.Time { + return time.Now() +} + +func (g File) IsDir() bool { + return false +} + +func (g File) Sys() any { + return g.content +} + +func (g File) Path() string { + return g.path +} + +func (g File) Lstat() (os.FileInfo, error) { + return g, nil +} + +func (g File) Open() (io.ReadCloser, error) { + return io.NopCloser(g.reader), nil +} + +func (g File) Data() []byte { + return g.content +} diff --git a/signature/generator/generator.go b/signature/generator/generator.go new file mode 100644 index 00000000..720b7e7d --- /dev/null +++ b/signature/generator/generator.go @@ -0,0 +1,515 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package generator + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "encoding/hex" + "fmt" + "path" + "strings" + + "github.com/loopholelabs/scale/signature/generator/typescript" + + "golang.org/x/mod/module" + "golang.org/x/mod/zip" + + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator/golang" + "github.com/loopholelabs/scale/signature/generator/rust" +) + +const ( + DefaultGolangPackageName = "signature" +) + +type GuestRegistryPackage struct { + GolangModule *bytes.Buffer + GolangModfile []byte + RustCrate *bytes.Buffer + RustCargofile []byte + TypescriptPackage *bytes.Buffer + TypescriptPackageJSON []byte +} + +type GuestLocalPackage struct { + GolangFiles []File + RustFiles []File + TypescriptFiles []File +} + +type HostRegistryPackage struct { + GolangModule *bytes.Buffer + GolangModfile []byte + TypescriptPackage *bytes.Buffer + TypescriptPackageJSON []byte +} + +type HostLocalPackage struct { + GolangFiles []File + TypescriptFiles []File +} + +type Options struct { + Signature *signature.Schema + + GolangPackageImportPath string + GolangPackageVersion string + + RustPackageName string + RustPackageVersion string + + TypescriptPackageName string + TypescriptPackageVersion string +} + +func GenerateGuestRegistry(options *Options) (*GuestRegistryPackage, error) { + hash, err := options.Signature.Hash() + if err != nil { + return nil, err + } + hashString := hex.EncodeToString(hash) + + golangTypes, err := golang.GenerateTypes(options.Signature, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + golangGuest, err := golang.GenerateGuest(options.Signature, hashString, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + modfile, err := golang.GenerateModfile(options.GolangPackageImportPath) + if err != nil { + return nil, err + } + + files := []zip.File{ + NewFile("types.go", "types.go", golangTypes), + NewFile("guest.go", "guest.go", golangGuest), + NewFile("go.mod", "go.mod", modfile), + } + + golangBuffer := new(bytes.Buffer) + err = zip.Create(golangBuffer, module.Version{ + Path: options.GolangPackageImportPath, + Version: options.GolangPackageVersion, + }, files) + if err != nil { + return nil, err + } + + rustTypes, err := rust.GenerateTypes(options.Signature, options.RustPackageName) + if err != nil { + return nil, err + } + + rustGuest, err := rust.GenerateGuest(options.Signature, hashString, options.RustPackageName) + if err != nil { + return nil, err + } + + cargofile, err := rust.GenerateCargofile(options.RustPackageName, options.RustPackageVersion) + if err != nil { + return nil, err + } + + rustFiles := []File{ + NewFile("types.rs", "types.rs", rustTypes), + NewFile("guest.rs", "guest.rs", rustGuest), + NewFile("Cargo.toml", "Cargo.toml", cargofile), + } + + rustBuffer := new(bytes.Buffer) + gzipRustWriter := gzip.NewWriter(rustBuffer) + tarRustWriter := tar.NewWriter(gzipRustWriter) + + var header *tar.Header + for _, file := range rustFiles { + header, err = tar.FileInfoHeader(file, file.Name()) + if err != nil { + _ = tarRustWriter.Close() + _ = gzipRustWriter.Close() + return nil, fmt.Errorf("failed to create tar header for %s: %w", file.Name(), err) + } + + header.Name = path.Join(fmt.Sprintf("%s-%s", options.RustPackageName, strings.TrimPrefix(options.RustPackageVersion, "v")), header.Name) + + err = tarRustWriter.WriteHeader(header) + if err != nil { + _ = tarRustWriter.Close() + _ = gzipRustWriter.Close() + return nil, fmt.Errorf("failed to write tar header for %s: %w", file.Name(), err) + } + _, err = tarRustWriter.Write(file.Data()) + if err != nil { + _ = tarRustWriter.Close() + _ = gzipRustWriter.Close() + return nil, fmt.Errorf("failed to write tar data for %s: %w", file.Name(), err) + } + } + + err = tarRustWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close tar writer: %w", err) + } + + err = gzipRustWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close gzip writer: %w", err) + } + + typescriptTypes, err := typescript.GenerateTypesTranspiled(options.Signature, options.TypescriptPackageName, "types.js") + if err != nil { + return nil, err + } + + typescriptGuest, err := typescript.GenerateGuestTranspiled(options.Signature, hashString, options.TypescriptPackageName, "index.js") + if err != nil { + return nil, err + } + + packageJSON, err := typescript.GeneratePackageJSON(options.TypescriptPackageName, options.TypescriptPackageVersion) + if err != nil { + return nil, err + } + + typescriptFiles := []File{ + NewFile("types.ts", "types.ts", typescriptTypes.Typescript), + NewFile("types.js", "types.js", typescriptTypes.Javascript), + NewFile("types.js.map", "types.js.map", typescriptTypes.SourceMap), + NewFile("types.d.ts", "types.d.ts", typescriptTypes.Declaration), + NewFile("index.ts", "index.ts", typescriptGuest.Typescript), + NewFile("index.js", "index.js", typescriptGuest.Javascript), + NewFile("index.js.map", "index.js.map", typescriptGuest.SourceMap), + NewFile("index.d.ts", "index.d.ts", typescriptGuest.Declaration), + NewFile("package.json", "package.json", packageJSON), + } + + typescriptBuffer := new(bytes.Buffer) + gzipTypescriptWriter := gzip.NewWriter(typescriptBuffer) + tarTypescriptWriter := tar.NewWriter(gzipTypescriptWriter) + + for _, file := range typescriptFiles { + header, err = tar.FileInfoHeader(file, file.Name()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to create tar header for %s: %w", file.Name(), err) + } + + header.Name = path.Join("package", header.Name) + + err = tarTypescriptWriter.WriteHeader(header) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar header for %s: %w", file.Name(), err) + } + _, err = tarTypescriptWriter.Write(file.Data()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar data for %s: %w", file.Name(), err) + } + } + + err = tarTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close tar writer: %w", err) + } + + err = gzipTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close gzip writer: %w", err) + } + + return &GuestRegistryPackage{ + GolangModule: golangBuffer, + GolangModfile: modfile, + RustCrate: rustBuffer, + RustCargofile: cargofile, + TypescriptPackage: typescriptBuffer, + TypescriptPackageJSON: packageJSON, + }, nil +} + +func GenerateGuestLocal(options *Options) (*GuestLocalPackage, error) { + hash, err := options.Signature.Hash() + if err != nil { + return nil, err + } + hashString := hex.EncodeToString(hash) + + golangTypes, err := golang.GenerateTypes(options.Signature, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + golangGuest, err := golang.GenerateGuest(options.Signature, hashString, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + modfile, err := golang.GenerateModfile(options.GolangPackageImportPath) + if err != nil { + return nil, err + } + + golangFiles := []File{ + NewFile("types.go", "types.go", golangTypes), + NewFile("guest.go", "guest.go", golangGuest), + NewFile("go.mod", "go.mod", modfile), + } + + rustTypes, err := rust.GenerateTypes(options.Signature, options.RustPackageName) + if err != nil { + return nil, err + } + + rustGuest, err := rust.GenerateGuest(options.Signature, hashString, options.RustPackageName) + if err != nil { + return nil, err + } + + cargofile, err := rust.GenerateCargofile(options.RustPackageName, options.RustPackageVersion) + if err != nil { + return nil, err + } + + rustFiles := []File{ + NewFile("types.rs", "types.rs", rustTypes), + NewFile("guest.rs", "guest.rs", rustGuest), + NewFile("Cargo.toml", "Cargo.toml", cargofile), + } + + typescriptTypes, err := typescript.GenerateTypesTranspiled(options.Signature, options.TypescriptPackageName, "types.js") + if err != nil { + return nil, err + } + + typescriptGuest, err := typescript.GenerateGuestTranspiled(options.Signature, hashString, options.TypescriptPackageName, "index.js") + if err != nil { + return nil, err + } + + packageJSON, err := typescript.GeneratePackageJSON(options.TypescriptPackageName, options.TypescriptPackageVersion) + if err != nil { + return nil, err + } + + typescriptFiles := []File{ + NewFile("types.ts", "types.ts", typescriptTypes.Typescript), + NewFile("types.js", "types.js", typescriptTypes.Javascript), + NewFile("types.js.map", "types.js.map", typescriptTypes.SourceMap), + NewFile("types.d.ts", "types.d.ts", typescriptTypes.Declaration), + NewFile("index.ts", "index.ts", typescriptGuest.Typescript), + NewFile("index.js", "index.js", typescriptGuest.Javascript), + NewFile("index.js.map", "index.js.map", typescriptGuest.SourceMap), + NewFile("index.d.ts", "index.d.ts", typescriptGuest.Declaration), + NewFile("package.json", "package.json", packageJSON), + } + + return &GuestLocalPackage{ + GolangFiles: golangFiles, + RustFiles: rustFiles, + TypescriptFiles: typescriptFiles, + }, nil +} + +func GenerateHostRegistry(options *Options) (*HostRegistryPackage, error) { + hash, err := options.Signature.Hash() + if err != nil { + return nil, err + } + hashString := hex.EncodeToString(hash) + + sig, err := options.Signature.CloneWithDisabledAccessorsValidatorsAndModifiers() + if err != nil { + return nil, err + } + + golangTypes, err := golang.GenerateTypes(sig, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + golangHost, err := golang.GenerateHost(sig, hashString, DefaultGolangPackageName) + + if err != nil { + return nil, err + } + + modfile, err := golang.GenerateModfile(options.GolangPackageImportPath) + if err != nil { + return nil, err + } + + files := []zip.File{ + NewFile("types.go", "types.go", golangTypes), + NewFile("host.go", "host.go", golangHost), + NewFile("go.mod", "go.mod", modfile), + } + + golangBuffer := new(bytes.Buffer) + err = zip.Create(golangBuffer, module.Version{ + Path: options.GolangPackageImportPath, + Version: options.GolangPackageVersion, + }, files) + if err != nil { + return nil, err + } + + typescriptTypes, err := typescript.GenerateTypesTranspiled(sig, options.TypescriptPackageName, "types.js") + if err != nil { + return nil, err + } + + typescriptHost, err := typescript.GenerateHostTranspiled(sig, hashString, options.TypescriptPackageName, "index.js") + if err != nil { + return nil, err + } + + packageJSON, err := typescript.GeneratePackageJSON(options.TypescriptPackageName, options.TypescriptPackageVersion) + if err != nil { + return nil, err + } + + typescriptFiles := []File{ + NewFile("types.ts", "types.ts", typescriptTypes.Typescript), + NewFile("types.js", "types.js", typescriptTypes.Javascript), + NewFile("types.js.map", "types.js.map", typescriptTypes.SourceMap), + NewFile("types.d.ts", "types.d.ts", typescriptTypes.Declaration), + NewFile("index.ts", "index.ts", typescriptHost.Typescript), + NewFile("index.js", "index.js", typescriptHost.Javascript), + NewFile("index.js.map", "index.js.map", typescriptHost.SourceMap), + NewFile("index.d.ts", "index.d.ts", typescriptHost.Declaration), + NewFile("package.json", "package.json", packageJSON), + } + + typescriptBuffer := new(bytes.Buffer) + gzipTypescriptWriter := gzip.NewWriter(typescriptBuffer) + tarTypescriptWriter := tar.NewWriter(gzipTypescriptWriter) + + var header *tar.Header + for _, file := range typescriptFiles { + header, err = tar.FileInfoHeader(file, file.Name()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to create tar header for %s: %w", file.Name(), err) + } + + header.Name = path.Join("package", header.Name) + + err = tarTypescriptWriter.WriteHeader(header) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar header for %s: %w", file.Name(), err) + } + _, err = tarTypescriptWriter.Write(file.Data()) + if err != nil { + _ = tarTypescriptWriter.Close() + _ = gzipTypescriptWriter.Close() + return nil, fmt.Errorf("failed to write tar data for %s: %w", file.Name(), err) + } + } + + err = tarTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close tar writer: %w", err) + } + + err = gzipTypescriptWriter.Close() + if err != nil { + return nil, fmt.Errorf("failed to close gzip writer: %w", err) + } + + return &HostRegistryPackage{ + GolangModule: golangBuffer, + GolangModfile: modfile, + TypescriptPackage: typescriptBuffer, + TypescriptPackageJSON: packageJSON, + }, nil +} + +func GenerateHostLocal(options *Options) (*HostLocalPackage, error) { + hash, err := options.Signature.Hash() + if err != nil { + return nil, err + } + hashString := hex.EncodeToString(hash) + + sig, err := options.Signature.CloneWithDisabledAccessorsValidatorsAndModifiers() + if err != nil { + return nil, err + } + + golangTypes, err := golang.GenerateTypes(sig, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + golangHost, err := golang.GenerateHost(sig, hashString, DefaultGolangPackageName) + if err != nil { + return nil, err + } + + modfile, err := golang.GenerateModfile(options.GolangPackageImportPath) + if err != nil { + return nil, err + } + + golangFiles := []File{ + NewFile("types.go", "types.go", golangTypes), + NewFile("host.go", "host.go", golangHost), + NewFile("go.mod", "go.mod", modfile), + } + + typescriptTypes, err := typescript.GenerateTypesTranspiled(sig, options.TypescriptPackageName, "types.js") + if err != nil { + return nil, err + } + + typescriptHost, err := typescript.GenerateHostTranspiled(sig, hashString, options.TypescriptPackageName, "index.js") + if err != nil { + return nil, err + } + + packageJSON, err := typescript.GeneratePackageJSON(options.TypescriptPackageName, options.TypescriptPackageVersion) + if err != nil { + return nil, err + } + + typescriptFiles := []File{ + NewFile("types.ts", "types.ts", typescriptTypes.Typescript), + NewFile("types.js", "types.js", typescriptTypes.Javascript), + NewFile("types.js.map", "types.js.map", typescriptTypes.SourceMap), + NewFile("types.d.ts", "types.d.ts", typescriptTypes.Declaration), + NewFile("index.ts", "index.ts", typescriptHost.Typescript), + NewFile("index.js", "index.js", typescriptHost.Javascript), + NewFile("index.js.map", "index.js.map", typescriptHost.SourceMap), + NewFile("index.d.ts", "index.d.ts", typescriptHost.Declaration), + NewFile("package.json", "package.json", packageJSON), + } + + return &HostLocalPackage{ + GolangFiles: golangFiles, + TypescriptFiles: typescriptFiles, + }, nil +} diff --git a/signature/generator/golang/generated.txt b/signature/generator/golang/generated.txt new file mode 100644 index 00000000..ae3f70d4 --- /dev/null +++ b/signature/generator/golang/generated.txt @@ -0,0 +1,1983 @@ +// Code generated by scale-signature v0.4.0, DO NOT EDIT. +// output: types + +package types + +import ( + "errors" + "fmt" + "github.com/loopholelabs/polyglot" + "regexp" + "strings" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type GenericEnum uint32 + +const ( + GenericEnumFirstValue GenericEnum = 0 + + GenericEnumSecondValue GenericEnum = 1 + + GenericEnumDefaultValue GenericEnum = 2 +) + +func decodeGenericEnum(d *polyglot.Decoder) (GenericEnum, error) { + enumValue, err := d.Uint32() + if err != nil { + return 0, err + } + switch GenericEnum(enumValue) { + case GenericEnumFirstValue: + return GenericEnumFirstValue, nil + case GenericEnumSecondValue: + return GenericEnumSecondValue, nil + case GenericEnumDefaultValue: + return GenericEnumDefaultValue, nil + default: + return 0, InvalidEnum + } +} + +type EmptyModel struct { +} + +func NewEmptyModel() *EmptyModel { + return &EmptyModel{} +} + +func (x *EmptyModel) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModel(x *EmptyModel, b []byte) (*EmptyModel, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModel(x, d) +} + +func _decodeEmptyModel(x *EmptyModel, d *polyglot.Decoder) (*EmptyModel, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModel() + } + + return x, nil +} + +// EmptyModelWithDescription: Test Description +type EmptyModelWithDescription struct { +} + +func NewEmptyModelWithDescription() *EmptyModelWithDescription { + return &EmptyModelWithDescription{} +} + +func (x *EmptyModelWithDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + } +} + +func DecodeEmptyModelWithDescription(x *EmptyModelWithDescription, b []byte) (*EmptyModelWithDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeEmptyModelWithDescription(x, d) +} + +func _decodeEmptyModelWithDescription(x *EmptyModelWithDescription, d *polyglot.Decoder) (*EmptyModelWithDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewEmptyModelWithDescription() + } + + return x, nil +} + +type ModelWithSingleStringField struct { + StringField string +} + +func NewModelWithSingleStringField() *ModelWithSingleStringField { + return &ModelWithSingleStringField{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringField) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringField(x *ModelWithSingleStringField, b []byte) (*ModelWithSingleStringField, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringField(x, d) +} + +func _decodeModelWithSingleStringField(x *ModelWithSingleStringField, d *polyglot.Decoder) (*ModelWithSingleStringField, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringField() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleStringFieldAndDescription: Test Description +type ModelWithSingleStringFieldAndDescription struct { + StringField string +} + +func NewModelWithSingleStringFieldAndDescription() *ModelWithSingleStringFieldAndDescription { + return &ModelWithSingleStringFieldAndDescription{ + + StringField: "DefaultValue", + } +} + +func (x *ModelWithSingleStringFieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + } +} + +func DecodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, b []byte) (*ModelWithSingleStringFieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleStringFieldAndDescription(x, d) +} + +func _decodeModelWithSingleStringFieldAndDescription(x *ModelWithSingleStringFieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleStringFieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleStringFieldAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithSingleInt32Field struct { + Int32Field int32 +} + +func NewModelWithSingleInt32Field() *ModelWithSingleInt32Field { + return &ModelWithSingleInt32Field{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32Field) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, b []byte) (*ModelWithSingleInt32Field, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32Field(x, d) +} + +func _decodeModelWithSingleInt32Field(x *ModelWithSingleInt32Field, d *polyglot.Decoder) (*ModelWithSingleInt32Field, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32Field() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +type ModelWithSingleInt32FieldAndDescription struct { + Int32Field int32 +} + +func NewModelWithSingleInt32FieldAndDescription() *ModelWithSingleInt32FieldAndDescription { + return &ModelWithSingleInt32FieldAndDescription{ + + Int32Field: 32, + } +} + +func (x *ModelWithSingleInt32FieldAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, b []byte) (*ModelWithSingleInt32FieldAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithSingleInt32FieldAndDescription(x, d) +} + +func _decodeModelWithSingleInt32FieldAndDescription(x *ModelWithSingleInt32FieldAndDescription, d *polyglot.Decoder) (*ModelWithSingleInt32FieldAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithSingleInt32FieldAndDescription() + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithMultipleFields struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFields() *ModelWithMultipleFields { + return &ModelWithMultipleFields{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFields) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFields(x *ModelWithMultipleFields, b []byte) (*ModelWithMultipleFields, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFields(x, d) +} + +func _decodeModelWithMultipleFields(x *ModelWithMultipleFields, d *polyglot.Decoder) (*ModelWithMultipleFields, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFields() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +// ModelWithMultipleFieldsAndDescription: Test Description +type ModelWithMultipleFieldsAndDescription struct { + StringField string + + Int32Field int32 +} + +func NewModelWithMultipleFieldsAndDescription() *ModelWithMultipleFieldsAndDescription { + return &ModelWithMultipleFieldsAndDescription{ + + StringField: "DefaultValue", + + Int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.StringField) + + e.Int32(x.Int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, b []byte) (*ModelWithMultipleFieldsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAndDescription(x *ModelWithMultipleFieldsAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAndDescription() + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +type ModelWithEnum struct { + EnumField GenericEnum +} + +func NewModelWithEnum() *ModelWithEnum { + return &ModelWithEnum{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnum) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnum(x *ModelWithEnum, b []byte) (*ModelWithEnum, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnum(x, d) +} + +func _decodeModelWithEnum(x *ModelWithEnum, d *polyglot.Decoder) (*ModelWithEnum, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnum() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +// ModelWithEnumAndDescription: Test Description +type ModelWithEnumAndDescription struct { + EnumField GenericEnum +} + +func NewModelWithEnumAndDescription() *ModelWithEnumAndDescription { + return &ModelWithEnumAndDescription{ + + EnumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.EnumField)) + + } +} + +func DecodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, b []byte) (*ModelWithEnumAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAndDescription(x, d) +} + +func _decodeModelWithEnumAndDescription(x *ModelWithEnumAndDescription, d *polyglot.Decoder) (*ModelWithEnumAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + return x, nil +} + +type ModelWithEnumAccessor struct { + enumField GenericEnum +} + +func NewModelWithEnumAccessor() *ModelWithEnumAccessor { + return &ModelWithEnumAccessor{ + + enumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.enumField)) + + } +} + +func DecodeModelWithEnumAccessor(x *ModelWithEnumAccessor, b []byte) (*ModelWithEnumAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessor(x, d) +} + +func _decodeModelWithEnumAccessor(x *ModelWithEnumAccessor, d *polyglot.Decoder) (*ModelWithEnumAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessor() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.enumField = result + + return x, nil +} + +func (x *ModelWithEnumAccessor) GetEnumField() (GenericEnum, error) { + return x.enumField, nil +} + +func (x *ModelWithEnumAccessor) SetEnumField(v GenericEnum) error { + x.enumField = v + return nil +} + +// ModelWithEnumAccessorAndDescription: Test Description +type ModelWithEnumAccessorAndDescription struct { + enumField GenericEnum +} + +func NewModelWithEnumAccessorAndDescription() *ModelWithEnumAccessorAndDescription { + return &ModelWithEnumAccessorAndDescription{ + + enumField: GenericEnumDefaultValue, + } +} + +func (x *ModelWithEnumAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.Uint32(uint32(x.enumField)) + + } +} + +func DecodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, b []byte) (*ModelWithEnumAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEnumAccessorAndDescription(x, d) +} + +func _decodeModelWithEnumAccessorAndDescription(x *ModelWithEnumAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEnumAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEnumAccessorAndDescription() + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.enumField = result + + return x, nil +} + +func (x *ModelWithEnumAccessorAndDescription) GetEnumField() (GenericEnum, error) { + return x.enumField, nil +} + +func (x *ModelWithEnumAccessorAndDescription) SetEnumField(v GenericEnum) error { + x.enumField = v + return nil +} + +type ModelWithMultipleFieldsAccessor struct { + stringField string + + int32Field int32 +} + +func NewModelWithMultipleFieldsAccessor() *ModelWithMultipleFieldsAccessor { + return &ModelWithMultipleFieldsAccessor{ + + stringField: "DefaultValue", + + int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.stringField) + + e.Int32(x.int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, b []byte) (*ModelWithMultipleFieldsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessor(x, d) +} + +func _decodeModelWithMultipleFieldsAccessor(x *ModelWithMultipleFieldsAccessor, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessor() + } + + x.stringField, err = d.String() + if err != nil { + return nil, err + } + + x.int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +func (x *ModelWithMultipleFieldsAccessor) GetStringField() (string, error) { + return x.stringField, nil +} + +func (x *ModelWithMultipleFieldsAccessor) SetStringField(v string) error { + if matched, err := regexp.MatchString(`^[a-zA-Z0-9]*$`, v); err != nil || !matched { + return fmt.Errorf("value must match ^[a-zA-Z0-9]*$") + } + + if len(v) > 20 || len(v) < 1 { + return fmt.Errorf("length must be between 1 and 20") + } + + v = strings.ToUpper(v) + + x.stringField = v + return nil +} + +func (x *ModelWithMultipleFieldsAccessor) GetInt32Field() (int32, error) { + return x.int32Field, nil +} + +func (x *ModelWithMultipleFieldsAccessor) SetInt32Field(v int32) error { + if v > 100 || v < 0 { + return fmt.Errorf("value must be between 0 and 100") + } + + x.int32Field = v + return nil +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +type ModelWithMultipleFieldsAccessorAndDescription struct { + stringField string + + int32Field int32 +} + +func NewModelWithMultipleFieldsAccessorAndDescription() *ModelWithMultipleFieldsAccessorAndDescription { + return &ModelWithMultipleFieldsAccessorAndDescription{ + + stringField: "DefaultValue", + + int32Field: 32, + } +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.stringField) + + e.Int32(x.int32Field) + + } +} + +func DecodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, b []byte) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithMultipleFieldsAccessorAndDescription(x, d) +} + +func _decodeModelWithMultipleFieldsAccessorAndDescription(x *ModelWithMultipleFieldsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithMultipleFieldsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithMultipleFieldsAccessorAndDescription() + } + + x.stringField, err = d.String() + if err != nil { + return nil, err + } + + x.int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + return x, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) GetStringField() (string, error) { + return x.stringField, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) SetStringField(v string) error { + + x.stringField = v + return nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) GetInt32Field() (int32, error) { + return x.int32Field, nil +} + +func (x *ModelWithMultipleFieldsAccessorAndDescription) SetInt32Field(v int32) error { + + x.int32Field = v + return nil +} + +type ModelWithEmbeddedModels struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModels() *ModelWithEmbeddedModels { + return &ModelWithEmbeddedModels{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 64), + } +} + +func (x *ModelWithEmbeddedModels) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, b []byte) (*ModelWithEmbeddedModels, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModels(x, d) +} + +func _decodeModelWithEmbeddedModels(x *ModelWithEmbeddedModels, d *polyglot.Decoder) (*ModelWithEmbeddedModels, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModels() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +type ModelWithEmbeddedModelsAndDescription struct { + EmbeddedEmptyModel *EmptyModel + + EmbeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAndDescription() *ModelWithEmbeddedModelsAndDescription { + return &ModelWithEmbeddedModelsAndDescription{ + + EmbeddedEmptyModel: NewEmptyModel(), + + EmbeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0, 0), + } +} + +func (x *ModelWithEmbeddedModelsAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.EmbeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.EmbeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, b []byte) (*ModelWithEmbeddedModelsAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAndDescription(x *ModelWithEmbeddedModelsAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAndDescription() + } + + x.EmbeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.EmbeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor { + x.EmbeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeEmbeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.EmbeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +type ModelWithEmbeddedModelsAccessor struct { + embeddedEmptyModel *EmptyModel + + embeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessor() *ModelWithEmbeddedModelsAccessor { + return &ModelWithEmbeddedModelsAccessor{ + + embeddedEmptyModel: NewEmptyModel(), + + embeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessor) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.embeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.embeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, b []byte) (*ModelWithEmbeddedModelsAccessor, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessor(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessor(x *ModelWithEmbeddedModelsAccessor, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessor, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessor() + } + + x.embeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeembeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeembeddedModelArrayWithMultipleFieldsAccessor { + x.embeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeembeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeembeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.embeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) GetEmbeddedEmptyModel() (*EmptyModel, error) { + return x.embeddedEmptyModel, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) SetEmbeddedEmptyModel(v *EmptyModel) error { + x.embeddedEmptyModel = v + return nil +} + +func (x *ModelWithEmbeddedModelsAccessor) GetEmbeddedModelArrayWithMultipleFieldsAccessor() ([]ModelWithMultipleFieldsAccessor, error) { + return x.embeddedModelArrayWithMultipleFieldsAccessor, nil +} + +func (x *ModelWithEmbeddedModelsAccessor) SetEmbeddedModelArrayWithMultipleFieldsAccessor(v []ModelWithMultipleFieldsAccessor) error { + x.embeddedModelArrayWithMultipleFieldsAccessor = v + return nil +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +type ModelWithEmbeddedModelsAccessorAndDescription struct { + embeddedEmptyModel *EmptyModel + + embeddedModelArrayWithMultipleFieldsAccessor []ModelWithMultipleFieldsAccessor +} + +func NewModelWithEmbeddedModelsAccessorAndDescription() *ModelWithEmbeddedModelsAccessorAndDescription { + return &ModelWithEmbeddedModelsAccessorAndDescription{ + + embeddedEmptyModel: NewEmptyModel(), + + embeddedModelArrayWithMultipleFieldsAccessor: make([]ModelWithMultipleFieldsAccessor, 0), + } +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.embeddedEmptyModel.Encode(b) + + e.Slice(uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)), polyglot.AnyKind) + for _, a := range x.embeddedModelArrayWithMultipleFieldsAccessor { + a.Encode(b) + } + + } +} + +func DecodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, b []byte) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithEmbeddedModelsAccessorAndDescription(x, d) +} + +func _decodeModelWithEmbeddedModelsAccessorAndDescription(x *ModelWithEmbeddedModelsAccessorAndDescription, d *polyglot.Decoder) (*ModelWithEmbeddedModelsAccessorAndDescription, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithEmbeddedModelsAccessorAndDescription() + } + + x.embeddedEmptyModel, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeembeddedModelArrayWithMultipleFieldsAccessor, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.embeddedModelArrayWithMultipleFieldsAccessor)) != sliceSizeembeddedModelArrayWithMultipleFieldsAccessor { + x.embeddedModelArrayWithMultipleFieldsAccessor = make([]ModelWithMultipleFieldsAccessor, sliceSizeembeddedModelArrayWithMultipleFieldsAccessor) + } + for i := uint32(0); i < sliceSizeembeddedModelArrayWithMultipleFieldsAccessor; i++ { + v, err := _decodeModelWithMultipleFieldsAccessor(nil, d) + if err != nil { + return nil, err + } + x.embeddedModelArrayWithMultipleFieldsAccessor[i] = *v + } + + return x, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) GetEmbeddedEmptyModel() (*EmptyModel, error) { + return x.embeddedEmptyModel, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) SetEmbeddedEmptyModel(v *EmptyModel) error { + x.embeddedEmptyModel = v + return nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) GetEmbeddedModelArrayWithMultipleFieldsAccessor() ([]ModelWithMultipleFieldsAccessor, error) { + return x.embeddedModelArrayWithMultipleFieldsAccessor, nil +} + +func (x *ModelWithEmbeddedModelsAccessorAndDescription) SetEmbeddedModelArrayWithMultipleFieldsAccessor(v []ModelWithMultipleFieldsAccessor) error { + x.embeddedModelArrayWithMultipleFieldsAccessor = v + return nil +} + +type ModelWithAllFieldTypes struct { + ModelField *EmptyModel + + ModelArrayField []EmptyModel + + StringField string + + StringArrayField []string + + StringMapField map[string]string + + StringMapFieldEmbedded map[string]EmptyModel + + Int32Field int32 + + Int32ArrayField []int32 + + Int32MapField map[int32]int32 + + Int32MapFieldEmbedded map[int32]EmptyModel + + Int64Field int64 + + Int64ArrayField []int64 + + Int64MapField map[int64]int64 + + Int64MapFieldEmbedded map[int64]EmptyModel + + Uint32Field uint32 + + Uint32ArrayField []uint32 + + Uint32MapField map[uint32]uint32 + + Uint32MapFieldEmbedded map[uint32]EmptyModel + + Uint64Field uint64 + + Uint64ArrayField []uint64 + + Uint64MapField map[uint64]uint64 + + Uint64MapFieldEmbedded map[uint64]EmptyModel + + Float32Field float32 + + Float32ArrayField []float32 + + Float64Field float64 + + Float64ArrayField []float64 + + EnumField GenericEnum + + EnumArrayField []GenericEnum + + EnumMapField map[GenericEnum]string + + EnumMapFieldEmbedded map[GenericEnum]EmptyModel + + BytesField []byte + + BytesArrayField [][]byte + + BoolField bool + + BoolArrayField []bool +} + +func NewModelWithAllFieldTypes() *ModelWithAllFieldTypes { + return &ModelWithAllFieldTypes{ + + ModelField: NewEmptyModel(), + + ModelArrayField: make([]EmptyModel, 0, 0), + + StringField: "DefaultValue", + + StringArrayField: make([]string, 0, 0), + + StringMapField: make(map[string]string), + + StringMapFieldEmbedded: make(map[string]EmptyModel), + + Int32Field: 32, + + Int32ArrayField: make([]int32, 0, 0), + + Int32MapField: make(map[int32]int32), + + Int32MapFieldEmbedded: make(map[int32]EmptyModel), + + Int64Field: 64, + + Int64ArrayField: make([]int64, 0, 0), + + Int64MapField: make(map[int64]int64), + + Int64MapFieldEmbedded: make(map[int64]EmptyModel), + + Uint32Field: 32, + + Uint32ArrayField: make([]uint32, 0, 0), + + Uint32MapField: make(map[uint32]uint32), + + Uint32MapFieldEmbedded: make(map[uint32]EmptyModel), + + Uint64Field: 64, + + Uint64ArrayField: make([]uint64, 0, 0), + + Uint64MapField: make(map[uint64]uint64), + + Uint64MapFieldEmbedded: make(map[uint64]EmptyModel), + + Float32Field: 32.32, + + Float32ArrayField: make([]float32, 0, 0), + + Float64Field: 64.64, + + Float64ArrayField: make([]float64, 0, 0), + + EnumField: GenericEnumDefaultValue, + + EnumArrayField: make([]GenericEnum, 0, 0), + + EnumMapField: make(map[GenericEnum]string), + + EnumMapFieldEmbedded: make(map[GenericEnum]EmptyModel), + + BytesField: make([]byte, 0, 512), + + BytesArrayField: make([][]byte, 0, 0), + + BoolField: true, + + BoolArrayField: make([]bool, 0, 0), + } +} + +func (x *ModelWithAllFieldTypes) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + x.ModelField.Encode(b) + + e.Slice(uint32(len(x.ModelArrayField)), polyglot.AnyKind) + for _, a := range x.ModelArrayField { + a.Encode(b) + } + + e.String(x.StringField) + + e.Slice(uint32(len(x.StringArrayField)), polyglot.StringKind) + for _, a := range x.StringArrayField { + e.String(a) + } + + e.Map(uint32(len(x.StringMapField)), polyglot.StringKind, polyglot.StringKind) + for k, v := range x.StringMapField { + e.String(k) + e.String(v) + } + + e.Map(uint32(len(x.StringMapFieldEmbedded)), polyglot.StringKind, polyglot.AnyKind) + for k, v := range x.StringMapFieldEmbedded { + e.String(k) + v.Encode(b) + } + + e.Int32(x.Int32Field) + + e.Slice(uint32(len(x.Int32ArrayField)), polyglot.Int32Kind) + for _, a := range x.Int32ArrayField { + e.Int32(a) + } + + e.Map(uint32(len(x.Int32MapField)), polyglot.Int32Kind, polyglot.Int32Kind) + for k, v := range x.Int32MapField { + e.Int32(k) + e.Int32(v) + } + + e.Map(uint32(len(x.Int32MapFieldEmbedded)), polyglot.Int32Kind, polyglot.AnyKind) + for k, v := range x.Int32MapFieldEmbedded { + e.Int32(k) + v.Encode(b) + } + + e.Int64(x.Int64Field) + + e.Slice(uint32(len(x.Int64ArrayField)), polyglot.Int64Kind) + for _, a := range x.Int64ArrayField { + e.Int64(a) + } + + e.Map(uint32(len(x.Int64MapField)), polyglot.Int64Kind, polyglot.Int64Kind) + for k, v := range x.Int64MapField { + e.Int64(k) + e.Int64(v) + } + + e.Map(uint32(len(x.Int64MapFieldEmbedded)), polyglot.Int64Kind, polyglot.AnyKind) + for k, v := range x.Int64MapFieldEmbedded { + e.Int64(k) + v.Encode(b) + } + + e.Uint32(x.Uint32Field) + + e.Slice(uint32(len(x.Uint32ArrayField)), polyglot.Uint32Kind) + for _, a := range x.Uint32ArrayField { + e.Uint32(a) + } + + e.Map(uint32(len(x.Uint32MapField)), polyglot.Uint32Kind, polyglot.Uint32Kind) + for k, v := range x.Uint32MapField { + e.Uint32(k) + e.Uint32(v) + } + + e.Map(uint32(len(x.Uint32MapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.Uint32MapFieldEmbedded { + e.Uint32(k) + v.Encode(b) + } + + e.Uint64(x.Uint64Field) + + e.Slice(uint32(len(x.Uint64ArrayField)), polyglot.Uint64Kind) + for _, a := range x.Uint64ArrayField { + e.Uint64(a) + } + + e.Map(uint32(len(x.Uint64MapField)), polyglot.Uint64Kind, polyglot.Uint64Kind) + for k, v := range x.Uint64MapField { + e.Uint64(k) + e.Uint64(v) + } + + e.Map(uint32(len(x.Uint64MapFieldEmbedded)), polyglot.Uint64Kind, polyglot.AnyKind) + for k, v := range x.Uint64MapFieldEmbedded { + e.Uint64(k) + v.Encode(b) + } + + e.Float32(x.Float32Field) + + e.Slice(uint32(len(x.Float32ArrayField)), polyglot.Float32Kind) + for _, a := range x.Float32ArrayField { + e.Float32(a) + } + + e.Float64(x.Float64Field) + + e.Slice(uint32(len(x.Float64ArrayField)), polyglot.Float64Kind) + for _, a := range x.Float64ArrayField { + e.Float64(a) + } + + e.Uint32(uint32(x.EnumField)) + + e.Slice(uint32(len(x.EnumArrayField)), polyglot.Uint32Kind) + for _, a := range x.EnumArrayField { + e.Uint32(uint32(a)) + } + + e.Map(uint32(len(x.EnumMapField)), polyglot.Uint32Kind, polyglot.StringKind) + for k, v := range x.EnumMapField { + e.Uint32(uint32(k)) + e.String(v) + } + + e.Map(uint32(len(x.EnumMapFieldEmbedded)), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.EnumMapFieldEmbedded { + e.Uint32(uint32(k)) + v.Encode(b) + } + + e.Bytes(x.BytesField) + + e.Slice(uint32(len(x.BytesArrayField)), polyglot.BytesKind) + for _, a := range x.BytesArrayField { + e.Bytes(a) + } + + e.Bool(x.BoolField) + + e.Slice(uint32(len(x.BoolArrayField)), polyglot.BoolKind) + for _, a := range x.BoolArrayField { + e.Bool(a) + } + + } +} + +func DecodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, b []byte) (*ModelWithAllFieldTypes, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeModelWithAllFieldTypes(x, d) +} + +func _decodeModelWithAllFieldTypes(x *ModelWithAllFieldTypes, d *polyglot.Decoder) (*ModelWithAllFieldTypes, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewModelWithAllFieldTypes() + } + + x.ModelField, err = _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + + sliceSizeModelArrayField, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.ModelArrayField)) != sliceSizeModelArrayField { + x.ModelArrayField = make([]EmptyModel, sliceSizeModelArrayField) + } + for i := uint32(0); i < sliceSizeModelArrayField; i++ { + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.ModelArrayField[i] = *v + } + + x.StringField, err = d.String() + if err != nil { + return nil, err + } + + sliceSizeStringArrayField, err := d.Slice(polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringArrayField)) != sliceSizeStringArrayField { + x.StringArrayField = make([]string, sliceSizeStringArrayField) + } + + for i := uint32(0); i < sliceSizeStringArrayField; i++ { + x.StringArrayField[i], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapField, err := d.Map(polyglot.StringKind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapField)) != mapSizeStringMapField { + x.StringMapField = make(map[string]string, mapSizeStringMapField) + } + + for i := uint32(0); i < mapSizeStringMapField; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + x.StringMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeStringMapFieldEmbedded, err := d.Map(polyglot.StringKind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.StringMapFieldEmbedded)) != mapSizeStringMapFieldEmbedded { + x.StringMapFieldEmbedded = make(map[string]EmptyModel, mapSizeStringMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeStringMapFieldEmbedded; i++ { + k, err := d.String() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.StringMapFieldEmbedded[k] = *v + } + + x.Int32Field, err = d.Int32() + if err != nil { + return nil, err + } + + sliceSizeInt32ArrayField, err := d.Slice(polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32ArrayField)) != sliceSizeInt32ArrayField { + x.Int32ArrayField = make([]int32, sliceSizeInt32ArrayField) + } + + for i := uint32(0); i < sliceSizeInt32ArrayField; i++ { + x.Int32ArrayField[i], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapField, err := d.Map(polyglot.Int32Kind, polyglot.Int32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapField)) != mapSizeInt32MapField { + x.Int32MapField = make(map[int32]int32, mapSizeInt32MapField) + } + + for i := uint32(0); i < mapSizeInt32MapField; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + x.Int32MapField[k], err = d.Int32() + if err != nil { + return nil, err + } + } + + mapSizeInt32MapFieldEmbedded, err := d.Map(polyglot.Int32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int32MapFieldEmbedded)) != mapSizeInt32MapFieldEmbedded { + x.Int32MapFieldEmbedded = make(map[int32]EmptyModel, mapSizeInt32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt32MapFieldEmbedded; i++ { + k, err := d.Int32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int32MapFieldEmbedded[k] = *v + } + + x.Int64Field, err = d.Int64() + if err != nil { + return nil, err + } + + sliceSizeInt64ArrayField, err := d.Slice(polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64ArrayField)) != sliceSizeInt64ArrayField { + x.Int64ArrayField = make([]int64, sliceSizeInt64ArrayField) + } + + for i := uint32(0); i < sliceSizeInt64ArrayField; i++ { + x.Int64ArrayField[i], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapField, err := d.Map(polyglot.Int64Kind, polyglot.Int64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapField)) != mapSizeInt64MapField { + x.Int64MapField = make(map[int64]int64, mapSizeInt64MapField) + } + + for i := uint32(0); i < mapSizeInt64MapField; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + x.Int64MapField[k], err = d.Int64() + if err != nil { + return nil, err + } + } + + mapSizeInt64MapFieldEmbedded, err := d.Map(polyglot.Int64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Int64MapFieldEmbedded)) != mapSizeInt64MapFieldEmbedded { + x.Int64MapFieldEmbedded = make(map[int64]EmptyModel, mapSizeInt64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeInt64MapFieldEmbedded; i++ { + k, err := d.Int64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Int64MapFieldEmbedded[k] = *v + } + + x.Uint32Field, err = d.Uint32() + if err != nil { + return nil, err + } + + sliceSizeUint32ArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32ArrayField)) != sliceSizeUint32ArrayField { + x.Uint32ArrayField = make([]uint32, sliceSizeUint32ArrayField) + } + + for i := uint32(0); i < sliceSizeUint32ArrayField; i++ { + x.Uint32ArrayField[i], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapField, err := d.Map(polyglot.Uint32Kind, polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapField)) != mapSizeUint32MapField { + x.Uint32MapField = make(map[uint32]uint32, mapSizeUint32MapField) + } + + for i := uint32(0); i < mapSizeUint32MapField; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + x.Uint32MapField[k], err = d.Uint32() + if err != nil { + return nil, err + } + } + + mapSizeUint32MapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint32MapFieldEmbedded)) != mapSizeUint32MapFieldEmbedded { + x.Uint32MapFieldEmbedded = make(map[uint32]EmptyModel, mapSizeUint32MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint32MapFieldEmbedded; i++ { + k, err := d.Uint32() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint32MapFieldEmbedded[k] = *v + } + + x.Uint64Field, err = d.Uint64() + if err != nil { + return nil, err + } + + sliceSizeUint64ArrayField, err := d.Slice(polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64ArrayField)) != sliceSizeUint64ArrayField { + x.Uint64ArrayField = make([]uint64, sliceSizeUint64ArrayField) + } + + for i := uint32(0); i < sliceSizeUint64ArrayField; i++ { + x.Uint64ArrayField[i], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapField, err := d.Map(polyglot.Uint64Kind, polyglot.Uint64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapField)) != mapSizeUint64MapField { + x.Uint64MapField = make(map[uint64]uint64, mapSizeUint64MapField) + } + + for i := uint32(0); i < mapSizeUint64MapField; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + x.Uint64MapField[k], err = d.Uint64() + if err != nil { + return nil, err + } + } + + mapSizeUint64MapFieldEmbedded, err := d.Map(polyglot.Uint64Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.Uint64MapFieldEmbedded)) != mapSizeUint64MapFieldEmbedded { + x.Uint64MapFieldEmbedded = make(map[uint64]EmptyModel, mapSizeUint64MapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeUint64MapFieldEmbedded; i++ { + k, err := d.Uint64() + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.Uint64MapFieldEmbedded[k] = *v + } + + x.Float32Field, err = d.Float32() + if err != nil { + return nil, err + } + + sliceSizeFloat32ArrayField, err := d.Slice(polyglot.Float32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float32ArrayField)) != sliceSizeFloat32ArrayField { + x.Float32ArrayField = make([]float32, sliceSizeFloat32ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat32ArrayField; i++ { + x.Float32ArrayField[i], err = d.Float32() + if err != nil { + return nil, err + } + } + + x.Float64Field, err = d.Float64() + if err != nil { + return nil, err + } + + sliceSizeFloat64ArrayField, err := d.Slice(polyglot.Float64Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.Float64ArrayField)) != sliceSizeFloat64ArrayField { + x.Float64ArrayField = make([]float64, sliceSizeFloat64ArrayField) + } + + for i := uint32(0); i < sliceSizeFloat64ArrayField; i++ { + x.Float64ArrayField[i], err = d.Float64() + if err != nil { + return nil, err + } + } + + result, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumField = result + + sliceSizeEnumArrayField, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumArrayField)) != sliceSizeEnumArrayField { + x.EnumArrayField = make([]GenericEnum, sliceSizeEnumArrayField) + } + + for i := uint32(0); i < sliceSizeEnumArrayField; i++ { + val, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumArrayField[i] = val + } + + mapSizeEnumMapField, err := d.Map(polyglot.Uint32Kind, polyglot.StringKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapField)) != mapSizeEnumMapField { + x.EnumMapField = make(map[GenericEnum]string, mapSizeEnumMapField) + } + + for i := uint32(0); i < mapSizeEnumMapField; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + x.EnumMapField[k], err = d.String() + if err != nil { + return nil, err + } + } + + mapSizeEnumMapFieldEmbedded, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.EnumMapFieldEmbedded)) != mapSizeEnumMapFieldEmbedded { + x.EnumMapFieldEmbedded = make(map[GenericEnum]EmptyModel, mapSizeEnumMapFieldEmbedded) + } + + for i := uint32(0); i < mapSizeEnumMapFieldEmbedded; i++ { + k, err := decodeGenericEnum(d) + if err != nil { + return nil, err + } + v, err := _decodeEmptyModel(nil, d) + if err != nil { + return nil, err + } + x.EnumMapFieldEmbedded[k] = *v + } + + x.BytesField, err = d.Bytes(nil) + if err != nil { + return nil, err + } + + sliceSizeBytesArrayField, err := d.Slice(polyglot.BytesKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BytesArrayField)) != sliceSizeBytesArrayField { + x.BytesArrayField = make([][]byte, sliceSizeBytesArrayField) + } + + for i := uint32(0); i < sliceSizeBytesArrayField; i++ { + x.BytesArrayField[i], err = d.Bytes(nil) + if err != nil { + return nil, err + } + } + + x.BoolField, err = d.Bool() + if err != nil { + return nil, err + } + + sliceSizeBoolArrayField, err := d.Slice(polyglot.BoolKind) + if err != nil { + return nil, err + } + + if uint32(len(x.BoolArrayField)) != sliceSizeBoolArrayField { + x.BoolArrayField = make([]bool, sliceSizeBoolArrayField) + } + + for i := uint32(0); i < sliceSizeBoolArrayField; i++ { + x.BoolArrayField[i], err = d.Bool() + if err != nil { + return nil, err + } + } + + return x, nil +} diff --git a/signature/generator/golang/generator.go b/signature/generator/golang/generator.go new file mode 100644 index 00000000..a20b2799 --- /dev/null +++ b/signature/generator/golang/generator.go @@ -0,0 +1,256 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package golang + +import ( + "bytes" + "go/format" + "text/template" + + polyglotVersion "github.com/loopholelabs/polyglot/version" + + scaleVersion "github.com/loopholelabs/scale/version" + + interfacesVersion "github.com/loopholelabs/scale-signature-interfaces/version" + + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator/golang/templates" + "github.com/loopholelabs/scale/signature/generator/utils" +) + +const ( + defaultPackageName = "types" +) + +var generator *Generator + +// GenerateTypes generates the types for the signature +func GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + return generator.GenerateTypes(signatureSchema, packageName) +} + +// GenerateModfile generates the go.mod file for the signature +func GenerateModfile(packageImportPath string) ([]byte, error) { + return generator.GenerateModfile(packageImportPath) +} + +// GenerateGuest generates the guest bindings for the signature +func GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + return generator.GenerateGuest(signatureSchema, signatureHash, packageName) +} + +// GenerateHost generates the host bindings for the signature +func GenerateHost(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + return generator.GenerateHost(signatureSchema, signatureHash, packageName) +} + +func init() { + var err error + generator, err = New() + if err != nil { + panic(err) + } +} + +// Generator is the go generator +type Generator struct { + templ *template.Template +} + +// New creates a new go generator +func New() (*Generator, error) { + templ, err := template.New("").Funcs(templateFunctions()).ParseFS(templates.FS, "*.go.templ") + if err != nil { + return nil, err + } + + return &Generator{ + templ: templ, + }, nil +} + +// GenerateTypes generates the types for the signature +func (g *Generator) GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "types.go.templ", map[string]any{ + "signature_schema": signatureSchema, + "generator_version": scaleVersion.Version(), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return format.Source(buf.Bytes()) +} + +// GenerateModfile generates the modfile for the signature +func (g *Generator) GenerateModfile(packageImportPath string) ([]byte, error) { + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "mod.go.templ", map[string]any{ + "polyglot_version": polyglotVersion.Version(), + "scale_signature_interfaces_version": interfacesVersion.Version(), + "package_import_path": packageImportPath, + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +// GenerateGuest generates the guest bindings for the signature +func (g *Generator) GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "guest.go.templ", map[string]any{ + "signature_schema": signatureSchema, + "signature_hash": signatureHash, + "generator_version": scaleVersion.Version(), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return format.Source(buf.Bytes()) +} + +// GenerateHost generates the host bindings for the signature +// +// Note: the given schema should already be normalized, validated, and modified to have its accessors and validators disabled +func (g *Generator) GenerateHost(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "host.go.templ", map[string]any{ + "signature_schema": signatureSchema, + "signature_hash": signatureHash, + "generator_version": scaleVersion.Version(), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return format.Source(buf.Bytes()) +} + +func templateFunctions() template.FuncMap { + return template.FuncMap{ + "Primitive": primitive, + "IsPrimitive": signature.ValidPrimitiveType, + "PolyglotPrimitive": polyglotPrimitive, + "PolyglotPrimitiveEncode": polyglotPrimitiveEncode, + "PolyglotPrimitiveDecode": polyglotPrimitiveDecode, + "Deref": func(i *bool) bool { return *i }, + "LowerFirst": func(s string) string { return string(s[0]+32) + s[1:] }, + "Params": utils.Params, + } +} + +func primitive(t string) string { + switch t { + case "string", "int32", "int64", "uint32", "uint64", "float32", "float64", "bool": + return t + case "bytes": + return "[]byte" + default: + return "" + } +} + +func polyglotPrimitive(t string) string { + switch t { + case "string": + return "polyglot.StringKind" + case "int32": + return "polyglot.Int32Kind" + case "int64": + return "polyglot.Int64Kind" + case "uint32": + return "polyglot.Uint32Kind" + case "uint64": + return "polyglot.Uint64Kind" + case "float32": + return "polyglot.Float32Kind" + case "float64": + return "polyglot.Float64Kind" + case "bool": + return "polyglot.BoolKind" + case "bytes": + return "polyglot.BytesKind" + default: + return "polyglot.AnyKind" + } +} + +func polyglotPrimitiveEncode(t string) string { + switch t { + case "string": + return "String" + case "int32": + return "Int32" + case "int64": + return "Int64" + case "uint32": + return "Uint32" + case "uint64": + return "Uint64" + case "float32": + return "Float32" + case "float64": + return "Float64" + case "bool": + return "Bool" + case "bytes": + return "Bytes" + default: + return "" + } +} + +func polyglotPrimitiveDecode(t string) string { + switch t { + case "string": + return "String" + case "int32": + return "Int32" + case "int64": + return "Int64" + case "uint32": + return "Uint32" + case "uint64": + return "Uint64" + case "float32": + return "Float32" + case "float64": + return "Float64" + case "bool": + return "Bool" + case "bytes": + return "Bytes" + default: + return "" + } +} diff --git a/signature/generator/golang/generator_test.go b/signature/generator/golang/generator_test.go new file mode 100644 index 00000000..fc9409ea --- /dev/null +++ b/signature/generator/golang/generator_test.go @@ -0,0 +1,42 @@ +//go:build !integration && !generate + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package golang + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/loopholelabs/scale/signature" +) + +func TestGenerator(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + formatted, err := GenerateTypes(s, "types") + require.NoError(t, err) + + // os.WriteFile("./generated.txt", formatted, 0644) + + master, err := os.ReadFile("./generated.txt") + require.NoError(t, err) + require.Equal(t, string(master), string(formatted)) + + t.Log(string(formatted)) +} diff --git a/signature/generator/golang/templates/arrays.go.templ b/signature/generator/golang/templates/arrays.go.templ new file mode 100644 index 00000000..0d256b1d --- /dev/null +++ b/signature/generator/golang/templates/arrays.go.templ @@ -0,0 +1,116 @@ +{{ define "go_arrays_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }} []{{ Primitive $type }} + {{- else }} + {{ .Name }} []{{ Primitive $type }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_arrays_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }}: make([]{{ Primitive $type }}, 0, {{ .InitialSize }}), + {{- else }} + {{ .Name }}: make([]{{ Primitive $type }}, 0, {{ .InitialSize }}), + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_arrays_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + e.Slice(uint32(len(x.{{ LowerFirst .Name }})), {{ PolyglotPrimitive $type }}) + for _, a := range x.{{ LowerFirst .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(a) + } + {{- else }} + e.Slice(uint32(len(x.{{ .Name }})), {{ PolyglotPrimitive $type }}) + for _, a := range x.{{ .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(a) + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_arrays_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + sliceSize{{ LowerFirst .Name }}, err := d.Slice({{ PolyglotPrimitive .Type }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != sliceSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make([]{{ Primitive $type }}, sliceSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < sliceSize{{ LowerFirst .Name }}; i++ { + x.{{ LowerFirst .Name }}[i], err = d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + } + {{- else }} + sliceSize{{ .Name }}, err := d.Slice({{ PolyglotPrimitive $type }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != sliceSize{{ .Name }} { + x.{{ .Name }} = make([]{{ Primitive $type }}, sliceSize{{ .Name }}) + } + + for i := uint32(0); i < sliceSize{{ .Name }}; i++ { + x.{{ .Name }}[i], err = d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_bytesarrays_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + sliceSize{{ LowerFirst .Name }}, err := d.Slice({{ PolyglotPrimitive .Type }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != sliceSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make([]{{ Primitive $type }}, sliceSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < sliceSize{{ LowerFirst .Name }}; i++ { + x.{{ LowerFirst .Name }}[i], err = d.{{ PolyglotPrimitiveDecode $type }}(nil) + if err != nil { + return nil, err + } + } + {{- else }} + sliceSize{{ .Name }}, err := d.Slice({{ PolyglotPrimitive $type }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != sliceSize{{ .Name }} { + x.{{ .Name }} = make([]{{ Primitive $type }}, sliceSize{{ .Name }}) + } + + for i := uint32(0); i < sliceSize{{ .Name }}; i++ { + x.{{ .Name }}[i], err = d.{{ PolyglotPrimitiveDecode $type }}(nil) + if err != nil { + return nil, err + } + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/enumarrays.go.templ b/signature/generator/golang/templates/enumarrays.go.templ new file mode 100644 index 00000000..a9e984b9 --- /dev/null +++ b/signature/generator/golang/templates/enumarrays.go.templ @@ -0,0 +1,89 @@ +{{ define "go_enumarrays_definition" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + type {{ .Name }} uint32 + {{ $current_enum := . }} + const ( + {{- range $index, $value := .Values }} + {{ $current_enum.Name }}{{ $value }} {{ .Reference }} = {{ $index }} + {{ end }} + ) + {{ end }} +{{ end }} + +{{ define "go_enumarrays_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }} []{{ .Reference }} + {{- else }} + {{ .Name }} []{{ .Reference }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enumarrays_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if .Accessor }} + {{ LowerFirst .Name }}: make([]{{ .Reference }}, 0, {{ .InitialSize }}), + {{- else }} + {{ .Name }}: make([]{{ .Reference }}, 0, {{ .InitialSize }}), + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enumarrays_encode" }} + {{- range .EnumArrays }} + {{- if (Deref .Accessor) }} + e.Slice(uint32(len(x.{{ LowerFirst .Name }})), polyglot.Uint32Kind) + for _, a := range x.{{ LowerFirst .Name }} { + e.Uint32(uint32(a)) + } + {{- else }} + e.Slice(uint32(len(x.{{ .Name }})), polyglot.Uint32Kind) + for _, a := range x.{{ .Name }} { + e.Uint32(uint32(a)) + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enumarrays_decode" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if (Deref .Accessor) }} + sliceSize{{ LowerFirst .Name }}, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != sliceSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make([]{{ .Reference }}, sliceSize{{ LowerFirst .Name }}) + } + + val, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }}[i] = val + {{- else }} + sliceSize{{ .Name }}, err := d.Slice(polyglot.Uint32Kind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != sliceSize{{ .Name }} { + x.{{ .Name }} = make([]{{ .Reference }}, sliceSize{{ .Name }}) + } + + for i := uint32(0); i < sliceSize{{ .Name }}; i++ { + val, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + x.{{ .Name }}[i] = val + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/enummaps.go.templ b/signature/generator/golang/templates/enummaps.go.templ new file mode 100644 index 00000000..d6a0ba9c --- /dev/null +++ b/signature/generator/golang/templates/enummaps.go.templ @@ -0,0 +1,205 @@ +{{ define "go_enummaps_definition" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + type {{ .Name }} uint32 + {{ $current_enum := . }} + const ( + {{- range $index, $value := .Values }} + {{ $current_enum.Name }}{{ $value }} {{ $current_enum.Name }} = {{ $index }} + {{ end }} + ) + {{ end }} +{{ end }} + +{{ define "go_enummaps_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + {{ LowerFirst .Name }} map[{{ .Reference }}]{{ Primitive .Value }} + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + {{ LowerFirst .Name }} map[{{ .Reference }}]{{ .Value }} + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ .Name }} map[{{ .Reference }}]{{ Primitive .Value }} + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ .Name }} map[{{ .Reference }}]{{ .Value }} + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_enummaps_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + {{ LowerFirst .Name }}: make(map[{{ .Reference }}]{{ Primitive .Value }}), + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + {{ LowerFirst .Name }}: make(map[{{ .Reference }}]{{ .Value }}), + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ .Name }}: make(map[{{ .Reference }}]{{ Primitive .Value }}), + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ .Name }}: make(map[{{ .Reference }}]{{ .Value }}), + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_enummaps_encode" }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + e.Map(uint32(len(x.{{ LowerFirst .Name }})), polyglot.Uint32Kind, {{ PolyglotPrimitive .Value }}) + for k, v := range x.{{ LowerFirst .Name }} { + e.Uint32(uint32(k)) + e.{{ PolyglotPrimitiveEncode .Value }}(v) + } + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + e.Map(uint32(len(x.{{ LowerFirst .Name }})), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.{{ LowerFirst .Name }} { + e.Uint32(uint32(k)) + v.Encode(e) + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + e.Map(uint32(len(x.{{ .Name }})), polyglot.Uint32Kind, {{ PolyglotPrimitive .Value }}) + for k, v := range x.{{ .Name }} { + e.Uint32(uint32(k)) + e.{{ PolyglotPrimitiveEncode .Value }}(v) + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + e.Map(uint32(len(x.{{ .Name }})), polyglot.Uint32Kind, polyglot.AnyKind) + for k, v := range x.{{ .Name }} { + e.Uint32(uint32(k)) + v.Encode(b) + } + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_enummaps_decode" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + mapSize{{ LowerFirst .Name }}, err := d.Map(polyglot.Uint32Kind, {{ PolyglotPrimitive .Value }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != mapSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make(map[{{ .Reference }}]{{ Primitive .Value }}, mapSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < mapSize{{ LowerFirst .Name }}; i++ { + var k {{ .Reference }} + enumValue{{ LowerFirst .Name }}, err := d.Uint32() + if err != nil { + return nil, err + } + {{ $current_enum := . }} + switch {{ .Reference }}(enumValue{{ LowerFirst .Name }}) { + {{- range $index, $value := .Values }} + case {{ .Reference }}{{ $value }}: + k = {{ .Reference }}{{ $value }} + {{- end }} + default: + return nil, InvalidEnum + } + x.{{ LowerFirst .Name }}[k], err = d.{{ PolyglotPrimitiveDecode .Value }}() + if err != nil { + return nil, err + } + } + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + mapSize{{ LowerFirst .Name }}, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != mapSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make(map[{{ .Reference }}]{{ .Value }}, mapSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < mapSize{{ LowerFirst .Name }}; i++ { + var k {{ .Reference }} + enumValue{{ LowerFirst .Name }}, err := d.Uint32() + if err != nil { + return nil, err + } + {{ $current_enum := . }} + switch {{ .Reference }}(enumValue{{ LowerFirst .Name }}) { + {{- range $index, $value := .Values }} + case {{ .Reference }}{{ $value }}: + k = {{ .Reference }}{{ $value }} + {{- end }} + default: + return nil, InvalidEnum + } + v, err := _decode{{ .Value }}(nil, d) + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }}[k] = *v + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + mapSize{{ .Name }}, err := d.Map(polyglot.Uint32Kind, {{ PolyglotPrimitive .Value }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != mapSize{{ .Name }} { + x.{{ .Name }} = make(map[{{ .Reference }}]{{ Primitive .Value }}, mapSize{{ .Name }}) + } + + for i := uint32(0); i < mapSize{{ .Name }}; i++ { + k, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + x.{{ .Name }}[k], err = d.{{ PolyglotPrimitiveDecode .Value }}() + if err != nil { + return nil, err + } + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + mapSize{{ .Name }}, err := d.Map(polyglot.Uint32Kind, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != mapSize{{ .Name }} { + x.{{ .Name }} = make(map[{{ .Reference }}]{{ .Value }}, mapSize{{ .Name }}) + } + + for i := uint32(0); i < mapSize{{ .Name }}; i++ { + k, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + v, err := _decode{{ .Value }}(nil, d) + if err != nil { + return nil, err + } + x.{{ .Name }}[k] = *v + } + {{- end }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/enums.go.templ b/signature/generator/golang/templates/enums.go.templ new file mode 100644 index 00000000..eb96205b --- /dev/null +++ b/signature/generator/golang/templates/enums.go.templ @@ -0,0 +1,90 @@ +{{ define "go_enums_definition" }} + type {{ .Name }} uint32 + {{ $current_enum := . }} + const ( + {{- range $index, $value := .Values }} + {{ $current_enum.Name }}{{ $value }} {{ $current_enum.Name }} = {{ $index }} + {{ end }} + ) + + func decode{{ .Name }}(d *polyglot.Decoder) ({{ .Name }}, error) { + enumValue, err := d.Uint32() + if err != nil { + return 0, err + } + switch {{ .Name }}(enumValue) { + {{- range $index, $value := .Values }} + case {{ $current_enum.Name }}{{ $value }}: + return {{ $current_enum.Name }}{{ $value }}, nil + {{- end }} + default: + return 0, InvalidEnum + } + } +{{ end }} + +{{ define "go_enums_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }} {{ .Reference }} + {{- else }} + {{ .Name }} {{ .Reference }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enums_new_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + {{ LowerFirst .Name }}: {{ .Reference }}{{ .Default }}, + {{- else }} + {{ .Name }}: {{ .Reference }}{{ .Default }}, + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enums_encode" }} + {{- range .Enums }} + {{- if (Deref .Accessor) }} + e.Uint32(uint32(x.{{ LowerFirst .Name }})) + {{- else }} + e.Uint32(uint32(x.{{ .Name }})) + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enums_decode" }} + {{- range .Model.Enums }} + {{- if (Deref .Accessor) }} + result, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }} = result + {{- else }} + result, err := decode{{ .Reference }}(d) + if err != nil { + return nil, err + } + x.{{ .Name }} = result + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_enums_accessor" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + func (x *{{ $current_model.Name }}) Get{{ .Name }}() ({{ .Reference }}, error) { + return x.{{ LowerFirst .Name }}, nil + } + + func (x *{{ $current_model.Name }}) Set{{ .Name }}(v {{ .Reference }}) error { + x.{{ LowerFirst .Name }} = v + return nil + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/guest.go.templ b/signature/generator/golang/templates/guest.go.templ new file mode 100644 index 00000000..76c3dbbd --- /dev/null +++ b/signature/generator/golang/templates/guest.go.templ @@ -0,0 +1,80 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +package {{ .package_name }} + +import ( + "github.com/loopholelabs/polyglot" + "unsafe" +) + +const hash = "{{ .signature_hash }}" + +var ( + writeBuffer = polyglot.NewBuffer() + readBuffer []byte +) + +// Write serializes the signature into the global writeBuffer and returns the pointer to the buffer and its size +// +// Users should not use this method. +func Write(ctx *{{ .signature_schema.Context }}) (uint32, uint32) { + writeBuffer.Reset() + ctx.Encode(writeBuffer) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Read deserializes signature from the global readBuffer +// +// Users should not use this method. +func Read(ctx *{{ .signature_schema.Context }}) (*{{ .signature_schema.Context }}, error) { + return Decode{{ .signature_schema.Context }}(ctx, readBuffer) +} + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +func Error(err error) (uint32, uint32) { + writeBuffer.Reset() + polyglot.Encoder(writeBuffer).Error(err) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Resize resizes the global readBuffer to the given size and returns the pointer to the buffer +// +// Users should not use this method. +func Resize(size uint32) uint32 { + if uint32(cap(readBuffer)) < size { + readBuffer = append(make([]byte, 0, uint32(len(readBuffer))+size), readBuffer...) + } + readBuffer = readBuffer[:size] + return uint32(uintptr(unsafe.Pointer(&readBuffer[0]))) +} + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +func Hash() (uint32, uint32) { + writeBuffer.Reset() + polyglot.Encoder(writeBuffer).String(hash) + underlying := writeBuffer.Bytes() + ptr := &underlying[0] + unsafePtr := uintptr(unsafe.Pointer(ptr)) + return uint32(unsafePtr), uint32(writeBuffer.Len()) +} + +// Next calls the next function in the Scale Function Chain +func Next(ctx *{{ .signature_schema.Context }}) (*{{ .signature_schema.Context }}, error) { + next(Write(ctx)) + return Read(ctx) +} + +//go:export next +//go:linkname next +func next(offset uint32, length uint32) \ No newline at end of file diff --git a/signature/generator/golang/templates/host.go.templ b/signature/generator/golang/templates/host.go.templ new file mode 100644 index 00000000..474edb51 --- /dev/null +++ b/signature/generator/golang/templates/host.go.templ @@ -0,0 +1,66 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +package {{ .package_name }} + +import ( + interfaces "github.com/loopholelabs/scale-signature-interfaces" + "github.com/loopholelabs/polyglot" +) + +const hash = "{{ .signature_hash }}" + +var _ interfaces.Signature = (*Signature)(nil) + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +type Signature struct { + Context *{{ .signature_schema.Context }} + buf *polyglot.Buffer +} + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +func New() *Signature { + return &Signature { + Context: New{{ .signature_schema.Context }}(), + buf: polyglot.NewBuffer(), + } +} + +// Read reads the context from the given byte slice and returns an error if one occurred +// +// This method is meant to be used by the Scale Runtime to deserialize the Signature +func (x *Signature) Read(b []byte) error { + var err error + x.Context, err = Decode{{ .signature_schema.Context }}(x.Context, b) + return err +} + +// Write writes the signature into a byte slice and returns it +// +// This method is meant to be used by the Scale Runtime to serialize the Signature +func (x *Signature) Write() []byte { + x.buf.Reset() + x.Context.Encode(x.buf) + return x.buf.Bytes() +} + +// Error writes the signature into a byte slice and returns it +// +// This method is meant to be used by the Scale Runtime to return an error +func (x *Signature) Error(err error) []byte { + x.buf.Reset() + polyglot.Encoder(x.buf).Error(err) + return x.buf.Bytes() +} + +// Hash returns the hash of the signature +// +// This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility +func (x *Signature) Hash() string { + return hash +} \ No newline at end of file diff --git a/signature/generator/golang/templates/maps.go.templ b/signature/generator/golang/templates/maps.go.templ new file mode 100644 index 00000000..bbfe4639 --- /dev/null +++ b/signature/generator/golang/templates/maps.go.templ @@ -0,0 +1,173 @@ +{{ define "go_maps_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + {{ LowerFirst .Name }} map[{{ Primitive $type }}]{{ Primitive .Value }} + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + {{ LowerFirst .Name }} map[{{ Primitive $type }}]{{ .Value }} + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ .Name }} map[{{ Primitive $type }}]{{ Primitive .Value }} + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ .Name }} map[{{ Primitive $type }}]{{ .Value }} + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_maps_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + {{ LowerFirst .Name }}: make(map[{{ Primitive $type }}]{{ Primitive .Value }}), + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + {{ LowerFirst .Name }}: make(map[{{ Primitive $type }}]{{ .Value }}), + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ .Name }}: make(map[{{ Primitive $type }}]{{ Primitive .Value }}), + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ .Name }}: make(map[{{ Primitive $type }}]{{ .Value }}), + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_maps_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + e.Map(uint32(len(x.{{ LowerFirst .Name }})), {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}) + for k, v := range x.{{ LowerFirst .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(k) + e.{{ PolyglotPrimitiveEncode .Value }}(v) + } + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + e.Map(uint32(len(x.{{ LowerFirst .Name }})), {{ PolyglotPrimitive $type }}, polyglot.AnyKind) + for k, v := range x.{{ LowerFirst .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(k) + v.Encode(b) + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + e.Map(uint32(len(x.{{ .Name }})), {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}) + for k, v := range x.{{ .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(k) + e.{{ PolyglotPrimitiveEncode .Value }}(v) + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + e.Map(uint32(len(x.{{ .Name }})), {{ PolyglotPrimitive $type }}, polyglot.AnyKind) + for k, v := range x.{{ .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(k) + v.Encode(b) + } + {{- end }} + {{ end }} +{{ end }} + +{{ define "go_maps_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + mapSize{{ LowerFirst .Name }}, err := d.Map({{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != mapSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make(map[{{ Primitive $type }}]{{ Primitive .Value }}, mapSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < mapSize{{ LowerFirst .Name }}; i++ { + k, err := d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }}[k], err = d.{{ PolyglotPrimitiveDecode .Value }}() + if err != nil { + return nil, err + } + } + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + mapSize{{ LowerFirst .Name }}, err := d.Map({{ PolyglotPrimitive $type }}, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ LowerFirst .Name }})) != mapSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make(map[{{ Primitive $type }}]{{ .Value }}, mapSize{{ LowerFirst .Name }}) + } + + for i := uint32(0); i < mapSize{{ LowerFirst .Name }}; i++ { + k, err := d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + v, err := _decode{{ .Value }}(nil, d) + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }}[k] = *v + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + mapSize{{ .Name }}, err := d.Map({{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != mapSize{{ .Name }} { + x.{{ .Name }} = make(map[{{ Primitive $type }}]{{ Primitive .Value }}, mapSize{{ .Name }}) + } + + for i := uint32(0); i < mapSize{{ .Name }}; i++ { + k, err := d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + x.{{ .Name }}[k], err = d.{{ PolyglotPrimitiveDecode .Value }}() + if err != nil { + return nil, err + } + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + mapSize{{ .Name }}, err := d.Map({{ PolyglotPrimitive $type }}, polyglot.AnyKind) + if err != nil { + return nil, err + } + + if uint32(len(x.{{ .Name }})) != mapSize{{ .Name }} { + x.{{ .Name }} = make(map[{{ Primitive $type }}]{{ .Value }}, mapSize{{ .Name }}) + } + + for i := uint32(0); i < mapSize{{ .Name }}; i++ { + k, err := d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + v, err := _decode{{ .Value }}(nil, d) + if err != nil { + return nil, err + } + x.{{ .Name }}[k] = *v + } + {{- end }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/mod.go.templ b/signature/generator/golang/templates/mod.go.templ new file mode 100644 index 00000000..7c330a0c --- /dev/null +++ b/signature/generator/golang/templates/mod.go.templ @@ -0,0 +1,8 @@ +module {{ .package_import_path }} + +go 1.20 + +require ( + github.com/loopholelabs/polyglot {{ .polyglot_version }} + github.com/loopholelabs/scale-signature-interfaces {{ .scale_signature_interfaces_version }} +) \ No newline at end of file diff --git a/signature/generator/golang/templates/modelarrays.go.templ b/signature/generator/golang/templates/modelarrays.go.templ new file mode 100644 index 00000000..71b8e7a8 --- /dev/null +++ b/signature/generator/golang/templates/modelarrays.go.templ @@ -0,0 +1,87 @@ +{{ define "go_modelarrays_struct_reference" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + {{ LowerFirst .Name }} []{{ .Reference }} + {{- else }} + {{ .Name }} []{{ .Reference }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_modelarrays_new_struct_reference" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + {{ LowerFirst .Name }}: make([]{{ .Reference }}, {{ .InitialSize }}), + {{- else }} + {{ .Name }}: make([]{{ .Reference }}, 0, {{ .InitialSize }}), + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_modelarrays_encode" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + e.Slice(uint32(len(x.{{ LowerFirst .Name }})), polyglot.AnyKind) + for _, a := range x.{{ LowerFirst .Name }} { + a.Encode(b) + } + {{- else }} + e.Slice(uint32(len(x.{{ .Name }})), polyglot.AnyKind) + for _, a := range x.{{ .Name }} { + a.Encode(b) + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_modelarrays_decode" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + sliceSize{{ LowerFirst .Name }}, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.{{ LowerFirst .Name }})) != sliceSize{{ LowerFirst .Name }} { + x.{{ LowerFirst .Name }} = make([]{{ .Reference }}, sliceSize{{ LowerFirst .Name }}) + } + for i := uint32(0); i < sliceSize{{ LowerFirst .Name }}; i++ { + v, err := _decode{{ .Reference }}(nil, d) + if err != nil { + return nil, err + } + x.{{ LowerFirst .Name }}[i] = *v + } + {{- else }} + sliceSize{{ .Name }}, err := d.Slice(polyglot.AnyKind) + if err != nil { + return nil, err + } + if uint32(len(x.{{ .Name }})) != sliceSize{{ .Name }} { + x.{{ .Name }} = make([]{{ .Reference }}, sliceSize{{ .Name }}) + } + for i := uint32(0); i < sliceSize{{ .Name }}; i++ { + v, err := _decode{{ .Reference }}(nil, d) + if err != nil { + return nil, err + } + x.{{ .Name }}[i] = *v + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_modelarrays_accessor" }} + {{ $current_model := . }} + {{- range .ModelArrays }} + {{- if .Accessor }} + func (x *{{ $current_model.Name }}) Get{{ .Name }}() ([]{{ .Reference }}, error) { + return x.{{ LowerFirst .Name }}, nil + } + + func (x *{{ $current_model.Name }}) Set{{ .Name }}(v []{{ .Reference }}) error { + x.{{ LowerFirst .Name }} = v + return nil + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/models.go.templ b/signature/generator/golang/templates/models.go.templ new file mode 100644 index 00000000..e35e81a0 --- /dev/null +++ b/signature/generator/golang/templates/models.go.templ @@ -0,0 +1,61 @@ +{{ define "go_models_struct_reference" }} + {{- range .Models }} + {{- if .Accessor }} + {{ LowerFirst .Name }} *{{ .Reference }} + {{- else }} + {{ .Name }} *{{ .Reference }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_models_new_struct_reference" }} + {{- range .Models }} + {{- if .Accessor }} + {{ LowerFirst .Name }}: New{{ .Reference }}(), + {{- else }} + {{ .Name }}: New{{ .Reference }}(), + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_models_encode" }} + {{- range .Models }} + {{- if .Accessor }} + x.{{ LowerFirst .Name }}.Encode(b) + {{- else }} + x.{{ .Name }}.Encode(b) + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_models_decode" }} + {{- range .Models }} + {{- if .Accessor }} + x.{{ LowerFirst .Name }}, err = _decode{{ .Reference }}(nil, d) + if err != nil { + return nil, err + } + {{- else }} + x.{{ .Name }}, err = _decode{{ .Reference }}(nil, d) + if err != nil { + return nil, err + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_models_accessor" }} + {{ $current_model := . }} + {{- range .Models }} + {{- if .Accessor }} + func (x *{{ $current_model.Name }}) Get{{ .Name }}() (*{{ .Reference }}, error) { + return x.{{ LowerFirst .Name }}, nil + } + + func (x *{{ $current_model.Name }}) Set{{ .Name }}(v *{{ .Reference }}) error { + x.{{ LowerFirst .Name }} = v + return nil + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/golang/templates/primitives.go.templ b/signature/generator/golang/templates/primitives.go.templ new file mode 100644 index 00000000..ba8205a2 --- /dev/null +++ b/signature/generator/golang/templates/primitives.go.templ @@ -0,0 +1,126 @@ +{{ define "go_primitives_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }} {{ Primitive $type }} + {{- else }} + {{ .Name }} {{ Primitive $type }} + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_primitives_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }}: {{ .Default }}, + {{- else }} + {{ .Name }}: {{ .Default }}, + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_strings_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }}: "{{ .Default }}", + {{- else }} + {{ .Name }}: "{{ .Default }}", + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_bytes_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ LowerFirst .Name }}: make([]byte, 0, {{ .InitialSize }}), + {{- else }} + {{ .Name }}: make([]byte, 0, {{ .InitialSize }}), + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_primitives_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + e.{{ PolyglotPrimitiveEncode $type }}(x.{{ LowerFirst .Name }}) + {{- else }} + e.{{ PolyglotPrimitiveEncode $type }}(x.{{ .Name }}) + {{- end -}} + {{ end }} +{{ end}} + +{{ define "go_primitives_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + x.{{ LowerFirst .Name }}, err = d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + {{- else }} + x.{{ .Name }}, err = d.{{ PolyglotPrimitiveDecode $type }}() + if err != nil { + return nil, err + } + {{- end -}} + {{ end }} +{{ end}} + +{{ define "go_bytes_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + x.{{ LowerFirst .Name }}, err = d.{{ PolyglotPrimitiveDecode $type }}(nil) + if err != nil { + return nil, err + } + {{- else }} + x.{{ .Name }}, err = d.{{ PolyglotPrimitiveDecode $type }}(nil) + if err != nil { + return nil, err + } + {{- end -}} + {{ end }} +{{ end}} + +{{ define "go_numbers_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + func (x *{{ $model.Name }}) Get{{ .Name }}() ({{ $type }}, error) { + return x.{{ LowerFirst .Name }}, nil + } + + func (x *{{ $model.Name }}) Set{{ .Name }}(v {{ $type }}) error { + {{- template "go_numbers_limit_validator" .LimitValidator }} + x.{{ LowerFirst .Name }} = v + return nil + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "go_strings_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + func (x *{{ $model.Name }}) Get{{ .Name }}() ({{ $type }}, error) { + return x.{{ LowerFirst .Name }}, nil + } + + func (x *{{ $model.Name }}) Set{{ .Name }}(v {{ $type }}) error { + {{- template "go_regex_validator" .RegexValidator }} + {{- template "go_length_validator" .LengthValidator }} + {{- template "go_case_modifier" .CaseModifier }} + x.{{ LowerFirst .Name }} = v + return nil + } + {{- end -}} + {{ end }} +{{ end }} diff --git a/signature/generator/golang/templates/templates.go b/signature/generator/golang/templates/templates.go new file mode 100644 index 00000000..fdfb581a --- /dev/null +++ b/signature/generator/golang/templates/templates.go @@ -0,0 +1,19 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package templates + +import "embed" + +//go:embed * +var FS embed.FS diff --git a/signature/generator/golang/templates/types.go.templ b/signature/generator/golang/templates/types.go.templ new file mode 100644 index 00000000..27be5545 --- /dev/null +++ b/signature/generator/golang/templates/types.go.templ @@ -0,0 +1,235 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +package {{ .package_name }} + +import ( + "github.com/loopholelabs/polyglot" + "errors" + {{ if or (.signature_schema.HasLengthValidator) (.signature_schema.HasRegexValidator) (.signature_schema.HasLimitValidator) }}"fmt"{{ end }} + {{ if .signature_schema.HasRegexValidator }}"regexp"{{ end }} + {{ if .signature_schema.HasCaseModifier }}"strings"{{ end }} +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +{{ range .signature_schema.Enums }} + {{ template "go_enums_definition" . }} +{{- end }} +{{- $allEnums := .signature_schema.Enums }} + +{{- range .signature_schema.Models -}} + {{- if .Description }} + // {{ .Name }}: {{ .Description }} + {{ end -}} + + type {{ .Name }} struct { + {{ template "go_models_struct_reference" . }} + {{ template "go_modelarrays_struct_reference" . }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Strings "Type" "string" }} + {{ template "go_arrays_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "go_maps_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Int32s "Type" "int32" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "go_maps_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + + {{ template "go_primitives_struct_reference" Params "Entries" .Int64s "Type" "int64" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "go_maps_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "go_maps_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "go_maps_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Float32s "Type" "float32" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Float64s "Type" "float64" }} + {{ template "go_arrays_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "go_enums_struct_reference" . }} + {{ template "go_enumarrays_struct_reference" . }} + {{ template "go_enummaps_struct_reference" . }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "go_arrays_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "go_primitives_struct_reference" Params "Entries" .Bools "Type" "bool" }} + {{ template "go_arrays_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + } + + func New{{ .Name }}() *{{ .Name }} { + return &{{ .Name }}{ + {{ template "go_models_new_struct_reference" . }} + {{ template "go_modelarrays_new_struct_reference" . }} + + {{ template "go_strings_new_struct_reference" Params "Entries" .Strings }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "go_maps_new_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Int32s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "go_maps_new_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Int64s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "go_maps_new_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Uint32s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "go_maps_new_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Uint64s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "go_maps_new_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Float32s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Float64s }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "go_enums_new_struct_reference" . }} + {{ template "go_enumarrays_new_struct_reference" . }} + {{ template "go_enummaps_new_struct_reference" . }} + + {{ template "go_bytes_new_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "go_primitives_new_struct_reference" Params "Entries" .Bools }} + {{ template "go_arrays_new_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + } + } + + func (x *{{ .Name }}) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + {{ template "go_models_encode" . }} + {{ template "go_modelarrays_encode" . }} + + {{ template "go_primitives_encode" Params "Entries" .Strings "Type" "string" }} + {{ template "go_arrays_encode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "go_maps_encode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "go_primitives_encode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "go_arrays_encode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "go_maps_encode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "go_primitives_encode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "go_arrays_encode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "go_maps_encode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "go_primitives_encode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "go_arrays_encode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "go_maps_encode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "go_primitives_encode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "go_arrays_encode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "go_maps_encode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "go_primitives_encode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "go_arrays_encode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "go_primitives_encode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "go_arrays_encode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "go_enums_encode" . }} + {{ template "go_enumarrays_encode" . }} + {{ template "go_enummaps_encode" . }} + + {{ template "go_primitives_encode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "go_arrays_encode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "go_primitives_encode" Params "Entries" .Bools "Type" "bool" }} + {{ template "go_arrays_encode" Params "Entries" .BoolArrays "Type" "bool" }} + } + } + + func Decode{{ .Name }}(x *{{ .Name }}, b []byte) (*{{ .Name }}, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decode{{ .Name }}(x, d) + } + + func _decode{{ .Name }}(x *{{ .Name }}, d *polyglot.Decoder) (*{{ .Name }}, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = New{{ .Name }}() + } + + {{ template "go_models_decode" . }} + {{ template "go_modelarrays_decode" . }} + + {{ template "go_primitives_decode" Params "Entries" .Strings "Type" "string" }} + {{ template "go_arrays_decode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "go_maps_decode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "go_primitives_decode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "go_arrays_decode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "go_maps_decode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "go_primitives_decode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "go_arrays_decode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "go_maps_decode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "go_primitives_decode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "go_arrays_decode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "go_maps_decode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "go_primitives_decode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "go_arrays_decode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "go_maps_decode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "go_primitives_decode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "go_arrays_decode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "go_primitives_decode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "go_arrays_decode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "go_enums_decode" Params "Model" . "Enums" $allEnums }} + {{ template "go_enumarrays_decode" . }} + {{ template "go_enummaps_decode" . }} + + {{ template "go_bytes_decode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "go_bytesarrays_decode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "go_primitives_decode" Params "Entries" .Bools "Type" "bool" }} + {{ template "go_arrays_decode" Params "Entries" .BoolArrays "Type" "bool" }} + + return x, nil + } + + {{ template "go_models_accessor" . }} + {{ template "go_modelarrays_accessor" . }} + + {{ template "go_enums_accessor" . }} + + {{ template "go_strings_accessor" Params "Model" . "Entries" .Strings "Type" "string" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Int32s "Type" "int32" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Int64s "Type" "int64" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Uint32s "Type" "uint32" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Uint64s "Type" "uint64" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Float32s "Type" "float32" }} + {{ template "go_numbers_accessor" Params "Model" . "Entries" .Float64s "Type" "float32" }} + +{{ end -}} \ No newline at end of file diff --git a/signature/generator/golang/templates/validators.go.templ b/signature/generator/golang/templates/validators.go.templ new file mode 100644 index 00000000..0b17f187 --- /dev/null +++ b/signature/generator/golang/templates/validators.go.templ @@ -0,0 +1,53 @@ +{{ define "go_numbers_limit_validator" }} +{{- if . }} + {{- if and .Maximum .Minimum }} + if v > {{ .Maximum }} || v < {{ .Minimum }} { + return fmt.Errorf("value must be between {{ .Minimum }} and {{ .Maximum }}") + } + {{- else if .Minimum }} + if v < {{ .Minimum }} { + return fmt.Errorf("value must be greater than or equal to {{ .Minimum }}") + } + {{- else if .Maximum }} + if v > {{ .Maximum }} { + return fmt.Errorf("value must be less than or equal to {{ .Maximum }}") + } + {{- end }} +{{- end }} +{{ end }} + +{{ define "go_regex_validator" }} + {{- if . }} + if matched, err := regexp.MatchString(`{{ .Expression }}`, v); err != nil || !matched { + return fmt.Errorf("value must match {{ .Expression }}") + } + {{- end }} +{{ end }} + +{{ define "go_length_validator" }} + {{- if . }} + {{- if and .Maximum .Minimum }} + if len(v) > {{ .Maximum }} || len(v) < {{ .Minimum }} { + return fmt.Errorf("length must be between {{ .Minimum }} and {{ .Maximum }}") + } + {{- else if .Minimum }} + if len(v) < {{ .Minimum }} { + return fmt.Errorf("length must be greater than or equal to {{ .Minimum }}") + } + {{- else if .Maximum }} + if len(v) > {{ .Maximum }} { + return fmt.Errorf("length must be less than or equal to {{ .Maximum }}") + } + {{- end }} + {{- end }} +{{ end }} + +{{ define "go_case_modifier" }} + {{- if . }} + {{- if eq .Kind "upper" }} + v = strings.ToUpper(v) + {{- else if eq .Kind "lower" }} + v = strings.ToLower(v) + {{- end }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/format/format.go b/signature/generator/rust/format/format.go new file mode 100644 index 00000000..15d28c4f --- /dev/null +++ b/signature/generator/rust/format/format.go @@ -0,0 +1,64 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package format + +import ( + "context" + _ "embed" + + "github.com/loopholelabs/scale" + "github.com/loopholelabs/scale/scalefunc" + signature "github.com/loopholelabs/scale/signature/generator/rust/format/signature/host" +) + +//go:embed rustfmt/local-rustfmt-latest.scale +var localRustfmtLatest []byte + +type Formatter struct { + runtime *scale.Scale[*signature.Signature] +} + +func New() (*Formatter, error) { + s := new(scalefunc.Schema) + err := s.Decode(localRustfmtLatest) + if err != nil { + return nil, err + } + + cfg := scale.NewConfig(signature.New).WithFunction(s) + runtime, err := scale.New(cfg) + if err != nil { + return nil, err + } + + return &Formatter{ + runtime: runtime, + }, nil +} + +func (f *Formatter) Format(ctx context.Context, code string) (string, error) { + instance, err := f.runtime.Instance() + if err != nil { + return "", err + } + + sig := signature.New() + sig.Context.Data = code + + err = instance.Run(ctx, sig) + if err != nil { + return "", err + } + return sig.Context.Data, nil +} diff --git a/signature/generator/rust/format/format_test.go b/signature/generator/rust/format/format_test.go new file mode 100644 index 00000000..ea2f0f5a --- /dev/null +++ b/signature/generator/rust/format/format_test.go @@ -0,0 +1,58 @@ +//go:build !integration + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package format + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +const data1 = ` +use crate::{ lazy::{Lazy, SyncLazy, SyncOnceCell}, panic, + sync::{ atomic::{AtomicUsize, Ordering::SeqCst}, + mpsc::channel, Mutex, }, + thread, + }; + impl Into for T where U: From { + fn into(self) -> U { U::from(self) } + } +` + +const data2 = ` +use crate::{ lazy::{Lazy, SyncLazy, SyncOnceCell}, panic,sync::{ atomic::{AtomicUsize, Ordering},mpsc::channel, Mutex, }, + thread, + }; + impl Into for T where U: From { + fn into(self) -> U { U::from(self) } + } +` + +func TestFormatter(t *testing.T) { + f, err := New() + require.NoError(t, err) + + formatted, err := f.Format(context.Background(), data1) + require.NoError(t, err) + + t.Logf("Formatted:\n\n%s\n", formatted) + + formatted, err = f.Format(context.Background(), data2) + require.NoError(t, err) + + t.Logf("Formatted:\n\n%s\n", formatted) +} diff --git a/signature/generator/rust/format/rustfmt/Cargo.toml b/signature/generator/rust/format/rustfmt/Cargo.toml new file mode 100644 index 00000000..17313efe --- /dev/null +++ b/signature/generator/rust/format/rustfmt/Cargo.toml @@ -0,0 +1,19 @@ + +[package] +name = "rustfmt" +version = "0.1.0" +edition = "2021" + +[lib] +path = "lib.rs" + +[dependencies] +prettyplease = "0.2.14" + +signature = { package = "local_rustfmt_latest_guest", path = "../signature/guest" } +syn = "2.0.31" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 diff --git a/signature/generator/rust/format/rustfmt/lib.rs b/signature/generator/rust/format/rustfmt/lib.rs new file mode 100644 index 00000000..38d5ba38 --- /dev/null +++ b/signature/generator/rust/format/rustfmt/lib.rs @@ -0,0 +1,9 @@ +use signature::types; + +pub fn scale( + ctx: Option<&mut types::Context>, +) -> Result, Box> { + let unwrapped = ctx.unwrap(); + unwrapped.data = prettyplease::unparse(&syn::parse_str(unwrapped.data.as_str()).unwrap()); + signature::next(Some(unwrapped)) +} diff --git a/signature/generator/rust/format/rustfmt/local-rustfmt-latest.scale b/signature/generator/rust/format/rustfmt/local-rustfmt-latest.scale new file mode 100644 index 00000000..2c99f990 Binary files /dev/null and b/signature/generator/rust/format/rustfmt/local-rustfmt-latest.scale differ diff --git a/signature/generator/rust/format/rustfmt/scalefile b/signature/generator/rust/format/rustfmt/scalefile new file mode 100644 index 00000000..e7834a2e --- /dev/null +++ b/signature/generator/rust/format/rustfmt/scalefile @@ -0,0 +1,16 @@ +version = "v1alpha" +name = "rustfmt" +tag = "latest" +language = "rust" + +signature { + organization = "local" + name = "rustfmt" + tag = "latest" +} + +stateless = true + +function = "scale" +initialize = "" +description = "" diff --git a/signature/generator/rust/format/signature/guest/Cargo.toml b/signature/generator/rust/format/signature/guest/Cargo.toml new file mode 100644 index 00000000..a462f1c9 --- /dev/null +++ b/signature/generator/rust/format/signature/guest/Cargo.toml @@ -0,0 +1,21 @@ +[package] +edition = "2021" +name = "local_rustfmt_latest_guest" +version = "0.1.0" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 + +[lib] +path = "guest.rs" + +[dependencies.num_enum] +version = "0.7.0" + +[dependencies.regex] +version = "1.9.4" + +[dependencies.polyglot_rs] +version = "1.1.2" \ No newline at end of file diff --git a/signature/generator/rust/format/signature/guest/guest.rs b/signature/generator/rust/format/signature/guest/guest.rs new file mode 100644 index 00000000..0fb5e5df --- /dev/null +++ b/signature/generator/rust/format/signature/guest/guest.rs @@ -0,0 +1,109 @@ +// Code generated by scale-signature , DO NOT EDIT. +// output: local_rustfmt_latest_guest + +pub mod types; +use crate::types::{Decode, Encode}; + +use polyglot_rs::Encoder; +use std::io::Cursor; + +static HASH: &'static str = "8b14119da31d0ea3a5fc4013005cafa4212efb9791389c9789fd47fbd5a805b2"; + +static mut READ_BUFFER: Vec = Vec::new(); +static mut WRITE_BUFFER: Vec = Vec::new(); + +// write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +pub unsafe fn write(ctx: Option<&mut types::Context>) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + match ctx { + Some(ctx) => { + cursor = match types::Context::encode(Some(ctx), &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + None => { + cursor = match types::Context::encode(None, &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + } + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); +} + +// read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +pub unsafe fn read() -> Result, Box> { + let mut cursor = Cursor::new(&mut READ_BUFFER); + types::Context::decode(&mut cursor) +} + +// error serializes an error into the global WRITE_BUFFER and returns a pointer to the buffer and its size +// +// Users should not use this method. +pub unsafe fn error(error: Box) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_error(error) { + Ok(_) => { + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => (0, 0), + }; +} + +// resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +pub unsafe fn resize(size: u32) -> *const u8 { + READ_BUFFER.resize(size as usize, 0); + return READ_BUFFER.as_ptr(); +} + +// hash returns the hash of the Scale Signature +// +// Users should not use this method. +pub unsafe fn hash() -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_string(&String::from(HASH)) { + Ok(_) => { + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => (0, 0), + }; +} + +// next calls the next function in the Scale Function Chain +pub fn next( + ctx: Option<&mut types::Context>, +) -> Result, Box> { + unsafe { + let (ptr, len) = write(ctx); + _next(ptr, len); + read() + } +} + +#[link(wasm_import_module = "env")] +extern "C" { + #[link_name = "next"] + fn _next(ptr: u32, size: u32); +} diff --git a/signature/generator/rust/format/signature/guest/types.rs b/signature/generator/rust/format/signature/guest/types.rs new file mode 100644 index 00000000..2a751b88 --- /dev/null +++ b/signature/generator/rust/format/signature/guest/types.rs @@ -0,0 +1,114 @@ +// Code generated by scale-signature , DO NOT EDIT. +// output: local_rustfmt_latest_guest + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_mut)] + +use num_enum::TryFromPrimitive; +use polyglot_rs::{Decoder, DecodingError, Encoder, Kind}; +use regex::Regex; +use std::collections::HashMap; +use std::convert::TryFrom; +use std::io::Cursor; + +pub trait Encode { + fn encode<'a>( + a: Option<&Self>, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> + where + Self: Sized; +} + +trait EncodeSelf { + fn encode_self<'a, 'b>( + &'b self, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box>; +} + +pub trait Decode { + fn decode(b: &mut Cursor<&mut Vec>) -> Result, Box> + where + Self: Sized; +} +#[derive(Clone, Debug, PartialEq)] +pub struct Context { + pub data: String, +} + +impl Context { + pub fn new() -> Self { + Self { + data: "".to_string(), + } + } +} + +impl Encode for Context { + fn encode<'a>( + a: Option<&Context>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} + +impl EncodeSelf for Context { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.data)?; + + Ok(e) + } +} + +impl EncodeSelf for Option<&Context> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} + +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} + +impl Decode for Context { + fn decode(d: &mut Cursor<&mut Vec>) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + + if let Ok(error) = d.decode_error() { + return Err(error); + } + + let mut x = Context::new(); + + x.data = d.decode_string()?; + + Ok(Some(x)) + } +} diff --git a/signature/generator/rust/format/signature/host/host.go b/signature/generator/rust/format/signature/host/host.go new file mode 100644 index 00000000..0e8aab97 --- /dev/null +++ b/signature/generator/rust/format/signature/host/host.go @@ -0,0 +1,60 @@ +// Code generated by scale-signature , DO NOT EDIT. +// output: signature + +package host + +import ( + "github.com/loopholelabs/polyglot" + interfaces "github.com/loopholelabs/scale-signature-interfaces" +) + +const hash = "8b14119da31d0ea3a5fc4013005cafa4212efb9791389c9789fd47fbd5a805b2" + +var _ interfaces.Signature = (*Signature)(nil) + +// sig is the host representation of the signature +// +// Users should not use this type directly, but instead pass the Signature() function +// to the Scale Runtime +type Signature struct { + Context *Context + buf *polyglot.Buffer +} + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime as an argument +func New() *Signature { + return &Signature{ + Context: NewContext(), + buf: polyglot.NewBuffer(), + } +} + +// Read reads the context from the given byte slice and returns an error if one occurred +// +// This method is meant to be used by the Scale Runtime to deserialize the Signature +func (x *Signature) Read(b []byte) error { + var err error + x.Context, err = DecodeContext(x.Context, b) + return err +} + +// Write writes the signature into a byte slice and returns it +func (x *Signature) Write() []byte { + x.buf.Reset() + x.Context.Encode(x.buf) + return x.buf.Bytes() +} + +// Error writes the signature into a byte slice and returns it +func (x *Signature) Error(err error) []byte { + x.buf.Reset() + polyglot.Encoder(x.buf).Error(err) + return x.buf.Bytes() +} + +// Hash returns the hash of the signature +func (x *Signature) Hash() string { + return hash +} diff --git a/signature/generator/rust/format/signature/host/types.go b/signature/generator/rust/format/signature/host/types.go new file mode 100644 index 00000000..b52984ad --- /dev/null +++ b/signature/generator/rust/format/signature/host/types.go @@ -0,0 +1,64 @@ +// Code generated by scale-signature , DO NOT EDIT. +// output: signature + +package host + +import ( + "errors" + "github.com/loopholelabs/polyglot" +) + +var ( + NilDecode = errors.New("cannot decode into a nil root struct") + InvalidEnum = errors.New("invalid enum value") +) + +type Context struct { + Data string +} + +func NewContext() *Context { + return &Context{ + + Data: "", + } +} + +func (x *Context) Encode(b *polyglot.Buffer) { + e := polyglot.Encoder(b) + if x == nil { + e.Nil() + } else { + + e.String(x.Data) + + } +} + +func DecodeContext(x *Context, b []byte) (*Context, error) { + d := polyglot.GetDecoder(b) + defer d.Return() + return _decodeContext(x, d) +} + +func _decodeContext(x *Context, d *polyglot.Decoder) (*Context, error) { + if d.Nil() { + return nil, nil + } + + err, _ := d.Error() + if err != nil { + return nil, err + } + + if x == nil { + x = NewContext() + } + + x.Data, err = d.String() + if err != nil { + return nil, err + } + + return x, nil +} diff --git a/signature/generator/rust/generated.txt b/signature/generator/rust/generated.txt new file mode 100755 index 00000000..8afa59ae --- /dev/null +++ b/signature/generator/rust/generated.txt @@ -0,0 +1,1887 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: types + +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_mut)] +use std::io::Cursor; +use polyglot_rs::{DecodingError, Encoder, Decoder, Kind}; +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; +use std::collections::HashMap; +use regex::Regex; +pub trait Encode { + fn encode<'a>( + a: Option<&Self>, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> + where + Self: Sized; +} +trait EncodeSelf { + fn encode_self<'a, 'b>( + &'b self, + b: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box>; +} +pub trait Decode { + fn decode( + b: &mut Cursor<&mut Vec>, + ) -> Result, Box> + where + Self: Sized; +} +#[derive(Debug, Eq, PartialEq, TryFromPrimitive, Copy, Clone, Hash)] +#[repr(u32)] +pub enum GenericEnum { + FirstValue = 0, + SecondValue = 1, + DefaultValue = 2, +} +#[derive(Clone, Debug, PartialEq)] +pub struct EmptyModel {} +impl EmptyModel { + pub fn new() -> Self { + Self {} + } +} +impl Encode for EmptyModel { + fn encode<'a>( + a: Option<&EmptyModel>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for EmptyModel { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + Ok(e) + } +} +impl EncodeSelf for Option<&EmptyModel> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for EmptyModel { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = EmptyModel::new(); + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct EmptyModelWithDescription {} +impl EmptyModelWithDescription { + pub fn new() -> Self { + Self {} + } +} +impl Encode for EmptyModelWithDescription { + fn encode<'a>( + a: Option<&EmptyModelWithDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for EmptyModelWithDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + Ok(e) + } +} +impl EncodeSelf for Option<&EmptyModelWithDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for EmptyModelWithDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = EmptyModelWithDescription::new(); + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleStringField { + pub string_field: String, +} +impl ModelWithSingleStringField { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + } + } +} +impl Encode for ModelWithSingleStringField { + fn encode<'a>( + a: Option<&ModelWithSingleStringField>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleStringField { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleStringField> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleStringField { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleStringField::new(); + x.string_field = d.decode_string()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleStringFieldAndDescription { + pub string_field: String, +} +impl ModelWithSingleStringFieldAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + } + } +} +impl Encode for ModelWithSingleStringFieldAndDescription { + fn encode<'a>( + a: Option<&ModelWithSingleStringFieldAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleStringFieldAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleStringFieldAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleStringFieldAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleStringFieldAndDescription::new(); + x.string_field = d.decode_string()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleInt32Field { + pub int32_field: i32, +} +impl ModelWithSingleInt32Field { + pub fn new() -> Self { + Self { int32_field: 32 } + } +} +impl Encode for ModelWithSingleInt32Field { + fn encode<'a>( + a: Option<&ModelWithSingleInt32Field>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleInt32Field { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleInt32Field> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleInt32Field { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleInt32Field::new(); + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithSingleInt32FieldAndDescription { + pub int32_field: i32, +} +impl ModelWithSingleInt32FieldAndDescription { + pub fn new() -> Self { + Self { int32_field: 32 } + } +} +impl Encode for ModelWithSingleInt32FieldAndDescription { + fn encode<'a>( + a: Option<&ModelWithSingleInt32FieldAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithSingleInt32FieldAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithSingleInt32FieldAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithSingleInt32FieldAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithSingleInt32FieldAndDescription::new(); + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFields { + pub string_field: String, + pub int32_field: i32, +} +impl ModelWithMultipleFields { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } +} +impl Encode for ModelWithMultipleFields { + fn encode<'a>( + a: Option<&ModelWithMultipleFields>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFields { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFields> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFields { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFields::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAndDescription { + pub string_field: String, + pub int32_field: i32, +} +impl ModelWithMultipleFieldsAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } +} +impl Encode for ModelWithMultipleFieldsAndDescription { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAndDescription::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnum { + pub enum_field: GenericEnum, +} +impl ModelWithEnum { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnum { + fn encode<'a>( + a: Option<&ModelWithEnum>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnum { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnum> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnum { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnum::new(); + x + .enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAndDescription { + pub enum_field: GenericEnum, +} +impl ModelWithEnumAndDescription { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAndDescription { + fn encode<'a>( + a: Option<&ModelWithEnumAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAndDescription::new(); + x + .enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAccessor { + enum_field: GenericEnum, +} +impl ModelWithEnumAccessor { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAccessor { + fn encode<'a>( + a: Option<&ModelWithEnumAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAccessor::new(); + x + .enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +impl ModelWithEnumAccessor { + pub fn get_enum_field(&self) -> &GenericEnum { + &self.enum_field + } + pub fn set_enum_field(&mut self, v: GenericEnum) { + self.enum_field = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEnumAccessorAndDescription { + enum_field: GenericEnum, +} +impl ModelWithEnumAccessorAndDescription { + pub fn new() -> Self { + Self { + enum_field: GenericEnum::DefaultValue, + } + } +} +impl Encode for ModelWithEnumAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithEnumAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEnumAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_u32(self.enum_field as u32)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEnumAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEnumAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEnumAccessorAndDescription::new(); + x + .enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + Ok(Some(x)) + } +} +impl ModelWithEnumAccessorAndDescription { + pub fn get_enum_field(&self) -> &GenericEnum { + &self.enum_field + } + pub fn set_enum_field(&mut self, v: GenericEnum) { + self.enum_field = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAccessor { + string_field: String, + int32_field: i32, +} +impl ModelWithMultipleFieldsAccessor { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } + pub fn get_string_field(&self) -> String { + self.string_field.clone() + } + pub fn set_string_field( + &mut self, + mut v: String, + ) -> Result<(), Box> { + if !Regex::new("^[a-zA-Z0-9]*$")?.is_match(v.as_str()) { + return Err( + Box::::from("value must match ^[a-zA-Z0-9]*$"), + ); + } + if v.len() > 20 || v.len() < 1 { + return Err( + Box::< + dyn std::error::Error, + >::from("value must be between { .Minimum }} and 20"), + ); + } + v = v.to_uppercase(); + self.string_field = v; + Ok(()) + } + pub fn get_int32_field(&self) -> i32 { + self.int32_field + } + pub fn set_int32_field(&mut self, v: i32) -> Result<(), Box> { + if v > 100 || v < 0 { + return Err( + Box::< + dyn std::error::Error, + >::from("value must be between { .Minimum }} and 100"), + ); + } + self.int32_field = v; + Ok(()) + } +} +impl Encode for ModelWithMultipleFieldsAccessor { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAccessor::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithMultipleFieldsAccessorAndDescription { + string_field: String, + int32_field: i32, +} +impl ModelWithMultipleFieldsAccessorAndDescription { + pub fn new() -> Self { + Self { + string_field: "DefaultValue".to_string(), + int32_field: 32, + } + } + pub fn get_string_field(&self) -> String { + self.string_field.clone() + } + pub fn set_string_field( + &mut self, + mut v: String, + ) -> Result<(), Box> { + self.string_field = v; + Ok(()) + } + pub fn get_int32_field(&self) -> i32 { + self.int32_field + } + pub fn set_int32_field(&mut self, v: i32) -> Result<(), Box> { + self.int32_field = v; + Ok(()) + } +} +impl Encode for ModelWithMultipleFieldsAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithMultipleFieldsAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithMultipleFieldsAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + e.encode_string(&self.string_field)?; + e.encode_i32(self.int32_field)?; + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithMultipleFieldsAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithMultipleFieldsAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithMultipleFieldsAccessorAndDescription::new(); + x.string_field = d.decode_string()?; + x.int32_field = d.decode_i32()?; + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModels { + pub embedded_empty_model: Option, + pub embedded_model_array_with_multiple_fields_accessor: Vec< + ModelWithMultipleFieldsAccessor, + >, +} +impl ModelWithEmbeddedModels { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(64), + } + } +} +impl Encode for ModelWithEmbeddedModels { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModels>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModels { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor.len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModels> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModels { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModels::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d + .decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor + .push( + ModelWithMultipleFieldsAccessor::decode(d)? + .ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAndDescription { + pub embedded_empty_model: Option, + pub embedded_model_array_with_multiple_fields_accessor: Vec< + ModelWithMultipleFieldsAccessor, + >, +} +impl ModelWithEmbeddedModelsAndDescription { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAndDescription { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor.len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAndDescription::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d + .decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor + .push( + ModelWithMultipleFieldsAccessor::decode(d)? + .ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAccessor { + embedded_empty_model: Option, + embedded_model_array_with_multiple_fields_accessor: Vec< + ModelWithMultipleFieldsAccessor, + >, +} +impl ModelWithEmbeddedModelsAccessor { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAccessor { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAccessor>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAccessor { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor.len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAccessor> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAccessor { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAccessor::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d + .decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor + .push( + ModelWithMultipleFieldsAccessor::decode(d)? + .ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +impl ModelWithEmbeddedModelsAccessor { + pub fn get_embedded_empty_model(&self) -> &Option { + &self.embedded_empty_model + } + pub fn set_embedded_empty_model(&mut self, v: Option) { + self.embedded_empty_model = v; + } +} +impl ModelWithEmbeddedModelsAccessor { + pub fn get_embedded_model_array_with_multiple_fields_accessor( + &self, + ) -> Option<&Vec> { + Some(&self.embedded_model_array_with_multiple_fields_accessor) + } + pub fn set_embedded_model_array_with_multiple_fields_accessor( + &mut self, + v: Vec, + ) { + self.embedded_model_array_with_multiple_fields_accessor = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithEmbeddedModelsAccessorAndDescription { + embedded_empty_model: Option, + embedded_model_array_with_multiple_fields_accessor: Vec< + ModelWithMultipleFieldsAccessor, + >, +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn new() -> Self { + Self { + embedded_empty_model: Some(EmptyModel::new()), + embedded_model_array_with_multiple_fields_accessor: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithEmbeddedModelsAccessorAndDescription { + fn encode<'a>( + a: Option<&ModelWithEmbeddedModelsAccessorAndDescription>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithEmbeddedModelsAccessorAndDescription { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.embedded_empty_model.encode_self(e)?; + e.encode_array( + self.embedded_model_array_with_multiple_fields_accessor.len(), + Kind::Any, + )?; + for a in &self.embedded_model_array_with_multiple_fields_accessor { + a.encode_self(e)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithEmbeddedModelsAccessorAndDescription> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithEmbeddedModelsAccessorAndDescription { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result< + Option, + Box, + > { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithEmbeddedModelsAccessorAndDescription::new(); + x.embedded_empty_model = EmptyModel::decode(d)?; + let size_embedded_model_array_with_multiple_fields_accessor = d + .decode_array(Kind::Any)?; + for _ in 0..size_embedded_model_array_with_multiple_fields_accessor { + x.embedded_model_array_with_multiple_fields_accessor + .push( + ModelWithMultipleFieldsAccessor::decode(d)? + .ok_or(DecodingError::InvalidArray)?, + ); + } + Ok(Some(x)) + } +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn get_embedded_empty_model(&self) -> &Option { + &self.embedded_empty_model + } + pub fn set_embedded_empty_model(&mut self, v: Option) { + self.embedded_empty_model = v; + } +} +impl ModelWithEmbeddedModelsAccessorAndDescription { + pub fn get_embedded_model_array_with_multiple_fields_accessor( + &self, + ) -> Option<&Vec> { + Some(&self.embedded_model_array_with_multiple_fields_accessor) + } + pub fn set_embedded_model_array_with_multiple_fields_accessor( + &mut self, + v: Vec, + ) { + self.embedded_model_array_with_multiple_fields_accessor = v; + } +} +#[derive(Clone, Debug, PartialEq)] +pub struct ModelWithAllFieldTypes { + pub model_field: Option, + pub model_array_field: Vec, + pub string_field: String, + pub string_array_field: Vec, + pub string_map_field: HashMap, + pub string_map_field_embedded: HashMap, + pub int32_field: i32, + pub int32_array_field: Vec, + pub int32_map_field: HashMap, + pub int32_map_field_embedded: HashMap, + pub int64_field: i64, + pub int64_array_field: Vec, + pub int64_map_field: HashMap, + pub int64_map_field_embedded: HashMap, + pub uint32_field: u32, + pub uint32_array_field: Vec, + pub uint32_map_field: HashMap, + pub uint32_map_field_embedded: HashMap, + pub uint64_field: u64, + pub uint64_array_field: Vec, + pub uint64_map_field: HashMap, + pub uint64_map_field_embedded: HashMap, + pub float32_field: f32, + pub float32_array_field: Vec, + pub float64_field: f64, + pub float64_array_field: Vec, + pub enum_field: GenericEnum, + pub enum_array_field: Vec, + pub enum_map_field: HashMap, + pub enum_map_field_embedded: HashMap, + pub bytes_field: Vec, + pub bytes_array_field: Vec>, + pub bool_field: bool, + pub bool_array_field: Vec, +} +impl ModelWithAllFieldTypes { + pub fn new() -> Self { + Self { + model_field: Some(EmptyModel::new()), + model_array_field: Vec::with_capacity(0), + string_field: "DefaultValue".to_string(), + string_array_field: Vec::with_capacity(0), + string_map_field: HashMap::new(), + string_map_field_embedded: HashMap::new(), + int32_field: 32, + int32_array_field: Vec::with_capacity(0), + int32_map_field: HashMap::new(), + int32_map_field_embedded: HashMap::new(), + int64_field: 64, + int64_array_field: Vec::with_capacity(0), + int64_map_field: HashMap::new(), + int64_map_field_embedded: HashMap::new(), + uint32_field: 32, + uint32_array_field: Vec::with_capacity(0), + uint32_map_field: HashMap::new(), + uint32_map_field_embedded: HashMap::new(), + uint64_field: 64, + uint64_array_field: Vec::with_capacity(0), + uint64_map_field: HashMap::new(), + uint64_map_field_embedded: HashMap::new(), + float32_field: 32.32, + float32_array_field: Vec::with_capacity(0), + float64_field: 64.64, + float64_array_field: Vec::with_capacity(0), + enum_field: GenericEnum::DefaultValue, + enum_array_field: Vec::with_capacity(0), + enum_map_field: HashMap::new(), + enum_map_field_embedded: HashMap::new(), + bytes_field: Vec::with_capacity(512), + bytes_array_field: Vec::with_capacity(0), + bool_field: true, + bool_array_field: Vec::with_capacity(0), + } + } +} +impl Encode for ModelWithAllFieldTypes { + fn encode<'a>( + a: Option<&ModelWithAllFieldTypes>, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } +} +impl EncodeSelf for ModelWithAllFieldTypes { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + self.model_field.encode_self(e)?; + e.encode_array(self.model_array_field.len(), Kind::Any)?; + for a in &self.model_array_field { + a.encode_self(e)?; + } + e.encode_string(&self.string_field)?; + e.encode_array(self.string_array_field.len(), Kind::String)?; + for a in &self.string_array_field { + e.encode_string(&a)?; + } + e.encode_map(self.string_map_field.len(), Kind::String, Kind::String)?; + for (k, v) in &self.string_map_field { + e.encode_string(&k)?; + e.encode_string(&v)?; + } + e.encode_map(self.string_map_field_embedded.len(), Kind::String, Kind::Any)?; + for (k, v) in &self.string_map_field_embedded { + e.encode_string(&k)?; + v.encode_self(e)?; + } + e.encode_i32(self.int32_field)?; + e.encode_array(self.int32_array_field.len(), Kind::I32)?; + for a in &self.int32_array_field { + e.encode_i32(*a)?; + } + e.encode_map(self.int32_map_field.len(), Kind::I32, Kind::I32)?; + for (k, v) in &self.int32_map_field { + e.encode_i32(*k)?; + e.encode_i32(*v)?; + } + e.encode_map(self.int32_map_field_embedded.len(), Kind::I32, Kind::Any)?; + for (k, v) in &self.int32_map_field_embedded { + e.encode_i32(*k)?; + v.encode_self(e)?; + } + e.encode_i64(self.int64_field)?; + e.encode_array(self.int64_array_field.len(), Kind::I64)?; + for a in &self.int64_array_field { + e.encode_i64(*a)?; + } + e.encode_map(self.int64_map_field.len(), Kind::I64, Kind::I64)?; + for (k, v) in &self.int64_map_field { + e.encode_i64(*k)?; + e.encode_i64(*v)?; + } + e.encode_map(self.int64_map_field_embedded.len(), Kind::I64, Kind::Any)?; + for (k, v) in &self.int64_map_field_embedded { + e.encode_i64(*k)?; + v.encode_self(e)?; + } + e.encode_u32(self.uint32_field)?; + e.encode_array(self.uint32_array_field.len(), Kind::U32)?; + for a in &self.uint32_array_field { + e.encode_u32(*a)?; + } + e.encode_map(self.uint32_map_field.len(), Kind::U32, Kind::U32)?; + for (k, v) in &self.uint32_map_field { + e.encode_u32(*k)?; + e.encode_u32(*v)?; + } + e.encode_map(self.uint32_map_field_embedded.len(), Kind::U32, Kind::Any)?; + for (k, v) in &self.uint32_map_field_embedded { + e.encode_u32(*k)?; + v.encode_self(e)?; + } + e.encode_u64(self.uint64_field)?; + e.encode_array(self.uint64_array_field.len(), Kind::U64)?; + for a in &self.uint64_array_field { + e.encode_u64(*a)?; + } + e.encode_map(self.uint64_map_field.len(), Kind::U64, Kind::U64)?; + for (k, v) in &self.uint64_map_field { + e.encode_u64(*k)?; + e.encode_u64(*v)?; + } + e.encode_map(self.uint64_map_field_embedded.len(), Kind::U64, Kind::Any)?; + for (k, v) in &self.uint64_map_field_embedded { + e.encode_u64(*k)?; + v.encode_self(e)?; + } + e.encode_f32(self.float32_field)?; + e.encode_array(self.float32_array_field.len(), Kind::F32)?; + for a in &self.float32_array_field { + e.encode_f32(*a)?; + } + e.encode_f64(self.float64_field)?; + e.encode_array(self.float64_array_field.len(), Kind::F64)?; + for a in &self.float64_array_field { + e.encode_f64(*a)?; + } + e.encode_u32(self.enum_field as u32)?; + e.encode_array(self.enum_array_field.len(), Kind::U32)?; + for a in &self.enum_array_field { + e.encode_u32(*a as u32)?; + } + e.encode_map(self.enum_map_field.len(), Kind::U32, Kind::String)?; + for (k, v) in &self.enum_map_field { + e.encode_u32(*k as u32)?; + e.encode_string(&v)?; + } + e.encode_map(self.enum_map_field_embedded.len(), Kind::U32, Kind::Any)?; + for (k, v) in &self.enum_map_field_embedded { + e.encode_u32(*k as u32)?; + v.encode_self(e)?; + } + e.encode_bytes(&self.bytes_field)?; + e.encode_array(self.bytes_array_field.len(), Kind::Bytes)?; + for a in &self.bytes_array_field { + e.encode_bytes(&a)?; + } + e.encode_bool(self.bool_field)?; + e.encode_array(self.bool_array_field.len(), Kind::Bool)?; + for a in &self.bool_array_field { + e.encode_bool(*a)?; + } + Ok(e) + } +} +impl EncodeSelf for Option<&ModelWithAllFieldTypes> { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl EncodeSelf for Option { + fn encode_self<'a, 'b>( + &'b self, + e: &'a mut Cursor>, + ) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } +} +impl Decode for ModelWithAllFieldTypes { + fn decode( + d: &mut Cursor<&mut Vec>, + ) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + if let Ok(error) = d.decode_error() { + return Err(error); + } + let mut x = ModelWithAllFieldTypes::new(); + x.model_field = EmptyModel::decode(d)?; + let size_model_array_field = d.decode_array(Kind::Any)?; + for _ in 0..size_model_array_field { + x.model_array_field + .push(EmptyModel::decode(d)?.ok_or(DecodingError::InvalidArray)?); + } + x.string_field = d.decode_string()?; + let size_string_array_field = d.decode_array(Kind::String)?; + for _ in 0..size_string_array_field { + x.string_array_field.push(d.decode_string()?); + } + let size_string_map_field = d.decode_map(Kind::String, Kind::String)?; + for _ in 0..size_string_map_field { + let k = d.decode_string()?; + let v = d.decode_string()?; + x.string_map_field.insert(k, v); + } + let size_string_map_field_embedded = d.decode_map(Kind::String, Kind::Any)?; + for _ in 0..size_string_map_field_embedded { + let k = d.decode_string()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.string_map_field_embedded.insert(k, v); + } + x.int32_field = d.decode_i32()?; + let size_int32_array_field = d.decode_array(Kind::I32)?; + for _ in 0..size_int32_array_field { + x.int32_array_field.push(d.decode_i32()?); + } + let size_int32_map_field = d.decode_map(Kind::I32, Kind::I32)?; + for _ in 0..size_int32_map_field { + let k = d.decode_i32()?; + let v = d.decode_i32()?; + x.int32_map_field.insert(k, v); + } + let size_int32_map_field_embedded = d.decode_map(Kind::I32, Kind::Any)?; + for _ in 0..size_int32_map_field_embedded { + let k = d.decode_i32()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.int32_map_field_embedded.insert(k, v); + } + x.int64_field = d.decode_i64()?; + let size_int64_array_field = d.decode_array(Kind::I64)?; + for _ in 0..size_int64_array_field { + x.int64_array_field.push(d.decode_i64()?); + } + let size_int64_map_field = d.decode_map(Kind::I64, Kind::I64)?; + for _ in 0..size_int64_map_field { + let k = d.decode_i64()?; + let v = d.decode_i64()?; + x.int64_map_field.insert(k, v); + } + let size_int64_map_field_embedded = d.decode_map(Kind::I64, Kind::Any)?; + for _ in 0..size_int64_map_field_embedded { + let k = d.decode_i64()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.int64_map_field_embedded.insert(k, v); + } + x.uint32_field = d.decode_u32()?; + let size_uint32_array_field = d.decode_array(Kind::U32)?; + for _ in 0..size_uint32_array_field { + x.uint32_array_field.push(d.decode_u32()?); + } + let size_uint32_map_field = d.decode_map(Kind::U32, Kind::U32)?; + for _ in 0..size_uint32_map_field { + let k = d.decode_u32()?; + let v = d.decode_u32()?; + x.uint32_map_field.insert(k, v); + } + let size_uint32_map_field_embedded = d.decode_map(Kind::U32, Kind::Any)?; + for _ in 0..size_uint32_map_field_embedded { + let k = d.decode_u32()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.uint32_map_field_embedded.insert(k, v); + } + x.uint64_field = d.decode_u64()?; + let size_uint64_array_field = d.decode_array(Kind::U64)?; + for _ in 0..size_uint64_array_field { + x.uint64_array_field.push(d.decode_u64()?); + } + let size_uint64_map_field = d.decode_map(Kind::U64, Kind::U64)?; + for _ in 0..size_uint64_map_field { + let k = d.decode_u64()?; + let v = d.decode_u64()?; + x.uint64_map_field.insert(k, v); + } + let size_uint64_map_field_embedded = d.decode_map(Kind::U64, Kind::Any)?; + for _ in 0..size_uint64_map_field_embedded { + let k = d.decode_u64()?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.uint64_map_field_embedded.insert(k, v); + } + x.float32_field = d.decode_f32()?; + let size_float32_array_field = d.decode_array(Kind::F32)?; + for _ in 0..size_float32_array_field { + x.float32_array_field.push(d.decode_f32()?); + } + x.float64_field = d.decode_f64()?; + let size_float64_array_field = d.decode_array(Kind::F64)?; + for _ in 0..size_float64_array_field { + x.float64_array_field.push(d.decode_f64()?); + } + x + .enum_field = GenericEnum::try_from(d.decode_u32()?) + .ok() + .ok_or(DecodingError::InvalidEnum)?; + let size_enum_array_field = d.decode_array(Kind::U32)?; + for _ in 0..size_enum_array_field { + x.enum_array_field.push(GenericEnum::try_from(d.decode_u32()?)?); + } + let size_enum_map_field = d.decode_map(Kind::U32, Kind::String)?; + for _ in 0..size_enum_map_field { + let k = GenericEnum::try_from(d.decode_u32()?)?; + let v = d.decode_string()?; + x.enum_map_field.insert(k, v); + } + let size_enum_map_field_embedded = d.decode_map(Kind::U32, Kind::Any)?; + for _ in 0..size_enum_map_field_embedded { + let k = GenericEnum::try_from(d.decode_u32()?)?; + let v = EmptyModel::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.enum_map_field_embedded.insert(k, v); + } + x.bytes_field = d.decode_bytes()?; + let size_bytes_array_field = d.decode_array(Kind::Bytes)?; + for _ in 0..size_bytes_array_field { + x.bytes_array_field.push(d.decode_bytes()?); + } + x.bool_field = d.decode_bool()?; + let size_bool_array_field = d.decode_array(Kind::Bool)?; + for _ in 0..size_bool_array_field { + x.bool_array_field.push(d.decode_bool()?); + } + Ok(Some(x)) + } +} diff --git a/signature/generator/rust/generator.go b/signature/generator/rust/generator.go new file mode 100644 index 00000000..9a45e323 --- /dev/null +++ b/signature/generator/rust/generator.go @@ -0,0 +1,278 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package rust + +import ( + "bytes" + "context" + "strings" + "text/template" + + interfacesVersion "github.com/loopholelabs/scale-signature-interfaces/version" + + polyglotVersion "github.com/loopholelabs/polyglot/version" + + scaleVersion "github.com/loopholelabs/scale/version" + + polyglotUtils "github.com/loopholelabs/polyglot/utils" + + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator/rust/format" + "github.com/loopholelabs/scale/signature/generator/rust/templates" + "github.com/loopholelabs/scale/signature/generator/utils" +) + +const ( + defaultPackageName = "types" +) + +var generator *Generator + +// GenerateTypes generates the types for the signature +func GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + return generator.GenerateTypes(signatureSchema, packageName) +} + +// GenerateCargofile generates the cargo.toml file for the signature +func GenerateCargofile(packageName string, packageVersion string) ([]byte, error) { + return generator.GenerateCargofile(packageName, packageVersion) +} + +func GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + return generator.GenerateGuest(signatureSchema, signatureHash, packageName) +} + +func init() { + var err error + generator, err = New() + if err != nil { + panic(err) + } +} + +// Generator is the rust generator +type Generator struct { + templ *template.Template + formatter *format.Formatter +} + +// New creates a new rust generator +func New() (*Generator, error) { + templ, err := template.New("").Funcs(templateFunctions()).ParseFS(templates.FS, "*.rs.templ") + if err != nil { + return nil, err + } + + formatter, err := format.New() + if err != nil { + return nil, err + } + + return &Generator{ + templ: templ, + formatter: formatter, + }, nil +} + +// GenerateTypes generates the types for the signature +func (g *Generator) GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "types.rs.templ", map[string]any{ + "signature_schema": signatureSchema, + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + formatted, err := g.formatter.Format(context.Background(), buf.String()) + if err != nil { + return nil, err + } + + buf.Reset() + err = g.templ.ExecuteTemplate(buf, "header.rs.templ", map[string]any{ + "generator_version": strings.Trim(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + return []byte(buf.String() + "\n\n" + formatted), nil +} + +// GenerateCargofile generates the cargofile for the signature +func (g *Generator) GenerateCargofile(packageName string, packageVersion string) ([]byte, error) { + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "cargo.rs.templ", map[string]any{ + "polyglot_version": strings.TrimPrefix(polyglotVersion.Version(), "v"), + "scale_signature_interfaces_version": strings.TrimPrefix(interfacesVersion.Version(), "v"), + "package_name": packageName, + "package_version": strings.TrimPrefix(packageVersion, "v"), + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +// GenerateGuest generates the guest bindings +func (g *Generator) GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "guest.rs.templ", map[string]any{ + "signature_schema": signatureSchema, + "signature_hash": signatureHash, + }) + if err != nil { + return nil, err + } + + formatted, err := g.formatter.Format(context.Background(), buf.String()) + if err != nil { + return nil, err + } + + buf.Reset() + err = g.templ.ExecuteTemplate(buf, "header.rs.templ", map[string]any{ + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + return []byte(buf.String() + "\n\n" + formatted), nil +} + +func templateFunctions() template.FuncMap { + return template.FuncMap{ + "Primitive": primitive, + "IsPrimitive": signature.ValidPrimitiveType, + "PolyglotPrimitive": polyglotPrimitive, + "PolyglotPrimitiveEncode": polyglotPrimitiveEncode, + "PolyglotPrimitiveDecode": polyglotPrimitiveDecode, + "Deref": func(i *bool) bool { return *i }, + "LowerFirst": func(s string) string { return string(s[0]+32) + s[1:] }, + "SnakeCase": polyglotUtils.SnakeCase, + "Params": utils.Params, + } +} + +func primitive(t string) string { + switch t { + case "string": + return "String" + case "int32": + return "i32" + case "int64": + return "i64" + case "uint32": + return "u32" + case "uint64": + return "u64" + case "float32": + return "f32" + case "float64": + return "f64" + case "bool": + return "bool" + case "bytes": + return "Vec" + default: + return t + } +} + +func polyglotPrimitive(t string) string { + switch t { + case "string": + return "Kind::String" + case "int32": + return "Kind::I32" + case "int64": + return "Kind::I64" + case "uint32": + return "Kind::U32" + case "uint64": + return "Kind::U64" + case "float32": + return "Kind::F32" + case "float64": + return "Kind::F64" + case "bool": + return "Kind::Bool" + case "bytes": + return "Kind::Bytes" + default: + return "Kind::Any" + } +} + +func polyglotPrimitiveEncode(t string) string { + switch t { + case "string": + return "encode_string" + case "int32": + return "encode_i32" + case "int64": + return "encode_i64" + case "uint32": + return "encode_u32" + case "uint64": + return "encode_u64" + case "float32": + return "encode_f32" + case "float64": + return "encode_f64" + case "bool": + return "encode_bool" + case "bytes": + return "encode_bytes" + default: + return t + } +} + +func polyglotPrimitiveDecode(t string) string { + switch t { + case "string": + return "decode_string" + case "int32": + return "decode_i32" + case "int64": + return "decode_i64" + case "uint32": + return "decode_u32" + case "uint64": + return "decode_u64" + case "float32": + return "decode_f32" + case "float64": + return "decode_f64" + case "bool": + return "decode_bool" + case "bytes": + return "decode_bytes" + default: + return "" + } +} diff --git a/signature/generator/rust/generator_test.go b/signature/generator/rust/generator_test.go new file mode 100644 index 00000000..3f501ac0 --- /dev/null +++ b/signature/generator/rust/generator_test.go @@ -0,0 +1,43 @@ +//go:build !integration && !generate + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package rust + +import ( + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/loopholelabs/scale/signature" +) + +func TestGenerator(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + formatted, err := GenerateTypes(s, "types") + require.NoError(t, err) + + // os.WriteFile("./generated.txt", formatted, 0644) + + master, err := os.ReadFile("./generated.txt") + require.NoError(t, err) + require.Equal(t, string(master), string(formatted)) + + t.Log(string(formatted)) + +} diff --git a/signature/generator/rust/templates/arrays.rs.templ b/signature/generator/rust/templates/arrays.rs.templ new file mode 100644 index 00000000..2d15e2ad --- /dev/null +++ b/signature/generator/rust/templates/arrays.rs.templ @@ -0,0 +1,37 @@ +{{ define "rs_arrays_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ SnakeCase .Name }}: Vec<{{ Primitive $type }}>, + {{- else }} + pub {{ SnakeCase .Name }}: Vec<{{ Primitive $type }}>, + {{- end -}} + {{- end }} +{{ end }} + +{{ define "rs_arrays_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{ SnakeCase .Name }}: Vec::with_capacity({{ .InitialSize }}), + {{- end }} +{{ end }} + +{{ define "rs_arrays_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + e.encode_array(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }})?; + for a in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(*a)?; + } + {{- end }} +{{ end }} + +{{ define "rs_arrays_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + let size_{{ SnakeCase .Name }} = d.decode_array({{ PolyglotPrimitive $type }})?; + for _ in 0..size_{{ SnakeCase .Name }} { + x.{{ SnakeCase .Name }}.push(d.{{ PolyglotPrimitiveDecode $type }}()?); + } + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/cargo.rs.templ b/signature/generator/rust/templates/cargo.rs.templ new file mode 100644 index 00000000..efb7fa5f --- /dev/null +++ b/signature/generator/rust/templates/cargo.rs.templ @@ -0,0 +1,24 @@ +[package] +edition = "2021" +name = "{{ .package_name }}" +version = "{{ .package_version }}" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 + +[lib] +path = "guest.rs" + +[dependencies.num_enum] +version = "0.7.0" + +[dependencies.regex] +version = "1.9.4" + +[dependencies.scale_signature_interfaces] +version = "{{ .scale_signature_interfaces_version }}" + +[dependencies.polyglot_rs] +version = "{{ .polyglot_version }}" diff --git a/signature/generator/rust/templates/enumarrays.rs.templ b/signature/generator/rust/templates/enumarrays.rs.templ new file mode 100644 index 00000000..bdd88db9 --- /dev/null +++ b/signature/generator/rust/templates/enumarrays.rs.templ @@ -0,0 +1,36 @@ +{{ define "rs_enumarrays_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if (Deref .Accessor) }} + {{ SnakeCase .Name }}: Vec<{{ .Reference }}>, + {{- else }} + pub {{ SnakeCase .Name }}: Vec<{{ .Reference }}>, + {{- end -}} + {{- end }} +{{ end }} + +{{ define "rs_enumarrays_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{ SnakeCase .Name }}: Vec::with_capacity({{ .InitialSize }}), + {{- end }} +{{ end }} + +{{ define "rs_enumarrays_encode" }} + {{- range .EnumArrays }} + e.encode_array(self.{{ SnakeCase .Name}}.len(), Kind::U32)?; + for a in &self.{{ SnakeCase .Name}} { + e.encode_u32(*a as u32)?; + } + {{- end }} +{{ end }} + +{{ define "rs_enumarrays_decode" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + let size_{{ SnakeCase .Name }} = d.decode_array(Kind::U32)?; + for _ in 0..size_{{ SnakeCase .Name }} { + x.{{ SnakeCase .Name }}.push({{ .Reference }}::try_from(d.decode_u32()?)?); + } + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/enummaps.rs.templ b/signature/generator/rust/templates/enummaps.rs.templ new file mode 100644 index 00000000..ace8824b --- /dev/null +++ b/signature/generator/rust/templates/enummaps.rs.templ @@ -0,0 +1,70 @@ +{{ define "rs_enummaps_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + {{ SnakeCase .Name }}: HashMap<{ .Reference }}, {{ Primitive .Value }}>, + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + {{ SnakeCase .Name }}: HashMap<{{ .Reference }}, {{ .Value }}>, + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + pub {{ SnakeCase .Name }}: HashMap<{{ .Reference }}, {{ Primitive .Value }}>, + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + pub {{ SnakeCase .Name }}: HashMap<{{ .Reference }}, {{ .Value }}>, + {{- end }} + {{- end }} +{{ end }} + +{{ define "rs_enummaps_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{ SnakeCase .Name }}: HashMap::new(), + {{ end }} +{{ end }} + +{{ define "rs_enummaps_encode" }} + {{- range .EnumMaps }} + {{- if IsPrimitive .Value }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), Kind::U32, {{ PolyglotPrimitive .Value }})?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.encode_u32(*k as u32)?; + {{- if eq .Value "string"}} + e.{{ PolyglotPrimitiveEncode .Value }}(&v)?; + {{- else }} + e.{{ PolyglotPrimitiveEncode .Value }}(v)?; + {{- end }} + } + {{- else }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), Kind::U32, Kind::Any)?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.encode_u32(*k as u32)?; + v.encode_self(e)?; + } + {{- end }} + {{- end }} +{{ end }} + +{{ define "rs_enummaps_decode" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if IsPrimitive .Value }} + let size_{{ SnakeCase .Name }} = d.decode_map(Kind::U32, {{ PolyglotPrimitive .Value }})?; + for _ in 0..size_{{ SnakeCase .Name }} { + let k = {{ .Reference }}::try_from(d.decode_u32()?)?; + let v = d.{{ PolyglotPrimitiveDecode .Value }}()?; + x.{{ SnakeCase .Name }}.insert(k, v); + } + {{- else }} + let size_{{ SnakeCase .Name }} = d.decode_map(Kind::U32, Kind::Any)?; + for _ in 0..size_{{ SnakeCase .Name }} { + let k = {{ .Reference }}::try_from(d.decode_u32()?)?; + let v = {{ .Value }}::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.{{ SnakeCase .Name }}.insert(k, v); + } + {{- end }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/enums.rs.templ b/signature/generator/rust/templates/enums.rs.templ new file mode 100644 index 00000000..800efa56 --- /dev/null +++ b/signature/generator/rust/templates/enums.rs.templ @@ -0,0 +1,58 @@ +{{ define "rs_enums_definition" }} + #[derive(Debug, Eq, PartialEq, TryFromPrimitive, Copy, Clone, Hash)] + #[repr(u32)] + pub enum {{ .Name }} { + {{- range $index, $value := .Values }} + {{ $value }} = {{ $index }}, + {{- end }} + } +{{ end }} + +{{ define "rs_enums_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if (Deref .Accessor) }} + {{ SnakeCase .Name }}: {{ .Reference }}, + {{- else }} + pub {{ SnakeCase .Name }}: {{ .Reference }}, + {{- end -}} + {{ end }} +{{ end }} + +{{ define "rs_enums_new_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{ SnakeCase .Name }}: {{ .Reference }}::{{ .Default }}, + {{ end }} +{{ end }} + +{{ define "rs_enums_encode" }} + {{ $current_model := . }} + {{- range .Enums }} + e.encode_u32(self.{{ SnakeCase .Name }} as u32)?; + {{- end }} +{{ end }} + +{{ define "rs_enums_decode" }} + {{ $current_model := . }} + {{- range .Enums }} + x.{{ SnakeCase .Name }} = {{ .Reference }}::try_from(d.decode_u32()?).ok().ok_or(DecodingError::InvalidEnum)?; + {{- end }} +{{ end }} + +{{ define "rs_enums_accessor" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + impl {{ $current_model.Name }} { + pub fn get_{{ SnakeCase .Name }}(&self) -> &{{ .Reference }} { + &self.{{ SnakeCase .Name }} + } + + pub fn set_{{ SnakeCase .Name }}(&mut self, v: {{ .Reference }}) { + self.{{ SnakeCase .Name }} = v; + } + } + {{- end -}} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/guest.rs.templ b/signature/generator/rust/templates/guest.rs.templ new file mode 100644 index 00000000..ed2fdea9 --- /dev/null +++ b/signature/generator/rust/templates/guest.rs.templ @@ -0,0 +1,108 @@ +pub mod types; +use crate::types::{Encode, Decode}; + +use std::io::Cursor; +use polyglot_rs::{Encoder}; + +static HASH: &'static str = "{{ .signature_hash }}"; + +static mut READ_BUFFER: Vec = Vec::new(); +static mut WRITE_BUFFER: Vec = Vec::new(); + +// write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +pub unsafe fn write(ctx: Option<&mut types::{{ .signature_schema.Context }}>) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + match ctx { + Some(ctx) => { + cursor = match types::{{ .signature_schema.Context }}::encode(Some(ctx), &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + None => { + cursor = match types::{{ .signature_schema.Context }}::encode(None, &mut cursor) { + Ok(_) => cursor, + Err(err) => return error(err), + }; + } + } + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + return (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32); +} + +// read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +pub unsafe fn read() -> Result, Box> { + let mut cursor = Cursor::new(&mut READ_BUFFER); + types::{{ .signature_schema.Context }}::decode(&mut cursor) +} + +// error serializes an error into the global WRITE_BUFFER and returns a pointer to the buffer and its size +// +// Users should not use this method. +pub unsafe fn error(error: Box) -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_error(error) { + Ok(_) => { + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => { + (0, 0) + } + }; +} + +// resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +pub unsafe fn resize(size: u32) -> *const u8 { + READ_BUFFER.resize(size as usize, 0); + return READ_BUFFER.as_ptr(); +} + +// hash returns the hash of the Scale Signature +// +// Users should not use this method. +pub unsafe fn hash() -> (u32, u32) { + let mut cursor = Cursor::new(Vec::new()); + return match cursor.encode_string(&String::from(HASH)) { + Ok(_) => { + let vec = cursor.into_inner(); + + WRITE_BUFFER.resize(vec.len() as usize, 0); + WRITE_BUFFER.copy_from_slice(&vec); + + (WRITE_BUFFER.as_ptr() as u32, WRITE_BUFFER.len() as u32) + } + Err(_) => { + (0, 0) + } + }; +} + +// next calls the next function in the Scale Function Chain +pub fn next(ctx: Option<&mut types::{{ .signature_schema.Context }}>) -> Result, Box> { + unsafe { + let (ptr, len) = write(ctx); + _next(ptr, len); + read() + } +} + +#[link(wasm_import_module = "env")] +extern "C" { + #[link_name = "next"] + fn _next(ptr: u32, size: u32); +} \ No newline at end of file diff --git a/signature/generator/rust/templates/header.rs.templ b/signature/generator/rust/templates/header.rs.templ new file mode 100644 index 00000000..6a9eabe3 --- /dev/null +++ b/signature/generator/rust/templates/header.rs.templ @@ -0,0 +1,2 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} \ No newline at end of file diff --git a/signature/generator/rust/templates/maps.rs.templ b/signature/generator/rust/templates/maps.rs.templ new file mode 100644 index 00000000..d8be9eda --- /dev/null +++ b/signature/generator/rust/templates/maps.rs.templ @@ -0,0 +1,58 @@ +{{ define "rs_maps_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ SnakeCase .Name }}: HashMap<{{ Primitive $type }}, {{ Primitive .Value }}>, + {{- else }} + pub {{ SnakeCase .Name }}: HashMap<{{ Primitive $type }}, {{ Primitive .Value }}>, + {{- end }} + {{ end }} +{{ end }} + +{{ define "rs_maps_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{ SnakeCase .Name }}: HashMap::new(), + {{- end }} +{{ end }} + +{{ define "rs_maps_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if IsPrimitive .Value }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }})?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(*k)?; + e.{{ PolyglotPrimitiveEncode .Value }}(*v)?; + } + {{- else }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }}, Kind::Any)?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(*k)?; + v.encode_self(e)?; + } + {{- end }} + + {{- end }} +{{ end }} + +{{ define "rs_maps_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if IsPrimitive .Value }} + let size_{{ SnakeCase .Name }} = d.decode_map({{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }})?; + for _ in 0..size_{{ SnakeCase .Name }} { + let k = d.{{ PolyglotPrimitiveDecode $type }}()?; + let v = d.{{ PolyglotPrimitiveDecode .Value }}()?; + x.{{ SnakeCase .Name }}.insert(k, v); + } + {{- else }} + let size_{{ SnakeCase .Name }} = d.decode_map({{ PolyglotPrimitive $type }}, Kind::Any)?; + for _ in 0..size_{{ SnakeCase .Name }} { + let k = d.{{ PolyglotPrimitiveDecode $type }}()?; + let v = {{ .Value }}::decode(d)?.ok_or(DecodingError::InvalidMap)?; + x.{{ SnakeCase .Name }}.insert(k, v); + } + {{- end }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/modelarrays.rs.templ b/signature/generator/rust/templates/modelarrays.rs.templ new file mode 100644 index 00000000..af3746aa --- /dev/null +++ b/signature/generator/rust/templates/modelarrays.rs.templ @@ -0,0 +1,50 @@ +{{ define "rs_modelarrays_struct_reference" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + {{ SnakeCase .Name }}: Vec<{{ .Reference }}>, + {{- else }} + pub {{ SnakeCase .Name }}: Vec<{{ .Reference }}>, + {{- end -}} + {{ end }} +{{ end }} + +{{ define "rs_modelarrays_new_struct_reference" }} + {{- range .ModelArrays }} + {{ SnakeCase .Name }}: Vec::with_capacity({{ .InitialSize }}), + {{- end }} +{{ end }} + +{{ define "rs_modelarrays_encode" }} + {{- range .ModelArrays }} + e.encode_array(self.{{ SnakeCase .Name }}.len(), Kind::Any)?; + for a in &self.{{ SnakeCase .Name }} { + a.encode_self(e)?; + } + {{- end }} +{{ end }} + +{{ define "rs_modelarrays_decode" }} + {{- range .ModelArrays }} + let size_{{ SnakeCase .Name }} = d.decode_array(Kind::Any)?; + for _ in 0..size_{{ SnakeCase .Name }} { + x.{{ SnakeCase .Name }}.push({{ .Reference }}::decode(d)?.ok_or(DecodingError::InvalidArray)?); + } + {{- end }} +{{ end }} + +{{ define "rs_modelarrays_accessor" }} + {{ $current_model := . }} + {{- range .ModelArrays }} + {{- if .Accessor }} + impl {{ $current_model.Name }} { + pub fn get_{{ SnakeCase .Name }} (&self) -> Option<&Vec<{{ .Reference }}>> { + Some(&self.{{ SnakeCase .Name }}) + } + + pub fn set_{{ SnakeCase .Name }} (&mut self, v: Vec<{{ .Reference }}>) { + self.{{ SnakeCase .Name }} = v; + } + } + {{- end -}} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/models.rs.templ b/signature/generator/rust/templates/models.rs.templ new file mode 100644 index 00000000..c1334abd --- /dev/null +++ b/signature/generator/rust/templates/models.rs.templ @@ -0,0 +1,44 @@ +{{ define "rs_models_struct_reference" }} + {{- range .Models }} + {{- if .Accessor }} + {{ SnakeCase .Name }}: Option<{{ .Reference }}>, + {{- else }} + pub {{ SnakeCase .Name }}: Option<{{ .Reference }}>, + {{- end -}} + {{- end }} +{{ end }} + +{{ define "rs_models_new_struct_reference" }} + {{- range .Models }} + {{ SnakeCase .Name }}: Some({{ .Reference }}::new()), + {{- end }} +{{ end }} + +{{ define "rs_models_encode" }} + {{- range .Models }} + self.{{ SnakeCase .Name }}.encode_self(e)?; + {{- end }} +{{ end }} + +{{ define "rs_models_decode" }} + {{- range .Models }} + x.{{ SnakeCase .Name }} = {{ .Reference }}::decode(d)?; + {{- end }} +{{ end }} + +{{ define "rs_models_accessor" }} + {{ $current_model := . }} + {{- range .Models }} + {{- if .Accessor }} + impl {{ $current_model.Name }} { + pub fn get_{{ SnakeCase .Name }}(&self) -> &Option<{{ .Reference }}> { + &self.{{ SnakeCase .Name }} + } + + pub fn set_{{ SnakeCase .Name }}(&mut self, v: Option<{{ .Reference }}>) { + self.{{ SnakeCase .Name }} = v; + } + } + {{- end -}} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/primitives.rs.templ b/signature/generator/rust/templates/primitives.rs.templ new file mode 100644 index 00000000..6d6d4c73 --- /dev/null +++ b/signature/generator/rust/templates/primitives.rs.templ @@ -0,0 +1,90 @@ +{{ define "rs_primitives_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + {{ SnakeCase .Name }}: {{ Primitive $type }}, + {{- else }} + pub {{ SnakeCase .Name }}: {{ Primitive $type }}, + {{- end -}} + {{ end }} +{{ end }} + +{{ define "rs_primitives_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{ SnakeCase .Name }}: {{ .Default }}, + {{ end }} +{{ end }} + +{{ define "rs_strings_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{ SnakeCase .Name }}: "{{ .Default }}".to_string(), + {{ end }} +{{ end }} + +{{ define "rs_bytes_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{ SnakeCase .Name }}: Vec::with_capacity({{ .InitialSize }}), + {{ end }} +{{ end }} + +{{ define "rs_primitives_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + e.{{ PolyglotPrimitiveEncode $type }}(self.{{ SnakeCase .Name }})?; + {{- end }} +{{ end}} + +{{ define "rs_ref_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + e.{{ PolyglotPrimitiveEncode $type }}(&self.{{ SnakeCase .Name }})?; + {{- end }} +{{ end}} + +{{ define "rs_primitives_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + x.{{ SnakeCase .Name }} = d.{{ PolyglotPrimitiveDecode $type }}()?; + {{- end }} +{{ end}} + +{{ define "rs_numbers_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + pub fn get_{{ SnakeCase .Name }}(&self) -> {{ Primitive $type }} { + self.{{ SnakeCase .Name }} + } + + pub fn set_{{ SnakeCase .Name }}(&mut self, v: {{ Primitive $type }}) -> Result<(), Box> { + {{- template "rs_numbers_limit_validator" .LimitValidator }} + self.{{ SnakeCase .Name }} = v; + Ok(()) + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "rs_strings_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + pub fn get_{{ SnakeCase .Name }}(&self) -> {{ Primitive $type }} { + self.{{ SnakeCase .Name }}.clone() + } + + pub fn set_{{ SnakeCase .Name }}(&mut self, mut v: {{ Primitive $type }}) -> Result<(), Box> { + {{- template "rs_regex_validator" .RegexValidator }} + {{- template "rs_length_validator" .LengthValidator }} + {{- template "rs_case_modifier" .CaseModifier }} + self.{{ SnakeCase .Name }} = v; + Ok(()) + } + {{- end -}} + {{ end }} +{{ end }} diff --git a/signature/generator/rust/templates/refarrays.rs.templ b/signature/generator/rust/templates/refarrays.rs.templ new file mode 100644 index 00000000..bfa6067b --- /dev/null +++ b/signature/generator/rust/templates/refarrays.rs.templ @@ -0,0 +1,9 @@ +{{ define "rs_refarrays_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + e.encode_array(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }})?; + for a in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(&a)?; + } + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/refmaps.rs.templ b/signature/generator/rust/templates/refmaps.rs.templ new file mode 100644 index 00000000..cb53ca9f --- /dev/null +++ b/signature/generator/rust/templates/refmaps.rs.templ @@ -0,0 +1,19 @@ +{{ define "rs_refmaps_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if IsPrimitive .Value }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }})?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(&k)?; + e.{{ PolyglotPrimitiveEncode .Value }}(&v)?; + } + {{- else }} + e.encode_map(self.{{ SnakeCase .Name }}.len(), {{ PolyglotPrimitive $type }}, Kind::Any)?; + for (k, v) in &self.{{ SnakeCase .Name }} { + e.{{ PolyglotPrimitiveEncode $type }}(&k)?; + v.encode_self(e)?; + } + {{- end }} + + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/rust/templates/templates.go b/signature/generator/rust/templates/templates.go new file mode 100644 index 00000000..fdfb581a --- /dev/null +++ b/signature/generator/rust/templates/templates.go @@ -0,0 +1,19 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package templates + +import "embed" + +//go:embed * +var FS embed.FS diff --git a/signature/generator/rust/templates/types.rs.templ b/signature/generator/rust/templates/types.rs.templ new file mode 100644 index 00000000..edb108dc --- /dev/null +++ b/signature/generator/rust/templates/types.rs.templ @@ -0,0 +1,262 @@ +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_mut)] + +use std::io::Cursor; +use polyglot_rs::{DecodingError, Encoder, Decoder, Kind}; +use num_enum::TryFromPrimitive; +use std::convert::TryFrom; +use std::collections::HashMap; +use regex::Regex; + +pub trait Encode { + fn encode<'a> (a: Option<&Self>, b: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box> where Self: Sized; +} + +trait EncodeSelf { + fn encode_self<'a, 'b> (&'b self, b: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box>; +} + +pub trait Decode { + fn decode (b: &mut Cursor<&mut Vec>) -> Result, Box> where Self: Sized; +} + +{{- range .signature_schema.Enums }} + {{ template "rs_enums_definition" . }} +{{- end }} + +{{- range .signature_schema.Models -}} + {{- if .Description }} + // {{ .Name }}: {{ .Description }} + {{ end -}} + + #[derive(Clone, Debug, PartialEq)] + pub struct {{ .Name }} { + {{ template "rs_models_struct_reference" . }} + {{ template "rs_modelarrays_struct_reference" . }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Strings "Type" "string" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "rs_maps_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Int32s "Type" "int32" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "rs_maps_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + + {{ template "rs_primitives_struct_reference" Params "Entries" .Int64s "Type" "int64" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "rs_maps_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "rs_maps_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "rs_maps_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Float32s "Type" "float32" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Float64s "Type" "float64" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "rs_enums_struct_reference" . }} + {{ template "rs_enumarrays_struct_reference" . }} + {{ template "rs_enummaps_struct_reference" . }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "rs_primitives_struct_reference" Params "Entries" .Bools "Type" "bool" }} + {{ template "rs_arrays_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + } + + impl {{ .Name }} { + pub fn new () -> Self { + Self { + {{ template "rs_models_new_struct_reference" . }} + {{ template "rs_modelarrays_new_struct_reference" . }} + + {{ template "rs_strings_new_struct_reference" Params "Entries" .Strings }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "rs_maps_new_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Int32s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "rs_maps_new_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Int64s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "rs_maps_new_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Uint32s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "rs_maps_new_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Uint64s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "rs_maps_new_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Float32s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Float64s }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "rs_enums_new_struct_reference" . }} + {{ template "rs_enumarrays_new_struct_reference" . }} + {{ template "rs_enummaps_new_struct_reference" . }} + + {{ template "rs_bytes_new_struct_reference" Params "Entries" .Bytes }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "rs_primitives_new_struct_reference" Params "Entries" .Bools }} + {{ template "rs_arrays_new_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + } + } + + + {{ template "rs_strings_accessor" Params "Model" . "Entries" .Strings "Type" "string" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Int32s "Type" "int32" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Int64s "Type" "int64" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Uint32s "Type" "uint32" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Uint64s "Type" "uint64" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Float32s "Type" "float32" }} + {{ template "rs_numbers_accessor" Params "Model" . "Entries" .Float64s "Type" "float32" }} + } + + impl Encode for {{ .Name }} { + fn encode<'a> (a: Option<&{{ .Name }}>, e: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box> { + a.encode_self(e) + } + } + + impl EncodeSelf for {{ .Name }} { + fn encode_self<'a, 'b> (&'b self, e: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box> { + {{ template "rs_models_encode" . }} + {{ template "rs_modelarrays_encode" . }} + + {{ template "rs_ref_encode" Params "Entries" .Strings "Type" "string" }} + {{ template "rs_refarrays_encode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "rs_refmaps_encode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "rs_primitives_encode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "rs_arrays_encode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "rs_maps_encode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "rs_primitives_encode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "rs_arrays_encode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "rs_maps_encode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "rs_primitives_encode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "rs_arrays_encode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "rs_maps_encode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "rs_primitives_encode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "rs_arrays_encode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "rs_maps_encode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "rs_primitives_encode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "rs_arrays_encode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "rs_primitives_encode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "rs_arrays_encode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "rs_enums_encode" . }} + {{ template "rs_enumarrays_encode" . }} + {{ template "rs_enummaps_encode" . }} + + {{ template "rs_ref_encode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "rs_refarrays_encode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "rs_primitives_encode" Params "Entries" .Bools "Type" "bool" }} + {{ template "rs_arrays_encode" Params "Entries" .BoolArrays "Type" "bool" }} + + Ok(e) + } + } + + impl EncodeSelf for Option<&{{ .Name }}> { + fn encode_self<'a, 'b> (&'b self, e: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } + } + + impl EncodeSelf for Option<{{ .Name }}> { + fn encode_self<'a, 'b> (&'b self, e: &'a mut Cursor>) -> Result<&'a mut Cursor>, Box> { + if let Some(x) = self { + x.encode_self(e)?; + } else { + e.encode_none()?; + } + Ok(e) + } + } + + impl Decode for {{ .Name }} { + fn decode (d: &mut Cursor<&mut Vec>) -> Result, Box> { + if d.decode_none() { + return Ok(None); + } + + if let Ok(error) = d.decode_error() { + return Err(error); + } + + let mut x = {{ .Name }}::new(); + + {{ template "rs_models_decode" . }} + {{ template "rs_modelarrays_decode" . }} + + {{ template "rs_primitives_decode" Params "Entries" .Strings "Type" "string" }} + {{ template "rs_arrays_decode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "rs_maps_decode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "rs_primitives_decode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "rs_arrays_decode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "rs_maps_decode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "rs_primitives_decode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "rs_arrays_decode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "rs_maps_decode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "rs_primitives_decode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "rs_arrays_decode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "rs_maps_decode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "rs_primitives_decode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "rs_arrays_decode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "rs_maps_decode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "rs_primitives_decode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "rs_arrays_decode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "rs_primitives_decode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "rs_arrays_decode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "rs_enums_decode" . }} + {{ template "rs_enumarrays_decode" . }} + {{ template "rs_enummaps_decode" . }} + + {{ template "rs_primitives_decode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "rs_arrays_decode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "rs_primitives_decode" Params "Entries" .Bools "Type" "bool" }} + {{ template "rs_arrays_decode" Params "Entries" .BoolArrays "Type" "bool" }} + + Ok(Some(x)) + } + } + + {{ template "rs_models_accessor" . }} + {{ template "rs_modelarrays_accessor" . }} + {{ template "rs_enums_accessor" . }} +{{ end -}} \ No newline at end of file diff --git a/signature/generator/rust/templates/validators.rs.templ b/signature/generator/rust/templates/validators.rs.templ new file mode 100644 index 00000000..5308a27d --- /dev/null +++ b/signature/generator/rust/templates/validators.rs.templ @@ -0,0 +1,53 @@ +{{ define "rs_numbers_limit_validator" }} +{{- if . }} + {{- if and .Maximum .Minimum }} + if v > {{ .Maximum }} || v < {{ .Minimum }} { + return Err(Box::::from("value must be between { .Minimum }} and {{ .Maximum }}")); + } + {{- else if .Minimum }} + if v < {{ .Minimum }} { + return Err(Box::::from("value must be greater than or equal to {{ .Minimum }}")); + } + {{- else if .Maximum }} + if v > {{ .Maximum }} { + return Err(Box::::from("value must be less than or equal to {{ .Maximum }}")); + } + {{- end }} +{{- end }} +{{ end }} + +{{ define "rs_regex_validator" }} + {{- if . }} + if !Regex::new("^[a-zA-Z0-9]*$")?.is_match(v.as_str()) { + return Err(Box::::from("value must match {{ .Expression }}")); + } + {{- end }} +{{ end }} + +{{ define "rs_length_validator" }} + {{- if . }} + {{- if and .Maximum .Minimum }} + if v.len() > {{ .Maximum }} || v.len() < {{ .Minimum }} { + return Err(Box::::from("value must be between { .Minimum }} and {{ .Maximum }}")); + } + {{- else if .Minimum }} + if v.len() < {{ .Minimum }} { + return Err(Box::::from("value must be greater than or equal to {{ .Minimum }}")); + } + {{- else if .Maximum }} + if v.len() > {{ .Maximum }} { + return Err(Box::::from("value must be less than or equal to {{ .Maximum }}")); + } + {{- end }} + {{- end }} +{{ end }} + +{{ define "rs_case_modifier" }} + {{- if . }} + {{- if eq .Kind "upper" }} + v = v.to_uppercase(); + {{- else if eq .Kind "lower" }} + v = v.to_lowercase(); + {{- end }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/generated.txt b/signature/generator/typescript/generated.txt new file mode 100755 index 00000000..e5ffaf8d --- /dev/null +++ b/signature/generator/typescript/generated.txt @@ -0,0 +1,1473 @@ +// Code generated by scale-signature 0.4.0, DO NOT EDIT. +// output: types + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +export enum GenericEnum { + FirstValue = 0, + + SecondValue = 1, + + DefaultValue = 2, + +} +export class EmptyModel { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModel | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModel(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// EmptyModelWithDescription: Test Description +export class EmptyModelWithDescription { + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + } else { + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): EmptyModelWithDescription | undefined { + if (decoder.null()) { + return undefined + } + return new EmptyModelWithDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleStringField { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringField | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringField(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleStringFieldAndDescription: Test Description +export class ModelWithSingleStringFieldAndDescription { + stringField: string; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + } else { + this.stringField = "DefaultValue"; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleStringFieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleStringFieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithSingleInt32Field { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32Field | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32Field(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithSingleInt32FieldAndDescription: Test Description +export class ModelWithSingleInt32FieldAndDescription { + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.int32Field = decoder.int32(); + } else { + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithSingleInt32FieldAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithSingleInt32FieldAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFields { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFields | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFields(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAndDescription: Test Description +export class ModelWithMultipleFieldsAndDescription { + stringField: string; + + int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.stringField = decoder.string(); + this.int32Field = decoder.int32(); + } else { + this.stringField = "DefaultValue"; + this.int32Field = 32; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.stringField); + encoder.int32(this.int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnum { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnum | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnum(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAndDescription: Test Description +export class ModelWithEnumAndDescription { + enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.enumField = decoder.uint32(); + } else { + this.enumField = GenericEnum.DefaultValue; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEnumAccessor { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = GenericEnum.DefaultValue; + } + } + + get enumField(): GenericEnum { + return this.#enumField; + } + + set enumField(val: GenericEnum) { + this.#enumField = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.#enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEnumAccessorAndDescription: Test Description +export class ModelWithEnumAccessorAndDescription { + #enumField: GenericEnum; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#enumField = decoder.uint32(); + } else { + this.#enumField = GenericEnum.DefaultValue; + } + } + + get enumField(): GenericEnum { + return this.#enumField; + } + + set enumField(val: GenericEnum) { + this.#enumField = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.uint32(this.#enumField); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEnumAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEnumAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithMultipleFieldsAccessor { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + + get stringField(): string { + return this.#stringField; + } + + set stringField(val: string) { + if (!/^[a-zA-Z0-9]*$/.test(val)) { + throw new Error("value must match ^[a-zA-Z0-9]*$"); + } + if (val.length > 20 || val.length < 1) { + throw new Error("length must be between 1 and 20"); + } + val = val.toUpperCase(); + this.#stringField = val; + } + + get int32Field(): number { + return this.#int32Field; + } + + set int32Field (val: number) { + if (val > 100 || val < 0) { + throw new Error("value must be between 0 and 100"); + } + this.#int32Field = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithMultipleFieldsAccessorAndDescription: Test Description +export class ModelWithMultipleFieldsAccessorAndDescription { + #stringField: string; + + #int32Field: number; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#stringField = decoder.string(); + this.#int32Field = decoder.int32(); + } else { + this.#stringField = "DefaultValue"; + this.#int32Field = 32; + } + } + + get stringField(): string { + return this.#stringField; + } + + set stringField(val: string) { + this.#stringField = val; + } + + get int32Field(): number { + return this.#int32Field; + } + + set int32Field (val: number) { + this.#int32Field = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + encoder.string(this.#stringField); + encoder.int32(this.#int32Field); + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithMultipleFieldsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithMultipleFieldsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModels { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModels | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModels(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAndDescription: Test Description +export class ModelWithEmbeddedModelsAndDescription { + embeddedEmptyModel: EmptyModel | undefined; + + embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.embeddedEmptyModel = new EmptyModel(); + this.embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithEmbeddedModelsAccessor { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + get embeddedEmptyModel(): EmptyModel | undefined { + return this.#embeddedEmptyModel; + } + + set embeddedEmptyModel(val: EmptyModel | undefined) { + this.#embeddedEmptyModel = val; + } + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessor | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessor(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +// ModelWithEmbeddedModelsAccessorAndDescription: Test Description +export class ModelWithEmbeddedModelsAccessorAndDescription { + #embeddedEmptyModel: EmptyModel | undefined; + + #embeddedModelArrayWithMultipleFieldsAccessor: Array; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.#embeddedEmptyModel = EmptyModel.decode(decoder); + const embeddedModelArrayWithMultipleFieldsAccessorSize = decoder.array(Kind.Any); + this.#embeddedModelArrayWithMultipleFieldsAccessor = new Array(embeddedModelArrayWithMultipleFieldsAccessorSize); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorSize; i += 1) { + const x = ModelWithMultipleFieldsAccessor.decode(decoder); + if (typeof x !== "undefined") { + this.#embeddedModelArrayWithMultipleFieldsAccessor[i] = x; + } + } + } else { + this.#embeddedEmptyModel = new EmptyModel(); + this.#embeddedModelArrayWithMultipleFieldsAccessor = []; + } + } + + get embeddedEmptyModel(): EmptyModel | undefined { + return this.#embeddedEmptyModel; + } + + set embeddedEmptyModel(val: EmptyModel | undefined) { + this.#embeddedEmptyModel = val; + } + + get embeddedModelArrayWithMultipleFieldsAccessor(): Array { + return this.#embeddedModelArrayWithMultipleFieldsAccessor; + } + + set EmbeddedModelArrayWithMultipleFieldsAccessor(val: Array) { + this.#embeddedModelArrayWithMultipleFieldsAccessor = val; + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.#embeddedEmptyModel === "undefined") { + encoder.null(); + } else { + this.#embeddedEmptyModel.encode(encoder); + } + const embeddedModelArrayWithMultipleFieldsAccessorLength = this.#embeddedModelArrayWithMultipleFieldsAccessor.length; + encoder.array(embeddedModelArrayWithMultipleFieldsAccessorLength, Kind.Any); + for (let i = 0; i < embeddedModelArrayWithMultipleFieldsAccessorLength; i += 1) { + const el = this.#embeddedModelArrayWithMultipleFieldsAccessor[i]; + el.encode(encoder); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithEmbeddedModelsAccessorAndDescription | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithEmbeddedModelsAccessorAndDescription(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + +export class ModelWithAllFieldTypes { + modelField: EmptyModel | undefined; + + modelArrayField: Array; + + stringField: string; + + stringArrayField: string[]; + + stringMapField: Map; + + stringMapFieldEmbedded: Map; + + int32Field: number; + + int32ArrayField: number[]; + + int32MapField: Map; + + int32MapFieldEmbedded: Map; + + int64Field: bigint; + + int64ArrayField: bigint[]; + + int64MapField: Map; + + int64MapFieldEmbedded: Map; + + uint32Field: number; + + uint32ArrayField: number[]; + + uint32MapField: Map; + + uint32MapFieldEmbedded: Map; + + uint64Field: bigint; + + uint64ArrayField: bigint[]; + + uint64MapField: Map; + + uint64MapFieldEmbedded: Map; + + float32Field: number; + + float32ArrayField: number[]; + + float64Field: number; + + float64ArrayField: number[]; + + enumField: GenericEnum; + + enumArrayField: GenericEnum[]; + + enumMapField: Map; + + enumMapFieldEmbedded: Map; + + bytesField: Uint8Array; + + bytesArrayField: Uint8Array[]; + + boolField: boolean; + + boolArrayField: boolean[]; + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + this.modelField = EmptyModel.decode(decoder); + const modelArrayFieldSize = decoder.array(Kind.Any); + this.modelArrayField = new Array(modelArrayFieldSize); + for (let i = 0; i < modelArrayFieldSize; i += 1) { + const x = EmptyModel.decode(decoder); + if (typeof x !== "undefined") { + this.modelArrayField[i] = x; + } + } + this.stringField = decoder.string(); + const stringArrayFieldSize = decoder.array(Kind.String); + this.stringArrayField = new Array(stringArrayFieldSize); + for (let i = 0; i < stringArrayFieldSize; i += 1) { + this.stringArrayField[i] = decoder.string(); + } + this.stringMapField = new Map(); + let stringMapFieldSize = decoder.map(Kind.String, Kind.String); + for (let i = 0; i < stringMapFieldSize; i++) { + let key = decoder.string(); + let val = decoder.string(); + this.stringMapField.set(key, val); + } + this.stringMapFieldEmbedded = new Map(); + let stringMapFieldEmbeddedSize = decoder.map(Kind.String, Kind.Any); + for (let i = 0; i < stringMapFieldEmbeddedSize; i++) { + let key = decoder.string(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.stringMapFieldEmbedded.set(key, val); + } + } + this.int32Field = decoder.int32(); + const int32ArrayFieldSize = decoder.array(Kind.Int32); + this.int32ArrayField = new Array(int32ArrayFieldSize); + for (let i = 0; i < int32ArrayFieldSize; i += 1) { + this.int32ArrayField[i] = decoder.int32(); + } + this.int32MapField = new Map(); + let int32MapFieldSize = decoder.map(Kind.Int32, Kind.Int32); + for (let i = 0; i < int32MapFieldSize; i++) { + let key = decoder.int32(); + let val = decoder.int32(); + this.int32MapField.set(key, val); + } + this.int32MapFieldEmbedded = new Map(); + let int32MapFieldEmbeddedSize = decoder.map(Kind.Int32, Kind.Any); + for (let i = 0; i < int32MapFieldEmbeddedSize; i++) { + let key = decoder.int32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int32MapFieldEmbedded.set(key, val); + } + } + this.int64Field = decoder.int64(); + const int64ArrayFieldSize = decoder.array(Kind.Int64); + this.int64ArrayField = new Array(int64ArrayFieldSize); + for (let i = 0; i < int64ArrayFieldSize; i += 1) { + this.int64ArrayField[i] = decoder.int64(); + } + this.int64MapField = new Map(); + let int64MapFieldSize = decoder.map(Kind.Int64, Kind.Int64); + for (let i = 0; i < int64MapFieldSize; i++) { + let key = decoder.int64(); + let val = decoder.int64(); + this.int64MapField.set(key, val); + } + this.int64MapFieldEmbedded = new Map(); + let int64MapFieldEmbeddedSize = decoder.map(Kind.Int64, Kind.Any); + for (let i = 0; i < int64MapFieldEmbeddedSize; i++) { + let key = decoder.int64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.int64MapFieldEmbedded.set(key, val); + } + } + this.uint32Field = decoder.uint32(); + const uint32ArrayFieldSize = decoder.array(Kind.Uint32); + this.uint32ArrayField = new Array(uint32ArrayFieldSize); + for (let i = 0; i < uint32ArrayFieldSize; i += 1) { + this.uint32ArrayField[i] = decoder.uint32(); + } + this.uint32MapField = new Map(); + let uint32MapFieldSize = decoder.map(Kind.Uint32, Kind.Uint32); + for (let i = 0; i < uint32MapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.uint32(); + this.uint32MapField.set(key, val); + } + this.uint32MapFieldEmbedded = new Map(); + let uint32MapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < uint32MapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint32MapFieldEmbedded.set(key, val); + } + } + this.uint64Field = decoder.uint64(); + const uint64ArrayFieldSize = decoder.array(Kind.Uint64); + this.uint64ArrayField = new Array(uint64ArrayFieldSize); + for (let i = 0; i < uint64ArrayFieldSize; i += 1) { + this.uint64ArrayField[i] = decoder.uint64(); + } + this.uint64MapField = new Map(); + let uint64MapFieldSize = decoder.map(Kind.Uint64, Kind.Uint64); + for (let i = 0; i < uint64MapFieldSize; i++) { + let key = decoder.uint64(); + let val = decoder.uint64(); + this.uint64MapField.set(key, val); + } + this.uint64MapFieldEmbedded = new Map(); + let uint64MapFieldEmbeddedSize = decoder.map(Kind.Uint64, Kind.Any); + for (let i = 0; i < uint64MapFieldEmbeddedSize; i++) { + let key = decoder.uint64(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.uint64MapFieldEmbedded.set(key, val); + } + } + this.float32Field = decoder.float32(); + const float32ArrayFieldSize = decoder.array(Kind.Float32); + this.float32ArrayField = new Array(float32ArrayFieldSize); + for (let i = 0; i < float32ArrayFieldSize; i += 1) { + this.float32ArrayField[i] = decoder.float32(); + } + this.float64Field = decoder.float64(); + const float64ArrayFieldSize = decoder.array(Kind.Float64); + this.float64ArrayField = new Array(float64ArrayFieldSize); + for (let i = 0; i < float64ArrayFieldSize; i += 1) { + this.float64ArrayField[i] = decoder.float64(); + } + this.enumField = decoder.uint32(); + const enumArrayFieldSize = decoder.array(Kind.Uint32); + this.enumArrayField = new Array(enumArrayFieldSize); + for (let i = 0; i < enumArrayFieldSize; i += 1) { + this.enumArrayField[i] = decoder.uint32(); + } + this.enumMapField = new Map(); + let enumMapFieldSize = decoder.map(Kind.Uint32, Kind.String); + for (let i = 0; i < enumMapFieldSize; i++) { + let key = decoder.uint32(); + let val = decoder.string(); + this.enumMapField.set(key, val); + } + this.enumMapFieldEmbedded = new Map(); + let enumMapFieldEmbeddedSize = decoder.map(Kind.Uint32, Kind.Any); + for (let i = 0; i < enumMapFieldEmbeddedSize; i++) { + let key = decoder.uint32(); + let val = EmptyModel.decode(decoder); + if (typeof val !== "undefined") { + this.enumMapFieldEmbedded.set(key, val); + } + } + this.bytesField = decoder.uint8Array(); + const bytesArrayFieldSize = decoder.array(Kind.Uint8Array); + this.bytesArrayField = new Array(bytesArrayFieldSize); + for (let i = 0; i < bytesArrayFieldSize; i += 1) { + this.bytesArrayField[i] = decoder.uint8Array(); + } + this.boolField = decoder.boolean(); + const boolArrayFieldSize = decoder.array(Kind.Boolean); + this.boolArrayField = new Array(boolArrayFieldSize); + for (let i = 0; i < boolArrayFieldSize; i += 1) { + this.boolArrayField[i] = decoder.boolean(); + } + } else { + this.modelField = new EmptyModel(); + this.modelArrayField = []; + this.stringField = "DefaultValue"; + this.stringArrayField = []; + this.stringMapField = new Map(); + this.stringMapFieldEmbedded = new Map(); + this.int32Field = 32; + this.int32ArrayField = []; + this.int32MapField = new Map(); + this.int32MapFieldEmbedded = new Map(); + this.int64Field = 64n; + this.int64ArrayField = []; + this.int64MapField = new Map(); + this.int64MapFieldEmbedded = new Map(); + this.uint32Field = 32; + this.uint32ArrayField = []; + this.uint32MapField = new Map(); + this.uint32MapFieldEmbedded = new Map(); + this.uint64Field = 64n; + this.uint64ArrayField = []; + this.uint64MapField = new Map(); + this.uint64MapFieldEmbedded = new Map(); + this.float32Field = 32.32; + this.float32ArrayField = []; + this.float64Field = 64.64; + this.float64ArrayField = []; + this.enumField = GenericEnum.DefaultValue; + this.enumArrayField = []; + this.enumMapField = new Map(); + this.enumMapFieldEmbedded = new Map(); + this.bytesField = new Uint8Array(512); + this.bytesArrayField = []; + this.boolField = true; + this.boolArrayField = []; + } + } + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + if (typeof this.modelField === "undefined") { + encoder.null(); + } else { + this.modelField.encode(encoder); + } + const modelArrayFieldLength = this.modelArrayField.length; + encoder.array(modelArrayFieldLength, Kind.Any); + for (let i = 0; i < modelArrayFieldLength; i += 1) { + const el = this.modelArrayField[i]; + el.encode(encoder); + } + encoder.string(this.stringField); + const stringArrayFieldLength = this.stringArrayField.length; + encoder.array(stringArrayFieldLength, Kind.String); + for (let i = 0; i < stringArrayFieldLength; i += 1) { + encoder.string(this.stringArrayField[i]); + } + encoder.map(this.stringMapField.size, Kind.String, Kind.String); + this.stringMapField.forEach((val, key) => { + encoder.string(key); + encoder.string(val); + }); + encoder.map(this.stringMapFieldEmbedded.size, Kind.String, Kind.Any); + this.stringMapFieldEmbedded.forEach((val, key) => { + encoder.string(key); + val.encode(encoder); + }); + encoder.int32(this.int32Field); + const int32ArrayFieldLength = this.int32ArrayField.length; + encoder.array(int32ArrayFieldLength, Kind.Int32); + for (let i = 0; i < int32ArrayFieldLength; i += 1) { + encoder.int32(this.int32ArrayField[i]); + } + encoder.map(this.int32MapField.size, Kind.Int32, Kind.Int32); + this.int32MapField.forEach((val, key) => { + encoder.int32(key); + encoder.int32(val); + }); + encoder.map(this.int32MapFieldEmbedded.size, Kind.Int32, Kind.Any); + this.int32MapFieldEmbedded.forEach((val, key) => { + encoder.int32(key); + val.encode(encoder); + }); + encoder.int64(this.int64Field); + const int64ArrayFieldLength = this.int64ArrayField.length; + encoder.array(int64ArrayFieldLength, Kind.Int64); + for (let i = 0; i < int64ArrayFieldLength; i += 1) { + encoder.int64(this.int64ArrayField[i]); + } + encoder.map(this.int64MapField.size, Kind.Int64, Kind.Int64); + this.int64MapField.forEach((val, key) => { + encoder.int64(key); + encoder.int64(val); + }); + encoder.map(this.int64MapFieldEmbedded.size, Kind.Int64, Kind.Any); + this.int64MapFieldEmbedded.forEach((val, key) => { + encoder.int64(key); + val.encode(encoder); + }); + encoder.uint32(this.uint32Field); + const uint32ArrayFieldLength = this.uint32ArrayField.length; + encoder.array(uint32ArrayFieldLength, Kind.Uint32); + for (let i = 0; i < uint32ArrayFieldLength; i += 1) { + encoder.uint32(this.uint32ArrayField[i]); + } + encoder.map(this.uint32MapField.size, Kind.Uint32, Kind.Uint32); + this.uint32MapField.forEach((val, key) => { + encoder.uint32(key); + encoder.uint32(val); + }); + encoder.map(this.uint32MapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.uint32MapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint64(this.uint64Field); + const uint64ArrayFieldLength = this.uint64ArrayField.length; + encoder.array(uint64ArrayFieldLength, Kind.Uint64); + for (let i = 0; i < uint64ArrayFieldLength; i += 1) { + encoder.uint64(this.uint64ArrayField[i]); + } + encoder.map(this.uint64MapField.size, Kind.Uint64, Kind.Uint64); + this.uint64MapField.forEach((val, key) => { + encoder.uint64(key); + encoder.uint64(val); + }); + encoder.map(this.uint64MapFieldEmbedded.size, Kind.Uint64, Kind.Any); + this.uint64MapFieldEmbedded.forEach((val, key) => { + encoder.uint64(key); + val.encode(encoder); + }); + encoder.float32(this.float32Field); + const float32ArrayFieldLength = this.float32ArrayField.length; + encoder.array(float32ArrayFieldLength, Kind.Float32); + for (let i = 0; i < float32ArrayFieldLength; i += 1) { + encoder.float32(this.float32ArrayField[i]); + } + encoder.float64(this.float64Field); + const float64ArrayFieldLength = this.float64ArrayField.length; + encoder.array(float64ArrayFieldLength, Kind.Float64); + for (let i = 0; i < float64ArrayFieldLength; i += 1) { + encoder.float64(this.float64ArrayField[i]); + } + encoder.uint32(this.enumField); + const enumArrayFieldLength = this.enumArrayField.length; + encoder.array(enumArrayFieldLength, Kind.Uint32); + for (let i = 0; i < enumArrayFieldLength; i += 1) { + encoder.uint32(this.enumArrayField[i]); + } + encoder.map(this.enumMapField.size, Kind.Uint32, Kind.String); + this.enumMapField.forEach((val, key) => { + encoder.uint32(key); + encoder.string(val); + }); + encoder.map(this.enumMapFieldEmbedded.size, Kind.Uint32, Kind.Any); + this.enumMapFieldEmbedded.forEach((val, key) => { + encoder.uint32(key); + val.encode(encoder); + }); + encoder.uint8Array(this.bytesField); + const bytesArrayFieldLength = this.bytesArrayField.length; + encoder.array(bytesArrayFieldLength, Kind.Uint8Array); + for (let i = 0; i < bytesArrayFieldLength; i += 1) { + encoder.uint8Array(this.bytesArrayField[i]); + } + encoder.boolean(this.boolField); + const boolArrayFieldLength = this.boolArrayField.length; + encoder.array(boolArrayFieldLength, Kind.Boolean); + for (let i = 0; i < boolArrayFieldLength; i += 1) { + encoder.boolean(this.boolArrayField[i]); + } + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): ModelWithAllFieldTypes | undefined { + if (decoder.null()) { + return undefined + } + return new ModelWithAllFieldTypes(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } +} + diff --git a/signature/generator/typescript/generator.go b/signature/generator/typescript/generator.go new file mode 100644 index 00000000..c85cb685 --- /dev/null +++ b/signature/generator/typescript/generator.go @@ -0,0 +1,541 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package typescript + +import ( + "bytes" + "errors" + "fmt" + "strings" + "text/template" + + "github.com/evanw/esbuild/pkg/api" + polyglotVersion "github.com/loopholelabs/polyglot/version" + + interfacesVersion "github.com/loopholelabs/scale-signature-interfaces/version" + scaleVersion "github.com/loopholelabs/scale/version" + + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator/typescript/templates" + + "github.com/loopholelabs/scale/signature/generator/utils" +) + +const ( + defaultPackageName = "types" + tsConfig = ` +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "sourceMap": true, + "paths": { + "signature": ["./"] + }, + "types": ["node"] + }, +}` +) + +var generator *Generator + +type Transpiled struct { + Typescript []byte + Javascript []byte + SourceMap []byte + Declaration []byte +} + +// GenerateTypes generates the types for the signature +func GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + return generator.GenerateTypes(signatureSchema, packageName) +} + +// GenerateTypesTranspiled generates the types for the signature and transpiles it to javascript +func GenerateTypesTranspiled(signatureSchema *signature.Schema, packageName string, sourceName string) (*Transpiled, error) { + typescriptSource, err := generator.GenerateTypes(signatureSchema, packageName) + if err != nil { + return nil, err + } + return generator.GenerateTypesTranspiled(signatureSchema, packageName, sourceName, string(typescriptSource)) +} + +// GeneratePackageJSON generates the package.json file for the signature +func GeneratePackageJSON(packageName string, packageVersion string) ([]byte, error) { + return generator.GeneratePackageJSON(packageName, packageVersion) +} + +// GenerateGuest generates the guest bindings for the signature +func GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + return generator.GenerateGuest(signatureSchema, signatureHash, packageName) +} + +// GenerateGuestTranspiled generates the guest bindings and transpiles it to javascript +func GenerateGuestTranspiled(signatureSchema *signature.Schema, signatureHash string, packageName string, sourceName string) (*Transpiled, error) { + typescriptSource, err := generator.GenerateGuest(signatureSchema, signatureHash, packageName) + if err != nil { + return nil, err + } + return generator.GenerateGuestTranspiled(signatureSchema, packageName, sourceName, string(typescriptSource)) +} + +// GenerateHost generates the host bindings for the signature +// +// Note: the given schema should already be normalized, validated, and modified to have its accessors and validators disabled +func GenerateHost(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + return generator.GenerateHost(signatureSchema, signatureHash, packageName) +} + +// GenerateHostTranspiled generates the host bindings and transpiles it to javascript +// +// Note: the given schema should already be normalized, validated, and modified to have its accessors and validators disabled +func GenerateHostTranspiled(signatureSchema *signature.Schema, signatureHash string, packageName string, sourceName string) (*Transpiled, error) { + typescriptSource, err := generator.GenerateHost(signatureSchema, signatureHash, packageName) + if err != nil { + return nil, err + } + return generator.GenerateHostTranspiled(signatureSchema, packageName, sourceName, string(typescriptSource)) +} + +func init() { + var err error + generator, err = New() + if err != nil { + panic(err) + } +} + +// Generator is the typescript generator +type Generator struct { + templ *template.Template +} + +// New creates a new typescript generator +func New() (*Generator, error) { + templ, err := template.New("").Funcs(templateFunctions()).ParseFS(templates.FS, "*.ts.templ") + if err != nil { + return nil, err + } + + return &Generator{ + templ: templ, + }, nil +} + +// GenerateTypes generates the types for the signature +// +// This is not transpiled to javascript and does not include source maps or type definitions +func (g *Generator) GenerateTypes(signatureSchema *signature.Schema, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "types.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return []byte(formatTS(buf.String())), nil +} + +// GenerateTypesTranspiled takes the typescript source for the generated types and transpiles it to javascript +func (g *Generator) GenerateTypesTranspiled(signatureSchema *signature.Schema, packageName string, sourceName string, typescriptSource string) (*Transpiled, error) { + result := api.Transform(typescriptSource, api.TransformOptions{ + Loader: api.LoaderTS, + Format: api.FormatCommonJS, + Sourcemap: api.SourceMapExternal, + SourceRoot: sourceName, + TsconfigRaw: tsConfig, + }) + + if len(result.Errors) > 0 { + var errString strings.Builder + for _, err := range result.Errors { + errString.WriteString(err.Text) + errString.WriteRune('\n') + } + return nil, errors.New(errString.String()) + } + if packageName == "" { + packageName = defaultPackageName + } + + headerBuf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(headerBuf, "header.ts.templ", map[string]any{ + "generator_version": strings.Trim(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + declarationBuf := new(bytes.Buffer) + err = g.templ.ExecuteTemplate(declarationBuf, "declaration.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return &Transpiled{ + Typescript: []byte(typescriptSource), + Javascript: append(append([]byte(headerBuf.String()+"\n\n"), result.Code...), []byte(fmt.Sprintf("//# sourceMappingURL=%s.map", sourceName))...), + SourceMap: result.Map, + Declaration: []byte(formatTS(declarationBuf.String())), + }, nil +} + +// GeneratePackageJSON generates the package.json file for the signature +func (g *Generator) GeneratePackageJSON(packageName string, packageVersion string) ([]byte, error) { + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "package.ts.templ", map[string]any{ + "polyglot_version": strings.TrimPrefix(polyglotVersion.Version(), "v"), + "scale_signature_interfaces_version": strings.TrimPrefix(interfacesVersion.Version(), "v"), + "package_name": packageName, + "package_version": strings.TrimPrefix(packageVersion, "v"), + }) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +} + +// GenerateGuest generates the guest bindings for the signature +func (g *Generator) GenerateGuest(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "guest.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "signature_hash": signatureHash, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return []byte(formatTS(buf.String())), nil +} + +// GenerateGuestTranspiled takes the typescript source for the generated guest bindings and transpiles it to javascript +func (g *Generator) GenerateGuestTranspiled(signatureSchema *signature.Schema, packageName string, sourceName string, typescriptSource string) (*Transpiled, error) { + result := api.Transform(typescriptSource, api.TransformOptions{ + Loader: api.LoaderTS, + Format: api.FormatCommonJS, + Sourcemap: api.SourceMapExternal, + SourceRoot: sourceName, + TsconfigRaw: tsConfig, + }) + + if len(result.Errors) > 0 { + var errString strings.Builder + for _, err := range result.Errors { + errString.WriteString(err.Text) + errString.WriteRune('\n') + } + return nil, errors.New(errString.String()) + } + if packageName == "" { + packageName = defaultPackageName + } + + headerBuf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(headerBuf, "header.ts.templ", map[string]any{ + "generator_version": strings.Trim(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + declarationBuf := new(bytes.Buffer) + err = g.templ.ExecuteTemplate(declarationBuf, "declaration-guest.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return &Transpiled{ + Typescript: []byte(typescriptSource), + Javascript: append(append([]byte(headerBuf.String()+"\n\n"), result.Code...), []byte(fmt.Sprintf("//# sourceMappingURL=%s.map", sourceName))...), + SourceMap: result.Map, + Declaration: []byte(formatTS(declarationBuf.String())), + }, nil +} + +// GenerateHost generates the host bindings for the signature +// +// Note: the given schema should already be normalized, validated, and modified to have its accessors and validators disabled +func (g *Generator) GenerateHost(signatureSchema *signature.Schema, signatureHash string, packageName string) ([]byte, error) { + if packageName == "" { + packageName = defaultPackageName + } + + buf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(buf, "host.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "signature_hash": signatureHash, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return []byte(formatTS(buf.String())), nil +} + +// GenerateHostTranspiled takes the typescript source for the generated host bindings and transpiles it to javascript +// +// Note: the given schema should already be normalized, validated, and modified to have its accessors and validators disabled +func (g *Generator) GenerateHostTranspiled(signatureSchema *signature.Schema, packageName string, sourceName string, typescriptSource string) (*Transpiled, error) { + result := api.Transform(typescriptSource, api.TransformOptions{ + Loader: api.LoaderTS, + Format: api.FormatCommonJS, + Sourcemap: api.SourceMapExternal, + SourceRoot: sourceName, + TsconfigRaw: tsConfig, + }) + + if len(result.Errors) > 0 { + var errString strings.Builder + for _, err := range result.Errors { + errString.WriteString(err.Text) + errString.WriteRune('\n') + } + return nil, errors.New(errString.String()) + } + if packageName == "" { + packageName = defaultPackageName + } + + headerBuf := new(bytes.Buffer) + err := g.templ.ExecuteTemplate(headerBuf, "header.ts.templ", map[string]any{ + "generator_version": strings.Trim(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + declarationBuf := new(bytes.Buffer) + err = g.templ.ExecuteTemplate(declarationBuf, "declaration-host.ts.templ", map[string]any{ + "signature_schema": signatureSchema, + "generator_version": strings.TrimPrefix(scaleVersion.Version(), "v"), + "package_name": packageName, + }) + if err != nil { + return nil, err + } + + return &Transpiled{ + Typescript: []byte(typescriptSource), + Javascript: append(append([]byte(headerBuf.String()+"\n\n"), result.Code...), []byte(fmt.Sprintf("//# sourceMappingURL=%s.map", sourceName))...), + SourceMap: result.Map, + Declaration: []byte(formatTS(declarationBuf.String())), + }, nil +} + +func templateFunctions() template.FuncMap { + return template.FuncMap{ + "Primitive": primitive, + "IsPrimitive": signature.ValidPrimitiveType, + "PolyglotPrimitive": polyglotPrimitive, + "PolyglotPrimitiveEncode": polyglotPrimitiveEncode, + "PolyglotPrimitiveDecode": polyglotPrimitiveDecode, + "Deref": func(i *bool) bool { return *i }, + "CamelCase": utils.CamelCase, + "Params": utils.Params, + "Constructor": constructor, + } +} + +func primitive(t string) string { + switch t { + case "string": + return "string" + case "int32": + return "number" + case "int64": + return "bigint" + case "uint32": + return "number" + case "uint64": + return "bigint" + case "float32": + return "number" + case "float64": + return "number" + case "bool": + return "boolean" + case "bytes": + return "Uint8Array" + default: + return t + } +} + +func constructor(t string) string { + switch t { + case "string": + return "String" + case "int32": + return "Number" + case "int64": + return "BigInt" + case "uint32": + return "Number" + case "uint64": + return "BigInt" + case "float32": + return "Number" + case "float64": + return "Number" + case "bool": + return "Boolean" + case "bytes": + return "Uint8Array" + default: + return t + } +} + +func polyglotPrimitive(t string) string { + switch t { + case "string": + return "Kind.String" + case "int32": + return "Kind.Int32" + case "int64": + return "Kind.Int64" + case "uint32": + return "Kind.Uint32" + case "uint64": + return "Kind.Uint64" + case "float32": + return "Kind.Float32" + case "float64": + return "Kind.Float64" + case "bool": + return "Kind.Boolean" + case "bytes": + return "Kind.Uint8Array" + default: + return "Kind.Any" + } +} + +func polyglotPrimitiveEncode(t string) string { + switch t { + case "string": + return "string" + case "int32": + return "int32" + case "int64": + return "int64" + case "uint32": + return "uint32" + case "uint64": + return "uint64" + case "float32": + return "float32" + case "float64": + return "float64" + case "bool": + return "boolean" + case "bytes": + return "uint8Array" + default: + return t + } +} + +func polyglotPrimitiveDecode(t string) string { + switch t { + case "string": + return "string" + case "int32": + return "int32" + case "int64": + return "int64" + case "uint32": + return "uint32" + case "uint64": + return "uint64" + case "float32": + return "float32" + case "float64": + return "float64" + case "bool": + return "boolean" + case "bytes": + return "uint8Array" + default: + return "" + } +} + +//nolint:revive +func formatTS(code string) string { + var output strings.Builder + indentLevel := 0 + lastLineEmpty := false + lastLineOpenBrace := false + for _, line := range strings.Split(code, "\n") { + trimmedLine := strings.TrimSpace(line) + if trimmedLine == "" { + // Allow empty lines between classes and class members, but only 1 empty line not more. + if indentLevel > 1 || lastLineEmpty || lastLineOpenBrace { + continue + } else { + output.WriteRune('\n') + } + lastLineEmpty = true + } else { + if strings.HasPrefix(trimmedLine, "}") { + indentLevel-- + } + output.WriteString(strings.Repeat(" ", indentLevel)) + output.WriteString(trimmedLine) + if strings.HasSuffix(trimmedLine, "{") { + lastLineOpenBrace = true + indentLevel++ + } else { + lastLineOpenBrace = false + } + output.WriteRune('\n') + lastLineEmpty = false + } + } + return output.String() +} diff --git a/signature/generator/typescript/generator_test.go b/signature/generator/typescript/generator_test.go new file mode 100644 index 00000000..6bab3c99 --- /dev/null +++ b/signature/generator/typescript/generator_test.go @@ -0,0 +1,43 @@ +//go:build !integration && !generate + +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package typescript + +import ( + "os" + "testing" + + "github.com/loopholelabs/scale/signature" + + "github.com/stretchr/testify/require" +) + +func TestGenerator(t *testing.T) { + s := new(signature.Schema) + err := s.Decode([]byte(signature.MasterTestingSchema)) + require.NoError(t, err) + + formatted, err := GenerateTypes(s, "types") + require.NoError(t, err) + + // os.WriteFile("./generated.txt", formatted, 0644) + + master, err := os.ReadFile("./generated.txt") + require.NoError(t, err) + require.Equal(t, string(master), string(formatted)) + + t.Log(string(formatted)) + +} diff --git a/signature/generator/typescript/templates/arrays.ts.templ b/signature/generator/typescript/templates/arrays.ts.templ new file mode 100644 index 00000000..7bb2126d --- /dev/null +++ b/signature/generator/typescript/templates/arrays.ts.templ @@ -0,0 +1,63 @@ +{{ define "ts_arrays_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + #{{ CamelCase .Name }}: {{ Primitive $type }}; + {{- else }} + {{ CamelCase .Name }}: {{ Primitive $type }}[]; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_arrays_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = []; + {{- else }} + this.{{ CamelCase .Name }} = []; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_arrays_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + const {{ CamelCase .Name }}Length = this.#{{ CamelCase .Name }}.length; + encoder.array({{ CamelCase .Name }}Length, {{ PolyglotPrimitive $type }}); + + for (let i = 0; i < {{ CamelCase .Name }}Length; i += 1) { + encoder.{{ PolyglotPrimitiveEncode $type }}(this.#{{ CamelCase .Name }}[i]); + } + {{- else }} + const {{ CamelCase .Name }}Length = this.{{ CamelCase .Name }}.length; + encoder.array({{ CamelCase .Name }}Length, {{ PolyglotPrimitive $type }}); + + for (let i = 0; i < {{ CamelCase .Name }}Length; i += 1) { + encoder.{{ PolyglotPrimitiveEncode $type }}(this.{{ CamelCase .Name }}[i]); + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_arrays_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + const {{ CamelCase .Name }}Size = decoder.array({{ PolyglotPrimitive $type }}); + this.#{{ CamelCase .Name }} = new Array({{ CamelCase .Name }}Size); + + for (let i = 0; i < {{ CamelCase .Name }}Size; i += 1) { + this.#{{ CamelCase .Name }}[i] = decoder.{{ PolyglotPrimitiveDecode $type }}(); + } + {{- else }} + const {{ CamelCase .Name }}Size = decoder.array({{ PolyglotPrimitive $type }}); + this.{{ CamelCase .Name }} = new Array({{ CamelCase .Name }}Size); + + for (let i = 0; i < {{ CamelCase .Name }}Size; i += 1) { + this.{{ CamelCase .Name }}[i] = decoder.{{ PolyglotPrimitiveDecode $type }}(); + } + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/declaration-guest.ts.templ b/signature/generator/typescript/templates/declaration-guest.ts.templ new file mode 100644 index 00000000..4a828f33 --- /dev/null +++ b/signature/generator/typescript/templates/declaration-guest.ts.templ @@ -0,0 +1,33 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +export * from "./types"; +import { {{ .signature_schema.Context }} } from "./types"; + +// Write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +export declare function Write(ctx?: {{ .signature_schema.Context }}): number[]; + +// Read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +export declare function Read(): {{ .signature_schema.Context }} | undefined; + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +export declare function Error(err: Error): number[]; + +// Resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +export declare function Resize(size: number): number; + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +export declare function Hash(): number[]; + +// Next calls the next function in the Scale Function Chain +export declare function Next(ctx?: {{ .signature_schema.Context }}): {{ .signature_schema.Context }} | undefined; \ No newline at end of file diff --git a/signature/generator/typescript/templates/declaration-host.ts.templ b/signature/generator/typescript/templates/declaration-host.ts.templ new file mode 100644 index 00000000..33ae2592 --- /dev/null +++ b/signature/generator/typescript/templates/declaration-host.ts.templ @@ -0,0 +1,42 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +import { Signature as SignatureInterface } from "@loopholelabs/scale-signature-interfaces"; + +export * from "./types"; +import { {{ .signature_schema.Context }} } from "./types"; + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +export declare function New(); + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +export declare class Signature implements SignatureInterface { + public context: {{ .signature_schema.Context }}; + + constructor(); + + // Read reads the context from the given Uint8Array and returns an error if one occurred + // + // This method is meant to be used by the Scale Runtime to deserialize the Signature + Read(b: Uint8Array): Error | undefined; + + // Write writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to serialize the Signature + Write(): Uint8Array; + + // Error writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to return an error + Error(err: Error): Uint8Array; + + // Hash returns the hash of the signature + // + // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility + Hash(): string; +} \ No newline at end of file diff --git a/signature/generator/typescript/templates/declaration.ts.templ b/signature/generator/typescript/templates/declaration.ts.templ new file mode 100644 index 00000000..11a9d2ae --- /dev/null +++ b/signature/generator/typescript/templates/declaration.ts.templ @@ -0,0 +1,93 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +{{ range .signature_schema.Enums }} + export declare enum {{ .Name }} { + {{- range $index, $value := .Values }} + {{ $value }} = {{ $index }}, + {{ end }} + } +{{- end }} +{{- $allEnums := .signature_schema.Enums }} + +{{- range .signature_schema.Models -}} + {{- if .Description }} + // {{ .Name }}: {{ .Description }} + {{ end -}} + + export declare class {{ .Name }} { + {{ template "ts_models_struct_reference" . }} + {{ template "ts_modelarrays_struct_reference" . }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Strings "Type" "string" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "ts_maps_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Int32s "Type" "int32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Int64s "Type" "int64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Float32s "Type" "float32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Float64s "Type" "float64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "ts_enums_struct_reference" . }} + {{ template "ts_enumarrays_struct_reference" . }} + {{ template "ts_enummaps_struct_reference" . }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Bools "Type" "bool" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder); + + {{ template "ts_strings_accessor_declaration" Params "Model" . "Entries" .Strings "Type" "string" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Int32s "Type" "int32" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Int64s "Type" "int64" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Float32s "Type" "float32" }} + {{ template "ts_numbers_accessor_declaration" Params "Model" . "Entries" .Float64s "Type" "float32" }} + + {{ template "ts_models_accessor_declaration" . }} + {{ template "ts_modelarrays_accessor_declaration" . }} + {{ template "ts_enums_accessor_declaration" . }} + + /** + * @throws {Error} + */ + encode (encoder: Encoder); + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): {{ .Name }} | undefined; + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder); + } + +{{ end -}} \ No newline at end of file diff --git a/signature/generator/typescript/templates/enumarrays.ts.templ b/signature/generator/typescript/templates/enumarrays.ts.templ new file mode 100644 index 00000000..81d1ec6d --- /dev/null +++ b/signature/generator/typescript/templates/enumarrays.ts.templ @@ -0,0 +1,21 @@ +{{ define "ts_enumarrays_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if (Deref .Accessor) }} + #{{ CamelCase .Name }}: {{ .Reference }}[]; + {{- else }} + {{ CamelCase .Name }}: {{ .Reference }}[]; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enumarrays_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumArrays }} + {{- if .Accessor }} + this.#{{ CamelCase .Name }} = []; + {{- else }} + this.{{ CamelCase .Name }} = []; + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/enummaps.ts.templ b/signature/generator/typescript/templates/enummaps.ts.templ new file mode 100644 index 00000000..c0a4a781 --- /dev/null +++ b/signature/generator/typescript/templates/enummaps.ts.templ @@ -0,0 +1,41 @@ +{{ define "ts_enummaps_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + #{{ CamelCase .Name }}: Map<{{ .Reference }}, {{ Primitive .Value }}>; + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + #{{ CamelCase .Name }}: Map<{{ .Reference }}, {{ .Value }}>; + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ CamelCase .Name }}: Map<{{ .Reference }}, {{ Primitive .Value }}>; + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ CamelCase .Name }}: Map<{{ .Reference }}, {{ .Value }}>; + {{- end }} + {{ end }} +{{ end }} + +{{ define "ts_enummaps_new_struct_reference" }} + {{ $current_model := . }} + {{- range .EnumMaps }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + this.#{{ CamelCase .Name }} = new Map<{{ .Reference }}, {{ Primitive .Value }}>(); + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + this.#{{ CamelCase .Name }} = new Map<{{ .Reference }}, {{ .Value }}>(); + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + this.{{ CamelCase .Name }} = new Map<{{ .Reference }}, {{ Primitive .Value }}>(); + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + this.{{ CamelCase .Name }} = new Map<{{ .Reference }}, {{ .Value }}>(); + {{- end }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/enums.ts.templ b/signature/generator/typescript/templates/enums.ts.templ new file mode 100644 index 00000000..dee1713c --- /dev/null +++ b/signature/generator/typescript/templates/enums.ts.templ @@ -0,0 +1,75 @@ +{{ define "ts_enums_definition" }} + export enum {{ .Name }} { + {{- range $index, $value := .Values }} + {{ $value }} = {{ $index }}, + {{ end }} + } +{{ end }} + +{{ define "ts_enums_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if (Deref .Accessor) }} + #{{ CamelCase .Name }}: {{ .Reference }}; + {{- else }} + {{ CamelCase .Name }}: {{ .Reference }}; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enums_new_struct_reference" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + this.#{{ CamelCase .Name }} = {{ .Reference }}.{{ .Default }}; + {{- else }} + this.{{ CamelCase .Name }} = {{ .Reference }}.{{ .Default }}; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enums_encode" }} + {{- range .Enums }} + {{- if (Deref .Accessor) }} + encoder.uint32(this.#{{ CamelCase .Name }}); + {{- else }} + encoder.uint32(this.{{ CamelCase .Name }}); + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enums_decode" }} + {{- range .Model.Enums }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = decoder.uint32(); + {{- else }} + this.{{ CamelCase .Name }} = decoder.uint32(); + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enums_accessor" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): {{ .Reference }} { + return this.#{{ CamelCase .Name }}; + } + + set {{ CamelCase .Name }}(val: {{ .Reference }}) { + this.#{{ CamelCase .Name }} = val; + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_enums_accessor_declaration" }} + {{ $current_model := . }} + {{- range .Enums }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): {{ .Reference }}; + + set {{ CamelCase .Name }}(val: {{ .Reference }}); + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/guest.ts.templ b/signature/generator/typescript/templates/guest.ts.templ new file mode 100644 index 00000000..a1932ce3 --- /dev/null +++ b/signature/generator/typescript/templates/guest.ts.templ @@ -0,0 +1,83 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +/* eslint no-bitwise: off */ + +import { Signature as SignatureInterface, TYPESCRIPT_ADDRESS_OF, TYPESCRIPT_NEXT} from "@loopholelabs/scale-signature-interfaces"; +import { Decoder, Encoder, Kind } from "@loopholelabs/polyglot"; + +(global as any).WRITE_BUFFER = new Uint8Array().buffer; +(global as any).READ_BUFFER = new Uint8Array().buffer; + +export * from "./types"; +import { {{ .signature_schema.Context }} } from "./types"; + +const hash = "{{ .signature_hash }}" + +// Write serializes the signature into the global WRITE_BUFFER and returns the pointer to the buffer and its size +// +// Users should not use this method. +export function Write(ctx?: {{ .signature_schema.Context }}): number[] { + const enc = new Encoder(); + if (typeof ctx === "undefined") { + enc.null(); + } else { + ctx.encode(enc); + } + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Read deserializes signature from the global READ_BUFFER +// +// Users should not use this method. +export function Read(): {{ .signature_schema.Context }} | undefined { + const dec = new Decoder(new Uint8Array((global as any).READ_BUFFER)); + return {{ .signature_schema.Context }}.decode(dec); +} + +// Error serializes an error into the global writeBuffer and returns a pointer to the buffer and its size +// +// Users should not use this method. +export function Error(err: Error): number[] { + const enc = new Encoder(); + enc.error(err); + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Resize resizes the global READ_BUFFER to the given size and returns the pointer to the buffer +// +// Users should not use this method. +export function Resize(size: number): number { + (global as any).READ_BUFFER = new Uint8Array(size).buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + return addrof((global as any).READ_BUFFER); +} + +// Hash returns the hash of the Scale Signature +// +// Users should not use this method. +export function Hash(): number[] { + const enc = new Encoder(); + enc.string(hash); + const len = enc.bytes.buffer.byteLength; + (global as any).WRITE_BUFFER = enc.bytes.buffer; + const addrof = (global as any)[TYPESCRIPT_ADDRESS_OF]; + const ptr = addrof((global as any).WRITE_BUFFER); + return [ptr, len]; +} + +// Next calls the next function in the Scale Function Chain +export function Next(ctx?: {{ .signature_schema.Context }}): {{ .signature_schema.Context }} | undefined { + const [ptr, len] = Write(ctx); + const next = (global as any)[TYPESCRIPT_NEXT]; + next([ptr, len]); + return Read(); +} \ No newline at end of file diff --git a/signature/generator/typescript/templates/header.ts.templ b/signature/generator/typescript/templates/header.ts.templ new file mode 100644 index 00000000..6a9eabe3 --- /dev/null +++ b/signature/generator/typescript/templates/header.ts.templ @@ -0,0 +1,2 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/host.ts.templ b/signature/generator/typescript/templates/host.ts.templ new file mode 100644 index 00000000..10a668c3 --- /dev/null +++ b/signature/generator/typescript/templates/host.ts.templ @@ -0,0 +1,69 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +/* eslint no-bitwise: off */ + +import { Signature as SignatureInterface } from "@loopholelabs/scale-signature-interfaces"; +import { Decoder, Encoder, Kind } from "@loopholelabs/polyglot"; + +export * from "./types"; +import { {{ .signature_schema.Context }} } from "./types"; + +const hash = "{{ .signature_hash }}" + +// New returns a new signature and tells the Scale Runtime how to use it +// +// This function should be passed into the scale runtime config as an argument +export function New(): Signature { + return new Signature(); +} + +// Signature is the host representation of the signature +// +// Users should not use this type directly, but instead pass the New() function +// to the Scale Runtime +export class Signature implements SignatureInterface { + public context: {{ .signature_schema.Context }}; + + constructor() { + this.context = new {{ .signature_schema.Context }}(); + } + + // Read reads the context from the given Uint8Array and returns an error if one occurred + // + // This method is meant to be used by the Scale Runtime to deserialize the Signature + Read(b: Uint8Array): Error | undefined { + const dec = new Decoder(b); + try { + Object.assign(this.context, {{ .signature_schema.Context }}.decode(dec)); + } catch (err) { + return err as Error; + } + return undefined; + } + + // Write writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to serialize the Signature + Write(): Uint8Array { + const enc = new Encoder(); + this.context.encode(enc); + return enc.bytes; + } + + // Error writes the signature into a Uint8Array and returns it + // + // This method is meant to be used by the Scale Runtime to return an error + Error(err: Error): Uint8Array { + const enc = new Encoder(); + enc.error(err); + return enc.bytes; + } + + // Hash returns the hash of the signature + // + // This method is meant to be used by the Scale Runtime to validate Signature and Function compatibility + Hash(): string { + return hash; + } +} \ No newline at end of file diff --git a/signature/generator/typescript/templates/maps.ts.templ b/signature/generator/typescript/templates/maps.ts.templ new file mode 100644 index 00000000..1efbeb81 --- /dev/null +++ b/signature/generator/typescript/templates/maps.ts.templ @@ -0,0 +1,127 @@ +{{ define "ts_maps_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + #{{ CamelCase .Name }}: Map<{{ Primitive $type }}, {{ Primitive .Value }}>; + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + #{{ CamelCase .Name }}: Map<{{ Primitive $type }}, {{ .Value }}>; + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + {{ CamelCase .Name }}: Map<{{ Primitive $type }}, {{ Primitive .Value }}>; + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + {{ CamelCase .Name }}: Map<{{ Primitive $type }}, {{ .Value }}>; + {{- end }} + {{ end }} +{{ end }} + +{{ define "ts_maps_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + this.#{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ Primitive .Value }}>(); + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + this.#{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ .Value }}>(); + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + this.{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ Primitive .Value }}>(); + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + this.{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ .Value }}>(); + {{- end }} + {{ end }} +{{ end }} + +{{ define "ts_maps_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + encoder.map(this.#{{ CamelCase .Name }}.size, {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}); + this.#{{ CamelCase .Name }}.forEach((val, key) => { + encoder.{{ PolyglotPrimitiveEncode $type }}(key); + encoder.{{ PolyglotPrimitiveEncode .Value }}(val); + }); + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + encoder.map(this.#{{ CamelCase .Name }}.size, {{ PolyglotPrimitive $type }}, Kind.Any); + this.#{{ CamelCase .Name }}.forEach((val, key) => { + encoder.{{ PolyglotPrimitiveEncode $type }}(key); + val.encode(encoder); + }); + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + encoder.map(this.{{ CamelCase .Name }}.size, {{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}); + this.{{ CamelCase .Name }}.forEach((val, key) => { + encoder.{{ PolyglotPrimitiveEncode $type }}(key); + encoder.{{ PolyglotPrimitiveEncode .Value }}(val); + }); + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + encoder.map(this.{{ CamelCase .Name }}.size, {{ PolyglotPrimitive $type }}, Kind.Any); + this.{{ CamelCase .Name }}.forEach((val, key) => { + encoder.{{ PolyglotPrimitiveEncode $type }}(key); + val.encode(encoder); + }); + {{- end }} + {{ end }} +{{ end }} + +{{ define "ts_maps_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if and (Deref .Accessor) (IsPrimitive .Value) }} + this.#{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ Primitive .Value }}>(); + let {{ CamelCase .Name }}Size = decoder.map({{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}); + for (let i = 0; i < {{ CamelCase .Name }}Size; i++) { + let key = decoder.{{ PolyglotPrimitiveDecode $type }}(); + let val = decoder.{{ PolyglotPrimitiveDecode .Value }}(); + this.#{{ CamelCase .Name }}.set(key, val); + } + {{- end }} + + {{- if and (Deref .Accessor) (not (IsPrimitive .Value)) }} + this.#{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ .Value }}>(); + let {{ CamelCase .Name }}Size = decoder.map({{ PolyglotPrimitive $type }}, Kind.Any); + for (let i = 0; i < {{ CamelCase .Name }}Size; i++) { + let key = decoder.{{ PolyglotPrimitiveDecode $type }}(); + let val = {{ .Value }}.decode(decoder); + if (typeof val !== "undefined") { + this.#{{ CamelCase .Name }}.set(key, val); + } + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (IsPrimitive .Value) }} + this.{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ Primitive .Value }}>(); + let {{ CamelCase .Name }}Size = decoder.map({{ PolyglotPrimitive $type }}, {{ PolyglotPrimitive .Value }}); + for (let i = 0; i < {{ CamelCase .Name }}Size; i++) { + let key = decoder.{{ PolyglotPrimitiveDecode $type }}(); + let val = decoder.{{ PolyglotPrimitiveDecode .Value }}(); + this.{{ CamelCase .Name }}.set(key, val); + } + {{- end }} + + {{- if and (not (Deref .Accessor)) (not (IsPrimitive .Value)) }} + this.{{ CamelCase .Name }} = new Map<{{ Primitive $type }}, {{ .Value }}>(); + let {{ CamelCase .Name }}Size = decoder.map({{ PolyglotPrimitive $type }}, Kind.Any); + for (let i = 0; i < {{ CamelCase .Name }}Size; i++) { + let key = decoder.{{ PolyglotPrimitiveDecode $type }}(); + let val = {{ .Value }}.decode(decoder); + if (typeof val !== "undefined") { + this.{{ CamelCase .Name }}.set(key, val); + } + } + {{- end }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/modelarrays.ts.templ b/signature/generator/typescript/templates/modelarrays.ts.templ new file mode 100644 index 00000000..e42794c6 --- /dev/null +++ b/signature/generator/typescript/templates/modelarrays.ts.templ @@ -0,0 +1,91 @@ +{{ define "ts_modelarrays_struct_reference" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + #{{ CamelCase .Name }}: Array<{{ .Reference }}>; + {{- else }} + {{ CamelCase .Name }}: Array<{{ .Reference }}>; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_modelarrays_new_struct_reference" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + this.#{{ CamelCase .Name }} = []; + {{- else }} + this.{{ CamelCase .Name }} = []; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_modelarrays_encode" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + const {{ CamelCase .Name }}Length = this.#{{ CamelCase .Name }}.length; + encoder.array({{ CamelCase .Name }}Length, Kind.Any); + for (let i = 0; i < {{ CamelCase .Name }}Length; i += 1) { + const el = this.#{{ CamelCase .Name }}[i]; + el.encode(encoder); + } + {{- else }} + const {{ CamelCase .Name }}Length = this.{{ CamelCase .Name }}.length; + encoder.array({{ CamelCase .Name }}Length, Kind.Any); + for (let i = 0; i < {{ CamelCase .Name }}Length; i += 1) { + const el = this.{{ CamelCase .Name }}[i]; + el.encode(encoder); + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_modelarrays_decode" }} + {{- range .ModelArrays }} + {{- if .Accessor }} + const {{ CamelCase .Name }}Size = decoder.array(Kind.Any); + this.#{{ CamelCase .Name }} = new Array({{ CamelCase .Name }}Size); + + for (let i = 0; i < {{ CamelCase .Name }}Size; i += 1) { + const x = {{ .Reference }}.decode(decoder); + if (typeof x !== "undefined") { + this.#{{ CamelCase .Name }}[i] = x; + } + } + {{- else }} + const {{ CamelCase .Name }}Size = decoder.array(Kind.Any); + this.{{ CamelCase .Name }} = new Array({{ CamelCase .Name }}Size); + + for (let i = 0; i < {{ CamelCase .Name }}Size; i += 1) { + const x = {{ .Reference }}.decode(decoder); + if (typeof x !== "undefined") { + this.{{ CamelCase .Name }}[i] = x; + } + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_modelarrays_accessor" }} + {{ $current_model := . }} + {{- range .ModelArrays }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): Array<{{ .Reference }}> { + return this.#{{ CamelCase .Name }}; + } + + set {{.Name }}(val: Array<{{ .Reference }}>) { + this.#{{ CamelCase .Name }} = val; + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_modelarrays_accessor_declaration" }} + {{ $current_model := . }} + {{- range .ModelArrays }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): Array<{{ .Reference }}>; + + set {{.Name }}(val: Array<{{ .Reference }}>); + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/models.ts.templ b/signature/generator/typescript/templates/models.ts.templ new file mode 100644 index 00000000..aec02e0f --- /dev/null +++ b/signature/generator/typescript/templates/models.ts.templ @@ -0,0 +1,73 @@ +{{ define "ts_models_struct_reference" }} + {{- range .Models }} + {{- if .Accessor }} + #{{ CamelCase .Name }}: {{ .Reference }} | undefined; + {{- else }} + {{ CamelCase .Name }}: {{ .Reference }} | undefined; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_models_new_struct_reference" }} + {{- range .Models }} + {{- if .Accessor }} + this.#{{ CamelCase .Name }} = new {{ .Reference }}(); + {{- else }} + this.{{ CamelCase .Name }} = new {{ .Reference }}(); + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_models_encode" }} + {{- range .Models }} + {{- if .Accessor }} + if (typeof this.#{{ CamelCase .Name }} === "undefined") { + encoder.null(); + } else { + this.#{{ CamelCase .Name }}.encode(encoder); + } + {{- else }} + if (typeof this.{{ CamelCase .Name }} === "undefined") { + encoder.null(); + } else { + this.{{ CamelCase .Name }}.encode(encoder); + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_models_decode" }} + {{- range .Models }} + {{- if .Accessor }} + this.#{{ CamelCase .Name }} = {{ .Reference }}.decode(decoder); + {{- else }} + this.{{ CamelCase .Name }} = {{ .Reference }}.decode(decoder); + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_models_accessor" }} + {{ $current_model := . }} + {{- range .Models }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): {{ .Reference }} | undefined { + return this.#{{ CamelCase .Name }}; + } + + set {{ CamelCase .Name }}(val: {{ .Reference }} | undefined) { + this.#{{ CamelCase .Name }} = val; + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_models_accessor_declaration" }} + {{ $current_model := . }} + {{- range .Models }} + {{- if .Accessor }} + get {{ CamelCase .Name }}(): {{ .Reference }} | undefined; + + set {{ CamelCase .Name }}(val: {{ .Reference }} | undefined); + {{- end -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/typescript/templates/package.ts.templ b/signature/generator/typescript/templates/package.ts.templ new file mode 100644 index 00000000..f566744f --- /dev/null +++ b/signature/generator/typescript/templates/package.ts.templ @@ -0,0 +1,20 @@ +{ + "name": "{{ .package_name }}", + "version": "{{ .package_version }}", + "source": "index.ts", + "types": "index.d.ts", + "scripts": { + "test": "jest index.test.ts" + }, + "devDependencies": { + "@types/jest": "^29.5.2", + "jest": "^29.5.0", + "ts-jest": "^29.1.0", + "typescript": "^5.1.3", + "@types/node": "^20.3.1" + }, + "dependencies": { + "@loopholelabs/polyglot": "^{{ .polyglot_version }}", + "@loopholelabs/scale-signature-interfaces": "^{{ .scale_signature_interfaces_version }}" + } +} diff --git a/signature/generator/typescript/templates/primitives.ts.templ b/signature/generator/typescript/templates/primitives.ts.templ new file mode 100644 index 00000000..cbfc05c3 --- /dev/null +++ b/signature/generator/typescript/templates/primitives.ts.templ @@ -0,0 +1,137 @@ +{{ define "ts_primitives_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + #{{ CamelCase .Name }}: {{ Primitive $type }}; + {{- else }} + {{ CamelCase .Name }}: {{ Primitive $type }}; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_primitives_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = {{ .Default }}; + {{- else }} + this.{{ CamelCase .Name }} = {{ .Default }}; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_strings_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = "{{ .Default }}"; + {{- else }} + this.{{ CamelCase .Name }} = "{{ .Default }}"; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_bigint_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = {{ .Default }}n; + {{- else }} + this.{{ CamelCase .Name }} = {{ .Default }}n; + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_bytes_new_struct_reference" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = new Uint8Array({{ .InitialSize }}); + {{- else }} + this.{{ CamelCase .Name }} = new Uint8Array({{ .InitialSize }}); + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_primitives_encode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + encoder.{{ PolyglotPrimitiveEncode $type }}(this.#{{ CamelCase .Name }}); + {{- else }} + encoder.{{ PolyglotPrimitiveEncode $type }}(this.{{ CamelCase .Name }}); + {{- end -}} + {{ end }} +{{ end}} + +{{ define "ts_primitives_decode" }} + {{ $type := .Type }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + this.#{{ CamelCase .Name }} = decoder.{{ PolyglotPrimitiveDecode $type }}(); + {{- else }} + this.{{ CamelCase .Name }} = decoder.{{ PolyglotPrimitiveDecode $type }}(); + {{- end -}} + {{ end }} +{{ end}} + +{{ define "ts_numbers_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + get {{ CamelCase .Name }}(): {{ Primitive $type }} { + return this.#{{ CamelCase .Name }}; + } + + set {{ CamelCase .Name }} (val: {{ Primitive $type }}) { + {{- template "ts_numbers_limit_validator" .LimitValidator }} + this.#{{ CamelCase .Name }} = val; + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_numbers_accessor_declaration" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + get {{ CamelCase .Name }}(): {{ Primitive $type }}; + + set {{ CamelCase .Name }} (val: {{ Primitive $type }}); + {{- end -}} + {{ end }} +{{ end }} + + +{{ define "ts_strings_accessor" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + get {{ CamelCase .Name }}(): {{ Primitive $type }} { + return this.#{{ CamelCase .Name }}; + } + + set {{ CamelCase .Name }}(val: {{ Primitive $type}}) { + {{- template "ts_regex_validator" .RegexValidator }} + {{- template "ts_length_validator" .LengthValidator }} + {{- template "ts_case_modifier" .CaseModifier }} + this.#{{ CamelCase .Name }} = val; + } + {{- end -}} + {{ end }} +{{ end }} + +{{ define "ts_strings_accessor_declaration" }} + {{ $type := .Type }} + {{ $model := .Model }} + {{- range .Entries }} + {{- if (Deref .Accessor) }} + get {{ CamelCase .Name }}(): {{ Primitive $type }}; + + set {{ CamelCase .Name }}(val: {{ Primitive $type }}); + {{- end -}} + {{ end }} +{{ end }} diff --git a/signature/generator/typescript/templates/templates.go b/signature/generator/typescript/templates/templates.go new file mode 100644 index 00000000..fdfb581a --- /dev/null +++ b/signature/generator/typescript/templates/templates.go @@ -0,0 +1,19 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package templates + +import "embed" + +//go:embed * +var FS embed.FS diff --git a/signature/generator/typescript/templates/types.ts.templ b/signature/generator/typescript/templates/types.ts.templ new file mode 100644 index 00000000..1e7ee48c --- /dev/null +++ b/signature/generator/typescript/templates/types.ts.templ @@ -0,0 +1,225 @@ +// Code generated by scale-signature {{ .generator_version }}, DO NOT EDIT. +// output: {{ .package_name }} + +import { Encoder, Decoder, Kind } from "@loopholelabs/polyglot" + +{{ range .signature_schema.Enums }} + {{ template "ts_enums_definition" . }} +{{- end }} +{{- $allEnums := .signature_schema.Enums }} + +{{- range .signature_schema.Models -}} + {{- if .Description }} + // {{ .Name }}: {{ .Description }} + {{ end -}} + + export class {{ .Name }} { + {{ template "ts_models_struct_reference" . }} + {{ template "ts_modelarrays_struct_reference" . }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Strings "Type" "string" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "ts_maps_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Int32s "Type" "int32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Int64s "Type" "int64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "ts_maps_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Float32s "Type" "float32" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Float64s "Type" "float64" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "ts_enums_struct_reference" . }} + {{ template "ts_enumarrays_struct_reference" . }} + {{ template "ts_enummaps_struct_reference" . }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "ts_primitives_struct_reference" Params "Entries" .Bools "Type" "bool" }} + {{ template "ts_arrays_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + + + /** + * @throws {Error} + */ + constructor (decoder?: Decoder) { + if (decoder) { + let err: Error | undefined; + try { + err = decoder.error(); + } catch (_) {} + if (typeof err !== "undefined") { + throw err; + } + {{ template "ts_models_decode" . }} + {{ template "ts_modelarrays_decode" . }} + + {{ template "ts_primitives_decode" Params "Entries" .Strings "Type" "string" }} + {{ template "ts_arrays_decode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "ts_maps_decode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "ts_primitives_decode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "ts_arrays_decode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "ts_maps_decode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "ts_primitives_decode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "ts_arrays_decode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "ts_maps_decode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "ts_primitives_decode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_arrays_decode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "ts_maps_decode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "ts_primitives_decode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_arrays_decode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "ts_maps_decode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "ts_primitives_decode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "ts_arrays_decode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "ts_primitives_decode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "ts_arrays_decode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "ts_primitives_decode" Params "Entries" .Enums "Type" "uint32" }} + {{ template "ts_arrays_decode" Params "Entries" .EnumArrays "Type" "uint32" }} + {{ template "ts_maps_decode" Params "Entries" .EnumMaps "Type" "uint32" }} + + {{ template "ts_primitives_decode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "ts_arrays_decode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "ts_primitives_decode" Params "Entries" .Bools "Type" "bool" }} + {{ template "ts_arrays_decode" Params "Entries" .BoolArrays "Type" "bool" }} + } else { + {{ template "ts_models_new_struct_reference" . }} + {{ template "ts_modelarrays_new_struct_reference" . }} + + {{ template "ts_strings_new_struct_reference" Params "Entries" .Strings }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .StringArrays "Type" "string" }} + {{ template "ts_maps_new_struct_reference" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "ts_primitives_new_struct_reference" Params "Entries" .Int32s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "ts_maps_new_struct_reference" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "ts_bigint_new_struct_reference" Params "Entries" .Int64s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "ts_maps_new_struct_reference" Params "Entries" .Int64Maps "Type" "int64" }} + + + {{ template "ts_primitives_new_struct_reference" Params "Entries" .Uint32s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "ts_maps_new_struct_reference" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "ts_bigint_new_struct_reference" Params "Entries" .Uint64s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "ts_maps_new_struct_reference" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "ts_primitives_new_struct_reference" Params "Entries" .Float32s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "ts_primitives_new_struct_reference" Params "Entries" .Float64s }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "ts_enums_new_struct_reference" . }} + {{ template "ts_enumarrays_new_struct_reference" . }} + {{ template "ts_enummaps_new_struct_reference" . }} + + {{ template "ts_bytes_new_struct_reference" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "ts_primitives_new_struct_reference" Params "Entries" .Bools }} + {{ template "ts_arrays_new_struct_reference" Params "Entries" .BoolArrays "Type" "bool" }} + } + } + + {{ template "ts_strings_accessor" Params "Model" . "Entries" .Strings "Type" "string" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Int32s "Type" "int32" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Int64s "Type" "int64" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Float32s "Type" "float32" }} + {{ template "ts_numbers_accessor" Params "Model" . "Entries" .Float64s "Type" "float32" }} + + {{ template "ts_models_accessor" . }} + {{ template "ts_modelarrays_accessor" . }} + {{ template "ts_enums_accessor" . }} + + /** + * @throws {Error} + */ + encode (encoder: Encoder) { + {{ template "ts_models_encode" . }} + {{ template "ts_modelarrays_encode" . }} + + {{ template "ts_primitives_encode" Params "Entries" .Strings "Type" "string" }} + {{ template "ts_arrays_encode" Params "Entries" .StringArrays "Type" "string" }} + {{ template "ts_maps_encode" Params "Entries" .StringMaps "Type" "string" }} + + {{ template "ts_primitives_encode" Params "Entries" .Int32s "Type" "int32" }} + {{ template "ts_arrays_encode" Params "Entries" .Int32Arrays "Type" "int32" }} + {{ template "ts_maps_encode" Params "Entries" .Int32Maps "Type" "int32" }} + + {{ template "ts_primitives_encode" Params "Entries" .Int64s "Type" "int64" }} + {{ template "ts_arrays_encode" Params "Entries" .Int64Arrays "Type" "int64" }} + {{ template "ts_maps_encode" Params "Entries" .Int64Maps "Type" "int64" }} + + {{ template "ts_primitives_encode" Params "Entries" .Uint32s "Type" "uint32" }} + {{ template "ts_arrays_encode" Params "Entries" .Uint32Arrays "Type" "uint32" }} + {{ template "ts_maps_encode" Params "Entries" .Uint32Maps "Type" "uint32" }} + + {{ template "ts_primitives_encode" Params "Entries" .Uint64s "Type" "uint64" }} + {{ template "ts_arrays_encode" Params "Entries" .Uint64Arrays "Type" "uint64" }} + {{ template "ts_maps_encode" Params "Entries" .Uint64Maps "Type" "uint64" }} + + {{ template "ts_primitives_encode" Params "Entries" .Float32s "Type" "float32" }} + {{ template "ts_arrays_encode" Params "Entries" .Float32Arrays "Type" "float32" }} + + {{ template "ts_primitives_encode" Params "Entries" .Float64s "Type" "float64" }} + {{ template "ts_arrays_encode" Params "Entries" .Float64Arrays "Type" "float64" }} + + {{ template "ts_primitives_encode" Params "Entries" .Enums "Type" "uint32" }} + {{ template "ts_arrays_encode" Params "Entries" .EnumArrays "Type" "uint32" }} + {{ template "ts_maps_encode" Params "Entries" .EnumMaps "Type" "uint32" }} + + {{ template "ts_primitives_encode" Params "Entries" .Bytes "Type" "bytes" }} + {{ template "ts_arrays_encode" Params "Entries" .BytesArrays "Type" "bytes" }} + + {{ template "ts_primitives_encode" Params "Entries" .Bools "Type" "bool" }} + {{ template "ts_arrays_encode" Params "Entries" .BoolArrays "Type" "bool" }} + } + + /** + * @throws {Error} + */ + static decode (decoder: Decoder): {{ .Name }} | undefined { + if (decoder.null()) { + return undefined + } + + return new {{ .Name }}(decoder); + } + + /** + * @throws {Error} + */ + static encode_undefined (encoder: Encoder) { + encoder.null(); + } + } + +{{ end -}} \ No newline at end of file diff --git a/signature/generator/typescript/templates/validators.ts.templ b/signature/generator/typescript/templates/validators.ts.templ new file mode 100644 index 00000000..526374ed --- /dev/null +++ b/signature/generator/typescript/templates/validators.ts.templ @@ -0,0 +1,53 @@ +{{ define "ts_numbers_limit_validator" }} +{{- if . }} + {{- if and .Maximum .Minimum }} + if (val > {{ .Maximum }} || val < {{ .Minimum }}) { + throw new Error("value must be between {{ .Minimum }} and {{ .Maximum }}"); + } + {{- else if .Minimum }} + if (val < {{ .Minimum }}) { + throw new Error("value must be greater or equal to {{ .Minimum }}"); + } + {{- else if .Maximum }} + if (val > {{ .Maximum }}) { + throw new Error("value must be less than or equal to {{ .Maximum }}"); + } + {{- end }} +{{- end }} +{{ end }} + +{{ define "ts_regex_validator" }} + {{- if . }} + if (!/{{ .Expression }}/.test(val)) { + throw new Error("value must match {{ .Expression }}"); + } + {{- end }} +{{ end }} + +{{ define "ts_length_validator" }} + {{- if . }} + {{- if and .Maximum .Minimum }} + if (val.length > {{ .Maximum }} || val.length < {{ .Minimum }}) { + throw new Error("length must be between {{ .Minimum }} and {{ .Maximum }}"); + } + {{- else if .Minimum }} + if (val.length < {{ .Minimum }}) { + throw new Error("length must be greater than or equal to {{ .Minimum }}"); + } + {{- else if .Maximum }} + if (val.length > {{ .Maximum }}) { + throw new Error("length must be less than or equal to {{ .Maximum }}"); + } + {{- end }} + {{- end }} +{{ end }} + +{{ define "ts_case_modifier" }} + {{- if . }} + {{- if eq .Kind "upper" }} + val = val.toUpperCase(); + {{- else if eq .Kind "lower" }} + val = val.toLowerCase(); + {{- end }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/signature/generator/utils/utils.go b/signature/generator/utils/utils.go new file mode 100644 index 00000000..4b73d621 --- /dev/null +++ b/signature/generator/utils/utils.go @@ -0,0 +1,58 @@ +/* + Copyright 2023 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package utils + +import ( + "errors" + "unicode" +) + +// Params is a function that creates a map of parameters for use in go templates to pass multiple values +func Params(values ...interface{}) (map[string]interface{}, error) { + if len(values)%2 != 0 { + return nil, errors.New("parameters must be a list of key/value pairs") + } + params := make(map[string]interface{}, len(values)/2) + for i := 0; i < len(values); i += 2 { + key, ok := values[i].(string) + if !ok { + return nil, errors.New("keys must be strings") + } + params[key] = values[i+1] + } + return params, nil +} + +// CamelCase converts a PascalCase string to camelCase +func CamelCase(s string) string { + runes := []rune(s) + // Lowercase consecutive uppercase characters at the beginning of the string + for i := 0; i < len(runes)-1; i++ { + if unicode.IsUpper(runes[i]) && unicode.IsUpper(runes[i+1]) { + runes[i] = unicode.ToLower(runes[i]) + } else { + break + } + } + // Convert to camelCase + for i := 0; i < len(runes); i++ { + if unicode.IsUpper(runes[i]) { + if i > 0 { + return string(runes[:i]) + string(unicode.ToLower(runes[i])) + string(runes[i+1:]) + } + return string(unicode.ToLower(runes[i])) + string(runes[i+1:]) + } + } + return string(runes) +} diff --git a/signature/model.go b/signature/model.go new file mode 100644 index 00000000..b8e11478 --- /dev/null +++ b/signature/model.go @@ -0,0 +1,629 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "fmt" + "strings" +) + +type ModelSchema struct { + Name string `hcl:"name,label"` + Description string `hcl:"description,optional"` + + Models []*ModelReferenceSchema `hcl:"model,block"` + ModelArrays []*ModelReferenceArraySchema `hcl:"model_array,block"` + + Strings []*StringSchema `hcl:"string,block"` + StringArrays []*StringArraySchema `hcl:"string_array,block"` + StringMaps []*StringMapSchema `hcl:"string_map,block"` + + Bools []*BoolSchema `hcl:"bool,block"` + BoolArrays []*BoolArraySchema `hcl:"bool_array,block"` + + Bytes []*BytesSchema `hcl:"bytes,block"` + BytesArrays []*BytesArraySchema `hcl:"bytes_array,block"` + + Enums []*EnumReferenceSchema `hcl:"enum,block"` + EnumArrays []*EnumArraySchema `hcl:"enum_array,block"` + EnumMaps []*EnumMapSchema `hcl:"enum_map,block"` + + Int32s []*NumberSchema[int32] `hcl:"int32,block"` + Int32Arrays []*NumberArraySchema[int32] `hcl:"int32_array,block"` + Int32Maps []*NumberMapSchema[int32] `hcl:"int32_map,block"` + + Int64s []*NumberSchema[int64] `hcl:"int64,block"` + Int64Arrays []*NumberArraySchema[int64] `hcl:"int64_array,block"` + Int64Maps []*NumberMapSchema[int64] `hcl:"int64_map,block"` + + Uint32s []*NumberSchema[uint32] `hcl:"uint32,block"` + Uint32Arrays []*NumberArraySchema[uint32] `hcl:"uint32_array,block"` + Uint32Maps []*NumberMapSchema[uint32] `hcl:"uint32_map,block"` + + Uint64s []*NumberSchema[uint64] `hcl:"uint64,block"` + Uint64Arrays []*NumberArraySchema[uint64] `hcl:"uint64_array,block"` + Uint64Maps []*NumberMapSchema[uint64] `hcl:"uint64_map,block"` + + Float32s []*NumberSchema[float32] `hcl:"float32,block"` + Float32Arrays []*NumberArraySchema[float32] `hcl:"float32_array,block"` + + Float64s []*NumberSchema[float64] `hcl:"float64,block"` + Float64Arrays []*NumberArraySchema[float64] `hcl:"float64_array,block"` +} + +func (m *ModelSchema) Normalize() { + m.Name = TitleCaser.String(m.Name) + for _, modelReference := range m.Models { + modelReference.Name = TitleCaser.String(modelReference.Name) + modelReference.Reference = TitleCaser.String(modelReference.Reference) + } + + for _, modelReferenceArray := range m.ModelArrays { + modelReferenceArray.Name = TitleCaser.String(modelReferenceArray.Name) + modelReferenceArray.Reference = TitleCaser.String(modelReferenceArray.Reference) + } + + for _, enumReference := range m.Enums { + enumReference.Name = TitleCaser.String(enumReference.Name) + enumReference.Reference = TitleCaser.String(enumReference.Reference) + } + + for _, enumReferenceArray := range m.EnumArrays { + enumReferenceArray.Name = TitleCaser.String(enumReferenceArray.Name) + enumReferenceArray.Reference = TitleCaser.String(enumReferenceArray.Reference) + } + + for _, enumReferenceMap := range m.EnumMaps { + enumReferenceMap.Name = TitleCaser.String(enumReferenceMap.Name) + enumReferenceMap.Reference = TitleCaser.String(enumReferenceMap.Reference) + + if !ValidPrimitiveType(strings.ToLower(enumReferenceMap.Value)) { + enumReferenceMap.Value = TitleCaser.String(enumReferenceMap.Value) + } else { + enumReferenceMap.Value = strings.ToLower(enumReferenceMap.Value) + } + } + + for _, str := range m.Strings { + str.Name = TitleCaser.String(str.Name) + } + + for _, strArray := range m.StringArrays { + strArray.Name = TitleCaser.String(strArray.Name) + } + + for _, strMap := range m.StringMaps { + strMap.Name = TitleCaser.String(strMap.Name) + + if !ValidPrimitiveType(strings.ToLower(strMap.Value)) { + strMap.Value = TitleCaser.String(strMap.Value) + } else { + strMap.Value = strings.ToLower(strMap.Value) + } + } + + for _, i32 := range m.Int32s { + i32.Name = TitleCaser.String(i32.Name) + } + + for _, i32Array := range m.Int32Arrays { + i32Array.Name = TitleCaser.String(i32Array.Name) + } + + for _, i32Map := range m.Int32Maps { + i32Map.Name = TitleCaser.String(i32Map.Name) + + if !ValidPrimitiveType(strings.ToLower(i32Map.Value)) { + i32Map.Value = TitleCaser.String(i32Map.Value) + } else { + i32Map.Value = strings.ToLower(i32Map.Value) + } + } + + for _, i64 := range m.Int64s { + i64.Name = TitleCaser.String(i64.Name) + } + + for _, i64Array := range m.Int64Arrays { + i64Array.Name = TitleCaser.String(i64Array.Name) + } + + for _, i64Map := range m.Int64Maps { + i64Map.Name = TitleCaser.String(i64Map.Name) + + if !ValidPrimitiveType(strings.ToLower(i64Map.Value)) { + i64Map.Value = TitleCaser.String(i64Map.Value) + } else { + i64Map.Value = strings.ToLower(i64Map.Value) + } + } + + for _, u32 := range m.Uint32s { + u32.Name = TitleCaser.String(u32.Name) + } + + for _, u32Array := range m.Uint32Arrays { + u32Array.Name = TitleCaser.String(u32Array.Name) + } + + for _, u32Map := range m.Uint32Maps { + u32Map.Name = TitleCaser.String(u32Map.Name) + + if !ValidPrimitiveType(strings.ToLower(u32Map.Value)) { + u32Map.Value = TitleCaser.String(u32Map.Value) + } else { + u32Map.Value = strings.ToLower(u32Map.Value) + } + } + + for _, u64 := range m.Uint64s { + u64.Name = TitleCaser.String(u64.Name) + } + + for _, u64Array := range m.Uint64Arrays { + u64Array.Name = TitleCaser.String(u64Array.Name) + } + + for _, u64Map := range m.Uint64Maps { + u64Map.Name = TitleCaser.String(u64Map.Name) + + if !ValidPrimitiveType(strings.ToLower(u64Map.Value)) { + u64Map.Value = TitleCaser.String(u64Map.Value) + } else { + u64Map.Value = strings.ToLower(u64Map.Value) + } + } + + for _, f32 := range m.Float32s { + f32.Name = TitleCaser.String(f32.Name) + } + + for _, f32Array := range m.Float32Arrays { + f32Array.Name = TitleCaser.String(f32Array.Name) + } + + for _, f64 := range m.Float64s { + f64.Name = TitleCaser.String(f64.Name) + } + + for _, f64Array := range m.Float64Arrays { + f64Array.Name = TitleCaser.String(f64Array.Name) + } + + for _, b := range m.Bools { + b.Name = TitleCaser.String(b.Name) + } + + for _, bArray := range m.BoolArrays { + bArray.Name = TitleCaser.String(bArray.Name) + } + + for _, b := range m.Bytes { + b.Name = TitleCaser.String(b.Name) + } + + for _, bArray := range m.BytesArrays { + bArray.Name = TitleCaser.String(bArray.Name) + } + +} + +func (m *ModelSchema) Validate(knownModels map[string]struct{}, enums []*EnumSchema) error { + if !ValidLabel.MatchString(m.Name) { + return fmt.Errorf("invalid model name: %s", m.Name) + } + + if _, ok := knownModels[m.Name]; ok { + return fmt.Errorf("duplicate model name: %s", m.Name) + } + knownModels[m.Name] = struct{}{} + + knownFields := make(map[string]struct{}) + for _, modelReference := range m.Models { + err := modelReference.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[modelReference.Name]; ok { + return fmt.Errorf("duplicate %s.model name: %s", m.Name, modelReference.Name) + } + knownFields[modelReference.Name] = struct{}{} + } + + for _, modelReferenceArray := range m.ModelArrays { + err := modelReferenceArray.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[modelReferenceArray.Name]; ok { + return fmt.Errorf("duplicate %s.model_array name: %s", m.Name, modelReferenceArray.Name) + } + knownFields[modelReferenceArray.Name] = struct{}{} + } + + for _, str := range m.Strings { + err := str.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[str.Name]; ok { + return fmt.Errorf("duplicate %s.string name: %s", m.Name, str.Name) + } + knownFields[str.Name] = struct{}{} + } + + for _, strArray := range m.StringArrays { + err := strArray.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[strArray.Name]; ok { + return fmt.Errorf("duplicate %s.string_array name: %s", m.Name, strArray.Name) + } + knownFields[strArray.Name] = struct{}{} + } + + for _, strMap := range m.StringMaps { + err := strMap.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[strMap.Name]; ok { + return fmt.Errorf("duplicate %s.string_map name: %s", m.Name, strMap.Name) + } + knownFields[strMap.Name] = struct{}{} + } + + for _, i32 := range m.Int32s { + err := i32.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i32.Name]; ok { + return fmt.Errorf("duplicate %s.i32 name: %s", m.Name, i32.Name) + } + knownFields[i32.Name] = struct{}{} + } + + for _, i32Array := range m.Int32Arrays { + err := i32Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i32Array.Name]; ok { + return fmt.Errorf("duplicate %s.i32_array name: %s", m.Name, i32Array.Name) + } + knownFields[i32Array.Name] = struct{}{} + } + + for _, i32Map := range m.Int32Maps { + err := i32Map.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i32Map.Name]; ok { + return fmt.Errorf("duplicate %s.i32_map name: %s", m.Name, i32Map.Name) + } + knownFields[i32Map.Name] = struct{}{} + } + + for _, i64 := range m.Int64s { + err := i64.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i64.Name]; ok { + return fmt.Errorf("duplicate %s.i64 name: %s", m.Name, i64.Name) + } + knownFields[i64.Name] = struct{}{} + } + + for _, i64Array := range m.Int64Arrays { + err := i64Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i64Array.Name]; ok { + return fmt.Errorf("duplicate %s.i64_array name: %s", m.Name, i64Array.Name) + } + knownFields[i64Array.Name] = struct{}{} + } + + for _, i64Map := range m.Int64Maps { + err := i64Map.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[i64Map.Name]; ok { + return fmt.Errorf("duplicate %s.i64_map name: %s", m.Name, i64Map.Name) + } + knownFields[i64Map.Name] = struct{}{} + } + + for _, u32 := range m.Uint32s { + err := u32.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u32.Name]; ok { + return fmt.Errorf("duplicate %s.u32 name: %s", m.Name, u32.Name) + } + knownFields[u32.Name] = struct{}{} + } + + for _, u32Array := range m.Uint32Arrays { + err := u32Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u32Array.Name]; ok { + return fmt.Errorf("duplicate %s.u32_array name: %s", m.Name, u32Array.Name) + } + knownFields[u32Array.Name] = struct{}{} + } + + for _, u32Map := range m.Uint32Maps { + err := u32Map.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u32Map.Name]; ok { + return fmt.Errorf("duplicate %s.u32_map name: %s", m.Name, u32Map.Name) + } + knownFields[u32Map.Name] = struct{}{} + } + + for _, u64 := range m.Uint64s { + err := u64.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u64.Name]; ok { + return fmt.Errorf("duplicate %s.u64 name: %s", m.Name, u64.Name) + } + knownFields[u64.Name] = struct{}{} + } + + for _, u64Array := range m.Uint64Arrays { + err := u64Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u64Array.Name]; ok { + return fmt.Errorf("duplicate %s.u64_array name: %s", m.Name, u64Array.Name) + } + knownFields[u64Array.Name] = struct{}{} + } + + for _, u64Map := range m.Uint64Maps { + err := u64Map.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[u64Map.Name]; ok { + return fmt.Errorf("duplicate %s.u64_map name: %s", m.Name, u64Map.Name) + } + knownFields[u64Map.Name] = struct{}{} + } + + for _, f32 := range m.Float32s { + err := f32.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[f32.Name]; ok { + return fmt.Errorf("duplicate %s.f32 name: %s", m.Name, f32.Name) + } + knownFields[f32.Name] = struct{}{} + } + + for _, f32Array := range m.Float32Arrays { + err := f32Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[f32Array.Name]; ok { + return fmt.Errorf("duplicate %s.f32_array name: %s", m.Name, f32Array.Name) + } + knownFields[f32Array.Name] = struct{}{} + } + + for _, f64 := range m.Float64s { + err := f64.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[f64.Name]; ok { + return fmt.Errorf("duplicate %s.f64 name: %s", m.Name, f64.Name) + } + knownFields[f64.Name] = struct{}{} + } + + for _, f64Array := range m.Float64Arrays { + err := f64Array.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[f64Array.Name]; ok { + return fmt.Errorf("duplicate %s.f64_array name: %s", m.Name, f64Array.Name) + } + knownFields[f64Array.Name] = struct{}{} + } + + for _, b := range m.Bools { + err := b.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[b.Name]; ok { + return fmt.Errorf("duplicate %s.bool name: %s", m.Name, b.Name) + } + knownFields[b.Name] = struct{}{} + } + + for _, bArray := range m.BoolArrays { + err := bArray.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[bArray.Name]; ok { + return fmt.Errorf("duplicate %s.bool_array name: %s", m.Name, bArray.Name) + } + knownFields[bArray.Name] = struct{}{} + } + + for _, b := range m.Bytes { + err := b.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[b.Name]; ok { + return fmt.Errorf("duplicate %s.bytes name: %s", m.Name, b.Name) + } + knownFields[b.Name] = struct{}{} + } + + for _, bArray := range m.BytesArrays { + err := bArray.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[bArray.Name]; ok { + return fmt.Errorf("duplicate %s.bytes_array name: %s", m.Name, bArray.Name) + } + knownFields[bArray.Name] = struct{}{} + } + + for _, enum := range m.Enums { + err := enum.Validate(m, enums) + if err != nil { + return err + } + + if _, ok := knownFields[enum.Name]; ok { + return fmt.Errorf("duplicate %s.enum name: %s", m.Name, enum.Name) + } + knownFields[enum.Name] = struct{}{} + } + + for _, enumArray := range m.EnumArrays { + err := enumArray.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[enumArray.Name]; ok { + return fmt.Errorf("duplicate %s.enum_array name: %s", m.Name, enumArray.Name) + } + knownFields[enumArray.Name] = struct{}{} + } + + for _, enumMap := range m.EnumMaps { + err := enumMap.Validate(m) + if err != nil { + return err + } + + if _, ok := knownFields[enumMap.Name]; ok { + return fmt.Errorf("duplicate %s.enum_map name: %s", m.Name, enumMap.Name) + } + knownFields[enumMap.Name] = struct{}{} + } + + return nil +} + +type ModelReferenceSchema struct { + Name string `hcl:"name,label"` + Reference string `hcl:"reference,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (m *ModelReferenceSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(m.Name) { + return fmt.Errorf("invalid %s.model name: %s", model.Name, m.Name) + } + + if !ValidLabel.MatchString(m.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, m.Name, m.Reference) + } + + return nil +} + +type ModelReferenceArraySchema struct { + Name string `hcl:"name,label"` + Reference string `hcl:"reference,attr"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (m *ModelReferenceArraySchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(m.Name) { + return fmt.Errorf("invalid %s.model name: %s", model.Name, m.Name) + } + + if !ValidLabel.MatchString(m.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, m.Name, m.Reference) + } + + return nil +} + +type ModelReferenceMapSchema struct { + Name string `hcl:"name,label"` + Reference string `hcl:"reference,attr"` + Value string `hcl:"value,attr"` + Accessor bool `hcl:"accessor,optional"` +} + +func (m *ModelReferenceMapSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(m.Name) { + return fmt.Errorf("invalid %s.model name: %s", model.Name, m.Name) + } + + if !ValidLabel.MatchString(m.Reference) { + return fmt.Errorf("invalid %s.%s.reference: %s", model.Name, m.Name, m.Reference) + } + + return nil +} diff --git a/signature/numbers.go b/signature/numbers.go new file mode 100644 index 00000000..d5f28272 --- /dev/null +++ b/signature/numbers.go @@ -0,0 +1,145 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import "fmt" + +type Number interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 +} + +type NumberLimitValidatorSchema[T Number] struct { + Maximum *T `hcl:"max,optional"` + Minimum *T `hcl:"min,optional"` +} + +type NumberSchema[T Number] struct { + Name string `hcl:"name,label"` + Default T `hcl:"default,attr"` + Accessor *bool `hcl:"accessor,optional"` + LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` +} + +func (s *NumberSchema[T]) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.%T name: %s", model.Name, *new(T), s.Name) + } + + if s.LimitValidator != nil { + if s.LimitValidator.Maximum != nil { + if s.LimitValidator.Minimum != nil { + if *s.LimitValidator.Minimum > *s.LimitValidator.Maximum { + return fmt.Errorf("invalid %s.%s.limit_validator: minimum cannot be greater than maximum", model.Name, s.Name) + } + } + } + } + + if s.Accessor != nil { + if !*s.Accessor && s.LimitValidator != nil { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LimitValidator != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} + +type NumberArraySchema[T Number] struct { + Name string `hcl:"name,label"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor *bool `hcl:"accessor,optional"` + LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` +} + +func (s *NumberArraySchema[T]) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.%T_array name: %s", model.Name, *new(T), s.Name) + } + + if s.LimitValidator != nil { + if s.LimitValidator.Maximum != nil { + if s.LimitValidator.Minimum != nil { + if *s.LimitValidator.Minimum > *s.LimitValidator.Maximum { + return fmt.Errorf("invalid %s.%s.limit_validator: minimum cannot be greater than maximum", model.Name, s.Name) + } + } + } + } + + if s.Accessor != nil { + if !*s.Accessor && s.LimitValidator != nil { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LimitValidator != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} + +type NumberMapSchema[T Number] struct { + Name string `hcl:"name,label"` + Value string `hcl:"value,attr"` + Accessor *bool `hcl:"accessor,optional"` + LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` +} + +func (s *NumberMapSchema[T]) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.%T_map name: %s", model.Name, *new(T), s.Name) + } + + if s.LimitValidator != nil { + if s.LimitValidator.Maximum != nil { + if s.LimitValidator.Minimum != nil { + if *s.LimitValidator.Minimum > *s.LimitValidator.Maximum { + return fmt.Errorf("invalid %s.%s.limit_validator: minimum cannot be greater than maximum", model.Name, s.Name) + } + } + } + } + + if s.Accessor != nil { + if !*s.Accessor && s.LimitValidator != nil { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LimitValidator != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} diff --git a/signature/signature.go b/signature/signature.go new file mode 100644 index 00000000..980c0c05 --- /dev/null +++ b/signature/signature.go @@ -0,0 +1,817 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package signature implements the interfaces, types, and utility functions that can be used by +// Guest and Host implementations of Scale Signatures. +package signature + +import ( + "crypto/sha256" + "fmt" + "os" + "regexp" + + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/gohcl" + "github.com/hashicorp/hcl/v2/hclsyntax" + "github.com/hashicorp/hcl/v2/hclwrite" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +const ( + V1AlphaVersion = "v1alpha" +) + +var ( + ValidLabel = regexp.MustCompile(`^[A-Za-z0-9]*$`) + InvalidString = regexp.MustCompile(`[^A-Za-z0-9-.]`) +) + +var ( + TitleCaser = cases.Title(language.Und, cases.NoLower) +) + +// Schema is the top-level structure of a Scale Signature schema +type Schema struct { + Version string `hcl:"version,attr"` + Context string `hcl:"context,attr"` + Enums []*EnumSchema `hcl:"enum,block"` + Models []*ModelSchema `hcl:"model,block"` + hasLimitValidator bool + hasLengthValidator bool + hasRegexValidator bool + hasCaseModifier bool +} + +// ReadSchema reads a Scale Signature schema from a file at the given path +func ReadSchema(path string) (*Schema, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read schema file: %w", err) + } + + s := new(Schema) + return s, s.Decode(data) +} + +// Decode decodes the given byte slice into the Schema +// +// Note: This function modifies the Schema in-place and validates/normalizes it as well. +func (s *Schema) Decode(data []byte) error { + file, diag := hclsyntax.ParseConfig(data, "", hcl.Pos{Line: 1, Column: 1}) + if diag.HasErrors() { + return diag.Errs()[0] + } + + diag = gohcl.DecodeBody(file.Body, nil, s) + if diag.HasErrors() { + return diag.Errs()[0] + } + + err := s.validateAndNormalize() + if err != nil { + return err + } + + return nil +} + +// Encode encodes the Schema into a byte slice +func (s *Schema) Encode() ([]byte, error) { + f := hclwrite.NewEmptyFile() + gohcl.EncodeIntoBody(s, f.Body()) + return f.Bytes(), nil +} + +// validateAndNormalize validates the Schema and normalizes it +// +// Note: This function modifies the Schema in-place +func (s *Schema) validateAndNormalize() error { + switch s.Version { + case V1AlphaVersion: + // Transform all model names and references to TitleCase (e.g. "myModel" -> "MyModel") + for _, model := range s.Models { + model.Normalize() + } + + // Transform all model names and references to TitleCase (e.g. "myModel" -> "MyModel") + for _, enum := range s.Enums { + enum.Normalize() + } + + // Validate all models + knownModels := make(map[string]struct{}) + for _, model := range s.Models { + err := model.Validate(knownModels, s.Enums) + if err != nil { + return err + } + } + + // Validate all enums + knownEnums := make(map[string]struct{}) + for _, enum := range s.Enums { + err := enum.Validate(knownEnums) + if err != nil { + return err + } + } + + // Ensure all model and enum references are valid + for _, model := range s.Models { + for _, modelReference := range model.Models { + if _, ok := knownModels[modelReference.Reference]; !ok { + return fmt.Errorf("unknown %s.%s.reference: %s", model.Name, modelReference.Name, modelReference.Reference) + } + } + + for _, modelReferenceArray := range model.ModelArrays { + if _, ok := knownModels[modelReferenceArray.Reference]; !ok { + return fmt.Errorf("unknown %s.%s.reference: %s", model.Name, modelReferenceArray.Name, modelReferenceArray.Reference) + } + } + + for _, str := range model.Strings { + if str.LengthValidator != nil { + s.hasLengthValidator = true + } + if str.RegexValidator != nil { + s.hasRegexValidator = true + } + if str.CaseModifier != nil { + s.hasCaseModifier = true + } + } + + for _, strMap := range model.StringMaps { + if !ValidPrimitiveType(strMap.Value) { + if _, ok := knownModels[strMap.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, strMap.Name, strMap.Value) + } + } + } + + for _, i32 := range model.Int32s { + if i32.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, i32Map := range model.Int32Maps { + if !ValidPrimitiveType(i32Map.Value) { + if _, ok := knownModels[i32Map.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, i32Map.Name, i32Map.Value) + } + } + } + + for _, i64 := range model.Int64s { + if i64.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, i64Map := range model.Int64Maps { + if !ValidPrimitiveType(i64Map.Value) { + if _, ok := knownModels[i64Map.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, i64Map.Name, i64Map.Value) + } + } + } + + for _, u32 := range model.Uint32s { + if u32.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, u32Map := range model.Uint32Maps { + if !ValidPrimitiveType(u32Map.Value) { + if _, ok := knownModels[u32Map.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, u32Map.Name, u32Map.Value) + } + } + } + + for _, u64 := range model.Uint64s { + if u64.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, u64Map := range model.Uint64Maps { + if !ValidPrimitiveType(u64Map.Value) { + if _, ok := knownModels[u64Map.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, u64Map.Name, u64Map.Value) + } + } + } + + for _, f32 := range model.Float32s { + if f32.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, f64 := range model.Float64s { + if f64.LimitValidator != nil { + s.hasLimitValidator = true + } + } + + for _, enumReference := range model.Enums { + if _, ok := knownEnums[enumReference.Reference]; !ok { + return fmt.Errorf("unknown %s.%s.reference: %s", model.Name, enumReference.Name, enumReference.Reference) + } + } + + for _, enumReferenceArray := range model.EnumArrays { + if _, ok := knownEnums[enumReferenceArray.Reference]; !ok { + return fmt.Errorf("unknown %s.%s.reference: %s", model.Name, enumReferenceArray.Name, enumReferenceArray.Reference) + } + } + + for _, enumReferenceMap := range model.EnumMaps { + if _, ok := knownEnums[enumReferenceMap.Reference]; !ok { + return fmt.Errorf("unknown %s.%s.reference: %s", model.Name, enumReferenceMap.Name, enumReferenceMap.Reference) + } + + if !ValidPrimitiveType(enumReferenceMap.Value) { + if _, ok := knownModels[enumReferenceMap.Value]; !ok { + return fmt.Errorf("unknown %s.%s.value: %s", model.Name, enumReferenceMap.Name, enumReferenceMap.Value) + } + } + } + } + + s.Context = TitleCaser.String(s.Context) + if _, ok := knownModels[s.Context]; !ok { + return fmt.Errorf("unknown context: %s", s.Context) + } + + return nil + default: + return fmt.Errorf("unknown schema version: %s", s.Version) + } +} + +// Hash returns the SHA256 hash of the schema +func (s *Schema) Hash() ([]byte, error) { + d, err := s.Encode() + if err != nil { + return nil, err + } + + h := sha256.New() + if _, err = h.Write(d); err != nil { + return nil, err + } + return h.Sum(nil), nil +} + +// Clone returns a deep copy of the schema +func (s *Schema) Clone() (*Schema, error) { + clone := new(Schema) + encoded, err := s.Encode() + if err != nil { + return nil, err + } + if err = clone.Decode(encoded); err != nil { + return nil, err + } + return clone, nil +} + +// CloneWithDisabledAccessorsValidatorsAndModifiers returns a clone of the +// schema with all accessors, validators, and modifiers disabled +func (s *Schema) CloneWithDisabledAccessorsValidatorsAndModifiers() (*Schema, error) { + clone, err := s.Clone() + if err != nil { + return nil, err + } + clone.hasCaseModifier = false + clone.hasLimitValidator = false + clone.hasRegexValidator = false + clone.hasLengthValidator = false + for _, model := range clone.Models { + for _, modelReference := range model.Models { + modelReference.Accessor = false + } + + for _, modelReferenceArray := range model.ModelArrays { + modelReferenceArray.Accessor = + false + } + + for _, str := range model.Strings { + var accessorValue bool + str.Accessor = &accessorValue + str.CaseModifier = nil + str.LengthValidator = nil + str.RegexValidator = nil + } + + for _, strArray := range model.StringArrays { + var accessorValue bool + strArray.Accessor = &accessorValue + } + + for _, strMap := range model.StringMaps { + var accessorValue bool + strMap.Accessor = &accessorValue + } + + for _, i32 := range model.Int32s { + var accessorValue bool + i32.Accessor = &accessorValue + i32.LimitValidator = nil + } + + for _, i32Array := range model.Int32Arrays { + var accessorValue bool + i32Array.Accessor = &accessorValue + } + + for _, i32Map := range model.Int32Maps { + var accessorValue bool + i32Map.Accessor = &accessorValue + } + + for _, i64 := range model.Int64s { + var accessorValue bool + i64.Accessor = &accessorValue + i64.LimitValidator = nil + } + + for _, i64Array := range model.Int64Arrays { + var accessorValue bool + i64Array.Accessor = &accessorValue + } + + for _, i64Map := range model.Int64Maps { + var accessorValue bool + i64Map.Accessor = &accessorValue + } + + for _, u32 := range model.Uint32s { + var accessorValue bool + u32.Accessor = &accessorValue + u32.LimitValidator = nil + } + + for _, u32Array := range model.Uint32Arrays { + var accessorValue bool + u32Array.Accessor = &accessorValue + } + + for _, u32Map := range model.Uint32Maps { + var accessorValue bool + u32Map.Accessor = &accessorValue + } + + for _, u64 := range model.Uint64s { + var accessorValue bool + u64.Accessor = &accessorValue + u64.LimitValidator = nil + } + + for _, u64Array := range model.Uint64Arrays { + var accessorValue bool + u64Array.Accessor = &accessorValue + } + + for _, u64Map := range model.Uint64Maps { + var accessorValue bool + u64Map.Accessor = &accessorValue + } + + for _, f32 := range model.Float32s { + var accessorValue bool + f32.Accessor = &accessorValue + f32.LimitValidator = nil + } + + for _, f32Array := range model.Float32Arrays { + var accessorValue bool + f32Array.Accessor = &accessorValue + } + + for _, f64 := range model.Float64s { + var accessorValue bool + f64.Accessor = &accessorValue + f64.LimitValidator = nil + } + + for _, f64Array := range model.Float64Arrays { + var accessorValue bool + f64Array.Accessor = &accessorValue + } + + for _, boolean := range model.Bools { + boolean.Accessor = false + } + + for _, booleanArray := range model.BoolArrays { + booleanArray.Accessor = false + } + + for _, b := range model.Bytes { + b.Accessor = false + } + + for _, bytesArray := range model.BytesArrays { + bytesArray.Accessor = false + } + + for _, enumReference := range model.Enums { + enumReference.Accessor = false + } + + for _, enumReferenceArray := range model.EnumArrays { + enumReferenceArray.Accessor = false + } + + for _, enumReferenceMap := range model.EnumMaps { + enumReferenceMap.Accessor = false + } + } + + return clone, clone.validateAndNormalize() +} + +// HasLimitValidator returns true if the schema has a limit validator +func (s *Schema) HasLimitValidator() bool { + return s.hasLimitValidator +} + +// HasLengthValidator returns true if the schema has a length validator +func (s *Schema) HasLengthValidator() bool { + return s.hasLengthValidator +} + +// HasRegexValidator returns true if the schema has a regex validator +func (s *Schema) HasRegexValidator() bool { + return s.hasRegexValidator +} + +// HasCaseModifier returns true if the schema has a case modifier +func (s *Schema) HasCaseModifier() bool { + return s.hasCaseModifier +} + +func ValidPrimitiveType(t string) bool { + switch t { + case "string", "int32", "int64", "uint32", "uint64", "float32", "float64", "bool", "bytes": + return true + default: + return false + } +} + +const MasterTestingSchema = ` +version = "v1alpha" +context = "ModelWithAllFieldTypes" + +model EmptyModel {} + +model EmptyModelWithDescription { + description = "Test Description" +} + +model ModelWithSingleStringField { + string StringField { + default = "DefaultValue" + } +} + +model ModelWithSingleStringFieldAndDescription { + description = "Test Description" + + string StringField { + default = "DefaultValue" + } +} + +model ModelWithSingleInt32Field { + int32 Int32Field { + default = 32 + } +} + +model ModelWithSingleInt32FieldAndDescription { + description = "Test Description" + + int32 Int32Field { + default = 32 + } +} + +model ModelWithMultipleFields { + string StringField { + default = "DefaultValue" + } + + int32 Int32Field { + default = 32 + } +} + +model ModelWithMultipleFieldsAndDescription { + description = "Test Description" + + string StringField { + default = "DefaultValue" + } + + int32 Int32Field { + default = 32 + } +} + +enum GenericEnum { + values = ["FirstValue", "SecondValue", "DefaultValue"] +} + +model ModelWithEnum { + enum EnumField { + default = "DefaultValue" + reference = "GenericEnum" + } +} + +model ModelWithEnumAndDescription { + description = "Test Description" + + enum EnumField { + default = "DefaultValue" + reference = "GenericEnum" + } +} + +model ModelWithEnumAccessor { + enum EnumField { + default = "DefaultValue" + reference = "GenericEnum" + accessor = true + } +} + +model ModelWithEnumAccessorAndDescription { + description = "Test Description" + + enum EnumField { + default = "DefaultValue" + reference = "GenericEnum" + accessor = true + } +} + +model ModelWithMultipleFieldsAccessor { + string StringField { + default = "DefaultValue" + accessor = true + regex_validator { + expression = "^[a-zA-Z0-9]*$" + } + length_validator { + min = 1 + max= 20 + } + case_modifier { + kind = "upper" + } + } + + int32 Int32Field { + default = 32 + accessor = true + limit_validator { + min = 0 + max = 100 + } + } +} + +model ModelWithMultipleFieldsAccessorAndDescription { + description = "Test Description" + + string StringField { + default = "DefaultValue" + accessor = true + } + + int32 Int32Field { + default = 32 + accessor = true + } +} + +model ModelWithEmbeddedModels { + model EmbeddedEmptyModel { + reference = "EmptyModel" + } + + model_array EmbeddedModelArrayWithMultipleFieldsAccessor { + reference = "ModelWithMultipleFieldsAccessor" + initial_size = 64 + } +} + +model ModelWithEmbeddedModelsAndDescription { + description = "Test Description" + + model EmbeddedEmptyModel { + reference = "EmptyModel" + } + + model_array EmbeddedModelArrayWithMultipleFieldsAccessor { + reference = "ModelWithMultipleFieldsAccessor" + initial_size = 0 + } +} + +model ModelWithEmbeddedModelsAccessor { + model EmbeddedEmptyModel { + reference = "EmptyModel" + accessor = true + } + + model_array EmbeddedModelArrayWithMultipleFieldsAccessor { + reference = "ModelWithMultipleFieldsAccessor" + initial_size = 0 + accessor = true + } +} + +model ModelWithEmbeddedModelsAccessorAndDescription { + description = "Test Description" + + model EmbeddedEmptyModel { + reference = "EmptyModel" + accessor = true + } + + model_array EmbeddedModelArrayWithMultipleFieldsAccessor { + reference = "ModelWithMultipleFieldsAccessor" + initial_size = 0 + accessor = true + } +} + +model ModelWithAllFieldTypes { + string StringField { + default = "DefaultValue" + } + + string_array StringArrayField { + initial_size = 0 + } + + string_map StringMapField { + value = "string" + } + + string_map StringMapFieldEmbedded { + value = "EmptyModel" + } + + int32 Int32Field { + default = 32 + } + + int32_array Int32ArrayField { + initial_size = 0 + } + + int32_map Int32MapField { + value = "int32" + } + + int32_map Int32MapFieldEmbedded { + value = "EmptyModel" + } + + int64 Int64Field { + default = 64 + } + + int64_array Int64ArrayField { + initial_size = 0 + } + + int64_map Int64MapField { + value = "int64" + } + + int64_map Int64MapFieldEmbedded { + value = "EmptyModel" + } + + uint32 Uint32Field { + default = 32 + } + + uint32_array Uint32ArrayField { + initial_size = 0 + } + + uint32_map Uint32MapField { + value = "uint32" + } + + uint32_map Uint32MapFieldEmbedded { + value = "EmptyModel" + } + + uint64 Uint64Field { + default = 64 + } + + uint64_array Uint64ArrayField { + initial_size = 0 + } + + uint64_map Uint64MapField { + value = "uint64" + } + + uint64_map Uint64MapFieldEmbedded { + value = "EmptyModel" + } + + float32 Float32Field { + default = 32.32 + } + + float32_array Float32ArrayField { + initial_size = 0 + } + + float64 Float64Field { + default = 64.64 + } + + float64_array Float64ArrayField { + initial_size = 0 + } + + bool BoolField { + default = true + } + + bool_array BoolArrayField { + initial_size = 0 + } + + bytes BytesField { + initial_size = 512 + } + + bytes_array BytesArrayField { + initial_size = 0 + } + + enum EnumField { + reference = "GenericEnum" + default = "DefaultValue" + } + + enum_array EnumArrayField { + reference = "GenericEnum" + initial_size = 0 + } + + enum_map EnumMapField { + reference = "GenericEnum" + value = "string" + } + + enum_map EnumMapFieldEmbedded { + reference = "GenericEnum" + value = "EmptyModel" + } + + model ModelField { + reference = "EmptyModel" + } + + model_array ModelArrayField { + reference = "EmptyModel" + initial_size = 0 + } +} +` diff --git a/signature/signature_test.go b/signature/signature_test.go new file mode 100644 index 00000000..58645323 --- /dev/null +++ b/signature/signature_test.go @@ -0,0 +1,202 @@ +//go:build !integration && !generate + +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestSchema(t *testing.T) { + s := new(Schema) + err := s.Decode([]byte(MasterTestingSchema)) + require.NoError(t, err) + + assert.Equal(t, V1AlphaVersion, s.Version) + assert.Equal(t, "ModelWithAllFieldTypes", s.Context) + + assert.Equal(t, "EmptyModel", s.Models[0].Name) + + assert.Equal(t, "EmptyModelWithDescription", s.Models[1].Name) + assert.Equal(t, "Test Description", s.Models[1].Description) + + assert.Equal(t, "ModelWithSingleStringField", s.Models[2].Name) + assert.Equal(t, "StringField", s.Models[2].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[2].Strings[0].Default) + + assert.Equal(t, "ModelWithSingleStringFieldAndDescription", s.Models[3].Name) + assert.Equal(t, "Test Description", s.Models[3].Description) + assert.Equal(t, "StringField", s.Models[3].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[3].Strings[0].Default) + + assert.Equal(t, "ModelWithSingleInt32Field", s.Models[4].Name) + assert.Equal(t, "Int32Field", s.Models[4].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[4].Int32s[0].Default) + + assert.Equal(t, "ModelWithSingleInt32FieldAndDescription", s.Models[5].Name) + assert.Equal(t, "Test Description", s.Models[5].Description) + assert.Equal(t, "Int32Field", s.Models[5].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[5].Int32s[0].Default) + + assert.Equal(t, "ModelWithMultipleFields", s.Models[6].Name) + assert.Equal(t, "StringField", s.Models[6].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[6].Strings[0].Default) + assert.Equal(t, "Int32Field", s.Models[6].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[6].Int32s[0].Default) + + assert.Equal(t, "ModelWithMultipleFieldsAndDescription", s.Models[7].Name) + assert.Equal(t, "Test Description", s.Models[7].Description) + assert.Equal(t, "StringField", s.Models[7].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[7].Strings[0].Default) + assert.Equal(t, "Int32Field", s.Models[7].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[7].Int32s[0].Default) + + assert.Equal(t, "GenericEnum", s.Enums[0].Name) + assert.Equal(t, []string{"FirstValue", "SecondValue", "DefaultValue"}, s.Enums[0].Values) + + assert.Equal(t, "ModelWithEnum", s.Models[8].Name) + assert.Equal(t, "EnumField", s.Models[8].Enums[0].Name) + assert.Equal(t, "GenericEnum", s.Models[8].Enums[0].Reference) + + assert.Equal(t, "ModelWithEnumAndDescription", s.Models[9].Name) + assert.Equal(t, "Test Description", s.Models[9].Description) + assert.Equal(t, "EnumField", s.Models[9].Enums[0].Name) + assert.Equal(t, "GenericEnum", s.Models[9].Enums[0].Reference) + + assert.Equal(t, "ModelWithEnumAccessor", s.Models[10].Name) + assert.Equal(t, "EnumField", s.Models[10].Enums[0].Name) + assert.Equal(t, "GenericEnum", s.Models[10].Enums[0].Reference) + assert.Equal(t, true, s.Models[10].Enums[0].Accessor) + + assert.Equal(t, "ModelWithEnumAccessorAndDescription", s.Models[11].Name) + assert.Equal(t, "Test Description", s.Models[11].Description) + assert.Equal(t, "EnumField", s.Models[11].Enums[0].Name) + assert.Equal(t, "GenericEnum", s.Models[11].Enums[0].Reference) + assert.Equal(t, true, s.Models[11].Enums[0].Accessor) + + assert.Equal(t, "ModelWithMultipleFieldsAccessor", s.Models[12].Name) + assert.Equal(t, "StringField", s.Models[12].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[12].Strings[0].Default) + assert.Equal(t, true, *s.Models[12].Strings[0].Accessor) + assert.Equal(t, "Int32Field", s.Models[12].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[12].Int32s[0].Default) + assert.Equal(t, true, *s.Models[12].Int32s[0].Accessor) + + assert.Equal(t, "ModelWithMultipleFieldsAccessorAndDescription", s.Models[13].Name) + assert.Equal(t, "Test Description", s.Models[13].Description) + assert.Equal(t, "StringField", s.Models[13].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[13].Strings[0].Default) + assert.Equal(t, true, *s.Models[13].Strings[0].Accessor) + assert.Equal(t, "Int32Field", s.Models[13].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[13].Int32s[0].Default) + assert.Equal(t, true, *s.Models[13].Int32s[0].Accessor) + + assert.Equal(t, "ModelWithEmbeddedModels", s.Models[14].Name) + assert.Equal(t, "EmbeddedEmptyModel", s.Models[14].Models[0].Name) + assert.Equal(t, "EmptyModel", s.Models[14].Models[0].Reference) + assert.Equal(t, "EmbeddedModelArrayWithMultipleFieldsAccessor", s.Models[14].ModelArrays[0].Name) + assert.Equal(t, "ModelWithMultipleFieldsAccessor", s.Models[14].ModelArrays[0].Reference) + assert.Equal(t, uint32(64), s.Models[14].ModelArrays[0].InitialSize) + + assert.Equal(t, "ModelWithEmbeddedModelsAndDescription", s.Models[15].Name) + assert.Equal(t, "Test Description", s.Models[15].Description) + assert.Equal(t, "EmbeddedEmptyModel", s.Models[15].Models[0].Name) + assert.Equal(t, "EmptyModel", s.Models[15].Models[0].Reference) + assert.Equal(t, "EmbeddedModelArrayWithMultipleFieldsAccessor", s.Models[15].ModelArrays[0].Name) + assert.Equal(t, "ModelWithMultipleFieldsAccessor", s.Models[15].ModelArrays[0].Reference) + assert.Equal(t, uint32(0), s.Models[15].ModelArrays[0].InitialSize) + + assert.Equal(t, "ModelWithEmbeddedModelsAccessor", s.Models[16].Name) + assert.Equal(t, "EmbeddedEmptyModel", s.Models[16].Models[0].Name) + assert.Equal(t, "EmptyModel", s.Models[16].Models[0].Reference) + assert.Equal(t, true, s.Models[16].Models[0].Accessor) + assert.Equal(t, "EmbeddedModelArrayWithMultipleFieldsAccessor", s.Models[16].ModelArrays[0].Name) + assert.Equal(t, "ModelWithMultipleFieldsAccessor", s.Models[16].ModelArrays[0].Reference) + assert.Equal(t, uint32(0), s.Models[16].ModelArrays[0].InitialSize) + assert.Equal(t, true, s.Models[16].ModelArrays[0].Accessor) + + assert.Equal(t, "ModelWithEmbeddedModelsAccessorAndDescription", s.Models[17].Name) + assert.Equal(t, "Test Description", s.Models[17].Description) + assert.Equal(t, "EmbeddedEmptyModel", s.Models[17].Models[0].Name) + assert.Equal(t, "EmptyModel", s.Models[17].Models[0].Reference) + assert.Equal(t, true, s.Models[17].Models[0].Accessor) + assert.Equal(t, "EmbeddedModelArrayWithMultipleFieldsAccessor", s.Models[17].ModelArrays[0].Name) + assert.Equal(t, "ModelWithMultipleFieldsAccessor", s.Models[17].ModelArrays[0].Reference) + assert.Equal(t, uint32(0), s.Models[17].ModelArrays[0].InitialSize) + assert.Equal(t, true, s.Models[17].ModelArrays[0].Accessor) + + assert.Equal(t, "ModelWithAllFieldTypes", s.Models[18].Name) + assert.Equal(t, "StringField", s.Models[18].Strings[0].Name) + assert.Equal(t, "DefaultValue", s.Models[18].Strings[0].Default) + assert.Equal(t, "StringArrayField", s.Models[18].StringArrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].StringArrays[0].InitialSize) + assert.Equal(t, "StringMapField", s.Models[18].StringMaps[0].Name) + assert.Equal(t, "string", s.Models[18].StringMaps[0].Value) + assert.Equal(t, "StringMapFieldEmbedded", s.Models[18].StringMaps[1].Name) + assert.Equal(t, "EmptyModel", s.Models[18].StringMaps[1].Value) + assert.Equal(t, "Int32Field", s.Models[18].Int32s[0].Name) + assert.Equal(t, int32(32), s.Models[18].Int32s[0].Default) + assert.Equal(t, "Int32ArrayField", s.Models[18].Int32Arrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].Int32Arrays[0].InitialSize) + assert.Equal(t, "Int32MapField", s.Models[18].Int32Maps[0].Name) + assert.Equal(t, "int32", s.Models[18].Int32Maps[0].Value) + assert.Equal(t, "Int32MapFieldEmbedded", s.Models[18].Int32Maps[1].Name) + assert.Equal(t, "EmptyModel", s.Models[18].Int32Maps[1].Value) + assert.Equal(t, "Int64Field", s.Models[18].Int64s[0].Name) + assert.Equal(t, int64(64), s.Models[18].Int64s[0].Default) + assert.Equal(t, "Int64ArrayField", s.Models[18].Int64Arrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].Int64Arrays[0].InitialSize) + assert.Equal(t, "Int64MapField", s.Models[18].Int64Maps[0].Name) + assert.Equal(t, "int64", s.Models[18].Int64Maps[0].Value) + assert.Equal(t, "Int64MapFieldEmbedded", s.Models[18].Int64Maps[1].Name) + assert.Equal(t, "EmptyModel", s.Models[18].Int64Maps[1].Value) + assert.Equal(t, "Float32Field", s.Models[18].Float32s[0].Name) + assert.Equal(t, float32(32.32), s.Models[18].Float32s[0].Default) + assert.Equal(t, "Float32ArrayField", s.Models[18].Float32Arrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].Float32Arrays[0].InitialSize) + assert.Equal(t, "Float64Field", s.Models[18].Float64s[0].Name) + assert.Equal(t, float64(64.64), s.Models[18].Float64s[0].Default) + assert.Equal(t, "Float64ArrayField", s.Models[18].Float64Arrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].Float64Arrays[0].InitialSize) + assert.Equal(t, "BoolField", s.Models[18].Bools[0].Name) + assert.Equal(t, true, s.Models[18].Bools[0].Default) + assert.Equal(t, "BoolArrayField", s.Models[18].BoolArrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].BoolArrays[0].InitialSize) + assert.Equal(t, "BytesField", s.Models[18].Bytes[0].Name) + assert.Equal(t, uint32(512), s.Models[18].Bytes[0].InitialSize) + assert.Equal(t, "BytesArrayField", s.Models[18].BytesArrays[0].Name) + assert.Equal(t, uint32(0), s.Models[18].BytesArrays[0].InitialSize) + assert.Equal(t, "EnumField", s.Models[18].Enums[0].Name) + assert.Equal(t, "GenericEnum", s.Models[18].Enums[0].Reference) + assert.Equal(t, "EnumArrayField", s.Models[18].EnumArrays[0].Name) + assert.Equal(t, "GenericEnum", s.Models[18].EnumArrays[0].Reference) + assert.Equal(t, uint32(0), s.Models[18].EnumArrays[0].InitialSize) + assert.Equal(t, "EnumMapField", s.Models[18].EnumMaps[0].Name) + assert.Equal(t, "GenericEnum", s.Models[18].EnumMaps[0].Reference) + assert.Equal(t, "string", s.Models[18].EnumMaps[0].Value) + assert.Equal(t, "EnumMapFieldEmbedded", s.Models[18].EnumMaps[1].Name) + assert.Equal(t, "EmptyModel", s.Models[18].EnumMaps[1].Value) + assert.Equal(t, "ModelField", s.Models[18].Models[0].Name) + assert.Equal(t, "EmptyModel", s.Models[18].Models[0].Reference) + assert.Equal(t, "ModelArrayField", s.Models[18].ModelArrays[0].Name) + assert.Equal(t, "EmptyModel", s.Models[18].ModelArrays[0].Reference) + assert.Equal(t, uint32(0), s.Models[18].ModelArrays[0].InitialSize) +} diff --git a/signature/string.go b/signature/string.go new file mode 100644 index 00000000..ffec2171 --- /dev/null +++ b/signature/string.go @@ -0,0 +1,216 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package signature + +import ( + "fmt" + "regexp" +) + +type StringRegexValidatorSchema struct { + Expression string `hcl:"expression,attr"` +} + +type StringLengthValidatorSchema struct { + Minimum *uint `hcl:"min,optional"` + Maximum *uint `hcl:"max,optional"` +} + +type StringCaseModifierSchema struct { + Kind string `hcl:"kind,attr"` +} + +type StringSchema struct { + Name string `hcl:"name,label"` + Default string `hcl:"default,attr"` + Accessor *bool `hcl:"accessor,optional"` + RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` + LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` + CaseModifier *StringCaseModifierSchema `hcl:"case_modifier,block"` +} + +func (s *StringSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.string name: %s", model.Name, s.Name) + } + + if s.LengthValidator != nil { + if s.LengthValidator.Maximum != nil { + if *s.LengthValidator.Maximum == 0 { + return fmt.Errorf("invalid %s.%s.length_validator: maximum length cannot be zero", model.Name, s.Name) + } + + if s.LengthValidator.Minimum != nil { + if *s.LengthValidator.Minimum > *s.LengthValidator.Maximum { + return fmt.Errorf("invalid %s.%s.length_validator: minimum length cannot be greater than maximum length", model.Name, s.Name) + } + } + } + } + + if s.RegexValidator != nil { + regex, err := regexp.Compile(s.RegexValidator.Expression) + if err != nil { + return fmt.Errorf("invalid %s.%s.regex_validator: %w", model.Name, s.Name, err) + } + if !regex.MatchString(s.Default) { + return fmt.Errorf("invalid %s.%s.default: does not match regex", model.Name, s.Name) + } + } + + if s.CaseModifier != nil { + switch s.CaseModifier.Kind { + case "upper", "lower", "none": + default: + return fmt.Errorf("invalid %s.%s.caseModifier: kind must be upper, lower or none", model.Name, s.Name) + } + } + + if s.Accessor != nil { + if !*s.Accessor && (s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil) { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} + +type StringArraySchema struct { + Name string `hcl:"name,label"` + InitialSize uint32 `hcl:"initial_size,attr"` + Accessor *bool `hcl:"accessor,optional"` + RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` + LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` + CaseModifier *StringCaseModifierSchema `hcl:"caseModifier,block"` +} + +func (s *StringArraySchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.string_array name: %s", model.Name, s.Name) + } + + if s.LengthValidator != nil { + if s.LengthValidator.Maximum != nil { + if *s.LengthValidator.Maximum == 0 { + return fmt.Errorf("invalid %s.%s.length_validator: maximum length cannot be zero", model.Name, s.Name) + } + + if s.LengthValidator.Minimum != nil { + if *s.LengthValidator.Minimum > *s.LengthValidator.Maximum { + return fmt.Errorf("invalid %s.%s.length_validator: minimum length cannot be greater than maximum length", model.Name, s.Name) + } + } + } + } + + if s.RegexValidator != nil { + if _, err := regexp.Compile(s.RegexValidator.Expression); err != nil { + return fmt.Errorf("invalid %s.%s.regex_validator: %w", model.Name, s.Name, err) + } + } + + if s.CaseModifier != nil { + switch s.CaseModifier.Kind { + case "upper", "lower", "none": + default: + return fmt.Errorf("invalid %s.%s.caseModifier: kind must be upper, lower or none", model.Name, s.Name) + } + } + + if s.Accessor != nil { + if !*s.Accessor && (s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil) { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} + +type StringMapSchema struct { + Name string `hcl:"name,label"` + Value string `hcl:"value,attr"` + Accessor *bool `hcl:"accessor,optional"` + RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` + LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` + CaseModifier *StringCaseModifierSchema `hcl:"caseModifier,block"` +} + +func (s *StringMapSchema) Validate(model *ModelSchema) error { + if !ValidLabel.MatchString(s.Name) { + return fmt.Errorf("invalid %s.string_map name: %s", model.Name, s.Name) + } + + if s.LengthValidator != nil { + if s.LengthValidator.Maximum != nil { + if *s.LengthValidator.Maximum == 0 { + return fmt.Errorf("invalid %s.%s.length_validator: maximum length cannot be zero", model.Name, s.Name) + } + + if s.LengthValidator.Minimum != nil { + if *s.LengthValidator.Minimum > *s.LengthValidator.Maximum { + return fmt.Errorf("invalid %s.%s.length_validator: minimum length cannot be greater than maximum length", model.Name, s.Name) + } + } + } + } + + if s.RegexValidator != nil { + if _, err := regexp.Compile(s.RegexValidator.Expression); err != nil { + return fmt.Errorf("invalid %s.%s.regex_validator: %w", model.Name, s.Name, err) + } + } + + if s.CaseModifier != nil { + switch s.CaseModifier.Kind { + case "upper", "lower": + default: + return fmt.Errorf("invalid %s.%s.caseModifier: kind must be upper or lowere", model.Name, s.Name) + } + } + + if s.Accessor != nil { + if !*s.Accessor && (s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil) { + return fmt.Errorf("invalid %s.%s.accessor: cannot be false while using validators or modifiers", model.Name, s.Name) + } + } else { + if s.LengthValidator != nil || s.RegexValidator != nil || s.CaseModifier != nil { + s.Accessor = new(bool) + *s.Accessor = true + } else { + s.Accessor = new(bool) + *s.Accessor = false + } + } + + return nil +} diff --git a/storage/build.go b/storage/build.go new file mode 100644 index 00000000..7aa3b3b3 --- /dev/null +++ b/storage/build.go @@ -0,0 +1,77 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package storage is used to store and retrieve built Scale Functions +package storage + +import ( + "os" + "path" + + "github.com/google/uuid" +) + +const ( + BuildDirectory = "builds" +) + +var ( + DefaultBuild *BuildStorage +) + +type Build struct { + Path string +} + +type BuildStorage struct { + Directory string +} + +func init() { + homeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + DefaultBuild, err = NewBuild(path.Join(homeDir, DefaultDirectory, BuildDirectory)) + if err != nil { + panic(err) + } +} + +func NewBuild(baseDirectory string) (*BuildStorage, error) { + err := os.MkdirAll(baseDirectory, 0755) + if err != nil { + if !os.IsExist(err) { + return nil, err + } + } + + return &BuildStorage{ + Directory: baseDirectory, + }, nil +} + +// Mkdir creates and returns a new build directory +func (s *BuildStorage) Mkdir() (*Build, error) { + p := path.Join(s.Directory, uuid.New().String()) + return &Build{ + Path: p, + }, os.MkdirAll(p, 0755) +} + +func (s *BuildStorage) Delete(b *Build) error { + return os.RemoveAll(b.Path) +} diff --git a/go/storage/storage.go b/storage/function.go similarity index 58% rename from go/storage/storage.go rename to storage/function.go index 08cee60b..9d233cc0 100644 --- a/go/storage/storage.go +++ b/storage/function.go @@ -18,31 +18,25 @@ package storage import ( - "errors" + "encoding/hex" "fmt" - "github.com/loopholelabs/scalefile/scalefunc" "os" "path" "path/filepath" - "strings" -) -var ( - ErrInvalidName = errors.New("invalid name") - ErrInvalidTag = errors.New("invalid tag") - ErrInvalidOrganization = errors.New("invalid organization") + "github.com/loopholelabs/scale/scalefunc" ) const ( - DefaultCacheDirectory = ".config/scale/functions" + FunctionDirectory = "functions" ) var ( - Default *Storage + DefaultFunction *FunctionStorage ) -type Entry struct { - ScaleFunc *scalefunc.ScaleFunc +type Function struct { + Schema *scalefunc.Schema Hash string Organization string } @@ -52,18 +46,18 @@ func init() { if err != nil { panic(err) } - Default, err = New(path.Join(homeDir, DefaultCacheDirectory)) + DefaultFunction, err = NewFunction(path.Join(homeDir, DefaultDirectory, FunctionDirectory)) if err != nil { panic(err) } } -// Storage is used to store and retrieve built Scale Functions -type Storage struct { - BaseDirectory string +// FunctionStorage is used to store and retrieve built Scale Functions +type FunctionStorage struct { + Directory string } -func New(baseDirectory string) (*Storage, error) { +func NewFunction(baseDirectory string) (*FunctionStorage, error) { err := os.MkdirAll(baseDirectory, 0755) if err != nil { if !os.IsExist(err) { @@ -71,14 +65,14 @@ func New(baseDirectory string) (*Storage, error) { } } - return &Storage{ - BaseDirectory: baseDirectory, + return &FunctionStorage{ + Directory: baseDirectory, }, nil } // Get returns the Scale Function with the given name, tag, and organization. // The hash parameter is optional and can be used to check for a specific hash. -func (s *Storage) Get(name string, tag string, org string, hash string) (*Entry, error) { +func (s *FunctionStorage) Get(name string, tag string, org string, hash string) (*Function, error) { if name == "" || !scalefunc.ValidString(name) { return nil, ErrInvalidName } @@ -94,12 +88,22 @@ func (s *Storage) Get(name string, tag string, org string, hash string) (*Entry, if hash != "" { f := s.functionName(name, tag, org, hash) p := s.fullPath(f) + + stat, err := os.Stat(p) + if err != nil { + return nil, err + } + + if stat.IsDir() { + return nil, fmt.Errorf("found function is a directory not a file %s/%s:%s", org, name, tag) + } + sf, err := scalefunc.Read(p) if err != nil { return nil, err } - return &Entry{ - ScaleFunc: sf, + return &Function{ + Schema: sf, Hash: hash, Organization: org, }, nil @@ -121,37 +125,46 @@ func (s *Storage) Get(name string, tag string, org string, hash string) (*Entry, return nil, fmt.Errorf("multiple matches found for %s/%s:%s", org, name, tag) } + stat, err := os.Stat(matches[0]) + if err != nil { + return nil, err + } + + if stat.IsDir() { + return nil, fmt.Errorf("found function is a directory not a file %s/%s:%s", org, name, tag) + } + sf, err := scalefunc.Read(matches[0]) if err != nil { return nil, err } - return &Entry{ - ScaleFunc: sf, - Hash: s.getHashFromFileName(path.Base(matches[0])), - Organization: s.getOrgFromFileName(path.Base(matches[0])), + return &Function{ + Schema: sf, + Hash: getHashFromName(path.Base(matches[0])), + Organization: getOrgFromName(path.Base(matches[0])), }, nil } // Put stores the Scale Function with the given name, tag, organization, and hash -func (s *Storage) Put(name string, tag string, org string, hash string, sf *scalefunc.ScaleFunc) error { - f := s.functionName(name, tag, org, hash) +func (s *FunctionStorage) Put(name string, tag string, org string, sf *scalefunc.Schema) error { + f := s.functionName(name, tag, org, hex.EncodeToString(sf.GetHash())) p := s.fullPath(f) return os.WriteFile(p, sf.Encode(), 0644) } // Delete removes the Scale Function with the given name, tag, org, and hash -func (s *Storage) Delete(name string, tag string, org string, hash string) error { +func (s *FunctionStorage) Delete(name string, tag string, org string, hash string) error { return os.Remove(s.fullPath(s.functionName(name, tag, org, hash))) } // List returns all the Scale Functions stored in the storage -func (s *Storage) List() ([]Entry, error) { - entries, err := os.ReadDir(s.BaseDirectory) +func (s *FunctionStorage) List() ([]Function, error) { + entries, err := os.ReadDir(s.Directory) if err != nil { - return nil, fmt.Errorf("failed to read storage directory %s: %w", s.BaseDirectory, err) + return nil, fmt.Errorf("failed to read storage directory %s: %w", s.Directory, err) } - var scaleFuncEntries []Entry + var scaleFuncEntries []Function for _, entry := range entries { if entry.IsDir() { continue @@ -160,41 +173,23 @@ func (s *Storage) List() ([]Entry, error) { if err != nil { return nil, fmt.Errorf("failed to decode scale function %s: %w", s.fullPath(entry.Name()), err) } - scaleFuncEntries = append(scaleFuncEntries, Entry{ - ScaleFunc: scaleFunc, - Hash: s.getHashFromFileName(entry.Name()), - Organization: s.getOrgFromFileName(entry.Name()), + scaleFuncEntries = append(scaleFuncEntries, Function{ + Schema: scaleFunc, + Hash: getHashFromName(entry.Name()), + Organization: getOrgFromName(entry.Name()), }) } return scaleFuncEntries, nil } -func (s *Storage) fullPath(p string) string { - return path.Join(s.BaseDirectory, p) +func (s *FunctionStorage) fullPath(p string) string { + return path.Join(s.Directory, p) } -func (s *Storage) functionName(name string, tag string, org string, hash string) string { +func (s *FunctionStorage) functionName(name string, tag string, org string, hash string) string { return fmt.Sprintf("%s_%s_%s_%s_scale", org, name, tag, hash) } -func (s *Storage) functionSearch(name string, tag string, org string) string { +func (s *FunctionStorage) functionSearch(name string, tag string, org string) string { return fmt.Sprintf("%s_%s_%s_*_scale", org, name, tag) } - -func (s *Storage) getHashFromFileName(fileName string) string { - split := strings.Split(fileName, "_") - if len(split) != 5 { - return "" - } - - return split[3] -} - -func (s *Storage) getOrgFromFileName(fileName string) string { - split := strings.Split(fileName, "_") - if len(split) != 5 { - return "" - } - - return split[0] -} diff --git a/storage/signature.go b/storage/signature.go new file mode 100644 index 00000000..4325b06a --- /dev/null +++ b/storage/signature.go @@ -0,0 +1,354 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package storage is used to store and retrieve built Scale Functions +package storage + +import ( + "encoding/hex" + "fmt" + "os" + "path" + "path/filepath" + + "github.com/loopholelabs/scale/scalefunc" + "github.com/loopholelabs/scale/signature" + "github.com/loopholelabs/scale/signature/generator" +) + +const ( + SignatureDirectory = "signatures" +) + +var ( + DefaultSignature *SignatureStorage +) + +type Signature struct { + Name string + Tag string + Schema *signature.Schema + Hash string + Organization string +} + +type SignatureStorage struct { + Directory string +} + +func init() { + homeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + DefaultSignature, err = NewSignature(path.Join(homeDir, DefaultDirectory, SignatureDirectory)) + if err != nil { + panic(err) + } +} + +func NewSignature(baseDirectory string) (*SignatureStorage, error) { + err := os.MkdirAll(baseDirectory, 0755) + if err != nil { + if !os.IsExist(err) { + return nil, err + } + } + + return &SignatureStorage{ + Directory: baseDirectory, + }, nil +} + +// Get returns the Scale Signature with the given name, tag, and organization. +// The hash parameter is optional and can be used to check for a specific hash. +func (s *SignatureStorage) Get(name string, tag string, org string, hash string) (*Signature, error) { + if name == "" || !scalefunc.ValidString(name) { + return nil, ErrInvalidName + } + + if tag == "" || !scalefunc.ValidString(tag) { + return nil, ErrInvalidTag + } + + if org == "" || !scalefunc.ValidString(org) { + return nil, ErrInvalidOrganization + } + + if hash != "" { + f := s.signatureName(name, tag, org, hash) + p := s.fullPath(f) + + stat, err := os.Stat(p) + if err != nil { + return nil, err + } + + if !stat.IsDir() { + return nil, fmt.Errorf("found signature is a file not a directory %s/%s:%s", org, name, tag) + } + + sig, err := signature.ReadSchema(path.Join(p, "signature")) + if err != nil { + return nil, err + } + + return &Signature{ + Name: name, + Tag: tag, + Schema: sig, + Hash: hash, + Organization: org, + }, nil + } + + f := s.signatureSearch(name, tag, org) + p := s.fullPath(f) + + matches, err := filepath.Glob(p) + if err != nil { + return nil, err + } + + if len(matches) == 0 { + return nil, nil + } + + if len(matches) > 1 { + return nil, fmt.Errorf("multiple matches found for %s/%s:%s", org, name, tag) + } + + stat, err := os.Stat(matches[0]) + if err != nil { + return nil, err + } + + if !stat.IsDir() { + return nil, fmt.Errorf("found signature is a file not a directory %s/%s:%s", org, name, tag) + } + + sig, err := signature.ReadSchema(path.Join(matches[0], "signature")) + if err != nil { + return nil, err + } + + return &Signature{ + Name: name, + Tag: tag, + Schema: sig, + Hash: getHashFromName(filepath.Base(matches[0])), + Organization: getOrgFromName(filepath.Base(matches[0])), + }, nil +} + +func (s *SignatureStorage) Path(name string, tag string, org string, hash string) (string, error) { + if name == "" || !scalefunc.ValidString(name) { + return "", ErrInvalidName + } + + if tag == "" || !scalefunc.ValidString(tag) { + return "", ErrInvalidTag + } + + if org == "" || !scalefunc.ValidString(org) { + return "", ErrInvalidOrganization + } + + if hash != "" { + f := s.signatureName(name, tag, org, hash) + p := s.fullPath(f) + + stat, err := os.Stat(p) + if err != nil { + return "", err + } + + if !stat.IsDir() { + return "", fmt.Errorf("found signature is a file not a directory %s/%s:%s", org, name, tag) + } + + return p, nil + } + + f := s.signatureSearch(name, tag, org) + p := s.fullPath(f) + + matches, err := filepath.Glob(p) + if err != nil { + return "", err + } + + if len(matches) == 0 { + return "", nil + } + + if len(matches) > 1 { + return "", fmt.Errorf("multiple matches found for %s/%s:%s", org, name, tag) + } + + stat, err := os.Stat(matches[0]) + if err != nil { + return "", err + } + + if !stat.IsDir() { + return "", fmt.Errorf("found signature is a file not a directory %s/%s:%s", org, name, tag) + } + + return matches[0], nil +} + +// Put stores the Scale Signature with the given name, tag, organization +func (s *SignatureStorage) Put(name string, tag string, org string, sig *signature.Schema) error { + hash, err := sig.Hash() + if err != nil { + return err + } + + hashString := hex.EncodeToString(hash) + + f := s.signatureName(name, tag, org, hashString) + directory := s.fullPath(f) + err = os.MkdirAll(directory, 0755) + if err != nil { + return err + } + + err = GenerateSignature(sig, name, tag, org, directory) + if err != nil { + return err + } + + return nil +} + +// Delete removes the Scale Signature with the given name, tag, org, and hash +func (s *SignatureStorage) Delete(name string, tag string, org string, hash string) error { + return os.RemoveAll(s.fullPath(s.signatureName(name, tag, org, hash))) +} + +// List returns all the Scale Signatures stored in the storage +func (s *SignatureStorage) List() ([]Signature, error) { + entries, err := os.ReadDir(s.Directory) + if err != nil { + return nil, fmt.Errorf("failed to read storage directory %s: %w", s.Directory, err) + } + var scaleSignatureEntries []Signature + for _, entry := range entries { + if !entry.IsDir() { + continue + } + + sig, err := signature.ReadSchema(path.Join(s.fullPath(entry.Name()), "signature")) + if err != nil { + return nil, fmt.Errorf("failed to decode scale signature %s: %w", s.fullPath(entry.Name()), err) + } + scaleSignatureEntries = append(scaleSignatureEntries, Signature{ + Name: getNameFromName(entry.Name()), + Tag: getTagFromName(entry.Name()), + Schema: sig, + Hash: getHashFromName(entry.Name()), + Organization: getOrgFromName(entry.Name()), + }) + } + return scaleSignatureEntries, nil +} + +func (s *SignatureStorage) fullPath(p string) string { + return path.Join(s.Directory, p) +} + +func (s *SignatureStorage) signatureName(name string, tag string, org string, hash string) string { + return fmt.Sprintf("%s_%s_%s_%s_signature", org, name, tag, hash) +} + +func (s *SignatureStorage) signatureSearch(name string, tag string, org string) string { + return fmt.Sprintf("%s_%s_%s_*_signature", org, name, tag) +} + +// GenerateSignature generates the signature files and writes them to +// the given path. +func GenerateSignature(sig *signature.Schema, name string, tag string, org string, directory string) error { + encoded, err := sig.Encode() + if err != nil { + return err + } + + err = os.WriteFile(path.Join(directory, "signature"), encoded, 0644) + if err != nil { + return err + } + + err = os.MkdirAll(path.Join(directory, "golang", "guest"), 0755) + if err != nil { + return err + } + + err = os.MkdirAll(path.Join(directory, "rust", "guest"), 0755) + if err != nil { + return err + } + + err = os.MkdirAll(path.Join(directory, "golang", "host"), 0755) + if err != nil { + return err + } + + guestPackage, err := generator.GenerateGuestLocal(&generator.Options{ + Signature: sig, + + GolangPackageImportPath: "signature", + GolangPackageVersion: "v0.1.0", + + RustPackageName: fmt.Sprintf("%s_%s_%s_guest", org, name, tag), + RustPackageVersion: "0.1.0", + }) + if err != nil { + return err + } + + for _, file := range guestPackage.GolangFiles { + err = os.WriteFile(path.Join(directory, "golang", "guest", file.Path()), file.Data(), 0644) + if err != nil { + return err + } + } + + for _, file := range guestPackage.RustFiles { + err = os.WriteFile(path.Join(directory, "rust", "guest", file.Path()), file.Data(), 0644) + if err != nil { + return err + } + } + + hostPackage, err := generator.GenerateHostLocal(&generator.Options{ + Signature: sig, + GolangPackageImportPath: "signature", + GolangPackageVersion: "v0.1.0", + }) + if err != nil { + return err + } + + for _, file := range hostPackage.GolangFiles { + err = os.WriteFile(path.Join(directory, "golang", "host", file.Path()), file.Data(), 0644) + if err != nil { + return err + } + } + + return nil +} diff --git a/storage/storage.go b/storage/storage.go new file mode 100644 index 00000000..6bba6b86 --- /dev/null +++ b/storage/storage.go @@ -0,0 +1,69 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Package storage is used to store and retrieve built Scale Functions and Scale Signatures +package storage + +import ( + "errors" + "strings" +) + +var ( + ErrInvalidName = errors.New("invalid name") + ErrInvalidTag = errors.New("invalid tag") + ErrInvalidOrganization = errors.New("invalid organization") +) + +const ( + DefaultDirectory = ".config/scale" +) + +func getNameFromName(fileName string) string { + split := strings.Split(fileName, "_") + if len(split) != 5 { + return "" + } + + return split[1] +} + +func getTagFromName(fileName string) string { + split := strings.Split(fileName, "_") + if len(split) != 5 { + return "" + } + + return split[2] +} + +func getOrgFromName(fileName string) string { + split := strings.Split(fileName, "_") + if len(split) != 5 { + return "" + } + + return split[0] +} + +func getHashFromName(fileName string) string { + split := strings.Split(fileName, "_") + if len(split) != 5 { + return "" + } + + return split[3] +} diff --git a/template.go b/template.go new file mode 100644 index 00000000..75bd1794 --- /dev/null +++ b/template.go @@ -0,0 +1,69 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + "fmt" + + "github.com/tetratelabs/wazero" + + interfaces "github.com/loopholelabs/scale-signature-interfaces" + "github.com/loopholelabs/scale/scalefunc" +) + +// template is a template for creating runnable scale functions +type template[T interfaces.Signature] struct { + // runtime is the scale runtime that the template belongs to + runtime *Scale[T] + + // identifier is the identifier for the template + identifier string + + // compiled is the compiled module source + compiled wazero.CompiledModule + + // next is the (optional) next function in the chain + next *template[T] + + // modulePool is the pool of modules for the template + modulePool *modulePool[T] + + // env contains the (optional) environment variables for the template + env map[string]string +} + +// newTemplate creates a new template from a scale function schema +func newTemplate[T interfaces.Signature](ctx context.Context, runtime *Scale[T], scaleFunc *scalefunc.Schema, env map[string]string) (*template[T], error) { + compiled, err := runtime.runtime.CompileModule(ctx, scaleFunc.Function) + if err != nil { + return nil, fmt.Errorf("failed to compile wasm module '%s': %w", scaleFunc.Name, err) + } + + templ := &template[T]{ + runtime: runtime, + identifier: fmt.Sprintf("%s:%s", scaleFunc.Name, scaleFunc.Tag), + compiled: compiled, + env: env, + } + + if scaleFunc.Stateless { + templ.modulePool = newModulePool[T](ctx, templ) + } + + return templ, nil +} diff --git a/template.ts b/template.ts new file mode 100644 index 00000000..a504a028 --- /dev/null +++ b/template.ts @@ -0,0 +1,57 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Signature } from "@loopholelabs/scale-signature-interfaces"; +import { Scale } from "./scale"; +import {ScaleFunc} from "./scalefunc/scalefunc"; +import {ModulePool} from "./pool"; + +export async function NewTemplate(runtime: Scale, scaleFunc: ScaleFunc, env?: { [key: string]: string }): Promise> { + const t = new Template(runtime, scaleFunc, env); + await t.Ready(); + return t; +} + +export class Template { + private readonly ready: Promise; + + public runtime: Scale + public identifier: string; + public compiled: WebAssembly.Module | undefined; + public next: undefined | Template; + + public modulePool: ModulePool | undefined; + public env: { [key: string]: string } | undefined; + + constructor(runtime: Scale, scaleFunc: ScaleFunc, env?: { [key: string]: string }) { + this.runtime = runtime; + this.identifier = `${scaleFunc.Name}:${scaleFunc.Tag}`; + this.env = env; + + if (scaleFunc.Stateless) { + this.modulePool = new ModulePool(this); + } + + this.ready = new Promise(async (resolve) => { // eslint-disable-line no-async-promise-executor + this.compiled = await WebAssembly.compile(scaleFunc.Function); + resolve(); + }); + } + + async Ready() { + await this.ready; + } +} \ No newline at end of file diff --git a/tracing.go b/tracing.go new file mode 100644 index 00000000..cf271761 --- /dev/null +++ b/tracing.go @@ -0,0 +1,78 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import ( + "context" + + "github.com/tetratelabs/wazero/api" +) + +// getFunctionNameLen is the Host function for getting the Function Name Length +func (r *Scale[T]) getFunctionNameLen(_ context.Context, module api.Module, params []uint64) { + r.activeModulesMu.RLock() + m := r.activeModules[module.Name()] + r.activeModulesMu.RUnlock() + if m == nil { + return + } + + params[0] = uint64(len([]byte(m.function.template.identifier))) +} + +// getFunctionName is the Host function for getting the Function Name +func (r *Scale[T]) getFunctionName(_ context.Context, module api.Module, params []uint64) { + r.activeModulesMu.RLock() + m := r.activeModules[module.Name()] + r.activeModulesMu.RUnlock() + if m == nil { + return + } + + ptr := uint32(params[0]) + mem := module.Memory() + mem.Write(ptr, []byte(m.function.template.identifier)) +} + +// getInstanceID is the Host function to get 16 byte Instance ID +func (r *Scale[T]) getInstanceID(_ context.Context, module api.Module, params []uint64) { + r.activeModulesMu.RLock() + m := r.activeModules[module.Name()] + r.activeModulesMu.RUnlock() + if m == nil { + return + } + + ptr := uint32(params[0]) + mem := module.Memory() + mem.Write(ptr, m.function.instance.identifier) +} + +// otelTraceJSON is the Host function to receive OTEL Trace data in JSON +// and then call the TraceDataCallback +func (r *Scale[T]) otelTraceJSON(_ context.Context, module api.Module, params []uint64) { + if r.TraceDataCallback == nil { + return + } + + ptr := uint32(params[0]) + length := uint32(params[1]) + mem := module.Memory() + if data, ok := mem.Read(ptr, length); ok { + r.TraceDataCallback(string(data)) + } +} diff --git a/tracing.ts b/tracing.ts new file mode 100644 index 00000000..22827d66 --- /dev/null +++ b/tracing.ts @@ -0,0 +1,102 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import {Module} from "./module"; +import {Signature} from "@loopholelabs/scale-signature-interfaces"; + +const ErrNoInstance = Error("no webassembly instance") +const ErrNoMemory = Error("no exported memory in webassembly instance") + +export interface HostFunctions extends WebAssembly.ModuleImports { + get_function_name_len(): number + get_function_name(ptr: number): void + get_instance_id(ptr: number): void + otel_trace_json(ptr: number, len: number): void +} + +export type CallbackFunction = (data: string) => void + +export class Tracing { + private exports: WebAssembly.Exports | undefined; + + private readonly module: Module; + private readonly traceCallback: CallbackFunction | undefined; + + constructor(module: Module, traceCallback: CallbackFunction | undefined) { + this.module = module; + this.traceCallback = traceCallback; + } + + getFunctionNameLen(): number { + const enc = new TextEncoder(); + const data = enc.encode(this.module.template.identifier); + return data.length; + } + + getFunctionName(ptr: number) { + const enc = new TextEncoder(); + const data = enc.encode(this.module.template.identifier); + const buffer = this.getDataView(); + for (let i=0;i; - readonly cookies?: Record; - readonly headers?: Record; - readonly query?: Record; - readonly formData?: Record; - readonly body?: any; - readonly mediaType?: string; - readonly responseHeader?: string; - readonly errors?: Record; -}; diff --git a/ts/client/core/ApiResult.ts b/ts/client/core/ApiResult.ts deleted file mode 100644 index b095dc77..00000000 --- a/ts/client/core/ApiResult.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export type ApiResult = { - readonly url: string; - readonly ok: boolean; - readonly status: number; - readonly statusText: string; - readonly body: any; -}; diff --git a/ts/client/core/CancelablePromise.ts b/ts/client/core/CancelablePromise.ts deleted file mode 100644 index 26ad3039..00000000 --- a/ts/client/core/CancelablePromise.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export class CancelError extends Error { - - constructor(message: string) { - super(message); - this.name = 'CancelError'; - } - - public get isCancelled(): boolean { - return true; - } -} - -export interface OnCancel { - readonly isResolved: boolean; - readonly isRejected: boolean; - readonly isCancelled: boolean; - - (cancelHandler: () => void): void; -} - -export class CancelablePromise implements Promise { - readonly [Symbol.toStringTag]!: string; - - private _isResolved: boolean; - private _isRejected: boolean; - private _isCancelled: boolean; - private readonly _cancelHandlers: (() => void)[]; - private readonly _promise: Promise; - private _resolve?: (value: T | PromiseLike) => void; - private _reject?: (reason?: any) => void; - - constructor( - executor: ( - resolve: (value: T | PromiseLike) => void, - reject: (reason?: any) => void, - onCancel: OnCancel - ) => void - ) { - this._isResolved = false; - this._isRejected = false; - this._isCancelled = false; - this._cancelHandlers = []; - this._promise = new Promise((resolve, reject) => { - this._resolve = resolve; - this._reject = reject; - - const onResolve = (value: T | PromiseLike): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isResolved = true; - this._resolve?.(value); - }; - - const onReject = (reason?: any): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isRejected = true; - this._reject?.(reason); - }; - - const onCancel = (cancelHandler: () => void): void => { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._cancelHandlers.push(cancelHandler); - }; - - Object.defineProperty(onCancel, 'isResolved', { - get: (): boolean => this._isResolved, - }); - - Object.defineProperty(onCancel, 'isRejected', { - get: (): boolean => this._isRejected, - }); - - Object.defineProperty(onCancel, 'isCancelled', { - get: (): boolean => this._isCancelled, - }); - - return executor(onResolve, onReject, onCancel as OnCancel); - }); - } - - public then( - onFulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onRejected?: ((reason: any) => TResult2 | PromiseLike) | null - ): Promise { - return this._promise.then(onFulfilled, onRejected); - } - - public catch( - onRejected?: ((reason: any) => TResult | PromiseLike) | null - ): Promise { - return this._promise.catch(onRejected); - } - - public finally(onFinally?: (() => void) | null): Promise { - return this._promise.finally(onFinally); - } - - public cancel(): void { - if (this._isResolved || this._isRejected || this._isCancelled) { - return; - } - this._isCancelled = true; - if (this._cancelHandlers.length) { - try { - for (const cancelHandler of this._cancelHandlers) { - cancelHandler(); - } - } catch (error) { - console.warn('Cancellation threw an error', error); - return; - } - } - this._cancelHandlers.length = 0; - this._reject?.(new CancelError('Request aborted')); - } - - public get isCancelled(): boolean { - return this._isCancelled; - } -} diff --git a/ts/client/core/OpenAPI.ts b/ts/client/core/OpenAPI.ts deleted file mode 100644 index f6ba3bb2..00000000 --- a/ts/client/core/OpenAPI.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { ApiRequestOptions } from './ApiRequestOptions'; - -type Resolver = (options: ApiRequestOptions) => Promise; -type Headers = Record; - -export type OpenAPIConfig = { - BASE: string; - VERSION: string; - WITH_CREDENTIALS: boolean; - CREDENTIALS: 'include' | 'omit' | 'same-origin'; - TOKEN?: string | Resolver; - USERNAME?: string | Resolver; - PASSWORD?: string | Resolver; - HEADERS?: Headers | Resolver; - ENCODE_PATH?: (path: string) => string; -}; - -export const OpenAPI: OpenAPIConfig = { - BASE: 'https://api.scale.sh/v1', - VERSION: '1.0', - WITH_CREDENTIALS: false, - CREDENTIALS: 'include', - TOKEN: undefined, - USERNAME: undefined, - PASSWORD: undefined, - HEADERS: undefined, - ENCODE_PATH: undefined, -}; diff --git a/ts/client/core/request.ts b/ts/client/core/request.ts deleted file mode 100644 index 0a87eb5f..00000000 --- a/ts/client/core/request.ts +++ /dev/null @@ -1,306 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import { ApiError } from './ApiError'; -import type { ApiRequestOptions } from './ApiRequestOptions'; -import type { ApiResult } from './ApiResult'; -import { CancelablePromise } from './CancelablePromise'; -import type { OnCancel } from './CancelablePromise'; -import type { OpenAPIConfig } from './OpenAPI'; - -const isDefined = (value: T | null | undefined): value is Exclude => { - return value !== undefined && value !== null; -}; - -const isString = (value: any): value is string => { - return typeof value === 'string'; -}; - -const isStringWithValue = (value: any): value is string => { - return isString(value) && value !== ''; -}; - -const isBlob = (value: any): value is Blob => { - return ( - typeof value === 'object' && - typeof value.type === 'string' && - typeof value.stream === 'function' && - typeof value.arrayBuffer === 'function' && - typeof value.constructor === 'function' && - typeof value.constructor.name === 'string' && - /^(Blob|File)$/.test(value.constructor.name) && - /^(Blob|File)$/.test(value[Symbol.toStringTag]) - ); -}; - -const isFormData = (value: any): value is FormData => { - return value instanceof FormData; -}; - -const base64 = (str: string): string => { - try { - return btoa(str); - } catch (err) { - // @ts-ignore - return Buffer.from(str).toString('base64'); - } -}; - -const getQueryString = (params: Record): string => { - const qs: string[] = []; - - const append = (key: string, value: any) => { - qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); - }; - - const process = (key: string, value: any) => { - if (isDefined(value)) { - if (Array.isArray(value)) { - value.forEach(v => { - process(key, v); - }); - } else if (typeof value === 'object') { - Object.entries(value).forEach(([k, v]) => { - process(`${key}[${k}]`, v); - }); - } else { - append(key, value); - } - } - }; - - Object.entries(params).forEach(([key, value]) => { - process(key, value); - }); - - if (qs.length > 0) { - return `?${qs.join('&')}`; - } - - return ''; -}; - -const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { - const encoder = config.ENCODE_PATH || encodeURI; - - const path = options.url - .replace('{api-version}', config.VERSION) - .replace(/{(.*?)}/g, (substring: string, group: string) => { - if (options.path?.hasOwnProperty(group)) { - return encoder(String(options.path[group])); - } - return substring; - }); - - const url = `${config.BASE}${path}`; - if (options.query) { - return `${url}${getQueryString(options.query)}`; - } - return url; -}; - -const getFormData = (options: ApiRequestOptions): FormData | undefined => { - if (options.formData) { - const formData = new FormData(); - - const process = (key: string, value: any) => { - if (isString(value) || isBlob(value)) { - formData.append(key, value); - } else { - formData.append(key, JSON.stringify(value)); - } - }; - - Object.entries(options.formData) - .filter(([_, value]) => isDefined(value)) - .forEach(([key, value]) => { - if (Array.isArray(value)) { - value.forEach(v => process(key, v)); - } else { - process(key, value); - } - }); - - return formData; - } - return undefined; -}; - -type Resolver = (options: ApiRequestOptions) => Promise; - -const resolve = async (options: ApiRequestOptions, resolver?: T | Resolver): Promise => { - if (typeof resolver === 'function') { - return (resolver as Resolver)(options); - } - return resolver; -}; - -const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); - - const headers = Object.entries({ - Accept: 'application/json', - ...additionalHeaders, - ...options.headers, - }) - .filter(([_, value]) => isDefined(value)) - .reduce((headers, [key, value]) => ({ - ...headers, - [key]: String(value), - }), {} as Record); - - if (isStringWithValue(token)) { - headers['Authorization'] = `Bearer ${token}`; - } - - if (isStringWithValue(username) && isStringWithValue(password)) { - const credentials = base64(`${username}:${password}`); - headers['Authorization'] = `Basic ${credentials}`; - } - - if (options.body) { - if (options.mediaType) { - headers['Content-Type'] = options.mediaType; - } else if (isBlob(options.body)) { - headers['Content-Type'] = options.body.type || 'application/octet-stream'; - } else if (isString(options.body)) { - headers['Content-Type'] = 'text/plain'; - } else if (!isFormData(options.body)) { - headers['Content-Type'] = 'application/json'; - } - } - - return new Headers(headers); -}; - -const getRequestBody = (options: ApiRequestOptions): any => { - if (options.body) { - if (options.mediaType?.includes('/json')) { - return JSON.stringify(options.body) - } else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) { - return options.body; - } else { - return JSON.stringify(options.body); - } - } - return undefined; -}; - -export const sendRequest = async ( - config: OpenAPIConfig, - options: ApiRequestOptions, - url: string, - body: any, - formData: FormData | undefined, - headers: Headers, - onCancel: OnCancel -): Promise => { - const controller = new AbortController(); - - const request: RequestInit = { - headers, - body: body ?? formData, - method: options.method, - signal: controller.signal, - }; - - if (config.WITH_CREDENTIALS) { - request.credentials = config.CREDENTIALS; - } - - onCancel(() => controller.abort()); - - return await fetch(url, request); -}; - -const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => { - if (responseHeader) { - const content = response.headers.get(responseHeader); - if (isString(content)) { - return content; - } - } - return undefined; -}; - -const getResponseBody = async (response: Response): Promise => { - if (response.status !== 204) { - try { - const contentType = response.headers.get('Content-Type'); - if (contentType) { - const isJSON = contentType.toLowerCase().startsWith('application/json'); - if (isJSON) { - return await response.json(); - } else { - return await response.text(); - } - } - } catch (error) { - console.error(error); - } - } - return undefined; -}; - -const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => { - const errors: Record = { - 400: 'Bad Request', - 401: 'Unauthorized', - 403: 'Forbidden', - 404: 'Not Found', - 500: 'Internal Server Error', - 502: 'Bad Gateway', - 503: 'Service Unavailable', - ...options.errors, - } - - const error = errors[result.status]; - if (error) { - throw new ApiError(options, result, error); - } - - if (!result.ok) { - throw new ApiError(options, result, 'Generic Error'); - } -}; - -/** - * Request method - * @param config The OpenAPI configuration object - * @param options The request options from the service - * @returns CancelablePromise - * @throws ApiError - */ -export const request = (config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise => { - return new CancelablePromise(async (resolve, reject, onCancel) => { - try { - const url = getUrl(config, options); - const formData = getFormData(options); - const body = getRequestBody(options); - const headers = await getHeaders(config, options); - - if (!onCancel.isCancelled) { - const response = await sendRequest(config, options, url, body, formData, headers, onCancel); - const responseBody = await getResponseBody(response); - const responseHeader = getResponseHeader(response, options.responseHeader); - - const result: ApiResult = { - url, - ok: response.ok, - status: response.status, - statusText: response.statusText, - body: responseHeader ?? responseBody, - }; - - catchErrorCodes(options, result); - - resolve(result.body); - } - } catch (error) { - reject(error); - } - }); -}; diff --git a/ts/client/index.ts b/ts/client/index.ts deleted file mode 100644 index a3336e4e..00000000 --- a/ts/client/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -export { ApiError } from './core/ApiError'; -export { CancelablePromise, CancelError } from './core/CancelablePromise'; -export { OpenAPI } from './core/OpenAPI'; -export type { OpenAPIConfig } from './core/OpenAPI'; - -export type { models_CreateAPIKeyRequest } from './models/models_CreateAPIKeyRequest'; -export type { models_CreateAPIKeyResponse } from './models/models_CreateAPIKeyResponse'; -export type { models_CreateDomainRequest } from './models/models_CreateDomainRequest'; -export type { models_CreateDomainResponse } from './models/models_CreateDomainResponse'; -export type { models_CreateFunctionResponse } from './models/models_CreateFunctionResponse'; -export type { models_DeployFunctionResponse } from './models/models_DeployFunctionResponse'; -export type { models_GetAPIKeyResponse } from './models/models_GetAPIKeyResponse'; -export type { models_GetFunctionResponse } from './models/models_GetFunctionResponse'; -export type { models_GetHealthResponse } from './models/models_GetHealthResponse'; -export type { models_UserInfoResponse } from './models/models_UserInfoResponse'; - -export { AccessService } from './services/AccessService'; -export { DeployService } from './services/DeployService'; -export { FunctionService } from './services/FunctionService'; -export { HealthService } from './services/HealthService'; -export { RegistryService } from './services/RegistryService'; -export { UserinfoService } from './services/UserinfoService'; diff --git a/ts/client/models/models_CreateAPIKeyRequest.ts b/ts/client/models/models_CreateAPIKeyRequest.ts deleted file mode 100644 index 8d2bfc41..00000000 --- a/ts/client/models/models_CreateAPIKeyRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_CreateAPIKeyRequest = { - name?: string; -}; - diff --git a/ts/client/models/models_CreateAPIKeyResponse.ts b/ts/client/models/models_CreateAPIKeyResponse.ts deleted file mode 100644 index b20c215f..00000000 --- a/ts/client/models/models_CreateAPIKeyResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_CreateAPIKeyResponse = { - apikey?: string; - created_at?: string; - id?: string; - name?: string; - organization?: string; -}; - diff --git a/ts/client/models/models_CreateDomainRequest.ts b/ts/client/models/models_CreateDomainRequest.ts deleted file mode 100644 index 632331c4..00000000 --- a/ts/client/models/models_CreateDomainRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_CreateDomainRequest = { - domain?: string; -}; - diff --git a/ts/client/models/models_CreateDomainResponse.ts b/ts/client/models/models_CreateDomainResponse.ts deleted file mode 100644 index 307e5304..00000000 --- a/ts/client/models/models_CreateDomainResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_CreateDomainResponse = { - cname?: string; - domain?: string; - txt_cname?: string; -}; - diff --git a/ts/client/models/models_CreateFunctionResponse.ts b/ts/client/models/models_CreateFunctionResponse.ts deleted file mode 100644 index dd42eac7..00000000 --- a/ts/client/models/models_CreateFunctionResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_CreateFunctionResponse = { - hash?: string; - name?: string; - organization?: string; - public?: boolean; - tag?: string; -}; - diff --git a/ts/client/models/models_DeployFunctionResponse.ts b/ts/client/models/models_DeployFunctionResponse.ts deleted file mode 100644 index 72165a5e..00000000 --- a/ts/client/models/models_DeployFunctionResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_DeployFunctionResponse = { - identifier?: string; - root_domain?: string; - subdomain?: string; -}; - diff --git a/ts/client/models/models_GetAPIKeyResponse.ts b/ts/client/models/models_GetAPIKeyResponse.ts deleted file mode 100644 index db1202e7..00000000 --- a/ts/client/models/models_GetAPIKeyResponse.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_GetAPIKeyResponse = { - created_at?: string; - id?: string; - name?: string; - organization?: string; -}; - diff --git a/ts/client/models/models_GetFunctionResponse.ts b/ts/client/models/models_GetFunctionResponse.ts deleted file mode 100644 index ba17c089..00000000 --- a/ts/client/models/models_GetFunctionResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_GetFunctionResponse = { - hash?: string; - name?: string; - organization?: string; - presigned_url?: string; - public?: boolean; - tag?: string; -}; - diff --git a/ts/client/models/models_GetHealthResponse.ts b/ts/client/models/models_GetHealthResponse.ts deleted file mode 100644 index 47100b07..00000000 --- a/ts/client/models/models_GetHealthResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_GetHealthResponse = { - database?: boolean; -}; - diff --git a/ts/client/models/models_UserInfoResponse.ts b/ts/client/models/models_UserInfoResponse.ts deleted file mode 100644 index 605df734..00000000 --- a/ts/client/models/models_UserInfoResponse.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type models_UserInfoResponse = { - email?: string; - member_organizations?: Array; - organization?: string; - owned_organizations?: Array; -}; - diff --git a/ts/client/services/AccessService.ts b/ts/client/services/AccessService.ts deleted file mode 100644 index adce2d6a..00000000 --- a/ts/client/services/AccessService.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_CreateAPIKeyRequest } from '../models/models_CreateAPIKeyRequest'; -import type { models_CreateAPIKeyResponse } from '../models/models_CreateAPIKeyResponse'; -import type { models_GetAPIKeyResponse } from '../models/models_GetAPIKeyResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class AccessService { - - /** - * Lists all the API Keys for the authenticated user. If the user's session is tied to an organization, only the API Keys for that organization will be returned. - * @returns models_GetAPIKeyResponse OK - * @throws ApiError - */ - public static getAccessApikey(): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/access/apikey', - errors: { - 401: `Unauthorized`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Creates a new API Key with the given `name` scoped to all the organizations the user is a member or owner of. If the user's session is already tied to an organization, the new API Key will be scoped to that organization. - * @param request Create API Key Request - * @returns models_CreateAPIKeyResponse OK - * @throws ApiError - */ - public static postAccessApikey( - request: models_CreateAPIKeyRequest, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/access/apikey', - body: request, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Gets information about a specific API Key given its `name` or `id`. If the user's session is tied to an organization, the API Key must be for that organization. - * @param nameorid API Key Name or ID - * @returns models_GetAPIKeyResponse OK - * @throws ApiError - */ - public static getAccessApikey1( - nameorid: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/access/apikey/{nameorid}', - path: { - 'nameorid': nameorid, - }, - errors: { - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Deletes an API Key given its `name` or `id`. If the user's session is tied to an organization, the API Key must be for that organization. - * @param nameorid API Key Name or ID - * @returns string OK - * @throws ApiError - */ - public static deleteAccessApikey( - nameorid: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/access/apikey/{nameorid}', - path: { - 'nameorid': nameorid, - }, - errors: { - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/client/services/DeployService.ts b/ts/client/services/DeployService.ts deleted file mode 100644 index b0731875..00000000 --- a/ts/client/services/DeployService.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_DeployFunctionResponse } from '../models/models_DeployFunctionResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class DeployService { - - /** - * Deploys a scale function - * @param functions functions - * @param name name - * @returns models_DeployFunctionResponse OK - * @throws ApiError - */ - public static postDeployFunction( - functions: Blob, - name?: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/deploy/function', - formData: { - 'functions': functions, - 'name': name, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Removes a deployed function from the servers - * @param identifier identifier - * @returns string OK - * @throws ApiError - */ - public static deleteDeployFunction( - identifier: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/deploy/function/{identifier}', - path: { - 'identifier': identifier, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/client/services/FunctionService.ts b/ts/client/services/FunctionService.ts deleted file mode 100644 index 0593d805..00000000 --- a/ts/client/services/FunctionService.ts +++ /dev/null @@ -1,250 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_CreateDomainRequest } from '../models/models_CreateDomainRequest'; -import type { models_CreateDomainResponse } from '../models/models_CreateDomainResponse'; -import type { models_CreateFunctionResponse } from '../models/models_CreateFunctionResponse'; -import type { models_DeployFunctionResponse } from '../models/models_DeployFunctionResponse'; -import type { models_GetFunctionResponse } from '../models/models_GetFunctionResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class FunctionService { - - /** - * Deploys a scale function - * @param functions functions - * @param name name - * @returns models_DeployFunctionResponse OK - * @throws ApiError - */ - public static postDeployFunction( - functions: Blob, - name?: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/deploy/function', - formData: { - 'functions': functions, - 'name': name, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Removes a deployed function from the servers - * @param identifier identifier - * @returns string OK - * @throws ApiError - */ - public static deleteDeployFunction( - identifier: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/deploy/function/{identifier}', - path: { - 'identifier': identifier, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. - * @param request Create Domain Request - * @returns models_CreateDomainResponse OK - * @throws ApiError - */ - public static postDomain( - request: models_CreateDomainRequest, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/domain', - body: request, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 412: `Precondition Failed`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Lists all the functions in the default organization. - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction(): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function', - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Uploads a function to the Scale Registry. If the session is scoped to an organization, the function will be uploaded to that `organization`, otherwise the function will be uploaded to the user's default `organization`. - * @param _function function - * @param _public public - * @param organization organization - * @returns models_CreateFunctionResponse OK - * @throws ApiError - */ - public static postRegistryFunction( - _function: Blob, - _public?: boolean, - organization?: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/registry/function', - formData: { - 'public': _public, - 'organization': organization, - 'function': _function, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 412: `Precondition Failed`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Retrieves a function from the default organization given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. - * @param name name - * @param tag tag - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction1( - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{name}/{tag}', - path: { - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Lists all the functions in the given `organization`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions from the `organization` will be returned. - * @param organization organization - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction2( - organization: string, - ): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{organization}', - path: { - 'organization': organization, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Retrieves a function from the given `organization` given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. - * @param organization organization - * @param name name - * @param tag tag - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction3( - organization: string, - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{organization}/{name}/{tag}', - path: { - 'organization': organization, - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Deletes a function from the given `organization` given its `name` and `tag`. If the session is scoped to an organization it must be the same as the organization of the function. - * @param organization organization - * @param name name - * @param tag tag - * @returns string OK - * @throws ApiError - */ - public static deleteRegistryFunction( - organization: string, - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/registry/function/{organization}/{name}/{tag}', - path: { - 'organization': organization, - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/client/services/HealthService.ts b/ts/client/services/HealthService.ts deleted file mode 100644 index 6c8ff666..00000000 --- a/ts/client/services/HealthService.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_GetHealthResponse } from '../models/models_GetHealthResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class HealthService { - - /** - * Returns the health and status of the various services that make up the API. - * @returns models_GetHealthResponse OK - * @throws ApiError - */ - public static getHealth(): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/health', - errors: { - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/client/services/RegistryService.ts b/ts/client/services/RegistryService.ts deleted file mode 100644 index d56c6fb4..00000000 --- a/ts/client/services/RegistryService.ts +++ /dev/null @@ -1,198 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_CreateDomainRequest } from '../models/models_CreateDomainRequest'; -import type { models_CreateDomainResponse } from '../models/models_CreateDomainResponse'; -import type { models_CreateFunctionResponse } from '../models/models_CreateFunctionResponse'; -import type { models_GetFunctionResponse } from '../models/models_GetFunctionResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class RegistryService { - - /** - * Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. - * @param request Create Domain Request - * @returns models_CreateDomainResponse OK - * @throws ApiError - */ - public static postDomain( - request: models_CreateDomainRequest, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/domain', - body: request, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 412: `Precondition Failed`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Lists all the functions in the default organization. - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction(): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function', - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Uploads a function to the Scale Registry. If the session is scoped to an organization, the function will be uploaded to that `organization`, otherwise the function will be uploaded to the user's default `organization`. - * @param _function function - * @param _public public - * @param organization organization - * @returns models_CreateFunctionResponse OK - * @throws ApiError - */ - public static postRegistryFunction( - _function: Blob, - _public?: boolean, - organization?: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/registry/function', - formData: { - 'public': _public, - 'organization': organization, - 'function': _function, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 412: `Precondition Failed`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Retrieves a function from the default organization given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. - * @param name name - * @param tag tag - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction1( - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{name}/{tag}', - path: { - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Lists all the functions in the given `organization`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions from the `organization` will be returned. - * @param organization organization - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction2( - organization: string, - ): CancelablePromise> { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{organization}', - path: { - 'organization': organization, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Retrieves a function from the given `organization` given its `name` and `tag`. If the session is scoped to the same `organization`, functions that are not public will be returned, otherwise only public functions will be returned. - * @param organization organization - * @param name name - * @param tag tag - * @returns models_GetFunctionResponse OK - * @throws ApiError - */ - public static getRegistryFunction3( - organization: string, - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'GET', - url: '/registry/function/{organization}/{name}/{tag}', - path: { - 'organization': organization, - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - - /** - * Deletes a function from the given `organization` given its `name` and `tag`. If the session is scoped to an organization it must be the same as the organization of the function. - * @param organization organization - * @param name name - * @param tag tag - * @returns string OK - * @throws ApiError - */ - public static deleteRegistryFunction( - organization: string, - name: string, - tag: string, - ): CancelablePromise { - return __request(OpenAPI, { - method: 'DELETE', - url: '/registry/function/{organization}/{name}/{tag}', - path: { - 'organization': organization, - 'name': name, - 'tag': tag, - }, - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 404: `Not Found`, - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/client/services/UserinfoService.ts b/ts/client/services/UserinfoService.ts deleted file mode 100644 index 1e98a538..00000000 --- a/ts/client/services/UserinfoService.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ -import type { models_UserInfoResponse } from '../models/models_UserInfoResponse'; - -import type { CancelablePromise } from '../core/CancelablePromise'; -import { OpenAPI } from '../core/OpenAPI'; -import { request as __request } from '../core/request'; - -export class UserinfoService { - - /** - * Checks if a user is logged in and returns the user's information. - * @returns models_UserInfoResponse OK - * @throws ApiError - */ - public static postUserinfo(): CancelablePromise { - return __request(OpenAPI, { - method: 'POST', - url: '/userinfo', - errors: { - 400: `Bad Request`, - 401: `Unauthorized`, - 500: `Internal Server Error`, - }, - }); - } - -} diff --git a/ts/compile/README.md b/ts/compile/README.md deleted file mode 100644 index dd73911c..00000000 --- a/ts/compile/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Typescript guest builder - -## Quickstart - -1. Build the rust jsbuilder - -``` - cd builder - ./install-wasi-sdk.sh - make -``` - -2. Build the example http scale functions - -``` - cd runner - npm install - ./build.sh -``` - -This should create 3 wasm modules. - -| Scale file | Description | -| ----------------------- | ---------------------------------------- | -| module_error.wasm | This scale function just throws an error | -| module_endpoint.wasm | This scale function sets the Body | -| module_middleware.wasm | This scale function adds a header | diff --git a/ts/compile/builder/Cargo.toml b/ts/compile/builder/Cargo.toml deleted file mode 100644 index 1bc42ff0..00000000 --- a/ts/compile/builder/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[workspace] -members = [ - "crates/core", - "crates/cli", -] - -[profile.release] -lto = true -opt-level = 3 diff --git a/ts/compile/builder/Makefile b/ts/compile/builder/Makefile deleted file mode 100644 index cbfe3c35..00000000 --- a/ts/compile/builder/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.PHONY: cli core clean -.DEFAULT_GOAL := cli - -current_dir := $(shell pwd) -export QUICKJS_WASM_SYS_WASI_SDK_PATH := $(current_dir)/wasi-sdk - -download-wasi-sdk: - ./install-wasi-sdk.sh - -install: - cargo install --path crates/cli - -cli: core - cd crates/cli && cargo build --release && cd - - -core: - cd crates/core \ - && cargo build --release --target=wasm32-wasi \ - && cd - - -jssource: - cd crates/core \ - && cargo build --release --target=wasm32-wasi --no-default-features --features js_source --target-dir target_jssource \ - && cd - - -clean: clean-wasi-sdk clean-cargo - -clean-cargo: - cargo clean - -clean-wasi-sdk: - rm -r wasi-sdk 2> /dev/null || true diff --git a/ts/compile/builder/README.md b/ts/compile/builder/README.md deleted file mode 100644 index 9228e399..00000000 --- a/ts/compile/builder/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# JS Builder - -JSBuilder is a tool for building a .wasm file from some js for use with scale functions. - -## Usage - -There are three options when it comes to building. - -### Build to a wasm with embedded js - -``` -JS_SOURCE=/path/to/index.js make jssource -cp crates/core/target_jssource/wasm32-wasi/release/jsbuilder_core.wasm index.wasm -``` - -### With size optimization (Compress js) - -``` -gzip /path/to/index.js -JS_SOURCE=/path/to/index.js.gz make jssource -cp crates/core/target_jssource/wasm32-wasi/release/jsbuilder_core.wasm index.wasm -``` - -### With speed optimization for fast cold start - -``` -make - -Should be an executable in `target/release/jsbuilder` - -target/release/jsbuilder -o something.wasm index.js -``` diff --git a/ts/compile/builder/crates/cli/Cargo.toml b/ts/compile/builder/crates/cli/Cargo.toml deleted file mode 100644 index b4250048..00000000 --- a/ts/compile/builder/crates/cli/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "jsbuilder" -version = "0.0.1" -build = "build.rs" - -[[bin]] -name = "jsbuilder" - -[dependencies] -wizer = "1.6.0" -# { git = "https://github.com/bytecodealliance/wizer", branch = "main" } -which = "4.2" -structopt = "0.3" -anyhow = "1.0" -tempfile = "3.2.0" -binaryen = "0.12.0" - -[dev-dependencies] -wasmtime = "0.35.3" -wasmtime-wasi = "0.35.3" -wasi-common = "0.35.3" -serde_json = "1.0" -uuid = { version = "0.8", features = ["v4"] } -serde = { version = "1.0", default-features = false, features = ["derive"] } diff --git a/ts/compile/builder/crates/cli/build.rs b/ts/compile/builder/crates/cli/build.rs deleted file mode 100644 index 361f422c..00000000 --- a/ts/compile/builder/crates/cli/build.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::env; -use std::fs; -use std::path::PathBuf; - -fn main() { - if let Ok("cargo-clippy") = env::var("CARGO_CFG_FEATURE").as_ref().map(String::as_str) { - stub_engine_for_clippy(); - } else { - copy_engine_binary(); - } -} - -// When using clippy, we need to write a stubbed engine.wasm file to ensure compilation succeeds. This -// skips building the actual engine.wasm binary that would be injected into the CLI binary. -fn stub_engine_for_clippy() { - let engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("engine.wasm"); - - if !engine_path.exists() { - std::fs::write(engine_path, &[]).expect("failed to write empty engine.wasm stub"); - println!("cargo:warning=using stubbed engine.wasm for static analysis purposes..."); - } -} - -// Copy the engine binary build from the `core` crate -fn copy_engine_binary() { - let override_engine_path = env::var("JSBUILDER_ENGINE_PATH"); - let is_override = override_engine_path.is_ok(); - let mut engine_path = PathBuf::from( - override_engine_path.unwrap_or_else(|_| env::var("CARGO_MANIFEST_DIR").unwrap()), - ); - - if !is_override { - engine_path.pop(); - engine_path.pop(); - engine_path = engine_path.join("target/wasm32-wasi/release/jsbuilder_core.wasm"); - } - - println!("cargo:rerun-if-changed={:?}", engine_path); - println!("cargo:rerun-if-changed=build.rs"); - - if engine_path.exists() { - let copied_engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("engine.wasm"); - - fs::copy(&engine_path, &copied_engine_path).unwrap(); - } -} diff --git a/ts/compile/builder/crates/cli/src/main.rs b/ts/compile/builder/crates/cli/src/main.rs deleted file mode 100644 index 6ab45e4e..00000000 --- a/ts/compile/builder/crates/cli/src/main.rs +++ /dev/null @@ -1,47 +0,0 @@ -mod opt; -mod options; - -extern crate anyhow; -extern crate binaryen; -extern crate wizer; -extern crate structopt; - -use crate::options::Options; -use anyhow::{bail, Context, Result}; -use std::env; -use std::{fs, process::Command}; -use structopt::StructOpt; - -fn main() -> Result<()> { - let opts = Options::from_args(); - let wizen = env::var("JS_WIZEN"); - - if wizen.eq(&Ok("1".into())) { - let wasm: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/engine.wasm")); - opt::Optimizer::new(wasm) - .optimize(true) - .write_optimized_wasm(opts.output)?; - - env::remove_var("JS_WIZEN"); - - return Ok(()); - } - - let contents = fs::File::open(&opts.input) - .with_context(|| format!("Failed to open input file {}", opts.input.display()))?; - let self_cmd = env::args().next().unwrap(); - - env::set_var("JS_WIZEN", "1"); - let status = Command::new(self_cmd) - .arg(&opts.input) - .arg("-o") - .arg(&opts.output) - .stdin(contents) - .status()?; - - if !status.success() { - bail!("Couldn't create wasm from input"); - } - - Ok(()) -} diff --git a/ts/compile/builder/crates/cli/src/opt.rs b/ts/compile/builder/crates/cli/src/opt.rs deleted file mode 100644 index ed052223..00000000 --- a/ts/compile/builder/crates/cli/src/opt.rs +++ /dev/null @@ -1,52 +0,0 @@ -use anyhow::{bail, Error, Result}; -use binaryen::{CodegenConfig, Module}; -use std::path::Path; -use wizer::Wizer; - -pub(crate) struct Optimizer<'a> { - optimize: bool, - wasm: &'a [u8], -} - -impl<'a> Optimizer<'a> { - pub fn new(wasm: &'a [u8]) -> Self { - Self { - wasm, - optimize: false, - } - } - - pub fn optimize(self, optimize: bool) -> Self { - Self { optimize, ..self } - } - - pub fn write_optimized_wasm(self, dest: impl AsRef) -> Result<(), Error> { - let mut wasm = Wizer::new() - .wasm_bulk_memory(true) - .allow_wasi(true)? - .inherit_stdio(true) - .run(self.wasm)?; - - if self.optimize { - let codegen_cfg = CodegenConfig { - optimization_level: 3, // Aggressively optimize for speed. - shrink_level: 0, // Don't optimize for size at the expense of performance. - debug_info: false, - }; - - if let Ok(mut module) = Module::read(&wasm) { - module.optimize(&codegen_cfg); - module - .run_optimization_passes(vec!["strip"], &codegen_cfg) - .unwrap(); - wasm = module.write(); - } else { - bail!("Unable to read wasm binary for wasm-opt optimizations"); - } - } - - std::fs::write(dest.as_ref(), wasm)?; - - Ok(()) - } -} diff --git a/ts/compile/builder/crates/cli/src/options.rs b/ts/compile/builder/crates/cli/src/options.rs deleted file mode 100644 index da6334f8..00000000 --- a/ts/compile/builder/crates/cli/src/options.rs +++ /dev/null @@ -1,12 +0,0 @@ -use std::path::PathBuf; -use structopt::StructOpt; - -#[derive(Debug, StructOpt)] -#[structopt(name = "jsbuilder", about = "JavaScript to WebAssembly")] -pub struct Options { - #[structopt(parse(from_os_str))] - pub input: PathBuf, - - #[structopt(short = "o", parse(from_os_str), default_value = "index.wasm")] - pub output: PathBuf, -} diff --git a/ts/compile/builder/crates/core/Cargo.toml b/ts/compile/builder/crates/core/Cargo.toml deleted file mode 100644 index 95776d35..00000000 --- a/ts/compile/builder/crates/core/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "jsbuilder-core" -version = "0.0.1" - -[[bin]] -name = "jsbuilder_core" -path = "src/main.rs" - -[dependencies] -anyhow = "1.0" -quickjs-wasm-sys = "0.1.1" -once_cell = "1.4.0" -polyglot_rs = "0.6.1" -flate2 = "1.0.25" - -[features] -# Optimize using wizer to do pre-init -default = ["wizer_opt"] -wizer_opt = [] -js_source = [] diff --git a/ts/compile/builder/crates/core/src/main.rs b/ts/compile/builder/crates/core/src/main.rs deleted file mode 100644 index ed83f1c1..00000000 --- a/ts/compile/builder/crates/core/src/main.rs +++ /dev/null @@ -1,304 +0,0 @@ -extern crate quickjs_wasm_sys; -extern crate once_cell; -extern crate polyglot_rs; -extern crate flate2; - -use polyglot_rs::{Encoder}; // So we can encode an error... - -use quickjs_wasm_sys::{ - ext_js_exception, ext_js_undefined, size_t as JS_size_t, JSCFunctionData, - JSContext, JSValue, JS_Eval, JS_FreeCString, JS_GetGlobalObject, - JS_Call, JS_NewCFunctionData, JS_NewContext, JS_NewInt32_Ext, - JS_NewObject, JS_NewRuntime, JS_ToCStringLen2, JS_EVAL_TYPE_GLOBAL, - JS_GetPropertyStr, JS_GetPropertyUint32, JS_DefinePropertyValueStr, JS_PROP_C_W_E, - JS_TAG_EXCEPTION, JS_GetArrayBuffer, JS_BigIntToUint64 -}; -use std::os::raw::{c_int, c_void}; - -#[cfg(feature = "js_source")] -use flate2::read::GzDecoder; - -use std::str; - -use std::io::{self, Cursor, Read, Write}; -use std::ffi::CString; -use std::error::Error; - -use once_cell::sync::OnceCell; -static mut JS_INITIALIZED: bool = false; -static mut JS_CONTEXT: OnceCell<*mut JSContext> = OnceCell::new(); - -static mut ENTRY_EXPORTS: OnceCell = OnceCell::new(); - -static mut ENTRY_MAIN: OnceCell = OnceCell::new(); -static mut ENTRY_RUN: OnceCell = OnceCell::new(); -static mut ENTRY_RESIZE: OnceCell = OnceCell::new(); - -static SCRIPT_NAME: &str = "script.js"; - -static mut GLOBAL_ERROR: Vec = Vec::new(); - - -// The function env.next exported by the host -#[link(wasm_import_module = "env")] -extern "C" { - #[link_name = "next"] - fn _next(ptr: u32, size: u32); -} - -// Wrap the exported next function so it can be called from js -fn nextwrap(context: *mut JSContext, _jsval1: JSValue, _int1: c_int, jsval2: *mut JSValue, _int2: c_int) -> JSValue { - unsafe { - // The args are [ptr / len] - // TODO: Make sure it's an array of 2 vals? - let ptr = JS_GetPropertyUint32(context, *jsval2, 0); - let len = JS_GetPropertyUint32(context, *jsval2, 1); - - _next(ptr as u32, len as u32); - return ext_js_undefined - } -} - -// Get the address of a javascript ArrayBuffer -fn getaddrwrap(context: *mut JSContext, _jsval1: JSValue, _int1: c_int, jsval2: *mut JSValue, _int2: c_int) -> JSValue { - unsafe { - let mut len = 0; - let addr = JS_GetArrayBuffer(context, &mut len, *jsval2) as i32; - return JS_NewInt32_Ext(context, addr); - } -} - -// If we're doing wizer_opt, include the init here... -#[cfg(feature = "wizer_opt")] -#[export_name = "wizer.initialize"] -pub extern "C" fn init() { - js_init(); -} - -fn js_init() { - unsafe { - let runtime = JS_NewRuntime(); - if runtime.is_null() { - panic!("Couldn't create JavaScript runtime"); - } - let context = JS_NewContext(runtime); - if context.is_null() { - panic!("Couldn't create JavaScript context"); - } - - let mut js_contents = String::new(); - - // If we are building with js_source, we should include the data. If it ends with .gz then unzip it. - #[cfg(feature = "js_source")] - { - let data = include_bytes!(env!("JS_SOURCE")); - if env!("JS_SOURCE").ends_with(".gz") { - // Unzip the data - let mut gz = GzDecoder::new(&data[..]); - gz.read_to_string(&mut js_contents).unwrap(); - } else { - // Include the js file as a string - js_contents = str::from_utf8(data).unwrap().to_string(); - } - } - - // If we are not building with js_source, we will read the javascript from stdin, which comes from the cli tool - #[cfg(not(feature = "js_source"))] - io::stdin().read_to_string(&mut js_contents).unwrap(); - - let len = js_contents.len() - 1; - let input = CString::new(js_contents).unwrap(); - let script_name = CString::new(SCRIPT_NAME).unwrap(); - JS_Eval(context, input.as_ptr(), len as _, script_name.as_ptr(), JS_EVAL_TYPE_GLOBAL as i32); - - let global = JS_GetGlobalObject(context); - let exports_key = CString::new("Exports").unwrap(); - let exports = JS_GetPropertyStr(context, global, exports_key.as_ptr()); - - let main_key = CString::new("main").unwrap(); - let main_fn = JS_GetPropertyStr(context, exports, main_key.as_ptr()); - ENTRY_MAIN.set(main_fn).unwrap(); - - let run_key = CString::new("run").unwrap(); - let run_fn = JS_GetPropertyStr(context, exports, run_key.as_ptr()); - ENTRY_RUN.set(run_fn).unwrap(); - - let resize_key = CString::new("resize").unwrap(); - let resize_fn = JS_GetPropertyStr(context, exports, resize_key.as_ptr()); - ENTRY_RESIZE.set(resize_fn).unwrap(); - - // Setup console.log and console.error to pipe through to io::stderr - let log_cb = console_log_to(io::stderr()); - let error_cb = console_log_to(io::stderr()); - - let console = JS_NewObject(context); - set_callback(context, console, "log", log_cb); - set_callback(context, console, "error", error_cb); - - let console_name = CString::new("console").unwrap(); - JS_DefinePropertyValueStr(context, global, console_name.as_ptr(), console, JS_PROP_C_W_E as i32); - - // Setup a function called next() in the global_object - set_callback(context, global, "scale_fn_next", &nextwrap); - - // Setup a function called getaddr() in the global object - set_callback(context, global, "getaddr", &getaddrwrap); - - ENTRY_EXPORTS.set(exports).unwrap(); - - JS_CONTEXT.set(context).unwrap(); - - JS_INITIALIZED = true; - } -} - -fn set_callback(context: *mut JSContext, global: JSValue, fn_name: impl Into>, f: F) -where - F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, -{ - unsafe { - let trampoline = build_trampoline(&f); - let data = &f as *const _ as *mut c_void as *mut JSValue; - let cb = JS_NewCFunctionData(context, trampoline, 0, 1, 1, data); - - let name_fn = CString::new(fn_name).unwrap(); - - JS_DefinePropertyValueStr(context, global, name_fn.as_ptr(), cb, JS_PROP_C_W_E as i32); - } -} - -fn build_trampoline(_f: &F) -> JSCFunctionData -where - F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, -{ - // We build a trampoline to jump between c <-> rust and allow closing over a specific context. - // For more info around how this works, see https://adventures.michaelfbryan.com/posts/rust-closures-in-ffi/. - unsafe extern "C" fn trampoline( - ctx: *mut JSContext, - this: JSValue, - argc: c_int, - argv: *mut JSValue, - magic: c_int, - data: *mut JSValue, - ) -> JSValue - where - F: FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue, - { - let closure_ptr = data; - let closure: &mut F = &mut *(closure_ptr as *mut F); - (*closure)(ctx, this, argc, argv, magic) - } - - Some(trampoline::) -} - -fn console_log_to( - mut stream: T, -) -> impl FnMut(*mut JSContext, JSValue, c_int, *mut JSValue, c_int) -> JSValue -where - T: Write, -{ - move |ctx: *mut JSContext, _this: JSValue, argc: c_int, argv: *mut JSValue, _magic: c_int| { - let mut len: JS_size_t = 0; - for i in 0..argc { - if i != 0 { - write!(stream, " ").unwrap(); - } - - let str_ptr = unsafe { JS_ToCStringLen2(ctx, &mut len, *argv.offset(i as isize), 0) }; - if str_ptr.is_null() { - return unsafe { ext_js_exception }; - } - - let str_ptr = str_ptr as *const u8; - let str_len = len as usize; - let buffer = unsafe { std::slice::from_raw_parts(str_ptr, str_len) }; - - stream.write_all(buffer).unwrap(); - unsafe { JS_FreeCString(ctx, str_ptr as *const i8) }; - } - - writeln!(stream,).unwrap(); - unsafe { ext_js_undefined } - } -} - -fn main() { - unsafe { - if !JS_INITIALIZED { - js_init(); - } - - let context = JS_CONTEXT.get().unwrap(); - let exports = ENTRY_EXPORTS.get().unwrap(); - let main = ENTRY_MAIN.get().unwrap(); - - let args: Vec = Vec::new(); - let _ret = JS_Call(*context, *main, *exports, args.len() as i32, args.as_slice().as_ptr() as *mut JSValue); - } -} - -fn global_err(msg: &str) -> u64 { - let mut cursor = Cursor::new(Vec::new()); - cursor.encode_error(Box::::from(msg)).unwrap(); - - unsafe { - - GLOBAL_ERROR = cursor.into_inner(); - - // Now pack the address and length and return... - let ptr = GLOBAL_ERROR.as_ptr() as u64; - let len = GLOBAL_ERROR.len() as u64; - return (ptr << 32) | len; - } -} - - -#[export_name = "run"] -fn run() -> u64 { - unsafe { - let context = JS_CONTEXT.get().unwrap(); - let exports = ENTRY_EXPORTS.get().unwrap(); - let runfn = ENTRY_RUN.get().unwrap(); - - let args: Vec = Vec::new(); - let ret = JS_Call(*context, *runfn, *exports, args.len() as i32, args.as_slice().as_ptr() as *mut JSValue); - - let ret_tag = (ret >> 32) as i32; - if ret_tag == JS_TAG_EXCEPTION { - // TODO: Get the exact exception message and return to the host - return global_err(&"Rust/js: Exception from js runtime"); - } - - let mut valret = 0_u64; - let err = JS_BigIntToUint64(*context, &mut valret, ret); - if err < 0 { - return global_err(&"Rust/js: Error converting run return value"); - } - return valret; - } -} - -#[cfg_attr(all(target_arch = "wasm32"), export_name = "resize")] -#[no_mangle] -pub unsafe extern "C" fn resize(size: u32) -> *mut u8 { - unsafe { - let context = JS_CONTEXT.get().unwrap(); - let exports = ENTRY_EXPORTS.get().unwrap(); - let resizefn = ENTRY_RESIZE.get().unwrap(); - - let mut args: Vec = Vec::new(); - let jval = JS_NewInt32_Ext(*context, size as i32); - args.push(jval); - - let ret = JS_Call(*context, *resizefn, *exports, args.len() as i32, args.as_slice().as_ptr() as *mut JSValue); - - let ret_tag = (ret >> 32) as i32; - if ret_tag == JS_TAG_EXCEPTION { - // TODO: Get the exact exception message and return to the host - return global_err("Rust/js: Exception from js runtime") as *mut u8; - } - - return ret as *mut u8; - } -} \ No newline at end of file diff --git a/ts/compile/builder/install-wasi-sdk.sh b/ts/compile/builder/install-wasi-sdk.sh deleted file mode 100755 index 02bb9ba6..00000000 --- a/ts/compile/builder/install-wasi-sdk.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -PATH_TO_SDK="wasi-sdk" -if [[ ! -d $PATH_TO_SDK ]]; then - TMPGZ=$(mktemp) - VERSION_MAJOR="12" - VERSION_MINOR="0" - if [[ "$(uname -s)" == "Darwin" ]]; then - curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-macos.tar.gz --output $TMPGZ - else - curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-linux.tar.gz --output $TMPGZ - fi - mkdir $PATH_TO_SDK - tar xf $TMPGZ -C $PATH_TO_SDK --strip-components=1 -fi - -# NB This doesn't set externally, so we'd need to build here or something... -echo "You should set QUICKJS_WASM_SYS_WASI_SDK_PATH to " `pwd`/${PATH_TO_SDK} \ No newline at end of file diff --git a/ts/compile/compile.go b/ts/compile/compile.go deleted file mode 100644 index c2b3501a..00000000 --- a/ts/compile/compile.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package compile - -import ( - "io" - "text/template" - - "github.com/loopholelabs/scale/ts/compile/templates" - "github.com/loopholelabs/scalefile" -) - -type Generator struct { - template *template.Template -} - -func NewGenerator() *Generator { - templ := template.Must(template.New("typescript").ParseFS(templates.FS, "*")) - return &Generator{ - template: templ, - } -} - -func (g *Generator) GeneratePackage(writer io.Writer, dependencies []*scalefile.Dependency, signature string, signaturePath string) error { - return g.template.ExecuteTemplate(writer, "package.json.templ", map[string]interface{}{ - "dependencies": dependencies, - "signature": signature, - "signature_path": signaturePath, - }) -} - -func (g *Generator) GenerateRunner(writer io.Writer, path string, signature string) error { - return g.template.ExecuteTemplate(writer, "runner.ts.templ", map[string]interface{}{ - "path": path, - "signature": signature, - }) -} diff --git a/ts/compile/runner/.parcelrc b/ts/compile/runner/.parcelrc deleted file mode 100644 index 97d580a3..00000000 --- a/ts/compile/runner/.parcelrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "@parcel/config-default", - "validators": { - "*.ts": [ - "@parcel/validator-typescript" - ] - } -} diff --git a/ts/compile/runner/build_test_modules.sh b/ts/compile/runner/build_test_modules.sh deleted file mode 100755 index 527f8a32..00000000 --- a/ts/compile/runner/build_test_modules.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# First go build the jsbuilder -#cd ../builder -#make -#cd ../runner - -# Build the typescript targets -npm run build - -# Now convert the js to wasm modules... - -for TARGET in module_middleware module_endpoint module_error -do - -# Find the nomodule version of the compiled js -JS=`cat dist/${TARGET}/index.html | tr ">" "\n" | grep nomodule | awk -F'"' '{print $2}'` - -# Use the builder to build a wasm module -BUILDER=../builder/target/release/jsbuilder - -echo "Building ${TARGET}_opt" -${BUILDER} dist/${TARGET}${JS} -o wasm/${TARGET}_opt.wasm - -SRC=`realpath dist/${TARGET}${JS}` - -cat ${SRC} | gzip > ${SRC}.gz - -# Build a non-optimized version -cd ../builder - -echo "Building ${TARGET}" -rm -rf crates/core/target_jssource -JS_SOURCE=${SRC} make jssource -cp crates/core/target_jssource/wasm32-wasi/release/jsbuilder_core.wasm ../runner/wasm/${TARGET}.wasm - -echo "Building ${TARGET}_gz" -rm -rf crates/core/target_jssource -JS_SOURCE=${SRC}.gz make jssource -cp crates/core/target_jssource/wasm32-wasi/release/jsbuilder_core.wasm ../runner/wasm/${TARGET}_gz.wasm - -cd ../runner -done diff --git a/ts/compile/runner/jest.config.json b/ts/compile/runner/jest.config.json deleted file mode 100644 index c3bffab2..00000000 --- a/ts/compile/runner/jest.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "clearMocks": true, - "collectCoverage": true, - "coverageDirectory": "coverage", - "preset": "ts-jest", - "testEnvironment": "node", - "testMatch": [ - "**/*.test.ts" - ] -} diff --git a/ts/compile/runner/package-lock.json b/ts/compile/runner/package-lock.json deleted file mode 100644 index 66233e6b..00000000 --- a/ts/compile/runner/package-lock.json +++ /dev/null @@ -1,8134 +0,0 @@ -{ - "name": "@loopholelabs/scale-http-examples", - "version": "0.1.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "@loopholelabs/scale-http-examples", - "version": "0.1.0", - "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale": "^0.3.13", - "@loopholelabs/scale-signature-http": "^0.3.7", - "@loopholelabs/scalefile": "^0.1.9" - }, - "devDependencies": { - "@parcel/packager-ts": "^2.7.0", - "@parcel/transformer-typescript-types": "^2.7.0", - "@parcel/validator-typescript": "^2.7.0", - "@types/express": "^4.17.14", - "@types/fastestsmallesttextencoderdecoder": "^1.0.0", - "@types/jest": "^29.2.0", - "@types/node": "^18.11.5", - "@types/supertest": "^2.0.12", - "@types/text-encoding": "^0.0.36", - "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "jest": "^29.2.2", - "jest-environment-jsdom": "^29.2.2", - "parcel": "^2.7.0", - "parcel-reporter-static-files-copy": "^1.4.0", - "process": "^0.11.10", - "stream-browserify": "^3.0.0", - "supertest": "^6.3.1", - "ts-jest": "^29.0.3", - "tty-browserify": "^0.0.1", - "typescript": "^4.7.0" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", - "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.1.0", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@apidevtools/json-schema-ref-parser": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", - "integrity": "sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==", - "dependencies": { - "@jsdevtools/ono": "^7.1.3", - "@types/json-schema": "^7.0.6", - "call-me-maybe": "^1.0.1", - "js-yaml": "^4.1.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", - "dependencies": { - "@babel/highlight": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.0.tgz", - "integrity": "sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.0.tgz", - "integrity": "sha512-PuxUbxcW6ZYe656yL3EAhpy7qXKq0DmYsrJLpbB8XrsCP9Nm+XCg9XFMb5vIDliPD7+U/+M+QJlH17XOcB7eXA==", - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.0", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-module-transforms": "^7.21.0", - "@babel/helpers": "^7.21.0", - "@babel/parser": "^7.21.0", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.0", - "@babel/types": "^7.21.0", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.2", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.21.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.1.tgz", - "integrity": "sha512-1lT45bAYlQhFn/BHivJs43AiW2rg3/UbLyShGfF3C0KmHvO5fSghWd5kBJy30kpRRucGzXStvnnCFniCR2kXAA==", - "dependencies": { - "@babel/types": "^7.21.0", - "@jridgewell/gen-mapping": "^0.3.2", - "@jridgewell/trace-mapping": "^0.3.17", - "jsesc": "^2.5.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dependencies": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz", - "integrity": "sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==", - "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-validator-option": "^7.18.6", - "browserslist": "^4.21.3", - "lru-cache": "^5.1.1", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", - "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz", - "integrity": "sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ==", - "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.20.2", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.2", - "@babel/types": "^7.21.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-plugin-utils": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz", - "integrity": "sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", - "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", - "dependencies": { - "@babel/types": "^7.20.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dependencies": { - "@babel/types": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.0.tgz", - "integrity": "sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA==", - "dependencies": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.0", - "@babel/types": "^7.21.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/parser": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.2.tgz", - "integrity": "sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==", - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/plugin-syntax-async-generators": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-bigint": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", - "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-properties": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.12.13" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-meta": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", - "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-json-strings": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", - "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-numeric-separator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-object-rest-spread": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-catch-binding": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-chaining": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-top-level-await": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz", - "integrity": "sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.19.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", - "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.2.tgz", - "integrity": "sha512-ts5FFU/dSUPS13tv8XiEObDu9K+iagEKME9kAbaP7r0Y9KtZJZ+NGndDvWoRAYNpeWafbpFeki3q9QoMD6gxyw==", - "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.1", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.2", - "@babel/types": "^7.21.2", - "debug": "^4.1.0", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.2.tgz", - "integrity": "sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw==", - "dependencies": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@bcoe/v8-coverage": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", - "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==" - }, - "node_modules/@istanbuljs/load-nyc-config": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", - "dependencies": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/@jest/console": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.5.0.tgz", - "integrity": "sha512-NEpkObxPwyw/XxZVLPmAGKE89IQRp4puc6IQRPru6JKd1M3fW9v1xM1AnzIJE65hbCkzQAdnL8P47e9hzhiYLQ==", - "dependencies": { - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", - "slash": "^3.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/core": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.5.0.tgz", - "integrity": "sha512-28UzQc7ulUrOQw1IsN/kv1QES3q2kkbl/wGslyhAclqZ/8cMdB5M68BffkIdSJgKBUt50d3hbwJ92XESlE7LiQ==", - "dependencies": { - "@jest/console": "^29.5.0", - "@jest/reporters": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "exit": "^0.1.2", - "graceful-fs": "^4.2.9", - "jest-changed-files": "^29.5.0", - "jest-config": "^29.5.0", - "jest-haste-map": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-resolve-dependencies": "^29.5.0", - "jest-runner": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "jest-watcher": "^29.5.0", - "micromatch": "^4.0.4", - "pretty-format": "^29.5.0", - "slash": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/@jest/environment": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.5.0.tgz", - "integrity": "sha512-5FXw2+wD29YU1d4I2htpRX7jYnAyTRjP2CsXQdo9SAM8g3ifxWPSV0HnClSn71xwctr0U3oZIIH+dtbfmnbXVQ==", - "dependencies": { - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "jest-mock": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/expect": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.5.0.tgz", - "integrity": "sha512-PueDR2HGihN3ciUNGr4uelropW7rqUfTiOn+8u0leg/42UhblPxHkfoh0Ruu3I9Y1962P3u2DY4+h7GVTSVU6g==", - "dependencies": { - "expect": "^29.5.0", - "jest-snapshot": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/expect-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.5.0.tgz", - "integrity": "sha512-fmKzsidoXQT2KwnrwE0SQq3uj8Z763vzR8LnLBwC2qYWEFpjX8daRsk6rHUM1QvNlEW/UJXNXm59ztmJJWs2Mg==", - "dependencies": { - "jest-get-type": "^29.4.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/fake-timers": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.5.0.tgz", - "integrity": "sha512-9ARvuAAQcBwDAqOnglWq2zwNIRUDtk/SCkp/ToGEhFv5r86K21l+VEs0qNTaXtyiY0lEePl3kylijSYJQqdbDg==", - "dependencies": { - "@jest/types": "^29.5.0", - "@sinonjs/fake-timers": "^10.0.2", - "@types/node": "*", - "jest-message-util": "^29.5.0", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/globals": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.5.0.tgz", - "integrity": "sha512-S02y0qMWGihdzNbUiqSAiKSpSozSuHX5UYc7QbnHP+D9Lyw8DgGGCinrN9uSuHPeKgSSzvPom2q1nAtBvUsvPQ==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/expect": "^29.5.0", - "@jest/types": "^29.5.0", - "jest-mock": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/reporters": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.5.0.tgz", - "integrity": "sha512-D05STXqj/M8bP9hQNSICtPqz97u7ffGzZu+9XLucXhkOFBqKcXe04JLZOgIekOxdb73MAoBUFnqvf7MCpKk5OA==", - "dependencies": { - "@bcoe/v8-coverage": "^0.2.3", - "@jest/console": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@jridgewell/trace-mapping": "^0.3.15", - "@types/node": "*", - "chalk": "^4.0.0", - "collect-v8-coverage": "^1.0.0", - "exit": "^0.1.2", - "glob": "^7.1.3", - "graceful-fs": "^4.2.9", - "istanbul-lib-coverage": "^3.0.0", - "istanbul-lib-instrument": "^5.1.0", - "istanbul-lib-report": "^3.0.0", - "istanbul-lib-source-maps": "^4.0.0", - "istanbul-reports": "^3.1.3", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", - "jest-worker": "^29.5.0", - "slash": "^3.0.0", - "string-length": "^4.0.1", - "strip-ansi": "^6.0.0", - "v8-to-istanbul": "^9.0.1" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/@jest/reporters/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@jest/reporters/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@jest/reporters/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/@jest/schemas": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.3.tgz", - "integrity": "sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg==", - "dependencies": { - "@sinclair/typebox": "^0.25.16" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/source-map": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.4.3.tgz", - "integrity": "sha512-qyt/mb6rLyd9j1jUts4EQncvS6Yy3PM9HghnNv86QBlV+zdL2inCdK1tuVlL+J+lpiw2BI67qXOrX3UurBqQ1w==", - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.15", - "callsites": "^3.0.0", - "graceful-fs": "^4.2.9" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/test-result": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.5.0.tgz", - "integrity": "sha512-fGl4rfitnbfLsrfx1uUpDEESS7zM8JdgZgOCQuxQvL1Sn/I6ijeAVQWGfXI9zb1i9Mzo495cIpVZhA0yr60PkQ==", - "dependencies": { - "@jest/console": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/istanbul-lib-coverage": "^2.0.0", - "collect-v8-coverage": "^1.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/test-sequencer": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.5.0.tgz", - "integrity": "sha512-yPafQEcKjkSfDXyvtgiV4pevSeyuA6MQr6ZIdVkWJly9vkqjnFfcfhRQqpD5whjoU8EORki752xQmjaqoFjzMQ==", - "dependencies": { - "@jest/test-result": "^29.5.0", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "slash": "^3.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/transform": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.5.0.tgz", - "integrity": "sha512-8vbeZWqLJOvHaDfeMuoHITGKSz5qWc9u04lnWrQE3VyuSw604PzQM824ZeX9XSjUCeDiE3GuxZe5UKa8J61NQw==", - "dependencies": { - "@babel/core": "^7.11.6", - "@jest/types": "^29.5.0", - "@jridgewell/trace-mapping": "^0.3.15", - "babel-plugin-istanbul": "^6.1.1", - "chalk": "^4.0.0", - "convert-source-map": "^2.0.0", - "fast-json-stable-stringify": "^2.1.0", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-util": "^29.5.0", - "micromatch": "^4.0.4", - "pirates": "^4.0.4", - "slash": "^3.0.0", - "write-file-atomic": "^4.0.2" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jest/types": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.5.0.tgz", - "integrity": "sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog==", - "dependencies": { - "@jest/schemas": "^29.4.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", - "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", - "dependencies": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/source-map": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", - "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", - "dev": true, - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.0", - "@jridgewell/trace-mapping": "^0.3.9" - } - }, - "node_modules/@jridgewell/source-map/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, - "dependencies": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", - "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", - "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" - } - }, - "node_modules/@jsdevtools/ono": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", - "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" - }, - "node_modules/@lezer/common": { - "version": "0.15.12", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-0.15.12.tgz", - "integrity": "sha512-edfwCxNLnzq5pBA/yaIhwJ3U3Kz8VAUOTRg0hhxaizaI1N+qxV7EXDv/kLCkLeq2RzSFvxexlaj5Mzfn2kY0Ig==", - "dev": true - }, - "node_modules/@lezer/lr": { - "version": "0.15.8", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-0.15.8.tgz", - "integrity": "sha512-bM6oE6VQZ6hIFxDNKk8bKPa14hqFrV07J/vHGOeiAbJReIaQXmkVb6xQu4MR+JBTLa5arGRyAAjJe1qaQt3Uvg==", - "dev": true, - "dependencies": { - "@lezer/common": "^0.15.0" - } - }, - "node_modules/@lmdb/lmdb-darwin-arm64": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-darwin-arm64/-/lmdb-darwin-arm64-2.5.2.tgz", - "integrity": "sha512-+F8ioQIUN68B4UFiIBYu0QQvgb9FmlKw2ctQMSBfW2QBrZIxz9vD9jCGqTCPqZBRbPHAS/vG1zSXnKqnS2ch/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@lmdb/lmdb-darwin-x64": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-darwin-x64/-/lmdb-darwin-x64-2.5.2.tgz", - "integrity": "sha512-KvPH56KRLLx4KSfKBx0m1r7GGGUMXm0jrKmNE7plbHlesZMuPJICtn07HYgQhj1LNsK7Yqwuvnqh1QxhJnF1EA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@lmdb/lmdb-linux-arm": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-linux-arm/-/lmdb-linux-arm-2.5.2.tgz", - "integrity": "sha512-5kQAP21hAkfW5Bl+e0P57dV4dGYnkNIpR7f/GAh6QHlgXx+vp/teVj4PGRZaKAvt0GX6++N6hF8NnGElLDuIDw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@lmdb/lmdb-linux-arm64": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-linux-arm64/-/lmdb-linux-arm64-2.5.2.tgz", - "integrity": "sha512-aLl89VHL/wjhievEOlPocoefUyWdvzVrcQ/MHQYZm2JfV1jUsrbr/ZfkPPUFvZBf+VSE+Q0clWs9l29PCX1hTQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@lmdb/lmdb-linux-x64": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-linux-x64/-/lmdb-linux-x64-2.5.2.tgz", - "integrity": "sha512-xUdUfwDJLGjOUPH3BuPBt0NlIrR7f/QHKgu3GZIXswMMIihAekj2i97oI0iWG5Bok/b+OBjHPfa8IU9velnP/Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@lmdb/lmdb-win32-x64": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/@lmdb/lmdb-win32-x64/-/lmdb-win32-x64-2.5.2.tgz", - "integrity": "sha512-zrBczSbXKxEyK2ijtbRdICDygRqWSRPpZMN5dD1T8VMEW5RIhIbwFWw2phDRXuBQdVDpSjalCIUMWMV2h3JaZA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@loopholelabs/polyglot-ts": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@loopholelabs/polyglot-ts/-/polyglot-ts-0.4.0.tgz", - "integrity": "sha512-wASTNWeNOVdjJZ7j+YMWxDL5fyGjfYMNPSMxS7+rrrlkhk5LYKAQbkWjb2WF4j5bMN62psPMhjk+3FnhMmv5tw==" - }, - "node_modules/@loopholelabs/scale": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@loopholelabs/scale/-/scale-0.3.13.tgz", - "integrity": "sha512-WCaQXQREKbWIP1ROF6fgmVoTyT4E3XBDIgQW8H4FFfFTHXbOhjVss4LO9AyO04ak9apX9Iz+WEKZpFdAZ6A9Lg==", - "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature": "^0.2.10", - "@loopholelabs/scale-signature-http": "^0.3.6", - "@loopholelabs/scalefile": "^0.1.8", - "@swc/helpers": "^0.4.12", - "@types/jest": "^29.2.0", - "@types/node-fetch": "^2.6.2", - "form-data": "^4.0.0", - "glob": "^8.1.0", - "jest": "^29.2.2", - "jest-environment-jsdom": "^29.2.2", - "js-sha256": "^0.9.0", - "next": "^12.3.3", - "node-fetch": "^2.6.7", - "openapi-typescript-codegen": "^0.23.0", - "ts-jest": "^29.0.3", - "util": "^0.12.5", - "uuid": "^9.0.0" - } - }, - "node_modules/@loopholelabs/scale-signature": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature/-/scale-signature-0.2.11.tgz", - "integrity": "sha512-/3JoWWrWe7e03isBKqFc5AvwVyxpCdRk2UhV60J2j8d1dreEtyr5/uhWg2J0IUVA98QPqojz1KpZXQ+ycU8c6Q==" - }, - "node_modules/@loopholelabs/scale-signature-http": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/@loopholelabs/scale-signature-http/-/scale-signature-http-0.3.7.tgz", - "integrity": "sha512-4x+QXnGwPQVvpWXJWkSCCRQjZjU3n61+BGQ+cNCwcv251DgSgcIsJcJ7nIvBUV4njAJCvzQQdjcGmBv6Pz6c1g==", - "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature": "^0.2.11", - "buffer": "6.0.3", - "fast-sha256": "^1.3.0", - "polyfill-crypto.getrandomvalues": "^1.0.0" - } - }, - "node_modules/@loopholelabs/scalefile": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@loopholelabs/scalefile/-/scalefile-0.1.9.tgz", - "integrity": "sha512-NEn0Xxi2f6+n/TYWwmtRBFAms69ZHTgTSAtnmrAwDQJEuWfgY1Y+aCcNz9dZi8JF8ArcMQJIo8wlMFKPLh4n3A==", - "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "buffer": "^6.0.3", - "fast-sha256": "^1.3.0", - "js-yaml": "^4.1.0" - } - }, - "node_modules/@mischnic/json-sourcemap": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@mischnic/json-sourcemap/-/json-sourcemap-0.1.0.tgz", - "integrity": "sha512-dQb3QnfNqmQNYA4nFSN/uLaByIic58gOXq4Y4XqLOWmOrw73KmJPt/HLyG0wvn1bnR6mBKs/Uwvkh+Hns1T0XA==", - "dev": true, - "dependencies": { - "@lezer/common": "^0.15.7", - "@lezer/lr": "^0.15.4", - "json5": "^2.2.1" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.2.tgz", - "integrity": "sha512-9bfjwDxIDWmmOKusUcqdS4Rw+SETlp9Dy39Xui9BEGEk19dDwH0jhipwFzEff/pFg95NKymc6TOTbRKcWeRqyQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.2.tgz", - "integrity": "sha512-lwriRAHm1Yg4iDf23Oxm9n/t5Zpw1lVnxYU3HnJPTi2lJRkKTrps1KVgvL6m7WvmhYVt/FIsssWay+k45QHeuw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.2.tgz", - "integrity": "sha512-MOI9Dlfrpi2Cuc7i5dXdxPbFIgbDBGgKR5F2yWEa6FVEtSWncfVNKW5AKjImAQ6CZlBK9tympdsZJ2xThBiWWA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.2.tgz", - "integrity": "sha512-FU20Bo66/f7He9Fp9sP2zaJ1Q8L9uLPZQDub/WlUip78JlPeMbVL8546HbZfcW9LNciEXc8d+tThSJjSC+tmsg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.2.tgz", - "integrity": "sha512-gsWNDCklNy7Ajk0vBBf9jEx04RUxuDQfBse918Ww+Qb9HCPoGzS+XJTLe96iN3BVK7grnLiYghP/M4L8VsaHeA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.2.tgz", - "integrity": "sha512-O+6Gs8UeDbyFpbSh2CPEz/UOrrdWPTBYNblZK5CxxLisYt4kGX3Sc+czffFonyjiGSq3jWLwJS/CCJc7tBr4sQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@next/env": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-12.3.4.tgz", - "integrity": "sha512-H/69Lc5Q02dq3o+dxxy5O/oNxFsZpdL6WREtOOtOM1B/weonIwDXkekr1KV5DPVPr12IHFPrMrcJQ6bgPMfn7A==" - }, - "node_modules/@next/swc-android-arm-eabi": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.3.4.tgz", - "integrity": "sha512-cM42Cw6V4Bz/2+j/xIzO8nK/Q3Ly+VSlZJTa1vHzsocJRYz8KT6MrreXaci2++SIZCF1rVRCDgAg5PpqRibdIA==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-android-arm64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.3.4.tgz", - "integrity": "sha512-5jf0dTBjL+rabWjGj3eghpLUxCukRhBcEJgwLedewEA/LJk2HyqCvGIwj5rH+iwmq1llCWbOky2dO3pVljrapg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-arm64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.3.4.tgz", - "integrity": "sha512-DqsSTd3FRjQUR6ao0E1e2OlOcrF5br+uegcEGPVonKYJpcr0MJrtYmPxd4v5T6UCJZ+XzydF7eQo5wdGvSZAyA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.3.4.tgz", - "integrity": "sha512-PPF7tbWD4k0dJ2EcUSnOsaOJ5rhT3rlEt/3LhZUGiYNL8KvoqczFrETlUx0cUYaXe11dRA3F80Hpt727QIwByQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-freebsd-x64": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.3.4.tgz", - "integrity": "sha512-KM9JXRXi/U2PUM928z7l4tnfQ9u8bTco/jb939pdFUHqc28V43Ohd31MmZD1QzEK4aFlMRaIBQOWQZh4D/E5lQ==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm-gnueabihf": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.3.4.tgz", - "integrity": "sha512-3zqD3pO+z5CZyxtKDTnOJ2XgFFRUBciOox6EWkoZvJfc9zcidNAQxuwonUeNts6Xbm8Wtm5YGIRC0x+12YH7kw==", - "cpu": [ - "arm" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.3.4.tgz", - "integrity": "sha512-kiX0vgJGMZVv+oo1QuObaYulXNvdH/IINmvdZnVzMO/jic/B8EEIGlZ8Bgvw8LCjH3zNVPO3mGrdMvnEEPEhKA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.3.4.tgz", - "integrity": "sha512-EETZPa1juczrKLWk5okoW2hv7D7WvonU+Cf2CgsSoxgsYbUCZ1voOpL4JZTOb6IbKMDo6ja+SbY0vzXZBUMvkQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.3.4.tgz", - "integrity": "sha512-4csPbRbfZbuWOk3ATyWcvVFdD9/Rsdq5YHKvRuEni68OCLkfy4f+4I9OBpyK1SKJ00Cih16NJbHE+k+ljPPpag==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.3.4.tgz", - "integrity": "sha512-YeBmI+63Ro75SUiL/QXEVXQ19T++58aI/IINOyhpsRL1LKdyfK/35iilraZEFz9bLQrwy1LYAR5lK200A9Gjbg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.3.4.tgz", - "integrity": "sha512-Sd0qFUJv8Tj0PukAYbCCDbmXcMkbIuhnTeHm9m4ZGjCf6kt7E/RMs55Pd3R5ePjOkN7dJEuxYBehawTR/aPDSQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.3.4.tgz", - "integrity": "sha512-rt/vv/vg/ZGGkrkKcuJ0LyliRdbskQU+91bje+PgoYmxTZf/tYs6IfbmgudBJk6gH3QnjHWbkphDdRQrseRefQ==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.3.4.tgz", - "integrity": "sha512-DQ20JEfTBZAgF8QCjYfJhv2/279M6onxFjdG/+5B0Cyj00/EdBxiWb2eGGFgQhrBbNv/lsvzFbbi0Ptf8Vw/bg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@parcel/bundler-default": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/bundler-default/-/bundler-default-2.8.3.tgz", - "integrity": "sha512-yJvRsNWWu5fVydsWk3O2L4yIy3UZiKWO2cPDukGOIWMgp/Vbpp+2Ct5IygVRtE22bnseW/E/oe0PV3d2IkEJGg==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/graph": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/cache": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/cache/-/cache-2.8.3.tgz", - "integrity": "sha512-k7xv5vSQrJLdXuglo+Hv3yF4BCSs1tQ/8Vbd6CHTkOhf7LcGg6CPtLw053R/KdMpd/4GPn0QrAsOLdATm1ELtQ==", - "dev": true, - "dependencies": { - "@parcel/fs": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/utils": "2.8.3", - "lmdb": "2.5.2" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/codeframe": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/codeframe/-/codeframe-2.8.3.tgz", - "integrity": "sha512-FE7sY53D6n/+2Pgg6M9iuEC6F5fvmyBkRE4d9VdnOoxhTXtkEqpqYgX7RJ12FAQwNlxKq4suBJQMgQHMF2Kjeg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/compressor-raw": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/compressor-raw/-/compressor-raw-2.8.3.tgz", - "integrity": "sha512-bVDsqleBUxRdKMakWSlWC9ZjOcqDKE60BE+Gh3JSN6WJrycJ02P5wxjTVF4CStNP/G7X17U+nkENxSlMG77ySg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/config-default": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/config-default/-/config-default-2.8.3.tgz", - "integrity": "sha512-o/A/mbrO6X/BfGS65Sib8d6SSG45NYrNooNBkH/o7zbOBSRQxwyTlysleK1/3Wa35YpvFyLOwgfakqCtbGy4fw==", - "dev": true, - "dependencies": { - "@parcel/bundler-default": "2.8.3", - "@parcel/compressor-raw": "2.8.3", - "@parcel/namer-default": "2.8.3", - "@parcel/optimizer-css": "2.8.3", - "@parcel/optimizer-htmlnano": "2.8.3", - "@parcel/optimizer-image": "2.8.3", - "@parcel/optimizer-svgo": "2.8.3", - "@parcel/optimizer-terser": "2.8.3", - "@parcel/packager-css": "2.8.3", - "@parcel/packager-html": "2.8.3", - "@parcel/packager-js": "2.8.3", - "@parcel/packager-raw": "2.8.3", - "@parcel/packager-svg": "2.8.3", - "@parcel/reporter-dev-server": "2.8.3", - "@parcel/resolver-default": "2.8.3", - "@parcel/runtime-browser-hmr": "2.8.3", - "@parcel/runtime-js": "2.8.3", - "@parcel/runtime-react-refresh": "2.8.3", - "@parcel/runtime-service-worker": "2.8.3", - "@parcel/transformer-babel": "2.8.3", - "@parcel/transformer-css": "2.8.3", - "@parcel/transformer-html": "2.8.3", - "@parcel/transformer-image": "2.8.3", - "@parcel/transformer-js": "2.8.3", - "@parcel/transformer-json": "2.8.3", - "@parcel/transformer-postcss": "2.8.3", - "@parcel/transformer-posthtml": "2.8.3", - "@parcel/transformer-raw": "2.8.3", - "@parcel/transformer-react-refresh-wrap": "2.8.3", - "@parcel/transformer-svg": "2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/core": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/core/-/core-2.8.3.tgz", - "integrity": "sha512-Euf/un4ZAiClnlUXqPB9phQlKbveU+2CotZv7m7i+qkgvFn5nAGnrV4h1OzQU42j9dpgOxWi7AttUDMrvkbhCQ==", - "dev": true, - "dependencies": { - "@mischnic/json-sourcemap": "^0.1.0", - "@parcel/cache": "2.8.3", - "@parcel/diagnostic": "2.8.3", - "@parcel/events": "2.8.3", - "@parcel/fs": "2.8.3", - "@parcel/graph": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/package-manager": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "@parcel/workers": "2.8.3", - "abortcontroller-polyfill": "^1.1.9", - "base-x": "^3.0.8", - "browserslist": "^4.6.6", - "clone": "^2.1.1", - "dotenv": "^7.0.0", - "dotenv-expand": "^5.1.0", - "json5": "^2.2.0", - "msgpackr": "^1.5.4", - "nullthrows": "^1.1.1", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/diagnostic": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/diagnostic/-/diagnostic-2.8.3.tgz", - "integrity": "sha512-u7wSzuMhLGWZjVNYJZq/SOViS3uFG0xwIcqXw12w54Uozd6BH8JlhVtVyAsq9kqnn7YFkw6pXHqAo5Tzh4FqsQ==", - "dev": true, - "dependencies": { - "@mischnic/json-sourcemap": "^0.1.0", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/events": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/events/-/events-2.8.3.tgz", - "integrity": "sha512-hoIS4tAxWp8FJk3628bsgKxEvR7bq2scCVYHSqZ4fTi/s0+VymEATrRCUqf+12e5H47uw1/ZjoqrGtBI02pz4w==", - "dev": true, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/fs": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/fs/-/fs-2.8.3.tgz", - "integrity": "sha512-y+i+oXbT7lP0e0pJZi/YSm1vg0LDsbycFuHZIL80pNwdEppUAtibfJZCp606B7HOjMAlNZOBo48e3hPG3d8jgQ==", - "dev": true, - "dependencies": { - "@parcel/fs-search": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "@parcel/watcher": "^2.0.7", - "@parcel/workers": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/fs-search": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/fs-search/-/fs-search-2.8.3.tgz", - "integrity": "sha512-DJBT2N8knfN7Na6PP2mett3spQLTqxFrvl0gv+TJRp61T8Ljc4VuUTb0hqBj+belaASIp3Q+e8+SgaFQu7wLiQ==", - "dev": true, - "dependencies": { - "detect-libc": "^1.0.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/graph": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/graph/-/graph-2.8.3.tgz", - "integrity": "sha512-26GL8fYZPdsRhSXCZ0ZWliloK6DHlMJPWh6Z+3VVZ5mnDSbYg/rRKWmrkhnr99ZWmL9rJsv4G74ZwvDEXTMPBg==", - "dev": true, - "dependencies": { - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/hash": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/hash/-/hash-2.8.3.tgz", - "integrity": "sha512-FVItqzjWmnyP4ZsVgX+G00+6U2IzOvqDtdwQIWisCcVoXJFCqZJDy6oa2qDDFz96xCCCynjRjPdQx2jYBCpfYw==", - "dev": true, - "dependencies": { - "detect-libc": "^1.0.3", - "xxhash-wasm": "^0.4.2" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/logger": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/logger/-/logger-2.8.3.tgz", - "integrity": "sha512-Kpxd3O/Vs7nYJIzkdmB6Bvp3l/85ydIxaZaPfGSGTYOfaffSOTkhcW9l6WemsxUrlts4za6CaEWcc4DOvaMOPA==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/events": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/markdown-ansi": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/markdown-ansi/-/markdown-ansi-2.8.3.tgz", - "integrity": "sha512-4v+pjyoh9f5zuU/gJlNvNFGEAb6J90sOBwpKJYJhdWXLZMNFCVzSigxrYO+vCsi8G4rl6/B2c0LcwIMjGPHmFQ==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/namer-default": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/namer-default/-/namer-default-2.8.3.tgz", - "integrity": "sha512-tJ7JehZviS5QwnxbARd8Uh63rkikZdZs1QOyivUhEvhN+DddSAVEdQLHGPzkl3YRk0tjFhbqo+Jci7TpezuAMw==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/node-resolver-core": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/node-resolver-core/-/node-resolver-core-2.8.3.tgz", - "integrity": "sha512-12YryWcA5Iw2WNoEVr/t2HDjYR1iEzbjEcxfh1vaVDdZ020PiGw67g5hyIE/tsnG7SRJ0xdRx1fQ2hDgED+0Ww==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/optimizer-css": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/optimizer-css/-/optimizer-css-2.8.3.tgz", - "integrity": "sha512-JotGAWo8JhuXsQDK0UkzeQB0UR5hDAKvAviXrjqB4KM9wZNLhLleeEAW4Hk8R9smCeQFP6Xg/N/NkLDpqMwT3g==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "browserslist": "^4.6.6", - "lightningcss": "^1.16.1", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/optimizer-htmlnano": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/optimizer-htmlnano/-/optimizer-htmlnano-2.8.3.tgz", - "integrity": "sha512-L8/fHbEy8Id2a2E0fwR5eKGlv9VYDjrH9PwdJE9Za9v1O/vEsfl/0T/79/x129l5O0yB6EFQkFa20MiK3b+vOg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "htmlnano": "^2.0.0", - "nullthrows": "^1.1.1", - "posthtml": "^0.16.5", - "svgo": "^2.4.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/optimizer-image": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/optimizer-image/-/optimizer-image-2.8.3.tgz", - "integrity": "sha512-SD71sSH27SkCDNUNx9A3jizqB/WIJr3dsfp+JZGZC42tpD/Siim6Rqy9M4To/BpMMQIIiEXa5ofwS+DgTEiEHQ==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "@parcel/workers": "2.8.3", - "detect-libc": "^1.0.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/optimizer-svgo": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/optimizer-svgo/-/optimizer-svgo-2.8.3.tgz", - "integrity": "sha512-9KQed99NZnQw3/W4qBYVQ7212rzA9EqrQG019TIWJzkA9tjGBMIm2c/nXpK1tc3hQ3e7KkXkFCQ3C+ibVUnHNA==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "svgo": "^2.4.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/optimizer-terser": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/optimizer-terser/-/optimizer-terser-2.8.3.tgz", - "integrity": "sha512-9EeQlN6zIeUWwzrzu6Q2pQSaYsYGah8MtiQ/hog9KEPlYTP60hBv/+utDyYEHSQhL7y5ym08tPX5GzBvwAD/dA==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1", - "terser": "^5.2.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/package-manager": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/package-manager/-/package-manager-2.8.3.tgz", - "integrity": "sha512-tIpY5pD2lH53p9hpi++GsODy6V3khSTX4pLEGuMpeSYbHthnOViobqIlFLsjni+QA1pfc8NNNIQwSNdGjYflVA==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/fs": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "@parcel/workers": "2.8.3", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/packager-css": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-css/-/packager-css-2.8.3.tgz", - "integrity": "sha512-WyvkMmsurlHG8d8oUVm7S+D+cC/T3qGeqogb7sTI52gB6uiywU7lRCizLNqGFyFGIxcVTVHWnSHqItBcLN76lA==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/packager-html": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-html/-/packager-html-2.8.3.tgz", - "integrity": "sha512-OhPu1Hx1RRKJodpiu86ZqL8el2Aa4uhBHF6RAL1Pcrh2EhRRlPf70Sk0tC22zUpYL7es+iNKZ/n0Rl+OWSHWEw==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1", - "posthtml": "^0.16.5" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/packager-js": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-js/-/packager-js-2.8.3.tgz", - "integrity": "sha512-0pGKC3Ax5vFuxuZCRB+nBucRfFRz4ioie19BbDxYnvBxrd4M3FIu45njf6zbBYsI9eXqaDnL1b3DcZJfYqtIzw==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "globals": "^13.2.0", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/packager-js/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@parcel/packager-js/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@parcel/packager-raw": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-raw/-/packager-raw-2.8.3.tgz", - "integrity": "sha512-BA6enNQo1RCnco9MhkxGrjOk59O71IZ9DPKu3lCtqqYEVd823tXff2clDKHK25i6cChmeHu6oB1Rb73hlPqhUA==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/packager-svg": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-svg/-/packager-svg-2.8.3.tgz", - "integrity": "sha512-mvIoHpmv5yzl36OjrklTDFShLUfPFTwrmp1eIwiszGdEBuQaX7JVI3Oo2jbVQgcN4W7J6SENzGQ3Q5hPTW3pMw==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "posthtml": "^0.16.4" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/packager-ts": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/packager-ts/-/packager-ts-2.8.3.tgz", - "integrity": "sha512-8JooYHjKntHnQywLT7LAnfoGiAQ1fUu0N2DtuM0PxpgQqYJ4KE9TZS+SZq7hpe24cZkD0A4A+1kBlYAyvuanrg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/plugin": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/plugin/-/plugin-2.8.3.tgz", - "integrity": "sha512-jZ6mnsS4D9X9GaNnvrixDQwlUQJCohDX2hGyM0U0bY2NWU8Km97SjtoCpWjq+XBCx/gpC4g58+fk9VQeZq2vlw==", - "dev": true, - "dependencies": { - "@parcel/types": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/reporter-cli": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/reporter-cli/-/reporter-cli-2.8.3.tgz", - "integrity": "sha512-3sJkS6tFFzgIOz3u3IpD/RsmRxvOKKiQHOTkiiqRt1l44mMDGKS7zANRnJYsQzdCsgwc9SOP30XFgJwtoVlMbw==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "chalk": "^4.1.0", - "term-size": "^2.2.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/reporter-dev-server": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/reporter-dev-server/-/reporter-dev-server-2.8.3.tgz", - "integrity": "sha512-Y8C8hzgzTd13IoWTj+COYXEyCkXfmVJs3//GDBsH22pbtSFMuzAZd+8J9qsCo0EWpiDow7V9f1LischvEh3FbQ==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/resolver-default": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/resolver-default/-/resolver-default-2.8.3.tgz", - "integrity": "sha512-k0B5M/PJ+3rFbNj4xZSBr6d6HVIe6DH/P3dClLcgBYSXAvElNDfXgtIimbjCyItFkW9/BfcgOVKEEIZOeySH/A==", - "dev": true, - "dependencies": { - "@parcel/node-resolver-core": "2.8.3", - "@parcel/plugin": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/runtime-browser-hmr": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/runtime-browser-hmr/-/runtime-browser-hmr-2.8.3.tgz", - "integrity": "sha512-2O1PYi2j/Q0lTyGNV3JdBYwg4rKo6TEVFlYGdd5wCYU9ZIN9RRuoCnWWH2qCPj3pjIVtBeppYxzfVjPEHINWVg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/runtime-js": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/runtime-js/-/runtime-js-2.8.3.tgz", - "integrity": "sha512-IRja0vNKwvMtPgIqkBQh0QtRn0XcxNC8HU1jrgWGRckzu10qJWO+5ULgtOeR4pv9krffmMPqywGXw6l/gvJKYQ==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/runtime-react-refresh": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/runtime-react-refresh/-/runtime-react-refresh-2.8.3.tgz", - "integrity": "sha512-2v/qFKp00MfG0234OdOgQNAo6TLENpFYZMbVbAsPMY9ITiqG73MrEsrGXVoGbYiGTMB/Toer/lSWlJxtacOCuA==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "react-error-overlay": "6.0.9", - "react-refresh": "^0.9.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/runtime-service-worker": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/runtime-service-worker/-/runtime-service-worker-2.8.3.tgz", - "integrity": "sha512-/Skkw+EeRiwzOJso5fQtK8c9b452uWLNhQH1ISTodbmlcyB4YalAiSsyHCtMYD0c3/t5Sx4ZS7vxBAtQd0RvOw==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/source-map": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@parcel/source-map/-/source-map-2.1.1.tgz", - "integrity": "sha512-Ejx1P/mj+kMjQb8/y5XxDUn4reGdr+WyKYloBljpppUy8gs42T+BNoEOuRYqDVdgPc6NxduzIDoJS9pOFfV5Ew==", - "dev": true, - "dependencies": { - "detect-libc": "^1.0.3" - }, - "engines": { - "node": "^12.18.3 || >=14" - } - }, - "node_modules/@parcel/transformer-babel": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-babel/-/transformer-babel-2.8.3.tgz", - "integrity": "sha512-L6lExfpvvC7T/g3pxf3CIJRouQl+sgrSzuWQ0fD4PemUDHvHchSP4SNUVnd6gOytF3Y1KpnEZIunQGi5xVqQCQ==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "browserslist": "^4.6.6", - "json5": "^2.2.0", - "nullthrows": "^1.1.1", - "semver": "^5.7.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-css": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-css/-/transformer-css-2.8.3.tgz", - "integrity": "sha512-xTqFwlSXtnaYen9ivAgz+xPW7yRl/u4QxtnDyDpz5dr8gSeOpQYRcjkd4RsYzKsWzZcGtB5EofEk8ayUbWKEUg==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "browserslist": "^4.6.6", - "lightningcss": "^1.16.1", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-html": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-html/-/transformer-html-2.8.3.tgz", - "integrity": "sha512-kIZO3qsMYTbSnSpl9cnZog+SwL517ffWH54JeB410OSAYF1ouf4n5v9qBnALZbuCCmPwJRGs4jUtE452hxwN4g==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/plugin": "2.8.3", - "nullthrows": "^1.1.1", - "posthtml": "^0.16.5", - "posthtml-parser": "^0.10.1", - "posthtml-render": "^3.0.0", - "semver": "^5.7.1", - "srcset": "4" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-image": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-image/-/transformer-image-2.8.3.tgz", - "integrity": "sha512-cO4uptcCGTi5H6bvTrAWEFUsTNhA4kCo8BSvRSCHA2sf/4C5tGQPHt3JhdO0GQLPwZRCh/R41EkJs5HZ8A8DAg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "@parcel/workers": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/transformer-js": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-js/-/transformer-js-2.8.3.tgz", - "integrity": "sha512-9Qd6bib+sWRcpovvzvxwy/PdFrLUXGfmSW9XcVVG8pvgXsZPFaNjnNT8stzGQj1pQiougCoxMY4aTM5p1lGHEQ==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/utils": "2.8.3", - "@parcel/workers": "2.8.3", - "@swc/helpers": "^0.4.12", - "browserslist": "^4.6.6", - "detect-libc": "^1.0.3", - "nullthrows": "^1.1.1", - "regenerator-runtime": "^0.13.7", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@parcel/transformer-json": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-json/-/transformer-json-2.8.3.tgz", - "integrity": "sha512-B7LmVq5Q7bZO4ERb6NHtRuUKWGysEeaj9H4zelnyBv+wLgpo4f5FCxSE1/rTNmP9u1qHvQ3scGdK6EdSSokGPg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "json5": "^2.2.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-postcss": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-postcss/-/transformer-postcss-2.8.3.tgz", - "integrity": "sha512-e8luB/poIlz6jBsD1Izms+6ElbyzuoFVa4lFVLZnTAChI3UxPdt9p/uTsIO46HyBps/Bk8ocvt3J4YF84jzmvg==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "clone": "^2.1.1", - "nullthrows": "^1.1.1", - "postcss-value-parser": "^4.2.0", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-posthtml": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-posthtml/-/transformer-posthtml-2.8.3.tgz", - "integrity": "sha512-pkzf9Smyeaw4uaRLsT41RGrPLT5Aip8ZPcntawAfIo+KivBQUV0erY1IvHYjyfFzq1ld/Fo2Ith9He6mxpPifA==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1", - "posthtml": "^0.16.5", - "posthtml-parser": "^0.10.1", - "posthtml-render": "^3.0.0", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-raw": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-raw/-/transformer-raw-2.8.3.tgz", - "integrity": "sha512-G+5cXnd2/1O3nV/pgRxVKZY/HcGSseuhAe71gQdSQftb8uJEURyUHoQ9Eh0JUD3MgWh9V+nIKoyFEZdf9T0sUQ==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-react-refresh-wrap": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-react-refresh-wrap/-/transformer-react-refresh-wrap-2.8.3.tgz", - "integrity": "sha512-q8AAoEvBnCf/nPvgOwFwKZfEl/thwq7c2duxXkhl+tTLDRN2vGmyz4355IxCkavSX+pLWSQ5MexklSEeMkgthg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "2.8.3", - "@parcel/utils": "2.8.3", - "react-refresh": "^0.9.0" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-svg": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-svg/-/transformer-svg-2.8.3.tgz", - "integrity": "sha512-3Zr/gBzxi1ZH1fftH/+KsZU7w5GqkmxlB0ZM8ovS5E/Pl1lq1t0xvGJue9m2VuQqP8Mxfpl5qLFmsKlhaZdMIQ==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/plugin": "2.8.3", - "nullthrows": "^1.1.1", - "posthtml": "^0.16.5", - "posthtml-parser": "^0.10.1", - "posthtml-render": "^3.0.0", - "semver": "^5.7.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/transformer-typescript-types": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/transformer-typescript-types/-/transformer-typescript-types-2.8.3.tgz", - "integrity": "sha512-zjsJsgecjw4X1nt5R7A61uWwzwCce0usKKPqnE5tQpYtF4FfK5X69r0l5JLovlyaT2uwoe+hvhu2AELA0kKRQA==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/ts-utils": "2.8.3", - "@parcel/utils": "2.8.3", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "typescript": ">=3.0.0" - } - }, - "node_modules/@parcel/ts-utils": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/ts-utils/-/ts-utils-2.8.3.tgz", - "integrity": "sha512-4HMt9B9LF2pDFvSKGImho48tlCvCUl7ly1ZMXvQdmEq2i0yoS81tDsmxX3yly/RVUVeUCGAj1JRuuy1lw5zw1A==", - "dev": true, - "dependencies": { - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "typescript": ">=3.0.0" - } - }, - "node_modules/@parcel/types": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/types/-/types-2.8.3.tgz", - "integrity": "sha512-FECA1FB7+0UpITKU0D6TgGBpGxYpVSMNEENZbSJxFSajNy3wrko+zwBKQmFOLOiPcEtnGikxNs+jkFWbPlUAtw==", - "dev": true, - "dependencies": { - "@parcel/cache": "2.8.3", - "@parcel/diagnostic": "2.8.3", - "@parcel/fs": "2.8.3", - "@parcel/package-manager": "2.8.3", - "@parcel/source-map": "^2.1.1", - "@parcel/workers": "2.8.3", - "utility-types": "^3.10.0" - } - }, - "node_modules/@parcel/utils": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/utils/-/utils-2.8.3.tgz", - "integrity": "sha512-IhVrmNiJ+LOKHcCivG5dnuLGjhPYxQ/IzbnF2DKNQXWBTsYlHkJZpmz7THoeLtLliGmSOZ3ZCsbR8/tJJKmxjA==", - "dev": true, - "dependencies": { - "@parcel/codeframe": "2.8.3", - "@parcel/diagnostic": "2.8.3", - "@parcel/hash": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/markdown-ansi": "2.8.3", - "@parcel/source-map": "^2.1.1", - "chalk": "^4.1.0" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/validator-typescript": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/validator-typescript/-/validator-typescript-2.8.3.tgz", - "integrity": "sha512-2UYGCAwrxh7HIGcrXl8Vu9Sisd8vAu/6Jp/oJV5n9ZQuT5O9pQAlK2lZGSocYRucBtmb4WajII2S2GTzUZeEuQ==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/plugin": "2.8.3", - "@parcel/ts-utils": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3" - }, - "engines": { - "node": ">= 12.0.0", - "parcel": "^2.8.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "typescript": ">=3.0.0" - } - }, - "node_modules/@parcel/watcher": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.1.0.tgz", - "integrity": "sha512-8s8yYjd19pDSsBpbkOHnT6Z2+UJSuLQx61pCFM0s5wSRvKCEMDjd/cHY3/GI1szHIWbpXpsJdg3V6ISGGx9xDw==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "is-glob": "^4.0.3", - "micromatch": "^4.0.5", - "node-addon-api": "^3.2.1", - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/workers": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/@parcel/workers/-/workers-2.8.3.tgz", - "integrity": "sha512-+AxBnKgjqVpUHBcHLWIHcjYgKIvHIpZjN33mG5LG9XXvrZiqdWvouEzqEXlVLq5VzzVbKIQQcmsvRy138YErkg==", - "dev": true, - "dependencies": { - "@parcel/diagnostic": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/types": "2.8.3", - "@parcel/utils": "2.8.3", - "chrome-trace-event": "^1.0.2", - "nullthrows": "^1.1.1" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "peerDependencies": { - "@parcel/core": "^2.8.3" - } - }, - "node_modules/@sinclair/typebox": { - "version": "0.25.24", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", - "integrity": "sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ==" - }, - "node_modules/@sinonjs/commons": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz", - "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", - "dependencies": { - "type-detect": "4.0.8" - } - }, - "node_modules/@sinonjs/fake-timers": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.0.2.tgz", - "integrity": "sha512-SwUDyjWnah1AaNl7kxsa7cfLhlTYoiyhDAIgyh+El30YvXs/o7OLXpYH88Zdhyx9JExKrmHDJ+10bwIcY80Jmw==", - "dependencies": { - "@sinonjs/commons": "^2.0.0" - } - }, - "node_modules/@swc/helpers": { - "version": "0.4.14", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz", - "integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==", - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@tootallnate/once": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", - "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", - "engines": { - "node": ">= 10" - } - }, - "node_modules/@trysound/sax": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", - "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/@types/babel__core": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", - "integrity": "sha512-+n8dL/9GWblDO0iU6eZAwEIJVr5DWigtle+Q6HLOrh/pdbXOhOtqzq8VPPE2zvNJzSKY4vH/z3iT3tn0A3ypiQ==", - "dependencies": { - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7", - "@types/babel__generator": "*", - "@types/babel__template": "*", - "@types/babel__traverse": "*" - } - }, - "node_modules/@types/babel__generator": { - "version": "7.6.4", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", - "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", - "dependencies": { - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", - "dependencies": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__traverse": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.18.3.tgz", - "integrity": "sha512-1kbcJ40lLB7MHsj39U4Sh1uTd2E7rLEa79kmDpI6cy+XiXsteB3POdQomoq4FxszMrO3ZYchkhYJw7A2862b3w==", - "dependencies": { - "@babel/types": "^7.3.0" - } - }, - "node_modules/@types/body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", - "dev": true, - "dependencies": { - "@types/connect": "*", - "@types/node": "*" - } - }, - "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/cookiejar": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz", - "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", - "dev": true - }, - "node_modules/@types/express": { - "version": "4.17.17", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", - "integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==", - "dev": true, - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.33", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, - "node_modules/@types/express-serve-static-core": { - "version": "4.17.33", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz", - "integrity": "sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA==", - "dev": true, - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*" - } - }, - "node_modules/@types/fastestsmallesttextencoderdecoder": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@types/fastestsmallesttextencoderdecoder/-/fastestsmallesttextencoderdecoder-1.0.0.tgz", - "integrity": "sha512-bCyxe0zloFjExUH/36vW/sMHItelWPYtf5Mp9w67hFDSc5a+IBZeb/1yQXxC55/DWYw+QrYftfhp8tl9lDl+ww==", - "dev": true - }, - "node_modules/@types/graceful-fs": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", - "integrity": "sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==" - }, - "node_modules/@types/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", - "dependencies": { - "@types/istanbul-lib-coverage": "*" - } - }, - "node_modules/@types/istanbul-reports": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", - "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", - "dependencies": { - "@types/istanbul-lib-report": "*" - } - }, - "node_modules/@types/jest": { - "version": "29.4.0", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.4.0.tgz", - "integrity": "sha512-VaywcGQ9tPorCX/Jkkni7RWGFfI11whqzs8dvxF41P17Z+z872thvEvlIbznjPJ02kl1HMX3LmLOonsj2n7HeQ==", - "dependencies": { - "expect": "^29.0.0", - "pretty-format": "^29.0.0" - } - }, - "node_modules/@types/jsdom": { - "version": "20.0.1", - "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz", - "integrity": "sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==", - "dependencies": { - "@types/node": "*", - "@types/tough-cookie": "*", - "parse5": "^7.0.0" - } - }, - "node_modules/@types/json-schema": { - "version": "7.0.11", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", - "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==" - }, - "node_modules/@types/mime": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz", - "integrity": "sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA==", - "dev": true - }, - "node_modules/@types/node": { - "version": "18.15.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.1.tgz", - "integrity": "sha512-U2TWca8AeHSmbpi314QBESRk7oPjSZjDsR+c+H4ECC1l+kFgpZf8Ydhv3SJpPy51VyZHHqxlb6mTTqYNNRVAIw==" - }, - "node_modules/@types/node-fetch": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", - "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } - }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/@types/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", - "dev": true - }, - "node_modules/@types/prettier": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", - "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==" - }, - "node_modules/@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", - "dev": true - }, - "node_modules/@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", - "dev": true - }, - "node_modules/@types/serve-static": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz", - "integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==", - "dev": true, - "dependencies": { - "@types/mime": "*", - "@types/node": "*" - } - }, - "node_modules/@types/stack-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" - }, - "node_modules/@types/superagent": { - "version": "4.1.16", - "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.16.tgz", - "integrity": "sha512-tLfnlJf6A5mB6ddqF159GqcDizfzbMUB1/DeT59/wBNqzRTNNKsaw79A/1TZ84X+f/EwWH8FeuSkjlCLyqS/zQ==", - "dev": true, - "dependencies": { - "@types/cookiejar": "*", - "@types/node": "*" - } - }, - "node_modules/@types/supertest": { - "version": "2.0.12", - "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.12.tgz", - "integrity": "sha512-X3HPWTwXRerBZS7Mo1k6vMVR1Z6zmJcDVn5O/31whe0tnjE4te6ZJSJGq1RiqHPjzPdMTfjCFogDJmwng9xHaQ==", - "dev": true, - "dependencies": { - "@types/superagent": "*" - } - }, - "node_modules/@types/text-encoding": { - "version": "0.0.36", - "resolved": "https://registry.npmjs.org/@types/text-encoding/-/text-encoding-0.0.36.tgz", - "integrity": "sha512-LfATA7bH+MtAPlOshYgQ1M3n2r0TSB6Ns5ESvKYlVugkKErQg5oFbR2qO7XrKtNsrtzedDvTeqQfyTjdPJH7jw==", - "dev": true - }, - "node_modules/@types/tough-cookie": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz", - "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==" - }, - "node_modules/@types/yargs": { - "version": "17.0.22", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", - "integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==", - "dependencies": { - "@types/yargs-parser": "*" - } - }, - "node_modules/@types/yargs-parser": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", - "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" - }, - "node_modules/abab": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", - "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==" - }, - "node_modules/abortcontroller-polyfill": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.5.tgz", - "integrity": "sha512-JMJ5soJWP18htbbxJjG7bG6yuI6pRhgJ0scHHTfkUjf6wjP912xZWvM+A4sJK3gqd9E8fcPbDnOefbA9Th/FIQ==", - "dev": true - }, - "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-globals": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz", - "integrity": "sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==", - "dependencies": { - "acorn": "^8.1.0", - "acorn-walk": "^8.0.2" - } - }, - "node_modules/acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/ansi-escapes": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", - "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", - "dependencies": { - "type-fest": "^0.21.3" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", - "dev": true - }, - "node_modules/asn1.js": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", - "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", - "dev": true, - "dependencies": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "safer-buffer": "^2.1.0" - } - }, - "node_modules/asn1.js/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/available-typed-arrays": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", - "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/babel-jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.5.0.tgz", - "integrity": "sha512-mA4eCDh5mSo2EcA9xQjVTpmbbNk32Zb3Q3QFQsNhaK56Q+yoXowzFodLux30HRgyOho5rsQ6B0P9QpMkvvnJ0Q==", - "dependencies": { - "@jest/transform": "^29.5.0", - "@types/babel__core": "^7.1.14", - "babel-plugin-istanbul": "^6.1.1", - "babel-preset-jest": "^29.5.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "slash": "^3.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.8.0" - } - }, - "node_modules/babel-plugin-istanbul": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", - "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@istanbuljs/load-nyc-config": "^1.0.0", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-instrument": "^5.0.4", - "test-exclude": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/babel-plugin-jest-hoist": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.5.0.tgz", - "integrity": "sha512-zSuuuAlTMT4mzLj2nPnUm6fsE6270vdOfnpbJ+RmruU75UhLFvL0N2NgI7xpeS7NaB6hGqmd5pVpGTDYvi4Q3w==", - "dependencies": { - "@babel/template": "^7.3.3", - "@babel/types": "^7.3.3", - "@types/babel__core": "^7.1.14", - "@types/babel__traverse": "^7.0.6" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/babel-preset-current-node-syntax": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", - "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", - "dependencies": { - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-bigint": "^7.8.3", - "@babel/plugin-syntax-class-properties": "^7.8.3", - "@babel/plugin-syntax-import-meta": "^7.8.3", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.8.3", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-top-level-await": "^7.8.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/babel-preset-jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.5.0.tgz", - "integrity": "sha512-JOMloxOqdiBSxMAzjRaH023/vvcaSaec49zvg+2LmNsktC7ei39LTJGw02J+9uUtTZUq6xbLyJ4dxe9sSmIuAg==", - "dependencies": { - "babel-plugin-jest-hoist": "^29.5.0", - "babel-preset-current-node-syntax": "^1.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "dev": true - }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", - "dev": true - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", - "dev": true - }, - "node_modules/browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "dependencies": { - "buffer-xor": "^1.0.3", - "cipher-base": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.3", - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", - "dev": true, - "dependencies": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" - } - }, - "node_modules/browserify-des": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", - "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/browserify-rsa": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", - "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", - "dev": true, - "dependencies": { - "bn.js": "^5.0.0", - "randombytes": "^2.0.1" - } - }, - "node_modules/browserify-sign": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", - "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", - "dev": true, - "dependencies": { - "bn.js": "^5.1.1", - "browserify-rsa": "^4.0.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "elliptic": "^6.5.3", - "inherits": "^2.0.4", - "parse-asn1": "^5.1.5", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - } - }, - "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/bs-logger": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", - "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", - "dependencies": { - "fast-json-stable-stringify": "2.x" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/bser": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", - "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", - "dependencies": { - "node-int64": "^0.4.0" - } - }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" - }, - "node_modules/buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", - "dev": true - }, - "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/call-me-maybe": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", - "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001465", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001465.tgz", - "integrity": "sha512-HvjgL3MYAJjceTDCcjRnQGjwUz/5qec9n7JPOzUursUoOTIsYCSDOb1l7RsnZE8mjbxG78zVRCKfrBXyvChBag==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - } - ] - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/char-regex": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", - "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/chrome-trace-event": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", - "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", - "dev": true, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/ci-info": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "engines": { - "node": ">=8" - } - }, - "node_modules/cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/cjs-module-lexer": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", - "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/clone": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", - "dev": true, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", - "engines": { - "iojs": ">= 1.0.0", - "node": ">= 0.12.0" - } - }, - "node_modules/collect-v8-coverage": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", - "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==" - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", - "engines": { - "node": "^12.20.0 || >=14" - } - }, - "node_modules/component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" - }, - "node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" - }, - "node_modules/cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", - "dev": true - }, - "node_modules/cosmiconfig": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", - "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", - "dev": true, - "dependencies": { - "@types/parse-json": "^4.0.0", - "import-fresh": "^3.2.1", - "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/create-ecdh": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", - "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", - "dev": true, - "dependencies": { - "bn.js": "^4.1.0", - "elliptic": "^6.5.3" - } - }, - "node_modules/create-ecdh/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" - } - }, - "node_modules/create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "dependencies": { - "cipher-base": "^1.0.3", - "create-hash": "^1.1.0", - "inherits": "^2.0.1", - "ripemd160": "^2.0.0", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", - "dev": true, - "dependencies": { - "browserify-cipher": "^1.0.0", - "browserify-sign": "^4.0.0", - "create-ecdh": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.0", - "diffie-hellman": "^5.0.0", - "inherits": "^2.0.1", - "pbkdf2": "^3.0.3", - "public-encrypt": "^4.0.0", - "randombytes": "^2.0.0", - "randomfill": "^1.0.3" - }, - "engines": { - "node": "*" - } - }, - "node_modules/css-select": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", - "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.0.1", - "domhandler": "^4.3.1", - "domutils": "^2.8.0", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-tree": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.1.3.tgz", - "integrity": "sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==", - "dev": true, - "dependencies": { - "mdn-data": "2.0.14", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "dev": true, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/csso": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/csso/-/csso-4.2.0.tgz", - "integrity": "sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==", - "dev": true, - "dependencies": { - "css-tree": "^1.1.2" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/cssom": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz", - "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==" - }, - "node_modules/cssstyle": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", - "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", - "dependencies": { - "cssom": "~0.3.6" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cssstyle/node_modules/cssom": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", - "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==" - }, - "node_modules/data-urls": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz", - "integrity": "sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==", - "dependencies": { - "abab": "^2.0.6", - "whatwg-mimetype": "^3.0.0", - "whatwg-url": "^11.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" - }, - "node_modules/dedent": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", - "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==" - }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" - }, - "node_modules/deepmerge": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.0.tgz", - "integrity": "sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/des.js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", - "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" - } - }, - "node_modules/detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", - "dev": true, - "bin": { - "detect-libc": "bin/detect-libc.js" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/detect-newline": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", - "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", - "engines": { - "node": ">=8" - } - }, - "node_modules/dezalgo": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", - "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", - "dev": true, - "dependencies": { - "asap": "^2.0.0", - "wrappy": "1" - } - }, - "node_modules/diff-sequences": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", - "integrity": "sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", - "dev": true, - "dependencies": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" - } - }, - "node_modules/diffie-hellman/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/dom-serializer": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", - "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", - "dev": true, - "dependencies": { - "domelementtype": "^2.0.1", - "domhandler": "^4.2.0", - "entities": "^2.0.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/dom-serializer/node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domexception": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", - "integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==", - "dependencies": { - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/domhandler": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", - "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", - "dev": true, - "dependencies": { - "domelementtype": "^2.2.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", - "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", - "dev": true, - "dependencies": { - "dom-serializer": "^1.0.1", - "domelementtype": "^2.2.0", - "domhandler": "^4.2.0" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/dotenv": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-7.0.0.tgz", - "integrity": "sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/dotenv-expand": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-5.1.0.tgz", - "integrity": "sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==", - "dev": true - }, - "node_modules/electron-to-chromium": { - "version": "1.4.328", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.328.tgz", - "integrity": "sha512-DE9tTy2PNmy1v55AZAO542ui+MLC2cvINMK4P2LXGsJdput/ThVG9t+QGecPuAZZSgC8XoI+Jh9M1OG9IoNSCw==" - }, - "node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/emittery": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", - "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sindresorhus/emittery?sponsor=1" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/entities": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz", - "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/escodegen": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", - "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^5.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=6.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, - "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "dependencies": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, - "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/expect": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.5.0.tgz", - "integrity": "sha512-yM7xqUrCO2JdpFo4XpM82t+PJBFybdqoQuJLDGeDX2ij8NZzqRHyu3Hp188/JX7SWqud+7t4MUdvcgGBICMHZg==", - "dependencies": { - "@jest/expect-utils": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" - }, - "node_modules/fast-safe-stringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", - "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "dev": true - }, - "node_modules/fast-sha256": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", - "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==" - }, - "node_modules/fb-watchman": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", - "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", - "dependencies": { - "bser": "2.1.1" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/for-each": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", - "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", - "dependencies": { - "is-callable": "^1.1.3" - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/formidable": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", - "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", - "dev": true, - "dependencies": { - "dezalgo": "^1.0.4", - "hexoid": "^1.0.0", - "once": "^1.4.0", - "qs": "^6.11.0" - }, - "funding": { - "url": "https://ko-fi.com/tunnckoCore/commissions" - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-intrinsic": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", - "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", - "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-package-type": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", - "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/get-port": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/get-port/-/get-port-4.2.0.tgz", - "integrity": "sha512-/b3jarXkH8KJoOMQc3uVGHASwGLPq3gSFJ7tgJm2diza+bydJPTGOibin2steecKeOylE8oY2JERlVWkAJO6yw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dependencies": { - "get-intrinsic": "^1.1.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" - }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dependencies": { - "function-bind": "^1.1.1" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dependencies": { - "has-symbols": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hash-base": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", - "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.4", - "readable-stream": "^3.6.0", - "safe-buffer": "^5.2.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "node_modules/hexoid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", - "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "dev": true, - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/html-encoding-sniffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", - "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", - "dependencies": { - "whatwg-encoding": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==" - }, - "node_modules/htmlnano": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/htmlnano/-/htmlnano-2.0.3.tgz", - "integrity": "sha512-S4PGGj9RbdgW8LhbILNK7W9JhmYP8zmDY7KDV/8eCiJBQJlbmltp5I0gv8c5ntLljfdxxfmJ+UJVSqyH4mb41A==", - "dev": true, - "dependencies": { - "cosmiconfig": "^7.0.1", - "posthtml": "^0.16.5", - "timsort": "^0.3.0" - }, - "peerDependencies": { - "cssnano": "^5.0.11", - "postcss": "^8.3.11", - "purgecss": "^5.0.0", - "relateurl": "^0.2.7", - "srcset": "4.0.0", - "svgo": "^2.8.0", - "terser": "^5.10.0", - "uncss": "^0.17.3" - }, - "peerDependenciesMeta": { - "cssnano": { - "optional": true - }, - "postcss": { - "optional": true - }, - "purgecss": { - "optional": true - }, - "relateurl": { - "optional": true - }, - "srcset": { - "optional": true - }, - "svgo": { - "optional": true - }, - "terser": { - "optional": true - }, - "uncss": { - "optional": true - } - } - }, - "node_modules/htmlparser2": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-7.2.0.tgz", - "integrity": "sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog==", - "dev": true, - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.0.1", - "domhandler": "^4.2.2", - "domutils": "^2.8.0", - "entities": "^3.0.1" - } - }, - "node_modules/htmlparser2/node_modules/entities": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", - "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", - "dev": true, - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/http-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", - "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", - "dependencies": { - "@tootallnate/once": "2", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "engines": { - "node": ">=10.17.0" - } - }, - "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/import-fresh/node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/import-local": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", - "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", - "dependencies": { - "pkg-dir": "^4.2.0", - "resolve-cwd": "^3.0.0" - }, - "bin": { - "import-local-fixture": "fixtures/cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" - }, - "node_modules/is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-core-module": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", - "dependencies": { - "has": "^1.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-generator-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", - "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/is-generator-function": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", - "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", - "dependencies": { - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-json": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-json/-/is-json-2.0.1.tgz", - "integrity": "sha512-6BEnpVn1rcf3ngfmViLM6vjUjGErbdrL4rwlv+u1NO1XO8kqT4YGL8+19Q+Z/bas8tY90BTWMk2+fW1g6hQjbA==", - "dev": true - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-potential-custom-element-name": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==" - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-typed-array": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", - "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", - "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" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" - }, - "node_modules/istanbul-lib-coverage": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", - "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", - "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", - "dependencies": { - "@babel/core": "^7.12.3", - "@babel/parser": "^7.14.7", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", - "dependencies": { - "istanbul-lib-coverage": "^3.0.0", - "make-dir": "^3.0.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/istanbul-lib-source-maps": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", - "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", - "dependencies": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^3.0.0", - "source-map": "^0.6.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-reports": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", - "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", - "dependencies": { - "html-escaper": "^2.0.0", - "istanbul-lib-report": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest/-/jest-29.5.0.tgz", - "integrity": "sha512-juMg3he2uru1QoXX078zTa7pO85QyB9xajZc6bU+d9yEGwrKX6+vGmJQ3UdVZsvTEUARIdObzH68QItim6OSSQ==", - "dependencies": { - "@jest/core": "^29.5.0", - "@jest/types": "^29.5.0", - "import-local": "^3.0.2", - "jest-cli": "^29.5.0" - }, - "bin": { - "jest": "bin/jest.js" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/jest-changed-files": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.5.0.tgz", - "integrity": "sha512-IFG34IUMUaNBIxjQXF/iu7g6EcdMrGRRxaUSw92I/2g2YC6vCdTltl4nHvt7Ci5nSJwXIkCu8Ka1DKF+X7Z1Ag==", - "dependencies": { - "execa": "^5.0.0", - "p-limit": "^3.1.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-circus": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.5.0.tgz", - "integrity": "sha512-gq/ongqeQKAplVxqJmbeUOJJKkW3dDNPY8PjhJ5G0lBRvu0e3EWGxGy5cI4LAGA7gV2UHCtWBI4EMXK8c9nQKA==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/expect": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "co": "^4.6.0", - "dedent": "^0.7.0", - "is-generator-fn": "^2.0.0", - "jest-each": "^29.5.0", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", - "p-limit": "^3.1.0", - "pretty-format": "^29.5.0", - "pure-rand": "^6.0.0", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-cli": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.5.0.tgz", - "integrity": "sha512-L1KcP1l4HtfwdxXNFCL5bmUbLQiKrakMUriBEcc1Vfz6gx31ORKdreuWvmQVBit+1ss9NNR3yxjwfwzZNdQXJw==", - "dependencies": { - "@jest/core": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", - "chalk": "^4.0.0", - "exit": "^0.1.2", - "graceful-fs": "^4.2.9", - "import-local": "^3.0.2", - "jest-config": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "prompts": "^2.0.1", - "yargs": "^17.3.1" - }, - "bin": { - "jest": "bin/jest.js" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" - }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } - } - }, - "node_modules/jest-config": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.5.0.tgz", - "integrity": "sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==", - "dependencies": { - "@babel/core": "^7.11.6", - "@jest/test-sequencer": "^29.5.0", - "@jest/types": "^29.5.0", - "babel-jest": "^29.5.0", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "deepmerge": "^4.2.2", - "glob": "^7.1.3", - "graceful-fs": "^4.2.9", - "jest-circus": "^29.5.0", - "jest-environment-node": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-runner": "^29.5.0", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "micromatch": "^4.0.4", - "parse-json": "^5.2.0", - "pretty-format": "^29.5.0", - "slash": "^3.0.0", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "@types/node": "*", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "ts-node": { - "optional": true - } - } - }, - "node_modules/jest-config/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/jest-config/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/jest-config/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/jest-diff": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.5.0.tgz", - "integrity": "sha512-LtxijLLZBduXnHSniy0WMdaHjmQnt3g5sa16W4p0HqukYTTsyTW3GD1q41TyGl5YFXj/5B2U6dlh5FM1LIMgxw==", - "dependencies": { - "chalk": "^4.0.0", - "diff-sequences": "^29.4.3", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-docblock": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.4.3.tgz", - "integrity": "sha512-fzdTftThczeSD9nZ3fzA/4KkHtnmllawWrXO69vtI+L9WjEIuXWs4AmyME7lN5hU7dB0sHhuPfcKofRsUb/2Fg==", - "dependencies": { - "detect-newline": "^3.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-each": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.5.0.tgz", - "integrity": "sha512-HM5kIJ1BTnVt+DQZ2ALp3rzXEl+g726csObrW/jpEGl+CDSSQpOJJX2KE/vEg8cxcMXdyEPu6U4QX5eruQv5hA==", - "dependencies": { - "@jest/types": "^29.5.0", - "chalk": "^4.0.0", - "jest-get-type": "^29.4.3", - "jest-util": "^29.5.0", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-environment-jsdom": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-29.5.0.tgz", - "integrity": "sha512-/KG8yEK4aN8ak56yFVdqFDzKNHgF4BAymCx2LbPNPsUshUlfAl0eX402Xm1pt+eoG9SLZEUVifqXtX8SK74KCw==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/jsdom": "^20.0.0", - "@types/node": "*", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0", - "jsdom": "^20.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "canvas": "^2.5.0" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, - "node_modules/jest-environment-node": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.5.0.tgz", - "integrity": "sha512-ExxuIK/+yQ+6PRGaHkKewYtg6hto2uGCgvKdb2nfJfKXgZ17DfXjvbZ+jA1Qt9A8EQSfPnt5FKIfnOO3u1h9qw==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "jest-mock": "^29.5.0", - "jest-util": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-get-type": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.4.3.tgz", - "integrity": "sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-haste-map": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.5.0.tgz", - "integrity": "sha512-IspOPnnBro8YfVYSw6yDRKh/TiCdRngjxeacCps1cQ9cgVN6+10JUcuJ1EabrgYLOATsIAigxA0rLR9x/YlrSA==", - "dependencies": { - "@jest/types": "^29.5.0", - "@types/graceful-fs": "^4.1.3", - "@types/node": "*", - "anymatch": "^3.0.3", - "fb-watchman": "^2.0.0", - "graceful-fs": "^4.2.9", - "jest-regex-util": "^29.4.3", - "jest-util": "^29.5.0", - "jest-worker": "^29.5.0", - "micromatch": "^4.0.4", - "walker": "^1.0.8" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "optionalDependencies": { - "fsevents": "^2.3.2" - } - }, - "node_modules/jest-leak-detector": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.5.0.tgz", - "integrity": "sha512-u9YdeeVnghBUtpN5mVxjID7KbkKE1QU4f6uUwuxiY0vYRi9BUCLKlPEZfDGR67ofdFmDz9oPAy2G92Ujrntmow==", - "dependencies": { - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-matcher-utils": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.5.0.tgz", - "integrity": "sha512-lecRtgm/rjIK0CQ7LPQwzCs2VwW6WAahA55YBuI+xqmhm7LAaxokSB8C97yJeYyT+HvQkH741StzpU41wohhWw==", - "dependencies": { - "chalk": "^4.0.0", - "jest-diff": "^29.5.0", - "jest-get-type": "^29.4.3", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-message-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.5.0.tgz", - "integrity": "sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==", - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.5.0", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^29.5.0", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-mock": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.5.0.tgz", - "integrity": "sha512-GqOzvdWDE4fAV2bWQLQCkujxYWL7RxjCnj71b5VhDAGOevB3qj3Ovg26A5NI84ZpODxyzaozXLOh2NCgkbvyaw==", - "dependencies": { - "@jest/types": "^29.5.0", - "@types/node": "*", - "jest-util": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-pnp-resolver": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", - "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "engines": { - "node": ">=6" - }, - "peerDependencies": { - "jest-resolve": "*" - }, - "peerDependenciesMeta": { - "jest-resolve": { - "optional": true - } - } - }, - "node_modules/jest-regex-util": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.4.3.tgz", - "integrity": "sha512-O4FglZaMmWXbGHSQInfXewIsd1LMn9p3ZXB/6r4FOkyhX2/iP/soMG98jGvk/A3HAN78+5VWcBGO0BJAPRh4kg==", - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-resolve": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.5.0.tgz", - "integrity": "sha512-1TzxJ37FQq7J10jPtQjcc+MkCkE3GBpBecsSUWJ0qZNJpmg6m0D9/7II03yJulm3H/fvVjgqLh/k2eYg+ui52w==", - "dependencies": { - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "jest-pnp-resolver": "^1.2.2", - "jest-util": "^29.5.0", - "jest-validate": "^29.5.0", - "resolve": "^1.20.0", - "resolve.exports": "^2.0.0", - "slash": "^3.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-resolve-dependencies": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.5.0.tgz", - "integrity": "sha512-sjV3GFr0hDJMBpYeUuGduP+YeCRbd7S/ck6IvL3kQ9cpySYKqcqhdLLC2rFwrcL7tz5vYibomBrsFYWkIGGjOg==", - "dependencies": { - "jest-regex-util": "^29.4.3", - "jest-snapshot": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-runner": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.5.0.tgz", - "integrity": "sha512-m7b6ypERhFghJsslMLhydaXBiLf7+jXy8FwGRHO3BGV1mcQpPbwiqiKUR2zU2NJuNeMenJmlFZCsIqzJCTeGLQ==", - "dependencies": { - "@jest/console": "^29.5.0", - "@jest/environment": "^29.5.0", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "emittery": "^0.13.1", - "graceful-fs": "^4.2.9", - "jest-docblock": "^29.4.3", - "jest-environment-node": "^29.5.0", - "jest-haste-map": "^29.5.0", - "jest-leak-detector": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-resolve": "^29.5.0", - "jest-runtime": "^29.5.0", - "jest-util": "^29.5.0", - "jest-watcher": "^29.5.0", - "jest-worker": "^29.5.0", - "p-limit": "^3.1.0", - "source-map-support": "0.5.13" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-runtime": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.5.0.tgz", - "integrity": "sha512-1Hr6Hh7bAgXQP+pln3homOiEZtCDZFqwmle7Ew2j8OlbkIu6uE3Y/etJQG8MLQs3Zy90xrp2C0BRrtPHG4zryw==", - "dependencies": { - "@jest/environment": "^29.5.0", - "@jest/fake-timers": "^29.5.0", - "@jest/globals": "^29.5.0", - "@jest/source-map": "^29.4.3", - "@jest/test-result": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "cjs-module-lexer": "^1.0.0", - "collect-v8-coverage": "^1.0.0", - "glob": "^7.1.3", - "graceful-fs": "^4.2.9", - "jest-haste-map": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-mock": "^29.5.0", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.5.0", - "jest-snapshot": "^29.5.0", - "jest-util": "^29.5.0", - "slash": "^3.0.0", - "strip-bom": "^4.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-runtime/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/jest-runtime/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/jest-runtime/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/jest-snapshot": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.5.0.tgz", - "integrity": "sha512-x7Wolra5V0tt3wRs3/ts3S6ciSQVypgGQlJpz2rsdQYoUKxMxPNaoHMGJN6qAuPJqS+2iQ1ZUn5kl7HCyls84g==", - "dependencies": { - "@babel/core": "^7.11.6", - "@babel/generator": "^7.7.2", - "@babel/plugin-syntax-jsx": "^7.7.2", - "@babel/plugin-syntax-typescript": "^7.7.2", - "@babel/traverse": "^7.7.2", - "@babel/types": "^7.3.3", - "@jest/expect-utils": "^29.5.0", - "@jest/transform": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/babel__traverse": "^7.0.6", - "@types/prettier": "^2.1.5", - "babel-preset-current-node-syntax": "^1.0.0", - "chalk": "^4.0.0", - "expect": "^29.5.0", - "graceful-fs": "^4.2.9", - "jest-diff": "^29.5.0", - "jest-get-type": "^29.4.3", - "jest-matcher-utils": "^29.5.0", - "jest-message-util": "^29.5.0", - "jest-util": "^29.5.0", - "natural-compare": "^1.4.0", - "pretty-format": "^29.5.0", - "semver": "^7.3.5" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-snapshot/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/jest-util": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.5.0.tgz", - "integrity": "sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ==", - "dependencies": { - "@jest/types": "^29.5.0", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-validate": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.5.0.tgz", - "integrity": "sha512-pC26etNIi+y3HV8A+tUGr/lph9B18GnzSRAkPaaZJIE1eFdiYm6/CewuiJQ8/RlfHd1u/8Ioi8/sJ+CmbA+zAQ==", - "dependencies": { - "@jest/types": "^29.5.0", - "camelcase": "^6.2.0", - "chalk": "^4.0.0", - "jest-get-type": "^29.4.3", - "leven": "^3.1.0", - "pretty-format": "^29.5.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-validate/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jest-watcher": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.5.0.tgz", - "integrity": "sha512-KmTojKcapuqYrKDpRwfqcQ3zjMlwu27SYext9pt4GlF5FUgB+7XE1mcCnSm6a4uUpFyQIkb6ZhzZvHl+jiBCiA==", - "dependencies": { - "@jest/test-result": "^29.5.0", - "@jest/types": "^29.5.0", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "emittery": "^0.13.1", - "jest-util": "^29.5.0", - "string-length": "^4.0.1" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-worker": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.5.0.tgz", - "integrity": "sha512-NcrQnevGoSp4b5kg+akIpthoAFHxPBcb5P6mYPY0fUNT+sSvmtu6jlkEle3anczUKIKEbMxFimk9oTP/tpIPgA==", - "dependencies": { - "@types/node": "*", - "jest-util": "^29.5.0", - "merge-stream": "^2.0.0", - "supports-color": "^8.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/jest-worker/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/jsdom": { - "version": "20.0.3", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-20.0.3.tgz", - "integrity": "sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ==", - "dependencies": { - "abab": "^2.0.6", - "acorn": "^8.8.1", - "acorn-globals": "^7.0.0", - "cssom": "^0.5.0", - "cssstyle": "^2.3.0", - "data-urls": "^3.0.2", - "decimal.js": "^10.4.2", - "domexception": "^4.0.0", - "escodegen": "^2.0.0", - "form-data": "^4.0.0", - "html-encoding-sniffer": "^3.0.0", - "http-proxy-agent": "^5.0.0", - "https-proxy-agent": "^5.0.1", - "is-potential-custom-element-name": "^1.0.1", - "nwsapi": "^2.2.2", - "parse5": "^7.1.1", - "saxes": "^6.0.0", - "symbol-tree": "^3.2.4", - "tough-cookie": "^4.1.2", - "w3c-xmlserializer": "^4.0.0", - "webidl-conversions": "^7.0.0", - "whatwg-encoding": "^2.0.0", - "whatwg-mimetype": "^3.0.0", - "whatwg-url": "^11.0.0", - "ws": "^8.11.0", - "xml-name-validator": "^4.0.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "canvas": "^2.5.0" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/json-parse-even-better-errors": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" - }, - "node_modules/json-schema-ref-parser": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", - "integrity": "sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==", - "deprecated": "Please switch to @apidevtools/json-schema-ref-parser", - "dependencies": { - "@apidevtools/json-schema-ref-parser": "9.0.9" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "engines": { - "node": ">=6" - } - }, - "node_modules/leven": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", - "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", - "engines": { - "node": ">=6" - } - }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/lightningcss": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.19.0.tgz", - "integrity": "sha512-yV5UR7og+Og7lQC+70DA7a8ta1uiOPnWPJfxa0wnxylev5qfo4P+4iMpzWAdYWOca4jdNQZii+bDL/l+4hUXIA==", - "dev": true, - "dependencies": { - "detect-libc": "^1.0.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "optionalDependencies": { - "lightningcss-darwin-arm64": "1.19.0", - "lightningcss-darwin-x64": "1.19.0", - "lightningcss-linux-arm-gnueabihf": "1.19.0", - "lightningcss-linux-arm64-gnu": "1.19.0", - "lightningcss-linux-arm64-musl": "1.19.0", - "lightningcss-linux-x64-gnu": "1.19.0", - "lightningcss-linux-x64-musl": "1.19.0", - "lightningcss-win32-x64-msvc": "1.19.0" - } - }, - "node_modules/lightningcss-darwin-arm64": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.19.0.tgz", - "integrity": "sha512-wIJmFtYX0rXHsXHSr4+sC5clwblEMji7HHQ4Ub1/CznVRxtCFha6JIt5JZaNf8vQrfdZnBxLLC6R8pC818jXqg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-darwin-x64": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.19.0.tgz", - "integrity": "sha512-Lif1wD6P4poaw9c/4Uh2z+gmrWhw/HtXFoeZ3bEsv6Ia4tt8rOJBdkfVaUJ6VXmpKHALve+iTyP2+50xY1wKPw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.19.0.tgz", - "integrity": "sha512-P15VXY5682mTXaiDtbnLYQflc8BYb774j2R84FgDLJTN6Qp0ZjWEFyN1SPqyfTj2B2TFjRHRUvQSSZ7qN4Weig==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.19.0.tgz", - "integrity": "sha512-zwXRjWqpev8wqO0sv0M1aM1PpjHz6RVIsBcxKszIG83Befuh4yNysjgHVplF9RTU7eozGe3Ts7r6we1+Qkqsww==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.19.0.tgz", - "integrity": "sha512-vSCKO7SDnZaFN9zEloKSZM5/kC5gbzUjoJQ43BvUpyTFUX7ACs/mDfl2Eq6fdz2+uWhUh7vf92c4EaaP4udEtA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.19.0.tgz", - "integrity": "sha512-0AFQKvVzXf9byrXUq9z0anMGLdZJS+XSDqidyijI5njIwj6MdbvX2UZK/c4FfNmeRa2N/8ngTffoIuOUit5eIQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-musl": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.19.0.tgz", - "integrity": "sha512-SJoM8CLPt6ECCgSuWe+g0qo8dqQYVcPiW2s19dxkmSI5+Uu1GIRzyKA0b7QqmEXolA+oSJhQqCmJpzjY4CuZAg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.19.0.tgz", - "integrity": "sha512-C+VuUTeSUOAaBZZOPT7Etn/agx/MatzJzGRkeV+zEABmPuntv1zihncsi+AyGmjkkzq3wVedEy7h0/4S84mUtg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lines-and-columns": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", - "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" - }, - "node_modules/lmdb": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/lmdb/-/lmdb-2.5.2.tgz", - "integrity": "sha512-V5V5Xa2Hp9i2XsbDALkBTeHXnBXh/lEmk9p22zdr7jtuOIY9TGhjK6vAvTpOOx9IKU4hJkRWZxn/HsvR1ELLtA==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "msgpackr": "^1.5.4", - "node-addon-api": "^4.3.0", - "node-gyp-build-optional-packages": "5.0.3", - "ordered-binary": "^1.2.4", - "weak-lru-cache": "^1.2.2" - }, - "optionalDependencies": { - "@lmdb/lmdb-darwin-arm64": "2.5.2", - "@lmdb/lmdb-darwin-x64": "2.5.2", - "@lmdb/lmdb-linux-arm": "2.5.2", - "@lmdb/lmdb-linux-arm64": "2.5.2", - "@lmdb/lmdb-linux-x64": "2.5.2", - "@lmdb/lmdb-win32-x64": "2.5.2" - } - }, - "node_modules/lmdb/node_modules/node-addon-api": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-4.3.0.tgz", - "integrity": "sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==", - "dev": true - }, - "node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "peer": true, - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" - }, - "node_modules/makeerror": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", - "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", - "dependencies": { - "tmpl": "1.0.5" - } - }, - "node_modules/md5.js": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", - "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", - "dev": true, - "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/mdn-data": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz", - "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==", - "dev": true - }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" - }, - "node_modules/mersenne-twister": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mersenne-twister/-/mersenne-twister-1.1.0.tgz", - "integrity": "sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA==" - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "dependencies": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" - }, - "bin": { - "miller-rabin": "bin/miller-rabin" - } - }, - "node_modules/miller-rabin/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/mime": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", - "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", - "dev": true, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true - }, - "node_modules/minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", - "dev": true - }, - "node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/msgpackr": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.8.5.tgz", - "integrity": "sha512-mpPs3qqTug6ahbblkThoUY2DQdNXcm4IapwOS3Vm/87vmpzLVelvp9h3It1y9l1VPpiFLV11vfOXnmeEwiIXwg==", - "dev": true, - "optionalDependencies": { - "msgpackr-extract": "^3.0.1" - } - }, - "node_modules/msgpackr-extract": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.2.tgz", - "integrity": "sha512-SdzXp4kD/Qf8agZ9+iTu6eql0m3kWm1A2y1hkpTeVNENutaB0BwHlSvAIaMxwntmRUAUjon2V4L8Z/njd0Ct8A==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "dependencies": { - "node-gyp-build-optional-packages": "5.0.7" - }, - "bin": { - "download-msgpackr-prebuilds": "bin/download-prebuilds.js" - }, - "optionalDependencies": { - "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.2", - "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.2", - "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.2", - "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.2", - "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.2", - "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.2" - } - }, - "node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.0.7.tgz", - "integrity": "sha512-YlCCc6Wffkx0kHkmam79GKvDQ6x+QZkMjFGrIMxgFNILFvGSbCp2fCBC55pGTT9gVaz8Na5CLmxt/urtzRv36w==", - "dev": true, - "optional": true, - "bin": { - "node-gyp-build-optional-packages": "bin.js", - "node-gyp-build-optional-packages-optional": "optional.js", - "node-gyp-build-optional-packages-test": "build-test.js" - } - }, - "node_modules/nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" - }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" - }, - "node_modules/next": { - "version": "12.3.4", - "resolved": "https://registry.npmjs.org/next/-/next-12.3.4.tgz", - "integrity": "sha512-VcyMJUtLZBGzLKo3oMxrEF0stxh8HwuW976pAzlHhI3t8qJ4SROjCrSh1T24bhrbjw55wfZXAbXPGwPt5FLRfQ==", - "dependencies": { - "@next/env": "12.3.4", - "@swc/helpers": "0.4.11", - "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", - "styled-jsx": "5.0.7", - "use-sync-external-store": "1.2.0" - }, - "bin": { - "next": "dist/bin/next" - }, - "engines": { - "node": ">=12.22.0" - }, - "optionalDependencies": { - "@next/swc-android-arm-eabi": "12.3.4", - "@next/swc-android-arm64": "12.3.4", - "@next/swc-darwin-arm64": "12.3.4", - "@next/swc-darwin-x64": "12.3.4", - "@next/swc-freebsd-x64": "12.3.4", - "@next/swc-linux-arm-gnueabihf": "12.3.4", - "@next/swc-linux-arm64-gnu": "12.3.4", - "@next/swc-linux-arm64-musl": "12.3.4", - "@next/swc-linux-x64-gnu": "12.3.4", - "@next/swc-linux-x64-musl": "12.3.4", - "@next/swc-win32-arm64-msvc": "12.3.4", - "@next/swc-win32-ia32-msvc": "12.3.4", - "@next/swc-win32-x64-msvc": "12.3.4" - }, - "peerDependencies": { - "fibers": ">= 3.1.0", - "node-sass": "^6.0.0 || ^7.0.0", - "react": "^17.0.2 || ^18.0.0-0", - "react-dom": "^17.0.2 || ^18.0.0-0", - "sass": "^1.3.0" - }, - "peerDependenciesMeta": { - "fibers": { - "optional": true - }, - "node-sass": { - "optional": true - }, - "sass": { - "optional": true - } - } - }, - "node_modules/next/node_modules/@swc/helpers": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.11.tgz", - "integrity": "sha512-rEUrBSGIoSFuYxwBYtlUFMlE2CwGhmW+w9355/5oduSw8e5h2+Tj4UrAGNNgP9915++wj5vkQo0UuOBqOAq4nw==", - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/node-addon-api": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", - "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", - "dev": true - }, - "node_modules/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/node-gyp-build": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", - "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", - "dev": true, - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, - "node_modules/node-gyp-build-optional-packages": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.0.3.tgz", - "integrity": "sha512-k75jcVzk5wnnc/FMxsf4udAoTEUv2jY3ycfdSd3yWu6Cnd1oee6/CfZJApyscA4FJOmdoixWwiwOyf16RzD5JA==", - "dev": true, - "bin": { - "node-gyp-build-optional-packages": "bin.js", - "node-gyp-build-optional-packages-optional": "optional.js", - "node-gyp-build-optional-packages-test": "build-test.js" - } - }, - "node_modules/node-int64": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", - "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==" - }, - "node_modules/node-releases": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", - "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==" - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, - "node_modules/nullthrows": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/nullthrows/-/nullthrows-1.1.1.tgz", - "integrity": "sha512-2vPPEi+Z7WqML2jZYddDIfy5Dqb0r2fze2zTxNNknZaFpVHU3mFB3R+DWeJWGVx0ecvttSGlJTI+WG+8Z4cDWw==", - "dev": true - }, - "node_modules/nwsapi": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.2.tgz", - "integrity": "sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw==" - }, - "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/openapi-typescript-codegen": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/openapi-typescript-codegen/-/openapi-typescript-codegen-0.23.0.tgz", - "integrity": "sha512-gOJXy5g3H3HlLpVNN+USrNK2i2KYBmDczk9Xk34u6JorwrGiDJZUj+al4S+i9TXdfUQ/ZaLxE59Xf3wqkxGfqA==", - "dependencies": { - "camelcase": "^6.3.0", - "commander": "^9.3.0", - "fs-extra": "^10.1.0", - "handlebars": "^4.7.7", - "json-schema-ref-parser": "^9.0.9" - }, - "bin": { - "openapi": "bin/index.js" - } - }, - "node_modules/openapi-typescript-codegen/node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "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" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/ordered-binary": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ordered-binary/-/ordered-binary-1.4.0.tgz", - "integrity": "sha512-EHQ/jk4/a9hLupIKxTfUsQRej1Yd/0QLQs3vGvIqg5ZtCYSzNhkzHoZc7Zf4e4kUlDaC3Uw8Q/1opOLNN2OKRQ==", - "dev": true - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/p-locate/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/parcel": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/parcel/-/parcel-2.8.3.tgz", - "integrity": "sha512-5rMBpbNE72g6jZvkdR5gS2nyhwIXaJy8i65osOqs/+5b7zgf3eMKgjSsDrv6bhz3gzifsba6MBJiZdBckl+vnA==", - "dev": true, - "dependencies": { - "@parcel/config-default": "2.8.3", - "@parcel/core": "2.8.3", - "@parcel/diagnostic": "2.8.3", - "@parcel/events": "2.8.3", - "@parcel/fs": "2.8.3", - "@parcel/logger": "2.8.3", - "@parcel/package-manager": "2.8.3", - "@parcel/reporter-cli": "2.8.3", - "@parcel/reporter-dev-server": "2.8.3", - "@parcel/utils": "2.8.3", - "chalk": "^4.1.0", - "commander": "^7.0.0", - "get-port": "^4.2.0", - "v8-compile-cache": "^2.0.0" - }, - "bin": { - "parcel": "lib/bin.js" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/parcel-reporter-static-files-copy": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/parcel-reporter-static-files-copy/-/parcel-reporter-static-files-copy-1.5.0.tgz", - "integrity": "sha512-dsY3MQkbYSgEqS0/22vtD2mZtel8UC0ItH0ok8LmgFeCMTsdhyOtJgvt945ODIzu9lYc/sCIzksM8C77uSE3Fg==", - "dev": true, - "dependencies": { - "@parcel/plugin": "^2.0.0-beta.1" - }, - "engines": { - "parcel": "^2.0.0-beta.1" - } - }, - "node_modules/parcel/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/parse-asn1": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", - "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", - "dev": true, - "dependencies": { - "asn1.js": "^5.2.0", - "browserify-aes": "^1.0.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3", - "safe-buffer": "^5.1.1" - } - }, - "node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/pbkdf2": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", - "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", - "dev": true, - "dependencies": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" - }, - "engines": { - "node": ">=0.12" - } - }, - "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", - "engines": { - "node": ">= 6" - } - }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/polyfill-crypto.getrandomvalues": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/polyfill-crypto.getrandomvalues/-/polyfill-crypto.getrandomvalues-1.0.0.tgz", - "integrity": "sha512-GIkU6bg4auRnDFOqUNit7eLn9hzznrJU1CGFuivQzDeVp4Ys8cY4OY6GhAdndJwo4jryz5cJyjg9ELhvQjdrtw==", - "dependencies": { - "mersenne-twister": "^1.0.1" - } - }, - "node_modules/postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - } - ], - "dependencies": { - "nanoid": "^3.3.4", - "picocolors": "^1.0.0", - "source-map-js": "^1.0.2" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", - "dev": true - }, - "node_modules/posthtml": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.16.6.tgz", - "integrity": "sha512-JcEmHlyLK/o0uGAlj65vgg+7LIms0xKXe60lcDOTU7oVX/3LuEuLwrQpW3VJ7de5TaFKiW4kWkaIpJL42FEgxQ==", - "dev": true, - "dependencies": { - "posthtml-parser": "^0.11.0", - "posthtml-render": "^3.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/posthtml-parser": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.10.2.tgz", - "integrity": "sha512-PId6zZ/2lyJi9LiKfe+i2xv57oEjJgWbsHGGANwos5AvdQp98i6AtamAl8gzSVFGfQ43Glb5D614cvZf012VKg==", - "dev": true, - "dependencies": { - "htmlparser2": "^7.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/posthtml-render": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/posthtml-render/-/posthtml-render-3.0.0.tgz", - "integrity": "sha512-z+16RoxK3fUPgwaIgH9NGnK1HKY9XIDpydky5eQGgAFVXTCSezalv9U2jQuNV+Z9qV1fDWNzldcw4eK0SSbqKA==", - "dev": true, - "dependencies": { - "is-json": "^2.0.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/posthtml/node_modules/posthtml-parser": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.11.0.tgz", - "integrity": "sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw==", - "dev": true, - "dependencies": { - "htmlparser2": "^7.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/pretty-format": { - "version": "29.5.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.5.0.tgz", - "integrity": "sha512-V2mGkI31qdttvTFX7Mt4efOqHXqJWMu4/r66Xh3Z3BwZaPfPJgp6/gbwoujRpPUtfEF6AUUWx3Jim3GCw5g/Qw==", - "dependencies": { - "@jest/schemas": "^29.4.3", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - } - }, - "node_modules/pretty-format/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "dev": true, - "engines": { - "node": ">= 0.6.0" - } - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" - }, - "node_modules/public-encrypt": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", - "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", - "dev": true, - "dependencies": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/public-encrypt/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/pure-rand": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.1.tgz", - "integrity": "sha512-t+x1zEHDjBwkDGY5v5ApnZ/utcd4XYDiJsaQQoptTXgUXX95sDg1elCdJghzicm7n2mbCBJ3uYWr6M22SO19rg==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ] - }, - "node_modules/qs": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.1.tgz", - "integrity": "sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "dev": true, - "dependencies": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" - } - }, - "node_modules/react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, - "node_modules/react-error-overlay": { - "version": "6.0.9", - "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz", - "integrity": "sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==", - "dev": true - }, - "node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - }, - "node_modules/react-refresh": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.9.0.tgz", - "integrity": "sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, - "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", - "dependencies": { - "is-core-module": "^2.9.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/resolve-cwd": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", - "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", - "dependencies": { - "resolve-from": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/resolve.exports": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.1.tgz", - "integrity": "sha512-OEJWVeimw8mgQuj3HfkNl4KqRevH7lzeQNaWRPfx0PPse7Jk6ozcsG4FKVgtzDsC1KUF+YlTHh17NcgHOPykLw==", - "engines": { - "node": ">=10" - } - }, - "node_modules/ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "dev": true, - "dependencies": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "node_modules/saxes": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", - "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", - "dependencies": { - "xmlchars": "^2.2.0" - }, - "engines": { - "node": ">=v12.22.7" - } - }, - "node_modules/scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0" - } - }, - "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - }, - "bin": { - "sha.js": "bin.js" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" - }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "engines": { - "node": ">=8" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.13", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", - "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==" - }, - "node_modules/srcset": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/srcset/-/srcset-4.0.0.tgz", - "integrity": "sha512-wvLeHgcVHKO8Sc/H/5lkGreJQVeYMm9rlmt8PuR1xE31rIuXhuzznUUqAt8MqLhB3MqJdFzlNAfpcWnxiFUcPw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/stable": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", - "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", - "deprecated": "Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility", - "dev": true - }, - "node_modules/stack-utils": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", - "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", - "dependencies": { - "escape-string-regexp": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/stream-browserify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", - "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", - "dev": true, - "dependencies": { - "inherits": "~2.0.4", - "readable-stream": "^3.5.0" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/string-length": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", - "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", - "dependencies": { - "char-regex": "^1.0.2", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", - "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/styled-jsx": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.7.tgz", - "integrity": "sha512-b3sUzamS086YLRuvnaDigdAewz1/EFYlHpYBP5mZovKEdQQOIIYq8lApylub3HHZ6xFjV051kkGU7cudJmrXEA==", - "engines": { - "node": ">= 12.0.0" - }, - "peerDependencies": { - "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "babel-plugin-macros": { - "optional": true - } - } - }, - "node_modules/superagent": { - "version": "8.0.9", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.0.9.tgz", - "integrity": "sha512-4C7Bh5pyHTvU33KpZgwrNKh/VQnvgtCSqPRfJAUdmrtSYePVzVg4E4OzsrbkhJj9O7SO6Bnv75K/F8XVZT8YHA==", - "dev": true, - "dependencies": { - "component-emitter": "^1.3.0", - "cookiejar": "^2.1.4", - "debug": "^4.3.4", - "fast-safe-stringify": "^2.1.1", - "form-data": "^4.0.0", - "formidable": "^2.1.2", - "methods": "^1.1.2", - "mime": "2.6.0", - "qs": "^6.11.0", - "semver": "^7.3.8" - }, - "engines": { - "node": ">=6.4.0 <13 || >=14" - } - }, - "node_modules/superagent/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/superagent/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/superagent/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, - "node_modules/supertest": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/supertest/-/supertest-6.3.3.tgz", - "integrity": "sha512-EMCG6G8gDu5qEqRQ3JjjPs6+FYT1a7Hv5ApHvtSghmOFJYtsU5S+pSb6Y2EUeCEY3CmEL3mmQ8YWlPOzQomabA==", - "dev": true, - "dependencies": { - "methods": "^1.1.2", - "superagent": "^8.0.5" - }, - "engines": { - "node": ">=6.4.0" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/svgo": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz", - "integrity": "sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==", - "dev": true, - "dependencies": { - "@trysound/sax": "0.2.0", - "commander": "^7.2.0", - "css-select": "^4.1.3", - "css-tree": "^1.1.3", - "csso": "^4.2.0", - "picocolors": "^1.0.0", - "stable": "^0.1.8" - }, - "bin": { - "svgo": "bin/svgo" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/svgo/node_modules/commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true, - "engines": { - "node": ">= 10" - } - }, - "node_modules/symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" - }, - "node_modules/term-size": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", - "integrity": "sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/terser": { - "version": "5.16.6", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.6.tgz", - "integrity": "sha512-IBZ+ZQIA9sMaXmRZCUMDjNH0D5AQQfdn4WUjHL0+1lF4TP1IHRJbrhb6fNaXWikrYQTSkb7SLxkeXAiy1p7mbg==", - "dev": true, - "dependencies": { - "@jridgewell/source-map": "^0.3.2", - "acorn": "^8.5.0", - "commander": "^2.20.0", - "source-map-support": "~0.5.20" - }, - "bin": { - "terser": "bin/terser" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "node_modules/terser/node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/test-exclude": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", - "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", - "dependencies": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^7.1.4", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/test-exclude/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/test-exclude/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "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" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/test-exclude/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/timsort": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", - "integrity": "sha512-qsdtZH+vMoCARQtyod4imc2nIJwg9Cc7lPRrw9CzF8ZKR0khdr8+2nX80PBhET3tcyTtJDxAffGh2rXH4tyU8A==", - "dev": true - }, - "node_modules/tmpl": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", - "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==" - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tough-cookie/node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/tr46": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", - "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", - "dependencies": { - "punycode": "^2.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/ts-jest": { - "version": "29.0.5", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.5.tgz", - "integrity": "sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==", - "dependencies": { - "bs-logger": "0.x", - "fast-json-stable-stringify": "2.x", - "jest-util": "^29.0.0", - "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "7.x", - "yargs-parser": "^21.0.1" - }, - "bin": { - "ts-jest": "cli.js" - }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "@babel/core": ">=7.0.0-beta.0 <8", - "@jest/types": "^29.0.0", - "babel-jest": "^29.0.0", - "jest": "^29.0.0", - "typescript": ">=4.3" - }, - "peerDependenciesMeta": { - "@babel/core": { - "optional": true - }, - "@jest/types": { - "optional": true - }, - "babel-jest": { - "optional": true - }, - "esbuild": { - "optional": true - } - } - }, - "node_modules/ts-jest/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-jest/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" - }, - "node_modules/tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true - }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "engines": { - "node": ">=4" - } - }, - "node_modules/type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/update-browserslist-db": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", - "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], - "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" - }, - "bin": { - "browserslist-lint": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, - "node_modules/use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/util": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "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" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "node_modules/utility-types": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz", - "integrity": "sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, - "node_modules/v8-to-istanbul": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", - "integrity": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==", - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.12", - "@types/istanbul-lib-coverage": "^2.0.1", - "convert-source-map": "^1.6.0" - }, - "engines": { - "node": ">=10.12.0" - } - }, - "node_modules/v8-to-istanbul/node_modules/convert-source-map": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", - "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" - }, - "node_modules/w3c-xmlserializer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", - "integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==", - "dependencies": { - "xml-name-validator": "^4.0.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/walker": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", - "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", - "dependencies": { - "makeerror": "1.0.12" - } - }, - "node_modules/weak-lru-cache": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/weak-lru-cache/-/weak-lru-cache-1.2.2.tgz", - "integrity": "sha512-DEAoo25RfSYMuTGc9vPJzZcZullwIqRDSI9LOy+fkCJPi6hykCnfKaXTuPBDuXAUcqHXyOgFtHNp/kB2FjYHbw==", - "dev": true - }, - "node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-encoding": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", - "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", - "dependencies": { - "iconv-lite": "0.6.3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-mimetype": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", - "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-url": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", - "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", - "dependencies": { - "tr46": "^3.0.0", - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/which-typed-array": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", - "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", - "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" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" - }, - "node_modules/write-file-atomic": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", - "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", - "dependencies": { - "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.7" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" - } - }, - "node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/xml-name-validator": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", - "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", - "engines": { - "node": ">=12" - } - }, - "node_modules/xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" - }, - "node_modules/xxhash-wasm": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz", - "integrity": "sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA==", - "dev": true - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" - }, - "node_modules/yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/yargs": { - "version": "17.7.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", - "integrity": "sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "engines": { - "node": ">=12" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/ts/compile/runner/package.json b/ts/compile/runner/package.json deleted file mode 100644 index a02f054d..00000000 --- a/ts/compile/runner/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@loopholelabs/scale-http-examples", - "version": "0.1.0", - "description": "TypeScript version of the scale functions.", - "browserslist": "> 0.5%, last 2 versions, not dead", - "default": "dist/browser.html", - "targets": { - "module_middleware": { - "source": "src/modules/middleware/index.html", - "context": "browser", - "isLibrary": false, - "optimize": true, - "includeNodeModules": true - }, - "module_endpoint": { - "source": "src/modules/endpoint/index.html", - "context": "browser", - "isLibrary": false, - "optimize": true, - "includeNodeModules": true - }, - "module_error": { - "source": "src/modules/error/index.html", - "context": "browser", - "isLibrary": false, - "optimize": true, - "includeNodeModules": true - } - }, - "scripts": { - "build": "parcel build --log-level verbose", - "start": "parcel", - "test": "node --experimental-wasi-unstable-preview1 --trace-warnings node_modules/.bin/jest --no-cache" - }, - "dependencies": { - "@loopholelabs/polyglot-ts": "^0.4.0", - "@loopholelabs/scale-signature-http": "^0.3.8", - "@loopholelabs/scale": "^0.3.14", - "@loopholelabs/scalefile": "^0.1.9" - }, - "devDependencies": { - "@parcel/packager-ts": "^2.7.0", - "@parcel/transformer-typescript-types": "^2.7.0", - "@parcel/validator-typescript": "^2.7.0", - "@types/express": "^4.17.14", - "@types/fastestsmallesttextencoderdecoder": "^1.0.0", - "@types/jest": "^29.2.0", - "@types/node": "^18.11.5", - "@types/supertest": "^2.0.12", - "@types/text-encoding": "^0.0.36", - "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "jest": "^29.2.2", - "jest-environment-jsdom": "^29.2.2", - "parcel": "^2.7.0", - "parcel-reporter-static-files-copy": "^1.4.0", - "process": "^0.11.10", - "stream-browserify": "^3.0.0", - "supertest": "^6.3.1", - "ts-jest": "^29.0.3", - "tty-browserify": "^0.0.1", - "typescript": "^4.7.0" - } -} diff --git a/ts/compile/runner/src/index.ts b/ts/compile/runner/src/index.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/ts/compile/runner/src/modules.test.ts b/ts/compile/runner/src/modules.test.ts deleted file mode 100644 index 45715a2f..00000000 --- a/ts/compile/runner/src/modules.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// import {TextEncoder as te2, TextDecoder as td2} from "fastestsmallesttextencoderdecoder"; - -import { ScaleFunc, V1Alpha, Go } from "@loopholelabs/scalefile/scalefunc"; -import { New } from "@loopholelabs/scale"; -import * as fs from "fs"; - -describe("modules", () => { - let mods = [ - {path: "wasm/module_middleware.wasm", description: "middleware"}, - {path: "wasm/module_middleware_opt.wasm", description: "middleware (speed optimized)"}, - {path: "wasm/module_middleware_gz.wasm", description: "middleware (size optimized)"} - ]; - - for (let k of mods) { - let fileSizeInMegabytes = ""; - - try { - var stats = fs.statSync(k.path); - var fileSizeInBytes = stats.size; - // Convert the file size to megabytes (optional) - fileSizeInMegabytes = (fileSizeInBytes / (1024*1024)).toFixed(2); - } catch(e) {} - - it("Can run module " + k.description + " " + fileSizeInMegabytes + "Mb" , async () => { - const modNext = fs.readFileSync(k.path); - - const fn = new ScaleFunc(V1Alpha, "Test.Middleware", "Test.Tag", "ExampleName@ExampleVersion", Go, modNext); - const r = await New([fn]); - const i = await r.Instance(null); - i.Run(); - let header = i.Context().Response.Headers.get("FROM_TYPESCRIPT"); - expect(header).not.toBeUndefined(); - if (header != undefined) { - let bits = header.Value; - expect(bits.length).toBe(1); - expect(bits[0]).toBe("TRUE"); - } - }); - } - - it("Can run module error" , async () => { - const modError = fs.readFileSync("wasm/module_error.wasm"); - const fn = new ScaleFunc(V1Alpha, "Test.Error", "Test.Tag", "ExampleName@ExampleVersion", Go, modError); - const r = await New([fn]); - const i = await r.Instance(null); - - expect(() => { - i.Run(); - }).toThrow("Something went wrong"); - - }); - - it("Can run module endpoint" , async () => { - const modEndpoint = fs.readFileSync("wasm/module_endpoint.wasm"); - const fn = new ScaleFunc(V1Alpha, "Test.Error", "Test.Tag", "ExampleName@ExampleVersion", Go, modEndpoint); - const r = await New([fn]); - const i = await r.Instance(null); - - i.Run(); - - let decoder = new TextDecoder(); - let body = decoder.decode(i.Context().Response.Body); - - expect(body).toBe("Hello from typescript!"); - }); - -}); \ No newline at end of file diff --git a/ts/compile/runner/src/modules/endpoint/app.ts b/ts/compile/runner/src/modules/endpoint/app.ts deleted file mode 100644 index 437d1f9e..00000000 --- a/ts/compile/runner/src/modules/endpoint/app.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright 2022 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import "../../runner"; -import { GuestContext, HttpStringList } from "@loopholelabs/scale-signature-http"; - -function scalefn(inContext: GuestContext) { - inContext.Next(); - - inContext.Response.SetBody("Hello from typescript!"); -} - -// Export it -(global as any).scale = scalefn; \ No newline at end of file diff --git a/ts/compile/runner/src/modules/endpoint/index.html b/ts/compile/runner/src/modules/endpoint/index.html deleted file mode 100644 index 6a668ef9..00000000 --- a/ts/compile/runner/src/modules/endpoint/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -Testing 1 2 3 - - - diff --git a/ts/compile/runner/src/modules/error/app.ts b/ts/compile/runner/src/modules/error/app.ts deleted file mode 100644 index 4a5b391b..00000000 --- a/ts/compile/runner/src/modules/error/app.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2022 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import "../../runner"; -import { GuestContext, HttpStringList } from "@loopholelabs/scale-signature-http"; - - -function scalefn(inContext: GuestContext) { - throw new Error("Something went wrong"); -} - -(global as any).scale = scalefn; \ No newline at end of file diff --git a/ts/compile/runner/src/modules/error/index.html b/ts/compile/runner/src/modules/error/index.html deleted file mode 100644 index 6a668ef9..00000000 --- a/ts/compile/runner/src/modules/error/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -Testing 1 2 3 - - - diff --git a/ts/compile/runner/src/modules/middleware/app.ts b/ts/compile/runner/src/modules/middleware/app.ts deleted file mode 100644 index 050a5de8..00000000 --- a/ts/compile/runner/src/modules/middleware/app.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright 2022 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import "../../runner"; -import { GuestContext, HttpStringList } from "@loopholelabs/scale-signature-http"; - - -function scalefn(inContext: GuestContext) { - inContext.Next(); - - // Lets add a header to show things are working... - inContext.Response.SetHeader("FROM_TYPESCRIPT", new HttpStringList(["TRUE"])); -} - -(global as any).scale = scalefn; \ No newline at end of file diff --git a/ts/compile/runner/src/modules/middleware/index.html b/ts/compile/runner/src/modules/middleware/index.html deleted file mode 100644 index 6a668ef9..00000000 --- a/ts/compile/runner/src/modules/middleware/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -Testing 1 2 3 - - - diff --git a/ts/compile/runner/src/runner.ts b/ts/compile/runner/src/runner.ts deleted file mode 100644 index 9a4b44ac..00000000 --- a/ts/compile/runner/src/runner.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2022 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -declare var scale: ScaleFunction; // This should be defined in the global scope. - - -import { TextEncoder, TextDecoder } from "./text"; - -//import { TextEncoder, TextDecoder } from "text-encoding"; -(global as any).TextEncoder = TextEncoder; -(global as any).TextDecoder = TextDecoder; - -import { Resize, GuestContext } from "@loopholelabs/scale-signature-http"; - -export type ScaleFunction = (a: GuestContext) => GuestContext; - -function mainFunction() { -// console.log("Console.log Main function called"); -// console.error("Console.error Main function called"); -} - -// Create a new dummy GuestContext. -var ctx = new GuestContext(); - -// Our own run function wrapper -function runFunction(): bigint { - ctx.FromReadBuffer(); // Read from the read buffer. - - try { - scale(ctx); - - let [ptr, len] = ctx.ToWriteBuffer(); - return BigInt(ptr) << BigInt(32) | BigInt(len); - } catch(e) { - let [ptr, len] = ctx.ErrorWriteBuffer(e as Error); - return BigInt(ptr) << BigInt(32) | BigInt(len); - } - -} - -// Route the resize through to the signature -function resizeFunction(size: number): number { - return Resize(size); -} - -(global as any).Exports = { - main: mainFunction, - run: runFunction, - resize: resizeFunction -} diff --git a/ts/compile/runner/src/text.ts b/ts/compile/runner/src/text.ts deleted file mode 100644 index 83c5444d..00000000 --- a/ts/compile/runner/src/text.ts +++ /dev/null @@ -1,117 +0,0 @@ -// TextEncoder/TextDecoder polyfills for utf-8 - an implementation of TextEncoder/TextDecoder APIs -// Written in 2013 by Viktor Mukhachev -// To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. -// You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . - -// Some important notes about the polyfill below: -// Native TextEncoder/TextDecoder implementation is overwritten -// String.prototype.codePointAt polyfill not included, as well as String.fromCodePoint -// TextEncoder.prototype.encode returns a regular array instead of Uint8Array -// No options (fatal of the TextDecoder constructor and stream of the TextDecoder.prototype.decode method) are supported. -// TextDecoder.prototype.decode does not valid byte sequences -// This is a demonstrative implementation not intended to have the best performance - -// http://encoding.spec.whatwg.org/#textencoder - -// http://encoding.spec.whatwg.org/#textencoder - -export class TextEncoder { - public encoding = "utf-8"; - - constructor() { - } - - public encodeInto(s: string, u: Uint8Array): any { - console.log("TODO: encodeInto unsupported"); - return {read: 0, written: 0}; - } - - public encode(s: string): Uint8Array { - var octets = []; - var length = s.length; - var i = 0; - while (i < length) { - var codePoint = s.codePointAt(i); - if (codePoint!=undefined) { - var c = 0; - var bits = 0; - if (codePoint <= 0x0000007F) { - c = 0; - bits = 0x00; - } else if (codePoint <= 0x000007FF) { - c = 6; - bits = 0xC0; - } else if (codePoint <= 0x0000FFFF) { - c = 12; - bits = 0xE0; - } else if (codePoint <= 0x001FFFFF) { - c = 18; - bits = 0xF0; - } - octets.push(bits | (codePoint >> c)); - c -= 6; - while (c >= 0) { - octets.push(0x80 | ((codePoint >> c) & 0x3F)); - c -= 6; - } - i += codePoint >= 0x10000 ? 2 : 1; - } - } - return new Uint8Array(octets); - } -} - -export class TextDecoder { - public encoding = "utf-8"; - public fatal = false; - public ignoreBOM = false; - - constructor() { - } - - public decode(a: any): string { - if (a instanceof Uint8Array) { - return this.decodeUint8Array(a); - } else { - console.log("TODO: TextDecoder called with " + typeof(a), a) - return ""; - } - } - - private decodeUint8Array(a: Uint8Array): string { - var string = ""; - var i = 0; - while (i < a.length) { - var octet = a[i]; - var bytesNeeded = 0; - var codePoint = 0; - if (octet <= 0x7F) { - bytesNeeded = 0; - codePoint = octet & 0xFF; - } else if (octet <= 0xDF) { - bytesNeeded = 1; - codePoint = octet & 0x1F; - } else if (octet <= 0xEF) { - bytesNeeded = 2; - codePoint = octet & 0x0F; - } else if (octet <= 0xF4) { - bytesNeeded = 3; - codePoint = octet & 0x07; - } - if (a.length - i - bytesNeeded > 0) { - var k = 0; - while (k < bytesNeeded) { - octet = a[i + k + 1]; - codePoint = (codePoint << 6) | (octet & 0x3F); - k += 1; - } - } else { - codePoint = 0xFFFD; - bytesNeeded = a.length - i; - } - string += String.fromCodePoint(codePoint); - i += bytesNeeded + 1; - } - return string - } -} diff --git a/ts/compile/runner/tsconfig.json b/ts/compile/runner/tsconfig.json deleted file mode 100644 index 33aec38c..00000000 --- a/ts/compile/runner/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "include": ["src/**/*.ts"], - "compilerOptions": { - "target": "es2020", - "module": "commonjs", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true, - "resolveJsonModule": true, - "paths": { - "scale-js": ["."] - }, - "types": ["node", "jest"] - } -} diff --git a/ts/compile/runner/wasm/README.md b/ts/compile/runner/wasm/README.md deleted file mode 100644 index 04929a3d..00000000 --- a/ts/compile/runner/wasm/README.md +++ /dev/null @@ -1 +0,0 @@ -HTTP sample modules go here diff --git a/ts/compile/templates/package.json.templ b/ts/compile/templates/package.json.templ deleted file mode 100644 index e5215d7c..00000000 --- a/ts/compile/templates/package.json.templ +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@loopholelabs/scale", - "version": "0.1.0", - "description": "TypeScript scale function.", - "browserslist": "> 0.5%, last 2 versions, not dead", - "default": "dist/browser.html", - "targets": { - "module_scale": { - "source": "runner.ts", - "context": "browser", - "isLibrary": false, - "optimize": true, - "includeNodeModules": true - } - }, - "scripts": { - "build": "parcel build --log-level verbose" - }, - "dependencies": { {{$first := true}}{{range $dependency := .dependencies -}}{{if $first}}{{$first = false}}{{else}},{{end}} - "{{ $dependency.Name }}": "{{ $dependency.Version }}"{{end}} - }, - "devDependencies": { - "@parcel/packager-ts": "^2.7.0", - "@parcel/transformer-typescript-types": "^2.7.0", - "@parcel/validator-typescript": "^2.7.0", - "@types/node": "^18.11.5", - "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", - "events": "^3.3.0", - "parcel": "^2.7.0", - "process": "^0.11.10", - "tty-browserify": "^0.0.1", - "typescript": "^4.7.0" - } -} diff --git a/ts/compile/templates/runner.ts.templ b/ts/compile/templates/runner.ts.templ deleted file mode 100644 index f6326eff..00000000 --- a/ts/compile/templates/runner.ts.templ +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright 2022 Loophole Labs - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -// First lets setup TextEncode and TextDecoder to ensure they're available for polyglot. -export class TextEncoder { - public encoding = "utf-8"; - - constructor() { - } - - public encodeInto(s: string, u: Uint8Array): any { - console.log("TODO: encodeInto unsupported"); - return {read: 0, written: 0}; - } - - public encode(s: string): Uint8Array { - var octets = []; - var length = s.length; - var i = 0; - while (i < length) { - var codePoint = s.codePointAt(i); - if (codePoint!=undefined) { - var c = 0; - var bits = 0; - if (codePoint <= 0x0000007F) { - c = 0; - bits = 0x00; - } else if (codePoint <= 0x000007FF) { - c = 6; - bits = 0xC0; - } else if (codePoint <= 0x0000FFFF) { - c = 12; - bits = 0xE0; - } else if (codePoint <= 0x001FFFFF) { - c = 18; - bits = 0xF0; - } - octets.push(bits | (codePoint >> c)); - c -= 6; - while (c >= 0) { - octets.push(0x80 | ((codePoint >> c) & 0x3F)); - c -= 6; - } - i += codePoint >= 0x10000 ? 2 : 1; - } - } - return new Uint8Array(octets); - } -} - -export class TextDecoder { - public encoding = "utf-8"; - public fatal = false; - public ignoreBOM = false; - - constructor() { - } - - public decode(a: any): string { - if (a instanceof Uint8Array) { - return this.decodeUint8Array(a); - } else { - console.log("TODO: TextDecoder called with " + typeof(a), a) - return ""; - } - } - - private decodeUint8Array(a: Uint8Array): string { - var string = ""; - var i = 0; - while (i < a.length) { - var octet = a[i]; - var bytesNeeded = 0; - var codePoint = 0; - if (octet <= 0x7F) { - bytesNeeded = 0; - codePoint = octet & 0xFF; - } else if (octet <= 0xDF) { - bytesNeeded = 1; - codePoint = octet & 0x1F; - } else if (octet <= 0xEF) { - bytesNeeded = 2; - codePoint = octet & 0x0F; - } else if (octet <= 0xF4) { - bytesNeeded = 3; - codePoint = octet & 0x07; - } - if (a.length - i - bytesNeeded > 0) { - var k = 0; - while (k < bytesNeeded) { - octet = a[i + k + 1]; - codePoint = (codePoint << 6) | (octet & 0x3F); - k += 1; - } - } else { - codePoint = 0xFFFD; - bytesNeeded = a.length - i; - } - string += String.fromCodePoint(codePoint); - i += bytesNeeded + 1; - } - return string - } -} - - -(global as any).TextEncoder = TextEncoder; -(global as any).TextDecoder = TextDecoder; - -import { Resize, GuestContext } from "@loopholelabs/{{ .signature }}"; - -import { scale } from "./scale"; - -// Create a new dummy GuestContext. -var ctx = new GuestContext(); - -// Any global init can be done here -function mainFunction() { -} - -// Our own run function wrapper -function runFunction(): bigint { - ctx.FromReadBuffer(); // Read from the read buffer. - - try { - scale(ctx); - - let [ptr, len] = ctx.ToWriteBuffer(); - return BigInt(ptr) << BigInt(32) | BigInt(len); - } catch(e) { - let [ptr, len] = ctx.ErrorWriteBuffer(e as Error); - return BigInt(ptr) << BigInt(32) | BigInt(len); - } -} - -// Route the resize through to the signature -function resizeFunction(size: number): number { - return Resize(size); -} - -(global as any).Exports = { - main: mainFunction, - run: runFunction, - resize: resizeFunction -} diff --git a/ts/func.ts b/ts/func.ts deleted file mode 100644 index 3eabab3f..00000000 --- a/ts/func.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { v4 as uuidv4 } from 'uuid'; -import { Signature } from "@loopholelabs/scale-signature"; - -import { Instance } from "./instance"; -import { Pool } from "./pool"; -import {ScaleFunc} from "@loopholelabs/scalefile/scalefunc"; - -export class Func { - public scaleFunc: ScaleFunc; - public wasmModule: WebAssembly.Module; - public next: undefined | Func; - public id: string; - - public modulePool: undefined | Pool; - - constructor(scaleFunc: ScaleFunc, wasmModule: WebAssembly.Module) { - this.scaleFunc = scaleFunc; - this.wasmModule = wasmModule; - this.id = uuidv4(); - } - - Run(i: Instance) { - if (this.modulePool === undefined) { - throw new Error("modulePool not set"); - } - const module = this.modulePool.Get(); - - module.init(i); - - const encoded = i.RuntimeContext().Write(); - - if (module.resize === undefined || module.run === undefined || module.memory === undefined) { - throw new Error("Module doesn't have resize/run/memory"); - } - - const encPtr = module.resize(encoded.length); - - const memData = new Uint8Array(module.memory.buffer); - memData.set(encoded, encPtr); - - const packed = module.run(encPtr, encoded.length); - - const [ptr, len] = Func.unpackMemoryRef(packed); - const memDataOut = new Uint8Array(module.memory.buffer); - const inContextBuff = memDataOut.slice(ptr, ptr + len); - - const err = i.RuntimeContext().Read(inContextBuff); - if (err !== undefined) { - throw err; - } - } - - // Pack a pointer and length into a single 64bit - public static packMemoryRef(ptr: number, len: number): BigInt { - if (ptr > 0xffffffff || len > 0xffffffff) { - // Error! We can't do it. - } - return (BigInt(ptr) << BigInt(32)) | BigInt(len); - } - - // Unpack a memory ref from 64bit to 2x32bits - public static unpackMemoryRef(packed: bigint): [number, number] { - const ptr = Number((packed >> BigInt(32)) & BigInt(0xffffffff)); - const len = Number(packed & BigInt(0xffffffff)); - return [ptr, len]; - } - -} \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts deleted file mode 100644 index 8ee5c8fb..00000000 --- a/ts/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -export * from "./runtime" -export * from "./instance" -export * from "./module" -export * from "./func" -export * from "./wasi" \ No newline at end of file diff --git a/ts/instance.ts b/ts/instance.ts deleted file mode 100644 index 663277c5..00000000 --- a/ts/instance.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { v4 as uuidv4 } from 'uuid'; -import { Signature, RuntimeContext } from "@loopholelabs/scale-signature"; -import { Cache } from './cache'; -import { NextFn, Runtime } from "./runtime"; - -const ErrNoCompiledFunctions = new Error("no compiled functions found in runtime"); -const ErrNoCacheID = new Error("no cache id found in instance"); - -export class Instance { - private runtime: Runtime; - public next: NextFn; - public ctx: T; - public id: string - private cache: Map = new Map; - - constructor(r: Runtime, n: null | NextFn) { - this.runtime = r; - this.ctx = r.NewSignature(); - this.id = uuidv4(); - - if (n === null) { - this.next = (ctx: T) => ctx; - } else { - this.next = n; - } - } - - Context(): T { - return this.ctx; - } - - RuntimeContext(): RuntimeContext { - return this.ctx.RuntimeContext(); - } - - Run() { - if (this.runtime.head === undefined) { - throw ErrNoCompiledFunctions; - } - const fn = this.runtime.head; - fn.Run(this); - } - - SetInstance(id: string, c: Cache) { - this.cache.set(id, c); - } - - GetInstance(id: string): Cache { - const c = this.cache.get(id); - if (c === undefined) { - throw ErrNoCacheID; - } - return c; - } -} \ No newline at end of file diff --git a/ts/module.ts b/ts/module.ts deleted file mode 100644 index 45a7f8a3..00000000 --- a/ts/module.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { Signature } from "@loopholelabs/scale-signature"; - -import { Instance } from "./instance"; -import { Runtime } from "./runtime"; -import { Func } from "./func"; - -export class Module { - private runtime: Runtime; - public func: Func; - - private wasmInstance: undefined | WebAssembly.Instance; - public run: undefined | Function; - public resize: undefined | Function; - public memory: undefined | WebAssembly.Memory; - - constructor(f: Func, r: Runtime) { - this.func = f; - this.runtime = r; - } - - init(i: Instance) { - this.wasmInstance = this.runtime.InstantiateModule(this.func.id, this, i); - - this.run = this.wasmInstance.exports.run as Function; - this.resize = this.wasmInstance.exports.resize as Function; - - if (this.run === undefined || this.resize === undefined) { - throw new Error("failed to find run or resize implementations"); - } - - this.memory = this.wasmInstance.exports.memory as WebAssembly.Memory; - } - -} \ No newline at end of file diff --git a/ts/pool.ts b/ts/pool.ts deleted file mode 100644 index 2fe38d80..00000000 --- a/ts/pool.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { Signature } from "@loopholelabs/scale-signature"; - -import { Func } from "./func"; -import { Runtime } from "./runtime"; -import { Module } from "./module"; - -export class Pool { - private readonly f: Func; - private readonly r: Runtime; - - constructor(f: Func, r: Runtime) { - this.f = f; - this.r = r; - } - - Get(): Module { - return new Module(this.f, this.r); - } -} \ No newline at end of file diff --git a/ts/registry/browser/index.ts b/ts/registry/browser/index.ts deleted file mode 100644 index 19faa987..00000000 --- a/ts/registry/browser/index.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { ScaleFunc } from "@loopholelabs/scalefile/scalefunc" - -let crypto = global.crypto; -if(global.crypto === undefined || global.crypto.subtle === undefined) { - crypto = require("crypto").webcrypto; -} - -import { OpenAPI, RegistryService } from "../../client"; - -const Buffer = require("buffer/").Buffer; - -export type PullPolicy = string; -export const AlwaysPullPolicy: PullPolicy = "always"; -export const IfNotPresentPullPolicy: PullPolicy = "if-not-present"; -export const NeverPullPolicy: PullPolicy = "never"; - -export const ErrHasMismatch = new Error("hash mismatch"); -export const ErrNoFunction = new Error("function does not exist locally and pull policy does not allow pulling from registry"); -export const ErrDownloadFailed = new Error("scale function could not be pull from the registry") - -export const DefaultBaseURL = "api.scale.sh" -export const DefaultOrganization = "scale" - -export interface Config { - baseURL: string, - organization: string, - apiKey: string, - pullPolicy: PullPolicy, - cacheDirectory: string, -} - -export type Option = (c: Config) => void; - -export function WithAPIKey(apiKey: string): Option { - return (c: Config) => { - c.apiKey = apiKey; - } -} - -export function WithBaseURL(baseURL: string): Option { - return (c: Config) => { - c.baseURL = baseURL; - } -} - -export function WithOrganization(organization: string): Option { - return (c: Config) => { - c.organization = organization; - } -} - -export function WithPullPolicy(pullPolicy: PullPolicy): Option { - return (c: Config) => { - c.pullPolicy = pullPolicy; - } -} - -export function WithCacheDirectory(cacheDirectory: string): Option { - return (c: Config) => { - c.cacheDirectory = cacheDirectory; - } -} - -export async function Download(name: string, tag: string, ...opts: Option[]): Promise { - const conf = DefaultConfig(...opts); - const memoryFn = await RegistryService.getRegistryFunction3(conf.organization, name, tag) - if(!memoryFn.presigned_url || !memoryFn.hash) { - throw ErrDownloadFailed - } - - const memoryData = await (await fetch(memoryFn.presigned_url)).arrayBuffer(); - const memoryHash = await ComputeSHA256(memoryData); - if (memoryHash !== memoryFn.hash) { - throw ErrHasMismatch; - } - - return ScaleFunc.Decode(new Uint8Array(memoryData)); -} - -export function DefaultConfig(...opts: Option[]): Config { - const conf: Config = { - baseURL: DefaultBaseURL, - organization: DefaultOrganization, - pullPolicy: IfNotPresentPullPolicy, - apiKey: "", - cacheDirectory: "" - } - - for (const opt of opts) { - opt(conf); - } - - if (!conf.baseURL || conf.baseURL === "") { - conf.baseURL = DefaultBaseURL - } - - if (!conf.organization || conf.organization === "") { - conf.organization = DefaultOrganization - } - - if (!conf.pullPolicy || conf.pullPolicy == "") { - conf.pullPolicy = IfNotPresentPullPolicy - } - - OpenAPI.BASE = `https://${conf.baseURL}/v1` - - if (conf.apiKey && conf.apiKey != "") { - OpenAPI.HEADERS = { - 'Authorization': `Bearer ${conf.apiKey}`, - } - } - - return conf; -} - -export function HexFromArrayBuffer (data: ArrayBuffer) { - return Buffer.from(data).toString("hex"); -} - -export async function ComputeSHA256(data: ArrayBuffer): Promise { - return HexFromArrayBuffer(await crypto.subtle.digest("SHA-256", data)) -} \ No newline at end of file diff --git a/ts/registry/index.test.ts b/ts/registry/index.test.ts deleted file mode 100644 index afe61db1..00000000 --- a/ts/registry/index.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -// setup jest -import 'jest'; -import { - NeverPullPolicy, - DefaultOrganization, - Download, - WithCacheDirectory, - WithPullPolicy, - WithAPIKey, WithBaseURL, WithOrganization, ComputeSHA256, -} from './index'; -import {ScaleFunc, V1Alpha, Go} from "@loopholelabs/scalefile/scalefunc"; -import {Storage} from "../storage"; - -const Buffer = require("buffer/").Buffer; - -const testingApiBaseUrl = "https://api.dev.scale.sh/v1" - - -/** - * @jest-environment node - */ -test('TestPulldownCache', async () => { - const st = new Storage("testDirectory"); - - const scaleFunc = new ScaleFunc( - V1Alpha, - "TestFunction", - "1", - "signature1", - Go, - Buffer.from("Hello world"), - ); - - const func = "TestFunction" - const tag = "1" - const hash = await ComputeSHA256(scaleFunc.Function); - st.Put(func, tag, DefaultOrganization, hash, scaleFunc) - - const newScaleFunc = await Download( - func, - tag, - WithCacheDirectory("testDirectory"), - WithPullPolicy(NeverPullPolicy), - ); - - expect(newScaleFunc.Version).toBe(scaleFunc.Version); - expect(newScaleFunc.Name).toBe(scaleFunc.Name); - expect(newScaleFunc.Tag).toBe(scaleFunc.Tag); - expect(newScaleFunc.Signature).toBe(scaleFunc.Signature); - expect(newScaleFunc.Language).toBe(scaleFunc.Language); - expect(newScaleFunc.Function).toEqual(scaleFunc.Function); - expect(newScaleFunc.Size).toBe(61); -}); - -test('TestRegistryDownload', async () => { - // get api key from environment - const apiKey = process.env.SCALE_API_KEY; - if (apiKey == undefined) { - console.log("SCALE_API_KEY not set, skipping test") - return - } - - const scaleFunc = await Download( - "TestRegistryDownload", - "1", - WithAPIKey(apiKey), - WithBaseURL(testingApiBaseUrl), - WithOrganization("alex"), - ); - - expect(scaleFunc.Version).toBe("v1alpha"); - expect(scaleFunc.Name).toBe("TestRegistryDownload"); - expect(scaleFunc.Tag).toBe("1"); - expect(scaleFunc.Signature).toBe("signature1"); - expect(scaleFunc.Language).toBe("go"); -}); diff --git a/ts/registry/index.ts b/ts/registry/index.ts deleted file mode 100644 index 6521abb4..00000000 --- a/ts/registry/index.ts +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import {ScaleFunc} from "@loopholelabs/scalefile/scalefunc" -import {sha256} from "js-sha256"; -import {webcrypto as crypto} from "crypto"; - -import {Default, Storage} from "../storage"; -import {models_GetFunctionResponse, OpenAPI, RegistryService} from "../client"; -import https from "https"; - -const Buffer = require("buffer/").Buffer; - -import { - ComputeSHA256 as BrowserComputeSHA256, - DefaultConfig, - Option, - HexFromArrayBuffer, - ErrHasMismatch, - ErrDownloadFailed, - ErrNoFunction, - DefaultBaseURL, - DefaultOrganization, - PullPolicy, - NeverPullPolicy, - IfNotPresentPullPolicy, - AlwaysPullPolicy, - WithAPIKey, - WithBaseURL, - WithOrganization, - WithPullPolicy, - WithCacheDirectory, -} from "./browser" - -export { ErrHasMismatch, ErrDownloadFailed, ErrNoFunction } -export { PullPolicy, NeverPullPolicy, IfNotPresentPullPolicy, AlwaysPullPolicy } -export { DefaultBaseURL, DefaultOrganization } - -export { WithAPIKey, WithBaseURL, WithOrganization, WithCacheDirectory, WithPullPolicy } - -export async function Download(name: string, tag: string, ...opts: Option[]): Promise { - const conf = DefaultConfig(...opts) - - let st = Default; - if (conf.cacheDirectory && conf.cacheDirectory != "") { - st = new Storage(conf.cacheDirectory) - } - - OpenAPI.BASE = `https://${conf.baseURL}/v1` - - if (conf.apiKey && conf.apiKey != "") { - OpenAPI.HEADERS = { - 'Authorization': `Bearer ${conf.apiKey}`, - } - } - - switch (conf.pullPolicy) { - case NeverPullPolicy: - const neverGet = st.Get(name, tag, conf.organization, ""); - if (!neverGet) { - throw ErrNoFunction - } - return neverGet.scaleFunc; - case IfNotPresentPullPolicy: - const notPresentGet = st.Get(name, tag, conf.organization, ""); - if (notPresentGet) { - return notPresentGet.scaleFunc - } - - let notPresentFn: models_GetFunctionResponse | undefined = undefined; - if (conf.organization === DefaultOrganization) { - notPresentFn = await RegistryService.getRegistryFunction1(name, tag) - } else { - notPresentFn = await RegistryService.getRegistryFunction3(conf.organization, name, tag) - } - - if(!notPresentFn.presigned_url || !notPresentFn.hash) { - throw ErrDownloadFailed - } - - const notPresentData = await RawDownload(notPresentFn.presigned_url); - const notPresentHash = await ComputeSHA256(notPresentData); - if (notPresentHash !== notPresentFn.hash) { - throw ErrHasMismatch; - } - const notPresentSF = ScaleFunc.Decode(new Uint8Array(notPresentData)); - st.Put(name, tag, conf.organization, notPresentHash, notPresentSF) - return notPresentSF; - case AlwaysPullPolicy: - const alwaysGet = st.Get(name, tag, conf.organization, ""); - let alwaysFn: models_GetFunctionResponse | undefined = undefined; - if (conf.organization === DefaultOrganization) { - alwaysFn = await RegistryService.getRegistryFunction1(name, tag) - } else { - alwaysFn = await RegistryService.getRegistryFunction3(conf.organization, name, tag) - } - - if(!alwaysFn.presigned_url || !alwaysFn.hash) { - throw ErrDownloadFailed - } - - if (alwaysGet) { - if (alwaysFn.hash === alwaysGet.hash) { - return alwaysGet.scaleFunc - } - } - - const alwaysData = await RawDownload(alwaysFn.presigned_url); - const alwaysHash = await ComputeSHA256(alwaysData); - if (alwaysHash !== alwaysFn.hash) { - throw ErrHasMismatch; - } - const alwaysSF = ScaleFunc.Decode(new Uint8Array(alwaysData)); - if (alwaysGet) { - st.Delete(name, tag, alwaysGet.organization, alwaysGet.hash) - } - st.Put(name, tag, conf.organization, alwaysHash, alwaysSF) - return alwaysSF; - default: - throw Error(`unknown pull policy ${conf.pullPolicy}`) - } -} - -export async function ComputeSHA256 (data: ArrayBuffer): Promise { - if (crypto && crypto.subtle) { - return BrowserComputeSHA256(data); - } - const hash = sha256.create(); - hash.update(data); - return HexFromArrayBuffer(hash.arrayBuffer()) -} - -async function RawDownload (url: string): Promise { - if (typeof window !== "undefined") { - const httpResp = await fetch(url) - return httpResp.arrayBuffer(); - } - return new Promise((resolve, reject) => { - let body: Uint8Array[] = []; - const request = https.request(url, (response) => { - if (response.statusCode !== 200) { - reject(ErrDownloadFailed); - } - - response.on('data', (chunk) => { - body.push(chunk); - }) - - response.on('end', () => { - resolve(Buffer.concat(body)); - }) - - response.on('error', (error) => { - reject(error); - }); - }); - - request.end(); - }); -} diff --git a/ts/runtime.test.ts b/ts/runtime.test.ts deleted file mode 100644 index a354683e..00000000 --- a/ts/runtime.test.ts +++ /dev/null @@ -1,269 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { TextEncoder, TextDecoder } from "util"; -import * as fs from "fs"; - -import {ScaleFunc, V1Alpha, Go, Rust} from "@loopholelabs/scalefile/scalefunc"; - -import * as signature from "./tests/signature" ; -import * as httpSignature from "@loopholelabs/scale-signature-http"; - -import { New, NewFromSignature } from "./index"; - -describe("TestRuntimeTs", () => { - const modPassthroughGo = fs.readFileSync("./ts/tests/modules/passthrough-TestRuntimeGo.wasm"); - const modPassthroughRs = fs.readFileSync("./ts/tests/modules/passthrough-TestRuntimeRs.wasm"); - const modModifyGo = fs.readFileSync("./ts/tests/modules/modify-TestRuntimeGo.wasm"); - const modModifyRs = fs.readFileSync("./ts/tests/modules/modify-TestRuntimeRs.wasm"); - const modNextGo = fs.readFileSync("./ts/tests/modules/next-TestRuntimeGo.wasm"); - const modNextRs = fs.readFileSync("./ts/tests/modules/next-TestRuntimeRs.wasm"); - const modModifyNextGo = fs.readFileSync("./ts/tests/modules/modifynext-TestRuntimeGo.wasm"); - const modModifyNextRs = fs.readFileSync("./ts/tests/modules/modifynext-TestRuntimeRs.wasm"); - const modFileGo = fs.readFileSync("./ts/tests/modules/file-TestRuntimeGo.wasm"); - const modFileRs = fs.readFileSync("./ts/tests/modules/file-TestRuntimeRs.wasm"); - const modNetworkGo = fs.readFileSync("./ts/tests/modules/network-TestRuntimeGo.wasm"); - const modNetworkRs = fs.readFileSync("./ts/tests/modules/network-TestRuntimeRs.wasm"); - const modPanicGo = fs.readFileSync("./ts/tests/modules/panic-TestRuntimeGo.wasm"); - const modPanicRs = fs.readFileSync("./ts/tests/modules/panic-TestRuntimeRs.wasm"); - const modBadSignatureGo = fs.readFileSync("./ts/tests/modules/bad-signature-TestRuntimeGo.wasm"); - const modBadSignatureRs = fs.readFileSync("./ts/tests/modules/bad-signature-TestRuntimeRs.wasm"); - - const modHttpPassthroughGo = fs.readFileSync("./ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureGo.wasm"); - const modHttpPassthroughRs = fs.readFileSync("./ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureRs.wasm"); - const modHttpHandlerGo = fs.readFileSync("./ts/tests/modules/http-handler-TestRuntimeHTTPSignatureGo.wasm"); - const modHttpHandlerRs = fs.readFileSync("./ts/tests/modules/http-handler-TestRuntimeHTTPSignatureRs.wasm"); - const modHttpNextGo = fs.readFileSync("./ts/tests/modules/http-next-TestRuntimeHTTPSignatureGo.wasm"); - const modHttpNextRs = fs.readFileSync("./ts/tests/modules/http-next-TestRuntimeHTTPSignatureRs.wasm"); - - const passthrough = [ - { name: "Passthrough", module: modPassthroughGo, language: Go }, - { name: "Passthrough", module: modPassthroughRs, language: Rust }, - ] - - passthrough.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).not.toThrowError(); - expect(i.Context().Data).toBe("Test Data"); - }); - }) - - const modify = [ - { name: "Modify", module: modModifyGo, language: Go }, - { name: "Modify", module: modModifyRs, language: Rust }, - ] - - modify.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).not.toThrowError(); - expect(i.Context().Data).toBe("modified"); - }); - }) - - const next = [ - { name: "Next", module: modNextGo, language: Go }, - { name: "Next", module: modNextRs, language: Rust }, - ] - - next.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(function (ctx: signature.Context): signature.Context { - ctx.Data = "Hello, world!"; - return ctx; - }); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).not.toThrowError(); - expect(i.Context().Data).toBe("Hello, world!"); - }); - }) - - const modifynext = [ - { name: "ModifyNext", module: modModifyNextGo, language: Go }, - { name: "ModifyNext", module: modModifyNextRs, language: Rust }, - ] - - modifynext.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(function (ctx: signature.Context): signature.Context { - ctx.Data += "-next"; - return ctx; - }); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).not.toThrowError(); - expect(i.Context().Data).toBe("modified-next"); - }); - }) - - next.forEach((fn) => { - it(`${fn.name} error ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(function (ctx: signature.Context): signature.Context { - throw new Error("Hello error"); - }); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).toThrow("Hello error"); - }); - }) - - const file = [ - { name: "File", module: modFileGo, language: Go }, - { name: "File", module: modFileRs, language: Rust }, - ] - - file.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - i.Context().Data = "Test Data"; - expect(() => { - i.Run(); - }).toThrowError(); - }); - }) - - - const network = [ - { name: "Network", module: modNetworkGo, language: Go }, - { name: "Network", module: modNetworkRs, language: Rust }, - ] - - network.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - expect(() => { - i.Run(); - }).toThrowError(); - }); - }) - - const panic = [ - { name: "Panic", module: modPanicGo, language: Go }, - { name: "Panic", module: modPanicRs, language: Rust }, - ] - - panic.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - expect(() => { - i.Run(); - }).toThrowError(); - }); - }) - - const badSignature = [ - { name: "BadSignature", module: modBadSignatureGo, language: Go }, - { name: "BadSignature", module: modBadSignatureRs, language: Rust }, - ] - - badSignature.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await NewFromSignature(signature.New, [sfn]); - const i = await r.Instance(null); - expect(() => { - i.Run(); - }).toThrowError(); - }); - }) - - const httpPassthrough = [ - { name: "HttpPassthrough", module: modHttpPassthroughGo, language: Go }, - { name: "HttpPassthrough", module: modHttpPassthroughRs, language: Rust }, - ] - - httpPassthrough.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await New([sfn]); - const i = await r.Instance(null) - i.Context().Response.Body = new TextEncoder().encode("Test Data"); - expect(() => { - i.Run(); - }).not.toThrowError(); - const textDecoder = new TextDecoder(); - expect(textDecoder.decode(i.Context().Response.Body)).toBe("Test Data"); - }); - }) - - const httpHandler = [ - { name: "HttpHandler", module: modHttpHandlerGo, language: Go }, - { name: "HttpHandler", module: modHttpHandlerRs, language: Rust }, - ] - - httpHandler.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await New([sfn]); - const i = await r.Instance(null) - i.Context().Response.Body = new TextEncoder().encode("Test Data"); - expect(() => { - i.Run(); - }).not.toThrowError(); - const textDecoder = new TextDecoder(); - expect(textDecoder.decode(i.Context().Response.Body)).toBe("Test Data-modified"); - }); - }) - - const httpNext = [ - { name: "HttpNext", module: modHttpNextGo, language: Go }, - { name: "HttpNext", module: modHttpNextRs, language: Rust }, - ] - - httpNext.forEach((fn) => { - it(`${fn.name} ${fn.language}`, async () => { - const sfn = new ScaleFunc(V1Alpha, `Test.${fn.name}`, "Test.TestTag", "ExampleName@ExampleVersion", fn.language, fn.module); - const r = await New([sfn]); - const i = await r.Instance(function (ctx: httpSignature.Context): httpSignature.Context { - ctx.Response.Body = new TextEncoder().encode(new TextDecoder().decode(ctx.Response.Body) + "-next"); - return ctx; - }); - i.Context().Response.Body = new TextEncoder().encode("Test Data"); - expect(() => { - i.Run(); - }).not.toThrowError(); - const textDecoder = new TextDecoder(); - expect(textDecoder.decode(i.Context().Response.Body)).toBe("Test Data-modified-next"); - }); - }) -}); diff --git a/ts/runtime.ts b/ts/runtime.ts deleted file mode 100644 index 91d8972d..00000000 --- a/ts/runtime.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { Signature, NewSignature } from "@loopholelabs/scale-signature"; -import { ScaleFunc } from "@loopholelabs/scalefile/scalefunc"; -import * as httpSignature from "@loopholelabs/scale-signature-http"; - -import { Func } from "./func"; -import { Instance } from "./instance"; -import { Pool } from "./pool"; -import { Module } from "./module"; -import { Cache } from "./cache"; -import {DisabledWASI} from "./wasi"; - -export type NextFn = (ctx: T) => T; - -export async function New(functions: (Promise|ScaleFunc|Func)[]): Promise> { - return NewFromSignature(httpSignature.New, functions); -} - -export async function NewFromSignature(newSignature: NewSignature, functions: (Promise|ScaleFunc|Func)[]): Promise> { - const r = new Runtime(newSignature, functions); - await r.Ready(); - return r; -} - -export class Runtime { - public NewSignature: NewSignature; - private readonly ready: Promise; - private functions: Func[]; - public head: undefined | Func; - public tail: undefined | Func; - - constructor(newSignature: NewSignature, functions: (Promise|ScaleFunc|Func)[]) { - this.NewSignature = newSignature; - this.functions = []; - - this.ready = new Promise(async (resolve) => { - for (let i = 0; i < functions.length; i++) { - const fn = functions[i]; - let f: Func; - if (fn instanceof ScaleFunc) { - const wasi = new DisabledWASI(); - const instantiatedSource = await WebAssembly.instantiate(fn.Function, { - wasi_snapshot_preview1: wasi.GetImports(), - env: { - next: (ptr: number, len: number): number => { - return 0; - } - }, - }); - f = new Func(fn, instantiatedSource.module); - } else if (fn instanceof Promise) { - const wasi = new DisabledWASI(); - const resolvedFn = await fn; - const instantiatedSource = await WebAssembly.instantiate(resolvedFn.Function, { - wasi_snapshot_preview1: wasi.GetImports(), - env: { - next: (ptr: number, len: number): number => { - return 0; - } - }, - }); - f = new Func(resolvedFn, instantiatedSource.module); - } else { - f = fn - } - - f.modulePool = new Pool(f, this); - this.functions.push(f); - if (this.head === undefined) { - this.head = f; - } - if (this.tail !== undefined) { - this.tail.next = f; - } - this.tail = f; - } - - resolve(true); - }); - } - - async Ready() { - await this.ready; - } - - async Instance(next: null | NextFn): Promise> { - const i = new Instance(this, next); - for (let a = 0; a < this.functions.length; a++) { - const module = this.functions[a].wasmModule; - const id = this.functions[a].id; - const cache = new Cache(); - await cache.Initialize(module); - i.SetInstance(id, cache); - } - - return i; - } - - InstantiateModule(fnid: string, mod: Module, i: Instance): WebAssembly.Instance { - const nextFunction = ((): Function => { - return (ptr: number, len: number): BigInt => { - if (mod.memory === undefined || mod.resize === undefined) { - return BigInt(0); - } - let buff: Uint8Array; - try { - const memDataOut = new Uint8Array(mod.memory.buffer); - const inContextBuff = memDataOut.slice(ptr, ptr + len); - - i.RuntimeContext().Read(inContextBuff); - - if (mod.func.next === undefined) { - i.ctx = i.next(i.Context()); - buff = i.RuntimeContext().Write(); - } else { - mod.func.next.Run(i); - buff = i.RuntimeContext().Write(); - } - } catch (e) { - buff = i.RuntimeContext().Error(e as Error); - } - - const encPtr = mod.resize(buff.length); - const memData = new Uint8Array(mod.memory.buffer); - memData.set(buff, encPtr); - return Func.packMemoryRef(encPtr, buff.length); - }; - })(); - - const cached = i.GetInstance(fnid); - cached.SetNext(nextFunction); - return cached.GetInstance(); - } -} diff --git a/ts/storage/index.ts b/ts/storage/index.ts deleted file mode 100644 index 67b12585..00000000 --- a/ts/storage/index.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { ScaleFunc, ValidString } from "@loopholelabs/scalefile/scalefunc" -import { Read, Write } from "@loopholelabs/scalefile/scalefunc/helpers" -import * as fs from "fs"; -import * as os from "os"; -import * as glob from "glob"; -import path from "path"; - -export const ErrInvalidName = new Error("invalid name"); -export const ErrInvalidTag = new Error("invalid tag"); -export const ErrInvalidOrg = new Error("invalid org"); - -export const DefaultCacheDirectory = ".config/scale/functions" - -export interface Entry { - scaleFunc: ScaleFunc, - hash: string, - organization: string, -} - -export class Storage{ - public baseDirectory: string; - constructor(baseDirectory: string) { - this.baseDirectory = baseDirectory; - if (!fs.existsSync(this.baseDirectory)) { - fs.mkdirSync(this.baseDirectory, { recursive: true, mode: 0o755 }); - } - } - - public Get(name: string, tag: string, org: string, hash: string | undefined): (Entry | undefined) { - if (name.length === 0 || !ValidString(name)) { - throw ErrInvalidName; - } - - if (tag.length === 0 || !ValidString(tag)) { - throw ErrInvalidTag; - } - - if (org.length === 0 || !ValidString(org)) { - throw ErrInvalidOrg; - } - - if (hash) { - const f = this.functionName(name, tag, org, hash); - const p = this.fullPath(f); - try { - return { - hash: hash, - scaleFunc: Read(p), - organization: org, - }; - } catch (error: any) { - if (error.code === 'ENOENT') { - return undefined; - } - throw error - } - } - - const f = this.functionSearch(name, tag, org); - const p = this.fullPath(f); - const matches = glob.sync(p) - if (matches.length === 0) { - return undefined; - } - - if (matches.length > 1) { - throw new Error("multiple matches found for " + name + ":" + tag); - } - - return { - scaleFunc: Read(matches[0]), - hash: path.basename(matches[0]).split("_")[3], - organization: path.basename(matches[0]).split("_")[0], - }; - } - - public Put(name: string, tag: string, org: string, hash: string, sf: ScaleFunc): void { - const f = this.functionName(name, tag, org, hash); - const p = this.fullPath(f); - Write(p, sf); - } - - public Delete(name: string, tag: string, org: string, hash: string): void { - const f = this.functionName(name, tag, org, hash); - const p = this.fullPath(f); - fs.rmSync(p); - } - - private fullPath(p: string): string { - return path.join(this.baseDirectory, p); - } - - private functionName(name: string, tag: string, org: string, hash: string): string { - return `${org}_${name}_${tag}_${hash}_scale`; - } - - private functionSearch(name: string, tag: string, org: string): string { - return `${org}_${name}_${tag}_*_scale`; - } -} - -export const Default = new Storage(path.join(os.homedir(), DefaultCacheDirectory)); \ No newline at end of file diff --git a/ts/tests/modules/bad-signature-TestRuntimeGo.wasm b/ts/tests/modules/bad-signature-TestRuntimeGo.wasm deleted file mode 100755 index 0e5a4618..00000000 Binary files a/ts/tests/modules/bad-signature-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/bad-signature-TestRuntimeRs.wasm b/ts/tests/modules/bad-signature-TestRuntimeRs.wasm deleted file mode 100755 index fb28703b..00000000 Binary files a/ts/tests/modules/bad-signature-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/file-TestRuntimeGo.wasm b/ts/tests/modules/file-TestRuntimeGo.wasm deleted file mode 100755 index 8f3af935..00000000 Binary files a/ts/tests/modules/file-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/file-TestRuntimeRs.wasm b/ts/tests/modules/file-TestRuntimeRs.wasm deleted file mode 100755 index c419c432..00000000 Binary files a/ts/tests/modules/file-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureGo.wasm b/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureGo.wasm deleted file mode 100755 index 8c6c10ee..00000000 Binary files a/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureGo.wasm and /dev/null differ diff --git a/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureRs.wasm b/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureRs.wasm deleted file mode 100755 index c7b1b501..00000000 Binary files a/ts/tests/modules/http-handler-TestRuntimeHTTPSignatureRs.wasm and /dev/null differ diff --git a/ts/tests/modules/http-next-TestRuntimeHTTPSignatureGo.wasm b/ts/tests/modules/http-next-TestRuntimeHTTPSignatureGo.wasm deleted file mode 100755 index cc446bf0..00000000 Binary files a/ts/tests/modules/http-next-TestRuntimeHTTPSignatureGo.wasm and /dev/null differ diff --git a/ts/tests/modules/http-next-TestRuntimeHTTPSignatureRs.wasm b/ts/tests/modules/http-next-TestRuntimeHTTPSignatureRs.wasm deleted file mode 100755 index 789594d0..00000000 Binary files a/ts/tests/modules/http-next-TestRuntimeHTTPSignatureRs.wasm and /dev/null differ diff --git a/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureGo.wasm b/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureGo.wasm deleted file mode 100755 index e5e47369..00000000 Binary files a/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureGo.wasm and /dev/null differ diff --git a/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureRs.wasm b/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureRs.wasm deleted file mode 100755 index 319ffb2b..00000000 Binary files a/ts/tests/modules/http-passthrough-TestRuntimeHTTPSignatureRs.wasm and /dev/null differ diff --git a/ts/tests/modules/modify-TestRuntimeGo.wasm b/ts/tests/modules/modify-TestRuntimeGo.wasm deleted file mode 100755 index f42cad8d..00000000 Binary files a/ts/tests/modules/modify-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/modify-TestRuntimeRs.wasm b/ts/tests/modules/modify-TestRuntimeRs.wasm deleted file mode 100755 index 27c29929..00000000 Binary files a/ts/tests/modules/modify-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/modifynext-TestRuntimeGo.wasm b/ts/tests/modules/modifynext-TestRuntimeGo.wasm deleted file mode 100755 index 269a9cfe..00000000 Binary files a/ts/tests/modules/modifynext-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/modifynext-TestRuntimeRs.wasm b/ts/tests/modules/modifynext-TestRuntimeRs.wasm deleted file mode 100755 index 4b2c9820..00000000 Binary files a/ts/tests/modules/modifynext-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/network-TestRuntimeGo.wasm b/ts/tests/modules/network-TestRuntimeGo.wasm deleted file mode 100755 index 032314fd..00000000 Binary files a/ts/tests/modules/network-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/network-TestRuntimeRs.wasm b/ts/tests/modules/network-TestRuntimeRs.wasm deleted file mode 100755 index 6b523e74..00000000 Binary files a/ts/tests/modules/network-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/next-TestRuntimeGo.wasm b/ts/tests/modules/next-TestRuntimeGo.wasm deleted file mode 100755 index 6ababaab..00000000 Binary files a/ts/tests/modules/next-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/next-TestRuntimeRs.wasm b/ts/tests/modules/next-TestRuntimeRs.wasm deleted file mode 100755 index 5ba0cc89..00000000 Binary files a/ts/tests/modules/next-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/panic-TestRuntimeGo.wasm b/ts/tests/modules/panic-TestRuntimeGo.wasm deleted file mode 100755 index 1e7e9b8c..00000000 Binary files a/ts/tests/modules/panic-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/panic-TestRuntimeRs.wasm b/ts/tests/modules/panic-TestRuntimeRs.wasm deleted file mode 100755 index a82b1f95..00000000 Binary files a/ts/tests/modules/panic-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/modules/passthrough-TestRuntimeGo.wasm b/ts/tests/modules/passthrough-TestRuntimeGo.wasm deleted file mode 100755 index 3985ce07..00000000 Binary files a/ts/tests/modules/passthrough-TestRuntimeGo.wasm and /dev/null differ diff --git a/ts/tests/modules/passthrough-TestRuntimeRs.wasm b/ts/tests/modules/passthrough-TestRuntimeRs.wasm deleted file mode 100755 index 2ad753a1..00000000 Binary files a/ts/tests/modules/passthrough-TestRuntimeRs.wasm and /dev/null differ diff --git a/ts/tests/signature/example.signature.ts b/ts/tests/signature/example.signature.ts deleted file mode 100644 index 4659f6a4..00000000 --- a/ts/tests/signature/example.signature.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import { - encodeString, - decodeString, - encodeError, -} from "@loopholelabs/polyglot-ts"; - -export class ExampleContext { - constructor(data: string) { - this._Data = data - } - - private _Data: string; - - get Data(): string { - return this._Data - } - - set Data(data: string) { - this._Data = data - } - - encode(buf: Uint8Array): Uint8Array { - let encoded = buf - encoded = encodeString(encoded, this._Data) - return encoded - } - - internalError(buf: Uint8Array, err: Error): Uint8Array { - return encodeError(buf, err) - } - - static decode(buf: Uint8Array): { - buf: Uint8Array, - value: ExampleContext - } { - let decoded = buf - const Data = decodeString(decoded) - decoded = Data.buf - return { - buf: decoded, - value: new ExampleContext(Data.value) - } - } -} \ No newline at end of file diff --git a/ts/tests/signature/index.ts b/ts/tests/signature/index.ts deleted file mode 100644 index f34cc447..00000000 --- a/ts/tests/signature/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Kind, decodeError } from "@loopholelabs/polyglot-ts"; - -import {ExampleContext} from "./example.signature"; -import {RuntimeContext as RuntimeContextInterface, Signature} from "@loopholelabs/scale-signature"; - -export class RuntimeContext implements RuntimeContextInterface { - private readonly context: ExampleContext; - - constructor(context: ExampleContext) { - this.context = context; - } - - Read(b: Uint8Array): Error | undefined { - if (b.length > 0 && b[0] === Kind.Error) { - return decodeError(b).value; - } - Object.assign(this.context, ExampleContext.decode(b).value); - return undefined; - } - - Write(): Uint8Array { - return this.context.encode(new Uint8Array()); - } - - Error(err: Error): Uint8Array { - return this.context.internalError(new Uint8Array(), err); - } -} - -export function New(): Context { - return new Context(); -} - -export class Context extends ExampleContext implements Signature { - private readonly runtimeContext; - constructor() { - super(""); - this.runtimeContext = new RuntimeContext(this); - } - - RuntimeContext(): RuntimeContext { - return this.runtimeContext; - } -} \ No newline at end of file diff --git a/ts/wasi.ts b/ts/wasi.ts deleted file mode 100644 index b47bbdc9..00000000 --- a/ts/wasi.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* - Copyright 2022 Loophole Labs - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -const ErrNoInstance = Error("no webassembly instance") -const ErrNoMemory = Error("no exported memory in webassembly instance") - -export interface RequiredFunctions extends WebAssembly.ModuleImports { - fd_prestat_get(fd: number, bufPtr: number): number - fd_prestat_dir_name(fd: number, pathPtr: number, pathLen: number): number - environ_sizes_get(environCount: number, environBufSize: number): number - environ_get(environ: number, environBuf: number): number - args_sizes_get(argc: number, argvBufSize: number): number - args_get(argv: number, argvBuf: number): number - fd_filestat_get(fd: number, bufPtr: number): number - fd_fdstat_get(fd: number, bufPtr: number): number - fd_read(fd: number, iovs_ptr: number, iovs_len: number, nread_ptr: number): number - fd_write(fd: number, iovs: number, iovsLen: number, nwritten: number): number - fd_close(fd: number): number - fd_seek(fd: number, offset: number, whence: number, newOffsetPtr: number): number - poll_oneoff(sin: number, sout: number, nsubscriptions: number, nevents: number): number - proc_exit(rval: number): number - path_open(fd: number, dirflags: number, path_ptr: number, path_len: number, oflags: number, fs_rights_base: number, fs_rights_inheriting: number, fd_flags: number, opened_fd_ptr: number): number - clock_time_get(id: number, precision: BigInt, time: number): number - random_get(buf: number, buf_len: number): void -} - -export class DisabledWASI { - public static ESUCCESS = 0; - public static EBADF = 8; - public static EINVAL = 28; - public static ENOSYS = 52; - - public static CLOCKID_REALTIME = 0; - - private exports: WebAssembly.Exports | undefined; - - private setBigUint64(view: DataView, byteOffset: number, value: number, littleEndian: boolean) { - const lowWord = value; - const highWord = 0; - view.setUint32(littleEndian ? 0 : 4, lowWord, littleEndian); - view.setUint32(littleEndian ? 4 : 0, highWord, littleEndian); - } - - private getDataView(): DataView { - if (!this.exports) { - throw ErrNoInstance; - } - if (!this.exports.memory) { - throw ErrNoMemory; - } - // @ts-ignore - return new DataView(this.exports.memory.buffer); - } - - public SetInstance(instance: WebAssembly.Instance) { - this.exports = instance.exports; - const start = (this.exports._start as Function | undefined); - if (start) { - start(); - } - } - - public environ_sizes_get(environCount: number, environBufSize: number): number { - let view = this.getDataView(); - view.setUint32(environCount, 0, true); - view.setUint32(environBufSize, 0, true); - return DisabledWASI.ESUCCESS; - } - - public environ_get(environ: number, environBuf: number): number { - return DisabledWASI.ESUCCESS; - } - - public args_sizes_get(argc: number, argvBufSize: number): number { - let view = this.getDataView(); - view.setUint32(argc, 0, true); - view.setUint32(argvBufSize, 0, true); - return DisabledWASI.ESUCCESS; - } - - public args_get(argv: number, argvBuf: number): number { - return DisabledWASI.ESUCCESS; - } - - public fd_prestat_get(fd: number, bufPtr: number): number { - return DisabledWASI.EBADF; - } - - public fd_prestat_dir_name(fd: number, pathPtr: number, pathLen: number): number { - return DisabledWASI.EINVAL; - } - - public fd_filestat_get(fd: number, bufPtr: number): number { - return DisabledWASI.EBADF; - } - - public fd_fdstat_get(fd: number, bufPtr: number): number { - return DisabledWASI.EBADF; - } - - public fd_read(fd: number, iovs_ptr: number, iovs_len: number, nread_ptr: number): number { - return DisabledWASI.EBADF; - } - - public fd_write(fd: number, iovs: number, iovsLen: number, nwritten: number): number { - return DisabledWASI.EBADF; - } - - public fd_close(fd: number): number { - return DisabledWASI.EBADF; - } - - public fd_seek(fd: number, offset: number, whence: number, newOffsetPtr: number): number { - return DisabledWASI.EBADF; - } - - public poll_oneoff(sin: number, sout: number, nsubscriptions: number, nevents: number): number { - return DisabledWASI.ENOSYS; - } - - public proc_exit(rval: number): number { - return DisabledWASI.ENOSYS; - } - - public path_open(fd: number, dirflags: number, path_ptr: number, path_len: number, oflags: number, fs_rights_base: number, fs_rights_inheriting: number, fd_flags: number, opened_fd_ptr: number): number { - return DisabledWASI.EBADF; - } - - public clock_time_get(id: number, precision: BigInt, time: number) { - let buffer = this.getDataView() - if (id === DisabledWASI.CLOCKID_REALTIME) { - buffer.setBigUint64(time, BigInt(new Date().getTime()) * 1000000n, true); - } else { - buffer.setBigUint64(time, 0n, true); - } - return DisabledWASI.ESUCCESS; - } - - public random_get(buf: number, buf_len: number): void { - let buffer = this.getDataView(); - for (let i = 0; i < buf_len; i++) { - buffer.setInt8(buf+i, (Math.random() * 256) | 0); - } - } - - public GetImports(): RequiredFunctions { - return { - environ_sizes_get: this.environ_sizes_get.bind(this), - environ_get: this.environ_get.bind(this), - args_sizes_get: this.args_sizes_get.bind(this), - args_get: this.args_get.bind(this), - fd_prestat_get: this.fd_prestat_get.bind(this), - fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this), - fd_filestat_get: this.fd_filestat_get.bind(this), - fd_fdstat_get: this.fd_fdstat_get.bind(this), - fd_read: this.fd_read.bind(this), - fd_write: this.fd_write.bind(this), - fd_close: this.fd_close.bind(this), - fd_seek: this.fd_seek.bind(this), - poll_oneoff: this.poll_oneoff.bind(this), - proc_exit: this.proc_exit.bind(this), - path_open: this.path_open.bind(this), - clock_time_get: this.clock_time_get.bind(this), - random_get: this.random_get.bind(this), - } - } -} diff --git a/tsconfig.json b/tsconfig.json index 19f147a6..031cdde3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { - "include": ["ts/**/*.ts"], - "exclude": ["node_modules", "ts/**/*.test.ts", "ts/tests", "ts/compile"], + "include": ["**/*.ts"], + "exclude": ["node_modules", "dist", "target","compile/typescript/builder", "integration", "**/*.go", "**/*.rs", "*.go", "*.rs"], "compilerOptions": { "target": "es2020", "module": "commonjs", @@ -12,7 +12,7 @@ "sourceMap": true, "declaration": true, "paths": { - "scale": ["./ts"] + "scale": ["./"] }, "types": ["node", "jest"] }, diff --git a/utils.go b/utils.go new file mode 100644 index 00000000..db57a7d2 --- /dev/null +++ b/utils.go @@ -0,0 +1,46 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package scale + +import "strings" + +type Parsed struct { + Organization string + Name string + Tag string +} + +// Parse parses a function or signature name of the form /: into its organization, name, and tag +func Parse(name string) *Parsed { + orgSplit := strings.Split(name, "/") + if len(orgSplit) == 1 { + orgSplit = []string{"", name} + } + tagSplit := strings.Split(orgSplit[1], ":") + if len(tagSplit) == 1 { + tagSplit = []string{tagSplit[0], ""} + } + return &Parsed{ + Organization: orgSplit[0], + Name: tagSplit[0], + Tag: tagSplit[1], + } +} + +func unpackUint32(packed uint64) (uint32, uint32) { + return uint32(packed >> 32), uint32(packed) +} diff --git a/go/utils/utils.go b/utils.ts similarity index 69% rename from go/utils/utils.go rename to utils.ts index d1ec3cad..27dadb40 100644 --- a/go/utils/utils.go +++ b/utils.ts @@ -14,12 +14,9 @@ limitations under the License. */ -package utils - -func PackUint32(offset uint32, length uint32) uint64 { - return uint64(offset)<<32 | uint64(length) -} - -func UnpackUint32(packed uint64) (uint32, uint32) { - return uint32(packed >> 32), uint32(packed) -} +// Unpack a memory ref from 64bit to 2x32bits +export function UnpackUint32(packed: bigint): [number, number] { + const ptr = Number((packed >> BigInt(32)) & BigInt(0xffffffff)); + const len = Number(packed & BigInt(0xffffffff)); + return [ptr, len]; +} \ No newline at end of file diff --git a/version/current_version b/version/current_version new file mode 100644 index 00000000..01e994d3 --- /dev/null +++ b/version/current_version @@ -0,0 +1 @@ +v0.4.0 \ No newline at end of file diff --git a/version/version.go b/version/version.go new file mode 100644 index 00000000..f725f09e --- /dev/null +++ b/version/version.go @@ -0,0 +1,28 @@ +/* + Copyright 2023 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package version + +import ( + _ "embed" +) + +//go:embed current_version +var currentVersion string + +func Version() string { + return currentVersion +} diff --git a/wasi.ts b/wasi.ts new file mode 100644 index 00000000..487f02ca --- /dev/null +++ b/wasi.ts @@ -0,0 +1,243 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import { Writer } from "./config"; + +const ErrNoInstance = Error("no webassembly instance") +const ErrNoMemory = Error("no exported memory in webassembly instance") + +export interface RequiredFunctions extends WebAssembly.ModuleImports { + fd_prestat_get(fd: number, bufPtr: number): number + fd_prestat_dir_name(fd: number, pathPtr: number, pathLen: number): number + environ_sizes_get(environCount: number, environBufSize: number): number + environ_get(environ: number, environBuf: number): number + args_sizes_get(argc: number, argvBufSize: number): number + args_get(argv: number, argvBuf: number): number + fd_filestat_get(fd: number, bufPtr: number): number + fd_fdstat_get(fd: number, bufPtr: number): number + fd_read(fd: number, iovs_ptr: number, iovs_len: number, nread_ptr: number): number + fd_write(fd: number, iovs: number, iovsLen: number, nwritten: number): number + fd_close(fd: number): number + fd_seek(fd: number, offset: number, whence: number, newOffsetPtr: number): number + poll_oneoff(sin: number, sout: number, nsubscriptions: number, nevents: number): number + proc_exit(rval: number): number + path_open(fd: number, dirflags: number, path_ptr: number, path_len: number, oflags: number, fs_rights_base: number, fs_rights_inheriting: number, fd_flags: number, opened_fd_ptr: number): number + clock_time_get(id: number, precision: bigint, time: number): number + random_get(buf: number, buf_len: number): void +} + +export class DisabledWASI { + public static ESUCCESS = 0; + public static EBADF = 8; + public static EINVAL = 28; + public static ENOSYS = 52; + + public static CLOCKID_REALTIME = 0; + + private exports: WebAssembly.Exports | undefined; + + private readonly env: { [key: string]: string } | undefined; + private readonly stdout: Writer | undefined; + private readonly stderr: Writer | undefined; + + constructor(env?: { [key: string]: string }, stdout?: Writer, stderr?: Writer) { + this.env = env; + this.stdout = stdout; + this.stderr = stderr; + } + + private getDataView(): DataView { + if (!this.exports) { + throw ErrNoInstance; + } + if (!this.exports.memory) { + throw ErrNoMemory; + } + + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + return new DataView(this.exports.memory.buffer); + } + + public SetInstance(instance: WebAssembly.Instance) { + this.exports = instance.exports; + } + + public environ_sizes_get(environCount: number, environBufSize: number): number { + const view = this.getDataView(); + let count = 0; + let size = 0; + if (typeof this.env !== "undefined") { + for (const key in this.env) { + count++; + size += key.length + 1 + this.env[key].length + 1; + } + } + view.setUint32(environCount, count, true); + view.setUint32(environBufSize, size, true); + return DisabledWASI.ESUCCESS; + } + + public environ_get(environ: number, environBuf: number): number { + const view = this.getDataView(); + let offset = 0; + if (typeof this.env !== "undefined") { + for (const key in this.env) { + const value = this.env[key]; + const keyLen = key.length; + const valueLen = value.length; + view.setUint32(environ + offset, environBuf, true); + offset += 4; + view.setUint32(environ + offset, keyLen + 1 + valueLen + 1, true); + offset += 4; + for (let i = 0; i < keyLen; i++) { + view.setUint8(environBuf, key.charCodeAt(i)); + environBuf++; + } + view.setUint8(environBuf, 0); + environBuf++; + for (let i = 0; i < valueLen; i++) { + view.setUint8(environBuf, value.charCodeAt(i)); + environBuf++; + } + view.setUint8(environBuf, 0); + environBuf++; + } + } + return DisabledWASI.ESUCCESS; + } + + public args_sizes_get(argc: number, argvBufSize: number): number { + const view = this.getDataView(); + view.setUint32(argc, 0, true); + view.setUint32(argvBufSize, 0, true); + return DisabledWASI.ESUCCESS; + } + + public args_get(_argv: number, _argvBuf: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.ESUCCESS; + } + + public fd_prestat_get(_fd: number, _bufPtr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public fd_prestat_dir_name(_fd: number, _pathPtr: number, _pathLen: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EINVAL; + } + + public fd_filestat_get(_fd: number, _bufPtr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public fd_fdstat_get(_fd: number, _bufPtr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public fd_read(_fd: number, _iovs_ptr: number, _iovs_len: number, _nread_ptr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public fd_write(fd: number, iovsPtr: number, iovsLength: number, bytesWrittenPtr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + if ( (fd === 1 && typeof this.stdout !== "undefined") || (fd === 2 && typeof this.stderr !== "undefined") ) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const iovs = new Uint32Array(this.exports.memory.buffer, iovsPtr, iovsLength * 2); + let text = ""; + let totalBytesWritten = 0; + const decoder = new TextDecoder(); + for(let i =0; i < iovsLength * 2; i += 2){ + const offset = iovs[i]; + const length = iovs[i+1]; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const textChunk = decoder.decode(new Int8Array(this.exports.memory.buffer, offset, length)); + text += textChunk; + totalBytesWritten += length; + } + const dataView = this.getDataView(); + dataView.setInt32(bytesWrittenPtr, totalBytesWritten, true); + if (fd === 1 && typeof this.stdout !== "undefined") { + this.stdout(text); + } else if (fd === 2 && typeof this.stderr !== "undefined") { + this.stderr(text); + } + + return DisabledWASI.ESUCCESS; + } + + return DisabledWASI.EBADF; + } + + public fd_close(_fd: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public fd_seek(_fd: number, _offset: number, _whence: number, _newOffsetPtr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public poll_oneoff(_sin: number, _sout: number, _nsubscriptions: number, _nevents: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.ENOSYS; + } + + public proc_exit(_rval: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.ENOSYS; + } + + public path_open(_fd: number, _dirflags: number, _path_ptr: number, _path_len: number, _oflags: number, _fs_rights_base: number, _fs_rights_inheriting: number, _fd_flags: number, _opened_fd_ptr: number): number { // eslint-disable-line @typescript-eslint/no-unused-vars + return DisabledWASI.EBADF; + } + + public clock_time_get(id: number, _precision: bigint, time: number) { // eslint-disable-line @typescript-eslint/no-unused-vars + const buffer = this.getDataView() + if (id === DisabledWASI.CLOCKID_REALTIME) { + buffer.setBigUint64(time, BigInt(new Date().getTime()) * 1000000n, true); + } else { + buffer.setBigUint64(time, 0n, true); + } + return DisabledWASI.ESUCCESS; + } + + public random_get(buf: number, buf_len: number): void { + const buffer = this.getDataView(); + for (let i = 0; i < buf_len; i++) { + buffer.setInt8(buf+i, (Math.random() * 256) | 0); + } + } + + public GetImports(): RequiredFunctions { + return { + environ_sizes_get: this.environ_sizes_get.bind(this), + environ_get: this.environ_get.bind(this), + args_sizes_get: this.args_sizes_get.bind(this), + args_get: this.args_get.bind(this), + fd_prestat_get: this.fd_prestat_get.bind(this), + fd_prestat_dir_name: this.fd_prestat_dir_name.bind(this), + fd_filestat_get: this.fd_filestat_get.bind(this), + fd_fdstat_get: this.fd_fdstat_get.bind(this), + fd_read: this.fd_read.bind(this), + fd_write: this.fd_write.bind(this), + fd_close: this.fd_close.bind(this), + fd_seek: this.fd_seek.bind(this), + poll_oneoff: this.poll_oneoff.bind(this), + proc_exit: this.proc_exit.bind(this), + path_open: this.path_open.bind(this), + clock_time_get: this.clock_time_get.bind(this), + random_get: this.random_get.bind(this), + } + } +}