This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add File Service Interface and Document Model (#69)
* Add File Service Interface and Document Model * Add File Interface * Generate Document Model Migration * Fix Core Config * Add Document Service Draft * Rename Document To Document Metadata * Add Document Metadata Service
- Loading branch information
1 parent
9151f49
commit 1999468
Showing
16 changed files
with
384 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/ocular/src/migrations/1715054351330-adddocumentmetadatamodel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class Adddocumentmetadatamodel1715054351330 implements MigrationInterface { | ||
name = 'Adddocumentmetadatamodel1715054351330' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TYPE "public"."document_metadata_type_enum" AS ENUM('pdf', 'text', 'docx', 'html', 'md')`); | ||
await queryRunner.query(`CREATE TYPE "public"."document_metadata_source_enum" AS ENUM('asana', 'confluence', 'github', 'gmail', 'google-drive', 'jira', 'notion', 'slack')`); | ||
await queryRunner.query(`CREATE TABLE "document_metadata" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "link" character varying NOT NULL, "title" character varying NOT NULL, "type" "public"."document_metadata_type_enum" NOT NULL, "source" "public"."document_metadata_source_enum" NOT NULL, "organisation_id" character varying NOT NULL, CONSTRAINT "UQ_b213a1ec4a3a720fed5cf55aa6d" UNIQUE ("link"), CONSTRAINT "PK_74b81e5979bc9e440e8d40f07e4" PRIMARY KEY ("id"))`); | ||
await queryRunner.query(`ALTER TABLE "o_auth" ALTER COLUMN "last_sync" SET DEFAULT NULL`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "o_auth" ALTER COLUMN "last_sync" DROP DEFAULT`); | ||
await queryRunner.query(`DROP TABLE "document_metadata"`); | ||
await queryRunner.query(`DROP TYPE "public"."document_metadata_source_enum"`); | ||
await queryRunner.query(`DROP TYPE "public"."document_metadata_type_enum"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
BeforeInsert, | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
ManyToOne, | ||
JoinColumn, | ||
OneToMany | ||
} from 'typeorm'; | ||
import { AppNameDefinitions, BaseEntity, DocType } from "@ocular/types" | ||
import { Organisation } from './organisation'; | ||
import { DbAwareColumn } from '@ocular/utils'; | ||
|
||
@Entity() | ||
export class DocumentMetadata extends BaseEntity { | ||
@Column({type: "varchar", nullable: false, unique: true}) | ||
link: string; | ||
|
||
@Column({type: "varchar", nullable: false}) | ||
title: string; | ||
|
||
@DbAwareColumn({ | ||
type: "enum", | ||
enum: DocType, | ||
nullable: false, | ||
}) | ||
type: DocType | ||
|
||
@DbAwareColumn({ | ||
type: "enum", | ||
enum: AppNameDefinitions, | ||
nullable: false, | ||
}) | ||
source: AppNameDefinitions | ||
|
||
@Column({type: "varchar", nullable: false}) | ||
organisation_id: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { DocumentMetadata } from "../models" | ||
import { dataSource } from "../loaders/database" | ||
|
||
export const DocumentMetadataRepository = dataSource.getRepository(DocumentMetadata) | ||
export default DocumentMetadataRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from "./app" | ||
export * from "./batch-job" | ||
export * from "./chat" | ||
export * from "./document-metadata" | ||
export * from "./message" | ||
export * from "./oauth" | ||
export * from "./user" |
Oops, something went wrong.