Skip to content

Commit

Permalink
feat(metagen): client_ts (#790)
Browse files Browse the repository at this point in the history
- Implements `client_ts` as described in #777 .

#### Migration notes

...

- [x] The change comes with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Improved error handling in the `typegraph` function to provide better
error messages.

- **Chores**
- Updated Docker image references to use `docker.io` prefix for
consistency.
  - Excluded unnecessary files from the VSCode settings.
  - Enhanced configurability of Docker commands in development tasks.
- Updated environment variable `GHJK_VERSION` to reflect a semantic
versioning format.

- **New Features**
- Introduced modules and methods for TypeScript and Python code
generation in the `metagen` library, enhancing client generation
capabilities.
  - Added `test_typegraph_3` function for improved testing capabilities.
  - Included metadata for the package manager in the project settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Yohe-Am authored Aug 25, 2024
1 parent 2db4e13 commit 51f20a0
Show file tree
Hide file tree
Showing 93 changed files with 13,842 additions and 2,227 deletions.
498 changes: 80 additions & 418 deletions .ghjk/deno.lock

Large diffs are not rendered by default.

907 changes: 278 additions & 629 deletions .ghjk/lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- main

env:
GHJK_VERSION: "b702292"
GHJK_VERSION: "v0.2.1"

jobs:
changes:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- v*

env:
GHJK_VERSION: "b702292"
GHJK_VERSION: "v0.2.1"
GHJK_ENV: "ci"
REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/typegate
DOCKER_BUILD_NO_SUMMARY: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- ready_for_review

env:
GHJK_VERSION: "b702292"
GHJK_VERSION: "v0.2.1"
GHJK_ENV: "ci"
RUST_BACKTRACE: "full"
DENO_DIR: deno-dir
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ repos:
- id: deno-fmt
name: Deno format
language: system
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp,tests/e2e/nextjs && cd ../dev && deno fmt && cd ../typegraph/deno && deno fmt --ignore=node_modules,dist'
entry: bash -c 'cd typegate && deno fmt --ignore=native,src/typegraphs,tmp,tests/e2e/nextjs && cd ../dev && deno fmt && cd ../typegraph/deno && deno fmt --ignore=node_modules,dist && cd ../../libs/metagen/src && deno fmt'
pass_filenames: false
types:
- ts
files: ^(typegate|dev|typegraph/deno)/
- id: deno-lint
name: Deno lint
language: system
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp,tests/e2e/nextjs && cd ../dev && deno lint'
entry: bash -c 'cd typegate && deno lint --rules-exclude=no-explicit-any --ignore=native,tmp,tests/e2e/nextjs && cd ../dev && deno lint && cd ../libs/metagen/src/ && deno lint'
pass_filenames: false
types:
- ts
Expand Down
31 changes: 20 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
"website/.docusaurus": true,
"website/node_modules": true
},
"deno.enablePaths": [
"typegate",
"dev",
"examples/templates/deno",
"examples/typegraphs",
"typegraph/deno/dev",
"typegraph/deno/sdk",
"ghjk.ts",
".ghjk"
"deno.disablePaths": [
"meta-lsp",
"typegraph/node",
"examples/templates/node",
"website"
],
"deno.importMap": "typegate/import_map.json",
// "deno.enablePaths": [
// "typegate",
// "dev",
// "examples/templates/deno",
// "examples/typegraphs",
// "typegraph/deno/dev",
// "typegraph/deno/sdk",
// "libs/metagen",
// "ghjk.ts",
// ".ghjk"
// ],
// "deno.config": "typegate/deno.jsonc",
"deno.unstable": true,
"typescript.suggest.completeFunctionCalls": true,
"typescript.inlayHints.variableTypes.enabled": true,
Expand Down Expand Up @@ -62,6 +69,8 @@
"wasmedge"
],
"python.languageServer": "Pylance",
"python.analysis.extraPaths": ["typegraph/python"],
"python.analysis.extraPaths": [
"typegraph/python"
],
"prettier.proseWrap": "never"
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ You can install it using the following instructions.

```bash
# install ghjk
GHJK_VERSION="b702292"
GHJK_VERSION="v0.2.1"
GHJK_INSTALL_HOOK_SHELLS=bash # add more shells if needed
curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/$GHJK_VERSION/install.sh | sh
bash # re-open your shells to have the hooks register
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"
members = [
"libs/*",
"libs/metagen/src/mdk_rust/static",
"libs/metagen/src/client_rs/static",
"typegate/engine",
"typegate/standalone",
"meta-cli",
Expand All @@ -12,6 +13,7 @@ members = [
exclude = [
"typegate/tests/runtimes/wasm_reflected/rust",
"typegate/tests/runtimes/wasm_wire/rust",
"typegate/tests/metagen/typegraphs/sample/rs",
"libs/pyrt_wit_wire",
]
[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RUN set -eux; \
; \
apt clean autoclean; apt autoremove --yes; rm -rf /var/lib/{apt,dpkg,cache,log}/;

ARG GHJK_VERSION=b702292
ARG GHJK_VERSION=v0.2.1
RUN GHJK_INSTALL_EXE_DIR=/usr/bin GHJK_INSTALL_HOOK_SHELLS=bash \
deno run -A https://raw.github.com/metatypedev/ghjk/$GHJK_VERSION/install.ts

Expand Down
2 changes: 1 addition & 1 deletion dev/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

export const METATYPE_VERSION = "0.4.8";
export const PUBLISHED_VERSION = "0.4.7";
export const GHJK_VERSION = "b702292";
export const GHJK_VERSION = "v0.2.1";
export const GHJK_ACTION_VERSION = "318209a9d215f70716a4ac89dbeb9653a2deb8bc";
export const RUST_VERSION = "1.79.0";
export const DENO_VERSION = "1.45.2";
Expand Down
2 changes: 1 addition & 1 deletion dev/cross.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN set -eux \
unzip

ENV GHJK_SHARE_DIR=/ghjk
ARG GHJK_VERSION=b702292
ARG GHJK_VERSION=v0.2.1
RUN curl -fsSL https://raw.github.com/metatypedev/ghjk/$GHJK_VERSION/install.sh \
| GHJK_INSTALL_EXE_DIR=/usr/bin GHJK_INSTALL_HOOK_SHELLS=bash sh

Expand Down
12 changes: 6 additions & 6 deletions dev/deps.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Copyright Metatype OÜ, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0

export { file } from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/mod.ts";
export * from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/mod.ts";
export * as ports from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/ports/mod.ts";
export { file } from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/mod.ts";
export * from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/mod.ts";
export * as ports from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/ports/mod.ts";
export {
std_url,
zod,
} from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/deps/common.ts";
} from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/deps/common.ts";
export {
copyLock,
sedLock,
} from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/std.ts";
export { downloadFile } from "https://raw.githubusercontent.com/metatypedev/ghjk/b702292/utils/mod.ts";
} from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/std.ts";
export { downloadFile } from "https://raw.githubusercontent.com/metatypedev/ghjk/v0.2.1/utils/mod.ts";
// export * from "../../ghjk/mod.ts";
// export * as ports from "../../ghjk/ports/mod.ts";
// export * as utils from "../../ghjk/utils/mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion dev/envs/compose.adminer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
adminer:
image: adminer:latest
image: docker.io/library/adminer:latest
restart: unless-stopped
ports:
- 8080:8080
4 changes: 2 additions & 2 deletions dev/envs/compose.base.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
envoy:
image: envoyproxy/envoy:v1.26-latest
image: docker.io/envoyproxy/envoy:v1.26-latest
restart: unless-stopped
ports:
- "9901:9901"
Expand All @@ -11,7 +11,7 @@ services:
- "host.docker.internal:host-gateway"

redis:
image: bitnami/redis:7.0
image: docker.io/bitnami/redis:7.0
restart: unless-stopped
ports:
- "6379:6379"
Expand Down
2 changes: 1 addition & 1 deletion dev/envs/compose.imgproxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
imgproxy:
image: darthsim/imgproxy:v3.9
image: docker.io/darthsim/imgproxy:v3.9
restart: unless-stopped
ports:
- "9002:8080"
Expand Down
2 changes: 1 addition & 1 deletion dev/envs/compose.prisma.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
postgres:
image: postgres:15
image: docker.io/library/postgres:15
restart: unless-stopped
ports:
- "5432:5432"
Expand Down
7 changes: 4 additions & 3 deletions dev/tasks-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import { DenoTaskDefArgs } from "./deps.ts";

const DOCKER_CMD = Deno.env.get("DOCKER_CMD") ?? "docker";

const tasks: Record<string, DenoTaskDefArgs> = {
dev: {
desc: "Execute dev/*.ts scripts.",
Expand Down Expand Up @@ -51,14 +53,14 @@ const tasks: Record<string, DenoTaskDefArgs> = {
}

if (on.size > 0) {
await $.raw`docker compose ${
await $.raw`${DOCKER_CMD} compose ${
[...on].flatMap((file) => [
"-f",
file,
])
} up -d --remove-orphans`;
} else {
await $.raw`docker compose ${
await $.raw`${DOCKER_CMD} compose ${
Object.values(files).flatMap((file) => [
"-f",
file,
Expand Down Expand Up @@ -87,7 +89,6 @@ const tasks: Record<string, DenoTaskDefArgs> = {
"a4lNi0PbEItlFZbus1oeH/+wyIxi9uH6TpL8AIqIaMBNvp7SESmuUBbfUwC0prxhGhZqHw8vMDYZAGMhSZ4fLw==",
TG_ADMIN_PASSWORD: "password",
TG_PORT: "7891",
// TMP_DIR: $.path(projectDir).join("tmp").toString(),
},
fn: ($) => $`cargo run -p typegate`,
},
Expand Down
28 changes: 28 additions & 0 deletions examples/deno.lock

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

14 changes: 6 additions & 8 deletions examples/typegraphs/metagen/rs/mdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]

// gen-static-start
#![allow(unused)]
#![allow(dead_code)]

pub mod wit {
wit_bindgen::generate!({
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.4.8-0";
static MT_VERSION: &str = "0.4.8";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down Expand Up @@ -219,20 +219,18 @@ macro_rules! init_mat {
// gen-static-end
use types::*;
pub mod types {
use super::*;
pub type StringDateTime = String;
pub type StringUri = String;
pub type StringDateTime4 = String;
pub type StringUri5 = String;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct Idv3 {
pub title: String,
pub artist: String,
#[serde(rename = "releaseTime")]
pub release_time: StringDateTime,
pub release_time: StringDateTime4,
#[serde(rename = "mp3Url")]
pub mp3_url: StringUri,
pub mp3_url: StringUri5,
}
}
use stubs::*;
pub mod stubs {
use super::*;
pub trait RemixTrack: Sized + 'static {
Expand Down
2 changes: 2 additions & 0 deletions ghjk.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck: Deno file

import { METATYPE_VERSION, PUBLISHED_VERSION } from "./dev/consts.ts";
import { file, ports, sedLock, semver, stdDeps } from "./dev/deps.ts";
import installs from "./dev/installs.ts";
Expand Down
Loading

0 comments on commit 51f20a0

Please sign in to comment.