@coasys/ad4m 0.12.0-dev-whisper-lang → 0.12.0-rc1-dev.1
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/lib/index.cjs +1746 -322
- package/lib/index.js +1745 -323
- package/lib/src/ai/AIClient.d.ts +1 -1
- package/lib/src/ai/AIClient.js +4 -5
- package/lib/src/ai/AIResolver.d.ts +1 -1
- package/lib/src/ai/AIResolver.js +2 -3
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.js +2 -0
- package/lib/src/model/Ad4mModel.js +21 -7
- package/lib/src/model/decorators.js +196 -6
- package/lib/src/model/util.d.ts +1 -1
- package/lib/src/model/util.js +15 -12
- package/lib/src/perspectives/PerspectiveClient.d.ts +11 -1
- package/lib/src/perspectives/PerspectiveClient.js +15 -4
- package/lib/src/perspectives/PerspectiveProxy.d.ts +124 -8
- package/lib/src/perspectives/PerspectiveProxy.js +573 -274
- package/lib/src/perspectives/PerspectiveResolver.d.ts +1 -1
- package/lib/src/perspectives/PerspectiveResolver.js +5 -4
- package/lib/src/schema.gql +2 -2
- package/lib/src/shacl/SHACLFlow.d.ts +171 -0
- package/lib/src/shacl/SHACLFlow.js +370 -0
- package/lib/src/shacl/SHACLFlow.test.d.ts +1 -0
- package/lib/src/shacl/SHACLFlow.test.js +205 -0
- package/lib/src/shacl/SHACLShape.d.ts +108 -0
- package/lib/src/shacl/SHACLShape.js +566 -0
- package/lib/src/shacl/SHACLShape.test.d.ts +1 -0
- package/lib/src/shacl/SHACLShape.test.js +336 -0
- package/lib/src/typeDefs.js +2 -2
- package/package.json +1 -2
- package/src/ai/AIClient.ts +4 -6
- package/src/ai/AIResolver.ts +1 -2
- package/src/index.ts +2 -0
- package/src/model/Ad4mModel.ts +23 -7
- package/src/model/decorators.ts +221 -5
- package/src/model/util.ts +15 -12
- package/src/perspectives/PerspectiveClient.ts +15 -4
- package/src/perspectives/PerspectiveProxy.ts +588 -304
- package/src/perspectives/PerspectiveResolver.ts +1 -1
- package/src/shacl/SHACLFlow.test.ts +237 -0
- package/src/shacl/SHACLFlow.ts +503 -0
- package/src/shacl/SHACLShape.test.ts +400 -0
- package/src/shacl/SHACLShape.ts +755 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { SHACLShape } from './SHACLShape';
|
|
2
|
+
describe('SHACLShape', () => {
|
|
3
|
+
describe('toLinks()', () => {
|
|
4
|
+
it('creates basic shape links', () => {
|
|
5
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
6
|
+
const links = shape.toLinks();
|
|
7
|
+
// Should have targetClass link
|
|
8
|
+
const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
|
|
9
|
+
expect(targetClassLink).toBeDefined();
|
|
10
|
+
expect(targetClassLink.source).toBe('recipe://RecipeShape');
|
|
11
|
+
expect(targetClassLink.target).toBe('recipe://Recipe');
|
|
12
|
+
});
|
|
13
|
+
it('creates property shape links with named URIs', () => {
|
|
14
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
15
|
+
const prop = {
|
|
16
|
+
name: 'name',
|
|
17
|
+
path: 'recipe://name',
|
|
18
|
+
datatype: 'xsd:string',
|
|
19
|
+
minCount: 1,
|
|
20
|
+
maxCount: 1,
|
|
21
|
+
};
|
|
22
|
+
shape.addProperty(prop);
|
|
23
|
+
const links = shape.toLinks();
|
|
24
|
+
// Property shape should use named URI
|
|
25
|
+
const propLink = links.find(l => l.predicate === 'sh://property');
|
|
26
|
+
expect(propLink).toBeDefined();
|
|
27
|
+
expect(propLink.target).toBe('recipe://Recipe.name'); // Named URI, not blank node
|
|
28
|
+
// Path link
|
|
29
|
+
const pathLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://path');
|
|
30
|
+
expect(pathLink).toBeDefined();
|
|
31
|
+
expect(pathLink.target).toBe('recipe://name');
|
|
32
|
+
// Datatype link
|
|
33
|
+
const datatypeLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://datatype');
|
|
34
|
+
expect(datatypeLink).toBeDefined();
|
|
35
|
+
expect(datatypeLink.target).toBe('xsd:string');
|
|
36
|
+
// Cardinality links
|
|
37
|
+
const minCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://minCount');
|
|
38
|
+
expect(minCountLink).toBeDefined();
|
|
39
|
+
expect(minCountLink.target).toContain('1');
|
|
40
|
+
const maxCountLink = links.find(l => l.source === 'recipe://Recipe.name' && l.predicate === 'sh://maxCount');
|
|
41
|
+
expect(maxCountLink).toBeDefined();
|
|
42
|
+
expect(maxCountLink.target).toContain('1');
|
|
43
|
+
});
|
|
44
|
+
it('creates action links', () => {
|
|
45
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
46
|
+
const setterAction = {
|
|
47
|
+
action: 'addLink',
|
|
48
|
+
source: 'this',
|
|
49
|
+
predicate: 'recipe://name',
|
|
50
|
+
target: 'value',
|
|
51
|
+
};
|
|
52
|
+
const prop = {
|
|
53
|
+
name: 'title',
|
|
54
|
+
path: 'recipe://title',
|
|
55
|
+
setter: [setterAction],
|
|
56
|
+
};
|
|
57
|
+
shape.addProperty(prop);
|
|
58
|
+
const links = shape.toLinks();
|
|
59
|
+
// Setter action link
|
|
60
|
+
const setterLink = links.find(l => l.source === 'recipe://Recipe.title' && l.predicate === 'ad4m://setter');
|
|
61
|
+
expect(setterLink).toBeDefined();
|
|
62
|
+
expect(setterLink.target).toContain('addLink');
|
|
63
|
+
});
|
|
64
|
+
it('includes constructor and destructor actions', () => {
|
|
65
|
+
const shape = new SHACLShape('recipe://Recipe');
|
|
66
|
+
shape.constructor_actions = [{
|
|
67
|
+
action: 'addLink',
|
|
68
|
+
source: 'this',
|
|
69
|
+
predicate: 'ad4m://type',
|
|
70
|
+
target: 'recipe://Recipe',
|
|
71
|
+
}];
|
|
72
|
+
shape.destructor_actions = [{
|
|
73
|
+
action: 'removeLink',
|
|
74
|
+
source: 'this',
|
|
75
|
+
predicate: 'ad4m://type',
|
|
76
|
+
target: 'recipe://Recipe',
|
|
77
|
+
}];
|
|
78
|
+
const links = shape.toLinks();
|
|
79
|
+
const constructorLink = links.find(l => l.predicate === 'ad4m://constructor');
|
|
80
|
+
expect(constructorLink).toBeDefined();
|
|
81
|
+
expect(constructorLink.target).toContain('addLink');
|
|
82
|
+
const destructorLink = links.find(l => l.predicate === 'ad4m://destructor');
|
|
83
|
+
expect(destructorLink).toBeDefined();
|
|
84
|
+
expect(destructorLink.target).toContain('removeLink');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('fromLinks()', () => {
|
|
88
|
+
it('reconstructs shape from links', () => {
|
|
89
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
90
|
+
originalShape.addProperty({
|
|
91
|
+
name: 'name',
|
|
92
|
+
path: 'recipe://name',
|
|
93
|
+
datatype: 'xsd:string',
|
|
94
|
+
minCount: 1,
|
|
95
|
+
});
|
|
96
|
+
const links = originalShape.toLinks();
|
|
97
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
98
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
99
|
+
expect(reconstructed.properties.length).toBe(1);
|
|
100
|
+
expect(reconstructed.properties[0].path).toBe('recipe://name');
|
|
101
|
+
expect(reconstructed.properties[0].datatype).toBe('xsd:string');
|
|
102
|
+
expect(reconstructed.properties[0].minCount).toBe(1);
|
|
103
|
+
});
|
|
104
|
+
it('handles multiple properties', () => {
|
|
105
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
106
|
+
originalShape.addProperty({
|
|
107
|
+
name: 'name',
|
|
108
|
+
path: 'recipe://name',
|
|
109
|
+
datatype: 'xsd:string',
|
|
110
|
+
});
|
|
111
|
+
originalShape.addProperty({
|
|
112
|
+
name: 'servings',
|
|
113
|
+
path: 'recipe://servings',
|
|
114
|
+
datatype: 'xsd:integer',
|
|
115
|
+
});
|
|
116
|
+
const links = originalShape.toLinks();
|
|
117
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
118
|
+
expect(reconstructed.properties.length).toBe(2);
|
|
119
|
+
const nameProp = reconstructed.properties.find(p => p.path === 'recipe://name');
|
|
120
|
+
const servingsProp = reconstructed.properties.find(p => p.path === 'recipe://servings');
|
|
121
|
+
expect(nameProp).toBeDefined();
|
|
122
|
+
expect(servingsProp).toBeDefined();
|
|
123
|
+
expect(nameProp.datatype).toBe('xsd:string');
|
|
124
|
+
expect(servingsProp.datatype).toBe('xsd:integer');
|
|
125
|
+
});
|
|
126
|
+
it('reconstructs action arrays', () => {
|
|
127
|
+
const originalShape = new SHACLShape('recipe://Recipe');
|
|
128
|
+
const setterAction = {
|
|
129
|
+
action: 'addLink',
|
|
130
|
+
source: 'this',
|
|
131
|
+
predicate: 'recipe://name',
|
|
132
|
+
target: 'value',
|
|
133
|
+
};
|
|
134
|
+
originalShape.addProperty({
|
|
135
|
+
name: 'name',
|
|
136
|
+
path: 'recipe://name',
|
|
137
|
+
setter: [setterAction],
|
|
138
|
+
});
|
|
139
|
+
const links = originalShape.toLinks();
|
|
140
|
+
const reconstructed = SHACLShape.fromLinks(links, 'recipe://RecipeShape');
|
|
141
|
+
expect(reconstructed.properties[0].setter).toBeDefined();
|
|
142
|
+
expect(reconstructed.properties[0].setter.length).toBe(1);
|
|
143
|
+
expect(reconstructed.properties[0].setter[0].action).toBe('addLink');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('round-trip serialization', () => {
|
|
147
|
+
it('preserves all property attributes', () => {
|
|
148
|
+
const original = new SHACLShape('test://Model');
|
|
149
|
+
original.addProperty({
|
|
150
|
+
name: 'field',
|
|
151
|
+
path: 'test://field',
|
|
152
|
+
datatype: 'xsd:string',
|
|
153
|
+
nodeKind: 'Literal',
|
|
154
|
+
minCount: 0,
|
|
155
|
+
maxCount: 5,
|
|
156
|
+
pattern: '^[a-z]+$',
|
|
157
|
+
minInclusive: 10,
|
|
158
|
+
maxInclusive: 100,
|
|
159
|
+
hasValue: 'expectedValue',
|
|
160
|
+
resolveLanguage: 'test://language',
|
|
161
|
+
local: true,
|
|
162
|
+
writable: true,
|
|
163
|
+
setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
|
|
164
|
+
adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
165
|
+
remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
166
|
+
});
|
|
167
|
+
const links = original.toLinks();
|
|
168
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
169
|
+
const prop = reconstructed.properties[0];
|
|
170
|
+
expect(prop.path).toBe('test://field');
|
|
171
|
+
expect(prop.datatype).toBe('xsd:string');
|
|
172
|
+
expect(prop.nodeKind).toBe('Literal');
|
|
173
|
+
expect(prop.minCount).toBe(0);
|
|
174
|
+
expect(prop.maxCount).toBe(5);
|
|
175
|
+
expect(prop.pattern).toBe('^[a-z]+$');
|
|
176
|
+
expect(prop.minInclusive).toBe(10);
|
|
177
|
+
expect(prop.maxInclusive).toBe(100);
|
|
178
|
+
expect(prop.hasValue).toBe('expectedValue');
|
|
179
|
+
expect(prop.resolveLanguage).toBe('test://language');
|
|
180
|
+
expect(prop.local).toBe(true);
|
|
181
|
+
expect(prop.writable).toBe(true);
|
|
182
|
+
expect(prop.setter).toBeDefined();
|
|
183
|
+
expect(prop.adder).toBeDefined();
|
|
184
|
+
expect(prop.remover).toBeDefined();
|
|
185
|
+
});
|
|
186
|
+
it('preserves constructor and destructor actions', () => {
|
|
187
|
+
const original = new SHACLShape('test://Model');
|
|
188
|
+
original.constructor_actions = [
|
|
189
|
+
{ action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
190
|
+
];
|
|
191
|
+
original.destructor_actions = [
|
|
192
|
+
{ action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
193
|
+
];
|
|
194
|
+
const links = original.toLinks();
|
|
195
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://ModelShape');
|
|
196
|
+
expect(reconstructed.constructor_actions).toBeDefined();
|
|
197
|
+
expect(reconstructed.constructor_actions.length).toBe(1);
|
|
198
|
+
expect(reconstructed.constructor_actions[0].action).toBe('addLink');
|
|
199
|
+
expect(reconstructed.destructor_actions).toBeDefined();
|
|
200
|
+
expect(reconstructed.destructor_actions.length).toBe(1);
|
|
201
|
+
expect(reconstructed.destructor_actions[0].action).toBe('removeLink');
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
describe('edge cases', () => {
|
|
205
|
+
it('handles empty shape', () => {
|
|
206
|
+
const shape = new SHACLShape('test://Empty');
|
|
207
|
+
const links = shape.toLinks();
|
|
208
|
+
expect(links.length).toBeGreaterThanOrEqual(1); // At least targetClass link
|
|
209
|
+
const reconstructed = SHACLShape.fromLinks(links, 'test://EmptyShape');
|
|
210
|
+
expect(reconstructed.targetClass).toBe('test://Empty');
|
|
211
|
+
expect(reconstructed.properties.length).toBe(0);
|
|
212
|
+
});
|
|
213
|
+
it('handles URI with hash fragment', () => {
|
|
214
|
+
const shape = new SHACLShape('https://example.com/vocab#Recipe');
|
|
215
|
+
const links = shape.toLinks();
|
|
216
|
+
const targetClassLink = links.find(l => l.predicate === 'sh://targetClass');
|
|
217
|
+
expect(targetClassLink.source).toBe('https://example.com/vocab#RecipeShape');
|
|
218
|
+
});
|
|
219
|
+
it('falls back to blank nodes when property has no name', () => {
|
|
220
|
+
const shape = new SHACLShape('test://Model');
|
|
221
|
+
shape.addProperty({
|
|
222
|
+
path: 'test://unnamed',
|
|
223
|
+
// No name property
|
|
224
|
+
});
|
|
225
|
+
const links = shape.toLinks();
|
|
226
|
+
const propLink = links.find(l => l.predicate === 'sh://property');
|
|
227
|
+
expect(propLink).toBeDefined();
|
|
228
|
+
// Should use blank node format when no name provided
|
|
229
|
+
expect(propLink.target).toMatch(/_:propShape\d+|test:\/\/Model\./);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
describe('toJSON/fromJSON', () => {
|
|
233
|
+
it('serializes and deserializes basic shape', () => {
|
|
234
|
+
const original = new SHACLShape('recipe://Recipe');
|
|
235
|
+
original.addProperty({
|
|
236
|
+
name: 'name',
|
|
237
|
+
path: 'recipe://name',
|
|
238
|
+
datatype: 'xsd:string',
|
|
239
|
+
minCount: 1,
|
|
240
|
+
});
|
|
241
|
+
const json = original.toJSON();
|
|
242
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
243
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
244
|
+
expect(reconstructed.properties.length).toBe(1);
|
|
245
|
+
expect(reconstructed.properties[0].name).toBe('name');
|
|
246
|
+
expect(reconstructed.properties[0].path).toBe('recipe://name');
|
|
247
|
+
expect(reconstructed.properties[0].datatype).toBe('xsd:string');
|
|
248
|
+
expect(reconstructed.properties[0].minCount).toBe(1);
|
|
249
|
+
});
|
|
250
|
+
it('preserves nodeShapeUri in round-trip', () => {
|
|
251
|
+
const original = new SHACLShape('custom://CustomShape', 'recipe://Recipe');
|
|
252
|
+
const json = original.toJSON();
|
|
253
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
254
|
+
expect(reconstructed.nodeShapeUri).toBe('custom://CustomShape');
|
|
255
|
+
expect(reconstructed.targetClass).toBe('recipe://Recipe');
|
|
256
|
+
});
|
|
257
|
+
it('preserves minInclusive and maxInclusive', () => {
|
|
258
|
+
const original = new SHACLShape('test://Model');
|
|
259
|
+
original.addProperty({
|
|
260
|
+
name: 'rating',
|
|
261
|
+
path: 'test://rating',
|
|
262
|
+
datatype: 'xsd:integer',
|
|
263
|
+
minInclusive: 1,
|
|
264
|
+
maxInclusive: 5,
|
|
265
|
+
});
|
|
266
|
+
const json = original.toJSON();
|
|
267
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
268
|
+
expect(reconstructed.properties[0].minInclusive).toBe(1);
|
|
269
|
+
expect(reconstructed.properties[0].maxInclusive).toBe(5);
|
|
270
|
+
});
|
|
271
|
+
it('preserves resolveLanguage', () => {
|
|
272
|
+
const original = new SHACLShape('test://Model');
|
|
273
|
+
original.addProperty({
|
|
274
|
+
name: 'content',
|
|
275
|
+
path: 'test://content',
|
|
276
|
+
resolveLanguage: 'literal',
|
|
277
|
+
});
|
|
278
|
+
const json = original.toJSON();
|
|
279
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
280
|
+
expect(reconstructed.properties[0].resolveLanguage).toBe('literal');
|
|
281
|
+
});
|
|
282
|
+
it('preserves constructor and destructor actions', () => {
|
|
283
|
+
const original = new SHACLShape('test://Model');
|
|
284
|
+
original.constructor_actions = [
|
|
285
|
+
{ action: 'addLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
286
|
+
];
|
|
287
|
+
original.destructor_actions = [
|
|
288
|
+
{ action: 'removeLink', source: 'this', predicate: 'rdf://type', target: 'test://Model' }
|
|
289
|
+
];
|
|
290
|
+
const json = original.toJSON();
|
|
291
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
292
|
+
expect(reconstructed.constructor_actions).toEqual(original.constructor_actions);
|
|
293
|
+
expect(reconstructed.destructor_actions).toEqual(original.destructor_actions);
|
|
294
|
+
});
|
|
295
|
+
it('preserves all property attributes', () => {
|
|
296
|
+
const original = new SHACLShape('test://Model');
|
|
297
|
+
original.addProperty({
|
|
298
|
+
name: 'field',
|
|
299
|
+
path: 'test://field',
|
|
300
|
+
datatype: 'xsd:string',
|
|
301
|
+
nodeKind: 'Literal',
|
|
302
|
+
minCount: 0,
|
|
303
|
+
maxCount: 5,
|
|
304
|
+
minInclusive: 0,
|
|
305
|
+
maxInclusive: 100,
|
|
306
|
+
pattern: '^[a-z]+$',
|
|
307
|
+
hasValue: 'default',
|
|
308
|
+
local: true,
|
|
309
|
+
writable: true,
|
|
310
|
+
resolveLanguage: 'literal',
|
|
311
|
+
setter: [{ action: 'addLink', source: 'this', predicate: 'test://field', target: 'value' }],
|
|
312
|
+
adder: [{ action: 'addLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
313
|
+
remover: [{ action: 'removeLink', source: 'this', predicate: 'test://items', target: 'value' }],
|
|
314
|
+
});
|
|
315
|
+
const json = original.toJSON();
|
|
316
|
+
const reconstructed = SHACLShape.fromJSON(json);
|
|
317
|
+
const prop = reconstructed.properties[0];
|
|
318
|
+
expect(prop.name).toBe('field');
|
|
319
|
+
expect(prop.path).toBe('test://field');
|
|
320
|
+
expect(prop.datatype).toBe('xsd:string');
|
|
321
|
+
expect(prop.nodeKind).toBe('Literal');
|
|
322
|
+
expect(prop.minCount).toBe(0);
|
|
323
|
+
expect(prop.maxCount).toBe(5);
|
|
324
|
+
expect(prop.minInclusive).toBe(0);
|
|
325
|
+
expect(prop.maxInclusive).toBe(100);
|
|
326
|
+
expect(prop.pattern).toBe('^[a-z]+$');
|
|
327
|
+
expect(prop.hasValue).toBe('default');
|
|
328
|
+
expect(prop.local).toBe(true);
|
|
329
|
+
expect(prop.writable).toBe(true);
|
|
330
|
+
expect(prop.resolveLanguage).toBe('literal');
|
|
331
|
+
expect(prop.setter).toEqual(original.properties[0].setter);
|
|
332
|
+
expect(prop.adder).toEqual(original.properties[0].adder);
|
|
333
|
+
expect(prop.remover).toEqual(original.properties[0].remover);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
package/lib/src/typeDefs.js
CHANGED
|
@@ -310,7 +310,7 @@ type Mutation {
|
|
|
310
310
|
aiCloseTranscriptionStream(streamId: String!): String!
|
|
311
311
|
aiEmbed(modelId: String!, text: String!): String!
|
|
312
312
|
aiFeedTranscriptionStream(audio: [Float!]!, streamIds: [String!]!): String!
|
|
313
|
-
aiOpenTranscriptionStream(
|
|
313
|
+
aiOpenTranscriptionStream(modelId: String!, params: VoiceActivityParamsInput): String!
|
|
314
314
|
aiPrompt(prompt: String!, taskId: String!): String!
|
|
315
315
|
aiRemoveModel(modelId: String!): Boolean!
|
|
316
316
|
aiRemoveTask(taskId: String!): AITask!
|
|
@@ -336,7 +336,7 @@ type Mutation {
|
|
|
336
336
|
perspectiveAddLink(batchId: String, link: LinkInput!, status: String = "shared", uuid: String!): LinkExpression!
|
|
337
337
|
perspectiveAddLinkExpression(batchId: String, link: LinkExpressionInput!, status: String = "shared", uuid: String!): LinkExpression!
|
|
338
338
|
perspectiveAddLinks(batchId: String, links: [LinkInput!]!, status: String = "shared", uuid: String!): [LinkExpression!]!
|
|
339
|
-
perspectiveAddSdna(name: String!, sdnaCode: String
|
|
339
|
+
perspectiveAddSdna(name: String!, sdnaCode: String, sdnaType: String!, shaclJson: String, uuid: String!): Boolean!
|
|
340
340
|
perspectiveCommitBatch(batchId: String!, uuid: String!): LinkExpressionMutations!
|
|
341
341
|
perspectiveCreateBatch(uuid: String!): String!
|
|
342
342
|
perspectiveCreateSubject(batchId: String, expressionAddress: String!, initialValues: String, subjectClass: String!, uuid: String!): Boolean!
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
-
|
|
9
8
|
"scripts": {
|
|
10
9
|
"build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
|
|
11
10
|
"buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
|
|
@@ -69,5 +68,5 @@
|
|
|
69
68
|
"graphql@15.7.2": "patches/graphql@15.7.2.patch"
|
|
70
69
|
}
|
|
71
70
|
},
|
|
72
|
-
"version": "0.12.0-dev
|
|
71
|
+
"version": "0.12.0-rc1-dev.1"
|
|
73
72
|
}
|
package/src/ai/AIClient.ts
CHANGED
|
@@ -302,19 +302,17 @@ export class AIClient {
|
|
|
302
302
|
endThreshold?: number;
|
|
303
303
|
endWindow?: number;
|
|
304
304
|
timeBeforeSpeech?: number;
|
|
305
|
-
}
|
|
306
|
-
language?: string
|
|
305
|
+
}
|
|
307
306
|
): Promise<string> {
|
|
308
307
|
const { aiOpenTranscriptionStream } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
309
308
|
mutation: gql`
|
|
310
|
-
mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput
|
|
311
|
-
aiOpenTranscriptionStream(modelId: $modelId, params: $params
|
|
309
|
+
mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
|
|
310
|
+
aiOpenTranscriptionStream(modelId: $modelId, params: $params)
|
|
312
311
|
}
|
|
313
312
|
`,
|
|
314
313
|
variables: {
|
|
315
314
|
modelId,
|
|
316
|
-
params
|
|
317
|
-
language
|
|
315
|
+
params
|
|
318
316
|
}
|
|
319
317
|
}));
|
|
320
318
|
|
package/src/ai/AIResolver.ts
CHANGED
|
@@ -338,8 +338,7 @@ export default class AIResolver {
|
|
|
338
338
|
@Mutation(() => String)
|
|
339
339
|
aiOpenTranscriptionStream(
|
|
340
340
|
@Arg("modelId") modelId: string,
|
|
341
|
-
@Arg("params", () => VoiceActivityParamsInput, { nullable: true }) params?: VoiceActivityParamsInput
|
|
342
|
-
@Arg("language", { nullable: true }) language?: string
|
|
341
|
+
@Arg("params", () => VoiceActivityParamsInput, { nullable: true }) params?: VoiceActivityParamsInput
|
|
343
342
|
): string {
|
|
344
343
|
return "streamId"
|
|
345
344
|
}
|
package/src/index.ts
CHANGED
|
@@ -31,3 +31,5 @@ export * from "./ai/AIClient"
|
|
|
31
31
|
export * from "./ai/Tasks"
|
|
32
32
|
export * from "./runtime/RuntimeResolver"
|
|
33
33
|
export * from './model/Ad4mModel'
|
|
34
|
+
export * from './shacl/SHACLShape'
|
|
35
|
+
export { SHACLFlow, FlowState, FlowTransition, LinkPattern, FlowableCondition } from './shacl/SHACLFlow'
|
package/src/model/Ad4mModel.ts
CHANGED
|
@@ -844,8 +844,10 @@ export class Ad4mModel {
|
|
|
844
844
|
} catch (e) {
|
|
845
845
|
console.warn(`Failed to resolve expression for ${propName}:`, e);
|
|
846
846
|
}
|
|
847
|
-
} else if (typeof value === 'string' && value.startsWith('literal://')) {
|
|
848
|
-
//
|
|
847
|
+
} else if (propMeta.resolveLanguage === 'literal' && typeof value === 'string' && value.startsWith('literal://')) {
|
|
848
|
+
// Only parse literal URIs when resolveLanguage is explicitly 'literal'.
|
|
849
|
+
// Without this guard, properties pointing to baseExpressions of other models
|
|
850
|
+
// (which may be literal:// strings) would get unwrapped, breaking link URI validation.
|
|
849
851
|
try {
|
|
850
852
|
const parsed = Literal.fromUrl(value).get();
|
|
851
853
|
value = parsed.data !== undefined ? parsed.data : parsed;
|
|
@@ -1671,8 +1673,12 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
1671
1673
|
|
|
1672
1674
|
// Only process if target has a value
|
|
1673
1675
|
if (target !== undefined && target !== null && target !== '') {
|
|
1674
|
-
// Check if we need to resolve a non-literal language expression
|
|
1675
|
-
|
|
1676
|
+
// Check if we need to resolve a non-literal language expression.
|
|
1677
|
+
// resolveLanguage must be defined and not 'literal' to trigger expression resolution.
|
|
1678
|
+
// Also skip if the target itself is a literal:// URI — those are handled by the
|
|
1679
|
+
// literal-parsing branch below (avoids calling getExpression on empty literals like
|
|
1680
|
+
// "literal://string:" which would cause a deserialization error).
|
|
1681
|
+
if (propMeta.resolveLanguage != undefined && propMeta.resolveLanguage !== 'literal' && typeof target === 'string' && !target.startsWith('literal://')) {
|
|
1676
1682
|
// For non-literal languages, resolve the expression via perspective.getExpression()
|
|
1677
1683
|
// Note: Literals are already parsed by SurrealDB's fn::parse_literal()
|
|
1678
1684
|
try {
|
|
@@ -1691,8 +1697,10 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
1691
1697
|
console.warn("Falling back to raw value");
|
|
1692
1698
|
convertedValue = target; // Fall back to raw value
|
|
1693
1699
|
}
|
|
1694
|
-
} else if (typeof target === 'string' && target.startsWith('literal://')) {
|
|
1695
|
-
//
|
|
1700
|
+
} else if (propMeta.resolveLanguage === 'literal' && typeof target === 'string' && target.startsWith('literal://')) {
|
|
1701
|
+
// Only parse literal URIs when resolveLanguage is explicitly set to 'literal'.
|
|
1702
|
+
// Without this check, properties pointing to baseExpressions of other models
|
|
1703
|
+
// (which may be literal:// strings) would get unwrapped, breaking link URI validation.
|
|
1696
1704
|
try {
|
|
1697
1705
|
const parsed = Literal.fromUrl(target).get();
|
|
1698
1706
|
if(parsed.data !== undefined) {
|
|
@@ -2236,6 +2244,11 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
2236
2244
|
// Get resolve language from metadata (replaces Prolog query)
|
|
2237
2245
|
let resolveLanguage = metadata.resolveLanguage;
|
|
2238
2246
|
|
|
2247
|
+
// Skip storing empty/null/undefined values to avoid invalid empty literals (e.g. literal://string:)
|
|
2248
|
+
if (value === undefined || value === null || value === "") {
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2239
2252
|
if (resolveLanguage) {
|
|
2240
2253
|
value = await this.#perspective.createExpression(value, resolveLanguage);
|
|
2241
2254
|
}
|
|
@@ -2355,9 +2368,12 @@ WHERE ${whereConditions.join(' AND ')}
|
|
|
2355
2368
|
}
|
|
2356
2369
|
}
|
|
2357
2370
|
|
|
2371
|
+
// Get the class name instead of passing the instance to avoid Prolog query generation
|
|
2372
|
+
const className = await this.perspective.stringOrTemplateObjectToSubjectClassName(this);
|
|
2373
|
+
|
|
2358
2374
|
// Create the subject with the initial values
|
|
2359
2375
|
await this.perspective.createSubject(
|
|
2360
|
-
|
|
2376
|
+
className,
|
|
2361
2377
|
this.#baseExpression,
|
|
2362
2378
|
initialValues,
|
|
2363
2379
|
batchId
|