@effect-app/vue 2.72.0 → 2.72.2
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.
- package/CHANGELOG.md +12 -0
- package/dist/experimental/commander.d.ts +63 -60
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +9 -9
- package/dist/experimental/makeUseCommand.d.ts +15 -13
- package/dist/experimental/makeUseCommand.d.ts.map +1 -1
- package/dist/makeClient.d.ts +50 -46
- package/dist/makeClient.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/experimental/commander.ts +224 -201
- package/src/makeClient.ts +18 -18
- package/test/dist/stubs.d.ts +15 -13
- package/test/dist/stubs.d.ts.map +1 -1
|
@@ -59,18 +59,23 @@ export const wrapEmit = <A, Event extends string>(
|
|
|
59
59
|
(value: A) => new Promise<void>((resolve) => emit(event, value, resolve))
|
|
60
60
|
|
|
61
61
|
export declare namespace Commander {
|
|
62
|
-
export interface CommandContextLocal<Id extends string> {
|
|
62
|
+
export interface CommandContextLocal<Id extends string, I18nKey extends string> {
|
|
63
63
|
id: Id
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
i18nKey: I18nKey
|
|
65
|
+
namespace: `action.${I18nKey}`
|
|
66
|
+
namespaced: <K extends string>(k: K) => `action.${I18nKey}.${K}`
|
|
66
67
|
action: string
|
|
67
68
|
}
|
|
68
|
-
export interface CommandProps<A, E, Id extends string
|
|
69
|
+
export interface CommandProps<A, E, Id extends string, I18nKey extends string>
|
|
70
|
+
extends CommandContextLocal<Id, I18nKey>
|
|
71
|
+
{
|
|
69
72
|
result: Result<A, E>
|
|
70
73
|
waiting: boolean
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
export interface CommandOut<Args extends Array<unknown>, A, E, R, Id extends string
|
|
76
|
+
export interface CommandOut<Args extends Array<unknown>, A, E, R, Id extends string, I18nKey extends string>
|
|
77
|
+
extends CommandProps<A, E, Id, I18nKey>
|
|
78
|
+
{
|
|
74
79
|
new(): {}
|
|
75
80
|
|
|
76
81
|
/** click handlers */
|
|
@@ -95,16 +100,21 @@ export declare namespace Commander {
|
|
|
95
100
|
// exec: (...args: Args) => Effect.Effect<Exit.Exit<A, E>, never, Exclude<R, CommandContext>>
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
type CommandOutHelper<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
type CommandOutHelper<
|
|
104
|
+
Args extends Array<unknown>,
|
|
105
|
+
Eff extends Effect.Effect<any, any, any>,
|
|
106
|
+
Id extends string,
|
|
107
|
+
I18nKey extends string
|
|
108
|
+
> = CommandOut<
|
|
109
|
+
Args,
|
|
110
|
+
Effect.Effect.Success<Eff>,
|
|
111
|
+
Effect.Effect.Error<Eff>,
|
|
112
|
+
Effect.Effect.Context<Eff>,
|
|
113
|
+
Id,
|
|
114
|
+
I18nKey
|
|
115
|
+
>
|
|
116
|
+
|
|
117
|
+
export type Gen<RT, Id extends string, I18nKey extends string> = {
|
|
108
118
|
<Eff extends YieldWrap<Effect.Effect<any, any, RT | CommandContext>>, AEff, Args extends Array<unknown>>(
|
|
109
119
|
body: (...args: Args) => Generator<Eff, AEff, never>
|
|
110
120
|
): CommandOut<
|
|
@@ -116,7 +126,8 @@ export declare namespace Commander {
|
|
|
116
126
|
[Eff] extends [never] ? never
|
|
117
127
|
: [Eff] extends [YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R
|
|
118
128
|
: never,
|
|
119
|
-
Id
|
|
129
|
+
Id,
|
|
130
|
+
I18nKey
|
|
120
131
|
>
|
|
121
132
|
<
|
|
122
133
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
@@ -137,7 +148,7 @@ export declare namespace Commander {
|
|
|
137
148
|
>,
|
|
138
149
|
...args: NoInfer<Args>
|
|
139
150
|
) => A
|
|
140
|
-
): CommandOutHelper<Args, A, Id>
|
|
151
|
+
): CommandOutHelper<Args, A, Id, I18nKey>
|
|
141
152
|
<
|
|
142
153
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
143
154
|
AEff,
|
|
@@ -159,7 +170,7 @@ export declare namespace Commander {
|
|
|
159
170
|
...args: NoInfer<Args>
|
|
160
171
|
) => A,
|
|
161
172
|
b: (_: A, ...args: NoInfer<Args>) => B
|
|
162
|
-
): CommandOutHelper<Args, B, Id>
|
|
173
|
+
): CommandOutHelper<Args, B, Id, I18nKey>
|
|
163
174
|
<
|
|
164
175
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
165
176
|
AEff,
|
|
@@ -183,7 +194,7 @@ export declare namespace Commander {
|
|
|
183
194
|
) => A,
|
|
184
195
|
b: (_: A, ...args: NoInfer<Args>) => B,
|
|
185
196
|
c: (_: B, ...args: NoInfer<Args>) => C
|
|
186
|
-
): CommandOutHelper<Args, C, Id>
|
|
197
|
+
): CommandOutHelper<Args, C, Id, I18nKey>
|
|
187
198
|
<
|
|
188
199
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
189
200
|
AEff,
|
|
@@ -209,7 +220,7 @@ export declare namespace Commander {
|
|
|
209
220
|
b: (_: A, ...args: NoInfer<Args>) => B,
|
|
210
221
|
c: (_: B, ...args: NoInfer<Args>) => C,
|
|
211
222
|
d: (_: C, ...args: NoInfer<Args>) => D
|
|
212
|
-
): CommandOutHelper<Args, D, Id>
|
|
223
|
+
): CommandOutHelper<Args, D, Id, I18nKey>
|
|
213
224
|
<
|
|
214
225
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
215
226
|
AEff,
|
|
@@ -237,7 +248,7 @@ export declare namespace Commander {
|
|
|
237
248
|
c: (_: B, ...args: NoInfer<Args>) => C,
|
|
238
249
|
d: (_: C, ...args: NoInfer<Args>) => D,
|
|
239
250
|
e: (_: D, ...args: NoInfer<Args>) => E
|
|
240
|
-
): CommandOutHelper<Args, E, Id>
|
|
251
|
+
): CommandOutHelper<Args, E, Id, I18nKey>
|
|
241
252
|
<
|
|
242
253
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
243
254
|
AEff,
|
|
@@ -267,7 +278,7 @@ export declare namespace Commander {
|
|
|
267
278
|
d: (_: C, ...args: NoInfer<Args>) => D,
|
|
268
279
|
e: (_: D, ...args: NoInfer<Args>) => E,
|
|
269
280
|
f: (_: E, ...args: NoInfer<Args>) => F
|
|
270
|
-
): CommandOutHelper<Args, F, Id>
|
|
281
|
+
): CommandOutHelper<Args, F, Id, I18nKey>
|
|
271
282
|
<
|
|
272
283
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
273
284
|
AEff,
|
|
@@ -299,7 +310,7 @@ export declare namespace Commander {
|
|
|
299
310
|
e: (_: D, ...args: NoInfer<Args>) => E,
|
|
300
311
|
f: (_: E, ...args: NoInfer<Args>) => F,
|
|
301
312
|
g: (_: F, ...args: NoInfer<Args>) => G
|
|
302
|
-
): CommandOutHelper<Args, G, Id>
|
|
313
|
+
): CommandOutHelper<Args, G, Id, I18nKey>
|
|
303
314
|
<
|
|
304
315
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
305
316
|
AEff,
|
|
@@ -333,7 +344,7 @@ export declare namespace Commander {
|
|
|
333
344
|
f: (_: E, ...args: NoInfer<Args>) => F,
|
|
334
345
|
g: (_: F, ...args: NoInfer<Args>) => G,
|
|
335
346
|
h: (_: G, ...args: NoInfer<Args>) => H
|
|
336
|
-
): CommandOutHelper<Args, H, Id>
|
|
347
|
+
): CommandOutHelper<Args, H, Id, I18nKey>
|
|
337
348
|
<
|
|
338
349
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
339
350
|
AEff,
|
|
@@ -369,35 +380,35 @@ export declare namespace Commander {
|
|
|
369
380
|
g: (_: F, ...args: NoInfer<Args>) => G,
|
|
370
381
|
h: (_: G, ...args: NoInfer<Args>) => H,
|
|
371
382
|
i: (_: H, ...args: NoInfer<Args>) => I
|
|
372
|
-
): CommandOutHelper<Args, I, Id>
|
|
383
|
+
): CommandOutHelper<Args, I, Id, I18nKey>
|
|
373
384
|
}
|
|
374
385
|
|
|
375
|
-
export type NonGen<RT, Id extends string> = {
|
|
386
|
+
export type NonGen<RT, Id extends string, I18nKey extends string> = {
|
|
376
387
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<unknown>>(
|
|
377
388
|
body: (...args: Args) => Eff
|
|
378
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
389
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
379
390
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, Args extends Array<unknown>>(
|
|
380
391
|
body: (...args: Args) => A,
|
|
381
392
|
a: (_: A, ...args: NoInfer<Args>) => Eff
|
|
382
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
393
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
383
394
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, Args extends Array<unknown>>(
|
|
384
395
|
body: (...args: Args) => A,
|
|
385
396
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
386
397
|
b: (_: B, ...args: NoInfer<Args>) => Eff
|
|
387
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
398
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
388
399
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, Args extends Array<unknown>>(
|
|
389
400
|
body: (...args: Args) => A,
|
|
390
401
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
391
402
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
392
403
|
c: (_: C, ...args: NoInfer<Args>) => Eff
|
|
393
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
404
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
394
405
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, Args extends Array<unknown>>(
|
|
395
406
|
body: (...args: Args) => A,
|
|
396
407
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
397
408
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
398
409
|
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
399
410
|
d: (_: D, ...args: NoInfer<Args>) => Eff
|
|
400
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
411
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
401
412
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, Args extends Array<unknown>>(
|
|
402
413
|
body: (...args: Args) => A,
|
|
403
414
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
@@ -405,7 +416,7 @@ export declare namespace Commander {
|
|
|
405
416
|
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
406
417
|
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
407
418
|
e: (_: E, ...args: NoInfer<Args>) => Eff
|
|
408
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
419
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
409
420
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, Args extends Array<unknown>>(
|
|
410
421
|
body: (...args: Args) => A,
|
|
411
422
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
@@ -414,7 +425,7 @@ export declare namespace Commander {
|
|
|
414
425
|
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
415
426
|
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
416
427
|
f: (_: F, ...args: NoInfer<Args>) => Eff
|
|
417
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
428
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
418
429
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, Args extends Array<unknown>>(
|
|
419
430
|
body: (...args: Args) => A,
|
|
420
431
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
@@ -424,7 +435,7 @@ export declare namespace Commander {
|
|
|
424
435
|
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
425
436
|
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
426
437
|
g: (_: G, ...args: NoInfer<Args>) => Eff
|
|
427
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
438
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
428
439
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, Args extends Array<unknown>>(
|
|
429
440
|
body: (...args: Args) => A,
|
|
430
441
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
@@ -435,7 +446,7 @@ export declare namespace Commander {
|
|
|
435
446
|
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
436
447
|
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
437
448
|
h: (_: H, ...args: NoInfer<Args>) => Eff
|
|
438
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
449
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
439
450
|
<Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, I, Args extends Array<unknown>>(
|
|
440
451
|
body: (...args: Args) => A,
|
|
441
452
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
@@ -447,16 +458,17 @@ export declare namespace Commander {
|
|
|
447
458
|
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
448
459
|
h: (_: H, ...args: NoInfer<Args>) => I,
|
|
449
460
|
i: (_: H, ...args: NoInfer<Args>) => Eff
|
|
450
|
-
): CommandOutHelper<Args, Eff, Id>
|
|
461
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
451
462
|
}
|
|
452
463
|
|
|
453
|
-
export type GenWrap<RT, Id extends string, Args extends Array<unknown>, AEff, EEff, REff> = {
|
|
464
|
+
export type GenWrap<RT, Id extends string, I18nKey extends string, Args extends Array<unknown>, AEff, EEff, REff> = {
|
|
454
465
|
(): CommandOut<
|
|
455
466
|
Args,
|
|
456
467
|
AEff,
|
|
457
468
|
EEff,
|
|
458
469
|
REff, // TODO: only allowed to be RT | CommandContext
|
|
459
|
-
Id
|
|
470
|
+
Id,
|
|
471
|
+
I18nKey
|
|
460
472
|
>
|
|
461
473
|
<
|
|
462
474
|
A extends Effect.Effect<any, any, RT | CommandContext>
|
|
@@ -469,7 +481,7 @@ export declare namespace Commander {
|
|
|
469
481
|
>,
|
|
470
482
|
...args: NoInfer<Args>
|
|
471
483
|
) => A
|
|
472
|
-
): CommandOutHelper<Args, A, Id>
|
|
484
|
+
): CommandOutHelper<Args, A, Id, I18nKey>
|
|
473
485
|
<
|
|
474
486
|
A,
|
|
475
487
|
B extends Effect.Effect<any, any, RT | CommandContext>
|
|
@@ -483,7 +495,7 @@ export declare namespace Commander {
|
|
|
483
495
|
...args: NoInfer<Args>
|
|
484
496
|
) => A,
|
|
485
497
|
b: (_: A, ...args: NoInfer<Args>) => B
|
|
486
|
-
): CommandOutHelper<Args, B, Id>
|
|
498
|
+
): CommandOutHelper<Args, B, Id, I18nKey>
|
|
487
499
|
<
|
|
488
500
|
A,
|
|
489
501
|
B,
|
|
@@ -499,7 +511,7 @@ export declare namespace Commander {
|
|
|
499
511
|
) => A,
|
|
500
512
|
b: (_: A, ...args: NoInfer<Args>) => B,
|
|
501
513
|
c: (_: B, ...args: NoInfer<Args>) => C
|
|
502
|
-
): CommandOutHelper<Args, C, Id>
|
|
514
|
+
): CommandOutHelper<Args, C, Id, I18nKey>
|
|
503
515
|
<
|
|
504
516
|
A,
|
|
505
517
|
B,
|
|
@@ -517,7 +529,7 @@ export declare namespace Commander {
|
|
|
517
529
|
b: (_: A, ...args: NoInfer<Args>) => B,
|
|
518
530
|
c: (_: B, ...args: NoInfer<Args>) => C,
|
|
519
531
|
d: (_: C, ...args: NoInfer<Args>) => D
|
|
520
|
-
): CommandOutHelper<Args, D, Id>
|
|
532
|
+
): CommandOutHelper<Args, D, Id, I18nKey>
|
|
521
533
|
<
|
|
522
534
|
A,
|
|
523
535
|
B,
|
|
@@ -537,7 +549,7 @@ export declare namespace Commander {
|
|
|
537
549
|
c: (_: B, ...args: NoInfer<Args>) => C,
|
|
538
550
|
d: (_: C, ...args: NoInfer<Args>) => D,
|
|
539
551
|
e: (_: D, ...args: NoInfer<Args>) => E
|
|
540
|
-
): CommandOutHelper<Args, E, Id>
|
|
552
|
+
): CommandOutHelper<Args, E, Id, I18nKey>
|
|
541
553
|
<
|
|
542
554
|
A,
|
|
543
555
|
B,
|
|
@@ -559,7 +571,7 @@ export declare namespace Commander {
|
|
|
559
571
|
d: (_: C, ...args: NoInfer<Args>) => D,
|
|
560
572
|
e: (_: D, ...args: NoInfer<Args>) => E,
|
|
561
573
|
f: (_: E, ...args: NoInfer<Args>) => F
|
|
562
|
-
): CommandOutHelper<Args, F, Id>
|
|
574
|
+
): CommandOutHelper<Args, F, Id, I18nKey>
|
|
563
575
|
<
|
|
564
576
|
A,
|
|
565
577
|
B,
|
|
@@ -583,7 +595,7 @@ export declare namespace Commander {
|
|
|
583
595
|
e: (_: D, ...args: NoInfer<Args>) => E,
|
|
584
596
|
f: (_: E, ...args: NoInfer<Args>) => F,
|
|
585
597
|
g: (_: F, ...args: NoInfer<Args>) => G
|
|
586
|
-
): CommandOutHelper<Args, G, Id>
|
|
598
|
+
): CommandOutHelper<Args, G, Id, I18nKey>
|
|
587
599
|
<A, B, C, D, E, F, G, H extends Effect.Effect<any, any, RT | CommandContext>>(
|
|
588
600
|
a: (
|
|
589
601
|
_: Effect.Effect<
|
|
@@ -600,7 +612,7 @@ export declare namespace Commander {
|
|
|
600
612
|
f: (_: E, ...args: NoInfer<Args>) => F,
|
|
601
613
|
g: (_: F, ...args: NoInfer<Args>) => G,
|
|
602
614
|
h: (_: G, ...args: NoInfer<Args>) => H
|
|
603
|
-
): CommandOutHelper<Args, H, Id>
|
|
615
|
+
): CommandOutHelper<Args, H, Id, I18nKey>
|
|
604
616
|
<A, B, C, D, E, F, G, H, I extends Effect.Effect<any, any, RT | CommandContext>>(
|
|
605
617
|
a: (
|
|
606
618
|
_: Effect.Effect<
|
|
@@ -618,138 +630,139 @@ export declare namespace Commander {
|
|
|
618
630
|
g: (_: F, ...args: NoInfer<Args>) => G,
|
|
619
631
|
h: (_: G, ...args: NoInfer<Args>) => H,
|
|
620
632
|
i: (_: H, ...args: NoInfer<Args>) => I
|
|
621
|
-
): CommandOutHelper<Args, I, Id>
|
|
633
|
+
): CommandOutHelper<Args, I, Id, I18nKey>
|
|
622
634
|
}
|
|
623
635
|
|
|
624
|
-
export type NonGenWrap<RT, Id extends string, Args extends Array<unknown>, AEff, EEff, REff> =
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
636
|
+
export type NonGenWrap<RT, Id extends string, I18nKey extends string, Args extends Array<unknown>, AEff, EEff, REff> =
|
|
637
|
+
{
|
|
638
|
+
(): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Id, I18nKey>
|
|
639
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<unknown>>(
|
|
640
|
+
a: (
|
|
641
|
+
_: Effect.Effect<
|
|
642
|
+
AEff,
|
|
643
|
+
EEff,
|
|
644
|
+
REff
|
|
645
|
+
>,
|
|
646
|
+
...args: NoInfer<Args>
|
|
647
|
+
) => Eff
|
|
648
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
649
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, Args extends Array<unknown>>(
|
|
650
|
+
a: (
|
|
651
|
+
_: Effect.Effect<
|
|
652
|
+
AEff,
|
|
653
|
+
EEff,
|
|
654
|
+
REff
|
|
655
|
+
>,
|
|
656
|
+
...args: NoInfer<Args>
|
|
657
|
+
) => B,
|
|
658
|
+
b: (_: B, ...args: NoInfer<Args>) => Eff
|
|
659
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
660
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, Args extends Array<unknown>>(
|
|
661
|
+
a: (
|
|
662
|
+
_: Effect.Effect<
|
|
663
|
+
AEff,
|
|
664
|
+
EEff,
|
|
665
|
+
REff
|
|
666
|
+
>,
|
|
667
|
+
...args: NoInfer<Args>
|
|
668
|
+
) => B,
|
|
669
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
670
|
+
c: (_: C, ...args: NoInfer<Args>) => Eff
|
|
671
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
672
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, Args extends Array<unknown>>(
|
|
673
|
+
a: (
|
|
674
|
+
_: Effect.Effect<
|
|
675
|
+
AEff,
|
|
676
|
+
EEff,
|
|
677
|
+
REff
|
|
678
|
+
>,
|
|
679
|
+
...args: NoInfer<Args>
|
|
680
|
+
) => B,
|
|
681
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
682
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
683
|
+
d: (_: D, ...args: NoInfer<Args>) => Eff
|
|
684
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
685
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, Args extends Array<unknown>>(
|
|
686
|
+
a: (
|
|
687
|
+
_: Effect.Effect<
|
|
688
|
+
AEff,
|
|
689
|
+
EEff,
|
|
690
|
+
REff
|
|
691
|
+
>,
|
|
692
|
+
...args: NoInfer<Args>
|
|
693
|
+
) => B,
|
|
694
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
695
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
696
|
+
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
697
|
+
e: (_: E, ...args: NoInfer<Args>) => Eff
|
|
698
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
699
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, Args extends Array<unknown>>(
|
|
700
|
+
a: (
|
|
701
|
+
_: Effect.Effect<
|
|
702
|
+
AEff,
|
|
703
|
+
EEff,
|
|
704
|
+
REff
|
|
705
|
+
>,
|
|
706
|
+
...args: NoInfer<Args>
|
|
707
|
+
) => B,
|
|
708
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
709
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
710
|
+
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
711
|
+
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
712
|
+
f: (_: F, ...args: NoInfer<Args>) => Eff
|
|
713
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
714
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, Args extends Array<unknown>>(
|
|
715
|
+
a: (
|
|
716
|
+
_: Effect.Effect<
|
|
717
|
+
AEff,
|
|
718
|
+
EEff,
|
|
719
|
+
REff
|
|
720
|
+
>,
|
|
721
|
+
...args: NoInfer<Args>
|
|
722
|
+
) => B,
|
|
723
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
724
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
725
|
+
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
726
|
+
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
727
|
+
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
728
|
+
g: (_: G, ...args: NoInfer<Args>) => Eff
|
|
729
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
730
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, Args extends Array<unknown>>(
|
|
731
|
+
a: (
|
|
732
|
+
_: Effect.Effect<
|
|
733
|
+
AEff,
|
|
734
|
+
EEff,
|
|
735
|
+
REff
|
|
736
|
+
>,
|
|
737
|
+
...args: NoInfer<Args>
|
|
738
|
+
) => B,
|
|
739
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
740
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
741
|
+
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
742
|
+
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
743
|
+
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
744
|
+
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
745
|
+
h: (_: H, ...args: NoInfer<Args>) => Eff
|
|
746
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
747
|
+
<Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, I, Args extends Array<unknown>>(
|
|
748
|
+
a: (
|
|
749
|
+
_: Effect.Effect<
|
|
750
|
+
AEff,
|
|
751
|
+
EEff,
|
|
752
|
+
REff
|
|
753
|
+
>,
|
|
754
|
+
...args: NoInfer<Args>
|
|
755
|
+
) => B,
|
|
756
|
+
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
757
|
+
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
758
|
+
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
759
|
+
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
760
|
+
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
761
|
+
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
762
|
+
h: (_: H, ...args: NoInfer<Args>) => I,
|
|
763
|
+
i: (_: H, ...args: NoInfer<Args>) => Eff
|
|
764
|
+
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
765
|
+
}
|
|
753
766
|
}
|
|
754
767
|
|
|
755
768
|
type ErrorRenderer<E, Args extends readonly any[]> = (e: E, action: string, ...args: Args) => string | undefined
|
|
@@ -911,16 +924,15 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
911
924
|
|
|
912
925
|
const makeContext = <const Id extends string, const I18nKey extends string = Id>(
|
|
913
926
|
id: Id,
|
|
914
|
-
customI18nKey
|
|
927
|
+
customI18nKey: I18nKey | undefined
|
|
915
928
|
) => {
|
|
916
929
|
if (!id) throw new Error("must specify an id")
|
|
917
930
|
const i18nKey: I18nKey = customI18nKey ?? id as unknown as I18nKey
|
|
918
931
|
|
|
919
|
-
|
|
920
|
-
const namespace = `action.${id}` as const
|
|
932
|
+
const namespace = `action.${i18nKey}` as const
|
|
921
933
|
|
|
922
934
|
const action = intl.formatMessage({
|
|
923
|
-
id:
|
|
935
|
+
id: namespace,
|
|
924
936
|
defaultMessage: id
|
|
925
937
|
})
|
|
926
938
|
const context = {
|
|
@@ -936,7 +948,8 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
936
948
|
|
|
937
949
|
const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
938
950
|
const runFork = Runtime.runFork(runtime)
|
|
939
|
-
return <const Id extends string>(id: Id, customI18nKey?: string, errorDef?: Error) => {
|
|
951
|
+
return <const Id extends string>(id_: Id | { id: Id }, customI18nKey?: string, errorDef?: Error) => {
|
|
952
|
+
const id = typeof id_ === "string" ? id_ : id_.id
|
|
940
953
|
const context = makeContext(id, customI18nKey)
|
|
941
954
|
|
|
942
955
|
return Object.assign(<Args extends ReadonlyArray<unknown>, A, E, R extends RT | CommandContext>(
|
|
@@ -1185,7 +1198,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1185
1198
|
return {
|
|
1186
1199
|
// /** @experimental */
|
|
1187
1200
|
// takeOver:
|
|
1188
|
-
// <Args extends any[], A, E, R, const Id extends string>(command: Commander.CommandOut<Args, A, E, R, Id>) =>
|
|
1201
|
+
// <Args extends any[], A, E, R, const Id extends string>(command: Commander.CommandOut<Args, A, E, R, Id,I18nKey>) =>
|
|
1189
1202
|
// (...args: Args) => {
|
|
1190
1203
|
// // we capture the call site stack here
|
|
1191
1204
|
// const limit = Error.stackTraceLimit
|
|
@@ -1256,9 +1269,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1256
1269
|
fn: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
1257
1270
|
const make = makeCommand(runtime)
|
|
1258
1271
|
return <const Id extends string, const I18nKey extends string = Id>(
|
|
1259
|
-
id: Id,
|
|
1272
|
+
id: Id | { id: Id },
|
|
1260
1273
|
customI18nKey?: I18nKey
|
|
1261
|
-
): Commander.Gen<RT, Id> & Commander.NonGen<RT, Id> =>
|
|
1274
|
+
): Commander.Gen<RT, Id, I18nKey> & Commander.NonGen<RT, Id, I18nKey> =>
|
|
1262
1275
|
Object.assign((
|
|
1263
1276
|
fn: any,
|
|
1264
1277
|
...combinators: any[]
|
|
@@ -1278,7 +1291,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1278
1291
|
...combinators as [any]
|
|
1279
1292
|
) as any
|
|
1280
1293
|
)
|
|
1281
|
-
}, makeContext(id))
|
|
1294
|
+
}, makeContext(typeof id === "string" ? id : id.id, customI18nKey))
|
|
1282
1295
|
},
|
|
1283
1296
|
|
|
1284
1297
|
alt2: ((rt: any) => {
|
|
@@ -1286,7 +1299,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1286
1299
|
return (_id: any, customI18nKey?: string) => {
|
|
1287
1300
|
const isObject = typeof _id === "object" || typeof _id === "function"
|
|
1288
1301
|
const id = isObject ? _id.id : _id
|
|
1289
|
-
const context = makeContext(id)
|
|
1302
|
+
const context = makeContext(id, customI18nKey)
|
|
1290
1303
|
const idCmd = cmd(id, customI18nKey)
|
|
1291
1304
|
// TODO: implement proper tracing stack
|
|
1292
1305
|
return Object.assign((cb: any) =>
|
|
@@ -1309,44 +1322,54 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1309
1322
|
}
|
|
1310
1323
|
}) as unknown as <RT>(
|
|
1311
1324
|
runtime: Runtime.Runtime<RT>
|
|
1312
|
-
) => <
|
|
1325
|
+
) => <
|
|
1326
|
+
const Id extends string,
|
|
1327
|
+
MutArgs extends Array<unknown>,
|
|
1328
|
+
MutA,
|
|
1329
|
+
MutE,
|
|
1330
|
+
MutR,
|
|
1331
|
+
const I18nKey extends string = Id
|
|
1332
|
+
>(
|
|
1313
1333
|
id:
|
|
1314
1334
|
| Id
|
|
1315
1335
|
| { id: Id; mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR> }
|
|
1316
|
-
| ((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & { id: Id }
|
|
1336
|
+
| ((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & { id: Id },
|
|
1337
|
+
customI18nKey?: I18nKey
|
|
1317
1338
|
) =>
|
|
1318
|
-
& Commander.CommandContextLocal<Id>
|
|
1339
|
+
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1319
1340
|
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext>(
|
|
1320
1341
|
handler: (
|
|
1321
|
-
ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id> & {
|
|
1342
|
+
ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id, I18nKey> & {
|
|
1322
1343
|
// todo: only if we passed in one
|
|
1323
1344
|
mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>
|
|
1324
1345
|
}
|
|
1325
1346
|
) => (...args: Args) => Effect.Effect<A, E, R>
|
|
1326
|
-
) => Commander.CommandOut<Args, A, E, R, Id>),
|
|
1347
|
+
) => Commander.CommandOut<Args, A, E, R, Id, I18nKey>),
|
|
1327
1348
|
|
|
1328
1349
|
/** @experimental */
|
|
1329
|
-
alt: makeCommand as unknown as <RT>(
|
|
1350
|
+
alt: makeCommand as unknown as <RT>(
|
|
1351
|
+
runtime: Runtime.Runtime<RT>
|
|
1352
|
+
) => <const Id extends string, const I18nKey extends string = Id>(
|
|
1330
1353
|
id: Id,
|
|
1331
|
-
customI18nKey?:
|
|
1354
|
+
customI18nKey?: I18nKey
|
|
1332
1355
|
) =>
|
|
1333
|
-
& Commander.CommandContextLocal<Id>
|
|
1356
|
+
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1334
1357
|
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext>(
|
|
1335
1358
|
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
1336
|
-
) => Commander.CommandOut<Args, A, E, R, Id>),
|
|
1359
|
+
) => Commander.CommandOut<Args, A, E, R, Id, I18nKey>),
|
|
1337
1360
|
|
|
1338
1361
|
/** @experimental */
|
|
1339
1362
|
wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
1340
1363
|
const make = makeCommand(runtime)
|
|
1341
|
-
return <const Id extends string, Args extends Array<unknown>, A, E, R>(
|
|
1364
|
+
return <const Id extends string, Args extends Array<unknown>, A, E, R, I18nKey extends string = Id>(
|
|
1342
1365
|
mutation:
|
|
1343
1366
|
| { mutate: (...args: Args) => Effect.Effect<A, E, R>; id: Id }
|
|
1344
1367
|
| ((...args: Args) => Effect.Effect<A, E, R>) & { id: Id },
|
|
1345
|
-
customI18nKey?:
|
|
1368
|
+
customI18nKey?: I18nKey
|
|
1346
1369
|
):
|
|
1347
|
-
& Commander.CommandContextLocal<Id>
|
|
1348
|
-
& Commander.GenWrap<RT, Id, Args, A, E, R>
|
|
1349
|
-
& Commander.NonGenWrap<RT, Id, Args, A, E, R> =>
|
|
1370
|
+
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1371
|
+
& Commander.GenWrap<RT, Id, I18nKey, Args, A, E, R>
|
|
1372
|
+
& Commander.NonGenWrap<RT, Id, I18nKey, Args, A, E, R> =>
|
|
1350
1373
|
Object.assign((
|
|
1351
1374
|
...combinators: any[]
|
|
1352
1375
|
): any => {
|
|
@@ -1367,7 +1390,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1367
1390
|
...combinators as [any]
|
|
1368
1391
|
) as any
|
|
1369
1392
|
)
|
|
1370
|
-
}, makeContext(mutation.id))
|
|
1393
|
+
}, makeContext(mutation.id, customI18nKey))
|
|
1371
1394
|
}
|
|
1372
1395
|
}
|
|
1373
1396
|
})
|