Skip to content

Commit d6f29b7

Browse files
Consent management component (#11)
* move data-collection to its own fodler * add consent-mapping component * update ci to build all component types * fix gitignores * rename component name
1 parent 66acd88 commit d6f29b7

File tree

15 files changed

+177
-30
lines changed

15 files changed

+177
-30
lines changed

.github/workflows/check.yml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
name: Check
22
on:
3-
push:
4-
branches:
5-
- main
6-
pull_request:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
77

88
env:
99
EDGEE_API_TOKEN: ${{ secrets.EDGEE_API_TOKEN }}
1010

1111
jobs:
12-
test:
13-
name: test
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
12+
full-ci:
13+
name: Full CI (${{ matrix.dir }})
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
dir: [consent-management, data-collection]
18+
defaults:
19+
run:
20+
working-directory: ${{ matrix.dir }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
1824

19-
- name: "Set up Dotnet SDK"
20-
run: |
21-
wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz
22-
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet
25+
- name: "Set up Dotnet SDK"
26+
run: |
27+
wget https://download.visualstudio.microsoft.com/download/pr/c526dc3b-5240-4449-ba07-ed9a3610fe09/442f1cf6e4e832eea0b045f9e108c8b7/dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz
28+
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-10.0.100-preview.2.25164.34-linux-x64.tar.gz -C $HOME/dotnet
2329
24-
- name: Install edgee
25-
uses: edgee-cloud/[email protected]
30+
- name: Install edgee
31+
uses: edgee-cloud/[email protected]
2632

27-
- name: Build component
28-
run: |
29-
export DOTNET_ROOT=$HOME/dotnet
30-
export PATH=$HOME/dotnet:$PATH
31-
edgee component build
32-
33-
- name: Verify .wasm file exists
34-
run: |
35-
if [ ! -f "./dc_component.wasm" ]; then
36-
echo "❌ Error: dc_component.wasm not found" >&2
37-
exit 1
38-
fi
33+
- name: Build component
34+
run: |
35+
export DOTNET_ROOT=$HOME/dotnet
36+
export PATH=$HOME/dotnet:$PATH
37+
edgee component build
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.edgee/
22
bin/
33
obj/
4-
dc-component.wasm
4+
component.wasm

consent-management/Component.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace ConsentManagementWorld.wit.exports.edgee.components.v1_0_0;
2+
3+
public struct Settings {
4+
public string Example { get; }
5+
6+
public Settings(List<(string, string)> settings) {
7+
Example = string.Empty;
8+
foreach (var setting in settings) {
9+
if (setting.Item1 == "example") {
10+
Example = setting.Item2;
11+
}
12+
}
13+
}
14+
}
15+
16+
public struct Cookies {
17+
public string Example { get; }
18+
19+
public Cookies(List<(string, string)> cookies) {
20+
Example = string.Empty;
21+
foreach (var cookie in cookies) {
22+
if (cookie.Item1 == "example") {
23+
Example = cookie.Item2;
24+
}
25+
}
26+
}
27+
}
28+
29+
public class ConsentManagementImpl: IConsentManagement {
30+
public static IConsentManagement.Consent? Map(List<(string, string)> cookies, List<(string, string)> settings) {
31+
Settings s = new Settings(settings);
32+
Cookies c = new Cookies(cookies);
33+
34+
if (c.Example == string.Empty) {
35+
return null;
36+
} else if (c.Example == "granted") {
37+
return IConsentManagement.Consent.GRANTED;
38+
} else if (c.Example == "denied") {
39+
return IConsentManagement.Consent.DENIED;
40+
} else {
41+
return IConsentManagement.Consent.PENDING;
42+
}
43+
44+
}
45+
}
46+
File renamed without changes.
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
manifest-version = 1
2+
3+
[component]
4+
name = "example-cs-consent-management-component"
5+
version = "1.0.0"
6+
category = "consent-management"
7+
subcategory = "consent-mapping"
8+
description = "Example CSharp component for consent management"
9+
documentation = "https://github.com/edgee-cloud/example-cs-component"
10+
repository = "https://github.com/edgee-cloud/example-cs-component"
11+
language = "CSharp"
12+
wit-version = "1.0.0"
13+
14+
[component.build]
15+
command = "dotnet build && mv ./bin/Debug/net10.0/wasi-wasm/publish/example-cs-component.wasm ./component.wasm"
16+
output_path = "./component.wasm"
17+
18+
[component.settings.example]
19+
title = "Example Config Field"
20+
type = "string"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<RootNamespace>example_cs_component</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
10+
<UseAppHost>false</UseAppHost>
11+
<PublishTrimmed>true</PublishTrimmed>
12+
<InvariantGlobalization>true</InvariantGlobalization>
13+
<SelfContained>true</SelfContained>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="BytecodeAlliance.Componentize.DotNet.Wasm.SDK" Version="0.5.0-preview00008" />
18+
<PackageReference Include="runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm" Version="10.0.0-alpha.1.25075.1" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Wit Remove="**\*.wit" />
23+
<Wit Include=".edgee/wit" World="consent-management" />
24+
</ItemGroup>
25+
26+
</Project>
File renamed without changes.

data-collection/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.edgee/
2+
bin/
3+
obj/
4+
component.wasm
File renamed without changes.

data-collection/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: all
2+
MAKEFLAGS += --silent
3+
4+
all: help
5+
6+
help:
7+
@grep -E '^[a-zA-Z1-9\._-]+:.*?## .*$$' $(MAKEFILE_LIST) \
8+
| sort \
9+
| sed -e "s/^Makefile://" -e "s///" \
10+
| awk 'BEGIN { FS = ":.*?## " }; { printf "\033[36m%-30s\033[0m %s\n", $$1, $$2 }'
11+
12+
build:
13+
edgee components build

data-collection/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div align="center">
2+
<p align="center">
3+
<a href="https://www.edgee.cloud">
4+
<picture>
5+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.edgee.cloud/img/component-dark.svg">
6+
<img src="https://cdn.edgee.cloud/img/component.svg" height="100" alt="Edgee">
7+
</picture>
8+
</a>
9+
</p>
10+
</div>
11+
12+
<h1 align="center">Example dotnet component for Edgee</h1>
13+
14+
This is an example of a C# Edgee Component.
15+
16+
## Setup
17+
Requirements:
18+
- [edgee-cli](https://github.com/edgee-cloud/edgee)
19+
- [dotnet SDK 10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0)
20+
- Modify the csproj file to match your OS:
21+
- On Linux
22+
```dotnet add package runtime.linux-x64.microsoft.dotnet.ilcompiler.llvm --prerelease```
23+
- On Windows
24+
```dotnet add package runtime.win-x64.microsoft.dotnet.ilcompiler.llvm --prerelease```
25+
26+
## Building
27+
28+
```shell
29+
$ make build
30+
```

edgee-component.toml renamed to data-collection/edgee-component.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
manifest-version = 1
22

33
[component]
4-
name = "example-cs-component"
4+
name = "example-cs-data-collection-component"
55
version = "1.0.0"
66
category = "data-collection"
77
subcategory = "analytics"

data-collection/nuget.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
7+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
8+
</packageSources>
9+
</configuration>

0 commit comments

Comments
 (0)