File size: 7,092 Bytes
a271c58 | 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | import 'reflect-metadata';
import { Injectable } from '@nestjs/common';
import { XProvider } from '@gitroom/nestjs-libraries/integrations/social/x.provider';
import { SocialProvider } from '@gitroom/nestjs-libraries/integrations/social/social.integrations.interface';
import { LinkedinProvider } from '@gitroom/nestjs-libraries/integrations/social/linkedin.provider';
import { RedditProvider } from '@gitroom/nestjs-libraries/integrations/social/reddit.provider';
import { DevToProvider } from '@gitroom/nestjs-libraries/integrations/social/dev.to.provider';
import { HashnodeProvider } from '@gitroom/nestjs-libraries/integrations/social/hashnode.provider';
import { MediumProvider } from '@gitroom/nestjs-libraries/integrations/social/medium.provider';
import { FacebookProvider } from '@gitroom/nestjs-libraries/integrations/social/facebook.provider';
import { InstagramProvider } from '@gitroom/nestjs-libraries/integrations/social/instagram.provider';
import { YoutubeProvider } from '@gitroom/nestjs-libraries/integrations/social/youtube.provider';
import { TiktokProvider } from '@gitroom/nestjs-libraries/integrations/social/tiktok.provider';
import { PinterestProvider } from '@gitroom/nestjs-libraries/integrations/social/pinterest.provider';
import { DribbbleProvider } from '@gitroom/nestjs-libraries/integrations/social/dribbble.provider';
import { LinkedinPageProvider } from '@gitroom/nestjs-libraries/integrations/social/linkedin.page.provider';
import { ThreadsProvider } from '@gitroom/nestjs-libraries/integrations/social/threads.provider';
import { DiscordProvider } from '@gitroom/nestjs-libraries/integrations/social/discord.provider';
import { SlackProvider } from '@gitroom/nestjs-libraries/integrations/social/slack.provider';
import { MastodonProvider } from '@gitroom/nestjs-libraries/integrations/social/mastodon.provider';
import { BlueskyProvider } from '@gitroom/nestjs-libraries/integrations/social/bluesky.provider';
import { LemmyProvider } from '@gitroom/nestjs-libraries/integrations/social/lemmy.provider';
import { InstagramStandaloneProvider } from '@gitroom/nestjs-libraries/integrations/social/instagram.standalone.provider';
import { FarcasterProvider } from '@gitroom/nestjs-libraries/integrations/social/farcaster.provider';
import { TelegramProvider } from '@gitroom/nestjs-libraries/integrations/social/telegram.provider';
import { NostrProvider } from '@gitroom/nestjs-libraries/integrations/social/nostr.provider';
import { VkProvider } from '@gitroom/nestjs-libraries/integrations/social/vk.provider';
import { WordpressProvider } from '@gitroom/nestjs-libraries/integrations/social/wordpress.provider';
import { ListmonkProvider } from '@gitroom/nestjs-libraries/integrations/social/listmonk.provider';
import { GmbProvider } from '@gitroom/nestjs-libraries/integrations/social/gmb.provider';
import { KickProvider } from '@gitroom/nestjs-libraries/integrations/social/kick.provider';
import { TwitchProvider } from '@gitroom/nestjs-libraries/integrations/social/twitch.provider';
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
import { MoltbookProvider } from '@gitroom/nestjs-libraries/integrations/social/moltbook.provider';
import { SkoolProvider } from '@gitroom/nestjs-libraries/integrations/social/skool.provider';
import { WhopProvider } from '@gitroom/nestjs-libraries/integrations/social/whop.provider';
import { MeweProvider } from '@gitroom/nestjs-libraries/integrations/social/mewe.provider';
import { TumblrProvider } from '@gitroom/nestjs-libraries/integrations/social/tumblr.provider';
export const socialIntegrationList: Array<SocialAbstract & SocialProvider> = [
new XProvider(),
new LinkedinProvider(),
new LinkedinPageProvider(),
new RedditProvider(),
new InstagramProvider(),
new InstagramStandaloneProvider(),
new FacebookProvider(),
new ThreadsProvider(),
new YoutubeProvider(),
new GmbProvider(),
new TiktokProvider(),
new PinterestProvider(),
new DribbbleProvider(),
new DiscordProvider(),
new SlackProvider(),
new KickProvider(),
new TwitchProvider(),
new MastodonProvider(),
new BlueskyProvider(),
new LemmyProvider(),
new FarcasterProvider(),
new TelegramProvider(),
new NostrProvider(),
new VkProvider(),
new MediumProvider(),
new DevToProvider(),
new HashnodeProvider(),
new WordpressProvider(),
new ListmonkProvider(),
new MoltbookProvider(),
new WhopProvider(),
new SkoolProvider(),
new MeweProvider(),
new TumblrProvider(),
// new MastodonCustomProvider(),
];
@Injectable()
export class IntegrationManager {
async getAllIntegrations() {
return {
social: await Promise.all(
socialIntegrationList.map(async (p) => ({
name: p.name,
identifier: p.identifier,
toolTip: p.toolTip,
editor: p.editor,
isExternal: !!p.externalUrl,
isWeb3: !!p.isWeb3,
isChromeExtension: !!p.isChromeExtension,
...(p.extensionCookies
? { extensionCookies: p.extensionCookies }
: {}),
...(p.customFields ? { customFields: await p.customFields() } : {}),
}))
),
article: [] as any[],
};
}
getAllTools(): {
[key: string]: {
description: string;
dataSchema: any;
methodName: string;
}[];
} {
return socialIntegrationList.reduce(
(all, current) => ({
...all,
[current.identifier]:
Reflect.getMetadata('custom:tool', current.constructor.prototype) ||
[],
}),
{}
);
}
getAllRulesDescription(): {
[key: string]: string;
} {
return socialIntegrationList.reduce(
(all, current) => ({
...all,
[current.identifier]:
Reflect.getMetadata(
'custom:rules:description',
current.constructor
) || '',
}),
{}
);
}
getAllPlugs() {
return socialIntegrationList
.map((p) => {
return {
name: p.name,
identifier: p.identifier,
plugs: (
Reflect.getMetadata('custom:plug', p.constructor.prototype) || []
)
.filter((f: any) => !f.disabled)
.map((p: any) => ({
...p,
fields: p.fields.map((c: any) => ({
...c,
validation: c?.validation?.toString(),
})),
})),
};
})
.filter((f) => f.plugs.length);
}
getInternalPlugs(providerName: string) {
const p = socialIntegrationList.find((p) => p.identifier === providerName)!;
return {
internalPlugs:
(
Reflect.getMetadata(
'custom:internal_plug',
p.constructor.prototype
) || []
).filter((f: any) => !f.disabled) || [],
};
}
getAllowedSocialsIntegrations() {
return socialIntegrationList.map((p) => p.identifier);
}
getSocialIntegration(integration: string): SocialProvider {
return socialIntegrationList.find((i) => i.identifier === integration)!;
}
}
|