2022-10-27 12:24:30 -04:00
|
|
|
import type {
|
|
|
|
EditorPlugin as MarkdownPlugin,
|
|
|
|
EditorType as MarkdownEditorType,
|
|
|
|
} from '@toast-ui/editor/types/editor';
|
|
|
|
import type { ToolbarItemOptions as MarkdownToolbarItemOptions } from '@toast-ui/editor/types/ui';
|
2022-10-20 11:57:30 -04:00
|
|
|
import type { PropertiesSchema } from 'ajv/dist/types/json-schema';
|
|
|
|
import type { ComponentType, ReactNode } from 'react';
|
2022-09-28 20:04:00 -06:00
|
|
|
import type { t, TranslateProps as ReactPolyglotTranslateProps } from 'react-polyglot';
|
2022-10-20 11:57:30 -04:00
|
|
|
import type { MediaFile as BackendMediaFile } from './backend';
|
|
|
|
import type { EditorControlProps } from './components/Editor/EditorControlPane/EditorControl';
|
|
|
|
import type { formatExtensions } from './formats/formats';
|
|
|
|
import type { I18N_STRUCTURE } from './lib/i18n';
|
|
|
|
import type { AllowedEvent } from './lib/registry';
|
2022-09-28 20:04:00 -06:00
|
|
|
import type Cursor from './lib/util/Cursor';
|
2022-10-20 11:57:30 -04:00
|
|
|
import type AssetProxy from './valueObjects/AssetProxy';
|
2022-11-01 14:07:30 -04:00
|
|
|
import type { MediaHolder } from './widgets/markdown/hooks/useMedia';
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface SlugConfig {
|
|
|
|
encoding: string;
|
|
|
|
clean_accents: boolean;
|
|
|
|
sanitize_replacement: string;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface Pages {
|
|
|
|
[collection: string]: { isFetching?: boolean; page?: number; ids: string[] };
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type SortableField =
|
|
|
|
| {
|
|
|
|
key: string;
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
}
|
|
|
|
| ({
|
|
|
|
key: string;
|
|
|
|
} & Field);
|
|
|
|
|
|
|
|
export interface SortObject {
|
|
|
|
key: string;
|
|
|
|
direction: SortDirection;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type SortMap = Record<string, SortObject>;
|
|
|
|
|
|
|
|
export type Sort = Record<string, SortMap>;
|
|
|
|
|
|
|
|
export type FilterMap = ViewFilter & { active?: boolean };
|
|
|
|
|
|
|
|
export type GroupMap = ViewGroup & { active?: boolean };
|
|
|
|
|
|
|
|
export type Filter = Record<string, Record<string, FilterMap>>; // collection.field.active
|
|
|
|
|
|
|
|
export type Group = Record<string, Record<string, GroupMap>>; // collection.field.active
|
|
|
|
|
|
|
|
export interface GroupOfEntries {
|
|
|
|
id: string;
|
|
|
|
label: string;
|
|
|
|
value: string | boolean | undefined;
|
|
|
|
paths: Set<string>;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type ObjectValue = {
|
|
|
|
[key: string]: ValueOrNestedValue;
|
2022-09-28 20:04:00 -06:00
|
|
|
};
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type ValueOrNestedValue =
|
|
|
|
| string
|
|
|
|
| number
|
|
|
|
| boolean
|
|
|
|
| string[]
|
|
|
|
| null
|
|
|
|
| undefined
|
|
|
|
| ObjectValue
|
|
|
|
| ObjectValue[];
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type EntryData = ObjectValue | undefined | null;
|
|
|
|
|
2022-11-02 08:54:30 -04:00
|
|
|
export interface Entry<T = ObjectValue> {
|
2022-10-20 11:57:30 -04:00
|
|
|
collection: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
slug: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
path: string;
|
|
|
|
partial: boolean;
|
2022-09-28 20:04:00 -06:00
|
|
|
raw: string;
|
2022-11-02 08:54:30 -04:00
|
|
|
data: T | undefined | null;
|
2022-10-20 11:57:30 -04:00
|
|
|
label: string | null;
|
|
|
|
isModification: boolean | null;
|
|
|
|
mediaFiles: MediaFile[];
|
|
|
|
author: string;
|
|
|
|
updatedOn: string;
|
|
|
|
status?: string;
|
|
|
|
newRecord?: boolean;
|
|
|
|
isFetching?: boolean;
|
|
|
|
isPersisting?: boolean;
|
|
|
|
isDeleting?: boolean;
|
|
|
|
error?: string;
|
|
|
|
i18n?: {
|
|
|
|
[locale: string]: {
|
|
|
|
data: EntryData;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Entities = Record<string, Entry>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface FieldError {
|
|
|
|
type: string;
|
|
|
|
message?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface FieldsErrors {
|
|
|
|
[field: string]: FieldError[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface FieldValidationMethodProps<T = unknown, F extends Field = Field> {
|
|
|
|
field: F;
|
|
|
|
value: T | undefined | null;
|
|
|
|
t: t;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type FieldValidationMethod<T = unknown, F extends Field = Field> = (
|
|
|
|
props: FieldValidationMethodProps<T, F>,
|
|
|
|
) => false | FieldError | Promise<false | FieldError>;
|
|
|
|
|
|
|
|
export interface EntryDraft {
|
|
|
|
entry: Entry;
|
|
|
|
fieldsErrors: FieldsErrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface FilterRule {
|
|
|
|
value: string;
|
|
|
|
field: string;
|
|
|
|
}
|
|
|
|
|
2022-10-26 14:55:26 -04:00
|
|
|
export interface EditorConfig {
|
|
|
|
preview?: boolean;
|
|
|
|
frame?: boolean;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface CollectionFile {
|
|
|
|
name: string;
|
|
|
|
label: string;
|
|
|
|
file: string;
|
|
|
|
fields: Field[];
|
|
|
|
label_singular?: string;
|
|
|
|
description?: string;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
i18n?: boolean | I18nInfo;
|
2022-10-26 14:55:26 -04:00
|
|
|
editor?: EditorConfig;
|
2022-10-20 11:57:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Nested {
|
|
|
|
summary?: string;
|
|
|
|
depth: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface I18nSettings {
|
|
|
|
currentLocale: string;
|
|
|
|
defaultLocale: string;
|
|
|
|
locales: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Format = keyof typeof formatExtensions;
|
|
|
|
|
|
|
|
export interface i18nCollection extends Omit<Collection, 'i18n'> {
|
|
|
|
i18n: Required<Collection>['i18n'];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Collection {
|
|
|
|
name: string;
|
|
|
|
description?: string;
|
|
|
|
icon?: string;
|
|
|
|
folder?: string;
|
|
|
|
files?: CollectionFile[];
|
|
|
|
fields: Field[];
|
|
|
|
isFetching?: boolean;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
preview_path?: string;
|
|
|
|
preview_path_date_field?: string;
|
|
|
|
summary?: string;
|
|
|
|
filter?: FilterRule;
|
|
|
|
type: 'file_based_collection' | 'folder_based_collection';
|
|
|
|
extension?: string;
|
|
|
|
format?: Format;
|
|
|
|
frontmatter_delimiter?: string | [string, string];
|
|
|
|
create?: boolean;
|
|
|
|
delete?: boolean;
|
|
|
|
identifier_field?: string;
|
|
|
|
path?: string;
|
|
|
|
slug?: string;
|
|
|
|
label_singular?: string;
|
|
|
|
label: string;
|
|
|
|
sortable_fields: SortableFields;
|
|
|
|
view_filters: ViewFilter[];
|
|
|
|
view_groups: ViewGroup[];
|
|
|
|
nested?: Nested;
|
|
|
|
i18n?: boolean | I18nInfo;
|
|
|
|
hide?: boolean;
|
2022-10-26 14:55:26 -04:00
|
|
|
editor?: EditorConfig;
|
2022-10-20 11:57:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export type Collections = Record<string, Collection>;
|
|
|
|
|
|
|
|
export interface MediaLibraryInstance {
|
|
|
|
show: (args: {
|
|
|
|
id?: string;
|
|
|
|
value?: string | string[];
|
|
|
|
config: Record<string, unknown>;
|
|
|
|
allowMultiple?: boolean;
|
|
|
|
imagesOnly?: boolean;
|
|
|
|
}) => void;
|
|
|
|
hide?: () => void;
|
|
|
|
onClearControl?: (args: { id: string }) => void;
|
|
|
|
onRemoveControl?: (args: { id: string }) => void;
|
|
|
|
enableStandalone: () => boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type MediaFile = BackendMediaFile & { key?: string };
|
|
|
|
|
|
|
|
export interface DisplayURLState {
|
|
|
|
isFetching: boolean;
|
|
|
|
url?: string;
|
|
|
|
err?: Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Hook = string | boolean;
|
|
|
|
|
|
|
|
export type TranslatedProps<T> = T & ReactPolyglotTranslateProps;
|
|
|
|
|
2022-11-01 14:07:30 -04:00
|
|
|
export type GetAssetFunction = (path: string, field?: Field) => Promise<AssetProxy>;
|
2022-10-20 11:57:30 -04:00
|
|
|
|
|
|
|
export interface WidgetControlProps<T, F extends Field = Field> {
|
|
|
|
clearFieldErrors: EditorControlProps['clearFieldErrors'];
|
|
|
|
clearSearch: EditorControlProps['clearSearch'];
|
|
|
|
collection: Collection;
|
|
|
|
config: Config;
|
|
|
|
entry: Entry;
|
|
|
|
field: F;
|
|
|
|
fieldsErrors: FieldsErrors;
|
|
|
|
submitted: boolean;
|
|
|
|
forList: boolean;
|
|
|
|
getAsset: GetAssetFunction;
|
|
|
|
isDisabled: boolean;
|
|
|
|
isFetching: boolean;
|
|
|
|
isFieldDuplicate: EditorControlProps['isFieldDuplicate'];
|
|
|
|
isFieldHidden: EditorControlProps['isFieldHidden'];
|
|
|
|
label: string;
|
|
|
|
loadEntry: EditorControlProps['loadEntry'];
|
|
|
|
locale: string | undefined;
|
|
|
|
mediaPaths: Record<string, string | string[]>;
|
|
|
|
onChange: (value: T | null | undefined) => void;
|
|
|
|
clearMediaControl: EditorControlProps['clearMediaControl'];
|
|
|
|
openMediaLibrary: EditorControlProps['openMediaLibrary'];
|
|
|
|
removeInsertedMedia: EditorControlProps['removeInsertedMedia'];
|
|
|
|
removeMediaControl: EditorControlProps['removeMediaControl'];
|
|
|
|
i18n: I18nSettings | undefined;
|
|
|
|
hasErrors: boolean;
|
2022-09-28 20:04:00 -06:00
|
|
|
path: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
query: EditorControlProps['query'];
|
|
|
|
t: t;
|
|
|
|
value: T | undefined | null;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface WidgetPreviewProps<T = unknown, F extends Field = Field> {
|
2022-11-01 14:07:30 -04:00
|
|
|
config: Config;
|
2022-10-27 12:24:30 -04:00
|
|
|
collection: Collection;
|
2022-10-20 11:57:30 -04:00
|
|
|
entry: Entry;
|
2022-10-27 12:24:30 -04:00
|
|
|
field: RenderedField<F>;
|
2022-10-20 11:57:30 -04:00
|
|
|
getAsset: GetAssetFunction;
|
|
|
|
resolveWidget: <W = unknown, WF extends Field = Field>(name: string) => Widget<W, WF>;
|
|
|
|
value: T | undefined | null;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type WidgetPreviewComponent<T = unknown, F extends Field = Field> =
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
| React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
|
|
|
|
| ComponentType<WidgetPreviewProps<T, F>>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-11-02 08:54:30 -04:00
|
|
|
export interface TemplatePreviewProps<T = unknown> {
|
2022-10-20 11:57:30 -04:00
|
|
|
collection: Collection;
|
|
|
|
fields: Field[];
|
2022-11-02 08:54:30 -04:00
|
|
|
entry: Entry<T>;
|
2022-10-26 14:55:26 -04:00
|
|
|
document: Document | undefined | null;
|
|
|
|
window: Window | undefined | null;
|
2022-10-20 11:57:30 -04:00
|
|
|
getAsset: GetAssetFunction;
|
|
|
|
widgetFor: (name: string) => ReactNode;
|
|
|
|
widgetsFor: (name: string) =>
|
|
|
|
| {
|
|
|
|
data: EntryData | null;
|
|
|
|
widgets: Record<string, React.ReactNode>;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
data: EntryData | null;
|
|
|
|
widgets: Record<string, React.ReactNode>;
|
|
|
|
}[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export type TemplatePreviewComponent =
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
| React.ReactElement<unknown, string | React.JSXElementConstructor<any>>
|
|
|
|
| ComponentType<TemplatePreviewProps>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface WidgetOptions<T = unknown, F extends Field = Field> {
|
|
|
|
validator?: Widget<T, F>['validator'];
|
|
|
|
getValidValue?: Widget<T, F>['getValidValue'];
|
|
|
|
schema?: Widget<T, F>['schema'];
|
|
|
|
allowMapValue?: boolean;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface Widget<T = unknown, F extends Field = Field> {
|
|
|
|
control: ComponentType<WidgetControlProps<T, F>>;
|
|
|
|
preview?: WidgetPreviewComponent<T, F>;
|
|
|
|
validator: FieldValidationMethod<T, F>;
|
|
|
|
getValidValue: (value: T | undefined | null) => T | undefined | null;
|
|
|
|
schema?: PropertiesSchema<unknown>;
|
|
|
|
allowMapValue?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WidgetParam<T = unknown, F extends Field = Field> {
|
2022-09-28 20:04:00 -06:00
|
|
|
name: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
controlComponent: Widget<T, F>['control'];
|
|
|
|
previewComponent?: Widget<T, F>['preview'];
|
|
|
|
options?: WidgetOptions<T, F>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PersistOptions {
|
|
|
|
newEntry?: boolean;
|
|
|
|
commitMessage: string;
|
|
|
|
collectionName?: string;
|
|
|
|
status?: string;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
|
|
|
export interface ImplementationEntry {
|
|
|
|
data: string;
|
|
|
|
file: { path: string; label?: string; id?: string | null; author?: string; updatedOn?: string };
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface DisplayURLObject {
|
|
|
|
id: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
path: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export type DisplayURL = DisplayURLObject | string;
|
|
|
|
|
2022-09-28 20:04:00 -06:00
|
|
|
export interface ImplementationMediaFile {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
size?: number;
|
|
|
|
displayURL?: DisplayURL;
|
|
|
|
path: string;
|
|
|
|
draft?: boolean;
|
|
|
|
url?: string;
|
|
|
|
file?: File;
|
2022-10-20 11:57:30 -04:00
|
|
|
field?: Field;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface DataFile {
|
|
|
|
path: string;
|
|
|
|
slug: string;
|
|
|
|
raw: string;
|
|
|
|
newPath?: string;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface BackendEntry {
|
|
|
|
dataFiles: DataFile[];
|
|
|
|
assets: AssetProxy[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export type DeleteOptions = {};
|
|
|
|
|
|
|
|
export interface Credentials {
|
|
|
|
token: string | {};
|
|
|
|
refresh_token?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type User = Credentials & {
|
|
|
|
backendName?: string;
|
|
|
|
login?: string;
|
|
|
|
name?: string;
|
|
|
|
avatar_url?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
};
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface ImplementationFile {
|
|
|
|
id?: string | null | undefined;
|
|
|
|
label?: string;
|
|
|
|
path: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AuthenticatorConfig {
|
|
|
|
site_id?: string;
|
|
|
|
base_url?: string;
|
|
|
|
auth_endpoint?: string;
|
|
|
|
auth_token_endpoint?: string;
|
|
|
|
auth_url?: string;
|
|
|
|
app_id?: string;
|
|
|
|
clearHash?: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export abstract class BackendClass {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
constructor(_config: Config, _options: BackendInitializerOptions) {}
|
|
|
|
|
|
|
|
abstract authComponent(): (props: TranslatedProps<AuthenticationPageProps>) => JSX.Element;
|
|
|
|
abstract restoreUser(user: User): Promise<User>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract authenticate(credentials: Credentials): Promise<User>;
|
|
|
|
abstract logout(): Promise<void> | void | null;
|
|
|
|
abstract getToken(): Promise<string | null>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract getEntry(path: string): Promise<ImplementationEntry>;
|
|
|
|
abstract entriesByFolder(
|
2022-09-28 20:04:00 -06:00
|
|
|
folder: string,
|
|
|
|
extension: string,
|
|
|
|
depth: number,
|
2022-10-20 11:57:30 -04:00
|
|
|
): Promise<ImplementationEntry[]>;
|
|
|
|
abstract entriesByFiles(files: ImplementationFile[]): Promise<ImplementationEntry[]>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract getMediaDisplayURL(displayURL: DisplayURL): Promise<string>;
|
|
|
|
abstract getMedia(folder?: string): Promise<ImplementationMediaFile[]>;
|
|
|
|
abstract getMediaFile(path: string): Promise<ImplementationMediaFile>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract persistEntry(entry: BackendEntry, opts: PersistOptions): Promise<void>;
|
|
|
|
abstract persistMedia(file: AssetProxy, opts: PersistOptions): Promise<ImplementationMediaFile>;
|
|
|
|
abstract deleteFiles(paths: string[], commitMessage: string): Promise<unknown>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract allEntriesByFolder(
|
2022-09-28 20:04:00 -06:00
|
|
|
folder: string,
|
|
|
|
extension: string,
|
|
|
|
depth: number,
|
2022-10-20 11:57:30 -04:00
|
|
|
): Promise<ImplementationEntry[]>;
|
|
|
|
abstract traverseCursor(
|
2022-09-28 20:04:00 -06:00
|
|
|
cursor: Cursor,
|
|
|
|
action: string,
|
2022-10-20 11:57:30 -04:00
|
|
|
): Promise<{ entries: ImplementationEntry[]; cursor: Cursor }>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
abstract isGitBackend(): boolean;
|
|
|
|
abstract status(): Promise<{
|
2022-09-28 20:04:00 -06:00
|
|
|
auth: { status: boolean };
|
|
|
|
api: { status: boolean; statusPage: string };
|
|
|
|
}>;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface LocalePhrasesRoot {
|
|
|
|
[property: string]: LocalePhrases;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
2022-10-20 11:57:30 -04:00
|
|
|
export type LocalePhrases = string | { [property: string]: LocalePhrases };
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type CustomIcon = () => JSX.Element;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type WidgetValueSerializer = {
|
|
|
|
serialize: (value: ValueOrNestedValue) => ValueOrNestedValue;
|
|
|
|
deserialize: (value: ValueOrNestedValue) => ValueOrNestedValue;
|
|
|
|
};
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type MediaLibraryOptions = Record<string, unknown>;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface MediaLibraryInitOptions {
|
|
|
|
options: Record<string, unknown> | undefined;
|
|
|
|
handleInsert: (url: string | string[]) => void;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface MediaLibraryExternalLibrary {
|
|
|
|
name: string;
|
|
|
|
config?: MediaLibraryOptions;
|
|
|
|
init: ({ options, handleInsert }: MediaLibraryInitOptions) => Promise<MediaLibraryInstance>;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface MediaLibraryInternalOptions {
|
|
|
|
allow_multiple?: boolean;
|
|
|
|
choose_url?: boolean;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type MediaLibrary = MediaLibraryExternalLibrary | MediaLibraryInternalOptions;
|
|
|
|
|
|
|
|
export type BackendType =
|
2022-09-28 20:04:00 -06:00
|
|
|
| 'azure'
|
|
|
|
| 'git-gateway'
|
|
|
|
| 'github'
|
|
|
|
| 'gitlab'
|
|
|
|
| 'bitbucket'
|
|
|
|
| 'test-repo'
|
|
|
|
| 'proxy';
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type MapWidgetType = 'Point' | 'LineString' | 'Polygon';
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type MarkdownWidgetButton =
|
2022-09-28 20:04:00 -06:00
|
|
|
| 'bold'
|
|
|
|
| 'italic'
|
|
|
|
| 'code'
|
|
|
|
| 'link'
|
|
|
|
| 'heading-one'
|
|
|
|
| 'heading-two'
|
|
|
|
| 'heading-three'
|
|
|
|
| 'heading-four'
|
|
|
|
| 'heading-five'
|
|
|
|
| 'heading-six'
|
|
|
|
| 'quote'
|
|
|
|
| 'code-block'
|
|
|
|
| 'bulleted-list'
|
|
|
|
| 'numbered-list';
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface SelectWidgetOptionObject {
|
2022-09-28 20:04:00 -06:00
|
|
|
label: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
value: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type AuthScope = 'repo' | 'public_repo';
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type SlugEncoding = 'unicode' | 'ascii';
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-27 12:24:30 -04:00
|
|
|
export type RenderedField<T extends Field = Field> = Omit<T, 'fields'> & {
|
|
|
|
fields?: ReactNode[];
|
|
|
|
};
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
name: string;
|
|
|
|
label?: string;
|
|
|
|
required?: boolean;
|
|
|
|
hint?: string;
|
|
|
|
pattern?: [string, string];
|
|
|
|
i18n?: boolean | 'translate' | 'duplicate' | 'none';
|
|
|
|
comment?: string;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface BooleanField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'boolean';
|
|
|
|
default?: boolean;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface CodeField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'code';
|
2022-10-20 11:57:30 -04:00
|
|
|
default?: string | { [key: string]: string };
|
2022-09-28 20:04:00 -06:00
|
|
|
|
|
|
|
default_language?: string;
|
|
|
|
allow_language_selection?: boolean;
|
|
|
|
keys?: { code: string; lang: string };
|
|
|
|
output_code_only?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
|
|
|
|
code_mirror_config: {
|
|
|
|
extra_keys?: Record<string, string>;
|
|
|
|
} & Record<string, unknown>;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface ColorField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'color';
|
|
|
|
default?: string;
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
allow_input?: boolean;
|
|
|
|
enable_alpha?: boolean;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface DateTimeField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'datetime';
|
|
|
|
default?: string;
|
|
|
|
|
|
|
|
format?: string;
|
|
|
|
date_format?: boolean | string;
|
|
|
|
time_format?: boolean | string;
|
2022-11-02 13:18:06 -04:00
|
|
|
picker_utc?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface FileOrImageField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'file' | 'image';
|
|
|
|
default?: string;
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
media_library?: MediaLibrary;
|
2022-11-02 13:18:06 -04:00
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
private?: boolean;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface ObjectField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'object';
|
2022-10-20 11:57:30 -04:00
|
|
|
default?: ObjectValue;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
|
|
|
collapsed?: boolean;
|
|
|
|
summary?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
fields: Field[];
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface ListField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'list';
|
2022-10-20 11:57:30 -04:00
|
|
|
default?: ObjectValue[];
|
2022-09-28 20:04:00 -06:00
|
|
|
|
|
|
|
allow_add?: boolean;
|
|
|
|
collapsed?: boolean;
|
|
|
|
summary?: string;
|
|
|
|
minimize_collapsed?: boolean;
|
|
|
|
label_singular?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
fields?: Field[];
|
2022-09-28 20:04:00 -06:00
|
|
|
max?: number;
|
|
|
|
min?: number;
|
|
|
|
add_to_top?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
types?: ObjectField[];
|
|
|
|
typeKey?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface MapField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'map';
|
|
|
|
default?: string;
|
|
|
|
|
|
|
|
decimals?: number;
|
2022-10-20 11:57:30 -04:00
|
|
|
type?: MapWidgetType;
|
|
|
|
height?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface MarkdownField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'markdown';
|
|
|
|
default?: string;
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
media_library?: MediaLibrary;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface NumberField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'number';
|
|
|
|
default?: string | number;
|
|
|
|
|
|
|
|
value_type?: 'int' | 'float' | string;
|
|
|
|
min?: number;
|
|
|
|
max?: number;
|
|
|
|
|
|
|
|
step?: number;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface SelectField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'select';
|
|
|
|
default?: string | string[];
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
options: string[] | SelectWidgetOptionObject[];
|
2022-09-28 20:04:00 -06:00
|
|
|
multiple?: boolean;
|
|
|
|
min?: number;
|
|
|
|
max?: number;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface RelationField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'relation';
|
|
|
|
default?: string | string[];
|
|
|
|
|
|
|
|
collection: string;
|
|
|
|
value_field: string;
|
|
|
|
search_fields: string[];
|
|
|
|
file?: string;
|
|
|
|
display_fields?: string[];
|
|
|
|
multiple?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
min?: number;
|
|
|
|
max?: number;
|
2022-09-28 20:04:00 -06:00
|
|
|
options_length?: number;
|
2022-10-20 11:57:30 -04:00
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface HiddenField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
widget: 'hidden';
|
2022-10-20 11:57:30 -04:00
|
|
|
default?: ValueOrNestedValue;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface StringOrTextField extends BaseField {
|
2022-09-28 20:04:00 -06:00
|
|
|
// This is the default widget, so declaring its type is optional.
|
|
|
|
widget?: 'string' | 'text';
|
|
|
|
default?: string;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export type Field =
|
|
|
|
| BooleanField
|
|
|
|
| CodeField
|
|
|
|
| ColorField
|
|
|
|
| DateTimeField
|
|
|
|
| FileOrImageField
|
|
|
|
| ListField
|
|
|
|
| MapField
|
|
|
|
| MarkdownField
|
|
|
|
| NumberField
|
|
|
|
| ObjectField
|
|
|
|
| RelationField
|
|
|
|
| SelectField
|
|
|
|
| HiddenField
|
|
|
|
| StringOrTextField;
|
2022-09-28 20:04:00 -06:00
|
|
|
|
|
|
|
export interface ViewFilter {
|
|
|
|
id: string;
|
|
|
|
label: string;
|
|
|
|
field: string;
|
|
|
|
pattern: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ViewGroup {
|
|
|
|
id: string;
|
|
|
|
label: string;
|
|
|
|
field: string;
|
|
|
|
pattern?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum SortDirection {
|
|
|
|
Ascending = 'Ascending',
|
|
|
|
Descending = 'Descending',
|
|
|
|
None = 'None',
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface SortableFieldsDefault {
|
2022-09-28 20:04:00 -06:00
|
|
|
field: string;
|
2022-09-28 22:10:31 -04:00
|
|
|
direction?: SortDirection;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface SortableFields {
|
|
|
|
default?: SortableFieldsDefault;
|
2022-09-28 20:04:00 -06:00
|
|
|
fields: string[];
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface Backend {
|
|
|
|
name: BackendType;
|
|
|
|
auth_scope?: AuthScope;
|
2022-09-28 20:04:00 -06:00
|
|
|
repo?: string;
|
|
|
|
branch?: string;
|
|
|
|
api_root?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
api_version?: string;
|
|
|
|
tenant_id?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
site_domain?: string;
|
|
|
|
base_url?: string;
|
|
|
|
auth_endpoint?: string;
|
|
|
|
app_id?: string;
|
|
|
|
auth_type?: 'implicit' | 'pkce';
|
|
|
|
proxy_url?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
large_media_url?: string;
|
|
|
|
login?: boolean;
|
|
|
|
use_large_media_transforms_in_media_library?: boolean;
|
|
|
|
identity_url?: string;
|
|
|
|
gateway_url?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
commit_messages?: {
|
|
|
|
create?: string;
|
|
|
|
update?: string;
|
|
|
|
delete?: string;
|
|
|
|
uploadMedia?: string;
|
|
|
|
deleteMedia?: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface Slug {
|
|
|
|
encoding?: SlugEncoding;
|
2022-09-28 20:04:00 -06:00
|
|
|
clean_accents?: boolean;
|
|
|
|
sanitize_replacement?: string;
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface LocalBackend {
|
2022-09-28 20:04:00 -06:00
|
|
|
url?: string;
|
|
|
|
allowed_hosts?: string[];
|
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface Config {
|
|
|
|
backend: Backend;
|
|
|
|
collections: Collection[];
|
2022-09-28 20:04:00 -06:00
|
|
|
locale?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
site_id?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
site_url?: string;
|
|
|
|
display_url?: string;
|
2022-10-20 11:57:30 -04:00
|
|
|
base_url?: string;
|
2022-09-28 20:04:00 -06:00
|
|
|
logo_url?: string;
|
|
|
|
media_folder?: string;
|
|
|
|
public_folder?: string;
|
|
|
|
media_folder_relative?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
media_library?: MediaLibrary;
|
2022-09-28 20:04:00 -06:00
|
|
|
load_config_file?: boolean;
|
2022-10-20 11:57:30 -04:00
|
|
|
integrations?: Integration[];
|
|
|
|
slug?: Slug;
|
|
|
|
i18n?: I18nInfo;
|
|
|
|
local_backend?: boolean | LocalBackend;
|
2022-10-26 14:55:26 -04:00
|
|
|
editor?: EditorConfig;
|
2022-09-28 20:04:00 -06:00
|
|
|
search?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface InitOptions {
|
2022-10-20 11:57:30 -04:00
|
|
|
config: Config;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface BackendInitializerOptions {
|
|
|
|
updateUserCredentials: (credentials: Credentials) => void;
|
|
|
|
}
|
2022-09-28 20:04:00 -06:00
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface BackendInitializer {
|
|
|
|
init: (config: Config, options: BackendInitializerOptions) => BackendClass;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
|
|
|
|
2022-10-20 11:57:30 -04:00
|
|
|
export interface EventData {
|
|
|
|
entry: Entry;
|
|
|
|
author: { login: string | undefined; name: string };
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface EventListener {
|
|
|
|
name: AllowedEvent;
|
|
|
|
handler: (
|
|
|
|
data: EventData,
|
|
|
|
options: Record<string, unknown>,
|
|
|
|
) => Promise<EntryData | undefined | null | void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type EventListenerOptions = Record<string, unknown>;
|
|
|
|
|
|
|
|
export interface AdditionalLink {
|
|
|
|
id: string;
|
|
|
|
title: string;
|
|
|
|
data: string | (() => JSX.Element);
|
|
|
|
options?: {
|
|
|
|
iconName?: string;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AuthenticationPageProps {
|
|
|
|
onLogin: (user: User) => void;
|
|
|
|
inProgress?: boolean;
|
|
|
|
base_url?: string;
|
|
|
|
siteId?: string;
|
|
|
|
authEndpoint?: string;
|
|
|
|
config: Config;
|
|
|
|
error?: string | undefined;
|
|
|
|
clearHash?: () => void;
|
2022-09-28 20:04:00 -06:00
|
|
|
}
|
2022-10-20 11:57:30 -04:00
|
|
|
|
|
|
|
export type Integration = {
|
|
|
|
collections?: '*' | string[];
|
|
|
|
} & (AlgoliaIntegration | AssetStoreIntegration);
|
|
|
|
|
|
|
|
export type IntegrationProvider = Integration['provider'];
|
|
|
|
export type SearchIntegrationProvider = 'algolia';
|
|
|
|
export type MediaIntegrationProvider = 'assetStore';
|
|
|
|
|
|
|
|
export interface AlgoliaIntegration extends AlgoliaConfig {
|
|
|
|
provider: 'algolia';
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AlgoliaConfig {
|
|
|
|
hooks: ['search' | 'listEntries'];
|
|
|
|
applicationID: string;
|
|
|
|
apiKey: string;
|
|
|
|
indexPrefix?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AssetStoreIntegration extends AssetStoreConfig {
|
|
|
|
provider: 'assetStore';
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AssetStoreConfig {
|
|
|
|
hooks: ['assetStore'];
|
|
|
|
shouldConfirmUpload?: boolean;
|
|
|
|
getSignedFormURL: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchResponse {
|
|
|
|
entries: Entry[];
|
|
|
|
pagination: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchQueryResponse {
|
|
|
|
hits: Entry[];
|
|
|
|
query: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface EditorPersistOptions {
|
|
|
|
createNew?: boolean;
|
|
|
|
duplicate?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface I18nInfo {
|
|
|
|
locales: string[];
|
|
|
|
defaultLocale: string;
|
|
|
|
structure?: I18N_STRUCTURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ProcessedCodeLanguage {
|
|
|
|
label: string;
|
|
|
|
identifiers: string[];
|
|
|
|
codemirror_mode: string;
|
|
|
|
codemirror_mime_type: string;
|
|
|
|
}
|
|
|
|
|
2022-10-26 14:55:26 -04:00
|
|
|
export interface FileMetadata {
|
2022-10-20 11:57:30 -04:00
|
|
|
author: string;
|
|
|
|
updatedOn: string;
|
2022-10-26 14:55:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PreviewStyleOptions {
|
|
|
|
raw?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PreviewStyle {
|
|
|
|
value: string;
|
|
|
|
raw: boolean;
|
|
|
|
}
|
|
|
|
|
2022-10-27 12:24:30 -04:00
|
|
|
export interface MarkdownPluginFactoryProps {
|
2022-11-01 14:07:30 -04:00
|
|
|
config: Config;
|
2022-10-26 14:55:26 -04:00
|
|
|
field: MarkdownField;
|
2022-11-01 14:07:30 -04:00
|
|
|
media: MediaHolder;
|
2022-10-27 12:24:30 -04:00
|
|
|
mode: 'editor' | 'preview';
|
2022-10-26 14:55:26 -04:00
|
|
|
}
|
|
|
|
|
2022-10-27 12:24:30 -04:00
|
|
|
export type MarkdownPluginFactory = (props: MarkdownPluginFactoryProps) => MarkdownPlugin;
|
2022-10-26 14:55:26 -04:00
|
|
|
|
2022-10-27 12:24:30 -04:00
|
|
|
export interface MarkdownToolbarItemsFactoryProps {
|
|
|
|
imageToolbarButton: MarkdownToolbarItemOptions;
|
2022-10-26 14:55:26 -04:00
|
|
|
}
|
|
|
|
|
2022-10-27 12:24:30 -04:00
|
|
|
export type MarkdownToolbarItemsFactory = (
|
|
|
|
props: MarkdownToolbarItemsFactoryProps,
|
|
|
|
) => (string | MarkdownToolbarItemOptions)[][];
|
2022-10-26 14:55:26 -04:00
|
|
|
|
|
|
|
export interface MarkdownEditorOptions {
|
2022-10-27 12:24:30 -04:00
|
|
|
initialEditType?: MarkdownEditorType;
|
2022-10-26 14:55:26 -04:00
|
|
|
height?: string;
|
2022-10-27 12:24:30 -04:00
|
|
|
toolbarItems?: MarkdownToolbarItemsFactory;
|
|
|
|
plugins?: MarkdownPluginFactory[];
|
2022-10-26 14:55:26 -04:00
|
|
|
}
|