alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
105 lines (104 loc) • 2.99 kB
TypeScript
import { Drafts } from 'alinea/backend/Drafts';
import { History, Revision } from 'alinea/backend/History';
import { ChangeSet } from 'alinea/backend/data/ChangeSet';
import { Draft } from './Draft.js';
import { EntryRecord } from './EntryRecord.js';
import { EntryRow } from './EntryRow.js';
import { Mutation } from './Mutation.js';
import { ResolveDefaults, Resolver } from './Resolver.js';
import { User } from './User.js';
import { Selection } from './pages/Selection.js';
import { Logger } from './util/Logger.js';
export interface SyncResponse {
insert: Array<EntryRow>;
remove: Array<string>;
}
export interface Syncable {
syncRequired(contentHash: string): Promise<boolean>;
sync(contentHashes: Array<string>): Promise<SyncResponse>;
}
export interface Connection extends Resolver, Syncable, History, Drafts {
previewToken(): Promise<string>;
mutate(mutations: Array<Mutation>): Promise<{
commitHash: string;
}>;
prepareUpload(file: string): Promise<Connection.UploadResponse>;
revisions(file: string): Promise<Array<Revision>>;
revisionData(file: string, revisionId: string): Promise<EntryRecord>;
getDraft(entryId: string): Promise<Draft | undefined>;
storeDraft(draft: Draft): Promise<void>;
}
export declare namespace Connection {
type UploadParams = {
parentId?: string;
workspace: string;
root: string;
path: string;
buffer: ArrayBuffer;
preview?: string;
averageColor?: string;
thumbHash?: string;
width?: number;
height?: number;
};
interface UploadResponse {
entryId: string;
location: string;
previewUrl: string;
upload: {
url: string;
method?: string;
};
}
interface ResolveParams extends ResolveDefaults {
selection: Selection;
location?: Array<string>;
locale?: string;
}
type MediaUploadParams = {
buffer: ArrayBuffer;
fileLocation: string;
};
type Download = {
type: 'buffer';
buffer: ArrayBuffer;
} | {
type: 'url';
url: string;
};
type DownloadParams = {
workspace: string;
location: string;
};
type DeleteParams = {
workspace: string;
location: string;
};
interface RevisionsParams {
file: string;
}
interface MutateParams {
commitHash: string;
mutations: ChangeSet;
}
interface AuthContext {
user?: User;
token?: string;
preview?: string;
}
interface Context extends AuthContext {
logger: Logger;
}
const routes: {
base: string;
resolve(): string;
mutate(): string;
revisions(): string;
sync(): string;
draft(): string;
media(): string;
prepareUpload(): string;
files(location?: string): string;
previewToken(): string;
};
}