···
import { AtprotoDid, Did, isNsid } from "@atcute/lexicons/syntax";
import { verifyRecord } from "@atcute/repo";
import { A, useLocation, useNavigate, useParams } from "@solidjs/router";
10
+
import { createResource, createSignal, ErrorBoundary, Show, Suspense } from "solid-js";
import { Backlinks } from "../components/backlinks.jsx";
import { Button } from "../components/button.jsx";
import { RecordEditor, setPlaceholder } from "../components/create.jsx";
···
setPlaceholder(res.data.value);
setExternalLink(checkUri(res.data.uri, res.data.value));
resolveLexicon(params.collection as Nsid);
226
+
verifyRecordIntegrity();
227
+
validateLocalSchema(res.data.value);
const [record, { refetch }] = createResource(fetchRecord);
239
-
const validateSchema = async (record: Record<string, unknown>) => {
234
+
const validateLocalSchema = async (record: Record<string, unknown>) => {
if (params.collection === "com.atproto.lexicon.schema") {
setLexiconNotFound(false);
···
} else if (params.collection && params.collection in lexicons) {
if (is(lexicons[params.collection], record)) setValidSchema(true);
else setValidSchema(false);
249
-
const { resolved, failed } = await resolveAllLexicons(params.collection as Nsid);
244
+
} catch (err: any) {
245
+
console.error("Schema validation error:", err);
246
+
setValidSchema(false);
247
+
setValidationError(err.message || String(err));
251
-
if (failed.size > 0) {
252
-
console.error(`Failed to resolve ${failed.size} documents:`, Array.from(failed));
253
-
setValidSchema(false);
254
-
setValidationError(
255
-
`Unable to resolve lexicon documents: ${Array.from(failed).join(", ")}`,
251
+
const validateRemoteSchema = async (record: Record<string, unknown>) => {
253
+
const { resolved, failed } = await resolveAllLexicons(params.collection as Nsid);
260
-
const lexiconDocs = Object.fromEntries(resolved);
261
-
console.log(lexiconDocs);
255
+
if (failed.size > 0) {
256
+
console.error(`Failed to resolve ${failed.size} documents:`, Array.from(failed));
257
+
setValidSchema(false);
258
+
setValidationError(`Unable to resolve lexicon documents: ${Array.from(failed).join(", ")}`);
263
-
const validator = new RecordValidator(lexiconDocs, params.collection as Nsid);
265
-
key: params.rkey ?? null,
262
+
const lexiconDocs = Object.fromEntries(resolved);
263
+
console.log(lexiconDocs);
265
+
const validator = new RecordValidator(lexiconDocs, params.collection as Nsid);
267
+
key: params.rkey ?? null,
269
-
setValidSchema(true);
271
+
setValidSchema(true);
console.error("Schema validation error:", err);
···
305
-
createEffect(() => {
306
-
if (location.hash === "#info" && record()) {
307
-
if (validSchema() === undefined) validateSchema(record()!.value);
308
-
if (validRecord() === undefined) verifyRecordIntegrity();
const resolveLexicon = async (nsid: Nsid) => {
const authority = await resolveLexiconAuthority(nsid);
···
return template(parsedUri, record);
353
-
const RecordTab = (props: { tab: "record" | "backlinks" | "info" | "schema"; label: string }) => {
347
+
const RecordTab = (props: {
348
+
tab: "record" | "backlinks" | "info" | "schema";
if (!location.hash && props.tab === "record") return true;
if (location.hash === `#${props.tab}`) return true;
···
371
+
<Show when={props.error && (validRecord() === false || validSchema() === false)}>
372
+
<span class="iconify lucide--x text-red-500 dark:text-red-400"></span>
···
<RecordTab tab="record" label="Record" />
<RecordTab tab="schema" label="Schema" />
<RecordTab tab="backlinks" label="Backlinks" />
385
-
<RecordTab tab="info" label="Info" />
386
+
<RecordTab tab="info" label="Info" error />
<div class="flex gap-0.5">
<Show when={agent() && agent()?.sub === record()?.uri.split("/")[2]}>