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