A tool for conquest of ATProto lexicons. https://jsr.io/@hotsocket/lexiconqueror
at main 1.6 kB view raw
1/* 2 * This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 */ 6 7import * as z from "@zod/zod"; 8import * as cfg from "./config.ts"; 9import * as dp from "./did_parts.ts"; 10 11export const serviceProperty_z = z.object({ 12 id: z.string(), 13 type: z.string(), 14 serviceEndpoint: z.string(), 15}); 16export type ServiceProperty = z.infer<typeof serviceProperty_z>; 17// incomplete but like come on i dont need all that 18export const didDoc_z = z.object({ 19 id: z.string(), 20 alsoKnownAs: z.optional(z.set(z.string())), 21 controller: z.optional(z.union([z.string(), z.set(z.string())])), 22 service: z.optional(z.set(serviceProperty_z)), 23}); 24export type DID = z.infer<typeof dp.did_z>; 25export type DIDDoc = z.infer<typeof didDoc_z>; 26 27const anyResolvedInput = z.object({ 28 raw: z.object({ 29 name: z.string(), 30 input: cfg.anyInput, 31 }), 32}); 33export const resolvedAtInput = anyResolvedInput.safeExtend({ 34 kind: z.literal("at"), 35 pds: z.httpUrl(), 36 did: z.string(), 37}); 38 39export const resolvedFileInput = anyResolvedInput.safeExtend({ 40 kind: z.literal("file"), 41 path: z.string(), 42}); 43 44export const resolvedGitInput = anyResolvedInput.safeExtend({ 45 kind: z.literal("git"), 46 url: z.url(), 47 dir: z.string(), 48 // rev: z.optional(z.string()), 49 ref: z.string(), 50}); 51 52export const resolvedInput_z = z.discriminatedUnion("kind", [ 53 resolvedAtInput, 54 resolvedGitInput, 55 resolvedFileInput, 56]); 57export type ResolvedInput = z.infer<typeof resolvedInput_z>;