Skip to content

Commit c07cfc6

Browse files
authored
Merge branch 'main' into upload/s3
2 parents 1317c75 + ac544b3 commit c07cfc6

File tree

18 files changed

+319
-277
lines changed

18 files changed

+319
-277
lines changed

examples/demo/metatype.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ typegates:
33
url: "http://localhost:7890"
44
username: admin
55
password: password
6-
env:
7-
TG_PUBLIC_API_POSTGRES: "postgresql://postgres:password@localhost:5432/db?schema=public-api"
8-
TG_PUBLIC_API_GITHUB_CLIENT_ID: infisical://app.infisical.com/643057c5bb17b13ef6e73d99/prod/GITHUB_CLIENT_ID
9-
TG_PUBLIC_API_GITHUB_CLIENT_SECRET: infisical://app.infisical.com/643057c5bb17b13ef6e73d99/prod/GITHUB_CLIENT_SECRET
6+
secrets:
7+
public-api:
8+
POSTGRES: "postgresql://postgres:password@localhost:5432/db?schema=public-api"
9+
GITHUB_CLIENT_ID: infisical://app.infisical.com/643057c5bb17b13ef6e73d99/prod/GITHUB_CLIENT_ID
10+
GITHUB_CLIENT_SECRET: infisical://app.infisical.com/643057c5bb17b13ef6e73d99/prod/GITHUB_CLIENT_SECRET

examples/deploy/deploy.mjs

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,66 @@ import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js";
77
import { wit_utils } from "@typegraph/sdk/wit.js";
88
import * as path from "path";
99

10-
11-
// deno
12-
// import { Policy, t, typegraph } from "../../typegraph/node/sdk/dist/index.js";
13-
// import { DenoRuntime } from "../../typegraph/node/sdk/dist/runtimes/deno.js";
14-
// import { PythonRuntime } from "../../typegraph/node/sdk/dist/runtimes/python.js";
15-
// import { WasmEdgeRuntime } from "../../typegraph/node/sdk/dist/runtimes/wasmedge.js";
16-
// import { tgDeploy } from "../../typegraph/node/sdk/dist/tg_deploy.js";
17-
// import { PrismaRuntime } from "../../typegraph/node/sdk/dist/providers/prisma.js";
18-
// import { BasicAuth } from "../../typegraph/node/sdk/dist/tg_deploy.js";
19-
// import { wit_utils } from "../../typegraph/node/sdk/dist/wit.js";
20-
2110
const tg = await typegraph({
2211
name: "deploy-example-node",
2312
}, (g) => {
24-
const deno = new DenoRuntime();
25-
const python = new PythonRuntime();
26-
const wasmedge = new WasmEdgeRuntime();
27-
const prisma = new PrismaRuntime("prisma", "POSTGRES")
28-
const pub = Policy.public();
29-
const student = t.struct(
30-
{
31-
id: t.integer({}, { asId: true }),
32-
name: t.string(),
33-
},
34-
{ name: "Student" },
35-
);
36-
37-
g.expose({
38-
test: deno.static(t.struct({ a: t.string() }), { a: "HELLO" }),
39-
// Deno
40-
sayHello: deno.import(
41-
t.struct({ name: t.string() }),
42-
t.string(),
43-
{ module: "scripts/deno/say_hello.ts", name: "sayHello" }
44-
),
45-
sayHelloLambda: deno.func(
46-
t.struct({ name: t.string() }),
47-
t.string(),
48-
{ code: "({ name }) => `Hello ${name} from deno lambda`" }
49-
),
50-
// Python
51-
sayHelloPyLambda: python.fromLambda(
52-
t.struct({ name: t.string() }),
53-
t.string(),
54-
{ code: `lambda obj: f"Hello {obj['name']} from python lambda"` }
55-
),
56-
sayHelloPyMod: python.import(
57-
t.struct({ name: t.string() }),
58-
t.string(),
59-
{ module: "scripts/python/say_hello.py", name: "sayHello" }
60-
),
61-
// Wasmedge
62-
testWasmedge: wasmedge.wasi(
63-
t.struct({"a": t.float(), "b": t.float()}),
64-
t.integer(),
65-
{ wasm: "wasi/rust.wasm", func: "add" }
66-
),
67-
// Prisma
68-
createStudent: prisma.create(student),
69-
findManyStudent: prisma.findMany(student),
70-
}, pub);
71-
},
72-
);
13+
const deno = new DenoRuntime();
14+
const python = new PythonRuntime();
15+
const wasmedge = new WasmEdgeRuntime();
16+
const prisma = new PrismaRuntime("prisma", "POSTGRES");
17+
const pub = Policy.public();
18+
const student = t.struct(
19+
{
20+
id: t.integer({}, { asId: true }),
21+
name: t.string(),
22+
},
23+
{ name: "Student" },
24+
);
25+
26+
g.expose({
27+
test: deno.static(t.struct({ a: t.string() }), { a: "HELLO" }),
28+
// Deno
29+
sayHello: deno.import(
30+
t.struct({ name: t.string() }),
31+
t.string(),
32+
{ module: "scripts/deno/say_hello.ts", name: "sayHello" },
33+
),
34+
sayHelloLambda: deno.func(
35+
t.struct({ name: t.string() }),
36+
t.string(),
37+
{ code: "({ name }) => `Hello ${name} from deno lambda`" },
38+
),
39+
// Python
40+
sayHelloPyLambda: python.fromLambda(
41+
t.struct({ name: t.string() }),
42+
t.string(),
43+
{ code: `lambda obj: f"Hello {obj['name']} from python lambda"` },
44+
),
45+
sayHelloPyMod: python.import(
46+
t.struct({ name: t.string() }),
47+
t.string(),
48+
{ module: "scripts/python/say_hello.py", name: "sayHello" },
49+
),
50+
// Wasmedge
51+
testWasmedge: wasmedge.wasi(
52+
t.struct({ "a": t.float(), "b": t.float() }),
53+
t.integer(),
54+
{ wasm: "wasi/rust.wasm", func: "add" },
55+
),
56+
// Prisma
57+
createStudent: prisma.create(student),
58+
findManyStudent: prisma.findMany(student),
59+
}, pub);
60+
});
7361

7462
const artifactsConfig = {
7563
prismaMigration: {
7664
globalAction: {
7765
create: true,
78-
reset: true
66+
reset: true,
7967
},
80-
migrationDir: path.join("prisma-migrations", tg.name)
81-
}
68+
migrationDir: path.join("prisma-migrations", tg.name),
69+
},
8270
};
8371
const baseUrl = "http://localhost:7890";
8472
const auth = new BasicAuth("admin", "password");
@@ -87,7 +75,7 @@ tgDeploy(tg, {
8775
baseUrl,
8876
auth,
8977
secrets: {
90-
TG_DEPLOY_EXAMPLE_NODE_POSTGRES: "postgresql://postgres:password@localhost:5432/db?schema=e2e7894"
78+
POSTGRES: "postgresql://postgres:password@localhost:5432/db?schema=e2e7894",
9179
},
9280
artifactsConfig: {
9381
...artifactsConfig,
@@ -106,11 +94,11 @@ tgDeploy(tg, {
10694
const baseDir = artifactsConfig.prismaMigration.migrationDir;
10795
// cwd + tg_name + runtime_name
10896
const fullPath = path.join(baseDir, runtime);
109-
wit_utils.unpackTarb64(migrations, fullPath);
110-
console.log(`Unpacked migrations at ${fullPath}`)
97+
wit_utils.unpackTarb64(migrations, fullPath);
98+
console.log(`Unpacked migrations at ${fullPath}`);
11199
});
112100
} else {
113101
throw new Error(JSON.stringify(typegate));
114102
}
115-
})
103+
})
116104
.catch(console.error);

examples/deploy/deploy.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
from typegraph import typegraph, Policy, t, Graph
2-
from typegraph.providers.prisma import PrismaRuntime
3-
from typegraph.runtimes.deno import DenoRuntime
1+
from os import path
42

3+
from typegraph import Graph, Policy, t, typegraph
54
from typegraph.graph.tg_deploy import (
6-
tg_deploy,
7-
TypegraphDeployParams,
85
BasicAuth,
6+
TypegraphDeployParams,
7+
tg_deploy,
98
)
9+
from typegraph.providers.prisma import PrismaRuntime
10+
from typegraph.runtimes.deno import DenoRuntime
1011
from typegraph.runtimes.python import PythonRuntime
1112
from typegraph.runtimes.wasmedge import WasmEdgeRuntime
1213
from typegraph.utils import unpack_tarb64
13-
from typegraph.wit import ArtifactResolutionConfig, MigrationConfig, MigrationAction
14-
15-
from os import path
14+
from typegraph.wit import ArtifactResolutionConfig, MigrationAction, MigrationConfig
1615

1716

1817
@typegraph()
@@ -97,7 +96,7 @@ def deploy_example_python(g: Graph):
9796
auth=auth,
9897
artifacts_config=artifacts_config,
9998
secrets={
100-
"TG_DEPLOY_EXAMPLE_PYTHON_POSTGRES": "postgresql://postgres:password@localhost:5432/db?schema=e2e7894"
99+
"POSTGRES": "postgresql://postgres:password@localhost:5432/db?schema=e2e7894"
101100
},
102101
),
103102
)

0 commit comments

Comments
 (0)