···
+
import type { Did } from "@/lib/types/atproto";
+
SystemsGmstnDevelopmentChannelInvite} from "@/lib/types/lexicon/systems.gmstn.development.channel.invite";
+
systemsGmstnDevelopmentChannelInviteRecordSchema,
+
} from "@/lib/types/lexicon/systems.gmstn.development.channel.invite";
+
import type { Result } from "@/lib/utils/result";
+
import { Client, simpleFetchHandler } from "@atcute/client";
+
import { z } from "zod";
+
// NOTE: might eventually want to put this into Prism as well.
+
export const getInviteRecordsFromPds = async ({
+
value: SystemsGmstnDevelopmentChannelInvite;
+
const handler = simpleFetchHandler({ service: pdsEndpoint });
+
const client = new Client({ handler });
+
const channelRecordsResult = await fetchRecords({
+
if (!channelRecordsResult.ok)
+
return { ok: false, error: channelRecordsResult.error };
+
return { ok: true, data: channelRecordsResult.data };
+
const fetchRecords = async ({
+
value: SystemsGmstnDevelopmentChannelInvite;
+
const allRecords: Array<{
+
value: SystemsGmstnDevelopmentChannelInvite;
+
let cursor: string | undefined;
+
let continueLoop = true;
+
const results = await client.get("com.atproto.repo.listRecords", {
+
collection: "systems.gmstn.development.channel.invite",
+
error: "Failed to fetch records. Check the response from PDS.",
+
const { records, cursor: nextCursor } = results.data;
+
value: systemsGmstnDevelopmentChannelInviteRecordSchema,
+
if (!success) return { ok: false, error: z.treeifyError(error) };
+
...responses.map((data) => {
+
return { uri: data.uri, value: data.value };
+
if (records.length < 100) continueLoop = false;
+
return { ok: true, data: allRecords };