@effect-app/vue 2.62.0 → 2.63.0

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.
@@ -42,7 +42,7 @@ export const DefaultIntl = {
42
42
 
43
43
  export class CommandContext extends Effect.Tag("CommandContext")<
44
44
  CommandContext,
45
- { action: string; baseName: string; namespace: string; namespaced: (key: string) => string }
45
+ { id: string; action: string; namespace: string; namespaced: (key: string) => string }
46
46
  >() {}
47
47
 
48
48
  export type EmitWithCallback<A, Event extends string> = (event: Event, value: A, onDone: () => void) => void
@@ -68,14 +68,16 @@ export const wrapEmitSubmit = <A>(
68
68
  }
69
69
 
70
70
  export declare namespace Commander {
71
- export interface CommandProps<A, E, Name extends string> {
72
- name: Name
71
+ export interface CommandProps<A, E, Id extends string> {
72
+ id: Id
73
+ namespace: `action.${Id}`
74
+ namespaced: <K extends string>(k: K) => `action.${Id}.${K}`
73
75
  action: string
74
76
  result: Result<A, E>
75
77
  waiting: boolean
76
78
  }
77
79
 
78
- export interface CommandOut<Args extends Array<any>, A, E, R, Name extends string> extends CommandProps<A, E, Name> {
80
+ export interface CommandOut<Args extends Array<any>, A, E, R, Id extends string> extends CommandProps<A, E, Id> {
79
81
  /** click handlers */
80
82
  handle: (...args: Args) => RuntimeFiber<Exit.Exit<A, E>, never>
81
83
 
@@ -95,16 +97,16 @@ export declare namespace Commander {
95
97
  exec: (...args: Args) => Effect.Effect<Exit.Exit<A, E>, never, Exclude<R, CommandContext>>
96
98
  }
97
99
 
98
- type CommandOutHelper<Args extends Array<any>, Eff extends Effect.Effect<any, any, any>, Name extends string> =
100
+ type CommandOutHelper<Args extends Array<any>, Eff extends Effect.Effect<any, any, any>, Id extends string> =
99
101
  CommandOut<
100
102
  Args,
101
103
  Effect.Effect.Success<Eff>,
102
104
  Effect.Effect.Error<Eff>,
103
105
  Effect.Effect.Context<Eff>,
104
- Name
106
+ Id
105
107
  >
106
108
 
107
- export type Gen<RT, Name extends string> = {
109
+ export type Gen<RT, Id extends string> = {
108
110
  <Eff extends YieldWrap<Effect.Effect<any, any, RT | CommandContext>>, AEff, Args extends Array<any>>(
109
111
  body: (...args: Args) => Generator<Eff, AEff, never>
110
112
  ): CommandOut<
@@ -116,7 +118,7 @@ export declare namespace Commander {
116
118
  [Eff] extends [never] ? never
117
119
  : [Eff] extends [YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R
118
120
  : never,
119
- Name
121
+ Id
120
122
  >
121
123
  <
122
124
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
@@ -137,7 +139,7 @@ export declare namespace Commander {
137
139
  >,
138
140
  ...args: NoInfer<Args>
139
141
  ) => A
140
- ): CommandOutHelper<Args, A, Name>
142
+ ): CommandOutHelper<Args, A, Id>
141
143
  <
142
144
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
143
145
  AEff,
@@ -159,7 +161,7 @@ export declare namespace Commander {
159
161
  ...args: NoInfer<Args>
160
162
  ) => A,
161
163
  b: (_: A, ...args: NoInfer<Args>) => B
162
- ): CommandOutHelper<Args, B, Name>
164
+ ): CommandOutHelper<Args, B, Id>
163
165
  <
164
166
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
165
167
  AEff,
@@ -183,7 +185,7 @@ export declare namespace Commander {
183
185
  ) => A,
184
186
  b: (_: A, ...args: NoInfer<Args>) => B,
185
187
  c: (_: B, ...args: NoInfer<Args>) => C
186
- ): CommandOutHelper<Args, C, Name>
188
+ ): CommandOutHelper<Args, C, Id>
187
189
  <
188
190
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
189
191
  AEff,
@@ -209,7 +211,7 @@ export declare namespace Commander {
209
211
  b: (_: A, ...args: NoInfer<Args>) => B,
210
212
  c: (_: B, ...args: NoInfer<Args>) => C,
211
213
  d: (_: C, ...args: NoInfer<Args>) => D
212
- ): CommandOutHelper<Args, D, Name>
214
+ ): CommandOutHelper<Args, D, Id>
213
215
  <
214
216
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
215
217
  AEff,
@@ -237,7 +239,7 @@ export declare namespace Commander {
237
239
  c: (_: B, ...args: NoInfer<Args>) => C,
238
240
  d: (_: C, ...args: NoInfer<Args>) => D,
239
241
  e: (_: D, ...args: NoInfer<Args>) => E
240
- ): CommandOutHelper<Args, E, Name>
242
+ ): CommandOutHelper<Args, E, Id>
241
243
  <
242
244
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
243
245
  AEff,
@@ -267,7 +269,7 @@ export declare namespace Commander {
267
269
  d: (_: C, ...args: NoInfer<Args>) => D,
268
270
  e: (_: D, ...args: NoInfer<Args>) => E,
269
271
  f: (_: E, ...args: NoInfer<Args>) => F
270
- ): CommandOutHelper<Args, F, Name>
272
+ ): CommandOutHelper<Args, F, Id>
271
273
  <
272
274
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
273
275
  AEff,
@@ -299,7 +301,7 @@ export declare namespace Commander {
299
301
  e: (_: D, ...args: NoInfer<Args>) => E,
300
302
  f: (_: E, ...args: NoInfer<Args>) => F,
301
303
  g: (_: F, ...args: NoInfer<Args>) => G
302
- ): CommandOutHelper<Args, G, Name>
304
+ ): CommandOutHelper<Args, G, Id>
303
305
  <
304
306
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
305
307
  AEff,
@@ -333,7 +335,7 @@ export declare namespace Commander {
333
335
  f: (_: E, ...args: NoInfer<Args>) => F,
334
336
  g: (_: F, ...args: NoInfer<Args>) => G,
335
337
  h: (_: G, ...args: NoInfer<Args>) => H
336
- ): CommandOutHelper<Args, H, Name>
338
+ ): CommandOutHelper<Args, H, Id>
337
339
  <
338
340
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
339
341
  AEff,
@@ -369,35 +371,35 @@ export declare namespace Commander {
369
371
  g: (_: F, ...args: NoInfer<Args>) => G,
370
372
  h: (_: G, ...args: NoInfer<Args>) => H,
371
373
  i: (_: H, ...args: NoInfer<Args>) => I
372
- ): CommandOutHelper<Args, I, Name>
374
+ ): CommandOutHelper<Args, I, Id>
373
375
  }
374
376
 
375
- export type NonGen<RT, Name extends string> = {
377
+ export type NonGen<RT, Id extends string> = {
376
378
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<any>>(
377
379
  body: (...args: Args) => Eff
378
- ): CommandOutHelper<Args, Eff, Name>
380
+ ): CommandOutHelper<Args, Eff, Id>
379
381
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, Args extends Array<any>>(
380
382
  body: (...args: Args) => A,
381
383
  a: (_: A, ...args: NoInfer<Args>) => Eff
382
- ): CommandOutHelper<Args, Eff, Name>
384
+ ): CommandOutHelper<Args, Eff, Id>
383
385
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, Args extends Array<any>>(
384
386
  body: (...args: Args) => A,
385
387
  a: (_: A, ...args: NoInfer<Args>) => B,
386
388
  b: (_: B, ...args: NoInfer<Args>) => Eff
387
- ): CommandOutHelper<Args, Eff, Name>
389
+ ): CommandOutHelper<Args, Eff, Id>
388
390
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, Args extends Array<any>>(
389
391
  body: (...args: Args) => A,
390
392
  a: (_: A, ...args: NoInfer<Args>) => B,
391
393
  b: (_: B, ...args: NoInfer<Args>) => C,
392
394
  c: (_: C, ...args: NoInfer<Args>) => Eff
393
- ): CommandOutHelper<Args, Eff, Name>
395
+ ): CommandOutHelper<Args, Eff, Id>
394
396
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, Args extends Array<any>>(
395
397
  body: (...args: Args) => A,
396
398
  a: (_: A, ...args: NoInfer<Args>) => B,
397
399
  b: (_: B, ...args: NoInfer<Args>) => C,
398
400
  c: (_: C, ...args: NoInfer<Args>) => D,
399
401
  d: (_: D, ...args: NoInfer<Args>) => Eff
400
- ): CommandOutHelper<Args, Eff, Name>
402
+ ): CommandOutHelper<Args, Eff, Id>
401
403
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, Args extends Array<any>>(
402
404
  body: (...args: Args) => A,
403
405
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -405,7 +407,7 @@ export declare namespace Commander {
405
407
  c: (_: C, ...args: NoInfer<Args>) => D,
406
408
  d: (_: D, ...args: NoInfer<Args>) => E,
407
409
  e: (_: E, ...args: NoInfer<Args>) => Eff
408
- ): CommandOutHelper<Args, Eff, Name>
410
+ ): CommandOutHelper<Args, Eff, Id>
409
411
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, Args extends Array<any>>(
410
412
  body: (...args: Args) => A,
411
413
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -414,7 +416,7 @@ export declare namespace Commander {
414
416
  d: (_: D, ...args: NoInfer<Args>) => E,
415
417
  e: (_: E, ...args: NoInfer<Args>) => F,
416
418
  f: (_: F, ...args: NoInfer<Args>) => Eff
417
- ): CommandOutHelper<Args, Eff, Name>
419
+ ): CommandOutHelper<Args, Eff, Id>
418
420
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, Args extends Array<any>>(
419
421
  body: (...args: Args) => A,
420
422
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -424,7 +426,7 @@ export declare namespace Commander {
424
426
  e: (_: E, ...args: NoInfer<Args>) => F,
425
427
  f: (_: F, ...args: NoInfer<Args>) => G,
426
428
  g: (_: G, ...args: NoInfer<Args>) => Eff
427
- ): CommandOutHelper<Args, Eff, Name>
429
+ ): CommandOutHelper<Args, Eff, Id>
428
430
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, Args extends Array<any>>(
429
431
  body: (...args: Args) => A,
430
432
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -435,7 +437,7 @@ export declare namespace Commander {
435
437
  f: (_: F, ...args: NoInfer<Args>) => G,
436
438
  g: (_: G, ...args: NoInfer<Args>) => H,
437
439
  h: (_: H, ...args: NoInfer<Args>) => Eff
438
- ): CommandOutHelper<Args, Eff, Name>
440
+ ): CommandOutHelper<Args, Eff, Id>
439
441
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, I, Args extends Array<any>>(
440
442
  body: (...args: Args) => A,
441
443
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -447,16 +449,16 @@ export declare namespace Commander {
447
449
  g: (_: G, ...args: NoInfer<Args>) => H,
448
450
  h: (_: H, ...args: NoInfer<Args>) => I,
449
451
  i: (_: H, ...args: NoInfer<Args>) => Eff
450
- ): CommandOutHelper<Args, Eff, Name>
452
+ ): CommandOutHelper<Args, Eff, Id>
451
453
  }
452
454
 
453
- export type GenWrap<RT, Name extends string, Args extends Array<any>, AEff, EEff, REff> = {
455
+ export type GenWrap<RT, Id extends string, Args extends Array<any>, AEff, EEff, REff> = {
454
456
  (): CommandOut<
455
457
  Args,
456
458
  AEff,
457
459
  EEff,
458
460
  REff, // TODO: only allowed to be RT | CommandContext
459
- Name
461
+ Id
460
462
  >
461
463
  <
462
464
  A extends Effect.Effect<any, any, RT | CommandContext>
@@ -469,7 +471,7 @@ export declare namespace Commander {
469
471
  >,
470
472
  ...args: NoInfer<Args>
471
473
  ) => A
472
- ): CommandOutHelper<Args, A, Name>
474
+ ): CommandOutHelper<Args, A, Id>
473
475
  <
474
476
  A,
475
477
  B extends Effect.Effect<any, any, RT | CommandContext>
@@ -483,7 +485,7 @@ export declare namespace Commander {
483
485
  ...args: NoInfer<Args>
484
486
  ) => A,
485
487
  b: (_: A, ...args: NoInfer<Args>) => B
486
- ): CommandOutHelper<Args, B, Name>
488
+ ): CommandOutHelper<Args, B, Id>
487
489
  <
488
490
  A,
489
491
  B,
@@ -499,7 +501,7 @@ export declare namespace Commander {
499
501
  ) => A,
500
502
  b: (_: A, ...args: NoInfer<Args>) => B,
501
503
  c: (_: B, ...args: NoInfer<Args>) => C
502
- ): CommandOutHelper<Args, C, Name>
504
+ ): CommandOutHelper<Args, C, Id>
503
505
  <
504
506
  A,
505
507
  B,
@@ -517,7 +519,7 @@ export declare namespace Commander {
517
519
  b: (_: A, ...args: NoInfer<Args>) => B,
518
520
  c: (_: B, ...args: NoInfer<Args>) => C,
519
521
  d: (_: C, ...args: NoInfer<Args>) => D
520
- ): CommandOutHelper<Args, D, Name>
522
+ ): CommandOutHelper<Args, D, Id>
521
523
  <
522
524
  A,
523
525
  B,
@@ -537,7 +539,7 @@ export declare namespace Commander {
537
539
  c: (_: B, ...args: NoInfer<Args>) => C,
538
540
  d: (_: C, ...args: NoInfer<Args>) => D,
539
541
  e: (_: D, ...args: NoInfer<Args>) => E
540
- ): CommandOutHelper<Args, E, Name>
542
+ ): CommandOutHelper<Args, E, Id>
541
543
  <
542
544
  A,
543
545
  B,
@@ -559,7 +561,7 @@ export declare namespace Commander {
559
561
  d: (_: C, ...args: NoInfer<Args>) => D,
560
562
  e: (_: D, ...args: NoInfer<Args>) => E,
561
563
  f: (_: E, ...args: NoInfer<Args>) => F
562
- ): CommandOutHelper<Args, F, Name>
564
+ ): CommandOutHelper<Args, F, Id>
563
565
  <
564
566
  A,
565
567
  B,
@@ -583,7 +585,7 @@ export declare namespace Commander {
583
585
  e: (_: D, ...args: NoInfer<Args>) => E,
584
586
  f: (_: E, ...args: NoInfer<Args>) => F,
585
587
  g: (_: F, ...args: NoInfer<Args>) => G
586
- ): CommandOutHelper<Args, G, Name>
588
+ ): CommandOutHelper<Args, G, Id>
587
589
  <A, B, C, D, E, F, G, H extends Effect.Effect<any, any, RT | CommandContext>>(
588
590
  a: (
589
591
  _: Effect.Effect<
@@ -600,7 +602,7 @@ export declare namespace Commander {
600
602
  f: (_: E, ...args: NoInfer<Args>) => F,
601
603
  g: (_: F, ...args: NoInfer<Args>) => G,
602
604
  h: (_: G, ...args: NoInfer<Args>) => H
603
- ): CommandOutHelper<Args, H, Name>
605
+ ): CommandOutHelper<Args, H, Id>
604
606
  <A, B, C, D, E, F, G, H, I extends Effect.Effect<any, any, RT | CommandContext>>(
605
607
  a: (
606
608
  _: Effect.Effect<
@@ -618,11 +620,11 @@ export declare namespace Commander {
618
620
  g: (_: F, ...args: NoInfer<Args>) => G,
619
621
  h: (_: G, ...args: NoInfer<Args>) => H,
620
622
  i: (_: H, ...args: NoInfer<Args>) => I
621
- ): CommandOutHelper<Args, I, Name>
623
+ ): CommandOutHelper<Args, I, Id>
622
624
  }
623
625
 
624
- export type NonGenWrap<RT, Name extends string, Args extends Array<any>, AEff, EEff, REff> = {
625
- (): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Name>
626
+ export type NonGenWrap<RT, Id extends string, Args extends Array<any>, AEff, EEff, REff> = {
627
+ (): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Id>
626
628
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<any>>(
627
629
  a: (
628
630
  _: Effect.Effect<
@@ -632,7 +634,7 @@ export declare namespace Commander {
632
634
  >,
633
635
  ...args: NoInfer<Args>
634
636
  ) => Eff
635
- ): CommandOutHelper<Args, Eff, Name>
637
+ ): CommandOutHelper<Args, Eff, Id>
636
638
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, Args extends Array<any>>(
637
639
  a: (
638
640
  _: Effect.Effect<
@@ -643,7 +645,7 @@ export declare namespace Commander {
643
645
  ...args: NoInfer<Args>
644
646
  ) => B,
645
647
  b: (_: B, ...args: NoInfer<Args>) => Eff
646
- ): CommandOutHelper<Args, Eff, Name>
648
+ ): CommandOutHelper<Args, Eff, Id>
647
649
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, Args extends Array<any>>(
648
650
  a: (
649
651
  _: Effect.Effect<
@@ -655,7 +657,7 @@ export declare namespace Commander {
655
657
  ) => B,
656
658
  b: (_: B, ...args: NoInfer<Args>) => C,
657
659
  c: (_: C, ...args: NoInfer<Args>) => Eff
658
- ): CommandOutHelper<Args, Eff, Name>
660
+ ): CommandOutHelper<Args, Eff, Id>
659
661
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, Args extends Array<any>>(
660
662
  a: (
661
663
  _: Effect.Effect<
@@ -668,7 +670,7 @@ export declare namespace Commander {
668
670
  b: (_: B, ...args: NoInfer<Args>) => C,
669
671
  c: (_: C, ...args: NoInfer<Args>) => D,
670
672
  d: (_: D, ...args: NoInfer<Args>) => Eff
671
- ): CommandOutHelper<Args, Eff, Name>
673
+ ): CommandOutHelper<Args, Eff, Id>
672
674
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, Args extends Array<any>>(
673
675
  a: (
674
676
  _: Effect.Effect<
@@ -682,7 +684,7 @@ export declare namespace Commander {
682
684
  c: (_: C, ...args: NoInfer<Args>) => D,
683
685
  d: (_: D, ...args: NoInfer<Args>) => E,
684
686
  e: (_: E, ...args: NoInfer<Args>) => Eff
685
- ): CommandOutHelper<Args, Eff, Name>
687
+ ): CommandOutHelper<Args, Eff, Id>
686
688
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, Args extends Array<any>>(
687
689
  a: (
688
690
  _: Effect.Effect<
@@ -697,7 +699,7 @@ export declare namespace Commander {
697
699
  d: (_: D, ...args: NoInfer<Args>) => E,
698
700
  e: (_: E, ...args: NoInfer<Args>) => F,
699
701
  f: (_: F, ...args: NoInfer<Args>) => Eff
700
- ): CommandOutHelper<Args, Eff, Name>
702
+ ): CommandOutHelper<Args, Eff, Id>
701
703
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, Args extends Array<any>>(
702
704
  a: (
703
705
  _: Effect.Effect<
@@ -713,7 +715,7 @@ export declare namespace Commander {
713
715
  e: (_: E, ...args: NoInfer<Args>) => F,
714
716
  f: (_: F, ...args: NoInfer<Args>) => G,
715
717
  g: (_: G, ...args: NoInfer<Args>) => Eff
716
- ): CommandOutHelper<Args, Eff, Name>
718
+ ): CommandOutHelper<Args, Eff, Id>
717
719
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, Args extends Array<any>>(
718
720
  a: (
719
721
  _: Effect.Effect<
@@ -730,7 +732,7 @@ export declare namespace Commander {
730
732
  f: (_: F, ...args: NoInfer<Args>) => G,
731
733
  g: (_: G, ...args: NoInfer<Args>) => H,
732
734
  h: (_: H, ...args: NoInfer<Args>) => Eff
733
- ): CommandOutHelper<Args, Eff, Name>
735
+ ): CommandOutHelper<Args, Eff, Id>
734
736
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, I, Args extends Array<any>>(
735
737
  a: (
736
738
  _: Effect.Effect<
@@ -748,10 +750,12 @@ export declare namespace Commander {
748
750
  g: (_: G, ...args: NoInfer<Args>) => H,
749
751
  h: (_: H, ...args: NoInfer<Args>) => I,
750
752
  i: (_: H, ...args: NoInfer<Args>) => Eff
751
- ): CommandOutHelper<Args, Eff, Name>
753
+ ): CommandOutHelper<Args, Eff, Id>
752
754
  }
753
755
  }
754
756
 
757
+ type ErrorRenderer<E, Args extends readonly any[]> = (e: E, action: string, ...args: Args) => string | undefined
758
+
755
759
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
756
760
  export class Commander extends Effect.Service<Commander>()("Commander", {
757
761
  dependencies: [WithToast.Default, Confirm.Default],
@@ -762,7 +766,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
762
766
 
763
767
  const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
764
768
  const runFork = Runtime.runFork(runtime)
765
- return (actionName: string, errorDef?: Error) =>
769
+ return <const Id extends string>(id: Id, errorDef?: Error) =>
766
770
  <Args extends ReadonlyArray<any>, A, E, R extends RT | CommandContext>(
767
771
  handler: (...args: Args) => Effect.Effect<A, E, R>
768
772
  ) => {
@@ -775,20 +779,25 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
775
779
  errorDef = localErrorDef
776
780
  }
777
781
 
778
- const namespace = `action.${actionName}`
782
+ const namespace = `action.${id}` as const
779
783
 
780
784
  const action = intl.formatMessage({
781
785
  id: namespace,
782
- defaultMessage: actionName
786
+ defaultMessage: id
783
787
  })
784
- const context = { action, baseName: actionName, namespace, namespaced: (k: string) => `${namespace}.${k}` }
788
+ const context = {
789
+ action,
790
+ id,
791
+ namespace,
792
+ namespaced: <const K extends string>(k: K) => `${namespace}.${k}` as const
793
+ }
785
794
 
786
795
  const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
787
796
  self.pipe(
788
797
  Effect.tapErrorCause(
789
798
  Effect.fnUntraced(function*(cause) {
790
799
  if (Cause.isInterruptedOnly(cause)) {
791
- console.info(`Interrupted while trying to ${actionName}`)
800
+ console.info(`Interrupted while trying to ${id}`)
792
801
  return
793
802
  }
794
803
 
@@ -801,9 +810,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
801
810
  // )
802
811
  // return
803
812
  // }
804
- const message = `Failure trying to ${actionName}`
813
+ const message = `Failure trying to ${id}`
805
814
  yield* reportMessage(message, {
806
- action: actionName,
815
+ action: id,
807
816
  error: fail.value
808
817
  })
809
818
  return
@@ -811,7 +820,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
811
820
 
812
821
  const extra = {
813
822
  action,
814
- message: `Unexpected Error trying to ${actionName}`
823
+ message: `Unexpected Error trying to ${id}`
815
824
  }
816
825
  yield* reportRuntimeError(cause, extra)
817
826
  }, Effect.uninterruptible)
@@ -863,7 +872,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
863
872
 
864
873
  const command = Effect.withSpan(
865
874
  exec(...args),
866
- actionName,
875
+ id,
867
876
  { captureStackTrace }
868
877
  )
869
878
 
@@ -903,7 +912,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
903
912
 
904
913
  const command = Effect.withSpan(
905
914
  exec(...args),
906
- actionName,
915
+ id,
907
916
  { captureStackTrace }
908
917
  )
909
918
 
@@ -948,7 +957,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
948
957
 
949
958
  const command = Effect.withSpan(
950
959
  exec(...args),
951
- actionName,
960
+ id,
952
961
  { captureStackTrace }
953
962
  )
954
963
 
@@ -988,7 +997,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
988
997
 
989
998
  const command = Effect.withSpan(
990
999
  exec(...args).pipe(Effect.flatten),
991
- actionName,
1000
+ id,
992
1001
  { captureStackTrace }
993
1002
  )
994
1003
 
@@ -996,7 +1005,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
996
1005
  }, { action })
997
1006
 
998
1007
  return reactive({
999
- name: actionName,
1008
+ id,
1009
+ namespaced: context.namespaced,
1010
+ namespace: context.namespace,
1000
1011
  result,
1001
1012
  waiting,
1002
1013
  action,
@@ -1009,10 +1020,73 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1009
1020
  }
1010
1021
  }
1011
1022
 
1023
+ const renderError =
1024
+ <E, Args extends readonly any[]>(action: string, errorRenderer?: ErrorRenderer<E, Args>) =>
1025
+ (e: E, ...args: Args): string => {
1026
+ if (errorRenderer) {
1027
+ const m = errorRenderer(e, action, ...args)
1028
+ if (m) {
1029
+ return m
1030
+ }
1031
+ }
1032
+ if (!S.is(SupportedErrors)(e) && !S.ParseResult.isParseError(e)) {
1033
+ if (typeof e === "object" && e !== null) {
1034
+ if ("message" in e) {
1035
+ return `${e.message}`
1036
+ }
1037
+ if ("_tag" in e) {
1038
+ return `${e._tag}`
1039
+ }
1040
+ }
1041
+ return ""
1042
+ }
1043
+ const e2: SupportedErrors | S.ParseResult.ParseError = e
1044
+ return Match.value(e2).pipe(
1045
+ Match.tags({
1046
+ ParseError: (e) => {
1047
+ console.warn(e.toString())
1048
+ return intl.formatMessage({ id: "validation.failed" })
1049
+ }
1050
+ }),
1051
+ Match.orElse((e) => `${e.message ?? e._tag ?? e}`)
1052
+ )
1053
+ }
1054
+
1055
+ const defaultFailureMessageHandler =
1056
+ <E, Args extends readonly any[]>(action: string, errorRenderer?: ErrorRenderer<E, Args>) =>
1057
+ (o: Option.Option<E>, ...args: Args) =>
1058
+ Option.match(o, {
1059
+ onNone: () =>
1060
+ intl.formatMessage(
1061
+ { id: "handle.unexpected_error2" },
1062
+ {
1063
+ action,
1064
+ error: "" // TODO consider again Cause.pretty(cause), // will be reported to Sentry/Otel anyway.. and we shouldn't bother users with error dumps?
1065
+ }
1066
+ ),
1067
+ onSome: (e) =>
1068
+ S.is(OperationFailure)(e)
1069
+ ? {
1070
+ level: "warn" as const,
1071
+ message: intl.formatMessage(
1072
+ { id: "handle.with_warnings" },
1073
+ { action }
1074
+ ) + e.message
1075
+ ? "\n" + e.message
1076
+ : ""
1077
+ }
1078
+ : `${
1079
+ intl.formatMessage(
1080
+ { id: "handle.with_errors" },
1081
+ { action }
1082
+ )
1083
+ }:\n` + renderError(action, errorRenderer)(e, ...args)
1084
+ })
1085
+
1012
1086
  return {
1013
1087
  /** @experimental */
1014
1088
  takeOver:
1015
- <Args extends any[], A, E, R, const Name extends string>(command: Commander.CommandOut<Args, A, E, R, Name>) =>
1089
+ <Args extends any[], A, E, R, const Id extends string>(command: Commander.CommandOut<Args, A, E, R, Id>) =>
1016
1090
  (...args: Args) => {
1017
1091
  // we capture the call site stack here
1018
1092
  const limit = Error.stackTraceLimit
@@ -1088,17 +1162,19 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1088
1162
  )
1089
1163
  }),
1090
1164
  updateAction:
1091
- <Args extends Array<any>>(update: (currentActionName: string, ...args: Args) => string) =>
1165
+ <Args extends Array<any>>(update: (currentActionId: string, ...args: Args) => string) =>
1092
1166
  <A, E, R>(_: Effect.Effect<A, E, R>, ...input: Args) =>
1093
1167
  Effect.updateService(
1094
1168
  _,
1095
1169
  CommandContext,
1096
1170
  (c) => ({ ...c, action: update(c.action, ...input) })
1097
1171
  ),
1172
+ defaultFailureMessageHandler,
1173
+ renderError,
1098
1174
  /** Version of withDefaultToast that automatically includes the action name in the default messages and uses intl */
1099
1175
  withDefaultToast: <A, E, R, Args extends ReadonlyArray<unknown>>(
1100
1176
  options?: {
1101
- errorRenderer?: (e: E, action: string, ...args: Args) => string | undefined
1177
+ errorRenderer?: ErrorRenderer<E, Args>
1102
1178
  onWaiting?: null | undefined | string | ((action: string, ...args: Args) => string | null | undefined)
1103
1179
  onSuccess?: null | undefined | string | ((a: A, action: string, ...args: Args) => string | null | undefined)
1104
1180
  }
@@ -1110,36 +1186,6 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1110
1186
  Effect.gen(function*() {
1111
1187
  const cc = yield* CommandContext
1112
1188
 
1113
- function renderError(e: E, ...args: Args): string {
1114
- if (options?.errorRenderer) {
1115
- const m = options.errorRenderer(e, cc.action, ...args)
1116
- if (m) {
1117
- return m
1118
- }
1119
- }
1120
- if (!S.is(SupportedErrors)(e) && !S.ParseResult.isParseError(e)) {
1121
- if (typeof e === "object" && e !== null) {
1122
- if ("message" in e) {
1123
- return `${e.message}`
1124
- }
1125
- if ("_tag" in e) {
1126
- return `${e._tag}`
1127
- }
1128
- }
1129
- return ""
1130
- }
1131
- const e2: SupportedErrors | S.ParseResult.ParseError = e
1132
- return Match.value(e2).pipe(
1133
- Match.tags({
1134
- ParseError: (e) => {
1135
- console.warn(e.toString())
1136
- return intl.formatMessage({ id: "validation.failed" })
1137
- }
1138
- }),
1139
- Match.orElse((e) => `${e.message ?? e._tag ?? e}`)
1140
- )
1141
- }
1142
-
1143
1189
  return yield* self.pipe(
1144
1190
  (_) =>
1145
1191
  withToast<A, E, Args, R>({
@@ -1152,42 +1198,15 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1152
1198
  : (a, ..._args) =>
1153
1199
  intl.formatMessage({ id: "handle.success" }, { action: cc.action })
1154
1200
  + (S.is(OperationSuccess)(a) && a.message ? "\n" + a.message : ""),
1155
- onFailure: (o, ...args) =>
1156
- Option.match(o, {
1157
- onNone: () =>
1158
- intl.formatMessage(
1159
- { id: "handle.unexpected_error2" },
1160
- {
1161
- action: cc.action,
1162
- error: "" // TODO consider again Cause.pretty(cause), // will be reported to Sentry/Otel anyway.. and we shouldn't bother users with error dumps?
1163
- }
1164
- ),
1165
- onSome: (e) =>
1166
- S.is(OperationFailure)(e)
1167
- ? {
1168
- level: "warn",
1169
- message: intl.formatMessage(
1170
- { id: "handle.with_warnings" },
1171
- { action: cc.action }
1172
- ) + e.message
1173
- ? "\n" + e.message
1174
- : ""
1175
- }
1176
- : `${
1177
- intl.formatMessage(
1178
- { id: "handle.with_errors" },
1179
- { action: cc.action }
1180
- )
1181
- }:\n` + renderError(e, ...args)
1182
- })
1201
+ onFailure: defaultFailureMessageHandler(cc.action, options?.errorRenderer)
1183
1202
  })(_, ...args)
1184
1203
  )
1185
1204
  }),
1186
1205
  /**
1187
1206
  * Define a Command for handling user actions with built-in error reporting and state management.
1188
1207
  *
1189
- * @param actionName The internal identifier for the action. Used as a tracing span and to lookup
1190
- * the user-facing name via internationalization (`action.${actionName}`).
1208
+ * @param id The internal identifier for the action. Used as a tracing span and to lookup
1209
+ * the user-facing name via internationalization (`action.${id}`).
1191
1210
  * @returns A function that executes the command when called (e.g., directly in `@click` handlers).
1192
1211
  * Built-in error reporting handles failures automatically.
1193
1212
  *
@@ -1205,7 +1224,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1205
1224
  */
1206
1225
  fn: <RT>(runtime: Runtime.Runtime<RT>) => {
1207
1226
  const make = makeCommand(runtime)
1208
- return <const Name extends string>(actionName: Name): Commander.Gen<RT, Name> & Commander.NonGen<RT, Name> =>
1227
+ return <const Id extends string>(id: Id): Commander.Gen<RT, Id> & Commander.NonGen<RT, Id> =>
1209
1228
  (
1210
1229
  fn: any,
1211
1230
  ...combinators: any[]
@@ -1216,7 +1235,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1216
1235
  const errorDef = new Error()
1217
1236
  Error.stackTraceLimit = limit
1218
1237
 
1219
- return make(actionName, errorDef)(
1238
+ return make(id, errorDef)(
1220
1239
  Effect.fnUntraced(
1221
1240
  // fnUntraced only supports generators as first arg, so we convert to generator if needed
1222
1241
  isGeneratorFunction(fn) ? fn : function*(...args) {
@@ -1229,18 +1248,18 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1229
1248
  },
1230
1249
 
1231
1250
  /** @experimental */
1232
- alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Name extends string>(
1233
- actionName: Name
1251
+ alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Id extends string>(
1252
+ id: Id
1234
1253
  ) => <Args extends Array<any>, A, E, R extends RT | CommandContext>(
1235
1254
  handler: (...args: Args) => Effect.Effect<A, E, R>
1236
- ) => Commander.CommandOut<Args, A, E, R, Name>,
1255
+ ) => Commander.CommandOut<Args, A, E, R, Id>,
1237
1256
 
1238
1257
  /** @experimental */
1239
1258
  wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
1240
1259
  const make = makeCommand(runtime)
1241
- return <const Name extends string, Args extends Array<any>, A, E, R>(
1242
- mutation: { mutate: (...args: Args) => Effect.Effect<A, E, R>; name: Name }
1243
- ): Commander.GenWrap<RT, Name, Args, A, E, R> & Commander.NonGenWrap<RT, Name, Args, A, E, R> =>
1260
+ return <const Id extends string, Args extends Array<any>, A, E, R>(
1261
+ mutation: { mutate: (...args: Args) => Effect.Effect<A, E, R>; name: Id }
1262
+ ): Commander.GenWrap<RT, Id, Args, A, E, R> & Commander.NonGenWrap<RT, Id, Args, A, E, R> =>
1244
1263
  (
1245
1264
  ...combinators: any[]
1246
1265
  ): any => {