feat: Add import/export of documents as JSON (#4621)

* feat: Add export of documents as JSON

* Rename, add structured collection description

* stash

* ui

* Add entity creation data to JSON archive

* Import JSON UI plumbing

* stash

* Messy, but working

* tsc

* tsc
This commit is contained in:
Tom Moor
2023-01-29 10:24:44 -08:00
committed by GitHub
parent 85ca25371c
commit d02d3cb55d
23 changed files with 649 additions and 119 deletions

View File

@@ -2,7 +2,12 @@ import { ParameterizedContext, DefaultContext } from "koa";
import { IRouterParamContext } from "koa-router";
import { Transaction } from "sequelize/types";
import { z } from "zod";
import { Client } from "@shared/types";
import {
CollectionSort,
NavigationNode,
Client,
CollectionPermission,
} from "@shared/types";
import BaseSchema from "@server/routes/api/BaseSchema";
import { AccountProvisionerResult } from "./commands/accountProvisioner";
import { FileOperation, Team, User } from "./models";
@@ -343,3 +348,60 @@ export type Event =
export type NotificationMetadata = {
notificationId?: string;
};
export type JSONExportMetadata = {
/* The version of the export, allows updated structure in the future. */
exportVersion: number;
/* The version of the application that created the export. */
version: string;
/* The date the export was created. */
createdAt: string;
/* The ID of the user that created the export. */
createdById: string;
/* The email of the user that created the export. */
createdByEmail: string | null;
};
export type DocumentJSONExport = {
id: string;
urlId: string;
title: string;
data: Record<string, any>;
createdById: string;
createdByEmail: string | null;
createdAt: string;
updatedAt: string;
publishedAt: string | null;
fullWidth: boolean;
template: boolean;
parentDocumentId: string | null;
};
export type AttachmentJSONExport = {
id: string;
documentId: string | null;
contentType: string;
name: string;
size: number;
key: string;
};
export type CollectionJSONExport = {
collection: {
id: string;
urlId: string;
name: string;
description: Record<string, any> | null;
permission?: CollectionPermission | null;
color: string;
icon?: string | null;
sort: CollectionSort;
documentStructure: NavigationNode[] | null;
};
documents: {
[id: string]: DocumentJSONExport;
};
attachments: {
[id: string]: AttachmentJSONExport;
};
};