diff --git a/Cargo.lock b/Cargo.lock index a00d99ddc..658d11491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1591,7 +1591,7 @@ dependencies = [ [[package]] name = "common" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "async-trait", @@ -6883,7 +6883,7 @@ dependencies = [ [[package]] name = "meta-cli" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "actix", "assert_cmd", @@ -6950,7 +6950,7 @@ dependencies = [ [[package]] name = "metagen" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "color-eyre", "common", @@ -6973,7 +6973,7 @@ dependencies = [ [[package]] name = "metagen-client" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "derive_more 1.0.0", "futures", @@ -7324,7 +7324,7 @@ dependencies = [ [[package]] name = "mt_deno" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "deno", @@ -10148,7 +10148,7 @@ dependencies = [ [[package]] name = "sample_client" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "metagen-client", "serde", @@ -10158,7 +10158,7 @@ dependencies = [ [[package]] name = "sample_client_upload" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "metagen-client", "serde", @@ -11310,7 +11310,7 @@ dependencies = [ [[package]] name = "substantial" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "chrono", @@ -12801,7 +12801,7 @@ dependencies = [ [[package]] name = "typegate" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "colored", "env_logger 0.11.0", @@ -12814,7 +12814,7 @@ dependencies = [ [[package]] name = "typegate_engine" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "base64 0.22.1", @@ -12859,7 +12859,7 @@ dependencies = [ [[package]] name = "typegraph_core" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "color-eyre", @@ -14645,7 +14645,7 @@ checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "xtask" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index c2fe2c3b1..40a4a340b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ exclude = [ ] [workspace.package] -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" edition = "2021" [workspace.dependencies] diff --git a/examples/templates/deno/api/example.ts b/examples/templates/deno/api/example.ts index d2cdb2aa5..84ed8f73f 100644 --- a/examples/templates/deno/api/example.ts +++ b/examples/templates/deno/api/example.ts @@ -1,6 +1,6 @@ import { Policy, t, typegraph } from "jsr:@typegraph/sdk@0.5.0-rc.7"; -import { PythonRuntime } from "jsr:@typegraph/sdk@0.5.0-rc.8/runtimes/python"; -import { DenoRuntime } from "jsr:@typegraph/sdk@0.5.0-rc.8/runtimes/deno"; +import { PythonRuntime } from "jsr:@typegraph/sdk@0.5.0-rc.9/runtimes/python"; +import { DenoRuntime } from "jsr:@typegraph/sdk@0.5.0-rc.9/runtimes/deno"; await typegraph("example", (g) => { const pub = Policy.public(); diff --git a/examples/templates/deno/compose.yml b/examples/templates/deno/compose.yml index 30ba2eef2..53edad51d 100644 --- a/examples/templates/deno/compose.yml +++ b/examples/templates/deno/compose.yml @@ -1,6 +1,6 @@ services: typegate: - image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8 + image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9 restart: always ports: - "7890:7890" diff --git a/examples/templates/node/compose.yml b/examples/templates/node/compose.yml index 617178f53..9aabef09c 100644 --- a/examples/templates/node/compose.yml +++ b/examples/templates/node/compose.yml @@ -1,6 +1,6 @@ services: typegate: - image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8 + image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9 restart: always ports: - "7890:7890" diff --git a/examples/templates/node/package.json b/examples/templates/node/package.json index 27c67864a..db711383a 100644 --- a/examples/templates/node/package.json +++ b/examples/templates/node/package.json @@ -6,7 +6,7 @@ "dev": "MCLI_LOADER_CMD='npm x tsx' meta dev" }, "dependencies": { - "@typegraph/sdk": "^0.5.0-rc.8" + "@typegraph/sdk": "^0.5.0-rc.9" }, "devDependencies": { "tsx": "^3.13.0", diff --git a/examples/templates/python/compose.yml b/examples/templates/python/compose.yml index 617178f53..9aabef09c 100644 --- a/examples/templates/python/compose.yml +++ b/examples/templates/python/compose.yml @@ -1,6 +1,6 @@ services: typegate: - image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8 + image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9 restart: always ports: - "7890:7890" diff --git a/examples/templates/python/pyproject.toml b/examples/templates/python/pyproject.toml index 41d63cb7e..15596621e 100644 --- a/examples/templates/python/pyproject.toml +++ b/examples/templates/python/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] name = "example" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" description = "" authors = [] [tool.poetry.dependencies] python = ">=3.8,<4.0" -typegraph = "0.5.0-rc.8" +typegraph = "0.5.0-rc.9" [build-system] requires = ["poetry-core"] diff --git a/pyproject.toml b/pyproject.toml index 31d03e64d..3ed96e97d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ [tool.poetry] name = "metatype" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" description = "" authors = [] diff --git a/src/pyrt_wit_wire/pyproject.toml b/src/pyrt_wit_wire/pyproject.toml index 2e9a66de5..d7033da20 100644 --- a/src/pyrt_wit_wire/pyproject.toml +++ b/src/pyrt_wit_wire/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyrt_wit_wire" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" description = "Wasm component implementing the PythonRuntime host using wit_wire protocol." license = "MPL-2.0" readme = "README.md" diff --git a/src/typegate/src/runtimes/deno/deno.ts b/src/typegate/src/runtimes/deno/deno.ts index 11989285f..c98ad0f50 100644 --- a/src/typegate/src/runtimes/deno/deno.ts +++ b/src/typegate/src/runtimes/deno/deno.ts @@ -37,7 +37,7 @@ const predefinedFuncs: Record>> = { allow: () => "ALLOW" as PolicyResolverOutput, deny: () => "DENY" as PolicyResolverOutput, pass: () => "PASS" as PolicyResolverOutput, - internal_policy: ({ _: { context } }) => context.provider === "internal" ? "ALLOW" : "DENY" as PolicyResolverOutput, + internal_policy: ({ _: { context } }) => context.provider === "internal" ? "ALLOW" : "PASS" as PolicyResolverOutput, }; export class DenoRuntime extends Runtime { @@ -73,9 +73,9 @@ export class DenoRuntime extends Runtime { const secrets: Record = {}; for (const m of materializers) { - let secrets = (m.data.secrets as string[]) ?? []; + let matSecrets = (m.data.secrets as string[]) ?? []; if (m.name === "outjection") { - secrets = m.data.source === "secret" + matSecrets = m.data.source === "secret" ? [...getInjectionValues(m.data)] : []; } diff --git a/src/typegate/src/runtimes/wit_wire/mod.ts b/src/typegate/src/runtimes/wit_wire/mod.ts index 49303d731..4174b2f9f 100644 --- a/src/typegate/src/runtimes/wit_wire/mod.ts +++ b/src/typegate/src/runtimes/wit_wire/mod.ts @@ -9,7 +9,7 @@ import { getLogger } from "../../log.ts"; const logger = getLogger(import.meta); -const METATYPE_VERSION = "0.5.0-rc.8"; +const METATYPE_VERSION = "0.5.0-rc.9"; export class WitWireMessenger { static async init( diff --git a/src/typegraph/core/Cargo.toml b/src/typegraph/core/Cargo.toml index 3ed60f8a4..eadd6d7ce 100644 --- a/src/typegraph/core/Cargo.toml +++ b/src/typegraph/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "typegraph_core" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" edition = "2021" [lib] diff --git a/src/typegraph/core/src/global_store.rs b/src/typegraph/core/src/global_store.rs index 700770420..b09b4a3a6 100644 --- a/src/typegraph/core/src/global_store.rs +++ b/src/typegraph/core/src/global_store.rs @@ -108,7 +108,7 @@ const PREDEFINED_DENO_FUNCTIONS: &[&str] = &["identity", "true"]; thread_local! { pub static STORE: RefCell = RefCell::new(Store::new()); - pub static SDK_VERSION: String = "0.5.0-rc.8".to_owned(); + pub static SDK_VERSION: String = "0.5.0-rc.9".to_owned(); } fn with_store T>(f: F) -> T { diff --git a/src/typegraph/deno/deno.json b/src/typegraph/deno/deno.json index 2dca8389f..0b0ea829e 100644 --- a/src/typegraph/deno/deno.json +++ b/src/typegraph/deno/deno.json @@ -1,6 +1,6 @@ { "name": "@typegraph/sdk", - "version": "0.5.0-rc.8", + "version": "0.5.0-rc.9", "publish": { "exclude": [ "!src/gen", diff --git a/src/typegraph/python/pyproject.toml b/src/typegraph/python/pyproject.toml index e8488d598..921b7e608 100644 --- a/src/typegraph/python/pyproject.toml +++ b/src/typegraph/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "typegraph" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" description = "Declarative API development platform. Build backend components with WASM, Typescript and Python, no matter where and how your (legacy) systems are." authors = ["Metatype Contributors "] license = "MPL-2.0" diff --git a/src/typegraph/python/typegraph/__init__.py b/src/typegraph/python/typegraph/__init__.py index 519178237..c88a4adc4 100644 --- a/src/typegraph/python/typegraph/__init__.py +++ b/src/typegraph/python/typegraph/__init__.py @@ -5,4 +5,4 @@ from typegraph.policy import Policy # noqa from typegraph import effects as fx # noqa -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" diff --git a/src/xtask/Cargo.toml b/src/xtask/Cargo.toml index 82009aec6..49320dbf5 100644 --- a/src/xtask/Cargo.toml +++ b/src/xtask/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xtask" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" edition = "2021" # this allows us to exclude the rust files diff --git a/tests/artifacts/artifacts_test.ts b/tests/artifacts/artifacts_test.ts index 17fafc273..63e6e4f66 100644 --- a/tests/artifacts/artifacts_test.ts +++ b/tests/artifacts/artifacts_test.ts @@ -81,7 +81,11 @@ for (const { mode, ...options } of variants) { ...options, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); const artifacts = e.tg.tg.meta.artifacts; await t.should("have uploaded artifacts on deploy", async () => { @@ -120,7 +124,11 @@ for (const { mode, ...options } of variants) { ...options, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); const artifacts = e.tg.tg.meta.artifacts; await t.should("have uploaded artifacts on deploy", async () => { @@ -149,7 +157,11 @@ for (const { mode, ...options } of variants) { ...options, }, async (t) => { - const engine = await t.engine("runtimes/deno/deno.py"); + const engine = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); const artifacts = engine.tg.tg.meta.artifacts; const enginePartial = await t.engine("runtimes/deno/deno_partial.py"); diff --git a/tests/metagen/__snapshots__/metagen_test.ts.snap b/tests/metagen/__snapshots__/metagen_test.ts.snap index 954bcd726..76e6d03fa 100644 --- a/tests/metagen/__snapshots__/metagen_test.ts.snap +++ b/tests/metagen/__snapshots__/metagen_test.ts.snap @@ -454,7 +454,7 @@ impl Router { } pub fn init(&self, args: InitArgs) -> Result { - static MT_VERSION: &str = "0.5.0-rc.8"; + static MT_VERSION: &str = "0.5.0-rc.9"; if args.metatype_version != MT_VERSION { return Err(InitError::VersionMismatch(MT_VERSION.into())); } @@ -1255,7 +1255,7 @@ impl Router { } pub fn init(&self, args: InitArgs) -> Result { - static MT_VERSION: &str = "0.5.0-rc.8"; + static MT_VERSION: &str = "0.5.0-rc.9"; if args.metatype_version != MT_VERSION { return Err(InitError::VersionMismatch(MT_VERSION.into())); } diff --git a/tests/metagen/typegraphs/sample/rs/Cargo.toml b/tests/metagen/typegraphs/sample/rs/Cargo.toml index 080341baa..40b12ca2c 100644 --- a/tests/metagen/typegraphs/sample/rs/Cargo.toml +++ b/tests/metagen/typegraphs/sample/rs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sample_client" edition = "2021" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" [dependencies] metagen-client.workspace = true diff --git a/tests/metagen/typegraphs/sample/rs_upload/Cargo.toml b/tests/metagen/typegraphs/sample/rs_upload/Cargo.toml index 69a4f9e50..9855c0e56 100644 --- a/tests/metagen/typegraphs/sample/rs_upload/Cargo.toml +++ b/tests/metagen/typegraphs/sample/rs_upload/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "sample_client_upload" edition = "2021" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" [dependencies] metagen-client.workspace = true diff --git a/tests/runtimes/deno/deno.py b/tests/runtimes/deno/deno.py index c29562f9a..b35b40288 100644 --- a/tests/runtimes/deno/deno.py +++ b/tests/runtimes/deno/deno.py @@ -36,6 +36,13 @@ def deno(g: Graph): name="counter", effect=effects.update(), ), + secrets=deno.import_( + t.struct(), + t.struct({"ok": t.boolean()}), + module="ts/deno.ts", + name="secrets", + secrets=["DENO_SECRET"], + ), min=deno.import_(number_input, t.float(), module="ts/math.ts", name="min"), max=deno.import_(number_input, t.float(), module="ts/math.ts", name="maxAsync"), log=deno.import_( diff --git a/tests/runtimes/deno/deno_sync_test.ts b/tests/runtimes/deno/deno_sync_test.ts index 00278d92f..79688aef9 100644 --- a/tests/runtimes/deno/deno_sync_test.ts +++ b/tests/runtimes/deno/deno_sync_test.ts @@ -37,7 +37,11 @@ Meta.test( }, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("work on the default worker", async () => { await gql` @@ -128,7 +132,11 @@ Meta.test( }, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("success for allowed network access", async () => { await gql` @@ -368,7 +376,11 @@ Meta.test( }, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("safely fail upon stack overflow", async () => { await gql` diff --git a/tests/runtimes/deno/deno_test.ts b/tests/runtimes/deno/deno_test.ts index cf18f285d..b0d14dce4 100644 --- a/tests/runtimes/deno/deno_test.ts +++ b/tests/runtimes/deno/deno_test.ts @@ -9,7 +9,11 @@ Meta.test( name: "Deno runtime", }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("work on the default worker", async () => { await gql` @@ -84,6 +88,22 @@ Meta.test( }) .on(e); }); + + await t.should("support secret injection", async () => { + await gql` + query { + secrets { + ok + } + } + ` + .expectData({ + secrets: { + ok: true, + }, + }) + .on(e); + }); }, ); @@ -92,7 +112,11 @@ Meta.test( name: "Deno runtime: file name reloading", }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("success for allowed network access", async () => { await gql` @@ -281,7 +305,11 @@ Meta.test( sanitizeOps: false, }, async (t) => { - const e = await t.engine("runtimes/deno/deno.py"); + const e = await t.engine("runtimes/deno/deno.py", { + secrets: { + DENO_SECRET: "deno_secret", + }, + }); await t.should("safely fail upon stack overflow", async () => { await gql` diff --git a/tests/runtimes/deno/ts/deno.ts b/tests/runtimes/deno/ts/deno.ts index 5da50ea67..f2b474fd2 100644 --- a/tests/runtimes/deno/ts/deno.ts +++ b/tests/runtimes/deno/ts/deno.ts @@ -10,3 +10,10 @@ export function counter(): number { export function sum({ numbers }: { numbers: number[] }): number { return numbers.reduce((a, b) => a + b, 0); } + +export function secrets(_inp: any, cx: { secrets: Record }) { + if (cx.secrets.DENO_SECRET !== "deno_secret") { + throw new Error("Deno secret not found"); + } + return { ok: true }; +} diff --git a/tests/runtimes/substantial/workflows/workflow.ts b/tests/runtimes/substantial/workflows/workflow.ts index b625ec99d..d9831739e 100644 --- a/tests/runtimes/substantial/workflows/workflow.ts +++ b/tests/runtimes/substantial/workflows/workflow.ts @@ -10,7 +10,7 @@ import { } from "../imports/common_types.ts"; export const eventsAndExceptionExample: Workflow = async ( - ctx: Context + ctx: Context, ) => { const { to } = ctx.kwargs; const messageDialog = await ctx.save(() => sendSubscriptionEmail(to)); @@ -37,18 +37,18 @@ export async function saveAndSleepExample(ctx: Context) { const sum = await ctx.save(async () => { const remoteAdd = new Date().getTime(); - const { data } = await ctx.gql/**/ `query { remote_add(a: $a, b: $b) }`.run( + const { data } = await ctx.gql /**/`query { remote_add(a: $a, b: $b) }`.run( { a: newA, b: newB, - } + }, ); const remoteAddEnd = new Date().getTime(); console.log( "Remote add:", (remoteAddEnd - remoteAdd) / 1000, ", Response:", - data + data, ); return (data as any)?.remote_add as number; @@ -76,7 +76,7 @@ export async function retryExample(ctx: Context) { maxBackoffMs: 5000, maxRetries: 4, }, - } + }, ); const timeoutRet = await ctx.save( @@ -95,7 +95,7 @@ export async function retryExample(ctx: Context) { maxBackoffMs: 3000, maxRetries: 5, }, - } + }, ); return [timeoutRet, retryRet].join(", "); @@ -107,7 +107,10 @@ export const secretsExample: Workflow = (_, { secrets }) => { throw new Error("unable to read secret"); } if (Object.keys(rest).length > 0) { - throw new Error("unexpected secrets found: ", rest); + throw new Error("unexpected secrets found: " + JSON.stringify(rest)); + } + if (MY_SECRET !== "Hello") { + throw new Error("unexpected secrets valu: " + MY_SECRET + " != Hello"); } return Promise.resolve(); }; @@ -125,9 +128,11 @@ export async function accidentalInputMutation(ctx: Context) { if (front.innerField == mutValue) { // Should throw on shallow clones throw new Error( - `actual kwargs was mutated after interrupts: copy ${JSON.stringify( - copy - )}, ${mutValue}` + `actual kwargs was mutated after interrupts: copy ${ + JSON.stringify( + copy, + ) + }, ${mutValue}`, ); } diff --git a/tests/runtimes/wasm_reflected/rust/Cargo.toml b/tests/runtimes/wasm_reflected/rust/Cargo.toml index 57560b412..7723fac0c 100644 --- a/tests/runtimes/wasm_reflected/rust/Cargo.toml +++ b/tests/runtimes/wasm_reflected/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust" -version = "0.5.0-rc.8" +version = "0.5.0-rc.9" edition = "2021" [lib] diff --git a/tools/consts.ts b/tools/consts.ts index d8d5da550..670acdb47 100644 --- a/tools/consts.ts +++ b/tools/consts.ts @@ -1,8 +1,8 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -export const METATYPE_VERSION = "0.5.0-rc.8"; -export const PUBLISHED_VERSION = "0.5.0-rc.7"; +export const METATYPE_VERSION = "0.5.0-rc.9"; +export const PUBLISHED_VERSION = "0.5.0-rc.8"; export const GHJK_VERSION = "v0.2.1"; export const GHJK_ACTION_VERSION = "318209a9d215f70716a4ac89dbeb9653a2deb8bc"; export const RUST_VERSION = "1.80.1";