Skip to content

Commit

Permalink
docs: improve docs/reference/types (#685)
Browse files Browse the repository at this point in the history
Improves `docs/reference/types`

#### Motivation and context

_N/A_

#### Migration notes

_N/A_

### Checklist

- [ ] The change come with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [x] End-user documentation is updated to reflect the change

---------

Signed-off-by: Michaël <afmichael73@gmail.com>
Co-authored-by: afmika <afmichael73@gmail.com>
Co-authored-by: Teo Stocco <teo@zifeo.com>
Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 25, 2024
1 parent f0f41ac commit 774fe3d
Show file tree
Hide file tree
Showing 37 changed files with 550 additions and 253 deletions.
44 changes: 22 additions & 22 deletions .ghjk/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"version": "0.13.5",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
}
},
"portRef": "wasmedge_ghrel@0.1.0"
},
"9e3fa7742c431c34ae7ba8d1e907e50c937ccfb631fb4dcfb7a1773742abe267": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
},
Expand All @@ -30,20 +30,20 @@
"version": "3.28.0-rc6",
"depConfigs": {
"curl_aa": {
"version": "8.2.1",
"version": "8.5.0",
"depConfigs": {},
"portRef": "curl_aa@0.1.0"
},
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
},
"asdf_plugin_git": {
"version": "d631481e96",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand All @@ -63,20 +63,20 @@
"installType": "version"
},
"c7d12a562ecc8f3f95df5469ec0272561bc6715ebc41bcd82ba94f17a69a6fcb": {
"version": "8.2.1",
"version": "8.5.0",
"depConfigs": {},
"portRef": "curl_aa@0.1.0"
},
"0c719c533251d13d9e84b3113733c9dcd9e48f978c02f3fc4e14816080f7a69e": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
},
"9ffe0540cc740abe4bae8b926d9f53b78deee279a25c863e64e99263ee0ec7d1": {
"version": "d631481e96",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand Down Expand Up @@ -109,7 +109,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand All @@ -132,7 +132,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand All @@ -147,7 +147,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand All @@ -169,7 +169,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand Down Expand Up @@ -200,7 +200,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand All @@ -220,7 +220,7 @@
"version": "v20.8.0",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
}
Expand All @@ -239,7 +239,7 @@
"version": "v20.8.0",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
}
Expand All @@ -257,7 +257,7 @@
"version": "v20.8.0",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
}
Expand All @@ -272,7 +272,7 @@
"version": "v2.4.0",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
}
Expand All @@ -284,7 +284,7 @@
"version": "3.8.18",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
},
Expand All @@ -309,7 +309,7 @@
"version": "3.12.2",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
},
Expand All @@ -330,7 +330,7 @@
"version": "3.12.2",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
},
Expand All @@ -350,7 +350,7 @@
"version": "3.12.2",
"depConfigs": {
"tar_aa": {
"version": "1.34",
"version": "1.35",
"depConfigs": {},
"portRef": "tar_aa@0.1.0"
},
Expand Down Expand Up @@ -387,7 +387,7 @@
"version": "1.27.0",
"depConfigs": {
"git_aa": {
"version": "2.40.1",
"version": "2.43.0",
"depConfigs": {},
"portRef": "git_aa@0.1.0"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/typegraphs/faas-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PythonRuntime } from "@typegraph/sdk/runtimes/python.js";

// skip:end

await typegraph({
typegraph({
name: "faas-runner",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand All @@ -20,7 +20,7 @@ await typegraph({

g.expose({
pycumsum: python.fromLambda(inp, out, {
code: `lambda inp: sum(range(inp["n"])`,
code: `lambda inp: sum(range(inp["n"]))`,
}),
tscumsum: deno.func(
inp,
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/iam-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getEnvOrDefault(key: string, defaultValue: string) {
}
// skip:end

await typegraph({
typegraph({
name: "iam-provider",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HttpRuntime } from "@typegraph/sdk/runtimes/http.js";

// skip:end

await typegraph({
typegraph({
name: "homepage",
// skip:start
rate: { windowLimit: 2000, windowSec: 60, queryLimit: 200, localExcess: 0 },
Expand Down
35 changes: 35 additions & 0 deletions examples/typegraphs/injections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typegraph import Policy, typegraph, t, Graph
from typegraph.runtimes.deno import DenoRuntime


@typegraph()
def injection_example(g: Graph):
deno = DenoRuntime()
pub = Policy.public()

g.expose(
get_injected=deno.func(
t.struct(
{
"static_value": t.integer().set(12),
"context_value": t.uuid().from_context("profile.userId"),
"secret_value": t.string().from_secret("secret_name"),
"dynamic_value": t.datetime().inject("now"),
}
).rename("Input"),
t.struct(
{
"static_value": t.integer().rename("Static"),
"context_value": t.uuid(),
"secret_value": t.string(),
"nested": deno.identity(
t.struct({"parent_value": t.integer().from_parent("Static")}),
),
"dynamic_value": t.datetime(),
}
).rename("Output"),
code="""
({ static_value, context_value, secret_value, dynamic_value }) => ({ static_value, context_value, secret_value, dynamic_value })
""",
).with_policy(pub)
)
34 changes: 34 additions & 0 deletions examples/typegraphs/injections.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Policy, t, typegraph } from "@typegraph/sdk";
import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";

typegraph("injection-example", (g) => {
const deno = new DenoRuntime();
const pub = Policy.public();

g.expose({
get_injected: deno.func(
t.struct({
static_value: t.integer().set(12),
context_value: t.uuid().fromContext("profile.userId"),
secret_value: t.string().fromSecret("secret_name"),
dynamic_value: t.datetime().inject("now"),
}).rename("Input"),
t.struct({
static_value: t.integer().rename("Static"),
context_value: t.uuid(),
secret_value: t.string(),
nested: deno.identity(
t.struct({
parent_value: t.integer().fromParent("Static"),
}),
),
dynamic_value: t.datetime(),
}).rename("Output"),
{
code: (
{ static_value, context_value, secret_value, dynamic_value },
) => ({ static_value, context_value, secret_value, dynamic_value }),
},
).withPolicy(pub),
});
});
2 changes: 1 addition & 1 deletion examples/typegraphs/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";

// skip:end

await typegraph({
typegraph({
name: "jwt-authentication",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Policy, t, typegraph } from "@typegraph/sdk/index.js";
// skip:end
import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";

await typegraph({
typegraph({
name: "math",
// skip:start
rate: { windowLimit: 2000, windowSec: 60, queryLimit: 200, localExcess: 0 },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/microservice-orchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getEnvOrDefault(key: string, defaultValue: string) {
}
// skip:end

await typegraph({
typegraph({
name: "team-a",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";

// skip:end

await typegraph({
typegraph({
name: "oauth2-authentication",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Auth } from "@typegraph/sdk/params.js";
import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";
import { RandomRuntime } from "@typegraph/sdk/runtimes/random.js";

await typegraph({
typegraph({
name: "policies",
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
}, (g) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/prisma-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.js";

// skip:end

await typegraph({
typegraph({
name: "prisma-runtime",
cors: {
// skip:start
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Policy, t, typegraph } from "@typegraph/sdk/index.js";
import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.js";

await typegraph({
typegraph({
name: "roadmap-prisma",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/programmable-api-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";

// skip:end

await typegraph({
typegraph({
name: "programmable-api-gateway",
// skip:next-line
cors: { allowOrigin: ["https://metatype.dev", "http://localhost:3000"] },
Expand Down
2 changes: 1 addition & 1 deletion examples/typegraphs/quick-start-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DenoRuntime } from "@typegraph/sdk/runtimes/deno.js";
import { PythonRuntime } from "@typegraph/sdk/runtimes/python.js";
import { PrismaRuntime } from "@typegraph/sdk/providers/prisma.js";

await typegraph("example", (g) => {
typegraph("example", (g) => {
// access control
const pub = Policy.public();

Expand Down
Loading

0 comments on commit 774fe3d

Please sign in to comment.