···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 { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util'
88-import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js'
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';
9131014const is$typed = _is$typed,
1111- validate = _validate
1212-const id = 'network.cosmik.collectionLink'
1515+ validate = _validate;
1616+const id = 'network.cosmik.collectionLink';
13171418export interface Record {
1515- $type: 'network.cosmik.collectionLink'
1616- collection: ComAtprotoRepoStrongRef.Main
1717- card: ComAtprotoRepoStrongRef.Main
1818- originalCard?: ComAtprotoRepoStrongRef.Main
1919+ $type: 'network.cosmik.collectionLink';
2020+ collection: ComAtprotoRepoStrongRef.Main;
2121+ card: ComAtprotoRepoStrongRef.Main;
2222+ originalCard?: ComAtprotoRepoStrongRef.Main;
1923 /** DID of the user who added the card to the collection */
2020- addedBy: string
2424+ addedBy: string;
2125 /** Timestamp when the card was added to the collection. */
2222- addedAt: string
2626+ addedAt: string;
2327 /** Timestamp when this link record was created (usually set by PDS). */
2424- createdAt?: string
2525- [k: string]: unknown
2828+ createdAt?: string;
2929+ [k: string]: unknown;
2630}
27312828-const hashRecord = 'main'
3232+const hashRecord = 'main';
29333034export function isRecord<V>(v: V) {
3131- return is$typed(v, id, hashRecord)
3535+ return is$typed(v, id, hashRecord);
3236}
33373438export function validateRecord<V>(v: V) {
3535- return validate<Record & V>(v, id, hashRecord, true)
3939+ return validate<Record & V>(v, id, hashRecord, true);
3640}
···22 * GENERATED CODE - DO NOT MODIFY
33 */
4455-import { type ValidationResult } from '@atproto/lexicon'
55+import { type ValidationResult } from '@atproto/lexicon';
6677export type OmitKey<T, K extends keyof T> = {
88- [K2 in keyof T as K2 extends K ? never : K2]: T[K2]
99-}
88+ [K2 in keyof T as K2 extends K ? never : K2]: T[K2];
99+};
10101111-export type $Typed<V, T extends string = string> = V & { $type: T }
1212-export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>
1111+export type $Typed<V, T extends string = string> = V & { $type: T };
1212+export type Un$Typed<V extends { $type?: string }> = OmitKey<V, '$type'>;
13131414export type $Type<Id extends string, Hash extends string> = Hash extends 'main'
1515 ? Id
1616- : `${Id}#${Hash}`
1616+ : `${Id}#${Hash}`;
17171818function isObject<V>(v: V): v is V & object {
1919- return v != null && typeof v === 'object'
1919+ return v != null && typeof v === 'object';
2020}
21212222function is$type<Id extends string, Hash extends string>(
···3131 $type.length === id.length + 1 + hash.length &&
3232 $type.charCodeAt(id.length) === 35 /* '#' */ &&
3333 $type.startsWith(id) &&
3434- $type.endsWith(hash)
3434+ $type.endsWith(hash);
3535}
36363737export type $TypedObject<
···3939 Id extends string,
4040 Hash extends string,
4141> = V extends {
4242- $type: $Type<Id, Hash>
4242+ $type: $Type<Id, Hash>;
4343}
4444 ? V
4545 : V extends { $type?: string }
4646 ? V extends { $type?: infer T extends $Type<Id, Hash> }
4747 ? V & { $type: T }
4848 : never
4949- : V & { $type: $Type<Id, Hash> }
4949+ : V & { $type: $Type<Id, Hash> };
50505151export function is$typed<V, Id extends string, Hash extends string>(
5252 v: V,
5353 id: Id,
5454 hash: Hash,
5555): v is $TypedObject<V, Id, Hash> {
5656- return isObject(v) && '$type' in v && is$type(v.$type, id, hash)
5656+ return isObject(v) && '$type' in v && is$type(v.$type, id, hash);
5757}
58585959export function maybe$typed<V, Id extends string, Hash extends string>(
···6464 return (
6565 isObject(v) &&
6666 ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true)
6767- )
6767+ );
6868}
69697070-export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>
7070+export type Validator<R = unknown> = (v: unknown) => ValidationResult<R>;
7171export type ValidatorParam<V extends Validator> =
7272- V extends Validator<infer R> ? R : never
7272+ V extends Validator<infer R> ? R : never;
73737474/**
7575 * Utility function that allows to convert a "validate*" utility function into a
···7777 */
7878export function asPredicate<V extends Validator>(validate: V) {
7979 return function <T>(v: T): v is T & ValidatorParam<V> {
8080- return validate(v).success
8181- }
8080+ return validate(v).success;
8181+ };
8282}
+27-9
src/modules/cards/domain/Card.ts
···1414 URL_CARD_CANNOT_HAVE_PARENT: 'URL cards cannot have parent cards',
1515 URL_CARD_MUST_HAVE_URL: 'URL cards must have a url property',
1616 URL_CARD_SINGLE_LIBRARY_ONLY: 'URL cards can only be in one library',
1717- URL_CARD_CREATOR_LIBRARY_ONLY: 'URL cards can only be in the library of the creator',
1818- LIBRARY_COUNT_MISMATCH: 'Library count does not match library memberships length',
1717+ URL_CARD_CREATOR_LIBRARY_ONLY:
1818+ 'URL cards can only be in the library of the creator',
1919+ LIBRARY_COUNT_MISMATCH:
2020+ 'Library count does not match library memberships length',
1921 CANNOT_CHANGE_CONTENT_TYPE: 'Cannot change card content to different type',
2022 ALREADY_IN_LIBRARY: "Card is already in user's library",
2123 NOT_IN_LIBRARY: "Card is not in user's library",
···123125 ): Result<Card, CardValidationError> {
124126 // Validate content type matches card type
125127 if (props.type.value !== props.content.type) {
126126- return err(new CardValidationError(CARD_ERROR_MESSAGES.CARD_TYPE_CONTENT_MISMATCH));
128128+ return err(
129129+ new CardValidationError(CARD_ERROR_MESSAGES.CARD_TYPE_CONTENT_MISMATCH),
130130+ );
127131 }
128132129133 // Validate parent/source card relationships
···157161 ): Result<void, CardValidationError> {
158162 // URL cards should not have parent cards
159163 if (props.type.value === CardTypeEnum.URL && props.parentCardId) {
160160- return err(new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_CANNOT_HAVE_PARENT));
164164+ return err(
165165+ new CardValidationError(
166166+ CARD_ERROR_MESSAGES.URL_CARD_CANNOT_HAVE_PARENT,
167167+ ),
168168+ );
161169 }
162170163171 // URL cards must have a URL property
164172 if (props.type.value === CardTypeEnum.URL && !props.url) {
165165- return err(new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_MUST_HAVE_URL));
173173+ return err(
174174+ new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_MUST_HAVE_URL),
175175+ );
166176 }
167177168178 // URL cards can only be in one library
···172182 libraryMemberships.length > 1
173183 ) {
174184 return err(
175175- new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY),
185185+ new CardValidationError(
186186+ CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY,
187187+ ),
176188 );
177189 }
178190···186198 );
187199 if (hasNonCreatorMembership) {
188200 return err(
189189- new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_CREATOR_LIBRARY_ONLY),
201201+ new CardValidationError(
202202+ CARD_ERROR_MESSAGES.URL_CARD_CREATOR_LIBRARY_ONLY,
203203+ ),
190204 );
191205 }
192206 }
···227241 link.curatorId.equals(userId),
228242 )
229243 ) {
230230- return err(new CardValidationError(CARD_ERROR_MESSAGES.ALREADY_IN_LIBRARY));
244244+ return err(
245245+ new CardValidationError(CARD_ERROR_MESSAGES.ALREADY_IN_LIBRARY),
246246+ );
231247 }
232248233249 // URL cards can only be in one library
234250 if (this.isUrlCard && this.props.libraryMemberships.length > 0) {
235251 return err(
236236- new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY),
252252+ new CardValidationError(
253253+ CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY,
254254+ ),
237255 );
238256 }
239257