alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
57 lines (56 loc) • 2.11 kB
TypeScript
import { Config, EntryUrlMeta } from 'alinea/core';
import { ArchiveMutation, CreateMutation, DiscardDraftMutation, EditMutation, FileRemoveMutation, MoveMutation, Mutation, OrderMutation, PublishMutation, RemoveEntryMutation, UploadMutation } from 'alinea/core/Mutation';
export declare enum ChangeType {
Write = "write",
Rename = "rename",
Patch = "patch",
Delete = "delete",
Upload = "upload"
}
export interface WriteChange {
type: ChangeType.Write;
file: string;
contents: string;
}
export interface RenameChange {
type: ChangeType.Rename;
from: string;
to: string;
}
export interface PatchChange {
type: ChangeType.Patch;
file: string;
patch: object;
}
export interface DeleteChange {
type: ChangeType.Delete;
file: string;
}
export interface UploadChange {
type: ChangeType.Upload;
file: string;
url: string;
}
export type Change = WriteChange | RenameChange | PatchChange | DeleteChange | UploadChange;
export type ChangeWithMeta = {
changes: Array<Change>;
meta: Mutation;
};
export type ChangeSet = Array<ChangeWithMeta>;
export declare class ChangeSetCreator {
config: Config;
constructor(config: Config);
entryLocation({ locale, parentPaths, path, phase }: EntryUrlMeta, extension: string): string;
editChanges({ previousFile, file, entry }: EditMutation): Array<Change>;
createChanges({ file, entry }: CreateMutation): Array<Change>;
publishChanges({ file }: PublishMutation): Array<Change>;
archiveChanges({ file }: ArchiveMutation): Array<Change>;
removeChanges({ file }: RemoveEntryMutation): Array<Change>;
discardChanges({ file }: DiscardDraftMutation): Array<Change>;
orderChanges({ file, index }: OrderMutation): Array<Change>;
moveChanges({ entryId, entryType, fromFile, toFile, index }: MoveMutation): Array<Change>;
fileUploadChanges(mutation: UploadMutation): Array<Change>;
fileRemoveChanges(mutation: FileRemoveMutation): Array<Change>;
mutationChanges(mutation: Mutation): Array<Change>;
create(mutations: Array<Mutation>): ChangeSet;
}