birdclaw 0.8.2 → 0.8.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.
- package/CHANGELOG.md +33 -0
- package/README.md +10 -8
- package/bin/birdclaw.mjs +4 -66
- package/dist/cli/birdclaw.js +28165 -0
- package/dist/client/assets/AvatarChip-DLoqM5xD.js +1 -0
- package/dist/client/assets/ProfilePreview-BejAuYsJ.js +1 -0
- package/dist/client/assets/SavedTimelineView-BIS7HKpp.js +1 -0
- package/dist/client/assets/SmartTimestamp-BR0-9se2.js +1 -0
- package/dist/client/assets/TimelineRouteFrame-CyGPj0eM.js +1 -0
- package/dist/client/assets/blocks-7UDKQp8H.js +1 -0
- package/dist/client/assets/bookmarks-CbBkMvXk.js +1 -0
- package/dist/client/assets/chunk-C0phanGV.js +1 -0
- package/dist/client/assets/circle-check-C_Vq3ElD.js +1 -0
- package/dist/client/assets/client-stream-contracts-ys3XhWG4.js +5 -0
- package/dist/client/assets/createLucideIcon-JV8isFFR.js +1 -0
- package/dist/client/assets/data-sources-Cm2bpNvg.js +1 -0
- package/dist/client/assets/discuss-DTjaOugw.js +1 -0
- package/dist/client/assets/dms-CGd6Eogq.js +1 -0
- package/dist/client/assets/inbox-BHlGuOy2.js +1 -0
- package/dist/client/assets/index-CEIG7S6s.js +31 -0
- package/dist/client/assets/index-bpFrQ5yG.css +1 -0
- package/dist/client/assets/likes-cLrcAQem.js +1 -0
- package/dist/client/assets/links-CM9QO1LC.js +1 -0
- package/dist/client/assets/mapbox-BxTlqXt9.js +2 -0
- package/dist/client/assets/mapbox-gl-dgf_hX3a.js +3215 -0
- package/dist/client/assets/mentions-CxKCgzIf.js +1 -0
- package/dist/client/assets/network-map-B5a3whqj.js +2 -0
- package/dist/client/assets/profile-analyze-CRtNEwlb.js +1 -0
- package/dist/client/assets/profile-hydration-client-YEtJsNTv.js +1 -0
- package/dist/client/assets/profiles._handle-C82_HoKX.js +1 -0
- package/dist/client/assets/query-client-fYu2rzRC.js +17 -0
- package/dist/client/assets/rate-limits-ScaEwdVK.js +1 -0
- package/dist/client/assets/react-dom-DHl6Ug7F.js +1 -0
- package/dist/client/assets/react-nBylq1U5.js +1 -0
- package/dist/client/assets/repeat-2-xCwHM9hD.js +1 -0
- package/dist/client/assets/routes-q7ZaW4En.js +1 -0
- package/dist/client/assets/schemas-I9r6F6ya.js +64 -0
- package/dist/client/assets/search-Dq5kYsxA.js +1 -0
- package/dist/client/assets/sparkles-CQVlvHsZ.js +1 -0
- package/dist/client/assets/styles-B8s3tt3r.css +2 -0
- package/dist/client/assets/today-CeG1O7Py.js +1 -0
- package/dist/client/assets/triangle-alert-CBL7s2pf.js +1 -0
- package/dist/client/assets/useTimelineRouteData-1HsqgvUi.js +1 -0
- package/dist/client/assets/users-CHbKlqUr.js +1 -0
- package/dist/server/assets/AvatarChip-zUDAEmjL.js +105 -0
- package/dist/server/assets/FeedState-ntW0Q2GB.js +214 -0
- package/dist/server/assets/ProfileAnalysisStream-BFvhVdhn.js +198 -0
- package/dist/server/assets/ProfilePreview-C6gAor_j.js +752 -0
- package/dist/server/assets/SavedTimelineView-BG1jnBp1.js +64 -0
- package/dist/server/assets/SmartTimestamp-DfwE1NGf.js +45 -0
- package/dist/server/assets/SyncNowButton-BOn_IBXS.js +76 -0
- package/dist/server/assets/TimelineRouteFrame-CU7ilM7U.js +85 -0
- package/dist/server/assets/TweetRichText-DhCVv1-6.js +74 -0
- package/dist/server/assets/_tanstack-start-manifest_v-C-ZRnG_n.js +148 -0
- package/dist/server/assets/account-selection-CTdFGWRk.js +44 -0
- package/dist/server/assets/blocks-C1mgGTB3.js +299 -0
- package/dist/server/assets/blocks-DSgQghqP.js +17 -0
- package/dist/server/assets/bookmarks-BJN8tykY.js +14 -0
- package/dist/server/assets/client-stream-contracts-C2xbWVjm.js +769 -0
- package/dist/server/assets/data-sources-BnA1Q94p.js +180 -0
- package/dist/server/assets/discuss-CJ1dau1j.js +15 -0
- package/dist/server/assets/discuss-QTo08NCN.js +338 -0
- package/dist/server/assets/dms-BuLj4bp8.js +368 -0
- package/dist/server/assets/dms-DAyQrVM2.js +240 -0
- package/dist/server/assets/empty-plugin-adapters-DzrEkdBF.js +5 -0
- package/dist/server/assets/inbox-CkGOaW1q.js +214 -0
- package/dist/server/assets/inbox-DpWd1EzC.js +146 -0
- package/dist/server/assets/likes-DBOAtsJU.js +14 -0
- package/dist/server/assets/links-DAhSjynu.js +240 -0
- package/dist/server/assets/links-DmH5lxHO.js +468 -0
- package/dist/server/assets/mentions-BH2MzKtB.js +26 -0
- package/dist/server/assets/network-map-D3CzRcC4.js +224 -0
- package/dist/server/assets/network-map-D5DoLOwR.js +582 -0
- package/dist/server/assets/profile-analyze-BP65PED0.js +90 -0
- package/dist/server/assets/profile-analyze-C1NoM0tV.js +9 -0
- package/dist/server/assets/profile-hydration-client-GJ4kwJS8.js +133 -0
- package/dist/server/assets/profiles._handle-DjwlN_ac.js +184 -0
- package/dist/server/assets/profiles._handle-DsLNj2Ca.js +12 -0
- package/dist/server/assets/query-client-BdauHBgd.js +923 -0
- package/dist/server/assets/rate-limits-VAr2qzYD.js +262 -0
- package/dist/server/assets/route-search-BUlQ5lGM.js +117 -0
- package/dist/server/assets/router-DqkwSPiM.js +17026 -0
- package/dist/server/assets/routes-A9c9ZhwN.js +26 -0
- package/dist/server/assets/start-FaDOTmto.js +4 -0
- package/dist/server/assets/today-B5hVM57Z.js +17 -0
- package/dist/server/assets/today-fvGiZ7ud.js +303 -0
- package/dist/server/assets/ui-qbmcMSSX.js +137 -0
- package/{src/components/useDebouncedValue.ts → dist/server/assets/useDebouncedValue-DOnA6Xcy.js} +4 -4
- package/dist/server/assets/useTimelineRouteData-27cxynxa.js +1101 -0
- package/dist/server/server.js +5520 -0
- package/package.json +27 -34
- package/playwright.config.ts +0 -35
- package/scripts/browser-perf.mjs +0 -427
- package/scripts/build-docs-site.mjs +0 -967
- package/scripts/docs-site-assets.mjs +0 -311
- package/scripts/run-vitest.mjs +0 -21
- package/scripts/sanitize-node-options.mjs +0 -23
- package/scripts/start-test-server.mjs +0 -42
- package/src/cli-moderation.ts +0 -210
- package/src/cli.ts +0 -2336
- package/src/components/AccountSwitcher.tsx +0 -186
- package/src/components/AppNav.tsx +0 -118
- package/src/components/AvatarChip.tsx +0 -58
- package/src/components/BrandMark.tsx +0 -67
- package/src/components/ConversationThread.tsx +0 -131
- package/src/components/DmWorkspace.tsx +0 -286
- package/src/components/EmbeddedTweetCard.tsx +0 -55
- package/src/components/FeedState.tsx +0 -147
- package/src/components/FloatingPreview.tsx +0 -382
- package/src/components/InboxCard.tsx +0 -152
- package/src/components/LinkPreviewCard.tsx +0 -292
- package/src/components/MarkdownViewer.tsx +0 -777
- package/src/components/ProfileAnalysisStream.tsx +0 -428
- package/src/components/ProfilePreview.tsx +0 -129
- package/src/components/SavedTimelineView.tsx +0 -155
- package/src/components/SmartTimestamp.tsx +0 -72
- package/src/components/SyncNowButton.tsx +0 -140
- package/src/components/ThemeSlider.tsx +0 -80
- package/src/components/TimelineCard.tsx +0 -533
- package/src/components/TimelineRouteFrame.tsx +0 -186
- package/src/components/TweetArticleCard.tsx +0 -66
- package/src/components/TweetMediaGrid.tsx +0 -185
- package/src/components/TweetRichText.tsx +0 -159
- package/src/components/account-selection.ts +0 -64
- package/src/components/useTimelineRouteData.ts +0 -323
- package/src/lib/account-sync-job.ts +0 -666
- package/src/lib/actions-transport.ts +0 -300
- package/src/lib/api-client.ts +0 -419
- package/src/lib/archive-finder.ts +0 -185
- package/src/lib/archive-import.ts +0 -2764
- package/src/lib/authored-live.ts +0 -1072
- package/src/lib/avatar-cache.ts +0 -349
- package/src/lib/backup.ts +0 -2741
- package/src/lib/bird-actions.ts +0 -294
- package/src/lib/bird-command.ts +0 -130
- package/src/lib/bird.ts +0 -1140
- package/src/lib/blocklist.ts +0 -136
- package/src/lib/blocks-write.ts +0 -167
- package/src/lib/blocks.ts +0 -389
- package/src/lib/bookmark-sync-job.ts +0 -536
- package/src/lib/client-cache.ts +0 -109
- package/src/lib/config.ts +0 -224
- package/src/lib/conversation-surface.ts +0 -205
- package/src/lib/data-sources.ts +0 -219
- package/src/lib/db.ts +0 -1135
- package/src/lib/dms-live.ts +0 -933
- package/src/lib/effect-runtime.ts +0 -45
- package/src/lib/follow-graph.ts +0 -1097
- package/src/lib/geocoding.ts +0 -296
- package/src/lib/http-effect.ts +0 -222
- package/src/lib/identity-search-index.ts +0 -369
- package/src/lib/inbox.ts +0 -241
- package/src/lib/link-index.ts +0 -641
- package/src/lib/link-insights.ts +0 -860
- package/src/lib/link-preview-metadata.ts +0 -754
- package/src/lib/location.ts +0 -137
- package/src/lib/media-fetch.ts +0 -860
- package/src/lib/media-includes.ts +0 -165
- package/src/lib/mention-threads-live.ts +0 -917
- package/src/lib/mentions-export.ts +0 -147
- package/src/lib/mentions-live.ts +0 -1238
- package/src/lib/moderation-target.ts +0 -216
- package/src/lib/moderation-write.ts +0 -131
- package/src/lib/mutes-write.ts +0 -167
- package/src/lib/mutes.ts +0 -84
- package/src/lib/ndjson-stream.ts +0 -106
- package/src/lib/network-map.ts +0 -382
- package/src/lib/openai.ts +0 -117
- package/src/lib/period-digest.ts +0 -1552
- package/src/lib/present.ts +0 -118
- package/src/lib/profile-affiliation-hydration.ts +0 -228
- package/src/lib/profile-affiliations.ts +0 -262
- package/src/lib/profile-analysis.ts +0 -1272
- package/src/lib/profile-bio-entities.ts +0 -318
- package/src/lib/profile-history.ts +0 -164
- package/src/lib/profile-hydration.ts +0 -180
- package/src/lib/profile-replies.ts +0 -77
- package/src/lib/profile-resolver.ts +0 -650
- package/src/lib/queries.ts +0 -2381
- package/src/lib/research.ts +0 -652
- package/src/lib/search-discussion.ts +0 -1016
- package/src/lib/seed.ts +0 -613
- package/src/lib/sqlite.ts +0 -147
- package/src/lib/sync-cache.ts +0 -65
- package/src/lib/theme-transition.ts +0 -113
- package/src/lib/theme.tsx +0 -165
- package/src/lib/timeline-collections-live.ts +0 -581
- package/src/lib/timeline-live.ts +0 -452
- package/src/lib/tweet-account-edges.ts +0 -48
- package/src/lib/tweet-lookup.ts +0 -46
- package/src/lib/tweet-render.ts +0 -430
- package/src/lib/tweet-search-live.ts +0 -566
- package/src/lib/types.ts +0 -723
- package/src/lib/ui.ts +0 -529
- package/src/lib/url-expansion-store.ts +0 -110
- package/src/lib/url-expansion.ts +0 -343
- package/src/lib/url-safety.ts +0 -220
- package/src/lib/web-sync.ts +0 -516
- package/src/lib/whois.ts +0 -1079
- package/src/lib/x-profile.ts +0 -365
- package/src/lib/x-web.ts +0 -199
- package/src/lib/xurl-rate-limits.ts +0 -267
- package/src/lib/xurl.ts +0 -1677
- package/src/routeTree.gen.ts +0 -723
- package/src/router.tsx +0 -20
- package/src/routes/__root.tsx +0 -79
- package/src/routes/api/action.tsx +0 -147
- package/src/routes/api/avatar.tsx +0 -50
- package/src/routes/api/blocks.tsx +0 -35
- package/src/routes/api/conversation.tsx +0 -45
- package/src/routes/api/data-sources.tsx +0 -24
- package/src/routes/api/inbox.tsx +0 -43
- package/src/routes/api/link-insights.tsx +0 -85
- package/src/routes/api/link-preview.tsx +0 -47
- package/src/routes/api/network-map.tsx +0 -55
- package/src/routes/api/period-digest.tsx +0 -101
- package/src/routes/api/profile-analysis.tsx +0 -97
- package/src/routes/api/profile-hydrate.tsx +0 -54
- package/src/routes/api/query.tsx +0 -115
- package/src/routes/api/search-discussion.tsx +0 -113
- package/src/routes/api/status.tsx +0 -28
- package/src/routes/api/sync.tsx +0 -105
- package/src/routes/api/xurl-rate-limits.tsx +0 -24
- package/src/routes/blocks.tsx +0 -377
- package/src/routes/bookmarks.tsx +0 -18
- package/src/routes/data-sources.tsx +0 -257
- package/src/routes/discuss.tsx +0 -419
- package/src/routes/dms.tsx +0 -432
- package/src/routes/inbox.tsx +0 -226
- package/src/routes/index.tsx +0 -32
- package/src/routes/likes.tsx +0 -18
- package/src/routes/links.tsx +0 -994
- package/src/routes/mentions.tsx +0 -32
- package/src/routes/network-map.tsx +0 -1035
- package/src/routes/profile-analyze.tsx +0 -112
- package/src/routes/profiles.$handle.tsx +0 -228
- package/src/routes/rate-limits.tsx +0 -309
- package/src/routes/today.tsx +0 -511
- package/src/styles.css +0 -257
- package/tsconfig.json +0 -29
- package/vite.config.ts +0 -29
- /package/{public → dist/client}/birdclaw-mark.png +0 -0
- /package/{public → dist/client}/favicon.ico +0 -0
- /package/{public → dist/client}/logo192.png +0 -0
- /package/{public → dist/client}/logo512.png +0 -0
- /package/{public → dist/client}/manifest.json +0 -0
- /package/{public → dist/client}/robots.txt +0 -0
package/src/router.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
|
|
2
|
-
import { routeTree } from "./routeTree.gen";
|
|
3
|
-
|
|
4
|
-
export function getRouter() {
|
|
5
|
-
const router = createTanStackRouter({
|
|
6
|
-
routeTree,
|
|
7
|
-
|
|
8
|
-
scrollRestoration: true,
|
|
9
|
-
defaultPreload: "intent",
|
|
10
|
-
defaultPreloadStaleTime: 60_000,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return router;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module "@tanstack/react-router" {
|
|
17
|
-
interface Register {
|
|
18
|
-
router: ReturnType<typeof getRouter>;
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/routes/__root.tsx
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRootRoute,
|
|
3
|
-
HeadContent,
|
|
4
|
-
Scripts,
|
|
5
|
-
useRouterState,
|
|
6
|
-
} from "@tanstack/react-router";
|
|
7
|
-
import type { ReactNode } from "react";
|
|
8
|
-
import { AppNav } from "#/components/AppNav";
|
|
9
|
-
import { ThemeProvider, themeScript } from "#/lib/theme";
|
|
10
|
-
import {
|
|
11
|
-
bodyClass,
|
|
12
|
-
mainColumnClass,
|
|
13
|
-
mainColumnDmClass,
|
|
14
|
-
siteShellClass,
|
|
15
|
-
siteShellDmClass,
|
|
16
|
-
} from "#/lib/ui";
|
|
17
|
-
|
|
18
|
-
import appCss from "../styles.css?url";
|
|
19
|
-
|
|
20
|
-
export const Route = createRootRoute({
|
|
21
|
-
head: () => ({
|
|
22
|
-
meta: [
|
|
23
|
-
{
|
|
24
|
-
charSet: "utf-8",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "viewport",
|
|
28
|
-
content: "width=device-width, initial-scale=1",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
title: "birdclaw",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
links: [
|
|
35
|
-
{
|
|
36
|
-
rel: "stylesheet",
|
|
37
|
-
href: appCss,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
}),
|
|
41
|
-
notFoundComponent: NotFoundView,
|
|
42
|
-
shellComponent: RootDocument,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
function NotFoundView() {
|
|
46
|
-
return (
|
|
47
|
-
<main className={mainColumnClass}>
|
|
48
|
-
<div className="px-4 py-10 text-[var(--ink-soft)]">Not Found</div>
|
|
49
|
-
</main>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function RootDocument({ children }: { children: ReactNode }) {
|
|
54
|
-
const pathname = useRouterState({
|
|
55
|
-
select: (state) => state.location.pathname,
|
|
56
|
-
});
|
|
57
|
-
const wideMode =
|
|
58
|
-
pathname.startsWith("/dms") || pathname.startsWith("/network-map");
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<html lang="en" suppressHydrationWarning>
|
|
62
|
-
<head>
|
|
63
|
-
<HeadContent />
|
|
64
|
-
<script suppressHydrationWarning>{themeScript}</script>
|
|
65
|
-
</head>
|
|
66
|
-
<body className={bodyClass}>
|
|
67
|
-
<ThemeProvider>
|
|
68
|
-
<div className={wideMode ? siteShellDmClass : siteShellClass}>
|
|
69
|
-
<AppNav compact={wideMode} />
|
|
70
|
-
<main className={wideMode ? mainColumnDmClass : mainColumnClass}>
|
|
71
|
-
{children}
|
|
72
|
-
</main>
|
|
73
|
-
</div>
|
|
74
|
-
</ThemeProvider>
|
|
75
|
-
<Scripts />
|
|
76
|
-
</body>
|
|
77
|
-
</html>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
addBlockEffect,
|
|
5
|
-
removeBlockEffect,
|
|
6
|
-
syncBlocksEffect,
|
|
7
|
-
} from "#/lib/blocks";
|
|
8
|
-
import {
|
|
9
|
-
jsonResponse,
|
|
10
|
-
parseBoundedInteger,
|
|
11
|
-
requestJsonEffect,
|
|
12
|
-
runRouteEffect,
|
|
13
|
-
sensitiveRequestErrorResponse,
|
|
14
|
-
} from "#/lib/http-effect";
|
|
15
|
-
import { scoreInboxEffect } from "#/lib/inbox";
|
|
16
|
-
import { addMuteEffect, removeMuteEffect } from "#/lib/mutes";
|
|
17
|
-
import {
|
|
18
|
-
createDmReplyEffect,
|
|
19
|
-
createPostEffect,
|
|
20
|
-
createTweetReplyEffect,
|
|
21
|
-
} from "#/lib/queries";
|
|
22
|
-
import type { ActionsTransport } from "#/lib/config";
|
|
23
|
-
import type { InboxKind } from "#/lib/types";
|
|
24
|
-
|
|
25
|
-
function parseActionsTransport(
|
|
26
|
-
value: string | undefined,
|
|
27
|
-
): ActionsTransport | undefined {
|
|
28
|
-
return value === "auto" || value === "bird" || value === "xurl"
|
|
29
|
-
? value
|
|
30
|
-
: undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function actionErrorMessage(error: unknown) {
|
|
34
|
-
if (
|
|
35
|
-
typeof error === "object" &&
|
|
36
|
-
error !== null &&
|
|
37
|
-
"cause" in error &&
|
|
38
|
-
error.cause instanceof Error
|
|
39
|
-
) {
|
|
40
|
-
return error.cause.message;
|
|
41
|
-
}
|
|
42
|
-
if (error instanceof Error) {
|
|
43
|
-
return error.message;
|
|
44
|
-
}
|
|
45
|
-
return String(error);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const Route = createFileRoute("/api/action")({
|
|
49
|
-
server: {
|
|
50
|
-
handlers: {
|
|
51
|
-
POST: ({ request }) =>
|
|
52
|
-
runRouteEffect(
|
|
53
|
-
Effect.gen(function* () {
|
|
54
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
55
|
-
if (denied) return denied;
|
|
56
|
-
|
|
57
|
-
const body =
|
|
58
|
-
yield* requestJsonEffect<Record<string, string>>(request);
|
|
59
|
-
const transport = parseActionsTransport(body.transport);
|
|
60
|
-
let result: unknown;
|
|
61
|
-
|
|
62
|
-
if (body.kind === "post") {
|
|
63
|
-
result = yield* createPostEffect(
|
|
64
|
-
body.accountId || "acct_primary",
|
|
65
|
-
body.text || "",
|
|
66
|
-
);
|
|
67
|
-
} else if (body.kind === "replyTweet") {
|
|
68
|
-
result = yield* createTweetReplyEffect(
|
|
69
|
-
body.accountId || "acct_primary",
|
|
70
|
-
body.tweetId || "",
|
|
71
|
-
body.text || "",
|
|
72
|
-
);
|
|
73
|
-
} else if (body.kind === "replyDm") {
|
|
74
|
-
result = yield* createDmReplyEffect(
|
|
75
|
-
body.conversationId || "",
|
|
76
|
-
body.text || "",
|
|
77
|
-
);
|
|
78
|
-
} else if (body.kind === "scoreInbox") {
|
|
79
|
-
result = yield* scoreInboxEffect({
|
|
80
|
-
kind: ((body.scoreKind as InboxKind) || "mixed") as InboxKind,
|
|
81
|
-
account: body.account,
|
|
82
|
-
limit: parseBoundedInteger(body.limit, {
|
|
83
|
-
defaultValue: 8,
|
|
84
|
-
max: 20,
|
|
85
|
-
}),
|
|
86
|
-
});
|
|
87
|
-
} else if (body.kind === "blockProfile") {
|
|
88
|
-
result = yield* addBlockEffect(
|
|
89
|
-
body.accountId || "acct_primary",
|
|
90
|
-
body.query || "",
|
|
91
|
-
{
|
|
92
|
-
transport,
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
} else if (body.kind === "unblockProfile") {
|
|
96
|
-
result = yield* removeBlockEffect(
|
|
97
|
-
body.accountId || "acct_primary",
|
|
98
|
-
body.query || "",
|
|
99
|
-
{
|
|
100
|
-
transport,
|
|
101
|
-
},
|
|
102
|
-
);
|
|
103
|
-
} else if (body.kind === "muteProfile") {
|
|
104
|
-
result = yield* addMuteEffect(
|
|
105
|
-
body.accountId || "acct_primary",
|
|
106
|
-
body.query || "",
|
|
107
|
-
{
|
|
108
|
-
transport,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
} else if (body.kind === "unmuteProfile") {
|
|
112
|
-
result = yield* removeMuteEffect(
|
|
113
|
-
body.accountId || "acct_primary",
|
|
114
|
-
body.query || "",
|
|
115
|
-
{
|
|
116
|
-
transport,
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
} else if (body.kind === "syncBlocks") {
|
|
120
|
-
result = yield* syncBlocksEffect(
|
|
121
|
-
body.accountId || "acct_primary",
|
|
122
|
-
);
|
|
123
|
-
} else {
|
|
124
|
-
return jsonResponse(
|
|
125
|
-
{ ok: false, message: "Unknown action kind" },
|
|
126
|
-
{ status: 400 },
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return jsonResponse(result);
|
|
131
|
-
}).pipe(
|
|
132
|
-
Effect.catchAll((error) =>
|
|
133
|
-
Effect.succeed(
|
|
134
|
-
jsonResponse(
|
|
135
|
-
{
|
|
136
|
-
ok: false,
|
|
137
|
-
message: actionErrorMessage(error),
|
|
138
|
-
},
|
|
139
|
-
{ status: 500 },
|
|
140
|
-
),
|
|
141
|
-
),
|
|
142
|
-
),
|
|
143
|
-
),
|
|
144
|
-
),
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { readCachedAvatarEffect } from "#/lib/avatar-cache";
|
|
4
|
-
import {
|
|
5
|
-
jsonResponse,
|
|
6
|
-
runRouteEffect,
|
|
7
|
-
sensitiveRequestErrorResponse,
|
|
8
|
-
} from "#/lib/http-effect";
|
|
9
|
-
|
|
10
|
-
export const Route = createFileRoute("/api/avatar")({
|
|
11
|
-
server: {
|
|
12
|
-
handlers: {
|
|
13
|
-
GET: ({ request }) =>
|
|
14
|
-
runRouteEffect(
|
|
15
|
-
Effect.gen(function* () {
|
|
16
|
-
const sensitiveError = sensitiveRequestErrorResponse(request);
|
|
17
|
-
if (sensitiveError) return sensitiveError;
|
|
18
|
-
|
|
19
|
-
const url = new URL(request.url);
|
|
20
|
-
const profileId = url.searchParams.get("profileId")?.trim();
|
|
21
|
-
|
|
22
|
-
if (!profileId) {
|
|
23
|
-
return jsonResponse(
|
|
24
|
-
{ ok: false, message: "Missing profileId" },
|
|
25
|
-
{ status: 400 },
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const avatar = yield* readCachedAvatarEffect(profileId).pipe(
|
|
30
|
-
Effect.catchAll(() => Effect.succeed(null)),
|
|
31
|
-
);
|
|
32
|
-
if (!avatar) {
|
|
33
|
-
return jsonResponse(
|
|
34
|
-
{ ok: false, message: "Avatar not found" },
|
|
35
|
-
{ status: 404 },
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return new Response(new Uint8Array(avatar.buffer), {
|
|
40
|
-
headers: {
|
|
41
|
-
"cache-control": "public, max-age=86400, immutable",
|
|
42
|
-
"content-type": avatar.contentType,
|
|
43
|
-
"x-content-type-options": "nosniff",
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { getBlocksResponse } from "#/lib/blocks";
|
|
4
|
-
import {
|
|
5
|
-
jsonResponse,
|
|
6
|
-
parseBoundedInteger,
|
|
7
|
-
runRouteEffect,
|
|
8
|
-
sensitiveRequestErrorResponse,
|
|
9
|
-
} from "#/lib/http-effect";
|
|
10
|
-
|
|
11
|
-
export const Route = createFileRoute("/api/blocks")({
|
|
12
|
-
server: {
|
|
13
|
-
handlers: {
|
|
14
|
-
GET: ({ request }) =>
|
|
15
|
-
runRouteEffect(
|
|
16
|
-
Effect.sync(() => {
|
|
17
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
18
|
-
if (denied) return denied;
|
|
19
|
-
|
|
20
|
-
const url = new URL(request.url);
|
|
21
|
-
return jsonResponse(
|
|
22
|
-
getBlocksResponse({
|
|
23
|
-
accountId: url.searchParams.get("account") ?? undefined,
|
|
24
|
-
search: url.searchParams.get("search") ?? undefined,
|
|
25
|
-
limit: parseBoundedInteger(url.searchParams.get("limit"), {
|
|
26
|
-
defaultValue: 12,
|
|
27
|
-
max: 50,
|
|
28
|
-
}),
|
|
29
|
-
}),
|
|
30
|
-
);
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { maybeAutoUpdateBackupEffect } from "#/lib/backup";
|
|
4
|
-
import {
|
|
5
|
-
runRouteEffect,
|
|
6
|
-
sensitiveRequestErrorResponse,
|
|
7
|
-
} from "#/lib/http-effect";
|
|
8
|
-
import { getTweetConversation } from "#/lib/queries";
|
|
9
|
-
|
|
10
|
-
function json(data: unknown, status = 200) {
|
|
11
|
-
return new Response(JSON.stringify(data), {
|
|
12
|
-
status,
|
|
13
|
-
headers: {
|
|
14
|
-
"content-type": "application/json",
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const Route = createFileRoute("/api/conversation")({
|
|
20
|
-
server: {
|
|
21
|
-
handlers: {
|
|
22
|
-
GET: ({ request }) =>
|
|
23
|
-
runRouteEffect(
|
|
24
|
-
Effect.gen(function* () {
|
|
25
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
26
|
-
if (denied) return denied;
|
|
27
|
-
|
|
28
|
-
yield* maybeAutoUpdateBackupEffect();
|
|
29
|
-
const url = new URL(request.url);
|
|
30
|
-
const tweetId = url.searchParams.get("tweetId")?.trim();
|
|
31
|
-
if (!tweetId) {
|
|
32
|
-
return json({ ok: false, error: "Missing tweetId" }, 400);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const conversation = getTweetConversation(tweetId);
|
|
36
|
-
if (!conversation) {
|
|
37
|
-
return json({ ok: false, error: "Tweet not found" }, 404);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return json({ ok: true, ...conversation });
|
|
41
|
-
}),
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { getLiveDataSourcesEffect } from "#/lib/data-sources";
|
|
4
|
-
import {
|
|
5
|
-
jsonResponse,
|
|
6
|
-
runRouteEffect,
|
|
7
|
-
sensitiveRequestErrorResponse,
|
|
8
|
-
} from "#/lib/http-effect";
|
|
9
|
-
|
|
10
|
-
export const Route = createFileRoute("/api/data-sources")({
|
|
11
|
-
server: {
|
|
12
|
-
handlers: {
|
|
13
|
-
GET: ({ request }) =>
|
|
14
|
-
runRouteEffect(
|
|
15
|
-
Effect.gen(function* () {
|
|
16
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
17
|
-
if (denied) return denied;
|
|
18
|
-
|
|
19
|
-
return jsonResponse(yield* getLiveDataSourcesEffect());
|
|
20
|
-
}),
|
|
21
|
-
),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
package/src/routes/api/inbox.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { maybeAutoUpdateBackupEffect } from "#/lib/backup";
|
|
4
|
-
import {
|
|
5
|
-
jsonResponse,
|
|
6
|
-
runRouteEffect,
|
|
7
|
-
sensitiveRequestErrorResponse,
|
|
8
|
-
} from "#/lib/http-effect";
|
|
9
|
-
import { listInboxItems } from "#/lib/inbox";
|
|
10
|
-
import type { InboxKind } from "#/lib/types";
|
|
11
|
-
|
|
12
|
-
function parseNumber(value: string | null) {
|
|
13
|
-
if (!value) return undefined;
|
|
14
|
-
const parsed = Number(value);
|
|
15
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Route = createFileRoute("/api/inbox")({
|
|
19
|
-
server: {
|
|
20
|
-
handlers: {
|
|
21
|
-
GET: ({ request }) =>
|
|
22
|
-
runRouteEffect(
|
|
23
|
-
Effect.gen(function* () {
|
|
24
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
25
|
-
if (denied) return denied;
|
|
26
|
-
|
|
27
|
-
yield* maybeAutoUpdateBackupEffect();
|
|
28
|
-
const url = new URL(request.url);
|
|
29
|
-
const kind = (url.searchParams.get("kind") ?? "mixed") as InboxKind;
|
|
30
|
-
return jsonResponse(
|
|
31
|
-
listInboxItems({
|
|
32
|
-
kind: kind === "mentions" || kind === "dms" ? kind : "mixed",
|
|
33
|
-
account: url.searchParams.get("account") ?? undefined,
|
|
34
|
-
minScore: parseNumber(url.searchParams.get("minScore")),
|
|
35
|
-
hideLowSignal: url.searchParams.get("hideLowSignal") === "1",
|
|
36
|
-
limit: parseNumber(url.searchParams.get("limit")) ?? 20,
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
39
|
-
}),
|
|
40
|
-
),
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { maybeAutoUpdateBackupEffect } from "#/lib/backup";
|
|
4
|
-
import { getNativeDb } from "#/lib/db";
|
|
5
|
-
import {
|
|
6
|
-
jsonResponse,
|
|
7
|
-
runRouteEffect,
|
|
8
|
-
sensitiveRequestErrorResponse,
|
|
9
|
-
} from "#/lib/http-effect";
|
|
10
|
-
import { getLinkInsights } from "#/lib/link-insights";
|
|
11
|
-
import type {
|
|
12
|
-
LinkInsightKind,
|
|
13
|
-
LinkInsightRange,
|
|
14
|
-
LinkInsightSort,
|
|
15
|
-
LinkInsightSource,
|
|
16
|
-
} from "#/lib/types";
|
|
17
|
-
|
|
18
|
-
function parseKind(value: string | null): LinkInsightKind {
|
|
19
|
-
return value === "videos" ? "videos" : "links";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function parseRange(value: string | null): LinkInsightRange {
|
|
23
|
-
if (
|
|
24
|
-
value === "today" ||
|
|
25
|
-
value === "week" ||
|
|
26
|
-
value === "month" ||
|
|
27
|
-
value === "year" ||
|
|
28
|
-
value === "all"
|
|
29
|
-
) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
return "week";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function parseSource(value: string | null): LinkInsightSource {
|
|
36
|
-
if (value === "tweet" || value === "dm") {
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
return "all";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function parseSort(value: string | null): LinkInsightSort {
|
|
43
|
-
if (value === "recent" || value === "comments") {
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
return "rank";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function parseNumber(value: string | null) {
|
|
50
|
-
if (!value) return undefined;
|
|
51
|
-
const parsed = Number(value);
|
|
52
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const Route = createFileRoute("/api/link-insights")({
|
|
56
|
-
server: {
|
|
57
|
-
handlers: {
|
|
58
|
-
GET: ({ request }) =>
|
|
59
|
-
runRouteEffect(
|
|
60
|
-
Effect.gen(function* () {
|
|
61
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
62
|
-
if (denied) return denied;
|
|
63
|
-
|
|
64
|
-
yield* maybeAutoUpdateBackupEffect();
|
|
65
|
-
getNativeDb();
|
|
66
|
-
const url = new URL(request.url);
|
|
67
|
-
return jsonResponse(
|
|
68
|
-
getLinkInsights({
|
|
69
|
-
kind: parseKind(url.searchParams.get("kind")),
|
|
70
|
-
range: parseRange(url.searchParams.get("range")),
|
|
71
|
-
sort: parseSort(url.searchParams.get("sort")),
|
|
72
|
-
source: parseSource(url.searchParams.get("source")),
|
|
73
|
-
since: url.searchParams.get("since") ?? undefined,
|
|
74
|
-
until: url.searchParams.get("until") ?? undefined,
|
|
75
|
-
limit: parseNumber(url.searchParams.get("limit")),
|
|
76
|
-
commentsLimit: parseNumber(
|
|
77
|
-
url.searchParams.get("commentsLimit"),
|
|
78
|
-
),
|
|
79
|
-
}),
|
|
80
|
-
);
|
|
81
|
-
}),
|
|
82
|
-
),
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
jsonResponse,
|
|
5
|
-
runRouteEffect,
|
|
6
|
-
sensitiveRequestErrorResponse,
|
|
7
|
-
} from "#/lib/http-effect";
|
|
8
|
-
import { getOrFetchLinkPreviewEffect } from "#/lib/link-preview-metadata";
|
|
9
|
-
|
|
10
|
-
function parseUrl(value: string | null) {
|
|
11
|
-
if (!value) return null;
|
|
12
|
-
try {
|
|
13
|
-
const parsed = new URL(value);
|
|
14
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return parsed.toString();
|
|
18
|
-
} catch {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const Route = createFileRoute("/api/link-preview")({
|
|
24
|
-
server: {
|
|
25
|
-
handlers: {
|
|
26
|
-
GET: ({ request }) =>
|
|
27
|
-
runRouteEffect(
|
|
28
|
-
Effect.gen(function* () {
|
|
29
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
30
|
-
if (denied) return denied;
|
|
31
|
-
|
|
32
|
-
const url = new URL(request.url);
|
|
33
|
-
const previewUrl = parseUrl(url.searchParams.get("url"));
|
|
34
|
-
if (!previewUrl) {
|
|
35
|
-
return jsonResponse(
|
|
36
|
-
{ ok: false, message: "Missing url" },
|
|
37
|
-
{ status: 400 },
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const preview = yield* getOrFetchLinkPreviewEffect(previewUrl);
|
|
42
|
-
return jsonResponse({ ok: true, preview });
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { maybeAutoUpdateBackupEffect } from "#/lib/backup";
|
|
4
|
-
import {
|
|
5
|
-
jsonResponse,
|
|
6
|
-
parseBoundedInteger,
|
|
7
|
-
runRouteEffect,
|
|
8
|
-
sensitiveRequestErrorResponse,
|
|
9
|
-
} from "#/lib/http-effect";
|
|
10
|
-
import { getNetworkMap, type NetworkMapKind } from "#/lib/network-map";
|
|
11
|
-
|
|
12
|
-
function parseType(value: string | null): NetworkMapKind {
|
|
13
|
-
if (
|
|
14
|
-
value === "followers" ||
|
|
15
|
-
value === "following" ||
|
|
16
|
-
value === "mutual" ||
|
|
17
|
-
value === "all"
|
|
18
|
-
) {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
return "all";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const Route = createFileRoute("/api/network-map")({
|
|
25
|
-
server: {
|
|
26
|
-
handlers: {
|
|
27
|
-
GET: ({ request }) =>
|
|
28
|
-
runRouteEffect(
|
|
29
|
-
Effect.gen(function* () {
|
|
30
|
-
const denied = sensitiveRequestErrorResponse(request);
|
|
31
|
-
if (denied) return denied;
|
|
32
|
-
|
|
33
|
-
yield* maybeAutoUpdateBackupEffect();
|
|
34
|
-
const url = new URL(request.url);
|
|
35
|
-
const response = yield* Effect.promise(() =>
|
|
36
|
-
getNetworkMap({
|
|
37
|
-
account: url.searchParams.get("account") ?? undefined,
|
|
38
|
-
type: parseType(url.searchParams.get("type")),
|
|
39
|
-
limit: parseBoundedInteger(url.searchParams.get("limit"), {
|
|
40
|
-
max: 50_000,
|
|
41
|
-
}),
|
|
42
|
-
geocodeLimit: parseBoundedInteger(
|
|
43
|
-
url.searchParams.get("geocodeLimit"),
|
|
44
|
-
{ max: 500, min: 0 },
|
|
45
|
-
),
|
|
46
|
-
refresh: url.searchParams.get("refresh") === "true",
|
|
47
|
-
signal: request.signal,
|
|
48
|
-
}),
|
|
49
|
-
);
|
|
50
|
-
return jsonResponse(response);
|
|
51
|
-
}),
|
|
52
|
-
),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|