@strav/machine 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # @stravigor/machine
1
+ # @strav/machine
2
2
 
3
- State machine for the [Strav](https://www.npmjs.com/package/@stravigor/core) framework. Declarative state definitions with transitions, guards, side effects, and event emission.
3
+ State machine for the [Strav](https://www.npmjs.com/package/@strav/core) framework. Declarative state definitions with transitions, guards, side effects, and event emission.
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- bun add @stravigor/machine
8
+ bun add @strav/machine
9
9
  ```
10
10
 
11
- Requires `@stravigor/core` as a peer dependency.
11
+ Requires `@strav/core` as a peer dependency.
12
12
 
13
13
  ## Usage
14
14
 
15
15
  ### Define a Machine
16
16
 
17
17
  ```ts
18
- import { defineMachine } from '@stravigor/machine'
18
+ import { defineMachine } from '@strav/machine'
19
19
 
20
20
  const orderMachine = defineMachine({
21
21
  field: 'status',
@@ -61,8 +61,8 @@ await orderMachine.apply(order, 'process')
61
61
  ### ORM Mixin
62
62
 
63
63
  ```ts
64
- import { BaseModel } from '@stravigor/core/orm'
65
- import { stateful } from '@stravigor/machine'
64
+ import { BaseModel } from '@strav/core/orm'
65
+ import { stateful } from '@strav/machine'
66
66
 
67
67
  class Order extends stateful(BaseModel, orderMachine) {
68
68
  declare id: number
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strav/machine",
3
- "version": "0.1.0",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "description": "State machine for the Strav framework",
6
6
  "license": "MIT",
@@ -14,8 +14,8 @@
14
14
  "tsconfig.json"
15
15
  ],
16
16
  "peerDependencies": {
17
- "@strav/kernel": "0.1.0",
18
- "@strav/database": "0.1.0"
17
+ "@strav/kernel": "0.1.4",
18
+ "@strav/database": "0.1.4"
19
19
  },
20
20
  "scripts": {
21
21
  "test": "bun test tests/",
package/src/errors.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StravError } from '@stravigor/kernel'
1
+ import { StravError } from '@strav/kernel'
2
2
 
3
3
  /** Thrown when a transition is not valid from the entity's current state. */
4
4
  export class TransitionError extends StravError {
package/src/machine.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Emitter } from '@stravigor/kernel'
1
+ import { Emitter } from '@strav/kernel'
2
2
  import type { MachineDefinition, Machine, TransitionMeta } from './types.ts'
3
3
  import { TransitionError, GuardError } from './errors.ts'
4
4
 
package/src/stateful.ts CHANGED
@@ -1,13 +1,13 @@
1
- import type { BaseModel } from '@stravigor/database'
2
- import type { NormalizeConstructor } from '@stravigor/kernel'
1
+ import type { BaseModel } from '@strav/database'
2
+ import type { NormalizeConstructor } from '@strav/kernel'
3
3
  import type { Machine, TransitionMeta } from './types.ts'
4
4
 
5
5
  /**
6
6
  * Mixin that adds state machine methods to a BaseModel subclass.
7
7
  *
8
8
  * @example
9
- * import { BaseModel } from '@stravigor/database'
10
- * import { defineMachine, stateful } from '@stravigor/machine'
9
+ * import { BaseModel } from '@strav/database'
10
+ * import { defineMachine, stateful } from '@strav/machine'
11
11
  *
12
12
  * const orderMachine = defineMachine({
13
13
  * field: 'status',
@@ -30,7 +30,7 @@ import type { Machine, TransitionMeta } from './types.ts'
30
30
  * await order.transition('process') // validates, mutates, saves, emits
31
31
  *
32
32
  * // Composable with other mixins:
33
- * import { compose } from '@stravigor/kernel'
33
+ * import { compose } from '@strav/kernel'
34
34
  * class Order extends compose(BaseModel, searchable, m => stateful(m, orderMachine)) { }
35
35
  */
36
36
  export function stateful<T extends NormalizeConstructor<typeof BaseModel>>(