@almadar/std 16.21.3 → 16.21.4

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.
@@ -0,0 +1,306 @@
1
+ {
2
+ "name": "std-status-lifecycle",
3
+ "version": "0.1.0",
4
+ "description": "Infra substrate: data-driven entity status lifecycle. The statuses and the allowed transitions are config data over a fixed single-state topology, so a host organism can expand or collapse its lifecycle without forking. Compose onto an entity, rename the ChangeStatusRequested listen to the host's status-change action, and supply `states` + `transitions`. A requested move is validated against the `transitions` table (illegal moves are rejected), then the new value is written to `statusField` on the target entity and StatusChanged is emitted. Surfaces nothing — the host renders the badge and buttons.",
5
+ "orbitals": [
6
+ {
7
+ "name": "StatusLifecycleOrbital",
8
+ "entity": {
9
+ "name": "StatusRecord",
10
+ "collection": "status_records",
11
+ "persistence": "persistent",
12
+ "fields": [
13
+ {
14
+ "name": "id",
15
+ "type": "string",
16
+ "required": true
17
+ },
18
+ {
19
+ "name": "status",
20
+ "type": "string",
21
+ "default": "",
22
+ "description": "Current lifecycle status of the record.",
23
+ "synonyms": "state, stage, phase"
24
+ }
25
+ ]
26
+ },
27
+ "traits": [
28
+ {
29
+ "name": "StatusMachine",
30
+ "entityRebindable": true,
31
+ "entityContract": {
32
+ "requires": [],
33
+ "provides": []
34
+ },
35
+ "category": "lifecycle",
36
+ "linkedEntity": "StatusRecord",
37
+ "emits": [
38
+ {
39
+ "event": "StatusChanged",
40
+ "scope": "external",
41
+ "payloadSchema": [
42
+ {
43
+ "name": "entityId",
44
+ "type": "string"
45
+ },
46
+ {
47
+ "name": "status",
48
+ "type": "string"
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "event": "StatusChangeFailed",
54
+ "payloadSchema": [
55
+ {
56
+ "name": "error",
57
+ "type": "string"
58
+ },
59
+ {
60
+ "name": "code",
61
+ "type": "string"
62
+ }
63
+ ]
64
+ }
65
+ ],
66
+ "stateMachine": {
67
+ "states": [
68
+ {
69
+ "name": "idle",
70
+ "isInitial": true
71
+ }
72
+ ],
73
+ "events": [
74
+ {
75
+ "key": "ChangeStatusRequested",
76
+ "name": "Change status requested",
77
+ "payloadSchema": [
78
+ {
79
+ "name": "id",
80
+ "type": "string"
81
+ },
82
+ {
83
+ "name": "from",
84
+ "type": "string"
85
+ },
86
+ {
87
+ "name": "to",
88
+ "type": "string"
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "key": "StatusChangeFailed",
94
+ "name": "Status change failed",
95
+ "payloadSchema": [
96
+ {
97
+ "name": "error",
98
+ "type": "string"
99
+ },
100
+ {
101
+ "name": "code",
102
+ "type": "string"
103
+ }
104
+ ]
105
+ },
106
+ {
107
+ "key": "StatusChanged",
108
+ "name": "Status changed",
109
+ "payloadSchema": [
110
+ {
111
+ "name": "entityId",
112
+ "type": "string"
113
+ },
114
+ {
115
+ "name": "status",
116
+ "type": "string"
117
+ }
118
+ ]
119
+ }
120
+ ],
121
+ "transitions": [
122
+ {
123
+ "from": "idle",
124
+ "to": "idle",
125
+ "event": "ChangeStatusRequested",
126
+ "guard": [
127
+ "and",
128
+ "@config.enabled",
129
+ [
130
+ "array/some",
131
+ "@config.transitions",
132
+ [
133
+ "fn",
134
+ "t",
135
+ [
136
+ "and",
137
+ [
138
+ "=",
139
+ [
140
+ "object/get",
141
+ "@t",
142
+ "from"
143
+ ],
144
+ "@payload.from"
145
+ ],
146
+ [
147
+ "=",
148
+ [
149
+ "object/get",
150
+ "@t",
151
+ "to"
152
+ ],
153
+ "@payload.to"
154
+ ]
155
+ ]
156
+ ]
157
+ ]
158
+ ],
159
+ "effects": [
160
+ [
161
+ "persist",
162
+ "update",
163
+ "@config.targetEntity",
164
+ [
165
+ "object/set",
166
+ {
167
+ "id": "@payload.id"
168
+ },
169
+ "@config.statusField",
170
+ "@payload.to"
171
+ ],
172
+ {
173
+ "emit": {
174
+ "failure": "StatusChangeFailed",
175
+ "success": "StatusChanged"
176
+ }
177
+ }
178
+ ],
179
+ [
180
+ "emit",
181
+ "StatusChanged",
182
+ {
183
+ "status": "@payload.to",
184
+ "entityId": "@payload.id"
185
+ }
186
+ ]
187
+ ]
188
+ },
189
+ {
190
+ "from": "idle",
191
+ "to": "idle",
192
+ "event": "StatusChangeFailed"
193
+ }
194
+ ]
195
+ },
196
+ "config": {
197
+ "enabled": {
198
+ "type": "boolean",
199
+ "default": false,
200
+ "label": "Enforce status lifecycle",
201
+ "description": "Validate and apply status transitions against the configured table. Off by default.",
202
+ "synonyms": "lifecycle, statuses, states, stages, workflow, status transitions, enforce, enable, apply",
203
+ "tier": "infra"
204
+ },
205
+ "statusField": {
206
+ "type": "string",
207
+ "default": "status",
208
+ "label": "Status field",
209
+ "description": "Which entity field this lifecycle drives. Defaults to 'status'; set it to bind any field (e.g. 'state', 'stage', 'phase').",
210
+ "synonyms": "state field, stage field, status column, lifecycle field",
211
+ "tier": "domain"
212
+ },
213
+ "transitions": {
214
+ "type": "[TransitionSpec]",
215
+ "default": [
216
+ {
217
+ "to": "active",
218
+ "from": "draft",
219
+ "event": "ACTIVATE",
220
+ "label": "Activate"
221
+ },
222
+ {
223
+ "from": "active",
224
+ "label": "Archive",
225
+ "event": "ARCHIVE",
226
+ "to": "archived"
227
+ }
228
+ ],
229
+ "label": "Allowed transitions",
230
+ "description": "The legal moves: each row is { from, to, event, label }. A requested move is applied only if it matches a row.",
231
+ "synonyms": "edges, allowed moves, status flow, workflow transitions",
232
+ "tier": "domain",
233
+ "items": {
234
+ "type": "object",
235
+ "properties": {
236
+ "event": {
237
+ "name": "event",
238
+ "type": "string",
239
+ "required": false
240
+ },
241
+ "label": {
242
+ "name": "label",
243
+ "type": "string",
244
+ "required": false
245
+ },
246
+ "to": {
247
+ "name": "to",
248
+ "type": "string",
249
+ "required": true
250
+ },
251
+ "from": {
252
+ "name": "from",
253
+ "type": "string",
254
+ "required": true
255
+ }
256
+ }
257
+ }
258
+ },
259
+ "states": {
260
+ "type": "[string]",
261
+ "default": [
262
+ "draft",
263
+ "active",
264
+ "archived"
265
+ ],
266
+ "label": "Statuses",
267
+ "description": "The closed set of statuses a record can hold.",
268
+ "synonyms": "states, stages, phases, statuses, lifecycle, workflow steps",
269
+ "tier": "domain",
270
+ "items": {
271
+ "type": "string"
272
+ }
273
+ },
274
+ "targetEntity": {
275
+ "type": "string",
276
+ "default": "StatusRecord",
277
+ "label": "Target entity",
278
+ "description": "Entity name whose status field this lifecycle drives (e.g. 'Contract'). Defaults to the atom's own record so the standalone validates; rebind per composition.",
279
+ "tier": "internal"
280
+ },
281
+ "initialStatus": {
282
+ "type": "string",
283
+ "default": "draft",
284
+ "label": "Initial status",
285
+ "description": "The status a new record starts in.",
286
+ "synonyms": "starting state, default status, first stage",
287
+ "tier": "domain"
288
+ }
289
+ },
290
+ "scope": "instance"
291
+ }
292
+ ],
293
+ "pages": [
294
+ {
295
+ "name": "StatusLifecyclePage",
296
+ "path": "/status-lifecycle",
297
+ "traits": [
298
+ {
299
+ "ref": "StatusMachine"
300
+ }
301
+ ]
302
+ }
303
+ ]
304
+ }
305
+ ]
306
+ }