feat: progress to draft types
This commit is contained in:
@@ -87,7 +87,7 @@ const collectionSchema = joi.object().keys({
|
||||
autosave: joi.alternatives().try(
|
||||
joi.boolean(),
|
||||
joi.object({
|
||||
time: joi.number(),
|
||||
interval: joi.number(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Field } from '../../fields/config/types';
|
||||
import { PayloadRequest } from '../../express/types';
|
||||
import { IncomingAuthType, Auth } from '../../auth/types';
|
||||
import { IncomingUploadType, Upload } from '../../uploads/types';
|
||||
import { IncomingRevisionsType } from '../../revisions/types';
|
||||
import { IncomingCollectionRevisionsType } from '../../revisions/types';
|
||||
|
||||
export interface CollectionModel extends PaginateModel<any>, PassportLocalModel<any> {
|
||||
buildQuery: (query: unknown, locale?: string) => Record<string, unknown>
|
||||
@@ -205,7 +205,7 @@ export type CollectionConfig = {
|
||||
* Upload options
|
||||
*/
|
||||
upload?: IncomingUploadType | boolean;
|
||||
revisions?: IncomingRevisionsType | boolean;
|
||||
revisions?: IncomingCollectionRevisionsType | boolean;
|
||||
timestamps?: boolean
|
||||
};
|
||||
|
||||
@@ -213,7 +213,7 @@ export interface SanitizedCollectionConfig extends Omit<DeepRequired<CollectionC
|
||||
auth: Auth;
|
||||
upload: Upload;
|
||||
fields: Field[];
|
||||
revisions: IncomingRevisionsType
|
||||
revisions: IncomingCollectionRevisionsType
|
||||
}
|
||||
|
||||
export type Collection = {
|
||||
|
||||
@@ -26,6 +26,17 @@ const globalSchema = joi.object().keys({
|
||||
revisions: joi.alternatives().try(
|
||||
joi.object({
|
||||
max: joi.number(),
|
||||
drafts: joi.alternatives().try(
|
||||
joi.object({
|
||||
autosave: joi.alternatives().try(
|
||||
joi.boolean(),
|
||||
joi.object({
|
||||
interval: joi.number(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
joi.boolean(),
|
||||
),
|
||||
}),
|
||||
joi.boolean(),
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import { DeepRequired } from 'ts-essentials';
|
||||
import { PayloadRequest } from '../../express/types';
|
||||
import { Access, GeneratePreviewURL } from '../../config/types';
|
||||
import { Field } from '../../fields/config/types';
|
||||
import { IncomingGlobalRevisionsType } from '../../revisions/types';
|
||||
|
||||
export type TypeWithID = {
|
||||
id: string
|
||||
@@ -44,9 +45,7 @@ export type GlobalConfig = {
|
||||
slug: string
|
||||
label?: string
|
||||
preview?: GeneratePreviewURL
|
||||
revisions?: {
|
||||
max?: number
|
||||
} | true
|
||||
revisions?: IncomingGlobalRevisionsType | boolean
|
||||
hooks?: {
|
||||
beforeValidate?: BeforeValidateHook[]
|
||||
beforeChange?: BeforeChangeHook[]
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import { IncomingRevisionsType } from './types';
|
||||
import { IncomingCollectionRevisionsType, IncomingGlobalRevisionsType } from './types';
|
||||
|
||||
export const revisionDefaults: IncomingRevisionsType = {
|
||||
export const revisionCollectionDefaults: IncomingCollectionRevisionsType = {
|
||||
drafts: {
|
||||
autosave: {
|
||||
time: 5, // in seconds
|
||||
interval: 5, // in seconds
|
||||
},
|
||||
},
|
||||
maxPerDoc: 50,
|
||||
retainDeleted: true,
|
||||
};
|
||||
|
||||
export const revisionGlobalDefaults: IncomingGlobalRevisionsType = {
|
||||
drafts: {
|
||||
autosave: {
|
||||
interval: 5, // in seconds
|
||||
},
|
||||
},
|
||||
max: 50,
|
||||
};
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
export type Autosave = {
|
||||
time?: number
|
||||
interval?: number
|
||||
}
|
||||
|
||||
export type Drafts = {
|
||||
autosave?: boolean | Autosave
|
||||
}
|
||||
|
||||
export type IncomingRevisionsType = {
|
||||
export type IncomingCollectionRevisionsType = {
|
||||
maxPerDoc?: number
|
||||
retainDeleted?: boolean
|
||||
drafts?: boolean | Drafts
|
||||
}
|
||||
|
||||
export type IncomingGlobalRevisionsType = {
|
||||
max?: number
|
||||
drafts?: boolean | Drafts
|
||||
}
|
||||
|
||||
export type TypeWithRevision<T> = {
|
||||
id: string
|
||||
parent: string | number
|
||||
|
||||
Reference in New Issue
Block a user