···11-/**
22- * GENERATED CODE - DO NOT MODIFY
33- */
44-import { type ValidationResult, BlobRef } from '@atproto/lexicon';
55-import { CID } from 'multiformats/cid';
66-import { validate as _validate } from '../../../lexicons';
77-import {
88- type $Typed,
99- is$typed as _is$typed,
1010- type OmitKey,
1111-} from '../../../util';
1212-import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js';
1313-1414-const is$typed = _is$typed,
1515- validate = _validate;
1616-const id = 'network.cosmik.annotationTemplate';
1717-1818-export interface Record {
1919- $type: 'network.cosmik.annotationTemplate';
2020- /** Name of the template */
2121- name: string;
2222- /** Description of the template */
2323- description: string;
2424- /** List of strong references to network.cosmik.annotationField records included in this template. */
2525- annotationFields: AnnotationFieldRef[];
2626- /** Timestamp when this template was created */
2727- createdAt?: string;
2828- [k: string]: unknown;
2929-}
3030-3131-const hashRecord = 'main';
3232-3333-export function isRecord<V>(v: V) {
3434- return is$typed(v, id, hashRecord);
3535-}
3636-3737-export function validateRecord<V>(v: V) {
3838- return validate<Record & V>(v, id, hashRecord, true);
3939-}
4040-4141-/** A reference to an annotation field. Defines if the field is required in the template. */
4242-export interface AnnotationFieldRef {
4343- $type?: 'network.cosmik.annotationTemplate#annotationFieldRef';
4444- subject: ComAtprotoRepoStrongRef.Main;
4545- required?: boolean;
4646-}
4747-4848-const hashAnnotationFieldRef = 'annotationFieldRef';
4949-5050-export function isAnnotationFieldRef<V>(v: V) {
5151- return is$typed(v, id, hashAnnotationFieldRef);
5252-}
5353-5454-export function validateAnnotationFieldRef<V>(v: V) {
5555- return validate<AnnotationFieldRef & V>(v, id, hashAnnotationFieldRef);
5656-}
···7777/** Metadata about a URL. */
7878export interface UrlMetadata {
7979 $type?: 'network.cosmik.card#urlMetadata';
8080- /** The URL */
8181- url: string;
8280 /** Title of the page */
8381 title?: string;
8482 /** Description of the page */
···1919 $type: 'network.cosmik.collectionLink';
2020 collection: ComAtprotoRepoStrongRef.Main;
2121 card: ComAtprotoRepoStrongRef.Main;
2222+ originalCard?: ComAtprotoRepoStrongRef.Main;
2223 /** DID of the user who added the card to the collection */
2324 addedBy: string;
2425 /** Timestamp when the card was added to the collection. */
2525- addedAt?: string;
2626+ addedAt: string;
2627 /** Timestamp when this link record was created (usually set by PDS). */
2728 createdAt?: string;
2829 [k: string]: unknown;
···1919 // Cards table (references published_records and self-references)
2020 sql`CREATE TABLE IF NOT EXISTS cards (
2121 id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
2222+ author_id TEXT NOT NULL,
2223 type TEXT NOT NULL,
2324 content_data JSONB NOT NULL,
2425 url TEXT,
2526 parent_card_id UUID REFERENCES cards(id),
2626- original_published_record_id UUID REFERENCES published_records(id),
2727+ published_record_id UUID REFERENCES published_records(id),
2728 library_count INTEGER NOT NULL DEFAULT 0,
2829 created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
2930 updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
···102103 // Index for efficient AT URI lookups
103104 await db.execute(sql`
104105 CREATE INDEX IF NOT EXISTS published_records_uri_idx ON published_records(uri);
106106+ `);
107107+108108+ // Cards table indexes
109109+ await db.execute(sql`
110110+ CREATE INDEX IF NOT EXISTS cards_author_url_idx ON cards(author_id, url);
111111+ `);
112112+ await db.execute(sql`
113113+ CREATE INDEX IF NOT EXISTS cards_author_id_idx ON cards(author_id);
114114+ `);
115115+116116+ // Collections table indexes
117117+ await db.execute(sql`
118118+ CREATE INDEX IF NOT EXISTS collections_author_id_idx ON collections(author_id);
119119+ `);
120120+ await db.execute(sql`
121121+ CREATE INDEX IF NOT EXISTS collections_author_updated_at_idx ON collections(author_id, updated_at);
122122+ `);
123123+124124+ // Collection cards table indexes
125125+ await db.execute(sql`
126126+ CREATE INDEX IF NOT EXISTS collection_cards_card_id_idx ON collection_cards(card_id);
127127+ `);
128128+ await db.execute(sql`
129129+ CREATE INDEX IF NOT EXISTS collection_cards_collection_id_idx ON collection_cards(collection_id);
105130 `);
106131}
···11+CREATE INDEX "cards_author_url_idx" ON "cards" USING btree ("author_id","url");--> statement-breakpoint
22+CREATE INDEX "cards_author_id_idx" ON "cards" USING btree ("author_id");--> statement-breakpoint
33+CREATE INDEX "collection_cards_card_id_idx" ON "collection_cards" USING btree ("card_id");--> statement-breakpoint
44+CREATE INDEX "collection_cards_collection_id_idx" ON "collection_cards" USING btree ("collection_id");--> statement-breakpoint
55+CREATE INDEX "collections_author_id_idx" ON "collections" USING btree ("author_id");--> statement-breakpoint
66+CREATE INDEX "collections_author_updated_at_idx" ON "collections" USING btree ("author_id","updated_at");