Fix StartOS 0.4 TypeScript packaging to match SDK API
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
import { InputSpec } from './input/builder';
|
||||
import { ExtractInputSpecType } from './input/builder/inputSpec';
|
||||
import * as T from '../types';
|
||||
import { InitScript } from '../inits';
|
||||
export type Run<A extends Record<string, any>> = (options: {
|
||||
effects: T.Effects;
|
||||
input: A;
|
||||
spec: T.inputSpecTypes.InputSpec;
|
||||
}) => Promise<(T.ActionResult & {
|
||||
version: '1';
|
||||
}) | null | void | undefined>;
|
||||
export type GetInput<A extends Record<string, any>> = (options: {
|
||||
effects: T.Effects;
|
||||
prefill: T.DeepPartial<A> | null;
|
||||
}) => Promise<null | void | undefined | T.DeepPartial<A>>;
|
||||
export type MaybeFn<T, Opts = {
|
||||
effects: T.Effects;
|
||||
}> = T | ((options: Opts) => Promise<T>);
|
||||
export interface ActionInfo<Id extends T.ActionId, Type extends Record<string, any>> {
|
||||
readonly id: Id;
|
||||
readonly _INPUT: Type;
|
||||
}
|
||||
export declare class Action<Id extends T.ActionId, Type extends Record<string, any>> implements ActionInfo<Id, Type> {
|
||||
readonly id: Id;
|
||||
private readonly metadataFn;
|
||||
private readonly inputSpec;
|
||||
private readonly getInputFn;
|
||||
private readonly runFn;
|
||||
readonly _INPUT: Type;
|
||||
private prevInputSpec;
|
||||
private constructor();
|
||||
static withInput<Id extends T.ActionId, InputSpecType extends InputSpec<Record<string, any>>>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, 'hasInput'>>, inputSpec: MaybeFn<InputSpecType, {
|
||||
effects: T.Effects;
|
||||
prefill: unknown | null;
|
||||
}>, getInput: GetInput<ExtractInputSpecType<InputSpecType>>, run: Run<ExtractInputSpecType<InputSpecType>>): Action<Id, ExtractInputSpecType<InputSpecType>>;
|
||||
static withoutInput<Id extends T.ActionId>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, 'hasInput'>>, run: Run<{}>): Action<Id, {}>;
|
||||
exportMetadata(options: {
|
||||
effects: T.Effects;
|
||||
}): Promise<T.ActionMetadata>;
|
||||
getInput(options: {
|
||||
effects: T.Effects;
|
||||
prefill: T.DeepPartial<Type> | null;
|
||||
}): Promise<T.ActionInput>;
|
||||
run(options: {
|
||||
effects: T.Effects;
|
||||
input: Type;
|
||||
}): Promise<T.ActionResult | null>;
|
||||
}
|
||||
export declare class Actions<AllActions extends Record<T.ActionId, Action<T.ActionId, any>>> implements InitScript {
|
||||
private readonly actions;
|
||||
private constructor();
|
||||
static of(): Actions<{}>;
|
||||
addAction<A extends Action<T.ActionId, any>>(action: A): Actions<AllActions & {
|
||||
[id in A['id']]: A;
|
||||
}>;
|
||||
init(effects: T.Effects): Promise<void>;
|
||||
get<Id extends T.ActionId>(actionId: Id): AllActions[Id];
|
||||
}
|
||||
Reference in New Issue
Block a user