aifastdb 2.8.0 → 2.8.2
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/aifastdb.win32-x64-msvc.node +0 -0
- package/dist/connectme-adapter.d.ts +4 -5
- package/dist/connectme-adapter.d.ts.map +1 -1
- package/dist/connectme-adapter.js +2 -3
- package/dist/connectme-adapter.js.map +1 -1
- package/dist/family-tree.d.ts +3 -4
- package/dist/family-tree.d.ts.map +1 -1
- package/dist/family-tree.js +3 -4
- package/dist/family-tree.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +20 -5
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/social-graph-v2.d.ts +515 -1
- package/dist/social-graph-v2.d.ts.map +1 -1
- package/dist/social-graph-v2.js +675 -0
- package/dist/social-graph-v2.js.map +1 -1
- package/dist/types.d.ts +43 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -1
- package/dist/vibe-synapse.d.ts.map +1 -1
- package/dist/vibe-synapse.js +6 -0
- package/dist/vibe-synapse.js.map +1 -1
- package/package.json +3 -3
package/dist/social-graph-v2.js
CHANGED
|
@@ -119,6 +119,15 @@ class SocialGraphV2 {
|
|
|
119
119
|
maxElements: config.vectorSearch.maxElements,
|
|
120
120
|
shardCount: config.vectorSearch.shardCount,
|
|
121
121
|
} : undefined,
|
|
122
|
+
textSearch: config.textSearch ? {
|
|
123
|
+
enableChinese: config.textSearch.enableChinese,
|
|
124
|
+
userDictPath: config.textSearch.userDictPath,
|
|
125
|
+
synonymPath: config.textSearch.synonymPath,
|
|
126
|
+
customStopWordsPath: config.textSearch.customStopWordsPath,
|
|
127
|
+
enableStopWords: config.textSearch.enableStopWords,
|
|
128
|
+
enableStemmer: config.textSearch.enableStemmer,
|
|
129
|
+
autoCommit: config.textSearch.autoCommit,
|
|
130
|
+
} : undefined,
|
|
122
131
|
});
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
@@ -430,6 +439,538 @@ class SocialGraphV2 {
|
|
|
430
439
|
return this.native.removeBirthday(personId);
|
|
431
440
|
}
|
|
432
441
|
// ========================================================================
|
|
442
|
+
// Birthday Advanced Queries (Phase-114)
|
|
443
|
+
// ========================================================================
|
|
444
|
+
/**
|
|
445
|
+
* Find people with exact same birthday (same year-month-day)
|
|
446
|
+
*
|
|
447
|
+
* @param birthday - Birthday in YYYY-MM-DD format
|
|
448
|
+
* @returns Array of person entities with matching birthday
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const matches = social.findSameBirthdayExact('1990-03-15');
|
|
453
|
+
* console.log(`${matches.length} people born on 1990-03-15`);
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
findSameBirthdayExact(birthday) {
|
|
457
|
+
return this.native.findSameBirthdayExact(birthday);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Find people with same month-day birthday (different years allowed)
|
|
461
|
+
*
|
|
462
|
+
* @param birthday - Birthday in YYYY-MM-DD or MM-DD format
|
|
463
|
+
* @returns Array of person entities with matching month-day
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const matches = social.findSameBirthdayDayMonth('03-15');
|
|
468
|
+
* console.log(`${matches.length} people born on March 15th`);
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
findSameBirthdayDayMonth(birthday) {
|
|
472
|
+
return this.native.findSameBirthdayDayMonth(birthday);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Find people with same exact birthday as a given person
|
|
476
|
+
*
|
|
477
|
+
* @param personId - The person ID to match against
|
|
478
|
+
* @returns Array of person entities (excludes the person themselves)
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```typescript
|
|
482
|
+
* const twins = social.findSameBirthdayAsPersonExact(alice.id);
|
|
483
|
+
* console.log(`${twins.length} people share Alice's exact birthday`);
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
findSameBirthdayAsPersonExact(personId) {
|
|
487
|
+
return this.native.findSameBirthdayAsPersonExact(personId);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Find people with same month-day birthday as a given person (different years allowed)
|
|
491
|
+
*
|
|
492
|
+
* @param personId - The person ID to match against
|
|
493
|
+
* @returns Array of person entities (excludes the person themselves)
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
497
|
+
* const matches = social.findSameBirthdayAsPerson(alice.id);
|
|
498
|
+
* console.log(`${matches.length} people share Alice's birthday (any year)`);
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
findSameBirthdayAsPerson(personId) {
|
|
502
|
+
return this.native.findSameBirthdayAsPerson(personId);
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Recommend birthday matches for a person
|
|
506
|
+
*
|
|
507
|
+
* Returns matches sorted by priority: exact match (same year-month-day) > same month-day.
|
|
508
|
+
*
|
|
509
|
+
* @param personId - The person ID to find matches for
|
|
510
|
+
* @param limit - Maximum number of results (default: 10)
|
|
511
|
+
* @returns Array of birthday match results with match type
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* const matches = social.recommendBirthdayMatches(alice.id, 5);
|
|
516
|
+
* for (const m of matches) {
|
|
517
|
+
* console.log(`${m.person.name}: ${m.birthday} (${m.matchType})`);
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
recommendBirthdayMatches(personId, limit) {
|
|
522
|
+
return this.native.recommendBirthdayMatches(personId, limit);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Find people with birthdays in the next N days
|
|
526
|
+
*
|
|
527
|
+
* @param days - Number of days to look ahead
|
|
528
|
+
* @returns Array of birthday match results
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* const upcoming = social.findUpcomingBirthdays(7);
|
|
533
|
+
* console.log(`${upcoming.length} birthdays in the next week`);
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
findUpcomingBirthdays(days) {
|
|
537
|
+
return this.native.findUpcomingBirthdays(days);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Find people with birthdays today
|
|
541
|
+
*
|
|
542
|
+
* @returns Array of person entities whose birthday is today
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const todayBirthdays = social.findTodayBirthdays();
|
|
547
|
+
* for (const p of todayBirthdays) {
|
|
548
|
+
* console.log(`🎂 Happy birthday, ${p.name}!`);
|
|
549
|
+
* }
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
findTodayBirthdays() {
|
|
553
|
+
return this.native.findTodayBirthdays();
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Find people with birthdays in a specific month
|
|
557
|
+
*
|
|
558
|
+
* @param month - Month number (1-12)
|
|
559
|
+
* @returns Array of person entities born in that month
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```typescript
|
|
563
|
+
* const marchBirthdays = social.findBirthdaysInMonth(3);
|
|
564
|
+
* console.log(`${marchBirthdays.length} people have March birthdays`);
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
findBirthdaysInMonth(month) {
|
|
568
|
+
return this.native.findBirthdaysInMonth(month);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Get birthday statistics
|
|
572
|
+
*
|
|
573
|
+
* @returns Statistics object with total count, most common dates, and monthly distribution
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* const stats = social.getBirthdayStats();
|
|
578
|
+
* console.log(`Total with birthday: ${stats.totalWithBirthday}`);
|
|
579
|
+
* console.log('Most common dates:', stats.mostCommonDates);
|
|
580
|
+
* console.log('By month:', stats.byMonth);
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
getBirthdayStats() {
|
|
584
|
+
return this.native.getBirthdayStats();
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Check if two people have the same birthday
|
|
588
|
+
*
|
|
589
|
+
* @param personA - First person ID
|
|
590
|
+
* @param personB - Second person ID
|
|
591
|
+
* @param exact - If true, compare year+month+day; if false (default), compare month+day only
|
|
592
|
+
* @returns true if birthdays match
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* const sameDay = social.isSameBirthday(alice.id, bob.id); // month+day only
|
|
597
|
+
* const sameExact = social.isSameBirthday(alice.id, bob.id, true); // exact date
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
isSameBirthday(personA, personB, exact) {
|
|
601
|
+
return this.native.isSameBirthday(personA, personB, exact);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Rebuild birthday index from all person entities
|
|
605
|
+
*
|
|
606
|
+
* Useful after bulk imports or data recovery. Scans all persons
|
|
607
|
+
* and re-indexes their birthday properties.
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* // After bulk import of persons with birthday properties
|
|
612
|
+
* social.rebuildBirthdayIndex();
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
rebuildBirthdayIndex() {
|
|
616
|
+
this.native.rebuildBirthdayIndex();
|
|
617
|
+
}
|
|
618
|
+
// ========================================================================
|
|
619
|
+
// Family Tree — Core Relationship Management (Phase-115)
|
|
620
|
+
// ========================================================================
|
|
621
|
+
/**
|
|
622
|
+
* Add parent-child relationship.
|
|
623
|
+
* Automatically determines father/mother based on parent's gender property.
|
|
624
|
+
* @param parentId - The parent's entity ID
|
|
625
|
+
* @param childId - The child's entity ID
|
|
626
|
+
* @returns The created relation, or null if failed
|
|
627
|
+
*/
|
|
628
|
+
addParentChild(parentId, childId) {
|
|
629
|
+
return this.native.addParentChild(parentId, childId) ?? null;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Add spouse relationship (bidirectional).
|
|
633
|
+
* @param personA - First person's ID
|
|
634
|
+
* @param personB - Second person's ID
|
|
635
|
+
*/
|
|
636
|
+
addSpouse(personA, personB) {
|
|
637
|
+
return this.native.addSpouse(personA, personB) ?? null;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Add sibling relationship (bidirectional).
|
|
641
|
+
* @param personA - First person's ID
|
|
642
|
+
* @param personB - Second person's ID
|
|
643
|
+
* @param halfSibling - Whether this is a half-sibling relationship (default: false)
|
|
644
|
+
*/
|
|
645
|
+
addSibling(personA, personB, halfSibling = false) {
|
|
646
|
+
return this.native.addSibling(personA, personB, halfSibling) ?? null;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Remove family relationship between two people.
|
|
650
|
+
* @returns True if any relationship was removed
|
|
651
|
+
*/
|
|
652
|
+
removeFamilyRelation(personA, personB) {
|
|
653
|
+
return this.native.removeFamilyRelation(personA, personB);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Add step-parent to step-child relationship (继父母-继子女).
|
|
657
|
+
*/
|
|
658
|
+
addStepParentChild(stepParentId, stepChildId) {
|
|
659
|
+
return this.native.addStepParentChild(stepParentId, stepChildId) ?? null;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Add adoptive parent to adopted child relationship (养父母-养子女).
|
|
663
|
+
*/
|
|
664
|
+
addAdoptiveParentChild(adoptiveParentId, adoptedChildId) {
|
|
665
|
+
return this.native.addAdoptiveParentChild(adoptiveParentId, adoptedChildId) ?? null;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Add ex-spouse relationship (前配偶).
|
|
669
|
+
*/
|
|
670
|
+
addExSpouse(personA, personB) {
|
|
671
|
+
return this.native.addExSpouse(personA, personB) ?? null;
|
|
672
|
+
}
|
|
673
|
+
// ========================================================================
|
|
674
|
+
// Family Tree — Direct Family Queries (Phase-115)
|
|
675
|
+
// ========================================================================
|
|
676
|
+
/** Get parents of a person */
|
|
677
|
+
getParents(personId) {
|
|
678
|
+
return this.native.getParents(personId);
|
|
679
|
+
}
|
|
680
|
+
/** Get father of a person */
|
|
681
|
+
getFather(personId) {
|
|
682
|
+
return this.native.getFather(personId) ?? null;
|
|
683
|
+
}
|
|
684
|
+
/** Get mother of a person */
|
|
685
|
+
getMother(personId) {
|
|
686
|
+
return this.native.getMother(personId) ?? null;
|
|
687
|
+
}
|
|
688
|
+
/** Get children of a person */
|
|
689
|
+
getChildren(personId) {
|
|
690
|
+
return this.native.getChildren(personId);
|
|
691
|
+
}
|
|
692
|
+
/** Get sons of a person */
|
|
693
|
+
getSons(personId) {
|
|
694
|
+
return this.native.getSons(personId);
|
|
695
|
+
}
|
|
696
|
+
/** Get daughters of a person */
|
|
697
|
+
getDaughters(personId) {
|
|
698
|
+
return this.native.getDaughters(personId);
|
|
699
|
+
}
|
|
700
|
+
/** Get current spouse of a person */
|
|
701
|
+
getSpouse(personId) {
|
|
702
|
+
return this.native.getSpouse(personId) ?? null;
|
|
703
|
+
}
|
|
704
|
+
/** Get all spouses including ex-spouses, with isEx flag */
|
|
705
|
+
getAllSpouses(personId) {
|
|
706
|
+
return this.native.getAllSpouses(personId);
|
|
707
|
+
}
|
|
708
|
+
// ========================================================================
|
|
709
|
+
// Family Tree — Step/Adoptive Family Queries (Phase-115)
|
|
710
|
+
// ========================================================================
|
|
711
|
+
/** Get step-parents (继父母) */
|
|
712
|
+
getStepParents(personId) {
|
|
713
|
+
return this.native.getStepParents(personId);
|
|
714
|
+
}
|
|
715
|
+
/** Get step-father (继父) */
|
|
716
|
+
getStepFather(personId) {
|
|
717
|
+
return this.native.getStepFather(personId) ?? null;
|
|
718
|
+
}
|
|
719
|
+
/** Get step-mother (继母) */
|
|
720
|
+
getStepMother(personId) {
|
|
721
|
+
return this.native.getStepMother(personId) ?? null;
|
|
722
|
+
}
|
|
723
|
+
/** Get step-children (继子女) */
|
|
724
|
+
getStepChildren(personId) {
|
|
725
|
+
return this.native.getStepChildren(personId);
|
|
726
|
+
}
|
|
727
|
+
/** Get adoptive parents (养父母) */
|
|
728
|
+
getAdoptiveParents(personId) {
|
|
729
|
+
return this.native.getAdoptiveParents(personId);
|
|
730
|
+
}
|
|
731
|
+
/** Get adoptive father (养父) */
|
|
732
|
+
getAdoptiveFather(personId) {
|
|
733
|
+
return this.native.getAdoptiveFather(personId) ?? null;
|
|
734
|
+
}
|
|
735
|
+
/** Get adoptive mother (养母) */
|
|
736
|
+
getAdoptiveMother(personId) {
|
|
737
|
+
return this.native.getAdoptiveMother(personId) ?? null;
|
|
738
|
+
}
|
|
739
|
+
/** Get adopted children (养子女) */
|
|
740
|
+
getAdoptedChildren(personId) {
|
|
741
|
+
return this.native.getAdoptedChildren(personId);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Get all parents with type (biological/step/adoptive).
|
|
745
|
+
* @returns Array of { person, type } objects
|
|
746
|
+
*/
|
|
747
|
+
getAllParentsWithType(personId) {
|
|
748
|
+
return this.native.getAllParentsWithType(personId);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Get all children with type (biological/step/adopted).
|
|
752
|
+
* @returns Array of { person, type } objects
|
|
753
|
+
*/
|
|
754
|
+
getAllChildrenWithType(personId) {
|
|
755
|
+
return this.native.getAllChildrenWithType(personId);
|
|
756
|
+
}
|
|
757
|
+
/** Get siblings */
|
|
758
|
+
getSiblings(personId) {
|
|
759
|
+
return this.native.getSiblings(personId);
|
|
760
|
+
}
|
|
761
|
+
/** Get brothers */
|
|
762
|
+
getBrothers(personId) {
|
|
763
|
+
return this.native.getBrothers(personId);
|
|
764
|
+
}
|
|
765
|
+
/** Get sisters */
|
|
766
|
+
getSisters(personId) {
|
|
767
|
+
return this.native.getSisters(personId);
|
|
768
|
+
}
|
|
769
|
+
// ========================================================================
|
|
770
|
+
// Family Tree — Extended Family Queries (Phase-115)
|
|
771
|
+
// ========================================================================
|
|
772
|
+
/**
|
|
773
|
+
* Get all ancestors (traversing upward).
|
|
774
|
+
* @param maxGenerations - Maximum generations to traverse (default: 10)
|
|
775
|
+
*/
|
|
776
|
+
getAncestors(personId, maxGenerations) {
|
|
777
|
+
return this.native.getAncestors(personId, maxGenerations);
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Get all descendants (traversing downward).
|
|
781
|
+
* @param maxGenerations - Maximum generations to traverse (default: 10)
|
|
782
|
+
*/
|
|
783
|
+
getDescendants(personId, maxGenerations) {
|
|
784
|
+
return this.native.getDescendants(personId, maxGenerations);
|
|
785
|
+
}
|
|
786
|
+
/** Get grandparents */
|
|
787
|
+
getGrandparents(personId) {
|
|
788
|
+
return this.native.getGrandparents(personId);
|
|
789
|
+
}
|
|
790
|
+
/** Get paternal grandfather (爷爷) */
|
|
791
|
+
getPaternalGrandfather(personId) {
|
|
792
|
+
return this.native.getPaternalGrandfather(personId) ?? null;
|
|
793
|
+
}
|
|
794
|
+
/** Get paternal grandmother (奶奶) */
|
|
795
|
+
getPaternalGrandmother(personId) {
|
|
796
|
+
return this.native.getPaternalGrandmother(personId) ?? null;
|
|
797
|
+
}
|
|
798
|
+
/** Get maternal grandfather (外公/姥爷) */
|
|
799
|
+
getMaternalGrandfather(personId) {
|
|
800
|
+
return this.native.getMaternalGrandfather(personId) ?? null;
|
|
801
|
+
}
|
|
802
|
+
/** Get maternal grandmother (外婆/姥姥) */
|
|
803
|
+
getMaternalGrandmother(personId) {
|
|
804
|
+
return this.native.getMaternalGrandmother(personId) ?? null;
|
|
805
|
+
}
|
|
806
|
+
/** Get grandchildren */
|
|
807
|
+
getGrandchildren(personId) {
|
|
808
|
+
return this.native.getGrandchildren(personId);
|
|
809
|
+
}
|
|
810
|
+
/** Get uncles and aunts (叔伯姑姨舅) */
|
|
811
|
+
getUnclesAunts(personId) {
|
|
812
|
+
return this.native.getUnclesAunts(personId);
|
|
813
|
+
}
|
|
814
|
+
/** Get paternal uncles (叔叔/伯伯) */
|
|
815
|
+
getPaternalUncles(personId) {
|
|
816
|
+
return this.native.getPaternalUncles(personId);
|
|
817
|
+
}
|
|
818
|
+
/** Get paternal aunts (姑姑) */
|
|
819
|
+
getPaternalAunts(personId) {
|
|
820
|
+
return this.native.getPaternalAunts(personId);
|
|
821
|
+
}
|
|
822
|
+
/** Get maternal uncles (舅舅) */
|
|
823
|
+
getMaternalUncles(personId) {
|
|
824
|
+
return this.native.getMaternalUncles(personId);
|
|
825
|
+
}
|
|
826
|
+
/** Get maternal aunts (姨妈) */
|
|
827
|
+
getMaternalAunts(personId) {
|
|
828
|
+
return this.native.getMaternalAunts(personId);
|
|
829
|
+
}
|
|
830
|
+
/** Get nephews and nieces (侄子/侄女/外甥/外甥女) */
|
|
831
|
+
getNephewsNieces(personId) {
|
|
832
|
+
return this.native.getNephewsNieces(personId);
|
|
833
|
+
}
|
|
834
|
+
/** Get cousins (堂/表兄弟姐妹) */
|
|
835
|
+
getCousins(personId) {
|
|
836
|
+
return this.native.getCousins(personId);
|
|
837
|
+
}
|
|
838
|
+
/** Get paternal cousins (堂兄弟姐妹) */
|
|
839
|
+
getPaternalCousins(personId) {
|
|
840
|
+
return this.native.getPaternalCousins(personId);
|
|
841
|
+
}
|
|
842
|
+
/** Get maternal cousins (表兄弟姐妹) */
|
|
843
|
+
getMaternalCousins(personId) {
|
|
844
|
+
return this.native.getMaternalCousins(personId);
|
|
845
|
+
}
|
|
846
|
+
// ========================================================================
|
|
847
|
+
// Family Tree — In-law Queries (Phase-115)
|
|
848
|
+
// ========================================================================
|
|
849
|
+
/** Get father-in-law (公公/岳父) */
|
|
850
|
+
getFatherInLaw(personId) {
|
|
851
|
+
return this.native.getFatherInLaw(personId) ?? null;
|
|
852
|
+
}
|
|
853
|
+
/** Get mother-in-law (婆婆/岳母) */
|
|
854
|
+
getMotherInLaw(personId) {
|
|
855
|
+
return this.native.getMotherInLaw(personId) ?? null;
|
|
856
|
+
}
|
|
857
|
+
/** Get siblings-in-law */
|
|
858
|
+
getSiblingsInLaw(personId) {
|
|
859
|
+
return this.native.getSiblingsInLaw(personId);
|
|
860
|
+
}
|
|
861
|
+
/** Get children-in-law (儿媳/女婿) */
|
|
862
|
+
getChildrenInLaw(personId) {
|
|
863
|
+
return this.native.getChildrenInLaw(personId);
|
|
864
|
+
}
|
|
865
|
+
// ========================================================================
|
|
866
|
+
// Family Tree — Relationship Calculation (Phase-115)
|
|
867
|
+
// ========================================================================
|
|
868
|
+
/**
|
|
869
|
+
* Calculate the family relationship between two people.
|
|
870
|
+
* Returns the full path including Chinese relationship title,
|
|
871
|
+
* generation difference, and blood distance.
|
|
872
|
+
* @param fromId - Starting person's ID
|
|
873
|
+
* @param toId - Ending person's ID
|
|
874
|
+
*/
|
|
875
|
+
calculateFamilyRelationship(fromId, toId) {
|
|
876
|
+
return this.native.calculateFamilyRelationship(fromId, toId) ?? null;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Get the Chinese relationship title between two people.
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* const title = social.getRelationshipTitle(child.id, father.id);
|
|
883
|
+
* // Returns: "父亲"
|
|
884
|
+
* ```
|
|
885
|
+
*/
|
|
886
|
+
getRelationshipTitle(fromId, toId) {
|
|
887
|
+
return this.native.getRelationshipTitle(fromId, toId) ?? null;
|
|
888
|
+
}
|
|
889
|
+
/** Find the closest common ancestor of two people */
|
|
890
|
+
findCommonAncestor(personA, personB) {
|
|
891
|
+
return this.native.findCommonAncestor(personA, personB) ?? null;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Calculate the blood distance between two people.
|
|
895
|
+
* Blood distance = number of parent-child links through common ancestor.
|
|
896
|
+
*/
|
|
897
|
+
calculateBloodDistance(personA, personB) {
|
|
898
|
+
return this.native.calculateBloodDistance(personA, personB) ?? null;
|
|
899
|
+
}
|
|
900
|
+
/** Check if two people are direct blood relatives (ancestor/descendant) */
|
|
901
|
+
isDirectBloodRelative(personA, personB) {
|
|
902
|
+
return this.native.isDirectBloodRelative(personA, personB);
|
|
903
|
+
}
|
|
904
|
+
// ========================================================================
|
|
905
|
+
// Family Tree — Tree Construction (Phase-115)
|
|
906
|
+
// ========================================================================
|
|
907
|
+
/**
|
|
908
|
+
* Build a family tree centered on a person.
|
|
909
|
+
* @param personId - Center person's ID
|
|
910
|
+
* @param generationsUp - Generations to traverse upward (default: 3)
|
|
911
|
+
* @param generationsDown - Generations to traverse downward (default: 3)
|
|
912
|
+
*/
|
|
913
|
+
buildFamilyTree(personId, generationsUp, generationsDown) {
|
|
914
|
+
return this.native.buildFamilyTree(personId, generationsUp, generationsDown) ?? null;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Get generation number of a person relative to a root.
|
|
918
|
+
* 0 = same as root, positive = younger, negative = older.
|
|
919
|
+
*/
|
|
920
|
+
getGeneration(personId, rootId) {
|
|
921
|
+
return this.native.getGeneration(personId, rootId) ?? null;
|
|
922
|
+
}
|
|
923
|
+
/** Get all people in the same generation (siblings, cousins, spouse) */
|
|
924
|
+
getSameGeneration(personId) {
|
|
925
|
+
return this.native.getSameGeneration(personId);
|
|
926
|
+
}
|
|
927
|
+
// ========================================================================
|
|
928
|
+
// Family Tree — Lineage Queries (Phase-115)
|
|
929
|
+
// ========================================================================
|
|
930
|
+
/**
|
|
931
|
+
* Get paternal lineage (父系血统): father → grandfather → great-grandfather → ...
|
|
932
|
+
* @param maxGenerations - Maximum generations to trace (default: 10)
|
|
933
|
+
*/
|
|
934
|
+
getPaternalLineage(personId, maxGenerations) {
|
|
935
|
+
return this.native.getPaternalLineage(personId, maxGenerations);
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Get maternal lineage (母系血统): mother → grandmother → great-grandmother → ...
|
|
939
|
+
* @param maxGenerations - Maximum generations to trace (default: 10)
|
|
940
|
+
*/
|
|
941
|
+
getMaternalLineage(personId, maxGenerations) {
|
|
942
|
+
return this.native.getMaternalLineage(personId, maxGenerations);
|
|
943
|
+
}
|
|
944
|
+
/** Get same surname relatives (同姓族人) */
|
|
945
|
+
getSameSurnameRelatives(personId) {
|
|
946
|
+
return this.native.getSameSurnameRelatives(personId);
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Get paternal clan members (父系宗族成员).
|
|
950
|
+
* Traditional Chinese "宗族" — all connected through paternal line.
|
|
951
|
+
* @param maxGenerations - Maximum generations to include (default: 5)
|
|
952
|
+
*/
|
|
953
|
+
getPaternalClan(personId, maxGenerations) {
|
|
954
|
+
return this.native.getPaternalClan(personId, maxGenerations);
|
|
955
|
+
}
|
|
956
|
+
// ========================================================================
|
|
957
|
+
// Family Tree — Statistics & Gender (Phase-115)
|
|
958
|
+
// ========================================================================
|
|
959
|
+
/**
|
|
960
|
+
* Get family statistics for a tree rooted at the given person.
|
|
961
|
+
* @returns { total_members, total_generations, male_count, female_count, ... }
|
|
962
|
+
*/
|
|
963
|
+
getFamilyStats(rootId) {
|
|
964
|
+
return this.native.getFamilyStats(rootId) ?? null;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Set the gender of a person.
|
|
968
|
+
* @param gender - 'male', 'female', or 'unknown'
|
|
969
|
+
*/
|
|
970
|
+
setPersonGender(personId, gender) {
|
|
971
|
+
return this.native.setPersonGender(personId, gender);
|
|
972
|
+
}
|
|
973
|
+
// ========================================================================
|
|
433
974
|
// Generic Entity Operations
|
|
434
975
|
// ========================================================================
|
|
435
976
|
/**
|
|
@@ -1361,6 +1902,140 @@ class SocialGraphV2 {
|
|
|
1361
1902
|
hybridSearch(embedding, textQuery, k, entityTypeFilter) {
|
|
1362
1903
|
return this.native.hybridSearch(embedding, textQuery, k, entityTypeFilter);
|
|
1363
1904
|
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Get the embedding dimension used by the HNSW index.
|
|
1907
|
+
* Returns null if vector search is not enabled.
|
|
1908
|
+
*/
|
|
1909
|
+
vectorDimension() {
|
|
1910
|
+
return this.native.vectorDimension() ?? null;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Get the current embedding model identifier (Phase-110).
|
|
1914
|
+
* Returns the model ID (e.g., "all-MiniLM-L6-v2") or null if not set.
|
|
1915
|
+
*/
|
|
1916
|
+
vectorModelId() {
|
|
1917
|
+
return this.native.vectorModelId() ?? null;
|
|
1918
|
+
}
|
|
1919
|
+
// ========================================================================
|
|
1920
|
+
// Phase-111: Full-Text Search (Tantivy BM25)
|
|
1921
|
+
// ========================================================================
|
|
1922
|
+
/**
|
|
1923
|
+
* Check if full-text search (Tantivy) is enabled on this store.
|
|
1924
|
+
*/
|
|
1925
|
+
hasTextSearch() {
|
|
1926
|
+
return this.native.hasTextSearch();
|
|
1927
|
+
}
|
|
1928
|
+
/**
|
|
1929
|
+
* Get the number of documents in the Tantivy index.
|
|
1930
|
+
* Returns null if text search is not enabled.
|
|
1931
|
+
*/
|
|
1932
|
+
textSearchDocCount() {
|
|
1933
|
+
return this.native.textSearchDocCount() ?? null;
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Full-text search on entity content using Tantivy BM25.
|
|
1937
|
+
*
|
|
1938
|
+
* Searches entity name, content property, and other indexed string properties.
|
|
1939
|
+
* Supports both Chinese (jieba-rs) and English tokenization.
|
|
1940
|
+
*
|
|
1941
|
+
* @param query - Search query text (supports Chinese and English)
|
|
1942
|
+
* @param entityTypeFilter - Optional: only return entities of this type
|
|
1943
|
+
* @param topK - Number of results to return (default: 10)
|
|
1944
|
+
* @returns Array of TextSearchHit sorted by BM25 score
|
|
1945
|
+
*
|
|
1946
|
+
* @example
|
|
1947
|
+
* ```typescript
|
|
1948
|
+
* const results = social.searchEntitiesByText('社交图谱', 'document', 20);
|
|
1949
|
+
* for (const hit of results) {
|
|
1950
|
+
* console.log(`${hit.entityId}: score=${hit.score}, snippet=${hit.snippet}`);
|
|
1951
|
+
* }
|
|
1952
|
+
* ```
|
|
1953
|
+
*/
|
|
1954
|
+
searchEntitiesByText(query, entityTypeFilter, topK) {
|
|
1955
|
+
return this.native.searchEntitiesByText(query, entityTypeFilter, topK);
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Hybrid search combining vector similarity (HNSW) + full-text (Tantivy BM25)
|
|
1959
|
+
* with Reciprocal Rank Fusion (RRF).
|
|
1960
|
+
*
|
|
1961
|
+
* This method differs from `hybridSearch` by using Tantivy (BM25 + jieba)
|
|
1962
|
+
* for the text component instead of simple substring matching on entity attributes.
|
|
1963
|
+
*
|
|
1964
|
+
* @param embedding - Optional query vector (pass null for text-only search)
|
|
1965
|
+
* @param textQuery - Optional BM25 search text (pass null for vector-only search)
|
|
1966
|
+
* @param entityTypeFilter - Optional: filter by entity type
|
|
1967
|
+
* @param topK - Number of results to return (default: 10)
|
|
1968
|
+
* @param rrfK - RRF constant (default: 60.0, higher = less weight to rank position)
|
|
1969
|
+
* @returns Array of VectorSearchHit sorted by fused RRF score
|
|
1970
|
+
*
|
|
1971
|
+
* @example
|
|
1972
|
+
* ```typescript
|
|
1973
|
+
* // Vector + BM25 hybrid
|
|
1974
|
+
* const results = social.hybridSearchTantivy(queryVec, '记忆树搜索', 'document', 10);
|
|
1975
|
+
*
|
|
1976
|
+
* // Text-only via Tantivy BM25 (pass null for embedding)
|
|
1977
|
+
* const textResults = social.hybridSearchTantivy(null, '架构决策', undefined, 10);
|
|
1978
|
+
*
|
|
1979
|
+
* // Vector-only (pass null for textQuery)
|
|
1980
|
+
* const vecResults = social.hybridSearchTantivy(queryVec, null, undefined, 10);
|
|
1981
|
+
* ```
|
|
1982
|
+
*/
|
|
1983
|
+
hybridSearchTantivy(embedding, textQuery, entityTypeFilter, topK, rrfK) {
|
|
1984
|
+
return this.native.hybridSearchTantivy(embedding ?? undefined, textQuery ?? undefined, entityTypeFilter, topK, rrfK);
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Manually commit the Tantivy text index.
|
|
1988
|
+
* Only needed when `autoCommit` is disabled in TextSearchConfig.
|
|
1989
|
+
*/
|
|
1990
|
+
textSearchCommit() {
|
|
1991
|
+
this.native.textSearchCommit();
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Hot-reload user dictionary for jieba Chinese tokenizer.
|
|
1995
|
+
*
|
|
1996
|
+
* Loads a new custom dictionary without restarting.
|
|
1997
|
+
* File format: one entry per line — `词语 词频 词性` (e.g., `SocialGraphV2 5 n`)
|
|
1998
|
+
*
|
|
1999
|
+
* @param dictPath - Path to the user dictionary file
|
|
2000
|
+
*/
|
|
2001
|
+
reloadUserDict(dictPath) {
|
|
2002
|
+
this.native.reloadUserDict(dictPath);
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Hot-reload synonym map for query expansion.
|
|
2006
|
+
*
|
|
2007
|
+
* JSON format: `{ "entries": [{ "term": "数据库", "synonyms": ["DB"], "bidirectional": true }] }`
|
|
2008
|
+
*
|
|
2009
|
+
* @param synonymPath - Path to the synonym map JSON file
|
|
2010
|
+
* @returns Number of synonym entries loaded
|
|
2011
|
+
*/
|
|
2012
|
+
reloadSynonyms(synonymPath) {
|
|
2013
|
+
return this.native.reloadSynonyms(synonymPath);
|
|
2014
|
+
}
|
|
2015
|
+
// ========================================================================
|
|
2016
|
+
// Phase-97: Entity Type Queries
|
|
2017
|
+
// ========================================================================
|
|
2018
|
+
/**
|
|
2019
|
+
* Get all unique entity types in the graph.
|
|
2020
|
+
*
|
|
2021
|
+
* @example
|
|
2022
|
+
* ```typescript
|
|
2023
|
+
* const types = social.getEntityTypes();
|
|
2024
|
+
* // ["person", "tag", "article", "category", ...]
|
|
2025
|
+
* ```
|
|
2026
|
+
*/
|
|
2027
|
+
getEntityTypes() {
|
|
2028
|
+
return this.native.getEntityTypes();
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* Count entities by type (optimized — reads index only, no entity loading).
|
|
2032
|
+
*
|
|
2033
|
+
* @param entityType - Entity type to count
|
|
2034
|
+
* @returns Number of entities of the given type
|
|
2035
|
+
*/
|
|
2036
|
+
countEntitiesByType(entityType) {
|
|
2037
|
+
return this.native.countEntitiesByType(entityType);
|
|
2038
|
+
}
|
|
1364
2039
|
// ========================================================================
|
|
1365
2040
|
// Phase-107: Graph Traversal, Mutations & DynamicNode
|
|
1366
2041
|
// ========================================================================
|