/** * Mailbox - https://github.com/huan/mailbox * * @copyright 2024 Huan LI (李卓桓) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type { AnyActorLogic } from 'xstate'; /** * Validation error with detailed message */ export declare class MailboxValidationError extends Error { constructor(message: string); } /** * Validate that a machine satisfies the Mailbox address protocol. * * A valid mailbox-addressable machine MUST: * 1. Send `ACTOR_IDLE` event to parent immediately after initialization * 2. Return to an idle state (with idle action) after processing events * * @param machine - The XState machine to validate * @returns true if valid * @throws MailboxValidationError if validation fails * * @example * ```typescript * import * as Mailbox from 'mailbox' * * const myMachine = createMachine({ * id: 'my-machine', * initial: 'idle', * states: { * idle: { * entry: Mailbox.actions.idle('my-machine'), * on: { WORK: 'working' }, * }, * working: { * always: 'idle', * }, * }, * }) * * // Throws if machine doesn't satisfy protocol * Mailbox.validate(myMachine) * ``` */ export declare function validate(machine: AnyActorLogic): boolean; //# sourceMappingURL=validate.d.ts.map