This repository has no description
1import { ok } from "@atcute/client";
2import { mainSchema as putRecordSchema } from "@atcute/atproto/types/repo/putRecord";
3import type { Nsid, RecordKey } from "@atcute/lexicons/syntax";
4import type { OAuthUserAgent } from "@atcute/oauth-browser-client";
5import { createClient } from "$lib/auth/agent";
6import type { StringRecord } from "./records";
7
8const STRING_COLLECTION = "sh.tangled.string" as Nsid;
9
10// strings live at a generated tid rkey; put upserts the record at `rkey`.
11export const putString = async (
12 agent: OAuthUserAgent,
13 rkey: string,
14 record: StringRecord
15): Promise<void> => {
16 const rpc = createClient(agent);
17 await ok(
18 rpc.call(putRecordSchema, {
19 input: {
20 repo: agent.sub,
21 collection: STRING_COLLECTION,
22 rkey: rkey as RecordKey,
23 record
24 }
25 })
26 );
27};