diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59ae7cf4cd..c1377ed7fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -124,14 +124,15 @@ jobs: cd ../.. npm install --global @bytecodealliance/jco@$JCO_VERSION - jco transpile $WASM_FILE -o typegraph/deno/src/gen - deno run -A typegraph/deno/dev/fix-declarations.ts - - cd typegraph/deno/src - deno run -A ../../../dev/publish.ts - cd ../../.. + jco transpile $WASM_FILE -o typegraph/node/src/gen cd typegraph/node + pnpm install + pnpm run sdk-build + cp ./sdk/{package.json,package-lock.json,LICENSE.md} ./sdk/dist + cd ../.. + + cd typegraph/node/sdk/dist pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" pnpm publish --no-git-checks - uses: svenstaro/upload-release-action@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 53d75c0e70..6d40aadf0c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -296,9 +296,13 @@ jobs: mkdir -p $(dirname $WASM_FILE) wasm-opt -Oz target/wasm/wasm32-unknown-unknown/debug/typegraph_core.wasm -o $WASM_FILE.opt wasm-tools component new $WASM_FILE.opt -o $WASM_FILE - rm -rf typegraph/deno/src/gen - jco transpile $WASM_FILE -o typegraph/deno/src/gen - deno run -A typegraph/deno/dev/fix-declarations.ts + rm -rf typegraph/node/sdk/src/gen typegraph/node/sdk/dist + jco transpile $WASM_FILE -o typegraph/node/sdk/src/gen + cd typegraph/node + pnpm install + pnpm run sdk-build + cp ./sdk/{package.json,package-lock.json,LICENSE.md} ./sdk/dist + cd ../.. rm -rf typegraph/python/typegraph/gen poetry run python -m wasmtime.bindgen $WASM_FILE --out-dir typegraph/python/typegraph/gen diff --git a/.gitignore b/.gitignore index 2efe5508df..2a2f16c925 100644 --- a/.gitignore +++ b/.gitignore @@ -40,8 +40,7 @@ recipe.json tmp/ coverage* -typegraph/node -typegraph/deno/src/gen +typegraph/node/sdk/src/gen typegraph/python/typegraph/gen *.egg-info/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 7152915ef7..c2d9c7ad6b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,8 +9,7 @@ "typegate", "dev", "examples/templates/deno", - "typegraph/core/tests/typegraphs/deno", - "typegraph/deno" + "typegraph/node/dev" ], "deno.unstable": true, "deno.suggest.completeFunctionCalls": true, @@ -30,8 +29,8 @@ "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.organizeImports": true + "source.fixAll": "explicit", + "source.organizeImports": "explicit" } }, "[typescript]": { diff --git a/Cargo.lock b/Cargo.lock index 16d8b6ef6b..d82503907d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,7 +454,7 @@ version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "cfg-if", "concurrent-queue", "futures-io", @@ -478,9 +478,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ "event-listener 4.0.3", "event-listener-strategy", @@ -943,7 +943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel", - "async-lock 3.2.0", + "async-lock 3.3.0", "async-task", "fastrand 2.0.1", "futures-io", @@ -954,9 +954,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d4d6dafc1a3bb54687538972158f07b2c948bc57d5890df22c0739098b3028" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive", "cfg_aliases", @@ -964,9 +964,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ "once_cell", "proc-macro-crate", @@ -4386,9 +4386,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "b553656127a00601c8ae5590fcfdc118e4083a7924b6cf4ffc1ea4b99dc429d7" dependencies = [ "bytes", "fnv", @@ -7275,11 +7275,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +checksum = "6b2685dd208a3771337d8d386a89840f0f43cd68be8dae90a5f8c2384effc9cd" dependencies = [ - "toml_edit 0.20.7", + "toml_edit", ] [[package]] @@ -9092,9 +9092,9 @@ dependencies = [ [[package]] name = "simd-json" -version = "0.13.6" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c58001aca67fc467da571f35e7e1dc9c094e91b099cc54bd3cead2962db2432" +checksum = "0a9511d2aa0b26dce65ea3860321cd680a8daeb6808b04f1e94429e0389ad952" dependencies = [ "getrandom 0.2.12", "halfbrown", @@ -10270,9 +10270,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -10634,7 +10634,7 @@ dependencies = [ "serde 1.0.195", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit", ] [[package]] @@ -10646,17 +10646,6 @@ dependencies = [ "serde 1.0.195", ] -[[package]] -name = "toml_edit" -version = "0.20.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" -dependencies = [ - "indexmap 2.1.0", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.21.0" @@ -12128,9 +12117,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.33" +version = "0.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" +checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] diff --git a/dev/lock.yml b/dev/lock.yml index 98ea058abb..2d80919e81 100644 --- a/dev/lock.yml +++ b/dev/lock.yml @@ -2,7 +2,8 @@ dev: files: dev/LICENSE-MPL-2.0.md: - typegraph/python/LICENSE.md - - typegraph/deno/LICENSE.md + - typegraph/node/LICENSE.md + - typegraph/node/sdk/LICENSE.md lines: rust-toolchain.toml: (channel = ").+("): RUST_VERSION @@ -25,6 +26,12 @@ dev: '([\s-]+uses:\s+metatypedev/setup-ghjk@).+()': GHJK_ACTION_VERSION typegraph/python/typegraph/__init__.py: (version = ").+("): METATYPE_VERSION + typegraph/node/sdk/package.json: + '(\s*"version"\s*:\s*").+(",?)': METATYPE_VERSION + '(\s*"description"\s*:\s*").*(",?)': TAGLINE + typegraph/node/package.json: + '(\s*"version"\s*:\s*").+(",?)': METATYPE_VERSION + '(\s*"description"\s*:\s*").*(",?)': TAGLINE typegraph/python/pyproject.toml: (description = ").+("): TAGLINE '**/Cargo.toml': @@ -72,7 +79,7 @@ dev: PNPM_VERSION: v8.8.0 CARGO_INSTA_VERSION: 1.33.0 WASM_TOOLS_VERSION: 1.0.53 - JCO_VERSION: 0.12.1 + JCO_VERSION: 0.14.2 WASMTIME_VERSION: 13.0.2 WASMEDGE_VERSION: 0.13.5 TYPEGRAPH_VERSION: 0.0.3 diff --git a/dev/publish.ts b/dev/publish.ts deleted file mode 100644 index 511a6e0ca9..0000000000 --- a/dev/publish.ts +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 - -import { dnt, expandGlobSync, resolve } from "./deps.ts"; -import { getLockfile, projectDir } from "./utils.ts"; - -// Direct node users need to use module -// module = Node16 or moduleResolution = Node16 inside tsconfig.json seems to be enough -// https://github.com/denoland/dnt/issues/205 - -const lockfile = await getLockfile(); - -const srcDir = resolve(projectDir, "./typegraph/deno/src"); -const outDir = resolve(projectDir, "./typegraph/node"); -await dnt.emptyDir(outDir); - -const entryPoints: dnt.BuildOptions["entryPoints"] = ["./mod.ts"]; -for ( - const { name, path } of expandGlobSync("./**/*.ts", { - root: srcDir, - includeDirs: false, - globstar: true, - }) -) { - const relPath = path.replace(srcDir, "."); - if ( - !relPath.startsWith("./gen") && !name.startsWith("_") && name !== "mod.ts" - ) { - entryPoints.push({ - name: relPath.slice(0, -3), - path: relPath, - }); - } -} - -// runs in cwd: https://github.com/denoland/dnt/issues/337 -await dnt.build({ - entryPoints, - outDir, - shims: { - deno: true, - }, - compilerOptions: { - target: "ES2020", - }, - test: false, - scriptModule: false, // only generate ESM - typeCheck: "single", - packageManager: "pnpm", - package: { - name: "@typegraph/sdk", - version: lockfile.dev.lock.METATYPE_VERSION, - description: lockfile.dev.lock.TAGLINE, - license: "MPL-2.0", - repository: { - type: "git", - url: "git+https://github.com/metatypedev/metatype.git", - }, - bugs: { - url: "https://github.com/metatypedev/metatype/issues", - }, - }, - postBuild() { - const wasm = "./typegraph/deno/src/gen/typegraph_core.core.wasm"; - const files = [ - ["./dev/LICENSE-MPL-2.0.md", "./LICENSE.md"], - [wasm, "./esm/gen/typegraph_core.core.wasm"], - ]; - for (const [src, dest] of files) { - Deno.copyFileSync(resolve(projectDir, src), resolve(outDir, dest)); - } - // remove source (comment when debugging) - Deno.removeSync(resolve(outDir, "src"), { recursive: true }); - }, -}); diff --git a/examples/templates/node/package.json b/examples/templates/node/package.json index 0f43c5f59d..d9a41c2245 100644 --- a/examples/templates/node/package.json +++ b/examples/templates/node/package.json @@ -3,8 +3,8 @@ "type": "module", "version": "1.0.0", "scripts": { - "load-tgraph": "tsx", - "dev": "MCLI_LOADER_CMD='npm load-tgraph' meta-cli dev" + "load-tgraph": "npx tsx api/example.ts", + "dev": "MCLI_LOADER_CMD='npm run load-tgraph --silent' meta dev" }, "dependencies": { "@typegraph/sdk": "^0.2.4" diff --git a/examples/templates/node/tsconfig.json b/examples/templates/node/tsconfig.json index aa534ac5f6..8fdbef4da1 100644 --- a/examples/templates/node/tsconfig.json +++ b/examples/templates/node/tsconfig.json @@ -2,6 +2,6 @@ "compilerOptions": { "strict": true, "moduleResolution": "node16", - "esModuleInterop": true + "esModuleInterop": true } } diff --git a/ghjk.ts b/ghjk.ts index 99c1bb56eb..ebbd04cb06 100644 --- a/ghjk.ts +++ b/ghjk.ts @@ -7,7 +7,7 @@ const POETRY_VERSION = "1.7.0"; const PYTHON_VERSION = "3.8.18"; const PNPM_VERSION = "v8.8.0"; const WASM_TOOLS_VERSION = "1.0.53"; -const JCO_VERSION = "0.12.1"; +const JCO_VERSION = "0.14.2"; const WASMEDGE_VERSION = "0.13.5"; const WASM_OPT_VERSION = "0.116.0"; const MOLD_VERSION = "v2.4.0"; diff --git a/typegate/import_map.json b/typegate/import_map.json index 9026d3b0c5..933dd6f634 100644 --- a/typegate/import_map.json +++ b/typegate/import_map.json @@ -23,7 +23,7 @@ "outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts", "json-schema-faker": "npm:json-schema-faker@0.5.3", "ajv": "https://esm.sh/ajv@8.12.0?pin=v131", - "@typegraph/sdk/": "../typegraph/deno/src/", + "@typegraph/sdk/": "../typegraph/node/sdk/dist/", "test-utils/": "./tests/utils/" } } diff --git a/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap b/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap index 63f70d84bb..fd0b992384 100644 --- a/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap +++ b/typegate/tests/e2e/typegraph/__snapshots__/typegraph_test.ts.snap @@ -1569,7 +1569,7 @@ snapshot[`typegraphs creation 6`] = ` "idempotent": true }, "data": { - "code": "file:scripts/three.ts;base64:H4sIAAAAAAAA/+0Y7W7bRsy//RSE/lTqFMWSk2BQ12JdW6wFOjRoM2BAYBhn6eQIlXSadJptGH6Tvc1ebLwPSWc7X8OQFG1NJNaJx+ORPJJHMWJ5mdGlx+vBg8EI4ezkRD4Rdp/j8cnpwB+dnPmjYBSMBd73Ax/pB48ATc1JBTD4v7Cr3FcCx8fwipWrKp1fcfiNcsJXJYUP//ztQpZGtKhpDE0R0wr4FYU3Gal5GsF7NQWBN/KGyOLT+es/jjTy6F1MC54mKa3CdsEREg6HaV6yisMakqUL5wz5r1zg+IdbzitSXsEGkorlYP3coY7r+PNxzmJ0UOtZz+E1LdjHBrfJ6U2LKjVdH6M4bGf5y4bfuFlJKpLXasGwm7KHAGv8ByhITkOwOK35UaSi50iQ1ZYr52saVZTXIVxaauhbLuhh0A/H1kTRV4QjP8UbYJEWMVt8olEIZyN3C/k+zVMegh/82OL/bGi10ugOmbGIZG+WEa1RhtMWG7GC0yU3z8ZqalppoTfqEbGq7mUhWcYWryoq15AMZxL8pa45/ZYSdA6h7WQLj650xWJphV/fXFjbkx/Q3dJCzD3tZ+iyZDW9hl9Oli/nVJrED0aGvPLHnjvw/IWWGbWsOYgDh+dQ0IXpJ7bzzKApmxmSKCf08AWfgsCgqFlOL0QwPAfu1bxqIm63lmEFHhn3srTmNvdSNO2cVrbjomvlQrExyoZj7SoXC2bBxmn14QsmFrOSp6wgmT33KprY1ie9n+U4rY49i24S+WxJqT3wJkHJFBFpMQ/VFI7sTg4yTTJGuJiSA1sL77uQNxlPke+HJITAEJ0UU1o0uVginlP70kJTCKdGpayJSaeN0tG3RlqDwFD0etQejxl3CyZSV71WapakKPIaPtMVKv8XyRqhect9s6tCt0mrx84W3ilu4p1OtlYqS4WGzUBu1PNxDPoCw53GxqHTFBNiZV8adjW0dCaO05/wDpfpAtdO8dDDzslMA+ckzaSFxcC+xhle9Wdu+MPcI5jVbJHavBmp0Z8vZZL6RYwFFs9Hh4BJepWTKDg9syXtW3yRpE7PVcVl51GCLJQh5iVNEdnGqXVSuR2SezPGMkqK3gZgnLRYFQuVbBnEeA7Uco1ZmiRUnFGyxBghscmk8wbHE+ZUkWxjJLcGk7oiFT4HB7gJ2kifttflA1SCd9R//ulor/4bj4PgUP89AnyR+u+L1n7nK6xMivsyKCX1XjWoyr82eI5acrwJjXrk1krjPsWKZiBF0DRb0uuKZSdHkxjvKS23UO49yWcxaRO1cd1ZSVrV3DIuPFWdsiK2rr8Fe0KNWLcJPJObwDKE5eUTyffJBH4QL4rhk0l3gd+QsLUxV9dcLg8ks72WzFxQ6zfy4CQKnmrc7UKLO2bzdd8vdVSlJa+P+VVF6QN1Ae7I/5j5x7v5Pxif+If8/wjwqPkfi+MqIRGFC+Ft74qy4TJRzkLAgn1GK5H0SP+yGQ5FZsO0LbKBKKZB+qn8GAfiwgw2ocFMxOR6E8oIl5+7IXzEMK7in1SN7qIqnwu2KF7IwlB96RJzc0OSjZzFL/WmKrrdhEyDbwnqVFTtD9r+uyv+g5F/ttf/G4nn4BHgEP/fR/03VMUUkV2S7jO9w9f+VvtEhvt220L1RkQ3RH1zq3WzLX4dlSu6ViGcjBXtbuGo+4X7xeI9qsHby0mZY7Hn0NO0GF0sKjLR+tvvF6WxqbIumLCyxDyqm1Tn+GKp2sdoSPwuGoltJ0KLiYT33ED0Ihj6ipBpl7Pcr+W8U+fKJlxfK9bYSZr1baStxoIftH3OrTquNY0WRDbmeoZSHqnIPlcxJznjkQulxIlLm26ca3eSXEs1tvBlJXpmSjbZU+2afvJ+01Ioj2+LYNRvb9TZSS5DnhgtTSYQu3XdN1/IHuAABzjAAf4T/AtWr19zACAAAA==" + "code": "file:scripts/three.ts;base64:H4sIAAAAAAAA/+0Y7W7bNtC//RQH/ancKYolx8GgrsW6tlgLdGjQZsCAwDBoiXK0SqImUrMNw2+yt9mL7Ujqg5aTNsOQFO18SCzqeDzeHe+OpwtZVqR07Qo+uDcYI5yfnaknQv85mUzPBt747Nwb+2N/IvGe53tIP3gAqLggJcDgv0Jfua8ETk/hBSs2ZbK8FvALFURsCgrv/v7LgTQJac5pBFUe0RLENYVXKeEiCeGtngLfHbtDZPHh4uVvJzXy5E1Ec5HECS2DZsEJEg6HSVawUsAW4rUDFwz5bxwQ+IdbLktSXMMO4pJlYP3Yok559PE0QQHW7u/cetLxeElz9r7CjTJ627JST/NTFIj1lj+vxK3bFaQkGdcLhu2UPQTY4j9ATjIagCUoFyehjp8TScYtR81zGpZU8ACuLD30LAfqod8NJ9ZM05dEID/NG2CF2rLVBxoGcD529pBvkywRAXj+9w3+j4qWmxrdIlMWkvTVOqQcZZg22JDlgq6FeTpWxWlZC73Tj5CVvJOFpClbvSipWkNSnInxlzrm9GtK0D2ktrM9PDrTNYuUFX5+dWntT75Dh0tyOfe4m6HrgnF6A7+MrJ8vqTKJ548NedWPvQyA5JsRPH1WC46qcgHy1OEp5HRlOos9emLQFNUCSbQvuviCT0lgUHCW0UsZE09BuFyUVSjsxjwsx3MTbppwYQs3QfsuaWmPHPSvTGo3QQFxXPvL5YpZsBs1SokVk4tZIRKWk9ReuiWNbetDvZ81GjWKdizaSeSzJ2XthrcJSuaISPJloKdwZLdykHmcMiLklBrYtfCeA1mVigT5vosD8A3RST6neZXJJfI5t68sNIX0bFTKmpl0tVFa+sZIW5AYiq6P2uNZ427+TOlar1WaxQmKvIWPdIPK/0nSSmrecN/1VWg3afTobeFOcRN3OttbqS0VGDYDtVHHZ2TQ5xjzNDIOnSaYF0v7yrCroeVoNhp1J9zjMl/h2jkeetA6mWngjCSpsrAc2Dc4w4vuzA1/WLoEU5st85u7IBz9+Uplqp/kWGLxfOoQMEmvMxL603Nb0b7GF0U66rjq4Gw9SpIFKsTcuMpD2zi1ViqnRQp3wVhKSd7ZAIyTlqsiqZKtghjPgVqOMUvjmMozitcYIyQymbTeMHKlOXUk2xjJjcGUrkiFz8ERDqAJ8XlzWd5DJfiZ+s+begf132Ti+8f67wHgi9R/X7j2u9hgZZLflUGhqA+qQV3+NeFz0pDjJdivRz5ZadylWKkZKDlqmj0V6oqll6NJhPdULbzU8C3JFhFpErVx3VlxUnJhGReeLlFZHlk334IdYY3YNgk8VZvAOoD11SPF99EMvpMvmuGjWXuB35Kwa4tubrhc7klme6uYOaDX79TBKRQ8rnGfFlreMbuv9H7hYZkUgp+K65LSe+oCfCb/Y+af9PO/Pznzjvn/AeBB8z9WxWVMQgqX0tve5EUlVIZcBICV+oKWMtuR7mU3HMqUhklbpgFZRYPyU/UpDsSBBewCg5kMxu0uUKGtPnYDeI/xW0Y/6OLcQVU+5myVP1MVof7OJebmhiQ7NYvf6VWZt7tJmQbfEvBEluv32v77XPxj0E8P+n9j+Rw8ABzj//9S/w11HUVUg6T9Qm/x3NvrnKiA3+9Y6LaIbIToz229brHHr6VyZNcqgLOJpu0XjnW/8JZi8Q7V4KfLSZVqsefQ0TSYuljUZLL/d9gvSiJT77pgwsoS02ndpLrAF0vXPkZD4lfZTWw6EbWYSHjHDWQvgqHLSJn6nNV+DedenauacF2tyLGTtOjaSHuNBc9vmp17dVxjmloQ1ZjrGCp5lCKHXOWc4oznLpWSx65suhvduJPiWuixhS8b2TPTsqnGatv0U9dcLYV2+6YIRv0ORq2d1DLkmbGoSiWiX959u4XsEY5whCMc4V/BP36axFYAIAAA" } }, { diff --git a/typegate/tests/e2e/typegraph/typegraphs/deno/complex.ts b/typegate/tests/e2e/typegraph/typegraphs/deno/complex.ts index df9f4d8da9..f2dfa4d7ee 100644 --- a/typegate/tests/e2e/typegraph/typegraphs/deno/complex.ts +++ b/typegate/tests/e2e/typegraph/typegraphs/deno/complex.ts @@ -1,9 +1,9 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { fx, Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; -import { Auth } from "@typegraph/sdk/params.ts"; +import { fx, Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; +import { Auth } from "@typegraph/sdk/params.js"; typegraph( { @@ -25,7 +25,7 @@ typegraph( maxAgeSec: 120, }, }, - (g) => { + (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/e2e/typegraph/typegraphs/deno/multiple_runtimes.ts b/typegate/tests/e2e/typegraph/typegraphs/deno/multiple_runtimes.ts index 6b7c84cc93..63c8b853d7 100644 --- a/typegate/tests/e2e/typegraph/typegraphs/deno/multiple_runtimes.ts +++ b/typegate/tests/e2e/typegraph/typegraphs/deno/multiple_runtimes.ts @@ -1,11 +1,11 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; -import { PythonRuntime } from "@typegraph/sdk/runtimes/python.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; +import { PythonRuntime } from "@typegraph/sdk/runtimes/python.js"; -typegraph("test-multiple-runtimes", (g) => { +typegraph("test-multiple-runtimes", (g: any) => { const pub = Policy.public(); const deno = new DenoRuntime(); const python = new PythonRuntime(); diff --git a/typegate/tests/e2e/typegraph/typegraphs/deno/simple.ts b/typegate/tests/e2e/typegraph/typegraphs/deno/simple.ts index e1a9f4870a..fde474c67b 100644 --- a/typegate/tests/e2e/typegraph/typegraphs/deno/simple.ts +++ b/typegate/tests/e2e/typegraph/typegraphs/deno/simple.ts @@ -1,8 +1,8 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; const a = t.integer(); @@ -10,7 +10,7 @@ const s1 = t.struct({ a, b: t.integer({ min: 12 }) }); const b = t.integer({ min: 12, max: 43 }); -typegraph("test-types", (g) => { +typegraph("test-types", (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); const internal = Policy.internal(); diff --git a/typegate/tests/injection/injection.ts b/typegate/tests/injection/injection.ts index 1a1e39902b..181da3dfd7 100644 --- a/typegate/tests/injection/injection.ts +++ b/typegate/tests/injection/injection.ts @@ -1,9 +1,9 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { CREATE, DELETE, READ, UPDATE } from "@typegraph/sdk/effects.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { CREATE, DELETE, READ, UPDATE } from "@typegraph/sdk/effects.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; const tpe = t.struct({ "a": t.integer({}, { name: "A" }), @@ -26,7 +26,7 @@ const tpe = t.struct({ "date": t.datetime().inject("now"), }); -typegraph("injection", (g) => { +typegraph("injection", (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/random/random.ts b/typegate/tests/random/random.ts index 179dd9e766..d9d9ea4c16 100644 --- a/typegate/tests/random/random.ts +++ b/typegate/tests/random/random.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { RandomRuntime } from "@typegraph/sdk/runtimes/random.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { RandomRuntime } from "@typegraph/sdk/runtimes/random.js"; -typegraph("random", (g) => { +typegraph("random", (g: any) => { const random = new RandomRuntime({ seed: 1, reset: "" }); const pub = Policy.public(); diff --git a/typegate/tests/rest/rest_custom_loader.ts b/typegate/tests/rest/rest_custom_loader.ts index 7a21ffc7bd..b054690609 100644 --- a/typegate/tests/rest/rest_custom_loader.ts +++ b/typegate/tests/rest/rest_custom_loader.ts @@ -1,8 +1,8 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { fx, Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; +import { fx, Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; import { endpoints } from "./custom/custom_loader.ts"; const user = t.struct({ @@ -22,7 +22,7 @@ const complexType = t.struct({ f: t.float({ enumeration: [1.0, 2.5] }), }, { name: "ComplexType" }); -typegraph("rest", (g) => { +typegraph("rest", (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/rest/rest_schema.ts b/typegate/tests/rest/rest_schema.ts index 960cca8b20..e6deca12ed 100644 --- a/typegate/tests/rest/rest_schema.ts +++ b/typegate/tests/rest/rest_schema.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { fx, Policy, t, typegraph } from "../../../typegraph/deno/src/mod.ts"; -import { DenoRuntime } from "../../../typegraph/deno/src/runtimes/deno.ts"; +import { fx, Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; -typegraph("rest_schema", (g) => { +typegraph("rest_schema", (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/graphql/typegraphs/deno/graphql.ts b/typegate/tests/runtimes/graphql/typegraphs/deno/graphql.ts index 8fd14cf258..daf3782a33 100644 --- a/typegate/tests/runtimes/graphql/typegraphs/deno/graphql.ts +++ b/typegate/tests/runtimes/graphql/typegraphs/deno/graphql.ts @@ -1,16 +1,16 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { GraphQLRuntime } from "@typegraph/sdk/runtimes/graphql.ts"; -import * as effects from "@typegraph/sdk/effects.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { GraphQLRuntime } from "@typegraph/sdk/runtimes/graphql.js"; +import * as effects from "@typegraph/sdk/effects.js"; const user = t.struct({ id: t.integer(), // TODO more fields with more types }, { name: "User" }); -typegraph("graphql", (g) => { +typegraph("graphql", (g: any) => { const graphql = new GraphQLRuntime("https://example.com/api/graphql"); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/prisma/normal_1_1.ts b/typegate/tests/runtimes/prisma/normal_1_1.ts index 03b8c2578e..01e6fb510a 100644 --- a/typegate/tests/runtimes/prisma/normal_1_1.ts +++ b/typegate/tests/runtimes/prisma/normal_1_1.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.js"; -typegraph("prisma_normal", (g) => { +typegraph("prisma_normal", (g: any) => { const db = new PrismaRuntime("prisma", "POSTGRES"); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/prisma/optional_1_n.ts b/typegate/tests/runtimes/prisma/optional_1_n.ts index cc3591d5d9..8e6e17c431 100644 --- a/typegate/tests/runtimes/prisma/optional_1_n.ts +++ b/typegate/tests/runtimes/prisma/optional_1_n.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.js"; -typegraph("prisma_opt_1", (g) => { +typegraph("prisma_opt_1", (g: any) => { const db = new PrismaRuntime("prisma", "POSTGRES"); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/python_wasi/python_wasi.ts b/typegate/tests/runtimes/python_wasi/python_wasi.ts index bb464832e4..e6b1397468 100644 --- a/typegate/tests/runtimes/python_wasi/python_wasi.ts +++ b/typegate/tests/runtimes/python_wasi/python_wasi.ts @@ -1,8 +1,8 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { PythonRuntime } from "@typegraph/sdk/runtimes/python.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { PythonRuntime } from "@typegraph/sdk/runtimes/python.js"; import outdent from "outdent"; const tpe = t.struct({ @@ -10,7 +10,7 @@ const tpe = t.struct({ "b": t.list(t.either([t.integer(), t.string()])), }); -typegraph("python_wasi", (g) => { +typegraph("python_wasi", (g: any) => { const python = new PythonRuntime(); const pub = Policy.public(); diff --git a/typegate/tests/runtimes/s3/s3.ts b/typegate/tests/runtimes/s3/s3.ts index 189d6e65d5..d6a3854670 100644 --- a/typegate/tests/runtimes/s3/s3.ts +++ b/typegate/tests/runtimes/s3/s3.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { S3Runtime } from "@typegraph/sdk/providers/aws.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { S3Runtime } from "@typegraph/sdk/providers/aws.js"; -typegraph("s3-test", (g) => { +typegraph("s3-test", (g: any) => { const pub = Policy.public(); const s3 = new S3Runtime({ diff --git a/typegate/tests/runtimes/temporal/temporal.ts b/typegate/tests/runtimes/temporal/temporal.ts index 0b363e4625..c53717db2b 100644 --- a/typegate/tests/runtimes/temporal/temporal.ts +++ b/typegate/tests/runtimes/temporal/temporal.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { TemporalRuntime } from "@typegraph/sdk/providers/temporal.ts"; +import { Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { TemporalRuntime } from "@typegraph/sdk/providers/temporal.js"; -typegraph("temporal", (g) => { +typegraph("temporal", (g: any) => { const pub = Policy.public(); const temporal = new TemporalRuntime("", ""); const arg = t.struct({ some_field: t.string() }); diff --git a/typegate/tests/typecheck/reduce.ts b/typegate/tests/typecheck/reduce.ts index ef781996e7..f55960dc9f 100644 --- a/typegate/tests/typecheck/reduce.ts +++ b/typegate/tests/typecheck/reduce.ts @@ -1,8 +1,8 @@ // Copyright Metatype OÜ, licensed under the Elastic License 2.0. // SPDX-License-Identifier: Elastic-2.0 -import { fx, Policy, t, typegraph } from "@typegraph/sdk/mod.ts"; -import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.ts"; +import { fx, Policy, t, typegraph } from "@typegraph/sdk/index.js"; +import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js"; const student = t.struct({ id: t.integer(), @@ -32,7 +32,7 @@ const grades = t.struct({ const tpe = t.struct({ student, grades: grades.optional() }); -typegraph("test-reduce-deno", (g) => { +typegraph("test-reduce-deno", (g: any) => { const deno = new DenoRuntime(); const pub = Policy.public(); const identityStudent = deno.func( diff --git a/typegraph/deno/dev/fix-declarations.ts b/typegraph/deno/dev/fix-declarations.ts deleted file mode 100644 index 14ccce3481..0000000000 --- a/typegraph/deno/dev/fix-declarations.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 - -import { - dirname, - fromFileUrl, - resolve, -} from "https://deno.land/std@0.202.0/path/mod.ts"; -import { expandGlobSync } from "https://deno.land/std@0.202.0/fs/mod.ts"; - -export const thisDir = dirname(fromFileUrl(import.meta.url)); - -const replacements = [ - ...Array.from(expandGlobSync("../src/gen/**/*.d.ts", { - root: thisDir, - includeDirs: false, - globstar: true, - })).map(({ path }) => ({ - path, - op: (s: string) => s.replace(/^(import .*)(? s.replaceAll(/,\s*\w+ as '[\w:\/]+'/g, ""), - }, -]; - -for ( - const { path, op } of replacements -) { - const text = Deno.readTextFileSync(path); - const rewrite = [...text.split("\n")]; - - for (let i = 0; i < rewrite.length; i += 1) { - rewrite[i] = op(rewrite[i]); - } - - const newText = rewrite.join("\n"); - if (text != newText) { - console.log(`Fixed generated code in ${path.replace(thisDir, "")}`); - Deno.writeTextFileSync(path, newText); - } -} diff --git a/typegraph/deno/src/deps.ts b/typegraph/deno/src/deps.ts deleted file mode 100644 index e5bdb1a376..0000000000 --- a/typegraph/deno/src/deps.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. -// SPDX-License-Identifier: MPL-2.0 - -export { mapValues } from "https://deno.land/std@0.192.0/collections/map_values.ts"; -export { expandGlobSync } from "https://deno.land/std@0.192.0/fs/mod.ts"; -export { default as caller } from "https://deno.land/x/caller@0.1.4/caller.ts"; -export { - dirname, - fromFileUrl, -} from "https://deno.land/std@0.192.0/path/mod.ts"; diff --git a/typegraph/deno/LICENSE.md b/typegraph/node/LICENSE.md similarity index 100% rename from typegraph/deno/LICENSE.md rename to typegraph/node/LICENSE.md diff --git a/typegraph/node/package.json b/typegraph/node/package.json new file mode 100644 index 0000000000..e15efb5a91 --- /dev/null +++ b/typegraph/node/package.json @@ -0,0 +1,19 @@ +{ + "name": "metatype", + "version": "0.3.1", + "description": "Declarative API development platform. Build serverless backends with zero-trust and less code, no matter where and how your (legacy) systems are.", + "scripts": { + "sdk-build": "cd sdk && pnpm run build", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/metatypedev/metatype.git" + }, + "bugs": { + "url": "https://github.com/metatypedev/metatype/issues" + }, + "keywords": [], + "author": "", + "license": "MPL-2.0" +} diff --git a/typegraph/node/pnpm-lock.yaml b/typegraph/node/pnpm-lock.yaml new file mode 100644 index 0000000000..c52efda16c --- /dev/null +++ b/typegraph/node/pnpm-lock.yaml @@ -0,0 +1,21 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + sdk: + devDependencies: + typescript: + specifier: ^5.3.3 + version: 5.3.3 + +packages: + + /typescript@5.3.3: + resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + engines: {node: '>=14.17'} + hasBin: true + dev: true diff --git a/typegraph/node/pnpm-workspace.yaml b/typegraph/node/pnpm-workspace.yaml new file mode 100644 index 0000000000..b8d8b6441f --- /dev/null +++ b/typegraph/node/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - sdk diff --git a/typegraph/node/sdk/LICENSE.md b/typegraph/node/sdk/LICENSE.md new file mode 100644 index 0000000000..9c9d472da2 --- /dev/null +++ b/typegraph/node/sdk/LICENSE.md @@ -0,0 +1,359 @@ +# Mozilla Public License Version 2.0 (MPL-2.0) + +1. Definitions + +--- + +1.1. "Contributor" means each individual or legal entity that creates, +contributes to the creation of, or owns Covered Software. + +1.2. "Contributor Version" means the combination of the Contributions of others +(if any) used by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" means Covered Software of a particular Contributor. + +1.4. "Covered Software" means Source Code Form to which the initial Contributor +has attached the notice in Exhibit A, the Executable Form of such Source Code +Form, and Modifications of such Source Code Form, in each case including +portions thereof. + +1.5. "Incompatible With Secondary Licenses" means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" means any form of the work other than Source Code Form. + +1.7. "Larger Work" means a work that combines Covered Software with other +material, in a separate file or files, that is not Covered Software. + +1.8. "License" means this document. + +1.9. "Licensable" means having the right to grant, to the maximum extent +possible, whether at the time of the initial grant or subsequently, any and all +of the rights conveyed by this License. + +1.10. "Modifications" means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor means any patent claim(s), including +without limitation, method, process, and apparatus claims, in any patent +Licensable by such Contributor that would be infringed, but for the grant of the +License, by the making, using, selling, offering for sale, having made, import, +or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" means either the GNU General Public License, Version +2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General +Public License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" means the form of the work preferred for making +modifications. + +1.14. "You" (or "Your") means an individual or a legal entity exercising rights +under this License. For legal entities, "You" includes any entity that controls, +is controlled by, or is under common control with You. For purposes of this +definition, "control" means (a) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or otherwise, or (b) +ownership of more than fifty percent (50%) of the outstanding shares or +beneficial ownership of such entity. + +2. License Grants and Conditions + +--- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive +license: + +(a) under intellectual property rights (other than patent or trademark) +Licensable by such Contributor to use, reproduce, make available, modify, +display, perform, distribute, and otherwise exploit its Contributions, either on +an unmodified basis, with Modifications, or as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer for sale, +have made, import, and otherwise transfer either its Contributions or its +Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution become +effective for each Contribution on the date the Contributor first distributes +such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under this +License. No additional rights or licenses will be implied from the distribution +or licensing of Covered Software under this License. Notwithstanding Section +2.1(b) above, no patent license is granted by a Contributor: + +(a) for any code that a Contributor has removed from Covered Software; or + +(b) for infringements caused by: (i) Your and any other third party's +modifications of Covered Software, or (ii) the combination of its Contributions +with other software (except as part of its Contributor Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of its +Contributions. + +This License does not grant any rights in the trademarks, service marks, or +logos of any Contributor (except as may be necessary to comply with the notice +requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to distribute +the Covered Software under a subsequent version of this License (see Section +10.2) or under the terms of a Secondary License (if permitted under the terms of +Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its Contributions are +its original creation(s) or it has sufficient rights to grant the rights to its +Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under applicable +copyright doctrines of fair use, fair dealing, or other equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in +Section 2.1. + +3. Responsibilities + +--- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under the +terms of this License. You must inform recipients that the Source Code Form of +the Covered Software is governed by the terms of this License, and how they can +obtain a copy of this License. You may not attempt to alter or restrict the +recipients' rights in the Source Code Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code Form, as +described in Section 3.1, and You must inform recipients of the Executable Form +how they can obtain a copy of such Source Code Form by reasonable means in a +timely manner, at a charge no more than the cost of distribution to the +recipient; and + +(b) You may distribute such Executable Form under the terms of this License, or +sublicense it under different terms, provided that the license for the +Executable Form does not attempt to limit or alter the recipients' rights in the +Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, provided +that You also comply with the requirements of this License for the Covered +Software. If the Larger Work is a combination of Covered Software with a work +governed by one or more Secondary Licenses, and the Covered Software is not +Incompatible With Secondary Licenses, this License permits You to additionally +distribute such Covered Software under the terms of such Secondary License(s), +so that the recipient of the Larger Work may, at their option, further +distribute the Covered Software under the terms of either this License or such +Secondary License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices (including +copyright notices, patent notices, disclaimers of warranty, or limitations of +liability) contained within the Source Code Form of the Covered Software, except +that You may alter any license notices to the extent required to remedy known +factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, indemnity +or liability obligations to one or more recipients of Covered Software. However, +You may do so only on Your own behalf, and not on behalf of any Contributor. You +must make it absolutely clear that any such warranty, support, indemnity, or +liability obligation is offered by You alone, and You hereby agree to indemnify +every Contributor for any liability incurred by such Contributor as a result of +warranty, support, indemnity or liability terms You offer. You may include +additional disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + +--- + +If it is impossible for You to comply with any of the terms of this License with +respect to some or all of the Covered Software due to statute, judicial order, +or regulation then You must: (a) comply with the terms of this License to the +maximum extent possible; and (b) describe the limitations and the code they +affect. Such description must be placed in a text file included with all +distributions of the Covered Software under this License. Except to the extent +prohibited by statute or regulation, such description must be sufficiently +detailed for a recipient of ordinary skill to be able to understand it. + +5. Termination + +--- + +5.1. The rights granted under this License will terminate automatically if You +fail to comply with any of its terms. However, if You become compliant, then the +rights granted under this License from a particular Contributor are reinstated +(a) provisionally, unless and until such Contributor explicitly and finally +terminates Your grants, and (b) on an ongoing basis, if such Contributor fails +to notify You of the non-compliance by some reasonable means prior to 60 days +after You have come back into compliance. Moreover, Your grants from a +particular Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the first +time You have received notice of non-compliance with this License from such +Contributor, and You become compliant prior to 30 days after Your receipt of the +notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, counter-claims, and +cross-claims) alleging that a Contributor Version directly or indirectly +infringes any patent, then the rights granted to You by any and all Contributors +for the Covered Software under Section 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user +license agreements (excluding distributors and resellers) which have been +validly granted by You or Your distributors under this License prior to +termination shall survive termination. + +--- + +- + - +- + 6. Disclaimer of Warranty * +- ------------------------- * +- + - +- Covered Software is provided under this License on an "as is" * +- basis, without warranty of any kind, either expressed, implied, or * +- statutory, including, without limitation, warranties that the * +- Covered Software is free of defects, merchantable, fit for a * +- particular purpose or non-infringing. The entire risk as to the * +- quality and performance of the Covered Software is with You. * +- Should any Covered Software prove defective in any respect, You * +- (not any Contributor) assume the cost of any necessary servicing, * +- repair, or correction. This disclaimer of warranty constitutes an * +- essential part of this License. No use of any Covered Software is * +- authorized under this License except under this disclaimer. * +- + - + +--- + +--- + +- + - +- + 7. Limitation of Liability * +- -------------------------- * +- + - +- Under no circumstances and under no legal theory, whether tort * +- (including negligence), contract, or otherwise, shall any * +- Contributor, or anyone who distributes Covered Software as * +- permitted above, be liable to You for any direct, indirect, * +- special, incidental, or consequential damages of any character * +- including, without limitation, damages for lost profits, loss of * +- goodwill, work stoppage, computer failure or malfunction, or any * +- and all other commercial damages or losses, even if such party * +- shall have been informed of the possibility of such damages. This * +- limitation of liability shall not apply to liability for death or * +- personal injury resulting from such party's negligence to the * +- extent applicable law prohibits such limitation. Some * +- jurisdictions do not allow the exclusion or limitation of * +- incidental or consequential damages, so this exclusion and * +- limitation may not apply to You. * +- + - + +--- + +8. Litigation + +--- + +Any litigation relating to this License may be brought only in the courts of a +jurisdiction where the defendant maintains its principal place of business and +such litigation shall be governed by laws of that jurisdiction, without +reference to its conflict-of-law provisions. Nothing in this Section shall +prevent a party's ability to bring cross-claims or counter-claims. + +9. Miscellaneous + +--- + +This License represents the complete agreement concerning the subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it enforceable. +Any law or regulation which provides that the language of a contract shall be +construed against the drafter shall not be used to construe this License against +a Contributor. + +10. Versions of the License + +--- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section 10.3, +no one other than the license steward has the right to modify or publish new +versions of this License. Each version will be given a distinguishing version +number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version of the +License under which You originally received the Covered Software, or under the +terms of any subsequent version published by the license steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to create a +new license for such software, you may create and use a modified version of this +License if you rename the license and remove any references to the name of the +license steward (except to note that such modified license differs from this +License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + +If You choose to distribute Source Code Form that is Incompatible With Secondary +Licenses under the terms of this version of the License, the notice described in +Exhibit B of this License must be attached. + +## Exhibit A - Source Code Form License Notice + +This Source Code Form is subject to the terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not distributed with this file, You can obtain one +at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then +You may include the notice in a location (such as a LICENSE file in a relevant +directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +## Exhibit B - "Incompatible With Secondary Licenses" Notice + +This Source Code Form is "Incompatible With Secondary Licenses", as defined by +the Mozilla Public License, v. 2.0. diff --git a/typegraph/node/sdk/package-lock.json b/typegraph/node/sdk/package-lock.json new file mode 100644 index 0000000000..f035ddb560 --- /dev/null +++ b/typegraph/node/sdk/package-lock.json @@ -0,0 +1,72 @@ +{ + "name": "node", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "node", + "version": "1.0.0", + "license": "MPL", + "dependencies": { + "@types/lodash": "^4.14.202", + "caller": "^1.1.0", + "lodash": "^4.17.21" + }, + "devDependencies": { + "@types/caller": "^1.0.2", + "@types/node": "^20.10.7", + "typescript": "^5.3.3" + } + }, + "node_modules/@types/caller": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/caller/-/caller-1.0.2.tgz", + "integrity": "sha512-NRXTeF8nnjSAHFxHKMnqpUWY1gTyAHLMhPTKeeHWTZdPilcFiCvlfvpVB8bOMfHbWYIxiPwZDwrYwMsRFkeh7A==", + "dev": true + }, + "node_modules/@types/lodash": { + "version": "4.14.202", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz", + "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==" + }, + "node_modules/@types/node": { + "version": "20.10.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz", + "integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/caller": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/caller/-/caller-1.1.0.tgz", + "integrity": "sha512-n+21IZC3j06YpCWaxmUy5AnVqhmCIM2bQtqQyy00HJlmStRt6kwDX5F9Z97pqwAB+G/tgSz6q/kUBbNyQzIubw==" + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/typegraph/node/sdk/package.json b/typegraph/node/sdk/package.json new file mode 100644 index 0000000000..69b931ad39 --- /dev/null +++ b/typegraph/node/sdk/package.json @@ -0,0 +1,23 @@ +{ + "name": "@typegraph/sdk", + "version": "0.3.1", + "description": "Declarative API development platform. Build serverless backends with zero-trust and less code, no matter where and how your (legacy) systems are.", + "type": "module", + "scripts": { + "build": "pnpm exec tsc && cp -R ./src/gen ./dist/", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/metatypedev/metatype.git" + }, + "bugs": { + "url": "https://github.com/metatypedev/metatype/issues" + }, + "keywords": [], + "author": "", + "license": "MPL-2.0", + "devDependencies": { + "typescript": "^5.3.3" + } +} diff --git a/typegraph/node/sdk/src/deps/_import.ts b/typegraph/node/sdk/src/deps/_import.ts new file mode 100644 index 0000000000..a1af115678 --- /dev/null +++ b/typegraph/node/sdk/src/deps/_import.ts @@ -0,0 +1,76 @@ +// no-auto-license-header + +/* +The MIT License (MIT) + +Copyright (c) 2020 Alexandre Piel +Copyright 2018-2022 the Deno authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +export interface Bind { + cb?: (file: string) => string; +} + +export const up = 3; + +export function caller(this: Bind | any, levelUp = up) { + const err = new Error(); + const stack = err.stack?.split("\n")[levelUp]; + if (stack) { + return getFile.bind(this)(stack); + } +} + +export function getFile(this: Bind | any, stack: string) { + stack = stack.substr(stack.indexOf("at ") + 3); + if (!stack.startsWith("file://")) { + stack = stack.substr(stack.lastIndexOf("(") + 1); + } + const path = stack.split(":"); + let file = `${path[0]}:${path[1]}`; + + if ((this as Bind)?.cb) { + const cb = (this as Bind).cb as any; + file = cb(file); + } + return file; +} + +export function fromFileUrlWin32(url: string): string { + const urlObj = new URL(url); + let path = decodeURIComponent( + urlObj.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), + ).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\"); + if (urlObj.hostname !== "") { + // Note: The `URL` implementation guarantees that the drive letter and + // hostname are mutually exclusive. Otherwise it would not have been valid + // to append the hostname and path like this. + path = `\\\\${urlObj.hostname}${path}`; + } + return path; +} + +export function fromFileUrlPosix(url: string): string { + const urlObject = new URL(url); + return decodeURIComponent( + urlObject.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), + ); +} diff --git a/typegraph/node/sdk/src/deps/mod.ts b/typegraph/node/sdk/src/deps/mod.ts new file mode 100644 index 0000000000..abe8cab244 --- /dev/null +++ b/typegraph/node/sdk/src/deps/mod.ts @@ -0,0 +1,28 @@ +// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. +// SPDX-License-Identifier: MPL-2.0 +export { caller } from "./_import.js"; + +export function mapValues( + object: Object, + fn: (value: any, key: string, object: Object) => any, +) { + const newEntries = Object + .entries(object) + .map(([k, v]) => [k, fn(v, k, object)]); + return Object.fromEntries(newEntries); +} + +export function dirname(path: string) { + // Note: Do not refactor with runtime dependent OS check + const [unixIdx, winIdx] = ["/", "\\"].map((sep) => path.lastIndexOf(sep)); + return path.substring((winIdx > 0 ? winIdx : unixIdx) + 1); +} + +import { fromFileUrlPosix, fromFileUrlWin32 } from "./_import.js"; + +export function fromFileUrl(path: string) { + // Note: Do not refactor with runtime dependent OS check + // Examples: file://C:, file://D: + const isWin32 = /^file:\/\/\w\:/.test(path); + return isWin32 ? fromFileUrlWin32(path) : fromFileUrlPosix(path); +} diff --git a/typegraph/deno/src/effects.ts b/typegraph/node/sdk/src/effects.ts similarity index 93% rename from typegraph/deno/src/effects.ts rename to typegraph/node/sdk/src/effects.ts index 28f0510f95..19bdf09cec 100644 --- a/typegraph/deno/src/effects.ts +++ b/typegraph/node/sdk/src/effects.ts @@ -6,7 +6,7 @@ import { EffectDelete, EffectRead, EffectUpdate, -} from "./gen/interfaces/metatype-typegraph-runtimes.d.ts"; +} from "./gen/interfaces/metatype-typegraph-runtimes.js"; export function read(): EffectRead { return { tag: "read" }; diff --git a/typegraph/deno/src/mod.ts b/typegraph/node/sdk/src/index.ts similarity index 51% rename from typegraph/deno/src/mod.ts rename to typegraph/node/sdk/src/index.ts index 599ca20615..071e0ca490 100644 --- a/typegraph/deno/src/mod.ts +++ b/typegraph/node/sdk/src/index.ts @@ -1,9 +1,9 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "./types.ts"; -import { typegraph } from "./typegraph.ts"; -import Policy from "./policy.ts"; -import * as fx from "./effects.ts"; +import * as t from "./types.js"; +import { typegraph } from "./typegraph.js"; +import Policy from "./policy.js"; +import * as fx from "./effects.js"; export { fx, Policy, t, typegraph }; diff --git a/typegraph/deno/src/params.ts b/typegraph/node/sdk/src/params.ts similarity index 73% rename from typegraph/deno/src/params.ts rename to typegraph/node/sdk/src/params.ts index 0c9bc045bb..40aca9b1da 100644 --- a/typegraph/deno/src/params.ts +++ b/typegraph/node/sdk/src/params.ts @@ -1,15 +1,15 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { RawAuth } from "./typegraph.ts"; -import { Auth as Auth_, wit_utils } from "./wit.ts"; -import * as t from "./types.ts"; +import { RawAuth } from "./typegraph.js"; +import { Auth as Auth_, wit_utils } from "./wit.js"; +import * as t from "./types.js"; export type StdOauth2Profiler = | { profiler: "default" } | { profiler: "none" } - | { profiler: "extended", extension: any } - | { profiler: "custom", id: number }; + | { profiler: "extended"; extension: any } + | { profiler: "custom"; id: number }; export function noProfiler(): StdOauth2Profiler { return { profiler: "none" }; @@ -62,21 +62,40 @@ export class Auth { }; } - private static stdOauth2(provider: string, scopes: string, profiler: StdOauth2Profiler): RawAuth { + private static stdOauth2( + provider: string, + scopes: string, + profiler: StdOauth2Profiler, + ): RawAuth { switch (profiler.profiler) { case "none": return new RawAuth(wit_utils.oauth2WithoutProfiler(provider, scopes)); case "extended": - return new RawAuth(wit_utils.oauth2WithExtendedProfiler(provider, scopes, JSON.stringify(profiler.extension))); + return new RawAuth( + wit_utils.oauth2WithExtendedProfiler( + provider, + scopes, + JSON.stringify(profiler.extension), + ), + ); case "custom": - return new RawAuth(wit_utils.oauth2WithCustomProfiler(provider, scopes, profiler.id)); + return new RawAuth( + wit_utils.oauth2WithCustomProfiler(provider, scopes, profiler.id), + ); default: return new RawAuth(wit_utils.oauth2(provider, scopes)); } } - static oauth2Digitalocean(scopes: string, profiler?: StdOauth2Profiler): RawAuth { - return Auth.stdOauth2("digitalocean", scopes, profiler ?? defaultProfiler()); + static oauth2Digitalocean( + scopes: string, + profiler?: StdOauth2Profiler, + ): RawAuth { + return Auth.stdOauth2( + "digitalocean", + scopes, + profiler ?? defaultProfiler(), + ); } static oauth2Discord(scopes: string, profiler?: StdOauth2Profiler): RawAuth { @@ -103,7 +122,10 @@ export class Auth { return Auth.stdOauth2("google", scopes, profiler ?? defaultProfiler()); } - static oauth2Instagram(scopes: string, profiler?: StdOauth2Profiler): RawAuth { + static oauth2Instagram( + scopes: string, + profiler?: StdOauth2Profiler, + ): RawAuth { return Auth.stdOauth2("instagram", scopes, profiler ?? defaultProfiler()); } @@ -111,7 +133,10 @@ export class Auth { return Auth.stdOauth2("linkedin", scopes, profiler ?? defaultProfiler()); } - static oauth2Microsoft(scopes: string, profiler?: StdOauth2Profiler): RawAuth { + static oauth2Microsoft( + scopes: string, + profiler?: StdOauth2Profiler, + ): RawAuth { return Auth.stdOauth2("microsoft", scopes, profiler ?? defaultProfiler()); } @@ -123,8 +148,15 @@ export class Auth { return Auth.stdOauth2("slack", scopes, profiler ?? defaultProfiler()); } - static oauth2Stackexchange(scopes: string, profiler?: StdOauth2Profiler): RawAuth { - return Auth.stdOauth2("stackexchange", scopes, profiler ?? defaultProfiler()); + static oauth2Stackexchange( + scopes: string, + profiler?: StdOauth2Profiler, + ): RawAuth { + return Auth.stdOauth2( + "stackexchange", + scopes, + profiler ?? defaultProfiler(), + ); } static oauth2Twitter(scopes: string, profiler?: StdOauth2Profiler): RawAuth { diff --git a/typegraph/deno/src/policy.ts b/typegraph/node/sdk/src/policy.ts similarity index 90% rename from typegraph/deno/src/policy.ts rename to typegraph/node/sdk/src/policy.ts index 9cd503964e..406d5b0220 100644 --- a/typegraph/deno/src/policy.ts +++ b/typegraph/node/sdk/src/policy.ts @@ -1,9 +1,9 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { MaterializerId } from "./gen/interfaces/metatype-typegraph-core.d.ts"; -import { core, runtimes } from "./wit.ts"; -import { DenoRuntime } from "./runtimes/deno.ts"; +import { MaterializerId } from "./gen/interfaces/metatype-typegraph-core.js"; +import { core, runtimes } from "./wit.js"; +import { DenoRuntime } from "./runtimes/deno.js"; export default class Policy { constructor(public readonly _id: number, public readonly name: string) {} diff --git a/typegraph/deno/src/providers/aws.ts b/typegraph/node/sdk/src/providers/aws.ts similarity index 93% rename from typegraph/deno/src/providers/aws.ts rename to typegraph/node/sdk/src/providers/aws.ts index 7335c07d4f..fbd6a7d9eb 100644 --- a/typegraph/deno/src/providers/aws.ts +++ b/typegraph/node/sdk/src/providers/aws.ts @@ -1,14 +1,14 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { Materializer, Runtime } from "../runtimes/mod.ts"; -import { aws } from "../wit.ts"; +import { Materializer, Runtime } from "../runtimes/mod.js"; +import { aws } from "../wit.js"; import { S3PresignGetParams, S3PresignPutParams, S3RuntimeData, -} from "../gen/interfaces/metatype-typegraph-aws.d.ts"; -import { t } from "../mod.ts"; +} from "../gen/interfaces/metatype-typegraph-aws.js"; +import { t } from "../index.js"; type S3PresignGetMat = Materializer & S3PresignGetParams; type S3PresignPutMat = Materializer & S3PresignPutParams; diff --git a/typegraph/deno/src/providers/prisma.ts b/typegraph/node/sdk/src/providers/prisma.ts similarity index 95% rename from typegraph/deno/src/providers/prisma.ts rename to typegraph/node/sdk/src/providers/prisma.ts index fba8deef6c..8cd6e0917e 100644 --- a/typegraph/deno/src/providers/prisma.ts +++ b/typegraph/node/sdk/src/providers/prisma.ts @@ -1,12 +1,12 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { Runtime } from "../runtimes/mod.ts"; -import { runtimes } from "../wit.ts"; -import { Typedef } from "../types.ts"; -import { t } from "../mod.ts"; -import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { genRef } from "./../typegraph.ts"; +import { Runtime } from "../runtimes/mod.js"; +import { runtimes } from "../wit.js"; +import { Typedef } from "../types.js"; +import { t } from "../index.js"; +import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import { genRef } from "./../typegraph.js"; type PrismaLinkArg = { fkey?: boolean; diff --git a/typegraph/deno/src/providers/temporal.ts b/typegraph/node/sdk/src/providers/temporal.ts similarity index 88% rename from typegraph/deno/src/providers/temporal.ts rename to typegraph/node/sdk/src/providers/temporal.ts index c2fbc16a08..a1b24444da 100644 --- a/typegraph/deno/src/providers/temporal.ts +++ b/typegraph/node/sdk/src/providers/temporal.ts @@ -1,13 +1,13 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { Runtime } from "../runtimes/mod.ts"; -import { runtimes } from "../wit.ts"; -import { Func, Typedef } from "../types.ts"; +import { Runtime } from "../runtimes/mod.js"; +import { runtimes } from "../wit.js"; +import { Func, Typedef } from "../types.js"; import { TemporalOperationData, TemporalOperationType, -} from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; +} from "../gen/interfaces/metatype-typegraph-runtimes.js"; export class TemporalRuntime extends Runtime { host: string; diff --git a/typegraph/deno/src/runtimes/deno.ts b/typegraph/node/sdk/src/runtimes/deno.ts similarity index 93% rename from typegraph/deno/src/runtimes/deno.ts rename to typegraph/node/sdk/src/runtimes/deno.ts index 45469e6d74..1d32b57019 100644 --- a/typegraph/deno/src/runtimes/deno.ts +++ b/typegraph/node/sdk/src/runtimes/deno.ts @@ -1,12 +1,12 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "../types.ts"; -import { runtimes } from "../wit.ts"; -import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import Policy from "../policy.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +import * as t from "../types.js"; +import { runtimes } from "../wit.js"; +import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import Policy from "../policy.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; interface FunMat extends Materializer { code: string; diff --git a/typegraph/deno/src/runtimes/graphql.ts b/typegraph/node/sdk/src/runtimes/graphql.ts similarity index 89% rename from typegraph/deno/src/runtimes/graphql.ts rename to typegraph/node/sdk/src/runtimes/graphql.ts index 186a6e7b2d..219e00c42d 100644 --- a/typegraph/deno/src/runtimes/graphql.ts +++ b/typegraph/node/sdk/src/runtimes/graphql.ts @@ -1,11 +1,11 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import * as t from "../types.ts"; -import { runtimes } from "../wit.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import * as t from "../types.js"; +import { runtimes } from "../wit.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; export class GraphQLRuntime extends Runtime { constructor(private endpoint: string) { diff --git a/typegraph/deno/src/runtimes/http.ts b/typegraph/node/sdk/src/runtimes/http.ts similarity index 93% rename from typegraph/deno/src/runtimes/http.ts rename to typegraph/node/sdk/src/runtimes/http.ts index 90e541fdc2..6ffe82b108 100644 --- a/typegraph/deno/src/runtimes/http.ts +++ b/typegraph/node/sdk/src/runtimes/http.ts @@ -1,15 +1,15 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "../types.ts"; +import * as t from "../types.js"; import { Effect, HttpMethod, MaterializerHttpRequest, -} from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { runtimes } from "../wit.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +} from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import { runtimes } from "../wit.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; type HttpRequestMat = & Materializer diff --git a/typegraph/deno/src/runtimes/mod.ts b/typegraph/node/sdk/src/runtimes/mod.ts similarity index 100% rename from typegraph/deno/src/runtimes/mod.ts rename to typegraph/node/sdk/src/runtimes/mod.ts diff --git a/typegraph/deno/src/runtimes/python.ts b/typegraph/node/sdk/src/runtimes/python.ts similarity index 93% rename from typegraph/deno/src/runtimes/python.ts rename to typegraph/node/sdk/src/runtimes/python.ts index 052a325493..63cfe00c48 100644 --- a/typegraph/deno/src/runtimes/python.ts +++ b/typegraph/node/sdk/src/runtimes/python.ts @@ -1,11 +1,11 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "../types.ts"; -import { runtimes } from "../wit.ts"; -import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +import * as t from "../types.js"; +import { runtimes } from "../wit.js"; +import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; interface LambdaMat extends Materializer { fn: string; diff --git a/typegraph/deno/src/runtimes/random.ts b/typegraph/node/sdk/src/runtimes/random.ts similarity index 76% rename from typegraph/deno/src/runtimes/random.ts rename to typegraph/node/sdk/src/runtimes/random.ts index fcc1dc92f2..44ea35b106 100644 --- a/typegraph/deno/src/runtimes/random.ts +++ b/typegraph/node/sdk/src/runtimes/random.ts @@ -1,13 +1,13 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "../types.ts"; -import { runtimes } from "../wit.ts"; +import * as t from "../types.js"; +import { runtimes } from "../wit.js"; import { RandomRuntimeData, -} from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +} from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; interface RandomMat extends Materializer { runtime: number; diff --git a/typegraph/deno/src/runtimes/wasmedge.ts b/typegraph/node/sdk/src/runtimes/wasmedge.ts similarity index 86% rename from typegraph/deno/src/runtimes/wasmedge.ts rename to typegraph/node/sdk/src/runtimes/wasmedge.ts index 8c26614fab..7355b25de7 100644 --- a/typegraph/deno/src/runtimes/wasmedge.ts +++ b/typegraph/node/sdk/src/runtimes/wasmedge.ts @@ -1,11 +1,11 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "../types.ts"; -import { runtimes } from "../wit.ts"; -import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { Materializer, Runtime } from "./mod.ts"; -import { fx } from "../mod.ts"; +import * as t from "../types.js"; +import { runtimes } from "../wit.js"; +import { Effect } from "../gen/interfaces/metatype-typegraph-runtimes.js"; +import { Materializer, Runtime } from "./mod.js"; +import { fx } from "../index.js"; interface WasiMat extends Materializer { module: string; diff --git a/typegraph/deno/src/typegraph.ts b/typegraph/node/sdk/src/typegraph.ts similarity index 89% rename from typegraph/deno/src/typegraph.ts rename to typegraph/node/sdk/src/typegraph.ts index b62698bbde..8ae4505f23 100644 --- a/typegraph/deno/src/typegraph.ts +++ b/typegraph/node/sdk/src/typegraph.ts @@ -1,18 +1,18 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import * as t from "./types.ts"; +import * as t from "./types.js"; import { core } from "./gen/typegraph_core.js"; -import { caller, dirname, fromFileUrl } from "./deps.ts"; -import { InjectionValue } from "./utils/type_utils.ts"; +import { caller, dirname, fromFileUrl } from "./deps/mod.js"; +import { InjectionValue } from "./utils/type_utils.js"; import { serializeFromParentInjection, serializeGenericInjection, serializeStaticInjection, -} from "./utils/injection_utils.ts"; -import { Auth, Cors, Rate, wit_utils } from "./wit.ts"; -import Policy from "./policy.ts"; -import { getPolicyChain } from "./types.ts"; +} from "./utils/injection_utils.js"; +import { Auth, Cors, Rate, wit_utils } from "./wit.js"; +import Policy from "./policy.js"; +import { getPolicyChain } from "./types.js"; type Exports = Record; @@ -26,7 +26,7 @@ interface TypegraphArgs { rate?: Rate; } -interface TypegraphBuilderArgs { +export interface TypegraphBuilderArgs { expose: (exports: Exports, defaultPolicy?: Policy) => void; inherit: () => InheritDef; rest: (graphql: string) => number; @@ -62,7 +62,7 @@ export class InheritDef { } } -type TypegraphBuilder = (g: TypegraphBuilderArgs) => void; +export type TypegraphBuilder = (g: TypegraphBuilderArgs) => void; export class RawAuth { constructor(readonly jsonStr: string) {} diff --git a/typegraph/deno/src/types.ts b/typegraph/node/sdk/src/types.ts similarity index 96% rename from typegraph/deno/src/types.ts rename to typegraph/node/sdk/src/types.ts index 3712b9208c..63337ca1c2 100644 --- a/typegraph/deno/src/types.ts +++ b/typegraph/node/sdk/src/types.ts @@ -1,7 +1,7 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { core, wit_utils } from "./wit.ts"; +import { core, wit_utils } from "./wit.js"; import { PolicyPerEffect, PolicySpec as WitPolicySpec, @@ -14,20 +14,20 @@ import { TypeOptional, TypeString, TypeUnion, -} from "./gen/interfaces/metatype-typegraph-core.d.ts"; -import { Reduce } from "./gen/interfaces/metatype-typegraph-utils.d.ts"; -import { FuncParams } from "./gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { Materializer } from "./runtimes/mod.ts"; -import { mapValues } from "./deps.ts"; -import Policy from "./policy.ts"; -import { buildReduceData, serializeRecordValues } from "./utils/func_utils.ts"; +} from "./gen/interfaces/metatype-typegraph-core.js"; +import { Reduce } from "./gen/interfaces/metatype-typegraph-utils.js"; +import { FuncParams } from "./gen/interfaces/metatype-typegraph-runtimes.js"; +import { Materializer } from "./runtimes/mod.js"; +import { mapValues } from "./deps/mod.js"; +import Policy from "./policy.js"; +import { buildReduceData, serializeRecordValues } from "./utils/func_utils.js"; import { serializeFromParentInjection, serializeGenericInjection, serializeStaticInjection, -} from "./utils/injection_utils.ts"; -import { InjectionValue } from "./utils/type_utils.ts"; -import { InheritDef } from "./typegraph.ts"; +} from "./utils/injection_utils.js"; +import { InjectionValue } from "./utils/type_utils.js"; +import { InheritDef } from "./typegraph.js"; export type PolicySpec = Policy | { none: Policy; @@ -60,7 +60,7 @@ export function getPolicyChain( } return { tag: "per-effect", - val: mapValues(p, (v) => v._id) as unknown as PolicyPerEffect, + val: mapValues(p, (v: any) => v._id) as unknown as PolicyPerEffect, } as const; }); } diff --git a/typegraph/deno/src/utils/func_utils.ts b/typegraph/node/sdk/src/utils/func_utils.ts similarity index 93% rename from typegraph/deno/src/utils/func_utils.ts rename to typegraph/node/sdk/src/utils/func_utils.ts index b1a1aa2369..5326ceb66d 100644 --- a/typegraph/deno/src/utils/func_utils.ts +++ b/typegraph/node/sdk/src/utils/func_utils.ts @@ -1,9 +1,9 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { InheritDef } from "../typegraph.ts"; -import { ReducePath } from "../gen/interfaces/metatype-typegraph-utils.d.ts"; -import { serializeStaticInjection } from "./injection_utils.ts"; +import { InheritDef } from "../typegraph.js"; +import { ReducePath } from "../gen/interfaces/metatype-typegraph-utils.js"; +import { serializeStaticInjection } from "./injection_utils.js"; export function stringifySymbol(symbol: symbol) { const name = symbol.toString().match(/\((.+)\)/)?.[1]; diff --git a/typegraph/deno/src/utils/injection_utils.ts b/typegraph/node/sdk/src/utils/injection_utils.ts similarity index 92% rename from typegraph/deno/src/utils/injection_utils.ts rename to typegraph/node/sdk/src/utils/injection_utils.ts index 96ddc1b3bc..5b45ac8241 100644 --- a/typegraph/deno/src/utils/injection_utils.ts +++ b/typegraph/node/sdk/src/utils/injection_utils.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { CREATE, DELETE, READ, UPDATE } from "../effects.ts"; -import { InjectionSource, InjectionValue } from "./type_utils.ts"; -import { stringifySymbol } from "./func_utils.ts"; -import { genRef } from "./../typegraph.ts"; +import { CREATE, DELETE, READ, UPDATE } from "../effects.js"; +import { InjectionSource, InjectionValue } from "./type_utils.js"; +import { stringifySymbol } from "./func_utils.js"; +import { genRef } from "./../typegraph.js"; export function serializeInjection( source: InjectionSource, diff --git a/typegraph/deno/src/utils/type_utils.ts b/typegraph/node/sdk/src/utils/type_utils.ts similarity index 94% rename from typegraph/deno/src/utils/type_utils.ts rename to typegraph/node/sdk/src/utils/type_utils.ts index 29dbeab086..9f23750447 100644 --- a/typegraph/deno/src/utils/type_utils.ts +++ b/typegraph/node/sdk/src/utils/type_utils.ts @@ -1,7 +1,7 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { PerEffect } from "../effects.ts"; +import { PerEffect } from "../effects.js"; type RequiredKeys = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; diff --git a/typegraph/deno/src/wit.ts b/typegraph/node/sdk/src/wit.ts similarity index 82% rename from typegraph/deno/src/wit.ts rename to typegraph/node/sdk/src/wit.ts index ce0fb4412b..ea8c311509 100644 --- a/typegraph/deno/src/wit.ts +++ b/typegraph/node/sdk/src/wit.ts @@ -1,10 +1,10 @@ // Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0. // SPDX-License-Identifier: MPL-2.0 -import { MetatypeTypegraphCore } from "./gen/interfaces/metatype-typegraph-core.d.ts"; -import { MetatypeTypegraphRuntimes } from "./gen/interfaces/metatype-typegraph-runtimes.d.ts"; -import { MetatypeTypegraphAws } from "./gen/interfaces/metatype-typegraph-aws.d.ts"; -import { MetatypeTypegraphUtils } from "./gen/interfaces/metatype-typegraph-utils.d.ts"; +import { MetatypeTypegraphCore } from "./gen/interfaces/metatype-typegraph-core.js"; +import { MetatypeTypegraphRuntimes } from "./gen/interfaces/metatype-typegraph-runtimes.js"; +import { MetatypeTypegraphAws } from "./gen/interfaces/metatype-typegraph-aws.js"; +import { MetatypeTypegraphUtils } from "./gen/interfaces/metatype-typegraph-utils.js"; import * as js from "./gen/typegraph_core.js"; export const core = js.core as typeof MetatypeTypegraphCore; @@ -12,11 +12,11 @@ export const runtimes = js.runtimes as typeof MetatypeTypegraphRuntimes; export const aws = js.aws as typeof MetatypeTypegraphAws; export const wit_utils = js.utils as typeof MetatypeTypegraphUtils; -export type { Cors, Rate } from "./gen/interfaces/metatype-typegraph-core.d.ts"; +export type { Cors, Rate } from "./gen/interfaces/metatype-typegraph-core.js"; export type { Auth, AuthProtocol, AuthProtocolBasic, AuthProtocolJwt, AuthProtocolOauth2, -} from "./gen/interfaces/metatype-typegraph-utils.d.ts"; +} from "./gen/interfaces/metatype-typegraph-utils.js"; diff --git a/typegraph/node/sdk/tsconfig.json b/typegraph/node/sdk/tsconfig.json new file mode 100644 index 0000000000..731b802d22 --- /dev/null +++ b/typegraph/node/sdk/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2019", + "module": "NodeNext", + "moduleResolution": "Node16", + "esModuleInterop": true, + "declaration": true, + "outDir": "dist" + }, + "include": ["src"] +} diff --git a/whiz.yaml b/whiz.yaml index 1e5ede94bd..4510922b62 100644 --- a/whiz.yaml +++ b/whiz.yaml @@ -47,7 +47,7 @@ typegraph: watch: - "typegraph/core/src/**/*.rs" - "typegraph/core/wit/*.wit" - - "typegraph/deno/dev/fix-declarations.sh" + - "typegraph/node/src/**/*.ts" env: WASM_FILE: target/debug/typegraph_core.wasm command: | @@ -55,9 +55,12 @@ typegraph: cargo build -p typegraph_core --target wasm32-unknown-unknown --target-dir target/wasm wasm-tools component new target/wasm/wasm32-unknown-unknown/debug/typegraph_core.wasm -o $WASM_FILE - rm -rf typegraph/deno/src/gen - jco transpile $WASM_FILE -o typegraph/deno/src/gen - deno run -A typegraph/deno/dev/fix-declarations.ts + rm -rf typegraph/node/sdk/src/gen typegraph/node/sdk/dist + jco transpile $WASM_FILE -o typegraph/node/sdk/src/gen + cd typegraph/node + pnpm run sdk-build + cp ./sdk/{package.json,package-lock.json,LICENSE.md} ./sdk/dist + cd ../.. rm -rf typegraph/python/typegraph/gen poetry run python -m wasmtime.bindgen $WASM_FILE --out-dir typegraph/python/typegraph/gen @@ -106,7 +109,7 @@ setup: - website/package.json env: WASM_TOOLS_VERSION: "1.0.53" - JCO_VERSION: "0.12.1" + JCO_VERSION: "0.14.2" CARGO_INSTA_VERSION: "1.33.0" WASMEDGE_VERSION: "0.13.5" WASM_OPT_VERSION: "0.116.0" @@ -123,3 +126,6 @@ setup: cd website pnpm install cd .. + cd typegraph/node + pnpm install + cd ../..