@astrale-os/sdk 0.5.0-beta.77 → 0.5.0-beta.78
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.0-beta.78](https://github.com/astrale-os/sdk/compare/sdk-v0.5.0-beta.77...sdk-v0.5.0-beta.78) (2026-08-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **mutation:** support atomic transition deltas ([#331](https://github.com/astrale-os/sdk/issues/331)) ([0bf94fa](https://github.com/astrale-os/sdk/commit/0bf94fa8193cdc52047007f25cbf59e79f1f97b4))
|
|
9
|
+
|
|
3
10
|
## [0.5.0-beta.77](https://github.com/astrale-os/sdk/compare/sdk-v0.5.0-beta.76...sdk-v0.5.0-beta.77) (2026-08-29)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -3,7 +3,7 @@ import type { Domain, ResolvedClass } from '../../../platform/schema/index.js';
|
|
|
3
3
|
import type { StatePropertiesOfClass } from '../../../platform/schema/state-property/index.js';
|
|
4
4
|
import type { EventOf, StateMachine, StateOf } from '../../state/machine.js';
|
|
5
5
|
import type { ExistingEndpoint } from './endpoint.js';
|
|
6
|
-
import type { RichPropertyConditions, RichPropertyName } from './properties.js';
|
|
6
|
+
import type { RichPropertyConditions, RichPropertyDelta, RichPropertyName } from './properties.js';
|
|
7
7
|
export type StatePropertyName<Class extends ResolvedClass<'node'>> = Extract<keyof StatePropertiesOfClass<Class>, RichPropertyName<Class>>;
|
|
8
8
|
export type StateMachineOf<Class extends ResolvedClass<'node'>, Property extends StatePropertyName<Class>> = Extract<StatePropertiesOfClass<Class>[Property], StateMachine>;
|
|
9
9
|
export interface StateTransitionInput<Class extends ResolvedClass<'node'>, Property extends StatePropertyName<Class>, Machine extends StateMachineOf<Class, Property>, From extends StateOf<Machine>, Event extends EventOf<Machine, From>> {
|
|
@@ -13,5 +13,7 @@ export interface StateTransitionInput<Class extends ResolvedClass<'node'>, Prope
|
|
|
13
13
|
readonly from: From;
|
|
14
14
|
readonly event: Event;
|
|
15
15
|
readonly props?: RichPropertyConditions<Class>;
|
|
16
|
+
/** Auxiliary property changes committed in the same compare-and-set as the state transition. */
|
|
17
|
+
readonly update?: RichPropertyDelta<Class>;
|
|
16
18
|
}
|
|
17
19
|
export declare function authorStateTransition<Class extends ResolvedClass<'node'>, Property extends StatePropertyName<Class>, Machine extends StateMachineOf<Class, Property>, From extends StateOf<Machine>, Event extends EventOf<Machine, From>>(core: MutationBuilder, domain: Domain, input: StateTransitionInput<Class, Property, Machine, From, Event>): void;
|
|
@@ -10,10 +10,15 @@ export function authorStateTransition(core, domain, input) {
|
|
|
10
10
|
const fromState = input.from;
|
|
11
11
|
const event = input.event;
|
|
12
12
|
const suppliedProps = input.props;
|
|
13
|
+
const suppliedUpdate = input.update;
|
|
13
14
|
const equals = suppliedProps?.equals;
|
|
14
15
|
const absent = suppliedProps?.absent;
|
|
16
|
+
const set = suppliedUpdate?.set;
|
|
17
|
+
const unset = suppliedUpdate?.unset;
|
|
15
18
|
const suppliedEquals = equals === undefined ? undefined : { ...equals };
|
|
16
19
|
const suppliedAbsent = absent === undefined ? undefined : [...absent];
|
|
20
|
+
const suppliedSet = set === undefined ? undefined : { ...set };
|
|
21
|
+
const suppliedUnset = unset === undefined ? undefined : [...unset];
|
|
17
22
|
const selected = resolvedProperty(selectedClass, property);
|
|
18
23
|
const selectedClassKey = ClassKey(selectedClass.key);
|
|
19
24
|
const machine = stateMachineFor(domain, selected);
|
|
@@ -28,7 +33,9 @@ export function authorStateTransition(core, domain, input) {
|
|
|
28
33
|
if ((suppliedEquals !== undefined &&
|
|
29
34
|
Object.hasOwn(suppliedEquals, property) &&
|
|
30
35
|
suppliedEquals[property] !== fromState) ||
|
|
31
|
-
suppliedAbsent?.includes(property) === true
|
|
36
|
+
suppliedAbsent?.includes(property) === true ||
|
|
37
|
+
(suppliedSet !== undefined && Object.hasOwn(suppliedSet, property)) ||
|
|
38
|
+
suppliedUnset?.includes(property) === true) {
|
|
32
39
|
throw new TypeError(`StateMachine transition conditions conflict with property ${String(property)}.`);
|
|
33
40
|
}
|
|
34
41
|
core.expect.node({
|
|
@@ -42,6 +49,9 @@ export function authorStateTransition(core, domain, input) {
|
|
|
42
49
|
core.updateNode({
|
|
43
50
|
node,
|
|
44
51
|
class: selectedClassKey,
|
|
45
|
-
props: delta(selectedClass, {
|
|
52
|
+
props: delta(selectedClass, {
|
|
53
|
+
set: { ...suppliedSet, ...to },
|
|
54
|
+
...(suppliedUnset === undefined ? {} : { unset: suppliedUnset }),
|
|
55
|
+
}),
|
|
46
56
|
});
|
|
47
57
|
}
|