Skip to content

Commit 8448da9

Browse files
Feat/generic request context (#13)
* feat: introduce generic request constraints + add utilities for generating policies and requests + add utility for parsing compliance reports * fix: update js-yaml in package-lock for vulnerability reasons * fix: add missing utility function for the test suite * docs: update release notes and changelog * feat: update index.core
1 parent e0535a7 commit 8448da9

17 files changed

Lines changed: 680 additions & 50 deletions

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# ODRL Evaluator release notes
22

3+
## [0.5.1](https://github.com/SolidLabResearch/ODRL-Evaluator/compare/v0.5.0...v0.5.2) (2025-12-02)
4+
5+
6+
### Features
7+
8+
* introduce generic request constraints + add utilities for generating policies and requests + add utility for parsing compliance reports ([7a4878f](https://github.com/SolidLabResearch/ODRL-Evaluator/commit/7a4878f3aee50f2d2ad1caf257273c515b05790a))
9+
10+
11+
### Fixes
12+
13+
* add missing utility function for the test suite ([2f8576e](https://github.com/SolidLabResearch/ODRL-Evaluator/commit/2f8576ee9ed72512467f6adba41407ae1457d2f3))
14+
* update js-yaml in package-lock for vulnerability reasons ([9d71463](https://github.com/SolidLabResearch/ODRL-Evaluator/commit/9d71463142b295cc0df412b1ef7d3fce83f107dd))
15+
316
## [0.5.0](https://github.com/SolidLabResearch/ODRL-Evaluator/compare/v0.4.0...v0.5.0) (2025-10-15)
417

518
### Features

RELEASE_NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# ODRL Evaluator
22

3+
## 0.5.1
4+
5+
### New Features
6+
7+
* Support for all constraints (so for all Left Operands) following the approach of `sotw:Context`
8+
* Addition of utilities for generating simple ODRL Policies and the ODRL Request as Quad[]
9+
* `src/util/policy/PolicyUtil.ts`
10+
* `src/util/request/RequestUtil.ts`
11+
* Addition of a parser for the Compliance Report Util
12+
* `src/util/report/ComplianceReportUtil.ts`
13+
314
## v0.5.0
415

516
### New features

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "odrl-evaluator",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "An open implementation of an ODRL Evaluator that evaluates ODRL policies by generating Compliance Reports",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/evaluator/Atomizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { replaceSubject } from "../util/RDFUtil";
1414
/**
1515
* Represents an ODRL policy containing its identifier and categorized rules.
1616
*/
17-
export type Policy = {
17+
type Policy = {
1818
/** Unique identifier for the policy */
1919
identifier: Term,
2020
/** List of permission rules associated with the policy */
@@ -28,7 +28,7 @@ export type Policy = {
2828
/**
2929
* Represents a single ODRL rule.
3030
*/
31-
export type Rule = {
31+
type Rule = {
3232
/** Identifier of the policy this rule belongs to */
3333
policyID: Term,
3434
/** Unique identifier for the rule */

src/index.core.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ export * from './util/Vocabularies'
1616
export * from './util/Prefixes'
1717

1818
export * from './util/report/ComplianceReportTypes'
19+
export * from './util/report/ComplianceReportUtil'
20+
export * from './util/policy/PolicyUtil'
21+
export * from './util/request/RequestUtil'
1922
export * from './util/report/ComplianceReportUtil'

src/rules/Rules.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,53 +94,59 @@ export const RULES: string[] = [`@prefix string: <http://www.w3.org/2000/10/swap
9494
?premiseReport report:constraintLeftOperand ?dateTime .
9595
}.
9696
97-
# odrl:purpose
98-
# https://www.w3.org/TR/odrl-vocab/#term-purpose
99-
# Create empty premise report for purposes (no purpose present in the evaluation request)
97+
# Other ODRL constraint Left operands
98+
# Create empty premise report for leftOperands (no leftOperand present in the evaluation request)
10099
{
101-
# check for number of purposes in evaluation request
100+
# acceptable ODRL Left Operands
101+
?leftOperand list:in ( odrl:absolutePosition odrl:absoluteSize odrl:absoluteSpatialPosition odrl:absoluteTemporalPosition odrl:count odrl:delayPeriod odrl:deliveryChannel odrl:device odrl:elapsedTime odrl:event odrl:fileFormat odrl:industry odrl:language odrl:media odrl:meteredTime odrl:payAmount odrl:percentage odrl:product odrl:purpose odrl:recipient odrl:relativePosition odrl:relativeSize odrl:relativeSpatialPosition odrl:relativeTemporalPosition odrl:resolution odrl:spatial odrl:spatialCoordinates odrl:system odrl:systemDevice odrl:timeInterval odrl:unitOfCount odrl:version odrl:virtualLocation ) .
102+
103+
# check for number of leftOperands in evaluation request
102104
(
103105
?template
104106
{
105107
?requestPermission sotw:context ?requestContextConstraint .
106-
?requestContextConstraint odrl:leftOperand odrl:purpose .
108+
?requestContextConstraint odrl:leftOperand ?leftOperand .
107109
}
108110
?L
109111
) log:collectAllIn ?SCOPE .
110-
# number of purposes in evaluation request is 0
112+
# number of leftOperands in evaluation request is 0
111113
?L list:length 0 .
112114
113-
# a rule with a purpose constraint
115+
# a rule with a leftOperand constraint
114116
_:a odrl:constraint ?constraint .
115-
?constraint odrl:leftOperand odrl:purpose .
117+
?constraint odrl:leftOperand ?leftOperand .
116118
117119
# created premiseReport
118120
?premiseReport report:constraint ?constraint .
119121
} => {
120-
?premiseReport report:constraintLeftOperand "" . #TODO: do we need a default purpose?
122+
?premiseReport report:constraintLeftOperand "" . #TODO: do we need a default null left operand value?
121123
}.
122124
123-
# Create empty premise report for purposes (one present in the evaluation request)
125+
# Create empty premise report for leftOperands (one present in the evaluation request)
124126
{
127+
# acceptable ODRL Left Operands
128+
?leftOperand list:in ( odrl:absolutePosition odrl:absoluteSize odrl:absoluteSpatialPosition odrl:absoluteTemporalPosition odrl:count odrl:delayPeriod odrl:deliveryChannel odrl:device odrl:elapsedTime odrl:event odrl:fileFormat odrl:industry odrl:language odrl:media odrl:meteredTime odrl:payAmount odrl:percentage odrl:product odrl:purpose odrl:recipient odrl:relativePosition odrl:relativeSize odrl:relativeSpatialPosition odrl:relativeTemporalPosition odrl:resolution odrl:spatial odrl:spatialCoordinates odrl:system odrl:systemDevice odrl:timeInterval odrl:unitOfCount odrl:version odrl:virtualLocation ) .
129+
130+
125131
?requestPermission sotw:context ?requestContextConstraint .
126-
?requestContextConstraint odrl:leftOperand odrl:purpose .
132+
?requestContextConstraint odrl:leftOperand ?leftOperand .
127133
?requestContextConstraint odrl:rightOperand ?requestedPurpose .
128134
129-
# check for number of purposes in evaluation request
135+
# check for number of leftOperands in evaluation request
130136
(
131137
?template
132138
{
133139
?requestPermission sotw:context ?requestContextConstraint .
134-
?requestContextConstraint odrl:leftOperand odrl:purpose .
140+
?requestContextConstraint odrl:leftOperand ?leftOperand .
135141
}
136142
?L
137143
) log:collectAllIn ?SCOPE .
138-
# number of purposes in evaluation request is 1
144+
# number of leftOperands in evaluation request is 1
139145
?L list:length 1 .
140146
141147
# a rule with a purpose constraint
142148
_:a odrl:constraint ?constraint .
143-
?constraint odrl:leftOperand odrl:purpose .
149+
?constraint odrl:leftOperand ?leftOperand .
144150
145151
# created premiseReport
146152
?premiseReport report:constraint ?constraint .

src/rules/constraints.n3

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,53 +57,59 @@
5757
?premiseReport report:constraintLeftOperand ?dateTime .
5858
}.
5959

60-
# odrl:purpose
61-
# https://www.w3.org/TR/odrl-vocab/#term-purpose
62-
# Create empty premise report for purposes (no purpose present in the evaluation request)
60+
# Other ODRL constraint Left operands
61+
# Create empty premise report for leftOperands (no leftOperand present in the evaluation request)
6362
{
64-
# check for number of purposes in evaluation request
63+
# acceptable ODRL Left Operands
64+
?leftOperand list:in ( odrl:absolutePosition odrl:absoluteSize odrl:absoluteSpatialPosition odrl:absoluteTemporalPosition odrl:count odrl:delayPeriod odrl:deliveryChannel odrl:device odrl:elapsedTime odrl:event odrl:fileFormat odrl:industry odrl:language odrl:media odrl:meteredTime odrl:payAmount odrl:percentage odrl:product odrl:purpose odrl:recipient odrl:relativePosition odrl:relativeSize odrl:relativeSpatialPosition odrl:relativeTemporalPosition odrl:resolution odrl:spatial odrl:spatialCoordinates odrl:system odrl:systemDevice odrl:timeInterval odrl:unitOfCount odrl:version odrl:virtualLocation ) .
65+
66+
# check for number of leftOperands in evaluation request
6567
(
6668
?template
6769
{
6870
?requestPermission sotw:context ?requestContextConstraint .
69-
?requestContextConstraint odrl:leftOperand odrl:purpose .
71+
?requestContextConstraint odrl:leftOperand ?leftOperand .
7072
}
7173
?L
7274
) log:collectAllIn ?SCOPE .
73-
# number of purposes in evaluation request is 0
75+
# number of leftOperands in evaluation request is 0
7476
?L list:length 0 .
7577

76-
# a rule with a purpose constraint
78+
# a rule with a leftOperand constraint
7779
_:a odrl:constraint ?constraint .
78-
?constraint odrl:leftOperand odrl:purpose .
80+
?constraint odrl:leftOperand ?leftOperand .
7981

8082
# created premiseReport
8183
?premiseReport report:constraint ?constraint .
8284
} => {
83-
?premiseReport report:constraintLeftOperand "" . #TODO: do we need a default purpose?
85+
?premiseReport report:constraintLeftOperand "" . #TODO: do we need a default null left operand value?
8486
}.
8587

86-
# Create empty premise report for purposes (one present in the evaluation request)
88+
# Create empty premise report for leftOperands (one present in the evaluation request)
8789
{
90+
# acceptable ODRL Left Operands
91+
?leftOperand list:in ( odrl:absolutePosition odrl:absoluteSize odrl:absoluteSpatialPosition odrl:absoluteTemporalPosition odrl:count odrl:delayPeriod odrl:deliveryChannel odrl:device odrl:elapsedTime odrl:event odrl:fileFormat odrl:industry odrl:language odrl:media odrl:meteredTime odrl:payAmount odrl:percentage odrl:product odrl:purpose odrl:recipient odrl:relativePosition odrl:relativeSize odrl:relativeSpatialPosition odrl:relativeTemporalPosition odrl:resolution odrl:spatial odrl:spatialCoordinates odrl:system odrl:systemDevice odrl:timeInterval odrl:unitOfCount odrl:version odrl:virtualLocation ) .
92+
93+
8894
?requestPermission sotw:context ?requestContextConstraint .
89-
?requestContextConstraint odrl:leftOperand odrl:purpose .
95+
?requestContextConstraint odrl:leftOperand ?leftOperand .
9096
?requestContextConstraint odrl:rightOperand ?requestedPurpose .
9197

92-
# check for number of purposes in evaluation request
98+
# check for number of leftOperands in evaluation request
9399
(
94100
?template
95101
{
96102
?requestPermission sotw:context ?requestContextConstraint .
97-
?requestContextConstraint odrl:leftOperand odrl:purpose .
103+
?requestContextConstraint odrl:leftOperand ?leftOperand .
98104
}
99105
?L
100106
) log:collectAllIn ?SCOPE .
101-
# number of purposes in evaluation request is 1
107+
# number of leftOperands in evaluation request is 1
102108
?L list:length 1 .
103109

104110
# a rule with a purpose constraint
105111
_:a odrl:constraint ?constraint .
106-
?constraint odrl:leftOperand odrl:purpose .
112+
?constraint odrl:leftOperand ?leftOperand .
107113

108114
# created premiseReport
109115
?premiseReport report:constraint ?constraint .

src/util/Prefixes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export const prefixes = {
66
odrl: "http://www.w3.org/ns/odrl/2/",
77
schema: "https://schema.org/",
88
xsd: "http://www.w3.org/2001/XMLSchema#",
9-
dpv: "https://w3id.org/dpv#"
9+
dpv: "https://w3id.org/dpv#",
10+
sotw: "https://w3id.org/force/sotw#"
1011
}

src/util/Util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { v4 as uuidv4 } from 'uuid';
2+
3+
/**
4+
* Helper to generate URNs from UUIDs.
5+
* Produces identifiers in the form: urn:uuid:<UUID>
6+
*/
7+
export function createRandomUrn(): string {
8+
return `urn:uuid:${uuidv4()}`;
9+
}

0 commit comments

Comments
 (0)