diff --git a/src/modules/atproto/infrastructure/lexicon/index.ts b/src/modules/atproto/infrastructure/lexicon/index.ts index 9d24d6c3..21d14790 100644 --- a/src/modules/atproto/infrastructure/lexicon/index.ts +++ b/src/modules/atproto/infrastructure/lexicon/index.ts @@ -7,93 +7,93 @@ import { type Options as XrpcOptions, type AuthVerifier, type StreamAuthVerifier, -} from '@atproto/xrpc-server' -import { schemas } from './lexicons.js' +} from '@atproto/xrpc-server'; +import { schemas } from './lexicons.js'; export function createServer(options?: XrpcOptions): Server { - return new Server(options) + return new Server(options); } export class Server { - xrpc: XrpcServer - network: NetworkNS - com: ComNS + xrpc: XrpcServer; + network: NetworkNS; + com: ComNS; constructor(options?: XrpcOptions) { - this.xrpc = createXrpcServer(schemas, options) - this.network = new NetworkNS(this) - this.com = new ComNS(this) + this.xrpc = createXrpcServer(schemas, options); + this.network = new NetworkNS(this); + this.com = new ComNS(this); } } export class NetworkNS { - _server: Server - cosmik: NetworkCosmikNS + _server: Server; + cosmik: NetworkCosmikNS; constructor(server: Server) { - this._server = server - this.cosmik = new NetworkCosmikNS(server) + this._server = server; + this.cosmik = new NetworkCosmikNS(server); } } export class NetworkCosmikNS { - _server: Server + _server: Server; constructor(server: Server) { - this._server = server + this._server = server; } } export class ComNS { - _server: Server - atproto: ComAtprotoNS + _server: Server; + atproto: ComAtprotoNS; constructor(server: Server) { - this._server = server - this.atproto = new ComAtprotoNS(server) + this._server = server; + this.atproto = new ComAtprotoNS(server); } } export class ComAtprotoNS { - _server: Server - repo: ComAtprotoRepoNS + _server: Server; + repo: ComAtprotoRepoNS; constructor(server: Server) { - this._server = server - this.repo = new ComAtprotoRepoNS(server) + this._server = server; + this.repo = new ComAtprotoRepoNS(server); } } export class ComAtprotoRepoNS { - _server: Server + _server: Server; constructor(server: Server) { - this._server = server + this._server = server; } } type SharedRateLimitOpts = { - name: string - calcKey?: (ctx: T) => string | null - calcPoints?: (ctx: T) => number -} + name: string; + calcKey?: (ctx: T) => string | null; + calcPoints?: (ctx: T) => number; +}; type RouteRateLimitOpts = { - durationMs: number - points: number - calcKey?: (ctx: T) => string | null - calcPoints?: (ctx: T) => number -} -type HandlerOpts = { blobLimit?: number } -type HandlerRateLimitOpts = SharedRateLimitOpts | RouteRateLimitOpts + durationMs: number; + points: number; + calcKey?: (ctx: T) => string | null; + calcPoints?: (ctx: T) => number; +}; +type HandlerOpts = { blobLimit?: number }; +type HandlerRateLimitOpts = SharedRateLimitOpts | RouteRateLimitOpts; type ConfigOf = | Handler | { - auth?: Auth - opts?: HandlerOpts - rateLimit?: HandlerRateLimitOpts | HandlerRateLimitOpts[] - handler: Handler - } + auth?: Auth; + opts?: HandlerOpts; + rateLimit?: HandlerRateLimitOpts | HandlerRateLimitOpts[]; + handler: Handler; + }; type ExtractAuth = Extract< Awaited>, { credentials: unknown } -> +>; diff --git a/src/modules/atproto/infrastructure/lexicon/lexicons.ts b/src/modules/atproto/infrastructure/lexicon/lexicons.ts index ae9f5a73..06f5c05b 100644 --- a/src/modules/atproto/infrastructure/lexicon/lexicons.ts +++ b/src/modules/atproto/infrastructure/lexicon/lexicons.ts @@ -6,8 +6,8 @@ import { Lexicons, ValidationError, type ValidationResult, -} from '@atproto/lexicon' -import { type $Typed, is$typed, maybe$typed } from './util.js' +} from '@atproto/lexicon'; +import { type $Typed, is$typed, maybe$typed } from './util.js'; export const schemaDict = { NetworkCosmikCard: { @@ -286,22 +286,22 @@ export const schemaDict = { }, }, }, -} as const satisfies Record -export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] -export const lexicons: Lexicons = new Lexicons(schemas) +} as const satisfies Record; +export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]; +export const lexicons: Lexicons = new Lexicons(schemas); export function validate( v: unknown, id: string, hash: string, requiredType: true, -): ValidationResult +): ValidationResult; export function validate( v: unknown, id: string, hash: string, requiredType?: false, -): ValidationResult +): ValidationResult; export function validate( v: unknown, id: string, @@ -315,7 +315,7 @@ export function validate( error: new ValidationError( `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, ), - } + }; } export const ids = { @@ -324,4 +324,4 @@ export const ids = { NetworkCosmikCollectionLink: 'network.cosmik.collectionLink', NetworkCosmikDefs: 'network.cosmik.defs', ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef', -} as const +} as const; diff --git a/src/modules/atproto/infrastructure/lexicon/types/com/atproto/repo/strongRef.ts b/src/modules/atproto/infrastructure/lexicon/types/com/atproto/repo/strongRef.ts index eac0bc16..e0149a5b 100644 --- a/src/modules/atproto/infrastructure/lexicon/types/com/atproto/repo/strongRef.ts +++ b/src/modules/atproto/infrastructure/lexicon/types/com/atproto/repo/strongRef.ts @@ -1,31 +1,31 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult, BlobRef } from '@atproto/lexicon' -import { CID } from 'multiformats/cid' -import { validate as _validate } from '../../../../lexicons' +import { type ValidationResult, BlobRef } from '@atproto/lexicon'; +import { CID } from 'multiformats/cid'; +import { validate as _validate } from '../../../../lexicons'; import { type $Typed, is$typed as _is$typed, type OmitKey, -} from '../../../../util' +} from '../../../../util'; const is$typed = _is$typed, - validate = _validate -const id = 'com.atproto.repo.strongRef' + validate = _validate; +const id = 'com.atproto.repo.strongRef'; export interface Main { - $type?: 'com.atproto.repo.strongRef' - cid: string - uri: string + $type?: 'com.atproto.repo.strongRef'; + cid: string; + uri: string; } -const hashMain = 'main' +const hashMain = 'main'; export function isMain(v: V) { - return is$typed(v, id, hashMain) + return is$typed(v, id, hashMain); } export function validateMain(v: V) { - return validate
(v, id, hashMain) + return validate
(v, id, hashMain); } diff --git a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/card.ts b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/card.ts index bd2dcf98..1fc00ae6 100644 --- a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/card.ts +++ b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/card.ts @@ -1,102 +1,106 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult, BlobRef } from '@atproto/lexicon' -import { CID } from 'multiformats/cid' -import { validate as _validate } from '../../../lexicons' -import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util' -import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js' +import { type ValidationResult, BlobRef } from '@atproto/lexicon'; +import { CID } from 'multiformats/cid'; +import { validate as _validate } from '../../../lexicons'; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from '../../../util'; +import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js'; const is$typed = _is$typed, - validate = _validate -const id = 'network.cosmik.card' + validate = _validate; +const id = 'network.cosmik.card'; export interface Record { - $type: 'network.cosmik.card' + $type: 'network.cosmik.card'; /** The type of card */ - type: 'URL' | 'NOTE' | (string & {}) - content: $Typed | $Typed | { $type: string } + type: 'URL' | 'NOTE' | (string & {}); + content: $Typed | $Typed | { $type: string }; /** Optional URL associated with the card. Required for URL cards, optional for NOTE cards. */ - url?: string - parentCard?: ComAtprotoRepoStrongRef.Main + url?: string; + parentCard?: ComAtprotoRepoStrongRef.Main; /** Timestamp when this card was created (usually set by PDS). */ - createdAt?: string - originalCard?: ComAtprotoRepoStrongRef.Main - [k: string]: unknown + createdAt?: string; + originalCard?: ComAtprotoRepoStrongRef.Main; + [k: string]: unknown; } -const hashRecord = 'main' +const hashRecord = 'main'; export function isRecord(v: V) { - return is$typed(v, id, hashRecord) + return is$typed(v, id, hashRecord); } export function validateRecord(v: V) { - return validate(v, id, hashRecord, true) + return validate(v, id, hashRecord, true); } /** Content structure for a URL card. */ export interface UrlContent { - $type?: 'network.cosmik.card#urlContent' + $type?: 'network.cosmik.card#urlContent'; /** The URL being saved */ - url: string - metadata?: UrlMetadata + url: string; + metadata?: UrlMetadata; } -const hashUrlContent = 'urlContent' +const hashUrlContent = 'urlContent'; export function isUrlContent(v: V) { - return is$typed(v, id, hashUrlContent) + return is$typed(v, id, hashUrlContent); } export function validateUrlContent(v: V) { - return validate(v, id, hashUrlContent) + return validate(v, id, hashUrlContent); } /** Content structure for a note card. */ export interface NoteContent { - $type?: 'network.cosmik.card#noteContent' + $type?: 'network.cosmik.card#noteContent'; /** The note text content */ - text: string + text: string; } -const hashNoteContent = 'noteContent' +const hashNoteContent = 'noteContent'; export function isNoteContent(v: V) { - return is$typed(v, id, hashNoteContent) + return is$typed(v, id, hashNoteContent); } export function validateNoteContent(v: V) { - return validate(v, id, hashNoteContent) + return validate(v, id, hashNoteContent); } /** Metadata about a URL. */ export interface UrlMetadata { - $type?: 'network.cosmik.card#urlMetadata' + $type?: 'network.cosmik.card#urlMetadata'; /** Title of the page */ - title?: string + title?: string; /** Description of the page */ - description?: string + description?: string; /** Author of the content */ - author?: string + author?: string; /** When the content was published */ - publishedDate?: string + publishedDate?: string; /** Name of the site */ - siteName?: string + siteName?: string; /** URL of a representative image */ - imageUrl?: string + imageUrl?: string; /** Type of content (e.g., 'video', 'article') */ - type?: string + type?: string; /** When the metadata was retrieved */ - retrievedAt?: string + retrievedAt?: string; } -const hashUrlMetadata = 'urlMetadata' +const hashUrlMetadata = 'urlMetadata'; export function isUrlMetadata(v: V) { - return is$typed(v, id, hashUrlMetadata) + return is$typed(v, id, hashUrlMetadata); } export function validateUrlMetadata(v: V) { - return validate(v, id, hashUrlMetadata) + return validate(v, id, hashUrlMetadata); } diff --git a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collection.ts b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collection.ts index ee696f15..06751324 100644 --- a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collection.ts +++ b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collection.ts @@ -1,38 +1,42 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult, BlobRef } from '@atproto/lexicon' -import { CID } from 'multiformats/cid' -import { validate as _validate } from '../../../lexicons' -import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util' +import { type ValidationResult, BlobRef } from '@atproto/lexicon'; +import { CID } from 'multiformats/cid'; +import { validate as _validate } from '../../../lexicons'; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from '../../../util'; const is$typed = _is$typed, - validate = _validate -const id = 'network.cosmik.collection' + validate = _validate; +const id = 'network.cosmik.collection'; export interface Record { - $type: 'network.cosmik.collection' + $type: 'network.cosmik.collection'; /** Name of the collection */ - name: string + name: string; /** Description of the collection */ - description?: string + description?: string; /** Access control for the collection */ - accessType: 'OPEN' | 'CLOSED' | (string & {}) + accessType: 'OPEN' | 'CLOSED' | (string & {}); /** List of collaborator DIDs who can add cards to closed collections */ - collaborators?: string[] + collaborators?: string[]; /** Timestamp when this collection was created (usually set by PDS). */ - createdAt?: string + createdAt?: string; /** Timestamp when this collection was last updated. */ - updatedAt?: string - [k: string]: unknown + updatedAt?: string; + [k: string]: unknown; } -const hashRecord = 'main' +const hashRecord = 'main'; export function isRecord(v: V) { - return is$typed(v, id, hashRecord) + return is$typed(v, id, hashRecord); } export function validateRecord(v: V) { - return validate(v, id, hashRecord, true) + return validate(v, id, hashRecord, true); } diff --git a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collectionLink.ts b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collectionLink.ts index f37b9628..2b7be1c6 100644 --- a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collectionLink.ts +++ b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/collectionLink.ts @@ -1,36 +1,40 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult, BlobRef } from '@atproto/lexicon' -import { CID } from 'multiformats/cid' -import { validate as _validate } from '../../../lexicons' -import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util' -import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js' +import { type ValidationResult, BlobRef } from '@atproto/lexicon'; +import { CID } from 'multiformats/cid'; +import { validate as _validate } from '../../../lexicons'; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from '../../../util'; +import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef.js'; const is$typed = _is$typed, - validate = _validate -const id = 'network.cosmik.collectionLink' + validate = _validate; +const id = 'network.cosmik.collectionLink'; export interface Record { - $type: 'network.cosmik.collectionLink' - collection: ComAtprotoRepoStrongRef.Main - card: ComAtprotoRepoStrongRef.Main - originalCard?: ComAtprotoRepoStrongRef.Main + $type: 'network.cosmik.collectionLink'; + collection: ComAtprotoRepoStrongRef.Main; + card: ComAtprotoRepoStrongRef.Main; + originalCard?: ComAtprotoRepoStrongRef.Main; /** DID of the user who added the card to the collection */ - addedBy: string + addedBy: string; /** Timestamp when the card was added to the collection. */ - addedAt: string + addedAt: string; /** Timestamp when this link record was created (usually set by PDS). */ - createdAt?: string - [k: string]: unknown + createdAt?: string; + [k: string]: unknown; } -const hashRecord = 'main' +const hashRecord = 'main'; export function isRecord(v: V) { - return is$typed(v, id, hashRecord) + return is$typed(v, id, hashRecord); } export function validateRecord(v: V) { - return validate(v, id, hashRecord, true) + return validate(v, id, hashRecord, true); } diff --git a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/defs.ts b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/defs.ts index 02cc5945..83f3e7c2 100644 --- a/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/defs.ts +++ b/src/modules/atproto/infrastructure/lexicon/types/network/cosmik/defs.ts @@ -1,30 +1,34 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult, BlobRef } from '@atproto/lexicon' -import { CID } from 'multiformats/cid' -import { validate as _validate } from '../../../lexicons' -import { type $Typed, is$typed as _is$typed, type OmitKey } from '../../../util' +import { type ValidationResult, BlobRef } from '@atproto/lexicon'; +import { CID } from 'multiformats/cid'; +import { validate as _validate } from '../../../lexicons'; +import { + type $Typed, + is$typed as _is$typed, + type OmitKey, +} from '../../../util'; const is$typed = _is$typed, - validate = _validate -const id = 'network.cosmik.defs' + validate = _validate; +const id = 'network.cosmik.defs'; /** Represents an identifier with a type and value. */ export interface Identifier { - $type?: 'network.cosmik.defs#identifier' + $type?: 'network.cosmik.defs#identifier'; /** The type of identifier (e.g., 'doi', 'at-uri', 'isbn'). */ - type: string + type: string; /** The identifier value. */ - value: string + value: string; } -const hashIdentifier = 'identifier' +const hashIdentifier = 'identifier'; export function isIdentifier(v: V) { - return is$typed(v, id, hashIdentifier) + return is$typed(v, id, hashIdentifier); } export function validateIdentifier(v: V) { - return validate(v, id, hashIdentifier) + return validate(v, id, hashIdentifier); } diff --git a/src/modules/atproto/infrastructure/lexicon/util.ts b/src/modules/atproto/infrastructure/lexicon/util.ts index 816ca10c..f7e33604 100644 --- a/src/modules/atproto/infrastructure/lexicon/util.ts +++ b/src/modules/atproto/infrastructure/lexicon/util.ts @@ -2,21 +2,21 @@ * GENERATED CODE - DO NOT MODIFY */ -import { type ValidationResult } from '@atproto/lexicon' +import { type ValidationResult } from '@atproto/lexicon'; export type OmitKey = { - [K2 in keyof T as K2 extends K ? never : K2]: T[K2] -} + [K2 in keyof T as K2 extends K ? never : K2]: T[K2]; +}; -export type $Typed = V & { $type: T } -export type Un$Typed = OmitKey +export type $Typed = V & { $type: T }; +export type Un$Typed = OmitKey; export type $Type = Hash extends 'main' ? Id - : `${Id}#${Hash}` + : `${Id}#${Hash}`; function isObject(v: V): v is V & object { - return v != null && typeof v === 'object' + return v != null && typeof v === 'object'; } function is$type( @@ -31,7 +31,7 @@ function is$type( $type.length === id.length + 1 + hash.length && $type.charCodeAt(id.length) === 35 /* '#' */ && $type.startsWith(id) && - $type.endsWith(hash) + $type.endsWith(hash); } export type $TypedObject< @@ -39,21 +39,21 @@ export type $TypedObject< Id extends string, Hash extends string, > = V extends { - $type: $Type + $type: $Type; } ? V : V extends { $type?: string } ? V extends { $type?: infer T extends $Type } ? V & { $type: T } : never - : V & { $type: $Type } + : V & { $type: $Type }; export function is$typed( v: V, id: Id, hash: Hash, ): v is $TypedObject { - return isObject(v) && '$type' in v && is$type(v.$type, id, hash) + return isObject(v) && '$type' in v && is$type(v.$type, id, hash); } export function maybe$typed( @@ -64,12 +64,12 @@ export function maybe$typed( return ( isObject(v) && ('$type' in v ? v.$type === undefined || is$type(v.$type, id, hash) : true) - ) + ); } -export type Validator = (v: unknown) => ValidationResult +export type Validator = (v: unknown) => ValidationResult; export type ValidatorParam = - V extends Validator ? R : never + V extends Validator ? R : never; /** * Utility function that allows to convert a "validate*" utility function into a @@ -77,6 +77,6 @@ export type ValidatorParam = */ export function asPredicate(validate: V) { return function (v: T): v is T & ValidatorParam { - return validate(v).success - } + return validate(v).success; + }; } diff --git a/src/modules/cards/domain/Card.ts b/src/modules/cards/domain/Card.ts index 48cdb654..c0dd9e62 100644 --- a/src/modules/cards/domain/Card.ts +++ b/src/modules/cards/domain/Card.ts @@ -14,8 +14,10 @@ export const CARD_ERROR_MESSAGES = { URL_CARD_CANNOT_HAVE_PARENT: 'URL cards cannot have parent cards', URL_CARD_MUST_HAVE_URL: 'URL cards must have a url property', URL_CARD_SINGLE_LIBRARY_ONLY: 'URL cards can only be in one library', - URL_CARD_CREATOR_LIBRARY_ONLY: 'URL cards can only be in the library of the creator', - LIBRARY_COUNT_MISMATCH: 'Library count does not match library memberships length', + URL_CARD_CREATOR_LIBRARY_ONLY: + 'URL cards can only be in the library of the creator', + LIBRARY_COUNT_MISMATCH: + 'Library count does not match library memberships length', CANNOT_CHANGE_CONTENT_TYPE: 'Cannot change card content to different type', ALREADY_IN_LIBRARY: "Card is already in user's library", NOT_IN_LIBRARY: "Card is not in user's library", @@ -123,7 +125,9 @@ export class Card extends AggregateRoot { ): Result { // Validate content type matches card type if (props.type.value !== props.content.type) { - return err(new CardValidationError(CARD_ERROR_MESSAGES.CARD_TYPE_CONTENT_MISMATCH)); + return err( + new CardValidationError(CARD_ERROR_MESSAGES.CARD_TYPE_CONTENT_MISMATCH), + ); } // Validate parent/source card relationships @@ -157,12 +161,18 @@ export class Card extends AggregateRoot { ): Result { // URL cards should not have parent cards if (props.type.value === CardTypeEnum.URL && props.parentCardId) { - return err(new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_CANNOT_HAVE_PARENT)); + return err( + new CardValidationError( + CARD_ERROR_MESSAGES.URL_CARD_CANNOT_HAVE_PARENT, + ), + ); } // URL cards must have a URL property if (props.type.value === CardTypeEnum.URL && !props.url) { - return err(new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_MUST_HAVE_URL)); + return err( + new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_MUST_HAVE_URL), + ); } // URL cards can only be in one library @@ -172,7 +182,9 @@ export class Card extends AggregateRoot { libraryMemberships.length > 1 ) { return err( - new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY), + new CardValidationError( + CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY, + ), ); } @@ -186,7 +198,9 @@ export class Card extends AggregateRoot { ); if (hasNonCreatorMembership) { return err( - new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_CREATOR_LIBRARY_ONLY), + new CardValidationError( + CARD_ERROR_MESSAGES.URL_CARD_CREATOR_LIBRARY_ONLY, + ), ); } } @@ -227,13 +241,17 @@ export class Card extends AggregateRoot { link.curatorId.equals(userId), ) ) { - return err(new CardValidationError(CARD_ERROR_MESSAGES.ALREADY_IN_LIBRARY)); + return err( + new CardValidationError(CARD_ERROR_MESSAGES.ALREADY_IN_LIBRARY), + ); } // URL cards can only be in one library if (this.isUrlCard && this.props.libraryMemberships.length > 0) { return err( - new CardValidationError(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY), + new CardValidationError( + CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY, + ), ); } diff --git a/src/modules/cards/domain/ICollectionQueryRepository.ts b/src/modules/cards/domain/ICollectionQueryRepository.ts index fe36974c..c8602fee 100644 --- a/src/modules/cards/domain/ICollectionQueryRepository.ts +++ b/src/modules/cards/domain/ICollectionQueryRepository.ts @@ -49,7 +49,7 @@ export interface ICollectionQueryRepository { curatorId: string, options: CollectionQueryOptions, ): Promise>; - + getCollectionsContainingCardForUser( cardId: string, curatorId: string, diff --git a/src/modules/cards/infrastructure/http/routes/cardRoutes.ts b/src/modules/cards/infrastructure/http/routes/cardRoutes.ts index 8c7634ce..648a291e 100644 --- a/src/modules/cards/infrastructure/http/routes/cardRoutes.ts +++ b/src/modules/cards/infrastructure/http/routes/cardRoutes.ts @@ -42,8 +42,10 @@ export function createCardRoutes( ); // GET /api/cards/library/status - Get URL status for my library - router.get('/library/status', authMiddleware.ensureAuthenticated(), (req, res) => - getUrlStatusForMyLibraryController.execute(req, res), + router.get( + '/library/status', + authMiddleware.ensureAuthenticated(), + (req, res) => getUrlStatusForMyLibraryController.execute(req, res), ); // GET /api/cards/user/:identifier - Get user's URL cards by identifier diff --git a/src/modules/cards/infrastructure/repositories/schema/card.sql.ts b/src/modules/cards/infrastructure/repositories/schema/card.sql.ts index f2bc42b0..8881c24a 100644 --- a/src/modules/cards/infrastructure/repositories/schema/card.sql.ts +++ b/src/modules/cards/infrastructure/repositories/schema/card.sql.ts @@ -10,25 +10,29 @@ import { } from 'drizzle-orm/pg-core'; import { publishedRecords } from './publishedRecord.sql'; -export const cards: PgTableWithColumns = pgTable('cards', { - id: uuid('id').primaryKey(), - authorId: text('author_id').notNull(), - type: text('type').notNull(), // URL, NOTE, HIGHLIGHT - contentData: jsonb('content_data').notNull(), - url: text('url'), // Optional URL field for all card types - parentCardId: uuid('parent_card_id').references(() => cards.id), - publishedRecordId: uuid('published_record_id').references( - () => publishedRecords.id, - ), - libraryCount: integer('library_count').notNull().default(0), - createdAt: timestamp('created_at').notNull().defaultNow(), - updatedAt: timestamp('updated_at').notNull().defaultNow(), -}, (table) => { - return { - // Critical for findUsersUrlCardByUrl queries - authorUrlIdx: index('cards_author_url_idx').on(table.authorId, table.url), - - // For general card queries by author - authorIdIdx: index('cards_author_id_idx').on(table.authorId), - }; -}); +export const cards: PgTableWithColumns = pgTable( + 'cards', + { + id: uuid('id').primaryKey(), + authorId: text('author_id').notNull(), + type: text('type').notNull(), // URL, NOTE, HIGHLIGHT + contentData: jsonb('content_data').notNull(), + url: text('url'), // Optional URL field for all card types + parentCardId: uuid('parent_card_id').references(() => cards.id), + publishedRecordId: uuid('published_record_id').references( + () => publishedRecords.id, + ), + libraryCount: integer('library_count').notNull().default(0), + createdAt: timestamp('created_at').notNull().defaultNow(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), + }, + (table) => { + return { + // Critical for findUsersUrlCardByUrl queries + authorUrlIdx: index('cards_author_url_idx').on(table.authorId, table.url), + + // For general card queries by author + authorIdIdx: index('cards_author_id_idx').on(table.authorId), + }; + }, +); diff --git a/src/modules/cards/infrastructure/repositories/schema/collection.sql.ts b/src/modules/cards/infrastructure/repositories/schema/collection.sql.ts index 936e9a58..48c092fc 100644 --- a/src/modules/cards/infrastructure/repositories/schema/collection.sql.ts +++ b/src/modules/cards/infrastructure/repositories/schema/collection.sql.ts @@ -10,27 +10,34 @@ import { import { publishedRecords } from './publishedRecord.sql'; import { cards } from './card.sql'; -export const collections = pgTable('collections', { - id: uuid('id').primaryKey(), - authorId: text('author_id').notNull(), - name: text('name').notNull(), - description: text('description'), - accessType: text('access_type').notNull(), // OPEN, CLOSED - cardCount: integer('card_count').notNull().default(0), - createdAt: timestamp('created_at').notNull().defaultNow(), - updatedAt: timestamp('updated_at').notNull().defaultNow(), - publishedRecordId: uuid('published_record_id').references( - () => publishedRecords.id, - ), -}, (table) => { - return { - // Critical for all collection queries by user - authorIdIdx: index('collections_author_id_idx').on(table.authorId), - - // For paginated collection listings (most common sort) - authorUpdatedAtIdx: index('collections_author_updated_at_idx').on(table.authorId, table.updatedAt), - }; -}); +export const collections = pgTable( + 'collections', + { + id: uuid('id').primaryKey(), + authorId: text('author_id').notNull(), + name: text('name').notNull(), + description: text('description'), + accessType: text('access_type').notNull(), // OPEN, CLOSED + cardCount: integer('card_count').notNull().default(0), + createdAt: timestamp('created_at').notNull().defaultNow(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), + publishedRecordId: uuid('published_record_id').references( + () => publishedRecords.id, + ), + }, + (table) => { + return { + // Critical for all collection queries by user + authorIdIdx: index('collections_author_id_idx').on(table.authorId), + + // For paginated collection listings (most common sort) + authorUpdatedAtIdx: index('collections_author_updated_at_idx').on( + table.authorId, + table.updatedAt, + ), + }; + }, +); // Join table for collection collaborators export const collectionCollaborators = pgTable('collection_collaborators', { @@ -42,23 +49,29 @@ export const collectionCollaborators = pgTable('collection_collaborators', { }); // Join table for cards in collections -export const collectionCards = pgTable('collection_cards', { - id: uuid('id').primaryKey(), - collectionId: uuid('collection_id') - .notNull() - .references(() => collections.id, { onDelete: 'cascade' }), - cardId: uuid('card_id') - .notNull() - .references(() => cards.id, { onDelete: 'cascade' }), - addedBy: text('added_by').notNull(), - addedAt: timestamp('added_at').notNull().defaultNow(), - publishedRecordId: uuid('published_record_id').references( - () => publishedRecords.id, - ), -}, (table) => { - return { - // Critical for getCollectionsContainingCardForUser queries - cardIdIdx: index('collection_cards_card_id_idx').on(table.cardId), - collectionIdIdx: index('collection_cards_collection_id_idx').on(table.collectionId), - }; -}); +export const collectionCards = pgTable( + 'collection_cards', + { + id: uuid('id').primaryKey(), + collectionId: uuid('collection_id') + .notNull() + .references(() => collections.id, { onDelete: 'cascade' }), + cardId: uuid('card_id') + .notNull() + .references(() => cards.id, { onDelete: 'cascade' }), + addedBy: text('added_by').notNull(), + addedAt: timestamp('added_at').notNull().defaultNow(), + publishedRecordId: uuid('published_record_id').references( + () => publishedRecords.id, + ), + }, + (table) => { + return { + // Critical for getCollectionsContainingCardForUser queries + cardIdIdx: index('collection_cards_card_id_idx').on(table.cardId), + collectionIdIdx: index('collection_cards_collection_id_idx').on( + table.collectionId, + ), + }; + }, +); diff --git a/src/modules/cards/tests/application/RemoveCardFromLibraryUseCase.test.ts b/src/modules/cards/tests/application/RemoveCardFromLibraryUseCase.test.ts index 90b2e2fa..be068b58 100644 --- a/src/modules/cards/tests/application/RemoveCardFromLibraryUseCase.test.ts +++ b/src/modules/cards/tests/application/RemoveCardFromLibraryUseCase.test.ts @@ -51,8 +51,14 @@ describe('RemoveCardFromLibraryUseCase', () => { cardPublisher.clear(); }); - const createCard = async (type: CardTypeEnum = CardTypeEnum.URL, creatorId: CuratorId = curatorId) => { - const card = new CardBuilder().withType(type).withCuratorId(creatorId.value).build(); + const createCard = async ( + type: CardTypeEnum = CardTypeEnum.URL, + creatorId: CuratorId = curatorId, + ) => { + const card = new CardBuilder() + .withType(type) + .withCuratorId(creatorId.value) + .build(); if (card instanceof Error) { throw new Error(`Failed to create card: ${card.message}`); @@ -65,9 +71,9 @@ describe('RemoveCardFromLibraryUseCase', () => { const addCardToLibrary = async (card: any, curatorId: CuratorId) => { // For URL cards, can only add to creator's library if (card.isUrlCard && !card.curatorId.equals(curatorId)) { - throw new Error('URL cards can only be added to creator\'s library'); + throw new Error("URL cards can only be added to creator's library"); } - + const addResult = await cardLibraryService.addCardToLibrary( card, curatorId, @@ -169,7 +175,7 @@ describe('RemoveCardFromLibraryUseCase', () => { it('should handle different card types', async () => { // Create URL card with curatorId as creator const urlCard = await createCard(CardTypeEnum.URL, curatorId); - // Create note card with curatorId as creator + // Create note card with curatorId as creator const noteCard = await createCard(CardTypeEnum.NOTE, curatorId); await addCardToLibrary(urlCard, curatorId); @@ -520,10 +526,10 @@ describe('RemoveCardFromLibraryUseCase', () => { it('should not delete card when curator is not the owner', async () => { // Create card with different owner const card = await createCard(CardTypeEnum.NOTE, otherCuratorId); - + // Add to other curator's library first await addCardToLibrary(card, otherCuratorId); - + // Add to current curator's library (note cards can be in multiple libraries) await addCardToLibrary(card, curatorId); @@ -548,7 +554,7 @@ describe('RemoveCardFromLibraryUseCase', () => { it('should not delete card when it still has other library memberships', async () => { // Create note card (can be in multiple libraries) const card = await createCard(CardTypeEnum.NOTE, curatorId); - + // Add to both curator's libraries await addCardToLibrary(card, curatorId); await addCardToLibrary(card, otherCuratorId); diff --git a/src/modules/cards/tests/domain/Card.test.ts b/src/modules/cards/tests/domain/Card.test.ts index 3b8028a6..151cc699 100644 --- a/src/modules/cards/tests/domain/Card.test.ts +++ b/src/modules/cards/tests/domain/Card.test.ts @@ -151,7 +151,9 @@ describe('Card', () => { throw new Error('Expected creation to fail but it succeeded'); } expect(result.isErr()).toBe(true); - expect(result.error.message).toBe(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY); + expect(result.error.message).toBe( + CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY, + ); }); it('should allow NOTE cards to have multiple library memberships', () => { @@ -256,7 +258,9 @@ describe('Card', () => { throw new Error('Expected creation to fail but it succeeded'); } expect(result.isErr()).toBe(true); - expect(result.error.message).toBe(CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY); + expect(result.error.message).toBe( + CARD_ERROR_MESSAGES.URL_CARD_SINGLE_LIBRARY_ONLY, + ); expect(card.libraryMembershipCount).toBe(1); expect(card.isInLibrary(curatorId)).toBe(true); expect(card.isInLibrary(otherUserId)).toBe(false); diff --git a/src/shared/infrastructure/config/EnvironmentConfigService.ts b/src/shared/infrastructure/config/EnvironmentConfigService.ts index aa097dac..1b447f5d 100644 --- a/src/shared/infrastructure/config/EnvironmentConfigService.ts +++ b/src/shared/infrastructure/config/EnvironmentConfigService.ts @@ -69,9 +69,18 @@ export class EnvironmentConfigService { process.env.ATPROTO_SERVICE_ENDPOINT || 'https://bsky.social', baseUrl: process.env.BASE_URL || 'http://127.0.0.1:3000', collections: { - card: environment === 'prod' ? 'network.cosmik.card' : 'network.cosmik.dev.card', - collection: environment === 'prod' ? 'network.cosmik.collection' : 'network.cosmik.dev.collection', - collectionLink: environment === 'prod' ? 'network.cosmik.collectionLink' : 'network.cosmik.dev.collectionLink', + card: + environment === 'prod' + ? 'network.cosmik.card' + : 'network.cosmik.dev.card', + collection: + environment === 'prod' + ? 'network.cosmik.collection' + : 'network.cosmik.dev.collection', + collectionLink: + environment === 'prod' + ? 'network.cosmik.collectionLink' + : 'network.cosmik.dev.collectionLink', }, }, server: { diff --git a/src/shared/infrastructure/database/migrations/meta/0004_snapshot.json b/src/shared/infrastructure/database/migrations/meta/0004_snapshot.json index bfb9e0ce..db051288 100644 --- a/src/shared/infrastructure/database/migrations/meta/0004_snapshot.json +++ b/src/shared/infrastructure/database/migrations/meta/0004_snapshot.json @@ -123,12 +123,8 @@ "name": "cards_parent_card_id_cards_id_fk", "tableFrom": "cards", "tableTo": "cards", - "columnsFrom": [ - "parent_card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["parent_card_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -136,12 +132,8 @@ "name": "cards_published_record_id_published_records_id_fk", "tableFrom": "cards", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -200,12 +192,8 @@ "name": "collection_cards_collection_id_collections_id_fk", "tableFrom": "collection_cards", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -213,12 +201,8 @@ "name": "collection_cards_card_id_cards_id_fk", "tableFrom": "collection_cards", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -226,12 +210,8 @@ "name": "collection_cards_published_record_id_published_records_id_fk", "tableFrom": "collection_cards", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -271,12 +251,8 @@ "name": "collection_collaborators_collection_id_collections_id_fk", "tableFrom": "collection_collaborators", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -355,12 +331,8 @@ "name": "collections_published_record_id_published_records_id_fk", "tableFrom": "collections", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -438,12 +410,8 @@ "name": "library_memberships_card_id_cards_id_fk", "tableFrom": "library_memberships", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -451,12 +419,8 @@ "name": "library_memberships_published_record_id_published_records_id_fk", "tableFrom": "library_memberships", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -464,10 +428,7 @@ "compositePrimaryKeys": { "library_memberships_card_id_user_id_pk": { "name": "library_memberships_card_id_user_id_pk", - "columns": [ - "card_id", - "user_id" - ] + "columns": ["card_id", "user_id"] } }, "uniqueConstraints": {}, @@ -699,12 +660,8 @@ "name": "auth_refresh_tokens_user_did_users_id_fk", "tableFrom": "auth_refresh_tokens", "tableTo": "users", - "columnsFrom": [ - "user_did" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_did"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -764,4 +721,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/src/shared/infrastructure/database/migrations/meta/0005_snapshot.json b/src/shared/infrastructure/database/migrations/meta/0005_snapshot.json index ebbfb9f6..6fadd60c 100644 --- a/src/shared/infrastructure/database/migrations/meta/0005_snapshot.json +++ b/src/shared/infrastructure/database/migrations/meta/0005_snapshot.json @@ -122,26 +122,18 @@ "cards_parent_card_id_cards_id_fk": { "name": "cards_parent_card_id_cards_id_fk", "tableFrom": "cards", - "columnsFrom": [ - "parent_card_id" - ], + "columnsFrom": ["parent_card_id"], "tableTo": "cards", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" }, "cards_published_record_id_published_records_id_fk": { "name": "cards_published_record_id_published_records_id_fk", "tableFrom": "cards", - "columnsFrom": [ - "published_record_id" - ], + "columnsFrom": ["published_record_id"], "tableTo": "published_records", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" } @@ -199,39 +191,27 @@ "collection_cards_collection_id_collections_id_fk": { "name": "collection_cards_collection_id_collections_id_fk", "tableFrom": "collection_cards", - "columnsFrom": [ - "collection_id" - ], + "columnsFrom": ["collection_id"], "tableTo": "collections", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "cascade" }, "collection_cards_card_id_cards_id_fk": { "name": "collection_cards_card_id_cards_id_fk", "tableFrom": "collection_cards", - "columnsFrom": [ - "card_id" - ], + "columnsFrom": ["card_id"], "tableTo": "cards", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "cascade" }, "collection_cards_published_record_id_published_records_id_fk": { "name": "collection_cards_published_record_id_published_records_id_fk", "tableFrom": "collection_cards", - "columnsFrom": [ - "published_record_id" - ], + "columnsFrom": ["published_record_id"], "tableTo": "published_records", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" } @@ -270,13 +250,9 @@ "collection_collaborators_collection_id_collections_id_fk": { "name": "collection_collaborators_collection_id_collections_id_fk", "tableFrom": "collection_collaborators", - "columnsFrom": [ - "collection_id" - ], + "columnsFrom": ["collection_id"], "tableTo": "collections", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "cascade" } @@ -354,13 +330,9 @@ "collections_published_record_id_published_records_id_fk": { "name": "collections_published_record_id_published_records_id_fk", "tableFrom": "collections", - "columnsFrom": [ - "published_record_id" - ], + "columnsFrom": ["published_record_id"], "tableTo": "published_records", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" } @@ -437,26 +409,18 @@ "library_memberships_card_id_cards_id_fk": { "name": "library_memberships_card_id_cards_id_fk", "tableFrom": "library_memberships", - "columnsFrom": [ - "card_id" - ], + "columnsFrom": ["card_id"], "tableTo": "cards", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "cascade" }, "library_memberships_published_record_id_published_records_id_fk": { "name": "library_memberships_published_record_id_published_records_id_fk", "tableFrom": "library_memberships", - "columnsFrom": [ - "published_record_id" - ], + "columnsFrom": ["published_record_id"], "tableTo": "published_records", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" } @@ -464,10 +428,7 @@ "compositePrimaryKeys": { "library_memberships_card_id_user_id_pk": { "name": "library_memberships_card_id_user_id_pk", - "columns": [ - "card_id", - "user_id" - ] + "columns": ["card_id", "user_id"] } }, "uniqueConstraints": {}, @@ -698,13 +659,9 @@ "auth_refresh_tokens_user_did_users_id_fk": { "name": "auth_refresh_tokens_user_did_users_id_fk", "tableFrom": "auth_refresh_tokens", - "columnsFrom": [ - "user_did" - ], + "columnsFrom": ["user_did"], "tableTo": "users", - "columnsTo": [ - "id" - ], + "columnsTo": ["id"], "onUpdate": "no action", "onDelete": "no action" } @@ -764,4 +721,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/src/shared/infrastructure/database/migrations/meta/0006_snapshot.json b/src/shared/infrastructure/database/migrations/meta/0006_snapshot.json index 71b71251..c9bc18fb 100644 --- a/src/shared/infrastructure/database/migrations/meta/0006_snapshot.json +++ b/src/shared/infrastructure/database/migrations/meta/0006_snapshot.json @@ -160,12 +160,8 @@ "name": "cards_parent_card_id_cards_id_fk", "tableFrom": "cards", "tableTo": "cards", - "columnsFrom": [ - "parent_card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["parent_card_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -173,12 +169,8 @@ "name": "cards_published_record_id_published_records_id_fk", "tableFrom": "cards", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -268,12 +260,8 @@ "name": "collection_cards_collection_id_collections_id_fk", "tableFrom": "collection_cards", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -281,12 +269,8 @@ "name": "collection_cards_card_id_cards_id_fk", "tableFrom": "collection_cards", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -294,12 +278,8 @@ "name": "collection_cards_published_record_id_published_records_id_fk", "tableFrom": "collection_cards", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -339,12 +319,8 @@ "name": "collection_collaborators_collection_id_collections_id_fk", "tableFrom": "collection_collaborators", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -460,12 +436,8 @@ "name": "collections_published_record_id_published_records_id_fk", "tableFrom": "collections", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -543,12 +515,8 @@ "name": "library_memberships_card_id_cards_id_fk", "tableFrom": "library_memberships", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -556,12 +524,8 @@ "name": "library_memberships_published_record_id_published_records_id_fk", "tableFrom": "library_memberships", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -569,10 +533,7 @@ "compositePrimaryKeys": { "library_memberships_card_id_user_id_pk": { "name": "library_memberships_card_id_user_id_pk", - "columns": [ - "card_id", - "user_id" - ] + "columns": ["card_id", "user_id"] } }, "uniqueConstraints": {}, @@ -804,12 +765,8 @@ "name": "auth_refresh_tokens_user_did_users_id_fk", "tableFrom": "auth_refresh_tokens", "tableTo": "users", - "columnsFrom": [ - "user_did" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_did"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -869,4 +826,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/src/shared/infrastructure/database/migrations/meta/_journal.json b/src/shared/infrastructure/database/migrations/meta/_journal.json index b8580269..aa94d9de 100644 --- a/src/shared/infrastructure/database/migrations/meta/_journal.json +++ b/src/shared/infrastructure/database/migrations/meta/_journal.json @@ -52,4 +52,4 @@ "breakpoints": true } ] -} \ No newline at end of file +}