@effect-app/vue 2.62.1 → 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,7 +750,7 @@ 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
 
@@ -764,7 +766,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
764
766
 
765
767
  const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
766
768
  const runFork = Runtime.runFork(runtime)
767
- return (actionName: string, errorDef?: Error) =>
769
+ return <const Id extends string>(id: Id, errorDef?: Error) =>
768
770
  <Args extends ReadonlyArray<any>, A, E, R extends RT | CommandContext>(
769
771
  handler: (...args: Args) => Effect.Effect<A, E, R>
770
772
  ) => {
@@ -777,20 +779,25 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
777
779
  errorDef = localErrorDef
778
780
  }
779
781
 
780
- const namespace = `action.${actionName}`
782
+ const namespace = `action.${id}` as const
781
783
 
782
784
  const action = intl.formatMessage({
783
785
  id: namespace,
784
- defaultMessage: actionName
786
+ defaultMessage: id
785
787
  })
786
- 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
+ }
787
794
 
788
795
  const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
789
796
  self.pipe(
790
797
  Effect.tapErrorCause(
791
798
  Effect.fnUntraced(function*(cause) {
792
799
  if (Cause.isInterruptedOnly(cause)) {
793
- console.info(`Interrupted while trying to ${actionName}`)
800
+ console.info(`Interrupted while trying to ${id}`)
794
801
  return
795
802
  }
796
803
 
@@ -803,9 +810,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
803
810
  // )
804
811
  // return
805
812
  // }
806
- const message = `Failure trying to ${actionName}`
813
+ const message = `Failure trying to ${id}`
807
814
  yield* reportMessage(message, {
808
- action: actionName,
815
+ action: id,
809
816
  error: fail.value
810
817
  })
811
818
  return
@@ -813,7 +820,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
813
820
 
814
821
  const extra = {
815
822
  action,
816
- message: `Unexpected Error trying to ${actionName}`
823
+ message: `Unexpected Error trying to ${id}`
817
824
  }
818
825
  yield* reportRuntimeError(cause, extra)
819
826
  }, Effect.uninterruptible)
@@ -865,7 +872,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
865
872
 
866
873
  const command = Effect.withSpan(
867
874
  exec(...args),
868
- actionName,
875
+ id,
869
876
  { captureStackTrace }
870
877
  )
871
878
 
@@ -905,7 +912,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
905
912
 
906
913
  const command = Effect.withSpan(
907
914
  exec(...args),
908
- actionName,
915
+ id,
909
916
  { captureStackTrace }
910
917
  )
911
918
 
@@ -950,7 +957,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
950
957
 
951
958
  const command = Effect.withSpan(
952
959
  exec(...args),
953
- actionName,
960
+ id,
954
961
  { captureStackTrace }
955
962
  )
956
963
 
@@ -990,7 +997,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
990
997
 
991
998
  const command = Effect.withSpan(
992
999
  exec(...args).pipe(Effect.flatten),
993
- actionName,
1000
+ id,
994
1001
  { captureStackTrace }
995
1002
  )
996
1003
 
@@ -998,7 +1005,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
998
1005
  }, { action })
999
1006
 
1000
1007
  return reactive({
1001
- name: actionName,
1008
+ id,
1009
+ namespaced: context.namespaced,
1010
+ namespace: context.namespace,
1002
1011
  result,
1003
1012
  waiting,
1004
1013
  action,
@@ -1077,7 +1086,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1077
1086
  return {
1078
1087
  /** @experimental */
1079
1088
  takeOver:
1080
- <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>) =>
1081
1090
  (...args: Args) => {
1082
1091
  // we capture the call site stack here
1083
1092
  const limit = Error.stackTraceLimit
@@ -1153,7 +1162,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1153
1162
  )
1154
1163
  }),
1155
1164
  updateAction:
1156
- <Args extends Array<any>>(update: (currentActionName: string, ...args: Args) => string) =>
1165
+ <Args extends Array<any>>(update: (currentActionId: string, ...args: Args) => string) =>
1157
1166
  <A, E, R>(_: Effect.Effect<A, E, R>, ...input: Args) =>
1158
1167
  Effect.updateService(
1159
1168
  _,
@@ -1196,8 +1205,8 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1196
1205
  /**
1197
1206
  * Define a Command for handling user actions with built-in error reporting and state management.
1198
1207
  *
1199
- * @param actionName The internal identifier for the action. Used as a tracing span and to lookup
1200
- * 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}`).
1201
1210
  * @returns A function that executes the command when called (e.g., directly in `@click` handlers).
1202
1211
  * Built-in error reporting handles failures automatically.
1203
1212
  *
@@ -1215,7 +1224,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1215
1224
  */
1216
1225
  fn: <RT>(runtime: Runtime.Runtime<RT>) => {
1217
1226
  const make = makeCommand(runtime)
1218
- 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> =>
1219
1228
  (
1220
1229
  fn: any,
1221
1230
  ...combinators: any[]
@@ -1226,7 +1235,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1226
1235
  const errorDef = new Error()
1227
1236
  Error.stackTraceLimit = limit
1228
1237
 
1229
- return make(actionName, errorDef)(
1238
+ return make(id, errorDef)(
1230
1239
  Effect.fnUntraced(
1231
1240
  // fnUntraced only supports generators as first arg, so we convert to generator if needed
1232
1241
  isGeneratorFunction(fn) ? fn : function*(...args) {
@@ -1239,18 +1248,18 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1239
1248
  },
1240
1249
 
1241
1250
  /** @experimental */
1242
- alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Name extends string>(
1243
- actionName: Name
1251
+ alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Id extends string>(
1252
+ id: Id
1244
1253
  ) => <Args extends Array<any>, A, E, R extends RT | CommandContext>(
1245
1254
  handler: (...args: Args) => Effect.Effect<A, E, R>
1246
- ) => Commander.CommandOut<Args, A, E, R, Name>,
1255
+ ) => Commander.CommandOut<Args, A, E, R, Id>,
1247
1256
 
1248
1257
  /** @experimental */
1249
1258
  wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
1250
1259
  const make = makeCommand(runtime)
1251
- return <const Name extends string, Args extends Array<any>, A, E, R>(
1252
- mutation: { mutate: (...args: Args) => Effect.Effect<A, E, R>; name: Name }
1253
- ): 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> =>
1254
1263
  (
1255
1264
  ...combinators: any[]
1256
1265
  ): any => {
@@ -23,10 +23,14 @@ it.live("works", () =>
23
23
 
24
24
  const command = Command.fn("Test Action")(
25
25
  function*() {
26
+ expect(command.id).toBe("Test Action")
27
+ expect(command.namespace).toBe("action.Test Action")
28
+ expect(command.namespaced("a")).toBe("action.Test Action.a")
29
+
26
30
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
27
31
  expect(command.waiting).toBe(true)
28
32
 
29
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
33
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
30
34
 
31
35
  expect(toasts.length).toBe(0)
32
36
 
@@ -41,6 +45,9 @@ it.live("works", () =>
41
45
  Effect.tap(() => executed = true)
42
46
  )
43
47
  expect(command.action).toBe("Test Action")
48
+ expect(command.id).toBe("Test Action")
49
+ expect(command.namespace).toBe("action.Test Action")
50
+ expect(command.namespaced("a")).toBe("action.Test Action.a")
44
51
 
45
52
  const r = yield* unwrap(command.handle())
46
53
  expect(command.waiting).toBe(false)
@@ -72,7 +79,7 @@ it.live("works non-gen", () =>
72
79
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
73
80
  expect(command.waiting).toBe(true)
74
81
 
75
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
82
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
76
83
 
77
84
  expect(toasts.length).toBe(0)
78
85
 
@@ -115,7 +122,7 @@ it.live("has custom action name", () =>
115
122
  function*() {
116
123
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
117
124
 
118
- expect(yield* CommandContext).toEqual({ action: "Test Action Translated", name: "Test Action" })
125
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action Translated", id: "Test Action" })
119
126
  return "test-value"
120
127
  },
121
128
  Effect.tap(() => executed = true)
@@ -229,6 +236,7 @@ it.live("with toasts", () =>
229
236
  // onSuccess: () => Effect.map(CommandContext, (_) => _.action),
230
237
  // onWaiting: null
231
238
  // }),
239
+ Command.withDefaultToast(),
232
240
  Effect.tap(() => executed = true)
233
241
  )
234
242
 
@@ -365,7 +373,7 @@ it.live("works with alt", () =>
365
373
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
366
374
  expect(command.waiting).toBe(true)
367
375
 
368
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
376
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
369
377
 
370
378
  expect(toasts.length).toBe(0)
371
379
 
@@ -409,7 +417,7 @@ it.live("has custom action name with alt", () =>
409
417
  function*() {
410
418
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
411
419
 
412
- expect(yield* CommandContext).toEqual({ action: "Test Action Translated", name: "Test Action" })
420
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action Translated", id: "Test Action" })
413
421
  return "test-value"
414
422
  },
415
423
  Effect.tap(() => executed = true)
@@ -9,16 +9,16 @@ export declare const useExperimental: (options?: {
9
9
  messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
10
10
  toasts: any[];
11
11
  }) => {
12
- alt: <const Name extends string>(actionName: Name) => <Args extends Array<any>, A, E, R_1 extends Toast.Toast | WithToast | import("../src/experimental/commander.js").CommandContext>(handler: (...args: Args) => Effect.Effect<A, E, R_1>) => Commander.CommandOut<Args, A, E, R_1, Name>;
13
- fn: <const Name extends string>(actionName: Name) => Commander.Gen<Toast.Toast | WithToast, Name> & Commander.NonGen<Toast.Toast | WithToast, Name>;
14
- wrap: <const Name extends string, Args extends Array<any>, A_1, E_1, R_2>(mutation: {
12
+ alt: <const Id extends string>(id: Id) => <Args extends Array<any>, A, E, R_1 extends WithToast | Toast.Toast | import("../src/experimental/commander.js").CommandContext>(handler: (...args: Args) => Effect.Effect<A, E, R_1>) => Commander.CommandOut<Args, A, E, R_1, Id>;
13
+ fn: <const Id extends string>(id: Id) => Commander.Gen<WithToast | Toast.Toast, Id> & Commander.NonGen<WithToast | Toast.Toast, Id>;
14
+ wrap: <const Id extends string, Args extends Array<any>, A_1, E_1, R_2>(mutation: {
15
15
  mutate: (...args: Args) => Effect.Effect<A_1, E_1, R_2>;
16
- name: Name;
17
- }) => Commander.GenWrap<Toast.Toast | WithToast, Name, Args, A_1, E_1, R_2> & Commander.NonGenWrap<Toast.Toast | WithToast, Name, Args, A_1, E_1, R_2>;
18
- takeOver: <Args_1 extends any[], A_2, E_2, R_3, const Name extends string>(command: Commander.CommandOut<Args_1, A_2, E_2, R_3, Name>) => (...args: Args_1) => Effect.Effect<A_2, E_2, import("../src/experimental/commander.js").CommandContext | Exclude<Exclude<R_3, import("../src/experimental/commander.js").CommandContext>, import("effect/Tracer").ParentSpan>>;
16
+ name: Id;
17
+ }) => Commander.GenWrap<WithToast | Toast.Toast, Id, Args, A_1, E_1, R_2> & Commander.NonGenWrap<WithToast | Toast.Toast, Id, Args, A_1, E_1, R_2>;
18
+ takeOver: <Args_1 extends any[], A_2, E_2, R_3, const Id extends string>(command: Commander.CommandOut<Args_1, A_2, E_2, R_3, Id>) => (...args: Args_1) => Effect.Effect<A_2, E_2, import("../src/experimental/commander.js").CommandContext | Exclude<Exclude<R_3, import("../src/experimental/commander.js").CommandContext>, import("effect/Tracer").ParentSpan>>;
19
19
  confirmOrInterrupt: (message?: string | undefined) => Effect.Effect<void, never, import("../src/experimental/commander.js").CommandContext>;
20
20
  confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/commander.js").CommandContext>;
21
- updateAction: <Args_1 extends Array<any>>(update: (currentActionName: string, ...args: Args_1) => string) => <A_3, E_3, R_4>(_: Effect.Effect<A_3, E_3, R_4>, ...input: Args_1) => Effect.Effect<A_3, E_3, import("../src/experimental/commander.js").CommandContext | R_4>;
21
+ updateAction: <Args_1 extends Array<any>>(update: (currentActionId: string, ...args: Args_1) => string) => <A_3, E_3, R_4>(_: Effect.Effect<A_3, E_3, R_4>, ...input: Args_1) => Effect.Effect<A_3, E_3, import("../src/experimental/commander.js").CommandContext | R_4>;
22
22
  defaultFailureMessageHandler: <E_4, Args_1 extends readonly any[]>(action: string, errorRenderer?: ((e: E_4, action: string, ...args: Args_1) => string | undefined) | undefined) => (o: import("effect/Option").Option<E_4>, ...args: Args_1) => string | {
23
23
  level: "warn";
24
24
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AA4C5D,eAAO,MAAM,aAAa,GAAI,WAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAM,oCAgBzG,CAAA;AAEH,eAAO,MAAM,eAAe,GAC1B,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE;;;;;;;+IAlD5F,GAAG;gCAIW,CAAC;qBAGG,CAAC;kFAKrB,GAAG,6EAEwB,GAAI;oGAQjC,CAAC,4BACG,GAAI,8FAIN,GACV;;;;mFAMK,CAAL,4BAA2B,GAAI,8DAE1B,GAAI;oFAGI,CAAC;qBAGP,CAAH,2BAEG,GAAH;iBAAsD,CAAC,6BACtC,GAAI;iBAKrB,CAAC,qCAAoC,GAAI;2DAES,GACrD;;CAMD,CAAA"}
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AA4C5D,eAAO,MAAM,aAAa,GAAI,WAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAM,oCAgBzG,CAAA;AAEH,eAAO,MAAM,eAAe,GAC1B,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE;;;;;;;2IArD1F,GAAG;gCAKwB,CAAC;qBAIhC,CAAC;gFAI+B,GACzC,6EAEO,GAAI;oGAKS,CAAC,4BAGnB,GAAD,8FAIa,GAAI;;;;mFAM0F,CAAA,4BAEtG,GAAI,8DAEH,GAAI;oFAEI,CAAC;qBACL,CAAC,2BAGR,GAAA;iBAGS,CAAC,6BAA4B,GAAI;iBAG9C,CAAF,qCAE+B,GAC7B;2DAES,GAAI;;CAOd,CAAA"}