Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Parameter transformation #587

Merged
merged 38 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2374530
update wit
Natoandro Feb 6, 2024
bf75c3a
parameter transform tree
Natoandro Feb 7, 2024
494be63
feat: conversion
Natoandro Feb 9, 2024
7839418
update conversion - add failing test
Natoandro Feb 9, 2024
235f2f3
first working test
Natoandro Feb 9, 2024
f228610
type aware transformer compiler
Natoandro Feb 10, 2024
c3a9377
more tests/fixes
Natoandro Feb 10, 2024
5403bbc
test in-list injection
Natoandro Feb 10, 2024
61d519e
address comments (security)
Natoandro Feb 12, 2024
afc60b5
Merge branch 'main' into feat/apply
Natoandro Feb 12, 2024
d8b869e
inline validators
Natoandro Feb 12, 2024
188f13d
visitor context
Natoandro Feb 12, 2024
293e7ca
inheritance validator
Natoandro Feb 13, 2024
5d4875f
fix validators
Natoandro Feb 14, 2024
47da8bc
test from_parent validation
Natoandro Feb 14, 2024
2a214a0
some doc comments
Natoandro Feb 14, 2024
a798ff1
Merge branch 'main' into feat/apply
Natoandro Feb 14, 2024
b3eb807
TypeScript client SDK for apply
Natoandro Feb 14, 2024
d3734fc
docs: Add doc for parameter transformation
Natoandro Feb 14, 2024
46fb126
upgrade pnpm
Natoandro Feb 14, 2024
78c619c
tests: fix typegraph_core tests
Natoandro Feb 15, 2024
50b1d2a
more tests
Natoandro Feb 15, 2024
85f68d8
fix tests
Natoandro Feb 15, 2024
8211dc2
docs: update docs
Natoandro Feb 15, 2024
6f91dbe
disable docker test on arm64
Natoandro Feb 15, 2024
2070366
fix tests
Natoandro Feb 15, 2024
9a54f26
Merge branch 'main' into feat/apply
Natoandro Feb 15, 2024
ff1c92f
fix visitor
Natoandro Feb 16, 2024
8ed22ef
fix tests
Natoandro Feb 16, 2024
e282c41
fix input validator test
Natoandro Feb 16, 2024
1214cc9
Merge branch 'main' into feat/apply
Natoandro Feb 16, 2024
ddca6e8
update snapshots
Natoandro Feb 16, 2024
85df23a
fix tests
Natoandro Feb 17, 2024
c6b6687
Merge branch 'main' into feat/apply
Natoandro Feb 19, 2024
32ccc87
fix merge confusions
Natoandro Feb 19, 2024
113b81a
fix test
Natoandro Feb 19, 2024
a519f1f
update snapshot
Natoandro Feb 19, 2024
3e4af7d
Merge branch 'main' into feat/apply
Natoandro Feb 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .ghjk/lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@
},
"portRef": "[email protected]",
"packageName": "@bytecodealliance/jco"
},
"f4760b34b6c9f9f96207cfb380deb77007a212a60bd10bdb3dc9d20b94c2785c": {
"version": "v8.15.2",
"depConfigs": {},
"portRef": "[email protected]"
}
}
},
Expand Down Expand Up @@ -746,7 +751,7 @@
}
},
{
"version": "v8.8.0",
"version": "v8.15.2",
"port": {
"ty": "denoWorker@v1",
"name": "pnpm_ghrel",
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ jobs:
strategy:
matrix:
include:
- os: macos-latest
activate: "source .venv/bin/activate"
# TODO
# - os: macos-latest
# activate: "source .venv/bin/activate"
- os: macos-14
activate: "source .venv/bin/activate"
#- os: windows-latest
Expand Down Expand Up @@ -186,8 +187,10 @@ jobs:
runner: ubuntu-latest
# FIXME: try macos-14 runner once all actions support it
# docker buildx action broken as of 2024-02-09
- platform: linux/arm64
runner: custom-macos

# TODO
# - platform: linux/arm64
# runner: custom-macos
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
Expand Down
79 changes: 45 additions & 34 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion dev/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ dev:
RUST_VERSION: 1.75.0
DENO_VERSION: 1.40.1
NODE_VERSION: 20.8.0
PNPM_VERSION: v8.8.0
PNPM_VERSION: v8.15.2
CARGO_INSTA_VERSION: 1.33.0
WASM_TOOLS_VERSION: 1.0.53
JCO_VERSION: 1.0.0
Expand Down
8 changes: 6 additions & 2 deletions examples/typegraphs/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def authentication(g: Graph):
deno = DenoRuntime()
public = Policy.public()

ctx = t.struct({"username": t.string().optional().from_context("username")})
ctx = t.struct({"username": t.string().optional()})

# highlight-start
# expects a secret in metatype.yml
Expand All @@ -26,6 +26,10 @@ def authentication(g: Graph):
# highlight-end

g.expose(
get_context=deno.identity(ctx),
get_context=deno.identity(ctx).apply(
{
"username": g.from_context("username"),
}
),
default_policy=[public],
)
6 changes: 4 additions & 2 deletions examples/typegraphs/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typegraph({
const pub = Policy.public();

const ctx = t.struct({
"username": t.string().optional().fromContext("username"),
"username": t.string().optional(),
});

// highlight-start
Expand All @@ -25,6 +25,8 @@ typegraph({
// highlight-end

g.expose({
get_context: deno.identity(ctx).withPolicy(pub),
get_context: deno.identity(ctx).apply({
username: g.fromContext("username"),
}).withPolicy(pub),
});
});
8 changes: 6 additions & 2 deletions examples/typegraphs/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def basic_authentication(g: Graph):
deno = DenoRuntime()
public = Policy.public()

ctx = t.struct({"username": t.string().optional().from_context("username")})
ctx = t.struct({"username": t.string().optional()})

# highlight-next-line
g.auth(Auth.basic(["admin"]))

g.expose(
public,
get_context=deno.identity(ctx),
get_context=deno.identity(ctx).apply(
{
"username": g.from_context("username"),
}
),
)
6 changes: 4 additions & 2 deletions examples/typegraphs/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ typegraph({
const pub = Policy.public();

const ctx = t.struct({
"username": t.string().optional().fromContext("username"),
"username": t.string().optional(),
});

// highlight-next-line
g.auth(Auth.basic(["admin"]));

g.expose({
get_context: deno.identity(ctx).withPolicy(pub),
get_context: deno.identity(ctx).apply({
username: g.fromContext("username"),
}).withPolicy(pub),
});
});
6 changes: 4 additions & 2 deletions examples/typegraphs/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def roadmap(g: Graph):
),
EffectUpdate(True),
),
get_context=deno.identity(
t.struct({"username": t.string().optional().from_context("username")})
get_context=deno.identity(t.struct({"username": t.string().optional()})).apply(
{
"username": g.from_context("username"),
}
),
)
6 changes: 4 additions & 2 deletions examples/typegraphs/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ typegraph({
effects.update(),
),
get_context: deno.identity(
t.struct({ "username": t.string().optional().fromContext("username") }),
),
t.struct({ "username": t.string().optional() }),
).apply({
"username": g.fromContext("username"),
}),
}, pub);
});
Loading
Loading