Skip to content

Commit

Permalink
feat(sdk/node): move js deno to node (#539)
Browse files Browse the repository at this point in the history
<!--
Pull requests are squash merged using:
- their title as the commit message
- their description as the commit body

Having a good title and description is important for the users to get
readable changelog and understand when they need to update his code and
how.
-->

### Describe your change

Change deno frontend to pure node

### Motivation and context

Easier integration.

### Migration notes

<!-- Explain HOW users should update their code when required -->

### Checklist

- [x] The change come with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change
  • Loading branch information
afmika committed Jan 12, 2024
1 parent 6cb9a1f commit 12e974f
Show file tree
Hide file tree
Showing 59 changed files with 855 additions and 335 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
7 changes: 3 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]": {
Expand Down
51 changes: 20 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions dev/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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':
Expand Down Expand Up @@ -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
Expand Down
75 changes: 0 additions & 75 deletions dev/publish.ts

This file was deleted.

4 changes: 2 additions & 2 deletions examples/templates/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"compilerOptions": {
"strict": true,
"moduleResolution": "node16",
"esModuleInterop": true
"esModuleInterop": true
}
}
2 changes: 1 addition & 1 deletion ghjk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion typegate/import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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/VFI7sTg4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jkeetA6mWngjCSpsrAc2Dc4w4vuzA1/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"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions typegate/tests/e2e/typegraph/typegraphs/deno/complex.ts
Original file line number Diff line number Diff line change
@@ -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(
{
Expand All @@ -25,7 +25,7 @@ typegraph(
maxAgeSec: 120,
},
},
(g) => {
(g: any) => {
const deno = new DenoRuntime();
const pub = Policy.public();

Expand Down
Loading

0 comments on commit 12e974f

Please sign in to comment.