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

Update wit #2

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 22 additions & 19 deletions dc_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (

// Implement the datacollection.Exports.Page, datacollection.Exports.Track, and datacollection.Exports.User functions.
// These functions are called by the Edgee runtime to get the HTTP request to make to the provider's API for each event type.
func PageHandler(e dc.Event, cred dc.Dict) dc.EdgeeRequest {
// Access creds by using the Slice method
func PageHandler(e dc.Event, settings dc.Dict) dc.EdgeeRequest {
// Access settings by using the Slice method
// For example, if you component is setup as following:
// [[components.data_collection]]
// name = "my_component"
// component = "outpout.wasm"
// credentials.test_project_id = "123456789"
// credentials.test_write_key = "abcdefg"
// settings.test_project_id = "123456789"
// settings.test_write_key = "abcdefg"
// Then
// cred.Slice() will return a slice of tuples with the following values:
// settings.Slice() will return a slice of tuples with the following values:
// [["test_project_id", "123456789"], ["test_write_key", "abcdefg"]]
headers := [][2]string{
{"Content-Type", "application/json"},
Expand All @@ -25,44 +25,47 @@ func PageHandler(e dc.Event, cred dc.Dict) dc.EdgeeRequest {
list := cm.NewList(&headers[0], len(headers))
dict := dc.Dict(list)
edgeeRequest := dc.EdgeeRequest{
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
ForwardClientHeaders: true,
}

return edgeeRequest
}

func TrackHandler(e dc.Event, cred dc.Dict) dc.EdgeeRequest {
func TrackHandler(e dc.Event, settings dc.Dict) dc.EdgeeRequest {
headers := [][2]string{
{"Content-Type", "application/json"},
{"Authorization", "Bearer token123"},
}
list := cm.NewList(&headers[0], len(headers))
dict := dc.Dict(list)
edgeeRequest := dc.EdgeeRequest{
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
ForwardClientHeaders: true,
}

return edgeeRequest
}

func UserHandler(e dc.Event, cred dc.Dict) dc.EdgeeRequest {
func UserHandler(e dc.Event, settings dc.Dict) dc.EdgeeRequest {
headers := [][2]string{
{"Content-Type", "application/json"},
{"Authorization", "Bearer token123"},
}
list := cm.NewList(&headers[0], len(headers))
dict := dc.Dict(list)
edgeeRequest := dc.EdgeeRequest{
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
Method: dc.HTTPMethodGET,
URL: "https://example.com/api/resource",
Headers: dict,
Body: `{"key": "value"}`,
ForwardClientHeaders: true,
}

return edgeeRequest
Expand Down
6 changes: 3 additions & 3 deletions wit/deps.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ sha256 = "6d8dbfaaaa685167c1829616dc7265f5f3cb776845879555612d56544f6d9bfc"
sha512 = "52219562c4183503169cd2947b8164e1c96974500a5adf15bbf382c5992a10a626cc89c3b319204aeda6698ce59cbca2c42f98f7fde296aa77b9db4b41154dbe"

[protocols]
url = "https://github.com/edgee-cloud/edgee-wit/archive/refs/tags/v0.3.0.tar.gz"
sha256 = "4d412367fff6f826280acbe95f7067e362d9299d76e60994981e7e27c74d1576"
sha512 = "65021cace5ed07990fdfb563699accb975a31cb22311739ff6189849b969b06b564a0f8f72de154fd086ba474757d3cffaef0175778e4989c467280cf1c86284"
url = "https://github.com/edgee-cloud/edgee-wit/archive/refs/tags/v0.4.0.tar.gz"
sha256 = "8b5c8ea97c81d1d6cf4f227e75afb8c4dc5c0a411c3a0401fb7e4f7b745e21ba"
sha512 = "16771cd12095409e7c4857a8f5c0b4ad680959e3c35dcd7999e11131bcce05d3b1a1b829daefceabbd853ae5b7f6453e3e359ddfbdebd6e2a94db6c55780368f"

[random]
sha256 = "b4bb285b1c51aac2f8911f6b44ba1587108a2b24f910fe4774414dc286678b66"
Expand Down
2 changes: 1 addition & 1 deletion wit/deps.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
protocols="https://github.com/edgee-cloud/edgee-wit/archive/refs/tags/v0.3.0.tar.gz"
protocols="https://github.com/edgee-cloud/edgee-wit/archive/refs/tags/v0.4.0.tar.gz"
cli="https://github.com/WebAssembly/wasi-cli/archive/refs/tags/v0.2.2.tar.gz"
4 changes: 2 additions & 2 deletions wit/deps/protocols/consent-mapping.wit
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package edgee:protocols;

interface consent-mapping {
type config = list<tuple<string,string>>;
type dict = list<tuple<string,string>>;

enum consent {
pending,
granted,
denied,
}

map: func(cookie: string, config: config) -> option<consent>;
map: func(cookie: string, settings: dict) -> option<consent>;
}
7 changes: 4 additions & 3 deletions wit/deps/protocols/data-collection.wit
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ interface data-collection {
method: http-method,
url: string,
headers: dict,
forward-client-headers: bool,
body: string,
}

enum http-method { GET, PUT, POST, DELETE }

page: func(e: event, cred: dict) -> result<edgee-request, string>;
track: func(e: event, cred: dict) -> result<edgee-request, string>;
user: func(e: event, cred:dict) -> result<edgee-request, string>;
page: func(e: event, settings: dict) -> result<edgee-request, string>;
track: func(e: event, settings: dict) -> result<edgee-request, string>;
user: func(e: event, settings:dict) -> result<edgee-request, string>;
}