export type LitLikeElement = { requestUpdate: () => void dispatchEvent: (e: Event) => boolean updateComplete: Promise } export type UpdateableLitLikeElement = { updated(_?: any): void } type States = { index: number, count: number, states: InjectableState[] reducers: Reduce[] workflows: Workflow[] } export type DecoratedLitLikeElement = LitLikeElement & { __registered_states: States } export type Reducer = (state: T) => {[action: string]: (payload?: any | unknown | undefined) => Promise} export type StateOptions = { updateDefault?: boolean } export type ReducerOptions = StateOptions & { dispatchEvent?: boolean } export interface State { /** * @deprecated The method should not be used. Use `get` or `value` instead. */ getState: () => T /** * @deprecated The method should not be used. Use `set` or `value` instead. */ publish: (update: T) => void get: () => T set: (update: T) => Promise value: T subscribe: (onChange: (state: T) => Promise) => void } export interface InjectableState extends State { inject: (update: T) => void, } export type Reduce = { get: () => T set: (action: string, data?: T) => Promise subscribe: (onChange: (action: string, state: T) => void) => void when: (action: string, onChange: (state: T) => void) => void dispatch: (action: string, data?: T) => Promise } export type WorkflowHistory = { type: string, args: unknown[] } export type Workflow = { addActivity: (activity: string, data?: unknown) => Promise addCompensation: (activity: string, data?: unknown) => void addSideeffect: (activity: string, sideeffect: (data?: unknown) => Promise) => void projections: (key: string) => any after: (timeout: Date, unlessActivity: WorkflowHistory, execute: () => Promise) => void compensate: () => Promise history: () => WorkflowHistory[] plan: (plan: {[entity: string]: () => Promise}) => Promise }