@almadar/std 7.4.1 → 7.4.3

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.
Files changed (32) hide show
  1. package/behaviors/registry/atoms/std-modal.orb +15 -9
  2. package/behaviors/registry/atoms/std-wizard.orb +306 -293
  3. package/behaviors/registry/molecules/std-detail.orb +513 -292
  4. package/behaviors/registry/molecules/std-geospatial.orb +543 -406
  5. package/behaviors/registry/molecules/std-inventory.orb +489 -445
  6. package/behaviors/registry/molecules/std-list.orb +492 -616
  7. package/behaviors/registry/molecules/std-messaging.orb +511 -327
  8. package/behaviors/registry/molecules/std-wizard-form.orb +2 -101
  9. package/dist/behaviors/behaviors-registry.json +1976 -719
  10. package/dist/behaviors/exports-reader.js +71 -11
  11. package/dist/behaviors/exports-reader.js.map +1 -1
  12. package/dist/behaviors/functions/index.d.ts +11 -3
  13. package/dist/behaviors/functions/index.js +67 -11
  14. package/dist/behaviors/functions/index.js.map +1 -1
  15. package/dist/behaviors/index.d.ts +1 -1
  16. package/dist/behaviors/index.js +72 -12
  17. package/dist/behaviors/index.js.map +1 -1
  18. package/dist/behaviors/query.js +71 -11
  19. package/dist/behaviors/query.js.map +1 -1
  20. package/dist/behaviors/registry/atoms/std-modal.orb +15 -9
  21. package/dist/behaviors/registry/atoms/std-wizard.orb +306 -293
  22. package/dist/behaviors/registry/molecules/std-detail.orb +513 -292
  23. package/dist/behaviors/registry/molecules/std-geospatial.orb +543 -406
  24. package/dist/behaviors/registry/molecules/std-inventory.orb +489 -445
  25. package/dist/behaviors/registry/molecules/std-list.orb +492 -616
  26. package/dist/behaviors/registry/molecules/std-messaging.orb +511 -327
  27. package/dist/behaviors/registry/molecules/std-wizard-form.orb +2 -101
  28. package/dist/behaviors-registry.json +1976 -719
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +72 -12
  31. package/dist/index.js.map +1 -1
  32. package/package.json +1 -1
@@ -6,10 +6,6 @@
6
6
  {
7
7
  "name": "InventoryItemOrbital",
8
8
  "uses": [
9
- {
10
- "from": "std/behaviors/std-browse",
11
- "as": "Browse"
12
- },
13
9
  {
14
10
  "from": "std/behaviors/std-confirmation",
15
11
  "as": "Confirmation"
@@ -26,11 +22,13 @@
26
22
  "fields": [
27
23
  {
28
24
  "name": "id",
29
- "type": "string"
25
+ "type": "string",
26
+ "required": true
30
27
  },
31
28
  {
32
29
  "name": "name",
33
- "type": "string"
30
+ "type": "string",
31
+ "required": true
34
32
  },
35
33
  {
36
34
  "name": "description",
@@ -59,16 +57,44 @@
59
57
  },
60
58
  "traits": [
61
59
  {
62
- "ref": "Browse.traits.BrowseItemBrowse",
63
60
  "name": "InventoryItemBrowse",
61
+ "category": "interaction",
64
62
  "linkedEntity": "InventoryItem",
63
+ "emits": [
64
+ {
65
+ "event": "InventoryItemLoaded",
66
+ "description": "Fired when the InventoryItem collection finishes loading; payload.data holds the list",
67
+ "scope": "internal",
68
+ "payload": [
69
+ {
70
+ "name": "data",
71
+ "type": "[InventoryItem]"
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "event": "InventoryItemLoadFailed",
77
+ "description": "Fired when the InventoryItem collection fails to load",
78
+ "scope": "internal",
79
+ "payload": [
80
+ {
81
+ "name": "error",
82
+ "type": "string"
83
+ },
84
+ {
85
+ "name": "code",
86
+ "type": "string"
87
+ }
88
+ ]
89
+ }
90
+ ],
65
91
  "listens": [
66
92
  {
67
93
  "event": "ITEM_ADDED",
68
94
  "triggers": "INIT",
69
95
  "source": {
70
96
  "kind": "trait",
71
- "trait": "InventoryItemAdd"
97
+ "trait": "InventoryItemPersistor"
72
98
  }
73
99
  },
74
100
  {
@@ -76,513 +102,528 @@
76
102
  "triggers": "INIT",
77
103
  "source": {
78
104
  "kind": "trait",
79
- "trait": "InventoryItemUse"
105
+ "trait": "InventoryItemPersistor"
80
106
  }
81
107
  },
82
108
  {
83
- "event": "CONFIRM_DROP",
109
+ "event": "ITEM_DROPPED",
84
110
  "triggers": "INIT",
85
111
  "source": {
86
112
  "kind": "trait",
87
- "trait": "InventoryItemDrop"
113
+ "trait": "InventoryItemPersistor"
88
114
  }
89
115
  }
90
116
  ],
91
- "effects": {
92
- "INIT": [
93
- [
94
- "ref",
95
- "InventoryItem"
96
- ],
97
- [
98
- "render-ui",
99
- "main",
100
- {
101
- "className": "max-w-5xl mx-auto w-full",
102
- "direction": "vertical",
103
- "type": "stack",
104
- "children": [
117
+ "stateMachine": {
118
+ "states": [
119
+ {
120
+ "name": "loading",
121
+ "isInitial": true
122
+ },
123
+ {
124
+ "name": "browsing"
125
+ },
126
+ {
127
+ "name": "error"
128
+ }
129
+ ],
130
+ "events": [
131
+ {
132
+ "key": "INIT",
133
+ "name": "Initialize"
134
+ },
135
+ {
136
+ "key": "InventoryItemLoaded",
137
+ "name": "InventoryItem loaded",
138
+ "payload": [
139
+ {
140
+ "name": "data",
141
+ "type": "[InventoryItem]"
142
+ }
143
+ ]
144
+ },
145
+ {
146
+ "key": "InventoryItemLoadFailed",
147
+ "name": "InventoryItem load failed",
148
+ "payload": [
149
+ {
150
+ "name": "error",
151
+ "type": "string"
152
+ },
153
+ {
154
+ "name": "code",
155
+ "type": "string"
156
+ }
157
+ ]
158
+ }
159
+ ],
160
+ "transitions": [
161
+ {
162
+ "from": "loading",
163
+ "to": "loading",
164
+ "event": "INIT",
165
+ "effects": [
166
+ [
167
+ "fetch",
168
+ "InventoryItem",
169
+ {
170
+ "emit": {
171
+ "success": "InventoryItemLoaded",
172
+ "failure": "InventoryItemLoadFailed"
173
+ }
174
+ }
175
+ ],
176
+ [
177
+ "render-ui",
178
+ "main",
105
179
  {
106
- "justify": "space-between",
107
180
  "type": "stack",
108
- "direction": "horizontal",
181
+ "gap": "md",
182
+ "className": "py-12",
183
+ "direction": "vertical",
109
184
  "align": "center",
110
185
  "children": [
111
186
  {
112
- "align": "center",
113
- "type": "stack",
187
+ "size": "lg",
188
+ "type": "spinner"
189
+ },
190
+ {
191
+ "variant": "caption",
192
+ "type": "typography",
193
+ "color": "muted",
194
+ "content": "Loading inventory…"
195
+ }
196
+ ]
197
+ }
198
+ ]
199
+ ]
200
+ },
201
+ {
202
+ "from": "loading",
203
+ "to": "browsing",
204
+ "event": "InventoryItemLoaded",
205
+ "effects": [
206
+ [
207
+ "render-ui",
208
+ "main",
209
+ {
210
+ "className": "max-w-5xl mx-auto w-full",
211
+ "children": [
212
+ {
114
213
  "children": [
115
214
  {
116
- "name": "package",
117
- "size": "lg",
118
- "type": "icon"
215
+ "direction": "horizontal",
216
+ "children": [
217
+ {
218
+ "type": "icon",
219
+ "name": "package",
220
+ "size": "lg"
221
+ },
222
+ {
223
+ "content": "Inventory",
224
+ "type": "typography",
225
+ "variant": "h2"
226
+ }
227
+ ],
228
+ "type": "stack",
229
+ "gap": "md"
119
230
  },
120
231
  {
121
- "content": "InventoryItems Inventory",
122
- "type": "typography",
123
- "variant": "h2"
232
+ "label": "Add Item",
233
+ "variant": "primary",
234
+ "type": "button",
235
+ "action": "ADD_ITEM",
236
+ "icon": "plus"
124
237
  }
125
238
  ],
126
- "direction": "horizontal",
127
- "gap": "sm"
239
+ "justify": "between",
240
+ "gap": "md",
241
+ "type": "stack",
242
+ "direction": "horizontal"
128
243
  },
129
244
  {
130
- "type": "stack",
131
- "children": [
245
+ "type": "divider"
246
+ },
247
+ {
248
+ "itemActions": [
132
249
  {
133
- "icon": "plus",
134
- "label": "Add InventoryItem",
135
- "type": "button",
136
- "event": "ADD_ITEM",
137
- "variant": "primary"
250
+ "variant": "ghost",
251
+ "label": "Use",
252
+ "event": "USE_ITEM"
253
+ },
254
+ {
255
+ "variant": "danger",
256
+ "label": "Drop",
257
+ "event": "DROP"
138
258
  }
139
259
  ],
140
- "gap": "sm",
141
- "direction": "horizontal"
260
+ "fields": [
261
+ {
262
+ "name": "name",
263
+ "variant": "h4",
264
+ "icon": "package",
265
+ "label": "Name"
266
+ },
267
+ {
268
+ "name": "description",
269
+ "variant": "caption",
270
+ "label": "Description"
271
+ },
272
+ {
273
+ "label": "Status",
274
+ "variant": "badge",
275
+ "name": "status"
276
+ }
277
+ ],
278
+ "entity": "@payload.data",
279
+ "type": "data-grid"
142
280
  }
143
281
  ],
144
- "gap": "md"
145
- },
146
- {
147
- "type": "divider"
148
- },
282
+ "direction": "vertical",
283
+ "type": "stack",
284
+ "gap": "lg"
285
+ }
286
+ ]
287
+ ]
288
+ },
289
+ {
290
+ "from": "loading",
291
+ "to": "error",
292
+ "event": "InventoryItemLoadFailed",
293
+ "effects": [
294
+ [
295
+ "render-ui",
296
+ "main",
149
297
  {
150
- "emptyDescription": "Add your first item to get started.",
151
- "entity": "InventoryItem",
152
- "emptyIcon": "inbox",
153
- "type": "data-grid",
154
- "emptyTitle": "No items yet",
155
- "itemActions": [
298
+ "type": "stack",
299
+ "direction": "vertical",
300
+ "className": "py-12",
301
+ "children": [
156
302
  {
157
- "event": "USE_ITEM",
158
- "variant": "ghost",
159
- "size": "sm",
160
- "label": "Use"
303
+ "size": "xl",
304
+ "name": "alert-triangle",
305
+ "type": "icon",
306
+ "color": "destructive"
161
307
  },
162
308
  {
163
- "label": "Drop",
164
- "event": "DROP",
165
- "variant": "danger",
166
- "size": "sm"
167
- }
168
- ],
169
- "columns": [
170
- {
171
- "icon": "package",
172
- "variant": "h4",
173
- "label": "Name",
174
- "name": "name"
309
+ "type": "typography",
310
+ "content": "Failed to load inventory",
311
+ "variant": "h3"
175
312
  },
176
313
  {
177
- "name": "description",
178
- "colorMap": {
179
- "draft": "warning",
180
- "archived": "neutral",
181
- "disabled": "neutral",
182
- "active": "success",
183
- "failed": "destructive",
184
- "cancelled": "destructive",
185
- "completed": "success",
186
- "pending": "warning",
187
- "scheduled": "warning",
188
- "inactive": "neutral",
189
- "done": "success",
190
- "error": "destructive"
191
- },
192
- "variant": "badge",
193
- "label": "Description"
314
+ "color": "muted",
315
+ "type": "typography",
316
+ "variant": "body",
317
+ "content": "@payload.error"
194
318
  },
195
319
  {
196
- "label": "Status",
197
- "name": "status",
198
- "variant": "caption"
320
+ "variant": "primary",
321
+ "label": "Retry",
322
+ "action": "INIT",
323
+ "type": "button",
324
+ "icon": "rotate-ccw"
199
325
  }
200
- ]
326
+ ],
327
+ "gap": "md",
328
+ "align": "center"
329
+ }
330
+ ]
331
+ ]
332
+ },
333
+ {
334
+ "from": "browsing",
335
+ "to": "loading",
336
+ "event": "INIT",
337
+ "effects": [
338
+ [
339
+ "fetch",
340
+ "InventoryItem",
341
+ {
342
+ "emit": {
343
+ "failure": "InventoryItemLoadFailed",
344
+ "success": "InventoryItemLoaded"
345
+ }
201
346
  }
202
347
  ],
203
- "gap": "lg"
204
- }
205
- ]
348
+ [
349
+ "render-ui",
350
+ "main",
351
+ {
352
+ "size": "lg",
353
+ "type": "spinner"
354
+ }
355
+ ]
356
+ ]
357
+ },
358
+ {
359
+ "from": "error",
360
+ "to": "loading",
361
+ "event": "INIT",
362
+ "effects": [
363
+ [
364
+ "fetch",
365
+ "InventoryItem",
366
+ {
367
+ "emit": {
368
+ "success": "InventoryItemLoaded",
369
+ "failure": "InventoryItemLoadFailed"
370
+ }
371
+ }
372
+ ],
373
+ [
374
+ "render-ui",
375
+ "main",
376
+ {
377
+ "type": "spinner",
378
+ "size": "lg"
379
+ }
380
+ ]
381
+ ]
382
+ }
206
383
  ]
207
- }
384
+ },
385
+ "scope": "collection"
208
386
  },
209
387
  {
210
388
  "ref": "Modal.traits.ModalRecordModal",
211
389
  "name": "InventoryItemAdd",
212
390
  "linkedEntity": "InventoryItem",
213
- "events": {
214
- "SAVE": "ITEM_ADDED",
215
- "OPEN": "ADD_ITEM"
216
- },
217
- "effects": {
218
- "ADD_ITEM": [
219
- [
220
- "fetch",
221
- "InventoryItem"
222
- ],
223
- [
224
- "render-ui",
225
- "modal",
226
- {
227
- "children": [
228
- {
229
- "direction": "horizontal",
230
- "type": "stack",
231
- "gap": "sm",
232
- "children": [
233
- {
234
- "name": "plus-circle",
235
- "size": "md",
236
- "type": "icon"
237
- },
238
- {
239
- "content": "Add InventoryItem",
240
- "type": "typography",
241
- "variant": "h3"
242
- }
243
- ]
244
- },
245
- {
246
- "type": "divider"
247
- },
248
- {
249
- "mode": "create",
250
- "entity": "InventoryItem",
251
- "submitEvent": "SAVE",
252
- "cancelEvent": "CLOSE",
253
- "type": "form-section",
254
- "fields": [
255
- "name",
256
- "description",
257
- "status"
258
- ]
259
- }
260
- ],
261
- "type": "stack",
262
- "gap": "md",
263
- "direction": "vertical"
264
- }
265
- ]
266
- ],
267
- "ITEM_ADDED": [
268
- [
269
- "persist",
270
- "create",
271
- "InventoryItem",
272
- "@payload.data"
273
- ],
274
- [
275
- "render-ui",
276
- "modal",
277
- null
278
- ],
279
- [
280
- "render-ui",
281
- "main",
282
- {
283
- "type": "box"
284
- }
285
- ]
286
- ],
287
- "CLOSE": [
288
- [
289
- "render-ui",
290
- "modal",
291
- null
292
- ],
293
- [
294
- "render-ui",
295
- "main",
296
- {
297
- "type": "box"
298
- }
299
- ],
300
- [
301
- "notify",
302
- "Cancelled",
303
- "info"
304
- ]
305
- ],
306
- "INIT": [
307
- [
308
- "ref",
309
- "InventoryItem"
310
- ]
391
+ "config": {
392
+ "mode": "create",
393
+ "title": "Add Item",
394
+ "icon": "plus-circle",
395
+ "fields": [
396
+ "name",
397
+ "description",
398
+ "status"
311
399
  ]
400
+ },
401
+ "events": {
402
+ "OPEN": "ADD_ITEM",
403
+ "SAVE": "ITEM_ADDED"
312
404
  }
313
405
  },
314
406
  {
315
- "ref": "Modal.traits.ModalRecordModal",
407
+ "ref": "Confirmation.traits.ConfirmActionConfirmation",
316
408
  "name": "InventoryItemUse",
317
409
  "linkedEntity": "InventoryItem",
318
- "events": {
319
- "SAVE": "ITEM_USED",
320
- "OPEN": "USE_ITEM"
410
+ "config": {
411
+ "alertMessage": "Consume this item?",
412
+ "icon": "zap",
413
+ "title": "Use Item",
414
+ "confirmLabel": "Confirm Use"
321
415
  },
322
- "effects": {
323
- "CLOSE": [
324
- [
325
- "render-ui",
326
- "modal",
327
- null
328
- ],
329
- [
330
- "render-ui",
331
- "main",
332
- {
333
- "type": "box"
334
- }
335
- ],
336
- [
337
- "notify",
338
- "Cancelled",
339
- "info"
340
- ]
341
- ],
342
- "ITEM_USED": [
343
- [
344
- "persist",
345
- "update",
346
- "InventoryItem",
347
- "@payload.data"
348
- ],
349
- [
350
- "render-ui",
351
- "modal",
352
- null
353
- ],
354
- [
355
- "render-ui",
356
- "main",
357
- {
358
- "type": "box"
359
- }
360
- ]
361
- ],
362
- "INIT": [
363
- [
364
- "ref",
365
- "InventoryItem"
366
- ]
367
- ],
368
- "USE_ITEM": [
369
- [
370
- "fetch",
371
- "InventoryItem",
372
- {
373
- "id": "@payload.id"
374
- }
375
- ],
376
- [
377
- "render-ui",
378
- "modal",
379
- {
380
- "gap": "md",
381
- "align": "center",
382
- "children": [
383
- {
384
- "children": [
385
- {
386
- "name": "zap",
387
- "size": "md",
388
- "type": "icon"
389
- },
390
- {
391
- "type": "typography",
392
- "variant": "h3",
393
- "content": "Use InventoryItem"
394
- }
395
- ],
396
- "direction": "horizontal",
397
- "gap": "sm",
398
- "type": "stack",
399
- "align": "center"
400
- },
401
- {
402
- "type": "divider"
403
- },
404
- {
405
- "type": "typography",
406
- "variant": "body",
407
- "content": "@entity.name"
408
- },
409
- {
410
- "type": "stack",
411
- "children": [
412
- {
413
- "label": "Cancel",
414
- "event": "CLOSE",
415
- "variant": "ghost",
416
- "type": "button"
417
- },
418
- {
419
- "event": "ITEM_USED",
420
- "variant": "primary",
421
- "label": "Confirm Use",
422
- "icon": "check",
423
- "type": "button"
424
- }
425
- ],
426
- "direction": "horizontal",
427
- "gap": "sm",
428
- "justify": "center"
429
- }
430
- ],
431
- "type": "stack",
432
- "direction": "vertical"
433
- }
434
- ]
435
- ]
416
+ "events": {
417
+ "CONFIRM": "ITEM_USED",
418
+ "REQUEST": "USE_ITEM"
436
419
  }
437
420
  },
438
421
  {
439
422
  "ref": "Confirmation.traits.ConfirmActionConfirmation",
440
423
  "name": "InventoryItemDrop",
441
424
  "linkedEntity": "InventoryItem",
425
+ "config": {
426
+ "alertMessage": "Are you sure you want to drop this item? This action cannot be undone.",
427
+ "icon": "alert-triangle",
428
+ "title": "Drop Item",
429
+ "confirmLabel": "Drop"
430
+ },
442
431
  "events": {
443
432
  "REQUEST": "DROP",
444
- "CONFIRM": "CONFIRM_DROP"
445
- },
446
- "effects": {
447
- "INIT": [
448
- [
449
- "ref",
450
- "InventoryItem"
451
- ]
452
- ],
453
- "DROP": [
454
- [
455
- "set",
456
- "@entity.pendingId",
457
- "@payload.id"
458
- ],
459
- [
460
- "fetch",
461
- "InventoryItem",
462
- {
463
- "id": "@payload.id"
464
- }
465
- ],
466
- [
467
- "render-ui",
468
- "modal",
433
+ "CONFIRM": "ITEM_DROPPED"
434
+ }
435
+ },
436
+ {
437
+ "name": "InventoryItemPersistor",
438
+ "category": "lifecycle",
439
+ "linkedEntity": "InventoryItem",
440
+ "emits": [
441
+ {
442
+ "event": "ITEM_ADDED",
443
+ "scope": "external",
444
+ "payload": [
469
445
  {
470
- "gap": "md",
471
- "type": "stack",
472
- "children": [
473
- {
474
- "gap": "sm",
475
- "type": "stack",
476
- "direction": "horizontal",
477
- "children": [
478
- {
479
- "size": "md",
480
- "type": "icon",
481
- "name": "alert-triangle"
482
- },
483
- {
484
- "content": "Drop InventoryItem",
485
- "type": "typography",
486
- "variant": "h3"
487
- }
488
- ],
489
- "align": "center"
490
- },
491
- {
492
- "type": "divider"
493
- },
494
- {
495
- "variant": "danger",
496
- "message": "Are you sure you want to drop this inventoryitem?",
497
- "type": "alert"
498
- },
499
- {
500
- "type": "stack",
501
- "direction": "horizontal",
502
- "gap": "sm",
503
- "children": [
504
- {
505
- "type": "button",
506
- "label": "Cancel",
507
- "event": "CANCEL",
508
- "variant": "ghost"
509
- },
510
- {
511
- "label": "Drop",
512
- "variant": "danger",
513
- "type": "button",
514
- "icon": "check",
515
- "event": "CONFIRM_DROP"
516
- }
517
- ],
518
- "justify": "end"
519
- }
520
- ],
521
- "direction": "vertical"
446
+ "name": "id",
447
+ "type": "string",
448
+ "required": true
522
449
  }
523
450
  ]
524
- ],
525
- "CANCEL": [
526
- [
527
- "render-ui",
528
- "modal",
529
- null
530
- ],
531
- [
532
- "render-ui",
533
- "main",
451
+ },
452
+ {
453
+ "event": "ITEM_USED",
454
+ "scope": "external",
455
+ "payload": [
534
456
  {
535
- "type": "box"
457
+ "name": "id",
458
+ "type": "string",
459
+ "required": true
536
460
  }
537
- ],
538
- [
539
- "ref",
540
- "InventoryItem"
541
461
  ]
542
- ],
543
- "CONFIRM_DROP": [
544
- [
545
- "persist",
546
- "delete",
547
- "InventoryItem",
548
- "@entity.pendingId"
549
- ],
550
- [
551
- "render-ui",
552
- "modal",
553
- null
554
- ],
555
- [
556
- "render-ui",
557
- "main",
462
+ },
463
+ {
464
+ "event": "ITEM_DROPPED",
465
+ "scope": "external",
466
+ "payload": [
558
467
  {
559
- "type": "box"
468
+ "name": "id",
469
+ "type": "string",
470
+ "required": true
560
471
  }
561
- ],
562
- [
563
- "ref",
564
- "InventoryItem"
565
472
  ]
473
+ }
474
+ ],
475
+ "listens": [
476
+ {
477
+ "event": "ITEM_ADDED",
478
+ "triggers": "DO_ADD",
479
+ "source": {
480
+ "kind": "trait",
481
+ "trait": "InventoryItemAdd"
482
+ }
483
+ },
484
+ {
485
+ "event": "ITEM_USED",
486
+ "triggers": "DO_USE",
487
+ "source": {
488
+ "kind": "trait",
489
+ "trait": "InventoryItemUse"
490
+ }
491
+ },
492
+ {
493
+ "event": "ITEM_DROPPED",
494
+ "triggers": "DO_DROP",
495
+ "source": {
496
+ "kind": "trait",
497
+ "trait": "InventoryItemDrop"
498
+ }
499
+ }
500
+ ],
501
+ "stateMachine": {
502
+ "states": [
503
+ {
504
+ "name": "idle",
505
+ "isInitial": true
506
+ }
566
507
  ],
567
- "CLOSE": [
568
- [
569
- "render-ui",
570
- "modal",
571
- null
572
- ],
573
- [
574
- "render-ui",
575
- "main",
576
- {
577
- "type": "box"
578
- }
579
- ],
580
- [
581
- "ref",
582
- "InventoryItem"
583
- ]
508
+ "events": [
509
+ {
510
+ "key": "INIT",
511
+ "name": "Initialize"
512
+ },
513
+ {
514
+ "key": "DO_ADD",
515
+ "name": "Do Add",
516
+ "payload": [
517
+ {
518
+ "name": "data",
519
+ "type": "InventoryItem"
520
+ }
521
+ ]
522
+ },
523
+ {
524
+ "key": "DO_USE",
525
+ "name": "Do Use",
526
+ "payload": [
527
+ {
528
+ "name": "id",
529
+ "type": "string",
530
+ "required": true
531
+ }
532
+ ]
533
+ },
534
+ {
535
+ "key": "DO_DROP",
536
+ "name": "Do Drop",
537
+ "payload": [
538
+ {
539
+ "name": "id",
540
+ "type": "string",
541
+ "required": true
542
+ }
543
+ ]
544
+ },
545
+ {
546
+ "key": "ITEM_ADDED",
547
+ "name": "Item Added"
548
+ },
549
+ {
550
+ "key": "ITEM_USED",
551
+ "name": "Item Used"
552
+ },
553
+ {
554
+ "key": "ITEM_DROPPED",
555
+ "name": "Item Dropped"
556
+ }
557
+ ],
558
+ "transitions": [
559
+ {
560
+ "from": "idle",
561
+ "to": "idle",
562
+ "event": "INIT"
563
+ },
564
+ {
565
+ "from": "idle",
566
+ "to": "idle",
567
+ "event": "DO_ADD",
568
+ "effects": [
569
+ [
570
+ "persist",
571
+ "create",
572
+ "InventoryItem",
573
+ "@payload.data"
574
+ ],
575
+ [
576
+ "emit",
577
+ "ITEM_ADDED",
578
+ {
579
+ "id": "@payload.data.id"
580
+ }
581
+ ]
582
+ ]
583
+ },
584
+ {
585
+ "from": "idle",
586
+ "to": "idle",
587
+ "event": "DO_USE",
588
+ "effects": [
589
+ [
590
+ "persist",
591
+ "delete",
592
+ "InventoryItem",
593
+ "@payload.id"
594
+ ],
595
+ [
596
+ "emit",
597
+ "ITEM_USED",
598
+ {
599
+ "id": "@payload.id"
600
+ }
601
+ ]
602
+ ]
603
+ },
604
+ {
605
+ "from": "idle",
606
+ "to": "idle",
607
+ "event": "DO_DROP",
608
+ "effects": [
609
+ [
610
+ "persist",
611
+ "delete",
612
+ "InventoryItem",
613
+ "@payload.id"
614
+ ],
615
+ [
616
+ "emit",
617
+ "ITEM_DROPPED",
618
+ {
619
+ "id": "@payload.id"
620
+ }
621
+ ]
622
+ ]
623
+ }
584
624
  ]
585
- }
625
+ },
626
+ "scope": "instance"
586
627
  }
587
628
  ],
588
629
  "pages": [
@@ -601,6 +642,9 @@
601
642
  },
602
643
  {
603
644
  "ref": "InventoryItemDrop"
645
+ },
646
+ {
647
+ "ref": "InventoryItemPersistor"
604
648
  }
605
649
  ]
606
650
  }