diff --git a/.ghjk/deno.lock b/.ghjk/deno.lock index 2768c989f4..90ef5d97b5 100644 --- a/.ghjk/deno.lock +++ b/.ghjk/deno.lock @@ -2,6 +2,9 @@ "version": "3", "redirects": { "https://deno.land/std/path/mod.ts": "https://deno.land/std@0.223.0/path/mod.ts", + "https://raw.github.com/metatypedev/ghjk/2725af8/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/mod.ts", + "https://raw.github.com/metatypedev/ghjk/2725af8/ports/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/mod.ts", + "https://raw.github.com/metatypedev/ghjk/2725af8/utils/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/mod.ts", "https://raw.github.com/metatypedev/ghjk/423d38e/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/mod.ts", "https://raw.github.com/metatypedev/ghjk/423d38e/ports/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/mod.ts", "https://raw.github.com/metatypedev/ghjk/423d38e/utils/mod.ts": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/utils/mod.ts" @@ -459,6 +462,63 @@ "https://deno.land/x/zod@v3.22.4/types.ts": "724185522fafe43ee56a52333958764c8c8cd6ad4effa27b42651df873fc151e", "https://esm.sh/jszip@3.7.1": "f3872a819b015715edb05f81d973b5cd05d3d213d8eb28293ca5471fe7a71773", "https://esm.sh/v135/jszip@3.7.1/denonext/jszip.mjs": "d31d7f9e0de9c6db3c07ca93f7301b756273d4dccb41b600461978fc313504c9", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/deps/cli.ts": "4eacc555cf80686b487e7502db63a4cfbc2060a7b847d15b14cf1cc008a3b65c", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/deps/common.ts": "46d30782086ccc79e4a2633fe859723e7686ebc5adb4101e76c4bf2d6d2e94ff", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/deps/ports.ts": "3c60d1f7ab626ffdd81b37f4e83a780910936480da8fe24f4ccceaefa207d339", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/host/types.ts": "22c06b190172d08092717ad788ed04b050af58af0cf3f8c78b1511984101e9e4", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/mod.ts": "7a78701c53b9ba6ba16f4dc6a45ea316b5d6818fda520751088a87c09fd82464", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/mod.ts": "6aa0b765ce5684842ea531e026926836ffde7d2513e62457bffe9cb4ec7eb0df", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/ambient.ts": "25623410c535e2bfaf51fca1e582e7325a00a7690d5b5e763a12be9407f619cf", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/base.ts": "8ef8a8de372420bddcd63a1b363937f43d898059e99478a58621e8432bcd5891", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/db.ts": "3f4541d6874c434f2f869774a17fd41c3d86914ed190d412e2f63f564b58ce95", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/ghrel.ts": "e94d53507feedb8f8456aed91b034621951def4f83102490e18eb5a367f2ee64", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/mod.ts": "e38ad2d3599b6a5522da436b52e5945bb85cabba2aca27f633eae43e465b5794", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/std.ts": "985902519aafef6e8e6aecc8922e70abdea5b8e97d5439bf94338b93242fe11f", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/sync.ts": "46447c2c51c085193f567ddcd2451b14bb33ee2d761edeb91a6153e2ba642f42", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/types.ts": "b3967d9d75def187b3b55f2b0b1357c9cb69a70e475a9280fc66717193b8b43c", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/types/platform.ts": "0ecffeda71919293f9ffdb6c564ddea4f23bc85c4e640b08ea78225d34387fdc", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/ports/worker.ts": "25c01e3afddd97d48af89d9c97a9a5188e7db09fceb26a69eac4dabacd8ac4fc", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/std.ts": "ddb2c134c080bb0e762a78f2f2edd69536991cc4257bd29a6fc95944b2f105a9", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/deno.ts": "f988a4d1062364b99272087fa0c7d54e699944ead3790c5b83140577bda089de", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/exec.ts": "7a07f2cce79fe16e86f0b74df6d57f0160bac75a8c6d58a03f2883a5ecccddf0", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/mod.ts": "0edbe1ce953a44b6b0fd45aa9c9dd52c11b12053eef21307eac3b24b6db4745e", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/tasks/types.ts": "536495a17c7a917bdd1c316ecc98ce2947b4959a713f92a175d372196dcaafc0", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/modules/types.ts": "b44609942d7ad66c925c24485057c5b4b2ffcad20c0a94e14dc6af34cf9e8241", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/port.ts": "c039a010dee7dfd978478cf4c5e2256c643135e10f33c30a09f8db9915e9d89d", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/act.ts": "a42bcd3e68ee476ccf30d99cdb7bc487cfad00d2e8fbf152e5776a32ccb29c76", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/asdf.ts": "70033efcd24b7d2b836e1bc36754597de69a4a1771174d3fbc2fdda6c45f5d0a", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/asdf_plugin_git.ts": "946e051218a7681bb9b6cc8834b8795aef2713ec6cb331e30440073e68161e2b", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargo-binstall.ts": "014ead93f46ed8463c4d620c958ed6b8df5f9e4c223b1d76ea8f27ac0575707b", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargobi.ts": "f3b84615cba7778d502d0ad4415ae1ff527337cd39801f25b5fae5804c05e5a2", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cpy_bs.ts": "cd3e53832969c2f94cb25e2bf96a3fc0d35d7a8929bd24da8aff07c4c4532ae4", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/curl.ts": "58acd2a158187f448d940f45bfcd87c9b4884db127dcbaaaef27258bb4ebce92", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/earthly.ts": "7a3c8cae1631f670105a63bc41c47a49da6fc777968c0e9546c55d43fa418619", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/git.ts": "2e68f1fa5ba534ee32db204bcc357f987437dffe5d87c1a0a9c47850fa654419", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/infisical.ts": "7e60029b1f73fa72c38aa8d134f9bd62ba488c5e23b6cb7a568acb79a7027e04", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/jq_ghrel.ts": "e31dc346bbeb9c3cc5411bf7170d1238bd75ca843bfc85baeb8e33375758f380", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/meta_cli_ghrel.ts": "c337c1ecc251694849f6e4b120e542272aa7ac1dac48db6d3dcd781fe6265159", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/mod.ts": "8521c092ee3d7b1b2cf28f47f084e353656cb98b4506f8c2fbbcc47505c2bf89", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/mold.ts": "0b91d6a73992d175a0cae048aa4c0547ad68906cd2b18377121b86dd318ab650", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/node.ts": "f68993de9d67168f68c4c950c73273d26eeea0a617852f59676cc64577afa6c8", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/npmi.ts": "05e69eb75f5b0350b988fd06ddc7fd47707b4027482b254c1a6d5d5d1c90cc95", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/opentofu_ghrel.ts": "46ef05d30772d36b91d88a2dc1aae31e096c59ba6ecf82af08359996c1476725", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pipi.ts": "7feece45b8fe0a8cb0735cb07c3f935f36ca7dac654d58f8ead098932a9dd202", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pnpm.ts": "41e7f473a687123ae96ab14a3a04f67ef0c4b44eea6747448826dbdae00bfdde", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/protoc.ts": "ef93af8f37d8186c2220b6d2f760b5da10decaa3e9fe7768003ee319d32335bf", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/ruff.ts": "d9a4d22224bec2829a794a718d275580a6b2836f970ba6c5923ff485016931d0", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/rust.ts": "72ca49bc8419b556af836d464ba62829e7fd961a9c3f5305c258f8562e242885", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/rustup.ts": "a3918809c59fb4681222a22279b03ea0333de42114e12ede3b1cb11f7bd5f59a", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/tar.ts": "c3c43a99f8a9b1c160286cbc6240f59658d994856eeacaee479f645ece44d6c4", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/temporal_cli.ts": "d2a99eb0f47abf69d5f08d360a289311a92977f6e2898a836688b280b12f96dc", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/terraform.ts": "0da89441ae69647cc63306fe92fc36c35c34eb17620e785a64d069f20d25d647", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/unzip.ts": "c4559c627246f9c051571bbdff8c63ab15780ffd9e71656a9055488cc3bf32c3", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/wasmedge.ts": "ea80044069a75ca9ce938bc72b2504955fa3747949f680cdcd64ce172c723545", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/zstd.ts": "fb8334b7b43ef34ba60ad391460e2fabb62889f77eade7798c823b14842cea45", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/setup_logger.ts": "f8a206bda0595497d6f4718032d4a959000b32ef3346d4b507777eec6a169458", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/logger.ts": "86fdf651123d00ea1081bf8001ed9039cd41a79940e6ebadb8484952ab390e73", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/mod.ts": "1ee68d9390259c065144c10663f6e360d29aec36db2af38d02647e304eeeaedc", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/unarchive.ts": "3f66464c445d67b003e792cdefea9c529e2fd527df19d3fc52000d91d43a65b2", + "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/utils/url.ts": "e1ada6fd30fc796b8918c88456ea1b5bbd87a07d0a0538b092b91fd2bb9b7623", "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/deps/cli.ts": "4eacc555cf80686b487e7502db63a4cfbc2060a7b847d15b14cf1cc008a3b65c", "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/deps/common.ts": "46d30782086ccc79e4a2633fe859723e7686ebc5adb4101e76c4bf2d6d2e94ff", "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/deps/ports.ts": "3c60d1f7ab626ffdd81b37f4e83a780910936480da8fe24f4ccceaefa207d339", diff --git a/.ghjk/lock.json b/.ghjk/lock.json index cdd720dafd..9804ab46d9 100644 --- a/.ghjk/lock.json +++ b/.ghjk/lock.json @@ -5,22 +5,6 @@ "ports": { "version": "0", "configResolutions": { - "9aaf6a4fddacb5a219afcb3a46e1fd21049cbbeb5808c49be95ea371e3928fc0": { - "version": "0.13.5", - "depConfigs": { - "tar_aa": { - "version": "1.35", - "depConfigs": {}, - "portRef": "tar_aa@0.1.0" - } - }, - "portRef": "wasmedge_ghrel@0.1.0" - }, - "9e3fa7742c431c34ae7ba8d1e907e50c937ccfb631fb4dcfb7a1773742abe267": { - "version": "1.35", - "depConfigs": {}, - "portRef": "tar_aa@0.1.0" - }, "5155b24a1a756a5b91108ba34188d8bc4f5d6744f5ac29454450d6275663df86": { "version": "v24.1", "depConfigs": {}, @@ -30,12 +14,12 @@ "version": "3.28.0-rc6", "depConfigs": { "curl_aa": { - "version": "8.5.0", + "version": "8.2.1", "depConfigs": {}, "portRef": "curl_aa@0.1.0" }, "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" }, @@ -43,7 +27,7 @@ "version": "d631481e96", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -63,12 +47,12 @@ "installType": "version" }, "c7d12a562ecc8f3f95df5469ec0272561bc6715ebc41bcd82ba94f17a69a6fcb": { - "version": "8.5.0", + "version": "8.2.1", "depConfigs": {}, "portRef": "curl_aa@0.1.0" }, "0c719c533251d13d9e84b3113733c9dcd9e48f978c02f3fc4e14816080f7a69e": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" }, @@ -76,7 +60,7 @@ "version": "d631481e96", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -109,7 +93,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -132,7 +116,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -147,7 +131,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -169,7 +153,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -200,7 +184,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -220,15 +204,20 @@ "version": "v20.8.0", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" } }, "portRef": "node_org@0.1.0" }, - "f4760b34b6c9f9f96207cfb380deb77007a212a60bd10bdb3dc9d20b94c2785c": { - "version": "v8.15.2", + "9e3fa7742c431c34ae7ba8d1e907e50c937ccfb631fb4dcfb7a1773742abe267": { + "version": "1.34", + "depConfigs": {}, + "portRef": "tar_aa@0.1.0" + }, + "66212eb79fbcb37961450d5dfffdaedc0b949e0e7c9257c3c63093d009a5fc75": { + "version": "v9.0.5", "depConfigs": {}, "portRef": "pnpm_ghrel@0.1.0" }, @@ -239,7 +228,7 @@ "version": "v20.8.0", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" } @@ -257,7 +246,7 @@ "version": "v20.8.0", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" } @@ -272,7 +261,7 @@ "version": "v2.4.0", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" } @@ -284,7 +273,7 @@ "version": "3.8.18", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" }, @@ -309,7 +298,7 @@ "version": "3.12.2", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" }, @@ -330,7 +319,7 @@ "version": "3.12.2", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" }, @@ -350,7 +339,7 @@ "version": "3.12.2", "depConfigs": { "tar_aa": { - "version": "1.35", + "version": "1.34", "depConfigs": {}, "portRef": "tar_aa@0.1.0" }, @@ -387,7 +376,7 @@ "version": "1.27.0", "depConfigs": { "git_aa": { - "version": "2.43.0", + "version": "2.40.1", "depConfigs": {}, "portRef": "git_aa@0.1.0" } @@ -403,10 +392,45 @@ "crateName": "whiz", "locked": true }, - "66212eb79fbcb37961450d5dfffdaedc0b949e0e7c9257c3c63093d009a5fc75": { - "version": "v9.0.5", - "depConfigs": {}, - "portRef": "pnpm_ghrel@0.1.0" + "3552829e559260faef01394d084d1c64d8da0b0fde33000127ae676322402254": { + "version": "0.13.3", + "depConfigs": { + "cpy_bs_ghrel": { + "version": "3.12.2", + "depConfigs": { + "tar_aa": { + "version": "1.34", + "depConfigs": {}, + "portRef": "tar_aa@0.1.0" + }, + "zstd_aa": { + "version": "v1.5.5,", + "depConfigs": {}, + "portRef": "zstd_aa@0.1.0" + } + }, + "portRef": "cpy_bs_ghrel@0.1.0", + "releaseTag": "20240224" + } + }, + "portRef": "pipi_pypi@0.1.0", + "packageName": "componentize-py" + }, + "84ecde630296f01e7cb8443c58d1596d668c357a0d9837c0a678b8a541ed0a39": { + "version": "3.12.3", + "depConfigs": { + "tar_aa": { + "version": "1.34", + "depConfigs": {}, + "portRef": "tar_aa@0.1.0" + }, + "zstd_aa": { + "version": "v1.5.5,", + "depConfigs": {}, + "portRef": "zstd_aa@0.1.0" + } + }, + "portRef": "cpy_bs_ghrel@0.1.0" } } }, @@ -420,24 +444,24 @@ "id": "ports", "config": { "installs": [ - "269266fdca40e20f9361848270d3e0f8ca6d4616", - "db5b506ba0936c6713a2efef3ee82df7ea271b06", - "651e1043d59561e4e71e5fb0775daf746467a028", - "e7b2f3414caa4c4441240c02dcb8f7c781fd01ee", - "af5c6b39c783d32544799829316564ffe51861a9", - "a24f45ef0b2064658d87264a95d31fe4694f6f4e", - "57da4ca242ec52ba50359a7fd78653e6bf253df0", - "67d371eb0c4ae641830a955975d7134f7ee9a864", - "4ca29edff5e070fd0885680b178ed6948d7a4c7f", - "a12d1020fe585e5ea75d9a2035bdcbde8dd90044", - "4d1916871a40b6ac730709f7721f740df192c84d", - "4df902463d60efc5b8e760ea4899f6ab6df0f16e", - "88f6aa5ddb513712623d31a17096ea26286064da", - "185be72d02330f9b3dfa3d0791274feb958e119d", - "5549508f1f5eddf9cb2465f07cf0c7603dc0c849", - "5c041a4209ae50657ea5acacc26683688f2913a9", - "d0bcae26fcc8ca53ffbdb66de5735c608858a313", - "ca8e4bf52171b6a173a6ba349f33721806b86d48" + "439fc98060b33a81493ea6c9d54d834f5d548c0a", + "6c4eb5db74544926094ea3be684f453ac448da0a", + "0dac7df77bad6ba3f8a46710f1199cf36b260c82", + "fefe1d7a6a79be5dedaf34f4c7e5c00bd6f41554", + "a4c9551574e821b184e492ffbdbf295311099397", + "c69d5f47d8bede1fc7a55bc46ca5f0f2c9252719", + "2aedace78ffe026f5c0918231de4f7f9050aab1c", + "c13712d0a06c2329378872201d5cb51e0575bed9", + "9e72a9f857bd9b14b47702b5b8ee660833828d4b", + "cfe6640502ddf9772073889af75888d361b1f2b9", + "8e5e02544073c4733d8f2156c404a0dd524cdaaf", + "e05f859f4a734a85fd3439f9b0fc0de1e733bdac", + "38285a3b335e394ccce5ac5d59e15f660bfa4cc9", + "7bbf00da8e265c56c2bff5bb7d89ba806e2590d2", + "14fd3752a984c5d82e1451f7388c73a21fcce705", + "f25385325ad568d22d9538724df856df62a7b06b", + "3ed4089145ee327a97198237a8a2eb8a48212b6c", + "ea543033c55cfcaa9f7e253529d0efe3a9827c6d" ], "allowedDeps": { "tar_aa": "e0d1f160d2d7755765f6f01a27a0c33a02ff98d2", @@ -445,13 +469,13 @@ "curl_aa": "3c447f912abf18883bd05314f946740975ee0dd3", "unzip_aa": "dfb0f5e74666817e6ab8cbceca0c9da271142bca", "zstd_aa": "d9122eff1fe3ef56872e53dae725ff3ccb37472e", - "rustup_rustlang": "89f6529a87b3d47e2ebdc50486bf0ed2f39049d4", - "rust_rustup": "201f72d1b59c9377240c3d5008d835ea83d0ba74", - "cargo_binstall_ghrel": "c8084cf4c423d1862a1d783c70b8221c0cf9d73c", - "pnpm_ghrel": "422c26d0e74744b87f0f6f0eefa25e54a1188e08", - "asdf_plugin_git": "f77828fcb8896a0df3511920d0055d0f89bfdec9", - "cpy_bs_ghrel": "ff0a30a4efc90a6a49611e273e167ac3d3444441", - "node_org": "601d3ac573271b2e2fb3c453ccd54f22d151c64e" + "rustup_rustlang": "4cd389bd9c1a017e3af681e4515df06afc8ae94b", + "rust_rustup": "78a3ffea7ebe9b9f09acee4f5912ce24df923dc3", + "cargo_binstall_ghrel": "ba089892903fc9374065ebf6466fa43baf308251", + "pnpm_ghrel": "5d09c2a1d5a6611daf46efcc36eca64f53cb279c", + "asdf_plugin_git": "9c0f4895f4f2512781cf21f405fdf1a3b6b276d2", + "cpy_bs_ghrel": "14d99c79513af7d220c32bef7a266958781e021b", + "node_org": "adf17609822d9b8edd5253323d2edab7a1152ec2" } } }, @@ -471,11 +495,63 @@ "3c447f912abf18883bd05314f946740975ee0dd3", "dfb0f5e74666817e6ab8cbceca0c9da271142bca", "d9122eff1fe3ef56872e53dae725ff3ccb37472e", - "89f6529a87b3d47e2ebdc50486bf0ed2f39049d4", - "201f72d1b59c9377240c3d5008d835ea83d0ba74", - "c8084cf4c423d1862a1d783c70b8221c0cf9d73c", - "422c26d0e74744b87f0f6f0eefa25e54a1188e08", - "f77828fcb8896a0df3511920d0055d0f89bfdec9" + "4cd389bd9c1a017e3af681e4515df06afc8ae94b", + "78a3ffea7ebe9b9f09acee4f5912ce24df923dc3", + "ba089892903fc9374065ebf6466fa43baf308251", + "5d09c2a1d5a6611daf46efcc36eca64f53cb279c", + "9c0f4895f4f2512781cf21f405fdf1a3b6b276d2" + ] + } + }, + "gen-pyrt-bind": { + "name": "gen-pyrt-bind", + "dependsOn": [], + "env": { + "installs": [ + "ea543033c55cfcaa9f7e253529d0efe3a9827c6d", + "3044097f18de955d9402bcac8b0006554638849d" + ], + "env": {}, + "allowedPortDeps": [ + "e0d1f160d2d7755765f6f01a27a0c33a02ff98d2", + "9d26d0d90f6ecdd69d0705a042b01a344aa626ee", + "3c447f912abf18883bd05314f946740975ee0dd3", + "dfb0f5e74666817e6ab8cbceca0c9da271142bca", + "d9122eff1fe3ef56872e53dae725ff3ccb37472e", + "4cd389bd9c1a017e3af681e4515df06afc8ae94b", + "78a3ffea7ebe9b9f09acee4f5912ce24df923dc3", + "ba089892903fc9374065ebf6466fa43baf308251", + "5d09c2a1d5a6611daf46efcc36eca64f53cb279c", + "9c0f4895f4f2512781cf21f405fdf1a3b6b276d2", + "39c0cfd108ba0ce29a11769416cadb7ed988b831", + "adf17609822d9b8edd5253323d2edab7a1152ec2" + ] + } + }, + "build-pyrt": { + "name": "build-pyrt", + "dependsOn": [ + "gen-pyrt-bind" + ], + "env": { + "installs": [ + "ea543033c55cfcaa9f7e253529d0efe3a9827c6d", + "3044097f18de955d9402bcac8b0006554638849d" + ], + "env": {}, + "allowedPortDeps": [ + "e0d1f160d2d7755765f6f01a27a0c33a02ff98d2", + "9d26d0d90f6ecdd69d0705a042b01a344aa626ee", + "3c447f912abf18883bd05314f946740975ee0dd3", + "dfb0f5e74666817e6ab8cbceca0c9da271142bca", + "d9122eff1fe3ef56872e53dae725ff3ccb37472e", + "4cd389bd9c1a017e3af681e4515df06afc8ae94b", + "78a3ffea7ebe9b9f09acee4f5912ce24df923dc3", + "ba089892903fc9374065ebf6466fa43baf308251", + "5d09c2a1d5a6611daf46efcc36eca64f53cb279c", + "9c0f4895f4f2512781cf21f405fdf1a3b6b276d2", + "39c0cfd108ba0ce29a11769416cadb7ed988b831", + "adf17609822d9b8edd5253323d2edab7a1152ec2" ] } }, @@ -494,27 +570,7 @@ ], "globalEnv": { "installs": { - "269266fdca40e20f9361848270d3e0f8ca6d4616": { - "version": "0.13.5", - "port": { - "ty": "denoWorker@v1", - "name": "wasmedge_ghrel", - "platforms": [ - "aarch64-linux", - "x86_64-linux", - "aarch64-darwin", - "x86_64-darwin" - ], - "version": "0.1.0", - "deps": [ - { - "name": "tar_aa" - } - ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/wasmedge.ts" - } - }, - "db5b506ba0936c6713a2efef3ee82df7ea271b06": { + "439fc98060b33a81493ea6c9d54d834f5d548c0a": { "version": "v24.1", "port": { "ty": "denoWorker@v1", @@ -526,10 +582,10 @@ "x86_64-darwin" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/protoc.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/protoc.ts" } }, - "651e1043d59561e4e71e5fb0775daf746467a028": { + "6c4eb5db74544926094ea3be684f453ac448da0a": { "version": "3.28.0-rc6", "depConfigs": { "asdf_plugin_git": { @@ -575,12 +631,12 @@ "name": "asdf_plugin_git" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/asdf.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/asdf.ts" }, "pluginRepo": "https://github.com/asdf-community/asdf-cmake", "installType": "version" }, - "e7b2f3414caa4c4441240c02dcb8f7c781fd01ee": { + "0dac7df77bad6ba3f8a46710f1199cf36b260c82": { "port": { "ty": "denoWorker@v1", "name": "cargo_binstall_ghrel", @@ -591,10 +647,10 @@ "x86_64-darwin" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargo-binstall.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargo-binstall.ts" } }, - "af5c6b39c783d32544799829316564ffe51861a9": { + "fefe1d7a6a79be5dedaf34f4c7e5c00bd6f41554": { "version": "0.10.7", "port": { "ty": "denoWorker@v1", @@ -609,10 +665,10 @@ ], "version": "0.1.0", "deps": [], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/temporal_cli.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/temporal_cli.ts" } }, - "a24f45ef0b2064658d87264a95d31fe4694f6f4e": { + "a4c9551574e821b184e492ffbdbf295311099397": { "version": "0.116.0", "depConfigs": { "rust_rustup": { @@ -652,12 +708,12 @@ "name": "rust_rustup" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargobi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargobi.ts" }, "crateName": "wasm-opt", "locked": true }, - "57da4ca242ec52ba50359a7fd78653e6bf253df0": { + "c69d5f47d8bede1fc7a55bc46ca5f0f2c9252719": { "version": "1.0.53", "depConfigs": { "rust_rustup": { @@ -697,12 +753,12 @@ "name": "rust_rustup" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargobi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargobi.ts" }, "crateName": "wasm-tools", "locked": true }, - "67d371eb0c4ae641830a955975d7134f7ee9a864": { + "2aedace78ffe026f5c0918231de4f7f9050aab1c": { "version": "1.33.0", "depConfigs": { "rust_rustup": { @@ -742,12 +798,12 @@ "name": "rust_rustup" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargobi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargobi.ts" }, "crateName": "cargo-insta", "locked": true }, - "4ca29edff5e070fd0885680b178ed6948d7a4c7f": { + "c13712d0a06c2329378872201d5cb51e0575bed9": { "version": "20.8.0", "port": { "ty": "denoWorker@v1", @@ -766,10 +822,10 @@ "name": "tar_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/node.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/node.ts" } }, - "a12d1020fe585e5ea75d9a2035bdcbde8dd90044": { + "9e72a9f857bd9b14b47702b5b8ee660833828d4b": { "version": "v9.0.5", "port": { "ty": "denoWorker@v1", @@ -783,10 +839,10 @@ "x86_64-windows" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/pnpm.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pnpm.ts" } }, - "4d1916871a40b6ac730709f7721f740df192c84d": { + "cfe6640502ddf9772073889af75888d361b1f2b9": { "version": "1.0.0", "port": { "ty": "denoWorker@v1", @@ -817,11 +873,11 @@ "name": "node_org" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/npmi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/npmi.ts" }, "packageName": "@bytecodealliance/jco" }, - "4df902463d60efc5b8e760ea4899f6ab6df0f16e": { + "8e5e02544073c4733d8f2156c404a0dd524cdaaf": { "version": "10.0.1", "port": { "ty": "denoWorker@v1", @@ -852,11 +908,11 @@ "name": "node_org" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/npmi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/npmi.ts" }, "packageName": "node-gyp" }, - "88f6aa5ddb513712623d31a17096ea26286064da": { + "e05f859f4a734a85fd3439f9b0fc0de1e733bdac": { "version": "v2.4.0", "port": { "ty": "denoWorker@v1", @@ -871,11 +927,11 @@ "name": "tar_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/mold.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/mold.ts" }, "replaceLd": false }, - "185be72d02330f9b3dfa3d0791274feb958e119d": { + "38285a3b335e394ccce5ac5d59e15f660bfa4cc9": { "version": "3.8.18", "port": { "ty": "denoWorker@v1", @@ -897,11 +953,11 @@ "name": "zstd_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cpy_bs.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cpy_bs.ts" }, "releaseTag": "20240224" }, - "5549508f1f5eddf9cb2465f07cf0c7603dc0c849": { + "7bbf00da8e265c56c2bff5bb7d89ba806e2590d2": { "version": "1.7.0", "port": { "ty": "denoWorker@v1", @@ -932,11 +988,11 @@ "name": "cpy_bs_ghrel" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/pipi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pipi.ts" }, "packageName": "poetry" }, - "5c041a4209ae50657ea5acacc26683688f2913a9": { + "14fd3752a984c5d82e1451f7388c73a21fcce705": { "port": { "ty": "denoWorker@v1", "name": "pipi_pypi", @@ -966,11 +1022,11 @@ "name": "cpy_bs_ghrel" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/pipi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pipi.ts" }, "packageName": "pre-commit" }, - "d0bcae26fcc8ca53ffbdb66de5735c608858a313": { + "f25385325ad568d22d9538724df856df62a7b06b": { "port": { "ty": "denoWorker@v1", "name": "act_ghrel", @@ -983,10 +1039,10 @@ "x86_64-windows" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/act.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/act.ts" } }, - "ca8e4bf52171b6a173a6ba349f33721806b86d48": { + "3ed4089145ee327a97198237a8a2eb8a48212b6c": { "depConfigs": { "rust_rustup": { "portRef": "rust_rustup@0.1.0", @@ -1025,10 +1081,68 @@ "name": "rust_rustup" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargobi.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargobi.ts" }, "crateName": "whiz", "locked": true + }, + "ea543033c55cfcaa9f7e253529d0efe3a9827c6d": { + "port": { + "ty": "denoWorker@v1", + "name": "pipi_pypi", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows", + "x86_64-freebsd", + "aarch64-freebsd", + "x86_64-netbsd", + "aarch64-netbsd", + "x86_64-aix", + "aarch64-aix", + "x86_64-solaris", + "aarch64-solaris", + "x86_64-illumos", + "aarch64-illumos", + "x86_64-android", + "aarch64-android" + ], + "version": "0.1.0", + "deps": [ + { + "name": "cpy_bs_ghrel" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pipi.ts" + }, + "packageName": "componentize-py" + }, + "3044097f18de955d9402bcac8b0006554638849d": { + "port": { + "ty": "denoWorker@v1", + "name": "cpy_bs_ghrel", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows" + ], + "version": "0.1.0", + "deps": [ + { + "name": "tar_aa" + }, + { + "name": "zstd_aa" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cpy_bs.ts" + } } }, "allowedPortDeps": { @@ -1162,7 +1276,7 @@ "portRef": "zstd_aa@0.1.0" } }, - "89f6529a87b3d47e2ebdc50486bf0ed2f39049d4": { + "4cd389bd9c1a017e3af681e4515df06afc8ae94b": { "manifest": { "ty": "denoWorker@v1", "name": "rustup_rustlang", @@ -1187,13 +1301,13 @@ "name": "git_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/rustup.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/rustup.ts" }, "defaultInst": { "portRef": "rustup_rustlang@0.1.0" } }, - "201f72d1b59c9377240c3d5008d835ea83d0ba74": { + "78a3ffea7ebe9b9f09acee4f5912ce24df923dc3": { "manifest": { "ty": "denoWorker@v1", "name": "rust_rustup", @@ -1223,13 +1337,13 @@ "name": "rustup_rustlang" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/rust.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/rust.ts" }, "defaultInst": { "portRef": "rust_rustup@0.1.0" } }, - "c8084cf4c423d1862a1d783c70b8221c0cf9d73c": { + "ba089892903fc9374065ebf6466fa43baf308251": { "manifest": { "ty": "denoWorker@v1", "name": "cargo_binstall_ghrel", @@ -1240,13 +1354,13 @@ "x86_64-darwin" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cargo-binstall.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cargo-binstall.ts" }, "defaultInst": { "portRef": "cargo_binstall_ghrel@0.1.0" } }, - "422c26d0e74744b87f0f6f0eefa25e54a1188e08": { + "5d09c2a1d5a6611daf46efcc36eca64f53cb279c": { "manifest": { "ty": "denoWorker@v1", "name": "pnpm_ghrel", @@ -1259,13 +1373,13 @@ "x86_64-windows" ], "version": "0.1.0", - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/pnpm.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/pnpm.ts" }, "defaultInst": { "portRef": "pnpm_ghrel@0.1.0" } }, - "f77828fcb8896a0df3511920d0055d0f89bfdec9": { + "9c0f4895f4f2512781cf21f405fdf1a3b6b276d2": { "manifest": { "ty": "denoWorker@v1", "name": "asdf_plugin_git", @@ -1288,13 +1402,13 @@ "name": "git_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/asdf_plugin_git.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/asdf_plugin_git.ts" }, "defaultInst": { "portRef": "asdf_plugin_git@0.1.0" } }, - "ff0a30a4efc90a6a49611e273e167ac3d3444441": { + "39c0cfd108ba0ce29a11769416cadb7ed988b831": { "manifest": { "ty": "denoWorker@v1", "name": "cpy_bs_ghrel", @@ -1315,14 +1429,14 @@ "name": "zstd_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/cpy_bs.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cpy_bs.ts" }, "defaultInst": { "portRef": "cpy_bs_ghrel@0.1.0", "releaseTag": "20240224" } }, - "601d3ac573271b2e2fb3c453ccd54f22d151c64e": { + "adf17609822d9b8edd5253323d2edab7a1152ec2": { "manifest": { "ty": "denoWorker@v1", "name": "node_org", @@ -1340,12 +1454,40 @@ "name": "tar_aa" } ], - "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/423d38e/ports/node.ts" + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/node.ts" }, "defaultInst": { "version": "20.8.0", "portRef": "node_org@0.1.0" } + }, + "14d99c79513af7d220c32bef7a266958781e021b": { + "manifest": { + "ty": "denoWorker@v1", + "name": "cpy_bs_ghrel", + "platforms": [ + "x86_64-linux", + "aarch64-linux", + "x86_64-darwin", + "aarch64-darwin", + "x86_64-windows", + "aarch64-windows" + ], + "version": "0.1.0", + "deps": [ + { + "name": "tar_aa" + }, + { + "name": "zstd_aa" + } + ], + "moduleSpecifier": "https://raw.githubusercontent.com/metatypedev/ghjk/2725af8/ports/cpy_bs.ts" + }, + "defaultInst": { + "portRef": "cpy_bs_ghrel@0.1.0", + "releaseTag": "20240224" + } } } } diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml index d4c2251f0c..d36dce20af 100644 --- a/.github/workflows/publish-website.yml +++ b/.github/workflows/publish-website.yml @@ -4,7 +4,7 @@ on: - main env: - GHJK_VERSION: "423d38e" + GHJK_VERSION: "2725af8" jobs: changes: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dedf928dac..36cf2875ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ on: - v* env: - GHJK_VERSION: "423d38e" + GHJK_VERSION: "2725af8" DENO_VERSION: "1.41.0" REGISTRY_IMAGE: ghcr.io/${{ github.repository_owner }}/typegate diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20af02bc30..d6ad21f00f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ on: - ready_for_review env: - GHJK_VERSION: "423d38e" + GHJK_VERSION: "2725af8" DENO_VERSION: "1.41.0" RUST_BACKTRACE: "full" RUST_LOG: "info,swc_ecma_codegen=off,tracing::span=off" @@ -188,8 +188,10 @@ jobs: runner: ubuntu-latest # FIXME: try macos-14 runner once all actions support it # docker buildx action broken as of 2024-02-09 + - platform: linux/arm64 + runner: custom-macos # - platform: linux/arm64 - # runner: custom-macos + # runner: macos-14 steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 @@ -221,7 +223,7 @@ jobs: if: "! steps.check.outputs.has-permission" with: file: dev/Dockerfile - platforms: linux/amd64 + platforms: ${{ matrix.platform }} push: false cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/typegate:latest target: check @@ -322,8 +324,9 @@ jobs: deno cache --import-map typegate/import_map.json \ typegate/src/main.ts \ typegate/tests/utils/*.ts \ - typegate/tests/runtimes/wasm/*.ts \ - typegate/tests/runtimes/python_wasi/*.ts \ + typegate/tests/runtimes/wasm_wire/*.ts \ + typegate/tests/runtimes/wasm_reflected/*.ts \ + typegate/tests/runtimes/python/*.ts \ dev/deps.ts \ dev/utils.ts deno --unstable-worker-options --unstable-net coverage ./coverage --lcov > coverage.lcov diff --git a/.gitignore b/.gitignore index 8d32968cbf..3718e9139f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ typegraph/python/typegraph/gen *.egg-info/ examples/typegraphs/migrations +libs/pyrt_wit_wire/wit_wire diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e55540e3a..1bdc03aa12 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,12 @@ repos: - id: check-merge-conflict - id: end-of-file-fixer # exclude all generated files - exclude: (.ghjk/.*|typegate/deno.lock|.*\.snap$|typegate/src/typegraphs/.*\.json|website/docs/reference/) + exclude: (?x)( + .ghjk/.* + |.*deno.lock + |.*\.snap$|typegate/src/typegraphs/.*\.json + |website/docs/reference/ + |libs/pyrt_wit_wire/pyrt) - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.27.2 hooks: @@ -113,6 +118,7 @@ repos: - --license-filepath=dev/license-header-Elastic-2.0.txt - "--comment-style=//" - "--skip-license-insertion-comment=no-auto-license-header" + - "--skip-license-insertion-comment=@generated" types_or: - rust files: ^(typegate|libs!(/metagen/.*))/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5603b17804..601a85cb99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,14 +171,9 @@ cargo install whiz pipx install pre-commit # manange python dependencies pipx install poetry -# wasmedge prerequisits -brew install llvm -sudo apt-get install libclang-dev # grpc prerequisits brew install protobuf sudo apt-get install protobuf-compiler libprotobuf-dev -# wasmedge runtime -curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash ``` #### Running The Project diff --git a/Cargo.lock b/Cargo.lock index c4fdac9188..e2d5826a76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ed51fb0cfa6f88331d4424a7aca87146b315a3b5bd2bbad298ec855718ef9df" dependencies = [ "erased-serde 0.3.31", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", ] @@ -46,7 +46,7 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", ] [[package]] @@ -62,7 +62,7 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tracing", ] @@ -100,7 +100,7 @@ dependencies = [ "sha1", "smallvec", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tracing", "zstd 0.13.1", ] @@ -112,7 +112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -124,7 +124,7 @@ dependencies = [ "bytestring", "http 0.2.12", "regex", - "serde 1.0.199", + "serde 1.0.200", "tracing", ] @@ -207,7 +207,7 @@ dependencies = [ "once_cell", "pin-project-lite", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_urlencoded", "smallvec", @@ -225,7 +225,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -236,7 +236,7 @@ checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -318,7 +318,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "once_cell", "version_check", ] @@ -330,7 +330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.14", + "getrandom 0.2.15", "once_cell", "version_check", "zerocopy", @@ -375,6 +375,12 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "ambient-authority" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" + [[package]] name = "ammonia" version = "3.3.0" @@ -414,47 +420,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -462,9 +469,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" dependencies = [ "backtrace", ] @@ -487,7 +494,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -521,7 +528,7 @@ dependencies = [ "asn1-rs-impl", "displaydoc", "nom 7.1.3", - "num-traits 0.2.18", + "num-traits 0.2.19", "rusticata-macros", "thiserror", "time", @@ -574,7 +581,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -700,7 +707,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -740,7 +747,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -757,7 +764,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -820,14 +827,14 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" @@ -850,7 +857,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustversion", - "serde 1.0.199", + "serde 1.0.200", "sync_wrapper", "tower", "tower-layer", @@ -880,7 +887,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "instant", "rand 0.8.5", ] @@ -954,9 +961,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64-simd" @@ -1000,7 +1007,7 @@ checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" dependencies = [ "num-bigint", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -1009,7 +1016,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -1031,26 +1038,6 @@ dependencies = [ "shlex", ] -[[package]] -name = "bindgen" -version = "0.69.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" -dependencies = [ - "bitflags 2.5.0", - "cexpr", - "clang-sys", - "itertools 0.12.1", - "lazy_static 1.4.0", - "lazycell", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.60", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -1078,7 +1065,7 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -1160,7 +1147,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "syn_derive", ] @@ -1221,7 +1208,7 @@ dependencies = [ "js-sys", "once_cell", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", "serde_bytes", "serde_json", "time", @@ -1236,7 +1223,7 @@ checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" dependencies = [ "memchr", "regex-automata 0.4.6", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -1339,6 +1326,83 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bf2a5fb3207c12b5d208ebc145f967fea5cac41a021c37417ccc31ba40f39ee" +[[package]] +name = "cap-fs-ext" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "769f8cd02eb04d57f14e2e371ebb533f96817f9b2525d73a5c72b61ca7973747" +dependencies = [ + "cap-primitives", + "cap-std", + "io-lifetimes 2.0.3", + "windows-sys 0.52.0", +] + +[[package]] +name = "cap-net-ext" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ff6d3fb274292a9af283417e383afe6ded1fe66f6472d2c781216d3d80c218" +dependencies = [ + "cap-primitives", + "cap-std", + "rustix 0.38.34", + "smallvec", +] + +[[package]] +name = "cap-primitives" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a0b44fc796b1a84535a63753d50ba3972c4db55c7255c186f79140e63d56d0" +dependencies = [ + "ambient-authority", + "fs-set-times", + "io-extras", + "io-lifetimes 2.0.3", + "ipnet", + "maybe-owned", + "rustix 0.38.34", + "windows-sys 0.52.0", + "winx", +] + +[[package]] +name = "cap-rand" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4327f08daac33a99bb03c54ae18c8f32c3ba31c728a33ddf683c6c6a5043de68" +dependencies = [ + "ambient-authority", + "rand 0.8.5", +] + +[[package]] +name = "cap-std" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266626ce180cf9709f317d0bf9754e3a5006359d87f4bf792f06c9c5f1b63c0f" +dependencies = [ + "cap-primitives", + "io-extras", + "io-lifetimes 2.0.3", + "rustix 0.38.34", +] + +[[package]] +name = "cap-time-ext" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1353421ba83c19da60726e35db0a89abef984b3be183ff6f58c5b8084fcd0c5" +dependencies = [ + "ambient-authority", + "cap-primitives", + "iana-time-zone", + "once_cell", + "rustix 0.38.34", + "winx", +] + [[package]] name = "castaway" version = "0.2.2" @@ -1359,9 +1423,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -1398,8 +1462,8 @@ dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", - "num-traits 0.2.18", - "serde 1.0.199", + "num-traits 0.2.19", + "serde 1.0.200", "wasm-bindgen", "windows-targets 0.52.5", ] @@ -1491,7 +1555,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1546,7 +1610,7 @@ dependencies = [ "nom 7.1.3", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -1557,9 +1621,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "colored" @@ -1599,7 +1663,7 @@ dependencies = [ "itertools 0.11.0", "reqwest", "schemars", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_with 3.8.1", "tar", @@ -1653,7 +1717,7 @@ dependencies = [ "lazy_static 1.4.0", "nom 5.1.3", "rust-ini 0.13.0", - "serde 1.0.199", + "serde 1.0.200", "serde-hjson", "serde_json", "toml 0.5.11", @@ -1710,7 +1774,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "once_cell", "tiny-keccak", ] @@ -1820,18 +1884,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b27922a6879b5b5361d0a084cb0b1941bf109a98540addcb932da13b68bed4" +checksum = "3c7a700bc3e2e834c81c7e9e57c6b27049172fc6156a6a406dd2265d64c30409" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304c455b28bf56372729acb356afbb55d622f2b0f2f7837aa5e57c138acaac4d" +checksum = "35bb55da792dc46a35e6e283b02b9d6aa7f21349691f41176d8ecf4a1494b6ad" dependencies = [ "bumpalo", "cranelift-bforest", @@ -1850,43 +1914,43 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1653c56b99591d07f67c5ca7f9f25888948af3f4b97186bff838d687d666f613" +checksum = "bf590672e1a7580158968898ade9c82801d6ebeaa4649d6f99f9cbb411512a8b" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5b6a9cf6b6eb820ee3f973a0db313c05dc12d370f37b4fe9630286e1672573f" +checksum = "3ab16a95d8b10b72eaa8bb9f0ce0fdd013e5f225bea92f69d2dbd2424aae5381" [[package]] name = "cranelift-control" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d06e6bf30075fb6bed9e034ec046475093392eea1aff90eb5c44c4a033d19a" +checksum = "60448a5af01f5716877e616ec1613424fb65f427320c6e6447315966507f12da" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29be04f931b73cdb9694874a295027471817f26f26d2f0ebe5454153176b6e3a" +checksum = "78689d6588f53981bf005b82d94125cc40cf9856b667bc276d1acdede400b633" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "serde_derive", ] [[package]] name = "cranelift-frontend" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07fd7393041d7faa2f37426f5dc7fc04003b70988810e8c063beefeff1cd8f9" +checksum = "c86da6e45adc39e8d66a73d6fb782b0d7961df9e44b724246e01e515f86b1f0d" dependencies = [ "cranelift-codegen", "log", @@ -1896,15 +1960,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f341d7938caa6dff8149dac05bb2b53fc680323826b83b4cf175ab9f5139a3c9" +checksum = "dcb6f70d94826074699bc350c33dab82eb6f06022a3518bb466f501569d7379e" [[package]] name = "cranelift-native" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82af6066e6448d26eeabb7aa26a43f7ff79f8217b06bade4ee6ef230aecc8880" +checksum = "e27ec0ef4115eb9cc15be9c841085db17233403f8ed325e02bd6a9d78d6c939c" dependencies = [ "cranelift-codegen", "libc", @@ -1913,9 +1977,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.107.0" +version = "0.107.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2766fab7284a914a7f17f90ebe865c86453225fb8637ac31f123f5028fee69cd" +checksum = "fce009efc27c598ac0c019c7f3dc582403835547128aeb497edf76cb77d75250" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -2112,7 +2176,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -2195,7 +2259,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -2228,7 +2292,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -2273,7 +2337,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "uuid", ] @@ -2350,7 +2414,7 @@ dependencies = [ "ring 0.17.8", "rustyline", "rustyline-derive", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_repr", "sha2 0.10.8", @@ -2361,7 +2425,7 @@ dependencies = [ "text_lines", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tower-lsp", "twox-hash", "typed-arena", @@ -2387,7 +2451,7 @@ dependencies = [ "dprint-swc-ext", "once_cell", "percent-encoding", - "serde 1.0.199", + "serde 1.0.200", "swc_atoms", "swc_bundler", "swc_common", @@ -2436,7 +2500,7 @@ dependencies = [ "async-trait", "deno_core", "rusqlite", - "serde 1.0.199", + "serde 1.0.200", "sha2 0.10.8", "tokio", ] @@ -2453,7 +2517,7 @@ dependencies = [ "log", "once_cell", "parking_lot 0.12.2", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.10.8", "thiserror", @@ -2468,7 +2532,7 @@ dependencies = [ "deno_core", "deno_webgpu", "image", - "serde 1.0.199", + "serde 1.0.200", "tokio", ] @@ -2484,7 +2548,7 @@ dependencies = [ "jsonc-parser", "log", "percent-encoding", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "url", ] @@ -2518,7 +2582,7 @@ dependencies = [ "memoffset 0.9.1", "parking_lot 0.12.2", "pin-project", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_v8", "smallvec", @@ -2565,7 +2629,7 @@ dependencies = [ "deno_core", "deno_web", "elliptic-curve", - "num-traits 0.2.18", + "num-traits 0.2.19", "once_cell", "p256", "p384", @@ -2573,7 +2637,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rsa", - "serde 1.0.199", + "serde 1.0.200", "serde_bytes", "sha1", "sha2 0.10.8", @@ -2603,7 +2667,7 @@ dependencies = [ "indexmap 2.2.6", "lazy_static 1.4.0", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "termcolor", ] @@ -2638,10 +2702,10 @@ dependencies = [ "http 0.2.12", "pin-project", "reqwest", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", ] [[package]] @@ -2654,7 +2718,7 @@ dependencies = [ "dynasmrt", "libffi", "libffi-sys", - "serde 1.0.199", + "serde 1.0.200", "serde-value", "serde_json", "tokio", @@ -2677,7 +2741,7 @@ dependencies = [ "nix 0.26.2", "rand 0.8.5", "rayon", - "serde 1.0.199", + "serde 1.0.200", "tokio", "winapi", ] @@ -2703,7 +2767,7 @@ dependencies = [ "once_cell", "parking_lot 0.12.2", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.10.8", "thiserror", @@ -2741,11 +2805,11 @@ dependencies = [ "pin-project", "ring 0.17.8", "scopeguard", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", ] [[package]] @@ -2789,7 +2853,7 @@ dependencies = [ "rand 0.8.5", "reqwest", "rusqlite", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "termcolor", "tokio", @@ -2810,7 +2874,7 @@ dependencies = [ "log", "once_cell", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -2820,7 +2884,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835418ae924f25ab20f508bf6240193b22d893519d44432b670a27b8fb1efeb" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.10.8", "thiserror", @@ -2833,7 +2897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8978229b82552bf8457a0125aa20863f023619cfc21ebb007b1e571d68fd85b" dependencies = [ "data-url", - "serde 1.0.199", + "serde 1.0.200", "url", ] @@ -2870,7 +2934,7 @@ dependencies = [ "log", "pin-project", "rustls-tokio-stream", - "serde 1.0.199", + "serde 1.0.200", "socket2 0.5.7", "tokio", "trust-dns-proto 0.22.0", @@ -2916,7 +2980,7 @@ dependencies = [ "num-bigint", "num-bigint-dig", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", "once_cell", "p224", "p256", @@ -2931,7 +2995,7 @@ dependencies = [ "ripemd", "rsa", "scrypt", - "serde 1.0.199", + "serde 1.0.200", "sha-1", "sha2 0.10.8", "signature", @@ -2958,7 +3022,7 @@ dependencies = [ "futures", "log", "monch", - "serde 1.0.199", + "serde 1.0.200", "thiserror", ] @@ -2973,7 +3037,7 @@ dependencies = [ "quote", "strum", "strum_macros", - "syn 2.0.60", + "syn 2.0.61", "thiserror", ] @@ -3030,7 +3094,7 @@ dependencies = [ "regex", "ring 0.17.8", "rustyline", - "serde 1.0.199", + "serde 1.0.200", "signal-hook-registry", "tokio", "tokio-metrics", @@ -3049,7 +3113,7 @@ checksum = "b49e14effd9df8ed261f7a1a34ac19bbaf0fa940c59bd19a6d8313cf41525e1c" dependencies = [ "monch", "once_cell", - "serde 1.0.199", + "serde 1.0.200", "thiserror", "url", ] @@ -3067,7 +3131,7 @@ dependencies = [ "os_pipe", "path-dedot", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", ] [[package]] @@ -3092,7 +3156,7 @@ dependencies = [ "rustls-pemfile", "rustls-tokio-stream", "rustls-webpki", - "serde 1.0.199", + "serde 1.0.200", "webpki-roots", ] @@ -3120,7 +3184,7 @@ version = "0.139.0" source = "git+https://github.com/metatypedev/deno?branch=v1.41.0-embeddable#2fa9bab20155ccd7f90e13d4b44e277457b86699" dependencies = [ "deno_core", - "serde 1.0.199", + "serde 1.0.200", "urlpattern", ] @@ -3136,7 +3200,7 @@ dependencies = [ "encoding_rs", "flate2", "futures", - "serde 1.0.199", + "serde 1.0.200", "tokio", "uuid", "windows-sys 0.48.0", @@ -3149,7 +3213,7 @@ source = "git+https://github.com/metatypedev/deno?branch=v1.41.0-embeddable#2fa9 dependencies = [ "deno_core", "raw-window-handle", - "serde 1.0.199", + "serde 1.0.200", "tokio", "wgpu-core", "wgpu-hal", @@ -3181,7 +3245,7 @@ dependencies = [ "hyper-util", "once_cell", "rustls-tokio-stream", - "serde 1.0.199", + "serde 1.0.200", "tokio", ] @@ -3193,7 +3257,7 @@ dependencies = [ "deno_core", "deno_web", "rusqlite", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -3219,7 +3283,7 @@ dependencies = [ "num-bigint", "prost", "prost-build", - "serde 1.0.199", + "serde 1.0.200", "uuid", ] @@ -3240,10 +3304,10 @@ dependencies = [ "prost", "rand 0.8.5", "reqwest", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "url", "uuid", ] @@ -3292,7 +3356,7 @@ dependencies = [ "displaydoc", "nom 7.1.3", "num-bigint", - "num-traits 0.2.18", + "num-traits 0.2.19", "rusticata-macros", ] @@ -3303,7 +3367,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -3390,6 +3454,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "difflib" version = "0.4.0" @@ -3445,6 +3515,15 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs-sys" version = "0.3.7" @@ -3487,7 +3566,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3516,7 +3595,7 @@ checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3538,7 +3617,7 @@ dependencies = [ "prisma-models", "psl", "schema", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -3564,7 +3643,7 @@ dependencies = [ "bumpalo", "indexmap 2.2.6", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "unicode-width", ] @@ -3577,7 +3656,7 @@ dependencies = [ "anyhow", "dprint-core", "jsonc-parser", - "serde 1.0.199", + "serde 1.0.200", "text_lines", ] @@ -3590,7 +3669,7 @@ dependencies = [ "anyhow", "dprint-core", "jsonc-parser", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -3604,7 +3683,7 @@ dependencies = [ "dprint-core", "pulldown-cmark", "regex", - "serde 1.0.199", + "serde 1.0.200", "unicode-width", ] @@ -3619,7 +3698,7 @@ dependencies = [ "dprint-core", "percent-encoding", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -3647,7 +3726,7 @@ checksum = "48bc224a9084ad760195584ce5abb3c2c34a225fa312a128ad245a6b412b7689" dependencies = [ "digest 0.10.7", "num-bigint-dig", - "num-traits 0.2.18", + "num-traits 0.2.19", "pkcs8", "rfc6979", "sha2 0.10.8", @@ -3870,7 +3949,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3880,7 +3959,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" dependencies = [ "enumflags2_derive", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -3891,7 +3970,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -3939,7 +4018,7 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -3948,7 +4027,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b73807008a3c7f171cc40312f37d95ef0396e048b5848d775f54b1a4dd4a0d3" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -4011,7 +4090,7 @@ dependencies = [ "deno_semver", "futures", "hashlink", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.10.8", "thiserror", @@ -4256,7 +4335,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -4292,7 +4371,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4324,7 +4403,7 @@ checksum = "3a0b11eeb173ce52f84ebd943d42e58813a2ebb78a6a3ff0a243b71c5199cd7b" dependencies = [ "proc-macro2", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4352,7 +4431,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4364,7 +4443,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4376,7 +4455,18 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.60", + "syn 2.0.61", +] + +[[package]] +name = "fs-set-times" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "033b337d725b97690d86893f9de22b67b80dcc4e9ad815f348254c38119db8fb" +dependencies = [ + "io-lifetimes 2.0.3", + "rustix 0.38.34", + "windows-sys 0.52.0", ] [[package]] @@ -4506,7 +4596,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4584,7 +4674,7 @@ dependencies = [ "bitflags 2.5.0", "debugid", "fxhash", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -4607,7 +4697,7 @@ checksum = "9cf62650515830c41553b72bd49ec20fb120226f9277c7f2847f071cf998325b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -4634,9 +4724,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -4858,7 +4948,7 @@ dependencies = [ "bstr", "grep-matcher", "grep-searcher", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "termcolor", ] @@ -4917,7 +5007,7 @@ dependencies = [ "indexmap 2.2.6", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tracing", ] @@ -4936,7 +5026,7 @@ dependencies = [ "indexmap 2.2.6", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tracing", ] @@ -4947,7 +5037,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8588661a8607108a5ca69cab034063441a0413a0b041c13618a7dd348021ef6f" dependencies = [ "hashbrown 0.14.5", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -4960,7 +5050,7 @@ dependencies = [ "log", "pest", "pest_derive", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", ] @@ -5410,7 +5500,7 @@ dependencies = [ "bytemuck", "byteorder", "color_quant", - "num-traits 0.2.18", + "num-traits 0.2.19", "png", ] @@ -5422,7 +5512,7 @@ checksum = "4bad4ef70a3e0f2ee403925d77d1e7b74e471b57ea75593f332aac31b57958b4" dependencies = [ "indexmap 2.2.6", "log", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "url", ] @@ -5454,7 +5544,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -5465,7 +5555,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.5", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -5546,6 +5636,16 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" +[[package]] +name = "io-extras" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b" +dependencies = [ + "io-lifetimes 2.0.3", + "windows-sys 0.52.0", +] + [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5557,6 +5657,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "io-lifetimes" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a611371471e98973dbcab4e0ec66c31a10bc356eeb4d54a0e05eac8158fe38c" + [[package]] name = "ipconfig" version = "0.3.2" @@ -5593,7 +5699,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -5623,6 +5729,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06d198e9919d9822d5f7083ba8530e04de87841eaf21ead9af8f2304efd57c89" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -5701,7 +5813,7 @@ source = "git+https://github.com/prisma/prisma-engines?tag=5.5.2#aebc046ce8b88eb dependencies = [ "backtrace", "heck 0.3.3", - "serde 1.0.199", + "serde 1.0.200", "toml 0.5.11", ] @@ -5724,7 +5836,7 @@ dependencies = [ "futures-executor", "futures-util", "log", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", ] @@ -5816,7 +5928,7 @@ dependencies = [ "once_cell", "regex", "rust-ini 0.19.0", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_yaml", "tempfile", @@ -5851,7 +5963,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -6105,7 +6217,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e01cc93c35479eaa65adbf8b9aa933aa3f400d9e4e2fc553f516d4f822c8b13" dependencies = [ - "syn 2.0.60", + "syn 2.0.61", "thiserror", ] @@ -6125,7 +6237,7 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -6162,7 +6274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2368312c59425dd133cb9a327afee65be0a633a8ce471d248e2202a48f8f68ae" dependencies = [ "bitflags 1.3.2", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_repr", "url", @@ -6175,7 +6287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c66bfd44a06ae10647fe3f8214762e9369fd4248df1350924b4ef9e770a85ea1" dependencies = [ "bitflags 1.3.2", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_repr", "url", @@ -6261,6 +6373,12 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "maybe-owned" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" + [[package]] name = "md-5" version = "0.10.6" @@ -6393,8 +6511,8 @@ dependencies = [ "question", "reqwest", "self_update", - "semver 1.0.22", - "serde 1.0.199", + "semver 1.0.23", + "serde 1.0.200", "serde_json", "serde_yaml", "shadow-rs", @@ -6418,9 +6536,10 @@ dependencies = [ "indexmap 2.2.6", "log", "once_cell", + "pretty_assertions", "regex", "reqwest", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tempfile", "tokio", @@ -6431,7 +6550,7 @@ name = "metagen_mdk_rust_static" version = "0.0.1" dependencies = [ "anyhow", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "wit-bindgen 0.22.0", ] @@ -6634,7 +6753,7 @@ dependencies = [ "rustc_version_runtime", "rustls 0.21.12", "rustls-pemfile", - "serde 1.0.199", + "serde 1.0.200", "serde_bytes", "serde_with 1.14.0", "sha-1", @@ -6646,7 +6765,7 @@ dependencies = [ "thiserror", "tokio", "tokio-rustls 0.24.1", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "trust-dns-proto 0.21.2", "trust-dns-resolver 0.21.2", "typed-builder", @@ -6688,7 +6807,7 @@ dependencies = [ "query-engine-metrics", "rand 0.7.3", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "tokio", @@ -6728,7 +6847,7 @@ source = "git+https://github.com/prisma/prisma-engines?tag=5.5.2#aebc046ce8b88eb dependencies = [ "futures", "mongodb", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -6769,13 +6888,13 @@ dependencies = [ "pin-project", "priority-queue", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "socket2 0.4.10", "thiserror", "tokio", "tokio-native-tls", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "twox-hash", "url", ] @@ -6788,7 +6907,7 @@ checksum = "9006c95034ccf7b903d955f210469119f6c3477fc9c9e7a7845ce38a3e665c2a" dependencies = [ "base64 0.13.1", "bigdecimal", - "bindgen 0.59.2", + "bindgen", "bitflags 1.3.2", "bitvec", "byteorder", @@ -6801,12 +6920,12 @@ dependencies = [ "lazy_static 1.4.0", "lexical", "num-bigint", - "num-traits 0.2.18", + "num-traits 0.2.19", "rand 0.8.5", "regex", "rust_decimal", "saturating", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha1", "sha2 0.10.8", @@ -6829,9 +6948,9 @@ dependencies = [ "hexf-parse", "indexmap 2.2.6", "log", - "num-traits 0.2.18", + "num-traits 0.2.19", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "spirv", "termcolor", "thiserror", @@ -6854,9 +6973,9 @@ source = "git+https://github.com/metatypedev/deno?branch=v1.41.0-embeddable#2fa9 dependencies = [ "proc-macro2", "quote", - "serde 1.0.199", + "serde 1.0.200", "serde_json", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -7046,20 +7165,19 @@ dependencies = [ "num-integer", "num-iter", "num-rational", - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -7073,9 +7191,9 @@ dependencies = [ "libm", "num-integer", "num-iter", - "num-traits 0.2.18", + "num-traits 0.2.19", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "zeroize", ] @@ -7086,7 +7204,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -7095,17 +7213,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "num-derive" version = "0.4.2" @@ -7114,7 +7221,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -7123,18 +7230,18 @@ version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -7146,7 +7253,7 @@ dependencies = [ "autocfg", "num-bigint", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -7155,14 +7262,14 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -7288,7 +7395,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -7335,7 +7442,7 @@ dependencies = [ "percent-encoding", "pin-project", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", "thiserror", "tokio", "tokio-stream", @@ -7413,7 +7520,7 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -7422,7 +7529,7 @@ version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e" dependencies = [ - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -7448,7 +7555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae99c7fa6dd38c7cafe1ec085e804f8f555a2f8659b0dbe03f1f9963a9b51092" dependencies = [ "log", - "serde 1.0.199", + "serde 1.0.200", "windows-sys 0.52.0", ] @@ -7610,9 +7717,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "path-clean" @@ -7686,9 +7793,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -7697,9 +7804,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -7707,22 +7814,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -7808,7 +7915,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -7846,7 +7953,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -7913,7 +8020,7 @@ checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -8016,7 +8123,7 @@ dependencies = [ "chrono", "fallible-iterator 0.2.0", "postgres-protocol", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "uuid", ] @@ -8078,6 +8185,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + [[package]] name = "prettyplease" version = "0.1.25" @@ -8133,7 +8250,7 @@ dependencies = [ "chrono", "once_cell", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "uuid", ] @@ -8179,7 +8296,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -8191,7 +8308,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -8278,7 +8395,7 @@ dependencies = [ "chrono", "inventory", "prost", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "typetag", @@ -8310,7 +8427,7 @@ dependencies = [ "prost-wkt", "prost-wkt-build", "regex", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", ] @@ -8341,7 +8458,7 @@ dependencies = [ "prisma-value", "regex", "schema-ast", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "url", ] @@ -8386,7 +8503,7 @@ dependencies = [ "config", "directories 4.0.1", "petgraph 0.6.4", - "serde 1.0.199", + "serde 1.0.200", "serde-value", "tint", ] @@ -8470,7 +8587,7 @@ dependencies = [ "itertools 0.10.5", "prisma-models", "prisma-value", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "user-facing-errors", @@ -8501,7 +8618,7 @@ dependencies = [ "query-connector", "query-engine-metrics", "schema", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "tokio", @@ -8523,7 +8640,7 @@ dependencies = [ "metrics-util 0.12.1", "once_cell", "parking_lot 0.12.2", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tracing", "tracing-futures", @@ -8664,7 +8781,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", ] [[package]] @@ -8750,7 +8867,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "libredox", "thiserror", ] @@ -8772,7 +8889,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -8834,9 +8951,9 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "relative-path" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "rend" @@ -8865,7 +8982,7 @@ dependencies = [ "psl", "quaint", "query-core", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sql-query-connector", "thiserror", @@ -8902,14 +9019,14 @@ dependencies = [ "pin-project-lite", "rustls 0.21.12", "rustls-pemfile", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", "tokio-socks", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tower-service", "url", "wasm-bindgen", @@ -8963,7 +9080,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.14", + "getrandom 0.2.15", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -9016,7 +9133,7 @@ checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64 0.21.7", "bitflags 2.5.0", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", ] @@ -9030,7 +9147,7 @@ dependencies = [ "digest 0.10.7", "num-bigint-dig", "num-integer", - "num-traits 0.2.18", + "num-traits 0.2.19", "pkcs1", "pkcs8", "rand_core 0.6.4", @@ -9080,10 +9197,10 @@ dependencies = [ "arrayvec 0.7.4", "borsh", "bytes", - "num-traits 0.2.18", + "num-traits 0.2.19", "rand 0.8.5", "rkyv", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -9114,7 +9231,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -9144,7 +9261,7 @@ checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno 0.3.8", - "io-lifetimes", + "io-lifetimes 1.0.11", "libc", "linux-raw-sys 0.3.8", "windows-sys 0.48.0", @@ -9158,8 +9275,10 @@ checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno 0.3.8", + "itoa", "libc", "linux-raw-sys 0.4.13", + "once_cell", "windows-sys 0.52.0", ] @@ -9271,9 +9390,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "ryu-js" @@ -9354,7 +9473,7 @@ dependencies = [ "enumflags2", "psl", "quaint", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.9.9", "tracing", @@ -9375,7 +9494,7 @@ dependencies = [ "mongodb-schema-connector", "psl", "schema-connector", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sql-schema-connector", "tokio", @@ -9388,27 +9507,27 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55c82c700538496bdc329bb4918a81f87cc8888811bd123cf325a0f2f8d309" +checksum = "fc6e7ed6919cb46507fb01ff1654309219f62b4d603822501b0b80d42f6f21ef" dependencies = [ "dyn-clone", "indexmap 1.9.3", "schemars_derive", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] [[package]] name = "schemars_derive" -version = "0.8.17" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83263746fe5e32097f06356968a077f96089739c927a61450efa069905eec108" +checksum = "185f2b7aa7e02d418e453790dde16890256bbd2bcd04b7dc5348811052b53f49" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -9467,11 +9586,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -9480,9 +9599,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -9514,7 +9633,7 @@ dependencies = [ "regex", "reqwest", "self-replace", - "semver 1.0.22", + "semver 1.0.23", "serde_json", "tar", "tempfile", @@ -9533,9 +9652,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "semver-parser" @@ -9609,7 +9728,7 @@ dependencies = [ "once_cell", "rand 0.8.5", "sentry-types", - "serde 1.0.199", + "serde 1.0.200", "serde_json", ] @@ -9655,7 +9774,7 @@ dependencies = [ "debugid", "hex", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "time", @@ -9671,9 +9790,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] @@ -9697,7 +9816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" dependencies = [ "ordered-float 2.10.1", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -9706,18 +9825,18 @@ version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] name = "serde_derive" -version = "1.0.199" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -9728,7 +9847,7 @@ checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -9740,7 +9859,7 @@ dependencies = [ "indexmap 2.2.6", "itoa", "ryu", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -9751,7 +9870,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -9760,7 +9879,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -9772,7 +9891,7 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -9784,7 +9903,7 @@ dependencies = [ "bytes", "derive_more", "num-bigint", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "thiserror", "v8", @@ -9796,7 +9915,7 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "serde_with_macros 1.5.2", ] @@ -9806,12 +9925,12 @@ version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.2.6", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "serde_with_macros 3.8.1", @@ -9839,7 +9958,7 @@ dependencies = [ "darling 0.20.8", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -9851,19 +9970,10 @@ dependencies = [ "indexmap 2.2.6", "itoa", "ryu", - "serde 1.0.199", + "serde 1.0.200", "unsafe-libyaml", ] -[[package]] -name = "setjmp" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a4a1d465f5de0833aed8a7c76b1c01606bc8160c5a7d2c0108867dfffdfef3" -dependencies = [ - "libc", -] - [[package]] name = "sha-1" version = "0.10.0" @@ -9910,19 +10020,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha256" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18278f6a914fa3070aa316493f7d2ddfb9ac86ebc06fa3b83bffda487e9065b0" -dependencies = [ - "async-trait", - "bytes", - "hex", - "sha2 0.10.8", - "tokio", -] - [[package]] name = "sha3" version = "0.10.8" @@ -9967,6 +10064,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "shellexpand" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" +dependencies = [ + "dirs", +] + [[package]] name = "shlex" version = "1.3.0" @@ -10013,11 +10119,11 @@ version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "570c430b3d902ea083097e853263ae782dfe40857d93db019a12356c8e8143fa" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "halfbrown", "lexical-core 0.8.5", "ref-cast", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "simdutf8", "value-trait", @@ -10134,7 +10240,7 @@ dependencies = [ "debugid", "if_chain", "rustc_version 0.2.3", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "unicode-id", "url", @@ -10151,7 +10257,7 @@ dependencies = [ "debugid", "if_chain", "rustc_version 0.2.3", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "unicode-id-start", "url", @@ -10185,7 +10291,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" dependencies = [ "bitflags 1.3.2", - "num-traits 0.2.18", + "num-traits 0.2.19", ] [[package]] @@ -10229,7 +10335,7 @@ dependencies = [ "quaint", "query-connector", "rand 0.7.3", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "tokio", @@ -10257,7 +10363,7 @@ dependencies = [ "quaint", "regex", "schema-connector", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sql-ddl", "sql-schema-describer", @@ -10287,7 +10393,7 @@ dependencies = [ "psl", "quaint", "regex", - "serde 1.0.199", + "serde 1.0.200", "tracing", "tracing-error", "tracing-futures", @@ -10349,7 +10455,7 @@ dependencies = [ "parking_lot 0.12.2", "phf_shared 0.10.0", "precomputed-hash", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -10373,7 +10479,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10421,7 +10527,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10449,7 +10555,7 @@ dependencies = [ "hstr", "once_cell", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -10493,7 +10599,7 @@ dependencies = [ "dashmap", "once_cell", "regex", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -10512,7 +10618,7 @@ dependencies = [ "num-bigint", "once_cell", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "siphasher", "sourcemap 6.4.1", "swc_atoms", @@ -10532,7 +10638,7 @@ checksum = "ce837c5eae1cb200a310940de989fd9b3d12ed62d7752bc69b39ef8aa775ec04" dependencies = [ "anyhow", "indexmap 2.2.6", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "swc_cached", "swc_config_macro", @@ -10547,7 +10653,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10578,7 +10684,7 @@ dependencies = [ "num-bigint", "phf 0.11.2", "scoped-tls", - "serde 1.0.199", + "serde 1.0.200", "string_enum", "swc_atoms", "swc_common", @@ -10595,7 +10701,7 @@ dependencies = [ "num-bigint", "once_cell", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "sourcemap 6.4.1", "swc_atoms", "swc_common", @@ -10614,7 +10720,7 @@ dependencies = [ "num-bigint", "once_cell", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "sourcemap 6.4.1", "swc_atoms", "swc_common", @@ -10632,7 +10738,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10643,7 +10749,7 @@ checksum = "7c16051bce5421992a1b49350735bf4d110f761fd68ae7098af17a64ad639b8d" dependencies = [ "anyhow", "pathdiff", - "serde 1.0.199", + "serde 1.0.200", "swc_atoms", "swc_common", "tracing", @@ -10658,9 +10764,9 @@ dependencies = [ "either", "new_debug_unreachable", "num-bigint", - "num-traits 0.2.18", + "num-traits 0.2.19", "phf 0.11.2", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "smartstring", "stacker", @@ -10680,9 +10786,9 @@ dependencies = [ "either", "new_debug_unreachable", "num-bigint", - "num-traits 0.2.18", + "num-traits 0.2.19", "phf 0.11.2", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "smartstring", "stacker", @@ -10705,7 +10811,7 @@ dependencies = [ "once_cell", "phf 0.11.2", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "swc_atoms", "swc_common", @@ -10728,7 +10834,7 @@ dependencies = [ "once_cell", "phf 0.11.2", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "swc_atoms", "swc_common", @@ -10762,7 +10868,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10797,7 +10903,7 @@ checksum = "39920f44aa30ab997dd7cfdc364addd54e4a5fcc3807ae69a6fe283f306bc5a5" dependencies = [ "either", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "swc_atoms", "swc_common", @@ -10819,7 +10925,7 @@ dependencies = [ "dashmap", "indexmap 2.2.6", "once_cell", - "serde 1.0.199", + "serde 1.0.200", "sha-1", "string_enum", "swc_atoms", @@ -10843,7 +10949,7 @@ dependencies = [ "dashmap", "indexmap 2.2.6", "once_cell", - "serde 1.0.199", + "serde 1.0.200", "sha-1", "string_enum", "swc_atoms", @@ -10864,7 +10970,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e4263372cc7cd1a3b4570ccf7438f3c1e1575f134fd05cdf074edb322480a5b" dependencies = [ "ryu-js", - "serde 1.0.199", + "serde 1.0.200", "swc_atoms", "swc_common", "swc_ecma_ast 0.110.17", @@ -10881,7 +10987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "432cf63b05d3ec435199bfbf7ba50793c6cb777bfcd8ad9f055f501aa9048d9c" dependencies = [ "ryu-js", - "serde 1.0.199", + "serde 1.0.200", "swc_atoms", "swc_common", "swc_ecma_ast 0.112.2", @@ -10963,7 +11069,7 @@ checksum = "695a1d8b461033d32429b5befbf0ad4d7a2c4d6ba9cd5ba4e0645c615839e8e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -10999,7 +11105,7 @@ checksum = "50176cfc1cbc8bb22f41c6fe9d1ec53fbe057001219b5954961b8ad0f336fce9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11023,7 +11129,7 @@ dependencies = [ "proc-macro2", "quote", "swc_macros_common", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11039,9 +11145,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", @@ -11057,7 +11163,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11078,6 +11184,22 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "system-interface" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b858526d22750088a9b3cf2e3c2aacebd5377f13adeec02860c30d09113010a6" +dependencies = [ + "bitflags 2.5.0", + "cap-fs-ext", + "cap-std", + "fd-lock", + "io-lifetimes 2.0.3", + "rustix 0.38.34", + "windows-sys 0.52.0", + "winx", +] + [[package]] name = "take_mut" version = "0.2.2" @@ -11158,7 +11280,7 @@ dependencies = [ "prost-wkt", "prost-wkt-build", "prost-wkt-types", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "thiserror", "tonic", @@ -11203,7 +11325,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fd5828de7deaa782e1dd713006ae96b3bee32d3279b79eb67ecf8072c059bcf" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -11219,22 +11341,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11266,14 +11388,14 @@ dependencies = [ "futures", "futures-sink", "futures-util", - "num-traits 0.2.18", + "num-traits 0.2.19", "once_cell", "opentls", "pin-project-lite", "pretty-hex", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tracing", "uuid", "winauth", @@ -11291,7 +11413,7 @@ dependencies = [ "num-conv", "num_threads", "powerfmt", - "serde 1.0.199", + "serde 1.0.200", "time-core", "time-macros", ] @@ -11394,7 +11516,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11439,7 +11561,7 @@ dependencies = [ "postgres-types", "socket2 0.5.7", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", ] [[package]] @@ -11503,9 +11625,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -11513,7 +11635,6 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -11522,7 +11643,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -11531,7 +11652,7 @@ version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "serde_spanned", "toml_datetime", "toml_edit 0.22.12", @@ -11543,7 +11664,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -11564,10 +11685,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", - "serde 1.0.199", + "serde 1.0.200", "serde_spanned", "toml_datetime", - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -11597,7 +11718,7 @@ dependencies = [ "tokio", "tokio-rustls 0.23.4", "tokio-stream", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tower", "tower-layer", "tower-service", @@ -11632,7 +11753,7 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tower-layer", "tower-service", "tracing", @@ -11658,10 +11779,10 @@ dependencies = [ "httparse", "lsp-types 0.94.1", "memchr", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "tower", "tower-lsp-macros", "tracing", @@ -11675,7 +11796,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11704,7 +11825,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -11797,7 +11918,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" dependencies = [ - "serde 1.0.199", + "serde 1.0.200", "stable_deref_trait", ] @@ -11843,7 +11964,7 @@ dependencies = [ "ipnet", "lazy_static 1.4.0", "rand 0.8.5", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "thiserror", "tinyvec", @@ -11885,7 +12006,7 @@ dependencies = [ "lru-cache", "parking_lot 0.12.2", "resolv-conf", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "thiserror", "tokio", @@ -11955,8 +12076,8 @@ dependencies = [ "futures", "log", "mt_deno", - "num-derive 0.4.2", - "num-traits 0.2.18", + "num-derive", + "num-traits 0.2.19", "once_cell", "prisma-models", "psl", @@ -11967,7 +12088,7 @@ dependencies = [ "request-handlers", "schema-connector", "schema-core", - "serde 1.0.199", + "serde 1.0.200", "shadow-rs", "tap", "tempfile", @@ -11977,10 +12098,9 @@ dependencies = [ "tokio", "typescript", "user-facing-errors", - "wasmedge-sdk", - "wasmedge-sys", - "wasmedge-types", "wasmtime", + "wasmtime-wasi", + "zstd 0.13.1", ] [[package]] @@ -12000,7 +12120,7 @@ dependencies = [ "ptree", "regex", "seahash", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "sha2 0.10.8", "wit-bindgen 0.24.0", @@ -12037,7 +12157,7 @@ dependencies = [ "erased-serde 0.4.4", "inventory", "once_cell", - "serde 1.0.199", + "serde 1.0.200", "typetag-impl", ] @@ -12049,7 +12169,7 @@ checksum = "ac73887f47b9312552aa90ef477927ff014d63d1920ca8037c6c1951eab64bb1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -12263,7 +12383,7 @@ version = "2.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d11a831e3c0b56e438a28308e7c810799e3c118417f342d30ecec080105395cd" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "log", "native-tls", "once_cell", @@ -12279,7 +12399,7 @@ dependencies = [ "form_urlencoded", "idna 0.5.0", "percent-encoding", - "serde 1.0.199", + "serde 1.0.200", ] [[package]] @@ -12296,7 +12416,7 @@ checksum = "f9bd5ff03aea02fa45b13a7980151fe45009af1980ba69f651ec367121a31609" dependencies = [ "derive_more", "regex", - "serde 1.0.199", + "serde 1.0.200", "unic-ucd-ident", "url", ] @@ -12320,7 +12440,7 @@ dependencies = [ "indoc", "itertools 0.10.5", "quaint", - "serde 1.0.199", + "serde 1.0.200", "serde_json", "tracing", "user-facing-error-macros", @@ -12350,8 +12470,8 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ - "getrandom 0.2.14", - "serde 1.0.199", + "getrandom 0.2.15", + "serde 1.0.200", ] [[package]] @@ -12509,7 +12629,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wasm-bindgen-shared", ] @@ -12543,7 +12663,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -12589,7 +12709,7 @@ checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" dependencies = [ "anyhow", "indexmap 2.2.6", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "spdx", @@ -12605,7 +12725,7 @@ checksum = "094aea3cb90e09f16ee25a4c0e324b3e8c934e7fd838bfa039aef5352f44a917" dependencies = [ "anyhow", "indexmap 2.2.6", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "spdx", @@ -12626,70 +12746,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmedge-macro" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe80d95a88e9ac87b6aaf7bc9acd1fdfcd92045db2bf41a2262f623e2406a92" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - -[[package]] -name = "wasmedge-sdk" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f477f3b515760c6f7fa734dae5b97c030ee443969f1c30ed12d3a09bea783a2" -dependencies = [ - "anyhow", - "cfg-if", - "num-derive 0.3.3", - "num-traits 0.2.18", - "thiserror", - "wasmedge-macro", - "wasmedge-sys", - "wasmedge-types", -] - -[[package]] -name = "wasmedge-sys" -version = "0.17.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d8e2276d63bb6f0c36871218643d193d2da6da3db36c1c1227547da465ed58" -dependencies = [ - "bindgen 0.69.4", - "cfg-if", - "cmake", - "flate2", - "lazy_static 1.4.0", - "libc", - "parking_lot 0.12.2", - "paste", - "phf 0.11.2", - "rand 0.8.5", - "reqwest", - "scoped-tls", - "setjmp", - "sha256", - "tar", - "thiserror", - "wasmedge-macro", - "wasmedge-types", - "wat", -] - -[[package]] -name = "wasmedge-types" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d4e7c8aebe2c513bb389beebc148253eb6f5904a6f9327179bbf2014c0efd52" -dependencies = [ - "thiserror", - "wat", -] - [[package]] name = "wasmparser" version = "0.201.0" @@ -12698,7 +12754,7 @@ checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" dependencies = [ "bitflags 2.5.0", "indexmap 2.2.6", - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -12709,7 +12765,7 @@ checksum = "d6998515d3cf3f8b980ef7c11b29a9b1017d4cf86b99ae93b546992df9931413" dependencies = [ "bitflags 2.5.0", "indexmap 2.2.6", - "semver 1.0.22", + "semver 1.0.23", ] [[package]] @@ -12724,9 +12780,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5990663c28d81015ddbb02a068ac1bf396a4ea296eba7125b2dfc7c00cb52e" +checksum = "2364a810370f08ece49d013255058c3c88ca6c0a080de66549233b7d2ca078b8" dependencies = [ "addr2line", "anyhow", @@ -12746,8 +12802,8 @@ dependencies = [ "paste", "rayon", "rustix 0.38.34", - "semver 1.0.22", - "serde 1.0.199", + "semver 1.0.23", + "serde 1.0.200", "serde_derive", "serde_json", "target-lexicon", @@ -12770,18 +12826,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625ee94c72004f3ea0228989c9506596e469517d7d0ed66f7300d1067bdf1ca9" +checksum = "c52cceae147514e279460ac3c43c1ea440c51c39202842611623b3f9734f73a8" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98534bf28de232299e83eab33984a7a6c40c69534d6bd0ea216150b63d41a83a" +checksum = "b34056847ca9bde1d97cbc829a95d634f54d2879faa17200e55f3cddac159aea" dependencies = [ "anyhow", "base64 0.21.7", @@ -12789,7 +12845,7 @@ dependencies = [ "directories-next", "log", "rustix 0.38.34", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "sha2 0.10.8", "toml 0.8.12", @@ -12799,14 +12855,14 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f84414a25ee3a624c8b77550f3fe7b5d8145bd3405ca58886ee6900abb6dc2" +checksum = "c8fd43a734bf424e3983363f1b7532a997edb206f52104568058e412e18db9ba" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser 0.202.0", @@ -12814,15 +12870,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78580bdb4e04c7da3bf98088559ca1d29382668536e4d5c7f2f966d79c390307" +checksum = "44d65e6a21c3e3482240ff03cc26f5c7ae7ee5df524c2283f39cf492ab711a15" [[package]] name = "wasmtime-cranelift" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60df0ee08c6a536c765f69e9e8205273435b66d02dd401e938769a2622a6c1a" +checksum = "e2a6ed70499769b4d51f6f656204b0806b3d783f6ec5a8517c68e8b75ecaad19" dependencies = [ "anyhow", "cfg-if", @@ -12844,9 +12900,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ffc1613db69ee47c96738861534f9a405e422a5aa00224fbf5d410b03fb445" +checksum = "90f7b5dbae8c3c6586e22f063ddb9e5cbf02c09629df75e5d8710f7bf880b117" dependencies = [ "anyhow", "bincode", @@ -12857,7 +12913,7 @@ dependencies = [ "log", "object 0.33.0", "rustc-demangle", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "target-lexicon", "thiserror", @@ -12870,9 +12926,9 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f043514a23792761c5765f8ba61a4aa7d67f260c0c37494caabceb41d8ae81de" +checksum = "582e7ef625be814c57b1f8c3924c8899560d315f2285436c9184a09985dc3756" dependencies = [ "anyhow", "cc", @@ -12885,9 +12941,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c0ca2ad8f5d2b37f507ef1c935687a690e84e9f325f5a2af9639440b43c1f0e" +checksum = "1bf1b989e3f648340253b76c6c58b2ade89bdf0e23edc4e911deb801fa915b18" dependencies = [ "object 0.33.0", "once_cell", @@ -12897,9 +12953,9 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9f93a3289057b26dc75eb84d6e60d7694f7d169c7c09597495de6e016a13ff" +checksum = "b55b43e693c0beeca494d522f4850afca53cb46acf309483aef32a125276ee78" dependencies = [ "cfg-if", "libc", @@ -12908,9 +12964,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6332a2b0af4224c3ea57c857ad39acd2780ccc2b0c99ba1baa01864d90d7c94" +checksum = "1d2b876c09b7863d8a01bf87eb45f3b121fab245f8afbff7c38c38c1c9059aee" dependencies = [ "anyhow", "cc", @@ -12938,18 +12994,18 @@ dependencies = [ [[package]] name = "wasmtime-slab" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3655075824a374c536a2b2cc9283bb765fcdf3d58b58587862c48571ad81ef" +checksum = "05c8ddfb8ebbab6ac186bc1f8c02ed988bc9ea455fea10f72bc3a07503309b4b" [[package]] name = "wasmtime-types" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf64a242b0b9257604181ca28b28a5fcaa4c9ea1d396f76d1d2d1c5b40eef" +checksum = "3fa3a1f3c0deb3034d76e7dcf340c5df670a6603019ee5b58adb70870649c769" dependencies = [ "cranelift-entity", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "thiserror", "wasmparser 0.202.0", @@ -12957,20 +13013,51 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8561d9e2920db2a175213d557d71c2ac7695831ab472bbfafb9060cd1034684f" +checksum = "b85321f0a1cd3c859b94e728533ba00074d3eca62362acf6998be0eab6f4001c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", +] + +[[package]] +name = "wasmtime-wasi" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c5966b1aa330f07ef58f83b074908ea210ee864948ae3697f8892c91104e6e3" +dependencies = [ + "anyhow", + "async-trait", + "bitflags 2.5.0", + "bytes", + "cap-fs-ext", + "cap-net-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "futures", + "io-extras", + "io-lifetimes 2.0.3", + "once_cell", + "rustix 0.38.34", + "system-interface", + "thiserror", + "tokio", + "tracing", + "url", + "wasmtime", + "wiggle", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-winch" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06b573d14ac846a0fb8c541d8fca6a64acf9a1d176176982472274ab1d2fa5d" +checksum = "e0d446696aa83f680d85e188670631cb7958957f63d027d6c36b945c2baa3e1e" dependencies = [ "anyhow", "cranelift-codegen", @@ -12985,9 +13072,9 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "20.0.0" +version = "20.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595bc7bb3b0ff4aa00fab718c323ea552c3034d77abc821a35112552f2ea487a" +checksum = "4d1d0c83af38eb6918af9c7cbc07d39f741a7baa9ddd152e19d9f93ff627dc05" dependencies = [ "anyhow", "heck 0.4.1", @@ -12995,6 +13082,15 @@ dependencies = [ "wit-parser 0.202.0", ] +[[package]] +name = "wast" +version = "35.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" +dependencies = [ + "leb128", +] + [[package]] name = "wast" version = "206.0.0" @@ -13014,7 +13110,7 @@ version = "1.206.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da4c6f2606276c6e991aebf441b2fc92c517807393f039992a3e0ad873efe4ad" dependencies = [ - "wast", + "wast 206.0.0", ] [[package]] @@ -13060,7 +13156,7 @@ dependencies = [ "raw-window-handle", "ron", "rustc-hash", - "serde 1.0.199", + "serde 1.0.200", "smallvec", "thiserror", "web-sys", @@ -13117,7 +13213,7 @@ checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd" dependencies = [ "bitflags 2.5.0", "js-sys", - "serde 1.0.199", + "serde 1.0.200", "web-sys", ] @@ -13163,6 +13259,48 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" +[[package]] +name = "wiggle" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909dcda9e41ab1f8280cf7d774fa16d240792d6fe086a88ef69a9dd97827d289" +dependencies = [ + "anyhow", + "async-trait", + "bitflags 2.5.0", + "thiserror", + "tracing", + "wasmtime", + "wiggle-macro", +] + +[[package]] +name = "wiggle-generate" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce431612cd480dbf925fb7c3c513dec176a57ea977bf3685726e4b0ab41a6408" +dependencies = [ + "anyhow", + "heck 0.4.1", + "proc-macro2", + "quote", + "shellexpand", + "syn 2.0.61", + "witx", +] + +[[package]] +name = "wiggle-macro" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9815f5f4b6c6e01449569469416783992ac703c8fbf83d3724dfb16a02fe2e5c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", + "wiggle-generate", +] + [[package]] name = "winapi" version = "0.3.9" @@ -13209,9 +13347,9 @@ dependencies = [ [[package]] name = "winch-codegen" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb23450977f9d4a23c02439cf6899340b2d68887b19465c5682740d9cc37d52e" +checksum = "720aabcf6838b31b42c7adc04d847696b066ddc5877efd6071ed5f08ae75bf20" dependencies = [ "anyhow", "cranelift-codegen", @@ -13402,9 +13540,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] @@ -13428,6 +13566,16 @@ dependencies = [ "toml 0.5.11", ] +[[package]] +name = "winx" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9643b83820c0cd246ecabe5fa454dd04ba4fa67996369466d0747472d337346" +dependencies = [ + "bitflags 2.5.0", + "windows-sys 0.52.0", +] + [[package]] name = "wit-bindgen" version = "0.22.0" @@ -13521,7 +13669,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wit-bindgen-core 0.22.0", "wit-bindgen-rust 0.22.0", ] @@ -13535,7 +13683,7 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", "wit-bindgen-core 0.24.0", "wit-bindgen-rust 0.24.0", ] @@ -13550,7 +13698,7 @@ dependencies = [ "bitflags 2.5.0", "indexmap 2.2.6", "log", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "wasm-encoder 0.201.0", @@ -13569,7 +13717,7 @@ dependencies = [ "bitflags 2.5.0", "indexmap 2.2.6", "log", - "serde 1.0.199", + "serde 1.0.200", "serde_derive", "serde_json", "wasm-encoder 0.202.0", @@ -13588,8 +13736,8 @@ dependencies = [ "id-arena", "indexmap 2.2.6", "log", - "semver 1.0.22", - "serde 1.0.199", + "semver 1.0.23", + "serde 1.0.200", "serde_derive", "serde_json", "unicode-xid", @@ -13606,14 +13754,26 @@ dependencies = [ "id-arena", "indexmap 2.2.6", "log", - "semver 1.0.22", - "serde 1.0.199", + "semver 1.0.23", + "serde 1.0.200", "serde_derive", "serde_json", "unicode-xid", "wasmparser 0.202.0", ] +[[package]] +name = "witx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" +dependencies = [ + "anyhow", + "log", + "thiserror", + "wast 35.0.2", +] + [[package]] name = "wyz" version = "0.5.1" @@ -13631,7 +13791,7 @@ checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ "curve25519-dalek", "rand_core 0.6.4", - "serde 1.0.199", + "serde 1.0.200", "zeroize", ] @@ -13690,24 +13850,30 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -13727,7 +13893,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.61", ] [[package]] @@ -13746,14 +13912,14 @@ dependencies = [ "futures-task", "futures-util", "log", - "num-traits 0.2.18", + "num-traits 0.2.19", "once_cell", "parking_lot 0.12.2", "rand 0.8.5", "regex", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.11", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index 740dc2512b..7dd8429cab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,14 @@ members = [ "typegate/engine", "typegate/standalone", "meta-cli", - "typegraph/core", ] + "typegraph/core", +] exclude = [ - "typegate/tests/runtimes/wasm/rust" + "typegate/tests/runtimes/wasm_reflected/rust", + "typegate/tests/runtimes/wasm_wire/rust", + "libs/pyrt_wit_wire", ] - [workspace.package] version = "0.3.7-0" edition = "2021" @@ -33,10 +35,6 @@ env_logger = "=0.10.0" clap = "=4.4.17" clap_complete = "=4.4.7" reqwest = "0.11.20" -# https://github.com/WasmEdge/wasmedge-rust-sdk -wasmedge-sdk = { version = "=0.13.2", features = ["standalone"] } -wasmedge-sys = "=0.17.5" -wasmedge-types = "=0.4.4" # https://github.com/denoland/deno_ast/blob/main/Cargo.toml swc_atoms = "=0.6.5" @@ -60,3 +58,6 @@ indexmap = { version = "2.1.0", features = ["serde"] } tempfile = "3.8.1" regex = "1.10.2" once_cell = "1.18.0" + +wasmtime = "20.0.0" +wasmtime-wasi = "20.0.0" diff --git a/dev/Dockerfile b/dev/Dockerfile index e710694d22..60ca57cbfa 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -39,8 +39,6 @@ RUN set -eux; \ automake \ # wasm-opt deps \ clang \ - ## wasmedge-sys \ - libclang-dev \ ## openssl deps \ pkg-config \ libssl-dev \ @@ -48,12 +46,13 @@ RUN set -eux; \ git \ curl \ # asdf deps \ + zstd \ xz-utils \ unzip \ ; \ apt clean autoclean; apt autoremove --yes; rm -rf /var/lib/{apt,dpkg,cache,log}/; -ARG GHJK_VERSION=423d38e +ARG GHJK_VERSION=2725af8 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 @@ -61,11 +60,6 @@ COPY ghjk.ts . RUN OCI=1 NO_PYTHON=1 ghjk ports sync ENV GHJK_ENV=/root/.local/share/ghjk/env.sh -ARG WASM_OPT_VERSION=0.116.0 -ARG WASM_TOOLS_VERSION=1.0.53 -RUN cargo install wasm-opt@$WASM_OPT_VERSION --locked --debug -RUN cargo install wasm-tools@$WASM_TOOLS_VERSION --locked --debug - COPY --from=plan /app/recipe.json recipe.json RUN . $GHJK_ENV \ @@ -101,8 +95,7 @@ RUN . $GHJK_ENV \ && chmod +x /tini \ && mkdir -p /lib/sym \ && ln -s /lib/aarch64-linux-gnu /lib/sym/arm64 \ - && ln -s /lib/x86_64-linux-gnu /lib/sym/amd64 \ - && cp $(dirname $(realpath $(which wasmedge)))/.. /.wasmedge -r + && ln -s /lib/x86_64-linux-gnu /lib/sym/amd64 # FROM gcr.io/distroless/cc-debian11:${DISTROLESS_TAG} as prd @@ -113,13 +106,11 @@ ARG TARGETARCH ENV NO_COLOR true ENV DENO_DIR /deno-dir/ -ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:/.wasmedge/lib64" WORKDIR /app COPY --from=runtime-bin /tini /tini COPY --from=runtime-bin /lib/sym /lib/sym -COPY --from=runtime-bin /.wasmedge /.wasmedge COPY --from=builder /lib/*-linux-gnu/libz.so* /lib/sym/${TARGETARCH} COPY --from=builder /app/target/release/typegate /bin/typegate diff --git a/dev/Dockerfile.dockerignore b/dev/Dockerfile.dockerignore index 491e0f8ef8..ef004ad9ed 100644 --- a/dev/Dockerfile.dockerignore +++ b/dev/Dockerfile.dockerignore @@ -4,6 +4,7 @@ !dev/update.ts !dev/LICENSE-Elastic-2.0.md !libs/ +!wit/ !meta-cli/Cargo.toml !typegraph/core/ !typegate/engine diff --git a/dev/cross.Dockerfile b/dev/cross.Dockerfile index a7685de9f1..9e869fbeb0 100644 --- a/dev/cross.Dockerfile +++ b/dev/cross.Dockerfile @@ -21,8 +21,6 @@ RUN set -eux \ automake \ # protoc\ libprotoc-dev:$ARCH \ - # wasmedge-sys crate build dep\ - libclang-dev \ # openssl crate build deps \ pkg-config \ libssl-dev:$ARCH \ @@ -35,7 +33,7 @@ RUN set -eux \ xz-utils \ unzip -ARG GHJK_VERSION=423d38e +ARG GHJK_VERSION=2725af8 ENV GHJK_SHARE_DIR=/ghjk 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 diff --git a/dev/lock.yml b/dev/lock.yml index 2ab82dd3e7..77d456ed0e 100644 --- a/dev/lock.yml +++ b/dev/lock.yml @@ -5,8 +5,6 @@ dev: - typegraph/node/LICENSE.md - typegraph/node/sdk/LICENSE.md lines: - installer.sh: - (WASMEDGE_VERSION=").+("): WASMEDGE_VERSION rust-toolchain.toml: (channel = ").+("): RUST_VERSION ghjk.ts: @@ -17,12 +15,12 @@ dev: (const\s+PNPM_VERSION\s*=\s*").*(";): PNPM_VERSION (const\s+WASM_TOOLS_VERSION = ").*(";): WASM_TOOLS_VERSION (const\s+JCO_VERSION =\s*").*(";): JCO_VERSION - (const\s+WASMEDGE_VERSION\s*=\s*").*(";): WASMEDGE_VERSION (const\s+WASM_OPT_VERSION\s*=\s*").*(";): WASM_OPT_VERSION (const\s+MOLD_VERSION\s*=\s*").*(";): MOLD_VERSION (const\s+CMAKE_VERSION\s*=\s*").*(";): CMAKE_VERSION (const\s+CARGO_INSTA_VERSION\s*=\s*").*(";): CARGO_INSTA_VERSION (const\s+TEMPORAL_VERSION\s*=\s*").*(";): TEMPORAL_VERSION + (const\s+WASMTIME_VERSION\s*=\s*").*(";): WASMTIME_VERSION (const\s+METATYPE_VERSION\s*=\s*").*(";): METATYPE_VERSION .github/*/*.yml: '( GHJK_VERSION: ").+(")': GHJK_VERSION @@ -51,14 +49,14 @@ dev: (description = ").+("): TAGLINE '([\w-]+\s*=\s*\{\s*git\s*=\s*"https:\/\/github\.com\/prisma\/prisma-engines"\s*,\s*tag\s*=\s*").+("\s*\})': PRISMA_VERSION '(deno\s*=\s*\{\s*git\s*=\s*"https:\/\/github\.com\/metatypedev\/deno"\s*,\s*branch\s*=\s*"v).+(-embeddable"\s*\})': DENO_VERSION + (wasmtime = ").+("): WASMTIME_VERSION + (wasmtime-wasi = ").+("): WASMTIME_VERSION dev/cross.Dockerfile: (ARG GHJK_VERSION=).*(): GHJK_VERSION dev/Dockerfile: (ARG DENO_VERSION=).*(): DENO_VERSION (ARG RUST_VERSION=).*(): RUST_VERSION (ARG GHJK_VERSION=).*(): GHJK_VERSION - (ARG WASM_OPT_VERSION=).*(): WASM_OPT_VERSION - (ARG WASM_TOOLS_VERSION=).*(): WASM_TOOLS_VERSION typegate/src/typegraph/versions.ts: (const typegraphVersion = ").*(";): TYPEGRAPH_VERSION typegraph/core/src/typegraph.rs: @@ -83,7 +81,7 @@ dev: '(\s*"@typegraph\/sdk"\s*:\s*"npm:@typegraph\/sdk@).+(",?)': METATYPE_VERSION '(\s*"@typegraph\/sdk\/"\s*:\s*"npm:/@typegraph\/sdk@).+(\/",?)': METATYPE_VERSION lock: - GHJK_VERSION: 423d38e + GHJK_VERSION: 2725af8 GHJK_ACTION_VERSION: 2e8bbf084060a18828338a7cdd43fde6feb2a3cc PYTHON_VERSION: 3.8.18 POETRY_VERSION: 1.7.0 @@ -95,8 +93,7 @@ dev: CARGO_INSTA_VERSION: 1.33.0 WASM_TOOLS_VERSION: 1.0.53 JCO_VERSION: 1.0.0 - WASMTIME_VERSION: 18.0.2 - WASMEDGE_VERSION: 0.13.5 + WASMTIME_VERSION: 20.0.0 TYPEGRAPH_VERSION: 0.0.3 PRISMA_VERSION: 5.5.2 METATYPE_VERSION: 0.3.7-0 diff --git a/examples/deploy/deploy.mjs b/examples/deploy/deploy.mjs index 1c6d361918..c88b22aee7 100644 --- a/examples/deploy/deploy.mjs +++ b/examples/deploy/deploy.mjs @@ -22,7 +22,7 @@ const tg = await typegraph({ }, (g) => { const deno = new DenoRuntime(); const python = new PythonRuntime(); - const wasm = new WasmRuntime(); + const wasm = WasmRuntime.reflected("wasi/rust.wasm"); const prisma = new PrismaRuntime("prisma", "POSTGRES"); const pub = Policy.public(); const student = t.struct( @@ -58,14 +58,14 @@ const tg = await typegraph({ { module: "scripts/python/say_hello.py", name: "sayHello", - deps: ["scripts/python/import_.py"] + deps: ["scripts/python/import_.py"], }, ), // Wasm testWasmAdd: wasm.fromWasm( t.struct({ a: t.float(), b: t.float() }), t.integer(), - { wasm: "wasm/rust.wasm", func: "add" } + { wasm: "wasm/rust.wasm", func: "add" }, ), // Prisma createStudent: prisma.create(student), @@ -95,7 +95,7 @@ tgDeploy(tg, { ...artifactsConfig, // dir: "." }, - typegraphPath: "./deploy.mjs" + typegraphPath: "./deploy.mjs", }).then(({ typegate }) => { // console.info(typegate); const selection = typegate?.data?.addTypegraph; diff --git a/examples/deploy/deploy.py b/examples/deploy/deploy.py index 51826b48ea..2d69a2daf1 100644 --- a/examples/deploy/deploy.py +++ b/examples/deploy/deploy.py @@ -18,7 +18,7 @@ def deploy_example_python(g: Graph): deno = DenoRuntime() python = PythonRuntime() - wasm = WasmRuntime() # noqa + wasm = WasmRuntime.reflected("wasi/rust.wasm") prisma = PrismaRuntime("prisma", "POSTGRES") pub = Policy.public() @@ -62,7 +62,6 @@ def deploy_example_python(g: Graph): testWasmAdd=wasm.from_wasm( t.struct({"a": t.float(), "b": t.float()}), t.integer(), - wasm="wasm/rust.wasm", func="add", ), # Prisma diff --git a/ghjk.ts b/ghjk.ts index a5174b4c8f..4f25f8c783 100644 --- a/ghjk.ts +++ b/ghjk.ts @@ -1,7 +1,7 @@ -export { ghjk } from "https://raw.github.com/metatypedev/ghjk/423d38e/mod.ts"; -import * as ghjk from "https://raw.github.com/metatypedev/ghjk/423d38e/mod.ts"; -import { thinInstallConfig } from "https://raw.github.com/metatypedev/ghjk/423d38e/utils/mod.ts"; -import * as ports from "https://raw.github.com/metatypedev/ghjk/423d38e/ports/mod.ts"; +export { ghjk } from "https://raw.github.com/metatypedev/ghjk/2725af8/mod.ts"; +import * as ghjk from "https://raw.github.com/metatypedev/ghjk/2725af8/mod.ts"; +import { thinInstallConfig } from "https://raw.github.com/metatypedev/ghjk/2725af8/utils/mod.ts"; +import * as ports from "https://raw.github.com/metatypedev/ghjk/2725af8/ports/mod.ts"; import { dirname, resolve } from "https://deno.land/std/path/mod.ts"; const PROTOC_VERSION = "v24.1"; @@ -10,7 +10,7 @@ const PYTHON_VERSION = "3.8.18"; const PNPM_VERSION = "v9.0.5"; const WASM_TOOLS_VERSION = "1.0.53"; const JCO_VERSION = "1.0.0"; -const WASMEDGE_VERSION = "0.13.5"; +const WASMTIME_VERSION = "20.0.0"; const WASM_OPT_VERSION = "0.116.0"; const MOLD_VERSION = "v2.4.0"; const CMAKE_VERSION = "3.28.0-rc6"; @@ -23,10 +23,33 @@ const installs = { python: ports.cpy_bs({ version: PYTHON_VERSION, releaseTag: "20240224" }), python_latest: ports.cpy_bs({ releaseTag: "20240224" }), node: ports.node({ version: NODE_VERSION }), + comp_py: ports.pipi({ packageName: "componentize-py" }), + wasm_opt: ports.cargobi({ + crateName: "wasm-opt", + version: WASM_OPT_VERSION, + locked: true, + }), + wasmtime: ports.cargobi({ + crateName: "wasmtime-cli", + version: WASMTIME_VERSION, + locked: true, + }), }; +const allowedPortDeps = [ + ...ghjk.stdDeps(), + ...[installs.python_latest, installs.node].map((fat) => ({ + manifest: fat.port, + defaultInst: thinInstallConfig(fat), + })), +]; +export const secureConfig = ghjk.secureConfig({ allowedPortDeps }); + +const inCi = () => !!Deno.env.get("CI"); +const inOci = () => !!Deno.env.get("OCI"); +const inDev = () => !inCi() && !inOci(); + ghjk.install( - ports.wasmedge({ version: WASMEDGE_VERSION }), ports.protoc({ version: PROTOC_VERSION }), ports.asdf({ pluginRepo: "https://github.com/asdf-community/asdf-cmake", @@ -35,21 +58,16 @@ ghjk.install( }), ports.cargo_binstall(), ports.temporal_cli({ version: TEMPORAL_VERSION }), + installs.wasm_opt, + ports.cargobi({ + crateName: "wasm-tools", + version: WASM_TOOLS_VERSION, + locked: true, + }), ); -if (!Deno.env.has("OCI")) { +if (!inOci()) { ghjk.install( - // FIXME: use cargobi when avail - ports.cargobi({ - crateName: "wasm-opt", - version: WASM_OPT_VERSION, - locked: true, - }), - ports.cargobi({ - crateName: "wasm-tools", - version: WASM_TOOLS_VERSION, - locked: true, - }), // these aren't required by the typegate build process ports.cargobi({ crateName: "cargo-insta", @@ -84,17 +102,18 @@ if (!Deno.env.has("NO_PYTHON")) { version: POETRY_VERSION, })[0], ); - if (!Deno.env.has("OCI")) { + if (!inOci()) { ghjk.install( ports.pipi({ packageName: "pre-commit" })[0], ); } } -if (!Deno.env.has("CI") && !Deno.env.has("OCI")) { +if (inDev()) { ghjk.install( ports.act({}), ports.cargobi({ crateName: "whiz", locked: true }), + installs.comp_py[0], ); } @@ -114,6 +133,29 @@ ghjk.task("clean-deno-lock", { }, }); +ghjk.task("gen-pyrt-bind", { + installs: installs.comp_py, + allowedPortDeps, + async fn({ $ }) { + await $.removeIfExists("./libs/pyrt_wit_wire/wit_wire"); + await $`componentize-py -d ../../wit/wit-wire.wit bindings .` + .cwd("./libs/pyrt_wit_wire"); + }, +}); + +ghjk.task("build-pyrt", { + installs: [...installs.comp_py], + allowedPortDeps, + dependsOn: ["gen-pyrt-bind"], + async fn({ $, argv, env }) { + const wasmOut = env["PYRT_WASM_OUT"] ?? "./target/pyrt.wasm"; + // TODO: support for `world-module` is missing on the `componentize` subcmd + await $`componentize-py -d ./wit/wit-wire.wit componentize -o ${wasmOut} libs.pyrt_wit_wire.main`; + // const target = env["PYRT_TARGET"] ? `--target ${env["PYRT_TARGET"]}` : ""; + // const cwasmOut = env["PYRT_CWASM_OUT"] ?? "./target/pyrt.cwasm"; + // await `wasmtime compile -W component-model ${target} ${wasmOut} -o ${cwasmOut}`; + }, +}); const projectDir = resolve(dirname(new URL(import.meta.url).pathname)); @@ -130,13 +172,3 @@ ghjk.task("dev", { await $`deno run --allow-all ${script} ${args}`; }, }); - -export const secureConfig = ghjk.secureConfig({ - allowedPortDeps: [ - ...ghjk.stdDeps(), - ...[installs.python_latest, installs.node].map((fat) => ({ - manifest: fat.port, - defaultInst: thinInstallConfig(fat), - })), - ], -}); diff --git a/installer.sh b/installer.sh index 877dbb65f3..8f8ccffc4f 100755 --- a/installer.sh +++ b/installer.sh @@ -123,22 +123,3 @@ Or moving the executable to another directory in your PATH: $ sudo mv $EXE /usr/local/bin EOF fi - -WASMEDGE_VERSION="0.13.5" - -cat < "deno", KnownRuntime::GraphQL(_) => "graphql", KnownRuntime::HTTP(_) => "http", - KnownRuntime::PythonWasi(_) => "python_wasi", + KnownRuntime::Python(_) => "python", KnownRuntime::Random(_) => "random", KnownRuntime::Prisma(_) => "prisma", KnownRuntime::PrismaMigration(_) => "prisma_migration", KnownRuntime::S3(_) => "s3", KnownRuntime::Temporal(_) => "temporal", - KnownRuntime::Wasm(_) => "wasm", + KnownRuntime::WasmWire(_) => "wasm_wire", + KnownRuntime::WasmReflected(_) => "wasm_reflected", KnownRuntime::Typegate(_) => "typegate", KnownRuntime::Typegraph(_) => "typegraph", }, diff --git a/libs/common/src/typegraph/runtimes/wasm.rs b/libs/common/src/typegraph/runtimes/wasm.rs index 148c909d9f..737c4d6703 100644 --- a/libs/common/src/typegraph/runtimes/wasm.rs +++ b/libs/common/src/typegraph/runtimes/wasm.rs @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Elastic-2.0 use serde::{Deserialize, Serialize}; +use std::path::PathBuf; #[derive(Serialize, Deserialize, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct WasmMatData { - pub wasm_artifact: String, + pub op_name: String, } #[derive(Serialize, Deserialize, Clone, Debug)] pub struct WasmRuntimeData { - pub config: Option, // placeholder (pre-commit fails on empty interfaces otherwise) + pub wasm_artifact: PathBuf, } diff --git a/libs/metagen/Cargo.toml b/libs/metagen/Cargo.toml index b998f8586e..1bbe90c864 100644 --- a/libs/metagen/Cargo.toml +++ b/libs/metagen/Cargo.toml @@ -16,6 +16,7 @@ garde = { version = "0.18", features = ["derive"] } heck = "0.5.0-rc.1" regex.workspace = true once_cell.workspace = true +pretty_assertions = "1.4.0" # indoc.workspace = true [dev-dependencies] diff --git a/libs/metagen/src/config.rs b/libs/metagen/src/config.rs index 4929f14693..2a9c0e05b6 100644 --- a/libs/metagen/src/config.rs +++ b/libs/metagen/src/config.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MPL-2.0 //! Sample yaml: +//! ```yaml //! generators: # this section only required when we support external generators //! - mdk_rust //! - mdk_ts @@ -14,6 +15,7 @@ //! typegraph: console //! path: ./mats/gen //! annotate_debug: true +//! ``` use crate::interlude::*; #[derive(Deserialize, Debug, Clone)] diff --git a/libs/metagen/src/lib.rs b/libs/metagen/src/lib.rs index ff570bad43..ce7618fcf9 100644 --- a/libs/metagen/src/lib.rs +++ b/libs/metagen/src/lib.rs @@ -14,6 +14,7 @@ mod interlude { pub use anyhow::Context; pub use indexmap::IndexMap; pub use log::{debug, error, info, trace, warn}; + pub use pretty_assertions::assert_str_eq; pub use serde::{Deserialize, Serialize}; #[cfg(test)] pub use tokio::process::Command; @@ -30,18 +31,28 @@ use crate::interlude::*; pub use config::*; +/// This implements a command object pattern API for generator +/// implemntations to access the external world. See [InputResolver]. +/// +/// The rationale being that +/// - Ease of mocking for tests through [InputResolver] implemntaiton. +/// - Ease of translating to wasm API for any future user implemented generators. #[derive(Debug)] pub enum GeneratorInputOrder { TypegraphFromTypegate { name: String }, TypegraphFromPath { path: PathBuf, name: Option }, } +/// Response types for the command object API implemented +/// by [GeneratorInputOrder]. #[derive(Debug)] pub enum GeneratorInputResolved { TypegraphFromTypegate { raw: Typegraph }, TypegraphFromPath { raw: Typegraph }, } +/// This type plays the "dispatcher" role to the command object +/// API implemented by [GeneratorInputOrder] and [GeneratorInputResolved]. pub trait InputResolver { fn resolve( &self, @@ -50,10 +61,22 @@ pub trait InputResolver { } #[derive(Debug)] -pub struct GeneratorOutput(pub HashMap); +pub struct GeneratedFile { + // pub path: PathBuf, + pub contents: String, + pub overwrite: bool, +} + +#[derive(Debug)] +pub struct GeneratorOutput(pub HashMap); +/// The core trait any metagen generator modules will implement. trait Plugin: Send + Sync { + /// A list of inputs required by an implementatoin to do it's job. + /// The [GeneratorInputOrder]s here will be resolved by the + /// host's [InputResolver]. fn bill_of_inputs(&self) -> HashMap; + fn generate( &self, inputs: HashMap, @@ -66,15 +89,16 @@ trait Plugin: Send + Sync { pub async fn generate_target( config: &config::Config, target_name: &str, + workspace_path: PathBuf, resolver: impl InputResolver + Send + Sync + Clone + 'static, -) -> anyhow::Result> { +) -> anyhow::Result { let generators = [ // builtin generators ( "mdk_rust".to_string(), // initialize the impl - &|val| { - let config: mdk_rust::MdkRustGenConfig = serde_json::from_value(val)?; + &|workspace_path: &Path, val| { + let config = mdk_rust::MdkRustGenConfig::from_json(val, workspace_path)?; let generator = mdk_rust::Generator::new(config)?; Ok::<_, anyhow::Error>(Box::new(generator) as Box) }, @@ -96,7 +120,7 @@ pub async fn generate_target( .get(&gen_name[..]) .with_context(|| format!("generator \"{gen_name}\" not found in config"))?; - let gen_impl = get_gen_fn(config)?; + let gen_impl = get_gen_fn(&workspace_path, config)?; let bill = gen_impl.bill_of_inputs(); let mut resolve_set = tokio::task::JoinSet::new(); @@ -132,5 +156,5 @@ pub async fn generate_target( .into_iter() .map(|(path, (_, buf))| (path, buf)) .collect(); - Ok(out) + Ok(GeneratorOutput(out)) } diff --git a/libs/metagen/src/mdk/mdk.wit b/libs/metagen/src/mdk/mdk.wit deleted file mode 100644 index 08030bb7de..0000000000 --- a/libs/metagen/src/mdk/mdk.wit +++ /dev/null @@ -1,42 +0,0 @@ -package metatype:mdk; - -interface shared { - record req { - op-name: string, - in-json: string, - } - - type res = result; -} - -interface typegate-wasi-host { - use shared.{req, res}; - - hostcall: func(req: req) -> res; -} - -interface mat { - use shared.{req, res}; - - handle: func(req: req) -> res; - - record init-args { - } - - record mat-tag { - title: string, - hash: string, - } - - record init-res { - metatype-version: string, - implemented-mats: list - } - - init: func(args: init-args) -> init-res; -} - -world wasi-mat { - import typegate-wasi-host; - export mat; -} diff --git a/libs/metagen/src/mdk_rust/mod.rs b/libs/metagen/src/mdk_rust/mod.rs index 9e272d8ff7..51eb6ff12e 100644 --- a/libs/metagen/src/mdk_rust/mod.rs +++ b/libs/metagen/src/mdk_rust/mod.rs @@ -1,6 +1,15 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 +//! Generates typegraph types and mdk interface for rust. +//! - dir/Cargo.toml +//! - Will not be replaced on second generation. +//! - dir/mdk.rs +//! - Contains generated types and mdk interface. +//! - dir/lib.rs +//! - Some directions to get the user started. +//! - Will not be replaced on second generation. + mod stubs; mod types; mod utils; @@ -10,15 +19,36 @@ use crate::mdk::*; use crate::utils::*; use crate::*; +use std::fmt::Write; + #[derive(Serialize, Deserialize, Debug, garde::Validate)] pub struct MdkRustGenConfig { #[serde(flatten)] #[garde(dive)] pub base: crate::config::MdkGeneratorConfigBase, + /// Runtimes to generate stubbed materializer implenetations for. #[garde(skip)] pub stubbed_runtimes: Option>, + /// Name of the crate to be put in the generated `Cargo.toml` + #[garde(length(min = 1))] + crate_name: Option, #[garde(skip)] - pub no_crate_manifest: Option, + pub skip_cargo_toml: Option, + #[garde(skip)] + pub skip_lib_rs: Option, +} + +impl MdkRustGenConfig { + pub fn from_json(json: serde_json::Value, workspace_path: &Path) -> anyhow::Result { + let mut config: mdk_rust::MdkRustGenConfig = serde_json::from_value(json)?; + config.base.path = workspace_path.join(config.base.path); + config.base.typegraph_path = config + .base + .typegraph_path + .as_ref() + .map(|path| workspace_path.join(path)); + Ok(config) + } } pub struct Generator { @@ -69,16 +99,33 @@ impl crate::Plugin for Generator { }; let mut out = HashMap::new(); out.insert( - self.config.base.path.join("mod.rs"), - gen_mod_rs(&self.config, tg)?, + self.config.base.path.join("mdk.rs"), + GeneratedFile { + contents: gen_mod_rs(&self.config, tg)?, + overwrite: true, + }, ); - if self.config.no_crate_manifest.unwrap_or(true) { + let crate_name = self.config.crate_name.clone().unwrap_or_else(|| { use heck::ToSnekCase; let tg_name = tg.name().unwrap_or_else(|_| "generated".to_string()); - let crate_name = format!("{}_mdk", tg_name.to_snek_case()); + format!("{}_mdk", tg_name.to_snek_case()) + }); + if !matches!(self.config.skip_cargo_toml, Some(true)) { out.insert( self.config.base.path.join("Cargo.toml"), - gen_cargo_toml(Some(&crate_name)), + GeneratedFile { + contents: gen_cargo_toml(Some(&crate_name)), + overwrite: false, + }, + ); + } + if !matches!(self.config.skip_lib_rs, Some(true)) { + out.insert( + self.config.base.path.join("lib.rs"), + GeneratedFile { + contents: gen_lib_rs(), + overwrite: false, + }, ); } Ok(GeneratorOutput(out)) @@ -89,71 +136,154 @@ fn gen_mod_rs(config: &MdkRustGenConfig, tg: &Typegraph) -> anyhow::Result) -> String { - let lib_rs = include_str!("static/Cargo.toml"); - if let Some(crate_name) = crate_name { - const DEF_CRATE_NAME: &str = "metagen_mdk_rust_static"; - lib_rs.replace(DEF_CRATE_NAME, crate_name) - } else { - lib_rs.to_string() + for line in stubs_rs.buf.lines() { + if !line.is_empty() { + writeln!(&mut mod_rs.buf, " {line}")?; + } else { + writeln!(&mut mod_rs.buf)?; + } + } } + writeln!(&mut mod_rs.buf, "}}")?; + Ok(mod_rs.buf) } pub fn gen_static(dest: &mut GenDestBuf) -> anyhow::Result> { - use std::fmt::Write; + let mod_rs = include_str!("static/mdk.rs").to_string(); + let mod_rs = mod_rs.replace("__METATYPE_VERSION__", std::env!("CARGO_PKG_VERSION")); - let mod_rs = include_str!("static/mod.rs"); - let mdk_wit = include_str!("../mdk/mdk.wit"); + let mdk_wit = include_str!("../../../../wit/wit-wire.wit"); writeln!(&mut dest.buf, "// gen-static-start")?; + + let gen_start = "// gen-start\n"; + let wit_start = "// wit-start\n"; write!( &mut dest.buf, "{}", - &mod_rs[..mod_rs.find("//wit-start").unwrap()] + &mod_rs[mod_rs.find(gen_start).unwrap() + gen_start.len()..mod_rs.find(wit_start).unwrap()] )?; + writeln!( &mut dest.buf, r#" - inline: "{mdk_wit}" -"# + inline: "{mdk_wit}""# )?; + + let gen_end = "// gen-end\n"; + let wit_end = "// wit-end\n"; write!( &mut dest.buf, "{}", - &mod_rs[mod_rs.find("//wit-end").unwrap() + "//wit-end".len()..] + &mod_rs[mod_rs.find(wit_end).unwrap() + wit_end.len()..mod_rs.find(gen_end).unwrap()] )?; + writeln!(&mut dest.buf, "// gen-static-end")?; Ok("Ctx".into()) } +pub fn gen_cargo_toml(crate_name: Option<&str>) -> String { + let cargo_toml = include_str!("static/Cargo.toml"); + if let Some(crate_name) = crate_name { + const DEF_CRATE_NAME: &str = "metagen_mdk_rust_static"; + cargo_toml.replace(DEF_CRATE_NAME, crate_name) + } else { + cargo_toml.to_string() + } +} + +pub fn gen_lib_rs() -> String { + r#" +mod mdk; +pub use mdk::*; + +/* +init_mat! { + hook: || { + // initialize global stuff here if you need it + MatBuilder::new() + // register function handlers here + .register_handler(stubs::MyFunc::erased(MyMat)) + } +} + +struct MyMat; + +// FIXME: use actual types from your mdk here +impl stubs::MyFunc for MyMat { + fn handle(&self, input: types::MyFuncIn, _cx: Ctx) -> anyhow::Result { + unimplemented!() + } +} +*/ +"# + .into() +} + #[test] fn mdk_rs_e2e() -> anyhow::Result<()> { use crate::tests::*; @@ -166,13 +296,15 @@ fn mdk_rs_e2e() -> anyhow::Result<()> { [( "mdk_rust".to_string(), serde_json::to_value(mdk_rust::MdkRustGenConfig { - stubbed_runtimes: None, - no_crate_manifest: None, + skip_cargo_toml: None, + skip_lib_rs: Some(true), + stubbed_runtimes: Some(vec!["wasm_wire".into()]), + crate_name: None, base: config::MdkGeneratorConfigBase { typegraph_name: Some(tg_name.into()), typegraph_path: None, // NOTE: root will map to the test's tempdir - path: "./gen/".into(), + path: "./".into(), }, })?, )] @@ -183,7 +315,7 @@ fn mdk_rs_e2e() -> anyhow::Result<()> { .into_iter() .collect(), }; - let out = tokio::runtime::Builder::new_multi_thread() + tokio::runtime::Builder::new_multi_thread() .enable_all() .thread_stack_size(16 * 1024 * 1024) .build()? diff --git a/libs/metagen/src/mdk_rust/static/Cargo.toml b/libs/metagen/src/mdk_rust/static/Cargo.toml index e50c6a70dd..42c3ddd4ed 100644 --- a/libs/metagen/src/mdk_rust/static/Cargo.toml +++ b/libs/metagen/src/mdk_rust/static/Cargo.toml @@ -3,12 +3,11 @@ package.edition = "2021" package.version = "0.0.1" [lib] -path = "mod.rs" +path = "lib.rs" crate-type = ["cdylib", "rlib"] [dependencies] anyhow = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" -# TODO: update typegraph_core bindgen version wit-bindgen = "0.22.0" diff --git a/libs/metagen/src/mdk_rust/static/lib.rs b/libs/metagen/src/mdk_rust/static/lib.rs new file mode 100644 index 0000000000..af7247c9ee --- /dev/null +++ b/libs/metagen/src/mdk_rust/static/lib.rs @@ -0,0 +1,4 @@ +// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. +// SPDX-License-Identifier: MPL-2.0 + +mod mdk; diff --git a/libs/metagen/src/mdk_rust/static/mdk.rs b/libs/metagen/src/mdk_rust/static/mdk.rs new file mode 100644 index 0000000000..5346cda52f --- /dev/null +++ b/libs/metagen/src/mdk_rust/static/mdk.rs @@ -0,0 +1,129 @@ +// no-auto-license-header | @generated (pre-commit doesn't support two headers) +// gen-start +#![allow(unused)] + +pub mod wit { + wit_bindgen::generate!({ + pub_export_macro: true, + // wit-start + // this bit gets replaced by the inline wit string + world: "wit-wire", + path: "../../../../../wit/wit-wire.wit" + // wit-end + }); +} + +use std::cell::RefCell; +use std::collections::HashMap; + +use anyhow::Context; + +use wit::exports::metatype::wit_wire::mat_wire::*; + +pub type HandlerFn = Box Result>; + +pub struct ErasedHandler { + mat_id: String, + mat_trait: String, + mat_title: String, + handler_fn: HandlerFn, +} + +pub struct MatBuilder { + handlers: HashMap, +} + +impl MatBuilder { + pub fn new() -> Self { + Self { + handlers: Default::default(), + } + } + + pub fn register_handler(mut self, handler: ErasedHandler) -> Self { + self.handlers.insert(handler.mat_trait.clone(), handler); + self + } +} + +pub struct Router { + handlers: HashMap, +} + +impl Router { + pub fn from_builder(builder: MatBuilder) -> Self { + Self { + handlers: builder.handlers, + } + } + + pub fn init(&self, args: InitArgs) -> Result { + static MT_VERSION: &str = "0.3.7-0"; + if args.metatype_version != MT_VERSION { + return Err(InitError::VersionMismatch(MT_VERSION.into())); + } + for info in args.expected_ops { + let mat_trait = stubs::op_to_trait_name(&info.op_name); + if !self.handlers.contains_key(mat_trait) { + return Err(InitError::UnexpectedMat(info)); + } + } + Ok(InitResponse { ok: true }) + } + + pub fn handle(&self, req: HandleReq) -> Result { + let mat_trait = stubs::op_to_trait_name(&req.op_name); + let Some(handler) = self.handlers.get(mat_trait) else { + return Err(HandleErr::NoHandler); + }; + let cx = Ctx { + gql: GraphqlClient {}, + }; + (handler.handler_fn)(&req.in_json, cx) + } +} + +pub type InitCallback = fn() -> anyhow::Result; + +thread_local! { + pub static MAT_STATE: RefCell = panic!("MDK_STATE has not been initialized"); +} + +pub struct Ctx { + gql: GraphqlClient, +} + +pub struct GraphqlClient {} + +#[macro_export] +macro_rules! init_mat { + (hook: $init_hook:expr) => { + struct MatWireGuest; + use wit::exports::metatype::wit_wire::mat_wire::*; + wit::export!(MatWireGuest with_types_in wit); + + #[allow(unused)] + impl Guest for MatWireGuest { + fn handle(req: HandleReq) -> Result { + MAT_STATE.with(|router| { + let router = router.borrow(); + router.handle(req) + }) + } + + fn init(args: InitArgs) -> Result { + let hook = $init_hook; + let router = Router::from_builder(hook()); + let resp = router.init(args)?; + MAT_STATE.set(router); + Ok(resp) + } + } + }; +} +// gen-end +mod stubs { + pub fn op_to_trait_name(op_name: &str) -> &'static str { + panic!("unrecognized op_name: {op_name}"); + } +} diff --git a/libs/metagen/src/mdk_rust/static/mod.rs b/libs/metagen/src/mdk_rust/static/mod.rs deleted file mode 100644 index c36a037858..0000000000 --- a/libs/metagen/src/mdk_rust/static/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![allow(unused)] - -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 - -mod wit { - wit_bindgen::generate!({ - //wit-start - // this bit gets replaced by the inline wit string - world: "wasi-mat", - path: "../../mdk/mdk.wit" - //wit-end - }); -} - -use wit::exports::metatype::mdk::mat::*; - -struct Module; - -#[allow(unused)] -impl Guest for Module { - fn handle(req: Req) -> Res { - todo!("do routing and rpc") - } - - fn init(args: InitArgs) -> InitRes { - todo!("do init") - } -} - -wit::export!(Module with_types_in wit); - -pub struct Ctx { - gql: GraphqlClient, -} - -pub struct GraphqlClient {} diff --git a/libs/metagen/src/mdk_rust/stubs.rs b/libs/metagen/src/mdk_rust/stubs.rs index 481f25436f..7f4f5cfc57 100644 --- a/libs/metagen/src/mdk_rust/stubs.rs +++ b/libs/metagen/src/mdk_rust/stubs.rs @@ -11,10 +11,10 @@ pub struct GenStubOptions {} pub fn gen_stub( fun: &StubbedFunction, - dest: &mut GenDestBuf, + mod_stub_traits: &mut GenDestBuf, type_names: &HashMap>, _opts: &GenStubOptions, -) -> anyhow::Result> { +) -> anyhow::Result { let TypeNode::Function { base, data } = &fun.node else { unreachable!() }; @@ -24,16 +24,58 @@ pub fn gen_stub( let out_ty = type_names .get(&data.output) .context("output type for function not found")?; - let trait_name: Arc = normalize_type_title(&base.title).into(); + let trait_name: String = normalize_type_title(&base.title); + let title = &base.title; + // FIXME: use hash or other stable id + let id = title; writeln!( - &mut dest.buf, - r#"pub trait {trait_name} {{ - fn handle(input: {inp_ty}, cx: Ctx) -> anyhow::Result<{out_ty}>; + &mut mod_stub_traits.buf, + r#"pub trait {trait_name}: Sized + 'static {{ + fn erased(self) -> ErasedHandler {{ + ErasedHandler {{ + mat_id: "{id}".into(), + mat_title: "{title}".into(), + mat_trait: "{trait_name}".into(), + handler_fn: Box::new(move |req, cx| {{ + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{{err}}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{{err}}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{{err}}"))) + }}), + }} + }} + + fn handle(&self, input: {inp_ty}, cx: Ctx) -> anyhow::Result<{out_ty}>; }}"# )?; Ok(trait_name) } +pub fn gen_op_to_mat_map( + op_to_trait_map: &HashMap, + dest: &mut GenDestBuf, + _opts: &GenStubOptions, +) -> anyhow::Result<()> { + writeln!( + &mut dest.buf, + r#"pub fn op_to_trait_name(op_name: &str) -> &'static str {{ + match op_name {{"# + )?; + for (op_name, trait_name) in op_to_trait_map { + writeln!(&mut dest.buf, r#" "{op_name}" => "{trait_name}","#,)?; + } + writeln!( + &mut dest.buf, + r#" _ => panic!("unrecognized op_name: {{op_name}}"), + }} +}}"# + )?; + Ok(()) +} + #[cfg(test)] mod test { use super::*; @@ -59,7 +101,7 @@ mod test { materializers: vec![Materializer { name: "function".into(), runtime: 0, - data: Default::default(), + data: serde_json::from_value(serde_json::json!({ "op_name": "my_op" })).unwrap(), effect: Effect { effect: None, idempotent: false, @@ -106,12 +148,14 @@ mod test { }; let generator = Generator::new(MdkRustGenConfig { base: crate::config::MdkGeneratorConfigBase { - path: "/tmp".into(), + path: "/".into(), typegraph_name: Some(tg_name.clone()), typegraph_path: None, }, stubbed_runtimes: Some(vec!["wasm".into()]), - no_crate_manifest: None, + crate_name: None, + skip_lib_rs: None, + skip_cargo_toml: None, })?; let out = generator.generate( [( @@ -124,32 +168,48 @@ mod test { let (_, buf) = out .0 .iter() - .find(|(path, _)| path.file_name().unwrap() == "mod.rs") + .find(|(path, _)| path.file_name().unwrap() == "mdk.rs") .unwrap(); - assert_eq!( + pretty_assertions::assert_eq!( r#"// gen-static-end -pub type MyInt = i64; -pub trait MyFunc { - fn handle(input: MyInt, cx: Ctx) -> anyhow::Result; +use types::*; +pub mod types { + use super::*; + pub type MyInt = i64; +} +use stubs::*; +pub mod stubs { + use super::*; + pub trait MyFunc: Sized + 'static { + fn erased(self) -> ErasedHandler { + ErasedHandler { + mat_id: "my_func".into(), + mat_title: "my_func".into(), + mat_trait: "MyFunc".into(), + handler_fn: Box::new(move |req, cx| { + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{err}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{err}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{err}"))) + }), + } + } + + fn handle(&self, input: MyInt, cx: Ctx) -> anyhow::Result; + } + pub fn op_to_trait_name(op_name: &str) -> &'static str { + match op_name { + "my_op" => "MyFunc", + _ => panic!("unrecognized op_name: {op_name}"), + } + } } "#, - &buf[buf.find("// gen-static-end").unwrap()..] + &buf.contents[buf.contents.find("// gen-static-end").unwrap()..] ); Ok(()) } } - -trait MyT { - fn hey() {} -} -trait MyT2 { - fn you() {} -} - -struct T {} -impl MyT for T { - fn hey() {} -} -impl MyT2 for T { - fn you() {} -} diff --git a/libs/metagen/src/mdk_rust/types.rs b/libs/metagen/src/mdk_rust/types.rs index 5584d098a6..ef8ba8efeb 100644 --- a/libs/metagen/src/mdk_rust/types.rs +++ b/libs/metagen/src/mdk_rust/types.rs @@ -4,6 +4,11 @@ use super::utils::*; use crate::interlude::*; use crate::utils::*; +use common::typegraph::FileTypeData; +use common::typegraph::FloatTypeData; +use common::typegraph::ListTypeData; +use common::typegraph::OptionalTypeData; +use common::typegraph::StringTypeData; use heck::ToPascalCase; use std::fmt::Write; @@ -38,176 +43,292 @@ pub fn gen_type( }; // generate the type name up first - let ty_name = match node { - TypeNode::Function { .. } => "()".to_string(), - TypeNode::Boolean { base, .. } - | TypeNode::Integer { base, .. } - | TypeNode::String { base, .. } - | TypeNode::File { base, .. } - | TypeNode::Any { base, .. } - | TypeNode::Object { base, .. } - | TypeNode::Float { base, .. } - | TypeNode::Optional { base, .. } - | TypeNode::List { base, .. } - | TypeNode::Union { base, .. } - | TypeNode::Either { base, .. } => normalize_type_title(&base.title), - /* TypeNode::Union { base, .. } => { + let (gen_code, ty_name) = match node { + // functions will be absent in our gnerated types + TypeNode::Function { .. } => (false, "()".to_string()), + + // under certain conditionds, we don't want to generate aliases + // for primitive types. this includes + // - types with defualt generated names + // - types with no special semantics + TypeNode::Boolean { base } if base.title.starts_with("boolean_") => { + (false, "bool".to_string()) + } + TypeNode::Integer { + base, + data: + common::typegraph::IntegerTypeData { + minimum: None, + maximum: None, + multiple_of: None, + exclusive_minimum: None, + exclusive_maximum: None, + }, + } if base.title.starts_with("integer_") => (false, "i64".to_string()), + TypeNode::Float { + base, + data: + FloatTypeData { + minimum: None, + maximum: None, + multiple_of: None, + exclusive_minimum: None, + exclusive_maximum: None, + }, + } if base.title.starts_with("float_") => (false, "f64".to_string()), + TypeNode::String { + base, + data: + StringTypeData { + min_length: None, + max_length: None, + format: None, + pattern: None, + }, + } if base.title.starts_with("string_") => (false, "String".to_string()), + TypeNode::File { + base, + data: + FileTypeData { + min_size: None, + max_size: None, + mime_types: None, + }, + } if base.title.starts_with("file_") => (false, "Vec".to_string()), + TypeNode::Optional { + // NOTE: keep this condition + // in sync with similar one + // below + base, + data: + OptionalTypeData { + default_value: None, + .. + }, + } if base.title.starts_with("optional_") => { + // since the type name of Optionl | Vec depends on + // the name of the inner type, we use placeholders at this ploint + (true, normalize_type_title(&format!("&&placeholder{id}%%"))) + } + TypeNode::List { + // NOTE: keep this condition + // in sync with similar one + // below + base, + data: + ListTypeData { + min_items: None, + max_items: None, + .. + }, + } if base.title.starts_with("list_") => { + // since the type name of Optionl | Vec depends on + // the name of the inner type, we use placeholders at this ploint + (true, normalize_type_title(&format!("&&placeholder{id}%%"))) + } + ty => (true, normalize_type_title(&ty.base().title)), + /* + TypeNode::Union { base, .. } => { format!("{}Union", normalize_type_title(&base.title)) } TypeNode::Either { base, .. } => { format!("{}Either", normalize_type_title(&base.title)) } - // since the type name of Optionl | Vec depends on - // the name of the inner type, we use placeholders at this ploint - TypeNode::Optional { .. } | TypeNode::List { .. } => { - normalize_type_title(&format!("Placeholder{id}")) - } */ + */ }; - let ty_name: Arc = ty_name.into(); + let mut ty_name: Arc = ty_name.into(); // insert typename into memo before generation to allow cyclic resolution // if this function is recursively called when generating dependent branches memo.insert(id, ty_name.clone()); - match node { - TypeNode::Function { .. } => {} - TypeNode::Boolean { .. } => { - gen_alias(&mut dest.buf, &ty_name, "bool")?; - } - TypeNode::Float { .. } => { - gen_alias(&mut dest.buf, &ty_name, "f64")?; - } - TypeNode::Integer { .. } => { - gen_alias(&mut dest.buf, &ty_name, "i64")?; - } - TypeNode::String { .. } => { - gen_alias(&mut dest.buf, &ty_name, "String")?; - } - TypeNode::File { .. } => { - gen_alias(&mut dest.buf, &ty_name, "Vec")?; - } - TypeNode::Any { .. } => { - gen_alias(&mut dest.buf, &ty_name, "serde_json::Value")?; - } - TypeNode::Object { data, .. } => { - let props = data - .properties - .iter() - // generate property type sfirst - .map(|(name, &dep_id)| { - let (ty_name, branch_visited_types) = - gen_type(dep_id, nodes, dest, memo, opts, &my_path)?; + if gen_code { + match node { + TypeNode::Function { .. } => unreachable!(), + TypeNode::Boolean { .. } => { + gen_alias(&mut dest.buf, &ty_name, "bool")?; + } + TypeNode::Float { .. } => { + gen_alias(&mut dest.buf, &ty_name, "f64")?; + } + TypeNode::Integer { .. } => { + gen_alias(&mut dest.buf, &ty_name, "i64")?; + } + TypeNode::String { .. } => { + gen_alias(&mut dest.buf, &ty_name, "String")?; + } + TypeNode::File { .. } => { + gen_alias(&mut dest.buf, &ty_name, "Vec")?; + } + TypeNode::Any { .. } => { + gen_alias(&mut dest.buf, &ty_name, "serde_json::Value")?; + } + TypeNode::Object { data, .. } => { + let props = data + .properties + .iter() + // generate property type sfirst + .map(|(name, &dep_id)| { + let (ty_name, branch_visited_types) = + gen_type(dep_id, nodes, dest, memo, opts, &my_path)?; - let ty_name = if data.required.contains(name) { - ty_name.to_string() - } else { - format!("Option<{ty_name}>") - }; + /* let ty_name = if data.required.contains(name) { + ty_name.to_string() + } else { + format!("Option<{ty_name}>") + }; */ - let ty_name = if let Some(true) = - is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) - { - format!("Box<{ty_name}>") - } else { - ty_name - }; - merge_visited_paths_into(branch_visited_types, &mut visited_types); + let ty_name = if let Some(true) = + is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) + { + format!("Box<{ty_name}>") + } else { + ty_name.to_string() + }; + merge_visited_paths_into(branch_visited_types, &mut visited_types); - let normalized_prop_name = normalize_struct_prop_name(name); - let rename_name = if normalized_prop_name.as_str() != name.as_str() { - Some(name.clone()) - } else { - None - }; - Ok::<_, anyhow::Error>((normalized_prop_name, (ty_name, rename_name))) - }) - .collect::, _>>()?; - gen_struct(&mut dest.buf, opts, &ty_name[..], props)?; - } - TypeNode::Union { data, .. } => { - let variants = data - .any_of - .iter() - .map(|&inner| { - let (ty_name, branch_visited_types) = - gen_type(inner, nodes, dest, memo, opts, &my_path)?; - let variant_name = ty_name.to_pascal_case(); - let ty_name = if let Some(true) = - is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) - { - format!("Box<{ty_name}>") - } else { - ty_name.to_string() - }; - merge_visited_paths_into(branch_visited_types, &mut visited_types); - Ok::<_, anyhow::Error>((variant_name, ty_name)) - }) - .collect::, _>>()?; - gen_enum(&mut dest.buf, opts, &ty_name, variants)?; - } - TypeNode::Either { data, .. } => { - let variants = data - .one_of - .iter() - .map(|&inner| { - let (ty_name, branch_visited_types) = - gen_type(inner, nodes, dest, memo, opts, &my_path)?; - let variant_name = ty_name.to_pascal_case(); - let ty_name = if let Some(true) = - is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) - { - format!("Box<{ty_name}>") - } else { - ty_name.to_string() - }; - merge_visited_paths_into(branch_visited_types, &mut visited_types); - Ok::<_, anyhow::Error>((variant_name, ty_name)) - }) - .collect::, _>>()?; - gen_enum(&mut dest.buf, opts, &ty_name, variants)?; - } - TypeNode::Optional { data, .. } => { - // TODO: handle cyclic case where entire cycle is aliases - let (inner_ty_name, inner_visited_types) = - gen_type(data.item, nodes, dest, memo, opts, &my_path)?; - // let optional_ty_name: Arc = format!("{inner_ty_name}Maybe").into(); - let inner_ty_name = if let Some(true) = - is_path_unsized_cyclic(id, &my_path, &inner_visited_types, nodes) - { - format!("Box<{inner_ty_name}>") - } else { - inner_ty_name.to_string() - }; - merge_visited_paths_into(inner_visited_types, &mut visited_types); - gen_alias(&mut dest.buf, &ty_name, &format!("Option<{inner_ty_name}>"))?; - // dest.buf = replace_placeholder_ty_name(&dest.buf, &ty_name, &optional_ty_name); - // memo.insert(id, optional_ty_name.clone()); - // ty_name = optional_ty_name; - } - TypeNode::List { data, .. } => { - // TODO: handle cyclic case where entire cycle is aliases - let (inner_ty_name, inner_visited_types) = - gen_type(data.items, nodes, dest, memo, opts, &my_path)?; - merge_visited_paths_into(inner_visited_types, &mut visited_types); - if let Some(true) = data.unique_items { - // let ty_name = format!("{inner_ty_name}Set"); - gen_alias( - &mut dest.buf, - &ty_name, - &format!("std::collections::HashSet<{inner_ty_name}>"), - )?; - // ty_name - } else { - // let ty_name = format!("{inner_ty_name}List"); - gen_alias(&mut dest.buf, &ty_name, &format!("Vec<{inner_ty_name}>"))?; - // ty_name - }; - // let true_ty_name: Arc = true_ty_name.into(); - // dest.buf = replace_placeholder_ty_name(&dest.buf, &ty_name, &true_ty_name); - // memo.insert(id, true_ty_name.clone()); - // ty_name = true_ty_name; - } - }; + let normalized_prop_name = normalize_struct_prop_name(name); + let rename_name = if normalized_prop_name.as_str() != name.as_str() { + Some(name.clone()) + } else { + None + }; + Ok::<_, anyhow::Error>((normalized_prop_name, (ty_name, rename_name))) + }) + .collect::, _>>()?; + gen_struct(&mut dest.buf, opts, &ty_name[..], props)?; + } + TypeNode::Union { data, .. } => { + let variants = data + .any_of + .iter() + .map(|&inner| { + let (ty_name, branch_visited_types) = + gen_type(inner, nodes, dest, memo, opts, &my_path)?; + let variant_name = ty_name.to_pascal_case(); + let ty_name = if let Some(true) = + is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) + { + format!("Box<{ty_name}>") + } else { + ty_name.to_string() + }; + merge_visited_paths_into(branch_visited_types, &mut visited_types); + Ok::<_, anyhow::Error>((variant_name, ty_name)) + }) + .collect::, _>>()?; + gen_enum(&mut dest.buf, opts, &ty_name, variants)?; + } + TypeNode::Either { data, .. } => { + let variants = data + .one_of + .iter() + .map(|&inner| { + let (ty_name, branch_visited_types) = + gen_type(inner, nodes, dest, memo, opts, &my_path)?; + let variant_name = ty_name.to_pascal_case(); + let ty_name = if let Some(true) = + is_path_unsized_cyclic(id, &my_path, &branch_visited_types, nodes) + { + format!("Box<{ty_name}>") + } else { + ty_name.to_string() + }; + merge_visited_paths_into(branch_visited_types, &mut visited_types); + Ok::<_, anyhow::Error>((variant_name, ty_name)) + }) + .collect::, _>>()?; + gen_enum(&mut dest.buf, opts, &ty_name, variants)?; + } + TypeNode::Optional { + // NOTE: keep this condition + // in sync with similar one above + base, + data: + OptionalTypeData { + default_value: None, + item, + }, + } if base.title.starts_with("optional_") => { + // TODO: handle cyclic case where entire cycle is aliases + let (inner_ty_name, inner_visited_types) = + gen_type(*item, nodes, dest, memo, opts, &my_path)?; + let inner_ty_name = if let Some(true) = + is_path_unsized_cyclic(id, &my_path, &inner_visited_types, nodes) + { + format!("Box<{inner_ty_name}>") + } else { + inner_ty_name.to_string() + }; + merge_visited_paths_into(inner_visited_types, &mut visited_types); + let true_ty_name = format!("Option<{inner_ty_name}>"); + let true_ty_name: Arc = true_ty_name.into(); + dest.buf = replace_placeholder_ty_name(&dest.buf, &ty_name, &true_ty_name); + memo.insert(id, true_ty_name.clone()); + ty_name = true_ty_name; + } + TypeNode::Optional { data, .. } => { + // TODO: handle cyclic case where entire cycle is aliases + let (inner_ty_name, inner_visited_types) = + gen_type(data.item, nodes, dest, memo, opts, &my_path)?; + // let optional_ty_name: Arc = format!("{inner_ty_name}Maybe").into(); + let inner_ty_name = if let Some(true) = + is_path_unsized_cyclic(id, &my_path, &inner_visited_types, nodes) + { + format!("Box<{inner_ty_name}>") + } else { + inner_ty_name.to_string() + }; + merge_visited_paths_into(inner_visited_types, &mut visited_types); + gen_alias(&mut dest.buf, &ty_name, &format!("Option<{inner_ty_name}>"))?; + } + TypeNode::List { + // NOTE: keep this condition + // in sync with similar one above + base, + data: + ListTypeData { + min_items: None, + max_items: None, + unique_items, + items, + }, + } if base.title.starts_with("list_") => { + // TODO: handle cyclic case where entire cycle is aliases + let (inner_ty_name, inner_visited_types) = + gen_type(*items, nodes, dest, memo, opts, &my_path)?; + merge_visited_paths_into(inner_visited_types, &mut visited_types); + let true_ty_name = if let Some(true) = unique_items { + format!("std::collections::HashSet<{inner_ty_name}>") + } else { + format!("Vec<{inner_ty_name}>") + }; + let true_ty_name: Arc = true_ty_name.into(); + dest.buf = replace_placeholder_ty_name(&dest.buf, &ty_name, &true_ty_name); + memo.insert(id, true_ty_name.clone()); + ty_name = true_ty_name; + } + TypeNode::List { data, .. } => { + // TODO: handle cyclic case where entire cycle is aliases + let (inner_ty_name, inner_visited_types) = + gen_type(data.items, nodes, dest, memo, opts, &my_path)?; + merge_visited_paths_into(inner_visited_types, &mut visited_types); + if let Some(true) = data.unique_items { + // let ty_name = format!("{inner_ty_name}Set"); + gen_alias( + &mut dest.buf, + &ty_name, + &format!("std::collections::HashSet<{inner_ty_name}>"), + )?; + // ty_name + } else { + // let ty_name = format!("{inner_ty_name}List"); + gen_alias(&mut dest.buf, &ty_name, &format!("Vec<{inner_ty_name}>"))?; + // ty_name + }; + } + }; + } Ok((ty_name, visited_types)) } @@ -242,7 +363,6 @@ fn is_path_unsized_cyclic( }) } -#[allow(unused)] fn replace_placeholder_ty_name(buf: &str, placeholder: &str, replacement: &str) -> String { buf.replace(placeholder, replacement).replace( &normalize_struct_prop_name(placeholder), @@ -302,6 +422,7 @@ fn gen_enum( variants: Vec<(String, String)>, ) -> std::fmt::Result { gen_derive(dest, opts)?; + writeln!(dest, "#[serde(untagged)]")?; writeln!(dest, "pub enum {ty_name} {{")?; for (var_name, ty_name) in variants.into_iter() { writeln!(dest, " {var_name}({ty_name}),")?; @@ -417,12 +538,12 @@ mod test { properties: [ ("myString".to_string(), 0), ("list".to_string(), 1), - ("optional".to_string(), 0), - ("optionalOptional".to_string(), 3), + ("optional".to_string(), 3), ] .into_iter() .collect(), - required: ["myString", "list"].into_iter().map(Into::into).collect(), + // FIXME: remove required + required: vec![], }, base: TypeNodeBase { title: "my_obj".into(), @@ -462,11 +583,10 @@ pub struct MyObj { #[serde(rename = "myString")] pub my_string: MyStr, pub list: MyStrList, - pub optional: Option, - #[serde(rename = "optionalOptional")] - pub optional_optional: Option, + pub optional: MyStrMaybe, } #[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(untagged)] pub enum MyEither { MyStr(MyStr), MyStrList(MyStrList), @@ -479,6 +599,7 @@ pub enum MyEither { MyObj(MyObj), } #[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(untagged)] pub enum MyUnion { MyStr(MyStr), MyStrList(MyStrList), @@ -493,6 +614,102 @@ pub enum MyUnion { } "#, ), + ( + "alias_avoidance", + vec![ + TypeNode::String { + data: StringTypeData { + format: None, + pattern: None, + min_length: None, + max_length: None, + }, + base: TypeNodeBase { + title: "string_0".into(), + ..default_type_node_base() + }, + }, + TypeNode::List { + data: ListTypeData { + items: 0, + max_items: None, + min_items: None, + unique_items: None, + }, + base: TypeNodeBase { + title: "list_1".into(), + ..default_type_node_base() + }, + }, + TypeNode::List { + data: ListTypeData { + items: 0, + max_items: None, + min_items: None, + unique_items: Some(true), + }, + base: TypeNodeBase { + title: "list_2".into(), + ..default_type_node_base() + }, + }, + TypeNode::Optional { + data: OptionalTypeData { + item: 0, + default_value: None, + }, + base: TypeNodeBase { + title: "optional_3".into(), + ..default_type_node_base() + }, + }, + TypeNode::Integer { + data: IntegerTypeData { + maximum: None, + multiple_of: None, + exclusive_minimum: None, + exclusive_maximum: None, + minimum: None, + }, + base: TypeNodeBase { + title: "integer_4".into(), + ..default_type_node_base() + }, + }, + TypeNode::Float { + data: FloatTypeData { + maximum: None, + multiple_of: None, + exclusive_minimum: None, + exclusive_maximum: None, + minimum: None, + }, + base: TypeNodeBase { + title: "float_5".into(), + ..default_type_node_base() + }, + }, + TypeNode::Boolean { + base: TypeNodeBase { + title: "boolean_6".into(), + ..default_type_node_base() + }, + }, + TypeNode::File { + data: FileTypeData { + min_size: None, + max_size: None, + mime_types: None, + }, + base: TypeNodeBase { + title: "file_7".into(), + ..default_type_node_base() + }, + }, + ], + "Vec", + r#""#, + ), ( "cycles_obj", vec![ @@ -583,6 +800,7 @@ pub struct ObjA { pub obj_b: ObjB, } #[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(untagged)] pub enum CUnion { ObjA(Box), } @@ -629,6 +847,7 @@ pub struct ObjA { pub obj_b: ObjB, } #[derive(Debug, serde::Serialize, serde::Deserialize)] +#[serde(untagged)] pub enum CEither { ObjA(Box), } @@ -649,17 +868,15 @@ pub enum CEither { &[], )?; - assert_eq!( + pretty_assertions::assert_eq!( &gen_name[..], name, "{test_name}: generated unexpected type name" ); - assert_eq!( - dest.buf.as_str(), - out, - "{test_name}: output buffer was not equal for {name}\n{}{}", + pretty_assertions::assert_eq!( dest.buf.as_str(), out, + "{test_name}: output buffer was not equal for {name}", ); } Ok(()) diff --git a/libs/metagen/src/tests/mod.rs b/libs/metagen/src/tests/mod.rs index d5acebda29..d8343cdbb3 100644 --- a/libs/metagen/src/tests/mod.rs +++ b/libs/metagen/src/tests/mod.rs @@ -41,7 +41,7 @@ pub struct E2eTestCase { pub async fn e2e_test(cases: Vec) -> anyhow::Result<()> { // spin_up_typegate for case in cases { - let tmp_dir = tokio::task::spawn_blocking(|| tempfile::tempdir()) + let tmp_dir = tokio::task::spawn_blocking(tempfile::tempdir) .await?? .into_path(); { @@ -60,11 +60,12 @@ pub async fn e2e_test(cases: Vec) -> anyhow::Result<()> { let test_cx = TestCtx { typegraphs: typegraphs.clone(), }; - let files = crate::generate_target(&case.config, &case.target, test_cx).await?; - for (path, buf) in files { + let files = + crate::generate_target(&case.config, &case.target, tmp_dir.clone(), test_cx).await?; + for (path, buf) in files.0 { let path = tmp_dir.join(path); tokio::fs::create_dir_all(path.parent().unwrap()).await?; - tokio::fs::write(path, buf).await?; + tokio::fs::write(path, buf.contents).await?; } // compile (case.build_fn)(BuildArgs { @@ -94,7 +95,7 @@ async fn spin_up_typegate() -> anyhow::Result<(tokio::process::Child, common::no let tg_admin_password = "password"; let typegate = tokio::process::Command::new("cargo") - .args(&["r", "-p", "typegate"]) + .args(["r", "-p", "typegate"]) .envs([ ("LOG_LEVEL".to_string(), "DEBUG".to_string()), ("TG_PORT".to_string(), tg_port.to_string()), diff --git a/libs/metagen/src/utils.rs b/libs/metagen/src/utils.rs index 03821d3c4a..f2664d7f1a 100644 --- a/libs/metagen/src/utils.rs +++ b/libs/metagen/src/utils.rs @@ -5,18 +5,14 @@ use crate::interlude::*; trait GenDest {} +/// A generation destination analogous to a single file. pub struct GenDestBuf { pub buf: String, } impl GenDest for GenDestBuf {} +/// A generation destination analogous to a directory. pub struct GenDestFs { pub files: HashMap, } impl GenDest for GenDestFs {} - -trait Generate { - type Dest: GenDest; - - fn generate(&self, dest: &mut Self::Dest) -> anyhow::Result<()>; -} diff --git a/libs/metagen/tests/mat_rust/lib.rs b/libs/metagen/tests/mat_rust/lib.rs index 6d36d3c11c..cab6d6f8da 100644 --- a/libs/metagen/tests/mat_rust/lib.rs +++ b/libs/metagen/tests/mat_rust/lib.rs @@ -1,9 +1,20 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -use gen_test_mdk::*; +#[rustfmt::skip] +mod mdk; +use mdk::stubs::*; +use mdk::types::*; +use mdk::*; -#[allow(unused)] -fn init() { - println!("im in it"); +init_mat! { + hook: || MatBuilder::new().register_handler(FaasImpl::erased(FaasImpl)) +} + +struct FaasImpl; + +impl MyFaas for FaasImpl { + fn handle(&self, input: MyObj, _cx: Ctx) -> anyhow::Result { + Ok(input) + } } diff --git a/libs/metagen/tests/placeholder b/libs/metagen/tests/placeholder new file mode 100644 index 0000000000..e69de29bb2 diff --git a/libs/metagen/tests/tg.ts b/libs/metagen/tests/tg.ts index 8a6db06dfa..e01bf14d9b 100644 --- a/libs/metagen/tests/tg.ts +++ b/libs/metagen/tests/tg.ts @@ -3,7 +3,7 @@ import { t, typegraph, } from "../../../typegraph/node/sdk/dist/index.js"; -import { RandomRuntime } from "../../../typegraph/node/sdk/dist/runtimes/random.js"; +import { WasmRuntime } from "../../../typegraph/node/sdk/dist/runtimes/wasm.js"; typegraph( { @@ -12,6 +12,8 @@ typegraph( const obj = t.struct({ str: t.string(), int: t.integer(), + float: t.float(), + boolean: t.boolean(), file: t.file(), opt: t.optional(t.string()), either: t.either([ @@ -23,12 +25,16 @@ typegraph( t.struct({ b: t.string() }), ]), list: t.list(t.string()), - }); + }).rename("MyObj"); - const rand_rt = new RandomRuntime({}); + const wasm = WasmRuntime.wire("placeholder"); g.expose( { - random: rand_rt.gen(obj), + my_faas: wasm.handler( + obj, + obj, + { func: "my_faas" }, + ).rename("my_faas"), }, Policy.public(), ); diff --git a/libs/pyrt_wit_wire/main.py b/libs/pyrt_wit_wire/main.py new file mode 100644 index 0000000000..f5b89af528 --- /dev/null +++ b/libs/pyrt_wit_wire/main.py @@ -0,0 +1,179 @@ +import wit_wire.exports + +# NOTE: all imports must be toplevel as constrained by `componentize-py` +# https://github.com/bytecodealliance/componentize-py/issues/23 +# from pyrt.imports.typegate_wire import hostcall +from wit_wire.exports.mat_wire import ( + InitArgs, + InitResponse, + InitError_UnexpectedMat, + InitError_Other, + MatInfo, + HandleReq, + HandleErr_NoHandler, + HandleErr_InJsonErr, + HandleErr_HandlerErr, + Err, +) + +import json +import types +from typing import Callable, Any, Dict +import importlib +import importlib.util +import importlib.abc +import importlib.machinery +import os +import sys +import traceback + +# the `MatWire` class is instantiated for each +# external call. We have to put any persisted +# state here. +handlers = {} + + +class MatWire(wit_wire.exports.MatWire): + def init(self, args: InitArgs): + for op in args.expected_ops: + try: + handlers[op.op_name] = op_to_handler(op) + except Exception as err: + traceback.print_exc() + raise Err(InitError_Other(str(err))) + return InitResponse(ok=True) + + def handle(self, req: HandleReq): + handler = handlers.get(req.op_name) + if handler is None: + print( + f"no handler found for {req.op_name}, registered handlers: {[op for op in handlers]}" + ) + raise Err(HandleErr_NoHandler()) + try: + return handler.handle(req) + except json.JSONDecodeError as err: + traceback.print_exc() + raise Err(HandleErr_InJsonErr(str(err))) + except Exception as err: + traceback.print_exc() + raise Err(HandleErr_HandlerErr(str(err))) + + +class ErasedHandler: + def __init__(self, handler_fn: Callable[[Any], Any]) -> None: + self.handler_fn = handler_fn + + def handle(self, req: HandleReq): + in_parsed = json.loads(req.in_json) + out = self.handler_fn(in_parsed) + return json.dumps(out) + + +def op_to_handler(op: MatInfo) -> ErasedHandler: + data_parsed = json.loads(op.mat_data_json) + if data_parsed["ty"] == "def": + module = types.ModuleType(op.op_name) + exec(data_parsed["source"], module.__dict__) + fn = module.__dict__[data_parsed["func_name"]] + return ErasedHandler(handler_fn=lambda inp: fn(inp)) + elif data_parsed["ty"] == "import_function": + prefix = data_parsed["func_name"] + + modules_raw = data_parsed["sources"] + finder = ThePathFinder( + {os.path.join(prefix, path): modules_raw[path] for path in modules_raw} + ) + sys.meta_path.append(finder) + + module = importlib.import_module( + ThePathFinder.path_to_module( + os.path.join(prefix, data_parsed["root_src_path"]) + ) + ) + return ErasedHandler(handler_fn=getattr(module, data_parsed["func_name"])) + elif data_parsed["ty"] == "lambda": + fn = eval(data_parsed["source"]) + return ErasedHandler(handler_fn=lambda inp: fn(inp)) + else: + raise Err(InitError_UnexpectedMat(op)) + + +class ThePathFinder(importlib.abc.MetaPathFinder): + @staticmethod + def path_to_module(path: str): + return os.path.splitext((os.path.normpath(path)))[0].replace("/", ".") + + def __init__(self, modules: Dict[str, str]): + self._mods_raw = modules + self._pkgs = set() + for path in self._mods_raw: + dirname = os.path.dirname(path) + while dirname != "/" and dirname != "" and dirname != ".": + if dirname not in self._mods_raw: + self._pkgs.add(dirname) + dirname = os.path.dirname(dirname) + self._mod_names = {ThePathFinder.path_to_module(path): path for path in modules} + self._pkg_names = { + ThePathFinder.path_to_module(path): path for path in self._pkgs + } + + # Look for a spec under a certain module name + # https://peps.python.org/pep-0302/ + # https://peps.python.org/pep-0451/ + def find_spec(self, fullname: str, _path, target=None): + if fullname in self._mod_names: + path = self._mod_names[fullname] + # this helper will return a ModuleSpec populating + # its' fields according to methods on the Loader + # note, the loader is ultimately responsible for making + # the module as well. The spec itself is an indirection + # for flexebility purposes + return importlib.util.spec_from_loader( + fullname, + # our fake loader will give out the raw module src + # when asked + FakeFileLoader( + fullname, path, src=self._mods_raw[path], is_package=False + ), + ) + # when one imports foo.bar.keg + # python will ask us for packages foo and bar + # to get to keg. + # incoming artifacts are written around directory + # based packages. this impl doesn't support that + # so we instead return empty files for packages + if fullname in self._pkg_names: + path = self._pkg_names[fullname] + return importlib.util.spec_from_loader( + fullname, FakeFileLoader(fullname, path, src="", is_package=True) + ) + + +# most of the actual Loader impl lives in FileLoader +# and othe parent classes. +# We only need to override enough for our usecases +class FakeFileLoader(importlib.abc.FileLoader): + def __init__( + self, + fullname: str, + path: str, + src: str, + is_package: bool, + ): + self.name = fullname + self.path = path + self._is_pkg = is_package + self._src = src + + def is_package(self, fullname: str): + assert fullname == self.name + return self._is_pkg + + def get_source(self, fullname: str): + assert fullname == self.name + return self._src + + def get_filename(self, name=None): + assert name is not None and name == self.name + return self.path diff --git a/libs/pyrt_wit_wire/pyproject.toml b/libs/pyrt_wit_wire/pyproject.toml new file mode 100644 index 0000000000..bde538bf38 --- /dev/null +++ b/libs/pyrt_wit_wire/pyproject.toml @@ -0,0 +1,13 @@ +[tool.poetry] +name = "pyrt_wit_wire" +version = "0.3.7-0" +description = "Wasm component implementing the PythonRuntime host using wit_wire protocol." +license = "Elastic-2.0" +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.8" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/meta-cli/src/cli/gen.rs b/meta-cli/src/cli/gen.rs index 3891ef875f..4f60ea13b9 100644 --- a/meta-cli/src/cli/gen.rs +++ b/meta-cli/src/cli/gen.rs @@ -108,12 +108,20 @@ impl Action for Gen { } } GeneratorOp::Mdk => { - let files = metagen::generate_target(mgen_conf, &self.gen_target, resolver).await?; + let files = metagen::generate_target( + mgen_conf, + &self.gen_target, + config.path.as_ref().unwrap().parent().unwrap().into(), + resolver, + ) + .await?; let mut set = tokio::task::JoinSet::new(); - for (path, file) in files { + for (path, file) in files.0 { set.spawn(async move { tokio::fs::create_dir_all(path.parent().unwrap()).await?; - tokio::fs::write(path, file).await?; + if file.overwrite || !tokio::fs::try_exists(&path).await? { + tokio::fs::write(path, file.contents).await?; + } Ok::<_, tokio::io::Error>(()) }); } diff --git a/poetry.lock b/poetry.lock index fcc3d8c788..4f48552058 100644 --- a/poetry.lock +++ b/poetry.lock @@ -50,13 +50,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.0" +version = "1.2.1" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, - {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, + {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, + {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, ] [package.extras] @@ -129,6 +129,24 @@ files = [ {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, ] +[[package]] +name = "importlib-resources" +version = "6.4.0" +description = "Read resources from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_resources-6.4.0-py3-none-any.whl", hash = "sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c"}, + {file = "importlib_resources-6.4.0.tar.gz", hash = "sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145"}, +] + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] + [[package]] name = "python-box" version = "7.1.1" @@ -285,7 +303,7 @@ files = [ [[package]] name = "typegraph" version = "0.3.7-0" -description = "Declarative API development platform. Build serverless backends with zero-trust and less code, no matter where and how your (legacy) systems are." +description = "Declarative API development platform. Build backend components with WASM/Typescript/Python, no matter where and how your (legacy) systems are." optional = false python-versions = ">=3.8,<4.0" files = [] @@ -295,7 +313,7 @@ develop = true astunparse = "^1.6.3" python-box = "^7.1.1" typing-extensions = "^4.8.0" -wasmtime = "^18.0.2" +wasmtime = "^20.0.0" [package.source] type = "directory" @@ -314,19 +332,22 @@ files = [ [[package]] name = "wasmtime" -version = "18.0.2" +version = "20.0.0" description = "A WebAssembly runtime powered by Wasmtime" optional = false python-versions = ">=3.8" files = [ - {file = "wasmtime-18.0.2-py3-none-any.whl", hash = "sha256:49625d389ddd766f5416a1723a76a25473df1dbe6ad706902b7bdbfa549ec3df"}, - {file = "wasmtime-18.0.2-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:190f182e51f7f0e5340a7ffeb01519eb759748872a2bb227c6b1c055cbee61ce"}, - {file = "wasmtime-18.0.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:817c780eb506deaabe31cf23c5e9fe9ab9a1815bc0b805d292ec7502c495e10a"}, - {file = "wasmtime-18.0.2-py3-none-manylinux1_x86_64.whl", hash = "sha256:30adbf2fb380aae2d7cfd18c6f14d7633d62a8204caf185b7557b2364533268d"}, - {file = "wasmtime-18.0.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:c43d281df87af4139735aa62950d855499f58f72778b0e7a79488b3b8807d108"}, - {file = "wasmtime-18.0.2-py3-none-win_amd64.whl", hash = "sha256:7ccc88a9ee2bb601dbd1dc065a22af7b2f1a85c39b1aa8ebfb8ea57f78157d35"}, + {file = "wasmtime-20.0.0-py3-none-any.whl", hash = "sha256:6d9806e34c7cebe3d2ff4ba58a0c7db3648d4d952a0b6821aed4c4d966a4b312"}, + {file = "wasmtime-20.0.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:2ae53f5d84f071f42bf7c05da3bfe4a18e0b5ad801931188bff2e5092137213e"}, + {file = "wasmtime-20.0.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3f9ea16cf19039c5dc11d1f9a8f024ebb0d4c6cd1cbb2d0889797326f8ba5c06"}, + {file = "wasmtime-20.0.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:137c92cfde23b9ed18a85d5d1a1bfa844f1322c3bd80bc36c3b5adc3322f4a6e"}, + {file = "wasmtime-20.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:69505f8c1f42815c3784f77df5b3be9f4742ede56299a0f2d7d71083893e855d"}, + {file = "wasmtime-20.0.0-py3-none-win_amd64.whl", hash = "sha256:8ddb958a1b6eed88e56ec4aaae9478c273bed2e4fcd3331f29fda8d9d12def3d"}, ] +[package.dependencies] +importlib-resources = ">=5.10" + [package.extras] testing = ["coverage", "pycparser", "pytest", "pytest-mypy"] @@ -344,6 +365,21 @@ files = [ [package.extras] test = ["pytest (>=6.0.0)", "setuptools (>=65)"] +[[package]] +name = "zipp" +version = "3.18.1" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.8" +files = [ + {file = "zipp-3.18.1-py3-none-any.whl", hash = "sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b"}, + {file = "zipp-3.18.1.tar.gz", hash = "sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] + [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" diff --git a/ruff.toml b/ruff.toml index f419fc5d89..d2c3f01ff8 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1 +1,4 @@ ignore = ["E501"] +exclude = [ + "libs/pyrt_wit_wire/pyrt" +] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000..40a6f9e62d --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +# format_generated_files=false diff --git a/typegate/engine/00_runtime.js b/typegate/engine/00_runtime.js index eff3931230..bdf651fbdb 100644 --- a/typegate/engine/00_runtime.js +++ b/typegate/engine/00_runtime.js @@ -42,18 +42,6 @@ globalThis.Meta = { workflowQuery: getOp("op_temporal_workflow_query"), workflowDescribe: getOp("op_temporal_workflow_describe"), }, - python: { - registerVm: getOp("op_register_virtual_machine"), - unregisterVm: getOp("op_unregister_virtual_machine"), - registerLambda: getOp("op_register_lambda"), - unregisterLambda: getOp("op_unregister_lambda"), - applyLambda: getOp("op_apply_lambda"), - registerDef: getOp("op_register_def"), - unregisterDef: getOp("op_unregister_def"), - applyDef: getOp("op_apply_def"), - registerModule: getOp("op_register_module"), - unregisterModule: getOp("op_unregister_module"), - }, deno: { transformTypescript: getOp("op_deno_transform_typescript"), }, @@ -62,4 +50,9 @@ globalThis.Meta = { typegraphValidate: getOp("op_typegraph_validate"), validatePrismaRuntimeData: getOp("op_validate_prisma_runtime_data"), wasmtimeWit: getOp("op_wasmtime_wit"), + wit_wire: { + init: getOp("op_wit_wire_init"), + destroy: getOp("op_wit_wire_destroy"), + handle: getOp("op_wit_wire_handle"), + }, }; diff --git a/typegate/engine/Cargo.toml b/typegate/engine/Cargo.toml index b529770f20..64eaa4dfed 100644 --- a/typegate/engine/Cargo.toml +++ b/typegate/engine/Cargo.toml @@ -34,19 +34,18 @@ mt_deno.workspace = true common.workspace = true typescript.workspace = true -# remove wasmedge once python runtime has been migrated -wasmedge-sdk.workspace = true -wasmedge-sys.workspace = true -wasmedge-types.workspace = true - -wasmtime = { version = "20.0.0", features = ["component-model"] } +wasmtime = { workspace = true, features = ["component-model"] } +wasmtime-wasi.workspace = true shadow-rs.workspace = true serde.workspace = true regex = "1.10.2" +zstd = "0.13" [dev-dependencies] env_logger.workspace = true [build-dependencies] shadow-rs.workspace = true +wasmtime = { workspace = true, features = ["component-model"] } +zstd = "0.13" diff --git a/typegate/engine/bindings.ts b/typegate/engine/bindings.ts index 3cb2e8233f..33517a0f2e 100644 --- a/typegate/engine/bindings.ts +++ b/typegate/engine/bindings.ts @@ -1,6 +1,21 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -/// + +import type { + ParsedDiff, + PrismaApplyOut, + PrismaCreateOut, + PrismaDeployOut, + PrismaQueryInp, + PrismaRegisterEngineInp, + TemporalRegisterInput, + TemporalWorkflowDescribeInput, + TemporalWorkflowDescribeOutput, + TemporalWorkflowQueryInput, + TemporalWorkflowSignalInput, + TemporalWorkflowStartInput, + WasmInput, +} from "./runtime.js"; export function get_version() { return Meta.version(); @@ -239,118 +254,6 @@ export async function temporal_workflow_query( } } -export type WasiVmInitConfig = { - vm_name: string; - pylib_path: string; - wasi_mod_path: string; - preopens: Array; -}; - -export type WasiVmSetupOut = - | "Ok" - | { - Err: { - message: string; - }; - }; -export type WasiVmUnregisterInp = { - vm_name: string; -}; -export function register_virtual_machine(a0: WasiVmInitConfig): WasiVmSetupOut { - try { - Meta.python.registerVm(a0); - return "Ok"; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} - -export function unregister_virtual_machine( - a0: WasiVmUnregisterInp, -): WasiVmSetupOut { - try { - Meta.python.unregisterVm(a0.vm_name); - return "Ok"; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} - -export type WasiReactorOut = - | { - Ok: { - res: string; - }; - } - | { - Err: { - message: string; - }; - }; -export function register_lambda(a0: PythonRegisterInp): WasiReactorOut { - try { - const res = Meta.python.registerLambda(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function apply_lambda(a0: PythonApplyInp): WasiReactorOut { - try { - const res = Meta.python.applyLambda(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function unregister_lambda(a0: PythonUnregisterInp): WasiReactorOut { - try { - const res = Meta.python.unregisterLambda(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function apply_def(a0: PythonApplyInp): WasiReactorOut { - try { - const res = Meta.python.applyDef(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function register_def(a0: PythonRegisterInp): WasiReactorOut { - try { - const res = Meta.python.registerDef(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function unregister_def(a0: PythonUnregisterInp): WasiReactorOut { - try { - const res = Meta.python.unregisterDef(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function register_module(a0: PythonRegisterInp): WasiReactorOut { - try { - const res = Meta.python.registerModule(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} -export function unregister_module(a0: PythonUnregisterInp): WasiReactorOut { - try { - const res = Meta.python.unregisterModule(a0); - return { Ok: { res } }; - } catch (err) { - return { Err: { message: err.toString() } }; - } -} export type PrismaRegisterEngineOut = | "Ok" | { diff --git a/typegate/engine/build.rs b/typegate/engine/build.rs index dba61fbd72..171873e275 100644 --- a/typegate/engine/build.rs +++ b/typegate/engine/build.rs @@ -1,9 +1,76 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 +use std::path::PathBuf; -fn main() -> shadow_rs::SdResult<()> { - shadow_rs::new() +fn main() -> Result<(), Box> { + shadow_rs::new()?; + + // build and compress the `pyrt_wit_wire` wasm compress + // into OUT_DIR/pyrt.cwasm.zst + + let cwd = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?); + let out_dir = PathBuf::from(std::env::var("OUT_DIR")?); + let target = std::env::var("TARGET")?; + + println!( + "cargo:rerun-if-changed={}/main.py", + cwd.join("../../libs/pyrt_wit_wire") + .canonicalize() + .unwrap() + .to_string_lossy() + ); + println!( + "cargo:rerun-if-changed={}/wit-wire.wit", + cwd.join("../../wit") + .canonicalize() + .unwrap() + .to_string_lossy() + ); + + let wasm_path = out_dir.join("pyrt.wasm"); + // note: we're using ghjk here + // if this proves troubsome, consider moving the + // task impl inline + assert!( + std::process::Command::new("ghjk") + .args(["x", "build-pyrt"]) + .env("PYRT_WASM_OUT", &wasm_path) + .env("PYRT_TARGET", &wasm_path) + .current_dir(cwd.join("../../")) + .spawn()? + .wait()? + .success(), + "error building pyrt" + ); + + let engine = wasmtime::Engine::new( + wasmtime::Config::new() + .cache_config_load_default() + .map_err(|err| format!("error reading system's wasmtime cache config: {err}"))? + .target(&target) + .map_err(|err| format!("error configuring wasmtime for target {target}: {err}"))?, + )?; + // note: compilation here is extra-slow if building under the debug profile + // since wasmtime will also be in the debug profile + // consider upgrading the cranelift crates to opt3 if this proves + // to be an issue. + // At first, I was just using the wasmtime CLI for precomiplation. + // The cli is distrubuted in release mode and did the deed in 3 secs max. + // The engine kept rejecting the checksum from the CLI even on the same + // version (19.0.0). + let comp = wasmtime::component::Component::from_file(&engine, wasm_path)?; + let cwasm = comp.serialize().unwrap(); + + zstd::stream::copy_encode( + &cwasm[..], + std::fs::File::create(out_dir.join("pyrt.cwasm.zst")).unwrap(), + if std::env::var("PROFILE")? == "release" { + 19 + } else { + 1 + }, + )?; + // wasmtime::Component + Ok(()) } diff --git a/typegate/engine/runtime.d.ts b/typegate/engine/runtime.d.ts index 53b61e1dcb..26d3d6d604 100644 --- a/typegate/engine/runtime.d.ts +++ b/typegate/engine/runtime.d.ts @@ -1,6 +1,71 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 +declare global { + const Meta: MetaNS; +} + +type MetaNS = { + version: () => string; + typescriptFormatCode: (source: string) => string; + typegraphValidate: (json: string) => string; + validatePrismaRuntimeData: (obj: any) => void; + wasmtimeWit: (inp: WasmInput) => string; + + prisma: { + registerEngine: ( + inp: PrismaRegisterEngineInp, + ) => Promise; + unregisterEngine: (engine_name: string) => Promise; + query: (inp: PrismaQueryInp) => Promise; + diff: ( + inp: PrismaDiffInp, + ) => Promise<[string, ParsedDiff[]] | undefined | null>; + apply: (inp: PrismaDevInp) => Promise; + deploy: (inp: PrismaDeployInp) => Promise; + create: (inp: PrismaCreateInp) => Promise; + reset: (datasource: string) => Promise; + unpack: (inp: UnpackInp) => void; + archive: (path: string) => string | undefined | null; + }; + + temporal: { + clientRegister: (inp: TemporalRegisterInput) => Promise; + clientUnregister: (client_id: string) => void; + workflowStart: ( + inp: TemporalWorkflowStartInput, + ) => Promise; + workflowSignal: ( + inp: TemporalWorkflowSignalInput, + ) => Promise; + workflowQuery: ( + inp: TemporalWorkflowQueryInput, + ) => Promise>; + workflowDescribe: ( + inp: TemporalWorkflowDescribeInput, + ) => Promise; + }; + + deno: { + transformTypescript: (inp: string) => string; + }; + + wit_wire: { + init: ( + componentPath: string, + instanceId: string, + args: WitWireInitArgs, + ) => Promise; + destroy: ( + instanceId: string, + ) => Promise; + handle: ( + instanceId: string, + args: WitWireReq, + ) => Promise; + }; +}; + interface WasmInput { func: string; wasm: string; @@ -142,63 +207,58 @@ interface ParsedDiff { table: string; diff: TableDiff[]; } -declare namespace Meta { - function version(): string; - function typescriptFormatCode(source: string): string; - function typegraphValidate(json: string): string; - function validatePrismaRuntimeData(obj: any): void; - function wasmtimeWit(inp: WasmInput): string; - namespace prisma { - function registerEngine( - inp: PrismaRegisterEngineInp, - ): Promise; - function unregisterEngine(engine_name: string): Promise; - function query(inp: PrismaQueryInp): Promise; - function diff( - inp: PrismaDiffInp, - ): Promise<[string, ParsedDiff[]] | undefined | null>; - function apply(inp: PrismaDevInp): Promise; - function deploy(inp: PrismaDeployInp): Promise; - function create(inp: PrismaCreateInp): Promise; - function reset(datasource: string): Promise; - function unpack(inp: UnpackInp): void; - function archive(path: string): string | undefined | null; - } +export type WitWireReq = { + op_name: string; + in_json: string; +}; - namespace temporal { - function clientRegister(inp: TemporalRegisterInput): Promise; - function clientUnregister(client_id: string): void; - function workflowStart( - inp: TemporalWorkflowStartInput, - ): Promise; - function workflowSignal( - inp: TemporalWorkflowSignalInput, - ): Promise; - function workflowQuery( - inp: TemporalWorkflowQueryInput, - ): Promise>; - function workflowDescribe( - inp: TemporalWorkflowDescribeInput, - ): Promise; +export type WitWireHandleError = + | { + InstanceNotFound: string; + } + | { + ModuleErr: string; } - namespace python { - function registerVm(inp: WasiVmInitConfig): void; - function unregisterVm(vm_name: string): void; + | { + MatErr: string; + }; - function registerLambda(inp: PythonRegisterInp): string; - function unregisterLambda(inp: PythonUnregisterInp): string; - function applyLambda(inp: PythonApplyInp): string; +export type WitWireMatInfo = { + op_name: string; + mat_title: string; + mat_hash: string; + mat_data_json: string; +}; - function registerDef(inp: PythonRegisterInp): string; - function unregisterDef(inp: PythonUnregisterInp): string; - function applyDef(inp: PythonApplyInp): string; +export type WitWireInitArgs = { + metatype_version: string; + expected_ops: WitWireMatInfo[]; +}; - function registerModule(inp: PythonRegisterInp): string; - function unregisterModule(inp: PythonUnregisterInp): string; +export type WitWireInitResponse = object; +export type WitWireInitError = + | { + VersionMismatch: string; + } + | { + UnexpectedMat: string; } + | { + ModuleErr: string; + } + | { + Other: string; + }; - namespace deno { - function transformTypescript(inp: string): string; +export type WitWireHandleResponse = + | { + Ok: string; } -} + | "NoHandler" + | { + InJsonErr: string; + } + | { + HandlerErr: string; + }; diff --git a/typegate/engine/runtime.js b/typegate/engine/runtime.js new file mode 100644 index 0000000000..c7d977e3b5 --- /dev/null +++ b/typegate/engine/runtime.js @@ -0,0 +1,9 @@ +/// + +//! This file provides the import point for types and values defined in: +// - ./00_runtime.js: which is preloaded by the custom deno runtime +// - ./runtime.d.ts: which types the objects from the preload +// +// The preload directly adds the Meta object the global scope but we can hide +// that implementation detail and users will "import" `Meta` from this file instead. +// Or at least that is what will appear to be happening to in the type system. diff --git a/typegate/engine/src/ext.rs b/typegate/engine/src/ext.rs index 34d82a4fc3..270c736c3f 100644 --- a/typegate/engine/src/ext.rs +++ b/typegate/engine/src/ext.rs @@ -3,7 +3,7 @@ use crate::interlude::*; use crate::{ - runtimes::{deno_rt, prisma, python::python_bindings, temporal, wasm}, + runtimes::{deno_rt, prisma, temporal, wasm, wit_wire}, typegraph, typescript, }; @@ -30,16 +30,6 @@ deno_core::extension!( temporal::op_temporal_workflow_query, temporal::op_temporal_workflow_signal, temporal::op_temporal_workflow_describe, - python_bindings::op_register_virtual_machine, - python_bindings::op_unregister_virtual_machine, - python_bindings::op_register_lambda, - python_bindings::op_unregister_lambda, - python_bindings::op_apply_lambda, - python_bindings::op_register_def, - python_bindings::op_unregister_def, - python_bindings::op_apply_def, - python_bindings::op_register_module, - python_bindings::op_unregister_module, prisma::op_prisma_register_engine, prisma::op_prisma_unregister_engine, prisma::op_prisma_query, @@ -50,7 +40,10 @@ deno_core::extension!( prisma::op_prisma_reset, prisma::op_unpack, prisma::op_archive, - deno_rt::op_deno_transform_typescript + deno_rt::op_deno_transform_typescript, + wit_wire::op_wit_wire_init, + wit_wire::op_wit_wire_handle, + wit_wire::op_wit_wire_destroy, ], // esm_entry_point = "ext:tg_metatype_ext/00_runtime.js", // esm = ["00_runtime.js"], diff --git a/typegate/engine/src/lib.rs b/typegate/engine/src/lib.rs index 0b31cafe0c..723205387a 100644 --- a/typegate/engine/src/lib.rs +++ b/typegate/engine/src/lib.rs @@ -74,8 +74,20 @@ impl OpDepInjector { #[cfg(test)] state.put(ext::tests::TestCtx { val: 10 }); state.put(runtimes::temporal::Ctx::default()); - state.put(runtimes::python::python_bindings::Ctx::default()); - state.put(runtimes::prisma::Ctx::new(self.tmp_dir.unwrap())); + let engine = wasmtime::Engine::new( + wasmtime::Config::new() + .async_support(true) + .cache_config_load_default() + .context("error reading system's wasmtime cache config") + .unwrap(), + ) + .expect("invalid wasmtime engine config"); + let tmp_dir = self.tmp_dir.unwrap(); + state.put( + runtimes::wit_wire::Ctx::new(engine, tmp_dir.join("wit_wire_workdir")) + .expect("error initializing wit_wire state"), + ); + state.put(runtimes::prisma::Ctx::new(tmp_dir)); } } diff --git a/typegate/engine/src/runtimes.rs b/typegate/engine/src/runtimes.rs index bd263c7929..1003e9e6c4 100644 --- a/typegate/engine/src/runtimes.rs +++ b/typegate/engine/src/runtimes.rs @@ -3,6 +3,6 @@ pub mod deno_rt; pub mod prisma; -pub mod python; pub mod temporal; pub mod wasm; +pub mod wit_wire; diff --git a/typegate/engine/src/runtimes/prisma/engine_import.rs b/typegate/engine/src/runtimes/prisma/engine_import.rs index 7a563c9d19..1e014b2ef9 100644 --- a/typegate/engine/src/runtimes/prisma/engine_import.rs +++ b/typegate/engine/src/runtimes/prisma/engine_import.rs @@ -1,4 +1,4 @@ -// no-auto-license-header +// no-auto-license-header | @generated (pre-commit doesn't support two headers) // Copyright 2019 Prisma Data, Inc. // Modifications copyright Metatype OÜ diff --git a/typegate/engine/src/runtimes/python.rs b/typegate/engine/src/runtimes/python.rs deleted file mode 100644 index 8d4c3a7df9..0000000000 --- a/typegate/engine/src/runtimes/python.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -pub mod python_bindings; -pub mod wasi_vm; diff --git a/typegate/engine/src/runtimes/python/python_bindings.rs b/typegate/engine/src/runtimes/python/python_bindings.rs deleted file mode 100644 index 335d529771..0000000000 --- a/typegate/engine/src/runtimes/python/python_bindings.rs +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -use crate::interlude::*; - -use dashmap::{mapref::one::Ref, DashMap}; -#[rustfmt::skip] -use deno_core as deno_core; // necessary for re-exported macros to work - -use std::path::PathBuf; -use wasmedge_sdk::dock::{Param, VmDock}; -use wasmedge_sdk::{params, Vm}; - -use super::wasi_vm; - -#[derive(Default)] -pub struct Ctx { - vms: DashMap, -} - -impl Ctx { - fn get_virtual_machine(&self, name: String) -> Result> { - match self.vms.get(&name) { - Some(vm) => Ok(vm), - None => Err(anyhow::format_err!("vm not initialized")), - } - } -} - -#[derive(Deserialize)] -#[serde(crate = "serde")] -pub struct WasiVmInitConfig { - vm_name: String, - pylib_path: String, - wasi_mod_path: String, - preopens: Vec, -} - -#[deno_core::op2] -pub fn op_register_virtual_machine( - #[state] ctx: &mut Ctx, - #[serde] config: WasiVmInitConfig, -) -> Result<()> { - if ctx.vms.get(&config.vm_name).is_none() { - let vm = wasi_vm::init_reactor_vm( - config.preopens, - PathBuf::from(config.pylib_path), - PathBuf::from(config.wasi_mod_path), - )?; - - vm.run_func(None, "init_python", params!())?; - - ctx.vms.insert(config.vm_name, vm); - } - Ok(()) -} - -#[deno_core::op2(fast)] -pub fn op_unregister_virtual_machine( - #[state] ctx: &mut Ctx, - #[string] vm_name: &str, -) -> Result<()> { - match ctx.vms.remove(vm_name) { - Some(_) => Ok(()), - None => anyhow::bail!( - "Could not remove virtual machine {:?}: entry not found", - vm_name - ), - } -} - -#[derive(Deserialize, Debug)] -#[serde(crate = "serde")] -pub struct PythonRegisterInp { - vm: String, - name: String, - code: String, -} - -#[derive(Deserialize, Debug)] -#[serde(crate = "serde")] -pub struct PythonUnregisterInp { - vm: String, - name: String, -} - -#[derive(Deserialize, Debug)] -#[serde(crate = "serde")] -pub struct PythonApplyInp { - vm: String, - id: i32, - name: String, - /// stringified json array - args: String, -} - -fn run_wasi_func(vm: &Vm, fn_name: String, args: Vec) -> Result { - let vm_dock = VmDock::new(vm.to_owned()); - match vm_dock.run_func(fn_name, args) { - Ok(ret) => { - let ret = ret.unwrap().pop().unwrap().downcast::().unwrap(); - Ok(ret.as_ref().to_owned()) - } - Err(e) => anyhow::bail!(e), - } -} - -fn register_entity(ctx: &Ctx, wasi_fn_callee: String, entity: PythonRegisterInp) -> Result { - let vm = ctx.get_virtual_machine(entity.vm)?; - let args = vec![Param::String(&entity.name), Param::String(&entity.code)]; - run_wasi_func(&vm, wasi_fn_callee, args) -} - -fn unregister_entity( - ctx: &Ctx, - wasi_fn_callee: String, - entity: PythonUnregisterInp, -) -> Result { - let vm = ctx.get_virtual_machine(entity.vm)?; - let args = vec![Param::String(&entity.name)]; - run_wasi_func(&vm, wasi_fn_callee, args) -} - -fn apply_entity(ctx: &Ctx, wasi_fn_callee: String, entity: PythonApplyInp) -> Result { - let vm = ctx.get_virtual_machine(entity.vm)?; - let args = vec![ - Param::I32(entity.id), - Param::String(&entity.name), - Param::String(&entity.args), - ]; - run_wasi_func(&vm, wasi_fn_callee, args) -} - -// deno bindings - -// lambda - -#[deno_core::op2] -#[string] -pub fn op_register_lambda( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonRegisterInp, -) -> Result { - register_entity(ctx, "register_lambda".to_string(), entity) -} - -#[deno_core::op2] -#[string] -pub fn op_unregister_lambda( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonUnregisterInp, -) -> Result { - unregister_entity(ctx, "unregister_lambda".to_string(), entity) -} - -#[deno_core::op2] -#[string] -pub fn op_apply_lambda(#[state] ctx: &mut Ctx, #[serde] entity: PythonApplyInp) -> Result { - apply_entity(ctx, "apply_lambda".to_string(), entity) -} - -// defun - -#[deno_core::op2] -#[string] -pub fn op_register_def( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonRegisterInp, -) -> Result { - register_entity(ctx, "register_def".to_string(), entity) -} - -#[deno_core::op2] -#[string] -pub fn op_unregister_def( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonUnregisterInp, -) -> Result { - unregister_entity(ctx, "unregister_def".to_string(), entity) -} - -#[deno_core::op2] -#[string] -pub fn op_apply_def(#[state] ctx: &mut Ctx, #[serde] entity: PythonApplyInp) -> Result { - apply_entity(ctx, "apply_def".to_string(), entity) -} - -// module - -#[deno_core::op2] -#[string] -pub fn op_register_module( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonRegisterInp, -) -> Result { - register_entity(ctx, "register_module".to_string(), entity) -} - -#[deno_core::op2] -#[string] -pub fn op_unregister_module( - #[state] ctx: &mut Ctx, - #[serde] entity: PythonUnregisterInp, -) -> Result { - unregister_entity(ctx, "unregister_module".to_string(), entity) -} diff --git a/typegate/engine/src/runtimes/python/wasi_vm.rs b/typegate/engine/src/runtimes/python/wasi_vm.rs deleted file mode 100644 index 245ea613a6..0000000000 --- a/typegate/engine/src/runtimes/python/wasi_vm.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -use anyhow::bail; -use once_cell::sync::OnceCell; -use std::path::PathBuf; -use wasmedge_sdk::{ - config::{CommonConfigOptions, ConfigBuilder, HostRegistrationConfigOptions}, - error::HostFuncError, - host_function, params, Caller, ImportObject, ImportObjectBuilder, Module, NeverType, Vm, - VmBuilder, WasmValue, -}; - -#[host_function] -pub fn callback(_caller: Caller, _args: Vec) -> Result, HostFuncError> { - // println!("[host] callback"); - Ok(vec![]) -} - -static IMPORTS: OnceCell> = OnceCell::new(); - -pub fn get_or_init_imports() -> anyhow::Result<&'static ImportObject> { - let import = ImportObjectBuilder::new() - .with_func::<(i32, i32), (), NeverType>("callback", callback, None)? - .build::("host", None)?; - Ok(IMPORTS.get_or_init(|| import)) -} - -pub fn init_reactor_vm( - inp_preopens: Vec, - pythonlib_path: PathBuf, - wasi_mod_path: PathBuf, -) -> anyhow::Result { - // start config - let common_options = CommonConfigOptions::default().threads(true); - let host_options = HostRegistrationConfigOptions::default().wasi(true); - let config = ConfigBuilder::new(common_options) - .with_host_registration_config(host_options) - .build()?; - // end config - - // [!] module order matters - let mut vm = VmBuilder::new().with_config(config).build()?; - - // FIXME: - // https://github.com/WasmEdge/WasmEdge/issues/3085 - // locally scoped import ref that uses the host function - // makes some bindings call segfault with exit code 11 - // Note: in version 0.8.1, register_import_module - // only required my_import vs &my_import (current) - - // Current solution: make a global ref - vm.register_import_module(get_or_init_imports()?)?; - - // load wasm module - let module = Module::from_file(None, wasi_mod_path)?; - let mut vm = vm.register_module(None, module)?; - - let wasi_module = vm.wasi_module_mut().unwrap(); - - // prepare preopens - let mut preopens = vec![format!( - "/usr/local/lib:{}:readonly", - pythonlib_path.display() - )]; - preopens.extend(inp_preopens); - let preopens = preopens.iter().map(|s| s.as_ref()).collect(); - wasi_module.initialize(None, None, Some(preopens)); - - let exit_code = wasi_module.exit_code(); - if exit_code != 0 { - bail!( - "wasi_module.initialize failed and returned exit code: {:?}", - exit_code - ) - } - - // if wasi-vfs is not used, initialize the reactor as not done automatically - let _init = vm.run_func(None, "_initialize", params!())?; - Ok(vm) -} diff --git a/typegate/engine/src/runtimes/wasm.rs b/typegate/engine/src/runtimes/wasm.rs index a9be67ad2d..6da88b34c7 100644 --- a/typegate/engine/src/runtimes/wasm.rs +++ b/typegate/engine/src/runtimes/wasm.rs @@ -35,6 +35,7 @@ pub fn op_wasmtime_wit(#[serde] input: WasmInput) -> Result { .map(|v| serde_json::from_str::(v).unwrap()) .collect(); + // TODO: share with wit_wire let engine = wasmtime::Engine::default(); let mut store = wasmtime::Store::new(&engine, ()); diff --git a/typegate/engine/src/runtimes/wit_wire.rs b/typegate/engine/src/runtimes/wit_wire.rs new file mode 100644 index 0000000000..d3d1776bcd --- /dev/null +++ b/typegate/engine/src/runtimes/wit_wire.rs @@ -0,0 +1,352 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +use crate::interlude::*; +use dashmap::DashMap; +#[rustfmt::skip] +use deno_core as deno_core; // necessary for re-exported macros to work +use deno_core::OpState; +use wasmtime::component::{Component, Linker}; +use wit::exports::metatype::wit_wire::mat_wire::{InitArgs, InitError, MatInfo}; +use wit::metatype::wit_wire::typegate_wire::Host; + +use self::wit::exports::metatype::wit_wire::mat_wire::{HandleErr, HandleReq}; + +mod wit { + wasmtime::component::bindgen!({ + world: "wit-wire", + path: "../../wit/", + async: true, + }); +} + +#[derive(Clone)] +pub struct Ctx { + engine: wasmtime::Engine, + instances: Arc>, + instance_workdir: PathBuf, + linker: Linker, + cached_components: DashMap, +} + +impl Ctx { + pub fn new(engine: wasmtime::Engine, instance_workdir: PathBuf) -> anyhow::Result { + Ok(Self { + instances: Default::default(), + instance_workdir, + cached_components: Default::default(), + linker: { + let mut linker = Linker::::new(&engine); + + wasmtime_wasi::add_to_linker_async(&mut linker)?; + wit::WitWire::add_to_linker(&mut linker, |state| &mut state.tg_host)?; + + linker + }, + engine, + }) + } + + async fn get_component(&self, wasm_relative_path: String) -> Result { + let engine = self.engine.clone(); + let comp = if wasm_relative_path == "inline://pyrt_wit_wire.cwasm" { + // we only manually cache inline components since they'll never change + if let Some(comp) = self.cached_components.get(&wasm_relative_path) { + return Ok(comp.clone()); + } + let cwasm_zst_bytes = include_bytes!(concat!(env!("OUT_DIR"), "/pyrt.cwasm.zst")); + let comp = tokio::task::spawn_blocking(move || unsafe { + let mut cwasm_bytes = vec![]; + zstd::stream::copy_decode(&cwasm_zst_bytes[..], &mut cwasm_bytes) + .map_err(|err| format!("error decompressing serialized component: {err}"))?; + Component::deserialize(&engine, cwasm_bytes) + .map_err(|err| format!("error loading pyrt serialized component: {err}")) + }) + .await + .map_err(|err| format!("tokio error loading serialized component: {err}"))??; + self.cached_components + .insert(wasm_relative_path, comp.clone()); + comp + } else { + // for user provided components, we let wasmtime take care + // of the caching + let wasm_absolute_path = match std::env::current_dir() { + Ok(cwd) => cwd.join(&wasm_relative_path), + Err(err) => return Err(format!("error trying to find cwd: {err}")), + }; + let raw = tokio::fs::read(&wasm_absolute_path).await.map_err(|err| { + format!("error loading serialized component from {wasm_relative_path}: {err}") + })?; + tokio::task::spawn_blocking(move || Component::from_binary(&engine, &raw[..])) + .await + .map_err(|err| format!("tokio error loading component: {err}"))? + .map_err(|err| format!("error loading component: {err}"))? + }; + Ok(comp) + } +} + +struct Instance { + bindings: wit::WitWire, + _instance: wasmtime::component::Instance, + store: wasmtime::Store, + preopen_dir: PathBuf, +} + +struct InstanceState { + table: wasmtime_wasi::ResourceTable, + ctx: wasmtime_wasi::WasiCtx, + tg_host: TypegateHost, +} + +impl InstanceState { + fn new(preopen_dir: impl AsRef, tg_host: TypegateHost) -> Self { + let preopen_dir = preopen_dir.as_ref(); + Self { + ctx: wasmtime_wasi::WasiCtxBuilder::new() + .allow_ip_name_lookup(true) + .preopened_dir( + preopen_dir, + ".", + wasmtime_wasi::DirPerms::all(), + wasmtime_wasi::FilePerms::all(), + ) + .with_context(|| format!("error preopening dir for instance at {preopen_dir:?}")) + .unwrap() + // TODO: stream stdio to debug log + .inherit_stdio() + .build(), + table: Default::default(), + tg_host, + } + } +} + +impl wasmtime_wasi::WasiView for InstanceState { + fn table(&mut self) -> &mut wasmtime_wasi::ResourceTable { + &mut self.table + } + + fn ctx(&mut self) -> &mut wasmtime_wasi::WasiCtx { + &mut self.ctx + } +} +#[derive(Deserialize)] +#[serde(crate = "serde")] +pub struct WitWireInitArgs { + metatype_version: String, + expected_ops: Vec, +} +struct TypegateHost {} + +#[wasmtime_wasi::async_trait] +impl Host for TypegateHost { + async fn hostcall( + &mut self, + _req: (String, String), + ) -> wasmtime::Result> { + todo!() + } +} + +impl From for InitArgs { + fn from(value: WitWireInitArgs) -> Self { + InitArgs { + metatype_version: value.metatype_version, + expected_ops: value.expected_ops.into_iter().map(Into::into).collect(), + } + } +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(crate = "serde")] +pub struct WitWireMatInfo { + op_name: String, + mat_title: String, + mat_hash: String, + mat_data_json: String, +} + +impl From for WitWireMatInfo { + fn from(value: MatInfo) -> Self { + WitWireMatInfo { + op_name: value.op_name, + mat_title: value.mat_title, + mat_hash: value.mat_hash, + mat_data_json: value.mat_data_json, + } + } +} + +impl From for MatInfo { + fn from(value: WitWireMatInfo) -> Self { + MatInfo { + op_name: value.op_name, + mat_title: value.mat_title, + mat_hash: value.mat_hash, + mat_data_json: value.mat_data_json, + } + } +} + +#[derive(Serialize)] +#[serde(crate = "serde")] +pub struct WitWireInitResponse {} + +#[derive(Serialize, Debug, thiserror::Error)] +#[serde(crate = "serde")] +pub enum WitWireInitError { + #[error("metatype version mismatch: {0:?}")] + VersionMismatch(String), + #[error("unexpected mat info: {0:?}")] + UnexpectedMat(WitWireMatInfo), + #[error("unexpected error: {0:?}")] + Other(String), + #[error("wasm module error: {0:?}")] + ModuleErr(String), +} + +impl From for WitWireInitError { + fn from(value: InitError) -> Self { + match value { + InitError::VersionMismatch(ver) => Self::VersionMismatch(ver), + InitError::UnexpectedMat(info) => Self::UnexpectedMat(info.into()), + InitError::Other(msg) => Self::Other(msg), + } + } +} + +#[deno_core::op2(async)] +#[serde] +pub async fn op_wit_wire_init( + state: Rc>, + #[string] component_path: String, + #[string] instance_id: String, + #[serde] input: WitWireInitArgs, +) -> Result { + let ctx = { + let state = state.borrow(); + let ctx = state.borrow::(); + ctx.clone() + }; + + let component = ctx + .get_component(component_path) + .await + .map_err(WitWireInitError::ModuleErr)?; + + let work_dir = ctx.instance_workdir.join(&instance_id); + tokio::fs::create_dir_all(&work_dir).await.unwrap(); + let mut store = + wasmtime::Store::new(&ctx.engine, InstanceState::new(&work_dir, TypegateHost {})); + let (bindings, instance) = wit::WitWire::instantiate_async(&mut store, &component, &ctx.linker) + .await + .map_err(|err| { + WitWireInitError::ModuleErr(format!("error tring to make component instance: {err}")) + })?; + let guest = bindings.metatype_wit_wire_mat_wire(); + let args = input.into(); + let res = guest.call_init(&mut store, &args).await.map_err(|err| { + WitWireInitError::ModuleErr(format!("module error calling init: {err}")) + })??; // <- note second try for the wit err. we have an into impl above + assert!(res.ok); + ctx.instances.insert( + instance_id, + Instance { + _instance: instance, + bindings, + store, + preopen_dir: work_dir, + }, + ); + Ok(WitWireInitResponse {}) +} + +#[deno_core::op2(async)] +pub async fn op_wit_wire_destroy(state: Rc>, #[string] instance_id: String) { + let ctx = { + let state = state.borrow(); + let ctx = state.borrow::(); + ctx.clone() + }; + + let Some((_id, instance)) = ctx.instances.remove(&instance_id) else { + return; + }; + if let Err(err) = tokio::fs::remove_dir_all(&instance.preopen_dir).await { + error!( + "error removing preopend dir for instance {_id} at {:?}: {err}", + instance.preopen_dir + ) + } +} + +#[derive(Deserialize)] +#[serde(crate = "serde")] +pub struct WitWireReq { + op_name: String, + in_json: String, +} + +impl From for HandleReq { + fn from(value: WitWireReq) -> Self { + Self { + op_name: value.op_name, + in_json: value.in_json, + } + } +} + +#[derive(Serialize, Debug, thiserror::Error)] +#[serde(crate = "serde")] +pub enum WitWireHandleError { + #[error("instance not found under id {id}")] + InstanceNotFound { id: String }, + #[error("wasm module error: {0:?}")] + ModuleErr(String), +} + +#[derive(Serialize)] +#[serde(crate = "serde")] +pub enum HandleRes { + Ok(String), + NoHandler, + InJsonErr(String), + HandlerErr(String), +} + +#[deno_core::op2(async)] +#[serde] +pub async fn op_wit_wire_handle( + state: Rc>, + #[string] instance_id: String, + #[serde] input: WitWireReq, +) -> Result { + let ctx = { + let state = state.borrow(); + let ctx = state.borrow::(); + ctx.clone() + }; + + let mut instance = ctx + .instances + .get_mut(&instance_id) + .ok_or(WitWireHandleError::InstanceNotFound { id: instance_id })?; + // reborrow https://bevy-cheatbook.github.io/pitfalls/split-borrows.html + let instance = &mut *instance; + let guest = instance.bindings.metatype_wit_wire_mat_wire(); + let res = guest + .call_handle(&mut instance.store, &input.into()) + .await + .map_err(|err| { + WitWireHandleError::ModuleErr(format!("module error calling handle: {err}")) + })?; + Ok(match res { + Ok(json) => HandleRes::Ok(json), + Err(err) => match err { + HandleErr::NoHandler => HandleRes::NoHandler, + HandleErr::InJsonErr(msg) => HandleRes::InJsonErr(msg), + HandleErr::HandlerErr(msg) => HandleRes::HandlerErr(msg), + }, + }) +} diff --git a/typegate/src/engine/planner/mod.ts b/typegate/src/engine/planner/mod.ts index be5a39768a..2dd234a274 100644 --- a/typegate/src/engine/planner/mod.ts +++ b/typegate/src/engine/planner/mod.ts @@ -134,15 +134,17 @@ export class Planner { this.verbose && logger.debug( - this.tg.root.title, - name, - args.map((n) => n.name?.value), - selection.map((n) => n.name?.value), - typ.type, - Object.entries(props).reduce( - (agg, [k, v]) => ({ ...agg, [k]: this.tg.type(v).type }), - {}, - ), + `${this.tg.root.title} {}`, + { + name, + args: args.map((n) => n.name?.value), + selection: selection.map((n) => n.name?.value), + type: typ.type, + props: Object.entries(props).reduce( + (agg, [k, v]) => ({ ...agg, [k]: this.tg.type(v).type }), + {}, + ), + }, ); stages.push( diff --git a/typegate/src/engine/query_engine.ts b/typegate/src/engine/query_engine.ts index d68fbc661e..d4eac71ffa 100644 --- a/typegate/src/engine/query_engine.ts +++ b/typegate/src/engine/query_engine.ts @@ -287,17 +287,17 @@ export class QueryEngine { return await this.tg.deinit(); } - materialize( + async materialize( stages: ComputeStage[], verbose: boolean, - ): ComputeStage[] { + ): Promise { const stagesMat: ComputeStage[] = []; const waitlist = [...stages]; while (waitlist.length > 0) { const stage = waitlist.shift()!; stagesMat.push( - ...stage.props.runtime.materialize(stage, waitlist, verbose), + ...await stage.props.runtime.materialize(stage, waitlist, verbose), ); } @@ -336,7 +336,7 @@ export class QueryEngine { */ // how - const stagesMat = this.materialize(stages, verbose); + const stagesMat = await this.materialize(stages, verbose); // when const optimizedStages = this.optimize(stagesMat, verbose); diff --git a/typegate/src/log.ts b/typegate/src/log.ts index 7d6f4b3868..5a02bda066 100644 --- a/typegate/src/log.ts +++ b/typegate/src/log.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Elastic-2.0 import { handlers, LevelName, Logger } from "std/log/mod.ts"; -import { basename } from "std/url/mod.ts"; +import { basename, dirname } from "std/url/mod.ts"; import { extname } from "std/path/mod.ts"; import { z } from "zod"; import { deepMerge } from "std/collections/deep_merge.ts"; @@ -104,9 +104,7 @@ const consoleHandler = new handlers.ConsoleHandler( typeof arg === "string" ? arg : JSON.stringify(arg), ); } - return `${log.datetime.toISOString()} ${log.levelName.padEnd(5)} ${ - log.loggerName.padEnd(16) - } ${msg}`; + return `${log.datetime.toISOString()} [${log.levelName} ${log.loggerName}] ${msg}`; }, }, ); @@ -124,8 +122,9 @@ export function getLogger( return defaultLogger; } if (typeof name === "object") { - name = basename(name.url); - name = name.replace(extname(name), ""); + const bname = basename(name.url); + const dname = basename(dirname(name.url)); + name = `${dname}/${bname.replace(extname(bname), "")}`; } let logger = loggers.get(name); if (!logger) { diff --git a/typegate/src/main.ts b/typegate/src/main.ts index 347282db49..b7e148e2ea 100644 --- a/typegate/src/main.ts +++ b/typegate/src/main.ts @@ -34,10 +34,10 @@ try { debug: true, }); - addEventListener("unhandledrejection", (e) => { - Sentry.captureException(e); - logger.error(e); - e.preventDefault(); + addEventListener("unhandledrejection", (err) => { + Sentry.captureException(err); + logger.error(Deno.inspect(err)); + err.preventDefault(); }); // init rust native libs @@ -60,6 +60,6 @@ try { await server.finished; } catch (err) { - logger.error(err); + logger.error(Deno.inspect(err)); throw err; } diff --git a/typegate/src/runtimes/Runtime.ts b/typegate/src/runtimes/Runtime.ts index 43abb2f7c6..895181c59f 100644 --- a/typegate/src/runtimes/Runtime.ts +++ b/typegate/src/runtimes/Runtime.ts @@ -8,7 +8,10 @@ import { Resolver } from "../types.ts"; export abstract class Runtime { readonly id: string; - constructor(public typegraphName: string, uuid = crypto.randomUUID()) { + constructor( + public typegraphName: string, + uuid = crypto.randomUUID() as string, + ) { this.id = `${typegraphName}_${this.constructor.name}_${uuid}`; } @@ -18,7 +21,7 @@ export abstract class Runtime { stage: ComputeStage, waitlist: ComputeStage[], verbose: boolean, - ): ComputeStage[]; + ): ComputeStage[] | Promise; static collectRelativeStages( base: ComputeStage, diff --git a/typegate/src/runtimes/mod.ts b/typegate/src/runtimes/mod.ts index da92abff74..56727de88c 100644 --- a/typegate/src/runtimes/mod.ts +++ b/typegate/src/runtimes/mod.ts @@ -35,18 +35,18 @@ export async function initRuntime( } export async function init_runtimes(): Promise { - await Promise.allSettled([ - import("./Runtime.ts"), + await Promise.all([ import("./deno.ts"), import("./graphql.ts"), import("./http.ts"), import("./prisma.ts"), - import("./python_wasi.ts"), + import("./python.ts"), import("./random.ts"), import("./s3.ts"), import("./temporal.ts"), import("./typegate.ts"), import("./typegraph.ts"), - import("./wasm.ts"), + import("./wasm_wire.ts"), + import("./wasm_reflected.ts"), ]); } diff --git a/typegate/src/runtimes/prisma/hooks/run_migrations.ts b/typegate/src/runtimes/prisma/hooks/run_migrations.ts index 5c28edb378..1b35001f2f 100644 --- a/typegate/src/runtimes/prisma/hooks/run_migrations.ts +++ b/typegate/src/runtimes/prisma/hooks/run_migrations.ts @@ -12,6 +12,7 @@ import * as native from "native"; import { nativeResult, pluralSuffix } from "../../../utils.ts"; import { MigrationOptions } from "../../../typegraph/types.ts"; import { SecretManager } from "../../../typegraph/mod.ts"; +import type { ParsedDiff } from "../../../../engine/runtime.js"; export class MigrationFailure extends Error { errors: PushFailure[] = []; diff --git a/typegate/src/runtimes/python.ts b/typegate/src/runtimes/python.ts new file mode 100644 index 0000000000..649aef824a --- /dev/null +++ b/typegate/src/runtimes/python.ts @@ -0,0 +1,189 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { registerRuntime } from "./mod.ts"; +import { getLogger } from "../log.ts"; +import { Runtime } from "./Runtime.ts"; +import type { Resolver, RuntimeInitParams } from "../types.ts"; +import { ComputeStage } from "../engine/query_engine.ts"; +import { Artifact, Materializer } from "../typegraph/types.ts"; +import * as ast from "graphql/ast"; +import { WitWireMessenger } from "./wit_wire/mod.ts"; +import { WitWireMatInfo } from "../../engine/runtime.js"; +import { sha256 } from "../crypto.ts"; + +const _logger = getLogger(import.meta); + +@registerRuntime("python") +export class PythonRuntime extends Runtime { + private constructor( + typegraphName: string, + uuid: string, + private wire: WitWireMessenger, + ) { + super(typegraphName, uuid); + } + + static async init(params: RuntimeInitParams): Promise { + const { materializers, typegraphName, typegraph, typegate } = params; + + const wireMatInfos = await Promise.all( + materializers + .filter((mat) => mat.name != "pymodule") + .map( + async (mat) => { + let matInfoData: object; + switch (mat.name) { + case "lambda": + matInfoData = { + ty: "lambda", + effect: mat.effect, + source: mat.data.fn as string, + }; + break; + case "def": + matInfoData = { + ty: "def", + func_name: mat.data.name as string, + effect: mat.effect, + source: mat.data.fn as string, + }; + break; + case "import_function": { + const pyModMat = + typegraph.materializers[mat.data.mod as number]; + + // resolve the python module artifacts/files + const { pythonArtifact, depsMeta: depArtifacts } = + pyModMat.data; + + const deps = depArtifacts as Artifact[]; + const artifact = pythonArtifact as Artifact; + + const sources = Object.fromEntries( + await Promise.all( + [ + { + typegraphName: typegraphName, + relativePath: artifact.path, + hash: artifact.hash, + sizeInBytes: artifact.size, + }, + ...deps.map((dep) => { + return { + typegraphName: typegraphName, + relativePath: dep.path, + hash: dep.hash, + sizeInBytes: dep.size, + }; + }), + ].map( + async (meta) => + [ + meta.relativePath, + await Deno.readTextFile( + await typegate.artifactStore.getLocalPath(meta), + ), + ] as const, + ), + ), + ); + + matInfoData = { + ty: "import_function", + effect: mat.effect, + root_src_path: artifact.path, + func_name: mat.data.name as string, + sources, + }; + break; + } + default: + throw new Error(`unsupported materializer type: ${mat.name}`); + } + + // TODO: use materializer type node hash instead + const dataHash = await sha256(JSON.stringify(mat.data)); + const op_name = `${mat.data.name as string}_${ + dataHash.slice(0, 12) + }`; + + const out: WitWireMatInfo = { + op_name, + mat_hash: dataHash, + // TODO: source title of materializer type? + mat_title: mat.data.name as string, + mat_data_json: JSON.stringify(matInfoData), + }; + return out; + }, + ), + ); + + // add default vm for lambda/def + const uuid = crypto.randomUUID(); + const wire = await WitWireMessenger.init( + "inline://pyrt_wit_wire.cwasm", + uuid, + wireMatInfos, + ); + + return new PythonRuntime(typegraphName, uuid, wire); + } + + async deinit(): Promise { + await using _drop = this.wire; + } + + async materialize( + stage: ComputeStage, + _waitlist: ComputeStage[], + _verbose: boolean, + ): Promise { + if (stage.props.node === "__typename") { + return [stage.withResolver(() => { + const { parent: parentStage } = stage.props; + if (parentStage != null) { + return parentStage.props.outType.title; + } + switch (stage.props.operationType) { + case ast.OperationTypeNode.QUERY: + return "Query"; + case ast.OperationTypeNode.MUTATION: + return "Mutation"; + default: + throw new Error( + `Unsupported operation type '${stage.props.operationType}'`, + ); + } + })]; + } + + if (stage.props.materializer != null) { + const mat = stage.props.materializer; + + return [ + stage.withResolver(await this.delegate(mat)), + ]; + } + + if (stage.props.outType.config?.__namespace) { + return [stage.withResolver(() => ({}))]; + } + + return [stage.withResolver(({ _: { parent } }) => { + if (stage.props.parent == null) { // namespace + return {}; + } + const resolver = parent[stage.props.node]; + return typeof resolver === "function" ? resolver() : resolver; + })]; + } + + async delegate(mat: Materializer): Promise { + const { name } = mat.data; + const dataHash = await sha256(JSON.stringify(mat.data)); + const op_name = `${name as string}_${dataHash.slice(0, 12)}`; + return (args) => this.wire.handle(op_name, args); + } +} diff --git a/typegate/src/runtimes/python_wasi.ts b/typegate/src/runtimes/python_wasi.ts deleted file mode 100644 index 740e3cab50..0000000000 --- a/typegate/src/runtimes/python_wasi.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { registerRuntime } from "./mod.ts"; -import { PythonWasiRuntime } from "./python_wasi/python_wasi.ts"; - -registerRuntime("python_wasi")(PythonWasiRuntime); diff --git a/typegate/src/runtimes/python_wasi/python_vm.ts b/typegate/src/runtimes/python_wasi/python_vm.ts deleted file mode 100644 index 2c62e5eecd..0000000000 --- a/typegate/src/runtimes/python_wasi/python_vm.ts +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { - apply_def, - apply_lambda, - register_def, - register_lambda, - register_module, - register_virtual_machine, - unregister_virtual_machine, - WasiVmInitConfig, - WasiVmSetupOut, -} from "native"; - -import { getLogger } from "../../log.ts"; -const logger = getLogger(import.meta); - -import config from "../../config.ts"; -import { gunzip, tar } from "compress/mod.ts"; -import { join } from "std/path/mod.ts"; -import { exists } from "std/fs/exists.ts"; - -type Tag = "ok" | "err"; -type NativeWasiOutput = { Ok: { res?: string } } | { Err: { message: string } }; -type PythonOutput = { - value: string; // json string - tag: Tag; -}; - -function nativePythonResult( - res: NativeWasiOutput | WasiVmSetupOut, -) { - if (res == "Ok") { - return null; - } - if ("Err" in res) { - throw new Error(res.Err.message); - } - const ret = res.Ok?.res; - if (ret) { - const py = JSON.parse(ret) as PythonOutput; - if (py.tag == "err") { - throw new Error(py.value); - } - return py.value; - } - return null; -} - -function promisify(fn: CallableFunction): Promise { - return new Promise((resolve, reject) => { - try { - resolve(fn()); - } catch (e) { - reject(e); - } - }); -} - -const pythonWasiReactorUrl = - "https://github.com/metatypedev/python-wasi-reactor/releases/download/v0.2.0/python3.11.1-wasi-reactor.wasm.tar.gz"; -const cachePathReactor = join(config.tmp_dir, "python3.11.1-wasi-reactor.wasm"); - -const libPythonUrl = - "https://github.com/vmware-labs/webassembly-language-runtimes/releases/download/python%2F3.11.4%2B20230714-11be424/libpython-3.11.4-wasi-sdk-20.0.tar.gz"; -const cachePathLibPython = join(config.tmp_dir, "libpython"); - -async function download(url: string, innerDir?: string) { - const res = await fetch(url); - const archivePath = await Deno.makeTempFile({ - dir: config.tmp_dir, - }); - const buffer = await res.arrayBuffer(); - const archive = gunzip(new Uint8Array(buffer)); - await Deno.writeFile(archivePath, archive); - - const destDir = innerDir ? join(config.tmp_dir, innerDir) : config.tmp_dir; - await tar.uncompress(archivePath, destDir); -} - -export class PythonVirtualMachine { - #config: WasiVmInitConfig; - #lambdas: Set; - - constructor() { - this.#config = { - vm_name: "defaultName", - preopens: [], - pylib_path: join(config.tmp_dir, "libpython/usr/local/lib"), - wasi_mod_path: join(config.tmp_dir, "python3.11.1-wasi-reactor.wasm"), - }; - this.#lambdas = new Set(); - } - - async setup(vmName: string, appDirectoryPath?: string) { - if (!await exists(cachePathReactor)) { - logger.info(`downloading ${pythonWasiReactorUrl}`); - await download(pythonWasiReactorUrl); - } - if (!await exists(cachePathLibPython)) { - logger.info(`downloading ${libPythonUrl}`); - await download(libPythonUrl, "libpython"); - } - - const preopens = []; - if (appDirectoryPath) { - preopens.push(`/app:${appDirectoryPath}:readonly`); - } - this.#config = { - ...this.#config, - preopens, - vm_name: vmName, - }; - nativePythonResult( - await promisify(() => register_virtual_machine(this.#config)), - ); - } - - async destroy() { - nativePythonResult( - await promisify(() => - unregister_virtual_machine({ - vm_name: this.getVmName(), - }) - ), - ); - this.#lambdas.clear(); - } - - getVmName() { - return this.#config.vm_name; - } - - async registerLambda(name: string, code: string) { - nativePythonResult( - await promisify(() => - register_lambda({ - name, - code, - vm: this.getVmName(), - }) - ), - ); - this.#lambdas.add(name); - } - - async registerDef(name: string, code: string) { - nativePythonResult( - await promisify(() => - register_def({ - name, - code, - vm: this.getVmName(), - }) - ), - ); - } - - async registerModule(name: string, code: string) { - nativePythonResult( - await promisify(() => - register_module({ - name, - code, - vm: this.getVmName(), - }) - ), - ); - } - - async applyLambda(id: number, name: string, args: unknown[]) { - const pyRet = nativePythonResult( - await promisify(() => - apply_lambda({ - id, - name, - args: JSON.stringify(args), - vm: this.getVmName(), - }) - ), - ); - return JSON.parse(pyRet ?? "null"); - } - - async applyDef(id: number, name: string, args: unknown[]) { - const pyRet = nativePythonResult( - await promisify(() => - apply_def({ - id, - name, - args: JSON.stringify(args), - vm: this.getVmName(), - }) - ), - ); - return JSON.parse(pyRet ?? "null"); - } - - async apply(id: number, name: string, args: unknown[]) { - // Notes: - // 1. if #[deno_bindgen], apply* runs on main thread => blocking - // 2. if #[deno], apply* runs on main separate thread? => still blocking - // alternative solution: - // timeout at wasm level - if (this.#lambdas.has(name)) { - return await this.applyLambda(id, name, args); - } - return await this.applyDef(id, name, args); - } -} diff --git a/typegate/src/runtimes/python_wasi/python_wasi.ts b/typegate/src/runtimes/python_wasi/python_wasi.ts deleted file mode 100644 index 03327ab04e..0000000000 --- a/typegate/src/runtimes/python_wasi/python_wasi.ts +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { getLogger } from "../../log.ts"; -import { Runtime } from "../Runtime.ts"; -import { basename } from "std/path/mod.ts"; -import { Resolver, RuntimeInitParams } from "../../types.ts"; -import { ComputeStage } from "../../engine/query_engine.ts"; -import { PythonWasmMessenger } from "./python_wasm_messenger.ts"; -import { path } from "compress/deps.ts"; -import { PythonVirtualMachine } from "./python_vm.ts"; -import { Artifact, Materializer } from "../../typegraph/types.ts"; -import * as ast from "graphql/ast"; - -const logger = getLogger(import.meta); - -function generateVmIdentifier(mat: Materializer, uuid: string) { - const { mod } = mat.data ?? {}; - let identifier = ""; - if (mod !== undefined) { - identifier = `pymod_${mod}`; - } else { - identifier = `default`; - } - identifier = `${identifier}_${uuid}`; - return identifier; -} - -export class PythonWasiRuntime extends Runtime { - private constructor( - typegraphName: string, - uuid: string, - private w: PythonWasmMessenger, - ) { - super(typegraphName, uuid); - this.uuid = uuid; - } - uuid: string; - - static async init(params: RuntimeInitParams): Promise { - const { materializers, typegraph, typegraphName, typegate } = params; - const w = await PythonWasmMessenger.init(); - - logger.info(`initializing default vm: ${typegraphName}`); - - // add default vm for lambda/def - const uuid = crypto.randomUUID(); - const defaultVm = new PythonVirtualMachine(); - await defaultVm.setup(`default_${uuid}`); - w.vmMap.set(`default_${uuid}`, defaultVm); - - for (const m of materializers) { - switch (m.name) { - case "lambda": { - logger.info(`registering lambda: ${m.data.name}`); - await defaultVm.registerLambda( - m.data.name as string, - m.data.fn as string, - ); - break; - } - case "def": { - logger.info(`registering def: ${m.data.name}`); - await defaultVm.registerDef( - m.data.name as string, - m.data.fn as string, - ); - break; - } - case "import_function": { - const pyModMat = typegraph.materializers[m.data.mod as number]; - - // resolve the python module artifacts/files - const { pythonArtifact, depsMeta: depArtifacts } = pyModMat.data; - - const deps = depArtifacts as Artifact[]; - - const vmId = generateVmIdentifier(m, uuid); - - const artifact = pythonArtifact as Artifact; - const modName = path.parse(basename(artifact.path)).name; - - // TODO: move this logic to postprocess or python runtime - m.data.name = `${modName}.${m.data.name as string}`; - logger.info(`setup vm "${vmId}" for module ${modName}`); - const vm = new PythonVirtualMachine(); - - // for python modules, imports must be inside a folder above or same directory - const artifactMeta = { - typegraphName: typegraphName, - relativePath: artifact.path, - hash: artifact.hash, - sizeInBytes: artifact.size, - }; - const depMetas = deps.map((dep) => { - return { - typegraphName: typegraphName, - relativePath: dep.path, - hash: dep.hash, - sizeInBytes: dep.size, - }; - }); - - const entryPointFullPath = await typegate.artifactStore.getLocalPath( - artifactMeta, - depMetas, - ); - const sourceCode = Deno.readTextFileSync(entryPointFullPath); - - // prepare vm - await vm.setup(vmId, path.parse(entryPointFullPath).dir); - w.vmMap.set(vmId, vm); - await vm.registerModule(modName, sourceCode); - - logger.info( - `register module "${modName}" to vm "${vmId}" located at "${entryPointFullPath}"`, - ); - break; - } - } - } - - return new PythonWasiRuntime(typegraphName, uuid, w); - } - - async deinit(): Promise { - for (const vm of this.w.vmMap.values()) { - logger.info(`unregister vm: ${vm.getVmName()}`); - await vm.destroy(); - } - await this.w.terminate(); - } - - materialize( - stage: ComputeStage, - _waitlist: ComputeStage[], - _verbose: boolean, - ): ComputeStage[] { - if (stage.props.node === "__typename") { - return [stage.withResolver(() => { - const { parent: parentStage } = stage.props; - if (parentStage != null) { - return parentStage.props.outType.title; - } - switch (stage.props.operationType) { - case ast.OperationTypeNode.QUERY: - return "Query"; - case ast.OperationTypeNode.MUTATION: - return "Mutation"; - default: - throw new Error( - `Unsupported operation type '${stage.props.operationType}'`, - ); - } - })]; - } - - if (stage.props.materializer != null) { - const mat = stage.props.materializer; - return [ - stage.withResolver(this.delegate(mat)), - ]; - } - - if (stage.props.outType.config?.__namespace) { - return [stage.withResolver(() => ({}))]; - } - - return [stage.withResolver(({ _: { parent } }) => { - if (stage.props.parent == null) { // namespace - return {}; - } - const resolver = parent[stage.props.node]; - return typeof resolver === "function" ? resolver() : resolver; - })]; - } - - delegate(mat: Materializer): Resolver { - const { name } = mat.data ?? {}; - const vmId = generateVmIdentifier(mat, this.uuid); - return (args: unknown) => this.w.execute(name as string, { vmId, args }); - } -} diff --git a/typegate/src/runtimes/python_wasi/python_wasm_messenger.ts b/typegate/src/runtimes/python_wasi/python_wasm_messenger.ts deleted file mode 100644 index 1887f990ad..0000000000 --- a/typegate/src/runtimes/python_wasi/python_wasm_messenger.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { AsyncMessenger } from "../patterns/messenger/async_messenger.ts"; -import { PythonVirtualMachine } from "./python_vm.ts"; - -export class PythonWasmMessenger extends AsyncMessenger< - Map, - unknown, - unknown -> { - vmMap: Map; - - private constructor() { - const vmMap = new Map(); - super( - () => vmMap, - (vmMap, { id, op, data }) => { - const { vmId, args } = data as any; - const vm = vmMap.get(vmId); - if (!vm) { - this.receive({ id, error: `vm "${vmId}" does not exist` }); - } else { - vm.apply(id, op as string, [args]) - .then((res) => { - this.receive({ id, data: res }); - }) - .catch((err) => { - this.receive({ id, error: err }); - }); - } - }, - () => {}, - ); - - this.vmMap = vmMap; - } - - static init(): PythonWasmMessenger { - return new PythonWasmMessenger(); - } -} diff --git a/typegate/src/runtimes/wasm.ts b/typegate/src/runtimes/wasm_reflected.ts similarity index 80% rename from typegate/src/runtimes/wasm.ts rename to typegate/src/runtimes/wasm_reflected.ts index 3b9bbf5aa4..c19a54f481 100644 --- a/typegate/src/runtimes/wasm.ts +++ b/typegate/src/runtimes/wasm_reflected.ts @@ -1,26 +1,29 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 +import { registerRuntime } from "./mod.ts"; import { Runtime } from "./Runtime.ts"; import * as native from "native"; import { Resolver, RuntimeInitParams } from "../types.ts"; import { nativeResult } from "../utils.ts"; import { ComputeStage } from "../engine/query_engine.ts"; -import { registerRuntime } from "./mod.ts"; import * as ast from "graphql/ast"; -import { Materializer } from "../typegraph/types.ts"; +import { Materializer, WasmRuntimeData } from "../typegraph/types.ts"; import { Typegate } from "../typegate/mod.ts"; -@registerRuntime("wasm") -export class WasmRuntime extends Runtime { - private constructor(typegraphName: string, private typegate: Typegate) { +@registerRuntime("wasm_reflected") +export class WasmRuntimeReflected extends Runtime { + private constructor( + public artifactKey: string, + typegraphName: string, + private typegate: Typegate, + ) { super(typegraphName); } - static init(params: RuntimeInitParams): Promise { - const { typegraphName, typegate } = params; - - return Promise.resolve(new WasmRuntime(typegraphName, typegate)); + static init(params: RuntimeInitParams): Runtime { + const { typegraphName, typegate, args: { wasm_artifact } } = params; + return new WasmRuntimeReflected(wasm_artifact, typegraphName, typegate); } async deinit(): Promise {} @@ -80,10 +83,10 @@ export class WasmRuntime extends Runtime { materializer: Materializer, argumentTypes?: Record, ): Resolver { - const { wasmArtifact, func } = materializer?.data ?? {}; + const { op_name } = materializer?.data ?? {}; const order = Object.keys(argumentTypes ?? {}); const typegraph = this.typegate.register.get(this.typegraphName)!; - const art = typegraph.tg.tg.meta.artifacts[wasmArtifact as string]; + const art = typegraph.tg.tg.meta.artifacts[this.artifactKey as string]; const artifactMeta = { typegraphName: this.typegraphName, @@ -96,7 +99,7 @@ export class WasmRuntime extends Runtime { const transfert = order.map((k) => JSON.stringify(args[k])); const { res } = nativeResult( await native.wasmtime_wit({ - func: func as string, + func: op_name as string, wasm: await this.typegate.artifactStore.getLocalPath(artifactMeta), args: transfert, }), diff --git a/typegate/src/runtimes/wasm_wire.ts b/typegate/src/runtimes/wasm_wire.ts new file mode 100644 index 0000000000..47fc8453c8 --- /dev/null +++ b/typegate/src/runtimes/wasm_wire.ts @@ -0,0 +1,116 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { registerRuntime } from "./mod.ts"; +import { Runtime } from "./Runtime.ts"; +import { Resolver, RuntimeInitParams } from "../types.ts"; +import { ComputeStage } from "../engine/query_engine.ts"; +import * as ast from "graphql/ast"; +import { Materializer, WasmRuntimeData } from "../typegraph/types.ts"; +import { getLogger } from "../log.ts"; +import { WitWireMessenger } from "./wit_wire/mod.ts"; + +const logger = getLogger(import.meta); + +@registerRuntime("wasm_wire") +export class WasmRuntimeWire extends Runtime { + private constructor( + typegraphName: string, + uuid: string, + private wire: WitWireMessenger, + ) { + super(typegraphName, uuid); + } + + static async init( + params: RuntimeInitParams, + ): Promise { + const { + typegraph, + typegraphName, + typegate, + args: { wasm_artifact }, + materializers, + } = params; + + const moduleArt = typegraph.meta.artifacts[wasm_artifact]; + const artifactMeta = { + typegraphName: typegraphName, + relativePath: moduleArt.path, + hash: moduleArt.hash, + sizeInBytes: moduleArt.size, + }; + + const uuid = crypto.randomUUID(); + logger.debug("initializing wit wire {}", { + instanceId: uuid, + module: artifactMeta, + }); + const wire = await WitWireMessenger.init( + await typegate.artifactStore.getLocalPath(artifactMeta), + uuid, + materializers.map((mat) => ({ + op_name: mat.data.op_name as string, + // TODO; appropriately source the following + mat_hash: mat.data.op_name as string, + mat_title: mat.data.op_name as string, + mat_data_json: JSON.stringify({}), + })), + ); + + return new WasmRuntimeWire(typegraphName, uuid, wire); + } + + async deinit(): Promise { + await using _drop = this.wire; + } + + materialize( + stage: ComputeStage, + _waitlist: ComputeStage[], + _verbose: boolean, + ): ComputeStage[] { + if (stage.props.node === "__typename") { + return [stage.withResolver(() => { + const { parent: parentStage } = stage.props; + if (parentStage != null) { + return parentStage.props.outType.title; + } + switch (stage.props.operationType) { + case ast.OperationTypeNode.QUERY: + return "Query"; + case ast.OperationTypeNode.MUTATION: + return "Mutation"; + default: + throw new Error( + `Unsupported operation type '${stage.props.operationType}'`, + ); + } + })]; + } + + if (stage.props.materializer != null) { + const mat = stage.props.materializer; + return [ + stage.withResolver(this.delegate(mat)), + ]; + } + + if (stage.props.outType.config?.__namespace) { + return [stage.withResolver(() => ({}))]; + } + + return [stage.withResolver(({ _: { parent } }) => { + if (stage.props.parent == null) { // namespace + return {}; + } + const resolver = parent[stage.props.node]; + return typeof resolver === "function" ? resolver() : resolver; + })]; + } + + delegate(mat: Materializer): Resolver { + const { op_name } = mat.data; + return (args) => this.wire.handle(op_name as string, args); + } +} diff --git a/typegate/src/runtimes/wit_wire/mod.ts b/typegate/src/runtimes/wit_wire/mod.ts new file mode 100644 index 0000000000..3c7588b901 --- /dev/null +++ b/typegate/src/runtimes/wit_wire/mod.ts @@ -0,0 +1,116 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import type { WitWireMatInfo } from "../../../engine/runtime.js"; +import { ResolverArgs } from "../../types.ts"; + +export class WitWireMessenger { + static async init( + componentPath: string, + instanceId: string, + ops: WitWireMatInfo[], + ) { + try { + const _res = await Meta.wit_wire.init(componentPath, instanceId, { + expected_ops: ops, + // FIXME: source actual version + metatype_version: "0.3.7-0", + }); + return new WitWireMessenger(instanceId, componentPath, ops); + } catch (err) { + throw new Error( + `error on init for component at path: ${componentPath}: ${err}`, + { + cause: { + componentPath, + ops, + err, + }, + }, + ); + } + } + + constructor( + public id: string, + public componentPath: string, + public ops: WitWireMatInfo[], + ) { + } + + async [Symbol.asyncDispose]() { + await Meta.wit_wire.destroy(this.id); + } + + async handle(opName: string, args: ResolverArgs) { + const { _, ...inJson } = args; + let res; + try { + res = await Meta.wit_wire.handle(this.id, { + op_name: opName, + in_json: JSON.stringify(inJson), + }); + } catch (err) { + throw new Error( + `unexpected error handling request for op ${opName}: ${err}`, + { + cause: { + opName, + args: inJson, + component: this.componentPath, + err, + }, + }, + ); + } + if ( + typeof res == "string" + ) { + if (res == "NoHandler") { + throw new Error( + `materializer doesn't implement handler for op ${opName}`, + { + cause: { + opName, + args: inJson, + component: this.componentPath, + ops: this.ops, + }, + }, + ); + } else { + throw new Error(`unexpected mat result for op ${opName}: ${res}`, { + cause: { + opName, + args: inJson, + component: this.componentPath, + }, + }); + } + } else if ("Ok" in res) { + return JSON.parse(res.Ok); + } else if ("InJsonErr" in res) { + throw new Error( + `materializer failed deserializing json args for op ${opName}: ${res.InJsonErr}`, + { + cause: { + opName, + args: inJson, + component: this.componentPath, + }, + }, + ); + } else { + throw new Error( + `materializer handler error for op ${opName}: ${res.HandlerErr}`, + { + cause: { + opName, + args: inJson, + component: this.componentPath, + }, + }, + ); + } + } +} diff --git a/typegate/src/services/auth/protocols/oauth2.ts b/typegate/src/services/auth/protocols/oauth2.ts index e4a0cb96bf..df626ba982 100644 --- a/typegate/src/services/auth/protocols/oauth2.ts +++ b/typegate/src/services/auth/protocols/oauth2.ts @@ -78,7 +78,7 @@ class AuthProfiler { validatorInputWeak(input); // Note: this assumes func is a simple t.func(inp, out, mat) - const stages = runtime.materialize( + const stages = await runtime.materialize( this.getComputeStage(), [], true, diff --git a/typegate/src/services/graphql_service.ts b/typegate/src/services/graphql_service.ts index bb6ff7f6aa..498944e950 100644 --- a/typegate/src/services/graphql_service.ts +++ b/typegate/src/services/graphql_service.ts @@ -63,8 +63,7 @@ export async function handleGraphQL( const verbose = !isIntrospection; if (verbose) { - logger.info("———"); - logger.info("op:", operationName); + logger.info("op: {}", operationName); } const startTime = performance.now(); @@ -114,8 +113,12 @@ export async function handleGraphQL( Object.keys(context).length === 0 ? 401 : 403, ); } else { - console.error(e); - logger.error(`request err: ${e}`); + logger.error(`request err: ${Deno.inspect(e)}`); + if (e.cause) { + logger.error( + Deno.inspect(e.cause, { strAbbreviateSize: 1024, depth: 10 }), + ); + } return jsonError(e.message, headers, 400); } } diff --git a/typegate/src/typegate/artifacts/local.ts b/typegate/src/typegate/artifacts/local.ts index c1dea6bba0..9dc1b10235 100644 --- a/typegate/src/typegate/artifacts/local.ts +++ b/typegate/src/typegate/artifacts/local.ts @@ -10,9 +10,12 @@ import { STORE_DIR, STORE_TEMP_DIR, } from "./mod.ts"; +import { getLogger } from "../../log.ts"; import { createHash } from "node:crypto"; import * as jwt from "jwt"; +const logger = getLogger(import.meta); + export interface UploadUrlStore { mapToMeta: Map; expirationQueue: [string, number][]; @@ -72,13 +75,14 @@ export class LocalArtifactStore extends ArtifactStore { const hash = hasher.digest("hex"); const targetFile = resolve(STORE_DIR, hash); - console.log(`Persisting artifact to ${targetFile}`); + logger.debug(`persisting artifact {}`, { hash }); await Deno.rename(tmpFile, targetFile); return hash; } override async delete(hash: string) { + logger.debug(`deleting artifact {}`, { hash }); await Deno.remove(resolve(STORE_DIR, hash)); } @@ -104,6 +108,10 @@ export class LocalArtifactStore extends ArtifactStore { override async prepareUpload(meta: ArtifactMeta, origin: URL) { // should not be uploaded again if (await this.has(ArtifactStore.getArtifactKey(meta))) { + logger.debug( + "artifact already exists, skipping upload preparation {}", + { meta }, + ); return null; } diff --git a/typegate/src/typegraph/types.ts b/typegate/src/typegraph/types.ts index 993a38a9b3..4dd07fc3a6 100644 --- a/typegate/src/typegraph/types.ts +++ b/typegate/src/typegraph/types.ts @@ -283,7 +283,7 @@ export type KnownRuntime = { name: "http"; data: HTTPRuntimeData; } | { - name: "python_wasi"; + name: "python"; data: PythonRuntimeData; } | { name: "random"; @@ -301,7 +301,10 @@ export type KnownRuntime = { name: "temporal"; data: TemporalRuntimeData; } | { - name: "wasm"; + name: "wasm_wire"; + data: WasmRuntimeData; +} | { + name: "wasm_reflected"; data: WasmRuntimeData; } | { name: "typegate"; @@ -483,7 +486,7 @@ export interface TemporalRuntimeData { namespace_secret?: string; } export interface WasmRuntimeData { - config?: string | null; + wasm_artifact: string; } export interface TypegateRuntimeData { } diff --git a/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap b/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap index eb0f691b51..5d4e293f3a 100644 --- a/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap +++ b/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap @@ -435,7 +435,7 @@ snapshot[`typegraphs creation 2`] = ` } }, { - "name": "python_wasi", + "name": "python", "data": { "config": null } @@ -1194,7 +1194,7 @@ snapshot[`typegraphs creation 5`] = ` } }, { - "name": "python_wasi", + "name": "python", "data": { "config": null } diff --git a/typegate/tests/metatype.yml b/typegate/tests/metatype.yml index 3067f30e81..087b1c7ad8 100644 --- a/typegate/tests/metatype.yml +++ b/typegate/tests/metatype.yml @@ -25,3 +25,11 @@ typegraphs: materializers: prisma: migrations_path: "prisma-migrations" + +metagen: + targets: + wasm_wire: + mdk_rust: + path: ./runtimes/wasm_wire/rust/ + typegraph_path: ./runtimes/wasm_wire/wasm_wire.ts + stubbed_runtimes: ["wasm_wire"] diff --git a/typegate/tests/planner/__snapshots__/planner_test.ts.snap b/typegate/tests/planner/__snapshots__/planner_test.ts.snap index 1122e72a27..8f52cc428c 100644 --- a/typegate/tests/planner/__snapshots__/planner_test.ts.snap +++ b/typegate/tests/planner/__snapshots__/planner_test.ts.snap @@ -1,98 +1,5 @@ export const snapshot = {}; -snapshot[`planner 1`] = ` -[ - { - id: "one", - node: "one", - path: [ - "one", - ], - type: { - title: "func_75", - type: "function", - }, - }, - { - id: "one.id", - node: "id", - path: [ - "one", - "id", - ], - type: { - format: "uuid", - title: "string_12", - type: "string", - }, - }, - { - id: "one.email", - node: "email", - path: [ - "one", - "email", - ], - type: { - format: "email", - title: "string_13", - type: "string", - }, - }, - { - id: "one.nested", - node: "nested", - path: [ - "one", - "nested", - ], - type: { - title: "object_19", - type: "object", - }, - }, - { - id: "one.nested.first", - node: "first", - path: [ - "one", - "nested", - "first", - ], - type: { - title: "string_14", - type: "string", - }, - }, - { - id: "one.nested.second", - node: "second", - path: [ - "one", - "nested", - "second", - ], - type: { - title: "list_16", - type: "list", - }, - }, - { - id: "one.nested.third", - node: "third", - path: [ - "one", - "nested", - "third", - ], - type: { - title: "optional_18", - type: "optional", - }, - }, -] -`; - snapshot[`planner 2`] = ` { one: { @@ -201,6 +108,99 @@ snapshot[`planner 4`] = ` ] `; +snapshot[`planner 1`] = ` +[ + { + id: "one", + node: "one", + path: [ + "one", + ], + type: { + title: "func_75", + type: "function", + }, + }, + { + id: "one.id", + node: "id", + path: [ + "one", + "id", + ], + type: { + format: "uuid", + title: "string_12", + type: "string", + }, + }, + { + id: "one.email", + node: "email", + path: [ + "one", + "email", + ], + type: { + format: "email", + title: "string_13", + type: "string", + }, + }, + { + id: "one.nested", + node: "nested", + path: [ + "one", + "nested", + ], + type: { + title: "object_19", + type: "object", + }, + }, + { + id: "one.nested.first", + node: "first", + path: [ + "one", + "nested", + "first", + ], + type: { + title: "string_14", + type: "string", + }, + }, + { + id: "one.nested.second", + node: "second", + path: [ + "one", + "nested", + "second", + ], + type: { + title: "list_16", + type: "list", + }, + }, + { + id: "one.nested.third", + node: "third", + path: [ + "one", + "nested", + "third", + ], + type: { + title: "optional_18", + type: "optional", + }, + }, +] +`; + snapshot[`planner: dependencies 1`] = ` [ "two two two object object_68 false", diff --git a/typegate/tests/runtimes/python/py/hello.py b/typegate/tests/runtimes/python/py/hello.py new file mode 100644 index 0000000000..dc9b0d49b8 --- /dev/null +++ b/typegate/tests/runtimes/python/py/hello.py @@ -0,0 +1,10 @@ +from .nested.dep import hello +from typing import Dict + + +def sayHello(x: Dict): + return hello(x["name"]) + + +def identity(x: Dict): + return x["input"] diff --git a/typegate/tests/runtimes/python_wasi/py/nested/dep.py b/typegate/tests/runtimes/python/py/nested/dep.py similarity index 100% rename from typegate/tests/runtimes/python_wasi/py/nested/dep.py rename to typegate/tests/runtimes/python/py/nested/dep.py diff --git a/typegate/tests/runtimes/python_wasi/python_wasi.py b/typegate/tests/runtimes/python/python.py similarity index 95% rename from typegate/tests/runtimes/python_wasi/python_wasi.py rename to typegate/tests/runtimes/python/python.py index 026f734e89..85f18856f4 100644 --- a/typegate/tests/runtimes/python_wasi/python_wasi.py +++ b/typegate/tests/runtimes/python/python.py @@ -46,7 +46,7 @@ def infinite_loop(x): @typegraph() -def python_wasi(g: Graph): +def python(g: Graph): public = Policy.public() python = PythonRuntime() @@ -91,13 +91,13 @@ def python_wasi(g: Graph): gate = f"http://localhost:{PORT}" auth = BasicAuth("admin", "password") -pytho_wasi_tg = python_wasi() +pytho_tg = python() deploy_result = tg_deploy( - pytho_wasi_tg, + pytho_tg, TypegraphDeployParams( base_url=gate, auth=auth, - typegraph_path=os.path.join(cwd, "python_wasi.py"), + typegraph_path=os.path.join(cwd, "python.py"), artifacts_config=ArtifactResolutionConfig( dir=cwd, prefix=None, diff --git a/typegate/tests/runtimes/python_wasi/python_wasi.ts b/typegate/tests/runtimes/python/python.ts similarity index 94% rename from typegate/tests/runtimes/python_wasi/python_wasi.ts rename to typegate/tests/runtimes/python/python.ts index 4077555cfa..cc82c57386 100644 --- a/typegate/tests/runtimes/python_wasi/python_wasi.ts +++ b/typegate/tests/runtimes/python/python.ts @@ -10,7 +10,7 @@ const tpe = t.struct({ "b": t.list(t.either([t.integer(), t.string()])), }); -export const tg = await typegraph("python_wasi", (g: any) => { +export const tg = await typegraph("python", (g: any) => { const python = new PythonRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/python_wasi/python_wasi_test.ts b/typegate/tests/runtimes/python/python_test.ts similarity index 66% rename from typegate/tests/runtimes/python_wasi/python_wasi_test.ts rename to typegate/tests/runtimes/python/python_test.ts index 95f92792cc..a17105268e 100644 --- a/typegate/tests/runtimes/python_wasi/python_wasi_test.ts +++ b/typegate/tests/runtimes/python/python_test.ts @@ -2,15 +2,16 @@ // SPDX-License-Identifier: Elastic-2.0 import { assert, assertEquals } from "std/assert/mod.ts"; -import { gql, Meta } from "../../utils/mod.ts"; -import { PythonVirtualMachine } from "../../../src/runtimes/python_wasi/python_vm.ts"; +import { gql, Meta } from "test-utils/mod.ts"; +import { WitWireMessenger } from "../../../src/runtimes/wit_wire/mod.ts"; +import { QueryEngine } from "../../../src/engine/query_engine.ts"; +import type { ResolverArgs } from "../../../src/types.ts"; import { testDir } from "test-utils/dir.ts"; -import { tg } from "./python_wasi.ts"; +import { tg } from "./python.ts"; import * as path from "std/path/mod.ts"; -import { QueryEngine } from "../../../src/engine/query_engine.ts"; import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js"; -const cwd = path.join(testDir, "runtimes/python_wasi"); +const cwd = path.join(testDir, "runtimes/python"); const auth = new BasicAuth("admin", "password"); const localSerializedMemo = tg.serialize({ @@ -28,14 +29,30 @@ const reusableTgOutput = { serialize: (_: any) => localSerializedMemo, }; -Meta.test("Python WASI VM performance", async (t) => { - const vm = new PythonVirtualMachine(); - await vm.setup("myVm"); - +Meta.test("Python VM performance", async (t) => { await t.should("work with low latency for lambdas", async () => { - await vm.registerLambda("test", "lambda x: x['a']"); - const samples = [...Array(100).keys()].map((i) => - vm.applyLambda(i, "test", [{ a: "test" }]) + await using wire = await WitWireMessenger.init( + "inline://pyrt_wit_wire.cwasm", + crypto.randomUUID(), + [ + { + op_name: "test_lambda", + mat_hash: "test_lambda", + mat_title: "test_lambda", + mat_data_json: JSON.stringify({ + ty: "lambda", + source: "lambda x: x['a']", + }), + }, + ], + ); + const samples = await Promise.all( + [...Array(100).keys()].map((_i) => + wire.handle( + "test_lambda", + { a: "test", _: {} } as unknown as ResolverArgs, + ) + ), ); const start = performance.now(); const items = await Promise.all(samples); @@ -51,9 +68,27 @@ Meta.test("Python WASI VM performance", async (t) => { }); await t.should("work with low latency for defs", async () => { - await vm.registerDef("test", "def test(x):\n\treturn x['a']"); - const samples = [...Array(100).keys()].map((i) => - vm.applyDef(i, "test", [{ a: "test" }]) + await using wire = await WitWireMessenger.init( + "inline://pyrt_wit_wire.cwasm", + crypto.randomUUID(), + [ + { + op_name: "test_def", + mat_hash: "test_def", + mat_title: "test_def", + mat_data_json: JSON.stringify({ + ty: "def", + func_name: "test_def", + source: "def test_def(x):\n\treturn x['a']", + }), + }, + ], + ); + const samples = [...Array(100).keys()].map((_i) => + wire.handle( + "test_def", + { a: "test", _: {} } as unknown as ResolverArgs, + ) ); const start = performance.now(); const items = await Promise.all(samples); @@ -67,19 +102,17 @@ Meta.test("Python WASI VM performance", async (t) => { `virtual machine execution was too slow: ${duration}ms`, ); }); - - await vm.destroy(); }); Meta.test( { - name: "Python WASI runtime", + name: "Python runtime", port: true, systemTypegraphs: true, }, async (t) => { const e = await t.engineFromTgDeployPython( - "runtimes/python_wasi/python_wasi.py", + "runtimes/python/python.py", cwd, ); @@ -161,7 +194,7 @@ Meta.test( const duration = end - start; console.log(`duration: ${duration}ms`); - assert(duration < 800, `Python WASI runtime was too slow: ${duration}ms`); + assert(duration < 800, `Python runtime was too slow: ${duration}ms`); }); }, ); @@ -191,7 +224,7 @@ Meta.test( }, dir: cwd, }, - typegraphPath: path.join(cwd, "python_wasi.ts"), + typegraphPath: path.join(cwd, "python.ts"), secrets: {}, }, ); @@ -239,129 +272,7 @@ Meta.test( Meta.test( { - name: "Python WASI: infinite loop or similar", - port: true, - systemTypegraphs: true, - }, - async (t) => { - const e = await t.engineFromTgDeployPython( - "runtimes/python_wasi/python_wasi.py", - cwd, - ); - - await t.should("safely fail upon stackoverflow", async () => { - await gql` - query { - stackOverflow(enable: true) - } - ` - .expectErrorContains("maximum recursion depth exceeded") - .on(e); - }); - - // let tic = 0; - // setTimeout(() => console.log("hearbeat", tic++), 100); - - // FIXME: blocks main deno thread - // current approach on deno_bindgen apply/applyDef needs to run on - // separate threads - // #[deno] works for applys but still manages to block the current thread - // await t.should("safely fail upon infinite loop", async () => { - // await gql` - // query { - // infiniteLoop(enable: true) - // } - // ` - // .expectErrorContains("timeout exceeded") - // .on(e); - // }); - }, -); - -Meta.test( - { - name: "Python WASI: reloading typegate", - port: true, - systemTypegraphs: true, - }, - async (metaTest) => { - const port = metaTest.port; - const gate = `http://localhost:${port}`; - - const load = async () => { - const { serialized, typegate: _gateResponseAdd } = await tgDeploy( - reusableTgOutput, - { - baseUrl: gate, - auth, - artifactsConfig: { - prismaMigration: { - globalAction: { - create: true, - reset: false, - }, - migrationDir: "prisma-migrations", - }, - dir: cwd, - }, - typegraphPath: path.join(cwd, "wasm.ts"), - secrets: {}, - }, - ); - - return await metaTest.engineFromDeployed(serialized); - }; - - const runPythonOnPythonWasi = async (currentEngine: QueryEngine) => { - await gql` - query { - identityDef(input: { a: "hello", b: [1, 2, "three"] }) { - a - b - } - identityLambda(input: { a: "hello", b: [1, 2, "three"] }) { - a - b - } - identityMod(input: { a: "hello", b: [1, 2, "three"] }) { - a - b - } - } - ` - .expectData({ - identityDef: { - a: "hello", - b: [1, 2, "three"], - }, - identityLambda: { - a: "hello", - b: [1, 2, "three"], - }, - identityMod: { - a: "hello", - b: [1, 2, "three"], - }, - }) - .on(currentEngine); - }; - const engine = await load(); - await metaTest.should("work before typegate is reloaded", async () => { - await runPythonOnPythonWasi(engine); - }); - - // reload - const reloadedEngine = await load(); - - await metaTest.should("work after typegate is reloaded", async () => { - await runPythonOnPythonWasi(reloadedEngine); - }); - }, -); - -Meta.test( - { - name: "Python WASI: upload artifacts with deps", + name: "Python: upload artifacts with deps", port: true, systemTypegraphs: true, }, @@ -385,7 +296,7 @@ Meta.test( }, dir: cwd, }, - typegraphPath: path.join(cwd, "pyton_wasi.ts"), + typegraphPath: path.join(cwd, "pyton.ts"), secrets: {}, }, ); @@ -413,14 +324,14 @@ Meta.test( Meta.test( { - name: "Python WASI: infinite loop or similar", + name: "Python: infinite loop or similar", sanitizeOps: false, port: true, systemTypegraphs: true, }, async (t) => { const e = await t.engineFromTgDeployPython( - "runtimes/python_wasi/python_wasi.py", + "runtimes/python/python.py", cwd, ); @@ -455,7 +366,7 @@ Meta.test( Meta.test( { - name: "Python WASI: typegate reloading", + name: "Python: typegate reloading", port: true, systemTypegraphs: true, }, @@ -479,7 +390,7 @@ Meta.test( }, dir: cwd, }, - typegraphPath: path.join(cwd, "python_wasi.ts"), + typegraphPath: path.join(cwd, "python.ts"), secrets: {}, }, ); @@ -487,7 +398,7 @@ Meta.test( return await metaTest.engineFromDeployed(serialized); }; - const runPythonOnPythonWasi = async (currentEngine: QueryEngine) => { + const runPythonOnPython = async (currentEngine: QueryEngine) => { await gql` query { identityDef(input: { a: "hello", b: [1, 2, "three"] }) { @@ -522,14 +433,14 @@ Meta.test( }; const engine = await load(); await metaTest.should("work before typegate is reloaded", async () => { - await runPythonOnPythonWasi(engine); + await runPythonOnPython(engine); }); // reload const reloadedEngine = await load(); await metaTest.should("work after typegate is reloaded", async () => { - await runPythonOnPythonWasi(reloadedEngine); + await runPythonOnPython(reloadedEngine); }); }, ); diff --git a/typegate/tests/runtimes/python_wasi/py/hello.py b/typegate/tests/runtimes/python_wasi/py/hello.py deleted file mode 100644 index 52d6a9ffdf..0000000000 --- a/typegate/tests/runtimes/python_wasi/py/hello.py +++ /dev/null @@ -1,9 +0,0 @@ -from nested.dep import hello - - -def sayHello(x: any): - return hello(x["name"]) - - -def identity(x: any): - return x["input"] diff --git a/typegate/tests/runtimes/wasm/rust.wasm b/typegate/tests/runtimes/wasm/rust.wasm deleted file mode 100644 index 5a954791b5..0000000000 Binary files a/typegate/tests/runtimes/wasm/rust.wasm and /dev/null differ diff --git a/typegate/tests/runtimes/wasm/rust/build.sh b/typegate/tests/runtimes/wasm/rust/build.sh deleted file mode 100755 index 1820252b2c..0000000000 --- a/typegate/tests/runtimes/wasm/rust/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env sh - -set -e - -cargo build --target wasm32-unknown-unknown -wasm-tools component new ./target/wasm32-unknown-unknown/debug/rust.wasm -o ./target/rust-component.wasm -# debug -wasm-tools component wit target/rust-component.wasm - -mv target/rust-component.wasm ../rust.wasm diff --git a/typegate/tests/runtimes/wasm/wasm.ts b/typegate/tests/runtimes/wasm/wasm.ts deleted file mode 100644 index de663b058e..0000000000 --- a/typegate/tests/runtimes/wasm/wasm.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { Policy, t, typegraph } from "@typegraph/sdk"; -import { WasmRuntime } from "@typegraph/sdk/runtimes/wasm.js"; - -export const tg = await typegraph("wasm-ts", (g: any) => { - const pub = Policy.public(); - const wasm = new WasmRuntime(); - const entity = t.struct({ - name: t.string(), - age: t.integer().optional(), - profile: t.struct({ - level: t.enum_(["bronze", "silver", "gold"]), // wit enum - attributes: t.list(t.enum_(["attack", "defend", "cast"])), // wit flags - category: t.struct({ // wit variant - tag: t.enum_(["a", "b", "c"]), - value: t.string().optional(), - }), - metadatas: t.list(t.list(t.either([t.string(), t.float()]))), - }), - }); - - g.expose({ - add: wasm - .fromWasm( - t.struct({ "a": t.float(), "b": t.float() }), - t.integer(), - { func: "add", wasm: "rust.wasm" }, - ).withPolicy(pub), - range: wasm - .fromWasm( - t.struct({ "a": t.integer().optional(), "b": t.integer() }), - t.list(t.integer()), - { func: "range", wasm: "rust.wasm" }, - ).withPolicy(pub), - record: wasm - .fromWasm( - t.struct({}), - t.list(entity), - { func: "record-creation", wasm: "rust.wasm" }, - ).withPolicy(pub), - identity: wasm - .fromWasm( - t.struct({ "arg0": entity }), - entity, - { func: "identity", wasm: "rust.wasm" }, - ).withPolicy(pub), - }); -}); diff --git a/typegate/tests/runtimes/wasm_reflected/rust.wasm b/typegate/tests/runtimes/wasm_reflected/rust.wasm new file mode 100644 index 0000000000..b60e774951 Binary files /dev/null and b/typegate/tests/runtimes/wasm_reflected/rust.wasm differ diff --git a/typegate/tests/runtimes/wasm/rust/Cargo.lock b/typegate/tests/runtimes/wasm_reflected/rust/Cargo.lock similarity index 100% rename from typegate/tests/runtimes/wasm/rust/Cargo.lock rename to typegate/tests/runtimes/wasm_reflected/rust/Cargo.lock diff --git a/typegate/tests/runtimes/wasm/rust/Cargo.toml b/typegate/tests/runtimes/wasm_reflected/rust/Cargo.toml similarity index 71% rename from typegate/tests/runtimes/wasm/rust/Cargo.toml rename to typegate/tests/runtimes/wasm_reflected/rust/Cargo.toml index b5cfcea6f8..02d1a7ae28 100644 --- a/typegate/tests/runtimes/wasm/rust/Cargo.toml +++ b/typegate/tests/runtimes/wasm_reflected/rust/Cargo.toml @@ -8,3 +8,7 @@ crate-type = ["cdylib"] [dependencies] wit-bindgen = "0.24.0" + +[profile.release] +strip = "symbols" +opt-level = "z" diff --git a/typegate/tests/runtimes/wasm_reflected/rust/build.sh b/typegate/tests/runtimes/wasm_reflected/rust/build.sh new file mode 100755 index 0000000000..d8b71f06ed --- /dev/null +++ b/typegate/tests/runtimes/wasm_reflected/rust/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +set -e + +cargo build --target wasm32-unknown-unknown --release +wasm-opt -Oz ./target/wasm32-unknown-unknown/release/rust.wasm -o ./target/rust-component.wasm.opt +wasm-tools component new ./target/rust-component.wasm.opt -o ./target/rust-component.wasm +# debug +wasm-tools component wit target/rust-component.wasm + +mv target/rust-component.wasm ../rust.wasm diff --git a/typegate/tests/runtimes/wasm/rust/src/lib.rs b/typegate/tests/runtimes/wasm_reflected/rust/src/lib.rs similarity index 100% rename from typegate/tests/runtimes/wasm/rust/src/lib.rs rename to typegate/tests/runtimes/wasm_reflected/rust/src/lib.rs diff --git a/typegate/tests/runtimes/wasm/rust/wit/example.wit b/typegate/tests/runtimes/wasm_reflected/rust/wit/example.wit similarity index 100% rename from typegate/tests/runtimes/wasm/rust/wit/example.wit rename to typegate/tests/runtimes/wasm_reflected/rust/wit/example.wit diff --git a/typegate/tests/runtimes/wasm/wasm.py b/typegate/tests/runtimes/wasm_reflected/wasm_reflected.py similarity index 90% rename from typegate/tests/runtimes/wasm/wasm.py rename to typegate/tests/runtimes/wasm_reflected/wasm_reflected.py index 634160cca2..feffec7500 100644 --- a/typegate/tests/runtimes/wasm/wasm.py +++ b/typegate/tests/runtimes/wasm_reflected/wasm_reflected.py @@ -16,15 +16,14 @@ @typegraph() -def wasm_py(g: Graph): +def wasm_reflected_py(g: Graph): pub = Policy.public() - wasm = WasmRuntime() + wasm = WasmRuntime.reflected("rust.wasm") g.expose( - test=wasm.from_wasm( + test=wasm.from_export( t.struct({"a": t.float(), "b": t.float()}), t.integer(), - wasm="rust.wasm", func="add", ).with_policy(pub), ) @@ -35,7 +34,7 @@ def wasm_py(g: Graph): gate = f"http://localhost:{PORT}" auth = BasicAuth("admin", "password") -wasm_tg = wasm_py() +wasm_tg = wasm_reflected_py() deploy_result = tg_deploy( wasm_tg, TypegraphDeployParams( diff --git a/typegate/tests/runtimes/wasm_reflected/wasm_reflected.ts b/typegate/tests/runtimes/wasm_reflected/wasm_reflected.ts new file mode 100644 index 0000000000..c3e71e5c81 --- /dev/null +++ b/typegate/tests/runtimes/wasm_reflected/wasm_reflected.ts @@ -0,0 +1,45 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { Policy, t, typegraph } from "@typegraph/sdk"; +import { WasmRuntime } from "@typegraph/sdk/runtimes/wasm.js"; + +export const tg = await typegraph("wasm-reflected-ts", (g: any) => { + const entity = t.struct({ + name: t.string(), + age: t.integer().optional(), + profile: t.struct({ + level: t.enum_(["bronze", "silver", "gold"]), // wit enum + attributes: t.list(t.enum_(["attack", "defend", "cast"])), // wit flags + category: t.struct({ // wit variant + tag: t.enum_(["a", "b", "c"]), + value: t.string().optional(), + }), + metadatas: t.list(t.list(t.either([t.string(), t.float()]))), + }), + }); + + const wasm = WasmRuntime.reflected("rust.wasm"); + g.expose({ + add: wasm.fromExport( + t.struct({ "a": t.float(), "b": t.float() }), + t.integer(), + { func: "add" }, + ), + range: wasm.fromExport( + t.struct({ "a": t.integer().optional(), "b": t.integer() }), + t.list(t.integer()), + { func: "range" }, + ), + record: wasm.fromExport( + t.struct({}), + t.list(entity), + { func: "record-creation" }, + ), + identity: wasm.fromExport( + t.struct({ "arg0": entity }), + entity, + { func: "identity" }, + ), + }, Policy.public()); +}); diff --git a/typegate/tests/runtimes/wasm/wasm_test.ts b/typegate/tests/runtimes/wasm_reflected/wasm_reflected_test.ts similarity index 92% rename from typegate/tests/runtimes/wasm/wasm_test.ts rename to typegate/tests/runtimes/wasm_reflected/wasm_reflected_test.ts index d33fbd94ce..dfc8a64590 100644 --- a/typegate/tests/runtimes/wasm/wasm_test.ts +++ b/typegate/tests/runtimes/wasm_reflected/wasm_reflected_test.ts @@ -4,20 +4,23 @@ import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js"; import { gql, Meta } from "test-utils/mod.ts"; import { testDir } from "test-utils/dir.ts"; -import { tg } from "./wasm.ts"; +import { tg } from "./wasm_reflected.ts"; import * as path from "std/path/mod.ts"; -const cwd = path.join(testDir, "runtimes/wasm"); +const cwd = path.join(testDir, "runtimes/wasm_reflected"); const auth = new BasicAuth("admin", "password"); Meta.test( { - name: "Wasm runtime", + name: "Wasm runtime: reflected", port: true, systemTypegraphs: true, }, async (t) => { - const e = await t.engineFromTgDeployPython("runtimes/wasm/wasm.py", cwd); + const e = await t.engineFromTgDeployPython( + path.join(cwd, "wasm_reflected.py"), + cwd, + ); await t.should("works", async () => { await gql` @@ -35,7 +38,7 @@ Meta.test( Meta.test( { - name: "Wasm Runtime typescript sdk", + name: "Wasm Runtime typescript sdk: reflected", port: true, systemTypegraphs: true, }, @@ -57,7 +60,7 @@ Meta.test( }, dir: cwd, }, - typegraphPath: path.join(cwd, "wasm.ts"), + typegraphPath: path.join(cwd, "wasm_reflected.ts"), secrets: {}, }); diff --git a/typegate/tests/runtimes/wasm_reflected/wasm_sync_test.ts b/typegate/tests/runtimes/wasm_reflected/wasm_sync_test.ts new file mode 100644 index 0000000000..ea1b83c24d --- /dev/null +++ b/typegate/tests/runtimes/wasm_reflected/wasm_sync_test.ts @@ -0,0 +1,166 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { BasicAuth, tgDeploy, tgRemove } from "@typegraph/sdk/tg_deploy.js"; +import { gql, Meta } from "test-utils/mod.ts"; +import { testDir } from "test-utils/dir.ts"; +import { tg } from "./wasm_reflected.ts"; +import * as path from "std/path/mod.ts"; +import { connect } from "redis"; +import { S3Client } from "aws-sdk/client-s3"; +import { createBucket, listObjects, tryDeleteBucket } from "test-utils/s3.ts"; +import { assertEquals, assertExists } from "std/assert/mod.ts"; + +const redisKey = "typegraph"; +const redisEventKey = "typegraph_event"; + +async function cleanUp() { + using redis = await connect(syncConfig.redis); + await redis.del(redisKey); + await redis.del(redisEventKey); + + const s3 = new S3Client(syncConfig.s3); + await tryDeleteBucket(s3, syncConfig.s3Bucket); + await createBucket(s3, syncConfig.s3Bucket); + s3.destroy(); + await redis.quit(); +} + +const syncConfig = { + redis: { + hostname: "localhost", + port: 6379, + password: "password", + db: 1, + }, + s3: { + endpoint: "http://localhost:9000", + region: "local", + credentials: { + accessKeyId: "minio", + secretAccessKey: "password", + }, + forcePathStyle: true, + }, + s3Bucket: "metatype-reflected-sync-test", +}; + +const cwd = path.join(testDir, "runtimes/wasm_reflected"); +const auth = new BasicAuth("admin", "password"); + +Meta.test( + { + name: "Wasm Runtime typescript SDK: Sync Config", + port: true, + systemTypegraphs: true, + syncConfig, + async setup() { + await cleanUp(); + }, + async teardown() { + await cleanUp(); + }, + }, + async (metaTest) => { + const port = metaTest.port; + const gate = `http://localhost:${port}`; + + const { serialized, typegate: gateResponseAdd } = await tgDeploy(tg, { + baseUrl: gate, + auth, + artifactsConfig: { + prismaMigration: { + globalAction: { + create: true, + reset: false, + }, + migrationDir: "prisma-migrations", + }, + dir: cwd, + }, + typegraphPath: path.join(cwd, "wasm_reflected.ts"), + secrets: {}, + }); + + await metaTest.should("work after deploying artifact to S3", async () => { + const s3 = new S3Client(syncConfig.s3); + assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 2); + + assertExists(serialized, "serialized has a value"); + assertEquals(gateResponseAdd, { + data: { + addTypegraph: { + name: "wasm-reflected-ts", + messages: [], + migrations: [], + }, + }, + }); + + const s3Objects = await listObjects(s3, syncConfig.s3Bucket); + // two objects, the artifact and the typegraph + assertEquals(s3Objects?.length, 2); + + const engine = await metaTest.engineFromDeployed(serialized); + + await gql` + query { + add(a: 11, b: 2) + range(a: 1, b: 4) + } + ` + .expectData({ + add: 13, + range: [1, 2, 3, 4], + }) + .on(engine); + + s3.destroy(); + }); + + await metaTest.should("work with multiple typegate instances", async () => { + const s3 = new S3Client(syncConfig.s3); + + // typegraphs are pushed to s3 whenever pushed to a typegate + assertEquals((await listObjects(s3, syncConfig.s3Bucket))?.length, 3); + + const engine = await metaTest.engineFromDeployed(serialized); + + await gql` + query { + add(a: 11, b: 2) + range(a: 1, b: 4) + } + ` + .expectData({ + add: 13, + range: [1, 2, 3, 4], + }) + .on(engine); + + // second engine on the other typegate instance + const engine2 = await metaTest.engineFromDeployed(serialized); + + await gql` + query { + add(a: 11, b: 2) + range(a: 1, b: 4) + } + ` + .expectData({ + add: 13, + range: [1, 2, 3, 4], + }) + .on(engine2); + + const { typegate: gateResponseRem } = await tgRemove(tg, { + baseUrl: gate, + auth, + }); + + assertEquals(gateResponseRem, { data: { removeTypegraphs: true } }); + + s3.destroy(); + }); + }, +); diff --git a/typegate/tests/runtimes/wasm_wire/rust.wasm b/typegate/tests/runtimes/wasm_wire/rust.wasm new file mode 100644 index 0000000000..3c60a8fce9 Binary files /dev/null and b/typegate/tests/runtimes/wasm_wire/rust.wasm differ diff --git a/typegate/tests/runtimes/wasm_wire/rust/Cargo.lock b/typegate/tests/runtimes/wasm_wire/rust/Cargo.lock new file mode 100644 index 0000000000..264d53ad93 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/rust/Cargo.lock @@ -0,0 +1,314 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "proc-macro2" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rust" +version = "0.0.1" +dependencies = [ + "anyhow", + "serde", + "serde_json", + "wit-bindgen", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "semver" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" + +[[package]] +name = "serde" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spdx" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ef1a0fa1e39ac22972c8db23ff89aea700ab96aa87114e1fb55937a631a0c9" +dependencies = [ + "smallvec", +] + +[[package]] +name = "syn" +version = "2.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "wasm-encoder" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd83062c17b9f4985d438603cde0a5e8c5c8198201a6937f778b607924c7da2" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e5df6dba6c0d7fafc63a450f1738451ed7a0b52295d83e868218fa286bf708" +dependencies = [ + "bitflags", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "288f992ea30e6b5c531b52cdd5f3be81c148554b09ea416f058d16556ba92c27" +dependencies = [ + "bitflags", + "wit-bindgen-rt", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e85e72719ffbccf279359ad071497e47eb0675fe22106dea4ed2d8a7fcb60ba4" +dependencies = [ + "anyhow", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb8738270f32a2d6739973cbbb7c1b6dd8959ce515578a6e19165853272ee64" + +[[package]] +name = "wit-bindgen-rust" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a39a15d1ae2077688213611209849cad40e9e5cccf6e61951a425850677ff3" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d376d3ae5850526dfd00d937faea0d81a06fa18f7ac1e26f386d760f241a8f4b" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "421c0c848a0660a8c22e2fd217929a0191f14476b68962afd2af89fd22e39825" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.201.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196d3ecfc4b759a8573bf86a9b3f8996b304b3732e4c7de81655f875f6efdca6" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] diff --git a/typegate/tests/runtimes/wasm_wire/rust/Cargo.toml b/typegate/tests/runtimes/wasm_wire/rust/Cargo.toml new file mode 100644 index 0000000000..595877dacb --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/rust/Cargo.toml @@ -0,0 +1,17 @@ +package.name = "rust" +package.edition = "2021" +package.version = "0.0.1" + +[lib] +path = "lib.rs" +crate-type = ["cdylib", "rlib"] + +[dependencies] +anyhow = "1" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +wit-bindgen = "0.22.0" + +[profile.release] +strip = "symbols" +opt-level = "z" diff --git a/typegate/tests/runtimes/wasm_wire/rust/build.sh b/typegate/tests/runtimes/wasm_wire/rust/build.sh new file mode 100755 index 0000000000..144d454112 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/rust/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +set -e + +pushd .. +cargo run -p meta-cli -- gen mdk wasm_wire +popd +cargo build --target wasm32-unknown-unknown --release +wasm-opt -Oz ./target/wasm32-unknown-unknown/release/rust.wasm -o ./target/rust-component.wasm.opt +wasm-tools component new ./target/rust-component.wasm.opt -o ./target/rust-component.wasm +# debug +wasm-tools component wit target/rust-component.wasm + +mv target/rust-component.wasm ../rust.wasm diff --git a/typegate/tests/runtimes/wasm_wire/rust/lib.rs b/typegate/tests/runtimes/wasm_wire/rust/lib.rs new file mode 100644 index 0000000000..44d512051c --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/rust/lib.rs @@ -0,0 +1,77 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +mod mdk; +use mdk::*; + +init_mat! { + hook: || { + // initialize global stuff here if you need it + MatBuilder::new() + // register function handlers here + .register_handler(stubs::Identity::erased(MyMat)) + .register_handler(stubs::Add::erased(MyMat)) + .register_handler(stubs::Range::erased(MyMat)) + .register_handler(stubs::RecordCreation::erased(MyMat)) + } +} + +struct MyMat; + +impl stubs::Identity for MyMat { + fn handle(&self, input: types::Entity, _cx: Ctx) -> anyhow::Result { + Ok(input) + } +} + +impl stubs::Add for MyMat { + fn handle(&self, input: types::AddArgs, _cx: Ctx) -> anyhow::Result { + Ok((input.a + input.b) as _) + } +} +impl stubs::Range for MyMat { + fn handle(&self, input: types::RangeArgs, _cx: Ctx) -> anyhow::Result> { + let a = input.a.unwrap_or(1); + let b = input.b; + if a > b { + anyhow::bail!("invalid range: {a} > {b}"); + } + Ok(Vec::from_iter(a..=b)) + } +} + +impl stubs::RecordCreation for MyMat { + fn handle(&self, _input: types::Object35, _cx: Ctx) -> anyhow::Result { + Ok(vec![ + types::Entity { + name: "Entity A".into(), + age: None, + profile: types::Profile { + category: types::Object9 { + tag: "a".into(), + value: None, + }, + level: "bronze".into(), + metadatas: vec![vec![ + types::Either12::String("strength".into()), + types::Either12::F64(3.14), + ]], + attributes: vec!["defend".into()], + }, + }, + types::Entity { + name: "Entity B".into(), + age: Some(11), + profile: types::Profile { + category: types::Object9 { + tag: "b".into(), + value: Some("bbb".into()), + }, + level: "gold".into(), + metadatas: vec![], + attributes: vec![format!("attack"), format!("defend"), format!("cast")], + }, + }, + ]) + } +} diff --git a/typegate/tests/runtimes/wasm_wire/rust/mdk.rs b/typegate/tests/runtimes/wasm_wire/rust/mdk.rs new file mode 100644 index 0000000000..84bc0864f7 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/rust/mdk.rs @@ -0,0 +1,310 @@ +// This file was @generated by metagen and is intended +// to be generated again on subsequent metagen runs. +#![cfg_attr(rustfmt, rustfmt_skip)] + +// gen-static-start +#![allow(unused)] + +pub mod wit { + wit_bindgen::generate!({ + pub_export_macro: true, + + inline: "package metatype:wit-wire; + +interface typegate-wire { + hostcall: func(req: tuple) -> result; +} + +interface mat-wire { + type json-str = string; + + record mat-info { + op-name: string, + mat-title: string, + mat-hash: string, + mat-data-json: string, + } + + record init-args { + metatype-version: string, + expected-ops: list + } + + record init-response { + ok: bool + } + + variant init-error { + version-mismatch(string), + unexpected-mat(mat-info), + other(string) + } + + init: func(args: init-args) -> result; + + record handle-req { + op-name: string, + in-json: json-str, + } + + variant handle-err { + no-handler, + in-json-err(string), + handler-err(string), + } + + handle: func(req: handle-req) -> result; +} + +world wit-wire { + import typegate-wire; + export mat-wire; +} +" + }); +} + +use std::cell::RefCell; +use std::collections::HashMap; + +use anyhow::Context; + +use wit::exports::metatype::wit_wire::mat_wire::*; + +pub type HandlerFn = Box Result>; + +pub struct ErasedHandler { + mat_id: String, + mat_trait: String, + mat_title: String, + handler_fn: HandlerFn, +} + +pub struct MatBuilder { + handlers: HashMap, +} + +impl MatBuilder { + pub fn new() -> Self { + Self { + handlers: Default::default(), + } + } + + pub fn register_handler(mut self, handler: ErasedHandler) -> Self { + self.handlers.insert(handler.mat_trait.clone(), handler); + self + } +} + +pub struct Router { + handlers: HashMap, +} + +impl Router { + pub fn from_builder(builder: MatBuilder) -> Self { + Self { + handlers: builder.handlers, + } + } + + pub fn init(&self, args: InitArgs) -> Result { + static MT_VERSION: &str = "0.3.7-0"; + if args.metatype_version != MT_VERSION { + return Err(InitError::VersionMismatch(MT_VERSION.into())); + } + for info in args.expected_ops { + let mat_trait = stubs::op_to_trait_name(&info.op_name); + if !self.handlers.contains_key(mat_trait) { + return Err(InitError::UnexpectedMat(info)); + } + } + Ok(InitResponse { ok: true }) + } + + pub fn handle(&self, req: HandleReq) -> Result { + let mat_trait = stubs::op_to_trait_name(&req.op_name); + let Some(handler) = self.handlers.get(mat_trait) else { + return Err(HandleErr::NoHandler); + }; + let cx = Ctx { + gql: GraphqlClient {}, + }; + (handler.handler_fn)(&req.in_json, cx) + } +} + +pub type InitCallback = fn() -> anyhow::Result; + +thread_local! { + pub static MAT_STATE: RefCell = panic!("MDK_STATE has not been initialized"); +} + +pub struct Ctx { + gql: GraphqlClient, +} + +pub struct GraphqlClient {} + +#[macro_export] +macro_rules! init_mat { + (hook: $init_hook:expr) => { + struct MatWireGuest; + use wit::exports::metatype::wit_wire::mat_wire::*; + wit::export!(MatWireGuest with_types_in wit); + + #[allow(unused)] + impl Guest for MatWireGuest { + fn handle(req: HandleReq) -> Result { + MAT_STATE.with(|router| { + let router = router.borrow(); + router.handle(req) + }) + } + + fn init(args: InitArgs) -> Result { + let hook = $init_hook; + let router = Router::from_builder(hook()); + let resp = router.init(args)?; + MAT_STATE.set(router); + Ok(resp) + } + } + }; +} +// gen-static-end +use types::*; +pub mod types { + use super::*; + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct AddArgs { + pub a: f64, + pub b: f64, + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct RangeArgs { + pub a: Option, + pub b: i64, + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct Object35 { + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct Object9 { + pub tag: String, + pub value: Option, + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + #[serde(untagged)] + pub enum Either12 { + String(String), + F64(f64), + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct Profile { + pub level: String, + pub attributes: Vec, + pub category: Object9, + pub metadatas: Vec>, + } + #[derive(Debug, serde::Serialize, serde::Deserialize)] + pub struct Entity { + pub name: String, + pub age: Option, + pub profile: Profile, + } + pub type Entity36 = Vec; +} +use stubs::*; +pub mod stubs { + use super::*; + pub trait Add: Sized + 'static { + fn erased(self) -> ErasedHandler { + ErasedHandler { + mat_id: "add".into(), + mat_title: "add".into(), + mat_trait: "Add".into(), + handler_fn: Box::new(move |req, cx| { + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{err}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{err}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{err}"))) + }), + } + } + + fn handle(&self, input: AddArgs, cx: Ctx) -> anyhow::Result; + } + pub trait Range: Sized + 'static { + fn erased(self) -> ErasedHandler { + ErasedHandler { + mat_id: "range".into(), + mat_title: "range".into(), + mat_trait: "Range".into(), + handler_fn: Box::new(move |req, cx| { + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{err}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{err}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{err}"))) + }), + } + } + + fn handle(&self, input: RangeArgs, cx: Ctx) -> anyhow::Result>; + } + pub trait RecordCreation: Sized + 'static { + fn erased(self) -> ErasedHandler { + ErasedHandler { + mat_id: "record-creation".into(), + mat_title: "record-creation".into(), + mat_trait: "RecordCreation".into(), + handler_fn: Box::new(move |req, cx| { + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{err}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{err}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{err}"))) + }), + } + } + + fn handle(&self, input: Object35, cx: Ctx) -> anyhow::Result; + } + pub trait Identity: Sized + 'static { + fn erased(self) -> ErasedHandler { + ErasedHandler { + mat_id: "identity".into(), + mat_title: "identity".into(), + mat_trait: "Identity".into(), + handler_fn: Box::new(move |req, cx| { + let req = serde_json::from_str(req) + .map_err(|err| HandleErr::InJsonErr(format!("{err}")))?; + let res = self + .handle(req, cx) + .map_err(|err| HandleErr::HandlerErr(format!("{err}")))?; + serde_json::to_string(&res) + .map_err(|err| HandleErr::HandlerErr(format!("{err}"))) + }), + } + } + + fn handle(&self, input: Entity, cx: Ctx) -> anyhow::Result; + } + pub fn op_to_trait_name(op_name: &str) -> &'static str { + match op_name { + "add" => "Add", + "record-creation" => "RecordCreation", + "range" => "Range", + "identity" => "Identity", + _ => panic!("unrecognized op_name: {op_name}"), + } + } +} diff --git a/typegate/tests/runtimes/wasm/wasm_sync_test.ts b/typegate/tests/runtimes/wasm_wire/wasm_sync_test.ts similarity index 92% rename from typegate/tests/runtimes/wasm/wasm_sync_test.ts rename to typegate/tests/runtimes/wasm_wire/wasm_sync_test.ts index 34f72aedf2..72bd25a9bc 100644 --- a/typegate/tests/runtimes/wasm/wasm_sync_test.ts +++ b/typegate/tests/runtimes/wasm_wire/wasm_sync_test.ts @@ -4,7 +4,7 @@ import { BasicAuth, tgDeploy, tgRemove } from "@typegraph/sdk/tg_deploy.js"; import { gql, Meta } from "test-utils/mod.ts"; import { testDir } from "test-utils/dir.ts"; -import { tg } from "./wasm.ts"; +import { tg } from "./wasm_wire.ts"; import * as path from "std/path/mod.ts"; import { connect } from "redis"; import { S3Client } from "aws-sdk/client-s3"; @@ -42,10 +42,10 @@ const syncConfig = { }, forcePathStyle: true, }, - s3Bucket: "metatype-sync-test", + s3Bucket: "metatype-wasm-wire-sync-test", }; -const cwd = path.join(testDir, "runtimes/wasm"); +const cwd = path.join(testDir, "runtimes/wasm_wire"); const auth = new BasicAuth("admin", "password"); Meta.test( @@ -78,7 +78,7 @@ Meta.test( }, dir: cwd, }, - typegraphPath: path.join(cwd, "wasm.ts"), + typegraphPath: path.join(cwd, "wasm_wire.ts"), secrets: {}, }); @@ -89,7 +89,11 @@ Meta.test( assertExists(serialized, "serialized has a value"); assertEquals(gateResponseAdd, { data: { - addTypegraph: { name: "wasm-ts", messages: [], migrations: [] }, + addTypegraph: { + name: "wasm-wire-ts", + messages: [], + migrations: [], + }, }, }); diff --git a/typegate/tests/runtimes/wasm_wire/wasm_wire.py b/typegate/tests/runtimes/wasm_wire/wasm_wire.py new file mode 100644 index 0000000000..260cbe73f4 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/wasm_wire.py @@ -0,0 +1,58 @@ +import os +import sys + +from typegraph.gen.exports.core import ( + ArtifactResolutionConfig, + MigrationAction, + MigrationConfig, +) +from typegraph.graph.shared_types import BasicAuth +from typegraph.graph.tg_deploy import TypegraphDeployParams, tg_deploy +from typegraph.graph.typegraph import Graph +from typegraph.policy import Policy +from typegraph.runtimes.wasm import WasmRuntime + +from typegraph import t, typegraph + + +@typegraph() +def wasm_wire_py(g: Graph): + wasm = WasmRuntime.wire("rust.wasm") + + g.expose( + Policy.public(), + test=wasm.handler( + t.struct({"a": t.float(), "b": t.float()}).rename("add_args"), + t.integer(), + func="add", + ).rename("add"), + ) + + +cwd = sys.argv[1] +PORT = sys.argv[2] +gate = f"http://localhost:{PORT}" +auth = BasicAuth("admin", "password") + +wasm_tg = wasm_wire_py() +deploy_result = tg_deploy( + wasm_tg, + TypegraphDeployParams( + base_url=gate, + auth=auth, + typegraph_path=os.path.join(cwd, "wasm.py"), + artifacts_config=ArtifactResolutionConfig( + dir=cwd, + prefix=None, + disable_artifact_resolution=None, + codegen=None, + prisma_migration=MigrationConfig( + migration_dir="prisma-migrations", + global_action=MigrationAction(reset=False, create=True), + runtime_actions=None, + ), + ), + ), +) + +print(deploy_result.serialized) diff --git a/typegate/tests/runtimes/wasm_wire/wasm_wire.ts b/typegate/tests/runtimes/wasm_wire/wasm_wire.ts new file mode 100644 index 0000000000..10c6f36040 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/wasm_wire.ts @@ -0,0 +1,47 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 + +import { Policy, t, typegraph } from "@typegraph/sdk"; +import { WasmRuntime } from "@typegraph/sdk/runtimes/wasm.js"; + +export const tg = await typegraph("wasm-wire-ts", (g: any) => { + const entity = t.struct({ + name: t.string(), + age: t.integer().optional(), + profile: t.struct({ + level: t.enum_(["bronze", "silver", "gold"]), // wit enum + attributes: t.list(t.enum_(["attack", "defend", "cast"])), // wit flags + category: t.struct({ // wit variant + tag: t.enum_(["a", "b", "c"]), + value: t.string().optional(), + }), + metadatas: t.list(t.list(t.either([t.string(), t.float()]))), + }).rename("profile"), + }).rename("entity"); + + const wasm = WasmRuntime.wire("rust.wasm"); + g.expose({ + add: wasm.handler( + t.struct({ "a": t.float(), "b": t.float() }).rename("add_args"), + t.integer(), + { func: "add" }, + ).rename("add"), + range: wasm.handler( + t.struct({ "a": t.integer().optional(), "b": t.integer() }).rename( + "range_args", + ), + t.list(t.integer()), + { func: "range" }, + ).rename("range"), + record: wasm.handler( + t.struct({}), + t.list(entity), + { func: "record-creation" }, + ).rename("record-creation"), + identity: wasm.handler( + entity, + entity, + { func: "identity" }, + ).rename("identity"), + }, Policy.public()); +}); diff --git a/typegate/tests/runtimes/wasm_wire/wasm_wire_test.ts b/typegate/tests/runtimes/wasm_wire/wasm_wire_test.ts new file mode 100644 index 0000000000..11970ec741 --- /dev/null +++ b/typegate/tests/runtimes/wasm_wire/wasm_wire_test.ts @@ -0,0 +1,189 @@ +// Copyright Metatype OÜ, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 +import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js"; +import { gql, Meta } from "test-utils/mod.ts"; +import { testDir } from "test-utils/dir.ts"; +import { tg } from "./wasm_wire.ts"; +import * as path from "std/path/mod.ts"; + +const cwd = path.join(testDir, "runtimes/wasm_wire"); +const auth = new BasicAuth("admin", "password"); + +Meta.test( + { + name: "Wasm runtime: wire", + port: true, + systemTypegraphs: true, + }, + async (t) => { + const e = await t.engineFromTgDeployPython( + path.join(cwd, "wasm_wire.py"), + cwd, + ); + + await t.should("works", async () => { + await gql` + query { + test(a: 1, b: 2) + } + ` + .expectData({ + test: 3, + }) + .on(e); + }); + }, +); + +Meta.test( + { + name: "Wasm Runtime typescript sdk: wire", + port: true, + systemTypegraphs: true, + }, + async (metaTest) => { + const port = metaTest.port; + const gate = `http://localhost:${port}`; + + await metaTest.should("work after deploying artifact", async (t) => { + const { serialized, typegate: _gateResponseAdd } = await tgDeploy(tg, { + baseUrl: gate, + auth, + artifactsConfig: { + prismaMigration: { + globalAction: { + create: true, + reset: false, + }, + migrationDir: "prisma-migrations", + }, + dir: cwd, + }, + typegraphPath: path.join(cwd, "wasm_wire.ts"), + secrets: {}, + }); + + const engine = await metaTest.engineFromDeployed(serialized); + + await t.step("wit bindings", async () => { + await gql` + query { + add(a: 11, b: 2) + range(a: 1, b: 4) + } + ` + .expectData({ + add: 13, + range: [1, 2, 3, 4], + }) + .on(engine); + }); + + await t.step("wit error should propagate gracefully", async () => { + await gql` + query { + range(a: 100, b: 1) + } + ` + .expectErrorContains("invalid range: 100 > 1") + .on(engine); + }); + + await t.step( + "nested wit output value should deserialize properly", + async () => { + await gql` + query { + record { + name + age + profile { + level + attributes + category { + tag + value + } + metadatas + } + } + } + ` + .expectData({ + record: [ + { + name: "Entity A", + age: null, + profile: { + attributes: ["defend"], + level: "bronze", + category: { tag: "a", value: null }, + metadatas: [["strength", 3.14]], + }, + }, + { + name: "Entity B", + age: 11, + profile: { + attributes: ["attack", "defend", "cast"], + level: "gold", + category: { tag: "b", value: "bbb" }, + metadatas: [], + }, + }, + ], + }) + .on(engine); + }, + ); + + await t.step("support nested wit input", async () => { + await gql` + query { + identity( + name: "Monster A" + age: null + profile: { + attributes: ["attack", "defend"] + level: "gold" + # category: { tag: "a", value: "unexpected" }, # fail! + category: { tag: "b", value: "payload" } + metadatas: [["a", 1.0], ["b", 1.3]] # list> + } + ) { + name + age + profile { + level + attributes + category { + tag + value + } + metadatas + } + } + } + ` + .expectData({ + identity: { + name: "Monster A", + age: null, + profile: { + attributes: ["attack", "defend"], + level: "gold", + category: { tag: "b", value: "payload" }, + metadatas: [ + ["a", 1.0], + ["b", 1.3], + ], + }, + }, + }) + .on(engine); + }); + + await engine.terminate(); + }); + }, +); diff --git a/typegate/tests/utils/bindings_test.ts b/typegate/tests/utils/bindings_test.ts index 202fa32d46..c5a26f09b3 100644 --- a/typegate/tests/utils/bindings_test.ts +++ b/typegate/tests/utils/bindings_test.ts @@ -8,6 +8,7 @@ import { validate_prisma_runtime_data, wasmtime_wit, } from "native"; +import type { WasmInput } from "../../engine/runtime.js"; function assert(val: T) { if (!val) throw Error("assertion failed"); @@ -149,7 +150,7 @@ Deno.test("typegraphValidate", () => { Deno.test("Wasm Wit", async () => { const input: WasmInput = { - wasm: "typegate/tests/runtimes/wasm/rust.wasm", + wasm: "typegate/tests/runtimes/wasm_reflected/rust.wasm", func: "add", args: [JSON.stringify(1), JSON.stringify(2)], }; diff --git a/typegate/tests/utils/shell.ts b/typegate/tests/utils/shell.ts index 30aa22a6aa..da868d0393 100644 --- a/typegate/tests/utils/shell.ts +++ b/typegate/tests/utils/shell.ts @@ -33,7 +33,6 @@ async function readOutput(p: Deno.ChildProcess): Promise { })(), ]); const status = await p.status; - console.log(status); return { stdout, stderr, code: status.code }; } diff --git a/typegraph/core/src/conversion/runtimes.rs b/typegraph/core/src/conversion/runtimes.rs index 5f5ac0db86..869b3a9059 100644 --- a/typegraph/core/src/conversion/runtimes.rs +++ b/typegraph/core/src/conversion/runtimes.rs @@ -316,15 +316,17 @@ impl MaterializerConverter for WasmMaterializer { effect: WitEffect, ) -> Result { let runtime = c.register_runtime(runtime_id)?; - let WasmMaterializer::Module(mat) = self; + let (name, func_name) = match &self { + WasmMaterializer::ReflectedFunc(func) => ("wasm_reflected_func", &func.func_name[..]), + WasmMaterializer::WireHandler(handler) => ("wasm_wire_handler", &handler.func_name[..]), + }; let data = serde_json::from_value(json!({ - "wasmArtifact": mat.wasm_artifact, - "func": mat.func_name, + "op_name": func_name, })) .map_err(|e| e.to_string())?; - let name = "wasm".to_string(); + let name = name.to_string(); Ok(Materializer { name, runtime, @@ -427,14 +429,21 @@ pub fn convert_runtime(_c: &mut TypegraphContext, runtime: Runtime) -> Result { - Ok(TGRuntime::Known(Rt::PythonWasi(PythonRuntimeData { config: None })).into()) + Ok(TGRuntime::Known(Rt::Python(PythonRuntimeData { config: None })).into()) } Runtime::Random(d) => Ok(TGRuntime::Known(Rt::Random(RandomRuntimeData { seed: d.seed, reset: d.reset.clone(), })) .into()), - Runtime::Wasm => Ok(TGRuntime::Known(Rt::Wasm(WasmRuntimeData { config: None })).into()), + Runtime::WasmReflected(data) => Ok(TGRuntime::Known(Rt::WasmReflected(WasmRuntimeData { + wasm_artifact: std::path::PathBuf::from(&data.wasm_artifact), + })) + .into()), + Runtime::WasmWire(data) => Ok(TGRuntime::Known(Rt::WasmWire(WasmRuntimeData { + wasm_artifact: std::path::PathBuf::from(&data.wasm_artifact), + })) + .into()), Runtime::Prisma(d, _) => Ok(ConvertedRuntime::Lazy(Box::new( move |runtime_id, runtime_idx, tg| -> Result<_> { let ctx = get_prisma_context(runtime_id); diff --git a/typegraph/core/src/runtimes/mod.rs b/typegraph/core/src/runtimes/mod.rs index 81952519d4..ad0953083d 100644 --- a/typegraph/core/src/runtimes/mod.rs +++ b/typegraph/core/src/runtimes/mod.rs @@ -28,7 +28,7 @@ use crate::wit::core::{FuncParams, MaterializerId, RuntimeId, TypeId as CoreType use crate::wit::runtimes::{ self as wit, BaseMaterializer, Error as TgError, GraphqlRuntimeData, HttpRuntimeData, MaterializerHttpRequest, PrismaLinkData, PrismaMigrationOperation, PrismaRuntimeData, - RandomRuntimeData, TemporalOperationData, TemporalRuntimeData, + RandomRuntimeData, TemporalOperationData, TemporalRuntimeData, WasmRuntimeData, }; use crate::{typegraph::TypegraphContext, wit::runtimes::Effect as WitEffect}; use enum_dispatch::enum_dispatch; @@ -57,7 +57,8 @@ pub enum Runtime { Http(Rc), Python, Random(Rc), - Wasm, + WasmWire(Rc), + WasmReflected(Rc), Prisma(Rc, Rc>), PrismaMigration, Temporal(Rc), @@ -175,7 +176,7 @@ pub enum MaterializerData { Http(Rc), Python(Rc), Random(Rc), - WasmEdge(Rc), + Wasm(Rc), Prisma(Rc), PrismaMigration(PrismaMigrationOperation), Temporal(Rc), @@ -355,15 +356,39 @@ impl crate::wit::runtimes::Guest for crate::Lib { Ok(Store::register_materializer(mat)) } - fn register_wasm_runtime() -> Result { - Ok(Store::register_runtime(Runtime::Wasm)) + fn register_wasm_reflected_runtime( + data: wit::WasmRuntimeData, + ) -> Result { + Ok(Store::register_runtime(Runtime::WasmReflected(data.into()))) } - fn from_wasm_module( + fn register_wasm_wire_runtime( + data: wit::WasmRuntimeData, + ) -> Result { + Ok(Store::register_runtime(Runtime::WasmWire(data.into()))) + } + + fn from_wasm_reflected_func( + base: wit::BaseMaterializer, + data: wit::MaterializerWasmReflectedFunc, + ) -> Result { + let mat = Materializer::wasm( + base.runtime, + WasmMaterializer::ReflectedFunc(data), + base.effect, + ); + Ok(Store::register_materializer(mat)) + } + + fn from_wasm_wire_handler( base: wit::BaseMaterializer, - data: wit::MaterializerWasm, + data: wit::MaterializerWasmWireHandler, ) -> Result { - let mat = Materializer::wasm(base.runtime, WasmMaterializer::Module(data), base.effect); + let mat = Materializer::wasm( + base.runtime, + WasmMaterializer::WireHandler(data), + base.effect, + ); Ok(Store::register_materializer(mat)) } @@ -390,14 +415,14 @@ impl crate::wit::runtimes::Guest for crate::Lib { prisma_op!(runtime, model, Aggregate, "aggregate") } - fn prisma_group_by(runtime: RuntimeId, model: CoreTypeId) -> Result { - prisma_op!(runtime, model, GroupBy, "groupBy") - } - fn prisma_count(runtime: RuntimeId, model: CoreTypeId) -> Result { prisma_op!(runtime, model, Count, "count") } + fn prisma_group_by(runtime: RuntimeId, model: CoreTypeId) -> Result { + prisma_op!(runtime, model, GroupBy, "groupBy") + } + fn prisma_create_one(runtime: RuntimeId, model: CoreTypeId) -> Result { prisma_op!( runtime, diff --git a/typegraph/core/src/runtimes/wasm.rs b/typegraph/core/src/runtimes/wasm.rs index df68ba8bb4..dc92261af4 100644 --- a/typegraph/core/src/runtimes/wasm.rs +++ b/typegraph/core/src/runtimes/wasm.rs @@ -5,5 +5,6 @@ use crate::wit::runtimes as wit; #[derive(Debug)] pub enum WasmMaterializer { - Module(wit::MaterializerWasm), + ReflectedFunc(wit::MaterializerWasmReflectedFunc), + WireHandler(wit::MaterializerWasmWireHandler), } diff --git a/typegraph/core/src/utils/postprocess/python_rt.rs b/typegraph/core/src/utils/postprocess/python_rt.rs index 0db7ff017f..fb6c33632c 100644 --- a/typegraph/core/src/utils/postprocess/python_rt.rs +++ b/typegraph/core/src/utils/postprocess/python_rt.rs @@ -28,7 +28,7 @@ impl PostProcessor for PythonProcessor { let python_module_path = fs_host::make_absolute(&path)?; - let (module_hash, size) = fs_host::hash_file(&python_module_path.clone())?; + let (module_hash, size) = fs_host::hash_file(&python_module_path)?; tg.deps.push(python_module_path); tg.meta.artifacts.insert( diff --git a/typegraph/core/src/utils/postprocess/wasm_rt.rs b/typegraph/core/src/utils/postprocess/wasm_rt.rs index b79d0bb785..b1cbb20ca0 100644 --- a/typegraph/core/src/utils/postprocess/wasm_rt.rs +++ b/typegraph/core/src/utils/postprocess/wasm_rt.rs @@ -2,7 +2,10 @@ // SPDX-License-Identifier: MPL-2.0 use crate::utils::fs_host; -use common::typegraph::{runtimes::Artifact, Typegraph}; +use common::typegraph::{ + runtimes::{Artifact, KnownRuntime, TGRuntime}, + Typegraph, +}; use std::path::PathBuf; use crate::utils::postprocess::PostProcessor; @@ -11,24 +14,27 @@ pub struct WasmProcessor; impl PostProcessor for WasmProcessor { fn postprocess(self, tg: &mut Typegraph) -> Result<(), crate::errors::TgError> { - for mat in tg.materializers.iter_mut() { - if mat.name.as_str() == "wasm" { - let path = mat.data.get("wasmArtifact").unwrap(); - let path: PathBuf = path.as_str().unwrap().into(); - - if tg.meta.artifacts.contains_key(&path) { + for rt in &tg.runtimes { + let data = match rt { + TGRuntime::Known(KnownRuntime::WasmReflected(data)) + | TGRuntime::Known(KnownRuntime::WasmWire(data)) => data, + _ => { continue; } + }; + let path = PathBuf::from(&data.wasm_artifact); + if tg.meta.artifacts.contains_key(&path) { + continue; + } - let wasi_path = fs_host::make_absolute(&path)?; + let wasi_path = fs_host::make_absolute(&path)?; - let (hash, size) = fs_host::hash_file(&wasi_path.clone())?; + let (hash, size) = fs_host::hash_file(&wasi_path)?; - tg.deps.push(wasi_path.clone()); - tg.meta - .artifacts - .insert(path.clone(), Artifact { hash, size, path }); - } + tg.deps.push(wasi_path.clone()); + tg.meta + .artifacts + .insert(path.clone(), Artifact { hash, size, path }); } Ok(()) } diff --git a/typegraph/core/wit/typegraph.wit b/typegraph/core/wit/typegraph.wit index 845b722185..fbf55057e5 100644 --- a/typegraph/core/wit/typegraph.wit +++ b/typegraph/core/wit/typegraph.wit @@ -368,13 +368,24 @@ interface runtimes { create-random-mat: func(base: base-materializer, data: materializer-random) -> result; // wasm - record materializer-wasm { - func-name: string, + + record wasm-runtime-data { wasm-artifact: string, } - register-wasm-runtime: func() -> result; - from-wasm-module: func(base: base-materializer, data: materializer-wasm) -> result; + record materializer-wasm-reflected-func { + func-name: string, + } + + register-wasm-reflected-runtime: func(data: wasm-runtime-data) -> result; + from-wasm-reflected-func: func(base: base-materializer, data: materializer-wasm-reflected-func) -> result; + + record materializer-wasm-wire-handler { + func-name: string, + } + + register-wasm-wire-runtime: func(data: wasm-runtime-data) -> result; + from-wasm-wire-handler: func(base: base-materializer, data: materializer-wasm-wire-handler) -> result; // prisma record prisma-runtime-data { diff --git a/typegraph/node/sdk/src/runtimes/wasm.ts b/typegraph/node/sdk/src/runtimes/wasm.ts index b606e1e3da..c4d2f40d07 100644 --- a/typegraph/node/sdk/src/runtimes/wasm.ts +++ b/typegraph/node/sdk/src/runtimes/wasm.ts @@ -7,36 +7,89 @@ import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; import { Materializer, Runtime } from "./mod.js"; import { fx } from "../index.js"; -interface WasmMat extends Materializer { - module: string; - funcMame: string; +export class WasmRuntime extends Runtime { + static reflected(modulePath: string) { + return new WasmRuntimeReflected(modulePath); + } + static wire(modulePath: string) { + return new WasmRuntimeWire(modulePath); + } +} + +interface ReflectedFuncWasmMat extends Materializer { + funcName: string; effect: Effect; } -export class WasmRuntime extends Runtime { - constructor() { - super(runtimes.registerWasmRuntime()); +interface WireHandlerWasmMat extends Materializer { + funcName: string; + effect: Effect; +} + +class WasmRuntimeWire extends WasmRuntime { + constructor(artifactPath: string) { + super( + runtimes.registerWasmWireRuntime({ + wasmArtifact: artifactPath, + }), + ); + } + + handler< + I extends t.Typedef = t.Typedef, + O extends t.Typedef = t.Typedef, + >( + inp: I, + out: O, + { func, effect = fx.read() }: { + func: string; + effect?: Effect; + }, + ): t.Func { + const matId = runtimes.fromWasmWireHandler( + { + runtime: this._id, + effect, + }, + { + funcName: func, + }, + ); + + return t.func(inp, out, { + _id: matId, + effect, + funcName: func, + }); + } +} + +class WasmRuntimeReflected extends WasmRuntime { + constructor(artifactPath: string) { + super( + runtimes.registerWasmReflectedRuntime({ + wasmArtifact: artifactPath, + }), + ); } - fromWasm< + fromExport< I extends t.Typedef = t.Typedef, O extends t.Typedef = t.Typedef, >( inp: I, out: O, - { func, wasm, effect = fx.read() }: { + { func, effect = fx.read() }: { func: string; - wasm: string; effect?: Effect; }, - ): t.Func { - const matId = runtimes.fromWasmModule( + ): t.Func { + const matId = runtimes.fromWasmReflectedFunc( { runtime: this._id, effect, }, { - wasmArtifact: wasm, funcName: func, }, ); @@ -44,8 +97,7 @@ export class WasmRuntime extends Runtime { return t.func(inp, out, { _id: matId, effect, - module: wasm, - funcMame: func, + funcName: func, }); } } diff --git a/typegraph/python/poetry.lock b/typegraph/python/poetry.lock index 20a456839b..24fc776425 100644 --- a/typegraph/python/poetry.lock +++ b/typegraph/python/poetry.lock @@ -15,6 +15,24 @@ files = [ six = ">=1.6.1,<2.0" wheel = ">=0.23.0,<1.0" +[[package]] +name = "importlib-resources" +version = "6.4.0" +description = "Read resources from Python packages" +optional = false +python-versions = ">=3.8" +files = [ + {file = "importlib_resources-6.4.0-py3-none-any.whl", hash = "sha256:50d10f043df931902d4194ea07ec57960f66a80449ff867bfe782b4c486ba78c"}, + {file = "importlib_resources-6.4.0.tar.gz", hash = "sha256:cdb2b453b8046ca4e3798eb1d84f3cce1446a0e8e7b5ef4efb600f19fc398145"}, +] + +[package.dependencies] +zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["jaraco.test (>=5.4)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] + [[package]] name = "python-box" version = "7.1.1" @@ -60,30 +78,33 @@ files = [ [[package]] name = "typing-extensions" -version = "4.10.0" +version = "4.11.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, - {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, + {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, + {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] [[package]] name = "wasmtime" -version = "18.0.2" +version = "20.0.0" description = "A WebAssembly runtime powered by Wasmtime" optional = false python-versions = ">=3.8" files = [ - {file = "wasmtime-18.0.2-py3-none-any.whl", hash = "sha256:49625d389ddd766f5416a1723a76a25473df1dbe6ad706902b7bdbfa549ec3df"}, - {file = "wasmtime-18.0.2-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:190f182e51f7f0e5340a7ffeb01519eb759748872a2bb227c6b1c055cbee61ce"}, - {file = "wasmtime-18.0.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:817c780eb506deaabe31cf23c5e9fe9ab9a1815bc0b805d292ec7502c495e10a"}, - {file = "wasmtime-18.0.2-py3-none-manylinux1_x86_64.whl", hash = "sha256:30adbf2fb380aae2d7cfd18c6f14d7633d62a8204caf185b7557b2364533268d"}, - {file = "wasmtime-18.0.2-py3-none-manylinux2014_aarch64.whl", hash = "sha256:c43d281df87af4139735aa62950d855499f58f72778b0e7a79488b3b8807d108"}, - {file = "wasmtime-18.0.2-py3-none-win_amd64.whl", hash = "sha256:7ccc88a9ee2bb601dbd1dc065a22af7b2f1a85c39b1aa8ebfb8ea57f78157d35"}, + {file = "wasmtime-20.0.0-py3-none-any.whl", hash = "sha256:6d9806e34c7cebe3d2ff4ba58a0c7db3648d4d952a0b6821aed4c4d966a4b312"}, + {file = "wasmtime-20.0.0-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:2ae53f5d84f071f42bf7c05da3bfe4a18e0b5ad801931188bff2e5092137213e"}, + {file = "wasmtime-20.0.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3f9ea16cf19039c5dc11d1f9a8f024ebb0d4c6cd1cbb2d0889797326f8ba5c06"}, + {file = "wasmtime-20.0.0-py3-none-manylinux1_x86_64.whl", hash = "sha256:137c92cfde23b9ed18a85d5d1a1bfa844f1322c3bd80bc36c3b5adc3322f4a6e"}, + {file = "wasmtime-20.0.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:69505f8c1f42815c3784f77df5b3be9f4742ede56299a0f2d7d71083893e855d"}, + {file = "wasmtime-20.0.0-py3-none-win_amd64.whl", hash = "sha256:8ddb958a1b6eed88e56ec4aaae9478c273bed2e4fcd3331f29fda8d9d12def3d"}, ] +[package.dependencies] +importlib-resources = ">=5.10" + [package.extras] testing = ["coverage", "pycparser", "pytest", "pytest-mypy"] @@ -101,7 +122,22 @@ files = [ [package.extras] test = ["pytest (>=6.0.0)", "setuptools (>=65)"] +[[package]] +name = "zipp" +version = "3.18.1" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.8" +files = [ + {file = "zipp-3.18.1-py3-none-any.whl", hash = "sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b"}, + {file = "zipp-3.18.1.tar.gz", hash = "sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] + [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" -content-hash = "56e8d570e226c410bc7f7e5161672004c4796a7e84637e7fe2893988a8a350ee" +content-hash = "054c721c7557b8c008b8d2baeada154e0c0b2e8b0812b34440c2bcb0f5cf525a" diff --git a/typegraph/python/pyproject.toml b/typegraph/python/pyproject.toml index 5e10142fcc..8262743705 100644 --- a/typegraph/python/pyproject.toml +++ b/typegraph/python/pyproject.toml @@ -15,7 +15,7 @@ classifiers = [ [tool.poetry.dependencies] python = ">=3.8,<4.0" -wasmtime = "^18.0.2" +wasmtime = "^20.0.0" typing-extensions = "^4.8.0" python-box = "^7.1.1" astunparse = "^1.6.3" diff --git a/typegraph/python/typegraph/runtimes/wasm.py b/typegraph/python/typegraph/runtimes/wasm.py index b6e5b06a19..1d225d8b12 100644 --- a/typegraph/python/typegraph/runtimes/wasm.py +++ b/typegraph/python/typegraph/runtimes/wasm.py @@ -1,13 +1,15 @@ # Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. # SPDX-License-Identifier: MPL-2.0 from dataclasses import dataclass -from typing import List, Optional +from typing import Optional from typegraph.gen.exports.runtimes import ( BaseMaterializer, Effect, EffectRead, - MaterializerWasm, + WasmRuntimeData, + MaterializerWasmReflectedFunc, + MaterializerWasmWireHandler, ) from typegraph.gen.types import Err from typegraph.runtimes.base import Materializer, Runtime @@ -17,24 +19,45 @@ class WasmRuntime(Runtime): - def __init__(self): - super().__init__(runtimes.register_wasm_runtime(store)) + @staticmethod + def reflected(module_path: str) -> "WasmRuntimeReflected": + return WasmRuntimeReflected(artifact_path=module_path) - def from_wasm( + @staticmethod + def wire(module_path: str) -> "WasmRuntimeWire": + return WasmRuntimeWire(artifact_path=module_path) + + +@dataclass +class WireWasmMat(Materializer): + func_name: str + + +class WasmRuntimeWire(WasmRuntime): + def __init__(self, artifact_path: str): + runtime_id = runtimes.register_wasm_wire_runtime( + store, + data=WasmRuntimeData(wasm_artifact=artifact_path), + ) + if isinstance(runtime_id, Err): + raise Exception(runtime_id.value) + + super().__init__(runtime_id.value) + + def handler( self, inp: "t.struct", out: "t.typedef", *, func: str, - wasm: str, effect: Optional[Effect] = None, ): effect = effect or EffectRead() - mat_id = runtimes.from_wasm_module( + mat_id = runtimes.from_wasm_wire_handler( store, - BaseMaterializer(runtime=self.id.value, effect=effect), - MaterializerWasm(wasm_artifact=wasm, func_name=func), + BaseMaterializer(runtime=self.id, effect=effect), + MaterializerWasmWireHandler(func_name=func), ) if isinstance(mat_id, Err): @@ -43,12 +66,47 @@ def from_wasm( return t.func( inp, out, - WasmMat(id=mat_id.value, module=wasm, func_name=func, effect=effect), + WireWasmMat(id=mat_id.value, func_name=func, effect=effect), ) @dataclass -class WasmMat(Materializer): - module: str +class ReflectedWasmMat(Materializer): func_name: str - effect: List[str] + + +class WasmRuntimeReflected(WasmRuntime): + def __init__(self, artifact_path: str): + runtime_id = runtimes.register_wasm_reflected_runtime( + store, + data=WasmRuntimeData(wasm_artifact=artifact_path), + ) + if isinstance(runtime_id, Err): + raise Exception(runtime_id.value) + + super().__init__(runtime_id.value) + + def from_export( + self, + inp: "t.struct", + out: "t.typedef", + *, + func: str, + effect: Optional[Effect] = None, + ): + effect = effect or EffectRead() + + mat_id = runtimes.from_wasm_reflected_func( + store, + BaseMaterializer(runtime=self.id, effect=effect), + MaterializerWasmReflectedFunc(func_name=func), + ) + + if isinstance(mat_id, Err): + raise Exception(mat_id.value) + + return t.func( + inp, + out, + ReflectedWasmMat(id=mat_id.value, func_name=func, effect=effect), + ) diff --git a/website/docs/reference/runtimes/deno/index.mdx b/website/docs/reference/runtimes/deno/index.mdx index fcc49ef51d..26cfb67ee8 100644 --- a/website/docs/reference/runtimes/deno/index.mdx +++ b/website/docs/reference/runtimes/deno/index.mdx @@ -53,4 +53,4 @@ export function doAddition({ a, b }: AddInput) { return a + b; } -``` \ No newline at end of file +``` diff --git a/website/docs/reference/runtimes/python/index.mdx b/website/docs/reference/runtimes/python/index.mdx index 253fa00dae..b43c278d40 100644 --- a/website/docs/reference/runtimes/python/index.mdx +++ b/website/docs/reference/runtimes/python/index.mdx @@ -38,5 +38,3 @@ def example_python(g: Graph): def say_hello(x: any): return f"Hello {x["name"]}" ``` - - \ No newline at end of file diff --git a/website/docs/reference/runtimes/s3/index.mdx b/website/docs/reference/runtimes/s3/index.mdx index e7aaf1e80a..89286a4e4d 100644 --- a/website/docs/reference/runtimes/s3/index.mdx +++ b/website/docs/reference/runtimes/s3/index.mdx @@ -4,4 +4,4 @@ import S3Intro from "@site/shared/s3/index.mdx"; ## S3 runtime - \ No newline at end of file + diff --git a/website/docs/reference/typegate/index.mdx b/website/docs/reference/typegate/index.mdx index 5c344e2d1d..8cf11337e9 100644 --- a/website/docs/reference/typegate/index.mdx +++ b/website/docs/reference/typegate/index.mdx @@ -81,4 +81,3 @@ The following environment variables can be used to configure the typegate. `SYNC | SYNC_S3_SECRET_KEY | Access key secret for the S3 store credentials. | | | SYNC_S3_PATH_STYLE | `true` or `false`, force path style if `true`. | | | SYNC_S3_BUCKET | The bucket to be used for the system (dedicated). | | - diff --git a/website/docs/reference/typegate/synchronization/index.mdx b/website/docs/reference/typegate/synchronization/index.mdx index d207ad063f..1b92715ee6 100644 --- a/website/docs/reference/typegate/synchronization/index.mdx +++ b/website/docs/reference/typegate/synchronization/index.mdx @@ -80,4 +80,3 @@ and some required `SYNC_*` variable is missing. - Sharing typegraphs accross multiple typegate instances - History (WIP) - diff --git a/website/docs/reference/types/parameter-transformations.mdx b/website/docs/reference/types/parameter-transformations.mdx index 46cfd32bac..11da9aeff3 100644 --- a/website/docs/reference/types/parameter-transformations.mdx +++ b/website/docs/reference/types/parameter-transformations.mdx @@ -278,4 +278,3 @@ Apply expression | Source `g.from_context(path)` | The node will have the value of the context field accessible by the path `path`. `g.from_secret(key)` | The node will have the value of the secret named `key` on the current typegraph. `g.set(literal_value)` | The passed `literal_value` will be used. - diff --git a/website/docs/reference/types/reducers.mdx b/website/docs/reference/types/reducers.mdx new file mode 100644 index 0000000000..840b86d476 --- /dev/null +++ b/website/docs/reference/types/reducers.mdx @@ -0,0 +1 @@ +# Reducers diff --git a/website/shared/install/meta-cli.mdx b/website/shared/install/meta-cli.mdx index 716a7f3d1f..985291c4f1 100644 --- a/website/shared/install/meta-cli.mdx +++ b/website/shared/install/meta-cli.mdx @@ -8,36 +8,11 @@ You can download the binary from the [releases page](https://github.com/metatypedev/metatype/releases/), make it executable and add it to your `PATH` or use the automated method below. -- First, you start by installing `Meta CLI`. The installer may ask for your password. +- An installer script is also provided for the CLI in our repository. Curl and install in it with the following one-liner. The installer may ask for your password. ```bash curl -fsSL https://raw.githubusercontent.com/metatypedev/metatype/main/installer.sh | bash ``` -- Next, you need to install [libwasmedge](https://wasmedge.org/docs/contribute/source/build_from_src/#what-will-be-built), which is a dependency to run `Meta CLI` on your machine. - ```bash - export WASMEDGE_VERSION=0.13.8 - curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v $WASMEDGE_VERSION - ``` - -- After successfully installing `libwasmedge`, you need to set it as a path variable to access it from terminal. You can use the following command to set the path variable, but it's advisable to add it to your shell rc permanently. - ```bash - # for macOS, - export DYLD_LIBRARY_PATH=~/.wasmedge/lib - ``` - - ```bash - # for linux, - export LD_LIBRARY_PATH=~/.wasmedge/lib - ``` - -- A `thin` version of the cli that doesn't rely on libwasmedge is also provided. -This version of the cli doesn't offer the `typegate` command that lets you spin up a typegate for development purposes. -To install it, you can pass `META_THIN=1` environment variable to the installer script or download it from the github releases. - ```bash - export META_THIN=1 - curl -fsSL https://raw.githubusercontent.com/metatypedev/metatype/main/installer.sh | bash - ``` - - For later use, you can run the following command to upgrade `Meta CLI` to a newer version. If your Meta CLI is up to date, you will get an `Already up to date!` response. ```bash meta upgrade diff --git a/website/static/specs/0.0.3.json b/website/static/specs/0.0.3.json index ab7f97e20e..9a7f7bcb89 100644 --- a/website/static/specs/0.0.3.json +++ b/website/static/specs/0.0.3.json @@ -1646,7 +1646,7 @@ "name": { "type": "string", "enum": [ - "python_wasi" + "python" ] }, "data": { @@ -1754,7 +1754,25 @@ "name": { "type": "string", "enum": [ - "wasm" + "wasm_reflected" + ] + }, + "data": { + "$ref": "#/definitions/WasmRuntimeData" + } + } + }, + { + "type": "object", + "required": [ + "data", + "name" + ], + "properties": { + "name": { + "type": "string", + "enum": [ + "wasm_wire" ] }, "data": { @@ -2293,12 +2311,12 @@ }, "WasmRuntimeData": { "type": "object", + "required": [ + "wasm_artifact" + ], "properties": { - "config": { - "type": [ - "string", - "null" - ] + "wasm_artifact": { + "type": "string" } } }, @@ -2572,11 +2590,29 @@ "title": "ModuleMatData", "type": "object", "required": [ - "code" + "denoArtifact", + "deps" ], "properties": { - "code": { - "type": "string" + "denoArtifact": { + "type": "object", + "additionalProperties": true + }, + "deps": { + "type": "array", + "items": { + "type": "string" + } + }, + "depsMeta": { + "type": [ + "array", + "null" + ], + "items": { + "type": "object", + "additionalProperties": true + } } } }, @@ -2766,10 +2802,10 @@ "title": "WasmMatData", "type": "object", "required": [ - "wasmArtifact" + "opName" ], "properties": { - "wasmArtifact": { + "opName": { "type": "string" } } diff --git a/whiz.yaml b/whiz.yaml index 9880e852d1..43c07eade9 100644 --- a/whiz.yaml +++ b/whiz.yaml @@ -3,6 +3,7 @@ env: CLICOLOR_FORCE: "1" RUST_LOG: "typegate=info,typegate_engine=info,mt_deno=info,swc_ecma_codegen=off,tracing::span=off,error" NPM_CONFIG_REGISTRY: http://localhost:4873 + WASMTIME_BACKTRACE_DETAILS: "1" gate1: &tp watch: @@ -104,13 +105,13 @@ setup: - typegraph/python/pyproject.toml - website/package.json env: - GHJK_VERSION: "423d38e" + GHJK_VERSION: "2725af8" command: | set -e curl -fsSL https://raw.githubusercontent.com/metatypedev/ghjk/$GHJK_VERSION/install.sh | bash . $(ghjk print share-dir-path)/env.sh ghjk p sync - echo "exec ./. to refresh env vars" - [ -d .venv ] || python3 -m venv .venv + echo "cd ./. to refresh env vars" + [ -d .venv ] || python3 -m venv .venv && echo "virtual env created" poetry install --sync --no-root yes | pnpm install --recursive --filter ./website/... --filter ./typegraph/node/... diff --git a/wit/wit-wire.wit b/wit/wit-wire.wit new file mode 100644 index 0000000000..52786b929c --- /dev/null +++ b/wit/wit-wire.wit @@ -0,0 +1,51 @@ +package metatype:wit-wire; + +interface typegate-wire { + hostcall: func(req: tuple) -> result; +} + +interface mat-wire { + type json-str = string; + + record mat-info { + op-name: string, + mat-title: string, + mat-hash: string, + mat-data-json: string, + } + + record init-args { + metatype-version: string, + expected-ops: list + } + + record init-response { + ok: bool + } + + variant init-error { + version-mismatch(string), + unexpected-mat(mat-info), + other(string) + } + + init: func(args: init-args) -> result; + + record handle-req { + op-name: string, + in-json: json-str, + } + + variant handle-err { + no-handler, + in-json-err(string), + handler-err(string), + } + + handle: func(req: handle-req) -> result; +} + +world wit-wire { + import typegate-wire; + export mat-wire; +}