@coasys/ad4m 0.12.0-rc1-dev.1 → 0.12.0-rc1-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +4 -4
- package/lib/index.cjs +5999 -6046
- package/lib/index.js +5977 -6040
- package/lib/src/Ad4mClient.d.ts +16 -9
- package/lib/src/Ad4mClient.js +25 -46
- package/lib/src/Ad4mClient.test.d.ts +1 -0
- package/lib/src/Ad4mClient.test.js +1204 -0
- package/lib/src/Literal.d.ts +2 -1
- package/lib/src/Literal.js +35 -38
- package/lib/src/Literal.test.d.ts +1 -0
- package/lib/src/Literal.test.js +41 -0
- package/lib/src/SmartLiteral.d.ts +2 -1
- package/lib/src/SmartLiteral.js +15 -30
- package/lib/src/agent/AgentClient.d.ts +4 -1
- package/lib/src/agent/AgentClient.js +99 -79
- package/lib/src/ai/AIClient.d.ts +2 -1
- package/lib/src/ai/AIClient.js +220 -224
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +86 -73
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/language/LanguageClient.d.ts +1 -1
- package/lib/src/language/LanguageClient.js +52 -52
- package/lib/src/model/Ad4mModel.d.ts +157 -937
- package/lib/src/model/Ad4mModel.js +212 -2799
- package/lib/src/model/Ad4mModel.test.js +1002 -561
- package/lib/src/model/decorators.d.ts +94 -426
- package/lib/src/model/decorators.js +333 -741
- package/lib/src/model/mutation.d.ts +81 -0
- package/lib/src/model/mutation.js +317 -0
- package/lib/src/model/parentUtils.d.ts +32 -0
- package/lib/src/model/parentUtils.js +64 -0
- package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
- package/lib/src/model/prolog/generatePrologFacts.js +139 -0
- package/lib/src/model/prolog/index.d.ts +1 -0
- package/lib/src/model/prolog/index.js +1 -0
- package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
- package/lib/src/model/query/ModelQueryBuilder.js +115 -0
- package/lib/src/model/query/QueryBuilder.d.ts +101 -0
- package/lib/src/model/query/QueryBuilder.js +193 -0
- package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
- package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
- package/lib/src/model/query/fetchInstance.d.ts +24 -0
- package/lib/src/model/query/fetchInstance.js +144 -0
- package/lib/src/model/query/hydration.d.ts +54 -0
- package/lib/src/model/query/hydration.js +214 -0
- package/lib/src/model/query/operations.d.ts +59 -0
- package/lib/src/model/query/operations.js +384 -0
- package/lib/src/model/query/snapshot.d.ts +59 -0
- package/lib/src/model/query/snapshot.js +106 -0
- package/lib/src/model/query/surrealCompiler.d.ts +42 -0
- package/lib/src/model/query/surrealCompiler.js +304 -0
- package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
- package/lib/src/model/schema/fromJSONSchema.js +264 -0
- package/lib/src/model/schema/metadata.d.ts +15 -0
- package/lib/src/model/schema/metadata.js +112 -0
- package/lib/src/model/subscription.d.ts +47 -0
- package/lib/src/model/subscription.js +231 -0
- package/lib/src/model/transaction.d.ts +27 -0
- package/lib/src/model/transaction.js +32 -0
- package/lib/src/model/types.d.ts +195 -0
- package/lib/src/model/types.js +8 -0
- package/lib/src/model/util.js +7 -7
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +316 -240
- package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
- package/lib/src/perspectives/PerspectiveProxy.js +803 -444
- package/lib/src/runtime/RuntimeClient.d.ts +5 -1
- package/lib/src/runtime/RuntimeClient.js +412 -238
- package/lib/src/shacl/SHACLFlow.test.js +164 -105
- package/lib/src/shacl/SHACLShape.d.ts +17 -3
- package/lib/src/shacl/SHACLShape.js +127 -90
- package/lib/src/shacl/SHACLShape.test.js +244 -176
- package/lib/src/utils.d.ts +8 -0
- package/lib/src/utils.js +21 -7
- package/package.json +8 -13
- package/src/Ad4mClient.test.ts +1564 -1315
- package/src/Ad4mClient.ts +55 -54
- package/src/Literal.test.ts +45 -26
- package/src/Literal.ts +82 -66
- package/src/SmartLiteral.ts +74 -58
- package/src/agent/AgentClient.ts +144 -99
- package/src/ai/AIClient.ts +409 -359
- package/src/expression/ExpressionClient.ts +142 -96
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +137 -113
- package/src/model/Ad4mModel.test.ts +1128 -647
- package/src/model/Ad4mModel.ts +485 -3249
- package/src/model/IMPROVEMENTS.md +482 -0
- package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
- package/src/model/README.md +317 -0
- package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
- package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
- package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
- package/src/model/decorators.ts +689 -1046
- package/src/model/mutation.ts +461 -0
- package/src/model/parentUtils.ts +91 -0
- package/src/model/prolog/generatePrologFacts.ts +176 -0
- package/src/model/prolog/index.ts +1 -0
- package/src/model/query/ModelQueryBuilder.ts +173 -0
- package/src/model/query/fetchInstance.ts +181 -0
- package/src/model/query/hydration.ts +273 -0
- package/src/model/query/operations.ts +510 -0
- package/src/model/query/snapshot.ts +126 -0
- package/src/model/query/surrealCompiler.ts +376 -0
- package/src/model/schema/fromJSONSchema.ts +411 -0
- package/src/model/schema/metadata.ts +148 -0
- package/src/model/subscription.ts +307 -0
- package/src/model/transaction.ts +60 -0
- package/src/model/types.ts +207 -0
- package/src/model/util.ts +47 -48
- package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
- package/src/perspectives/PerspectiveClient.ts +779 -540
- package/src/perspectives/PerspectiveProxy.ts +2860 -2053
- package/src/runtime/RuntimeClient.ts +775 -476
- package/src/shacl/SHACLFlow.test.ts +196 -129
- package/src/shacl/SHACLShape.test.ts +284 -190
- package/src/shacl/SHACLShape.ts +225 -172
- package/src/utils.ts +31 -17
- package/tsconfig.json +9 -10
- package/src/model/Subject.ts +0 -159
|
@@ -1,233 +1,300 @@
|
|
|
1
|
-
import { SHACLFlow
|
|
2
|
-
|
|
3
|
-
describe(
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
6
|
-
const flow = new SHACLFlow(
|
|
7
|
-
expect(flow.name).toBe(
|
|
8
|
-
expect(flow.namespace).toBe(
|
|
9
|
-
expect(flow.flowUri).toBe(
|
|
1
|
+
import { SHACLFlow } from "./SHACLFlow";
|
|
2
|
+
|
|
3
|
+
describe("SHACLFlow", () => {
|
|
4
|
+
describe("basic construction", () => {
|
|
5
|
+
it("creates a flow with name and namespace", () => {
|
|
6
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
7
|
+
expect(flow.name).toBe("TODO");
|
|
8
|
+
expect(flow.namespace).toBe("todo://");
|
|
9
|
+
expect(flow.flowUri).toBe("todo://TODOFlow");
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
it(
|
|
13
|
-
const flow = new SHACLFlow(
|
|
14
|
-
expect(flow.stateUri(
|
|
15
|
-
expect(flow.stateUri(
|
|
12
|
+
it("generates correct state URIs", () => {
|
|
13
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
14
|
+
expect(flow.stateUri("ready")).toBe("todo://TODO.ready");
|
|
15
|
+
expect(flow.stateUri("done")).toBe("todo://TODO.done");
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it(
|
|
19
|
-
const flow = new SHACLFlow(
|
|
20
|
-
expect(flow.transitionUri(
|
|
18
|
+
it("generates correct transition URIs", () => {
|
|
19
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
20
|
+
expect(flow.transitionUri("ready", "doing")).toBe(
|
|
21
|
+
"todo://TODO.readyTodoing",
|
|
22
|
+
);
|
|
21
23
|
});
|
|
22
24
|
});
|
|
23
25
|
|
|
24
|
-
describe(
|
|
25
|
-
it(
|
|
26
|
-
const flow = new SHACLFlow(
|
|
27
|
-
|
|
26
|
+
describe("state management", () => {
|
|
27
|
+
it("adds and retrieves states", () => {
|
|
28
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
29
|
+
|
|
28
30
|
flow.addState({
|
|
29
|
-
name:
|
|
31
|
+
name: "ready",
|
|
30
32
|
value: 0,
|
|
31
|
-
stateCheck: { predicate:
|
|
33
|
+
stateCheck: { predicate: "todo://state", target: "todo://ready" },
|
|
32
34
|
});
|
|
33
|
-
|
|
35
|
+
|
|
34
36
|
flow.addState({
|
|
35
|
-
name:
|
|
37
|
+
name: "done",
|
|
36
38
|
value: 1,
|
|
37
|
-
stateCheck: { predicate:
|
|
39
|
+
stateCheck: { predicate: "todo://state", target: "todo://done" },
|
|
38
40
|
});
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
expect(flow.states.length).toBe(2);
|
|
41
|
-
expect(flow.states[0].name).toBe(
|
|
42
|
-
expect(flow.states[1].name).toBe(
|
|
43
|
+
expect(flow.states[0].name).toBe("ready");
|
|
44
|
+
expect(flow.states[1].name).toBe("done");
|
|
43
45
|
});
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
describe(
|
|
47
|
-
it(
|
|
48
|
-
const flow = new SHACLFlow(
|
|
49
|
-
|
|
48
|
+
describe("transition management", () => {
|
|
49
|
+
it("adds and retrieves transitions", () => {
|
|
50
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
51
|
+
|
|
50
52
|
flow.addTransition({
|
|
51
|
-
actionName:
|
|
52
|
-
fromState:
|
|
53
|
-
toState:
|
|
53
|
+
actionName: "Complete",
|
|
54
|
+
fromState: "ready",
|
|
55
|
+
toState: "done",
|
|
54
56
|
actions: [
|
|
55
|
-
{
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
{
|
|
58
|
+
action: "addLink",
|
|
59
|
+
source: "this",
|
|
60
|
+
predicate: "todo://state",
|
|
61
|
+
target: "todo://done",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
action: "removeLink",
|
|
65
|
+
source: "this",
|
|
66
|
+
predicate: "todo://state",
|
|
67
|
+
target: "todo://ready",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
58
70
|
});
|
|
59
|
-
|
|
71
|
+
|
|
60
72
|
expect(flow.transitions.length).toBe(1);
|
|
61
|
-
expect(flow.transitions[0].actionName).toBe(
|
|
73
|
+
expect(flow.transitions[0].actionName).toBe("Complete");
|
|
62
74
|
expect(flow.transitions[0].actions.length).toBe(2);
|
|
63
75
|
});
|
|
64
76
|
});
|
|
65
77
|
|
|
66
|
-
describe(
|
|
67
|
-
it(
|
|
68
|
-
const flow = new SHACLFlow(
|
|
69
|
-
flow.flowable =
|
|
78
|
+
describe("toLinks()", () => {
|
|
79
|
+
it("serializes flow to links", () => {
|
|
80
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
81
|
+
flow.flowable = "any";
|
|
70
82
|
flow.startAction = [
|
|
71
|
-
{
|
|
83
|
+
{
|
|
84
|
+
action: "addLink",
|
|
85
|
+
source: "this",
|
|
86
|
+
predicate: "todo://state",
|
|
87
|
+
target: "todo://ready",
|
|
88
|
+
},
|
|
72
89
|
];
|
|
73
|
-
|
|
90
|
+
|
|
74
91
|
flow.addState({
|
|
75
|
-
name:
|
|
92
|
+
name: "ready",
|
|
76
93
|
value: 0,
|
|
77
|
-
stateCheck: { predicate:
|
|
94
|
+
stateCheck: { predicate: "todo://state", target: "todo://ready" },
|
|
78
95
|
});
|
|
79
|
-
|
|
96
|
+
|
|
80
97
|
flow.addTransition({
|
|
81
|
-
actionName:
|
|
82
|
-
fromState:
|
|
83
|
-
toState:
|
|
84
|
-
actions: [
|
|
98
|
+
actionName: "Start",
|
|
99
|
+
fromState: "ready",
|
|
100
|
+
toState: "doing",
|
|
101
|
+
actions: [
|
|
102
|
+
{
|
|
103
|
+
action: "addLink",
|
|
104
|
+
source: "this",
|
|
105
|
+
predicate: "todo://state",
|
|
106
|
+
target: "todo://doing",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
85
109
|
});
|
|
86
|
-
|
|
110
|
+
|
|
87
111
|
const links = flow.toLinks();
|
|
88
|
-
|
|
112
|
+
|
|
89
113
|
// Check flow type link
|
|
90
|
-
const typeLink = links.find(
|
|
114
|
+
const typeLink = links.find(
|
|
115
|
+
(l) => l.predicate === "rdf://type" && l.target === "ad4m://Flow",
|
|
116
|
+
);
|
|
91
117
|
expect(typeLink).toBeDefined();
|
|
92
|
-
expect(typeLink!.source).toBe(
|
|
93
|
-
|
|
118
|
+
expect(typeLink!.source).toBe("todo://TODOFlow");
|
|
119
|
+
|
|
94
120
|
// Check flowable link
|
|
95
|
-
const flowableLink = links.find(l => l.predicate ===
|
|
121
|
+
const flowableLink = links.find((l) => l.predicate === "ad4m://flowable");
|
|
96
122
|
expect(flowableLink).toBeDefined();
|
|
97
|
-
expect(flowableLink!.target).toBe(
|
|
98
|
-
|
|
123
|
+
expect(flowableLink!.target).toBe("ad4m://any");
|
|
124
|
+
|
|
99
125
|
// Check start action link
|
|
100
|
-
const startActionLink = links.find(
|
|
126
|
+
const startActionLink = links.find(
|
|
127
|
+
(l) => l.predicate === "ad4m://startAction",
|
|
128
|
+
);
|
|
101
129
|
expect(startActionLink).toBeDefined();
|
|
102
|
-
expect(startActionLink!.target).toContain(
|
|
103
|
-
|
|
130
|
+
expect(startActionLink!.target).toContain("addLink");
|
|
131
|
+
|
|
104
132
|
// Check state link
|
|
105
|
-
const stateLink = links.find(l => l.predicate ===
|
|
133
|
+
const stateLink = links.find((l) => l.predicate === "ad4m://hasState");
|
|
106
134
|
expect(stateLink).toBeDefined();
|
|
107
|
-
expect(stateLink!.target).toBe(
|
|
108
|
-
|
|
135
|
+
expect(stateLink!.target).toBe("todo://TODO.ready");
|
|
136
|
+
|
|
109
137
|
// Check transition link
|
|
110
|
-
const transitionLink = links.find(
|
|
138
|
+
const transitionLink = links.find(
|
|
139
|
+
(l) => l.predicate === "ad4m://hasTransition",
|
|
140
|
+
);
|
|
111
141
|
expect(transitionLink).toBeDefined();
|
|
112
142
|
});
|
|
113
143
|
});
|
|
114
144
|
|
|
115
|
-
describe(
|
|
116
|
-
it(
|
|
117
|
-
const original = new SHACLFlow(
|
|
118
|
-
original.flowable =
|
|
145
|
+
describe("fromLinks()", () => {
|
|
146
|
+
it("reconstructs flow from links", () => {
|
|
147
|
+
const original = new SHACLFlow("TODO", "todo://");
|
|
148
|
+
original.flowable = "any";
|
|
119
149
|
original.startAction = [
|
|
120
|
-
{
|
|
150
|
+
{
|
|
151
|
+
action: "addLink",
|
|
152
|
+
source: "this",
|
|
153
|
+
predicate: "todo://state",
|
|
154
|
+
target: "todo://ready",
|
|
155
|
+
},
|
|
121
156
|
];
|
|
122
157
|
original.addState({
|
|
123
|
-
name:
|
|
158
|
+
name: "ready",
|
|
124
159
|
value: 0,
|
|
125
|
-
stateCheck: { predicate:
|
|
160
|
+
stateCheck: { predicate: "todo://state", target: "todo://ready" },
|
|
126
161
|
});
|
|
127
162
|
original.addState({
|
|
128
|
-
name:
|
|
163
|
+
name: "done",
|
|
129
164
|
value: 1,
|
|
130
|
-
stateCheck: { predicate:
|
|
165
|
+
stateCheck: { predicate: "todo://state", target: "todo://done" },
|
|
131
166
|
});
|
|
132
167
|
original.addTransition({
|
|
133
|
-
actionName:
|
|
134
|
-
fromState:
|
|
135
|
-
toState:
|
|
136
|
-
actions: [
|
|
168
|
+
actionName: "Complete",
|
|
169
|
+
fromState: "ready",
|
|
170
|
+
toState: "done",
|
|
171
|
+
actions: [
|
|
172
|
+
{
|
|
173
|
+
action: "addLink",
|
|
174
|
+
source: "this",
|
|
175
|
+
predicate: "todo://state",
|
|
176
|
+
target: "todo://done",
|
|
177
|
+
},
|
|
178
|
+
],
|
|
137
179
|
});
|
|
138
|
-
|
|
180
|
+
|
|
139
181
|
const links = original.toLinks();
|
|
140
|
-
const reconstructed = SHACLFlow.fromLinks(links,
|
|
141
|
-
|
|
142
|
-
expect(reconstructed.name).toBe(
|
|
143
|
-
expect(reconstructed.namespace).toBe(
|
|
144
|
-
expect(reconstructed.flowable).toBe(
|
|
182
|
+
const reconstructed = SHACLFlow.fromLinks(links, "todo://TODOFlow");
|
|
183
|
+
|
|
184
|
+
expect(reconstructed.name).toBe("TODO");
|
|
185
|
+
expect(reconstructed.namespace).toBe("todo://");
|
|
186
|
+
expect(reconstructed.flowable).toBe("any");
|
|
145
187
|
expect(reconstructed.startAction.length).toBe(1);
|
|
146
188
|
expect(reconstructed.states.length).toBe(2);
|
|
147
189
|
expect(reconstructed.transitions.length).toBe(1);
|
|
148
|
-
expect(reconstructed.transitions[0].actionName).toBe(
|
|
190
|
+
expect(reconstructed.transitions[0].actionName).toBe("Complete");
|
|
149
191
|
});
|
|
150
192
|
});
|
|
151
193
|
|
|
152
|
-
describe(
|
|
153
|
-
it(
|
|
154
|
-
const original = new SHACLFlow(
|
|
194
|
+
describe("JSON serialization", () => {
|
|
195
|
+
it("converts to and from JSON", () => {
|
|
196
|
+
const original = new SHACLFlow("TODO", "todo://");
|
|
155
197
|
original.addState({
|
|
156
|
-
name:
|
|
198
|
+
name: "ready",
|
|
157
199
|
value: 0,
|
|
158
|
-
stateCheck: { predicate:
|
|
200
|
+
stateCheck: { predicate: "todo://state", target: "todo://ready" },
|
|
159
201
|
});
|
|
160
202
|
original.addTransition({
|
|
161
|
-
actionName:
|
|
162
|
-
fromState:
|
|
163
|
-
toState:
|
|
164
|
-
actions: []
|
|
203
|
+
actionName: "Start",
|
|
204
|
+
fromState: "ready",
|
|
205
|
+
toState: "doing",
|
|
206
|
+
actions: [],
|
|
165
207
|
});
|
|
166
|
-
|
|
208
|
+
|
|
167
209
|
const json = original.toJSON();
|
|
168
210
|
const reconstructed = SHACLFlow.fromJSON(json);
|
|
169
|
-
|
|
170
|
-
expect(reconstructed.name).toBe(
|
|
211
|
+
|
|
212
|
+
expect(reconstructed.name).toBe("TODO");
|
|
171
213
|
expect(reconstructed.states.length).toBe(1);
|
|
172
214
|
expect(reconstructed.transitions.length).toBe(1);
|
|
173
215
|
});
|
|
174
216
|
});
|
|
175
217
|
|
|
176
|
-
describe(
|
|
177
|
-
it(
|
|
178
|
-
const flow = new SHACLFlow(
|
|
179
|
-
flow.flowable =
|
|
180
|
-
|
|
218
|
+
describe("full TODO example", () => {
|
|
219
|
+
it("creates complete TODO flow matching Prolog example", () => {
|
|
220
|
+
const flow = new SHACLFlow("TODO", "todo://");
|
|
221
|
+
flow.flowable = "any";
|
|
222
|
+
|
|
181
223
|
// Start action - renders expression as TODO in 'ready' state
|
|
182
224
|
flow.startAction = [
|
|
183
|
-
{
|
|
225
|
+
{
|
|
226
|
+
action: "addLink",
|
|
227
|
+
source: "this",
|
|
228
|
+
predicate: "todo://state",
|
|
229
|
+
target: "todo://ready",
|
|
230
|
+
},
|
|
184
231
|
];
|
|
185
|
-
|
|
232
|
+
|
|
186
233
|
// Three states
|
|
187
234
|
flow.addState({
|
|
188
|
-
name:
|
|
235
|
+
name: "ready",
|
|
189
236
|
value: 0,
|
|
190
|
-
stateCheck: { predicate:
|
|
237
|
+
stateCheck: { predicate: "todo://state", target: "todo://ready" },
|
|
191
238
|
});
|
|
192
239
|
flow.addState({
|
|
193
|
-
name:
|
|
240
|
+
name: "doing",
|
|
194
241
|
value: 0.5,
|
|
195
|
-
stateCheck: { predicate:
|
|
242
|
+
stateCheck: { predicate: "todo://state", target: "todo://doing" },
|
|
196
243
|
});
|
|
197
244
|
flow.addState({
|
|
198
|
-
name:
|
|
245
|
+
name: "done",
|
|
199
246
|
value: 1,
|
|
200
|
-
stateCheck: { predicate:
|
|
247
|
+
stateCheck: { predicate: "todo://state", target: "todo://done" },
|
|
201
248
|
});
|
|
202
|
-
|
|
249
|
+
|
|
203
250
|
// Transitions
|
|
204
251
|
flow.addTransition({
|
|
205
|
-
actionName:
|
|
206
|
-
fromState:
|
|
207
|
-
toState:
|
|
252
|
+
actionName: "Start",
|
|
253
|
+
fromState: "ready",
|
|
254
|
+
toState: "doing",
|
|
208
255
|
actions: [
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
256
|
+
{
|
|
257
|
+
action: "addLink",
|
|
258
|
+
source: "this",
|
|
259
|
+
predicate: "todo://state",
|
|
260
|
+
target: "todo://doing",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
action: "removeLink",
|
|
264
|
+
source: "this",
|
|
265
|
+
predicate: "todo://state",
|
|
266
|
+
target: "todo://ready",
|
|
267
|
+
},
|
|
268
|
+
],
|
|
212
269
|
});
|
|
213
270
|
flow.addTransition({
|
|
214
|
-
actionName:
|
|
215
|
-
fromState:
|
|
216
|
-
toState:
|
|
271
|
+
actionName: "Finish",
|
|
272
|
+
fromState: "doing",
|
|
273
|
+
toState: "done",
|
|
217
274
|
actions: [
|
|
218
|
-
{
|
|
219
|
-
|
|
220
|
-
|
|
275
|
+
{
|
|
276
|
+
action: "addLink",
|
|
277
|
+
source: "this",
|
|
278
|
+
predicate: "todo://state",
|
|
279
|
+
target: "todo://done",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
action: "removeLink",
|
|
283
|
+
source: "this",
|
|
284
|
+
predicate: "todo://state",
|
|
285
|
+
target: "todo://doing",
|
|
286
|
+
},
|
|
287
|
+
],
|
|
221
288
|
});
|
|
222
|
-
|
|
289
|
+
|
|
223
290
|
// Verify structure
|
|
224
291
|
expect(flow.states.length).toBe(3);
|
|
225
292
|
expect(flow.transitions.length).toBe(2);
|
|
226
|
-
|
|
293
|
+
|
|
227
294
|
// Verify links generation
|
|
228
295
|
const links = flow.toLinks();
|
|
229
296
|
expect(links.length).toBeGreaterThan(15); // Flow + 3 states + 2 transitions = many links
|
|
230
|
-
|
|
297
|
+
|
|
231
298
|
// Verify round-trip
|
|
232
299
|
const reconstructed = SHACLFlow.fromLinks(links, flow.flowUri);
|
|
233
300
|
expect(reconstructed.states.length).toBe(3);
|