diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9b1ee42e --- /dev/null +++ b/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..8b188c10 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "submodules/chainlink-protos"] + path = submodules/chainlink-protos + url = https://github.com/smartcontractkit/chainlink-protos.git +[submodule "submodules/chainlink-common"] + path = submodules/chainlink-common + url = https://github.com/smartcontractkit/chainlink-common.git diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..5dbd3660 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +bun 1.2.19 \ No newline at end of file diff --git a/README.md b/README.md index d531736e..99cc3f7e 100644 --- a/README.md +++ b/README.md @@ -1 +1,251 @@ -# cre-sdk-typescript \ No newline at end of file +# cre-sdk-typescript + +# cre-ts-sdk + +## Submodules + +This project uses Git submodules to include external dependencies. After cloning the repository, you need to initialize and update the submodules: + +### Initial Setup + +```zsh +# Clone with submodules +git clone --recursive https://github.com/ernest-nowacki/cre-ts-sdk.git + +# Or if already cloned without submodules +git submodule update --init --recursive +``` + +### Updating Submodules + +When there are changes in the submodule repositories: + +```zsh +# Update all submodules to their latest commits +git submodule update --remote + +# Or update a specific submodule +git submodule update --remote submodules/chainlink-protos +``` + +### Working with Submodules + +```zsh +# Check submodule status +git submodule status + +# Enter a submodule directory and switch branches +cd submodules/chainlink-protos +git checkout main +git pull origin main +cd ../.. +``` + +If you need to make changes to the submodule, it's recommended to contribute to the original repository, following all the contribution guidelines, and then once the changes are merged, update the submodule to the latest version. + +Currently sdk uses two submodules: + +- chainlink-protos - for protobuf definitions +- chainlink-common - for extra protobuf definitions for test capabilities + +## Setup + +This repo is using [Bun](https://bun.sh/) as the package manager and TS engine. +Use [asdf](https://asdf-vm.com/) to install the correct version, supported by the project. + +```bash +asdf install +``` + +To install dependencies: + +```zsh +bun i +``` + +To build everything you need in one shot: + +```zsh +bun build:all +``` + +To build just the Chainlink SDK Javy plugin: + +```zsh +bun build:javy:plugin +``` + +To compile Javy WASM that includes the Chainlink SDK plugin: + +```zsh +bun build:javy:sdk:wasm +``` + +To transpile TS workflow to JS: + +```zsh +bun build:workflows:js +``` + +To compile JS workflows to WASM: + +```zsh +bun build:workflows:wasm +``` + +## Javy + +[Javy](https://github.com/bytecodealliance/javy) is a main tool that drives our TS -> Wasm compilation. + +When installing it on a Mac, you might run into an error, caused by Apple's security policy. This repo contains a pre-compiled version of Javy for ARM architecture, +which is safe to run. However if you still run into issues, remove the quarantine attribute from the file: + +```zsh +xattr -d com.apple.quarantine ./bin/javy-arm-macos-v5.0.4 +``` + +Then make sure the file has execute permissions: + +```zsh +chmod +x ./bin/javy-arm-macos-v5.0.4 +``` + +Finally, verify if everything is working: + +```zsh +./bin/javy-arm-macos-v5.0.4 --version +``` + +If you see the version number, you're good to go. +For your convenience, there's a bun script that simply exposes `bun javy` to the CLI: + +```zsh +bun javy --version +``` + +### Javy Chainlink SDK + +Javy Chainlink SDK is a plugin that exposes host functions to the guest. + +To build the plugin, run: + +```zsh +bun build:javy:plugin +``` + +or manually: + +```zsh +cd plugins/javy_chainlink_sdk +cargo build --target wasm32-wasip1 --release +``` + +The plugin is later used to compile the Guest workflows. +**Important**: There are two options of how the plugin can be used: `dynamic` and `static`. +Currently we're using the static approach, but support for dynamic (looking for plugin at runtime) would be explored. + +### Linux + +Similar to the macOS instructions, for Linux you'll need: + +```zsh +chmod +x ./bin/javy-arm-linux-v5.0.4 +``` + +Verify the binary: + +```zsh +./bin/javy-arm-linux-v5.0.4 --version +``` + +Convenience script: + +```zsh +bun javy:linux --version +``` + +## Biome + +[Biome](https://github.com/biomejs/biome) is our default formatter and linter. + +To run the checks and auto-fix everything that can be auto-fixed: + +```zsh +bun biome:check +``` + +To run just the formatter: + +```zsh +bun biome:format +``` + +To run just the linter: + +```zsh +bun biome:lint +``` + +## Compile to Wasm + +Write your workflow and build it. Build process will generate output in `/dist`. + +```zsh +bun build:all +``` + +This will compile the workflows to Wasm and output the files to the `dist/workflows` directory. +Build is also compiling SDK files from TS to JS and outputting them to the `dist` directory, maintaining the same structure. + +### Build Output Structure + +After running `bun build:all`, the following structure will be created: + +``` +dist/ +├── workflows/ # Compiled WASM workflows +│ └── hello-world.wasm +├── sdk/ # Compiled JS SDK files +└── javy/ # Javy SDK plugin artifacts +``` + +## Tooling + +You would need Rust installed to build the plugin. + +## `wasm-tools` - for debugging content of compiled Wasm files + +To install: + +```zsh +cargo install --locked wasm-tools +``` + +Example usage (validate the hello-world workflow): + +```zsh +wasm-tools component targets --world workflow src/workflows/workflow.wit dist/workflows/hello-world.wasm +``` + +## Protobuf Generation + +This project uses [ts-proto](https://github.com/stephenh/ts-proto) for generating TypeScript types from Protocol Buffers. + +### Prerequisites + +`buf` is managed via bunx from dev dependencies, so only prerequisite is that you've run `bun install` before attempting to run proto related commands. + +### Available Commands + +- `bun proto:generate` - Generate TypeScript types from .proto files +- `bun proto:lint` - Lint .proto files +- `bun proto:format` - Format .proto files + +### Configuration + +- **buf.yaml** - Main buf configuration +- **buf.gen.yaml** - Code generation configuration using ts-proto +- **.tool-versions** - Version management for bun only +- **package.json** - buf version managed as dev dependency + +Generated files are placed in `src/generated/`. diff --git a/bin/.DS_Store b/bin/.DS_Store new file mode 100644 index 00000000..21af7d8c Binary files /dev/null and b/bin/.DS_Store differ diff --git a/bin/javy-arm-linux-v5.0.4 b/bin/javy-arm-linux-v5.0.4 new file mode 100755 index 00000000..8d69f2d5 Binary files /dev/null and b/bin/javy-arm-linux-v5.0.4 differ diff --git a/bin/javy-arm-macos-v5.0.4 b/bin/javy-arm-macos-v5.0.4 new file mode 100755 index 00000000..a61e2453 Binary files /dev/null and b/bin/javy-arm-macos-v5.0.4 differ diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..8d70b5be --- /dev/null +++ b/biome.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.0.5/schema.json", + "vcs": { + "enabled": false, + "clientKind": "git", + "useIgnoreFile": false + }, + "files": { + "ignoreUnknown": false, + "includes": ["src/**/*", "scripts/**/*"] + }, + "formatter": { + "enabled": true, + "indentStyle": "tab", + "lineWidth": 100 + }, + "assist": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "error" + }, + "suspicious": { + "noExplicitAny": "warn" + }, + "style": { + "useConst": "error" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "asNeeded" + } + } +} diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..1ecd9fe9 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,30 @@ +# Improved buf.gen.yaml using modern Protobuf-ES +version: v2 + +# Managed mode for better field handling +managed: + enabled: true + override: + # Use string for 64-bit integers (important for WASM compatibility) + - field_option: jstype + value: JS_STRING + +inputs: + - directory: submodules/chainlink-protos/cre + +plugins: + # Modern @bufbuild/protoc-gen-es plugin + - local: protoc-gen-es + out: src/generated + opt: + # Generate TypeScript (required for WASM compilation) + - target=ts + + # No import extension (modern bundlers handle this) + - import_extension=none + + # Generate JSON types for better type safety + - json_types=true + + # Keep empty files (useful for consistent imports) + - keep_empty_files=false diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 00000000..3d0079dc --- /dev/null +++ b/buf.yaml @@ -0,0 +1,13 @@ +version: v2 + +modules: + - path: submodules/chainlink-protos/cre + +lint: + use: + - STANDARD + +# Breaking change detection +breaking: + use: + - FILE diff --git a/build.ts b/build.ts new file mode 100644 index 00000000..efa9d9ea --- /dev/null +++ b/build.ts @@ -0,0 +1,9 @@ +import { main as compileToJS } from "./scripts/compile-to-js"; +import { main as compileToWasm } from "./scripts/compile-to-wasm"; +import { main as compileJavySdkPlugin } from "./scripts/compile-javy-sdk-plugin"; +import { main as compileJavyWithSdkPlugin } from "./scripts/compile-javy-with-sdk-plugin"; + +await compileJavySdkPlugin(); +await compileJavyWithSdkPlugin(); +await compileToJS(); +await compileToWasm(); diff --git a/bun.lock b/bun.lock new file mode 100644 index 00000000..4a11c7e8 --- /dev/null +++ b/bun.lock @@ -0,0 +1,143 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "cre-ts-sdk", + "dependencies": { + "@bufbuild/protobuf": "2.6.3", + "@bufbuild/protoc-gen-es": "2.6.3", + "rxjs": "7.8.2", + "zod": "3.25.76", + }, + "devDependencies": { + "@biomejs/biome": "2.1.3", + "@bufbuild/buf": "1.56.0", + "@types/bun": "1.2.19", + "fast-glob": "3.3.3", + "ts-proto": "2.7.5", + "typescript": "5.9.2", + }, + }, + }, + "packages": { + "@biomejs/biome": ["@biomejs/biome@2.1.3", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.1.3", "@biomejs/cli-darwin-x64": "2.1.3", "@biomejs/cli-linux-arm64": "2.1.3", "@biomejs/cli-linux-arm64-musl": "2.1.3", "@biomejs/cli-linux-x64": "2.1.3", "@biomejs/cli-linux-x64-musl": "2.1.3", "@biomejs/cli-win32-arm64": "2.1.3", "@biomejs/cli-win32-x64": "2.1.3" }, "bin": { "biome": "bin/biome" } }, "sha512-KE/tegvJIxTkl7gJbGWSgun7G6X/n2M6C35COT6ctYrAy7SiPyNvi6JtoQERVK/VRbttZfgGq96j2bFmhmnH4w=="], + + "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.1.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-LFLkSWRoSGS1wVUD/BE6Nlt2dSn0ulH3XImzg2O/36BoToJHKXjSxzPEMAqT9QvwVtk7/9AQhZpTneERU9qaXA=="], + + "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.1.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-Q/4OTw8P9No9QeowyxswcWdm0n2MsdCwWcc5NcKQQvzwPjwuPdf8dpPPf4r+x0RWKBtl1FLiAUtJvBlri6DnYw=="], + + "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.1.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-2hS6LgylRqMFmAZCOFwYrf77QMdUwJp49oe8PX/O8+P2yKZMSpyQTf3Eo5ewnsMFUEmYbPOskafdV1ds1MZMJA=="], + + "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.1.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-KXouFSBnoxAWZYDQrnNRzZBbt5s9UJkIm40hdvSL9mBxSSoxRFQJbtg1hP3aa8A2SnXyQHxQfpiVeJlczZt76w=="], + + "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.1.3", "", { "os": "linux", "cpu": "x64" }, "sha512-NxlSCBhLvQtWGagEztfAZ4WcE1AkMTntZV65ZvR+J9jp06+EtOYEBPQndA70ZGhHbEDG57bR6uNvqkd1WrEYVA=="], + + "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.1.3", "", { "os": "linux", "cpu": "x64" }, "sha512-KaLAxnROouzIWtl6a0Y88r/4hW5oDUJTIqQorOTVQITaKQsKjZX4XCUmHIhdEk8zMnaiLZzRTAwk1yIAl+mIew=="], + + "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.1.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-V9CUZCtWH4u0YwyCYbQ3W5F4ZGPWp2C2TYcsiWFNNyRfmOW1j/TY/jAurl33SaRjgZPO5UUhGyr9m6BN9t84NQ=="], + + "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.1.3", "", { "os": "win32", "cpu": "x64" }, "sha512-dxy599q6lgp8ANPpR8sDMscwdp9oOumEsVXuVCVT9N2vAho8uYXlCz53JhxX6LtJOXaE73qzgkGQ7QqvFlMC0g=="], + + "@bufbuild/buf": ["@bufbuild/buf@1.56.0", "", { "optionalDependencies": { "@bufbuild/buf-darwin-arm64": "1.56.0", "@bufbuild/buf-darwin-x64": "1.56.0", "@bufbuild/buf-linux-aarch64": "1.56.0", "@bufbuild/buf-linux-armv7": "1.56.0", "@bufbuild/buf-linux-x64": "1.56.0", "@bufbuild/buf-win32-arm64": "1.56.0", "@bufbuild/buf-win32-x64": "1.56.0" }, "bin": { "buf": "bin/buf", "protoc-gen-buf-breaking": "bin/protoc-gen-buf-breaking", "protoc-gen-buf-lint": "bin/protoc-gen-buf-lint" } }, "sha512-1xQWOf3FCDDTi+5B/VScQ73EP6ACwQPCP4ODvCq2L6IVgFtvYX49ur6cQ2qCM8yFitIHESm/Nbff93sh+V/Iog=="], + + "@bufbuild/buf-darwin-arm64": ["@bufbuild/buf-darwin-arm64@1.56.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-9neaI9gx1sxOGl9xrL7kw6H+0WmVAFlIQTIDc3vt1qRhfgOt/8AWOHSOWppGTRjNiB0qh6Xie1LYHv/jgDVN0g=="], + + "@bufbuild/buf-darwin-x64": ["@bufbuild/buf-darwin-x64@1.56.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-nRHPMXV8fr/lqU+u/1GGsUg7OvNcxJuCJoJpfRoRg38b+NPzOz2FkQAs5OEJzzprQB5aftn5//cl8YXjgvTuFA=="], + + "@bufbuild/buf-linux-aarch64": ["@bufbuild/buf-linux-aarch64@1.56.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-+td559RuKNwYDnq49NrIDGJ4F73Ra4QzVVbsC+UeveA0HMnIGRzFbchGjHtNJyaZsI57sXJ7dCHH0iFV3jcYwQ=="], + + "@bufbuild/buf-linux-armv7": ["@bufbuild/buf-linux-armv7@1.56.0", "", { "os": "linux", "cpu": "arm" }, "sha512-9v3zmos6wRTBc4QeIg4rfDmPzmTgtUTRCbhr87qws/yddIT8cFtHHhy1whnozBNqtmYOdwZNBNx/QXqGGcRuKw=="], + + "@bufbuild/buf-linux-x64": ["@bufbuild/buf-linux-x64@1.56.0", "", { "os": "linux", "cpu": "x64" }, "sha512-3jZHHBol1fuichNke7LJtHJUdw314XBj6OuJHY6IufsaaVIj1mtM2DPbGiDhYB453J7FiV/buadctKBxAAHclg=="], + + "@bufbuild/buf-win32-arm64": ["@bufbuild/buf-win32-arm64@1.56.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-KMGzSf9rIbT01Jb2685JovwRRYEdL7Zbs6ZrjyhIHBgKK6cBwz1AJvEaDrWMEzCdv+opQwjgM6UdtA4e9BWP1A=="], + + "@bufbuild/buf-win32-x64": ["@bufbuild/buf-win32-x64@1.56.0", "", { "os": "win32", "cpu": "x64" }, "sha512-19LFOCyFFVTaaqNGtYTpiF67fcpneWZFlm8UNU+Xs87Kh+N5i/LjDjNytnpFT6snwU4/S+UUkq7WgS6UPjqXIg=="], + + "@bufbuild/protobuf": ["@bufbuild/protobuf@2.6.3", "", {}, "sha512-w/gJKME9mYN7ZoUAmSMAWXk4hkVpxRKvEJCb3dV5g9wwWdxTJJ0ayOJAVcNxtdqaxDyFuC0uz4RSGVacJ030PQ=="], + + "@bufbuild/protoc-gen-es": ["@bufbuild/protoc-gen-es@2.6.3", "", { "dependencies": { "@bufbuild/protobuf": "2.6.3", "@bufbuild/protoplugin": "2.6.3" }, "bin": { "protoc-gen-es": "bin/protoc-gen-es" } }, "sha512-20o4U/Th0yLK/ayQGJ8hwh+fmcI/2PWZFkTS4gv08AtOx31YA05/X/wbn+pLZLJCDP2ik4KTIWuV1j4gERs15A=="], + + "@bufbuild/protoplugin": ["@bufbuild/protoplugin@2.6.3", "", { "dependencies": { "@bufbuild/protobuf": "2.6.3", "@typescript/vfs": "^1.5.2", "typescript": "5.4.5" } }, "sha512-VceMuxeRukxGeABfo34SXq0VqY1MU+mzS+PBf0HAWo97ylFut8F6sQ3mV0tKiM08UQ/xQco7lxCn83BkoxrWrA=="], + + "@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="], + + "@nodelib/fs.stat": ["@nodelib/fs.stat@2.0.5", "", {}, "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="], + + "@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="], + + "@types/bun": ["@types/bun@1.2.19", "", { "dependencies": { "bun-types": "1.2.19" } }, "sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg=="], + + "@types/node": ["@types/node@22.14.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw=="], + + "@types/react": ["@types/react@19.1.8", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g=="], + + "@typescript/vfs": ["@typescript/vfs@1.6.1", "", { "dependencies": { "debug": "^4.1.1" }, "peerDependencies": { "typescript": "*" } }, "sha512-JwoxboBh7Oz1v38tPbkrZ62ZXNHAk9bJ7c9x0eI5zBfBnBYGhURdbnh7Z4smN/MV48Y5OCcZb58n972UtbazsA=="], + + "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="], + + "bun-types": ["bun-types@1.2.19", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-uAOTaZSPuYsWIXRpj7o56Let0g/wjihKCkeRqUBhlLVM/Bt+Fj9xTo+LhC1OV1XDaGkz4hNC80et5xgy+9KTHQ=="], + + "case-anything": ["case-anything@2.1.13", "", {}, "sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng=="], + + "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], + + "debug": ["debug@4.4.1", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="], + + "detect-libc": ["detect-libc@1.0.3", "", { "bin": { "detect-libc": "./bin/detect-libc.js" } }, "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="], + + "dprint-node": ["dprint-node@1.0.8", "", { "dependencies": { "detect-libc": "^1.0.3" } }, "sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg=="], + + "fast-glob": ["fast-glob@3.3.3", "", { "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.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="], + + "fastq": ["fastq@1.19.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="], + + "fill-range": ["fill-range@7.1.1", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="], + + "glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="], + + "is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="], + + "is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="], + + "is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="], + + "merge2": ["merge2@1.4.1", "", {}, "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg=="], + + "micromatch": ["micromatch@4.0.8", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="], + + "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="], + + "picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], + + "queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="], + + "reusify": ["reusify@1.1.0", "", {}, "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw=="], + + "run-parallel": ["run-parallel@1.2.0", "", { "dependencies": { "queue-microtask": "^1.2.2" } }, "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA=="], + + "rxjs": ["rxjs@7.8.2", "", { "dependencies": { "tslib": "^2.1.0" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="], + + "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], + + "ts-poet": ["ts-poet@6.12.0", "", { "dependencies": { "dprint-node": "^1.0.8" } }, "sha512-xo+iRNMWqyvXpFTaOAvLPA5QAWO6TZrSUs5s4Odaya3epqofBu/fMLHEWl8jPmjhA0s9sgj9sNvF1BmaQlmQkA=="], + + "ts-proto": ["ts-proto@2.7.5", "", { "dependencies": { "@bufbuild/protobuf": "^2.0.0", "case-anything": "^2.1.13", "ts-poet": "^6.12.0", "ts-proto-descriptors": "2.0.0" }, "bin": { "protoc-gen-ts_proto": "protoc-gen-ts_proto" } }, "sha512-FoRxSaNW+P3m+GiXIZjUjhaHXT67Ah4zMGKzn4yklbGRQTS+PqpUhKo5AJnwfUDUByjEUG7ch36byFUYWRH9Nw=="], + + "ts-proto-descriptors": ["ts-proto-descriptors@2.0.0", "", { "dependencies": { "@bufbuild/protobuf": "^2.0.0" } }, "sha512-wHcTH3xIv11jxgkX5OyCSFfw27agpInAd6yh89hKG6zqIXnjW9SYqSER2CVQxdPj4czeOhGagNvZBEbJPy7qkw=="], + + "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], + + "typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="], + + "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="], + + "zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="], + + "@bufbuild/protoplugin/typescript": ["typescript@5.4.5", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ=="], + + "ts-proto/@bufbuild/protobuf": ["@bufbuild/protobuf@2.5.2", "", {}, "sha512-foZ7qr0IsUBjzWIq+SuBLfdQCpJ1j8cTuNNT4owngTHoN5KsJb8L9t65fzz7SCeSWzescoOil/0ldqiL041ABg=="], + + "ts-proto-descriptors/@bufbuild/protobuf": ["@bufbuild/protobuf@2.5.2", "", {}, "sha512-foZ7qr0IsUBjzWIq+SuBLfdQCpJ1j8cTuNNT4owngTHoN5KsJb8L9t65fzz7SCeSWzescoOil/0ldqiL041ABg=="], + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..7e2f7a2e --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "cre-sdk-typescript", + "module": "src/index.ts", + "type": "module", + "scripts": { + "biome:check": "biome check --write", + "biome:format": "biome format --write", + "biome:lint": "biome lint --write", + "build:javy:plugin": "bun scripts/run.ts compile-javy-sdk-plugin", + "build:javy:sdk:wasm": "bun scripts/run.ts compile-javy-with-sdk-plugin", + "build:workflows:wasm": "bun scripts/run.ts compile-to-wasm", + "build:workflows:js": "bun scripts/run.ts compile-to-js", + "build:workflows": "bun build:workflows:js && bun build:workflows:wasm", + "build:workflow:single:js": "bun scripts/run.ts build-single-workflow-js", + "build:workflow:single:wasm": "bun scripts/run.ts compile-single-workflow-to-wasm", + "build:workflow:single": "bun scripts/run.ts build-single-workflow", + "build:all": "bun build.ts", + "javy": "./bin/javy-arm-macos-v5.0.4", + "javy:linux": "./bin/javy-arm-linux-v5.0.4", + "start": "bun --watch src/index.ts", + "typecheck": "tsc", + "proto:generate": "bunx @bufbuild/buf generate", + "proto:lint": "bunx @bufbuild/buf lint", + "proto:format": "bunx @bufbuild/buf format --write", + "test": "bun test" + }, + "dependencies": { + "@bufbuild/protobuf": "2.6.3", + "@bufbuild/protoc-gen-es": "2.6.3", + "rxjs": "7.8.2", + "zod": "3.25.76" + }, + "devDependencies": { + "@biomejs/biome": "2.1.3", + "@bufbuild/buf": "1.56.0", + "@types/bun": "1.2.19", + "fast-glob": "3.3.3", + "ts-proto": "2.7.5", + "typescript": "5.9.2" + } +} diff --git a/plugins/javy_chainlink_sdk/Cargo.lock b/plugins/javy_chainlink_sdk/Cargo.lock new file mode 100644 index 00000000..a6a0c4e0 --- /dev/null +++ b/plugins/javy_chainlink_sdk/Cargo.lock @@ -0,0 +1,765 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.101", + "which", +] + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "cc" +version = "1.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956a5e21988b87f372569b66183b78babf23ebc2e744b733e4350a752c4dafac" +dependencies = [ + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "env_logger" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "javy" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10119b9ea70e813d800b3a3a734ec91ae1c2cdf9846c52f8a7a426ea1331ce5c" +dependencies = [ + "anyhow", + "bitflags", + "fastrand", + "quickcheck", + "rquickjs", + "rquickjs-core", + "rquickjs-sys", + "serde", +] + +[[package]] +name = "javy-plugin-api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc259712f0b003a0b63ae04389312303d4e4940ff7df941990069ed2b1166aaf" +dependencies = [ + "anyhow", + "javy", +] + +[[package]] +name = "javy_chainlink_sdk" +version = "0.1.0" +dependencies = [ + "base64", + "javy", + "javy-plugin-api", + "serde_json", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.172" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" + +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets 0.53.0", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "prettyplease" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dee91521343f4c5c6a63edd65e54f31f5c92fe8978c40a4282f8372194c6a7d" +dependencies = [ + "proc-macro2", + "syn 2.0.101", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quickcheck" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" +dependencies = [ + "env_logger", + "log", + "rand", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + +[[package]] +name = "rquickjs" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "313802853d6b1a91a7ecaef37b88b2e3be94dbfd8e46e8c585ec7d03977c4585" +dependencies = [ + "rquickjs-core", + "rquickjs-macro", +] + +[[package]] +name = "rquickjs-core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b61d5ef0cf929f69b30c106b70cafbf8c9b00435da7b13c004e61db639ae7cc" +dependencies = [ + "relative-path", + "rquickjs-sys", +] + +[[package]] +name = "rquickjs-macro" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52decfafae40368b74e1513235245612680224924925736f386b9456b78efce9" +dependencies = [ + "convert_case", + "fnv", + "ident_case", + "indexmap", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "rquickjs-core", + "syn 2.0.101", +] + +[[package]] +name = "rquickjs-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a6df95dbd61eacfa2fb7571c9d0a6d2acb168135f6261ddd53d0347fd65441" +dependencies = [ + "bindgen", + "cc", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.101", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] diff --git a/plugins/javy_chainlink_sdk/Cargo.toml b/plugins/javy_chainlink_sdk/Cargo.toml new file mode 100644 index 00000000..fd81b16c --- /dev/null +++ b/plugins/javy_chainlink_sdk/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "javy_chainlink_sdk" +version = "0.1.0" +edition = "2024" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +javy-plugin-api = "3.1.0" +javy = "4.0.0" +serde_json = "1.0" +base64 = "0.21" \ No newline at end of file diff --git a/plugins/javy_chainlink_sdk/src/lib.rs b/plugins/javy_chainlink_sdk/src/lib.rs new file mode 100644 index 00000000..39193bf8 --- /dev/null +++ b/plugins/javy_chainlink_sdk/src/lib.rs @@ -0,0 +1,272 @@ +use javy_plugin_api::{ + import_namespace, + javy::quickjs::prelude::*, + Config, +}; + +use javy_plugin_api::javy::quickjs::Error; +use std::env; +use base64::Engine; + +// ✅ Host imports: implemented in Go +#[link(wasm_import_module = "env")] +unsafe extern "C" { + // Core capability communication + fn call_capability(req_ptr: *const u8, req_len: i32) -> i64; + fn await_capabilities(await_request_ptr: *const u8, await_request_len: i32, response_buffer_ptr: *mut u8, max_response_len: i32) -> i64; + + // Secrets management + fn get_secrets(req_ptr: *const u8, req_len: i32, response_buffer_ptr: *mut u8, max_response_len: i32) -> i64; + fn await_secrets(await_request_ptr: *const u8, await_request_len: i32, response_buffer_ptr: *mut u8, max_response_len: i32) -> i64; + + // Logging and response + fn log(message_ptr: *const u8, message_len: i32); + fn send_response(response_ptr: *const u8, response_len: i32) -> i32; + + // Mode switching and versioning + fn switch_modes(mode: i32); + fn version_v2(); + + // Random seed generation + fn random_seed(mode: i32) -> i64; +} + +import_namespace!("javy_chainlink_sdk"); + +#[unsafe(no_mangle)] +pub unsafe extern "C" fn initialize_runtime() { + let mut config = Config::default(); + config + .event_loop(true) + .text_encoding(true) + .promise(true); + + javy_plugin_api::initialize_runtime(config, |runtime| { + runtime.context().with(|ctx| { + // Bind JS global: callCapability() + ctx.globals() + .set( + "callCapability", + Func::from(|_ctx: Ctx<'_>, request: String| { + // Decode base64 request to get original binary data + let request_bytes = match base64::engine::general_purpose::STANDARD.decode(&request) { + Ok(bytes) => bytes, + Err(_) => { + // Fallback to UTF-8 for backward compatibility with simple string requests + request.as_bytes().to_vec() + } + }; + let request_len = request_bytes.len() as i32; + + let result = unsafe { + call_capability(request_bytes.as_ptr(), request_len) + }; + + Ok::(result) + }), + ) + .unwrap(); + + // Bind JS global: awaitCapabilities() + ctx.globals() + .set( + "awaitCapabilities", + Func::from(|_ctx: Ctx<'_>, await_request: String, max_response_len: i32| { + // Decode base64 request to get original binary data + let await_request_bytes = match base64::engine::general_purpose::STANDARD.decode(&await_request) { + Ok(bytes) => bytes, + Err(_) => { + // Fallback to UTF-8 for backward compatibility with simple string requests + await_request.as_bytes().to_vec() + } + }; + let await_request_len = await_request_bytes.len() as i32; + let mut response_buffer = vec![0u8; max_response_len as usize]; + + let bytes_written = unsafe { + await_capabilities( + await_request_bytes.as_ptr(), + await_request_len, + response_buffer.as_mut_ptr(), + max_response_len + ) + }; + + if bytes_written < 0 { + return Err(Error::new_into_js("Error", "await_capabilities failed")); + } + + // Convert binary data to base64 string for JS + let response_bytes = response_buffer[..bytes_written as usize].to_vec(); + let base64_response = base64::engine::general_purpose::STANDARD.encode(response_bytes); + + Ok(base64_response) + }), + ) + .unwrap(); + + // Bind JS global: getSecrets() + ctx.globals() + .set( + "getSecrets", + Func::from(|_ctx: Ctx<'_>, request: String, max_response_len: i32| { + let request_bytes = request.as_bytes(); + let request_len = request_bytes.len() as i32; + + let mut response_buffer = vec![0u8; max_response_len as usize]; + + let result = unsafe { + get_secrets( + request_bytes.as_ptr(), + request_len, + response_buffer.as_mut_ptr(), + max_response_len + ) + }; + + Ok::(result) + }), + ) + .unwrap(); + + // Bind JS global: awaitSecrets() + ctx.globals() + .set( + "awaitSecrets", + Func::from(|_ctx: Ctx<'_>, await_request: String, max_response_len: i32| { + // Decode base64 request to get original binary data + let await_request_bytes = match base64::engine::general_purpose::STANDARD.decode(&await_request) { + Ok(bytes) => bytes, + Err(_) => { + // Fallback to UTF-8 for backward compatibility with simple string requests + await_request.as_bytes().to_vec() + } + }; + let await_request_len = await_request_bytes.len() as i32; + + let mut response_buffer = vec![0u8; max_response_len as usize]; + + let bytes_written = unsafe { + await_secrets( + await_request_bytes.as_ptr(), + await_request_len, + response_buffer.as_mut_ptr(), + max_response_len + ) + }; + + if bytes_written < 0 { + return Err(Error::new_into_js("Error", "await_secrets failed")); + } + + // Convert binary data to base64 string for JS + let response_bytes = response_buffer[..bytes_written as usize].to_vec(); + let base64_response = base64::engine::general_purpose::STANDARD.encode(response_bytes); + + Ok(base64_response) + }), + ) + .unwrap(); + + // Bind JS global: log() + ctx.globals() + .set( + "log", + Func::from(|message: String| { + let message_bytes = message.as_bytes(); + let message_len = message_bytes.len() as i32; + + unsafe { + log(message_bytes.as_ptr(), message_len); + } + }), + ) + .unwrap(); + + // Bind JS global: sendResponse() + ctx.globals() + .set( + "sendResponse", + Func::from(|_ctx: Ctx<'_>, response: String| { + // Decode base64 response to get original binary data + let response_bytes = match base64::engine::general_purpose::STANDARD.decode(&response) { + Ok(bytes) => bytes, + Err(_) => { + // Fallback to UTF-8 for backward compatibility with simple string responses + response.as_bytes().to_vec() + } + }; + let response_len = response_bytes.len() as i32; + + let result = unsafe { + send_response(response_bytes.as_ptr(), response_len) + }; + + if result == 0 { + // tell WASI to exit(0) → host sees success and returns exec.response + std::process::exit(0); + } + + // non-zero -> propagate as-is + Ok::(result) + }), + ) + .unwrap(); + + // Bind JS global: switchModes() + ctx.globals() + .set( + "switchModes", + Func::from(|mode: i32| { + unsafe { + switch_modes(mode); + } + }), + ) + .unwrap(); + + // Bind JS global: versionV2() + ctx.globals() + .set( + "versionV2", + Func::from(|| { + unsafe { + version_v2(); + } + }), + ) + .unwrap(); + + // Bind JS global: randomSeed() + ctx.globals() + .set( + "randomSeed", + Func::from(|mode: i32| { + let result = unsafe { + random_seed(mode) + }; + + Ok::(result) + }), + ) + .unwrap(); + + // Bind JS global: getWasiArgs() + ctx.globals() + .set( + "getWasiArgs", + Func::from(|_ctx: Ctx<'_>| -> Result { + let args: Vec = env::args().collect(); + let args_json = serde_json::to_string(&args) + .map_err(|_| Error::new_into_js("Error", "Failed to serialize args to JSON"))?; + + Ok(args_json) + }), + ) + .unwrap(); + }); + + runtime + }) + .unwrap(); +} \ No newline at end of file diff --git a/scripts/build-and-deploy.sh b/scripts/build-and-deploy.sh new file mode 100755 index 00000000..a8d62ee2 --- /dev/null +++ b/scripts/build-and-deploy.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Check if arguments are provided +if [ $# -eq 0 ]; then + echo "Error: Workflow name is required" + echo "Usage: $0 " + echo " $0 " + echo "Examples:" + echo " Single: $0 capability_calls_are_async" + echo " Nested: $0 mode_switch don_runtime_in_node_mode" + exit 1 +fi + +if [ $# -eq 1 ]; then + # Single workflow + workflow_name=$1 + echo "Building and deploying workflow: $workflow_name" + + # Step 1: Build JavaScript workflow + echo "Building JavaScript workflow..." + bun build:workflow:single:js "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: JavaScript build failed" + exit 1 + fi + + # Step 2: Build WASM workflow + echo "Building WASM workflow..." + bun build:workflow:single:wasm "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: WASM build failed" + exit 1 + fi + + # Step 3: Copy WASM files + echo "Copying WASM files..." + ./scripts/copy-wasm.sh "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: WASM copy failed" + exit 1 + fi + + echo "Build and deploy completed successfully for workflow: $workflow_name" + +elif [ $# -eq 2 ]; then + # Nested workflow + directory=$1 + workflow_name=$2 + echo "Building and deploying nested workflow: $directory/$workflow_name" + + # Step 1: Build JavaScript workflow + echo "Building JavaScript workflow..." + bun build:workflow:single:js "$directory" "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: JavaScript build failed" + exit 1 + fi + + # Step 2: Build WASM workflow + echo "Building WASM workflow..." + bun build:workflow:single:wasm "$directory" "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: WASM build failed" + exit 1 + fi + + # Step 3: Copy WASM files + echo "Copying WASM files..." + ./scripts/copy-nested-wasm.sh "$directory" "$workflow_name" + + # Check if the previous command was successful + if [ $? -ne 0 ]; then + echo "Error: WASM copy failed" + exit 1 + fi + + echo "Build and deploy completed successfully for nested workflow: $directory/$workflow_name" + +else + echo "Error: Too many arguments provided" + echo "Usage: $0 " + echo " $0 " + exit 1 +fi + diff --git a/scripts/build-single-workflow-js.ts b/scripts/build-single-workflow-js.ts new file mode 100644 index 00000000..d5730493 --- /dev/null +++ b/scripts/build-single-workflow-js.ts @@ -0,0 +1,72 @@ +import fg from "fast-glob"; +import { $ } from "bun"; +import { mkdir } from "fs/promises"; +import { existsSync } from "fs"; + +export const main = async () => { + const args = process.argv.slice(3); + + if (args.length === 0) { + console.error("Usage: bun run build-single-workflow-js.ts "); + console.error(" bun run build-single-workflow-js.ts "); + console.error("Examples:"); + console.error(" Single: bun run build-single-workflow-js.ts capability_calls_are_async"); + console.error(" Nested: bun run build-single-workflow-js.ts mode_switch don_runtime_in_node_mode"); + process.exit(1); + } + + let workflowPath: string; + let outputPath: string; + let pattern: string; + + if (args.length === 1) { + // Single workflow parameter - works as before + const workflowName = args[0]; + console.info(`Building workflow: ${workflowName}`); + pattern = `src/workflows/standard_tests/${workflowName}/testts.ts`; + outputPath = `dist/workflows/standard_tests/${workflowName}`; + } else if (args.length === 2) { + // Two parameters - first is directory, second is nested workflow + const directory = args[0]; + const workflowName = args[1]; + console.info(`Building nested workflow: ${directory}/${workflowName}`); + pattern = `src/workflows/standard_tests/${directory}/${workflowName}/testts.ts`; + outputPath = `dist/workflows/standard_tests/${directory}/${workflowName}`; + } else { + console.error("❌ Too many arguments provided"); + process.exit(1); + } + + // Find the specific workflow file + const workflowsSourcePaths = await fg(pattern); + + if (workflowsSourcePaths.length === 0) { + console.error(`❌ No workflow found: ${pattern}`); + process.exit(1); + } + + workflowPath = workflowsSourcePaths[0]; + console.info(`📁 Found: ${workflowPath}`); + + // Ensure the output directory exists + await mkdir(outputPath, { recursive: true }); + + // Build the single workflow + await Bun.build({ + entrypoints: [`./${workflowPath}`], + outdir: outputPath, + target: "node", + format: "esm", + }); + + const targetJsFile = `${outputPath}/testts.js`; + + if (!existsSync(targetJsFile)) { + console.error(`❌ Expected file not found: ${targetJsFile}`); + process.exit(1); + } + + await $`bun build ${targetJsFile} --bundle --outfile=${targetJsFile}`; + + console.info(`✅ Built: ${targetJsFile}`); +}; diff --git a/scripts/build-single-workflow.ts b/scripts/build-single-workflow.ts new file mode 100644 index 00000000..c79422d3 --- /dev/null +++ b/scripts/build-single-workflow.ts @@ -0,0 +1,23 @@ +import { $ } from "bun"; + +export const main = async () => { + const workflowArg = process.argv[3]; + + if (!workflowArg) { + console.error("Usage: bun run build-single-workflow.ts "); + console.error("Example: bun run build-single-workflow.ts secrets"); + process.exit(1); + } + + console.info(`🚀 Building workflow: ${workflowArg}`); + + // Build JS + console.info("\n📦 Step 1: Building JS..."); + await $`bun scripts/run.ts build-single-workflow-js ${workflowArg}`; + + // Build WASM + console.info("\n🔨 Step 2: Compiling to WASM..."); + await $`bun scripts/run.ts compile-single-workflow-to-wasm ${workflowArg}`; + + console.info(`\n✅ Workflow '${workflowArg}' built successfully!`); +}; diff --git a/scripts/compile-javy-sdk-plugin.ts b/scripts/compile-javy-sdk-plugin.ts new file mode 100755 index 00000000..9677561c --- /dev/null +++ b/scripts/compile-javy-sdk-plugin.ts @@ -0,0 +1,37 @@ +#!/usr/bin/env bun + +import { spawn } from "node:child_process"; +import { join } from "node:path"; + +export const main = async () => { + const pluginDir = join(process.cwd(), "plugins", "javy_chainlink_sdk"); + + console.info("\n\n---> Chainlink SDK Javy plugin (Rust) \n\n"); + + return new Promise((resolve, reject) => { + const buildProcess = spawn( + "cargo", + ["build", "--target", "wasm32-wasip1", "--release"], + { + cwd: pluginDir, + stdio: "inherit", + shell: true, + } + ); + + buildProcess.on("close", (code) => { + if (code === 0) { + console.info("Done!"); + resolve(); + } else { + console.error(`❌ Plugin build failed with code ${code}`); + reject(new Error(`Plugin build failed with code ${code}`)); + } + }); + + buildProcess.on("error", (error) => { + console.error("❌ Failed to start build process:", error); + reject(error); + }); + }); +}; diff --git a/scripts/compile-javy-with-sdk-plugin.ts b/scripts/compile-javy-with-sdk-plugin.ts new file mode 100644 index 00000000..6e3b4185 --- /dev/null +++ b/scripts/compile-javy-with-sdk-plugin.ts @@ -0,0 +1,11 @@ +import { $ } from "bun"; + +export const main = async () => { + console.info("\n\n---> Compile Javy SDK plugin \n\n"); + + await $`mkdir -p dist`; + + await $`bun javy init-plugin plugins/javy_chainlink_sdk/target/wasm32-wasip1/release/javy_chainlink_sdk.wasm -o dist/javy-chainlink-sdk.plugin.wasm`; + + console.info("Done!"); +}; diff --git a/scripts/compile-single-workflow-to-wasm.ts b/scripts/compile-single-workflow-to-wasm.ts new file mode 100644 index 00000000..b6f996c4 --- /dev/null +++ b/scripts/compile-single-workflow-to-wasm.ts @@ -0,0 +1,68 @@ +import { $ } from "bun"; +import fg from "fast-glob"; + +export const main = async () => { + const args = process.argv.slice(3); + + if (args.length === 0) { + console.error( + "Usage: bun run compile-single-workflow-to-wasm.ts " + ); + console.error( + " bun run compile-single-workflow-to-wasm.ts " + ); + console.error("Examples:"); + console.error( + " Single: bun run compile-single-workflow-to-wasm.ts capability_calls_are_async" + ); + console.error( + " Nested: bun run compile-single-workflow-to-wasm.ts mode_switch don_runtime_in_node_mode" + ); + process.exit(1); + } + + let jsFile: string; + let buildCommand: string; + + if (args.length === 1) { + // Single workflow parameter - works as before + const workflowName = args[0]; + console.info(`🔨 Compiling workflow to WASM: ${workflowName}`); + jsFile = `dist/workflows/standard_tests/${workflowName}/testts.js`; + buildCommand = `bun run build-single-workflow-js.ts ${workflowName}`; + } else if (args.length === 2) { + // Two parameters - first is directory, second is nested workflow + const directory = args[0]; + const workflowName = args[1]; + console.info(`🔨 Compiling nested workflow to WASM: ${directory}/${workflowName}`); + jsFile = `dist/workflows/standard_tests/${directory}/${workflowName}/testts.js`; + buildCommand = `bun run build-single-workflow-js.ts ${directory} ${workflowName}`; + } else { + console.error("❌ Too many arguments provided"); + process.exit(1); + } + + const wasmFile = jsFile.replace(/\.js$/, ".wasm"); + + // Check if the JS file exists + const jsFiles = fg.sync(jsFile); + if (jsFiles.length === 0) { + console.error(`❌ No JS file found: ${jsFile}`); + console.error( + `Make sure to build the workflow first with: ${buildCommand}` + ); + process.exit(1); + } + + console.info(`📁 Found: ${jsFile}`); + console.info(`🎯 Output: ${wasmFile}`); + + /** + * -C wit=src/workflows/workflow.wit — points to the WIT file (definition of what will be available for the Host). + * -C wit-world=workflow — specifies the WIT world name (world "workflow" which is defined in the .wit file). + * -C plugin=... — uses your custom runtime (bundled javy chainlink sdk plugin) + */ + await $`bun javy build -C wit=src/workflows/workflow.wit -C wit-world=workflow -C plugin=dist/javy-chainlink-sdk.plugin.wasm ${jsFile} -o ${wasmFile}`; + + console.info(`✅ Compiled: ${wasmFile}`); +}; diff --git a/scripts/compile-to-js.ts b/scripts/compile-to-js.ts new file mode 100644 index 00000000..e768ecac --- /dev/null +++ b/scripts/compile-to-js.ts @@ -0,0 +1,28 @@ +import fg from "fast-glob"; +import { $ } from "bun"; + +export const main = async () => { + console.info("\n\n---> Compile TS source files to JS\n\n"); + + const workflowsSourcePaths = await fg("src/workflows/**/*.ts"); + const workflows = Array.from(workflowsSourcePaths).map((path) => `./${path}`); + + await Bun.build({ + entrypoints: [...workflows], + outdir: "./dist/workflows", + target: "node", + format: "esm", + root: "./src/workflows", + }); + + console.info("\n---> Bundling individual workflow files\n\n"); + + // Get all the generated JS files in dist/workflows + const workflowJSFiles = await fg("dist/workflows/**/*.js"); + + for (const jsFile of workflowJSFiles) { + await $`bun build ${jsFile} --bundle --outfile=${jsFile}`; + } + + console.info("Bundling: Done!"); +}; diff --git a/scripts/compile-to-wasm.ts b/scripts/compile-to-wasm.ts new file mode 100644 index 00000000..b40f52f1 --- /dev/null +++ b/scripts/compile-to-wasm.ts @@ -0,0 +1,23 @@ +import { $ } from "bun"; +import fg from "fast-glob"; + +export const main = async () => { + console.info("\n\n---> Compile JS workflows to WASM \n\n"); + + const workflowJSFiles = fg.sync("dist/workflows/**/*.js"); + + for (const jsFile of workflowJSFiles) { + const wasmFile = jsFile.replace(/\.js$/, ".wasm"); + + console.log(`\n\n🔨 Building WASM for: ${jsFile}`); + + /** + * -C wit=src/workflows/workflow.wit — points to the WIT file (definition of what will be available for the Host). + * -C wit-world=workflow — specifies the WIT world name (world "workflow" which is defined in the .wit file). + * -C plugin=... — uses your custom runtime (bundled javy chainlink sdk plugin) + */ + await $`bun javy build -C wit=src/workflows/workflow.wit -C wit-world=workflow -C plugin=dist/javy-chainlink-sdk.plugin.wasm ${jsFile} -o ${wasmFile}`; + } + + console.info("Done!"); +}; diff --git a/scripts/compile-workflow-local.sh b/scripts/compile-workflow-local.sh new file mode 100755 index 00000000..9c238450 --- /dev/null +++ b/scripts/compile-workflow-local.sh @@ -0,0 +1,42 @@ +#!/bin/zsh + +# Deploy workflow script +# Usage: ./scripts/deploy-workflow.sh + +set -e + +# Check if workflow name is provided +if [ $# -eq 0 ]; then + echo "Error: Workflow name is required" + echo "Usage: $0 " + exit 1 +fi + +WORKFLOW_NAME=$1 + +echo "🚀 Deploying workflow: $WORKFLOW_NAME" + +# Change to cre-ts-sdk root directory +cd "$(dirname "$0")/.." + +# Build workflows +echo "📦 Building workflows..." +bun build:workflows + +# Source WASM file path +SOURCE_WASM="dist/workflows/${WORKFLOW_NAME}/testts.wasm" + +# Check if source file exists +if [ ! -f "$SOURCE_WASM" ]; then + echo "❌ Error: Source WASM file not found: $SOURCE_WASM" + exit 1 +fi + +# Target directory path (chainlink-common is at workspace root) +TARGET_DIR="../chainlink-common/pkg/workflows/wasm/host/standard_tests/${WORKFLOW_NAME}" + +# Copy WASM file to target location +echo "📋 Copying $SOURCE_WASM to $TARGET_DIR/" +cp "$SOURCE_WASM" "$TARGET_DIR/" + +echo "✅ Successfully deployed workflow $WORKFLOW_NAME to chainlink-common standard_tests" \ No newline at end of file diff --git a/scripts/copy-nested-wasm.sh b/scripts/copy-nested-wasm.sh new file mode 100755 index 00000000..2b35385a --- /dev/null +++ b/scripts/copy-nested-wasm.sh @@ -0,0 +1,37 @@ +#!/bin/zsh + +# Deploy workflow script +# Usage: ./scripts/deploy-workflow.sh + +set -e + +# Check if both arguments are provided +if [ $# -lt 2 ]; then + echo "Error: Both directory name and workflow name are required" + echo "Usage: $0 " + exit 1 +fi + +DIR_NAME=$1 +WORKFLOW_NAME=$2 + +# Change to cre-ts-sdk root directory +cd "$(dirname "$0")/.." + +# Source WASM file path +SOURCE_WASM="dist/workflows/standard_tests/${DIR_NAME}/${WORKFLOW_NAME}/testts.wasm" + +# Check if source file exists +if [ ! -f "$SOURCE_WASM" ]; then + echo "❌ Error: Source WASM file not found: $SOURCE_WASM" + exit 1 +fi + +# Target directory path (chainlink-common is at workspace root) +TARGET_DIR="../chainlink-common/pkg/workflows/wasm/host/standard_tests/${DIR_NAME}/${WORKFLOW_NAME}" + +# Copy WASM file to target location +echo "📋 Copying $SOURCE_WASM to $TARGET_DIR/" +cp "$SOURCE_WASM" "$TARGET_DIR/" + +echo "✅ Successfully deployed workflow $WORKFLOW_NAME to chainlink-common standard_tests" \ No newline at end of file diff --git a/scripts/copy-wasm.sh b/scripts/copy-wasm.sh new file mode 100755 index 00000000..fbe65f63 --- /dev/null +++ b/scripts/copy-wasm.sh @@ -0,0 +1,36 @@ +#!/bin/zsh + +# Deploy workflow script +# Usage: ./scripts/copy-wasm.sh + +set -e + +# Check if workflow name is provided +if [ $# -eq 0 ]; then + echo "Error: Workflow name is required" + echo "Usage: $0 " + exit 1 +fi + +WORKFLOW_NAME=$1 + +# Change to cre-ts-sdk root directory +cd "$(dirname "$0")/.." + +# Source WASM file path +SOURCE_WASM="dist/workflows/standard_tests/${WORKFLOW_NAME}/testts.wasm" + +# Check if source file exists +if [ ! -f "$SOURCE_WASM" ]; then + echo "❌ Error: Source WASM file not found: $SOURCE_WASM" + exit 1 +fi + +# Target directory path (chainlink-common is at workspace root) +TARGET_DIR="../chainlink-common/pkg/workflows/wasm/host/standard_tests/${WORKFLOW_NAME}" + +# Copy WASM file to target location +echo "📋 Copying $SOURCE_WASM to $TARGET_DIR/" +cp "$SOURCE_WASM" "$TARGET_DIR/" + +echo "✅ Successfully deployed workflow $WORKFLOW_NAME to chainlink-common standard_tests" \ No newline at end of file diff --git a/scripts/generate-sdks.ts b/scripts/generate-sdks.ts new file mode 100644 index 00000000..f1a7f33d --- /dev/null +++ b/scripts/generate-sdks.ts @@ -0,0 +1,56 @@ +import { generateSdk } from "@cre/generator/generate-sdk"; +import { file_capabilities_internal_basicaction_v1_basic_action } from "@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb"; +import { file_capabilities_internal_basictrigger_v1_basic_trigger } from "@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb"; +import { file_capabilities_blockchain_evm_v1alpha_client } from "@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb"; +import { file_capabilities_internal_nodeaction_v1_node_action } from "@cre/generated/capabilities/internal/nodeaction/v1/node_action_pb"; +import { file_capabilities_internal_consensus_v1alpha_consensus } from "@cre/generated/capabilities/internal/consensus/v1alpha/consensus_pb"; +import { file_capabilities_internal_actionandtrigger_v1_action_and_trigger } from "@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb"; +import { file_capabilities_networking_http_v1alpha_client } from "@cre/generated/capabilities/networking/http/v1alpha/client_pb"; +import { file_capabilities_networking_http_v1alpha_trigger } from "@cre/generated/capabilities/networking/http/v1alpha/trigger_pb"; +import { file_capabilities_scheduler_cron_v1_trigger } from "@cre/generated/capabilities/scheduler/cron/v1/trigger_pb"; + +// Internal Testing SDKs + +generateSdk( + file_capabilities_internal_basicaction_v1_basic_action, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_internal_basictrigger_v1_basic_trigger, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_internal_nodeaction_v1_node_action, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_internal_consensus_v1alpha_consensus, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_internal_actionandtrigger_v1_action_and_trigger, + "./src/generated-sdk" +); + +// Production SDKs + +generateSdk( + file_capabilities_blockchain_evm_v1alpha_client, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_networking_http_v1alpha_client, + "./src/generated-sdk" +); + +generateSdk( + file_capabilities_networking_http_v1alpha_trigger, + "./src/generated-sdk" +); + +generateSdk(file_capabilities_scheduler_cron_v1_trigger, "./src/generated-sdk"); diff --git a/scripts/run.ts b/scripts/run.ts new file mode 100644 index 00000000..35f25e0c --- /dev/null +++ b/scripts/run.ts @@ -0,0 +1,41 @@ +#!/usr/bin/env bun + +const availableScripts = [ + "compile-javy-sdk-plugin", + "compile-javy-with-sdk-plugin", + "compile-to-js", + "compile-to-wasm", + "build-single-workflow-js", + "compile-single-workflow-to-wasm", + "build-single-workflow", +]; + +const main = async () => { + const scriptName = process.argv[2]; + + if (!scriptName) { + console.error("Usage: bun run.ts "); + console.error("Available scripts:"); + availableScripts.forEach((script) => { + console.error(` ${script}`); + }); + process.exit(1); + } + + try { + const scriptPath = `./${scriptName}.ts`; + const script = await import(scriptPath); + + if (typeof script.main === "function") { + await script.main(); + } else { + console.error(`Script ${scriptName} does not export a main function`); + process.exit(1); + } + } catch (error) { + console.error(`Failed to load script ${scriptName}:`, error); + process.exit(1); + } +}; + +main(); diff --git a/src/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.ts b/src/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.ts new file mode 100644 index 00000000..2a07901e --- /dev/null +++ b/src/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.ts @@ -0,0 +1,444 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface"; +import { type Any, AnySchema } from "@bufbuild/protobuf/wkt"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + BalanceAtReplySchema, + BalanceAtRequestSchema, + CallContractReplySchema, + CallContractRequestSchema, + EstimateGasReplySchema, + EstimateGasRequestSchema, + FilterLogTriggerRequestSchema, + FilterLogsReplySchema, + FilterLogsRequestSchema, + GetTransactionByHashReplySchema, + GetTransactionByHashRequestSchema, + GetTransactionReceiptReplySchema, + GetTransactionReceiptRequestSchema, + HeaderByNumberReplySchema, + HeaderByNumberRequestSchema, + LogSchema, + RegisterLogTrackingRequestSchema, + UnregisterLogTrackingRequestSchema, + WriteReportReplySchema, + WriteReportRequestSchema, + type BalanceAtReply, + type BalanceAtRequestJson, + type CallContractReply, + type CallContractRequestJson, + type EstimateGasReply, + type EstimateGasRequestJson, + type FilterLogTriggerRequestJson, + type FilterLogsReply, + type FilterLogsRequestJson, + type GetTransactionByHashReply, + type GetTransactionByHashRequestJson, + type GetTransactionReceiptReply, + type GetTransactionReceiptRequestJson, + type HeaderByNumberReply, + type HeaderByNumberRequestJson, + type Log, + type RegisterLogTrackingRequestJson, + type UnregisterLogTrackingRequestJson, + type WriteReportReply, + type WriteReportRequestJson, +} from "@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb"; +import { + EmptySchema, + type Empty, +} from "@bufbuild/protobuf/wkt"; + +/** + * Client Capability + * + * Capability ID: evm@1.0.0 + * Default Mode: Mode.DON + */ +export class ClientCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "evm@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = ClientCapability.DEFAULT_MODE + ) {} + + async callContract(input: CallContractRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(CallContractRequestSchema), + value: toBinary(CallContractRequestSchema, fromJson(CallContractRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "CallContract", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "CallContract", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "CallContract", + mode: this.mode, + }); + } + + return fromBinary(CallContractReplySchema, capabilityResponse.response.value.value); + }); + } + + async filterLogs(input: FilterLogsRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(FilterLogsRequestSchema), + value: toBinary(FilterLogsRequestSchema, fromJson(FilterLogsRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "FilterLogs", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "FilterLogs", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "FilterLogs", + mode: this.mode, + }); + } + + return fromBinary(FilterLogsReplySchema, capabilityResponse.response.value.value); + }); + } + + async balanceAt(input: BalanceAtRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(BalanceAtRequestSchema), + value: toBinary(BalanceAtRequestSchema, fromJson(BalanceAtRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "BalanceAt", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "BalanceAt", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "BalanceAt", + mode: this.mode, + }); + } + + return fromBinary(BalanceAtReplySchema, capabilityResponse.response.value.value); + }); + } + + async estimateGas(input: EstimateGasRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(EstimateGasRequestSchema), + value: toBinary(EstimateGasRequestSchema, fromJson(EstimateGasRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "EstimateGas", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "EstimateGas", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "EstimateGas", + mode: this.mode, + }); + } + + return fromBinary(EstimateGasReplySchema, capabilityResponse.response.value.value); + }); + } + + async getTransactionByHash(input: GetTransactionByHashRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(GetTransactionByHashRequestSchema), + value: toBinary(GetTransactionByHashRequestSchema, fromJson(GetTransactionByHashRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionByHash", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionByHash", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionByHash", + mode: this.mode, + }); + } + + return fromBinary(GetTransactionByHashReplySchema, capabilityResponse.response.value.value); + }); + } + + async getTransactionReceipt(input: GetTransactionReceiptRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(GetTransactionReceiptRequestSchema), + value: toBinary(GetTransactionReceiptRequestSchema, fromJson(GetTransactionReceiptRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionReceipt", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionReceipt", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "GetTransactionReceipt", + mode: this.mode, + }); + } + + return fromBinary(GetTransactionReceiptReplySchema, capabilityResponse.response.value.value); + }); + } + + async headerByNumber(input: HeaderByNumberRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(HeaderByNumberRequestSchema), + value: toBinary(HeaderByNumberRequestSchema, fromJson(HeaderByNumberRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "HeaderByNumber", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "HeaderByNumber", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "HeaderByNumber", + mode: this.mode, + }); + } + + return fromBinary(HeaderByNumberReplySchema, capabilityResponse.response.value.value); + }); + } + + async registerLogTracking(input: RegisterLogTrackingRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(RegisterLogTrackingRequestSchema), + value: toBinary(RegisterLogTrackingRequestSchema, fromJson(RegisterLogTrackingRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "RegisterLogTracking", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "RegisterLogTracking", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "RegisterLogTracking", + mode: this.mode, + }); + } + + return fromBinary(EmptySchema, capabilityResponse.response.value.value); + }); + } + + async unregisterLogTracking(input: UnregisterLogTrackingRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(UnregisterLogTrackingRequestSchema), + value: toBinary(UnregisterLogTrackingRequestSchema, fromJson(UnregisterLogTrackingRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "UnregisterLogTracking", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "UnregisterLogTracking", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "UnregisterLogTracking", + mode: this.mode, + }); + } + + return fromBinary(EmptySchema, capabilityResponse.response.value.value); + }); + } + + logTrigger(config: FilterLogTriggerRequestJson): ClientLogTrigger { + return new ClientLogTrigger(this.mode, config, ClientCapability.CAPABILITY_ID, "LogTrigger"); + } + + async writeReport(input: WriteReportRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(WriteReportRequestSchema), + value: toBinary(WriteReportRequestSchema, fromJson(WriteReportRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "WriteReport", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "WriteReport", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "WriteReport", + mode: this.mode, + }); + } + + return fromBinary(WriteReportReplySchema, capabilityResponse.response.value.value); + }); + } +} + +/** + * Trigger implementation for LogTrigger + */ +class ClientLogTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: FilterLogTriggerRequestJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): Log { + return create(LogSchema); + } + + outputSchema() { + return LogSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(FilterLogTriggerRequestSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(FilterLogTriggerRequestSchema), + value: toBinary(FilterLogTriggerRequestSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: Log): Log { + return output; + } +} \ No newline at end of file diff --git a/src/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.ts b/src/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.ts new file mode 100644 index 00000000..d9db33f1 --- /dev/null +++ b/src/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.ts @@ -0,0 +1,120 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface"; +import { type Any, AnySchema } from "@bufbuild/protobuf/wkt"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + ConfigSchema, + InputSchema, + OutputSchema, + TriggerEventSchema, + type ConfigJson, + type InputJson, + type Output, + type TriggerEvent, +} from "@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb"; + +/** + * Basic Capability + * + * Capability ID: basic-test-action-trigger@1.0.0 + * Default Mode: Mode.DON + */ +export class BasicCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "basic-test-action-trigger@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = BasicCapability.DEFAULT_MODE + ) {} + + async action(input: InputJson): Promise { + const payload = { + typeUrl: getTypeUrl(InputSchema), + value: toBinary(InputSchema, fromJson(InputSchema, input)), + }; + + return callCapability({ + capabilityId: BasicCapability.CAPABILITY_ID, + method: "Action", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: BasicCapability.CAPABILITY_ID, + method: "Action", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: BasicCapability.CAPABILITY_ID, + method: "Action", + mode: this.mode, + }); + } + + return fromBinary(OutputSchema, capabilityResponse.response.value.value); + }); + } + + trigger(config: ConfigJson): BasicTrigger { + return new BasicTrigger(this.mode, config, BasicCapability.CAPABILITY_ID, "Trigger"); + } +} + +/** + * Trigger implementation for Trigger + */ +class BasicTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: ConfigJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): TriggerEvent { + return create(TriggerEventSchema); + } + + outputSchema() { + return TriggerEventSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(ConfigSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(ConfigSchema), + value: toBinary(ConfigSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: TriggerEvent): TriggerEvent { + return output; + } +} \ No newline at end of file diff --git a/src/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.ts b/src/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.ts new file mode 100644 index 00000000..adea931c --- /dev/null +++ b/src/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.ts @@ -0,0 +1,64 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + InputsSchema, + OutputsSchema, + type InputsJson, + type Outputs, +} from "@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb"; + +/** + * BasicAction Capability + * + * Capability ID: basic-test-action@1.0.0 + * Default Mode: Mode.DON + */ +export class BasicActionCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "basic-test-action@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = BasicActionCapability.DEFAULT_MODE + ) {} + + async performAction(input: InputsJson): Promise { + const payload = { + typeUrl: getTypeUrl(InputsSchema), + value: toBinary(InputsSchema, fromJson(InputsSchema, input)), + }; + + return callCapability({ + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + }); + } + + return fromBinary(OutputsSchema, capabilityResponse.response.value.value); + }); + } +} diff --git a/src/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.ts b/src/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.ts new file mode 100644 index 00000000..a5641b5c --- /dev/null +++ b/src/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.ts @@ -0,0 +1,84 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface"; +import { type Any, AnySchema } from "@bufbuild/protobuf/wkt"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + ConfigSchema, + OutputsSchema, + type ConfigJson, + type Outputs, +} from "@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb"; + +/** + * Basic Capability + * + * Capability ID: basic-test-trigger@1.0.0 + * Default Mode: Mode.DON + */ +export class BasicCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "basic-test-trigger@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = BasicCapability.DEFAULT_MODE + ) {} + + trigger(config: ConfigJson): BasicTrigger { + return new BasicTrigger(this.mode, config, BasicCapability.CAPABILITY_ID, "Trigger"); + } +} + +/** + * Trigger implementation for Trigger + */ +class BasicTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: ConfigJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): Outputs { + return create(OutputsSchema); + } + + outputSchema() { + return OutputsSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(ConfigSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(ConfigSchema), + value: toBinary(ConfigSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: Outputs): Outputs { + return output; + } +} \ No newline at end of file diff --git a/src/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.ts b/src/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.ts new file mode 100644 index 00000000..4dcc0cd8 --- /dev/null +++ b/src/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.ts @@ -0,0 +1,102 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + ReportRequestSchema, + ReportResponseSchema, + SimpleConsensusInputsSchema, + type ReportRequestJson, + type ReportResponse, + type SimpleConsensusInputsJson, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { + ValueSchema, + type Value, +} from "@cre/generated/values/v1/values_pb"; + +/** + * Consensus Capability + * + * Capability ID: consensus@1.0.0-alpha + * Default Mode: Mode.DON + */ +export class ConsensusCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "consensus@1.0.0-alpha"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = ConsensusCapability.DEFAULT_MODE + ) {} + + async simple(input: SimpleConsensusInputsJson): Promise { + const payload = { + typeUrl: getTypeUrl(SimpleConsensusInputsSchema), + value: toBinary(SimpleConsensusInputsSchema, fromJson(SimpleConsensusInputsSchema, input)), + }; + + return callCapability({ + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Simple", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Simple", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Simple", + mode: this.mode, + }); + } + + return fromBinary(ValueSchema, capabilityResponse.response.value.value); + }); + } + + async report(input: ReportRequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(ReportRequestSchema), + value: toBinary(ReportRequestSchema, fromJson(ReportRequestSchema, input)), + }; + + return callCapability({ + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Report", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Report", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ConsensusCapability.CAPABILITY_ID, + method: "Report", + mode: this.mode, + }); + } + + return fromBinary(ReportResponseSchema, capabilityResponse.response.value.value); + }); + } +} diff --git a/src/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.ts b/src/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.ts new file mode 100644 index 00000000..07d81bee --- /dev/null +++ b/src/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.ts @@ -0,0 +1,64 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + NodeInputsSchema, + NodeOutputsSchema, + type NodeInputsJson, + type NodeOutputs, +} from "@cre/generated/capabilities/internal/nodeaction/v1/node_action_pb"; + +/** + * BasicAction Capability + * + * Capability ID: basic-test-node-action@1.0.0 + * Default Mode: Mode.NODE + */ +export class BasicActionCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "basic-test-node-action@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.NODE; + + constructor( + private readonly mode: Mode = BasicActionCapability.DEFAULT_MODE + ) {} + + async performAction(input: NodeInputsJson): Promise { + const payload = { + typeUrl: getTypeUrl(NodeInputsSchema), + value: toBinary(NodeInputsSchema, fromJson(NodeInputsSchema, input)), + }; + + return callCapability({ + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: BasicActionCapability.CAPABILITY_ID, + method: "PerformAction", + mode: this.mode, + }); + } + + return fromBinary(NodeOutputsSchema, capabilityResponse.response.value.value); + }); + } +} diff --git a/src/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.ts b/src/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.ts new file mode 100644 index 00000000..cbfa1d8d --- /dev/null +++ b/src/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.ts @@ -0,0 +1,65 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + RequestSchema, + ResponseSchema, + type RequestJson, + type Response, +} from "@cre/generated/capabilities/networking/http/v1alpha/client_pb"; + +/** + * Client Capability + * + * Capability ID: http-actions@1.0.0-alpha + * Default Mode: Mode.NODE + */ +export class ClientCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "http-actions@1.0.0-alpha"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.NODE; + + constructor(private readonly mode: Mode = ClientCapability.DEFAULT_MODE) {} + + async sendRequest(input: RequestJson): Promise { + const payload = { + typeUrl: getTypeUrl(RequestSchema), + value: toBinary(RequestSchema, fromJson(RequestSchema, input)), + }; + + return callCapability({ + capabilityId: ClientCapability.CAPABILITY_ID, + method: "SendRequest", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "SendRequest", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ClientCapability.CAPABILITY_ID, + method: "SendRequest", + mode: this.mode, + }); + } + + return fromBinary( + ResponseSchema, + capabilityResponse.response.value.value + ); + }); + } +} diff --git a/src/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.ts b/src/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.ts new file mode 100644 index 00000000..ee62eca6 --- /dev/null +++ b/src/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.ts @@ -0,0 +1,84 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface"; +import { type Any, AnySchema } from "@bufbuild/protobuf/wkt"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + ConfigSchema, + PayloadSchema, + type ConfigJson, + type Payload, +} from "@cre/generated/capabilities/networking/http/v1alpha/trigger_pb"; + +/** + * HTTP Capability + * + * Capability ID: http-trigger@1.0.0-alpha + * Default Mode: Mode.DON + */ +export class HTTPCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "http-trigger@1.0.0-alpha"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = HTTPCapability.DEFAULT_MODE + ) {} + + trigger(config: ConfigJson): HTTPTrigger { + return new HTTPTrigger(this.mode, config, HTTPCapability.CAPABILITY_ID, "Trigger"); + } +} + +/** + * Trigger implementation for Trigger + */ +class HTTPTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: ConfigJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): Payload { + return create(PayloadSchema); + } + + outputSchema() { + return PayloadSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(ConfigSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(ConfigSchema), + value: toBinary(ConfigSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: Payload): Payload { + return output; + } +} \ No newline at end of file diff --git a/src/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.ts b/src/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.ts new file mode 100644 index 00000000..52c707d2 --- /dev/null +++ b/src/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.ts @@ -0,0 +1,134 @@ +import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface"; +import { type Any, AnySchema } from "@bufbuild/protobuf/wkt"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { + ConfigSchema, + LegacyPayloadSchema, + PayloadSchema, + type ConfigJson, + type LegacyPayload, + type Payload, +} from "@cre/generated/capabilities/scheduler/cron/v1/trigger_pb"; + +/** + * Cron Capability + * + * Capability ID: cron-trigger@1.0.0 + * Default Mode: Mode.DON + */ +export class CronCapability { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "cron-trigger@1.0.0"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = Mode.DON; + + constructor( + private readonly mode: Mode = CronCapability.DEFAULT_MODE + ) {} + + trigger(config: ConfigJson): CronTrigger { + return new CronTrigger(this.mode, config, CronCapability.CAPABILITY_ID, "Trigger"); + } + + // Method legacyTrigger is mapped to untyped API +} + +/** + * Trigger implementation for Trigger + */ +class CronTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: ConfigJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): Payload { + return create(PayloadSchema); + } + + outputSchema() { + return PayloadSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(ConfigSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(ConfigSchema), + value: toBinary(ConfigSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: Payload): Payload { + return output; + } +} + +/** + * Trigger implementation for LegacyTrigger + */ +class CronLegacyTrigger extends BaseTriggerImpl { + constructor( + mode: Mode, + config: ConfigJson, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): LegacyPayload { + return create(LegacyPayloadSchema); + } + + outputSchema() { + return LegacyPayloadSchema; + } + + configAsAny(): Any { + const configMessage = fromJson(ConfigSchema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(ConfigSchema), + value: toBinary(ConfigSchema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: LegacyPayload): LegacyPayload { + return output; + } +} \ No newline at end of file diff --git a/src/generated/.gitkeep b/src/generated/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/generated/capabilities/blockchain/evm/v1alpha/client_pb.ts b/src/generated/capabilities/blockchain/evm/v1alpha/client_pb.ts new file mode 100644 index 00000000..c2f0aeb8 --- /dev/null +++ b/src/generated/capabilities/blockchain/evm/v1alpha/client_pb.ts @@ -0,0 +1,1767 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/blockchain/evm/v1alpha/client.proto (package capabilities.blockchain.evm.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { EmptySchema } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_empty } from "@bufbuild/protobuf/wkt"; +import type { ReportResponse, ReportResponseJson } from "../../../../sdk/v1alpha/sdk_pb"; +import { file_sdk_v1alpha_sdk } from "../../../../sdk/v1alpha/sdk_pb"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { BigInt, BigIntJson } from "../../../../values/v1/values_pb"; +import { file_values_v1_values } from "../../../../values/v1/values_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/blockchain/evm/v1alpha/client.proto. + */ +export const file_capabilities_blockchain_evm_v1alpha_client: GenFile = /*@__PURE__*/ + fileDesc("CjBjYXBhYmlsaXRpZXMvYmxvY2tjaGFpbi9ldm0vdjFhbHBoYS9jbGllbnQucHJvdG8SI2NhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhIh0KC1RvcGljVmFsdWVzEg4KBnZhbHVlcxgBIAMoDCK4AQoXRmlsdGVyTG9nVHJpZ2dlclJlcXVlc3QSEQoJYWRkcmVzc2VzGAEgAygMEkAKBnRvcGljcxgCIAMoCzIwLmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLlRvcGljVmFsdWVzEkgKCmNvbmZpZGVuY2UYAyABKA4yNC5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5Db25maWRlbmNlTGV2ZWwiegoTQ2FsbENvbnRyYWN0UmVxdWVzdBI6CgRjYWxsGAEgASgLMiwuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuQ2FsbE1zZxInCgxibG9ja19udW1iZXIYAiABKAsyES52YWx1ZXMudjEuQmlnSW50IiEKEUNhbGxDb250cmFjdFJlcGx5EgwKBGRhdGEYASABKAwiWwoRRmlsdGVyTG9nc1JlcXVlc3QSRgoMZmlsdGVyX3F1ZXJ5GAEgASgLMjAuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuRmlsdGVyUXVlcnkiSQoPRmlsdGVyTG9nc1JlcGx5EjYKBGxvZ3MYASADKAsyKC5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5Mb2cixwEKA0xvZxIPCgdhZGRyZXNzGAEgASgMEg4KBnRvcGljcxgCIAMoDBIPCgd0eF9oYXNoGAMgASgMEhIKCmJsb2NrX2hhc2gYBCABKAwSDAoEZGF0YRgFIAEoDBIRCglldmVudF9zaWcYBiABKAwSJwoMYmxvY2tfbnVtYmVyGAcgASgLMhEudmFsdWVzLnYxLkJpZ0ludBIQCgh0eF9pbmRleBgIIAEoDRINCgVpbmRleBgJIAEoDRIPCgdyZW1vdmVkGAogASgIIjEKB0NhbGxNc2cSDAoEZnJvbRgBIAEoDBIKCgJ0bxgCIAEoDBIMCgRkYXRhGAMgASgMIr0BCgtGaWx0ZXJRdWVyeRISCgpibG9ja19oYXNoGAEgASgMEiUKCmZyb21fYmxvY2sYAiABKAsyES52YWx1ZXMudjEuQmlnSW50EiMKCHRvX2Jsb2NrGAMgASgLMhEudmFsdWVzLnYxLkJpZ0ludBIRCglhZGRyZXNzZXMYBCADKAwSOwoGdG9waWNzGAUgAygLMisuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuVG9waWNzIhcKBlRvcGljcxINCgV0b3BpYxgBIAMoDCJMChBCYWxhbmNlQXRSZXF1ZXN0Eg8KB2FjY291bnQYASABKAwSJwoMYmxvY2tfbnVtYmVyGAIgASgLMhEudmFsdWVzLnYxLkJpZ0ludCI0Cg5CYWxhbmNlQXRSZXBseRIiCgdiYWxhbmNlGAEgASgLMhEudmFsdWVzLnYxLkJpZ0ludCJPChJFc3RpbWF0ZUdhc1JlcXVlc3QSOQoDbXNnGAEgASgLMiwuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuQ2FsbE1zZyIjChBFc3RpbWF0ZUdhc1JlcGx5Eg8KA2dhcxgBIAEoBEICMAEiKwobR2V0VHJhbnNhY3Rpb25CeUhhc2hSZXF1ZXN0EgwKBGhhc2gYASABKAwiYgoZR2V0VHJhbnNhY3Rpb25CeUhhc2hSZXBseRJFCgt0cmFuc2FjdGlvbhgBIAEoCzIwLmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLlRyYW5zYWN0aW9uIqEBCgtUcmFuc2FjdGlvbhIRCgVub25jZRgBIAEoBEICMAESDwoDZ2FzGAIgASgEQgIwARIKCgJ0bxgDIAEoDBIMCgRkYXRhGAQgASgMEgwKBGhhc2gYBSABKAwSIAoFdmFsdWUYBiABKAsyES52YWx1ZXMudjEuQmlnSW50EiQKCWdhc19wcmljZRgHIAEoCzIRLnZhbHVlcy52MS5CaWdJbnQiLAocR2V0VHJhbnNhY3Rpb25SZWNlaXB0UmVxdWVzdBIMCgRoYXNoGAEgASgMIlsKGkdldFRyYW5zYWN0aW9uUmVjZWlwdFJlcGx5Ej0KB3JlY2VpcHQYASABKAsyLC5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5SZWNlaXB0IpkCCgdSZWNlaXB0EhIKBnN0YXR1cxgBIAEoBEICMAESFAoIZ2FzX3VzZWQYAiABKARCAjABEhQKCHR4X2luZGV4GAMgASgEQgIwARISCgpibG9ja19oYXNoGAQgASgMEjYKBGxvZ3MYBiADKAsyKC5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5Mb2cSDwoHdHhfaGFzaBgHIAEoDBIuChNlZmZlY3RpdmVfZ2FzX3ByaWNlGAggASgLMhEudmFsdWVzLnYxLkJpZ0ludBInCgxibG9ja19udW1iZXIYCSABKAsyES52YWx1ZXMudjEuQmlnSW50EhgKEGNvbnRyYWN0X2FkZHJlc3MYCiABKAwiQAoVSGVhZGVyQnlOdW1iZXJSZXF1ZXN0EicKDGJsb2NrX251bWJlchgBIAEoCzIRLnZhbHVlcy52MS5CaWdJbnQiUgoTSGVhZGVyQnlOdW1iZXJSZXBseRI7CgZoZWFkZXIYASABKAsyKy5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5IZWFkZXIiawoGSGVhZGVyEhUKCXRpbWVzdGFtcBgBIAEoBEICMAESJwoMYmxvY2tfbnVtYmVyGAIgASgLMhEudmFsdWVzLnYxLkJpZ0ludBIMCgRoYXNoGAMgASgMEhMKC3BhcmVudF9oYXNoGAQgASgMIlsKGlJlZ2lzdGVyTG9nVHJhY2tpbmdSZXF1ZXN0Ej0KBmZpbHRlchgBIAEoCzItLmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkxQRmlsdGVyIsIBCghMUEZpbHRlchIZCg1tYXhfbG9nc19rZXB0GAEgASgEQgIwARIaCg5yZXRlbnRpb25fdGltZRgCIAEoA0ICMAESGgoObG9nc19wZXJfYmxvY2sYAyABKARCAjABEgwKBG5hbWUYBCABKAkSEQoJYWRkcmVzc2VzGAUgAygMEhIKCmV2ZW50X3NpZ3MYBiADKAwSDgoGdG9waWMyGAcgAygMEg4KBnRvcGljMxgIIAMoDBIOCgZ0b3BpYzQYCSADKAwiMwocVW5yZWdpc3RlckxvZ1RyYWNraW5nUmVxdWVzdBITCgtmaWx0ZXJfbmFtZRgBIAEoCSKrAQoSV3JpdGVSZXBvcnRSZXF1ZXN0EhAKCHJlY2VpdmVyGAEgASgMEisKBnJlcG9ydBgCIAEoCzIbLnNkay52MWFscGhhLlJlcG9ydFJlc3BvbnNlEkcKCmdhc19jb25maWcYAyABKAsyLi5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5HYXNDb25maWdIAIgBAUINCgtfZ2FzX2NvbmZpZyIiCglHYXNDb25maWcSFQoJZ2FzX2xpbWl0GAEgASgEQgIwASKHAwoQV3JpdGVSZXBvcnRSZXBseRJACgl0eF9zdGF0dXMYASABKA4yLS5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5UeFN0YXR1cxJ1CiJyZWNlaXZlcl9jb250cmFjdF9leGVjdXRpb25fc3RhdHVzGAIgASgOMkQuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuUmVjZWl2ZXJDb250cmFjdEV4ZWN1dGlvblN0YXR1c0gAiAEBEhQKB3R4X2hhc2gYAyABKAxIAYgBARIvCg90cmFuc2FjdGlvbl9mZWUYBCABKAsyES52YWx1ZXMudjEuQmlnSW50SAKIAQESGgoNZXJyb3JfbWVzc2FnZRgFIAEoCUgDiAEBQiUKI19yZWNlaXZlcl9jb250cmFjdF9leGVjdXRpb25fc3RhdHVzQgoKCF90eF9oYXNoQhIKEF90cmFuc2FjdGlvbl9mZWVCEAoOX2Vycm9yX21lc3NhZ2UqaQoPQ29uZmlkZW5jZUxldmVsEhkKFUNPTkZJREVOQ0VfTEVWRUxfU0FGRRAAEhsKF0NPTkZJREVOQ0VfTEVWRUxfTEFURVNUEAESHgoaQ09ORklERU5DRV9MRVZFTF9GSU5BTElaRUQQAiqCAQofUmVjZWl2ZXJDb250cmFjdEV4ZWN1dGlvblN0YXR1cxIuCipSRUNFSVZFUl9DT05UUkFDVF9FWEVDVVRJT05fU1RBVFVTX1NVQ0NFU1MQABIvCitSRUNFSVZFUl9DT05UUkFDVF9FWEVDVVRJT05fU1RBVFVTX1JFVkVSVEVEEAEqTgoIVHhTdGF0dXMSEwoPVFhfU1RBVFVTX0ZBVEFMEAASFgoSVFhfU1RBVFVTX1JFVkVSVEVEEAESFQoRVFhfU1RBVFVTX1NVQ0NFU1MQAjLXDwoGQ2xpZW50EoABCgxDYWxsQ29udHJhY3QSOC5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5DYWxsQ29udHJhY3RSZXF1ZXN0GjYuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuQ2FsbENvbnRyYWN0UmVwbHkSegoKRmlsdGVyTG9ncxI2LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkZpbHRlckxvZ3NSZXF1ZXN0GjQuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuRmlsdGVyTG9nc1JlcGx5EncKCUJhbGFuY2VBdBI1LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkJhbGFuY2VBdFJlcXVlc3QaMy5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5CYWxhbmNlQXRSZXBseRJ9CgtFc3RpbWF0ZUdhcxI3LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkVzdGltYXRlR2FzUmVxdWVzdBo1LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkVzdGltYXRlR2FzUmVwbHkSmAEKFEdldFRyYW5zYWN0aW9uQnlIYXNoEkAuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuR2V0VHJhbnNhY3Rpb25CeUhhc2hSZXF1ZXN0Gj4uY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuR2V0VHJhbnNhY3Rpb25CeUhhc2hSZXBseRKbAQoVR2V0VHJhbnNhY3Rpb25SZWNlaXB0EkEuY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuR2V0VHJhbnNhY3Rpb25SZWNlaXB0UmVxdWVzdBo/LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkdldFRyYW5zYWN0aW9uUmVjZWlwdFJlcGx5EoYBCg5IZWFkZXJCeU51bWJlchI6LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkhlYWRlckJ5TnVtYmVyUmVxdWVzdBo4LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkhlYWRlckJ5TnVtYmVyUmVwbHkSbgoTUmVnaXN0ZXJMb2dUcmFja2luZxI/LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLlJlZ2lzdGVyTG9nVHJhY2tpbmdSZXF1ZXN0GhYuZ29vZ2xlLnByb3RvYnVmLkVtcHR5EnIKFVVucmVnaXN0ZXJMb2dUcmFja2luZxJBLmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLlVucmVnaXN0ZXJMb2dUcmFja2luZ1JlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkSdgoKTG9nVHJpZ2dlchI8LmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhLkZpbHRlckxvZ1RyaWdnZXJSZXF1ZXN0GiguY2FwYWJpbGl0aWVzLmJsb2NrY2hhaW4uZXZtLnYxYWxwaGEuTG9nMAESfQoLV3JpdGVSZXBvcnQSNy5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5Xcml0ZVJlcG9ydFJlcXVlc3QaNS5jYXBhYmlsaXRpZXMuYmxvY2tjaGFpbi5ldm0udjFhbHBoYS5Xcml0ZVJlcG9ydFJlcGx5GrgEgrUYswQIARIJZXZtQDEuMC4wGqMECg1DaGFpblNlbGVjdG9yEpEEEo4ECh0KEWF2YWxhbmNoZS1tYWlubmV0ENXnisDh1ZikWQojChZhdmFsYW5jaGUtdGVzdG5ldC1mdWppEJv5/JCi46j4zAEKLwojYmluYW5jZV9zbWFydF9jaGFpbi1tYWlubmV0LW9wYm5iLTEQia2P75PG17sGCjAKI2JpbmFuY2Vfc21hcnRfY2hhaW4tdGVzdG5ldC1vcGJuYi0xEI71hZHBg4+cuAEKHAoQZXRoZXJldW0tbWFpbm5ldBCV9vHkz7KmwkUKJwobZXRoZXJldW0tbWFpbm5ldC1hcmJpdHJ1bS0xEMTojc2Om6HXRAonChtldGhlcmV1bS1tYWlubmV0LW9wdGltaXNtLTEQuJWPw/f+0OkzCiUKGGV0aGVyZXVtLXRlc3RuZXQtc2Vwb2xpYRDZteTO/MnuoN4BCi8KI2V0aGVyZXVtLXRlc3RuZXQtc2Vwb2xpYS1hcmJpdHJ1bS0xEOrO7v/qtoSjMAosCh9ldGhlcmV1bS10ZXN0bmV0LXNlcG9saWEtYmFzZS0xELjKue/2kK7IjwEKLwojZXRoZXJldW0tdGVzdG5ldC1zZXBvbGlhLW9wdGltaXNtLTEQn4bFob7Yw8BIChsKD3BvbHlnb24tbWFpbm5ldBCxq+TwmpKGnTgKIQoUcG9seWdvbi10ZXN0bmV0LWFtb3kQzY/W3/HHkPrhAULlAQonY29tLmNhcGFiaWxpdGllcy5ibG9ja2NoYWluLmV2bS52MWFscGhhQgtDbGllbnRQcm90b1ABogIDQ0JFqgIjQ2FwYWJpbGl0aWVzLkJsb2NrY2hhaW4uRXZtLlYxYWxwaGHKAiNDYXBhYmlsaXRpZXNcQmxvY2tjaGFpblxFdm1cVjFhbHBoYeICL0NhcGFiaWxpdGllc1xCbG9ja2NoYWluXEV2bVxWMWFscGhhXEdQQk1ldGFkYXRh6gImQ2FwYWJpbGl0aWVzOjpCbG9ja2NoYWluOjpFdm06OlYxYWxwaGFiBnByb3RvMw", [file_google_protobuf_empty, file_sdk_v1alpha_sdk, file_tools_generator_v1alpha_cre_metadata, file_values_v1_values]); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.TopicValues + */ +export type TopicValues = Message<"capabilities.blockchain.evm.v1alpha.TopicValues"> & { + /** + * list of possible values for any topic, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes values = 1; + */ + values: Uint8Array[]; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.TopicValues + */ +export type TopicValuesJson = { + /** + * list of possible values for any topic, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes values = 1; + */ + values?: string[]; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.TopicValues. + * Use `create(TopicValuesSchema)` to create a new message. + */ +export const TopicValuesSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 0); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogTriggerRequest + */ +export type FilterLogTriggerRequest = Message<"capabilities.blockchain.evm.v1alpha.FilterLogTriggerRequest"> & { + /** + * list of addresses to include in evm address [20]byte fix-sized array format, at least one address is required + * + * @generated from field: repeated bytes addresses = 1; + */ + addresses: Uint8Array[]; + + /** + * + * TopicValues is a fixed 4 length array of possible values for any topic where: + * a) the first element is an array of the event signatures (keccak256 of the event name and indexed args types), it has to have at least one value + * b) the second element is an array of possible values for the first indexed argument, can be empty + * c) the third element is an array of possible values for the second indexed argument, can be empty + * d) the fourth element is an array of possible values for the third indexed argument, can be empty + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.TopicValues topics = 2; + */ + topics: TopicValues[]; + + /** + * optional, defaults to "SAFE" + * + * @generated from field: capabilities.blockchain.evm.v1alpha.ConfidenceLevel confidence = 3; + */ + confidence: ConfidenceLevel; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogTriggerRequest + */ +export type FilterLogTriggerRequestJson = { + /** + * list of addresses to include in evm address [20]byte fix-sized array format, at least one address is required + * + * @generated from field: repeated bytes addresses = 1; + */ + addresses?: string[]; + + /** + * + * TopicValues is a fixed 4 length array of possible values for any topic where: + * a) the first element is an array of the event signatures (keccak256 of the event name and indexed args types), it has to have at least one value + * b) the second element is an array of possible values for the first indexed argument, can be empty + * c) the third element is an array of possible values for the second indexed argument, can be empty + * d) the fourth element is an array of possible values for the third indexed argument, can be empty + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.TopicValues topics = 2; + */ + topics?: TopicValuesJson[]; + + /** + * optional, defaults to "SAFE" + * + * @generated from field: capabilities.blockchain.evm.v1alpha.ConfidenceLevel confidence = 3; + */ + confidence?: ConfidenceLevelJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.FilterLogTriggerRequest. + * Use `create(FilterLogTriggerRequestSchema)` to create a new message. + */ +export const FilterLogTriggerRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 1); + +/** + * CallContractRequest has arguments for reading a contract as specified in the call message at a block height defined by blockNumber where: + * blockNumber : + * nil (default) or (-2) → use the latest mined block (“latest”) + * FinalizedBlockNumber(-3) → last finalized block (“finalized”) + * + * Any positive value is treated as an explicit block height. + * + * @generated from message capabilities.blockchain.evm.v1alpha.CallContractRequest + */ +export type CallContractRequest = Message<"capabilities.blockchain.evm.v1alpha.CallContractRequest"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.CallMsg call = 1; + */ + call?: CallMsg; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigInt; +}; + +/** + * CallContractRequest has arguments for reading a contract as specified in the call message at a block height defined by blockNumber where: + * blockNumber : + * nil (default) or (-2) → use the latest mined block (“latest”) + * FinalizedBlockNumber(-3) → last finalized block (“finalized”) + * + * Any positive value is treated as an explicit block height. + * + * @generated from message capabilities.blockchain.evm.v1alpha.CallContractRequest + */ +export type CallContractRequestJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.CallMsg call = 1; + */ + call?: CallMsgJson; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigIntJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.CallContractRequest. + * Use `create(CallContractRequestSchema)` to create a new message. + */ +export const CallContractRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 2); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.CallContractReply + */ +export type CallContractReply = Message<"capabilities.blockchain.evm.v1alpha.CallContractReply"> & { + /** + * solidity-spec abi encoded bytes + * + * @generated from field: bytes data = 1; + */ + data: Uint8Array; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.CallContractReply + */ +export type CallContractReplyJson = { + /** + * solidity-spec abi encoded bytes + * + * @generated from field: bytes data = 1; + */ + data?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.CallContractReply. + * Use `create(CallContractReplySchema)` to create a new message. + */ +export const CallContractReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 3); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogsRequest + */ +export type FilterLogsRequest = Message<"capabilities.blockchain.evm.v1alpha.FilterLogsRequest"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.FilterQuery filter_query = 1; + */ + filterQuery?: FilterQuery; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogsRequest + */ +export type FilterLogsRequestJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.FilterQuery filter_query = 1; + */ + filterQuery?: FilterQueryJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.FilterLogsRequest. + * Use `create(FilterLogsRequestSchema)` to create a new message. + */ +export const FilterLogsRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 4); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogsReply + */ +export type FilterLogsReply = Message<"capabilities.blockchain.evm.v1alpha.FilterLogsReply"> & { + /** + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Log logs = 1; + */ + logs: Log[]; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.FilterLogsReply + */ +export type FilterLogsReplyJson = { + /** + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Log logs = 1; + */ + logs?: LogJson[]; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.FilterLogsReply. + * Use `create(FilterLogsReplySchema)` to create a new message. + */ +export const FilterLogsReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 5); + +/** + * represents evm-style log + * + * @generated from message capabilities.blockchain.evm.v1alpha.Log + */ +export type Log = Message<"capabilities.blockchain.evm.v1alpha.Log"> & { + /** + * address of the contract emitted the log in evm address [20]byte fix-sized array format + * + * @generated from field: bytes address = 1; + */ + address: Uint8Array; + + /** + * indexed log fields, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topics = 2; + */ + topics: Uint8Array[]; + + /** + * hash of the transaction containing the log, in [32]byte fix-sized array format + * + * @generated from field: bytes tx_hash = 3; + */ + txHash: Uint8Array; + + /** + * hash of the block containing the log, in [32]byte fix-sized array format + * + * @generated from field: bytes block_hash = 4; + */ + blockHash: Uint8Array; + + /** + * solidity-spec abi encoded log Data + * + * @generated from field: bytes data = 5; + */ + data: Uint8Array; + + /** + * keccak256 of event signature, in [32]byte fix-sized array format + * + * @generated from field: bytes event_sig = 6; + */ + eventSig: Uint8Array; + + /** + * block number containing the log + * + * @generated from field: values.v1.BigInt block_number = 7; + */ + blockNumber?: BigInt; + + /** + * index of transaction emmited the log + * + * @generated from field: uint32 tx_index = 8; + */ + txIndex: number; + + /** + * index of the Log within the intire block + * + * @generated from field: uint32 index = 9; + */ + index: number; + + /** + * flag if the log was removed during reorg + * + * @generated from field: bool removed = 10; + */ + removed: boolean; +}; + +/** + * represents evm-style log + * + * @generated from message capabilities.blockchain.evm.v1alpha.Log + */ +export type LogJson = { + /** + * address of the contract emitted the log in evm address [20]byte fix-sized array format + * + * @generated from field: bytes address = 1; + */ + address?: string; + + /** + * indexed log fields, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topics = 2; + */ + topics?: string[]; + + /** + * hash of the transaction containing the log, in [32]byte fix-sized array format + * + * @generated from field: bytes tx_hash = 3; + */ + txHash?: string; + + /** + * hash of the block containing the log, in [32]byte fix-sized array format + * + * @generated from field: bytes block_hash = 4; + */ + blockHash?: string; + + /** + * solidity-spec abi encoded log Data + * + * @generated from field: bytes data = 5; + */ + data?: string; + + /** + * keccak256 of event signature, in [32]byte fix-sized array format + * + * @generated from field: bytes event_sig = 6; + */ + eventSig?: string; + + /** + * block number containing the log + * + * @generated from field: values.v1.BigInt block_number = 7; + */ + blockNumber?: BigIntJson; + + /** + * index of transaction emmited the log + * + * @generated from field: uint32 tx_index = 8; + */ + txIndex?: number; + + /** + * index of the Log within the intire block + * + * @generated from field: uint32 index = 9; + */ + index?: number; + + /** + * flag if the log was removed during reorg + * + * @generated from field: bool removed = 10; + */ + removed?: boolean; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.Log. + * Use `create(LogSchema)` to create a new message. + */ +export const LogSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 6); + +/** + * represents simplified evm-style CallMsg + * + * @generated from message capabilities.blockchain.evm.v1alpha.CallMsg + */ +export type CallMsg = Message<"capabilities.blockchain.evm.v1alpha.CallMsg"> & { + /** + * sender address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes from = 1; + */ + from: Uint8Array; + + /** + * contract address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes to = 2; + */ + to: Uint8Array; + + /** + * solidity-spec abi encoded bytes + * + * @generated from field: bytes data = 3; + */ + data: Uint8Array; +}; + +/** + * represents simplified evm-style CallMsg + * + * @generated from message capabilities.blockchain.evm.v1alpha.CallMsg + */ +export type CallMsgJson = { + /** + * sender address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes from = 1; + */ + from?: string; + + /** + * contract address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes to = 2; + */ + to?: string; + + /** + * solidity-spec abi encoded bytes + * + * @generated from field: bytes data = 3; + */ + data?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.CallMsg. + * Use `create(CallMsgSchema)` to create a new message. + */ +export const CallMsgSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 7); + +/** + * represents evm-style filter query + * + * @generated from message capabilities.blockchain.evm.v1alpha.FilterQuery + */ +export type FilterQuery = Message<"capabilities.blockchain.evm.v1alpha.FilterQuery"> & { + /** + * exact block (cant use from/to), in [32]byte fix-sized array format + * + * @generated from field: bytes block_hash = 1; + */ + blockHash: Uint8Array; + + /** + * start block range + * + * @generated from field: values.v1.BigInt from_block = 2; + */ + fromBlock?: BigInt; + + /** + * end block range + * + * @generated from field: values.v1.BigInt to_block = 3; + */ + toBlock?: BigInt; + + /** + * contract(s) to filter logs from in evm address [20]byte fix-sized array format + * + * @generated from field: repeated bytes addresses = 4; + */ + addresses: Uint8Array[]; + + /** + * filter log by event signature and indexed args + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Topics topics = 5; + */ + topics: Topics[]; +}; + +/** + * represents evm-style filter query + * + * @generated from message capabilities.blockchain.evm.v1alpha.FilterQuery + */ +export type FilterQueryJson = { + /** + * exact block (cant use from/to), in [32]byte fix-sized array format + * + * @generated from field: bytes block_hash = 1; + */ + blockHash?: string; + + /** + * start block range + * + * @generated from field: values.v1.BigInt from_block = 2; + */ + fromBlock?: BigIntJson; + + /** + * end block range + * + * @generated from field: values.v1.BigInt to_block = 3; + */ + toBlock?: BigIntJson; + + /** + * contract(s) to filter logs from in evm address [20]byte fix-sized array format + * + * @generated from field: repeated bytes addresses = 4; + */ + addresses?: string[]; + + /** + * filter log by event signature and indexed args + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Topics topics = 5; + */ + topics?: TopicsJson[]; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.FilterQuery. + * Use `create(FilterQuerySchema)` to create a new message. + */ +export const FilterQuerySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 8); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.Topics + */ +export type Topics = Message<"capabilities.blockchain.evm.v1alpha.Topics"> & { + /** + * in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic = 1; + */ + topic: Uint8Array[]; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.Topics + */ +export type TopicsJson = { + /** + * in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic = 1; + */ + topic?: string[]; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.Topics. + * Use `create(TopicsSchema)` to create a new message. + */ +export const TopicsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 9); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.BalanceAtRequest + */ +export type BalanceAtRequest = Message<"capabilities.blockchain.evm.v1alpha.BalanceAtRequest"> & { + /** + * in evm address [20]byte fix-sized array format + * + * @generated from field: bytes account = 1; + */ + account: Uint8Array; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigInt; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.BalanceAtRequest + */ +export type BalanceAtRequestJson = { + /** + * in evm address [20]byte fix-sized array format + * + * @generated from field: bytes account = 1; + */ + account?: string; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigIntJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.BalanceAtRequest. + * Use `create(BalanceAtRequestSchema)` to create a new message. + */ +export const BalanceAtRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 10); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.BalanceAtReply + */ +export type BalanceAtReply = Message<"capabilities.blockchain.evm.v1alpha.BalanceAtReply"> & { + /** + * Balance of the account in wei (10^-18 eth) + * + * @generated from field: values.v1.BigInt balance = 1; + */ + balance?: BigInt; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.BalanceAtReply + */ +export type BalanceAtReplyJson = { + /** + * Balance of the account in wei (10^-18 eth) + * + * @generated from field: values.v1.BigInt balance = 1; + */ + balance?: BigIntJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.BalanceAtReply. + * Use `create(BalanceAtReplySchema)` to create a new message. + */ +export const BalanceAtReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 11); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.EstimateGasRequest + */ +export type EstimateGasRequest = Message<"capabilities.blockchain.evm.v1alpha.EstimateGasRequest"> & { + /** + * simulates tx execution returns approximate amount of gas units needed + * + * @generated from field: capabilities.blockchain.evm.v1alpha.CallMsg msg = 1; + */ + msg?: CallMsg; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.EstimateGasRequest + */ +export type EstimateGasRequestJson = { + /** + * simulates tx execution returns approximate amount of gas units needed + * + * @generated from field: capabilities.blockchain.evm.v1alpha.CallMsg msg = 1; + */ + msg?: CallMsgJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.EstimateGasRequest. + * Use `create(EstimateGasRequestSchema)` to create a new message. + */ +export const EstimateGasRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 12); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.EstimateGasReply + */ +export type EstimateGasReply = Message<"capabilities.blockchain.evm.v1alpha.EstimateGasReply"> & { + /** + * estimated amount of gas in gas units, needed for tx execution + * + * @generated from field: uint64 gas = 1 [jstype = JS_STRING]; + */ + gas: string; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.EstimateGasReply + */ +export type EstimateGasReplyJson = { + /** + * estimated amount of gas in gas units, needed for tx execution + * + * @generated from field: uint64 gas = 1 [jstype = JS_STRING]; + */ + gas?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.EstimateGasReply. + * Use `create(EstimateGasReplySchema)` to create a new message. + */ +export const EstimateGasReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 13); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionByHashRequest + */ +export type GetTransactionByHashRequest = Message<"capabilities.blockchain.evm.v1alpha.GetTransactionByHashRequest"> & { + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 1; + */ + hash: Uint8Array; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionByHashRequest + */ +export type GetTransactionByHashRequestJson = { + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 1; + */ + hash?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.GetTransactionByHashRequest. + * Use `create(GetTransactionByHashRequestSchema)` to create a new message. + */ +export const GetTransactionByHashRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 14); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionByHashReply + */ +export type GetTransactionByHashReply = Message<"capabilities.blockchain.evm.v1alpha.GetTransactionByHashReply"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Transaction transaction = 1; + */ + transaction?: Transaction; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionByHashReply + */ +export type GetTransactionByHashReplyJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Transaction transaction = 1; + */ + transaction?: TransactionJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.GetTransactionByHashReply. + * Use `create(GetTransactionByHashReplySchema)` to create a new message. + */ +export const GetTransactionByHashReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 15); + +/** + * represents evm-style transaction + * + * @generated from message capabilities.blockchain.evm.v1alpha.Transaction + */ +export type Transaction = Message<"capabilities.blockchain.evm.v1alpha.Transaction"> & { + /** + * number of txs sent from sender + * + * @generated from field: uint64 nonce = 1 [jstype = JS_STRING]; + */ + nonce: string; + + /** + * max gas allowed per execution (in gas units) + * + * @generated from field: uint64 gas = 2 [jstype = JS_STRING]; + */ + gas: string; + + /** + * recipient address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes to = 3; + */ + to: Uint8Array; + + /** + * solidity-spec abi encoded input data for function call payload + * + * @generated from field: bytes data = 4; + */ + data: Uint8Array; + + /** + * transaction hash, in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 5; + */ + hash: Uint8Array; + + /** + * amount of eth sent in wei + * + * @generated from field: values.v1.BigInt value = 6; + */ + value?: BigInt; + + /** + * price for a single gas unit in wei + * + * @generated from field: values.v1.BigInt gas_price = 7; + */ + gasPrice?: BigInt; +}; + +/** + * represents evm-style transaction + * + * @generated from message capabilities.blockchain.evm.v1alpha.Transaction + */ +export type TransactionJson = { + /** + * number of txs sent from sender + * + * @generated from field: uint64 nonce = 1 [jstype = JS_STRING]; + */ + nonce?: string; + + /** + * max gas allowed per execution (in gas units) + * + * @generated from field: uint64 gas = 2 [jstype = JS_STRING]; + */ + gas?: string; + + /** + * recipient address in evm address [20]byte fix-sized array format + * + * @generated from field: bytes to = 3; + */ + to?: string; + + /** + * solidity-spec abi encoded input data for function call payload + * + * @generated from field: bytes data = 4; + */ + data?: string; + + /** + * transaction hash, in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 5; + */ + hash?: string; + + /** + * amount of eth sent in wei + * + * @generated from field: values.v1.BigInt value = 6; + */ + value?: BigIntJson; + + /** + * price for a single gas unit in wei + * + * @generated from field: values.v1.BigInt gas_price = 7; + */ + gasPrice?: BigIntJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.Transaction. + * Use `create(TransactionSchema)` to create a new message. + */ +export const TransactionSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 16); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptRequest + */ +export type GetTransactionReceiptRequest = Message<"capabilities.blockchain.evm.v1alpha.GetTransactionReceiptRequest"> & { + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 1; + */ + hash: Uint8Array; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptRequest + */ +export type GetTransactionReceiptRequestJson = { + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 1; + */ + hash?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptRequest. + * Use `create(GetTransactionReceiptRequestSchema)` to create a new message. + */ +export const GetTransactionReceiptRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 17); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptReply + */ +export type GetTransactionReceiptReply = Message<"capabilities.blockchain.evm.v1alpha.GetTransactionReceiptReply"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Receipt receipt = 1; + */ + receipt?: Receipt; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptReply + */ +export type GetTransactionReceiptReplyJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Receipt receipt = 1; + */ + receipt?: ReceiptJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.GetTransactionReceiptReply. + * Use `create(GetTransactionReceiptReplySchema)` to create a new message. + */ +export const GetTransactionReceiptReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 18); + +/** + * represents evm-style receipt + * + * @generated from message capabilities.blockchain.evm.v1alpha.Receipt + */ +export type Receipt = Message<"capabilities.blockchain.evm.v1alpha.Receipt"> & { + /** + * 1 for success 0 for failure + * + * @generated from field: uint64 status = 1 [jstype = JS_STRING]; + */ + status: string; + + /** + * gas used by this transaction (in gas units) + * + * @generated from field: uint64 gas_used = 2 [jstype = JS_STRING]; + */ + gasUsed: string; + + /** + * index of the transaction inside of the block + * + * @generated from field: uint64 tx_index = 3 [jstype = JS_STRING]; + */ + txIndex: string; + + /** + * block hash containing the transaction + * + * @generated from field: bytes block_hash = 4; + */ + blockHash: Uint8Array; + + /** + * logs emitted by this transaction + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Log logs = 6; + */ + logs: Log[]; + + /** + * hash of the transaction this receipt is for, in [32]byte fix-sized array format + * + * @generated from field: bytes tx_hash = 7; + */ + txHash: Uint8Array; + + /** + * actual gas price paid in wei (include after EIP-1559) + * + * @generated from field: values.v1.BigInt effective_gas_price = 8; + */ + effectiveGasPrice?: BigInt; + + /** + * block number containing the transaction + * + * @generated from field: values.v1.BigInt block_number = 9; + */ + blockNumber?: BigInt; + + /** + * address of the contract if this transaction created one in evm address [20]byte fix-sized array format + * + * @generated from field: bytes contract_address = 10; + */ + contractAddress: Uint8Array; +}; + +/** + * represents evm-style receipt + * + * @generated from message capabilities.blockchain.evm.v1alpha.Receipt + */ +export type ReceiptJson = { + /** + * 1 for success 0 for failure + * + * @generated from field: uint64 status = 1 [jstype = JS_STRING]; + */ + status?: string; + + /** + * gas used by this transaction (in gas units) + * + * @generated from field: uint64 gas_used = 2 [jstype = JS_STRING]; + */ + gasUsed?: string; + + /** + * index of the transaction inside of the block + * + * @generated from field: uint64 tx_index = 3 [jstype = JS_STRING]; + */ + txIndex?: string; + + /** + * block hash containing the transaction + * + * @generated from field: bytes block_hash = 4; + */ + blockHash?: string; + + /** + * logs emitted by this transaction + * + * @generated from field: repeated capabilities.blockchain.evm.v1alpha.Log logs = 6; + */ + logs?: LogJson[]; + + /** + * hash of the transaction this receipt is for, in [32]byte fix-sized array format + * + * @generated from field: bytes tx_hash = 7; + */ + txHash?: string; + + /** + * actual gas price paid in wei (include after EIP-1559) + * + * @generated from field: values.v1.BigInt effective_gas_price = 8; + */ + effectiveGasPrice?: BigIntJson; + + /** + * block number containing the transaction + * + * @generated from field: values.v1.BigInt block_number = 9; + */ + blockNumber?: BigIntJson; + + /** + * address of the contract if this transaction created one in evm address [20]byte fix-sized array format + * + * @generated from field: bytes contract_address = 10; + */ + contractAddress?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.Receipt. + * Use `create(ReceiptSchema)` to create a new message. + */ +export const ReceiptSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 19); + +/** + * ----- Request/Reply Wrappers ----- + * + * @generated from message capabilities.blockchain.evm.v1alpha.HeaderByNumberRequest + */ +export type HeaderByNumberRequest = Message<"capabilities.blockchain.evm.v1alpha.HeaderByNumberRequest"> & { + /** + * @generated from field: values.v1.BigInt block_number = 1; + */ + blockNumber?: BigInt; +}; + +/** + * ----- Request/Reply Wrappers ----- + * + * @generated from message capabilities.blockchain.evm.v1alpha.HeaderByNumberRequest + */ +export type HeaderByNumberRequestJson = { + /** + * @generated from field: values.v1.BigInt block_number = 1; + */ + blockNumber?: BigIntJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.HeaderByNumberRequest. + * Use `create(HeaderByNumberRequestSchema)` to create a new message. + */ +export const HeaderByNumberRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 20); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.HeaderByNumberReply + */ +export type HeaderByNumberReply = Message<"capabilities.blockchain.evm.v1alpha.HeaderByNumberReply"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Header header = 1; + */ + header?: Header; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.HeaderByNumberReply + */ +export type HeaderByNumberReplyJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.Header header = 1; + */ + header?: HeaderJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.HeaderByNumberReply. + * Use `create(HeaderByNumberReplySchema)` to create a new message. + */ +export const HeaderByNumberReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 21); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.Header + */ +export type Header = Message<"capabilities.blockchain.evm.v1alpha.Header"> & { + /** + * unix timestamp + * + * @generated from field: uint64 timestamp = 1 [jstype = JS_STRING]; + */ + timestamp: string; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigInt; + + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 3; + */ + hash: Uint8Array; + + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes parent_hash = 4; + */ + parentHash: Uint8Array; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.Header + */ +export type HeaderJson = { + /** + * unix timestamp + * + * @generated from field: uint64 timestamp = 1 [jstype = JS_STRING]; + */ + timestamp?: string; + + /** + * @generated from field: values.v1.BigInt block_number = 2; + */ + blockNumber?: BigIntJson; + + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes hash = 3; + */ + hash?: string; + + /** + * in [32]byte fix-sized array format + * + * @generated from field: bytes parent_hash = 4; + */ + parentHash?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.Header. + * Use `create(HeaderSchema)` to create a new message. + */ +export const HeaderSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 22); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.RegisterLogTrackingRequest + */ +export type RegisterLogTrackingRequest = Message<"capabilities.blockchain.evm.v1alpha.RegisterLogTrackingRequest"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.LPFilter filter = 1; + */ + filter?: LPFilter; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.RegisterLogTrackingRequest + */ +export type RegisterLogTrackingRequestJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.LPFilter filter = 1; + */ + filter?: LPFilterJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.RegisterLogTrackingRequest. + * Use `create(RegisterLogTrackingRequestSchema)` to create a new message. + */ +export const RegisterLogTrackingRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 23); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.LPFilter + */ +export type LPFilter = Message<"capabilities.blockchain.evm.v1alpha.LPFilter"> & { + /** + * maximum number of logs to retain ( 0 = unlimited ) + * + * @generated from field: uint64 max_logs_kept = 1 [jstype = JS_STRING]; + */ + maxLogsKept: string; + + /** + * maximum amount of time to retain logs in seconds + * + * @generated from field: int64 retention_time = 2 [jstype = JS_STRING]; + */ + retentionTime: string; + + /** + * rate limit ( maximum # of logs per block, 0 = unlimited ) + * + * @generated from field: uint64 logs_per_block = 3 [jstype = JS_STRING]; + */ + logsPerBlock: string; + + /** + * filter name, has to persist for removing filter + * + * @generated from field: string name = 4; + */ + name: string; + + /** + * list of addresses to include in evm address [20]byte fix-sized array format + * + * @generated from field: repeated bytes addresses = 5; + */ + addresses: Uint8Array[]; + + /** + * list of possible signatures (aka topic1), in [32]byte fix-sized array format + * + * @generated from field: repeated bytes event_sigs = 6; + */ + eventSigs: Uint8Array[]; + + /** + * list of possible values for topic2, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic2 = 7; + */ + topic2: Uint8Array[]; + + /** + * list of possible values for topic3, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic3 = 8; + */ + topic3: Uint8Array[]; + + /** + * list of possible values for topic4, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic4 = 9; + */ + topic4: Uint8Array[]; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.LPFilter + */ +export type LPFilterJson = { + /** + * maximum number of logs to retain ( 0 = unlimited ) + * + * @generated from field: uint64 max_logs_kept = 1 [jstype = JS_STRING]; + */ + maxLogsKept?: string; + + /** + * maximum amount of time to retain logs in seconds + * + * @generated from field: int64 retention_time = 2 [jstype = JS_STRING]; + */ + retentionTime?: string; + + /** + * rate limit ( maximum # of logs per block, 0 = unlimited ) + * + * @generated from field: uint64 logs_per_block = 3 [jstype = JS_STRING]; + */ + logsPerBlock?: string; + + /** + * filter name, has to persist for removing filter + * + * @generated from field: string name = 4; + */ + name?: string; + + /** + * list of addresses to include in evm address [20]byte fix-sized array format + * + * @generated from field: repeated bytes addresses = 5; + */ + addresses?: string[]; + + /** + * list of possible signatures (aka topic1), in [32]byte fix-sized array format + * + * @generated from field: repeated bytes event_sigs = 6; + */ + eventSigs?: string[]; + + /** + * list of possible values for topic2, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic2 = 7; + */ + topic2?: string[]; + + /** + * list of possible values for topic3, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic3 = 8; + */ + topic3?: string[]; + + /** + * list of possible values for topic4, in [32]byte fix-sized array format + * + * @generated from field: repeated bytes topic4 = 9; + */ + topic4?: string[]; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.LPFilter. + * Use `create(LPFilterSchema)` to create a new message. + */ +export const LPFilterSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 24); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.UnregisterLogTrackingRequest + */ +export type UnregisterLogTrackingRequest = Message<"capabilities.blockchain.evm.v1alpha.UnregisterLogTrackingRequest"> & { + /** + * @generated from field: string filter_name = 1; + */ + filterName: string; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.UnregisterLogTrackingRequest + */ +export type UnregisterLogTrackingRequestJson = { + /** + * @generated from field: string filter_name = 1; + */ + filterName?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.UnregisterLogTrackingRequest. + * Use `create(UnregisterLogTrackingRequestSchema)` to create a new message. + */ +export const UnregisterLogTrackingRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 25); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.WriteReportRequest + */ +export type WriteReportRequest = Message<"capabilities.blockchain.evm.v1alpha.WriteReportRequest"> & { + /** + * @generated from field: bytes receiver = 1; + */ + receiver: Uint8Array; + + /** + * @generated from field: sdk.v1alpha.ReportResponse report = 2; + */ + report?: ReportResponse; + + /** + * @generated from field: optional capabilities.blockchain.evm.v1alpha.GasConfig gas_config = 3; + */ + gasConfig?: GasConfig; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.WriteReportRequest + */ +export type WriteReportRequestJson = { + /** + * @generated from field: bytes receiver = 1; + */ + receiver?: string; + + /** + * @generated from field: sdk.v1alpha.ReportResponse report = 2; + */ + report?: ReportResponseJson; + + /** + * @generated from field: optional capabilities.blockchain.evm.v1alpha.GasConfig gas_config = 3; + */ + gasConfig?: GasConfigJson; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.WriteReportRequest. + * Use `create(WriteReportRequestSchema)` to create a new message. + */ +export const WriteReportRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 26); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GasConfig + */ +export type GasConfig = Message<"capabilities.blockchain.evm.v1alpha.GasConfig"> & { + /** + * @generated from field: uint64 gas_limit = 1 [jstype = JS_STRING]; + */ + gasLimit: string; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.GasConfig + */ +export type GasConfigJson = { + /** + * @generated from field: uint64 gas_limit = 1 [jstype = JS_STRING]; + */ + gasLimit?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.GasConfig. + * Use `create(GasConfigSchema)` to create a new message. + */ +export const GasConfigSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 27); + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.WriteReportReply + */ +export type WriteReportReply = Message<"capabilities.blockchain.evm.v1alpha.WriteReportReply"> & { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.TxStatus tx_status = 1; + */ + txStatus: TxStatus; + + /** + * @generated from field: optional capabilities.blockchain.evm.v1alpha.ReceiverContractExecutionStatus receiver_contract_execution_status = 2; + */ + receiverContractExecutionStatus?: ReceiverContractExecutionStatus; + + /** + * @generated from field: optional bytes tx_hash = 3; + */ + txHash?: Uint8Array; + + /** + * @generated from field: optional values.v1.BigInt transaction_fee = 4; + */ + transactionFee?: BigInt; + + /** + * @generated from field: optional string error_message = 5; + */ + errorMessage?: string; +}; + +/** + * @generated from message capabilities.blockchain.evm.v1alpha.WriteReportReply + */ +export type WriteReportReplyJson = { + /** + * @generated from field: capabilities.blockchain.evm.v1alpha.TxStatus tx_status = 1; + */ + txStatus?: TxStatusJson; + + /** + * @generated from field: optional capabilities.blockchain.evm.v1alpha.ReceiverContractExecutionStatus receiver_contract_execution_status = 2; + */ + receiverContractExecutionStatus?: ReceiverContractExecutionStatusJson; + + /** + * @generated from field: optional bytes tx_hash = 3; + */ + txHash?: string; + + /** + * @generated from field: optional values.v1.BigInt transaction_fee = 4; + */ + transactionFee?: BigIntJson; + + /** + * @generated from field: optional string error_message = 5; + */ + errorMessage?: string; +}; + +/** + * Describes the message capabilities.blockchain.evm.v1alpha.WriteReportReply. + * Use `create(WriteReportReplySchema)` to create a new message. + */ +export const WriteReportReplySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_blockchain_evm_v1alpha_client, 28); + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.ConfidenceLevel + */ +export enum ConfidenceLevel { + /** + * @generated from enum value: CONFIDENCE_LEVEL_SAFE = 0; + */ + SAFE = 0, + + /** + * @generated from enum value: CONFIDENCE_LEVEL_LATEST = 1; + */ + LATEST = 1, + + /** + * @generated from enum value: CONFIDENCE_LEVEL_FINALIZED = 2; + */ + FINALIZED = 2, +} + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.ConfidenceLevel + */ +export type ConfidenceLevelJson = "CONFIDENCE_LEVEL_SAFE" | "CONFIDENCE_LEVEL_LATEST" | "CONFIDENCE_LEVEL_FINALIZED"; + +/** + * Describes the enum capabilities.blockchain.evm.v1alpha.ConfidenceLevel. + */ +export const ConfidenceLevelSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_capabilities_blockchain_evm_v1alpha_client, 0); + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.ReceiverContractExecutionStatus + */ +export enum ReceiverContractExecutionStatus { + /** + * @generated from enum value: RECEIVER_CONTRACT_EXECUTION_STATUS_SUCCESS = 0; + */ + SUCCESS = 0, + + /** + * @generated from enum value: RECEIVER_CONTRACT_EXECUTION_STATUS_REVERTED = 1; + */ + REVERTED = 1, +} + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.ReceiverContractExecutionStatus + */ +export type ReceiverContractExecutionStatusJson = "RECEIVER_CONTRACT_EXECUTION_STATUS_SUCCESS" | "RECEIVER_CONTRACT_EXECUTION_STATUS_REVERTED"; + +/** + * Describes the enum capabilities.blockchain.evm.v1alpha.ReceiverContractExecutionStatus. + */ +export const ReceiverContractExecutionStatusSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_capabilities_blockchain_evm_v1alpha_client, 1); + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.TxStatus + */ +export enum TxStatus { + /** + * @generated from enum value: TX_STATUS_FATAL = 0; + */ + FATAL = 0, + + /** + * @generated from enum value: TX_STATUS_REVERTED = 1; + */ + REVERTED = 1, + + /** + * @generated from enum value: TX_STATUS_SUCCESS = 2; + */ + SUCCESS = 2, +} + +/** + * @generated from enum capabilities.blockchain.evm.v1alpha.TxStatus + */ +export type TxStatusJson = "TX_STATUS_FATAL" | "TX_STATUS_REVERTED" | "TX_STATUS_SUCCESS"; + +/** + * Describes the enum capabilities.blockchain.evm.v1alpha.TxStatus. + */ +export const TxStatusSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_capabilities_blockchain_evm_v1alpha_client, 2); + +/** + * @generated from service capabilities.blockchain.evm.v1alpha.Client + */ +export const Client: GenService<{ + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.CallContract + */ + callContract: { + methodKind: "unary"; + input: typeof CallContractRequestSchema; + output: typeof CallContractReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.FilterLogs + */ + filterLogs: { + methodKind: "unary"; + input: typeof FilterLogsRequestSchema; + output: typeof FilterLogsReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.BalanceAt + */ + balanceAt: { + methodKind: "unary"; + input: typeof BalanceAtRequestSchema; + output: typeof BalanceAtReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.EstimateGas + */ + estimateGas: { + methodKind: "unary"; + input: typeof EstimateGasRequestSchema; + output: typeof EstimateGasReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.GetTransactionByHash + */ + getTransactionByHash: { + methodKind: "unary"; + input: typeof GetTransactionByHashRequestSchema; + output: typeof GetTransactionByHashReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.GetTransactionReceipt + */ + getTransactionReceipt: { + methodKind: "unary"; + input: typeof GetTransactionReceiptRequestSchema; + output: typeof GetTransactionReceiptReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.HeaderByNumber + */ + headerByNumber: { + methodKind: "unary"; + input: typeof HeaderByNumberRequestSchema; + output: typeof HeaderByNumberReplySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.RegisterLogTracking + */ + registerLogTracking: { + methodKind: "unary"; + input: typeof RegisterLogTrackingRequestSchema; + output: typeof EmptySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.UnregisterLogTracking + */ + unregisterLogTracking: { + methodKind: "unary"; + input: typeof UnregisterLogTrackingRequestSchema; + output: typeof EmptySchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.LogTrigger + */ + logTrigger: { + methodKind: "server_streaming"; + input: typeof FilterLogTriggerRequestSchema; + output: typeof LogSchema; + }, + /** + * @generated from rpc capabilities.blockchain.evm.v1alpha.Client.WriteReport + */ + writeReport: { + methodKind: "unary"; + input: typeof WriteReportRequestSchema; + output: typeof WriteReportReplySchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_blockchain_evm_v1alpha_client, 0); + diff --git a/src/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb.ts b/src/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb.ts new file mode 100644 index 00000000..6cba3f9b --- /dev/null +++ b/src/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb.ts @@ -0,0 +1,156 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/actionandtrigger/v1/action_and_trigger.proto (package capabilities.internal.actionandtrigger.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/actionandtrigger/v1/action_and_trigger.proto. + */ +export const file_capabilities_internal_actionandtrigger_v1_action_and_trigger: GenFile = /*@__PURE__*/ + fileDesc("CkJjYXBhYmlsaXRpZXMvaW50ZXJuYWwvYWN0aW9uYW5kdHJpZ2dlci92MS9hY3Rpb25fYW5kX3RyaWdnZXIucHJvdG8SKWNhcGFiaWxpdGllcy5pbnRlcm5hbC5hY3Rpb25hbmR0cmlnZ2VyLnYxIiYKBkNvbmZpZxIMCgRuYW1lGAEgASgJEg4KBm51bWJlchgCIAEoBSIjCgxUcmlnZ2VyRXZlbnQSEwoLY29vbF9vdXRwdXQYASABKAkiFQoFSW5wdXQSDAoEbmFtZRgBIAEoCSIZCgZPdXRwdXQSDwoHd2VsY29tZRgBIAEoCTKYAgoFQmFzaWMSbQoGQWN0aW9uEjAuY2FwYWJpbGl0aWVzLmludGVybmFsLmFjdGlvbmFuZHRyaWdnZXIudjEuSW5wdXQaMS5jYXBhYmlsaXRpZXMuaW50ZXJuYWwuYWN0aW9uYW5kdHJpZ2dlci52MS5PdXRwdXQSdwoHVHJpZ2dlchIxLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5hY3Rpb25hbmR0cmlnZ2VyLnYxLkNvbmZpZxo3LmNhcGFiaWxpdGllcy5pbnRlcm5hbC5hY3Rpb25hbmR0cmlnZ2VyLnYxLlRyaWdnZXJFdmVudDABGieCtRgjCAESH2Jhc2ljLXRlc3QtYWN0aW9uLXRyaWdnZXJAMS4wLjBCjQIKLWNvbS5jYXBhYmlsaXRpZXMuaW50ZXJuYWwuYWN0aW9uYW5kdHJpZ2dlci52MUIVQWN0aW9uQW5kVHJpZ2dlclByb3RvUAGiAgNDSUGqAilDYXBhYmlsaXRpZXMuSW50ZXJuYWwuQWN0aW9uYW5kdHJpZ2dlci5WMcoCKUNhcGFiaWxpdGllc1xJbnRlcm5hbFxBY3Rpb25hbmR0cmlnZ2VyXFYx4gI1Q2FwYWJpbGl0aWVzXEludGVybmFsXEFjdGlvbmFuZHRyaWdnZXJcVjFcR1BCTWV0YWRhdGHqAixDYXBhYmlsaXRpZXM6OkludGVybmFsOjpBY3Rpb25hbmR0cmlnZ2VyOjpWMWIGcHJvdG8z", [file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Config + */ +export type Config = Message<"capabilities.internal.actionandtrigger.v1.Config"> & { + /** + * @generated from field: string name = 1; + */ + name: string; + + /** + * @generated from field: int32 number = 2; + */ + number: number; +}; + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Config + */ +export type ConfigJson = { + /** + * @generated from field: string name = 1; + */ + name?: string; + + /** + * @generated from field: int32 number = 2; + */ + number?: number; +}; + +/** + * Describes the message capabilities.internal.actionandtrigger.v1.Config. + * Use `create(ConfigSchema)` to create a new message. + */ +export const ConfigSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_actionandtrigger_v1_action_and_trigger, 0); + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.TriggerEvent + */ +export type TriggerEvent = Message<"capabilities.internal.actionandtrigger.v1.TriggerEvent"> & { + /** + * @generated from field: string cool_output = 1; + */ + coolOutput: string; +}; + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.TriggerEvent + */ +export type TriggerEventJson = { + /** + * @generated from field: string cool_output = 1; + */ + coolOutput?: string; +}; + +/** + * Describes the message capabilities.internal.actionandtrigger.v1.TriggerEvent. + * Use `create(TriggerEventSchema)` to create a new message. + */ +export const TriggerEventSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_actionandtrigger_v1_action_and_trigger, 1); + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Input + */ +export type Input = Message<"capabilities.internal.actionandtrigger.v1.Input"> & { + /** + * @generated from field: string name = 1; + */ + name: string; +}; + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Input + */ +export type InputJson = { + /** + * @generated from field: string name = 1; + */ + name?: string; +}; + +/** + * Describes the message capabilities.internal.actionandtrigger.v1.Input. + * Use `create(InputSchema)` to create a new message. + */ +export const InputSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_actionandtrigger_v1_action_and_trigger, 2); + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Output + */ +export type Output = Message<"capabilities.internal.actionandtrigger.v1.Output"> & { + /** + * @generated from field: string welcome = 1; + */ + welcome: string; +}; + +/** + * @generated from message capabilities.internal.actionandtrigger.v1.Output + */ +export type OutputJson = { + /** + * @generated from field: string welcome = 1; + */ + welcome?: string; +}; + +/** + * Describes the message capabilities.internal.actionandtrigger.v1.Output. + * Use `create(OutputSchema)` to create a new message. + */ +export const OutputSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_actionandtrigger_v1_action_and_trigger, 3); + +/** + * @generated from service capabilities.internal.actionandtrigger.v1.Basic + */ +export const Basic: GenService<{ + /** + * @generated from rpc capabilities.internal.actionandtrigger.v1.Basic.Action + */ + action: { + methodKind: "unary"; + input: typeof InputSchema; + output: typeof OutputSchema; + }, + /** + * @generated from rpc capabilities.internal.actionandtrigger.v1.Basic.Trigger + */ + trigger: { + methodKind: "server_streaming"; + input: typeof ConfigSchema; + output: typeof TriggerEventSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_actionandtrigger_v1_action_and_trigger, 0); + diff --git a/src/generated/capabilities/internal/basicaction/v1/basic_action_pb.ts b/src/generated/capabilities/internal/basicaction/v1/basic_action_pb.ts new file mode 100644 index 00000000..f225faed --- /dev/null +++ b/src/generated/capabilities/internal/basicaction/v1/basic_action_pb.ts @@ -0,0 +1,92 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/basicaction/v1/basic_action.proto (package capabilities.internal.basicaction.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/basicaction/v1/basic_action.proto. + */ +export const file_capabilities_internal_basicaction_v1_basic_action: GenFile = /*@__PURE__*/ + fileDesc("CjdjYXBhYmlsaXRpZXMvaW50ZXJuYWwvYmFzaWNhY3Rpb24vdjEvYmFzaWNfYWN0aW9uLnByb3RvEiRjYXBhYmlsaXRpZXMuaW50ZXJuYWwuYmFzaWNhY3Rpb24udjEiHQoGSW5wdXRzEhMKC2lucHV0X3RoaW5nGAEgASgIIiAKB091dHB1dHMSFQoNYWRhcHRlZF90aGluZxgBIAEoCTKcAQoLQmFzaWNBY3Rpb24SbAoNUGVyZm9ybUFjdGlvbhIsLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5iYXNpY2FjdGlvbi52MS5JbnB1dHMaLS5jYXBhYmlsaXRpZXMuaW50ZXJuYWwuYmFzaWNhY3Rpb24udjEuT3V0cHV0cxofgrUYGwgBEhdiYXNpYy10ZXN0LWFjdGlvbkAxLjAuMELvAQooY29tLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5iYXNpY2FjdGlvbi52MUIQQmFzaWNBY3Rpb25Qcm90b1ABogIDQ0lCqgIkQ2FwYWJpbGl0aWVzLkludGVybmFsLkJhc2ljYWN0aW9uLlYxygIkQ2FwYWJpbGl0aWVzXEludGVybmFsXEJhc2ljYWN0aW9uXFYx4gIwQ2FwYWJpbGl0aWVzXEludGVybmFsXEJhc2ljYWN0aW9uXFYxXEdQQk1ldGFkYXRh6gInQ2FwYWJpbGl0aWVzOjpJbnRlcm5hbDo6QmFzaWNhY3Rpb246OlYxYgZwcm90bzM", [file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.internal.basicaction.v1.Inputs + */ +export type Inputs = Message<"capabilities.internal.basicaction.v1.Inputs"> & { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing: boolean; +}; + +/** + * @generated from message capabilities.internal.basicaction.v1.Inputs + */ +export type InputsJson = { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing?: boolean; +}; + +/** + * Describes the message capabilities.internal.basicaction.v1.Inputs. + * Use `create(InputsSchema)` to create a new message. + */ +export const InputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_basicaction_v1_basic_action, 0); + +/** + * @generated from message capabilities.internal.basicaction.v1.Outputs + */ +export type Outputs = Message<"capabilities.internal.basicaction.v1.Outputs"> & { + /** + * @generated from field: string adapted_thing = 1; + */ + adaptedThing: string; +}; + +/** + * @generated from message capabilities.internal.basicaction.v1.Outputs + */ +export type OutputsJson = { + /** + * @generated from field: string adapted_thing = 1; + */ + adaptedThing?: string; +}; + +/** + * Describes the message capabilities.internal.basicaction.v1.Outputs. + * Use `create(OutputsSchema)` to create a new message. + */ +export const OutputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_basicaction_v1_basic_action, 1); + +/** + * This action server for testing purposes only. + * + * This comment tests the generator's ability to handle comments. + * + * @generated from service capabilities.internal.basicaction.v1.BasicAction + */ +export const BasicAction: GenService<{ + /** + * This comment tests the generator's ability to handle leading comments on methods. + * + * This comment tests the generator's ability to handle trailing comments on methods. + * + * @generated from rpc capabilities.internal.basicaction.v1.BasicAction.PerformAction + */ + performAction: { + methodKind: "unary"; + input: typeof InputsSchema; + output: typeof OutputsSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_basicaction_v1_basic_action, 0); + diff --git a/src/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb.ts b/src/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb.ts new file mode 100644 index 00000000..8f8a538f --- /dev/null +++ b/src/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb.ts @@ -0,0 +1,94 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/basictrigger/v1/basic_trigger.proto (package capabilities.internal.basictrigger.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/basictrigger/v1/basic_trigger.proto. + */ +export const file_capabilities_internal_basictrigger_v1_basic_trigger: GenFile = /*@__PURE__*/ + fileDesc("CjljYXBhYmlsaXRpZXMvaW50ZXJuYWwvYmFzaWN0cmlnZ2VyL3YxL2Jhc2ljX3RyaWdnZXIucHJvdG8SJWNhcGFiaWxpdGllcy5pbnRlcm5hbC5iYXNpY3RyaWdnZXIudjEiJgoGQ29uZmlnEgwKBG5hbWUYASABKAkSDgoGbnVtYmVyGAIgASgFIh4KB091dHB1dHMSEwoLY29vbF9vdXRwdXQYASABKAkylQEKBUJhc2ljEmoKB1RyaWdnZXISLS5jYXBhYmlsaXRpZXMuaW50ZXJuYWwuYmFzaWN0cmlnZ2VyLnYxLkNvbmZpZxouLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5iYXNpY3RyaWdnZXIudjEuT3V0cHV0czABGiCCtRgcCAESGGJhc2ljLXRlc3QtdHJpZ2dlckAxLjAuMEL1AQopY29tLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5iYXNpY3RyaWdnZXIudjFCEUJhc2ljVHJpZ2dlclByb3RvUAGiAgNDSUKqAiVDYXBhYmlsaXRpZXMuSW50ZXJuYWwuQmFzaWN0cmlnZ2VyLlYxygIlQ2FwYWJpbGl0aWVzXEludGVybmFsXEJhc2ljdHJpZ2dlclxWMeICMUNhcGFiaWxpdGllc1xJbnRlcm5hbFxCYXNpY3RyaWdnZXJcVjFcR1BCTWV0YWRhdGHqAihDYXBhYmlsaXRpZXM6OkludGVybmFsOjpCYXNpY3RyaWdnZXI6OlYxYgZwcm90bzM", [file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.internal.basictrigger.v1.Config + */ +export type Config = Message<"capabilities.internal.basictrigger.v1.Config"> & { + /** + * @generated from field: string name = 1; + */ + name: string; + + /** + * @generated from field: int32 number = 2; + */ + number: number; +}; + +/** + * @generated from message capabilities.internal.basictrigger.v1.Config + */ +export type ConfigJson = { + /** + * @generated from field: string name = 1; + */ + name?: string; + + /** + * @generated from field: int32 number = 2; + */ + number?: number; +}; + +/** + * Describes the message capabilities.internal.basictrigger.v1.Config. + * Use `create(ConfigSchema)` to create a new message. + */ +export const ConfigSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_basictrigger_v1_basic_trigger, 0); + +/** + * @generated from message capabilities.internal.basictrigger.v1.Outputs + */ +export type Outputs = Message<"capabilities.internal.basictrigger.v1.Outputs"> & { + /** + * @generated from field: string cool_output = 1; + */ + coolOutput: string; +}; + +/** + * @generated from message capabilities.internal.basictrigger.v1.Outputs + */ +export type OutputsJson = { + /** + * @generated from field: string cool_output = 1; + */ + coolOutput?: string; +}; + +/** + * Describes the message capabilities.internal.basictrigger.v1.Outputs. + * Use `create(OutputsSchema)` to create a new message. + */ +export const OutputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_basictrigger_v1_basic_trigger, 1); + +/** + * @generated from service capabilities.internal.basictrigger.v1.Basic + */ +export const Basic: GenService<{ + /** + * @generated from rpc capabilities.internal.basictrigger.v1.Basic.Trigger + */ + trigger: { + methodKind: "server_streaming"; + input: typeof ConfigSchema; + output: typeof OutputsSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_basictrigger_v1_basic_trigger, 0); + diff --git a/src/generated/capabilities/internal/consensus/v1alpha/consensus_pb.ts b/src/generated/capabilities/internal/consensus/v1alpha/consensus_pb.ts new file mode 100644 index 00000000..2977a437 --- /dev/null +++ b/src/generated/capabilities/internal/consensus/v1alpha/consensus_pb.ts @@ -0,0 +1,41 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/consensus/v1alpha/consensus.proto (package capabilities.internal.consensus.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { ReportRequestSchema, ReportResponseSchema, SimpleConsensusInputsSchema } from "../../../../sdk/v1alpha/sdk_pb"; +import { file_sdk_v1alpha_sdk } from "../../../../sdk/v1alpha/sdk_pb"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { ValueSchema } from "../../../../values/v1/values_pb"; +import { file_values_v1_values } from "../../../../values/v1/values_pb"; + +/** + * Describes the file capabilities/internal/consensus/v1alpha/consensus.proto. + */ +export const file_capabilities_internal_consensus_v1alpha_consensus: GenFile = /*@__PURE__*/ + fileDesc("CjdjYXBhYmlsaXRpZXMvaW50ZXJuYWwvY29uc2Vuc3VzL3YxYWxwaGEvY29uc2Vuc3VzLnByb3RvEidjYXBhYmlsaXRpZXMuaW50ZXJuYWwuY29uc2Vuc3VzLnYxYWxwaGEyrQEKCUNvbnNlbnN1cxI+CgZTaW1wbGUSIi5zZGsudjFhbHBoYS5TaW1wbGVDb25zZW5zdXNJbnB1dHMaEC52YWx1ZXMudjEuVmFsdWUSQQoGUmVwb3J0Ehouc2RrLnYxYWxwaGEuUmVwb3J0UmVxdWVzdBobLnNkay52MWFscGhhLlJlcG9ydFJlc3BvbnNlGh2CtRgZCAESFWNvbnNlbnN1c0AxLjAuMC1hbHBoYUL8AQorY29tLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5jb25zZW5zdXMudjFhbHBoYUIOQ29uc2Vuc3VzUHJvdG9QAaICA0NJQ6oCJ0NhcGFiaWxpdGllcy5JbnRlcm5hbC5Db25zZW5zdXMuVjFhbHBoYcoCJ0NhcGFiaWxpdGllc1xJbnRlcm5hbFxDb25zZW5zdXNcVjFhbHBoYeICM0NhcGFiaWxpdGllc1xJbnRlcm5hbFxDb25zZW5zdXNcVjFhbHBoYVxHUEJNZXRhZGF0YeoCKkNhcGFiaWxpdGllczo6SW50ZXJuYWw6OkNvbnNlbnN1czo6VjFhbHBoYWIGcHJvdG8z", [file_sdk_v1alpha_sdk, file_tools_generator_v1alpha_cre_metadata, file_values_v1_values]); + +/** + * @generated from service capabilities.internal.consensus.v1alpha.Consensus + */ +export const Consensus: GenService<{ + /** + * @generated from rpc capabilities.internal.consensus.v1alpha.Consensus.Simple + */ + simple: { + methodKind: "unary"; + input: typeof SimpleConsensusInputsSchema; + output: typeof ValueSchema; + }, + /** + * @generated from rpc capabilities.internal.consensus.v1alpha.Consensus.Report + */ + report: { + methodKind: "unary"; + input: typeof ReportRequestSchema; + output: typeof ReportResponseSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_consensus_v1alpha_consensus, 0); + diff --git a/src/generated/capabilities/internal/importclash/p1/v1/import_pb.ts b/src/generated/capabilities/internal/importclash/p1/v1/import_pb.ts new file mode 100644 index 00000000..a93fe8dd --- /dev/null +++ b/src/generated/capabilities/internal/importclash/p1/v1/import_pb.ts @@ -0,0 +1,41 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/importclash/p1/v1/import.proto (package capabilities.internal.importclash.p1.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/importclash/p1/v1/import.proto. + */ +export const file_capabilities_internal_importclash_p1_v1_import: GenFile = /*@__PURE__*/ + fileDesc("CjRjYXBhYmlsaXRpZXMvaW50ZXJuYWwvaW1wb3J0Y2xhc2gvcDEvdjEvaW1wb3J0LnByb3RvEidjYXBhYmlsaXRpZXMuaW50ZXJuYWwuaW1wb3J0Y2xhc2gucDEudjEiGwoESXRlbRITCgtpbnB1dF90aGluZxgBIAEoCEL7AQorY29tLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5pbXBvcnRjbGFzaC5wMS52MUILSW1wb3J0UHJvdG9QAaICBENJSVCqAidDYXBhYmlsaXRpZXMuSW50ZXJuYWwuSW1wb3J0Y2xhc2guUDEuVjHKAidDYXBhYmlsaXRpZXNcSW50ZXJuYWxcSW1wb3J0Y2xhc2hcUDFcVjHiAjNDYXBhYmlsaXRpZXNcSW50ZXJuYWxcSW1wb3J0Y2xhc2hcUDFcVjFcR1BCTWV0YWRhdGHqAitDYXBhYmlsaXRpZXM6OkludGVybmFsOjpJbXBvcnRjbGFzaDo6UDE6OlYxYgZwcm90bzM"); + +/** + * @generated from message capabilities.internal.importclash.p1.v1.Item + */ +export type Item = Message<"capabilities.internal.importclash.p1.v1.Item"> & { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing: boolean; +}; + +/** + * @generated from message capabilities.internal.importclash.p1.v1.Item + */ +export type ItemJson = { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing?: boolean; +}; + +/** + * Describes the message capabilities.internal.importclash.p1.v1.Item. + * Use `create(ItemSchema)` to create a new message. + */ +export const ItemSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_importclash_p1_v1_import, 0); + diff --git a/src/generated/capabilities/internal/importclash/p2/v1/import_pb.ts b/src/generated/capabilities/internal/importclash/p2/v1/import_pb.ts new file mode 100644 index 00000000..ee6a57fd --- /dev/null +++ b/src/generated/capabilities/internal/importclash/p2/v1/import_pb.ts @@ -0,0 +1,41 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/importclash/p2/v1/import.proto (package capabilities.internal.importclash.p2.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/importclash/p2/v1/import.proto. + */ +export const file_capabilities_internal_importclash_p2_v1_import: GenFile = /*@__PURE__*/ + fileDesc("CjRjYXBhYmlsaXRpZXMvaW50ZXJuYWwvaW1wb3J0Y2xhc2gvcDIvdjEvaW1wb3J0LnByb3RvEidjYXBhYmlsaXRpZXMuaW50ZXJuYWwuaW1wb3J0Y2xhc2gucDIudjEiHQoESXRlbRIVCg1hZGFwdGVkX3RoaW5nGAEgASgJQvsBCitjb20uY2FwYWJpbGl0aWVzLmludGVybmFsLmltcG9ydGNsYXNoLnAyLnYxQgtJbXBvcnRQcm90b1ABogIEQ0lJUKoCJ0NhcGFiaWxpdGllcy5JbnRlcm5hbC5JbXBvcnRjbGFzaC5QMi5WMcoCJ0NhcGFiaWxpdGllc1xJbnRlcm5hbFxJbXBvcnRjbGFzaFxQMlxWMeICM0NhcGFiaWxpdGllc1xJbnRlcm5hbFxJbXBvcnRjbGFzaFxQMlxWMVxHUEJNZXRhZGF0YeoCK0NhcGFiaWxpdGllczo6SW50ZXJuYWw6OkltcG9ydGNsYXNoOjpQMjo6VjFiBnByb3RvMw"); + +/** + * @generated from message capabilities.internal.importclash.p2.v1.Item + */ +export type Item = Message<"capabilities.internal.importclash.p2.v1.Item"> & { + /** + * @generated from field: string adapted_thing = 1; + */ + adaptedThing: string; +}; + +/** + * @generated from message capabilities.internal.importclash.p2.v1.Item + */ +export type ItemJson = { + /** + * @generated from field: string adapted_thing = 1; + */ + adaptedThing?: string; +}; + +/** + * Describes the message capabilities.internal.importclash.p2.v1.Item. + * Use `create(ItemSchema)` to create a new message. + */ +export const ItemSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_importclash_p2_v1_import, 0); + diff --git a/src/generated/capabilities/internal/importclash/v1/clash_pb.ts b/src/generated/capabilities/internal/importclash/v1/clash_pb.ts new file mode 100644 index 00000000..de884309 --- /dev/null +++ b/src/generated/capabilities/internal/importclash/v1/clash_pb.ts @@ -0,0 +1,33 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/importclash/v1/clash.proto (package capabilities.internal.importclash.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { ItemSchema } from "../p1/v1/import_pb"; +import { file_capabilities_internal_importclash_p1_v1_import } from "../p1/v1/import_pb"; +import type { ItemSchema as ItemSchema$1 } from "../p2/v1/import_pb"; +import { file_capabilities_internal_importclash_p2_v1_import } from "../p2/v1/import_pb"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; + +/** + * Describes the file capabilities/internal/importclash/v1/clash.proto. + */ +export const file_capabilities_internal_importclash_v1_clash: GenFile = /*@__PURE__*/ + fileDesc("CjBjYXBhYmlsaXRpZXMvaW50ZXJuYWwvaW1wb3J0Y2xhc2gvdjEvY2xhc2gucHJvdG8SJGNhcGFiaWxpdGllcy5pbnRlcm5hbC5pbXBvcnRjbGFzaC52MTKYAQoLQmFzaWNBY3Rpb24SbQoNUGVyZm9ybUFjdGlvbhItLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5pbXBvcnRjbGFzaC5wMS52MS5JdGVtGi0uY2FwYWJpbGl0aWVzLmludGVybmFsLmltcG9ydGNsYXNoLnAyLnYxLkl0ZW0aGoK1GBYIARISaW1wb3J0LWNsYXNoQDEuMC4wQukBCihjb20uY2FwYWJpbGl0aWVzLmludGVybmFsLmltcG9ydGNsYXNoLnYxQgpDbGFzaFByb3RvUAGiAgNDSUmqAiRDYXBhYmlsaXRpZXMuSW50ZXJuYWwuSW1wb3J0Y2xhc2guVjHKAiRDYXBhYmlsaXRpZXNcSW50ZXJuYWxcSW1wb3J0Y2xhc2hcVjHiAjBDYXBhYmlsaXRpZXNcSW50ZXJuYWxcSW1wb3J0Y2xhc2hcVjFcR1BCTWV0YWRhdGHqAidDYXBhYmlsaXRpZXM6OkludGVybmFsOjpJbXBvcnRjbGFzaDo6VjFiBnByb3RvMw", [file_capabilities_internal_importclash_p1_v1_import, file_capabilities_internal_importclash_p2_v1_import, file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from service capabilities.internal.importclash.v1.BasicAction + */ +export const BasicAction: GenService<{ + /** + * @generated from rpc capabilities.internal.importclash.v1.BasicAction.PerformAction + */ + performAction: { + methodKind: "unary"; + input: typeof ItemSchema; + output: typeof ItemSchema$1; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_importclash_v1_clash, 0); + diff --git a/src/generated/capabilities/internal/nodeaction/v1/node_action_pb.ts b/src/generated/capabilities/internal/nodeaction/v1/node_action_pb.ts new file mode 100644 index 00000000..d36ac88b --- /dev/null +++ b/src/generated/capabilities/internal/nodeaction/v1/node_action_pb.ts @@ -0,0 +1,84 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/internal/nodeaction/v1/node_action.proto (package capabilities.internal.nodeaction.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/internal/nodeaction/v1/node_action.proto. + */ +export const file_capabilities_internal_nodeaction_v1_node_action: GenFile = /*@__PURE__*/ + fileDesc("CjVjYXBhYmlsaXRpZXMvaW50ZXJuYWwvbm9kZWFjdGlvbi92MS9ub2RlX2FjdGlvbi5wcm90bxIjY2FwYWJpbGl0aWVzLmludGVybmFsLm5vZGVhY3Rpb24udjEiIQoKTm9kZUlucHV0cxITCgtpbnB1dF90aGluZxgBIAEoCCIjCgtOb2RlT3V0cHV0cxIUCgxvdXRwdXRfdGhpbmcYASABKAUypwEKC0Jhc2ljQWN0aW9uEnIKDVBlcmZvcm1BY3Rpb24SLy5jYXBhYmlsaXRpZXMuaW50ZXJuYWwubm9kZWFjdGlvbi52MS5Ob2RlSW5wdXRzGjAuY2FwYWJpbGl0aWVzLmludGVybmFsLm5vZGVhY3Rpb24udjEuTm9kZU91dHB1dHMaJIK1GCAIAhIcYmFzaWMtdGVzdC1ub2RlLWFjdGlvbkAxLjAuMELpAQonY29tLmNhcGFiaWxpdGllcy5pbnRlcm5hbC5ub2RlYWN0aW9uLnYxQg9Ob2RlQWN0aW9uUHJvdG9QAaICA0NJTqoCI0NhcGFiaWxpdGllcy5JbnRlcm5hbC5Ob2RlYWN0aW9uLlYxygIjQ2FwYWJpbGl0aWVzXEludGVybmFsXE5vZGVhY3Rpb25cVjHiAi9DYXBhYmlsaXRpZXNcSW50ZXJuYWxcTm9kZWFjdGlvblxWMVxHUEJNZXRhZGF0YeoCJkNhcGFiaWxpdGllczo6SW50ZXJuYWw6Ok5vZGVhY3Rpb246OlYxYgZwcm90bzM", [file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.internal.nodeaction.v1.NodeInputs + */ +export type NodeInputs = Message<"capabilities.internal.nodeaction.v1.NodeInputs"> & { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing: boolean; +}; + +/** + * @generated from message capabilities.internal.nodeaction.v1.NodeInputs + */ +export type NodeInputsJson = { + /** + * @generated from field: bool input_thing = 1; + */ + inputThing?: boolean; +}; + +/** + * Describes the message capabilities.internal.nodeaction.v1.NodeInputs. + * Use `create(NodeInputsSchema)` to create a new message. + */ +export const NodeInputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_nodeaction_v1_node_action, 0); + +/** + * @generated from message capabilities.internal.nodeaction.v1.NodeOutputs + */ +export type NodeOutputs = Message<"capabilities.internal.nodeaction.v1.NodeOutputs"> & { + /** + * @generated from field: int32 output_thing = 1; + */ + outputThing: number; +}; + +/** + * @generated from message capabilities.internal.nodeaction.v1.NodeOutputs + */ +export type NodeOutputsJson = { + /** + * @generated from field: int32 output_thing = 1; + */ + outputThing?: number; +}; + +/** + * Describes the message capabilities.internal.nodeaction.v1.NodeOutputs. + * Use `create(NodeOutputsSchema)` to create a new message. + */ +export const NodeOutputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_internal_nodeaction_v1_node_action, 1); + +/** + * @generated from service capabilities.internal.nodeaction.v1.BasicAction + */ +export const BasicAction: GenService<{ + /** + * @generated from rpc capabilities.internal.nodeaction.v1.BasicAction.PerformAction + */ + performAction: { + methodKind: "unary"; + input: typeof NodeInputsSchema; + output: typeof NodeOutputsSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_internal_nodeaction_v1_node_action, 0); + diff --git a/src/generated/capabilities/networking/http/v1alpha/client_pb.ts b/src/generated/capabilities/networking/http/v1alpha/client_pb.ts new file mode 100644 index 00000000..c0cbfbe0 --- /dev/null +++ b/src/generated/capabilities/networking/http/v1alpha/client_pb.ts @@ -0,0 +1,203 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/networking/http/v1alpha/client.proto (package capabilities.networking.http.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/networking/http/v1alpha/client.proto. + */ +export const file_capabilities_networking_http_v1alpha_client: GenFile = /*@__PURE__*/ + fileDesc("CjFjYXBhYmlsaXRpZXMvbmV0d29ya2luZy9odHRwL3YxYWxwaGEvY2xpZW50LnByb3RvEiRjYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEiPAoNQ2FjaGVTZXR0aW5ncxIXCg9yZWFkX2Zyb21fY2FjaGUYASABKAgSEgoKbWF4X2FnZV9tcxgCIAEoBSKSAgoHUmVxdWVzdBILCgN1cmwYASABKAkSDgoGbWV0aG9kGAIgASgJEksKB2hlYWRlcnMYAyADKAsyOi5jYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEuUmVxdWVzdC5IZWFkZXJzRW50cnkSDAoEYm9keRgEIAEoDBISCgp0aW1lb3V0X21zGAUgASgFEksKDmNhY2hlX3NldHRpbmdzGAYgASgLMjMuY2FwYWJpbGl0aWVzLm5ldHdvcmtpbmcuaHR0cC52MWFscGhhLkNhY2hlU2V0dGluZ3MaLgoMSGVhZGVyc0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAEiqwEKCFJlc3BvbnNlEhMKC3N0YXR1c19jb2RlGAEgASgNEkwKB2hlYWRlcnMYAiADKAsyOy5jYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEuUmVzcG9uc2UuSGVhZGVyc0VudHJ5EgwKBGJvZHkYAyABKAwaLgoMSGVhZGVyc0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAEymAEKBkNsaWVudBJsCgtTZW5kUmVxdWVzdBItLmNhcGFiaWxpdGllcy5uZXR3b3JraW5nLmh0dHAudjFhbHBoYS5SZXF1ZXN0Gi4uY2FwYWJpbGl0aWVzLm5ldHdvcmtpbmcuaHR0cC52MWFscGhhLlJlc3BvbnNlGiCCtRgcCAISGGh0dHAtYWN0aW9uc0AxLjAuMC1hbHBoYULqAQooY29tLmNhcGFiaWxpdGllcy5uZXR3b3JraW5nLmh0dHAudjFhbHBoYUILQ2xpZW50UHJvdG9QAaICA0NOSKoCJENhcGFiaWxpdGllcy5OZXR3b3JraW5nLkh0dHAuVjFhbHBoYcoCJENhcGFiaWxpdGllc1xOZXR3b3JraW5nXEh0dHBcVjFhbHBoYeICMENhcGFiaWxpdGllc1xOZXR3b3JraW5nXEh0dHBcVjFhbHBoYVxHUEJNZXRhZGF0YeoCJ0NhcGFiaWxpdGllczo6TmV0d29ya2luZzo6SHR0cDo6VjFhbHBoYWIGcHJvdG8z", [file_tools_generator_v1alpha_cre_metadata]); + +/** + * CacheSettings defines cache control options for outbound HTTP requests. + * + * @generated from message capabilities.networking.http.v1alpha.CacheSettings + */ +export type CacheSettings = Message<"capabilities.networking.http.v1alpha.CacheSettings"> & { + /** + * If true, attempt to read a cached response for the request. + * + * @generated from field: bool read_from_cache = 1; + */ + readFromCache: boolean; + + /** + * Maximum age of a cached response in milliseconds. + * + * @generated from field: int32 max_age_ms = 2; + */ + maxAgeMs: number; +}; + +/** + * CacheSettings defines cache control options for outbound HTTP requests. + * + * @generated from message capabilities.networking.http.v1alpha.CacheSettings + */ +export type CacheSettingsJson = { + /** + * If true, attempt to read a cached response for the request. + * + * @generated from field: bool read_from_cache = 1; + */ + readFromCache?: boolean; + + /** + * Maximum age of a cached response in milliseconds. + * + * @generated from field: int32 max_age_ms = 2; + */ + maxAgeMs?: number; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.CacheSettings. + * Use `create(CacheSettingsSchema)` to create a new message. + */ +export const CacheSettingsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_client, 0); + +/** + * @generated from message capabilities.networking.http.v1alpha.Request + */ +export type Request = Message<"capabilities.networking.http.v1alpha.Request"> & { + /** + * @generated from field: string url = 1; + */ + url: string; + + /** + * @generated from field: string method = 2; + */ + method: string; + + /** + * @generated from field: map headers = 3; + */ + headers: { [key: string]: string }; + + /** + * @generated from field: bytes body = 4; + */ + body: Uint8Array; + + /** + * @generated from field: int32 timeout_ms = 5; + */ + timeoutMs: number; + + /** + * @generated from field: capabilities.networking.http.v1alpha.CacheSettings cache_settings = 6; + */ + cacheSettings?: CacheSettings; +}; + +/** + * @generated from message capabilities.networking.http.v1alpha.Request + */ +export type RequestJson = { + /** + * @generated from field: string url = 1; + */ + url?: string; + + /** + * @generated from field: string method = 2; + */ + method?: string; + + /** + * @generated from field: map headers = 3; + */ + headers?: { [key: string]: string }; + + /** + * @generated from field: bytes body = 4; + */ + body?: string; + + /** + * @generated from field: int32 timeout_ms = 5; + */ + timeoutMs?: number; + + /** + * @generated from field: capabilities.networking.http.v1alpha.CacheSettings cache_settings = 6; + */ + cacheSettings?: CacheSettingsJson; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.Request. + * Use `create(RequestSchema)` to create a new message. + */ +export const RequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_client, 1); + +/** + * @generated from message capabilities.networking.http.v1alpha.Response + */ +export type Response = Message<"capabilities.networking.http.v1alpha.Response"> & { + /** + * @generated from field: uint32 status_code = 1; + */ + statusCode: number; + + /** + * @generated from field: map headers = 2; + */ + headers: { [key: string]: string }; + + /** + * @generated from field: bytes body = 3; + */ + body: Uint8Array; +}; + +/** + * @generated from message capabilities.networking.http.v1alpha.Response + */ +export type ResponseJson = { + /** + * @generated from field: uint32 status_code = 1; + */ + statusCode?: number; + + /** + * @generated from field: map headers = 2; + */ + headers?: { [key: string]: string }; + + /** + * @generated from field: bytes body = 3; + */ + body?: string; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.Response. + * Use `create(ResponseSchema)` to create a new message. + */ +export const ResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_client, 2); + +/** + * @generated from service capabilities.networking.http.v1alpha.Client + */ +export const Client: GenService<{ + /** + * @generated from rpc capabilities.networking.http.v1alpha.Client.SendRequest + */ + sendRequest: { + methodKind: "unary"; + input: typeof RequestSchema; + output: typeof ResponseSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_networking_http_v1alpha_client, 0); + diff --git a/src/generated/capabilities/networking/http/v1alpha/trigger_pb.ts b/src/generated/capabilities/networking/http/v1alpha/trigger_pb.ts new file mode 100644 index 00000000..80afdf65 --- /dev/null +++ b/src/generated/capabilities/networking/http/v1alpha/trigger_pb.ts @@ -0,0 +1,175 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/networking/http/v1alpha/trigger.proto (package capabilities.networking.http.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { enumDesc, fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { StructJson } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_struct } from "@bufbuild/protobuf/wkt"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { JsonObject, Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/networking/http/v1alpha/trigger.proto. + */ +export const file_capabilities_networking_http_v1alpha_trigger: GenFile = /*@__PURE__*/ + fileDesc("CjJjYXBhYmlsaXRpZXMvbmV0d29ya2luZy9odHRwL3YxYWxwaGEvdHJpZ2dlci5wcm90bxIkY2FwYWJpbGl0aWVzLm5ldHdvcmtpbmcuaHR0cC52MWFscGhhIlYKBkNvbmZpZxJMCg9hdXRob3JpemVkX2tleXMYASADKAsyMy5jYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEuQXV0aG9yaXplZEtleSJzCgdQYXlsb2FkEiYKBWlucHV0GAEgASgLMhcuZ29vZ2xlLnByb3RvYnVmLlN0cnVjdBJACgNrZXkYAiABKAsyMy5jYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEuQXV0aG9yaXplZEtleSJgCg1BdXRob3JpemVkS2V5EjsKBHR5cGUYASABKA4yLS5jYXBhYmlsaXRpZXMubmV0d29ya2luZy5odHRwLnYxYWxwaGEuS2V5VHlwZRISCgpwdWJsaWNfa2V5GAIgASgJKjsKB0tleVR5cGUSGAoUS0VZX1RZUEVfVU5TUEVDSUZJRUQQABIWChJLRVlfVFlQRV9FQ0RTQV9FVk0QATKSAQoESFRUUBJoCgdUcmlnZ2VyEiwuY2FwYWJpbGl0aWVzLm5ldHdvcmtpbmcuaHR0cC52MWFscGhhLkNvbmZpZxotLmNhcGFiaWxpdGllcy5uZXR3b3JraW5nLmh0dHAudjFhbHBoYS5QYXlsb2FkMAEaIIK1GBwIARIYaHR0cC10cmlnZ2VyQDEuMC4wLWFscGhhQusBCihjb20uY2FwYWJpbGl0aWVzLm5ldHdvcmtpbmcuaHR0cC52MWFscGhhQgxUcmlnZ2VyUHJvdG9QAaICA0NOSKoCJENhcGFiaWxpdGllcy5OZXR3b3JraW5nLkh0dHAuVjFhbHBoYcoCJENhcGFiaWxpdGllc1xOZXR3b3JraW5nXEh0dHBcVjFhbHBoYeICMENhcGFiaWxpdGllc1xOZXR3b3JraW5nXEh0dHBcVjFhbHBoYVxHUEJNZXRhZGF0YeoCJ0NhcGFiaWxpdGllczo6TmV0d29ya2luZzo6SHR0cDo6VjFhbHBoYWIGcHJvdG8z", [file_google_protobuf_struct, file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.networking.http.v1alpha.Config + */ +export type Config = Message<"capabilities.networking.http.v1alpha.Config"> & { + /** + * Public keys against which the signature of incoming requests are validated + * + * @generated from field: repeated capabilities.networking.http.v1alpha.AuthorizedKey authorized_keys = 1; + */ + authorizedKeys: AuthorizedKey[]; +}; + +/** + * @generated from message capabilities.networking.http.v1alpha.Config + */ +export type ConfigJson = { + /** + * Public keys against which the signature of incoming requests are validated + * + * @generated from field: repeated capabilities.networking.http.v1alpha.AuthorizedKey authorized_keys = 1; + */ + authorizedKeys?: AuthorizedKeyJson[]; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.Config. + * Use `create(ConfigSchema)` to create a new message. + */ +export const ConfigSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_trigger, 0); + +/** + * @generated from message capabilities.networking.http.v1alpha.Payload + */ +export type Payload = Message<"capabilities.networking.http.v1alpha.Payload"> & { + /** + * JSON input in the HTTP trigger request + * + * @generated from field: google.protobuf.Struct input = 1; + */ + input?: JsonObject; + + /** + * Key used to sign the HTTP trigger request + * + * @generated from field: capabilities.networking.http.v1alpha.AuthorizedKey key = 2; + */ + key?: AuthorizedKey; +}; + +/** + * @generated from message capabilities.networking.http.v1alpha.Payload + */ +export type PayloadJson = { + /** + * JSON input in the HTTP trigger request + * + * @generated from field: google.protobuf.Struct input = 1; + */ + input?: StructJson; + + /** + * Key used to sign the HTTP trigger request + * + * @generated from field: capabilities.networking.http.v1alpha.AuthorizedKey key = 2; + */ + key?: AuthorizedKeyJson; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.Payload. + * Use `create(PayloadSchema)` to create a new message. + */ +export const PayloadSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_trigger, 1); + +/** + * Generic and extensible authorized signer abstraction + * + * @generated from message capabilities.networking.http.v1alpha.AuthorizedKey + */ +export type AuthorizedKey = Message<"capabilities.networking.http.v1alpha.AuthorizedKey"> & { + /** + * @generated from field: capabilities.networking.http.v1alpha.KeyType type = 1; + */ + type: KeyType; + + /** + * @generated from field: string public_key = 2; + */ + publicKey: string; +}; + +/** + * Generic and extensible authorized signer abstraction + * + * @generated from message capabilities.networking.http.v1alpha.AuthorizedKey + */ +export type AuthorizedKeyJson = { + /** + * @generated from field: capabilities.networking.http.v1alpha.KeyType type = 1; + */ + type?: KeyTypeJson; + + /** + * @generated from field: string public_key = 2; + */ + publicKey?: string; +}; + +/** + * Describes the message capabilities.networking.http.v1alpha.AuthorizedKey. + * Use `create(AuthorizedKeySchema)` to create a new message. + */ +export const AuthorizedKeySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_networking_http_v1alpha_trigger, 2); + +/** + * @generated from enum capabilities.networking.http.v1alpha.KeyType + */ +export enum KeyType { + /** + * @generated from enum value: KEY_TYPE_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * @generated from enum value: KEY_TYPE_ECDSA_EVM = 1; + */ + ECDSA_EVM = 1, +} + +/** + * @generated from enum capabilities.networking.http.v1alpha.KeyType + */ +export type KeyTypeJson = "KEY_TYPE_UNSPECIFIED" | "KEY_TYPE_ECDSA_EVM"; + +/** + * Describes the enum capabilities.networking.http.v1alpha.KeyType. + */ +export const KeyTypeSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_capabilities_networking_http_v1alpha_trigger, 0); + +/** + * @generated from service capabilities.networking.http.v1alpha.HTTP + */ +export const HTTP: GenService<{ + /** + * @generated from rpc capabilities.networking.http.v1alpha.HTTP.Trigger + */ + trigger: { + methodKind: "server_streaming"; + input: typeof ConfigSchema; + output: typeof PayloadSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_networking_http_v1alpha_trigger, 0); + diff --git a/src/generated/capabilities/scheduler/cron/v1/trigger_pb.ts b/src/generated/capabilities/scheduler/cron/v1/trigger_pb.ts new file mode 100644 index 00000000..063ea161 --- /dev/null +++ b/src/generated/capabilities/scheduler/cron/v1/trigger_pb.ts @@ -0,0 +1,133 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file capabilities/scheduler/cron/v1/trigger.proto (package capabilities.scheduler.cron.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Timestamp, TimestampJson } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt"; +import { file_tools_generator_v1alpha_cre_metadata } from "../../../../tools/generator/v1alpha/cre_metadata_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file capabilities/scheduler/cron/v1/trigger.proto. + */ +export const file_capabilities_scheduler_cron_v1_trigger: GenFile = /*@__PURE__*/ + fileDesc("CixjYXBhYmlsaXRpZXMvc2NoZWR1bGVyL2Nyb24vdjEvdHJpZ2dlci5wcm90bxIeY2FwYWJpbGl0aWVzLnNjaGVkdWxlci5jcm9uLnYxIhoKBkNvbmZpZxIQCghzY2hlZHVsZRgBIAEoCSJHCgdQYXlsb2FkEjwKGHNjaGVkdWxlZF9leGVjdXRpb25fdGltZRgBIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXAiNQoNTGVnYWN5UGF5bG9hZBIgChhzY2hlZHVsZWRfZXhlY3V0aW9uX3RpbWUYASABKAk6AhgBMvUBCgRDcm9uElwKB1RyaWdnZXISJi5jYXBhYmlsaXRpZXMuc2NoZWR1bGVyLmNyb24udjEuQ29uZmlnGicuY2FwYWJpbGl0aWVzLnNjaGVkdWxlci5jcm9uLnYxLlBheWxvYWQwARJzCg1MZWdhY3lUcmlnZ2VyEiYuY2FwYWJpbGl0aWVzLnNjaGVkdWxlci5jcm9uLnYxLkNvbmZpZxotLmNhcGFiaWxpdGllcy5zY2hlZHVsZXIuY3Jvbi52MS5MZWdhY3lQYXlsb2FkIgmIAgGKtRgCCAEwARoagrUYFggBEhJjcm9uLXRyaWdnZXJAMS4wLjBCzQEKImNvbS5jYXBhYmlsaXRpZXMuc2NoZWR1bGVyLmNyb24udjFCDFRyaWdnZXJQcm90b1ABogIDQ1NDqgIeQ2FwYWJpbGl0aWVzLlNjaGVkdWxlci5Dcm9uLlYxygIeQ2FwYWJpbGl0aWVzXFNjaGVkdWxlclxDcm9uXFYx4gIqQ2FwYWJpbGl0aWVzXFNjaGVkdWxlclxDcm9uXFYxXEdQQk1ldGFkYXRh6gIhQ2FwYWJpbGl0aWVzOjpTY2hlZHVsZXI6OkNyb246OlYxYgZwcm90bzM", [file_google_protobuf_timestamp, file_tools_generator_v1alpha_cre_metadata]); + +/** + * @generated from message capabilities.scheduler.cron.v1.Config + */ +export type Config = Message<"capabilities.scheduler.cron.v1.Config"> & { + /** + * Cron schedule string + * + * @generated from field: string schedule = 1; + */ + schedule: string; +}; + +/** + * @generated from message capabilities.scheduler.cron.v1.Config + */ +export type ConfigJson = { + /** + * Cron schedule string + * + * @generated from field: string schedule = 1; + */ + schedule?: string; +}; + +/** + * Describes the message capabilities.scheduler.cron.v1.Config. + * Use `create(ConfigSchema)` to create a new message. + */ +export const ConfigSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_scheduler_cron_v1_trigger, 0); + +/** + * @generated from message capabilities.scheduler.cron.v1.Payload + */ +export type Payload = Message<"capabilities.scheduler.cron.v1.Payload"> & { + /** + * @generated from field: google.protobuf.Timestamp scheduled_execution_time = 1; + */ + scheduledExecutionTime?: Timestamp; +}; + +/** + * @generated from message capabilities.scheduler.cron.v1.Payload + */ +export type PayloadJson = { + /** + * @generated from field: google.protobuf.Timestamp scheduled_execution_time = 1; + */ + scheduledExecutionTime?: TimestampJson; +}; + +/** + * Describes the message capabilities.scheduler.cron.v1.Payload. + * Use `create(PayloadSchema)` to create a new message. + */ +export const PayloadSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_scheduler_cron_v1_trigger, 1); + +/** + * @generated from message capabilities.scheduler.cron.v1.LegacyPayload + * @deprecated + */ +export type LegacyPayload = Message<"capabilities.scheduler.cron.v1.LegacyPayload"> & { + /** + * Time that cron trigger's task execution had been scheduled to occur (RFC3339Nano formatted) + * + * @generated from field: string scheduled_execution_time = 1; + */ + scheduledExecutionTime: string; +}; + +/** + * @generated from message capabilities.scheduler.cron.v1.LegacyPayload + * @deprecated + */ +export type LegacyPayloadJson = { + /** + * Time that cron trigger's task execution had been scheduled to occur (RFC3339Nano formatted) + * + * @generated from field: string scheduled_execution_time = 1; + */ + scheduledExecutionTime?: string; +}; + +/** + * Describes the message capabilities.scheduler.cron.v1.LegacyPayload. + * Use `create(LegacyPayloadSchema)` to create a new message. + * @deprecated + */ +export const LegacyPayloadSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_capabilities_scheduler_cron_v1_trigger, 2); + +/** + * @generated from service capabilities.scheduler.cron.v1.Cron + */ +export const Cron: GenService<{ + /** + * @generated from rpc capabilities.scheduler.cron.v1.Cron.Trigger + */ + trigger: { + methodKind: "server_streaming"; + input: typeof ConfigSchema; + output: typeof PayloadSchema; + }, + /** + * @generated from rpc capabilities.scheduler.cron.v1.Cron.LegacyTrigger + * @deprecated + */ + legacyTrigger: { + methodKind: "server_streaming"; + input: typeof ConfigSchema; + output: typeof LegacyPayloadSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_capabilities_scheduler_cron_v1_trigger, 0); + diff --git a/src/generated/sdk/v1alpha/sdk_pb.ts b/src/generated/sdk/v1alpha/sdk_pb.ts new file mode 100644 index 00000000..57130f75 --- /dev/null +++ b/src/generated/sdk/v1alpha/sdk_pb.ts @@ -0,0 +1,1088 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file sdk/v1alpha/sdk.proto (package sdk.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2"; +import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Any, AnyJson, Empty, EmptyJson } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_any, file_google_protobuf_empty } from "@bufbuild/protobuf/wkt"; +import type { Value, ValueJson } from "../../values/v1/values_pb"; +import { file_values_v1_values } from "../../values/v1/values_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file sdk/v1alpha/sdk.proto. + */ +export const file_sdk_v1alpha_sdk: GenFile = /*@__PURE__*/ + fileDesc("ChVzZGsvdjFhbHBoYS9zZGsucHJvdG8SC3Nkay52MWFscGhhIrQBChVTaW1wbGVDb25zZW5zdXNJbnB1dHMSIQoFdmFsdWUYASABKAsyEC52YWx1ZXMudjEuVmFsdWVIABIPCgVlcnJvchgCIAEoCUgAEjUKC2Rlc2NyaXB0b3JzGAMgASgLMiAuc2RrLnYxYWxwaGEuQ29uc2Vuc3VzRGVzY3JpcHRvchIhCgdkZWZhdWx0GAQgASgLMhAudmFsdWVzLnYxLlZhbHVlQg0KC29ic2VydmF0aW9uIpABCglGaWVsZHNNYXASMgoGZmllbGRzGAEgAygLMiIuc2RrLnYxYWxwaGEuRmllbGRzTWFwLkZpZWxkc0VudHJ5Gk8KC0ZpZWxkc0VudHJ5EgsKA2tleRgBIAEoCRIvCgV2YWx1ZRgCIAEoCzIgLnNkay52MWFscGhhLkNvbnNlbnN1c0Rlc2NyaXB0b3I6AjgBIoYBChNDb25zZW5zdXNEZXNjcmlwdG9yEjMKC2FnZ3JlZ2F0aW9uGAEgASgOMhwuc2RrLnYxYWxwaGEuQWdncmVnYXRpb25UeXBlSAASLAoKZmllbGRzX21hcBgCIAEoCzIWLnNkay52MWFscGhhLkZpZWxkc01hcEgAQgwKCmRlc2NyaXB0b3IiagoNUmVwb3J0UmVxdWVzdBIXCg9lbmNvZGVkX3BheWxvYWQYASABKAwSFAoMZW5jb2Rlcl9uYW1lGAIgASgJEhQKDHNpZ25pbmdfYWxnbxgDIAEoCRIUCgxoYXNoaW5nX2FsZ28YBCABKAkilwEKDlJlcG9ydFJlc3BvbnNlEhUKDWNvbmZpZ19kaWdlc3QYASABKAwSEgoGc2VxX25yGAIgASgEQgIwARIWCg5yZXBvcnRfY29udGV4dBgDIAEoDBISCgpyYXdfcmVwb3J0GAQgASgMEi4KBHNpZ3MYBSADKAsyIC5zZGsudjFhbHBoYS5BdHRyaWJ1dGVkU2lnbmF0dXJlIjsKE0F0dHJpYnV0ZWRTaWduYXR1cmUSEQoJc2lnbmF0dXJlGAEgASgMEhEKCXNpZ25lcl9pZBgCIAEoDSJrChFDYXBhYmlsaXR5UmVxdWVzdBIKCgJpZBgBIAEoCRIlCgdwYXlsb2FkGAIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRIOCgZtZXRob2QYAyABKAkSEwoLY2FsbGJhY2tfaWQYBCABKAUiWgoSQ2FwYWJpbGl0eVJlc3BvbnNlEicKB3BheWxvYWQYASABKAsyFC5nb29nbGUucHJvdG9idWYuQW55SAASDwoFZXJyb3IYAiABKAlIAEIKCghyZXNwb25zZSJYChNUcmlnZ2VyU3Vic2NyaXB0aW9uEgoKAmlkGAEgASgJEiUKB3BheWxvYWQYAiABKAsyFC5nb29nbGUucHJvdG9idWYuQW55Eg4KBm1ldGhvZBgDIAEoCSJVChpUcmlnZ2VyU3Vic2NyaXB0aW9uUmVxdWVzdBI3Cg1zdWJzY3JpcHRpb25zGAEgAygLMiAuc2RrLnYxYWxwaGEuVHJpZ2dlclN1YnNjcmlwdGlvbiJACgdUcmlnZ2VyEg4KAmlkGAEgASgEQgIwARIlCgdwYXlsb2FkGAIgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueSInChhBd2FpdENhcGFiaWxpdGllc1JlcXVlc3QSCwoDaWRzGAEgAygFIrgBChlBd2FpdENhcGFiaWxpdGllc1Jlc3BvbnNlEkgKCXJlc3BvbnNlcxgBIAMoCzI1LnNkay52MWFscGhhLkF3YWl0Q2FwYWJpbGl0aWVzUmVzcG9uc2UuUmVzcG9uc2VzRW50cnkaUQoOUmVzcG9uc2VzRW50cnkSCwoDa2V5GAEgASgFEi4KBXZhbHVlGAIgASgLMh8uc2RrLnYxYWxwaGEuQ2FwYWJpbGl0eVJlc3BvbnNlOgI4ASKgAQoORXhlY3V0ZVJlcXVlc3QSDgoGY29uZmlnGAEgASgMEisKCXN1YnNjcmliZRgCIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eUgAEicKB3RyaWdnZXIYAyABKAsyFC5zZGsudjFhbHBoYS5UcmlnZ2VySAASHQoRbWF4X3Jlc3BvbnNlX3NpemUYBCABKARCAjABQgkKB3JlcXVlc3QimQEKD0V4ZWN1dGlvblJlc3VsdBIhCgV2YWx1ZRgBIAEoCzIQLnZhbHVlcy52MS5WYWx1ZUgAEg8KBWVycm9yGAIgASgJSAASSAoVdHJpZ2dlcl9zdWJzY3JpcHRpb25zGAMgASgLMicuc2RrLnYxYWxwaGEuVHJpZ2dlclN1YnNjcmlwdGlvblJlcXVlc3RIAEIICgZyZXN1bHQiVgoRR2V0U2VjcmV0c1JlcXVlc3QSLAoIcmVxdWVzdHMYASADKAsyGi5zZGsudjFhbHBoYS5TZWNyZXRSZXF1ZXN0EhMKC2NhbGxiYWNrX2lkGAIgASgFIiIKE0F3YWl0U2VjcmV0c1JlcXVlc3QSCwoDaWRzGAEgAygFIqsBChRBd2FpdFNlY3JldHNSZXNwb25zZRJDCglyZXNwb25zZXMYASADKAsyMC5zZGsudjFhbHBoYS5Bd2FpdFNlY3JldHNSZXNwb25zZS5SZXNwb25zZXNFbnRyeRpOCg5SZXNwb25zZXNFbnRyeRILCgNrZXkYASABKAUSKwoFdmFsdWUYAiABKAsyHC5zZGsudjFhbHBoYS5TZWNyZXRSZXNwb25zZXM6AjgBIi4KDVNlY3JldFJlcXVlc3QSCgoCaWQYASABKAkSEQoJbmFtZXNwYWNlGAIgASgJIkUKBlNlY3JldBIKCgJpZBgBIAEoCRIRCgluYW1lc3BhY2UYAiABKAkSDQoFb3duZXIYAyABKAkSDQoFdmFsdWUYBCABKAkiSgoLU2VjcmV0RXJyb3ISCgoCaWQYASABKAkSEQoJbmFtZXNwYWNlGAIgASgJEg0KBW93bmVyGAMgASgJEg0KBWVycm9yGAQgASgJIm4KDlNlY3JldFJlc3BvbnNlEiUKBnNlY3JldBgBIAEoCzITLnNkay52MWFscGhhLlNlY3JldEgAEikKBWVycm9yGAIgASgLMhguc2RrLnYxYWxwaGEuU2VjcmV0RXJyb3JIAEIKCghyZXNwb25zZSJBCg9TZWNyZXRSZXNwb25zZXMSLgoJcmVzcG9uc2VzGAEgAygLMhsuc2RrLnYxYWxwaGEuU2VjcmV0UmVzcG9uc2UquAEKD0FnZ3JlZ2F0aW9uVHlwZRIgChxBR0dSRUdBVElPTl9UWVBFX1VOU1BFQ0lGSUVEEAASGwoXQUdHUkVHQVRJT05fVFlQRV9NRURJQU4QARIeChpBR0dSRUdBVElPTl9UWVBFX0lERU5USUNBTBACEiIKHkFHR1JFR0FUSU9OX1RZUEVfQ09NTU9OX1BSRUZJWBADEiIKHkFHR1JFR0FUSU9OX1RZUEVfQ09NTU9OX1NVRkZJWBAEKjkKBE1vZGUSFAoQTU9ERV9VTlNQRUNJRklFRBAAEgwKCE1PREVfRE9OEAESDQoJTU9ERV9OT0RFEAJCaAoPY29tLnNkay52MWFscGhhQghTZGtQcm90b1ABogIDU1hYqgILU2RrLlYxYWxwaGHKAgtTZGtcVjFhbHBoYeICF1Nka1xWMWFscGhhXEdQQk1ldGFkYXRh6gIMU2RrOjpWMWFscGhhYgZwcm90bzM", [file_google_protobuf_any, file_google_protobuf_empty, file_values_v1_values]); + +/** + * @generated from message sdk.v1alpha.SimpleConsensusInputs + */ +export type SimpleConsensusInputs = Message<"sdk.v1alpha.SimpleConsensusInputs"> & { + /** + * @generated from oneof sdk.v1alpha.SimpleConsensusInputs.observation + */ + observation: { + /** + * @generated from field: values.v1.Value value = 1; + */ + value: Value; + case: "value"; + } | { + /** + * @generated from field: string error = 2; + */ + value: string; + case: "error"; + } | { case: undefined; value?: undefined }; + + /** + * @generated from field: sdk.v1alpha.ConsensusDescriptor descriptors = 3; + */ + descriptors?: ConsensusDescriptor; + + /** + * @generated from field: values.v1.Value default = 4; + */ + default?: Value; +}; + +/** + * @generated from message sdk.v1alpha.SimpleConsensusInputs + */ +export type SimpleConsensusInputsJson = { + /** + * @generated from field: values.v1.Value value = 1; + */ + value?: ValueJson; + + /** + * @generated from field: string error = 2; + */ + error?: string; + + /** + * @generated from field: sdk.v1alpha.ConsensusDescriptor descriptors = 3; + */ + descriptors?: ConsensusDescriptorJson; + + /** + * @generated from field: values.v1.Value default = 4; + */ + default?: ValueJson; +}; + +/** + * Describes the message sdk.v1alpha.SimpleConsensusInputs. + * Use `create(SimpleConsensusInputsSchema)` to create a new message. + */ +export const SimpleConsensusInputsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 0); + +/** + * @generated from message sdk.v1alpha.FieldsMap + */ +export type FieldsMap = Message<"sdk.v1alpha.FieldsMap"> & { + /** + * @generated from field: map fields = 1; + */ + fields: { [key: string]: ConsensusDescriptor }; +}; + +/** + * @generated from message sdk.v1alpha.FieldsMap + */ +export type FieldsMapJson = { + /** + * @generated from field: map fields = 1; + */ + fields?: { [key: string]: ConsensusDescriptorJson }; +}; + +/** + * Describes the message sdk.v1alpha.FieldsMap. + * Use `create(FieldsMapSchema)` to create a new message. + */ +export const FieldsMapSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 1); + +/** + * @generated from message sdk.v1alpha.ConsensusDescriptor + */ +export type ConsensusDescriptor = Message<"sdk.v1alpha.ConsensusDescriptor"> & { + /** + * @generated from oneof sdk.v1alpha.ConsensusDescriptor.descriptor + */ + descriptor: { + /** + * @generated from field: sdk.v1alpha.AggregationType aggregation = 1; + */ + value: AggregationType; + case: "aggregation"; + } | { + /** + * @generated from field: sdk.v1alpha.FieldsMap fields_map = 2; + */ + value: FieldsMap; + case: "fieldsMap"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message sdk.v1alpha.ConsensusDescriptor + */ +export type ConsensusDescriptorJson = { + /** + * @generated from field: sdk.v1alpha.AggregationType aggregation = 1; + */ + aggregation?: AggregationTypeJson; + + /** + * @generated from field: sdk.v1alpha.FieldsMap fields_map = 2; + */ + fieldsMap?: FieldsMapJson; +}; + +/** + * Describes the message sdk.v1alpha.ConsensusDescriptor. + * Use `create(ConsensusDescriptorSchema)` to create a new message. + */ +export const ConsensusDescriptorSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 2); + +/** + * @generated from message sdk.v1alpha.ReportRequest + */ +export type ReportRequest = Message<"sdk.v1alpha.ReportRequest"> & { + /** + * @generated from field: bytes encoded_payload = 1; + */ + encodedPayload: Uint8Array; + + /** + * @generated from field: string encoder_name = 2; + */ + encoderName: string; + + /** + * @generated from field: string signing_algo = 3; + */ + signingAlgo: string; + + /** + * @generated from field: string hashing_algo = 4; + */ + hashingAlgo: string; +}; + +/** + * @generated from message sdk.v1alpha.ReportRequest + */ +export type ReportRequestJson = { + /** + * @generated from field: bytes encoded_payload = 1; + */ + encodedPayload?: string; + + /** + * @generated from field: string encoder_name = 2; + */ + encoderName?: string; + + /** + * @generated from field: string signing_algo = 3; + */ + signingAlgo?: string; + + /** + * @generated from field: string hashing_algo = 4; + */ + hashingAlgo?: string; +}; + +/** + * Describes the message sdk.v1alpha.ReportRequest. + * Use `create(ReportRequestSchema)` to create a new message. + */ +export const ReportRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 3); + +/** + * @generated from message sdk.v1alpha.ReportResponse + */ +export type ReportResponse = Message<"sdk.v1alpha.ReportResponse"> & { + /** + * @generated from field: bytes config_digest = 1; + */ + configDigest: Uint8Array; + + /** + * @generated from field: uint64 seq_nr = 2 [jstype = JS_STRING]; + */ + seqNr: string; + + /** + * combination of seq_nr and config_digest + * + * @generated from field: bytes report_context = 3; + */ + reportContext: Uint8Array; + + /** + * @generated from field: bytes raw_report = 4; + */ + rawReport: Uint8Array; + + /** + * @generated from field: repeated sdk.v1alpha.AttributedSignature sigs = 5; + */ + sigs: AttributedSignature[]; +}; + +/** + * @generated from message sdk.v1alpha.ReportResponse + */ +export type ReportResponseJson = { + /** + * @generated from field: bytes config_digest = 1; + */ + configDigest?: string; + + /** + * @generated from field: uint64 seq_nr = 2 [jstype = JS_STRING]; + */ + seqNr?: string; + + /** + * combination of seq_nr and config_digest + * + * @generated from field: bytes report_context = 3; + */ + reportContext?: string; + + /** + * @generated from field: bytes raw_report = 4; + */ + rawReport?: string; + + /** + * @generated from field: repeated sdk.v1alpha.AttributedSignature sigs = 5; + */ + sigs?: AttributedSignatureJson[]; +}; + +/** + * Describes the message sdk.v1alpha.ReportResponse. + * Use `create(ReportResponseSchema)` to create a new message. + */ +export const ReportResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 4); + +/** + * @generated from message sdk.v1alpha.AttributedSignature + */ +export type AttributedSignature = Message<"sdk.v1alpha.AttributedSignature"> & { + /** + * @generated from field: bytes signature = 1; + */ + signature: Uint8Array; + + /** + * @generated from field: uint32 signer_id = 2; + */ + signerId: number; +}; + +/** + * @generated from message sdk.v1alpha.AttributedSignature + */ +export type AttributedSignatureJson = { + /** + * @generated from field: bytes signature = 1; + */ + signature?: string; + + /** + * @generated from field: uint32 signer_id = 2; + */ + signerId?: number; +}; + +/** + * Describes the message sdk.v1alpha.AttributedSignature. + * Use `create(AttributedSignatureSchema)` to create a new message. + */ +export const AttributedSignatureSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 5); + +/** + * @generated from message sdk.v1alpha.CapabilityRequest + */ +export type CapabilityRequest = Message<"sdk.v1alpha.CapabilityRequest"> & { + /** + * @generated from field: string id = 1; + */ + id: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: Any; + + /** + * @generated from field: string method = 3; + */ + method: string; + + /** + * @generated from field: int32 callback_id = 4; + */ + callbackId: number; +}; + +/** + * @generated from message sdk.v1alpha.CapabilityRequest + */ +export type CapabilityRequestJson = { + /** + * @generated from field: string id = 1; + */ + id?: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: AnyJson; + + /** + * @generated from field: string method = 3; + */ + method?: string; + + /** + * @generated from field: int32 callback_id = 4; + */ + callbackId?: number; +}; + +/** + * Describes the message sdk.v1alpha.CapabilityRequest. + * Use `create(CapabilityRequestSchema)` to create a new message. + */ +export const CapabilityRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 6); + +/** + * @generated from message sdk.v1alpha.CapabilityResponse + */ +export type CapabilityResponse = Message<"sdk.v1alpha.CapabilityResponse"> & { + /** + * @generated from oneof sdk.v1alpha.CapabilityResponse.response + */ + response: { + /** + * @generated from field: google.protobuf.Any payload = 1; + */ + value: Any; + case: "payload"; + } | { + /** + * @generated from field: string error = 2; + */ + value: string; + case: "error"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message sdk.v1alpha.CapabilityResponse + */ +export type CapabilityResponseJson = { + /** + * @generated from field: google.protobuf.Any payload = 1; + */ + payload?: AnyJson; + + /** + * @generated from field: string error = 2; + */ + error?: string; +}; + +/** + * Describes the message sdk.v1alpha.CapabilityResponse. + * Use `create(CapabilityResponseSchema)` to create a new message. + */ +export const CapabilityResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 7); + +/** + * @generated from message sdk.v1alpha.TriggerSubscription + */ +export type TriggerSubscription = Message<"sdk.v1alpha.TriggerSubscription"> & { + /** + * @generated from field: string id = 1; + */ + id: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: Any; + + /** + * @generated from field: string method = 3; + */ + method: string; +}; + +/** + * @generated from message sdk.v1alpha.TriggerSubscription + */ +export type TriggerSubscriptionJson = { + /** + * @generated from field: string id = 1; + */ + id?: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: AnyJson; + + /** + * @generated from field: string method = 3; + */ + method?: string; +}; + +/** + * Describes the message sdk.v1alpha.TriggerSubscription. + * Use `create(TriggerSubscriptionSchema)` to create a new message. + */ +export const TriggerSubscriptionSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 8); + +/** + * @generated from message sdk.v1alpha.TriggerSubscriptionRequest + */ +export type TriggerSubscriptionRequest = Message<"sdk.v1alpha.TriggerSubscriptionRequest"> & { + /** + * @generated from field: repeated sdk.v1alpha.TriggerSubscription subscriptions = 1; + */ + subscriptions: TriggerSubscription[]; +}; + +/** + * @generated from message sdk.v1alpha.TriggerSubscriptionRequest + */ +export type TriggerSubscriptionRequestJson = { + /** + * @generated from field: repeated sdk.v1alpha.TriggerSubscription subscriptions = 1; + */ + subscriptions?: TriggerSubscriptionJson[]; +}; + +/** + * Describes the message sdk.v1alpha.TriggerSubscriptionRequest. + * Use `create(TriggerSubscriptionRequestSchema)` to create a new message. + */ +export const TriggerSubscriptionRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 9); + +/** + * @generated from message sdk.v1alpha.Trigger + */ +export type Trigger = Message<"sdk.v1alpha.Trigger"> & { + /** + * @generated from field: uint64 id = 1 [jstype = JS_STRING]; + */ + id: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: Any; +}; + +/** + * @generated from message sdk.v1alpha.Trigger + */ +export type TriggerJson = { + /** + * @generated from field: uint64 id = 1 [jstype = JS_STRING]; + */ + id?: string; + + /** + * @generated from field: google.protobuf.Any payload = 2; + */ + payload?: AnyJson; +}; + +/** + * Describes the message sdk.v1alpha.Trigger. + * Use `create(TriggerSchema)` to create a new message. + */ +export const TriggerSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 10); + +/** + * @generated from message sdk.v1alpha.AwaitCapabilitiesRequest + */ +export type AwaitCapabilitiesRequest = Message<"sdk.v1alpha.AwaitCapabilitiesRequest"> & { + /** + * @generated from field: repeated int32 ids = 1; + */ + ids: number[]; +}; + +/** + * @generated from message sdk.v1alpha.AwaitCapabilitiesRequest + */ +export type AwaitCapabilitiesRequestJson = { + /** + * @generated from field: repeated int32 ids = 1; + */ + ids?: number[]; +}; + +/** + * Describes the message sdk.v1alpha.AwaitCapabilitiesRequest. + * Use `create(AwaitCapabilitiesRequestSchema)` to create a new message. + */ +export const AwaitCapabilitiesRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 11); + +/** + * @generated from message sdk.v1alpha.AwaitCapabilitiesResponse + */ +export type AwaitCapabilitiesResponse = Message<"sdk.v1alpha.AwaitCapabilitiesResponse"> & { + /** + * @generated from field: map responses = 1; + */ + responses: { [key: number]: CapabilityResponse }; +}; + +/** + * @generated from message sdk.v1alpha.AwaitCapabilitiesResponse + */ +export type AwaitCapabilitiesResponseJson = { + /** + * @generated from field: map responses = 1; + */ + responses?: { [key: number]: CapabilityResponseJson }; +}; + +/** + * Describes the message sdk.v1alpha.AwaitCapabilitiesResponse. + * Use `create(AwaitCapabilitiesResponseSchema)` to create a new message. + */ +export const AwaitCapabilitiesResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 12); + +/** + * @generated from message sdk.v1alpha.ExecuteRequest + */ +export type ExecuteRequest = Message<"sdk.v1alpha.ExecuteRequest"> & { + /** + * @generated from field: bytes config = 1; + */ + config: Uint8Array; + + /** + * @generated from oneof sdk.v1alpha.ExecuteRequest.request + */ + request: { + /** + * @generated from field: google.protobuf.Empty subscribe = 2; + */ + value: Empty; + case: "subscribe"; + } | { + /** + * @generated from field: sdk.v1alpha.Trigger trigger = 3; + */ + value: Trigger; + case: "trigger"; + } | { case: undefined; value?: undefined }; + + /** + * @generated from field: uint64 max_response_size = 4 [jstype = JS_STRING]; + */ + maxResponseSize: string; +}; + +/** + * @generated from message sdk.v1alpha.ExecuteRequest + */ +export type ExecuteRequestJson = { + /** + * @generated from field: bytes config = 1; + */ + config?: string; + + /** + * @generated from field: google.protobuf.Empty subscribe = 2; + */ + subscribe?: EmptyJson; + + /** + * @generated from field: sdk.v1alpha.Trigger trigger = 3; + */ + trigger?: TriggerJson; + + /** + * @generated from field: uint64 max_response_size = 4 [jstype = JS_STRING]; + */ + maxResponseSize?: string; +}; + +/** + * Describes the message sdk.v1alpha.ExecuteRequest. + * Use `create(ExecuteRequestSchema)` to create a new message. + */ +export const ExecuteRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 13); + +/** + * @generated from message sdk.v1alpha.ExecutionResult + */ +export type ExecutionResult = Message<"sdk.v1alpha.ExecutionResult"> & { + /** + * @generated from oneof sdk.v1alpha.ExecutionResult.result + */ + result: { + /** + * @generated from field: values.v1.Value value = 1; + */ + value: Value; + case: "value"; + } | { + /** + * @generated from field: string error = 2; + */ + value: string; + case: "error"; + } | { + /** + * @generated from field: sdk.v1alpha.TriggerSubscriptionRequest trigger_subscriptions = 3; + */ + value: TriggerSubscriptionRequest; + case: "triggerSubscriptions"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message sdk.v1alpha.ExecutionResult + */ +export type ExecutionResultJson = { + /** + * @generated from field: values.v1.Value value = 1; + */ + value?: ValueJson; + + /** + * @generated from field: string error = 2; + */ + error?: string; + + /** + * @generated from field: sdk.v1alpha.TriggerSubscriptionRequest trigger_subscriptions = 3; + */ + triggerSubscriptions?: TriggerSubscriptionRequestJson; +}; + +/** + * Describes the message sdk.v1alpha.ExecutionResult. + * Use `create(ExecutionResultSchema)` to create a new message. + */ +export const ExecutionResultSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 14); + +/** + * @generated from message sdk.v1alpha.GetSecretsRequest + */ +export type GetSecretsRequest = Message<"sdk.v1alpha.GetSecretsRequest"> & { + /** + * @generated from field: repeated sdk.v1alpha.SecretRequest requests = 1; + */ + requests: SecretRequest[]; + + /** + * @generated from field: int32 callback_id = 2; + */ + callbackId: number; +}; + +/** + * @generated from message sdk.v1alpha.GetSecretsRequest + */ +export type GetSecretsRequestJson = { + /** + * @generated from field: repeated sdk.v1alpha.SecretRequest requests = 1; + */ + requests?: SecretRequestJson[]; + + /** + * @generated from field: int32 callback_id = 2; + */ + callbackId?: number; +}; + +/** + * Describes the message sdk.v1alpha.GetSecretsRequest. + * Use `create(GetSecretsRequestSchema)` to create a new message. + */ +export const GetSecretsRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 15); + +/** + * @generated from message sdk.v1alpha.AwaitSecretsRequest + */ +export type AwaitSecretsRequest = Message<"sdk.v1alpha.AwaitSecretsRequest"> & { + /** + * @generated from field: repeated int32 ids = 1; + */ + ids: number[]; +}; + +/** + * @generated from message sdk.v1alpha.AwaitSecretsRequest + */ +export type AwaitSecretsRequestJson = { + /** + * @generated from field: repeated int32 ids = 1; + */ + ids?: number[]; +}; + +/** + * Describes the message sdk.v1alpha.AwaitSecretsRequest. + * Use `create(AwaitSecretsRequestSchema)` to create a new message. + */ +export const AwaitSecretsRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 16); + +/** + * @generated from message sdk.v1alpha.AwaitSecretsResponse + */ +export type AwaitSecretsResponse = Message<"sdk.v1alpha.AwaitSecretsResponse"> & { + /** + * @generated from field: map responses = 1; + */ + responses: { [key: number]: SecretResponses }; +}; + +/** + * @generated from message sdk.v1alpha.AwaitSecretsResponse + */ +export type AwaitSecretsResponseJson = { + /** + * @generated from field: map responses = 1; + */ + responses?: { [key: number]: SecretResponsesJson }; +}; + +/** + * Describes the message sdk.v1alpha.AwaitSecretsResponse. + * Use `create(AwaitSecretsResponseSchema)` to create a new message. + */ +export const AwaitSecretsResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 17); + +/** + * @generated from message sdk.v1alpha.SecretRequest + */ +export type SecretRequest = Message<"sdk.v1alpha.SecretRequest"> & { + /** + * @generated from field: string id = 1; + */ + id: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace: string; +}; + +/** + * @generated from message sdk.v1alpha.SecretRequest + */ +export type SecretRequestJson = { + /** + * @generated from field: string id = 1; + */ + id?: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace?: string; +}; + +/** + * Describes the message sdk.v1alpha.SecretRequest. + * Use `create(SecretRequestSchema)` to create a new message. + */ +export const SecretRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 18); + +/** + * @generated from message sdk.v1alpha.Secret + */ +export type Secret = Message<"sdk.v1alpha.Secret"> & { + /** + * @generated from field: string id = 1; + */ + id: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace: string; + + /** + * @generated from field: string owner = 3; + */ + owner: string; + + /** + * @generated from field: string value = 4; + */ + value: string; +}; + +/** + * @generated from message sdk.v1alpha.Secret + */ +export type SecretJson = { + /** + * @generated from field: string id = 1; + */ + id?: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace?: string; + + /** + * @generated from field: string owner = 3; + */ + owner?: string; + + /** + * @generated from field: string value = 4; + */ + value?: string; +}; + +/** + * Describes the message sdk.v1alpha.Secret. + * Use `create(SecretSchema)` to create a new message. + */ +export const SecretSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 19); + +/** + * @generated from message sdk.v1alpha.SecretError + */ +export type SecretError = Message<"sdk.v1alpha.SecretError"> & { + /** + * @generated from field: string id = 1; + */ + id: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace: string; + + /** + * @generated from field: string owner = 3; + */ + owner: string; + + /** + * @generated from field: string error = 4; + */ + error: string; +}; + +/** + * @generated from message sdk.v1alpha.SecretError + */ +export type SecretErrorJson = { + /** + * @generated from field: string id = 1; + */ + id?: string; + + /** + * @generated from field: string namespace = 2; + */ + namespace?: string; + + /** + * @generated from field: string owner = 3; + */ + owner?: string; + + /** + * @generated from field: string error = 4; + */ + error?: string; +}; + +/** + * Describes the message sdk.v1alpha.SecretError. + * Use `create(SecretErrorSchema)` to create a new message. + */ +export const SecretErrorSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 20); + +/** + * @generated from message sdk.v1alpha.SecretResponse + */ +export type SecretResponse = Message<"sdk.v1alpha.SecretResponse"> & { + /** + * @generated from oneof sdk.v1alpha.SecretResponse.response + */ + response: { + /** + * @generated from field: sdk.v1alpha.Secret secret = 1; + */ + value: Secret; + case: "secret"; + } | { + /** + * @generated from field: sdk.v1alpha.SecretError error = 2; + */ + value: SecretError; + case: "error"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message sdk.v1alpha.SecretResponse + */ +export type SecretResponseJson = { + /** + * @generated from field: sdk.v1alpha.Secret secret = 1; + */ + secret?: SecretJson; + + /** + * @generated from field: sdk.v1alpha.SecretError error = 2; + */ + error?: SecretErrorJson; +}; + +/** + * Describes the message sdk.v1alpha.SecretResponse. + * Use `create(SecretResponseSchema)` to create a new message. + */ +export const SecretResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 21); + +/** + * @generated from message sdk.v1alpha.SecretResponses + */ +export type SecretResponses = Message<"sdk.v1alpha.SecretResponses"> & { + /** + * @generated from field: repeated sdk.v1alpha.SecretResponse responses = 1; + */ + responses: SecretResponse[]; +}; + +/** + * @generated from message sdk.v1alpha.SecretResponses + */ +export type SecretResponsesJson = { + /** + * @generated from field: repeated sdk.v1alpha.SecretResponse responses = 1; + */ + responses?: SecretResponseJson[]; +}; + +/** + * Describes the message sdk.v1alpha.SecretResponses. + * Use `create(SecretResponsesSchema)` to create a new message. + */ +export const SecretResponsesSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_sdk_v1alpha_sdk, 22); + +/** + * @generated from enum sdk.v1alpha.AggregationType + */ +export enum AggregationType { + /** + * @generated from enum value: AGGREGATION_TYPE_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * @generated from enum value: AGGREGATION_TYPE_MEDIAN = 1; + */ + MEDIAN = 1, + + /** + * @generated from enum value: AGGREGATION_TYPE_IDENTICAL = 2; + */ + IDENTICAL = 2, + + /** + * @generated from enum value: AGGREGATION_TYPE_COMMON_PREFIX = 3; + */ + COMMON_PREFIX = 3, + + /** + * @generated from enum value: AGGREGATION_TYPE_COMMON_SUFFIX = 4; + */ + COMMON_SUFFIX = 4, +} + +/** + * @generated from enum sdk.v1alpha.AggregationType + */ +export type AggregationTypeJson = "AGGREGATION_TYPE_UNSPECIFIED" | "AGGREGATION_TYPE_MEDIAN" | "AGGREGATION_TYPE_IDENTICAL" | "AGGREGATION_TYPE_COMMON_PREFIX" | "AGGREGATION_TYPE_COMMON_SUFFIX"; + +/** + * Describes the enum sdk.v1alpha.AggregationType. + */ +export const AggregationTypeSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_sdk_v1alpha_sdk, 0); + +/** + * @generated from enum sdk.v1alpha.Mode + */ +export enum Mode { + /** + * @generated from enum value: MODE_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * @generated from enum value: MODE_DON = 1; + */ + DON = 1, + + /** + * @generated from enum value: MODE_NODE = 2; + */ + NODE = 2, +} + +/** + * @generated from enum sdk.v1alpha.Mode + */ +export type ModeJson = "MODE_UNSPECIFIED" | "MODE_DON" | "MODE_NODE"; + +/** + * Describes the enum sdk.v1alpha.Mode. + */ +export const ModeSchema: GenEnum = /*@__PURE__*/ + enumDesc(file_sdk_v1alpha_sdk, 1); + diff --git a/src/generated/tools/generator/v1alpha/cre_metadata_pb.ts b/src/generated/tools/generator/v1alpha/cre_metadata_pb.ts new file mode 100644 index 00000000..c5e1960d --- /dev/null +++ b/src/generated/tools/generator/v1alpha/cre_metadata_pb.ts @@ -0,0 +1,320 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file tools/generator/v1alpha/cre_metadata.proto (package tools.generator.v1alpha, syntax proto3) +/* eslint-disable */ + +import type { GenExtension, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2"; +import { extDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2"; +import type { MethodOptions, ServiceOptions } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_descriptor } from "@bufbuild/protobuf/wkt"; +import type { Mode, ModeJson } from "../../../sdk/v1alpha/sdk_pb"; +import { file_sdk_v1alpha_sdk } from "../../../sdk/v1alpha/sdk_pb"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file tools/generator/v1alpha/cre_metadata.proto. + */ +export const file_tools_generator_v1alpha_cre_metadata: GenFile = /*@__PURE__*/ + fileDesc("Cip0b29scy9nZW5lcmF0b3IvdjFhbHBoYS9jcmVfbWV0YWRhdGEucHJvdG8SF3Rvb2xzLmdlbmVyYXRvci52MWFscGhhIoQBCgtTdHJpbmdMYWJlbBJECghkZWZhdWx0cxgBIAMoCzIyLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLlN0cmluZ0xhYmVsLkRlZmF1bHRzRW50cnkaLwoNRGVmYXVsdHNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBIogBCgtVaW50NjRMYWJlbBJECghkZWZhdWx0cxgBIAMoCzIyLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLlVpbnQ2NExhYmVsLkRlZmF1bHRzRW50cnkaMwoNRGVmYXVsdHNFbnRyeRILCgNrZXkYASABKAkSEQoFdmFsdWUYAiABKARCAjABOgI4ASKEAQoLVWludDMyTGFiZWwSRAoIZGVmYXVsdHMYASADKAsyMi50b29scy5nZW5lcmF0b3IudjFhbHBoYS5VaW50MzJMYWJlbC5EZWZhdWx0c0VudHJ5Gi8KDURlZmF1bHRzRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgNOgI4ASKGAQoKSW50NjRMYWJlbBJDCghkZWZhdWx0cxgBIAMoCzIxLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLkludDY0TGFiZWwuRGVmYXVsdHNFbnRyeRozCg1EZWZhdWx0c0VudHJ5EgsKA2tleRgBIAEoCRIRCgV2YWx1ZRgCIAEoA0ICMAE6AjgBIoIBCgpJbnQzMkxhYmVsEkMKCGRlZmF1bHRzGAEgAygLMjEudG9vbHMuZ2VuZXJhdG9yLnYxYWxwaGEuSW50MzJMYWJlbC5EZWZhdWx0c0VudHJ5Gi8KDURlZmF1bHRzRW50cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgFOgI4ASLBAgoFTGFiZWwSPAoMc3RyaW5nX2xhYmVsGAEgASgLMiQudG9vbHMuZ2VuZXJhdG9yLnYxYWxwaGEuU3RyaW5nTGFiZWxIABI8Cgx1aW50NjRfbGFiZWwYAiABKAsyJC50b29scy5nZW5lcmF0b3IudjFhbHBoYS5VaW50NjRMYWJlbEgAEjoKC2ludDY0X2xhYmVsGAMgASgLMiMudG9vbHMuZ2VuZXJhdG9yLnYxYWxwaGEuSW50NjRMYWJlbEgAEjwKDHVpbnQzMl9sYWJlbBgEIAEoCzIkLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLlVpbnQzMkxhYmVsSAASOgoLaW50MzJfbGFiZWwYBSABKAsyIy50b29scy5nZW5lcmF0b3IudjFhbHBoYS5JbnQzMkxhYmVsSABCBgoEa2luZCLkAQoSQ2FwYWJpbGl0eU1ldGFkYXRhEh8KBG1vZGUYASABKA4yES5zZGsudjFhbHBoYS5Nb2RlEhUKDWNhcGFiaWxpdHlfaWQYAiABKAkSRwoGbGFiZWxzGAMgAygLMjcudG9vbHMuZ2VuZXJhdG9yLnYxYWxwaGEuQ2FwYWJpbGl0eU1ldGFkYXRhLkxhYmVsc0VudHJ5Gk0KC0xhYmVsc0VudHJ5EgsKA2tleRgBIAEoCRItCgV2YWx1ZRgCIAEoCzIeLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLkxhYmVsOgI4ASI2ChhDYXBhYmlsaXR5TWV0aG9kTWV0YWRhdGESGgoSbWFwX3RvX3VudHlwZWRfYXBpGAEgASgIOm4KCmNhcGFiaWxpdHkSHy5nb29nbGUucHJvdG9idWYuU2VydmljZU9wdGlvbnMY0IYDIAEoCzIrLnRvb2xzLmdlbmVyYXRvci52MWFscGhhLkNhcGFiaWxpdHlNZXRhZGF0YVIKY2FwYWJpbGl0eTprCgZtZXRob2QSHi5nb29nbGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxjRhgMgASgLMjEudG9vbHMuZ2VuZXJhdG9yLnYxYWxwaGEuQ2FwYWJpbGl0eU1ldGhvZE1ldGFkYXRhUgZtZXRob2RCrwEKG2NvbS50b29scy5nZW5lcmF0b3IudjFhbHBoYUIQQ3JlTWV0YWRhdGFQcm90b1ABogIDVEdYqgIXVG9vbHMuR2VuZXJhdG9yLlYxYWxwaGHKAhhUb29sc1xHZW5lcmF0b3JfXFYxYWxwaGHiAiRUb29sc1xHZW5lcmF0b3JfXFYxYWxwaGFcR1BCTWV0YWRhdGHqAhlUb29sczo6R2VuZXJhdG9yOjpWMWFscGhhYgZwcm90bzM", [file_google_protobuf_descriptor, file_sdk_v1alpha_sdk]); + +/** + * @generated from message tools.generator.v1alpha.StringLabel + */ +export type StringLabel = Message<"tools.generator.v1alpha.StringLabel"> & { + /** + * @generated from field: map defaults = 1; + */ + defaults: { [key: string]: string }; +}; + +/** + * @generated from message tools.generator.v1alpha.StringLabel + */ +export type StringLabelJson = { + /** + * @generated from field: map defaults = 1; + */ + defaults?: { [key: string]: string }; +}; + +/** + * Describes the message tools.generator.v1alpha.StringLabel. + * Use `create(StringLabelSchema)` to create a new message. + */ +export const StringLabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 0); + +/** + * @generated from message tools.generator.v1alpha.Uint64Label + */ +export type Uint64Label = Message<"tools.generator.v1alpha.Uint64Label"> & { + /** + * @generated from field: map defaults = 1; + */ + defaults: { [key: string]: bigint }; +}; + +/** + * @generated from message tools.generator.v1alpha.Uint64Label + */ +export type Uint64LabelJson = { + /** + * @generated from field: map defaults = 1; + */ + defaults?: { [key: string]: string }; +}; + +/** + * Describes the message tools.generator.v1alpha.Uint64Label. + * Use `create(Uint64LabelSchema)` to create a new message. + */ +export const Uint64LabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 1); + +/** + * @generated from message tools.generator.v1alpha.Uint32Label + */ +export type Uint32Label = Message<"tools.generator.v1alpha.Uint32Label"> & { + /** + * @generated from field: map defaults = 1; + */ + defaults: { [key: string]: number }; +}; + +/** + * @generated from message tools.generator.v1alpha.Uint32Label + */ +export type Uint32LabelJson = { + /** + * @generated from field: map defaults = 1; + */ + defaults?: { [key: string]: number }; +}; + +/** + * Describes the message tools.generator.v1alpha.Uint32Label. + * Use `create(Uint32LabelSchema)` to create a new message. + */ +export const Uint32LabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 2); + +/** + * @generated from message tools.generator.v1alpha.Int64Label + */ +export type Int64Label = Message<"tools.generator.v1alpha.Int64Label"> & { + /** + * @generated from field: map defaults = 1; + */ + defaults: { [key: string]: bigint }; +}; + +/** + * @generated from message tools.generator.v1alpha.Int64Label + */ +export type Int64LabelJson = { + /** + * @generated from field: map defaults = 1; + */ + defaults?: { [key: string]: string }; +}; + +/** + * Describes the message tools.generator.v1alpha.Int64Label. + * Use `create(Int64LabelSchema)` to create a new message. + */ +export const Int64LabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 3); + +/** + * @generated from message tools.generator.v1alpha.Int32Label + */ +export type Int32Label = Message<"tools.generator.v1alpha.Int32Label"> & { + /** + * @generated from field: map defaults = 1; + */ + defaults: { [key: string]: number }; +}; + +/** + * @generated from message tools.generator.v1alpha.Int32Label + */ +export type Int32LabelJson = { + /** + * @generated from field: map defaults = 1; + */ + defaults?: { [key: string]: number }; +}; + +/** + * Describes the message tools.generator.v1alpha.Int32Label. + * Use `create(Int32LabelSchema)` to create a new message. + */ +export const Int32LabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 4); + +/** + * @generated from message tools.generator.v1alpha.Label + */ +export type Label = Message<"tools.generator.v1alpha.Label"> & { + /** + * @generated from oneof tools.generator.v1alpha.Label.kind + */ + kind: { + /** + * @generated from field: tools.generator.v1alpha.StringLabel string_label = 1; + */ + value: StringLabel; + case: "stringLabel"; + } | { + /** + * @generated from field: tools.generator.v1alpha.Uint64Label uint64_label = 2; + */ + value: Uint64Label; + case: "uint64Label"; + } | { + /** + * @generated from field: tools.generator.v1alpha.Int64Label int64_label = 3; + */ + value: Int64Label; + case: "int64Label"; + } | { + /** + * @generated from field: tools.generator.v1alpha.Uint32Label uint32_label = 4; + */ + value: Uint32Label; + case: "uint32Label"; + } | { + /** + * @generated from field: tools.generator.v1alpha.Int32Label int32_label = 5; + */ + value: Int32Label; + case: "int32Label"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message tools.generator.v1alpha.Label + */ +export type LabelJson = { + /** + * @generated from field: tools.generator.v1alpha.StringLabel string_label = 1; + */ + stringLabel?: StringLabelJson; + + /** + * @generated from field: tools.generator.v1alpha.Uint64Label uint64_label = 2; + */ + uint64Label?: Uint64LabelJson; + + /** + * @generated from field: tools.generator.v1alpha.Int64Label int64_label = 3; + */ + int64Label?: Int64LabelJson; + + /** + * @generated from field: tools.generator.v1alpha.Uint32Label uint32_label = 4; + */ + uint32Label?: Uint32LabelJson; + + /** + * @generated from field: tools.generator.v1alpha.Int32Label int32_label = 5; + */ + int32Label?: Int32LabelJson; +}; + +/** + * Describes the message tools.generator.v1alpha.Label. + * Use `create(LabelSchema)` to create a new message. + */ +export const LabelSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 5); + +/** + * @generated from message tools.generator.v1alpha.CapabilityMetadata + */ +export type CapabilityMetadata = Message<"tools.generator.v1alpha.CapabilityMetadata"> & { + /** + * @generated from field: sdk.v1alpha.Mode mode = 1; + */ + mode: Mode; + + /** + * @generated from field: string capability_id = 2; + */ + capabilityId: string; + + /** + * @generated from field: map labels = 3; + */ + labels: { [key: string]: Label }; +}; + +/** + * @generated from message tools.generator.v1alpha.CapabilityMetadata + */ +export type CapabilityMetadataJson = { + /** + * @generated from field: sdk.v1alpha.Mode mode = 1; + */ + mode?: ModeJson; + + /** + * @generated from field: string capability_id = 2; + */ + capabilityId?: string; + + /** + * @generated from field: map labels = 3; + */ + labels?: { [key: string]: LabelJson }; +}; + +/** + * Describes the message tools.generator.v1alpha.CapabilityMetadata. + * Use `create(CapabilityMetadataSchema)` to create a new message. + */ +export const CapabilityMetadataSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 6); + +/** + * @generated from message tools.generator.v1alpha.CapabilityMethodMetadata + */ +export type CapabilityMethodMetadata = Message<"tools.generator.v1alpha.CapabilityMethodMetadata"> & { + /** + * @generated from field: bool map_to_untyped_api = 1; + */ + mapToUntypedApi: boolean; +}; + +/** + * @generated from message tools.generator.v1alpha.CapabilityMethodMetadata + */ +export type CapabilityMethodMetadataJson = { + /** + * @generated from field: bool map_to_untyped_api = 1; + */ + mapToUntypedApi?: boolean; +}; + +/** + * Describes the message tools.generator.v1alpha.CapabilityMethodMetadata. + * Use `create(CapabilityMethodMetadataSchema)` to create a new message. + */ +export const CapabilityMethodMetadataSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_tools_generator_v1alpha_cre_metadata, 7); + +/** + * 50000-99999 is the range for custom options. + * + * @generated from extension: tools.generator.v1alpha.CapabilityMetadata capability = 50000; + */ +export const capability: GenExtension = /*@__PURE__*/ + extDesc(file_tools_generator_v1alpha_cre_metadata, 0); + +/** + * 50000-99999 is the range for custom options. + * + * @generated from extension: tools.generator.v1alpha.CapabilityMethodMetadata method = 50001; + */ +export const method: GenExtension = /*@__PURE__*/ + extDesc(file_tools_generator_v1alpha_cre_metadata, 1); + diff --git a/src/generated/values/v1/values_pb.ts b/src/generated/values/v1/values_pb.ts new file mode 100644 index 00000000..071ec3f0 --- /dev/null +++ b/src/generated/values/v1/values_pb.ts @@ -0,0 +1,276 @@ +// @generated by protoc-gen-es v2.6.3 with parameter "target=ts,import_extension=none,json_types=true,keep_empty_files=false" +// @generated from file values/v1/values.proto (package values.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Timestamp, TimestampJson } from "@bufbuild/protobuf/wkt"; +import { file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file values/v1/values.proto. + */ +export const file_values_v1_values: GenFile = /*@__PURE__*/ + fileDesc("ChZ2YWx1ZXMvdjEvdmFsdWVzLnByb3RvEgl2YWx1ZXMudjEi5QIKBVZhbHVlEhYKDHN0cmluZ192YWx1ZRgBIAEoCUgAEhQKCmJvb2xfdmFsdWUYAiABKAhIABIVCgtieXRlc192YWx1ZRgDIAEoDEgAEiMKCW1hcF92YWx1ZRgEIAEoCzIOLnZhbHVlcy52MS5NYXBIABIlCgpsaXN0X3ZhbHVlGAUgASgLMg8udmFsdWVzLnYxLkxpc3RIABIrCg1kZWNpbWFsX3ZhbHVlGAYgASgLMhIudmFsdWVzLnYxLkRlY2ltYWxIABIZCgtpbnQ2NF92YWx1ZRgHIAEoA0ICMAFIABIpCgxiaWdpbnRfdmFsdWUYCSABKAsyES52YWx1ZXMudjEuQmlnSW50SAASMAoKdGltZV92YWx1ZRgKIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBIABIXCg1mbG9hdDY0X3ZhbHVlGAsgASgBSABCBwoFdmFsdWVKBAgIEAkiKwoGQmlnSW50Eg8KB2Fic192YWwYASABKAwSEAoEc2lnbhgCIAEoA0ICMAEicgoDTWFwEioKBmZpZWxkcxgBIAMoCzIaLnZhbHVlcy52MS5NYXAuRmllbGRzRW50cnkaPwoLRmllbGRzRW50cnkSCwoDa2V5GAEgASgJEh8KBXZhbHVlGAIgASgLMhAudmFsdWVzLnYxLlZhbHVlOgI4ASIoCgRMaXN0EiAKBmZpZWxkcxgCIAMoCzIQLnZhbHVlcy52MS5WYWx1ZSJDCgdEZWNpbWFsEiYKC2NvZWZmaWNpZW50GAEgASgLMhEudmFsdWVzLnYxLkJpZ0ludBIQCghleHBvbmVudBgCIAEoBUJhCg1jb20udmFsdWVzLnYxQgtWYWx1ZXNQcm90b1ABogIDVlhYqgIJVmFsdWVzLlYxygIJVmFsdWVzXFYx4gIVVmFsdWVzXFYxXEdQQk1ldGFkYXRh6gIKVmFsdWVzOjpWMWIGcHJvdG8z", [file_google_protobuf_timestamp]); + +/** + * @generated from message values.v1.Value + */ +export type Value = Message<"values.v1.Value"> & { + /** + * @generated from oneof values.v1.Value.value + */ + value: { + /** + * @generated from field: string string_value = 1; + */ + value: string; + case: "stringValue"; + } | { + /** + * @generated from field: bool bool_value = 2; + */ + value: boolean; + case: "boolValue"; + } | { + /** + * @generated from field: bytes bytes_value = 3; + */ + value: Uint8Array; + case: "bytesValue"; + } | { + /** + * @generated from field: values.v1.Map map_value = 4; + */ + value: Map; + case: "mapValue"; + } | { + /** + * @generated from field: values.v1.List list_value = 5; + */ + value: List; + case: "listValue"; + } | { + /** + * @generated from field: values.v1.Decimal decimal_value = 6; + */ + value: Decimal; + case: "decimalValue"; + } | { + /** + * @generated from field: int64 int64_value = 7 [jstype = JS_STRING]; + */ + value: string; + case: "int64Value"; + } | { + /** + * @generated from field: values.v1.BigInt bigint_value = 9; + */ + value: BigInt; + case: "bigintValue"; + } | { + /** + * @generated from field: google.protobuf.Timestamp time_value = 10; + */ + value: Timestamp; + case: "timeValue"; + } | { + /** + * @generated from field: double float64_value = 11; + */ + value: number; + case: "float64Value"; + } | { case: undefined; value?: undefined }; +}; + +/** + * @generated from message values.v1.Value + */ +export type ValueJson = { + /** + * @generated from field: string string_value = 1; + */ + stringValue?: string; + + /** + * @generated from field: bool bool_value = 2; + */ + boolValue?: boolean; + + /** + * @generated from field: bytes bytes_value = 3; + */ + bytesValue?: string; + + /** + * @generated from field: values.v1.Map map_value = 4; + */ + mapValue?: MapJson; + + /** + * @generated from field: values.v1.List list_value = 5; + */ + listValue?: ListJson; + + /** + * @generated from field: values.v1.Decimal decimal_value = 6; + */ + decimalValue?: DecimalJson; + + /** + * @generated from field: int64 int64_value = 7 [jstype = JS_STRING]; + */ + int64Value?: string; + + /** + * @generated from field: values.v1.BigInt bigint_value = 9; + */ + bigintValue?: BigIntJson; + + /** + * @generated from field: google.protobuf.Timestamp time_value = 10; + */ + timeValue?: TimestampJson; + + /** + * @generated from field: double float64_value = 11; + */ + float64Value?: number | "NaN" | "Infinity" | "-Infinity"; +}; + +/** + * Describes the message values.v1.Value. + * Use `create(ValueSchema)` to create a new message. + */ +export const ValueSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_values_v1_values, 0); + +/** + * @generated from message values.v1.BigInt + */ +export type BigInt = Message<"values.v1.BigInt"> & { + /** + * @generated from field: bytes abs_val = 1; + */ + absVal: Uint8Array; + + /** + * @generated from field: int64 sign = 2 [jstype = JS_STRING]; + */ + sign: string; +}; + +/** + * @generated from message values.v1.BigInt + */ +export type BigIntJson = { + /** + * @generated from field: bytes abs_val = 1; + */ + absVal?: string; + + /** + * @generated from field: int64 sign = 2 [jstype = JS_STRING]; + */ + sign?: string; +}; + +/** + * Describes the message values.v1.BigInt. + * Use `create(BigIntSchema)` to create a new message. + */ +export const BigIntSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_values_v1_values, 1); + +/** + * @generated from message values.v1.Map + */ +export type Map = Message<"values.v1.Map"> & { + /** + * @generated from field: map fields = 1; + */ + fields: { [key: string]: Value }; +}; + +/** + * @generated from message values.v1.Map + */ +export type MapJson = { + /** + * @generated from field: map fields = 1; + */ + fields?: { [key: string]: ValueJson }; +}; + +/** + * Describes the message values.v1.Map. + * Use `create(MapSchema)` to create a new message. + */ +export const MapSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_values_v1_values, 2); + +/** + * @generated from message values.v1.List + */ +export type List = Message<"values.v1.List"> & { + /** + * @generated from field: repeated values.v1.Value fields = 2; + */ + fields: Value[]; +}; + +/** + * @generated from message values.v1.List + */ +export type ListJson = { + /** + * @generated from field: repeated values.v1.Value fields = 2; + */ + fields?: ValueJson[]; +}; + +/** + * Describes the message values.v1.List. + * Use `create(ListSchema)` to create a new message. + */ +export const ListSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_values_v1_values, 3); + +/** + * @generated from message values.v1.Decimal + */ +export type Decimal = Message<"values.v1.Decimal"> & { + /** + * @generated from field: values.v1.BigInt coefficient = 1; + */ + coefficient?: BigInt; + + /** + * @generated from field: int32 exponent = 2; + */ + exponent: number; +}; + +/** + * @generated from message values.v1.Decimal + */ +export type DecimalJson = { + /** + * @generated from field: values.v1.BigInt coefficient = 1; + */ + coefficient?: BigIntJson; + + /** + * @generated from field: int32 exponent = 2; + */ + exponent?: number; +}; + +/** + * Describes the message values.v1.Decimal. + * Use `create(DecimalSchema)` to create a new message. + */ +export const DecimalSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_values_v1_values, 4); + diff --git a/src/generator/generate-action.ts b/src/generator/generate-action.ts new file mode 100644 index 00000000..9fef9382 --- /dev/null +++ b/src/generator/generate-action.ts @@ -0,0 +1,48 @@ +import type { DescMethod } from "@bufbuild/protobuf"; + +/** + * Generates the action method implementation for a capability + * + * @param method - The method descriptor + * @param methodName - The camelCase method name + * @param capabilityClassName - The class name of the capability object + * @returns The generated action method code + */ +export function generateActionMethod( + method: DescMethod, + methodName: string, + capabilityClassName: string +): string { + return ` + async ${methodName}(input: ${method.input.name}Json): Promise<${method.output.name}> { + const payload = { + typeUrl: getTypeUrl(${method.input.name}Schema), + value: toBinary(${method.input.name}Schema, fromJson(${method.input.name}Schema, input)), + }; + + return callCapability({ + capabilityId: ${capabilityClassName}.CAPABILITY_ID, + method: "${method.name}", + mode: this.mode, + payload, + }).then((capabilityResponse: CapabilityResponse) => { + if (capabilityResponse.response.case === "error") { + throw new CapabilityError(capabilityResponse.response.value, { + capabilityId: ${capabilityClassName}.CAPABILITY_ID, + method: "${method.name}", + mode: this.mode, + }); + } + + if (capabilityResponse.response.case !== "payload") { + throw new CapabilityError("No payload in response", { + capabilityId: ${capabilityClassName}.CAPABILITY_ID, + method: "${method.name}", + mode: this.mode, + }); + } + + return fromBinary(${method.output.name}Schema, capabilityResponse.response.value.value); + }); + }`; +} diff --git a/src/generator/generate-sdk.ts b/src/generator/generate-sdk.ts new file mode 100644 index 00000000..655070ec --- /dev/null +++ b/src/generator/generate-sdk.ts @@ -0,0 +1,213 @@ +import { writeFileSync, mkdirSync } from "node:fs"; +import { join, dirname } from "node:path"; +import { getExtension, type DescService } from "@bufbuild/protobuf"; +import { + capability, + method as methodOption, +} from "@cre/generated/tools/generator/v1alpha/cre_metadata_pb"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { GenFile } from "@bufbuild/protobuf/codegenv2"; +import type { CapabilityMetadata } from "@cre/generated/tools/generator/v1alpha/cre_metadata_pb"; +import { generateActionMethod } from "./generate-action"; +import { + generateTriggerMethod, + generateTriggerClass, +} from "./generate-trigger"; +import { lowerCaseFirstLetter, getImportPathForFile } from "./utils"; + +const getCapabilityServiceOptions = ( + service: DescService +): CapabilityMetadata | false => { + if (!service.proto.options) { + return false; + } + + const capabilityOption = getExtension(service.proto.options, capability); + return capabilityOption || false; +}; + +/** + * Generates SDK for a given file (should include capability service). + * + * @param file - The file to generate the SDK for. + * @param outputDir - The directory to output the SDK to. + */ +export function generateSdk(file: GenFile, outputDir: string) { + const capabilityServices = file.services.filter(getCapabilityServiceOptions); + if (capabilityServices.length === 0) { + console.warn(`No capability services found in ${file.name}. Skipping...`); + return; + } + + // Process each service + capabilityServices.forEach((service) => { + const capOption = getCapabilityServiceOptions(service); + if (!capOption) { + // Shouldn't happen, we already filtered for services with capability metadata. + return; + } + + // Generate imports - collect all unique types first + const typeImports = new Map>(); + + // Process each method to collect types + service.methods.forEach((method) => { + // Handle input type + const inputFile = method.input.file; + const inputPath = + inputFile.name === file.name + ? `@cre/generated/${file.name}_pb` + : getImportPathForFile(inputFile.name); + + if (!typeImports.has(inputPath)) { + typeImports.set(inputPath, new Set()); + } + + const inputPathTypes = typeImports.get(inputPath)!; + inputPathTypes.add(`${method.input.name}Schema`); + inputPathTypes.add(`type ${method.input.name}Json`); + + // Handle output type + const outputFile = method.output.file; + const outputPath = + outputFile.name === file.name + ? `@cre/generated/${file.name}_pb` + : getImportPathForFile(outputFile.name); + + if (!typeImports.has(outputPath)) { + typeImports.set(outputPath, new Set()); + } + + const outputPathTypes = typeImports.get(outputPath)!; + outputPathTypes.add(`${method.output.name}Schema`); + outputPathTypes.add(`type ${method.output.name}`); + }); + + // Check if we have any triggers + const hasTriggers = service.methods.some( + (m) => m.methodKind === "server_streaming" + ); + + // Build import statements + const imports = new Set(); + imports.add( + 'import { fromBinary, toBinary, fromJson, create } from "@bufbuild/protobuf";' + ); + imports.add(`import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb";`); + imports.add( + `import { callCapability } from "@cre/sdk/utils/capabilities/call-capability";` + ); + imports.add( + `import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error";` + ); + + // Add trigger imports if needed + if (hasTriggers) { + imports.add( + `import { BaseTriggerImpl } from "@cre/sdk/utils/triggers/trigger-interface";` + ); + imports.add( + `import { type Any, AnySchema } from "@bufbuild/protobuf/wkt";` + ); + } + + // Always import getTypeUrl when we generate Any payloads + imports.add(`import { getTypeUrl } from "@cre/sdk/utils/typeurl";`); + + // Generate deduplicated type imports + typeImports.forEach((types, path) => { + const sortedTypes = Array.from(types).sort(); + imports.add(`import { + ${sortedTypes.join(",\n ")}, +} from "${path}";`); + }); + + const capabilityClassName = `${service.name}Capability`; + + // Generate methods + const methods = service.methods + .map((method) => { + const methodName = lowerCaseFirstLetter(method.name); + + // Check for method-specific options + const methodMeta = method.proto.options + ? getExtension(method.proto.options, methodOption) + : null; + + // Skip methods that map to untyped API if configured + if (methodMeta?.mapToUntypedApi) { + return ` + // Method ${methodName} is mapped to untyped API`; + } + + // Check if this is a streaming method (trigger) + if (method.methodKind === "server_streaming") { + return generateTriggerMethod( + method, + methodName, + capabilityClassName, + service.name + ); + } + + // Generate action method + return generateActionMethod(method, methodName, capabilityClassName); + }) + .join("\n"); + + // Generate trigger classes + const triggerClasses = service.methods + .filter((method) => method.methodKind === "server_streaming") + .map((method) => generateTriggerClass(method, service.name)) + .join("\n"); + + // Determine default mode from metadata: NODE is specifically stated, DON otherwise. + const defaultMode = capOption.mode === Mode.NODE ? "Mode.NODE" : "Mode.DON"; + + // Add JSDoc with metadata information + const classComment = ` +/** + * ${service.name} Capability + * + * Capability ID: ${capOption.capabilityId} + * Default Mode: ${defaultMode} + */`; + + // Generate the complete file + const output = `${Array.from(imports).join("\n")} +${classComment} +export class ${capabilityClassName} { + /** The capability ID for this service */ + static readonly CAPABILITY_ID = "${capOption.capabilityId}"; + + /** The default execution mode for this capability */ + static readonly DEFAULT_MODE = ${defaultMode}; + + constructor( + private readonly mode: Mode = ${service.name}Capability.DEFAULT_MODE + ) {} +${methods} +} +${triggerClasses}`; + + // Determine output path + const serviceNameLowerCased: Lowercase = + service.name.toLowerCase() as Lowercase; + const outputPath = join( + outputDir, + dirname(file.name), + `${serviceNameLowerCased}_sdk_gen.ts` + ); + + // Create directory if needed + mkdirSync(dirname(outputPath), { recursive: true }); + + // Write file + writeFileSync(outputPath, output); + + console.log(`✅ Generated SDK for ${service.name} at: ${outputPath} .`); + }); +} diff --git a/src/generator/generate-trigger.ts b/src/generator/generate-trigger.ts new file mode 100644 index 00000000..c265a34a --- /dev/null +++ b/src/generator/generate-trigger.ts @@ -0,0 +1,86 @@ +import type { DescMethod } from "@bufbuild/protobuf"; + +/** + * Generates the trigger method implementation for a capability + * + * @param method - The method descriptor + * @param methodName - The camelCase method name + * @param capabilityId - The capability ID + * @param className - The capability class name + * @returns The generated trigger method code + */ +export function generateTriggerMethod( + method: DescMethod, + methodName: string, + capabilityClassName: string, + className: string +): string { + const triggerClassName = `${className}${method.name}`; + + return ` + ${methodName}(config: ${method.input.name}Json): ${triggerClassName} { + return new ${triggerClassName}(this.mode, config, ${capabilityClassName}.CAPABILITY_ID, "${method.name}"); + }`; +} + +/** + * Generates the trigger class implementation + * + * @param method - The method descriptor + * @param capabilityId - The capability ID + * @param className - The capability class name + * @returns The generated trigger class code + */ +export function generateTriggerClass( + method: DescMethod, + className: string +): string { + const triggerClassName = `${className}${method.name}`; + + return ` +/** + * Trigger implementation for ${method.name} + */ +class ${triggerClassName} extends BaseTriggerImpl<${method.input.name}Json, ${method.output.name}> { + constructor( + mode: Mode, + config: ${method.input.name}Json, + private readonly _capabilityId: string, + private readonly _method: string + ) { + super(mode, config); + } + + capabilityId(): string { + return this._capabilityId; + } + + method(): string { + return this._method; + } + + newOutput(): ${method.output.name} { + return create(${method.output.name}Schema); + } + + outputSchema() { + return ${method.output.name}Schema; + } + + configAsAny(): Any { + const configMessage = fromJson(${method.input.name}Schema, this.config); + return create(AnySchema, { + typeUrl: getTypeUrl(${method.input.name}Schema), + value: toBinary(${method.input.name}Schema, configMessage), + }); + } + + /** + * Transform the trigger output - override this method if needed + * Default implementation returns the output unchanged + */ + adapt(output: ${method.output.name}): ${method.output.name} { + return output; + } +}`; +} diff --git a/src/generator/utils.ts b/src/generator/utils.ts new file mode 100644 index 00000000..ceed44be --- /dev/null +++ b/src/generator/utils.ts @@ -0,0 +1,19 @@ +/** + * Converts first letter of string to lowercase + */ +export const lowerCaseFirstLetter = (str: string) => + `${str.charAt(0).toLowerCase()}${str.slice(1)}`; + +/** + * Gets the import path for a given protobuf file + */ +export const getImportPathForFile = (fileName: string): string => { + // Handle well-known types from protobuf + // TODO: validate if there isn't nicer way around this + if (fileName === "google/protobuf/empty") { + return "@bufbuild/protobuf/wkt"; + } + + // Default to local generated path + return `@cre/generated/${fileName.replace(".proto", "")}_pb`; +}; \ No newline at end of file diff --git a/src/sdk/cre/index.ts b/src/sdk/cre/index.ts new file mode 100644 index 00000000..bb0dc2f3 --- /dev/null +++ b/src/sdk/cre/index.ts @@ -0,0 +1,8 @@ +/** + * Public API for the CRE SDK. + */ +import { callCapability } from "@cre/sdk/utils/capabilities/call-capability"; + +export const cre = { + callCapability, +}; diff --git a/src/sdk/engine/execute.test.ts b/src/sdk/engine/execute.test.ts new file mode 100644 index 00000000..fff3d5b3 --- /dev/null +++ b/src/sdk/engine/execute.test.ts @@ -0,0 +1,187 @@ +import { describe, test, expect, mock, beforeEach } from "bun:test"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { Handler } from "@cre/sdk/workflow"; +import { create, toBinary, fromBinary } from "@bufbuild/protobuf"; +import { + ExecuteRequestSchema, + type ExecuteRequest, + ExecutionResultSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { EmptySchema } from "@bufbuild/protobuf/wkt"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; +import { BasicCapability as ActionAndTriggerCapability } from "@cre/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen"; +import { TriggerEventSchema as ActionTriggerEventSchema } from "@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb"; +import { OutputsSchema as BasicTriggerOutputsSchema } from "@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; + +const decodeExecutionResult = (b64: string) => + fromBinary(ExecutionResultSchema, Buffer.from(b64, "base64")); + +describe("engine/execute", () => { + let originalSendResponse: typeof globalThis.sendResponse; + + beforeEach(() => { + originalSendResponse = globalThis.sendResponse; + }); + + test("subscribe returns TriggerSubscriptionRequest wrapped in ExecutionResult", async () => { + const subs: string[] = []; + // mock sendResponse to capture base64 payload + globalThis.sendResponse = mock((resp: string) => { + const exec = decodeExecutionResult(resp); + const ts = + exec.result.case === "triggerSubscriptions" + ? exec.result.value + : undefined; + expect(ts).toBeDefined(); + expect(ts!.subscriptions.length).toBe(3); + ts!.subscriptions.forEach((s) => + subs.push(`${s.id}:${s.method}:${s.payload?.typeUrl}`) + ); + return 0; + }); + + const basic = new BasicTriggerCapability(); + const action = new ActionAndTriggerCapability(); + const workflow = [ + Handler(basic.trigger({ name: "first-trigger", number: 100 }), () => {}), + Handler( + action.trigger({ name: "second-trigger", number: 150 }), + () => {} + ), + Handler(basic.trigger({ name: "third-trigger", number: 200 }), () => {}), + ]; + + const req: ExecuteRequest = create(ExecuteRequestSchema, { + config: new Uint8Array(), + request: { case: "subscribe", value: create(EmptySchema) }, + maxResponseSize: "0", + }); + + await handleExecuteRequest(req, workflow); + + expect(subs[0]).toContain( + "basic-test-trigger@1.0.0:Trigger:type.googleapis.com/capabilities.internal.basictrigger.v1.Config" + ); + expect(subs[1]).toContain( + "basic-test-action-trigger@1.0.0:Trigger:type.googleapis.com/capabilities.internal.actionandtrigger.v1.Config" + ); + expect(subs[2]).toContain( + "basic-test-trigger@1.0.0:Trigger:type.googleapis.com/capabilities.internal.basictrigger.v1.Config" + ); + + globalThis.sendResponse = originalSendResponse; + }); + + test("trigger routes by id and decodes payload for correct handler", async () => { + const calls: string[] = []; + + const basic = new BasicTriggerCapability(); + const action = new ActionAndTriggerCapability(); + const workflow = [ + Handler( + basic.trigger({ name: "first-trigger", number: 100 }), + (_e, _r, out) => { + // @ts-ignore + calls.push(`basic:${out.coolOutput}`); + } + ), + Handler( + action.trigger({ name: "second-trigger", number: 150 }), + (_e, _r, out) => { + // @ts-ignore + calls.push(`action:${out.coolOutput}`); + } + ), + Handler( + basic.trigger({ name: "third-trigger", number: 200 }), + (_e, _r, out) => { + // @ts-ignore + calls.push(`basic2:${out.coolOutput}`); + } + ), + ]; + + // Build ExecuteRequest with id=1 (second handler) and payload of Action TriggerEvent + const payloadAny = { + typeUrl: getTypeUrl(ActionTriggerEventSchema), + value: toBinary( + ActionTriggerEventSchema, + create(ActionTriggerEventSchema, { coolOutput: "different" }) + ), + }; + const req: ExecuteRequest = create(ExecuteRequestSchema, { + config: new Uint8Array(), + request: { + case: "trigger", + value: { id: "1", payload: payloadAny }, + }, + maxResponseSize: "0", + }); + + await handleExecuteRequest(req, workflow); + + expect(calls).toEqual(["action:different"]); + }); + + test("trigger ignores out-of-range id (no handler invoked)", async () => { + const calls: string[] = []; + const basic = new BasicTriggerCapability(); + const action = new ActionAndTriggerCapability(); + const workflow = [ + Handler(basic.trigger({ name: "first-trigger", number: 100 }), () => { + calls.push("basic"); + }), + Handler(action.trigger({ name: "second-trigger", number: 150 }), () => { + calls.push("action"); + }), + ]; + + const payloadAny = { + typeUrl: getTypeUrl(ActionTriggerEventSchema), + value: toBinary( + ActionTriggerEventSchema, + create(ActionTriggerEventSchema, { coolOutput: "x" }) + ), + }; + const req: ExecuteRequest = create(ExecuteRequestSchema, { + config: new Uint8Array(), + request: { case: "trigger", value: { id: "999", payload: payloadAny } }, + maxResponseSize: "0", + }); + + await handleExecuteRequest(req, workflow); + expect(calls).toEqual([]); + }); + + test("trigger ignores typeUrl mismatch for targeted handler", async () => { + const calls: string[] = []; + const basic = new BasicTriggerCapability(); + const action = new ActionAndTriggerCapability(); + const workflow = [ + Handler(basic.trigger({ name: "first-trigger", number: 100 }), () => { + calls.push("basic"); + }), + Handler(action.trigger({ name: "second-trigger", number: 150 }), () => { + calls.push("action"); + }), + ]; + + // Intentionally send BasicTriggerOutputs payload to the action trigger handler (index 1) + const payloadAny = { + typeUrl: `type.googleapis.com/${BasicTriggerOutputsSchema.typeName}`, + value: toBinary( + BasicTriggerOutputsSchema, + create(BasicTriggerOutputsSchema, { coolOutput: "mismatch" }) + ), + }; + const req: ExecuteRequest = create(ExecuteRequestSchema, { + config: new Uint8Array(), + request: { case: "trigger", value: { id: "1", payload: payloadAny } }, + maxResponseSize: "0", + }); + + await handleExecuteRequest(req, workflow); + expect(calls).toEqual([]); + }); +}); diff --git a/src/sdk/engine/execute.ts b/src/sdk/engine/execute.ts new file mode 100644 index 00000000..ecb10ea2 --- /dev/null +++ b/src/sdk/engine/execute.ts @@ -0,0 +1,73 @@ +import type { + ExecuteRequest, + CapabilityResponse, + ExecutionResult, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { + TriggerSubscriptionRequestSchema, + ExecutionResultSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { fromBinary, create, toBinary } from "@bufbuild/protobuf"; +import type { Workflow, Environment, Runtime } from "@cre/sdk/workflow"; +import { getTypeUrl } from "@cre/sdk/utils/typeurl"; +import { buildEnvFromExecuteRequest } from "@cre/sdk/utils/env"; + +export const handleExecuteRequest = async ( + req: ExecuteRequest, + workflow: Workflow, + env: Environment = {}, + rt: Runtime = {} +): Promise => { + if (req.request.case === "subscribe") { + // Build TriggerSubscriptionRequest from the workflow entries + const subscriptions = workflow.map((entry) => ({ + id: entry.trigger.capabilityId(), + method: entry.trigger.method(), + payload: entry.trigger.configAsAny(), + })); + + const subscriptionRequest = create(TriggerSubscriptionRequestSchema, { + subscriptions, + }); + + // Wrap in ExecutionResult.triggerSubscriptions + const execResult: ExecutionResult = create(ExecutionResultSchema, { + result: { case: "triggerSubscriptions", value: subscriptionRequest }, + }); + + const encoded = toBinary(ExecutionResultSchema, execResult); + sendResponse(Buffer.from(encoded).toString("base64")); + return undefined; + } + + if (req.request.case === "trigger") { + const triggerMsg = req.request.value; + const index = Number(triggerMsg.id); + if (Number.isFinite(index) && index >= 0 && index < workflow.length) { + const entry = workflow[index]; + const schema = entry.trigger.outputSchema(); + const payloadAny = triggerMsg.payload; + if (!payloadAny) return undefined; + + // Extra safety: verify payload typeUrl matches expected schema type + const expectedTypeUrl = getTypeUrl(schema); + if (payloadAny.typeUrl && payloadAny.typeUrl !== expectedTypeUrl) { + return undefined; + } + + /** + * Note: do not hardcode method name; routing by id is authoritative. + * + * This matches the GO SDK behavior, which also just checks for the id. + * + * @see https://github.com/smartcontractkit/cre-sdk-go/blob/5a41d81e3e072008484e85dc96d746401aafcba2/cre/wasm/runner.go#L81 + * */ + const decoded = fromBinary(schema, payloadAny.value); + const adapted = await entry.trigger.adapt(decoded); + const handlerEnv: Environment = + env || buildEnvFromExecuteRequest(req); + await entry.fn(handlerEnv, rt, adapted); + } + } + return undefined; +}; diff --git a/src/sdk/runtime/run-in-node-mode.test.ts b/src/sdk/runtime/run-in-node-mode.test.ts new file mode 100644 index 00000000..1f1a7bf2 --- /dev/null +++ b/src/sdk/runtime/run-in-node-mode.test.ts @@ -0,0 +1,95 @@ +import { describe, test, expect, mock } from "bun:test"; +import { runInNodeMode } from "@cre/sdk/runtime/run-in-node-mode"; +import { create } from "@bufbuild/protobuf"; +import { + SimpleConsensusInputsSchema, + type SimpleConsensusInputsJson, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { host } from "@cre/sdk/utils/host"; + +describe("runInNodeMode", () => { + test("accepts message input and returns Value", async () => { + // spy on consensus.simple + const origSimple = ConsensusCapability.prototype.simple; + ConsensusCapability.prototype.simple = mock( + async (_: SimpleConsensusInputsJson) => { + return {} as any; // a Value; not asserting shape here + } + ); + + const res = await runInNodeMode(() => create(SimpleConsensusInputsSchema)); + expect(res).toBeDefined(); + + ConsensusCapability.prototype.simple = origSimple; + }); + + test("accepts json input and returns Value", async () => { + const origSimple = ConsensusCapability.prototype.simple; + ConsensusCapability.prototype.simple = mock( + async (_: SimpleConsensusInputsJson) => { + return {} as any; + } + ); + + const res = await runInNodeMode(() => ({} as SimpleConsensusInputsJson)); + expect(res).toBeDefined(); + + ConsensusCapability.prototype.simple = origSimple; + }); + + test("restores DON mode before calling consensus", async () => { + const calls: string[] = []; + const origSwitch = (globalThis as any).switchModes; + (globalThis as any).switchModes = (mode: 0 | 1 | 2) => { + calls.push(mode === 2 ? "NODE" : mode === 1 ? "DON" : "UNSPECIFIED"); + }; + + const origSimple = ConsensusCapability.prototype.simple; + ConsensusCapability.prototype.simple = mock( + async (_: SimpleConsensusInputsJson) => { + // At this point we expect mode to have been restored to DON + calls.push("CONSENSUS_SIMPLE"); + return {} as any; + } + ); + + await runInNodeMode(() => create(SimpleConsensusInputsSchema)); + expect(calls).toEqual(["NODE", "DON", "CONSENSUS_SIMPLE"]); + + // restore + ConsensusCapability.prototype.simple = origSimple; + (globalThis as any).switchModes = origSwitch; + }); + + test("guards DON calls while in node mode", async () => { + // Simulate host.switchModes by touching global function used by host + const origSwitch = (globalThis as any).switchModes; + (globalThis as any).switchModes = (_m: 0 | 1 | 2) => {}; + + // Mock consensus.simple but also try to make a DON call in node mode + const origSimple = ConsensusCapability.prototype.simple; + ConsensusCapability.prototype.simple = mock( + async (_: SimpleConsensusInputsJson) => { + return {} as any; + } + ); + + let threw = false; + try { + await runInNodeMode(async () => { + // During builder, we are in NODE mode, performing a DON call should throw + expect(() => host.log("")); + return create(SimpleConsensusInputsSchema); + }); + } catch (_e) { + threw = true; + } + + // The guard may not throw on host.log; rely on callCapability guard instead by attempting a DON call + // restore + ConsensusCapability.prototype.simple = origSimple; + (globalThis as any).switchModes = origSwitch; + expect(threw).toBeFalse(); + }); +}); diff --git a/src/sdk/runtime/run-in-node-mode.ts b/src/sdk/runtime/run-in-node-mode.ts new file mode 100644 index 00000000..56bce173 --- /dev/null +++ b/src/sdk/runtime/run-in-node-mode.ts @@ -0,0 +1,68 @@ +import { toJson } from "@bufbuild/protobuf"; +import { + Mode, + SimpleConsensusInputsSchema, + type SimpleConsensusInputs, + type SimpleConsensusInputsJson, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { host, runtimeGuards } from "@cre/sdk/utils/host"; +import type { Value } from "@cre/generated/values/v1/values_pb"; + +type Inputs = SimpleConsensusInputs | SimpleConsensusInputsJson; + +const isMessageInputs = (i: unknown): i is SimpleConsensusInputs => { + const anyI = i as any; + return ( + anyI && + typeof anyI === "object" && + "observation" in anyI && + anyI.observation && + typeof anyI.observation === "object" && + "case" in anyI.observation + ); +}; + +const isJsonInputs = (i: unknown): i is SimpleConsensusInputsJson => { + const anyI = i as any; + if (!anyI || typeof anyI !== "object") return false; + if (!("observation" in anyI)) return true; + const obs = anyI.observation; + if (obs == null) return true; + return typeof obs === "object" && ("value" in obs || "error" in obs); +}; + +const toInputsJson = (input: Inputs): SimpleConsensusInputsJson => { + if (isMessageInputs(input)) { + return toJson(SimpleConsensusInputsSchema, input); + } + if (isJsonInputs(input)) { + return input; + } + throw new Error( + "runInNodeMode: invalid input shape; expected SimpleConsensusInputs message or SimpleConsensusInputsJson" + ); +}; + +/** + * Runs the provided builder inside Node mode and returns the consensus result Value. + * Ensures mode is switched back to DON even if errors occur. + */ +export const runInNodeMode = async ( + buildConsensusInputs: () => Promise | Inputs +): Promise => { + host.switchModes(Mode.NODE); + let consensusInputJson: SimpleConsensusInputsJson; + try { + const consensusInput = await buildConsensusInputs(); + consensusInputJson = toInputsJson(consensusInput); + } finally { + // Always restore DON mode before invoking consensus + host.switchModes(Mode.DON); + } + + const consensus = new ConsensusCapability(); + // simple() expects JSON per generated client conventions + const result = await consensus.simple(consensusInputJson); + return result; +}; diff --git a/src/sdk/testhelpers/await-async-secret.ts b/src/sdk/testhelpers/await-async-secret.ts new file mode 100644 index 00000000..4a4f6b9d --- /dev/null +++ b/src/sdk/testhelpers/await-async-secret.ts @@ -0,0 +1,54 @@ +import { + AwaitSecretsRequestSchema, + AwaitSecretsResponseSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary, fromBinary } from "@bufbuild/protobuf"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { SecretsError } from "@cre/sdk/utils/secrets-error"; + +export const awaitAsyncSecret = async (callbackId: number) => { + // Create proper AwaitSecretsRequest protobuf message + const awaitSecretRequest = create(AwaitSecretsRequestSchema, { + ids: [callbackId], + }); + + // Encode to protobuf bytes + const awaitSecretRequestBytes = toBinary( + AwaitSecretsRequestSchema, + awaitSecretRequest + ); + + const awaitSecretRequestString = Buffer.from( + awaitSecretRequestBytes + ).toString("base64"); + + const response = awaitSecrets(awaitSecretRequestString, 1024 * 1024); + + try { + const bytes = Buffer.from(response, "base64"); + + // Decode as AwaitSecretsResponse first + const awaitResponse = fromBinary(AwaitSecretsResponseSchema, bytes); + + // Get the specific secretId response for our callback ID + const secretResponses = awaitResponse.responses[callbackId]; + if (!secretResponses || !secretResponses.responses.length) { + throw new Error(`No response found for callback ID ${callbackId}`); + } + + const secretResponse = secretResponses.responses[0]; + + if (secretResponse.response.case === "secret") { + return secretResponse.response.value.value; + } + + if (secretResponse.response.case === "error") { + throw new SecretsError(secretResponse.response.value.error); + } + + throw new Error(`No secret found for callback ID ${callbackId}`); + } catch (e) { + errorBoundary(e); + throw e; + } +}; diff --git a/src/sdk/testhelpers/do-get-secret.ts b/src/sdk/testhelpers/do-get-secret.ts new file mode 100644 index 00000000..e236b7eb --- /dev/null +++ b/src/sdk/testhelpers/do-get-secret.ts @@ -0,0 +1,26 @@ +import { + GetSecretsRequestSchema, + Mode, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary } from "@bufbuild/protobuf"; +import { + getLastCallbackId, + incrementCallbackId, +} from "@cre/sdk/utils/capabilities/callback-id"; + +export const doGetSecret = (id: string) => { + const callbackId = getLastCallbackId(Mode.DON); + incrementCallbackId(Mode.DON); + + const request = create(GetSecretsRequestSchema, { + requests: [{ id }], + callbackId, + }); + + getSecrets( + Buffer.from(toBinary(GetSecretsRequestSchema, request)).toString("utf-8"), + 1024 * 1024 + ); + + return callbackId; +}; diff --git a/src/sdk/testhelpers/send-error-wrapped.ts b/src/sdk/testhelpers/send-error-wrapped.ts new file mode 100644 index 00000000..79b5662f --- /dev/null +++ b/src/sdk/testhelpers/send-error-wrapped.ts @@ -0,0 +1,22 @@ +import { + type ExecutionResult, + ExecutionResultSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary } from "@bufbuild/protobuf"; + +// Updated sendError function that matches Go's SendError +export const sendErrorWrapped = (error: string | Error): void => { + // Create ExecutionResult with error + const execResult: ExecutionResult = create(ExecutionResultSchema, { + result: { + case: "error", + value: error instanceof Error ? error.message : error, + }, + }); + + // Marshal to protobuf bytes + const encoded = toBinary(ExecutionResultSchema, execResult); + + // Send the result + sendResponse(Buffer.from(encoded).toString("base64")); +}; diff --git a/src/sdk/types/global.d.ts b/src/sdk/types/global.d.ts new file mode 100644 index 00000000..5b42b7f4 --- /dev/null +++ b/src/sdk/types/global.d.ts @@ -0,0 +1,80 @@ +// Global type declarations for the CRE SDK runtime +// Those are the methods that the Host exposes to the Guest. + +/** + * Host functions exposed by the CRE runtime to WASM guests + */ +declare global { + /** + * Initiates an asynchronous capability call + * @param request - Base64-encoded protobuf request + * @returns Callback ID for the async operation + */ + function callCapability(request: string): number; + + /** + * Awaits completion of async capability calls + * @param awaitRequest - Base64-encoded await request + * @param maxResponseLen - Maximum response size in bytes + * @returns Base64-encoded response + */ + function awaitCapabilities( + awaitRequest: string, + maxResponseLen: number + ): string; + + /** + * Gets secrets asynchronously + * @param request - Base64-encoded secret request + * @param maxResponseLen - Maximum response size in bytes + * @returns Callback ID for the async operation + */ + function getSecrets(request: string, maxResponseLen: number): number; + + /** + * Awaits completion of async secret requests + * @param awaitRequest - Base64-encoded await request + * @param maxResponseLen - Maximum response size in bytes + * @returns Base64-encoded response + */ + function awaitSecrets(awaitRequest: string, maxResponseLen: number): string; + + /** + * Logs a message to the host runtime + * @param message - The message to log + */ + function log(message: string): void; + + /** + * Sends a response back to the host + * @param response - Base64-encoded response + * @returns Status code (0 for success) + */ + function sendResponse(response: string): number; + + /** + * Switches execution mode between NODE and DON + * @param mode - The mode to switch to (0 = UNSPECIFIED, 1 = DON, 2 = NODE) + */ + function switchModes(mode: 0 | 1 | 2): void; + + /** + * Indicates this is a V2 SDK workflow + */ + function versionV2(): void; + + /** + * Gets a random seed from the host + * @param mode - 1 for non-deterministic, 2 for deterministic + * @returns Random seed value + */ + function randomSeed(mode: 1 | 2): number; + + /** + * Gets WASI command line arguments + * @returns Serialized arguments + */ + function getWasiArgs(): string; +} + +export {}; diff --git a/src/sdk/utils/await-async-request.ts b/src/sdk/utils/await-async-request.ts new file mode 100644 index 00000000..4d99c76c --- /dev/null +++ b/src/sdk/utils/await-async-request.ts @@ -0,0 +1,54 @@ +import { + AwaitCapabilitiesRequestSchema, + AwaitCapabilitiesResponseSchema, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary, fromBinary } from "@bufbuild/protobuf"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; + +type Params = { + capabilityId: string; + method: string; + mode: Mode; +}; + +// Implementation signature (general fallback) +export async function awaitAsyncRequest( + callbackId: number, + { capabilityId, method, mode }: Params +): Promise { + // Create proper AwaitCapabilitiesRequest protobuf message + const awaitRequest = create(AwaitCapabilitiesRequestSchema, { + ids: [callbackId], + }); + + // Encode to protobuf bytes + const awaitRequestBytes = toBinary( + AwaitCapabilitiesRequestSchema, + awaitRequest + ); + + // Convert to base64 string for the host function + const awaitRequestString = Buffer.from(awaitRequestBytes).toString("base64"); + const response = awaitCapabilities(awaitRequestString, 1024 * 1024); + + const bytes = Buffer.from(response, "base64"); + + const awaitResponse = fromBinary(AwaitCapabilitiesResponseSchema, bytes); + const capabilityResponse = awaitResponse.responses[callbackId]; + + if (!capabilityResponse) { + throw new CapabilityError( + `No response found for callback ID ${callbackId}`, + { + capabilityId, + method, + mode, + callbackId, + } + ); + } + + return capabilityResponse; +} diff --git a/src/sdk/utils/capabilities/call-capability.ts b/src/sdk/utils/capabilities/call-capability.ts new file mode 100644 index 00000000..634a1501 --- /dev/null +++ b/src/sdk/utils/capabilities/call-capability.ts @@ -0,0 +1,43 @@ +import { doRequestAsync } from "@cre/sdk/utils/do-request-async"; +import { awaitAsyncRequest } from "@cre/sdk/utils/await-async-request"; +import { + Mode, + type CapabilityResponse, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { LazyPromise } from "@cre/sdk/utils/lazy-promise"; +import { runtimeGuards } from "@cre/sdk/utils/host"; + +export type CallCapabilityParams = { + capabilityId: string; + method: string; + mode: Mode; + payload: { + typeUrl: string; + value: Uint8Array; + }; +}; + +/** + * Calls a capability asynchronously and returns a promise for the response. + * The actual call is deferred until the promise is awaited (lazy execution). + * + * @param params - The capability call parameters + * @returns A promise that resolves to the capability response + */ +export function callCapability({ + capabilityId, + method, + mode = Mode.DON, + payload, +}: CallCapabilityParams): Promise { + // Guards: + // - Block DON-mode calls while currently in NODE mode + // - Block NODE-mode calls while currently in DON mode + if (mode === Mode.DON) runtimeGuards.assertDonSafe(); + if (mode === Mode.NODE) runtimeGuards.assertNodeSafe(); + const callbackId = doRequestAsync({ capabilityId, method, mode, payload }); + + return new LazyPromise(async () => { + return awaitAsyncRequest(callbackId, { capabilityId, method, mode }); + }); +} diff --git a/src/sdk/utils/capabilities/callback-id.ts b/src/sdk/utils/capabilities/callback-id.ts new file mode 100644 index 00000000..ecb04766 --- /dev/null +++ b/src/sdk/utils/capabilities/callback-id.ts @@ -0,0 +1,29 @@ +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; + +// Tracks async requests using DON mode, increments to the positive side, 0, 1, 2, 3 ... +let donCall = 0; + +// Tracks async requests using Node mode, increments to the negative side, -1, -2, -3, -4 ... +let nodeCall = -1; + +export const getLastCallbackId = (mode: Mode): number => { + if (mode !== Mode.DON && mode !== Mode.NODE) { + throw new Error(`Unsupported capability mode: ${mode}`); + } + + return mode === Mode.DON ? donCall : nodeCall; +}; + +export const incrementCallbackId = (mode: Mode): number => { + if (mode !== Mode.DON && mode !== Mode.NODE) { + throw new Error(`Unsupported capability mode: ${mode}`); + } + + if (mode === Mode.DON) { + donCall++; + return donCall; + } + + nodeCall--; + return nodeCall; +}; diff --git a/src/sdk/utils/capabilities/capability-error.ts b/src/sdk/utils/capabilities/capability-error.ts new file mode 100644 index 00000000..38f3ab56 --- /dev/null +++ b/src/sdk/utils/capabilities/capability-error.ts @@ -0,0 +1,29 @@ +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; + +export class CapabilityError extends Error { + public name: string; + public capabilityId?: string; + public method?: string; + public mode?: Mode; + public callbackId?: number; + + constructor( + message: string, + options?: { + capabilityId?: string; + method?: string; + mode?: Mode; + callbackId?: number; + } + ) { + super(message); + this.name = "CapabilityError"; + + if (options) { + this.capabilityId = options.capabilityId; + this.method = options.method; + this.mode = options.mode; + this.callbackId = options.callbackId; + } + } +} diff --git a/src/sdk/utils/do-request-async.ts b/src/sdk/utils/do-request-async.ts new file mode 100644 index 00000000..84ea2c04 --- /dev/null +++ b/src/sdk/utils/do-request-async.ts @@ -0,0 +1,44 @@ +import { + type CapabilityRequest, + CapabilityRequestSchema, + Mode, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary } from "@bufbuild/protobuf"; +import { + getLastCallbackId, + incrementCallbackId, +} from "@cre/sdk/utils/capabilities/callback-id"; + +type Params = { + capabilityId: string; + method: string; + mode: Mode; + // TODO: Payload depends on the capability. For simplicity we can accept binary data, we could consider generics support. + payload: { + typeUrl: string; + value: Uint8Array; + }; +}; + +export const doRequestAsync = ({ + capabilityId, + method, + mode, + payload, +}: Params) => { + const callbackId = getLastCallbackId(mode); + incrementCallbackId(mode); + + const req: CapabilityRequest = create(CapabilityRequestSchema, { + id: capabilityId, + method, + payload, + callbackId, + }); + + const reqBytes = toBinary(CapabilityRequestSchema, req); + + callCapability(Buffer.from(reqBytes).toString("base64")); + + return callbackId; +}; diff --git a/src/sdk/utils/env.ts b/src/sdk/utils/env.ts new file mode 100644 index 00000000..fd5f1b89 --- /dev/null +++ b/src/sdk/utils/env.ts @@ -0,0 +1,27 @@ +import type { ExecuteRequest } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { Environment } from "@cre/sdk/workflow"; + +export const buildEnvFromExecuteRequest = ( + req: ExecuteRequest, + baseEnv?: Environment +): Environment => { + const merged: Environment = { + ...(baseEnv ?? {}), + config: req.config as unknown as TConfig, + logger: baseEnv?.logger ?? { + log: (message: string) => log(String(message)), + }, + }; + return merged; +}; + +export const buildEnvFromConfig = ( + config: TConfig +): Environment => { + return { + config, + logger: { + log: (message: string) => log(String(message)), + }, + }; +}; diff --git a/src/sdk/utils/error-boundary.ts b/src/sdk/utils/error-boundary.ts new file mode 100644 index 00000000..7e61640f --- /dev/null +++ b/src/sdk/utils/error-boundary.ts @@ -0,0 +1,9 @@ +export const errorBoundary = (e: any) => { + console.log("ErrorBoundary: TS error thrown."); + if (e instanceof Error) { + console.log(e.message); + console.log(e.stack); + } else { + console.log(e); + } +}; diff --git a/src/sdk/utils/get-config.ts b/src/sdk/utils/get-config.ts new file mode 100644 index 00000000..99e752d6 --- /dev/null +++ b/src/sdk/utils/get-config.ts @@ -0,0 +1,14 @@ +import type { ExecuteRequest } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { getRequest } from "./get-request"; + +export const getConfigFromExecuteRequest = (executeRequest: ExecuteRequest) => { + const config = executeRequest.config; + const configString = Buffer.from(config).toString(); + + return JSON.parse(configString); +}; + +export const getConfig = () => { + const executeRequest: ExecuteRequest = getRequest(); + return getConfigFromExecuteRequest(executeRequest); +}; diff --git a/src/sdk/utils/get-request.ts b/src/sdk/utils/get-request.ts new file mode 100644 index 00000000..578e49e5 --- /dev/null +++ b/src/sdk/utils/get-request.ts @@ -0,0 +1,19 @@ +import { fromBinary } from "@bufbuild/protobuf"; +import { ExecuteRequestSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; + +export const getRequest = () => { + const argsString = getWasiArgs(); + const args = JSON.parse(argsString); + + // SDK expects exactly 2 args: + // 1st is the script name + // 2nd is the base64 encoded request + if (args.length !== 2) { + throw new Error("Invalid request: must contain payload"); + } + + const base64Request = args[1]; + + const bytes = Buffer.from(base64Request, "base64"); + return fromBinary(ExecuteRequestSchema, bytes); +}; diff --git a/src/sdk/utils/get-secret.ts b/src/sdk/utils/get-secret.ts new file mode 100644 index 00000000..96651e77 --- /dev/null +++ b/src/sdk/utils/get-secret.ts @@ -0,0 +1,8 @@ +import { doGetSecret } from "@cre/sdk/testhelpers/do-get-secret"; +import { awaitAsyncSecret } from "@cre/sdk/testhelpers/await-async-secret"; +import { LazyPromise } from "@cre/sdk/utils/lazy-promise"; + +export const getSecret = (id: string): Promise => { + const callbackId = doGetSecret("Foo"); + return new LazyPromise(async () => awaitAsyncSecret(callbackId)); +}; diff --git a/src/sdk/utils/host.ts b/src/sdk/utils/host.ts new file mode 100644 index 00000000..6d2392c7 --- /dev/null +++ b/src/sdk/utils/host.ts @@ -0,0 +1,67 @@ +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; + +// TODO: zod validation can be setup before running the workflows +// Making sure the hosts functions are exposed and this code will be removed +type GlobalHostFunctionsMap = { + switchModes: (mode: Mode) => void; + log: (message: string) => void; + sendResponse: (response: string) => number; + randomSeed: (mode: Mode.DON | Mode.NODE) => number; + versionV2: () => void; + callCapability: (request: string) => number; + awaitCapabilities: (awaitRequest: string, maxResponseLen: number) => string; + getSecrets: (request: string, maxResponseLen: number) => number; + awaitSecrets: (awaitRequest: string, maxResponseLen: number) => string; + getWasiArgs: () => string; +}; + +const g = globalThis as unknown as Partial; + +export const host = { + switchModes: (mode: Mode): void => { + g.switchModes?.(mode); + runtimeGuards.setMode(mode); + }, + log: (message: string): void => g.log?.(String(message)), + sendResponse: (payloadBase64: string): number => + g.sendResponse ? g.sendResponse(payloadBase64) : -1, + randomSeed: (mode: Mode.DON | Mode.NODE = Mode.DON): number => + g.randomSeed ? g.randomSeed(mode) : 0, +}; + +// Simple runtime guard state +export const runtimeGuards = (() => { + let currentMode: Mode = Mode.DON; + let donModeGuardError: Error | null = null; + let nodeModeGuardError: Error | null = null; + + const setMode = (mode: Mode) => { + currentMode = mode; + if (mode === Mode.NODE) { + // In node mode, forbid DON runtime calls + donModeGuardError = new Error("cannot use Runtime inside RunInNodeMode"); + nodeModeGuardError = null; + } else if (mode === Mode.DON) { + // Back in DON mode, forbid node runtime calls + nodeModeGuardError = new Error( + "cannot use NodeRuntime outside RunInNodeMode" + ); + donModeGuardError = null; + } else { + donModeGuardError = null; + nodeModeGuardError = null; + } + }; + + const assertDonSafe = () => { + if (donModeGuardError) throw donModeGuardError; + }; + + const assertNodeSafe = () => { + if (nodeModeGuardError) throw nodeModeGuardError; + }; + + const getMode = () => currentMode; + + return { setMode, assertDonSafe, assertNodeSafe, getMode }; +})(); diff --git a/src/sdk/utils/lazy-promise.ts b/src/sdk/utils/lazy-promise.ts new file mode 100644 index 00000000..2bb66102 --- /dev/null +++ b/src/sdk/utils/lazy-promise.ts @@ -0,0 +1,89 @@ +/** + * LazyPromise is a utility class that implements the Promise interface + * but defers execution of the actual work until the promise is first accessed. + * + * This is useful when you want to return a promise immediately without + * starting the async work, but ensure the work begins as soon as someone + * tries to await, .then(), .catch(), or .finally() the promise. + * + * Example usage: + * ```typescript + * const lazyPromise = new LazyPromise(() => { + * // This expensive operation won't start until the promise is accessed + * return fetch('/api/data'); + * }); + * + * // Promise is returned immediately, no work done yet + * // Work starts when you await it: + * const result = await lazyPromise; + * ``` + * + * This abstraction has been created for calling capabilities in a non-blocking way. + */ +export class LazyPromise implements Promise { + /** Tracks whether the factory function has been executed */ + private started = false; + + /** The actual promise that gets created when work starts */ + private promise!: Promise; + + /** + * Creates a new LazyPromise + * @param factory - Function that returns the value or promise to resolve with + */ + constructor(private readonly factory: () => T | Promise) {} + + /** + * Ensures the factory function has been executed and the promise is created. + * This is called by all promise methods (.then, .catch, .finally) to start the work. + */ + private ensureStarted() { + if (!this.started) { + this.started = true; + try { + const result = this.factory(); + this.promise = Promise.resolve(result); + } catch (err) { + this.promise = Promise.reject(err); + } + } + } + + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * This triggers the lazy execution if it hasn't started yet. + */ + then( + onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null + ): Promise { + this.ensureStarted(); + return this.promise.then(onfulfilled, onrejected); + } + + /** + * Attaches a callback for only the rejection of the Promise. + * This triggers the lazy execution if it hasn't started yet. + */ + catch( + onrejected?: ((reason: any) => TResult | PromiseLike) | null + ): Promise { + this.ensureStarted(); + return this.promise.catch(onrejected); + } + + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). + * This triggers the lazy execution if it hasn't started yet. + */ + finally(onfinally?: (() => void) | null): Promise { + this.ensureStarted(); + return this.promise.finally(onfinally); + } + + /** + * Required to make this behave like a native Promise. + * This allows instanceof checks and proper string representation. + */ + [Symbol.toStringTag] = "Promise"; +} diff --git a/src/sdk/utils/prepare-runtime.ts b/src/sdk/utils/prepare-runtime.ts new file mode 100644 index 00000000..e8ed3c64 --- /dev/null +++ b/src/sdk/utils/prepare-runtime.ts @@ -0,0 +1,10 @@ +import { Buffer } from "node:buffer"; + +/** + * This function is used to prepare the runtime for the SDK to work. + * It should be called as a part of SDK initialization. + * It exposes NodeJS Buffer in global namespace, so it can be bundled and used in workflow code. + */ +export const prepareRuntime = () => { + globalThis.Buffer = Buffer as any; +}; diff --git a/src/sdk/utils/random.ts b/src/sdk/utils/random.ts new file mode 100644 index 00000000..b8e08be0 --- /dev/null +++ b/src/sdk/utils/random.ts @@ -0,0 +1,139 @@ +// Full TypeScript port of Go's math/rand +// Complete API: Int63, Uint64, Uint32, Int31, Int, Float64, Float32, Int63n, Int31n, Intn, Perm, Seed +// See: https://cs.opensource.google/go/go/+/refs/tags/go1.22.0:src/math/rand/rand.go + +export class Source { + private s0: bigint = 0n; + private s1: bigint = 0n; + + constructor(seed: bigint) { + this.Seed(seed); + } + + Seed(seed: bigint) { + seed = BigInt.asUintN(64, seed); + this.s0 = this.splitMix64(seed); + this.s1 = this.splitMix64(this.s0); + } + + private splitMix64(seed: bigint): bigint { + seed = (seed + 0x9e3779b97f4a7c15n) & 0xffffffffffffffffn; + let z = seed; + z = ((z ^ (z >> 30n)) * 0xbf58476d1ce4e5b9n) & 0xffffffffffffffffn; + z = ((z ^ (z >> 27n)) * 0x94d049bb133111ebn) & 0xffffffffffffffffn; + return z ^ (z >> 31n); + } + + private next(): bigint { + const s1 = this.s0; + let s0 = this.s1; + this.s0 = s0; + s0 ^= s0 << 23n; + this.s1 = s0 ^ s1 ^ (s0 >> 17n) ^ (s1 >> 26n); + return BigInt.asUintN(64, this.s1 + s1); + } + + Int63(): bigint { + return this.next() & 0x7fffffffffffffffn; + } + + Uint32(): number { + return Number(this.next() >> 32n) >>> 0; + } + + Uint64(): bigint { + return this.next(); + } + + Int31(): number { + return Number(this.Int63() >> 32n); + } + + Float64(): number { + // Use top 53 bits like Go's implementation: Int63() >> 11 + return Number(this.Int63() >> 11n) * (1.0 / 9007199254740992.0); // 1.0 / (1 << 53) + } + + Int63n(n: bigint): bigint { + if (n <= 0n) throw new Error("invalid argument to Int63n"); + const max = (1n << 63n) - ((1n << 63n) % n); + let v: bigint; + do { + v = this.Int63(); + } while (v >= max); + return v % n; + } + + Int31n(n: number): number { + if (n <= 0) throw new Error("invalid argument to Int31n"); + return Number(this.Int63n(BigInt(n))); + } + + Intn(n: number): number { + return this.Int31n(n); + } + + Int(): number { + return Number(this.Int63() >> 32n); + } + + Float32(): number { + // Use top 24 bits for float32 precision + return Number(this.Int63() >> 40n) * (1.0 / 8388608.0); // 1.0 / (1 << 23) + } + + Perm(n: number): number[] { + const m = new Array(n); + for (let i = 0; i < n; i++) m[i] = i; + for (let i = 1; i < n; i++) { + const j = Number(this.Int63n(BigInt(i + 1))); + [m[i], m[j]] = [m[j], m[i]]; + } + return m; + } +} + +export class Rand { + private src: Source; + + constructor(seed: bigint) { + this.src = new Source(seed); + } + + Float64() { + return this.src.Float64(); + } + Float32() { + return this.src.Float32(); + } + Int63() { + return this.src.Int63(); + } + Int63n(n: bigint) { + return this.src.Int63n(n); + } + Int31() { + return this.src.Int31(); + } + Int31n(n: number) { + return this.src.Int31n(n); + } + Int() { + return this.src.Int(); + } + Intn(n: number) { + return this.src.Intn(n); + } + Uint32() { + return this.src.Uint32(); + } + Uint64() { + return this.src.Uint64(); + } + Perm(n: number) { + return this.src.Perm(n); + } + Seed(seed: bigint) { + this.src.Seed(seed); + } +} diff --git a/src/sdk/utils/secrets-error.ts b/src/sdk/utils/secrets-error.ts new file mode 100644 index 00000000..2860e75b --- /dev/null +++ b/src/sdk/utils/secrets-error.ts @@ -0,0 +1,13 @@ +export class SecretsError extends Error { + constructor( + message: string + + // TODO: think if adding more info would be useful and how to do it + // public id?: string, + // public namespace?: string, + // public owner?: number + ) { + super(message); + this.name = "SecretsError"; + } +} diff --git a/src/sdk/utils/send-response-value.ts b/src/sdk/utils/send-response-value.ts new file mode 100644 index 00000000..02ae6334 --- /dev/null +++ b/src/sdk/utils/send-response-value.ts @@ -0,0 +1,22 @@ +import { type Value } from "@cre/generated/values/v1/values_pb"; +import { + type ExecutionResult, + ExecutionResultSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create, toBinary } from "@bufbuild/protobuf"; + +export const sendResponseValue = (value: Value): void => { + // Insert into the correct oneof field: 'payload' + const execResult: ExecutionResult = create(ExecutionResultSchema, { + result: { + case: "value", + value, + }, + }); + + // Marshal to protobuf bytes + const encoded = toBinary(ExecutionResultSchema, execResult); + + // Send the result + sendResponse(Buffer.from(encoded).toString("base64")); +}; diff --git a/src/sdk/utils/triggers/register-trigger.ts b/src/sdk/utils/triggers/register-trigger.ts new file mode 100644 index 00000000..b0221b9b --- /dev/null +++ b/src/sdk/utils/triggers/register-trigger.ts @@ -0,0 +1,46 @@ +import type { Trigger } from "./trigger-interface"; +import type { Message } from "@bufbuild/protobuf"; +import { create, toBinary } from "@bufbuild/protobuf"; +import { + TriggerSubscriptionRequestSchema, + type TriggerSubscriptionRequest, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; + +/** + * Registers a trigger with the CRE runtime + * + * This function is called by the runtime to subscribe to trigger events. + * The actual implementation would send this request to the host environment. + * + * @param trigger - The trigger to register + * @returns A promise that resolves when the trigger is registered + */ +export async function registerTrigger, TAdapted = TOutput>( + trigger: Trigger +): Promise { + // Create the subscription request + const request = create(TriggerSubscriptionRequestSchema, { + subscriptions: [ + { + id: trigger.capabilityId(), + method: trigger.method(), + payload: trigger.configAsAny(), + }, + ], + }); + + // TODO: Send this request to the host environment + // For now, we'll just log it + console.log("Registering trigger:", { + capabilityId: trigger.capabilityId(), + method: trigger.method(), + payload: trigger.configAsAny(), + }); + + // In the real implementation, this would communicate with the host + // through the WASM boundary or other runtime mechanism + const requestBytes = toBinary(TriggerSubscriptionRequestSchema, request); + + // Placeholder for actual host communication + // hostRegisterTrigger(requestBytes); +} diff --git a/src/sdk/utils/triggers/trigger-interface.ts b/src/sdk/utils/triggers/trigger-interface.ts new file mode 100644 index 00000000..9260830d --- /dev/null +++ b/src/sdk/utils/triggers/trigger-interface.ts @@ -0,0 +1,69 @@ +import type { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { Any } from "@bufbuild/protobuf/wkt"; +import type { Message } from "@bufbuild/protobuf"; +import type { GenMessage } from "@bufbuild/protobuf/codegenv2"; + +/** + * Base interface for trigger capabilities in the CRE SDK + * + * Triggers are server-streaming RPC methods that emit events + * to the workflow runtime. + */ +export interface BaseTrigger> { + /** The capability ID for this trigger */ + capabilityId(): string; + + /** The method name for this trigger */ + method(): string; + + /** Create a new instance of the output type */ + newOutput(): TOutput; + + /** Access the output schema for decoding */ + outputSchema(): GenMessage; + + /** Get the configuration as an Any type for protobuf serialization */ + configAsAny(): Any; +} + +/** + * Full trigger interface with adapt method + * + * The adapt method allows transformation of the raw protobuf output + * to a more convenient type for the workflow. + */ +export interface Trigger, TAdapted = TOutput> + extends BaseTrigger { + /** Transform the trigger output to the adapted type */ + adapt(output: TOutput): TAdapted | Promise; +} + +/** + * Base class for trigger implementations + */ +export abstract class BaseTriggerImpl< + TConfig, + TOutput extends Message, + TAdapted = TOutput +> implements Trigger +{ + constructor(public readonly mode: Mode, public readonly config: TConfig) {} + + abstract capabilityId(): string; + abstract method(): string; + abstract newOutput(): TOutput; + abstract outputSchema(): GenMessage; + + /** Go naming parity */ + abstract configAsAny(): Any; + + /** + * Default adapt implementation - returns output unchanged + * Override this method to transform the output + */ + adapt(output: TOutput): TAdapted | Promise { + // Type assertion is safe here as TAdapted defaults to TOutput + // when not explicitly specified + return output as unknown as TAdapted; + } +} diff --git a/src/sdk/utils/typeurl.ts b/src/sdk/utils/typeurl.ts new file mode 100644 index 00000000..d3760a4c --- /dev/null +++ b/src/sdk/utils/typeurl.ts @@ -0,0 +1,2 @@ +export const getTypeUrl = (schema: { typeName: string }): string => + `type.googleapis.com/${schema.typeName}`; diff --git a/src/sdk/utils/values/consensus.test.ts b/src/sdk/utils/values/consensus.test.ts new file mode 100644 index 00000000..76fbb29e --- /dev/null +++ b/src/sdk/utils/values/consensus.test.ts @@ -0,0 +1,98 @@ +import { describe, expect, test } from "bun:test"; +import { AggregationType } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { ConsensusDescriptor } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { + consensusDescriptorMedian, + consensusDescriptorIdentical, + consensusDescriptorCommonPrefix, + consensusDescriptorCommonSuffix, + createConsensusDescriptorAggregation, + consensusFields, + consensusFieldsFrom, + observationValue, + observationError, +} from "./consensus"; +import { val } from "./value"; + +const getAggregation = (d: ConsensusDescriptor): AggregationType | undefined => + d.descriptor.case === "aggregation" ? d.descriptor.value : undefined; + +const isFieldsMap = (d: ConsensusDescriptor): boolean => + d.descriptor.case === "fieldsMap"; + +describe("consensus helpers", () => { + test("aggregation helpers", () => { + expect(getAggregation(consensusDescriptorMedian)).toBe( + AggregationType.MEDIAN + ); + expect(getAggregation(consensusDescriptorIdentical)).toBe( + AggregationType.IDENTICAL + ); + expect(getAggregation(consensusDescriptorCommonPrefix)).toBe( + AggregationType.COMMON_PREFIX + ); + expect(getAggregation(consensusDescriptorCommonSuffix)).toBe( + AggregationType.COMMON_SUFFIX + ); + }); + + test("createConsensusDescriptorAggregation", () => { + const d = createConsensusDescriptorAggregation(AggregationType.IDENTICAL); + expect(getAggregation(d)).toBe(AggregationType.IDENTICAL); + }); + + test("consensusFields builds fieldsMap", () => { + const fields: Record = { + Price: createConsensusDescriptorAggregation(AggregationType.MEDIAN), + }; + const d = consensusFields(fields); + expect(isFieldsMap(d)).toBe(true); + const map = + d.descriptor.case === "fieldsMap" ? d.descriptor.value.fields : {}; + expect(Object.keys(map)).toEqual(["Price"]); + expect(getAggregation(map.Price!)).toBe(AggregationType.MEDIAN); + }); + + test("consensusFieldsFrom normalizes enums and descriptors", () => { + const prebuilt = createConsensusDescriptorAggregation( + AggregationType.IDENTICAL + ); + const d = consensusFieldsFrom({ + a: AggregationType.MEDIAN, + b: prebuilt, + }); + expect(isFieldsMap(d)).toBe(true); + const map = + d.descriptor.case === "fieldsMap" ? d.descriptor.value.fields : {}; + expect(getAggregation(map.a!)).toBe(AggregationType.MEDIAN); + expect(getAggregation(map.b!)).toBe(AggregationType.IDENTICAL); + }); + + test("consensusFieldsFrom nested fieldsMap", () => { + const nested = consensusFieldsFrom({ + In: consensusFieldsFrom({ Score: AggregationType.MEDIAN }), + }); + expect(isFieldsMap(nested)).toBe(true); + const outer = + nested.descriptor.case === "fieldsMap" + ? nested.descriptor.value.fields + : {}; + const inner = outer.In!; + expect(isFieldsMap(inner)).toBe(true); + const innerFields = + inner.descriptor.case === "fieldsMap" + ? inner.descriptor.value.fields + : {}; + expect(getAggregation(innerFields.Score!)).toBe(AggregationType.MEDIAN); + }); + + test("observation helpers", () => { + const ov = observationValue(val.string("ok")); + expect(ov.case).toBe("value"); + expect(ov.value.value.case).toBe("stringValue"); + + const oe = observationError("boom"); + expect(oe.case).toBe("error"); + expect(oe.value).toBe("boom"); + }); +}); diff --git a/src/sdk/utils/values/consensus.ts b/src/sdk/utils/values/consensus.ts new file mode 100644 index 00000000..dd8223d4 --- /dev/null +++ b/src/sdk/utils/values/consensus.ts @@ -0,0 +1,96 @@ +import { create } from "@bufbuild/protobuf"; +import type { + ConsensusDescriptor, + SimpleConsensusInputs, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { Value } from "@cre/generated/values/v1/values_pb"; +import { + AggregationType, + ConsensusDescriptorSchema, + FieldsMapSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; + +export const consensusDescriptorMedian = create(ConsensusDescriptorSchema, { + descriptor: { + case: "aggregation", + value: AggregationType.MEDIAN, + }, +}); + +export const consensusDescriptorIdentical = create(ConsensusDescriptorSchema, { + descriptor: { + case: "aggregation", + value: AggregationType.IDENTICAL, + }, +}); + +export const consensusDescriptorCommonPrefix = create( + ConsensusDescriptorSchema, + { + descriptor: { + case: "aggregation", + value: AggregationType.COMMON_PREFIX, + }, + } +); + +export const consensusDescriptorCommonSuffix = create( + ConsensusDescriptorSchema, + { + descriptor: { + case: "aggregation", + value: AggregationType.COMMON_SUFFIX, + }, + } +); + +export const createConsensusDescriptorAggregation = ( + aggregation: AggregationType +) => + create(ConsensusDescriptorSchema, { + descriptor: { + case: "aggregation", + value: aggregation, + }, + }); + +export const consensusFields = (fields: Record) => + create(ConsensusDescriptorSchema, { + descriptor: { + case: "fieldsMap", + value: create(FieldsMapSchema, { fields }), + }, + }); + +export const consensusFieldsFrom = ( + spec: Record +) => { + const normalized: Record = {}; + for (const key of Object.keys(spec)) { + const value = spec[key]; + normalized[key] = + typeof value === "number" + ? createConsensusDescriptorAggregation(value) + : value; + } + return consensusFields(normalized); +}; + +export type ObservationValueCase = Extract< + SimpleConsensusInputs["observation"], + { case: "value" } +>; +export type ObservationErrorCase = Extract< + SimpleConsensusInputs["observation"], + { case: "error" } +>; + +export const observationValue = (value: Value): ObservationValueCase => ({ + case: "value", + value, +}); + +export const observationError = (message: string): ObservationErrorCase => ({ + case: "error", + value: message, +}); diff --git a/src/sdk/utils/values/value.test.ts b/src/sdk/utils/values/value.test.ts new file mode 100644 index 00000000..3e6d14ec --- /dev/null +++ b/src/sdk/utils/values/value.test.ts @@ -0,0 +1,261 @@ +import { describe, expect, test } from "bun:test"; +import type { Value } from "@cre/generated/values/v1/values_pb"; +import { toJson } from "@bufbuild/protobuf"; +import { ValueSchema } from "@cre/generated/values/v1/values_pb"; +import { val, vJson } from "./value"; + +const bytesToBigIntBE = (bytes: Uint8Array): bigint => { + let out = 0n; + for (const b of bytes) out = (out << 8n) + BigInt(b); + return out; +}; + +const ensureCase = (v: Value, c: Value["value"]["case"]) => { + if (v.value.case !== c) + throw new Error(`expected case ${c} but got ${v.value.case}`); + return v.value as any; +}; + +describe("val helpers", () => { + test("string", () => { + const v = val.string("hello"); + expect(v.value.case).toBe("stringValue"); + expect(v.value.value).toBe("hello"); + }); + + test("bool", () => { + const v = val.bool(true); + expect(v.value.case).toBe("boolValue"); + expect(v.value.value).toBe(true); + }); + + test("bytes Uint8Array", () => { + const data = new Uint8Array([1, 2, 3]); + const v = val.bytes(data); + expect(v.value.case).toBe("bytesValue"); + const bv = ensureCase(v, "bytesValue").value as Uint8Array; + expect(Array.from(bv)).toEqual([1, 2, 3]); + }); + + test("bytes ArrayBuffer", () => { + const ab = new Uint8Array([9, 8]).buffer; + const v = val.bytes(ab); + expect(v.value.case).toBe("bytesValue"); + const bv = ensureCase(v, "bytesValue").value as Uint8Array; + expect(Array.from(bv)).toEqual([9, 8]); + }); + + test("int64 from number", () => { + const v = val.int64(42); + expect(v.value.case).toBe("int64Value"); + expect(v.value.value).toBe("42"); + }); + + test("int64 from bigint within range", () => { + const v = val.int64(123n); + expect(v.value.case).toBe("int64Value"); + expect(v.value.value).toBe("123"); + }); + + test("int64 throws on non-integer number", () => { + expect(() => val.int64(1.5)).toThrow(); + }); + + test("int64 overflow throws (number)", () => { + // larger than int64 max + const tooBig = Number(2n ** 63n); + expect(Number.isFinite(tooBig)).toBe(true); + expect(() => val.int64(tooBig)).toThrow(); + }); + + test("int64 accepts string passthrough", () => { + const v = val.int64("-42"); + expect(v.value.case).toBe("int64Value"); + expect(v.value.value).toBe("-42"); + }); + + test("float64", () => { + const v = val.float64(3.14); + expect(v.value.case).toBe("float64Value"); + expect(v.value.value).toBeCloseTo(3.14); + }); + + test("float64 supports NaN and Infinity", () => { + const n = val.float64(NaN); + expect(n.value.case).toBe("float64Value"); + expect(Number.isNaN(n.value.value)).toBe(true); + const inf = val.float64(Infinity); + expect(inf.value.case).toBe("float64Value"); + expect(inf.value.value).toBe(Infinity); + }); + + test("bigint encodes sign and abs bytes", () => { + const big = -123456789012345678901234567890n; + const v = val.bigint(big); + expect(v.value.case).toBe("bigintValue"); + const pb = ensureCase(v, "bigintValue").value as { + sign: string; + absVal: Uint8Array; + }; + expect(pb.sign).toBe("-1"); + const abs = bytesToBigIntBE(pb.absVal); + expect(abs).toBe(-big); + }); + + test("bigint uses int64 when safe", () => { + const v = val.from(99n); + expect(v.value.case).toBe("int64Value"); + expect(v.value.value).toBe("99"); + }); + + test("from(number) outside int64 becomes float64", () => { + // 2^63 is outside int64 max + const n = 2 ** 63; + const v = val.from(n); + expect(v.value.case).toBe("float64Value"); + expect(v.value.value).toBe(n); + }); + + test("time from Date", () => { + const d = new Date(1700000123456); + const v = val.time(d); + expect(v.value.case).toBe("timeValue"); + const ts = ensureCase(v, "timeValue").value as { + seconds: string; + nanos: number; + }; + expect(ts.seconds).toBe(String(Math.floor(d.getTime() / 1000))); + expect(ts.nanos).toBe((d.getTime() % 1000) * 1_000_000); + }); + + test("list from raw items and prebuilt values", () => { + const v1 = val.string("x"); + const v = val.list([1, v1, true]); + expect(v.value.case).toBe("listValue"); + const items = ensureCase(v, "listValue").value.fields as Value[]; + expect(items[0].value.case).toBe("int64Value"); + expect(items[1].value.case).toBe("stringValue"); + expect(items[2].value.case).toBe("boolValue"); + }); + + test("list empty", () => { + const v = val.list([]); + expect(v.value.case).toBe("listValue"); + expect((ensureCase(v, "listValue").value.fields as Value[]).length).toBe(0); + }); + + test("map from raw values and prebuilt values", () => { + const v1 = val.float64(1.25); + const v = val.mapValue({ a: 1, b: v1, s: "ok" }); + expect(v.value.case).toBe("mapValue"); + const m = ensureCase(v, "mapValue").value.fields as Record; + expect(m.a.value.case).toBe("int64Value"); + expect(m.b.value.case).toBe("float64Value"); + expect(m.s.value.case).toBe("stringValue"); + }); + + test("map empty", () => { + const v = val.mapValue({}); + expect(v.value.case).toBe("mapValue"); + expect( + Object.keys( + ensureCase(v, "mapValue").value.fields as Record + ) + ).toHaveLength(0); + }); + + test("from object and array", () => { + const vObj = val.from({ k: [1, "a", false] }); + expect(vObj.value.case).toBe("mapValue"); + const mv = ensureCase(vObj, "mapValue"); + const innerList = mv.value.fields.k as Value; + const list = ensureCase(innerList, "listValue").value.fields as Value[]; + expect(list[0].value.case).toBe("int64Value"); + expect(list[1].value.case).toBe("stringValue"); + expect(list[2].value.case).toBe("boolValue"); + }); + + test("from unsupported object instances throw (Set, Map, Int8Array)", () => { + expect(() => val.from(new Set([1, 2]))).toThrow(); + expect(() => val.from(new Map([["a", 1]]))).toThrow(); + expect(() => val.from(new Int8Array([1, 2]))).toThrow(); + }); + + test("decimal normalization and structure", () => { + const v = val.decimal("15.2300"); + expect(v.value.case).toBe("decimalValue"); + const d = ensureCase(v, "decimalValue").value as { + exponent: number; + coefficient?: { sign: string; absVal: Uint8Array }; + }; + expect(d.exponent).toBe(-2); + // coefficient should be 1523 (sign + digits) + const coeffAbs = bytesToBigIntBE(d.coefficient!.absVal); + expect(d.coefficient!.sign).toBe("1"); + expect(coeffAbs).toBe(1523n); + }); + + test("decimal negative and integer only", () => { + const v = val.decimal("-123.4500"); + const d = ensureCase(v, "decimalValue").value as { + exponent: number; + coefficient?: { sign: string; absVal: Uint8Array }; + }; + expect(d.exponent).toBe(-2); + expect(d.coefficient!.sign).toBe("-1"); + const coeffAbs = bytesToBigIntBE(d.coefficient!.absVal); + expect(coeffAbs).toBe(12345n); + + const i = val.decimal("42"); + const id = ensureCase(i, "decimalValue").value as { + exponent: number; + coefficient?: { sign: string; absVal: Uint8Array }; + }; + expect(id.exponent).toBe(0); + expect(bytesToBigIntBE(id.coefficient!.absVal)).toBe(42n); + }); + + test("decimal invalid strings throw", () => { + expect(() => val.decimal("abc")).toThrow(); + expect(() => val.decimal("1.")).toThrow(); + expect(() => val.decimal(".5")).toThrow(); + }); + + test("from throws on null/undefined", () => { + expect(() => val.from(null as unknown as string)).toThrow(); + expect(() => val.from(undefined as unknown as string)).toThrow(); + }); + + test("vJson.get for direct value cases", () => { + const i = val.int64(7); + const ij = toJson(ValueSchema, i); + expect(vJson.get(ij, "int64Value")).toBe("7"); + expect(vJson.get(ij, "stringValue")).toBeUndefined(); + + const s = val.string("ok"); + const sj = toJson(ValueSchema, s); + expect(vJson.get(sj, "stringValue")).toBe("ok"); + expect(vJson.get(sj, "int64Value")).toBeUndefined(); + }); + + test("vJson.getMap / getMapField / getFromMap", () => { + const m = val.mapValue({ + a: val.int64(5), + b: val.string("x"), + c: val.bool(true), + }); + const mj = toJson(ValueSchema, m); + + const map = vJson.getMap(mj); + expect(map.a?.int64Value).toBe("5"); + expect(map.b?.stringValue).toBe("x"); + expect(map.c?.boolValue).toBe(true); + + const aField = vJson.getMapField(mj, "a"); + expect(aField?.int64Value).toBe("5"); + + expect(vJson.getFromMap(mj, "a", "int64Value")).toBe("5"); + expect(vJson.getFromMap(mj, "a", "stringValue")).toBeUndefined(); + expect(vJson.getFromMap(mj, "zzz", "int64Value")).toBeUndefined(); + }); +}); diff --git a/src/sdk/utils/values/value.ts b/src/sdk/utils/values/value.ts new file mode 100644 index 00000000..047cf981 --- /dev/null +++ b/src/sdk/utils/values/value.ts @@ -0,0 +1,234 @@ +import { create } from "@bufbuild/protobuf"; +import type { Timestamp } from "@bufbuild/protobuf/wkt"; +import type { + Value, + BigInt as ProtoBigInt, + Map as ProtoMap, + List as ProtoList, + Decimal as ProtoDecimal, +} from "@cre/generated/values/v1/values_pb"; +import type { ValueJson } from "@cre/generated/values/v1/values_pb"; +import { + ValueSchema, + BigIntSchema, + MapSchema, + ListSchema, + DecimalSchema, +} from "@cre/generated/values/v1/values_pb"; + +// int64 bounds +const INT64_MIN = -(2n ** 63n); +const INT64_MAX = 2n ** 63n - 1n; + +const toUint8Array = (input: Uint8Array | ArrayBuffer): Uint8Array => + input instanceof Uint8Array ? input : new Uint8Array(input); + +const bigintToBytesBE = (abs: bigint): Uint8Array => { + if (abs === 0n) return new Uint8Array(); + let hex = abs.toString(16); + if (hex.length % 2 === 1) hex = "0" + hex; + const len = hex.length / 2; + const out = new Uint8Array(len); + for (let i = 0; i < len; i++) { + out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16); + } + return out; +}; + +const jsBigIntToProtoBigInt = (v: bigint): ProtoBigInt => { + const sign = v === 0n ? 0n : v < 0n ? -1n : 1n; + const abs = v < 0n ? -v : v; + return create(BigIntSchema, { + absVal: bigintToBytesBE(abs), + sign: sign.toString(), + }); +}; + +const toInt64String = (v: number | bigint | string): string => { + if (typeof v === "string") return v; // assume valid int64 string + if (typeof v === "bigint") { + if (v < INT64_MIN || v > INT64_MAX) throw new Error("int64 overflow"); + return v.toString(); + } + if (!Number.isFinite(v) || !Number.isInteger(v)) + throw new Error("int64 requires an integer number"); + const bi = BigInt(v); + if (bi < INT64_MIN || bi > INT64_MAX) throw new Error("int64 overflow"); + return bi.toString(); +}; + +const toTimestamp = (d: Date | number | string): Timestamp => { + const date = d instanceof Date ? d : new Date(d); + const ms = date.getTime(); + const secs = Math.trunc(ms / 1000); + let msRemainder = ms - secs * 1000; + if (msRemainder < 0) msRemainder += 1000; // normalize negatives + const nanos = msRemainder * 1_000_000; + return { seconds: secs.toString(), nanos } as unknown as Timestamp; +}; + +const isPlainObject = (v: unknown): v is Record => + typeof v === "object" && v !== null && v.constructor === Object; + +const wrapInternal = (v: unknown): Value => { + // null/undefined not supported by Value oneof + if (v === null || v === undefined) + throw new Error("cannot wrap null/undefined into Value"); + + // Bytes + if (v instanceof Uint8Array) + return create(ValueSchema, { value: { case: "bytesValue", value: v } }); + if (v instanceof ArrayBuffer) + return create(ValueSchema, { + value: { case: "bytesValue", value: new Uint8Array(v) }, + }); + + // Date / time + if (v instanceof Date) + return create(ValueSchema, { + value: { case: "timeValue", value: toTimestamp(v) }, + }); + + // Primitive + switch (typeof v) { + case "string": + return create(ValueSchema, { value: { case: "stringValue", value: v } }); + case "boolean": + return create(ValueSchema, { value: { case: "boolValue", value: v } }); + case "bigint": { + // prefer int64 when in range, else BigInt proto + if (v >= INT64_MIN && v <= INT64_MAX) { + return create(ValueSchema, { + value: { case: "int64Value", value: v.toString() }, + }); + } + return create(ValueSchema, { + value: { case: "bigintValue", value: jsBigIntToProtoBigInt(v) }, + }); + } + case "number": { + if (Number.isInteger(v)) { + const bi = BigInt(v); + if (bi >= INT64_MIN && bi <= INT64_MAX) { + return create(ValueSchema, { + value: { case: "int64Value", value: bi.toString() }, + }); + } + } + return create(ValueSchema, { value: { case: "float64Value", value: v } }); + } + case "object": + break; // handled below + default: + throw new Error(`unsupported type: ${typeof v}`); + } + + // Array + if (Array.isArray(v)) { + const fields = v.map(wrapInternal); + const list: ProtoList = create(ListSchema, { fields }); + return create(ValueSchema, { value: { case: "listValue", value: list } }); + } + + // Plain object -> Map + if (isPlainObject(v)) { + const fields: Record = {}; + for (const [k, vv] of Object.entries(v)) { + fields[k] = wrapInternal(vv); + } + const map: ProtoMap = create(MapSchema, { fields }); + return create(ValueSchema, { value: { case: "mapValue", value: map } }); + } + + // Fallback + throw new Error("unsupported object instance"); +}; + +export const val = { + string: (s: string): Value => + create(ValueSchema, { value: { case: "stringValue", value: s } }), + bool: (b: boolean): Value => + create(ValueSchema, { value: { case: "boolValue", value: b } }), + bytes: (d: Uint8Array | ArrayBuffer): Value => + create(ValueSchema, { + value: { case: "bytesValue", value: toUint8Array(d) }, + }), + int64: (n: number | bigint | string): Value => + create(ValueSchema, { + value: { case: "int64Value", value: toInt64String(n) }, + }), + float64: (n: number): Value => + create(ValueSchema, { value: { case: "float64Value", value: n } }), + bigint: (n: bigint): Value => + create(ValueSchema, { + value: { case: "bigintValue", value: jsBigIntToProtoBigInt(n) }, + }), + time: (d: Date | number | string): Value => + create(ValueSchema, { + value: { case: "timeValue", value: toTimestamp(d) }, + }), + list: (items: Array): Value => { + const fields = items.map((i) => + typeof i === "object" && i !== null && (i as Value).value + ? (i as Value) + : wrapInternal(i) + ); + return create(ValueSchema, { + value: { case: "listValue", value: create(ListSchema, { fields }) }, + }); + }, + mapValue: (obj: Record): Value => { + const fields: Record = {}; + for (const [k, v] of Object.entries(obj)) { + fields[k] = + typeof v === "object" && v !== null && (v as Value).value + ? (v as Value) + : wrapInternal(v); + } + return create(ValueSchema, { + value: { case: "mapValue", value: create(MapSchema, { fields }) }, + }); + }, + decimal: (s: string): Value => { + // Parse decimal string into coefficient (bigint) and exponent (int32) + const m = /^([+-])?(\d+)(?:\.(\d+))?$/.exec(s.trim()); + if (!m) throw new Error("invalid decimal string"); + const signStr = m[1] ?? "+"; + let intPart = m[2] ?? "0"; + let fracPart = m[3] ?? ""; + // remove trailing zeros in fractional part to normalize + fracPart = fracPart.replace(/0+$/g, ""); + const exp = fracPart.length === 0 ? 0 : -fracPart.length; + const digits = intPart + fracPart || "0"; + const coeff = BigInt((signStr === "-" ? "-" : "") + digits); + const decimal: ProtoDecimal = create(DecimalSchema, { + coefficient: jsBigIntToProtoBigInt(coeff), + exponent: exp, + }); + return create(ValueSchema, { + value: { case: "decimalValue", value: decimal }, + }); + }, + from: (v: unknown): Value => wrapInternal(v), +}; + +export type { Value }; + +export type ValueJsonCase = Extract; +export type ValueJsonReturn = ValueJson[T]; + +export const vJson = { + getMap: (v: ValueJson): Record => v.mapValue?.fields ?? {}, + getMapField: (v: ValueJson, key: string): ValueJson | undefined => + v.mapValue?.fields?.[key], + get: (v: ValueJson, type: T): ValueJsonReturn => + v[type] as ValueJsonReturn, + getFromMap: ( + v: ValueJson, + key: string, + type: T + ): ValueJsonReturn => { + const field = v.mapValue?.fields?.[key]; + return field ? (field[type] as ValueJsonReturn) : undefined; + }, +}; diff --git a/src/sdk/workflow.ts b/src/sdk/workflow.ts new file mode 100644 index 00000000..8ae4355a --- /dev/null +++ b/src/sdk/workflow.ts @@ -0,0 +1,68 @@ +import type { Message } from "@bufbuild/protobuf"; +import type { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import type { Trigger } from "@cre/sdk/utils/triggers/trigger-interface"; + +export type Logger = { + log: (message: string) => void; +}; + +export type Environment = { + config?: TConfig; + mode?: Mode; + logger?: Logger; +}; + +export type Runtime = { + // Reserved for future runtime operations (e.g., generateReport) +}; + +export type HandlerFn = ( + env: Environment, + rt: Runtime, + output: TAdapted +) => Promise | unknown; + +export interface HandlerEntry< + TConfig = unknown, + TOutput extends Message = Message, + TAdapted = TOutput +> { + trigger: Trigger; + fn: HandlerFn; +} + +export type Workflow = ReadonlyArray< + HandlerEntry +>; + +export const Handler = < + TOutput extends Message, + TAdapted = TOutput, + TConfig = unknown +>( + trigger: Trigger, + fn: HandlerFn +): HandlerEntry => ({ trigger, fn }); + +export class Runner { + constructor( + private readonly env: Environment = {}, + private readonly rt: Runtime = {} + ) {} + + async run( + initFn: ( + env: Environment + ) => Promise> | Workflow + ): Promise { + const wf = await initFn(this.env); + const results: unknown[] = []; + for (const entry of wf) { + const out = entry.trigger.newOutput(); + const adapted = await entry.trigger.adapt(out); + const res = await entry.fn(this.env, this.rt, adapted); + results.push(res); + } + return results; + } +} diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 00000000..4e69930f --- /dev/null +++ b/src/test.ts @@ -0,0 +1,23 @@ +import { LazyPromise } from "@cre/sdk/utils/lazy-promise"; + +function getPromise(arg: string): Promise { + return new LazyPromise(async () => { + console.log(`Running logic for: ${arg}`); + // simulate async work + await new Promise((res) => setTimeout(res, 500)); + return `${arg} - done`; + }); +} + +console.log("Just a scratchpad for testing \n\n"); + +const promise = getPromise("test1"); +const promise2 = getPromise("test2"); + +await promise2; +await promise; + +// Write your code here and run it with `bun src/test.ts`. +// It's a quick and easy way to make sure TS part works as expected. + +console.log("Thanks for using the scratchpad!"); diff --git a/src/workflows/README.md b/src/workflows/README.md new file mode 100644 index 00000000..3f097b50 --- /dev/null +++ b/src/workflows/README.md @@ -0,0 +1,15 @@ +# Workflows + +Workflows directory contains all the workflows that will be compiled to WASM. +You should only place workflow files in this directory and keep all the utils outside of it. + +## WIT + +WIT file defines the shape of the workflow file - basically it needs to export the `main` function. +It is used by Javy to expose `main()` function as callable for the host. + +## Available Scripts + +- `bun build:all` - Build all workflows and Javy plugins +- `bun build:workflows:wasm` - Build workflows to WASM only +- `bun build:workflows:js` - Build workflows to JS only diff --git a/src/workflows/hello-world/hello-world.ts b/src/workflows/hello-world/hello-world.ts new file mode 100644 index 00000000..6ba45e5b --- /dev/null +++ b/src/workflows/hello-world/hello-world.ts @@ -0,0 +1,55 @@ +import { z } from "zod"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { Handler } from "@cre/sdk/workflow"; +import { CronCapability } from "@cre/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen"; +import type { Environment } from "@cre/sdk/workflow"; +import { getConfigFromExecuteRequest } from "@cre/sdk/utils/get-config"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import type { ExecuteRequest } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { buildEnvFromConfig } from "@cre/sdk/utils/env"; + +// Config struct defines the parameters that can be passed to the workflow +const configSchema = z.object({ + schedule: z.string(), +}); + +type Config = z.infer; + +// onCronTrigger is the callback function that gets executed when the cron trigger fires +const onCronTrigger = (env: Environment): void => { + env.logger?.log("Hello, Calculator! Workflow triggered."); +}; + +// InitWorkflow is the required entry point for a CRE workflow +// The runner calls this function to initialize the workflow and register its handlers +const initWorkflow = (env: Environment) => { + const cron = new CronCapability(); + + return [ + Handler( + // Use the schedule from our config file + cron.trigger({ schedule: env.config?.schedule }), + onCronTrigger + ), + ]; +}; + +// main is the entry point for the workflow +export async function main(): Promise { + console.log(`\n\n\nTS workflow: hello-world [${new Date().toISOString()}]`); + + prepareRuntime(); + versionV2(); + + const executeRequest: ExecuteRequest = getRequest(); + const config = getConfigFromExecuteRequest(executeRequest); + const configParsed = configSchema.parse(config); + + const env = buildEnvFromConfig(configParsed); + + const workflow = initWorkflow(env); + await handleExecuteRequest(executeRequest, workflow, env); +} + +main(); diff --git a/src/workflows/http-fetch/http-fetch.ts b/src/workflows/http-fetch/http-fetch.ts new file mode 100644 index 00000000..fbe156e0 --- /dev/null +++ b/src/workflows/http-fetch/http-fetch.ts @@ -0,0 +1,87 @@ +import { z } from "zod"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { Handler } from "@cre/sdk/workflow"; +import { CronCapability } from "@cre/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen"; +import type { Environment } from "@cre/sdk/workflow"; +import { getConfigFromExecuteRequest } from "@cre/sdk/utils/get-config"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import type { ExecuteRequest } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { runInNodeMode } from "@cre/sdk/runtime/run-in-node-mode"; +import { ClientCapability as HTTPClient } from "@cre/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { create } from "@bufbuild/protobuf"; +import { + consensusDescriptorMedian, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { val } from "@cre/sdk/utils/values/value"; +import { buildEnvFromConfig } from "@cre/sdk/utils/env"; + +// Config struct defines the parameters that can be passed to the workflow +const configSchema = z.object({ + schedule: z.string(), + apiUrl: z.string(), +}); + +type Config = z.infer; + +// onCronTrigger is the callback function that gets executed when the cron trigger fires +const onCronTrigger = async (env: Environment): Promise => { + env.logger?.log("Hello, Calculator! Workflow triggered."); + + const aggregatedValue = await runInNodeMode(async () => { + const http = new HTTPClient(); + const resp = await http.sendRequest({ + url: env.config?.apiUrl, + method: "GET", + }); + + const bodyStr = new TextDecoder().decode(resp.body); + const num = Number.parseFloat(bodyStr.trim()); + + return create(SimpleConsensusInputsSchema, { + observation: observationValue(val.float64(num)), + descriptors: consensusDescriptorMedian, + }); + }); + + sendResponseValue(val.mapValue({ Result: aggregatedValue })); +}; + +// InitWorkflow is the required entry point for a CRE workflow +// The runner calls this function to initialize the workflow and register its handlers +const initWorkflow = (env: Environment) => { + const cron = new CronCapability(); + + return [ + Handler( + // Use the schedule from our config file + cron.trigger({ schedule: env.config?.schedule }), + onCronTrigger + ), + ]; +}; + +// main is the entry point for the workflow +export async function main(): Promise { + console.log(`\n\n\nTS workflow: http-fetch [${new Date().toISOString()}]`); + + prepareRuntime(); + versionV2(); + + try { + const executeRequest: ExecuteRequest = getRequest(); + const config = getConfigFromExecuteRequest(executeRequest); + const configParsed = configSchema.parse(config); + const env = buildEnvFromConfig(configParsed); + + const workflow = initWorkflow(env); + await handleExecuteRequest(executeRequest, workflow, env); + } catch (error) { + console.log("error", JSON.stringify(error, null, 2)); + } +} + +main(); diff --git a/src/workflows/standard_tests/capability_calls_are_async/testts.old.ts b/src/workflows/standard_tests/capability_calls_are_async/testts.old.ts new file mode 100644 index 00000000..4cdce6ea --- /dev/null +++ b/src/workflows/standard_tests/capability_calls_are_async/testts.old.ts @@ -0,0 +1,33 @@ +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { BasicActionCapability } from "@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: capability calls are async [${new Date().toISOString()}]` + ); + + prepareRuntime(); + + const input1 = { inputThing: true }; + const input2 = { inputThing: false }; + + try { + const basicActionCapability = new BasicActionCapability(); + const promise1 = basicActionCapability.performAction(input1); + const promise2 = basicActionCapability.performAction(input2); + + const result2 = await promise2; + const result1 = await promise1; + + sendResponseValue( + val.string(`${result1.adaptedThing}${result2.adaptedThing}`) + ); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/capability_calls_are_async/testts.ts b/src/workflows/standard_tests/capability_calls_are_async/testts.ts new file mode 100644 index 00000000..b99d42db --- /dev/null +++ b/src/workflows/standard_tests/capability_calls_are_async/testts.ts @@ -0,0 +1,45 @@ +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Handler, Runner } from "@cre/sdk/workflow"; +import { BasicActionCapability } from "@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: capability calls are async [${new Date().toISOString()}]` + ); + + prepareRuntime(); + + const basicTrigger = new BasicTriggerCapability(); + + const asyncCalls = async (): Promise => { + const input1 = { inputThing: true }; + const input2 = { inputThing: false }; + const basicAction = new BasicActionCapability(); + const p1 = basicAction.performAction(input1); + const p2 = basicAction.performAction(input2); + const r2 = await p2; + const r1 = await p1; + return `${r1.adaptedThing}${r2.adaptedThing}`; + }; + + const initFn = async () => [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + asyncCalls + ), + ]; + + try { + const results = await new Runner().run(initFn); + const out = String(results[0] ?? ""); + sendResponseValue(val.string(out)); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/config/testts.old.ts b/src/workflows/standard_tests/config/testts.old.ts new file mode 100644 index 00000000..ece2c876 --- /dev/null +++ b/src/workflows/standard_tests/config/testts.old.ts @@ -0,0 +1,19 @@ +import { getRequest } from "@cre/sdk/utils/get-request"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: config [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const executeRequest = getRequest(); + + sendResponseValue(val.bytes(executeRequest.config)); +} + +main(); diff --git a/src/workflows/standard_tests/config/testts.ts b/src/workflows/standard_tests/config/testts.ts new file mode 100644 index 00000000..ece2c876 --- /dev/null +++ b/src/workflows/standard_tests/config/testts.ts @@ -0,0 +1,19 @@ +import { getRequest } from "@cre/sdk/utils/get-request"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: config [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const executeRequest = getRequest(); + + sendResponseValue(val.bytes(executeRequest.config)); +} + +main(); diff --git a/src/workflows/standard_tests/errors/testts.old.ts b/src/workflows/standard_tests/errors/testts.old.ts new file mode 100644 index 00000000..de8b19c2 --- /dev/null +++ b/src/workflows/standard_tests/errors/testts.old.ts @@ -0,0 +1,15 @@ +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; + +export async function main() { + console.log( + `TS workflow: standard test: errors [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + sendErrorWrapped(new Error("workflow execution failure")); +} + +main(); diff --git a/src/workflows/standard_tests/errors/testts.ts b/src/workflows/standard_tests/errors/testts.ts new file mode 100644 index 00000000..de8b19c2 --- /dev/null +++ b/src/workflows/standard_tests/errors/testts.ts @@ -0,0 +1,15 @@ +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; + +export async function main() { + console.log( + `TS workflow: standard test: errors [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + sendErrorWrapped(new Error("workflow execution failure")); +} + +main(); diff --git a/src/workflows/standard_tests/logging/testts.old.ts b/src/workflows/standard_tests/logging/testts.old.ts new file mode 100644 index 00000000..7ce1e8aa --- /dev/null +++ b/src/workflows/standard_tests/logging/testts.old.ts @@ -0,0 +1,26 @@ +import { getRequest } from "@cre/sdk/utils/get-request"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: logging [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const executeRequest = getRequest(); + + log("log from wasm!"); + + sendResponseValue(val.bytes(executeRequest.config)); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/logging/testts.ts b/src/workflows/standard_tests/logging/testts.ts new file mode 100644 index 00000000..7ce1e8aa --- /dev/null +++ b/src/workflows/standard_tests/logging/testts.ts @@ -0,0 +1,26 @@ +import { getRequest } from "@cre/sdk/utils/get-request"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: logging [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const executeRequest = getRequest(); + + log("log from wasm!"); + + sendResponseValue(val.bytes(executeRequest.config)); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.old.ts b/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.old.ts new file mode 100644 index 00000000..837d32a7 --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.old.ts @@ -0,0 +1,50 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { create, toJson } from "@bufbuild/protobuf"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusDescriptorIdentical, + observationError, +} from "@cre/sdk/utils/values/consensus"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: don_runtime_in_node_mode [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + switchModes(Mode.NODE); + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationError("cannot use Runtime inside RunInNodeMode"), + descriptors: consensusDescriptorIdentical, + }); + + try { + const consensusCapability = new ConsensusCapability(); + await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + } catch (e) { + if (e instanceof CapabilityError) { + sendErrorWrapped(e.message); + } else { + throw e; + } + } + + switchModes(Mode.DON); + sendErrorWrapped("cannot use Runtime inside RunInNodeMode"); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.ts b/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.ts new file mode 100644 index 00000000..d8565f46 --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/testts.ts @@ -0,0 +1,66 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { CapabilityError } from "@cre/sdk/utils/capabilities/capability-error"; +import { create, toJson } from "@bufbuild/protobuf"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusDescriptorIdentical, + observationError, +} from "@cre/sdk/utils/values/consensus"; + +import { Handler } from "@cre/sdk/workflow"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: don_runtime_in_node_mode [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const basicTrigger = new BasicTriggerCapability(); + const handler = async () => { + switchModes(Mode.NODE); + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationError("cannot use Runtime inside RunInNodeMode"), + descriptors: consensusDescriptorIdentical, + }); + + try { + const consensusCapability = new ConsensusCapability(); + await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + } catch (e) { + if (e instanceof CapabilityError) { + sendErrorWrapped(e.message); + } else { + throw e; + } + } + + switchModes(Mode.DON); + sendErrorWrapped("cannot use Runtime inside RunInNodeMode"); + }; + + try { + const executeRequest = getRequest(); + await handleExecuteRequest(executeRequest, [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + handler + ), + ]); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.old.ts b/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.old.ts new file mode 100644 index 00000000..f769abe3 --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.old.ts @@ -0,0 +1,42 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { create, toJson } from "@bufbuild/protobuf"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusDescriptorIdentical, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: node_runtime_in_don_mode [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + switchModes(Mode.NODE); + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue(val.string("hi")), + descriptors: consensusDescriptorIdentical, + }); + + const consensusCapability = new ConsensusCapability(); + await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + + switchModes(Mode.DON); + sendErrorWrapped("cannot use NodeRuntime outside RunInNodeMode"); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.ts b/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.ts new file mode 100644 index 00000000..d46e7a20 --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/testts.ts @@ -0,0 +1,57 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { create, toJson } from "@bufbuild/protobuf"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusDescriptorIdentical, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { val } from "@cre/sdk/utils/values/value"; +import { Handler } from "@cre/sdk/workflow"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: node_runtime_in_don_mode [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const basicTrigger = new BasicTriggerCapability(); + const handler = async () => { + switchModes(Mode.NODE); + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue(val.string("hi")), + descriptors: consensusDescriptorIdentical, + }); + + const consensusCapability = new ConsensusCapability(); + await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + + switchModes(Mode.DON); + sendErrorWrapped("cannot use NodeRuntime outside RunInNodeMode"); + }; + + try { + const executeRequest = getRequest(); + await handleExecuteRequest(executeRequest, [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + handler + ), + ]); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.old.ts b/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.old.ts new file mode 100644 index 00000000..da04d442 --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.old.ts @@ -0,0 +1,79 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { AggregationType, Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { ValueSchema } from "@cre/generated/values/v1/values_pb"; +import { create, toJson } from "@bufbuild/protobuf"; +import { BasicActionCapability } from "@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen"; +import { BasicActionCapability as NodeActionCapability } from "@cre/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusFieldsFrom, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { val, vJson } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: successful_mode_switch [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + switchModes(Mode.DON); + // Getting time is required by test case after switching modes + Date.now(); + + const donInput = { inputThing: true }; + const basicActionCapability = new BasicActionCapability(); + + const donResponse = await basicActionCapability.performAction(donInput); + + switchModes(Mode.NODE); + Date.now(); + + const nodeInput = { inputThing: true }; + + const nodeActionCapability = new NodeActionCapability(); + const nodeResponse = await nodeActionCapability.performAction(nodeInput); + + switchModes(Mode.DON); + Date.now(); + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue( + val.mapValue({ OutputThing: val.int64(nodeResponse.outputThing) }) + ), + descriptors: consensusFieldsFrom({ + OutputThing: AggregationType.MEDIAN, + }), + default: val.mapValue({ + OutputThing: val.int64(123), + }), + }); + + const consensusCapability = new ConsensusCapability(); + const consensusOutput = await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + + const outputJson = toJson(ValueSchema, consensusOutput); + + sendResponseValue( + val.string( + `${donResponse.adaptedThing}${vJson.getFromMap( + outputJson, + "OutputThing", + "int64Value" + )}` + ) + ); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.ts b/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.ts new file mode 100644 index 00000000..b80f02fc --- /dev/null +++ b/src/workflows/standard_tests/mode_switch/successful_mode_switch/testts.ts @@ -0,0 +1,83 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { AggregationType, Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { ValueSchema } from "@cre/generated/values/v1/values_pb"; +import { create, toJson } from "@bufbuild/protobuf"; +import { BasicActionCapability } from "@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen"; +import { BasicActionCapability as NodeActionCapability } from "@cre/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { + consensusFieldsFrom, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { val, vJson } from "@cre/sdk/utils/values/value"; +import { Handler } from "@cre/sdk/workflow"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; +import { runInNodeMode } from "@cre/sdk/runtime/run-in-node-mode"; + +export async function main() { + console.log( + `TS workflow: standard test: mode_switch: successful_mode_switch [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const basicTrigger = new BasicTriggerCapability(); + const handler = async () => { + switchModes(Mode.DON); + Date.now(); + + const donInput = { inputThing: true }; + const basicActionCapability = new BasicActionCapability(); + const donResponse = await basicActionCapability.performAction(donInput); + + const consensusOutput = await runInNodeMode(async () => { + Date.now(); + const nodeActionCapability = new NodeActionCapability(); + const nodeResponse = await nodeActionCapability.performAction({ + inputThing: true, + }); + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue( + val.mapValue({ OutputThing: val.int64(nodeResponse.outputThing) }) + ), + descriptors: consensusFieldsFrom({ + OutputThing: AggregationType.MEDIAN, + }), + default: val.mapValue({ OutputThing: val.int64(123) }), + }); + return consensusInput; + }); + + Date.now(); + const outputJson = toJson(ValueSchema, consensusOutput); + sendResponseValue( + val.string( + `${donResponse.adaptedThing}${vJson.getFromMap( + outputJson, + "OutputThing", + "int64Value" + )}` + ) + ); + }; + + try { + const executeRequest = getRequest(); + await handleExecuteRequest(executeRequest, [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + handler + ), + ]); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/multiple_triggers/testts.old.ts b/src/workflows/standard_tests/multiple_triggers/testts.old.ts new file mode 100644 index 00000000..55d19ffc --- /dev/null +++ b/src/workflows/standard_tests/multiple_triggers/testts.old.ts @@ -0,0 +1,197 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import type { + ExecuteRequest, + ExecutionResult, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { + TriggerSubscriptionRequestSchema, + ExecutionResultSchema, +} from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { + ConfigSchema as BasicTriggerConfigSchema, + OutputsSchema as BasicTriggerOutputsSchema, +} from "@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb"; +import { + ConfigSchema as ActionTriggerConfigSchema, + TriggerEventSchema as ActionTriggerEventSchema, +} from "@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { create, toBinary, fromBinary } from "@bufbuild/protobuf"; +import { val } from "@cre/sdk/utils/values/value"; + +// Helpers declared here as its the last file left using them +export type ExecuteRequestType = "subscribe" | "trigger"; + +/** + * Type guard to check if the request is a subscribe request + */ +export const isSubscribeRequest = ( + executeRequest: ExecuteRequest +): executeRequest is ExecuteRequest & { subscribe: any } => + executeRequest.request.case === "subscribe"; + +/** + * Type guard to check if the request is a trigger request + */ +export const isTriggerRequest = ( + executeRequest: ExecuteRequest +): executeRequest is ExecuteRequest & { trigger: any } => + executeRequest.request.case === "trigger"; + +export const getRequestType = ( + executeRequest: ExecuteRequest +): ExecuteRequestType => { + if (isSubscribeRequest(executeRequest)) { + return "subscribe"; + } + + if (isTriggerRequest(executeRequest)) { + return "trigger"; + } + + throw new Error( + "Invalid ExecuteRequest: neither subscribe nor trigger is present" + ); +}; + +// END OF HELPERS + +function subscribe() { + // Create config objects for each capability + const basicTriggerConfig1 = create(BasicTriggerConfigSchema, { + name: "first-trigger", + number: 100, + }); + + const actionTriggerConfig = create(ActionTriggerConfigSchema, { + name: "second-trigger", + number: 150, + }); + + const basicTriggerConfig2 = create(BasicTriggerConfigSchema, { + name: "third-trigger", + number: 200, + }); + + const payload1 = { + typeUrl: `type.googleapis.com/${BasicTriggerConfigSchema.typeName}`, + value: toBinary(BasicTriggerConfigSchema, basicTriggerConfig1), + }; + + const payload2 = { + typeUrl: `type.googleapis.com/${ActionTriggerConfigSchema.typeName}`, + value: toBinary(ActionTriggerConfigSchema, actionTriggerConfig), + }; + + const payload3 = { + typeUrl: `type.googleapis.com/${BasicTriggerConfigSchema.typeName}`, + value: toBinary(BasicTriggerConfigSchema, basicTriggerConfig2), + }; + + const subscriptionRequest = create(TriggerSubscriptionRequestSchema, { + subscriptions: [ + { + id: "basic-test-trigger@1.0.0", + payload: payload1, + method: "Trigger", + }, + { + id: "basic-test-action-trigger@1.0.0", + payload: payload2, + method: "Trigger", + }, + { + id: "basic-test-trigger@1.0.0", + payload: payload3, + method: "Trigger", + }, + ], + }); + + const execResult: ExecutionResult = create(ExecutionResultSchema, { + result: { + case: "triggerSubscriptions", + value: subscriptionRequest, + }, + }); + + const encoded = toBinary(ExecutionResultSchema, execResult); + + sendResponse(Buffer.from(encoded).toString("base64")); +} + +function trigger(executeRequest: ExecuteRequest) { + if (!executeRequest.request.value.payload) { + throw new Error("TS: no payload in trigger"); + } + + try { + const triggerId = parseInt(executeRequest.request.value.id, 10); + // Hardcoded ids are matching standard test definition in GO + switch (triggerId) { + case 0: + case 2: { + const basicTriggerOutputs = fromBinary( + BasicTriggerOutputsSchema, + executeRequest.request.value.payload.value + ); + + sendResponseValue( + val.string( + `called ${triggerId} with ${basicTriggerOutputs.coolOutput}` + ) + ); + break; + } + case 1: { + const actionTriggerEvent = fromBinary( + ActionTriggerEventSchema, + executeRequest.request.value.payload.value + ); + sendResponseValue( + val.string( + `called ${triggerId} with ${actionTriggerEvent.coolOutput}` + ) + ); + break; + } + default: + throw new Error(`TS: unknown trigger id: ${triggerId}`); + } + } catch (e) { + errorBoundary(e); + } +} + +export async function main() { + console.log( + `TS workflow: standard test: multiple_triggers [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const executeRequest = getRequest(); + const requestType = getRequestType(executeRequest); + + switch (requestType) { + case "subscribe": + subscribe(); + break; + case "trigger": + trigger(executeRequest); + break; + default: + throw new Error(`Unknown request type: ${requestType}`); + } + + console.log("TS - MULTIPLE TRIGGERS DONE"); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/multiple_triggers/testts.ts b/src/workflows/standard_tests/multiple_triggers/testts.ts new file mode 100644 index 00000000..fa5cd7b6 --- /dev/null +++ b/src/workflows/standard_tests/multiple_triggers/testts.ts @@ -0,0 +1,52 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { Handler } from "@cre/sdk/workflow"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { type ExecuteRequest } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; +import { BasicCapability as ActionAndTriggerCapability } from "@cre/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { val } from "@cre/sdk/utils/values/value"; + +const buildWorkflow = () => { + const basicTrigger = new BasicTriggerCapability(); + const actionTrigger = new ActionAndTriggerCapability(); + + return [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + (_env, _rt, out) => + sendResponseValue(val.string(`called 0 with ${out.coolOutput}`)) + ), + Handler( + actionTrigger.trigger({ name: "second-trigger", number: 150 }), + (_env, _rt, out) => + sendResponseValue(val.string(`called 1 with ${out.coolOutput}`)) + ), + Handler( + basicTrigger.trigger({ name: "third-trigger", number: 200 }), + (_env, _rt, out) => + sendResponseValue(val.string(`called 2 with ${out.coolOutput}`)) + ), + ]; +}; + +export async function main() { + console.log( + `TS workflow: standard test: multiple_triggers [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const executeRequest: ExecuteRequest = getRequest(); + const workflow = buildWorkflow(); + await handleExecuteRequest(executeRequest, workflow); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/random/testts.old.ts b/src/workflows/standard_tests/random/testts.old.ts new file mode 100644 index 00000000..0d0e920d --- /dev/null +++ b/src/workflows/standard_tests/random/testts.old.ts @@ -0,0 +1,70 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { AggregationType, Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { Rand } from "@cre/sdk/utils/random"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { create, toJson } from "@bufbuild/protobuf"; +import { BasicActionCapability as NodeActionCapability } from "@cre/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen"; +import { ConsensusCapability } from "@cre/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen"; +import { val } from "@cre/sdk/utils/values/value"; +import { + consensusFieldsFrom, + observationValue, +} from "@cre/sdk/utils/values/consensus"; + +export async function main() { + console.log( + `TS workflow: standard test: random [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const donModeNumber = Mode.DON; + const donSeed = BigInt(randomSeed(donModeNumber)); + const donRandomNumber = new Rand(donSeed); + let total = donRandomNumber.Uint64(); + + switchModes(Mode.NODE); + + const nodeModeNumber = Mode.NODE; + const nodeSeed = BigInt(randomSeed(nodeModeNumber)); + const nodeRandomNumber = new Rand(nodeSeed); + + const nodeActionCapability = new NodeActionCapability(); + const nodeResponse = await nodeActionCapability.performAction({ + inputThing: true, + }); + + if (nodeResponse.outputThing < 100) { + log("***" + nodeRandomNumber.Uint64().toString()); + } + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue( + val.mapValue({ OutputThing: val.int64(nodeResponse.outputThing) }) + ), + descriptors: consensusFieldsFrom({ OutputThing: AggregationType.MEDIAN }), + default: val.mapValue({ + OutputThing: val.int64(123), + }), + }); + + const consensusCapability = new ConsensusCapability(); + await consensusCapability.simple( + toJson(SimpleConsensusInputsSchema, consensusInput) + ); + + switchModes(Mode.DON); + + total += donRandomNumber.Uint64(); + + sendResponseValue(val.bigint(total)); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/random/testts.ts b/src/workflows/standard_tests/random/testts.ts new file mode 100644 index 00000000..187fb67a --- /dev/null +++ b/src/workflows/standard_tests/random/testts.ts @@ -0,0 +1,83 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { AggregationType, Mode } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { SimpleConsensusInputsSchema } from "@cre/generated/sdk/v1alpha/sdk_pb"; +import { Rand } from "@cre/sdk/utils/random"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { create } from "@bufbuild/protobuf"; +import { BasicActionCapability as NodeActionCapability } from "@cre/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen"; +import { val } from "@cre/sdk/utils/values/value"; +import { Handler } from "@cre/sdk/workflow"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; +import { + consensusFieldsFrom, + observationValue, +} from "@cre/sdk/utils/values/consensus"; +import { runInNodeMode } from "@cre/sdk/runtime/run-in-node-mode"; + +export async function main() { + console.log( + `TS workflow: standard test: random [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const basicTrigger = new BasicTriggerCapability(); + const handler = async () => { + const donSeed = BigInt(randomSeed(Mode.DON)); + const donRandomNumber = new Rand(donSeed); + let total = donRandomNumber.Uint64(); + + await runInNodeMode(async () => { + const nodeSeed = BigInt(randomSeed(Mode.NODE)); + const nodeRandomNumber = new Rand(nodeSeed); + + const nodeActionCapability = new NodeActionCapability(); + const nodeResponse = await nodeActionCapability.performAction({ + inputThing: true, + }); + + if (nodeResponse.outputThing < 100) { + log("***" + nodeRandomNumber.Uint64().toString()); + } + + const consensusInput = create(SimpleConsensusInputsSchema, { + observation: observationValue( + val.mapValue({ OutputThing: val.int64(nodeResponse.outputThing) }) + ), + descriptors: consensusFieldsFrom({ + OutputThing: AggregationType.MEDIAN, + }), + default: val.mapValue({ + OutputThing: val.int64(123), + }), + }); + + // runInNodeMode accepts message or JSON; pass message for clarity + return consensusInput; + }); + + total += donRandomNumber.Uint64(); + + sendResponseValue(val.bigint(total)); + }; + + const workflow = [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + handler + ), + ]; + + try { + const executeRequest = getRequest(); + await handleExecuteRequest(executeRequest, workflow); + } catch (e) { + errorBoundary(e); + } +} + +main(); diff --git a/src/workflows/standard_tests/secrets/testts.old.ts b/src/workflows/standard_tests/secrets/testts.old.ts new file mode 100644 index 00000000..a5c4d137 --- /dev/null +++ b/src/workflows/standard_tests/secrets/testts.old.ts @@ -0,0 +1,30 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { SecretsError } from "@cre/sdk/utils/secrets-error"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { getSecret } from "@cre/sdk/utils/get-secret"; +import { val } from "@cre/sdk/utils/values/value"; + +export async function main() { + console.log( + `TS workflow: standard test: secrets [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + try { + const secret = await getSecret("Foo"); + + sendResponseValue(val.string(secret)); + } catch (e) { + if (e instanceof SecretsError) { + sendErrorWrapped(e.message); + } else { + errorBoundary(e); + } + } +} + +main(); diff --git a/src/workflows/standard_tests/secrets/testts.ts b/src/workflows/standard_tests/secrets/testts.ts new file mode 100644 index 00000000..8234cfa0 --- /dev/null +++ b/src/workflows/standard_tests/secrets/testts.ts @@ -0,0 +1,44 @@ +import { prepareRuntime } from "@cre/sdk/utils/prepare-runtime"; +import { sendResponseValue } from "@cre/sdk/utils/send-response-value"; +import { sendErrorWrapped } from "@cre/sdk/testhelpers/send-error-wrapped"; +import { SecretsError } from "@cre/sdk/utils/secrets-error"; +import { errorBoundary } from "@cre/sdk/utils/error-boundary"; +import { getSecret } from "@cre/sdk/utils/get-secret"; +import { val } from "@cre/sdk/utils/values/value"; +import { Handler } from "@cre/sdk/workflow"; +import { handleExecuteRequest } from "@cre/sdk/engine/execute"; +import { getRequest } from "@cre/sdk/utils/get-request"; +import { BasicCapability as BasicTriggerCapability } from "@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen"; + +export async function main() { + console.log( + `TS workflow: standard test: secrets [${new Date().toISOString()}]` + ); + + prepareRuntime(); + versionV2(); + + const basicTrigger = new BasicTriggerCapability(); + const workflow = [ + Handler( + basicTrigger.trigger({ name: "first-trigger", number: 100 }), + async () => { + const secret = await getSecret("Foo"); + sendResponseValue(val.string(secret)); + } + ), + ]; + + try { + const executeRequest = getRequest(); + await handleExecuteRequest(executeRequest, workflow); + } catch (e) { + if (e instanceof SecretsError) { + sendErrorWrapped(e.message); + } else { + errorBoundary(e); + } + } +} + +main(); diff --git a/src/workflows/workflow.wit b/src/workflows/workflow.wit new file mode 100644 index 00000000..356d6101 --- /dev/null +++ b/src/workflows/workflow.wit @@ -0,0 +1,5 @@ +package local:main; + +world workflow { + export main: func(); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..56203c5d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Path aliases + "baseUrl": ".", + "paths": { + "@cre/*": ["src/*"] + }, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + }, + "include": ["src/**/*", "scripts/generate-sdks.ts"], + "exclude": ["ai/**/*"] +}