This repository has no description
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import {
5 type LexiconDoc,
6 Lexicons,
7 ValidationError,
8 type ValidationResult,
9} from '@atproto/lexicon';
10import { type $Typed, is$typed, maybe$typed } from './util.js';
11
12export const schemaDict = {
13 NetworkCosmikCard: {
14 lexicon: 1,
15 id: 'network.cosmik.card',
16 description: 'A single record type for all cards.',
17 defs: {
18 main: {
19 type: 'record',
20 description: 'A record representing a card with content.',
21 key: 'tid',
22 record: {
23 type: 'object',
24 required: ['type', 'content'],
25 properties: {
26 type: {
27 type: 'string',
28 description: 'The type of card',
29 knownValues: ['URL', 'NOTE'],
30 },
31 content: {
32 type: 'union',
33 description:
34 'The specific content of the card, determined by the card type.',
35 refs: [
36 'lex:network.cosmik.card#urlContent',
37 'lex:network.cosmik.card#noteContent',
38 ],
39 },
40 url: {
41 type: 'string',
42 format: 'uri',
43 description:
44 'Optional URL associated with the card. Required for URL cards, optional for NOTE cards.',
45 },
46 parentCard: {
47 type: 'ref',
48 description:
49 'Optional strong reference to a parent card (for NOTE cards).',
50 ref: 'lex:com.atproto.repo.strongRef',
51 },
52 createdAt: {
53 type: 'string',
54 format: 'datetime',
55 description:
56 'Timestamp when this card was created (usually set by PDS).',
57 },
58 originalCard: {
59 type: 'ref',
60 description:
61 'Optional strong reference to the original card (for NOTE cards).',
62 ref: 'lex:com.atproto.repo.strongRef',
63 },
64 provenance: {
65 type: 'ref',
66 description: 'Optional provenance information for this card.',
67 ref: 'lex:network.cosmik.defs#provenance',
68 },
69 },
70 },
71 },
72 urlContent: {
73 type: 'object',
74 description: 'Content structure for a URL card.',
75 required: ['url'],
76 properties: {
77 url: {
78 type: 'string',
79 format: 'uri',
80 description: 'The URL being saved',
81 },
82 metadata: {
83 type: 'ref',
84 ref: 'lex:network.cosmik.card#urlMetadata',
85 description: 'Optional metadata about the URL',
86 },
87 },
88 },
89 noteContent: {
90 type: 'object',
91 description: 'Content structure for a note card.',
92 required: ['text'],
93 properties: {
94 text: {
95 type: 'string',
96 description: 'The note text content',
97 maxLength: 10000,
98 },
99 },
100 },
101 urlMetadata: {
102 type: 'object',
103 description: 'Metadata about a URL.',
104 properties: {
105 title: {
106 type: 'string',
107 description: 'Title of the page',
108 },
109 description: {
110 type: 'string',
111 description: 'Description of the page',
112 },
113 author: {
114 type: 'string',
115 description: 'Author of the content',
116 },
117 publishedDate: {
118 type: 'string',
119 format: 'datetime',
120 description: 'When the content was published',
121 },
122 siteName: {
123 type: 'string',
124 description: 'Name of the site',
125 },
126 imageUrl: {
127 type: 'string',
128 format: 'uri',
129 description: 'URL of a representative image',
130 },
131 type: {
132 type: 'string',
133 description: "Type of content (e.g., 'video', 'article')",
134 },
135 retrievedAt: {
136 type: 'string',
137 format: 'datetime',
138 description: 'When the metadata was retrieved',
139 },
140 doi: {
141 type: 'string',
142 description: 'Digital Object Identifier (DOI) for academic content',
143 },
144 isbn: {
145 type: 'string',
146 description: 'International Standard Book Number (ISBN) for books',
147 },
148 },
149 },
150 },
151 },
152 NetworkCosmikCollection: {
153 lexicon: 1,
154 id: 'network.cosmik.collection',
155 description: 'A single record type for collections of cards.',
156 defs: {
157 main: {
158 type: 'record',
159 description: 'A record representing a collection of cards.',
160 key: 'tid',
161 record: {
162 type: 'object',
163 required: ['name', 'accessType'],
164 properties: {
165 name: {
166 type: 'string',
167 description: 'Name of the collection',
168 maxLength: 100,
169 },
170 description: {
171 type: 'string',
172 description: 'Description of the collection',
173 maxLength: 500,
174 },
175 accessType: {
176 type: 'string',
177 description: 'Access control for the collection',
178 knownValues: ['OPEN', 'CLOSED'],
179 },
180 collaborators: {
181 type: 'array',
182 description:
183 'List of collaborator DIDs who can add cards to closed collections',
184 items: {
185 type: 'string',
186 description: 'DID of a collaborator',
187 },
188 },
189 createdAt: {
190 type: 'string',
191 format: 'datetime',
192 description:
193 'Timestamp when this collection was created (usually set by PDS).',
194 },
195 updatedAt: {
196 type: 'string',
197 format: 'datetime',
198 description: 'Timestamp when this collection was last updated.',
199 },
200 },
201 },
202 },
203 },
204 },
205 NetworkCosmikCollectionLink: {
206 lexicon: 1,
207 id: 'network.cosmik.collectionLink',
208 description: 'A record that links a card to a collection.',
209 defs: {
210 main: {
211 type: 'record',
212 description:
213 'A record representing the relationship between a card and a collection.',
214 key: 'tid',
215 record: {
216 type: 'object',
217 required: ['collection', 'card', 'addedBy', 'addedAt'],
218 properties: {
219 collection: {
220 type: 'ref',
221 description: 'Strong reference to the collection record.',
222 ref: 'lex:com.atproto.repo.strongRef',
223 },
224 card: {
225 type: 'ref',
226 description:
227 'Strong reference to the card record in the users library.',
228 ref: 'lex:com.atproto.repo.strongRef',
229 },
230 originalCard: {
231 type: 'ref',
232 description:
233 'Strong reference to the original card record (may be in another library).',
234 ref: 'lex:com.atproto.repo.strongRef',
235 },
236 addedBy: {
237 type: 'string',
238 description:
239 'DID of the user who added the card to the collection',
240 },
241 addedAt: {
242 type: 'string',
243 format: 'datetime',
244 description:
245 'Timestamp when the card was added to the collection.',
246 },
247 createdAt: {
248 type: 'string',
249 format: 'datetime',
250 description:
251 'Timestamp when this link record was created (usually set by PDS).',
252 },
253 provenance: {
254 type: 'ref',
255 description: 'Optional provenance information for this link.',
256 ref: 'lex:network.cosmik.defs#provenance',
257 },
258 },
259 },
260 },
261 },
262 },
263 NetworkCosmikCollectionLinkRemoval: {
264 lexicon: 1,
265 id: 'network.cosmik.collectionLinkRemoval',
266 description:
267 'A record indicating that a card was removed from a collection by the collection owner.',
268 defs: {
269 main: {
270 type: 'record',
271 description:
272 "A record representing the removal of a collection link by a collection owner when they cannot delete the original link (which exists in another user's repository). The creator of this record (determined from the AT-URI) is the user who performed the removal.",
273 key: 'tid',
274 record: {
275 type: 'object',
276 required: ['collection', 'removedLink', 'removedAt'],
277 properties: {
278 collection: {
279 type: 'ref',
280 description: 'Strong reference to the collection record.',
281 ref: 'lex:com.atproto.repo.strongRef',
282 },
283 removedLink: {
284 type: 'ref',
285 description:
286 'Strong reference to the collectionLink record that is being removed.',
287 ref: 'lex:com.atproto.repo.strongRef',
288 },
289 removedAt: {
290 type: 'string',
291 format: 'datetime',
292 description:
293 'Timestamp when the link was removed from the collection.',
294 },
295 },
296 },
297 },
298 },
299 },
300 NetworkCosmikDefs: {
301 lexicon: 1,
302 id: 'network.cosmik.defs',
303 description: 'Common definitions for annotation types and references',
304 defs: {
305 provenance: {
306 type: 'object',
307 description: 'Represents the provenance or source of a record.',
308 properties: {
309 via: {
310 type: 'ref',
311 description:
312 'Strong reference to the card that led to this record.',
313 ref: 'lex:com.atproto.repo.strongRef',
314 },
315 },
316 },
317 },
318 },
319 ComAtprotoRepoStrongRef: {
320 lexicon: 1,
321 id: 'com.atproto.repo.strongRef',
322 description: 'A URI with a content-hash fingerprint.',
323 defs: {
324 main: {
325 type: 'object',
326 required: ['uri', 'cid'],
327 properties: {
328 cid: {
329 type: 'string',
330 format: 'cid',
331 },
332 uri: {
333 type: 'string',
334 format: 'at-uri',
335 },
336 },
337 },
338 },
339 },
340 AtMarginAnnotation: {
341 defs: {
342 body: {
343 description: 'Annotation body - the content of the annotation',
344 properties: {
345 format: {
346 default: 'text/plain',
347 description: 'MIME type of the body content',
348 type: 'string',
349 },
350 language: {
351 description: 'BCP47 language tag',
352 type: 'string',
353 },
354 uri: {
355 description: 'Reference to external body content',
356 format: 'uri',
357 type: 'string',
358 },
359 value: {
360 description: 'Text content of the annotation',
361 maxGraphemes: 3000,
362 maxLength: 10000,
363 type: 'string',
364 },
365 },
366 type: 'object',
367 },
368 cssSelector: {
369 description: 'W3C CssSelector - select DOM elements by CSS selector',
370 properties: {
371 type: {
372 const: 'CssSelector',
373 type: 'string',
374 },
375 value: {
376 description: 'CSS selector string',
377 maxLength: 2000,
378 type: 'string',
379 },
380 },
381 required: ['value'],
382 type: 'object',
383 },
384 fragmentSelector: {
385 description: 'W3C FragmentSelector - select by URI fragment',
386 properties: {
387 conformsTo: {
388 description: 'Specification the fragment conforms to',
389 format: 'uri',
390 type: 'string',
391 },
392 type: {
393 const: 'FragmentSelector',
394 type: 'string',
395 },
396 value: {
397 description: 'Fragment identifier value',
398 maxLength: 1000,
399 type: 'string',
400 },
401 },
402 required: ['value'],
403 type: 'object',
404 },
405 main: {
406 description: 'A W3C-compliant web annotation stored on the AT Protocol',
407 key: 'tid',
408 record: {
409 properties: {
410 body: {
411 description: 'The annotation content (text or reference)',
412 ref: 'lex:at.margin.annotation#body',
413 type: 'ref',
414 },
415 createdAt: {
416 format: 'datetime',
417 type: 'string',
418 },
419 motivation: {
420 description: 'W3C motivation for the annotation',
421 knownValues: [
422 'commenting',
423 'highlighting',
424 'bookmarking',
425 'tagging',
426 'describing',
427 'linking',
428 'replying',
429 'editing',
430 'questioning',
431 'assessing',
432 ],
433 type: 'string',
434 },
435 tags: {
436 description: 'Tags for categorization',
437 items: {
438 maxGraphemes: 32,
439 maxLength: 64,
440 type: 'string',
441 },
442 maxLength: 10,
443 type: 'array',
444 },
445 target: {
446 description:
447 'The resource being annotated with optional selector',
448 ref: 'lex:at.margin.annotation#target',
449 type: 'ref',
450 },
451 },
452 required: ['target', 'createdAt'],
453 type: 'object',
454 },
455 type: 'record',
456 },
457 rangeSelector: {
458 description: 'W3C RangeSelector - select range between two selectors',
459 properties: {
460 endSelector: {
461 description: 'Selector for range end',
462 refs: [
463 'lex:at.margin.annotation#textQuoteSelector',
464 'lex:at.margin.annotation#textPositionSelector',
465 'lex:at.margin.annotation#cssSelector',
466 'lex:at.margin.annotation#xpathSelector',
467 ],
468 type: 'union',
469 },
470 startSelector: {
471 description: 'Selector for range start',
472 refs: [
473 'lex:at.margin.annotation#textQuoteSelector',
474 'lex:at.margin.annotation#textPositionSelector',
475 'lex:at.margin.annotation#cssSelector',
476 'lex:at.margin.annotation#xpathSelector',
477 ],
478 type: 'union',
479 },
480 type: {
481 const: 'RangeSelector',
482 type: 'string',
483 },
484 },
485 required: ['startSelector', 'endSelector'],
486 type: 'object',
487 },
488 target: {
489 description: 'W3C SpecificResource - the target with optional selector',
490 properties: {
491 selector: {
492 description: 'Selector to identify the specific segment',
493 refs: [
494 'lex:at.margin.annotation#textQuoteSelector',
495 'lex:at.margin.annotation#textPositionSelector',
496 'lex:at.margin.annotation#cssSelector',
497 'lex:at.margin.annotation#xpathSelector',
498 'lex:at.margin.annotation#fragmentSelector',
499 'lex:at.margin.annotation#rangeSelector',
500 ],
501 type: 'union',
502 },
503 source: {
504 description: 'The URL being annotated',
505 format: 'uri',
506 type: 'string',
507 },
508 sourceHash: {
509 description: 'SHA256 hash of normalized URL for indexing',
510 type: 'string',
511 },
512 state: {
513 description: 'State of the resource at annotation time',
514 ref: 'lex:at.margin.annotation#timeState',
515 type: 'ref',
516 },
517 title: {
518 description: 'Page title at time of annotation',
519 maxLength: 500,
520 type: 'string',
521 },
522 },
523 required: ['source'],
524 type: 'object',
525 },
526 textPositionSelector: {
527 description: 'W3C TextPositionSelector - select by character offsets',
528 properties: {
529 end: {
530 description: 'Ending character position (exclusive)',
531 minimum: 0,
532 type: 'integer',
533 },
534 start: {
535 description: 'Starting character position (0-indexed, inclusive)',
536 minimum: 0,
537 type: 'integer',
538 },
539 type: {
540 const: 'TextPositionSelector',
541 type: 'string',
542 },
543 },
544 required: ['start', 'end'],
545 type: 'object',
546 },
547 textQuoteSelector: {
548 description:
549 'W3C TextQuoteSelector - select text by quoting it with context',
550 properties: {
551 exact: {
552 description: 'The exact text to match',
553 maxGraphemes: 1500,
554 maxLength: 5000,
555 type: 'string',
556 },
557 prefix: {
558 description: 'Text immediately before the selection',
559 maxGraphemes: 150,
560 maxLength: 500,
561 type: 'string',
562 },
563 suffix: {
564 description: 'Text immediately after the selection',
565 maxGraphemes: 150,
566 maxLength: 500,
567 type: 'string',
568 },
569 type: {
570 const: 'TextQuoteSelector',
571 type: 'string',
572 },
573 },
574 required: ['exact'],
575 type: 'object',
576 },
577 timeState: {
578 description: 'W3C TimeState - record when content was captured',
579 properties: {
580 cached: {
581 description: 'URL to cached/archived version',
582 format: 'uri',
583 type: 'string',
584 },
585 sourceDate: {
586 description: 'When the source was accessed',
587 format: 'datetime',
588 type: 'string',
589 },
590 },
591 type: 'object',
592 },
593 xpathSelector: {
594 description: 'W3C XPathSelector - select by XPath expression',
595 properties: {
596 type: {
597 const: 'XPathSelector',
598 type: 'string',
599 },
600 value: {
601 description: 'XPath expression',
602 maxLength: 2000,
603 type: 'string',
604 },
605 },
606 required: ['value'],
607 type: 'object',
608 },
609 },
610 description:
611 'W3C Web Annotation Data Model compliant annotation record for ATProto',
612 id: 'at.margin.annotation',
613 lexicon: 1,
614 revision: 2,
615 },
616 AtMarginBookmark: {
617 defs: {
618 main: {
619 description: 'A bookmarked URL (motivation: bookmarking)',
620 key: 'tid',
621 record: {
622 properties: {
623 createdAt: {
624 format: 'datetime',
625 type: 'string',
626 },
627 description: {
628 description: 'Optional description/note',
629 maxGraphemes: 300,
630 maxLength: 1000,
631 type: 'string',
632 },
633 source: {
634 description: 'The bookmarked URL',
635 format: 'uri',
636 type: 'string',
637 },
638 sourceHash: {
639 description: 'SHA256 hash of normalized URL for indexing',
640 type: 'string',
641 },
642 tags: {
643 description: 'Tags for categorization',
644 items: {
645 maxGraphemes: 32,
646 maxLength: 64,
647 type: 'string',
648 },
649 maxLength: 10,
650 type: 'array',
651 },
652 title: {
653 description: 'Page title',
654 maxLength: 500,
655 type: 'string',
656 },
657 },
658 required: ['source', 'createdAt'],
659 type: 'object',
660 },
661 type: 'record',
662 },
663 },
664 description: 'A bookmark record - save URL for later',
665 id: 'at.margin.bookmark',
666 lexicon: 1,
667 },
668 AtMarginCollection: {
669 defs: {
670 main: {
671 description: 'A named collection for organizing annotations',
672 key: 'tid',
673 record: {
674 properties: {
675 createdAt: {
676 format: 'datetime',
677 type: 'string',
678 },
679 description: {
680 description: 'Collection description',
681 maxGraphemes: 150,
682 maxLength: 500,
683 type: 'string',
684 },
685 icon: {
686 description: 'Emoji icon or icon identifier for the collection',
687 maxGraphemes: 100,
688 maxLength: 100,
689 type: 'string',
690 },
691 name: {
692 description: 'Collection name',
693 maxGraphemes: 50,
694 maxLength: 100,
695 type: 'string',
696 },
697 },
698 required: ['name', 'createdAt'],
699 type: 'object',
700 },
701 type: 'record',
702 },
703 },
704 description: 'A collection of annotations (like a folder or notebook)',
705 id: 'at.margin.collection',
706 lexicon: 1,
707 },
708 AtMarginCollectionItem: {
709 defs: {
710 main: {
711 description: 'Associates an annotation with a collection',
712 key: 'tid',
713 record: {
714 properties: {
715 annotation: {
716 description: 'AT URI of the annotation, highlight, or bookmark',
717 format: 'at-uri',
718 type: 'string',
719 },
720 collection: {
721 description: 'AT URI of the collection',
722 format: 'at-uri',
723 type: 'string',
724 },
725 createdAt: {
726 format: 'datetime',
727 type: 'string',
728 },
729 position: {
730 description: 'Sort order within the collection',
731 minimum: 0,
732 type: 'integer',
733 },
734 },
735 required: ['collection', 'annotation', 'createdAt'],
736 type: 'object',
737 },
738 type: 'record',
739 },
740 },
741 description: 'An item in a collection (links annotation to collection)',
742 id: 'at.margin.collectionItem',
743 lexicon: 1,
744 },
745 AtMarginHighlight: {
746 defs: {
747 main: {
748 description: 'A highlight on a web page (motivation: highlighting)',
749 key: 'tid',
750 record: {
751 properties: {
752 color: {
753 description: 'Highlight color (hex or named)',
754 maxLength: 20,
755 type: 'string',
756 },
757 createdAt: {
758 format: 'datetime',
759 type: 'string',
760 },
761 tags: {
762 description: 'Tags for categorization',
763 items: {
764 maxGraphemes: 32,
765 maxLength: 64,
766 type: 'string',
767 },
768 maxLength: 10,
769 type: 'array',
770 },
771 target: {
772 description: 'The resource and segment being highlighted',
773 ref: 'lex:at.margin.annotation#target',
774 type: 'ref',
775 },
776 },
777 required: ['target', 'createdAt'],
778 type: 'object',
779 },
780 type: 'record',
781 },
782 },
783 description:
784 'A lightweight highlight record - annotation without body text',
785 id: 'at.margin.highlight',
786 lexicon: 1,
787 },
788 AtMarginLike: {
789 defs: {
790 main: {
791 description: 'A like on an annotation or reply',
792 key: 'tid',
793 record: {
794 properties: {
795 createdAt: {
796 format: 'datetime',
797 type: 'string',
798 },
799 subject: {
800 description: 'Reference to the annotation or reply being liked',
801 ref: 'lex:at.margin.like#subjectRef',
802 type: 'ref',
803 },
804 },
805 required: ['subject', 'createdAt'],
806 type: 'object',
807 },
808 type: 'record',
809 },
810 subjectRef: {
811 properties: {
812 cid: {
813 format: 'cid',
814 type: 'string',
815 },
816 uri: {
817 format: 'at-uri',
818 type: 'string',
819 },
820 },
821 required: ['uri', 'cid'],
822 type: 'object',
823 },
824 },
825 id: 'at.margin.like',
826 lexicon: 1,
827 },
828 AtMarginProfile: {
829 defs: {
830 main: {
831 description: 'A profile for a user on the Margin network.',
832 key: 'literal:self',
833 record: {
834 properties: {
835 bio: {
836 description: 'User biography or description.',
837 maxLength: 5000,
838 type: 'string',
839 },
840 createdAt: {
841 format: 'datetime',
842 type: 'string',
843 },
844 links: {
845 description:
846 'List of other relevant links (e.g. GitHub, Bluesky, etc).',
847 items: {
848 maxLength: 1000,
849 type: 'string',
850 },
851 maxLength: 20,
852 type: 'array',
853 },
854 website: {
855 description: 'User website URL.',
856 maxLength: 1000,
857 type: 'string',
858 },
859 },
860 required: ['createdAt'],
861 type: 'object',
862 },
863 type: 'record',
864 },
865 },
866 id: 'at.margin.profile',
867 lexicon: 1,
868 },
869 AtMarginReply: {
870 defs: {
871 main: {
872 description: 'A reply to an annotation (motivation: replying)',
873 key: 'tid',
874 record: {
875 properties: {
876 createdAt: {
877 format: 'datetime',
878 type: 'string',
879 },
880 format: {
881 default: 'text/plain',
882 description: 'MIME type of the text content',
883 type: 'string',
884 },
885 parent: {
886 description: 'Reference to the parent annotation or reply',
887 ref: 'lex:at.margin.reply#replyRef',
888 type: 'ref',
889 },
890 root: {
891 description: 'Reference to the root annotation of the thread',
892 ref: 'lex:at.margin.reply#replyRef',
893 type: 'ref',
894 },
895 text: {
896 description: 'Reply text content',
897 maxGraphemes: 3000,
898 maxLength: 10000,
899 type: 'string',
900 },
901 },
902 required: ['parent', 'root', 'text', 'createdAt'],
903 type: 'object',
904 },
905 type: 'record',
906 },
907 replyRef: {
908 description: 'Strong reference to an annotation or reply',
909 properties: {
910 cid: {
911 format: 'cid',
912 type: 'string',
913 },
914 uri: {
915 format: 'at-uri',
916 type: 'string',
917 },
918 },
919 required: ['uri', 'cid'],
920 type: 'object',
921 },
922 },
923 description: 'A reply to an annotation or another reply',
924 id: 'at.margin.reply',
925 lexicon: 1,
926 revision: 2,
927 },
928} as const satisfies Record<string, LexiconDoc>;
929export const schemas = Object.values(schemaDict) satisfies LexiconDoc[];
930export const lexicons: Lexicons = new Lexicons(schemas);
931
932export function validate<T extends { $type: string }>(
933 v: unknown,
934 id: string,
935 hash: string,
936 requiredType: true,
937): ValidationResult<T>;
938export function validate<T extends { $type?: string }>(
939 v: unknown,
940 id: string,
941 hash: string,
942 requiredType?: false,
943): ValidationResult<T>;
944export function validate(
945 v: unknown,
946 id: string,
947 hash: string,
948 requiredType?: boolean,
949): ValidationResult {
950 return (requiredType ? is$typed : maybe$typed)(v, id, hash)
951 ? lexicons.validate(`${id}#${hash}`, v)
952 : {
953 success: false,
954 error: new ValidationError(
955 `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`,
956 ),
957 };
958}
959
960export const ids = {
961 NetworkCosmikCard: 'network.cosmik.card',
962 NetworkCosmikCollection: 'network.cosmik.collection',
963 NetworkCosmikCollectionLink: 'network.cosmik.collectionLink',
964 NetworkCosmikCollectionLinkRemoval: 'network.cosmik.collectionLinkRemoval',
965 NetworkCosmikDefs: 'network.cosmik.defs',
966 ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef',
967 AtMarginAnnotation: 'at.margin.annotation',
968 AtMarginBookmark: 'at.margin.bookmark',
969 AtMarginCollection: 'at.margin.collection',
970 AtMarginCollectionItem: 'at.margin.collectionItem',
971 AtMarginHighlight: 'at.margin.highlight',
972 AtMarginLike: 'at.margin.like',
973 AtMarginProfile: 'at.margin.profile',
974 AtMarginReply: 'at.margin.reply',
975} as const;