mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
Add communication account plugin scaffolds
This commit is contained in:
parent
5cfeea6b57
commit
c23ce42948
48 changed files with 1949 additions and 13 deletions
|
|
@ -15,8 +15,10 @@
|
|||
"@logicsrc/plugin-core": "file:../../packages/plugin-core",
|
||||
"@logicsrc/plugin-c0mpute": "file:../../plugins/c0mpute",
|
||||
"@logicsrc/plugin-coinpay": "file:../../plugins/coinpay",
|
||||
"@logicsrc/plugin-email-accounts": "file:../../plugins/email-accounts",
|
||||
"@logicsrc/plugin-feed-discovery": "file:../../plugins/feed-discovery",
|
||||
"@logicsrc/plugin-sh1pt": "file:../../plugins/sh1pt",
|
||||
"@logicsrc/plugin-social-accounts": "file:../../plugins/social-accounts",
|
||||
"@logicsrc/plugin-ugig": "file:../../plugins/ugig",
|
||||
"@logicsrc/validators": "file:../../packages/validators"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ describe("CommandBoard API contracts", () => {
|
|||
};
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(body.plugins.map((plugin) => plugin.id)).toEqual(["coinpay", "ugig", "sh1pt", "c0mpute", "feed-discovery"]);
|
||||
expect(body.plugins.map((plugin) => plugin.id)).toEqual(["coinpay", "ugig", "sh1pt", "c0mpute", "feed-discovery", "social-accounts", "email-accounts"]);
|
||||
expect(body.plugins.find((plugin) => plugin.id === "sh1pt")).toMatchObject({
|
||||
enabled: true,
|
||||
capabilities: expect.arrayContaining(["projects.sync", "actions.publish", "deployments.status"])
|
||||
|
|
@ -59,6 +59,24 @@ describe("CommandBoard API contracts", () => {
|
|||
expect(body.capabilities["actions.publish"]).toEqual(["sh1pt"]);
|
||||
expect(body.capabilities["compute.jobs.dispatch"]).toEqual(["c0mpute"]);
|
||||
expect(body.capabilities["feeds.discover"]).toEqual(["feed-discovery"]);
|
||||
expect(body.capabilities["social.post.publish"]).toEqual(["social-accounts"]);
|
||||
expect(body.capabilities["email.send"]).toEqual(["email-accounts"]);
|
||||
});
|
||||
|
||||
it("exposes communication account provider contracts", async () => {
|
||||
const accountsResponse = await fetch(`${baseUrl}/api/accounts/providers`);
|
||||
const accountsBody = await accountsResponse.json() as { providers: Array<{ id: string; kind: string }> };
|
||||
const socialResponse = await fetch(`${baseUrl}/api/social/providers`);
|
||||
const socialBody = await socialResponse.json() as { providers: Array<{ id: string; kind: string }> };
|
||||
const emailResponse = await fetch(`${baseUrl}/api/email/providers`);
|
||||
const emailBody = await emailResponse.json() as { providers: Array<{ id: string; kind: string }> };
|
||||
|
||||
expect(accountsResponse.status).toBe(200);
|
||||
expect(accountsBody.providers.map((provider) => provider.id)).toEqual(expect.arrayContaining(["mastodon", "gmail", "imap-smtp"]));
|
||||
expect(socialResponse.status).toBe(200);
|
||||
expect(socialBody.providers[0]).toMatchObject({ id: "mastodon", kind: "social" });
|
||||
expect(emailResponse.status).toBe(200);
|
||||
expect(emailBody.providers[0]).toMatchObject({ id: "imap-smtp", kind: "email" });
|
||||
});
|
||||
|
||||
it("exposes feed discovery plugin endpoints", async () => {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ import { pathToFileURL } from "node:url";
|
|||
import { createPluginRegistry } from "@logicsrc/plugin-core";
|
||||
import { c0mputePlugin } from "@logicsrc/plugin-c0mpute";
|
||||
import { coinPayPlugin } from "@logicsrc/plugin-coinpay";
|
||||
import { emailAccountsPlugin, listEmailAccountProviders } from "@logicsrc/plugin-email-accounts";
|
||||
import { discoverFeeds, feedDiscoveryPlugin, listFeedProviders, renderAtom, renderJsonFeed, renderOpml, renderRss, type FeedKind } from "@logicsrc/plugin-feed-discovery";
|
||||
import { sh1ptPlugin } from "@logicsrc/plugin-sh1pt";
|
||||
import { listSocialAccountProviders, socialAccountsPlugin } from "@logicsrc/plugin-social-accounts";
|
||||
import { uGigPlugin } from "@logicsrc/plugin-ugig";
|
||||
import { schemas, validate } from "@logicsrc/validators";
|
||||
|
||||
const registry = createPluginRegistry([coinPayPlugin, uGigPlugin, sh1ptPlugin, c0mputePlugin, feedDiscoveryPlugin]);
|
||||
const registry = createPluginRegistry([coinPayPlugin, uGigPlugin, sh1ptPlugin, c0mputePlugin, feedDiscoveryPlugin, socialAccountsPlugin, emailAccountsPlugin]);
|
||||
|
||||
const boards = [
|
||||
{ path: "/general", title: "General", description: "CommandBoard.run general discussion." },
|
||||
|
|
@ -70,7 +72,7 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
|||
json(response, 200, {
|
||||
ok: true,
|
||||
service: "commandboard-api",
|
||||
endpoints: ["/health", "/api/boards", "/api/tasks", "/api/plugins", "/api/schemas", "/api/feeds/discover", "/api/feeds/providers", "/rss/discover/:keyword.xml", "/opml/discover/:keyword.xml", "/atom/discover/:keyword.xml", "/json-feed/discover/:keyword.json"]
|
||||
endpoints: ["/health", "/api/boards", "/api/tasks", "/api/plugins", "/api/schemas", "/api/accounts/providers", "/api/accounts", "/api/social/providers", "/api/email/providers", "/api/feeds/discover", "/api/feeds/providers", "/rss/discover/:keyword.xml", "/opml/discover/:keyword.xml", "/atom/discover/:keyword.xml", "/json-feed/discover/:keyword.json"]
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -114,6 +116,38 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/accounts/providers") {
|
||||
const kind = url.searchParams.get("kind");
|
||||
const providers = [...listSocialAccountProviders(), ...listEmailAccountProviders()].filter((provider) => !kind || provider.kind === kind);
|
||||
json(response, 200, { providers });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/accounts") {
|
||||
json(response, 200, { accounts: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/social/providers") {
|
||||
json(response, 200, { providers: listSocialAccountProviders() });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/social/accounts") {
|
||||
json(response, 200, { accounts: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/email/providers") {
|
||||
json(response, 200, { providers: listEmailAccountProviders() });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && url.pathname === "/api/email/accounts") {
|
||||
json(response, 200, { accounts: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.method === "GET" && (url.pathname === "/api/feeds/providers" || url.pathname === "/api/rss/providers")) {
|
||||
json(response, 200, { providers: listFeedProviders() });
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue