diff --git a/Cargo.lock b/Cargo.lock index 87ffbcaba7..c41d5d4f2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ dependencies = [ "actix-macros", "actix-rt", "actix_derive", - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "crossbeam-channel", "futures-core", @@ -416,9 +416,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc2d0cfb2a7388d34f590e76686704c494ed7aaceed62ee1ba35cbf363abc2a5" +checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" dependencies = [ "brotli", "flate2", @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.2.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" +checksum = "fb41eb19024a91746eba0773aa5e16036045bbf45733766661099e182ea6a744" dependencies = [ "async-lock 3.3.0", "cfg-if", @@ -533,7 +533,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.2.2", + "async-io 2.3.0", "async-lock 2.8.0", "atomic-waker", "cfg-if", @@ -847,7 +847,7 @@ version = "0.69.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cexpr", "clang-sys", "lazy_static 1.4.0", @@ -884,9 +884,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" dependencies = [ "serde 1.0.195", ] @@ -1207,9 +1207,9 @@ dependencies = [ [[package]] name = "clap-verbosity-flag" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c90e95e5bd4e8ac34fa6f37c774b0c6f8ed06ea90c79931fd448fcf941a9767" +checksum = "b57f73ca21b17a0352944b9bb61803b6007bd911b6cccfef7153f7f0600ac495" dependencies = [ "clap", "log", @@ -1711,7 +1711,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libloading 0.8.1", "winapi", ] @@ -4154,7 +4154,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "libgit2-sys", "log", @@ -4202,9 +4202,9 @@ dependencies = [ [[package]] name = "glow" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "886c2a30b160c4c6fec8f987430c26b526b7988ca71f664e6a699ddf6f9601e4" +checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1" dependencies = [ "js-sys", "slotmap", @@ -4227,7 +4227,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "gpu-alloc-types", ] @@ -4237,7 +4237,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", ] [[package]] @@ -4260,7 +4260,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "gpu-descriptor-types", "hashbrown 0.14.3", ] @@ -4271,7 +4271,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", ] [[package]] @@ -4386,9 +4386,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.23" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b553656127a00601c8ae5590fcfdc118e4083a7924b6cf4ffc1ea4b99dc429d7" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -4488,9 +4488,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -4926,7 +4926,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "libc", "windows-sys 0.48.0", ] @@ -4967,7 +4967,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "rustix 0.38.30", "windows-sys 0.52.0", ] @@ -5365,7 +5365,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall 0.4.1", ] @@ -5408,9 +5408,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -5660,7 +5660,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "block", "core-graphics-types", "foreign-types 0.5.0", @@ -6029,7 +6029,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e" dependencies = [ "bit-set", - "bitflags 2.4.1", + "bitflags 2.4.2", "codespan-reporting", "hexf-parse", "indexmap 2.1.0", @@ -6133,7 +6133,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "libc", ] @@ -6192,7 +6192,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "crossbeam-channel", "filetime", "fsevent-sys", @@ -6368,7 +6368,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "libc", ] @@ -6442,7 +6442,7 @@ version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types 0.3.2", "libc", @@ -7043,9 +7043,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "platforms" @@ -7175,13 +7175,12 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "predicates" -version = "3.0.4" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dfc28575c2e3f19cb3c73b93af36460ae898d426eba6fc15b9bd2a5220758a0" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" dependencies = [ "anstyle", "difflib", - "itertools 0.11.0", "predicates-core", ] @@ -7275,9 +7274,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ "toml_edit", ] @@ -8114,7 +8113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", - "bitflags 2.4.1", + "bitflags 2.4.2", "serde 1.0.195", "serde_derive", ] @@ -8145,7 +8144,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "549b9d036d571d42e6e85d1c1425e2ac83491075078ca9a15be021c56b1641f2" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "chrono", "fallible-iterator", "fallible-streaming-iterator", @@ -8255,10 +8254,10 @@ version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno 0.3.8", "libc", - "linux-raw-sys 0.4.12", + "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -8340,7 +8339,7 @@ version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02a2d683a4ac90aeef5b1013933f6d977bd37d51ff3f4dad829d4931a7e6be86" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "clipboard-win", "fd-lock", @@ -9652,7 +9651,7 @@ version = "0.109.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bc2286cedd688a68f214faa1c19bb5cceab7c9c54d0cbe3273e4c1704e38f69" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "is-macro", "num-bigint", "scoped-tls", @@ -9669,7 +9668,7 @@ version = "0.110.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c3d416121da2d56bcbd1b1623725a68890af4552fef0c6d1e4bfa92776ccd6a" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "is-macro", "num-bigint", "phf 0.11.2", @@ -9806,7 +9805,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e082ff07a2d31fd8e480dc590dd81efb75106e79bec24483dbece03630ca67b3" dependencies = [ "better_scoped_tls", - "bitflags 2.4.1", + "bitflags 2.4.2", "indexmap 1.9.3", "once_cell", "phf 0.10.1", @@ -9829,7 +9828,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d74ca42a400257d8563624122813c1849c3d87e7abe3b9b2ed7514c76f64ad2f" dependencies = [ "better_scoped_tls", - "bitflags 2.4.1", + "bitflags 2.4.2", "indexmap 1.9.3", "once_cell", "phf 0.11.2", @@ -11244,9 +11243,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-id" @@ -11754,7 +11753,7 @@ version = "0.119.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c35daf77afb4f9b14016625144a391085ec2ca99ca9cc53ed291bb53ab5278d" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "indexmap 2.1.0", "semver 1.0.21", ] @@ -11814,7 +11813,7 @@ checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726" dependencies = [ "arrayvec 0.7.4", "bit-vec", - "bitflags 2.4.1", + "bitflags 2.4.2", "codespan-reporting", "log", "naga", @@ -11840,7 +11839,7 @@ dependencies = [ "arrayvec 0.7.4", "ash", "bit-set", - "bitflags 2.4.1", + "bitflags 2.4.2", "block", "core-graphics-types", "d3d12", @@ -11877,7 +11876,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "js-sys", "serde 1.0.195", "web-sys", @@ -12149,7 +12148,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4f7c5d6f59ae013fc4c013c76eab667844a46e86b51987acb71b1e32953211a" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "wit-bindgen-rust-macro", ] @@ -12210,7 +12209,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66981fe851118de3b6b7a92f51ce8a86b919569c37becbeca8df9bd30141da25" dependencies = [ "anyhow", - "bitflags 2.4.1", + "bitflags 2.4.2", "indexmap 2.1.0", "log", "serde 1.0.195", @@ -12284,7 +12283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", - "linux-raw-sys 0.4.12", + "linux-raw-sys 0.4.13", "rustix 0.38.30", ] diff --git a/dev/lock.yml b/dev/lock.yml index 8649daf65d..8b7d30ef73 100644 --- a/dev/lock.yml +++ b/dev/lock.yml @@ -91,7 +91,7 @@ dev: TYPEGRAPH_VERSION: 0.0.3 PRISMA_VERSION: 5.5.2 METATYPE_VERSION: 0.3.2 - PUBLISHED_VERSION: 0.2.4 + PUBLISHED_VERSION: 0.3.2 WASM_OPT_VERSION: 0.116.0 MOLD_VERSION: v2.4.0 CMAKE_VERSION: 3.28.0-rc6 diff --git a/examples/templates/deno/api/example.ts b/examples/templates/deno/api/example.ts index 719169970d..9d5046c1fd 100644 --- a/examples/templates/deno/api/example.ts +++ b/examples/templates/deno/api/example.ts @@ -1,6 +1,6 @@ -import { Policy, t, typegraph } from "npm:@typegraph/sdk@0.2.4"; -import { PythonRuntime } from "npm:@typegraph/sdk@0.2.4/runtimes/python"; -import { DenoRuntime } from "npm:@typegraph/sdk@0.2.4/runtimes/deno"; +import { Policy, t, typegraph } from "npm:@typegraph/sdk@0.3.2/index.js"; +import { PythonRuntime } from "npm:@typegraph/sdk@0.3.2/runtimes/python.js"; +import { DenoRuntime } from "npm:@typegraph/sdk@0.3.2/runtimes/deno.js"; typegraph("example", (g) => { const pub = Policy.public(); diff --git a/examples/templates/node/api/example.ts b/examples/templates/node/api/example.ts index a0da888951..029c122520 100644 --- a/examples/templates/node/api/example.ts +++ b/examples/templates/node/api/example.ts @@ -1,6 +1,6 @@ -import { Policy, t, typegraph } from "@typegraph/sdk"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno"; -import { PythonRuntime } from "@typegraph/sdk/runtimes/python"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; +import { PythonRuntime } from "@typegraph/sdk/runtimes/python.js"; typegraph("example", (g) => { const pub = Policy.public(); diff --git a/examples/templates/node/package.json b/examples/templates/node/package.json index d9a41c2245..9b3cad7874 100644 --- a/examples/templates/node/package.json +++ b/examples/templates/node/package.json @@ -7,7 +7,7 @@ "dev": "MCLI_LOADER_CMD='npm run load-tgraph --silent' meta dev" }, "dependencies": { - "@typegraph/sdk": "^0.2.4" + "@typegraph/sdk": "^0.3.2" }, "devDependencies": { "tsx": "^3.13.0", diff --git a/examples/templates/node/tsconfig.json b/examples/templates/node/tsconfig.json index 8fdbef4da1..707bdf3d64 100644 --- a/examples/templates/node/tsconfig.json +++ b/examples/templates/node/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "strict": true, "moduleResolution": "node16", + "module": "NodeNext", "esModuleInterop": true } } diff --git a/typegate/tests/e2e/templates/templates_test.ts b/typegate/tests/e2e/templates/templates_test.ts index c9e425bcb2..69c0d59c33 100644 --- a/typegate/tests/e2e/templates/templates_test.ts +++ b/typegate/tests/e2e/templates/templates_test.ts @@ -16,12 +16,17 @@ const modifiers: Record Promise | void> = { const version = await get_version(); console.log(version); for await (const f of expandGlob("**/*.ts", { root: dir })) { - const data = await Deno.readTextFile(f.path); - const level = f.path.replace(projectDir, "").split("/").length - 1; + // FIXME: deno is unable to map the types from .d.ts files when used locally + const data = (await Deno.readTextFile(f.path)).replace( + /\(\s*g\s*\)/, + "(g: any)", + ); + const level = f.path.replace(projectDir, "").split("/").length - 2; const newData = data.replaceAll( `npm:@typegraph/sdk@${version}`, - `${Array(level).fill("..").join("/")}/typegraph/deno/src`, + `${Array(level).fill("..").join("/")}/typegraph/node/sdk/dist`, ); + await Deno.writeTextFile(f.path, newData); } }, diff --git a/typegate/tests/runtimes/deno/deno_static.ts b/typegate/tests/runtimes/deno/deno_static.ts new file mode 100644 index 0000000000..22c81a7ee7 --- /dev/null +++ b/typegate/tests/runtimes/deno/deno_static.ts @@ -0,0 +1,21 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; + +typegraph("test-deno-static", (g: any) => { + const deno = new DenoRuntime(); + const pub = Policy.public(); + + g.expose({ + simpleStatic: deno.static( + t.either([t.string(), t.integer()]), + "One!", + ).withPolicy(pub), + structStatic: deno.static(t.struct({ "a": t.string() }), { + a: "Hello World", + }) + .withPolicy(pub), + }); +}); diff --git a/typegate/tests/runtimes/deno/deno_test.ts b/typegate/tests/runtimes/deno/deno_test.ts index 56940b261d..c27f3b30aa 100644 --- a/typegate/tests/runtimes/deno/deno_test.ts +++ b/typegate/tests/runtimes/deno/deno_test.ts @@ -121,6 +121,25 @@ Meta.test("Deno runtime: use local imports", async (t) => { }); }); +Meta.test("Deno runtime with typescript", async (t) => { + const e = await t.engine("runtimes/deno/deno_static.ts"); + await t.should("work with static values", async () => { + await gql` + query { + simpleStatic + structStatic { + a + } + } + `.expectData({ + simpleStatic: "One!", + structStatic: { + a: "Hello World", + }, + }).on(e); + }); +}); + Meta.test("Deno runtime: file name reloading", async (t) => { const load = async (value: number) => { Deno.env.set("DYNAMIC", join("dynamic", `${value}.ts`)); diff --git a/typegraph/node/sdk/src/runtimes/deno.ts b/typegraph/node/sdk/src/runtimes/deno.ts index 1d32b57019..660e45e36f 100644 --- a/typegraph/node/sdk/src/runtimes/deno.ts +++ b/typegraph/node/sdk/src/runtimes/deno.ts @@ -101,6 +101,21 @@ export class DenoRuntime extends Runtime { ); } + static< + P extends t.Typedef, + >(out: P, value: any) { + const mat = { + _id: runtimes.registerDenoStatic({ + value: JSON.stringify(value), + }, out._id), + }; + return t.func( + t.struct({}), + out, + mat, + ); + } + policy(name: string, _code: string): Policy; policy(name: string, data: Omit): Policy; policy(name: string, data: string | Omit): Policy { diff --git a/typegraph/node/sdk/src/types.ts b/typegraph/node/sdk/src/types.ts index 3c73848be0..430ac1661d 100644 --- a/typegraph/node/sdk/src/types.ts +++ b/typegraph/node/sdk/src/types.ts @@ -544,6 +544,17 @@ export class Func< ); } + rate( + inp: { calls: boolean; weight?: number }, + ): Func { + return func( + this.inp, + this.out, + this.mat, + { rateCalls: inp.calls ?? false, rateWeight: inp.weight }, + ); + } + static fromTypeFunc(data: FuncParams) { return func( new Typedef(data.inp, {}) as Struct<{ [key: string]: Typedef }>,