@chainlesschain/personal-data-hub 0.2.2 → 0.2.4

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 (28) hide show
  1. package/__tests__/adapters/social-toutiao-kuaishou-scaffold.test.js +58 -16
  2. package/__tests__/analysis.test.js +1 -1
  3. package/__tests__/longtail-adapters.test.js +67 -16
  4. package/__tests__/messaging-qq-snapshot.test.js +294 -0
  5. package/__tests__/shopping-pinduoduo-snapshot.test.js +302 -0
  6. package/__tests__/shopping-snapshot.test.js +438 -0
  7. package/__tests__/social-adapters.test.js +28 -3
  8. package/__tests__/social-douyin-snapshot.test.js +253 -0
  9. package/__tests__/social-kuaishou-snapshot.test.js +309 -0
  10. package/__tests__/social-toutiao-snapshot.test.js +314 -0
  11. package/__tests__/social-weibo-snapshot.test.js +234 -0
  12. package/__tests__/social-xiaohongshu-snapshot.test.js +232 -0
  13. package/__tests__/travel-maps-snapshot.test.js +426 -0
  14. package/__tests__/vault-driver-error.test.js +74 -0
  15. package/lib/adapters/messaging-qq/index.js +498 -92
  16. package/lib/adapters/shopping-jd/index.js +228 -25
  17. package/lib/adapters/shopping-meituan/index.js +222 -26
  18. package/lib/adapters/shopping-pinduoduo/index.js +275 -0
  19. package/lib/adapters/social-douyin/index.js +454 -63
  20. package/lib/adapters/social-kuaishou/index.js +379 -127
  21. package/lib/adapters/social-toutiao/index.js +400 -130
  22. package/lib/adapters/social-weibo/index.js +393 -95
  23. package/lib/adapters/social-xiaohongshu/index.js +389 -49
  24. package/lib/adapters/travel-baidu-map/index.js +286 -26
  25. package/lib/adapters/travel-tencent-map/index.js +414 -0
  26. package/lib/index.js +5 -1
  27. package/lib/vault.js +60 -8
  28. package/package.json +2 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Unit tests for formatDriverLoadError — the pure error-translation helper
3
+ * sitting in front of `require("better-sqlite3-multiple-ciphers")`.
4
+ *
5
+ * Why this matters: bs3mc upstream only ships prebuilds for Node LTS ABIs
6
+ * (108/115/127). Running cc / PDH on Node 23/24/25 throws a cryptic
7
+ * "NODE_MODULE_VERSION X / requires NODE_MODULE_VERSION Y" stack that
8
+ * buries the real fix (use Node 22 LTS). This helper translates that into
9
+ * actionable Chinese guidance. See memory `node_23_native_dep_trap.md`.
10
+ */
11
+
12
+ "use strict";
13
+
14
+ import { describe, it, expect } from "vitest";
15
+
16
+ const {
17
+ _internal: { formatDriverLoadError },
18
+ } = require("../lib/vault");
19
+
20
+ describe("formatDriverLoadError", () => {
21
+ it("detects ABI mismatch and emits actionable Chinese guidance", () => {
22
+ const original = new Error(
23
+ "The module '\\\\?\\C:\\code\\chainlesschain\\node_modules\\better-sqlite3-multiple-ciphers\\build\\Release\\better_sqlite3.node'\n" +
24
+ "was compiled against a different Node.js version using\n" +
25
+ "NODE_MODULE_VERSION 140. This version of Node.js requires\n" +
26
+ "NODE_MODULE_VERSION 127. Please try re-compiling or re-installing\n" +
27
+ "the module (for instance, using `npm rebuild` or `npm install`).",
28
+ );
29
+ const wrapped = formatDriverLoadError(original, "v24.0.1");
30
+ expect(wrapped.code).toBe("BS3MC_ABI_MISMATCH");
31
+ expect(wrapped.cause).toBe(original);
32
+ expect(wrapped.message).toMatch(/Node v24\.0\.1 has ABI 127/);
33
+ expect(wrapped.message).toMatch(/bs3mc prebuild is ABI 140/);
34
+ expect(wrapped.message).toMatch(/切 Node 22 LTS/);
35
+ expect(wrapped.message).toMatch(/nvm install 22\.12\.0/);
36
+ expect(wrapped.message).toMatch(/npm rebuild better-sqlite3-multiple-ciphers/);
37
+ });
38
+
39
+ it("falls back to generic message when error is not ABI-related", () => {
40
+ const original = new Error("ENOENT: no such file or directory");
41
+ const wrapped = formatDriverLoadError(original, "v22.12.0");
42
+ expect(wrapped.code).toBeUndefined();
43
+ expect(wrapped.cause).toBe(original);
44
+ expect(wrapped.message).toMatch(/Failed to load better-sqlite3-multiple-ciphers/);
45
+ expect(wrapped.message).toMatch(/ENOENT: no such file or directory/);
46
+ });
47
+
48
+ it("handles non-Error throw values (string / null)", () => {
49
+ const wrapped1 = formatDriverLoadError("plain string", "v22.12.0");
50
+ expect(wrapped1.message).toMatch(/Original error: plain string/);
51
+
52
+ const wrapped2 = formatDriverLoadError(null, "v22.12.0");
53
+ expect(wrapped2.message).toMatch(/Original error: null/);
54
+ });
55
+
56
+ it("uses process.versions.node when nodeVer omitted", () => {
57
+ const original = new Error(
58
+ "NODE_MODULE_VERSION 200. requires NODE_MODULE_VERSION 127.",
59
+ );
60
+ const wrapped = formatDriverLoadError(original);
61
+ expect(wrapped.code).toBe("BS3MC_ABI_MISMATCH");
62
+ expect(wrapped.message).toContain(process.versions.node);
63
+ });
64
+
65
+ it("preserves ABI numbers from the original error message in the rewritten body", () => {
66
+ const original = new Error(
67
+ "NODE_MODULE_VERSION 137. requires NODE_MODULE_VERSION 131.",
68
+ );
69
+ const wrapped = formatDriverLoadError(original, "v23.7.0");
70
+ expect(wrapped.message).toContain("ABI 131");
71
+ expect(wrapped.message).toContain("ABI 137");
72
+ expect(wrapped.message).toContain("v23.7.0");
73
+ });
74
+ });