@statebacked/machine-def - State Backed machine definition types and utilities

GitHub license npm version CI Docs

The types and utilities exported by this package are useful in defining State Backed machine definitions.

Installation

NPM

npm install --save @statebacked/machine-def

Yarn

yarn add @statebacked/machine-def

Deno

import type { AllowRead, AllowWrite } from "https://deno.land/x/statebacked_machine_def/mod.ts";

Overview

A State Backed machine definition consists of a javascript file that exports the following:

  • Default export an XState state machine (e.g. export default createMachine(...))
  • Export an allowRead function that accepts an object containing { machineInstanceName, state, context, authContext } and returns a boolean indicating whether an entity with the provided authContext should be allowed to read an instance of the machine having the provided name, state, and context.
  • Export an allowWrite function that accepts an object containing { machineInstanceName, state, context, event, authContext } and returns a boolean indicating whether an entity with the provided authContext should be allowed to write event to an instance of the machine having the provided name, state, and context.

This module provides types and utilities for these functions.

State Backed

State Backed allows you to spin up a backend by writing only an XState state machine.

Check out our docs and get started with the smply CLI. You can have a state machine backend running in 5 minutes.

License

@statebacked/machine-def is MIT licensed.