@_linked/core 0.0.1 → 1.0.0-next.20260216062729

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/LICENSE +1 -1
  3. package/README.md +147 -92
  4. package/lib/cjs/queries/SelectQuery.d.ts +5 -0
  5. package/lib/cjs/queries/SelectQuery.js +14 -0
  6. package/lib/cjs/queries/SelectQuery.js.map +1 -1
  7. package/lib/cjs/shapes/SHACL.d.ts +1 -0
  8. package/lib/cjs/shapes/SHACL.js +82 -2
  9. package/lib/cjs/shapes/SHACL.js.map +1 -1
  10. package/lib/cjs/shapes/Shape.d.ts +13 -1
  11. package/lib/cjs/shapes/Shape.js +6 -0
  12. package/lib/cjs/shapes/Shape.js.map +1 -1
  13. package/lib/cjs/test-helpers/query-fixtures.d.ts +583 -0
  14. package/lib/cjs/test-helpers/query-fixtures.js +39 -1
  15. package/lib/cjs/test-helpers/query-fixtures.js.map +1 -1
  16. package/lib/esm/queries/SelectQuery.d.ts +5 -0
  17. package/lib/esm/queries/SelectQuery.js +14 -0
  18. package/lib/esm/queries/SelectQuery.js.map +1 -1
  19. package/lib/esm/shapes/SHACL.d.ts +1 -0
  20. package/lib/esm/shapes/SHACL.js +82 -2
  21. package/lib/esm/shapes/SHACL.js.map +1 -1
  22. package/lib/esm/shapes/Shape.d.ts +13 -1
  23. package/lib/esm/shapes/Shape.js +6 -0
  24. package/lib/esm/shapes/Shape.js.map +1 -1
  25. package/lib/esm/test-helpers/query-fixtures.d.ts +583 -0
  26. package/lib/esm/test-helpers/query-fixtures.js +38 -0
  27. package/lib/esm/test-helpers/query-fixtures.js.map +1 -1
  28. package/package.json +17 -1
  29. package/.context/notes.md +0 -0
  30. package/.context/todos.md +0 -0
  31. package/AGENTS.md +0 -59
  32. package/docs/001-core-extraction.md +0 -305
  33. package/jest.config.js +0 -25
  34. package/scripts/dual-package.js +0 -25
  35. package/src/collections/CoreMap.ts +0 -127
  36. package/src/collections/CoreSet.ts +0 -171
  37. package/src/collections/ShapeSet.ts +0 -18
  38. package/src/index.ts +0 -88
  39. package/src/interfaces/ICoreIterable.ts +0 -35
  40. package/src/interfaces/IFileStore.ts +0 -28
  41. package/src/interfaces/IQuadStore.ts +0 -16
  42. package/src/interfaces/IQueryParser.ts +0 -51
  43. package/src/ontologies/lincd.ts +0 -25
  44. package/src/ontologies/npm.ts +0 -15
  45. package/src/ontologies/owl.ts +0 -26
  46. package/src/ontologies/rdf.ts +0 -32
  47. package/src/ontologies/rdfs.ts +0 -38
  48. package/src/ontologies/shacl.ts +0 -136
  49. package/src/ontologies/xsd.ts +0 -47
  50. package/src/package.ts +0 -11
  51. package/src/queries/CreateQuery.ts +0 -41
  52. package/src/queries/DeleteQuery.ts +0 -54
  53. package/src/queries/MutationQuery.ts +0 -287
  54. package/src/queries/QueryContext.ts +0 -41
  55. package/src/queries/QueryFactory.ts +0 -275
  56. package/src/queries/QueryParser.ts +0 -79
  57. package/src/queries/SelectQuery.ts +0 -2101
  58. package/src/queries/UpdateQuery.ts +0 -47
  59. package/src/shapes/List.ts +0 -52
  60. package/src/shapes/SHACL.ts +0 -653
  61. package/src/shapes/Shape.ts +0 -282
  62. package/src/test-helpers/query-fixtures.ts +0 -313
  63. package/src/tests/core-utils.test.ts +0 -286
  64. package/src/tests/metadata.test.ts +0 -65
  65. package/src/tests/query.test.ts +0 -599
  66. package/src/tests/query.types.test.ts +0 -606
  67. package/src/tests/store-routing.test.ts +0 -133
  68. package/src/utils/LinkedErrorLogging.ts +0 -25
  69. package/src/utils/LinkedFileStorage.ts +0 -75
  70. package/src/utils/LinkedStorage.ts +0 -120
  71. package/src/utils/NameSpace.ts +0 -5
  72. package/src/utils/NodeReference.ts +0 -16
  73. package/src/utils/Package.ts +0 -681
  74. package/src/utils/Prefix.ts +0 -108
  75. package/src/utils/ShapeClass.ts +0 -335
  76. package/src/utils/Types.ts +0 -19
  77. package/src/utils/URI.ts +0 -40
  78. package/src/utils/cached.ts +0 -53
  79. package/tsconfig-cjs.json +0 -8
  80. package/tsconfig-esm.json +0 -9
  81. package/tsconfig.json +0 -29
@@ -1,606 +0,0 @@
1
- import {describe, test} from '@jest/globals';
2
- import {Shape} from '../shapes/Shape';
3
- import {SelectQueryFactory} from '../queries/SelectQuery';
4
- import {IQueryParser} from '../interfaces/IQueryParser';
5
- import {DeleteResponse} from '../queries/DeleteQuery';
6
- import {CreateResponse} from '../queries/CreateQuery';
7
- import {AddId, NodeReferenceValue, UpdatePartial} from '../queries/QueryFactory';
8
- import {UpdateQueryFactory} from '../queries/UpdateQuery';
9
- import {CreateQueryFactory} from '../queries/CreateQuery';
10
- import {DeleteQueryFactory} from '../queries/DeleteQuery';
11
- import {NodeId} from '../queries/MutationQuery';
12
- import {Dog, Person, Pet, queryFactories} from '../test-helpers/query-fixtures';
13
- import {setQueryContext} from '../queries/QueryContext';
14
-
15
- class QueryCaptureStore implements IQueryParser {
16
- async selectQuery<ResultType>(query: SelectQueryFactory<Shape>) {
17
- query.getQueryObject();
18
- return [] as ResultType;
19
- }
20
-
21
- async createQuery<ShapeType extends Shape, U extends UpdatePartial<ShapeType>>(
22
- updateObjectOrFn: U,
23
- shapeClass: typeof Shape,
24
- ): Promise<CreateResponse<U>> {
25
- const factory = new CreateQueryFactory(shapeClass, updateObjectOrFn);
26
- factory.getQueryObject();
27
- return {} as CreateResponse<U>;
28
- }
29
-
30
- async updateQuery<ShapeType extends Shape, U extends UpdatePartial<ShapeType>>(
31
- id: string | NodeReferenceValue,
32
- updateObjectOrFn: U,
33
- shapeClass: typeof Shape,
34
- ): Promise<AddId<U>> {
35
- const factory = new UpdateQueryFactory(shapeClass, id, updateObjectOrFn);
36
- factory.getQueryObject();
37
- return {} as AddId<U>;
38
- }
39
-
40
- async deleteQuery(
41
- id: NodeId | NodeId[] | NodeReferenceValue[],
42
- shapeClass: typeof Shape,
43
- ): Promise<DeleteResponse> {
44
- const ids = (Array.isArray(id) ? id : [id]) as NodeId[];
45
- const factory = new DeleteQueryFactory(shapeClass, ids);
46
- factory.getQueryObject();
47
- return {deleted: [], count: 0};
48
- }
49
- }
50
-
51
- Person.queryParser = new QueryCaptureStore();
52
- Pet.queryParser = Person.queryParser;
53
- Dog.queryParser = Person.queryParser;
54
-
55
- const expectType = <T>(_value: T) => _value;
56
-
57
- setQueryContext('user', {id: 'user-1'}, Person);
58
-
59
- // Compile-time checks only; skipped at runtime.
60
- describe.skip('query result type inference (compile only)', () => {
61
- test('can select a literal property of all instances', () => {
62
- const promise = queryFactories.selectName();
63
- type Result = Awaited<typeof promise>;
64
- const first = (null as unknown as Result)[0];
65
- expectType<string | null | undefined>(first.name);
66
- expectType<string | undefined>(first.id);
67
- });
68
-
69
- test('can select an object property of all instances', () => {
70
- const promise = queryFactories.selectFriends();
71
- type Result = Awaited<typeof promise>;
72
- const first = (null as unknown as Result)[0];
73
- expectType<string | undefined>(first.id);
74
- expectType<string | undefined>(first.friends[0].id);
75
- });
76
-
77
- test('can select a date', () => {
78
- const promise = queryFactories.selectBirthDate();
79
- type Result = Awaited<typeof promise>;
80
- const first = (null as unknown as Result)[0];
81
- expectType<Date | null | undefined>(first.birthDate);
82
- expectType<string | undefined>(first.id);
83
- });
84
-
85
- test('can select a boolean', () => {
86
- const promise = queryFactories.selectIsRealPerson();
87
- type Result = Awaited<typeof promise>;
88
- const first = (null as unknown as Result)[0];
89
- expectType<boolean | null | undefined>(first.isRealPerson);
90
- expectType<string | undefined>(first.id);
91
- });
92
-
93
- test('can select properties of a specific subject', () => {
94
- const promise = queryFactories.selectById();
95
- type Result = Awaited<typeof promise>;
96
- const single = null as unknown as Result;
97
- expectType<string | undefined>(single.id);
98
- expectType<string | null | undefined>(single.name);
99
- });
100
-
101
- test('can select properties of a specific subject by ID reference', () => {
102
- const promise = queryFactories.selectByIdReference();
103
- type Result = Awaited<typeof promise>;
104
- const single = null as unknown as Result;
105
- expectType<string | undefined>(single.id);
106
- expectType<string | null | undefined>(single.name);
107
- });
108
-
109
- test('select with a non existing returns undefined (query object still exists)', () => {
110
- const promise = queryFactories.selectNonExisting();
111
- type Result = Awaited<typeof promise>;
112
- const single = null as unknown as Result;
113
- expectType<string | undefined>(single.id);
114
- expectType<string | null | undefined>(single.name);
115
- });
116
-
117
- test('selecting only undefined properties returns an empty object (query still captures)', () => {
118
- const promise = queryFactories.selectUndefinedOnly();
119
- type Result = Awaited<typeof promise>;
120
- const single = null as unknown as Result;
121
- expectType<string | null | undefined>(single.hobby);
122
- expectType<{id?: string} | null | undefined>(single.bestFriend);
123
- });
124
-
125
- test('can select sub properties of a first property that returns a set', () => {
126
- const promise = queryFactories.selectFriendsName();
127
- type Result = Awaited<typeof promise>;
128
- const first = (null as unknown as Result)[0];
129
- expectType<string | null | undefined>(first.friends[0].name);
130
- expectType<string | undefined>(first.friends[0].id);
131
- });
132
-
133
- test('can select a nested set of shapes', () => {
134
- const promise = queryFactories.selectNestedFriendsName();
135
- type Result = Awaited<typeof promise>;
136
- const first = (null as unknown as Result)[0];
137
- expectType<string | null | undefined>(first.friends[0].friends[0].name);
138
- });
139
-
140
- test('can select multiple property paths', () => {
141
- const promise = queryFactories.selectMultiplePaths();
142
- type Result = Awaited<typeof promise>;
143
- const first = (null as unknown as Result)[0];
144
- expectType<string | null | undefined>(first.name);
145
- expectType<string | undefined>(first.friends[0].id);
146
- expectType<string | null | undefined>(first.bestFriend.name);
147
- });
148
-
149
- test('can select property of single shape value', () => {
150
- const promise = queryFactories.selectBestFriendName();
151
- type Result = Awaited<typeof promise>;
152
- const first = (null as unknown as Result)[0];
153
- expectType<string | null | undefined>(first.bestFriend.name);
154
- });
155
-
156
- test('can select 3 level deep nested paths', () => {
157
- const promise = queryFactories.selectDeepNested();
158
- type Result = Awaited<typeof promise>;
159
- const first = (null as unknown as Result)[0];
160
- expectType<string | null | undefined>(
161
- first.friends[0].bestFriend.bestFriend.name,
162
- );
163
- });
164
-
165
- test('can use where() to filter a string in a set of Literals with equals', () => {
166
- const promise = queryFactories.whereFriendsNameEquals();
167
- type Result = Awaited<typeof promise>;
168
- const first = (null as unknown as Result)[0];
169
- expectType<string | undefined>(first.id);
170
- expectType<string | undefined>(first.friends[0].id);
171
- });
172
-
173
- test('where object value', () => {
174
- const promise = queryFactories.whereBestFriendEquals();
175
- type Result = Awaited<typeof promise>;
176
- const first = (null as unknown as Result)[0];
177
- expectType<string | undefined>(first.id);
178
- });
179
-
180
- test('where on literal', () => {
181
- const promise = queryFactories.whereHobbyEquals();
182
- type Result = Awaited<typeof promise>;
183
- const first = (null as unknown as Result)[0];
184
- expectType<string | null | undefined>(first.hobby);
185
- });
186
-
187
- test('where and', () => {
188
- const promise = queryFactories.whereAnd();
189
- type Result = Awaited<typeof promise>;
190
- const first = (null as unknown as Result)[0];
191
- expectType<string | undefined>(first.friends[0].id);
192
- });
193
-
194
- test('where or', () => {
195
- const promise = queryFactories.whereOr();
196
- type Result = Awaited<typeof promise>;
197
- const first = (null as unknown as Result)[0];
198
- expectType<string | undefined>(first.friends[0].id);
199
- });
200
-
201
- test('select all', () => {
202
- const promise = queryFactories.selectAll();
203
- type Result = Awaited<typeof promise>;
204
- const first = (null as unknown as Result)[0];
205
- expectType<string | undefined>(first.id);
206
- });
207
-
208
- test('empty select with where', () => {
209
- const promise = queryFactories.selectWhereNameSemmy();
210
- type Result = Awaited<typeof promise>;
211
- const first = (null as unknown as Result)[0];
212
- expectType<string | undefined>(first.id);
213
- });
214
-
215
- test('where and or and', () => {
216
- const promise = queryFactories.whereAndOrAnd();
217
- type Result = Awaited<typeof promise>;
218
- const first = (null as unknown as Result)[0];
219
- expectType<string | undefined>(first.friends[0].id);
220
- });
221
-
222
- test('where and or and (nested)', () => {
223
- const promise = queryFactories.whereAndOrAndNested();
224
- type Result = Awaited<typeof promise>;
225
- const first = (null as unknown as Result)[0];
226
- expectType<string | undefined>(first.friends[0].id);
227
- });
228
-
229
- test('where some implicit', () => {
230
- const promise = queryFactories.whereSomeImplicit();
231
- type Result = Awaited<typeof promise>;
232
- const first = (null as unknown as Result)[0];
233
- expectType<string | undefined>(first.id);
234
- });
235
-
236
- test('where some explicit', () => {
237
- const promise = queryFactories.whereSomeExplicit();
238
- type Result = Awaited<typeof promise>;
239
- const first = (null as unknown as Result)[0];
240
- expectType<string | undefined>(first.id);
241
- });
242
-
243
- test('where every', () => {
244
- const promise = queryFactories.whereEvery();
245
- type Result = Awaited<typeof promise>;
246
- const first = (null as unknown as Result)[0];
247
- expectType<string | undefined>(first.id);
248
- });
249
-
250
- test('where sequences', () => {
251
- const promise = queryFactories.whereSequences();
252
- type Result = Awaited<typeof promise>;
253
- const first = (null as unknown as Result)[0];
254
- expectType<string | undefined>(first.id);
255
- });
256
-
257
- test('outer where()', () => {
258
- const promise = queryFactories.outerWhere();
259
- type Result = Awaited<typeof promise>;
260
- const first = (null as unknown as Result)[0];
261
- expectType<string | undefined>(first.id);
262
- expectType<string | undefined>(first.friends[0].id);
263
- });
264
-
265
- test('where with query context', () => {
266
- const promise = queryFactories.whereWithContext();
267
- type Result = Awaited<typeof promise>;
268
- const first = (null as unknown as Result)[0];
269
- expectType<string | null | undefined>(first.name);
270
- });
271
-
272
- test('where with query context as base of property path', () => {
273
- const promise = queryFactories.whereWithContextPath();
274
- type Result = Awaited<typeof promise>;
275
- const first = (null as unknown as Result)[0];
276
- expectType<string | null | undefined>(first.name);
277
- });
278
-
279
- test('count a shapeset', () => {
280
- const promise = queryFactories.countFriends();
281
- type Result = Awaited<typeof promise>;
282
- const first = (null as unknown as Result)[0];
283
- expectType<number>(first.friends);
284
- });
285
-
286
- test('count a nested property', () => {
287
- const promise = queryFactories.countNestedFriends();
288
- type Result = Awaited<typeof promise>;
289
- const first = (null as unknown as Result)[0];
290
- expectType<number>(first.friends[0].friends);
291
- });
292
-
293
- test('labeling the key of count()', () => {
294
- const promise = queryFactories.countLabel();
295
- type Result = Awaited<typeof promise>;
296
- const first = (null as unknown as Result)[0];
297
- expectType<number>(first.friends[0].numFriends);
298
- });
299
-
300
- test('nested object property', () => {
301
- const promise = queryFactories.nestedObjectProperty();
302
- type Result = Awaited<typeof promise>;
303
- const first = (null as unknown as Result)[0];
304
- expectType<string | undefined>(first.friends[0].bestFriend.id);
305
- });
306
-
307
- test('nested object property (single)', () => {
308
- const promise = queryFactories.nestedObjectPropertySingle();
309
- type Result = Awaited<typeof promise>;
310
- const first = (null as unknown as Result)[0];
311
- expectType<string | undefined>(first.friends[0].bestFriend.id);
312
- });
313
-
314
- test('sub select single prop', () => {
315
- const promise = queryFactories.subSelectSingleProp();
316
- type Result = Awaited<typeof promise>;
317
- const first = (null as unknown as Result)[0];
318
- expectType<string | null | undefined>(first.bestFriend.name);
319
- });
320
-
321
- test('sub select plural prop - custom object', () => {
322
- const promise = queryFactories.subSelectPluralCustom();
323
- type Result = Awaited<typeof promise>;
324
- const first = (null as unknown as Result)[0];
325
- expectType<string | null | undefined>(first.friends[0].name);
326
- expectType<string | null | undefined>(first.friends[0].hobby);
327
- });
328
-
329
- test('double nested sub select', () => {
330
- const promise = queryFactories.doubleNestedSubSelect();
331
- type Result = Awaited<typeof promise>;
332
- const first = (null as unknown as Result)[0];
333
- expectType<string | null | undefined>(first.friends[0].bestFriend.name);
334
- });
335
-
336
- test('sub select all primitives', () => {
337
- const promise = queryFactories.subSelectAllPrimitives();
338
- type Result = Awaited<typeof promise>;
339
- const first = (null as unknown as Result)[0];
340
- expectType<string | null | undefined>(first.bestFriend.name);
341
- expectType<Date | null | undefined>(first.bestFriend.birthDate);
342
- expectType<boolean | null | undefined>(first.bestFriend.isRealPerson);
343
- });
344
-
345
- test('custom result object - equals without where returns a boolean', () => {
346
- const promise = queryFactories.customResultEqualsBoolean();
347
- type Result = Awaited<typeof promise>;
348
- const first = (null as unknown as Result)[0];
349
- expectType<boolean>(first.isBestFriend);
350
- });
351
-
352
- test('custom result object 2', () => {
353
- const promise = queryFactories.customResultNumFriends();
354
- type Result = Awaited<typeof promise>;
355
- const first = (null as unknown as Result)[0];
356
- expectType<number>(first.numFriends);
357
- });
358
-
359
- test('count equals', () => {
360
- const promise = queryFactories.countEquals();
361
- type Result = Awaited<typeof promise>;
362
- const first = (null as unknown as Result)[0];
363
- expectType<string | undefined>(first.id);
364
- });
365
-
366
- test('sub select query returning an array', () => {
367
- const promise = queryFactories.subSelectArray();
368
- type Result = Awaited<typeof promise>;
369
- const first = (null as unknown as Result)[0];
370
- expectType<string | null | undefined>(first.friends[0].name);
371
- expectType<string | null | undefined>(first.friends[0].hobby);
372
- });
373
-
374
- test('select shapeset as', () => {
375
- const promise = queryFactories.selectShapeSetAs();
376
- type Result = Awaited<typeof promise>;
377
- const first = (null as unknown as Result)[0];
378
- expectType<number | null | undefined>(first.pets[0].guardDogLevel);
379
- });
380
-
381
- test('select non existing returns null or empty array for multiple value properties', () => {
382
- const promise = queryFactories.selectNonExistingMultiple();
383
- type Result = Awaited<typeof promise>;
384
- const first = (null as unknown as Result)[0];
385
- expectType<{id?: string} | null | undefined>(first.bestFriend);
386
- expectType<string | undefined>(first.friends[0].id);
387
- });
388
-
389
- test('select shape as', () => {
390
- const promise = queryFactories.selectShapeAs();
391
- type Result = Awaited<typeof promise>;
392
- const first = (null as unknown as Result)[0];
393
- expectType<number | null | undefined>(first.firstPet.guardDogLevel);
394
- });
395
-
396
- test('select one', () => {
397
- const promise = queryFactories.selectOne();
398
- type Result = Awaited<typeof promise>;
399
- const single = null as unknown as Result;
400
- expectType<string | null | undefined>(single.name);
401
- });
402
-
403
- test('nested queries 2', () => {
404
- const promise = queryFactories.nestedQueries2();
405
- type Result = Awaited<typeof promise>;
406
- const first = (null as unknown as Result)[0];
407
- expectType<{id?: string} | null | undefined>(first.friends[0].firstPet);
408
- expectType<string | null | undefined>(first.friends[0].bestFriend.name);
409
- });
410
-
411
- test('select duplicate paths', () => {
412
- const promise = queryFactories.selectDuplicatePaths();
413
- type Result = Awaited<typeof promise>;
414
- const first = (null as unknown as Result)[0];
415
- expectType<string | null | undefined>(first.bestFriend.name);
416
- expectType<string | null | undefined>(first.bestFriend.hobby);
417
- expectType<boolean | null | undefined>(first.bestFriend.isRealPerson);
418
- });
419
-
420
- test('can preload a component query onto a property path', () => {
421
- const promise = queryFactories.preloadBestFriend();
422
- type Result = Awaited<typeof promise>;
423
- const first = (null as unknown as Result)[0];
424
- expectType<string | null | undefined>(first.bestFriend.name);
425
- });
426
-
427
- test('outer where with limit', () => {
428
- const promise = queryFactories.outerWhereLimit();
429
- type Result = Awaited<typeof promise>;
430
- const first = (null as unknown as Result)[0];
431
- expectType<string | null | undefined>(first.name);
432
- });
433
-
434
- test('sort by 1 property - ASC (default)', () => {
435
- const promise = queryFactories.sortByAsc();
436
- type Result = Awaited<typeof promise>;
437
- const first = (null as unknown as Result)[0];
438
- expectType<string | null | undefined>(first.name);
439
- });
440
-
441
- test('sort by 1 property - DESC', () => {
442
- const promise = queryFactories.sortByDesc();
443
- type Result = Awaited<typeof promise>;
444
- const first = (null as unknown as Result)[0];
445
- expectType<string | null | undefined>(first.name);
446
- });
447
-
448
- test('update query 1 - with simple object argument', () => {
449
- const promise = queryFactories.updateSimple();
450
- type Result = Awaited<typeof promise>;
451
- const updated = null as unknown as Result;
452
- expectType<string | undefined>(updated.id);
453
- expectType<string | undefined>(updated.hobby);
454
- });
455
-
456
- test('create query 1 - create simple person with literal fields', () => {
457
- const promise = queryFactories.createSimple();
458
- type Result = Awaited<typeof promise>;
459
- const created = null as unknown as Result;
460
- expectType<string | undefined>(created.id);
461
- expectType<string | undefined>(created.name);
462
- expectType<string | undefined>(created.hobby);
463
- });
464
-
465
- test('create query 2 - create person with new and existing friends', () => {
466
- const promise = queryFactories.createWithFriends();
467
- type Result = Awaited<typeof promise>;
468
- const created = null as unknown as Result;
469
- expectType<string | undefined>(created.id);
470
- expectType<{id?: string}[]>(created.friends);
471
- });
472
-
473
- test('create query 3 - create a new person with a fixed ID', () => {
474
- const promise = queryFactories.createWithFixedId();
475
- type Result = Awaited<typeof promise>;
476
- const created = null as unknown as Result;
477
- expectType<string | undefined>(created.id);
478
- expectType<string | undefined>(created.name);
479
- });
480
-
481
- test('delete query 1 - delete newly created node', () => {
482
- const promise = queryFactories.deleteSingle();
483
- type Result = Awaited<typeof promise>;
484
- const deleted = null as unknown as Result;
485
- expectType<number>(deleted.count);
486
- });
487
-
488
- test('delete query 2 - delete newly created node by node reference', () => {
489
- const promise = queryFactories.deleteSingleRef();
490
- type Result = Awaited<typeof promise>;
491
- const deleted = null as unknown as Result;
492
- expectType<number>(deleted.count);
493
- });
494
-
495
- test('delete query 3 - delete multiple newly created nodes', () => {
496
- const promise = queryFactories.deleteMultiple();
497
- type Result = Awaited<typeof promise>;
498
- const deleted = null as unknown as Result;
499
- expectType<number>(deleted.count);
500
- });
501
-
502
- test('delete query 4 - delete multiple newly created nodes by passing the full result objects', () => {
503
- const promise = queryFactories.deleteMultipleFull();
504
- type Result = Awaited<typeof promise>;
505
- const deleted = null as unknown as Result;
506
- expectType<number>(deleted.count);
507
- });
508
-
509
- test('update query 2 - overwrite a set (default)', () => {
510
- const promise = queryFactories.updateOverwriteSet();
511
- type Result = Awaited<typeof promise>;
512
- const updated = null as unknown as Result;
513
- expectType<string | undefined>(updated.id);
514
- expectType<
515
- | {updatedTo: {id?: string}[]}
516
- | {added: {id?: string}[]; removed: {id?: string}[]}
517
- | undefined
518
- >(updated.friends);
519
- });
520
-
521
- test('update query 3 - unset a single value property', () => {
522
- const promise = queryFactories.updateUnsetSingleUndefined();
523
- type Result = Awaited<typeof promise>;
524
- const updated = null as unknown as Result;
525
- expectType<string | undefined>(updated.id);
526
- expectType<string | undefined>(updated.hobby);
527
- });
528
-
529
- test('update query 3B - unset a single value property with null', () => {
530
- const promise = queryFactories.updateUnsetSingleNull();
531
- type Result = Awaited<typeof promise>;
532
- const updated = null as unknown as Result;
533
- expectType<string | null | undefined>(updated.hobby);
534
- });
535
-
536
- test('update query 4 - overwrite a nested object argument', () => {
537
- const promise = queryFactories.updateOverwriteNested();
538
- type Result = Awaited<typeof promise>;
539
- const updated = null as unknown as Result;
540
- expectType<{id?: string} | undefined>(updated.bestFriend);
541
- });
542
-
543
- test('update query 5 - pass id references', () => {
544
- const promise = queryFactories.updatePassIdReferences();
545
- type Result = Awaited<typeof promise>;
546
- const updated = null as unknown as Result;
547
- expectType<{id?: string} | undefined>(updated.bestFriend);
548
- });
549
-
550
- test('update query 6 - add to and remove from Multi-Value Property (friends)', () => {
551
- const promise = queryFactories.updateAddRemoveMulti();
552
- type Result = Awaited<typeof promise>;
553
- const updated = null as unknown as Result;
554
- const friends = updated.friends;
555
- if (friends && 'added' in friends) {
556
- expectType<{id?: string}[]>(friends.added);
557
- expectType<{id?: string}[]>(friends.removed);
558
- }
559
- });
560
-
561
- test('update query 7 - remove from Multi-Value Property (friends)', () => {
562
- const promise = queryFactories.updateRemoveMulti();
563
- type Result = Awaited<typeof promise>;
564
- const updated = null as unknown as Result;
565
- const friends = updated.friends;
566
- if (friends && 'removed' in friends) {
567
- expectType<{id?: string}[]>(friends.removed);
568
- }
569
- });
570
-
571
- test('update query 8 - $add and $remove in same update', () => {
572
- const promise = queryFactories.updateAddRemoveSame();
573
- type Result = Awaited<typeof promise>;
574
- const updated = null as unknown as Result;
575
- const friends = updated.friends;
576
- if (friends && 'added' in friends) {
577
- expectType<{id?: string}[]>(friends.added);
578
- expectType<{id?: string}[]>(friends.removed);
579
- }
580
- });
581
-
582
- test('update query 9 - unset Multi-Value Property with undefined', () => {
583
- const promise = queryFactories.updateUnsetMultiUndefined();
584
- type Result = Awaited<typeof promise>;
585
- const updated = null as unknown as Result;
586
- expectType<
587
- | {updatedTo: {id?: string}[]}
588
- | {added: {id?: string}[]; removed: {id?: string}[]}
589
- | undefined
590
- >(updated.friends);
591
- });
592
-
593
- test('update query 10 - create new nested object with predefined ID', () => {
594
- const promise = queryFactories.updateNestedWithPredefinedId();
595
- type Result = Awaited<typeof promise>;
596
- const updated = null as unknown as Result;
597
- expectType<{id?: string} | undefined>(updated.bestFriend);
598
- });
599
-
600
- test('update query 11 - update datatype: Date', () => {
601
- const promise = queryFactories.updateBirthDate();
602
- type Result = Awaited<typeof promise>;
603
- const updated = null as unknown as Result;
604
- expectType<Date | undefined>(updated.birthDate);
605
- });
606
- });