chore: Refactor data import (#3434)
* Complete refactor of import * feat: Notion data import (#3442)
This commit is contained in:
@@ -7,13 +7,31 @@ import {
|
||||
Table,
|
||||
DataType,
|
||||
} from "sequelize-typescript";
|
||||
import { deleteFromS3 } from "@server/utils/s3";
|
||||
import { deleteFromS3, getFileByKey } from "@server/utils/s3";
|
||||
import Collection from "./Collection";
|
||||
import Team from "./Team";
|
||||
import User from "./User";
|
||||
import BaseModel from "./base/BaseModel";
|
||||
import Fix from "./decorators/Fix";
|
||||
|
||||
export enum FileOperationType {
|
||||
Import = "import",
|
||||
Export = "export",
|
||||
}
|
||||
|
||||
export enum FileOperationFormat {
|
||||
MarkdownZip = "outline-markdown",
|
||||
Notion = "notion",
|
||||
}
|
||||
|
||||
export enum FileOperationState {
|
||||
Creating = "creating",
|
||||
Uploading = "uploading",
|
||||
Complete = "complete",
|
||||
Error = "error",
|
||||
Expired = "expired",
|
||||
}
|
||||
|
||||
@DefaultScope(() => ({
|
||||
include: [
|
||||
{
|
||||
@@ -32,12 +50,15 @@ import Fix from "./decorators/Fix";
|
||||
@Fix
|
||||
class FileOperation extends BaseModel {
|
||||
@Column(DataType.ENUM("import", "export"))
|
||||
type: "import" | "export";
|
||||
type: FileOperationType;
|
||||
|
||||
@Column(DataType.STRING)
|
||||
format: FileOperationFormat;
|
||||
|
||||
@Column(
|
||||
DataType.ENUM("creating", "uploading", "complete", "error", "expired")
|
||||
)
|
||||
state: "creating" | "uploading" | "complete" | "error" | "expired";
|
||||
state: FileOperationState;
|
||||
|
||||
@Column
|
||||
key: string;
|
||||
@@ -57,6 +78,10 @@ class FileOperation extends BaseModel {
|
||||
await this.save();
|
||||
};
|
||||
|
||||
get buffer() {
|
||||
return getFileByKey(this.key);
|
||||
}
|
||||
|
||||
// hooks
|
||||
|
||||
@BeforeDestroy
|
||||
|
||||
Reference in New Issue
Block a user