@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.3
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 +6872 -5886
- package/lib/index.js +6868 -5874
- 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 +3737 -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 +4361 -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,253 +1,194 @@
|
|
|
1
|
-
import { SHACLFlow } from
|
|
2
|
-
describe(
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
5
|
-
const flow = new SHACLFlow(
|
|
6
|
-
expect(flow.name).toBe(
|
|
7
|
-
expect(flow.namespace).toBe(
|
|
8
|
-
expect(flow.flowUri).toBe(
|
|
1
|
+
import { SHACLFlow } from './SHACLFlow';
|
|
2
|
+
describe('SHACLFlow', () => {
|
|
3
|
+
describe('basic construction', () => {
|
|
4
|
+
it('creates a flow with name and namespace', () => {
|
|
5
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
6
|
+
expect(flow.name).toBe('TODO');
|
|
7
|
+
expect(flow.namespace).toBe('todo://');
|
|
8
|
+
expect(flow.flowUri).toBe('todo://TODOFlow');
|
|
9
9
|
});
|
|
10
|
-
it(
|
|
11
|
-
const flow = new SHACLFlow(
|
|
12
|
-
expect(flow.stateUri(
|
|
13
|
-
expect(flow.stateUri(
|
|
10
|
+
it('generates correct state URIs', () => {
|
|
11
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
12
|
+
expect(flow.stateUri('ready')).toBe('todo://TODO.ready');
|
|
13
|
+
expect(flow.stateUri('done')).toBe('todo://TODO.done');
|
|
14
14
|
});
|
|
15
|
-
it(
|
|
16
|
-
const flow = new SHACLFlow(
|
|
17
|
-
expect(flow.transitionUri(
|
|
15
|
+
it('generates correct transition URIs', () => {
|
|
16
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
17
|
+
expect(flow.transitionUri('ready', 'doing')).toBe('todo://TODO.readyTodoing');
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
describe(
|
|
21
|
-
it(
|
|
22
|
-
const flow = new SHACLFlow(
|
|
20
|
+
describe('state management', () => {
|
|
21
|
+
it('adds and retrieves states', () => {
|
|
22
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
23
23
|
flow.addState({
|
|
24
|
-
name:
|
|
24
|
+
name: 'ready',
|
|
25
25
|
value: 0,
|
|
26
|
-
stateCheck: { predicate:
|
|
26
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
27
27
|
});
|
|
28
28
|
flow.addState({
|
|
29
|
-
name:
|
|
29
|
+
name: 'done',
|
|
30
30
|
value: 1,
|
|
31
|
-
stateCheck: { predicate:
|
|
31
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
32
32
|
});
|
|
33
33
|
expect(flow.states.length).toBe(2);
|
|
34
|
-
expect(flow.states[0].name).toBe(
|
|
35
|
-
expect(flow.states[1].name).toBe(
|
|
34
|
+
expect(flow.states[0].name).toBe('ready');
|
|
35
|
+
expect(flow.states[1].name).toBe('done');
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
-
describe(
|
|
39
|
-
it(
|
|
40
|
-
const flow = new SHACLFlow(
|
|
38
|
+
describe('transition management', () => {
|
|
39
|
+
it('adds and retrieves transitions', () => {
|
|
40
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
41
41
|
flow.addTransition({
|
|
42
|
-
actionName:
|
|
43
|
-
fromState:
|
|
44
|
-
toState:
|
|
42
|
+
actionName: 'Complete',
|
|
43
|
+
fromState: 'ready',
|
|
44
|
+
toState: 'done',
|
|
45
45
|
actions: [
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
predicate: "todo://state",
|
|
50
|
-
target: "todo://done",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
action: "removeLink",
|
|
54
|
-
source: "this",
|
|
55
|
-
predicate: "todo://state",
|
|
56
|
-
target: "todo://ready",
|
|
57
|
-
},
|
|
58
|
-
],
|
|
46
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' },
|
|
47
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
48
|
+
]
|
|
59
49
|
});
|
|
60
50
|
expect(flow.transitions.length).toBe(1);
|
|
61
|
-
expect(flow.transitions[0].actionName).toBe(
|
|
51
|
+
expect(flow.transitions[0].actionName).toBe('Complete');
|
|
62
52
|
expect(flow.transitions[0].actions.length).toBe(2);
|
|
63
53
|
});
|
|
64
54
|
});
|
|
65
|
-
describe(
|
|
66
|
-
it(
|
|
67
|
-
const flow = new SHACLFlow(
|
|
68
|
-
flow.flowable =
|
|
55
|
+
describe('toLinks()', () => {
|
|
56
|
+
it('serializes flow to links', () => {
|
|
57
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
58
|
+
flow.flowable = 'any';
|
|
69
59
|
flow.startAction = [
|
|
70
|
-
{
|
|
71
|
-
action: "addLink",
|
|
72
|
-
source: "this",
|
|
73
|
-
predicate: "todo://state",
|
|
74
|
-
target: "todo://ready",
|
|
75
|
-
},
|
|
60
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
76
61
|
];
|
|
77
62
|
flow.addState({
|
|
78
|
-
name:
|
|
63
|
+
name: 'ready',
|
|
79
64
|
value: 0,
|
|
80
|
-
stateCheck: { predicate:
|
|
65
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
81
66
|
});
|
|
82
67
|
flow.addTransition({
|
|
83
|
-
actionName:
|
|
84
|
-
fromState:
|
|
85
|
-
toState:
|
|
86
|
-
actions: [
|
|
87
|
-
{
|
|
88
|
-
action: "addLink",
|
|
89
|
-
source: "this",
|
|
90
|
-
predicate: "todo://state",
|
|
91
|
-
target: "todo://doing",
|
|
92
|
-
},
|
|
93
|
-
],
|
|
68
|
+
actionName: 'Start',
|
|
69
|
+
fromState: 'ready',
|
|
70
|
+
toState: 'doing',
|
|
71
|
+
actions: [{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' }]
|
|
94
72
|
});
|
|
95
73
|
const links = flow.toLinks();
|
|
96
74
|
// Check flow type link
|
|
97
|
-
const typeLink = links.find(
|
|
75
|
+
const typeLink = links.find(l => l.predicate === 'rdf://type' && l.target === 'ad4m://Flow');
|
|
98
76
|
expect(typeLink).toBeDefined();
|
|
99
|
-
expect(typeLink.source).toBe(
|
|
77
|
+
expect(typeLink.source).toBe('todo://TODOFlow');
|
|
100
78
|
// Check flowable link
|
|
101
|
-
const flowableLink = links.find(
|
|
79
|
+
const flowableLink = links.find(l => l.predicate === 'ad4m://flowable');
|
|
102
80
|
expect(flowableLink).toBeDefined();
|
|
103
|
-
expect(flowableLink.target).toBe(
|
|
81
|
+
expect(flowableLink.target).toBe('ad4m://any');
|
|
104
82
|
// Check start action link
|
|
105
|
-
const startActionLink = links.find(
|
|
83
|
+
const startActionLink = links.find(l => l.predicate === 'ad4m://startAction');
|
|
106
84
|
expect(startActionLink).toBeDefined();
|
|
107
|
-
expect(startActionLink.target).toContain(
|
|
85
|
+
expect(startActionLink.target).toContain('addLink');
|
|
108
86
|
// Check state link
|
|
109
|
-
const stateLink = links.find(
|
|
87
|
+
const stateLink = links.find(l => l.predicate === 'ad4m://hasState');
|
|
110
88
|
expect(stateLink).toBeDefined();
|
|
111
|
-
expect(stateLink.target).toBe(
|
|
89
|
+
expect(stateLink.target).toBe('todo://TODO.ready');
|
|
112
90
|
// Check transition link
|
|
113
|
-
const transitionLink = links.find(
|
|
91
|
+
const transitionLink = links.find(l => l.predicate === 'ad4m://hasTransition');
|
|
114
92
|
expect(transitionLink).toBeDefined();
|
|
115
93
|
});
|
|
116
94
|
});
|
|
117
|
-
describe(
|
|
118
|
-
it(
|
|
119
|
-
const original = new SHACLFlow(
|
|
120
|
-
original.flowable =
|
|
95
|
+
describe('fromLinks()', () => {
|
|
96
|
+
it('reconstructs flow from links', () => {
|
|
97
|
+
const original = new SHACLFlow('TODO', 'todo://');
|
|
98
|
+
original.flowable = 'any';
|
|
121
99
|
original.startAction = [
|
|
122
|
-
{
|
|
123
|
-
action: "addLink",
|
|
124
|
-
source: "this",
|
|
125
|
-
predicate: "todo://state",
|
|
126
|
-
target: "todo://ready",
|
|
127
|
-
},
|
|
100
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
128
101
|
];
|
|
129
102
|
original.addState({
|
|
130
|
-
name:
|
|
103
|
+
name: 'ready',
|
|
131
104
|
value: 0,
|
|
132
|
-
stateCheck: { predicate:
|
|
105
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
133
106
|
});
|
|
134
107
|
original.addState({
|
|
135
|
-
name:
|
|
108
|
+
name: 'done',
|
|
136
109
|
value: 1,
|
|
137
|
-
stateCheck: { predicate:
|
|
110
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
138
111
|
});
|
|
139
112
|
original.addTransition({
|
|
140
|
-
actionName:
|
|
141
|
-
fromState:
|
|
142
|
-
toState:
|
|
143
|
-
actions: [
|
|
144
|
-
{
|
|
145
|
-
action: "addLink",
|
|
146
|
-
source: "this",
|
|
147
|
-
predicate: "todo://state",
|
|
148
|
-
target: "todo://done",
|
|
149
|
-
},
|
|
150
|
-
],
|
|
113
|
+
actionName: 'Complete',
|
|
114
|
+
fromState: 'ready',
|
|
115
|
+
toState: 'done',
|
|
116
|
+
actions: [{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' }]
|
|
151
117
|
});
|
|
152
118
|
const links = original.toLinks();
|
|
153
|
-
const reconstructed = SHACLFlow.fromLinks(links,
|
|
154
|
-
expect(reconstructed.name).toBe(
|
|
155
|
-
expect(reconstructed.namespace).toBe(
|
|
156
|
-
expect(reconstructed.flowable).toBe(
|
|
119
|
+
const reconstructed = SHACLFlow.fromLinks(links, 'todo://TODOFlow');
|
|
120
|
+
expect(reconstructed.name).toBe('TODO');
|
|
121
|
+
expect(reconstructed.namespace).toBe('todo://');
|
|
122
|
+
expect(reconstructed.flowable).toBe('any');
|
|
157
123
|
expect(reconstructed.startAction.length).toBe(1);
|
|
158
124
|
expect(reconstructed.states.length).toBe(2);
|
|
159
125
|
expect(reconstructed.transitions.length).toBe(1);
|
|
160
|
-
expect(reconstructed.transitions[0].actionName).toBe(
|
|
126
|
+
expect(reconstructed.transitions[0].actionName).toBe('Complete');
|
|
161
127
|
});
|
|
162
128
|
});
|
|
163
|
-
describe(
|
|
164
|
-
it(
|
|
165
|
-
const original = new SHACLFlow(
|
|
129
|
+
describe('JSON serialization', () => {
|
|
130
|
+
it('converts to and from JSON', () => {
|
|
131
|
+
const original = new SHACLFlow('TODO', 'todo://');
|
|
166
132
|
original.addState({
|
|
167
|
-
name:
|
|
133
|
+
name: 'ready',
|
|
168
134
|
value: 0,
|
|
169
|
-
stateCheck: { predicate:
|
|
135
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
170
136
|
});
|
|
171
137
|
original.addTransition({
|
|
172
|
-
actionName:
|
|
173
|
-
fromState:
|
|
174
|
-
toState:
|
|
175
|
-
actions: []
|
|
138
|
+
actionName: 'Start',
|
|
139
|
+
fromState: 'ready',
|
|
140
|
+
toState: 'doing',
|
|
141
|
+
actions: []
|
|
176
142
|
});
|
|
177
143
|
const json = original.toJSON();
|
|
178
144
|
const reconstructed = SHACLFlow.fromJSON(json);
|
|
179
|
-
expect(reconstructed.name).toBe(
|
|
145
|
+
expect(reconstructed.name).toBe('TODO');
|
|
180
146
|
expect(reconstructed.states.length).toBe(1);
|
|
181
147
|
expect(reconstructed.transitions.length).toBe(1);
|
|
182
148
|
});
|
|
183
149
|
});
|
|
184
|
-
describe(
|
|
185
|
-
it(
|
|
186
|
-
const flow = new SHACLFlow(
|
|
187
|
-
flow.flowable =
|
|
150
|
+
describe('full TODO example', () => {
|
|
151
|
+
it('creates complete TODO flow matching Prolog example', () => {
|
|
152
|
+
const flow = new SHACLFlow('TODO', 'todo://');
|
|
153
|
+
flow.flowable = 'any';
|
|
188
154
|
// Start action - renders expression as TODO in 'ready' state
|
|
189
155
|
flow.startAction = [
|
|
190
|
-
{
|
|
191
|
-
action: "addLink",
|
|
192
|
-
source: "this",
|
|
193
|
-
predicate: "todo://state",
|
|
194
|
-
target: "todo://ready",
|
|
195
|
-
},
|
|
156
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
196
157
|
];
|
|
197
158
|
// Three states
|
|
198
159
|
flow.addState({
|
|
199
|
-
name:
|
|
160
|
+
name: 'ready',
|
|
200
161
|
value: 0,
|
|
201
|
-
stateCheck: { predicate:
|
|
162
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://ready' }
|
|
202
163
|
});
|
|
203
164
|
flow.addState({
|
|
204
|
-
name:
|
|
165
|
+
name: 'doing',
|
|
205
166
|
value: 0.5,
|
|
206
|
-
stateCheck: { predicate:
|
|
167
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://doing' }
|
|
207
168
|
});
|
|
208
169
|
flow.addState({
|
|
209
|
-
name:
|
|
170
|
+
name: 'done',
|
|
210
171
|
value: 1,
|
|
211
|
-
stateCheck: { predicate:
|
|
172
|
+
stateCheck: { predicate: 'todo://state', target: 'todo://done' }
|
|
212
173
|
});
|
|
213
174
|
// Transitions
|
|
214
175
|
flow.addTransition({
|
|
215
|
-
actionName:
|
|
216
|
-
fromState:
|
|
217
|
-
toState:
|
|
176
|
+
actionName: 'Start',
|
|
177
|
+
fromState: 'ready',
|
|
178
|
+
toState: 'doing',
|
|
218
179
|
actions: [
|
|
219
|
-
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
predicate: "todo://state",
|
|
223
|
-
target: "todo://doing",
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
action: "removeLink",
|
|
227
|
-
source: "this",
|
|
228
|
-
predicate: "todo://state",
|
|
229
|
-
target: "todo://ready",
|
|
230
|
-
},
|
|
231
|
-
],
|
|
180
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' },
|
|
181
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://ready' }
|
|
182
|
+
]
|
|
232
183
|
});
|
|
233
184
|
flow.addTransition({
|
|
234
|
-
actionName:
|
|
235
|
-
fromState:
|
|
236
|
-
toState:
|
|
185
|
+
actionName: 'Finish',
|
|
186
|
+
fromState: 'doing',
|
|
187
|
+
toState: 'done',
|
|
237
188
|
actions: [
|
|
238
|
-
{
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
predicate: "todo://state",
|
|
242
|
-
target: "todo://done",
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
action: "removeLink",
|
|
246
|
-
source: "this",
|
|
247
|
-
predicate: "todo://state",
|
|
248
|
-
target: "todo://doing",
|
|
249
|
-
},
|
|
250
|
-
],
|
|
189
|
+
{ action: 'addLink', source: 'this', predicate: 'todo://state', target: 'todo://done' },
|
|
190
|
+
{ action: 'removeLink', source: 'this', predicate: 'todo://state', target: 'todo://doing' }
|
|
191
|
+
]
|
|
251
192
|
});
|
|
252
193
|
// Verify structure
|
|
253
194
|
expect(flow.states.length).toBe(3);
|
|
@@ -21,7 +21,7 @@ export interface SHACLPropertyShape {
|
|
|
21
21
|
/** Expected datatype (e.g., xsd:string, xsd:integer) */
|
|
22
22
|
datatype?: string;
|
|
23
23
|
/** Node kind constraint (IRI, Literal, BlankNode) */
|
|
24
|
-
nodeKind?:
|
|
24
|
+
nodeKind?: 'IRI' | 'Literal' | 'BlankNode';
|
|
25
25
|
/** Minimum cardinality (required if >= 1) */
|
|
26
26
|
minCount?: number;
|
|
27
27
|
/** Maximum cardinality (single-valued if 1, omit for collections) */
|
|
@@ -36,8 +36,8 @@ export interface SHACLPropertyShape {
|
|
|
36
36
|
hasValue?: string;
|
|
37
37
|
/** AD4M-specific: Local-only property */
|
|
38
38
|
local?: boolean;
|
|
39
|
-
/** AD4M-specific:
|
|
40
|
-
|
|
39
|
+
/** AD4M-specific: Writable property */
|
|
40
|
+
writable?: boolean;
|
|
41
41
|
/** AD4M-specific: Language to resolve property values through */
|
|
42
42
|
resolveLanguage?: string;
|
|
43
43
|
/** AD4M-specific: Setter action for this property */
|
|
@@ -46,8 +46,6 @@ export interface SHACLPropertyShape {
|
|
|
46
46
|
adder?: AD4MAction[];
|
|
47
47
|
/** AD4M-specific: Remover action for collection properties */
|
|
48
48
|
remover?: AD4MAction[];
|
|
49
|
-
/** AD4M-specific: Reverse path traversal — sh:inversePath instead of sh:path */
|
|
50
|
-
inversePath?: boolean;
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* SHACL Node Shape
|
|
@@ -60,16 +58,12 @@ export declare class SHACLShape {
|
|
|
60
58
|
targetClass?: string;
|
|
61
59
|
/** Property constraints */
|
|
62
60
|
properties: SHACLPropertyShape[];
|
|
63
|
-
/**
|
|
64
|
-
* Parent shape URIs for SHACL inheritance (sh:node references).
|
|
65
|
-
* When a model class extends another @Model-decorated class, the child shape
|
|
66
|
-
* references the parent shape via sh:node rather than duplicating its properties.
|
|
67
|
-
*/
|
|
68
|
-
parentShapes?: string[];
|
|
69
61
|
/** AD4M-specific: Constructor actions for creating instances */
|
|
70
62
|
constructor_actions?: AD4MAction[];
|
|
71
63
|
/** AD4M-specific: Destructor actions for removing instances */
|
|
72
64
|
destructor_actions?: AD4MAction[];
|
|
65
|
+
/** Parent shape URIs for model inheritance (sh:node references) */
|
|
66
|
+
parentShapes: string[];
|
|
73
67
|
/**
|
|
74
68
|
* Create a new SHACL Shape
|
|
75
69
|
* @param targetClassOrShapeUri - If one argument: the target class (shape URI auto-derived as {class}Shape)
|
|
@@ -78,15 +72,16 @@ export declare class SHACLShape {
|
|
|
78
72
|
*/
|
|
79
73
|
constructor(targetClassOrShapeUri: string, targetClass?: string);
|
|
80
74
|
/**
|
|
81
|
-
* Add a
|
|
75
|
+
* Add a parent shape reference (sh:node) for model inheritance.
|
|
76
|
+
* When a @Model class extends another @Model, the child shape
|
|
77
|
+
* references the parent shape so SHACL validators can walk the
|
|
78
|
+
* class hierarchy.
|
|
82
79
|
*/
|
|
83
|
-
|
|
80
|
+
addParentShape(parentShapeUri: string): void;
|
|
84
81
|
/**
|
|
85
|
-
* Add a
|
|
86
|
-
* The child shape will reference the parent shape instead of duplicating its properties.
|
|
87
|
-
* @param parentShapeUri - URI of the parent SHACL shape
|
|
82
|
+
* Add a property constraint to this shape
|
|
88
83
|
*/
|
|
89
|
-
|
|
84
|
+
addProperty(prop: SHACLPropertyShape): void;
|
|
90
85
|
/**
|
|
91
86
|
* Set constructor actions for this shape
|
|
92
87
|
*/
|