generated from NEARBuilders/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin-registry.ts
More file actions
91 lines (85 loc) · 2.52 KB
/
plugin-registry.ts
File metadata and controls
91 lines (85 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { PluginType } from "@curatedotfun/types";
interface PluginMetadata {
url: string;
type: PluginType;
}
// Initial plugin registry with types
// UPDATE THIS IF ADDING A NEW PLUGIN TO REPOSITORY
let pluginRegistry: Record<string, PluginMetadata> = {
"@curatedotfun/object-transform": {
url: "http://localhost:3008/remoteEntry.js",
type: "transformer",
},
"@curatedotfun/notion": {
url: "http://localhost:3003/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/rss": {
url: "http://localhost:3004/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/supabase": {
url: "http://localhost:3006/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/telegram": {
url: "http://localhost:3007/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/simple-transform": {
url: "http://localhost:3005/remoteEntry.js",
type: "transformer",
},
"@curatedotfun/ai-transform": {
url: "http://localhost:3002/remoteEntry.js",
type: "transformer",
},
"@curatedotfun/near-social": {
url: "http://localhost:3009/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/crosspost": {
url: "http://localhost:3010/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/translate-transform": {
url: "http://localhost:3012/remoteEntry.js",
type: "transformer",
},
"@curatedotfun/masa-source": {
// Added masa-source plugin
url: "http://localhost:3011/remoteEntry.js", // Assuming port 3011, adjust if necessary
type: "source",
},
"@curatedotfun/discord": {
url: "http://localhost:3012/remoteEntry.js",
type: "distributor",
},
"@curatedotfun/farcaster": {
url: "http://localhost:3013/remoteEntry.js",
type: "distributor",
},
};
export function getPluginByName(name: string): PluginMetadata | undefined {
return pluginRegistry[name];
}
export function getPluginRegistry(): Record<string, PluginMetadata> {
return pluginRegistry;
}
export function setPluginRegistry(
newRegistry: Record<string, PluginMetadata>,
): void {
// Validate the new registry
for (const [name, metadata] of Object.entries(newRegistry)) {
if (!metadata.url || !metadata.type) {
throw new Error(
`Invalid plugin metadata for ${name}: missing url or type`,
);
}
// Updated to include "source" as a valid type
if (!["distributor", "transformer", "source"].includes(metadata.type)) {
throw new Error(`Invalid plugin type for ${name}: ${metadata.type}`);
}
}
pluginRegistry = newRegistry;
}