Skip to content

Commit

Permalink
fix: stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Feb 6, 2025
2 parents 43ed42c + 47d1005 commit ba59756
Show file tree
Hide file tree
Showing 86 changed files with 2,148 additions and 1,279 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
- uses: dsherret/rust-toolchain-file@v1
with:
targets: ${{ matrix.target }}
- uses: mozilla-actions/[email protected].6
- uses: mozilla-actions/[email protected].7
- run: |
# sometimes, dtolnay/rust-toolchain does not select the correct default target
rustup target add ${{ matrix.target }}
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
- uses: WyriHaximus/[email protected]
id: latest-tag
- uses: dsherret/rust-toolchain-file@v1
- uses: mozilla-actions/[email protected].6
- uses: mozilla-actions/[email protected].7
- uses: metatypedev/setup-ghjk@318209a9d215f70716a4ac89dbeb9653a2deb8bc
- shell: bash
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
name: Setup sccache secrets
run: echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- if: ${{ env.AWS_ACCESS_KEY_ID != '' }}
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].7
- uses: metatypedev/setup-ghjk@318209a9d215f70716a4ac89dbeb9653a2deb8bc
- shell: bash
run: |
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
name: Setup sccache secrets
run: echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- if: ${{ env.AWS_ACCESS_KEY_ID != '' }}
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].7
- uses: metatypedev/setup-ghjk@318209a9d215f70716a4ac89dbeb9653a2deb8bc
with:
# temporary fix
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
name: Setup sccache secrets
run: echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- if: ${{ env.AWS_ACCESS_KEY_ID != '' }}
uses: mozilla-actions/[email protected].6
uses: mozilla-actions/[email protected].7
# - name: Cache deno dir
# uses: actions/cache@v4
# with:
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"src/common",
"src/meta-cli",
"src/metagen",
"src/metagen/src/fdk_rust/static",
"src/metagen/src/fdk_rs/static",
"src/mt_deno",
"src/typegate/engine",
"src/typegate/standalone",
Expand Down
3 changes: 3 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/metatype.dev/docs/guides/external-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ metagen:
targets:
# named targets to configure a bunch of generators together
metagen_deno:
- generator: fdk_typescript # generator to use
- generator: fdk_ts # generator to use
# path to generate to
path: ./metagen/ts/
# point to the typegraph location
Expand Down Expand Up @@ -142,7 +142,7 @@ Within `fdk.ts` and the types and helpers, all the types from your typegraph sho

</details>

Note, this also include typescript function types for specific typegraph functions. By default, the `fdk_typescript` generator will only include stub function types for those defined on the `DenoRuntime` but this is [configurable](/docs/reference/metagen#fdk_typescript).
Note, this also include typescript function types for specific typegraph functions. By default, the `fdk_ts` generator will only include stub function types for those defined on the `DenoRuntime` but this is [configurable](/docs/reference/metagen#fdk_ts).

We can then use these types in the following manner. Add the following snippet into `metagen/ts/remix.ts`.

Expand Down
8 changes: 4 additions & 4 deletions docs/metatype.dev/docs/guides/wasm-functions/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ Note that the `WasmRuntime` constructor mentions a non-existent wasm file on dis

## Metagen

We can now tackle the boilerplate. Metagen bundles the [`fdk_rust`](/docs/reference/metagen#fdk_rust) generator which can generate all the glue code along with Rust types that correspond to our typegraph types. Let's configure a metagen target in our configuration file to get just that done.
We can now tackle the boilerplate. Metagen bundles the [`fdk_rs`](/docs/reference/metagen#fdk_rs) generator which can generate all the glue code along with Rust types that correspond to our typegraph types. Let's configure a metagen target in our configuration file to get just that done.

```yaml
metagen:
targets:
metagen_rs:
# this is the generator we're interested in
- generator: fdk_rust
- generator: fdk_rs
# the location where to put the generated files
path: ./metagen/rs/
# the path to our typegraph
Expand All @@ -69,7 +69,7 @@ This should give us the following files:
└──  fdk.rs
```

By default, the `fdk_rust` generator outputs all the necessary files required to build our wasm file. This includes the `Cargo.toml` manifest for our Rust crate.
By default, the `fdk_rs` generator outputs all the necessary files required to build our wasm file. This includes the `Cargo.toml` manifest for our Rust crate.

<CodeBlock language="toml">
{
Expand All @@ -78,7 +78,7 @@ By default, the `fdk_rust` generator outputs all the necessary files required to
}
</CodeBlock>

`fdk_rust` will not overwrite a `Cargo.toml` file discovered at generation path so you can add other dependencies if need be.
`fdk_rs` will not overwrite a `Cargo.toml` file discovered at generation path so you can add other dependencies if need be.

The `fdk.rs` file contains all the glue code including the typegraph types.

Expand Down
12 changes: 6 additions & 6 deletions docs/metatype.dev/docs/reference/metagen/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ metagen:
targets:
main:
# generator to use
- generator: fdk_rust
- generator: fdk_rs
# path to generate to
path: ./bff/
# typegraph path to use
typegraph_path: ./typegraphs/svc-bff.ts
# we can have multiple generators per target
- generator: fdk_rust
- generator: fdk_rs
path: ./telemetry/
typegraph_path: ./typegraphs/svc-telemetry.ts
# generators might have custom keys
Expand Down Expand Up @@ -118,7 +118,7 @@ This generator supports:

Refer to the [client reference](/docs/reference/typegraph/client/) for usage guidelines and examples.

### `fdk_typescript`
### `fdk_ts`

This generator supports:

Expand Down Expand Up @@ -163,14 +163,14 @@ It supports the following extra configuration keys.
| ------------------ | ---------- | ---------- | ------------------------------------------ |
| `stubbed_runtimes` | `string[]` | `["deno"]` | Runtimes for which to generate stub types. |

### `fdk_python`
### `fdk_py`

This generator supports:

- Python classes that map to typegraph types
- Decorators for custom functions implementors that require adherance to typegraph function types.
- By default, all functions from the `PythonRuntime` get stub types.
- TODO: `stubbed_runtimes` for `fdk_python`
- TODO: `stubbed_runtimes` for `fdk_py`
- TODO: types for interacting with the typegate from within custom functions.

If the referenced module for the custom function is not found, the generator will also output stub implementation (in addition to the types) at the given type. It will not replace our code on a second run.
Expand Down Expand Up @@ -202,7 +202,7 @@ Custom function:
/>
</details>

### `fdk_rust`
### `fdk_rs`

This generator generates types, serializers and bindings needed to implement custom functions in Rust. Rust implementations will need to be compiled to wasm components to be executed on the metatype platform and the generator assumes such usage.

Expand Down
6 changes: 3 additions & 3 deletions examples/metatype.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ typegraphs:
metagen:
targets:
metagen_deno:
- generator: fdk_typescript
- generator: fdk_ts
path: ./typegraphs/metagen/ts/
typegraph_path: ./typegraphs/metagen-deno.ts
metagen_py:
- generator: fdk_python
- generator: fdk_py
path: ./typegraphs/metagen/py/
typegraph_path: ./typegraphs/metagen-py.ts
metagen_rs:
- generator: fdk_rust
- generator: fdk_rs
path: ./typegraphs/metagen/rs/
typegraph_path: ./typegraphs/metagen-rs.ts
2 changes: 1 addition & 1 deletion examples/typegraphs/metagen-sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def metagen_sdk(g: Graph):
"targets": {
"main": [
{
"generator": "fdk_typescript",
"generator": "fdk_ts",
"typegraph_path": __file__,
"path": "funcs/",
},
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/metagen-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if (false) {
targets: {
main: [
{
generator: "fdk_typescript",
generator: "fdk_ts",
typegraph_path: myPath,
path: "funcs/",
},
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typegraph = { path = "src/typegraph/python", develop = true }

[tool.poetry.group.dev.dependencies]
# used in ./tests/importers/*.py
respx = "^0.21.1"
respx = "^0.22.0"
# used in examples/programmable-api-gateway
pyyaml = "^6.0.1"

Expand Down
6 changes: 3 additions & 3 deletions src/common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::{Context, Result};
use indoc::indoc;
use reqwest::{Client, IntoUrl, RequestBuilder, Url};
use serde::Serialize;
use std::{collections::HashMap, time::Duration};
use std::{collections::HashMap, sync::Arc, time::Duration};

use crate::{
graphql::{self, Query},
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Node {
Ok(())
}

pub async fn typegraph(&self, name: &str) -> Result<Option<Box<Typegraph>>, Error> {
pub async fn typegraph(&self, name: &str) -> Result<Option<Arc<Typegraph>>, Error> {
let res = self
.post("/typegate")
.map_err(Error::Other)?
Expand Down Expand Up @@ -157,7 +157,7 @@ impl Node {
return Ok(None);
};
serde_json::from_str::<Typegraph>(&res.serialized)
.map(|tg| Some(Box::new(tg)))
.map(|tg| Some(Arc::new(tg)))
.map_err(|err| Error::Other(anyhow::anyhow!(err)))
}
}
2 changes: 1 addition & 1 deletion src/meta-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ git2 = { workspace = true, features = [
], default-features = false }

# codecs
serde.workspace = true
serde = { workspace = true, features = ["rc"] }
serde_json = { workspace = true, features = ["preserve_order"] }
flate2.workspace = true
tar.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions src/meta-cli/src/cli/fdk_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ impl Action for CreateFdkTemplate {
.context("failed to create target directory")?;

let template = match self.template {
Template::Rust => metagen::FDK_RUST_DEFAULT_TEMPLATE,
Template::Python => metagen::FDK_PYTHON_DEFAULT_TEMPLATE,
Template::Typescript => metagen::FDK_TYPESCRIPT_DEFAULT_TEMPLATE,
Template::Rust => metagen::FDK_RS_DEFAULT_TEMPLATE,
Template::Python => metagen::FDK_PY_DEFAULT_TEMPLATE,
Template::Typescript => metagen::FDK_TS_DEFAULT_TEMPLATE,
};

for (file_name, content) in template.iter() {
Expand Down
Loading

0 comments on commit ba59756

Please sign in to comment.