/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as z from "@zod/zod"; import * as cfg from "./config.ts"; import * as dp from "./did_parts.ts"; export const serviceProperty_z = z.object({ id: z.string(), type: z.string(), serviceEndpoint: z.string(), }); export type ServiceProperty = z.infer; // incomplete but like come on i dont need all that export const didDoc_z = z.object({ id: z.string(), alsoKnownAs: z.optional(z.set(z.string())), controller: z.optional(z.union([z.string(), z.set(z.string())])), service: z.optional(z.set(serviceProperty_z)), }); export type DID = z.infer; export type DIDDoc = z.infer; const anyResolvedInput = z.object({ raw: z.object({ name: z.string(), input: cfg.anyInput, }), }); export const resolvedAtInput = anyResolvedInput.safeExtend({ kind: z.literal("at"), pds: z.httpUrl(), did: z.string(), }); export const resolvedFileInput = anyResolvedInput.safeExtend({ kind: z.literal("file"), path: z.string(), }); export const resolvedGitInput = anyResolvedInput.safeExtend({ kind: z.literal("git"), url: z.url(), dir: z.string(), // rev: z.optional(z.string()), ref: z.string(), }); export const resolvedInput_z = z.discriminatedUnion("kind", [ resolvedAtInput, resolvedGitInput, resolvedFileInput, ]); export type ResolvedInput = z.infer;