Skip to content

Commit 3b539a9

Browse files
committed
fix: fix getuuid bug not generating random urns
1 parent d6689f3 commit 3b539a9

7 files changed

Lines changed: 28 additions & 49 deletions

File tree

demo/dynamic-policy.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Parser, Writer } from 'n3';
2-
import { materializePolicy, ODRLEngineMultipleSteps, ODRLEvaluator, resourceToOptimisedTurtle } from "../dist/index";
2+
import { materializePolicy, ODRLEngineMultipleSteps, ODRLEvaluator, prefixes } from "../dist/index";
3+
import { write } from '@jeswr/pretty-turtle';
34

45

56
// Variant on test case 036: Read request from Alice to resource X returns into yes (temporal lt) (Alice Request Read X).
@@ -87,20 +88,10 @@ async function main() {
8788
const output = writer.quadsToString(reasoningResult);
8889
console.log("Compliance Report")
8990
console.log(output);
90-
91-
const prefixes = {
92-
'odrl': 'http://www.w3.org/ns/odrl/2/',
93-
'ex': 'http://example.org/',
94-
'temp': 'http://example.com/request/',
95-
'dct': 'http://purl.org/dc/terms/',
96-
'xsd': 'http://www.w3.org/2001/XMLSchema#',
97-
'foaf': 'http://xmlns.com/foaf/0.1/',
98-
'report': 'https://w3id.org/force/compliance-report#'
99-
}
10091

10192
// created report with N3
102-
// @ts-ignore
103-
console.log(resourceToOptimisedTurtle(reasoningResult, prefixes));
93+
console.log(await write(reasoningResult, { prefixes }));
94+
10495

10596
}
10697
main()

demo/test-eyeling.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
import { ODRLEngineMultipleSteps, ODRLEvaluator, resourceToOptimisedTurtle, turtleStringToStore } from "../dist/index";
3-
import { EyelingReasoner } from "../src";
2+
import { ODRLEngineMultipleSteps, ODRLEvaluator, prefixes, EyelingReasoner, turtleStringToStore } from "../dist/index";
3+
import { write } from '@jeswr/pretty-turtle';
44

55

66
const odrlPolicyText = `
@@ -70,19 +70,7 @@ async function main() {
7070
odrlRequestStore.getQuads(null, null, null, null),
7171
stateOfTheWorldStore.getQuads(null, null, null, null))
7272
// printing report nicely
73-
const prefixes = {
74-
'odrl': 'http://www.w3.org/ns/odrl/2/',
75-
'ex': 'http://example.org/',
76-
'temp': 'http://example.com/request/',
77-
'dct': 'http://purl.org/dc/terms/',
78-
'xsd': 'http://www.w3.org/2001/XMLSchema#',
79-
'foaf': 'http://xmlns.com/foaf/0.1/',
80-
'report': 'https://w3id.org/force/compliance-report#'
81-
}
82-
83-
// created report with N3
84-
// @ts-ignore
85-
console.log(resourceToOptimisedTurtle(reasoningResult, prefixes));
73+
console.log(await write(reasoningResult, {prefixes}));
8674

8775
}
8876
main()

demo/test-n3-engine.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { write } from '@jeswr/pretty-turtle';
12
import * as fs from "fs";
2-
import { Store } from "n3";
33
import * as path from "path";
4-
import { EyeJsReasoner, EyeReasoner, ODRLN3Engine, storeToString, turtleStringToStore } from "../dist/index";
4+
import { EyeJsReasoner, EyeReasoner, ODRLN3Engine, prefixes, turtleStringToStore } from "../dist/index";
55

66
const odrlPolicyText = `
77
@prefix odrl: <http://www.w3.org/ns/odrl/2/>.
@@ -78,10 +78,12 @@ async function main() {
7878
const reasoningResultJs = await ODRLEyeJsEngine.evaluate(input);
7979

8080
console.log("Compliance Report evaluated using the EYE JS reasoner");
81-
console.log(storeToString(new Store(reasoningResultJs)));
81+
console.log(await write(reasoningResultJs, {prefixes}));
82+
8283
console.log();
8384
console.log("Compliance Report evaluated using the EYE reasoner (local)");
84-
console.log(storeToString(new Store(reasoningResultLocal)));
85+
console.log(await write(reasoningResultLocal, {prefixes}));
86+
8587

8688
}
8789
main()

demo/test-n3-evaluator.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ODRLEngineMultipleSteps, ODRLEvaluator, resourceToOptimisedTurtle, turtleStringToStore } from "../dist/index";
1+
import { ODRLEngineMultipleSteps, ODRLEvaluator, prefixes, turtleStringToStore } from "../dist/index";
2+
import { write } from '@jeswr/pretty-turtle';
23

34

45
const odrlPolicyText = `
@@ -68,19 +69,8 @@ async function main() {
6869
odrlRequestStore.getQuads(null, null, null, null),
6970
stateOfTheWorldStore.getQuads(null, null, null, null))
7071
// printing report nicely
71-
const prefixes = {
72-
'odrl': 'http://www.w3.org/ns/odrl/2/',
73-
'ex': 'http://example.org/',
74-
'temp': 'http://example.com/request/',
75-
'dct': 'http://purl.org/dc/terms/',
76-
'xsd': 'http://www.w3.org/2001/XMLSchema#',
77-
'foaf': 'http://xmlns.com/foaf/0.1/',
78-
'report': 'https://w3id.org/force/compliance-report#'
79-
}
8072

81-
// created report with N3
82-
// @ts-ignore
83-
console.log(resourceToOptimisedTurtle(reasoningResult, prefixes));
73+
console.log(await write(reasoningResult, {prefixes}));
8474

8575
}
8676
main()

package-lock.json

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

src/rules/Rules.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ export const RULES: string[] = [`@prefix string: <http://www.w3.org/2000/10/swap
4040
}
4141
<=
4242
{
43+
# 0. add some skolem uri to introduce randomness when there are multiple runs with the same ID
44+
( "test" ) log:skolem ?skolem .
45+
(?input (?skolem) ) list:append ?newList .
46+
4347
# 1. Convert input to a stable string
44-
?input :listToString ?inputString .
48+
?newList :listToString ?inputString .
4549
4650
# 2. Generate a stable hash (works identically in 2026 eyeJS and Eyeling)
4751
?inputString crypto:sha ?hash .

src/rules/built-ins.n3

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
}
99
<=
1010
{
11+
# 0. add some skolem uri to introduce randomness when there are multiple runs with the same ID
12+
( "test" ) log:skolem ?skolem .
13+
(?input (?skolem) ) list:append ?newList .
14+
1115
# 1. Convert input to a stable string
12-
?input :listToString ?inputString .
16+
?newList :listToString ?inputString .
1317

1418
# 2. Generate a stable hash (works identically in 2026 eyeJS and Eyeling)
1519
?inputString crypto:sha ?hash .

0 commit comments

Comments
 (0)