@symbiosis-lab/moss-plugin-matters 1.4.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +18 -0
  3. package/assets/icon.svg +1 -0
  4. package/assets/manifest.json +36 -0
  5. package/codegen.ts +26 -0
  6. package/e2e/moss-cli.test.ts +338 -0
  7. package/features/api/fetch-articles.feature +39 -0
  8. package/features/auth/wallet-auth.feature +27 -0
  9. package/features/download/retry-logic.feature +36 -0
  10. package/features/download/self-correcting.feature +83 -0
  11. package/features/download/worker-pool.feature +29 -0
  12. package/features/social/fetch-social-data.feature +40 -0
  13. package/features/steps/api.steps.ts +180 -0
  14. package/features/steps/download.steps.ts +423 -0
  15. package/features/steps/incremental-sync.steps.ts +105 -0
  16. package/features/steps/self-correcting.steps.ts +575 -0
  17. package/features/steps/social.steps.ts +257 -0
  18. package/features/steps/syndication.steps.ts +264 -0
  19. package/features/steps/wallet-auth.steps.ts +185 -0
  20. package/features/sync/article-sync.feature +49 -0
  21. package/features/sync/homepage-grid.feature +43 -0
  22. package/features/sync/incremental-sync.feature +28 -0
  23. package/features/syndication/create-draft.feature +35 -0
  24. package/package.json +58 -0
  25. package/src/__generated__/schema.graphql +4289 -0
  26. package/src/__generated__/types.ts +5355 -0
  27. package/src/__tests__/api.test.ts +678 -0
  28. package/src/__tests__/auth-route.test.ts +38 -0
  29. package/src/__tests__/auth-routing.test.ts +462 -0
  30. package/src/__tests__/auto-detect.test.ts +412 -0
  31. package/src/__tests__/binding-guard.test.ts +256 -0
  32. package/src/__tests__/config.test.ts +212 -0
  33. package/src/__tests__/converter.test.ts +289 -0
  34. package/src/__tests__/credential.test.ts +332 -0
  35. package/src/__tests__/domain.test.ts +341 -0
  36. package/src/__tests__/downloader.test.ts +679 -0
  37. package/src/__tests__/folder-detection.test.ts +289 -0
  38. package/src/__tests__/force-fresh-login.test.ts +236 -0
  39. package/src/__tests__/main.test.ts +2437 -0
  40. package/src/__tests__/progress.test.ts +93 -0
  41. package/src/__tests__/session.test.ts +375 -0
  42. package/src/__tests__/social-integration.test.ts +386 -0
  43. package/src/__tests__/social-sync-logic.test.ts +107 -0
  44. package/src/__tests__/social.test.ts +788 -0
  45. package/src/__tests__/sync.test.ts +1273 -0
  46. package/src/__tests__/syndication-toast-law.test.ts +649 -0
  47. package/src/__tests__/syndication.test.ts +125 -0
  48. package/src/__tests__/test-profile-escape.test.ts +209 -0
  49. package/src/__tests__/url-detect.test.ts +79 -0
  50. package/src/__tests__/utils.test.ts +226 -0
  51. package/src/api.ts +1366 -0
  52. package/src/auth-route.ts +38 -0
  53. package/src/config.ts +80 -0
  54. package/src/converter.ts +305 -0
  55. package/src/credential.ts +329 -0
  56. package/src/domain.ts +183 -0
  57. package/src/downloader.ts +761 -0
  58. package/src/main.ts +2092 -0
  59. package/src/progress.ts +89 -0
  60. package/src/queries/user.graphql +85 -0
  61. package/src/queries/viewer.graphql +104 -0
  62. package/src/social.ts +413 -0
  63. package/src/sync.ts +818 -0
  64. package/src/types.ts +477 -0
  65. package/src/url-detect.ts +49 -0
  66. package/src/utils.ts +305 -0
  67. package/test-fixtures/syndication-test-site/input/index.md +8 -0
  68. package/test-fixtures/syndication-test-site/input/posts/rich-test-article.md +90 -0
  69. package/test-helpers/TEST_ACCOUNT.md +151 -0
  70. package/test-helpers/api-client.ts +252 -0
  71. package/test-helpers/fixtures/articles.ts +147 -0
  72. package/test-helpers/wallet-auth.ts +305 -0
  73. package/test-setup/e2e.ts +93 -0
  74. package/tsconfig.json +23 -0
  75. package/vitest.config.ts +39 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * E2E Test Setup for Matters Plugin
3
+ *
4
+ * Configures the test environment for e2e tests that run against
5
+ * the Matters test environment (matters.icu).
6
+ *
7
+ * Required Environment Variables:
8
+ * - MATTERS_TEST_WALLET_PRIVATE_KEY: Ethereum private key for authentication
9
+ * - MATTERS_TEST_USER: Username for public queries (default: yhh354)
10
+ * - MATTERS_TEST_ARTICLE_HASH: Article shortHash for social data tests
11
+ *
12
+ * Optional Environment Variables:
13
+ * - MATTERS_TEST_ENDPOINT: GraphQL endpoint (default: https://server.matters.icu/graphql)
14
+ */
15
+
16
+ import { beforeAll, afterAll, beforeEach } from "vitest";
17
+ import { apiConfig } from "../src/api";
18
+
19
+ // Default test user with known articles on matters.icu
20
+ const DEFAULT_TEST_USER = "yhh354";
21
+
22
+ // Default endpoint for test environment
23
+ const DEFAULT_ENDPOINT = "https://server.matters.icu/graphql";
24
+
25
+ beforeAll(() => {
26
+ // Configure API for test environment
27
+ apiConfig.endpoint = process.env.MATTERS_TEST_ENDPOINT || DEFAULT_ENDPOINT;
28
+ apiConfig.queryMode = "user";
29
+ apiConfig.testUserName = process.env.MATTERS_TEST_USER || DEFAULT_TEST_USER;
30
+
31
+ console.log("🧪 E2E Test Environment Configuration:");
32
+ console.log(` Endpoint: ${apiConfig.endpoint}`);
33
+ console.log(` Query Mode: ${apiConfig.queryMode}`);
34
+ console.log(` Test User: ${apiConfig.testUserName}`);
35
+
36
+ // Check for wallet authentication
37
+ if (process.env.MATTERS_TEST_WALLET_PRIVATE_KEY) {
38
+ console.log(" ✅ Wallet authentication available");
39
+ } else {
40
+ console.warn(" ⚠️ MATTERS_TEST_WALLET_PRIVATE_KEY not set");
41
+ console.warn(" Some tests requiring authentication will be skipped or use mocks");
42
+ }
43
+
44
+ // Check for test article hash
45
+ if (process.env.MATTERS_TEST_ARTICLE_HASH) {
46
+ console.log(` Test Article: ${process.env.MATTERS_TEST_ARTICLE_HASH}`);
47
+ } else {
48
+ console.log(" Test Article: Using default article from test user");
49
+ }
50
+ });
51
+
52
+ beforeEach(() => {
53
+ // Reset API config before each test to ensure clean state
54
+ apiConfig.endpoint = process.env.MATTERS_TEST_ENDPOINT || DEFAULT_ENDPOINT;
55
+ apiConfig.queryMode = "user";
56
+ apiConfig.testUserName = process.env.MATTERS_TEST_USER || DEFAULT_TEST_USER;
57
+ });
58
+
59
+ afterAll(async () => {
60
+ // Cleanup: No specific cleanup needed for e2e tests
61
+ // Drafts created during testing can be manually deleted if needed
62
+ console.log("🧹 E2E Test cleanup complete");
63
+ });
64
+
65
+ /**
66
+ * Helper to check if wallet authentication is available
67
+ */
68
+ export function hasWalletAuth(): boolean {
69
+ return !!process.env.MATTERS_TEST_WALLET_PRIVATE_KEY;
70
+ }
71
+
72
+ /**
73
+ * Helper to skip test if wallet auth is not available
74
+ */
75
+ export function skipIfNoWalletAuth(): void {
76
+ if (!hasWalletAuth()) {
77
+ console.warn("⏭️ Test skipped: MATTERS_TEST_WALLET_PRIVATE_KEY not set");
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Get the test endpoint
83
+ */
84
+ export function getTestEndpoint(): string {
85
+ return process.env.MATTERS_TEST_ENDPOINT || DEFAULT_ENDPOINT;
86
+ }
87
+
88
+ /**
89
+ * Get the test user name
90
+ */
91
+ export function getTestUser(): string {
92
+ return process.env.MATTERS_TEST_USER || DEFAULT_TEST_USER;
93
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "node",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "removeComments": false,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "noImplicitReturns": true,
19
+ "noFallthroughCasesInSwitch": true
20
+ },
21
+ "include": ["src/**/*"],
22
+ "exclude": ["node_modules", "dist", "src/**/*.test.ts"]
23
+ }
@@ -0,0 +1,39 @@
1
+ import os from "node:os";
2
+ import { createSocialPluginConfig } from "../vitest.shared.ts";
3
+
4
+ export default createSocialPluginConfig(import.meta.dirname, {
5
+ coverageExclude: ["src/**/*.test.ts", "src/__generated__/**"],
6
+ // Cap fork-worker heap to prevent the orphan swap-storm (2026-06-14):
7
+ // main.ts is large; loading syndication-toast-law.test.ts in the same
8
+ // worker after main.test.ts OOMs without a cap.
9
+ poolOptions: {
10
+ forks: {
11
+ execArgv: ["--max-old-space-size=3072"],
12
+ maxForks: Math.min(8, os.availableParallelism()),
13
+ },
14
+ },
15
+ extraProjects: [
16
+ {
17
+ extends: true,
18
+ test: {
19
+ name: "features",
20
+ include: ["features/steps/**/*.steps.ts"],
21
+ environment: "node",
22
+ testTimeout: 120000,
23
+ hookTimeout: 60000,
24
+ globals: true,
25
+ setupFiles: ["./test-setup/e2e.ts"],
26
+ },
27
+ },
28
+ {
29
+ extends: true,
30
+ test: {
31
+ name: "e2e",
32
+ include: ["e2e/**/*.test.ts"],
33
+ environment: "node",
34
+ testTimeout: 120000,
35
+ hookTimeout: 60000,
36
+ },
37
+ },
38
+ ],
39
+ });