@ghostpaw/affinity 0.2.0 → 0.2.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/dist/index.cjs CHANGED
@@ -520,6 +520,7 @@ __export(read_exports, {
520
520
  getContactProfile: () => getContactProfile,
521
521
  getLinkDetail: () => getLinkDetail,
522
522
  getLinkTimeline: () => getLinkTimeline,
523
+ getLinksBetween: () => getLinksBetween,
523
524
  getMergeHistory: () => getMergeHistory,
524
525
  getOwnerProfile: () => getOwnerProfile,
525
526
  listContacts: () => listContacts,
@@ -2774,6 +2775,28 @@ function getLinkDetail(db, linkId, options) {
2774
2775
  };
2775
2776
  }
2776
2777
 
2778
+ // src/links/get_links_between.ts
2779
+ function getLinksBetween(db, contactId1, contactId2) {
2780
+ const rows = db.prepare(
2781
+ `SELECT id, from_contact_id, to_contact_id, kind, role, is_structural,
2782
+ rank, affinity, trust, state, cadence_days, bond,
2783
+ created_at, updated_at, removed_at
2784
+ FROM links
2785
+ WHERE removed_at IS NULL
2786
+ AND (
2787
+ (from_contact_id = ? AND to_contact_id = ?)
2788
+ OR (from_contact_id = ? AND to_contact_id = ?)
2789
+ )
2790
+ ORDER BY id ASC`
2791
+ ).all(
2792
+ contactId1,
2793
+ contactId2,
2794
+ contactId2,
2795
+ contactId1
2796
+ );
2797
+ return rows.map((r) => mapLinkRowToLinkListItem(r));
2798
+ }
2799
+
2777
2800
  // src/links/kinds.ts
2778
2801
  var RELATIONAL = /* @__PURE__ */ new Set([
2779
2802
  "personal",
@@ -3332,11 +3355,10 @@ function dedupeLiveLinks(db, now) {
3332
3355
  }
3333
3356
  return [...removed];
3334
3357
  }
3335
- function softDeleteSelfLoops(db, contactId, now) {
3358
+ function softDeleteSelfLoops(db, now) {
3336
3359
  const rows = db.prepare(
3337
- `SELECT id FROM links
3338
- WHERE removed_at IS NULL AND from_contact_id = to_contact_id AND from_contact_id = ?`
3339
- ).all(contactId);
3360
+ "SELECT id FROM links WHERE removed_at IS NULL AND from_contact_id = to_contact_id"
3361
+ ).all();
3340
3362
  const ids = [];
3341
3363
  for (const r of rows) {
3342
3364
  db.prepare(
@@ -3439,7 +3461,7 @@ function mergeContacts(db, input) {
3439
3461
  WHERE to_contact_id = ? AND removed_at IS NULL`
3440
3462
  ).run(winnerId, now, loserId);
3441
3463
  const affectedLinks = /* @__PURE__ */ new Set();
3442
- for (const id of softDeleteSelfLoops(db, winnerId, now)) {
3464
+ for (const id of softDeleteSelfLoops(db, now)) {
3443
3465
  affectedLinks.add(id);
3444
3466
  }
3445
3467
  for (const id of dedupeLiveLinks(db, now)) {
@@ -8509,6 +8531,11 @@ var affinityToolMappings = [
8509
8531
  tool: inspectAffinityItemToolName,
8510
8532
  action: "link"
8511
8533
  },
8534
+ {
8535
+ source: "getLinksBetween",
8536
+ tool: inspectAffinityItemToolName,
8537
+ action: "links_between"
8538
+ },
8512
8539
  {
8513
8540
  source: "listContacts",
8514
8541
  tool: reviewAffinityToolName,
package/dist/index.d.cts CHANGED
@@ -878,6 +878,12 @@ declare function getAffinityChart(db: AffinityDb, options?: AffinityChartReadOpt
878
878
 
879
879
  declare function getLinkDetail(db: AffinityDb, linkId: number, options?: LinkDetailReadOptions): LinkDetailRecord | null;
880
880
 
881
+ /**
882
+ * Returns all live links (both relational and structural) between two contacts,
883
+ * in either direction.
884
+ */
885
+ declare function getLinksBetween(db: AffinityDb, contactId1: number, contactId2: number): LinkListItem[];
886
+
881
887
  declare function getLinkTimeline(db: AffinityDb, linkId: number, options?: ContactJournalReadOptions): EventRecord[];
882
888
 
883
889
  declare function listObservedLinks(db: AffinityDb, filters?: LinkListReadFilters, options?: AffinityListReadOptions): LinkListItem[];
@@ -933,6 +939,7 @@ declare const read_getContactJournal: typeof getContactJournal;
933
939
  declare const read_getContactProfile: typeof getContactProfile;
934
940
  declare const read_getLinkDetail: typeof getLinkDetail;
935
941
  declare const read_getLinkTimeline: typeof getLinkTimeline;
942
+ declare const read_getLinksBetween: typeof getLinksBetween;
936
943
  declare const read_getMergeHistory: typeof getMergeHistory;
937
944
  declare const read_getOwnerProfile: typeof getOwnerProfile;
938
945
  declare const read_listContacts: typeof listContacts;
@@ -947,7 +954,7 @@ declare const read_listRadar: typeof listRadar;
947
954
  declare const read_listUpcomingDates: typeof listUpcomingDates;
948
955
  declare const read_searchContacts: typeof searchContacts;
949
956
  declare namespace read {
950
- export { read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts };
957
+ export { read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getLinksBetween as getLinksBetween, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts };
951
958
  }
952
959
 
953
960
  interface AffinitySoulTrait {
package/dist/index.d.ts CHANGED
@@ -878,6 +878,12 @@ declare function getAffinityChart(db: AffinityDb, options?: AffinityChartReadOpt
878
878
 
879
879
  declare function getLinkDetail(db: AffinityDb, linkId: number, options?: LinkDetailReadOptions): LinkDetailRecord | null;
880
880
 
881
+ /**
882
+ * Returns all live links (both relational and structural) between two contacts,
883
+ * in either direction.
884
+ */
885
+ declare function getLinksBetween(db: AffinityDb, contactId1: number, contactId2: number): LinkListItem[];
886
+
881
887
  declare function getLinkTimeline(db: AffinityDb, linkId: number, options?: ContactJournalReadOptions): EventRecord[];
882
888
 
883
889
  declare function listObservedLinks(db: AffinityDb, filters?: LinkListReadFilters, options?: AffinityListReadOptions): LinkListItem[];
@@ -933,6 +939,7 @@ declare const read_getContactJournal: typeof getContactJournal;
933
939
  declare const read_getContactProfile: typeof getContactProfile;
934
940
  declare const read_getLinkDetail: typeof getLinkDetail;
935
941
  declare const read_getLinkTimeline: typeof getLinkTimeline;
942
+ declare const read_getLinksBetween: typeof getLinksBetween;
936
943
  declare const read_getMergeHistory: typeof getMergeHistory;
937
944
  declare const read_getOwnerProfile: typeof getOwnerProfile;
938
945
  declare const read_listContacts: typeof listContacts;
@@ -947,7 +954,7 @@ declare const read_listRadar: typeof listRadar;
947
954
  declare const read_listUpcomingDates: typeof listUpcomingDates;
948
955
  declare const read_searchContacts: typeof searchContacts;
949
956
  declare namespace read {
950
- export { read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts };
957
+ export { read_getAffinityChart as getAffinityChart, read_getContactJournal as getContactJournal, read_getContactProfile as getContactProfile, read_getLinkDetail as getLinkDetail, read_getLinkTimeline as getLinkTimeline, read_getLinksBetween as getLinksBetween, read_getMergeHistory as getMergeHistory, read_getOwnerProfile as getOwnerProfile, read_listContacts as listContacts, read_listDismissedDuplicates as listDismissedDuplicates, read_listDuplicateCandidates as listDuplicateCandidates, read_listMoments as listMoments, read_listObservedLinks as listObservedLinks, read_listOpenCommitments as listOpenCommitments, read_listOwnerSocialLinks as listOwnerSocialLinks, read_listProgressionReadiness as listProgressionReadiness, read_listRadar as listRadar, read_listUpcomingDates as listUpcomingDates, read_searchContacts as searchContacts };
951
958
  }
952
959
 
953
960
  interface AffinitySoulTrait {
package/dist/index.js CHANGED
@@ -518,6 +518,7 @@ __export(read_exports, {
518
518
  getContactProfile: () => getContactProfile,
519
519
  getLinkDetail: () => getLinkDetail,
520
520
  getLinkTimeline: () => getLinkTimeline,
521
+ getLinksBetween: () => getLinksBetween,
521
522
  getMergeHistory: () => getMergeHistory,
522
523
  getOwnerProfile: () => getOwnerProfile,
523
524
  listContacts: () => listContacts,
@@ -2772,6 +2773,28 @@ function getLinkDetail(db, linkId, options) {
2772
2773
  };
2773
2774
  }
2774
2775
 
2776
+ // src/links/get_links_between.ts
2777
+ function getLinksBetween(db, contactId1, contactId2) {
2778
+ const rows = db.prepare(
2779
+ `SELECT id, from_contact_id, to_contact_id, kind, role, is_structural,
2780
+ rank, affinity, trust, state, cadence_days, bond,
2781
+ created_at, updated_at, removed_at
2782
+ FROM links
2783
+ WHERE removed_at IS NULL
2784
+ AND (
2785
+ (from_contact_id = ? AND to_contact_id = ?)
2786
+ OR (from_contact_id = ? AND to_contact_id = ?)
2787
+ )
2788
+ ORDER BY id ASC`
2789
+ ).all(
2790
+ contactId1,
2791
+ contactId2,
2792
+ contactId2,
2793
+ contactId1
2794
+ );
2795
+ return rows.map((r) => mapLinkRowToLinkListItem(r));
2796
+ }
2797
+
2775
2798
  // src/links/kinds.ts
2776
2799
  var RELATIONAL = /* @__PURE__ */ new Set([
2777
2800
  "personal",
@@ -3330,11 +3353,10 @@ function dedupeLiveLinks(db, now) {
3330
3353
  }
3331
3354
  return [...removed];
3332
3355
  }
3333
- function softDeleteSelfLoops(db, contactId, now) {
3356
+ function softDeleteSelfLoops(db, now) {
3334
3357
  const rows = db.prepare(
3335
- `SELECT id FROM links
3336
- WHERE removed_at IS NULL AND from_contact_id = to_contact_id AND from_contact_id = ?`
3337
- ).all(contactId);
3358
+ "SELECT id FROM links WHERE removed_at IS NULL AND from_contact_id = to_contact_id"
3359
+ ).all();
3338
3360
  const ids = [];
3339
3361
  for (const r of rows) {
3340
3362
  db.prepare(
@@ -3437,7 +3459,7 @@ function mergeContacts(db, input) {
3437
3459
  WHERE to_contact_id = ? AND removed_at IS NULL`
3438
3460
  ).run(winnerId, now, loserId);
3439
3461
  const affectedLinks = /* @__PURE__ */ new Set();
3440
- for (const id of softDeleteSelfLoops(db, winnerId, now)) {
3462
+ for (const id of softDeleteSelfLoops(db, now)) {
3441
3463
  affectedLinks.add(id);
3442
3464
  }
3443
3465
  for (const id of dedupeLiveLinks(db, now)) {
@@ -8507,6 +8529,11 @@ var affinityToolMappings = [
8507
8529
  tool: inspectAffinityItemToolName,
8508
8530
  action: "link"
8509
8531
  },
8532
+ {
8533
+ source: "getLinksBetween",
8534
+ tool: inspectAffinityItemToolName,
8535
+ action: "links_between"
8536
+ },
8510
8537
  {
8511
8538
  source: "listContacts",
8512
8539
  tool: reviewAffinityToolName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostpaw/affinity",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Relationship intelligence and social CRM model for Node.js — SQLite, zero dependencies, with a built-in LLM tool facade",
5
5
  "license": "MIT",
6
6
  "author": {