@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.4
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 +10 -3
- package/lib/index.cjs +6893 -5884
- package/lib/index.js +6889 -5872
- package/lib/src/Ad4mClient.d.ts +9 -16
- package/lib/src/Ad4mClient.js +46 -25
- package/lib/src/Literal.d.ts +1 -2
- package/lib/src/Literal.js +38 -35
- package/lib/src/SmartLiteral.d.ts +1 -2
- package/lib/src/SmartLiteral.js +30 -15
- package/lib/src/agent/AgentClient.d.ts +1 -4
- package/lib/src/agent/AgentClient.js +79 -99
- package/lib/src/ai/AIClient.d.ts +1 -2
- package/lib/src/ai/AIClient.js +224 -220
- package/lib/src/expression/ExpressionClient.d.ts +1 -1
- package/lib/src/expression/ExpressionClient.js +73 -86
- 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 +1351 -144
- package/lib/src/model/Ad4mModel.js +3760 -228
- package/lib/src/model/Ad4mModel.test.js +522 -979
- package/lib/src/model/Subject.d.ts +3 -3
- package/lib/src/model/Subject.js +25 -25
- package/lib/src/model/decorators.d.ts +444 -100
- package/lib/src/model/decorators.js +686 -321
- package/lib/src/model/util.d.ts +6 -6
- package/lib/src/model/util.js +24 -24
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
- package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
- package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveClient.js +240 -316
- package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
- package/lib/src/perspectives/PerspectiveProxy.js +485 -832
- package/lib/src/runtime/RuntimeClient.d.ts +1 -5
- package/lib/src/runtime/RuntimeClient.js +238 -412
- package/lib/src/shacl/SHACLFlow.test.js +105 -164
- package/lib/src/shacl/SHACLShape.d.ts +12 -17
- package/lib/src/shacl/SHACLShape.js +115 -128
- package/lib/src/shacl/SHACLShape.test.js +176 -244
- package/lib/src/shims/reflect-metadata.d.ts +0 -0
- package/lib/src/shims/type-graphql.d.ts +32 -0
- package/lib/src/src/Ad4mClient.d.ts +28 -0
- package/lib/src/src/Address.d.ts +1 -0
- package/lib/src/src/DID.d.ts +1 -0
- package/lib/src/src/Exception.d.ts +7 -0
- package/lib/src/src/Literal.d.ts +7 -0
- package/lib/src/src/PubSub.d.ts +17 -0
- package/lib/src/src/SmartLiteral.d.ts +12 -0
- package/lib/src/src/agent/Agent.d.ts +110 -0
- package/lib/src/src/agent/AgentClient.d.ts +62 -0
- package/lib/src/src/agent/AgentResolver.d.ts +30 -0
- package/lib/src/src/agent/AgentStatus.d.ts +8 -0
- package/lib/src/src/ai/AIClient.d.ts +32 -0
- package/lib/src/src/ai/AIResolver.d.ts +75 -0
- package/lib/src/src/ai/Tasks.d.ts +37 -0
- package/lib/src/src/buildSchema.d.ts +1 -0
- package/lib/src/src/expression/Expression.d.ts +28 -0
- package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
- package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
- package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
- package/lib/src/src/index.d.ts +35 -0
- package/lib/src/src/jestSetup.d.ts +1 -0
- package/lib/src/src/language/Icon.d.ts +4 -0
- package/lib/src/src/language/Language.d.ts +206 -0
- package/lib/src/src/language/LanguageClient.d.ts +17 -0
- package/lib/src/src/language/LanguageContext.d.ts +37 -0
- package/lib/src/src/language/LanguageHandle.d.ts +9 -0
- package/lib/src/src/language/LanguageMeta.d.ts +35 -0
- package/lib/src/src/language/LanguageRef.d.ts +6 -0
- package/lib/src/src/language/LanguageResolver.d.ts +19 -0
- package/lib/src/src/links/Links.d.ts +39 -0
- package/lib/src/src/links/Links.test.d.ts +1 -0
- package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
- package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
- package/lib/src/src/model/Subject.d.ts +25 -0
- package/lib/src/src/model/decorators.d.ts +545 -0
- package/lib/src/src/model/util.d.ts +12 -0
- package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
- package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
- package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
- package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
- package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
- package/lib/src/src/perspectives/Perspective.d.ts +38 -0
- package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
- package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
- package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
- package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
- package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
- package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
- package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
- package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
- package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
- package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
- package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
- package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
- package/lib/src/src/typeDefs.d.ts +1 -0
- package/lib/src/src/unwrapApolloResult.d.ts +2 -0
- package/lib/src/src/utils.d.ts +25 -0
- package/lib/src/utils.d.ts +0 -8
- package/lib/src/utils.js +7 -21
- package/package.json +15 -14
- package/src/Ad4mClient.test.ts +1315 -1564
- package/src/Ad4mClient.ts +54 -55
- package/src/Literal.test.ts +26 -45
- package/src/Literal.ts +66 -82
- package/src/SmartLiteral.ts +58 -74
- package/src/agent/AgentClient.ts +99 -144
- package/src/ai/AIClient.ts +359 -409
- package/src/expression/ExpressionClient.ts +96 -142
- package/src/index.ts +1 -1
- package/src/language/LanguageClient.ts +113 -137
- package/src/model/Ad4mModel.test.ts +616 -1114
- package/src/model/Ad4mModel.ts +4386 -451
- package/src/model/Subject.ts +159 -0
- package/src/model/decorators.ts +1168 -667
- package/src/model/util.ts +54 -53
- package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
- package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
- package/src/perspectives/PerspectiveClient.ts +540 -779
- package/src/perspectives/PerspectiveProxy.ts +2067 -2860
- package/src/runtime/RuntimeClient.ts +476 -775
- package/src/shacl/SHACLFlow.test.ts +129 -196
- package/src/shacl/SHACLShape.test.ts +190 -284
- package/src/shacl/SHACLShape.ts +200 -224
- package/src/utils.ts +17 -31
- package/tsconfig.json +10 -9
- package/src/model/IMPROVEMENTS.md +0 -482
- package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
- package/src/model/README.md +0 -317
- package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
- package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
- package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
- package/src/model/mutation.ts +0 -461
- package/src/model/parentUtils.ts +0 -91
- package/src/model/prolog/generatePrologFacts.ts +0 -176
- package/src/model/prolog/index.ts +0 -1
- package/src/model/query/ModelQueryBuilder.ts +0 -173
- package/src/model/query/fetchInstance.ts +0 -181
- package/src/model/query/hydration.ts +0 -273
- package/src/model/query/operations.ts +0 -510
- package/src/model/query/snapshot.ts +0 -126
- package/src/model/query/surrealCompiler.ts +0 -376
- package/src/model/schema/fromJSONSchema.ts +0 -411
- package/src/model/schema/metadata.ts +0 -148
- package/src/model/subscription.ts +0 -307
- package/src/model/transaction.ts +0 -60
- package/src/model/types.ts +0 -207
|
@@ -1,300 +1,233 @@
|
|
|
1
|
-
import { SHACLFlow } from
|
|
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, FlowState, FlowTransition, AD4MAction } 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(
|
|
21
|
-
"todo://TODO.readyTodoing",
|
|
22
|
-
);
|
|
18
|
+
it('generates correct transition URIs', () => {
|
|
19
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
20
|
+
expect(flow.transitionUri('ready', 'doing')).toBe('todo://TODO.readyTodoing');
|
|
23
21
|
});
|
|
24
22
|
});
|
|
25
23
|
|
|
26
|
-
describe(
|
|
27
|
-
it(
|
|
28
|
-
const flow = new SHACLFlow(
|
|
29
|
-
|
|
24
|
+
describe('state management', () => {
|
|
25
|
+
it('adds and retrieves states', () => {
|
|
26
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
27
|
+
|
|
30
28
|
flow.addState({
|
|
31
|
-
name:
|
|
29
|
+
name: 'ready',
|
|
32
30
|
value: 0,
|
|
33
|
-
stateCheck: { predicate:
|
|
31
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
34
32
|
});
|
|
35
|
-
|
|
33
|
+
|
|
36
34
|
flow.addState({
|
|
37
|
-
name:
|
|
35
|
+
name: 'done',
|
|
38
36
|
value: 1,
|
|
39
|
-
stateCheck: { predicate:
|
|
37
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
40
38
|
});
|
|
41
|
-
|
|
39
|
+
|
|
42
40
|
expect(flow.states.length).toBe(2);
|
|
43
|
-
expect(flow.states[0].name).toBe(
|
|
44
|
-
expect(flow.states[1].name).toBe(
|
|
41
|
+
expect(flow.states[0].name).toBe('ready');
|
|
42
|
+
expect(flow.states[1].name).toBe('done');
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
45
|
|
|
48
|
-
describe(
|
|
49
|
-
it(
|
|
50
|
-
const flow = new SHACLFlow(
|
|
51
|
-
|
|
46
|
+
describe('transition management', () => {
|
|
47
|
+
it('adds and retrieves transitions', () => {
|
|
48
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
49
|
+
|
|
52
50
|
flow.addTransition({
|
|
53
|
-
actionName:
|
|
54
|
-
fromState:
|
|
55
|
-
toState:
|
|
51
|
+
actionName: 'Complete',
|
|
52
|
+
fromState: 'ready',
|
|
53
|
+
toState: 'done',
|
|
56
54
|
actions: [
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
],
|
|
55
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' },
|
|
56
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
57
|
+
]
|
|
70
58
|
});
|
|
71
|
-
|
|
59
|
+
|
|
72
60
|
expect(flow.transitions.length).toBe(1);
|
|
73
|
-
expect(flow.transitions[0].actionName).toBe(
|
|
61
|
+
expect(flow.transitions[0].actionName).toBe('Complete');
|
|
74
62
|
expect(flow.transitions[0].actions.length).toBe(2);
|
|
75
63
|
});
|
|
76
64
|
});
|
|
77
65
|
|
|
78
|
-
describe(
|
|
79
|
-
it(
|
|
80
|
-
const flow = new SHACLFlow(
|
|
81
|
-
flow.flowable =
|
|
66
|
+
describe('toLinks()', () => {
|
|
67
|
+
it('serializes flow to links', () => {
|
|
68
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
69
|
+
flow.flowable = 'any';
|
|
82
70
|
flow.startAction = [
|
|
83
|
-
{
|
|
84
|
-
action: "addLink",
|
|
85
|
-
source: "this",
|
|
86
|
-
predicate: "todo://state",
|
|
87
|
-
target: "todo://ready",
|
|
88
|
-
},
|
|
71
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
89
72
|
];
|
|
90
|
-
|
|
73
|
+
|
|
91
74
|
flow.addState({
|
|
92
|
-
name:
|
|
75
|
+
name: 'ready',
|
|
93
76
|
value: 0,
|
|
94
|
-
stateCheck: { predicate:
|
|
77
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
95
78
|
});
|
|
96
|
-
|
|
79
|
+
|
|
97
80
|
flow.addTransition({
|
|
98
|
-
actionName:
|
|
99
|
-
fromState:
|
|
100
|
-
toState:
|
|
101
|
-
actions: [
|
|
102
|
-
{
|
|
103
|
-
action: "addLink",
|
|
104
|
-
source: "this",
|
|
105
|
-
predicate: "todo://state",
|
|
106
|
-
target: "todo://doing",
|
|
107
|
-
},
|
|
108
|
-
],
|
|
81
|
+
actionName: 'Start',
|
|
82
|
+
fromState: 'ready',
|
|
83
|
+
toState: 'doing',
|
|
84
|
+
actions: [{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' }]
|
|
109
85
|
});
|
|
110
|
-
|
|
86
|
+
|
|
111
87
|
const links = flow.toLinks();
|
|
112
|
-
|
|
88
|
+
|
|
113
89
|
// Check flow type link
|
|
114
|
-
const typeLink = links.find(
|
|
115
|
-
(l) => l.predicate === "rdf://type" && l.target === "ad4m://Flow",
|
|
116
|
-
);
|
|
90
|
+
const typeLink = links.find(l => l.predicate === 'rdf://type' && l.target === 'ad4m://Flow');
|
|
117
91
|
expect(typeLink).toBeDefined();
|
|
118
|
-
expect(typeLink!.source).toBe(
|
|
119
|
-
|
|
92
|
+
expect(typeLink!.source).toBe('todo://TODOFlow');
|
|
93
|
+
|
|
120
94
|
// Check flowable link
|
|
121
|
-
const flowableLink = links.find(
|
|
95
|
+
const flowableLink = links.find(l => l.predicate === 'ad4m://flowable');
|
|
122
96
|
expect(flowableLink).toBeDefined();
|
|
123
|
-
expect(flowableLink!.target).toBe(
|
|
124
|
-
|
|
97
|
+
expect(flowableLink!.target).toBe('ad4m://any');
|
|
98
|
+
|
|
125
99
|
// Check start action link
|
|
126
|
-
const startActionLink = links.find(
|
|
127
|
-
(l) => l.predicate === "ad4m://startAction",
|
|
128
|
-
);
|
|
100
|
+
const startActionLink = links.find(l => l.predicate === 'ad4m://startAction');
|
|
129
101
|
expect(startActionLink).toBeDefined();
|
|
130
|
-
expect(startActionLink!.target).toContain(
|
|
131
|
-
|
|
102
|
+
expect(startActionLink!.target).toContain('addLink');
|
|
103
|
+
|
|
132
104
|
// Check state link
|
|
133
|
-
const stateLink = links.find(
|
|
105
|
+
const stateLink = links.find(l => l.predicate === 'ad4m://hasState');
|
|
134
106
|
expect(stateLink).toBeDefined();
|
|
135
|
-
expect(stateLink!.target).toBe(
|
|
136
|
-
|
|
107
|
+
expect(stateLink!.target).toBe('todo://TODO.ready');
|
|
108
|
+
|
|
137
109
|
// Check transition link
|
|
138
|
-
const transitionLink = links.find(
|
|
139
|
-
(l) => l.predicate === "ad4m://hasTransition",
|
|
140
|
-
);
|
|
110
|
+
const transitionLink = links.find(l => l.predicate === 'ad4m://hasTransition');
|
|
141
111
|
expect(transitionLink).toBeDefined();
|
|
142
112
|
});
|
|
143
113
|
});
|
|
144
114
|
|
|
145
|
-
describe(
|
|
146
|
-
it(
|
|
147
|
-
const original = new SHACLFlow(
|
|
148
|
-
original.flowable =
|
|
115
|
+
describe('fromLinks()', () => {
|
|
116
|
+
it('reconstructs flow from links', () => {
|
|
117
|
+
const original = new SHACLFlow('TODO', 'todo://');
|
|
118
|
+
original.flowable = 'any';
|
|
149
119
|
original.startAction = [
|
|
150
|
-
{
|
|
151
|
-
action: "addLink",
|
|
152
|
-
source: "this",
|
|
153
|
-
predicate: "todo://state",
|
|
154
|
-
target: "todo://ready",
|
|
155
|
-
},
|
|
120
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
156
121
|
];
|
|
157
122
|
original.addState({
|
|
158
|
-
name:
|
|
123
|
+
name: 'ready',
|
|
159
124
|
value: 0,
|
|
160
|
-
stateCheck: { predicate:
|
|
125
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
161
126
|
});
|
|
162
127
|
original.addState({
|
|
163
|
-
name:
|
|
128
|
+
name: 'done',
|
|
164
129
|
value: 1,
|
|
165
|
-
stateCheck: { predicate:
|
|
130
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
166
131
|
});
|
|
167
132
|
original.addTransition({
|
|
168
|
-
actionName:
|
|
169
|
-
fromState:
|
|
170
|
-
toState:
|
|
171
|
-
actions: [
|
|
172
|
-
{
|
|
173
|
-
action: "addLink",
|
|
174
|
-
source: "this",
|
|
175
|
-
predicate: "todo://state",
|
|
176
|
-
target: "todo://done",
|
|
177
|
-
},
|
|
178
|
-
],
|
|
133
|
+
actionName: 'Complete',
|
|
134
|
+
fromState: 'ready',
|
|
135
|
+
toState: 'done',
|
|
136
|
+
actions: [{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' }]
|
|
179
137
|
});
|
|
180
|
-
|
|
138
|
+
|
|
181
139
|
const links = original.toLinks();
|
|
182
|
-
const reconstructed = SHACLFlow.fromLinks(links,
|
|
183
|
-
|
|
184
|
-
expect(reconstructed.name).toBe(
|
|
185
|
-
expect(reconstructed.namespace).toBe(
|
|
186
|
-
expect(reconstructed.flowable).toBe(
|
|
140
|
+
const reconstructed = SHACLFlow.fromLinks(links, 'todo://TODOFlow');
|
|
141
|
+
|
|
142
|
+
expect(reconstructed.name).toBe('TODO');
|
|
143
|
+
expect(reconstructed.namespace).toBe('todo://');
|
|
144
|
+
expect(reconstructed.flowable).toBe('any');
|
|
187
145
|
expect(reconstructed.startAction.length).toBe(1);
|
|
188
146
|
expect(reconstructed.states.length).toBe(2);
|
|
189
147
|
expect(reconstructed.transitions.length).toBe(1);
|
|
190
|
-
expect(reconstructed.transitions[0].actionName).toBe(
|
|
148
|
+
expect(reconstructed.transitions[0].actionName).toBe('Complete');
|
|
191
149
|
});
|
|
192
150
|
});
|
|
193
151
|
|
|
194
|
-
describe(
|
|
195
|
-
it(
|
|
196
|
-
const original = new SHACLFlow(
|
|
152
|
+
describe('JSON serialization', () => {
|
|
153
|
+
it('converts to and from JSON', () => {
|
|
154
|
+
const original = new SHACLFlow('TODO', 'todo://');
|
|
197
155
|
original.addState({
|
|
198
|
-
name:
|
|
156
|
+
name: 'ready',
|
|
199
157
|
value: 0,
|
|
200
|
-
stateCheck: { predicate:
|
|
158
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
201
159
|
});
|
|
202
160
|
original.addTransition({
|
|
203
|
-
actionName:
|
|
204
|
-
fromState:
|
|
205
|
-
toState:
|
|
206
|
-
actions: []
|
|
161
|
+
actionName: 'Start',
|
|
162
|
+
fromState: 'ready',
|
|
163
|
+
toState: 'doing',
|
|
164
|
+
actions: []
|
|
207
165
|
});
|
|
208
|
-
|
|
166
|
+
|
|
209
167
|
const json = original.toJSON();
|
|
210
168
|
const reconstructed = SHACLFlow.fromJSON(json);
|
|
211
|
-
|
|
212
|
-
expect(reconstructed.name).toBe(
|
|
169
|
+
|
|
170
|
+
expect(reconstructed.name).toBe('TODO');
|
|
213
171
|
expect(reconstructed.states.length).toBe(1);
|
|
214
172
|
expect(reconstructed.transitions.length).toBe(1);
|
|
215
173
|
});
|
|
216
174
|
});
|
|
217
175
|
|
|
218
|
-
describe(
|
|
219
|
-
it(
|
|
220
|
-
const flow = new SHACLFlow(
|
|
221
|
-
flow.flowable =
|
|
222
|
-
|
|
176
|
+
describe('full TODO example', () => {
|
|
177
|
+
it('creates complete TODO flow matching Prolog example', () => {
|
|
178
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
179
|
+
flow.flowable = 'any';
|
|
180
|
+
|
|
223
181
|
// Start action - renders expression as TODO in 'ready' state
|
|
224
182
|
flow.startAction = [
|
|
225
|
-
{
|
|
226
|
-
action: "addLink",
|
|
227
|
-
source: "this",
|
|
228
|
-
predicate: "todo://state",
|
|
229
|
-
target: "todo://ready",
|
|
230
|
-
},
|
|
183
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
231
184
|
];
|
|
232
|
-
|
|
185
|
+
|
|
233
186
|
// Three states
|
|
234
187
|
flow.addState({
|
|
235
|
-
name:
|
|
188
|
+
name: 'ready',
|
|
236
189
|
value: 0,
|
|
237
|
-
stateCheck: { predicate:
|
|
190
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
238
191
|
});
|
|
239
192
|
flow.addState({
|
|
240
|
-
name:
|
|
193
|
+
name: 'doing',
|
|
241
194
|
value: 0.5,
|
|
242
|
-
stateCheck: { predicate:
|
|
195
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://doing' }
|
|
243
196
|
});
|
|
244
197
|
flow.addState({
|
|
245
|
-
name:
|
|
198
|
+
name: 'done',
|
|
246
199
|
value: 1,
|
|
247
|
-
stateCheck: { predicate:
|
|
200
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
248
201
|
});
|
|
249
|
-
|
|
202
|
+
|
|
250
203
|
// Transitions
|
|
251
204
|
flow.addTransition({
|
|
252
|
-
actionName:
|
|
253
|
-
fromState:
|
|
254
|
-
toState:
|
|
205
|
+
actionName: 'Start',
|
|
206
|
+
fromState: 'ready',
|
|
207
|
+
toState: 'doing',
|
|
255
208
|
actions: [
|
|
256
|
-
{
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
],
|
|
209
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' },
|
|
210
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
211
|
+
]
|
|
269
212
|
});
|
|
270
213
|
flow.addTransition({
|
|
271
|
-
actionName:
|
|
272
|
-
fromState:
|
|
273
|
-
toState:
|
|
214
|
+
actionName: 'Finish',
|
|
215
|
+
fromState: 'doing',
|
|
216
|
+
toState: 'done',
|
|
274
217
|
actions: [
|
|
275
|
-
{
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
],
|
|
218
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' },
|
|
219
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' }
|
|
220
|
+
]
|
|
288
221
|
});
|
|
289
|
-
|
|
222
|
+
|
|
290
223
|
// Verify structure
|
|
291
224
|
expect(flow.states.length).toBe(3);
|
|
292
225
|
expect(flow.transitions.length).toBe(2);
|
|
293
|
-
|
|
226
|
+
|
|
294
227
|
// Verify links generation
|
|
295
228
|
const links = flow.toLinks();
|
|
296
229
|
expect(links.length).toBeGreaterThan(15); // Flow + 3 states + 2 transitions = many links
|
|
297
|
-
|
|
230
|
+
|
|
298
231
|
// Verify round-trip
|
|
299
232
|
const reconstructed = SHACLFlow.fromLinks(links, flow.flowUri);
|
|
300
233
|
expect(reconstructed.states.length).toBe(3);
|