Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove runtime field from TypeNode #858

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ src/typegraph/python/typegraph/gen
examples/typegraphs/migrations
examples/typegraphs/**/*.wasm
src/pyrt_wit_wire/wit_wire

/.metatype
249 changes: 74 additions & 175 deletions deno.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/common/src/typegraph/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub enum Injection {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct TypeNodeBase {
pub title: String,
pub runtime: u32,
pub policies: Vec<PolicyIndices>,
#[serde(default)]
pub description: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/metagen/fixtures/mat_rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ init_mat! {

struct FaasImpl;

impl MyFaas for FaasImpl {
impl RootMyFaasFn for FaasImpl {
fn handle(&self, input: MyObj, _cx: Ctx) -> anyhow::Result<MyObj> {
Ok(input)
}
Expand Down
1 change: 0 additions & 1 deletion src/metagen/src/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ pub fn default_type_node_base() -> TypeNodeBase {
title: String::new(),
as_id: false,
config: Default::default(),
runtime: 0,
policies: vec![],
injection: None,
description: None,
Expand Down
6 changes: 5 additions & 1 deletion src/typegate/src/engine/planner/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ export class Planner {
);
}

const runtime = this.tg.runtimeReferences[schema.runtime];
const runtime = (schema.type === Type.FUNCTION)
? this.tg
.runtimeReferences[(this.tg.materializer(schema.materializer)).runtime]
: node.parentStage?.props.runtime ??
this.tg.runtimeReferences[this.tg.denoRuntimeIdx];

const stage = this.createComputeStage(node, {
dependencies: node.parentStage ? [node.parentStage.id()] : [],
Expand Down
1 change: 0 additions & 1 deletion src/typegate/src/engine/typecheck/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export class ResultValidationCompiler {
cg.generateStringValidator({
type: "string",
title: "__TypeName",
runtime: -1,
policies: [],
as_id: false,
});
Expand Down
2 changes: 0 additions & 2 deletions src/typegate/src/runtimes/typegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface TypeInfo {
as_id: boolean;
title: string;
type: string;
runtime: string;
/** list of json string */
enum: string[] | null;
/** json string */
Expand Down Expand Up @@ -562,7 +561,6 @@ function walkPath(
title: node.title,
type: node.type,
enum: node.enum ?? null,
runtime: tg.runtime(node.runtime).name,
config: node.config ? JSON.stringify(node.config) : null,
default: defaultValue ? JSON.stringify(defaultValue) : null,
format: format ?? null,
Expand Down
10 changes: 8 additions & 2 deletions src/typegate/src/typegraph/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ import randomizeRecursively from "../runtimes/random.ts";
import type { Typegate } from "../typegate/mod.ts";
import { TypeUtils } from "./utils.ts";

export type { Cors, Rate, TypeGraphDS, TypeMaterializer, TypePolicy, TypeRuntime };
export type {
Cors,
Rate,
TypeGraphDS,
TypeMaterializer,
TypePolicy,
TypeRuntime,
};

export type RuntimeResolver = Record<string, Runtime>;

Expand Down Expand Up @@ -89,7 +96,6 @@ export class TypeGraph implements AsyncDisposable {
title: "string",
type: "string",
policies: [],
runtime: -1,
as_id: false,
};

Expand Down
12 changes: 0 additions & 12 deletions src/typegate/src/typegraph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
export type OptionalNode = {
type: "optional";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -21,7 +20,6 @@ export type OptionalNode = {
export type BooleanNode = {
type: "boolean";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -34,7 +32,6 @@ export type BooleanNode = {
export type FloatNode = {
type: "float";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -52,7 +49,6 @@ export type FloatNode = {
export type IntegerNode = {
type: "integer";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -70,7 +66,6 @@ export type IntegerNode = {
export type StringNode = {
type: "string";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -87,7 +82,6 @@ export type StringNode = {
export type FileNode = {
type: "file";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -103,7 +97,6 @@ export type FileNode = {
export type ObjectNode = {
type: "object";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -120,7 +113,6 @@ export type ObjectNode = {
export type ListNode = {
type: "list";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -137,7 +129,6 @@ export type ListNode = {
export type FunctionNode = {
type: "function";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -156,7 +147,6 @@ export type FunctionNode = {
export type UnionNode = {
type: "union";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -170,7 +160,6 @@ export type UnionNode = {
export type EitherNode = {
type: "either";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand All @@ -184,7 +173,6 @@ export type EitherNode = {
export type AnyNode = {
type: "any";
title: string;
runtime: number;
policies: PolicyIndices[];
description?: string | null;
injection?: Injection | null;
Expand Down
Loading
Loading