@chainlesschain/personal-data-hub 0.3.8 → 0.4.0

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 (57) hide show
  1. package/__tests__/adapters/apple-health.test.js +95 -0
  2. package/__tests__/adapters/email-templates.test.js +123 -0
  3. package/__tests__/adapters/family-23-collectors-scaffold.test.js +178 -0
  4. package/__tests__/adapters/game-genshin-scaffold.test.js +107 -0
  5. package/__tests__/adapters/git-activity.test.js +7 -1
  6. package/__tests__/adapters/local-im-pc.test.js +149 -0
  7. package/__tests__/adapters/netease-music.test.js +74 -0
  8. package/__tests__/adapters/qq-pc-direct-read.test.js +186 -0
  9. package/__tests__/adapters/system-data-adapter.test.js +4 -1
  10. package/__tests__/adapters/wechat-pc-direct-read.test.js +207 -0
  11. package/__tests__/adapters/weread.test.js +123 -0
  12. package/__tests__/analysis.test.js +120 -15
  13. package/__tests__/mobile-extractor-encrypted.test.js +460 -0
  14. package/__tests__/prompt-builder.test.js +47 -2
  15. package/__tests__/registry-readiness.test.js +233 -0
  16. package/__tests__/social-douyin-im-direct-read.test.js +311 -0
  17. package/__tests__/social-douyin-snapshot.test.js +5 -2
  18. package/__tests__/vault.test.js +99 -0
  19. package/lib/adapter-guide.js +520 -0
  20. package/lib/adapter-readiness.js +257 -0
  21. package/lib/adapters/_local-im-db-reader.js +218 -0
  22. package/lib/adapters/_local-im-pc-adapter.js +162 -0
  23. package/lib/adapters/apple-health/index.js +329 -0
  24. package/lib/adapters/dingtalk-pc/index.js +29 -0
  25. package/lib/adapters/edu-huawei-learning/api-client.js +47 -0
  26. package/lib/adapters/edu-huawei-learning/index.js +255 -0
  27. package/lib/adapters/edu-zuoyebang/api-client.js +48 -0
  28. package/lib/adapters/edu-zuoyebang/index.js +259 -0
  29. package/lib/adapters/email-imap/email-adapter.js +16 -0
  30. package/lib/adapters/email-imap/templates/bill.js +174 -18
  31. package/lib/adapters/feishu-pc/index.js +29 -0
  32. package/lib/adapters/finance-alipay/api-client.js +48 -0
  33. package/lib/adapters/finance-alipay/index.js +257 -0
  34. package/lib/adapters/game-genshin/api-client.js +59 -0
  35. package/lib/adapters/game-genshin/index.js +274 -0
  36. package/lib/adapters/game-honor-of-kings/api-client.js +54 -0
  37. package/lib/adapters/game-honor-of-kings/index.js +259 -0
  38. package/lib/adapters/netease-music/index.js +227 -0
  39. package/lib/adapters/qq-pc/index.js +200 -0
  40. package/lib/adapters/qq-pc/nt-db-reader.js +210 -0
  41. package/lib/adapters/social-douyin/index.js +194 -1
  42. package/lib/adapters/wechat/wechat-adapter.js +7 -1
  43. package/lib/adapters/wechat-pc/index.js +335 -0
  44. package/lib/adapters/wechat-pc/pc-db-reader.js +327 -0
  45. package/lib/adapters/weread/api-client.js +128 -0
  46. package/lib/adapters/weread/index.js +337 -0
  47. package/lib/analysis.js +65 -0
  48. package/lib/index.js +39 -0
  49. package/lib/mobile-extractor/bplist.js +233 -0
  50. package/lib/mobile-extractor/ios-backup-crypto.js +315 -0
  51. package/lib/mobile-extractor/ios.js +131 -16
  52. package/lib/prompt-builder.js +19 -1
  53. package/lib/registry.js +170 -0
  54. package/lib/vault.js +105 -0
  55. package/package.json +1 -1
  56. package/scripts/run-native-tests-sandbox.sh +2 -0
  57. package/vitest.config.js +79 -1
package/vitest.config.js CHANGED
@@ -1,10 +1,88 @@
1
- import { defineConfig } from "vitest/config";
1
+ import { createRequire } from "node:module";
2
+ import { defineConfig, configDefaults } from "vitest/config";
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ /**
7
+ * Probe once at config load whether the native SQLCipher driver
8
+ * (better-sqlite3-multiple-ciphers / "bs3mc") loads on the *host* Node.
9
+ *
10
+ * Why this matters locally: the root node_modules bs3mc binding is built for
11
+ * Electron (NODE_MODULE_VERSION 140) and does NOT match a plain host Node
12
+ * (e.g. ABI 127). Any test that opens a LocalVault then throws an ABI-mismatch
13
+ * error at construction time, which surfaces as a cascade of ~228 cryptic
14
+ * red failures (most as `Cannot destructure property 'vault' of undefined`,
15
+ * because per-file setup helpers swallow the throw and return undefined).
16
+ *
17
+ * That noise drowns out any *real* regression locally. So: when the host
18
+ * binding doesn't load, we EXCLUDE the vault-dependent test files and print a
19
+ * banner pointing at the sandbox runner that installs a host-ABI bs3mc.
20
+ *
21
+ * CI is unaffected — it rebuilds node_modules fresh for the host Node, the
22
+ * probe succeeds, nothing is excluded, and the full suite runs.
23
+ *
24
+ * See: scripts/run-native-tests-sandbox.sh, memory `bs3mc_electron_abi_sandbox_workaround`.
25
+ */
26
+ function probeNativeVault() {
27
+ try {
28
+ const Database = require("better-sqlite3-multiple-ciphers");
29
+ const db = new Database(":memory:");
30
+ db.close();
31
+ return { available: true, reason: null };
32
+ } catch (err) {
33
+ return { available: false, reason: (err && err.message ? err.message : String(err)).split("\n")[0] };
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Tests that open a LocalVault (directly or transitively via registry /
39
+ * entity-resolver / analysis / e2e / integration pipelines). Empirically the
40
+ * exact set that fails when bs3mc can't load on the host. Skipped locally,
41
+ * always run in CI. Keep in sync if you add a new vault-touching test file.
42
+ */
43
+ const NATIVE_DEPENDENT_TESTS = [
44
+ "__tests__/vault.test.js",
45
+ "__tests__/vault-search.test.js",
46
+ "__tests__/registry.test.js",
47
+ "__tests__/analysis.test.js",
48
+ "__tests__/analysis-skills.test.js",
49
+ "__tests__/entity-resolver.test.js",
50
+ "__tests__/entity-resolver-stages.test.js",
51
+ "__tests__/entity-resolver-vault.test.js",
52
+ "__tests__/entity-resolver-ingest-hook.test.js",
53
+ "__tests__/e2e/full-user-journey.test.js",
54
+ "__tests__/e2e/ai-chat-cross-source-journey.test.js",
55
+ "__tests__/integration/cross-adapter-pipelines.test.js",
56
+ "__tests__/integration/ai-chat-history-registry.test.js",
57
+ "__tests__/integration/social-bilibili-pipeline.test.js",
58
+ "__tests__/integration/wechat-bootstrap-end-to-end.test.js",
59
+ ];
60
+
61
+ const native = probeNativeVault();
62
+ const exclude = [...configDefaults.exclude];
63
+
64
+ if (!native.available) {
65
+ exclude.push(...NATIVE_DEPENDENT_TESTS);
66
+ // eslint-disable-next-line no-console
67
+ console.warn(
68
+ [
69
+ "",
70
+ "⚠️ PDH: native SQLCipher driver (bs3mc) does not load on this host Node —",
71
+ " " + (native.reason || "unknown load failure"),
72
+ " Skipping " + NATIVE_DEPENDENT_TESTS.length + " vault-dependent test file(s) so the rest stay green.",
73
+ " For full native coverage run: bash scripts/run-native-tests-sandbox.sh",
74
+ " (CI rebuilds bs3mc for the host ABI and runs the full suite.)",
75
+ "",
76
+ ].join("\n"),
77
+ );
78
+ }
2
79
 
3
80
  export default defineConfig({
4
81
  test: {
5
82
  globals: false,
6
83
  environment: "node",
7
84
  include: ["__tests__/**/*.test.js"],
85
+ exclude,
8
86
  testTimeout: 10000,
9
87
  },
10
88
  });