mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add libraryItemPreview entity class
This commit is contained in:
parent
e1af53ab48
commit
928ed2e6a9
12 changed files with 83 additions and 34 deletions
|
|
@ -3,9 +3,12 @@ import {
|
|||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm'
|
||||
import { LibraryItem } from './library_item'
|
||||
import { User } from './user'
|
||||
|
||||
@Entity({ name: 'labels' })
|
||||
|
|
@ -34,4 +37,8 @@ export class Label {
|
|||
|
||||
@Column('boolean', { default: false })
|
||||
internal!: boolean
|
||||
|
||||
@ManyToMany(() => LibraryItem, (libraryItem) => libraryItem.labels)
|
||||
@JoinTable()
|
||||
libraryItems?: LibraryItem[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@ import {
|
|||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { Label } from './label'
|
||||
import { Subscription } from './subscription'
|
||||
import { UploadFile } from './upload_file'
|
||||
import { User } from './user'
|
||||
|
||||
|
|
@ -36,6 +40,11 @@ export enum ContentReaderType {
|
|||
EPUB = 'EPUB',
|
||||
}
|
||||
|
||||
export enum DirectionalityType {
|
||||
LTR = 'LTR',
|
||||
RTL = 'RTL',
|
||||
}
|
||||
|
||||
@Entity({ name: 'library_item' })
|
||||
export class LibraryItem {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
|
|
@ -166,4 +175,15 @@ export class LibraryItem {
|
|||
|
||||
@Column('text', { nullable: true })
|
||||
gcsArchiveId?: string
|
||||
|
||||
@OneToOne(() => Subscription, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'subscription_id' })
|
||||
subscription?: Subscription
|
||||
|
||||
@ManyToMany(() => Label, (label) => label.libraryItems)
|
||||
@JoinTable()
|
||||
labels?: Label[]
|
||||
|
||||
@Column('enum', { enum: DirectionalityType, default: DirectionalityType.LTR })
|
||||
directionality?: DirectionalityType
|
||||
}
|
||||
|
|
|
|||
43
packages/api/src/entity/library_item_preview.ts
Normal file
43
packages/api/src/entity/library_item_preview.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { LibraryItem } from './library_item'
|
||||
import { User } from './user'
|
||||
|
||||
@Entity({ name: 'library_item_preview' })
|
||||
export class LibraryItemPreview {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id?: string
|
||||
|
||||
@OneToOne(() => User, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'sender_id' })
|
||||
sender!: User
|
||||
|
||||
@Column('array', { name: 'recipient_ids' })
|
||||
recipientIds!: string[]
|
||||
|
||||
@OneToOne(() => LibraryItem, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'library_item_id' })
|
||||
libraryItem!: LibraryItem
|
||||
|
||||
@Column('text')
|
||||
thumbnail?: string
|
||||
|
||||
@Column('bool', { default: false })
|
||||
includesNote?: boolean
|
||||
|
||||
@Column('bool', { default: false })
|
||||
includesHighlight?: boolean
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt?: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt?: Date
|
||||
}
|
||||
|
|
@ -4,9 +4,7 @@
|
|||
"files": true
|
||||
},
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src", "test"],
|
||||
"exclude": ["./src/generated", "./test"]
|
||||
|
|
|
|||
|
|
@ -7,10 +7,9 @@ BEGIN;
|
|||
CREATE EXTENSION vector;
|
||||
|
||||
CREATE TYPE library_item_state AS ENUM ('SUCCEEDED', 'FAILED', 'PROCESSING', 'ARCHIVED', 'DELETED');
|
||||
|
||||
CREATE TYPE content_reader_type AS ENUM ('WEB', 'PDF', 'EPUB');
|
||||
|
||||
CREATE TYPE library_item_type AS ENUM ('ARTICLE', 'BOOK', 'FILE', 'PROFILE', 'WEBSITE', 'TWEET', 'VIDEO', 'IMAGE', 'UNKNOWN');
|
||||
CREATE TYPE directionality_type AS ENUM ('LTR', 'RTL');
|
||||
|
||||
CREATE TABLE omnivore.library_item (
|
||||
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
|
||||
|
|
@ -53,7 +52,10 @@ CREATE TABLE omnivore.library_item (
|
|||
model_name text,
|
||||
embedding vector(768),
|
||||
text_content_hash text,
|
||||
gcs_archive_id text
|
||||
gcs_archive_id text,
|
||||
directionality directionality_type NOT NULL DEFAULT 'LTR',
|
||||
subscription_id uuid REFERENCES omnivore.subscriptions ON DELETE CASCADE,
|
||||
UNIQUE (user_id, original_url)
|
||||
);
|
||||
|
||||
CREATE TRIGGER update_library_item_modtime BEFORE UPDATE ON omnivore.library_item FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
|
||||
|
|
|
|||
|
|
@ -7,15 +7,16 @@ BEGIN;
|
|||
DROP TRIGGER library_item_tsv_update ON omnivore.library_item;
|
||||
DROP FUNCTION update_library_item_tsv();
|
||||
|
||||
DROP INDEX library_item_search_tsv_idx;
|
||||
DROP INDEX library_item_description_tsv_idx;
|
||||
DROP INDEX library_item_author_tsv_idx;
|
||||
DROP INDEX library_item_title_tsv_idx;
|
||||
DROP INDEX library_item_site_tsv_idx;
|
||||
DROP INDEX library_item_content_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_search_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_description_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_author_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_title_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_site_tsv_idx;
|
||||
DROP INDEX omnivore.library_item_content_tsv_idx;
|
||||
|
||||
DROP TRIGGER update_library_item_modtime ON omnivore.library_item;
|
||||
DROP TABLE omnivore.library_item;
|
||||
DROP TYPE directionality_type;
|
||||
DROP TYPE library_item_type;
|
||||
DROP TYPE content_reader_type;
|
||||
DROP TYPE library_item_state;
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
-- Type: DO
|
||||
-- Name: library_item_subscriptions
|
||||
-- Description: Create a join table for library item and subscriptions
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE omnivore.library_item_subscriptions (
|
||||
library_item_id uuid NOT NULL REFERENCES omnivore.library_item(id) ON DELETE CASCADE,
|
||||
subscription_id uuid NOT NULL REFERENCES omnivore.subscriptions(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (library_item_id, subscription_id)
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
-- Type: UNDO
|
||||
-- Name: library_item_subscriptions
|
||||
-- Description: Create a join table for library item and subscriptions
|
||||
|
||||
BEGIN;
|
||||
|
||||
DROP TABLE omnivore.library_item_subscriptions;
|
||||
|
||||
COMMIT;
|
||||
Loading…
Reference in a new issue