@based/schema 1.1.8 → 1.1.10

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/test/walker.ts CHANGED
@@ -120,7 +120,7 @@ const schema: BasedSchema = {
120
120
  },
121
121
  }
122
122
 
123
- test('walker', async (t) => {
123
+ test('backtracking', async (t) => {
124
124
  const results: any[] = []
125
125
 
126
126
  const setObj = {
@@ -176,7 +176,6 @@ test('walker', async (t) => {
176
176
  },
177
177
  ])
178
178
 
179
- console.log('--------------------------------------')
180
179
  const results2: any[] = []
181
180
 
182
181
  await walk<{ lullz: true }>(
@@ -206,7 +205,6 @@ test('walker', async (t) => {
206
205
 
207
206
  t.deepEqual(results, results2)
208
207
 
209
- console.log('--------------------------------------')
210
208
  const results3: any[] = []
211
209
 
212
210
  let cnt = 0
@@ -239,107 +237,66 @@ test('walker', async (t) => {
239
237
  t.deepEqual(results, results3)
240
238
  })
241
239
 
242
- test('set walker', async (t) => {
243
- const schema: BasedSchema = {
244
- types: {
245
- bla: {
246
- prefix: 'bl',
247
- fields: {
248
- record: {
249
- type: 'record',
250
- values: {
251
- type: 'cardinality',
252
- },
253
- },
254
- array: {
255
- type: 'array',
256
- values: {
257
- type: 'object',
258
- properties: {
259
- uniqMap: {
260
- type: 'record',
261
- values: {
262
- type: 'cardinality',
263
- },
264
- },
265
- bla: { type: 'boolean' },
266
- },
267
- },
268
- },
269
- uniq: { type: 'cardinality' },
270
- snup: { type: 'boolean' },
271
- flap: {
272
- type: 'object',
273
- required: ['durp'],
274
- properties: {
275
- durp: { type: 'boolean' },
276
- gurt: { type: 'boolean' },
277
- durpi: {
278
- enum: ['yuzi', 'jux', 'mr tony', 9000],
279
- },
280
- x: {
281
- type: 'array',
282
- values: {
283
- type: 'boolean',
284
- },
240
+ test.only('parseTop update target', async (t) => {
241
+ const parsed: { path: (number | string)[]; target: any }[] = []
242
+ await walk<any>(
243
+ schema,
244
+ {
245
+ init: async () => {
246
+ return { target: { path: [] } }
247
+ },
248
+ parsers: {
249
+ keys: {},
250
+ fields: {},
251
+ any: async (args) => {
252
+ args.collect()
253
+ if (args.prev.key !== args.key) {
254
+ return {
255
+ parseTopLevel: true,
256
+ target: {
257
+ path: args.path.join('.'),
258
+ prevTarget: args.target.id,
259
+ id: args.id,
285
260
  },
286
- },
287
- },
261
+ value: args.value,
262
+ }
263
+ }
288
264
  },
289
265
  },
266
+ collect: (args) => {
267
+ parsed.push({ path: args.path, target: args.target })
268
+ return args.path.join('.')
269
+ },
290
270
  },
291
- $defs: {},
292
- languages: ['en'],
293
- root: {
294
- fields: {},
295
- },
296
- prefixToTypeMapping: {
297
- bl: 'bla',
298
- },
299
- }
271
+ {
272
+ x: {
273
+ y: {
274
+ z: 'bla!',
275
+ },
276
+ },
277
+ }
278
+ )
300
279
 
301
- const x = await setWalker(schema, {
302
- $id: 'bl1',
303
- snup: false,
304
- uniq: {
305
- $value: 'wpeojwepojfewpio',
280
+ t.deepEqual(parsed, [
281
+ { path: ['x'], target: { path: [] } },
282
+ {
283
+ path: ['x'],
284
+ target: { path: 'x', prevTarget: undefined, id: 2 },
306
285
  },
307
- record: {
308
- a: 1000,
309
- b: 'bla',
310
- c: { x: 'snap', y: 'flap' },
311
- bla: { $value: { a: true, b: false } },
286
+ {
287
+ path: ['x', 'y'],
288
+ target: { path: 'x', prevTarget: undefined, id: 2 },
312
289
  },
313
- flap: {
314
- gurt: true,
315
- durpi: {
316
- $value: 'jux',
317
- },
318
- x: [
319
- true,
320
- false,
321
- false,
322
- true,
323
- { $value: false },
324
- { $default: true, $value: false },
325
- ],
290
+ { path: ['x', 'y'], target: { path: 'x.y', prevTarget: 2, id: 4 } },
291
+ {
292
+ path: ['x', 'y', 'z'],
293
+ target: { path: 'x.y', prevTarget: 2, id: 4 },
326
294
  },
327
- array: {
328
- $insert: {
329
- $idx: 2,
330
- $value: {
331
- bla: false,
332
- uniqMap: {
333
- a: false,
334
- b: { $value: { a: true, b: true }, c: { x: true } },
335
- },
336
- },
337
- },
295
+ {
296
+ path: ['x', 'y', 'z'],
297
+ target: { path: 'x.y.z', prevTarget: 4, id: 6 },
338
298
  },
339
- })
340
-
341
- console.info('------------', x)
342
- t.true(true)
299
+ ])
343
300
  })
344
301
 
345
302
  test.serial('perf setWalker', async (t) => {
@@ -359,723 +316,3 @@ test.serial('perf setWalker', async (t) => {
359
316
  console.info('setting 200k', d, 'ms')
360
317
  t.true(d < 1e3)
361
318
  })
362
-
363
- test.skip('string', async (t) => {
364
- // for (let i = 0; i < 10; i++) {
365
- // console.log(
366
- // (await setWalker(schema, { $id: 'bl120', name: 'blax' })).target
367
- // .collected
368
- // )
369
- // }
370
-
371
- // console.info('----------')
372
- // console.log(
373
- // (await setWalker(schema, { $id: 'bl120', name: { $value: 'blax' } }))
374
- // .target.collected
375
- // )
376
- console.info('---- default ------')
377
- const x = await setWalker(schema, {
378
- $id: 'bl120',
379
- name: { $default: 'blax' },
380
- })
381
-
382
- // TODO: Error also has to include path
383
- console.log(
384
- x.errors,
385
- x.collected.map((v) => ({ path: v.path, value: v.value }))
386
- )
387
-
388
- console.info('---- default too many fields ------')
389
- const y = await setWalker(schema, {
390
- $id: 'bl120',
391
- name: { $default: 'blax', meanboys: true },
392
- })
393
-
394
- // TODO: Error also has to include path
395
- console.log(
396
- y.errors,
397
- y.collected.map((v) => ({ path: v.path, value: v.value }))
398
- )
399
-
400
- console.info('---- ------')
401
- const z = await setWalker(schema, {
402
- $id: 'bl120',
403
- exclusiveminmax: { $default: 10, $decrement: 10 },
404
- })
405
-
406
- console.log(
407
- z.errors,
408
- z.collected.map((v) => ({ path: v.path, value: v.value }))
409
- )
410
-
411
- console.info('---- doink ------')
412
- const j = await setWalker(schema, {
413
- $id: 'bl120',
414
- exclusiveminmax: { $default: 4, $decrement: 10 },
415
- })
416
-
417
- console.log(
418
- j.errors,
419
- j.collected.map((v) => ({ path: v.path, value: v.value }))
420
- )
421
-
422
- console.info('---- doink 2 ------')
423
- const c = await setWalker(schema, {
424
- $id: 'bl120',
425
- exclusiveminmax: { $default: 4, $decrement: 10, flapperdeflip: true },
426
- })
427
-
428
- console.log(
429
- c.errors,
430
- c.collected.map((v) => ({ path: v.path, value: v.value }))
431
- )
432
-
433
- console.info('---- doink 3 ------')
434
- const g = await setWalker(schema, {
435
- $id: 'bl120',
436
- timestamp: { $default: 4 },
437
- })
438
-
439
- console.log(
440
- g.errors,
441
- g.collected.map((v) => ({ path: v.path, value: v.value }))
442
- )
443
-
444
- console.info('---- doink 4 ------')
445
- const d = await setWalker(schema, {
446
- $id: 'bl120',
447
- exclusiveminmax: { $value: 4 },
448
- })
449
-
450
- console.log(
451
- d.errors,
452
- d.collected.map((v) => ({ path: v.path, value: v.value }))
453
- )
454
-
455
- console.info('---- doink 5 ------')
456
- let r = await setWalker(schema, {
457
- $id: 'bl120',
458
- text: { $value: 'x' },
459
- })
460
-
461
- console.log(
462
- r.errors,
463
- r.collected.map((v) => ({ path: v.path, value: v.value }))
464
- )
465
-
466
- console.info('---- doink 6 ------')
467
- r = await setWalker(schema, {
468
- $id: 'bl120',
469
- $language: 'za',
470
- text: { $value: 'sdsdds' },
471
- })
472
-
473
- console.log(
474
- r.errors,
475
- r.collected.map((v) => ({ path: v.path, value: v.value }))
476
- )
477
-
478
- console.info('---- doink 7 ------')
479
- r = await setWalker(schema, {
480
- $id: 'bl120',
481
- $language: 'za',
482
- text: { $default: 'sdsdds' },
483
- })
484
-
485
- console.log(r.errors)
486
- console.dir(
487
- r.collected.map((v) => ({ path: v.path, value: v.value })),
488
- { depth: 10 }
489
- )
490
-
491
- console.info('---- doink 8 ------')
492
- r = await setWalker(schema, {
493
- $id: 'bl120',
494
- $language: 'za',
495
- text: { $default: 'sdsdds', en: { $default: 'flapflap' } },
496
- })
497
-
498
- console.log(r.errors)
499
- console.dir(
500
- r.collected.map((v) => ({ path: v.path, value: v.value })),
501
- { depth: 10 }
502
- )
503
-
504
- console.info('---- doink 9 ------')
505
- r = await setWalker(schema, {
506
- $id: 'bl120',
507
- $language: 'za',
508
- text: { $default: { de: 'dsnfds' }, en: { $default: 'flapflap' } },
509
- })
510
-
511
- console.log(r.errors)
512
- console.dir(
513
- r.collected.map((v) => ({ path: v.path, value: v.value })),
514
- { depth: 10 }
515
- )
516
-
517
- t.true(true)
518
-
519
- console.info('---- doink 10 ------')
520
- r = await setWalker(schema, {
521
- $id: 'bl120',
522
- $language: 'za',
523
- text: {
524
- $default: { de: 'dsnfds' },
525
- nl: 'flapperonus',
526
- en: { $default: 'flapflap' },
527
- },
528
- })
529
-
530
- console.log(r.errors)
531
- console.dir(
532
- r.collected.map((v) => ({ path: v.path, value: v.value })),
533
- { depth: 10 }
534
- )
535
-
536
- console.info('---- doink 11 ------')
537
- r = await setWalker(schema, {
538
- $id: 'bl120',
539
- $language: 'za',
540
- text: {
541
- $default: { de: 'dsnfds' },
542
- nl: 'flapperonus',
543
- ro: { $value: 'durp' },
544
- en: { $default: 'flapflap' },
545
- },
546
- })
547
-
548
- console.log(r.errors)
549
- console.dir(
550
- r.collected.map((v) => ({ path: v.path, value: v.value })),
551
- { depth: 10 }
552
- )
553
-
554
- console.info('---- doink 12 ------')
555
- r = await setWalker(schema, {
556
- $id: 'bl120',
557
- $language: 'za',
558
- text: {
559
- $value: 'durp',
560
- nl: 'flapperonus',
561
- $default: {
562
- ae: 'habibi',
563
- },
564
- ro: { $value: 'durp' },
565
- en: { $default: 'flapflap' },
566
- },
567
- })
568
-
569
- console.log(r.errors)
570
- console.dir(
571
- r.collected.map((v) => ({ path: v.path, value: v.value })),
572
- { depth: 10 }
573
- )
574
-
575
- console.info('---- doink 13 ------')
576
- r = await setWalker(schema, {
577
- $id: 'bl120',
578
- $language: 'za',
579
- text: {
580
- $value: 'xz',
581
- nl: 'flapperonus',
582
- $default: {
583
- ae: 'habibi',
584
- },
585
- ro: { $value: 'durp' },
586
- en: { $default: 'xzxz' },
587
- },
588
- })
589
-
590
- console.log(r.errors)
591
- console.dir(
592
- r.collected.map((v) => ({ path: v.path, value: v.value })),
593
- { depth: 10 }
594
- )
595
-
596
- console.info('---- doink 14 ------')
597
- r = await setWalker(schema, {
598
- $id: 'bl120',
599
- $language: 'za',
600
- text: {
601
- $value: 'xz',
602
- nl: 'flapperonus',
603
- $default: {
604
- ae: 'habibi',
605
- },
606
- ro: { $value: 'durp' },
607
- en: { $default: 'xzxz' },
608
- },
609
- })
610
-
611
- console.log(r.errors)
612
- console.dir(
613
- r.collected.map((v) => ({ path: v.path, value: v.value })),
614
- { depth: 10 }
615
- )
616
-
617
- console.info('---- doink 15 ------')
618
- r = await setWalker(schema, {
619
- $id: 'bl120',
620
- setOfNumbers: [1, 2, 3, 4, 5],
621
- })
622
-
623
- console.log(r.errors)
624
- console.dir(
625
- r.collected.map((v) => ({ path: v.path, value: v.value })),
626
- { depth: 10 }
627
- )
628
-
629
- console.info('---- doink 16 ------')
630
- r = await setWalker(schema, {
631
- $id: 'bl120',
632
- setOfNumbers: { $add: 20 },
633
- })
634
-
635
- console.log(r.errors)
636
- console.dir(
637
- r.collected.map((v) => ({ path: v.path, value: v.value })),
638
- { depth: 10 }
639
- )
640
-
641
- console.info('---- doink 17 ------')
642
- r = await setWalker(schema, {
643
- $id: 'bl120',
644
- setOfNumbers: { $add: [1, 2, 3, 4, 5, 6] },
645
- })
646
-
647
- console.log(r.errors)
648
- console.dir(
649
- r.collected.map((v) => ({ path: v.path, value: v.value })),
650
- { depth: 10 }
651
- )
652
-
653
- console.info('---- doink 18 ------')
654
- r = await setWalker(schema, {
655
- $id: 'bl120',
656
- setOfNumbers: { $remove: [1, 2, 3, 4, 5, 6] },
657
- })
658
-
659
- console.log(r.errors)
660
- console.dir(
661
- r.collected.map((v) => ({ path: v.path, value: v.value })),
662
- { depth: 10 }
663
- )
664
-
665
- console.info('---- doink 19 ------')
666
- r = await setWalker(schema, {
667
- $id: 'bl120',
668
- referenceToThing: 'sdfefewfewfewewffwe',
669
- })
670
-
671
- console.log(r.errors)
672
- console.dir(
673
- r.collected.map((v) => ({ path: v.path, value: v.value })),
674
- { depth: 10 }
675
- )
676
-
677
- console.info('---- doink 20 ------')
678
- r = await setWalker(schema, {
679
- $id: 'bl120',
680
- referenceToThing: 'tibla',
681
- })
682
-
683
- console.log(r.errors)
684
- console.dir(
685
- r.collected.map((v) => ({ path: v.path, value: v.value })),
686
- { depth: 10 }
687
- )
688
-
689
- console.info('---- doink 21 ------')
690
- r = await setWalker(schema, {
691
- $id: 'bl120',
692
- referenceToThing: 'blbla',
693
- })
694
-
695
- console.log(r.errors)
696
- console.dir(
697
- r.collected.map((v) => ({ path: v.path, value: v.value })),
698
- { depth: 10 }
699
- )
700
-
701
- console.info('---- doink 22 ------')
702
- r = await setWalker(schema, {
703
- $id: 'bl120',
704
- referencesToThings: ['blbla', 'ti123', 'ewiohfdoweihfw'],
705
- })
706
-
707
- console.log(r.errors)
708
- console.dir(
709
- r.collected.map((v) => ({ path: v.path, value: v.value })),
710
- { depth: 10 }
711
- )
712
-
713
- console.info('---- doink 23 ------')
714
- r = await setWalker(schema, {
715
- $id: 'bl120',
716
- referencesToThings: { $remove: ['ti123'] },
717
- })
718
-
719
- console.log(r.errors)
720
- console.dir(
721
- r.collected.map((v) => ({ path: v.path, value: v.value })),
722
- { depth: 10 }
723
- )
724
-
725
- console.info('---- doink 24 ------')
726
- r = await setWalker(schema, {
727
- $id: 'bl120',
728
- referencesToThings: { $add: ['blbla', 'ti123', 'ewiohfdoweihfw'] },
729
- })
730
-
731
- console.log(r.errors)
732
- console.dir(
733
- r.collected.map((v) => ({ path: v.path, value: v.value })),
734
- { depth: 10 }
735
- )
736
-
737
- console.info('---- doink 25 ------')
738
- r = await setWalker(schema, {
739
- $id: 'bl120',
740
- referencesToThings: { $add: 'ti123' },
741
- })
742
-
743
- console.log(r.errors)
744
- console.dir(
745
- r.collected.map((v) => ({ path: v.path, value: v.value })),
746
- { depth: 10 }
747
- )
748
-
749
- console.info('---- doink 26 ------')
750
- r = await setWalker(schema, {
751
- $id: 'bl120',
752
- intarray: {
753
- $assign: {
754
- $idx: 0,
755
- $value: 6,
756
- },
757
- },
758
- })
759
-
760
- console.log(r.errors)
761
- console.dir(
762
- r.collected.map((v) => ({ path: v.path, value: v.value })),
763
- { depth: 10 }
764
- )
765
-
766
- console.info('---- doink 27 ------')
767
- r = await setWalker(schema, {
768
- $id: 'bl120',
769
- intarray: {
770
- $push: [1, 2, 3, 4, 5],
771
- },
772
- })
773
-
774
- console.log(r.errors)
775
- console.dir(
776
- r.collected.map((v) => ({ path: v.path, value: v.value })),
777
- { depth: 10 }
778
- )
779
-
780
- console.info('---- doink 28 ------')
781
- r = await setWalker(schema, {
782
- $id: 'bl120',
783
- intarray: {
784
- $unshift: [1, 2, 3, 4, 5],
785
- },
786
- })
787
-
788
- console.log(r.errors)
789
- console.dir(
790
- r.collected.map((v) => ({ path: v.path, value: v.value })),
791
- { depth: 10 }
792
- )
793
-
794
- console.info('---- doink 29 ------')
795
- r = await setWalker(schema, {
796
- $id: 'bl120',
797
- text: {
798
- en: 'bla',
799
- },
800
- })
801
-
802
- console.dir(
803
- r.collected.map((v) => ({ path: v.path, value: v.value })),
804
- { depth: 10 }
805
- )
806
-
807
- t.true(true)
808
-
809
- console.info('---- doink 30 ------')
810
- r = await setWalker(schema, {
811
- $id: 'bl120',
812
- text: {
813
- $delete: true,
814
- },
815
- })
816
-
817
- console.dir(
818
- r.collected.map((v) => ({ path: v.path, value: v.value })),
819
- { depth: 10 }
820
- )
821
-
822
- console.info('---- doink 31 ------')
823
- r = await setWalker(schema, {
824
- $id: 'bl120',
825
- $delete: true,
826
- })
827
-
828
- console.dir(r.errors)
829
- console.dir(
830
- r.collected.map((v) => ({ path: v.path, value: v.value })),
831
- { depth: 10 }
832
- )
833
-
834
- console.info('---- doink 32 ------')
835
- r = await setWalker(schema, {
836
- $id: 'bl120',
837
- $alias: 'bla',
838
- })
839
-
840
- console.dir(r.errors)
841
- console.dir(
842
- r.collected.map((v) => ({ path: v.path, value: v.value })),
843
- { depth: 10 }
844
- )
845
-
846
- console.info('---- doink 33 ------')
847
- r = await setWalker(schema, {
848
- $id: 'bl120',
849
- $alias: ['bla'],
850
- })
851
-
852
- console.dir(r.errors)
853
- console.dir(
854
- r.collected.map((v) => ({ path: v.path, value: v.value })),
855
- { depth: 10 }
856
- )
857
-
858
- console.info('---- doink 34 ------')
859
- r = await setWalker(schema, {
860
- $id: 'bl120',
861
- enum: 'tony',
862
- })
863
-
864
- console.dir(r.errors)
865
- console.dir(
866
- r.collected.map((v) => ({ path: v.path, value: v.value })),
867
- { depth: 10 }
868
- )
869
-
870
- console.info('---- doink 35 ------')
871
- r = await setWalker(schema, {
872
- $id: 'bl120',
873
- integer: NaN,
874
- })
875
-
876
- console.dir(r.errors)
877
- console.dir(
878
- r.collected.map((v) => ({ path: v.path, value: v.value })),
879
- { depth: 10 }
880
- )
881
-
882
- console.info('---- doink 36 ------')
883
- r = await setWalker(schema, {
884
- $id: 'bl120',
885
- integer: Infinity,
886
- })
887
-
888
- console.dir(r.errors)
889
- console.dir(
890
- r.collected.map((v) => ({ path: v.path, value: v.value })),
891
- { depth: 10 }
892
- )
893
-
894
- console.info('---- doink 37 ------')
895
- r = await setWalker(schema, {
896
- $id: 'bl120',
897
- integer: Infinity,
898
- })
899
-
900
- console.dir(r.errors)
901
- console.dir(
902
- r.collected.map((v) => ({ path: v.path, value: v.value })),
903
- { depth: 10 }
904
- )
905
-
906
- console.info('---- doink 38 ------')
907
- r = await setWalker(schema, {
908
- $id: 'bl120',
909
- integer: -Infinity,
910
- })
911
-
912
- console.dir(r.errors)
913
- console.dir(
914
- r.collected.map((v) => ({ path: v.path, value: v.value })),
915
- { depth: 10 }
916
- )
917
-
918
- console.info('---- doink 39 ------')
919
- r = await setWalker(
920
- schema,
921
- {
922
- $id: 'bl120',
923
- referencesToThings: [
924
- {
925
- type: 'thing',
926
- priority: 9000,
927
- },
928
- {
929
- type: 'thing',
930
- priority: 10000,
931
- },
932
- {
933
- type: 'flurp',
934
- priority: 10000,
935
- },
936
- ],
937
- },
938
- async (args, type) => {
939
- console.info('GO ASYNC', args.path, args.value, type)
940
- if (args.value.type === 'thing') {
941
- return 'ti' + Math.floor(Math.random() * 10000).toString(16)
942
- } else {
943
- return 'bl1221'
944
- }
945
- }
946
- )
947
-
948
- console.dir(r.errors)
949
- console.dir(
950
- r.collected.map((v) => ({ path: v.path, value: v.value })),
951
- { depth: 10 }
952
- )
953
-
954
- console.info('---- doink 40 array ------')
955
- r = await setWalker(schema, {
956
- $id: 'bl120',
957
- intarray: {
958
- $insert: {
959
- $idx: 10,
960
- $value: 1212,
961
- },
962
- },
963
- })
964
-
965
- console.dir(r.errors)
966
- console.dir(
967
- r.collected.map((v) => ({ path: v.path, value: v.value })),
968
- { depth: 10 }
969
- )
970
-
971
- console.info('---- doink 41 record + array ------')
972
- r = await setWalker(schema, {
973
- $id: 'bl120',
974
- record: {
975
- blabla: {
976
- bla: {
977
- $insert: {
978
- $value: { flap: 100 },
979
- $idx: 5,
980
- },
981
- },
982
- },
983
- },
984
- })
985
-
986
- console.dir(r.errors)
987
- console.dir(
988
- r.collected.map((v) => ({ path: v.path, value: v.value })),
989
- { depth: 10 }
990
- )
991
-
992
- console.info('---- doink 41 int unshift + array ------')
993
- r = await setWalker(schema, {
994
- $id: 'bl120',
995
- intarray: {
996
- $unshift: [-10, -20, -30],
997
- },
998
- })
999
-
1000
- console.dir(r.errors)
1001
- console.dir(
1002
- r.collected.map((v) => ({ path: v.path, value: v.value })),
1003
- { depth: 10 }
1004
- )
1005
-
1006
- console.info('---- doink 42 int unshift + array ------')
1007
- r = await setWalker(schema, {
1008
- $id: 'bl120',
1009
- intarray: {
1010
- $unshift: { $value: [-10, -20, -30] },
1011
- },
1012
- })
1013
-
1014
- console.dir(r.errors)
1015
- console.dir(
1016
- r.collected.map((v) => ({ path: v.path, value: v.value })),
1017
- { depth: 10 }
1018
- )
1019
-
1020
- console.info('---- doink 42 object ------')
1021
- r = await setWalker(schema, {
1022
- $id: 'bl120',
1023
- object: {
1024
- flap: true,
1025
- },
1026
- })
1027
-
1028
- console.dir(r.errors)
1029
- console.dir(
1030
- r.collected.map((v) => ({ path: v.path, value: v.value })),
1031
- { depth: 10 }
1032
- )
1033
-
1034
- console.info('---- doink 43 object ------')
1035
- r = await setWalker(schema, {
1036
- $id: 'bl120',
1037
- object: {},
1038
- })
1039
-
1040
- console.dir(r.errors)
1041
- console.dir(
1042
- r.collected.map((v) => ({ path: v.path, value: v.value })),
1043
- { depth: 10 }
1044
- )
1045
-
1046
- console.info('---- doink 44 reference ------')
1047
- r = await setWalker(
1048
- schema,
1049
- {
1050
- $id: parent,
1051
- type: 'match',
1052
- children: {
1053
- $add: [
1054
- {
1055
- type: 'match',
1056
- $alias: 'maTestWithAlias',
1057
- title: {
1058
- nl: 'yes with alias',
1059
- },
1060
- },
1061
- ],
1062
- },
1063
- },
1064
- async (args, type) => {
1065
- console.info('GO ASYNC', args.path, args.value, type)
1066
- if (args.value.type === 'thing') {
1067
- return 'ti' + Math.floor(Math.random() * 10000).toString(16)
1068
- } else {
1069
- return 'bl1221'
1070
- }
1071
- }
1072
- )
1073
-
1074
- console.dir(r.errors)
1075
- console.dir(
1076
- r.collected.map((v) => ({ path: v.path, value: v.value })),
1077
- { depth: 10 }
1078
- )
1079
-
1080
- t.true(true)
1081
- })