@chainlesschain/personal-data-hub 0.4.32 → 0.4.33

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.
@@ -65,15 +65,25 @@ function ingestPlaintextDb(Database, dbPath, app) {
65
65
  if (!parts.length) continue;
66
66
  const text = [...new Set(parts)].join(' · ').slice(0, 800);
67
67
  const occurredAt = timeCol ? normTime(row[timeCol]) : 0;
68
- const id = `${app}:${dbName}:${t}:` +
69
- crypto.createHash('md5').update(JSON.stringify(row)).digest('hex').slice(0, 12);
68
+ // Per-row hash → unique id AND unique source.originalId. A per-table
69
+ // originalId would collide on the vault's UNIQUE(source_adapter,
70
+ // source_original_id) and collapse every row of a table into one event.
71
+ const rowHash = crypto
72
+ .createHash('md5')
73
+ .update(JSON.stringify(row))
74
+ .digest('hex')
75
+ .slice(0, 12);
76
+ const id = `${app}:${dbName}:${t}:${rowHash}`;
70
77
  events.push({
71
- type: 'event', subtype: 'record',
78
+ // subtype must be a schema enum value; generic plaintext records →
79
+ // 'other' (the vault schema has no 'record' subtype).
80
+ type: 'event', subtype: 'other',
72
81
  id, occurredAt: occurredAt || Date.now(),
73
82
  content: { text },
74
83
  source: {
75
84
  adapter: `local-${app}`, adapterVersion: '0.1.0',
76
- originalId: `${dbName}:${t}`, capturedAt: occurredAt || Date.now(), capturedBy: 'sqlite',
85
+ originalId: `${dbName}:${t}:${rowHash}`,
86
+ capturedAt: occurredAt || Date.now(), capturedBy: 'sqlite',
77
87
  },
78
88
  topics: [`local-${app}`, `db-${dbName}`],
79
89
  ingestedAt: Date.now(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainlesschain/personal-data-hub",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "description": "Personal Data Hub — UnifiedSchema + validators + KG ingest helpers for the data-back-to-the-individual middleware",
5
5
  "type": "commonjs",
6
6
  "main": "lib/index.js",