arvo-xstate
Version:
This package allows you to use xstate Actors and State Machines to act as orchestrators in an Arvo Event Driven System
41 lines (40 loc) • 1.51 kB
TypeScript
import type { ArvoContract, VersionedArvoContract } from 'arvo-core';
import type { MachineConfig } from 'xstate';
/**
* Detects if an XState machine configuration contains any parallel states.
* Uses a stack-based approach for efficient traversal of the state hierarchy.
*
* @param config - XState machine configuration
* @returns True if the machine contains at least one parallel state, false otherwise
*
* @example
* const machine = {
* states: {
* processing: {
* type: 'parallel',
* states: {
* upload: { ... },
* scan: { ... }
* }
* }
* }
* }
* const hasParallel = detectParallelStates(machine) // Returns true
*/
export declare const detectParallelStates: (config?: MachineConfig<any, any, any, any, any, any, any, any, any, any, any>) => boolean;
/**
* Validates that all service contracts in a collection have unique URIs.
*
* Iterates through the provided contracts and checks if any URI appears more than once.
* Multiple versions of the same contract (with the same URI) are not allowed.
*
* @param contracts - A record mapping contract keys to their respective ArvoContract objects
* @returns An object with a boolean result indicating if all contracts are unique, and the error keys if not
*/
export declare const areServiceContractsUnique: (contracts: Record<string, ArvoContract | VersionedArvoContract<any, any>>) => {
result: false;
keys: [string, string];
contractUri: string;
} | {
result: true;
};