stackpress
Version:
Incept is a content management framework.
129 lines (128 loc) • 4.58 kB
TypeScript
import type { UnknownNest, NestedObject } from '@stackpress/lib/types';
import type Engine from '@stackpress/inquire/Engine';
import type Model from '../../schema/spec/Model';
import type { SearchParams } from '../types';
import batch from './batch';
import create from './create';
import detail from './detail';
import get from './get';
import remove from './remove';
import restore from './restore';
import search from './search';
import update from './update';
import upsert from './upsert';
export { batch, create, detail, get, remove, restore, search, update, upsert };
export declare class Actions<M extends UnknownNest = UnknownNest> {
readonly engine: Engine;
readonly model: Model;
protected _seed?: string;
constructor(model: Model, engine: Engine, seed?: string);
batch(rows: M[]): Promise<{
code: number;
status: string;
results: any;
total: number;
} | {
code: number;
status: string;
results: any;
total?: number;
} | {
code: number;
status: string;
error: string;
results: Partial<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: Partial<M>;
total?: number;
}>>[];
total: number;
stack: import("@stackpress/lib/types").Trace[];
}>;
create(input: NestedObject): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: Partial<M>;
total?: number;
}>>;
detail(ids: Record<string, string | number>, columns?: string[]): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M | null;
total?: number;
}>>;
get(key: string, value: string | number, columns?: string[]): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M | null;
total?: number;
}>>;
remove(ids: Record<string, string | number>): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M | null;
total?: number;
}>>;
restore(ids: Record<string, string | number>): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M | null;
total?: number;
}>>;
search(query: SearchParams): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M[];
total?: number;
}>>;
update(ids: Record<string, string | number>, input: NestedObject): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: M;
total?: number;
}>>;
upsert(input: NestedObject): Promise<Partial<import("@stackpress/lib/types").ResponseStatus & {
error: string;
errors?: NestedObject<string | string[]>;
start?: number;
end?: number;
stack?: import("@stackpress/lib/types").Trace[];
} & {
results: Partial<M>;
total?: number;
}>>;
}
export default function actions<M extends UnknownNest = UnknownNest>(model: Model, engine: Engine, seed?: string): Actions<M>;