// state machine types export interface StreamGeneric { [id:string]: any }; export interface StreamStateSchema { context: { active: string, fields: StreamGeneric, // machines: StreamGeneric, timer: { elapsed: number; duration: number; interval: number; }, result: StreamGeneric }; states: StreamGeneric ; } export type XIO__STORE_INITIATED = { type: 'XIO__STORE_INITIATED', store: any }; export type XIO__CHILD_TO_PARENT = { type: 'XIO__CHILD_TO_PARENT', value: any }; export type XIO__DOM_READY = { type: 'XIO__DOM_READY' }; // The events that the machine handles export type ValueEvent = { type: 'VALUE_UPDATED'; id: string; value: any }; export type StreamEvents = | { type: 'NEXT' } | { type: 'PREVIOUS' } | { type: 'SUBMIT' } | ValueEvent; // The context (extended state) of the machine export interface StreamContext extends StreamGeneric {} // Note: Based on Firestore query operators. export enum StreamQueryOperators { '==', // anchor is equal to this value '!=', // anchor is not equal to this value '<', // anchor is smaller than this value '>', // anchor is larger than this value '=<', // anchor is equal to or larger than this value '=>', // anchor is equal to or smaller than this value 'array-contains', // anchor is an array and contains this value 'in', // anchor is included in this value which is an array, 'VALID', // anchor is valid 'INVALID', // anchor is invalid } export interface IStreamQuery { operator: string, anchorValues: any[], message: string } export class StreamQuery implements IStreamQuery { operator = 'equalTo'; // StreamQueryOperators[StreamQueryOperators["=="]]; anchorValues = []; message = ''; constructor(query: Partial){ this.operator = query.operator || this.operator; this.anchorValues = query.anchorValues || this.anchorValues; this.message = query.message || this.message; } }