@effect-app/vue 2.67.0 → 2.67.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 +5 -5
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +176 -174
- package/dist/experimental/intl.d.ts +1 -1
- package/dist/experimental/makeUseCommand.d.ts +4 -4
- package/dist/experimental/toast.d.ts +1 -1
- package/dist/makeClient.d.ts +12 -8
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/mutate.d.ts +8 -2
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +28 -21
- package/package.json +1 -1
- package/src/experimental/commander.ts +262 -253
- package/src/mutate.ts +60 -51
- package/test/dist/stubs.d.ts +4 -4
- package/test/dist/stubs.d.ts.map +1 -1
|
@@ -779,247 +779,249 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
779
779
|
|
|
780
780
|
const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
781
781
|
const runFork = Runtime.runFork(runtime)
|
|
782
|
-
return <const Id extends string>(id: Id, errorDef?: Error) =>
|
|
783
|
-
<Args extends ReadonlyArray<unknown>, A, E, R extends RT | CommandContext>(
|
|
784
|
-
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
785
|
-
) => {
|
|
786
|
-
// we capture the definition stack here, so we can append it to later stack traces
|
|
787
|
-
const limit = Error.stackTraceLimit
|
|
788
|
-
Error.stackTraceLimit = 2
|
|
789
|
-
const localErrorDef = new Error()
|
|
790
|
-
Error.stackTraceLimit = limit
|
|
791
|
-
if (!errorDef) {
|
|
792
|
-
errorDef = localErrorDef
|
|
793
|
-
}
|
|
794
|
-
|
|
782
|
+
return <const Id extends string>(id: Id, errorDef?: Error) => {
|
|
795
783
|
const context = makeContext(id)
|
|
796
|
-
const action = context.action
|
|
797
|
-
|
|
798
|
-
const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
799
|
-
self.pipe(
|
|
800
|
-
Effect.tapErrorCause(
|
|
801
|
-
Effect.fnUntraced(function*(cause) {
|
|
802
|
-
if (Cause.isInterruptedOnly(cause)) {
|
|
803
|
-
console.info(`Interrupted while trying to ${id}`)
|
|
804
|
-
return
|
|
805
|
-
}
|
|
806
784
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
action: id,
|
|
819
|
-
error: fail.value
|
|
820
|
-
})
|
|
821
|
-
return
|
|
822
|
-
}
|
|
785
|
+
return Object.assign(<Args extends ReadonlyArray<unknown>, A, E, R extends RT | CommandContext>(
|
|
786
|
+
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
787
|
+
) => {
|
|
788
|
+
// we capture the definition stack here, so we can append it to later stack traces
|
|
789
|
+
const limit = Error.stackTraceLimit
|
|
790
|
+
Error.stackTraceLimit = 2
|
|
791
|
+
const localErrorDef = new Error()
|
|
792
|
+
Error.stackTraceLimit = limit
|
|
793
|
+
if (!errorDef) {
|
|
794
|
+
errorDef = localErrorDef
|
|
795
|
+
}
|
|
823
796
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
797
|
+
const action = context.action
|
|
798
|
+
|
|
799
|
+
const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
800
|
+
self.pipe(
|
|
801
|
+
Effect.tapErrorCause(
|
|
802
|
+
Effect.fnUntraced(function*(cause) {
|
|
803
|
+
if (Cause.isInterruptedOnly(cause)) {
|
|
804
|
+
console.info(`Interrupted while trying to ${id}`)
|
|
805
|
+
return
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
const fail = Cause.failureOption(cause)
|
|
809
|
+
if (Option.isSome(fail)) {
|
|
810
|
+
// if (fail.value._tag === "SuppressErrors") {
|
|
811
|
+
// console.info(
|
|
812
|
+
// `Suppressed error trying to ${action}`,
|
|
813
|
+
// fail.value,
|
|
814
|
+
// )
|
|
815
|
+
// return
|
|
816
|
+
// }
|
|
817
|
+
const message = `Failure trying to ${id}`
|
|
818
|
+
yield* reportMessage(message, {
|
|
819
|
+
action: id,
|
|
820
|
+
error: fail.value
|
|
821
|
+
})
|
|
822
|
+
return
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
const extra = {
|
|
826
|
+
action,
|
|
827
|
+
message: `Unexpected Error trying to ${id}`
|
|
828
|
+
}
|
|
829
|
+
yield* reportRuntimeError(cause, extra)
|
|
830
|
+
}, Effect.uninterruptible)
|
|
831
|
+
)
|
|
830
832
|
)
|
|
833
|
+
|
|
834
|
+
const theHandler = flow(
|
|
835
|
+
handler,
|
|
836
|
+
// all must be within the Effect.fn to fit within the Span
|
|
837
|
+
Effect.provideService(CommandContext, context),
|
|
838
|
+
(_) => Effect.annotateCurrentSpan({ action }).pipe(Effect.zipRight(_)),
|
|
839
|
+
errorReporter
|
|
831
840
|
)
|
|
832
841
|
|
|
833
|
-
|
|
834
|
-
handler,
|
|
835
|
-
// all must be within the Effect.fn to fit within the Span
|
|
836
|
-
Effect.provideService(CommandContext, context),
|
|
837
|
-
(_) => Effect.annotateCurrentSpan({ action }).pipe(Effect.zipRight(_)),
|
|
838
|
-
errorReporter
|
|
839
|
-
)
|
|
842
|
+
const [result, exec] = asResult(theHandler)
|
|
840
843
|
|
|
841
|
-
|
|
844
|
+
const waiting = computed(() => result.value.waiting)
|
|
842
845
|
|
|
843
|
-
|
|
846
|
+
const handle = Object.assign((...args: Args) => {
|
|
847
|
+
// we capture the call site stack here
|
|
848
|
+
const limit = Error.stackTraceLimit
|
|
849
|
+
Error.stackTraceLimit = 2
|
|
850
|
+
const errorCall = new Error()
|
|
851
|
+
Error.stackTraceLimit = limit
|
|
844
852
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
const errorCall = new Error()
|
|
850
|
-
Error.stackTraceLimit = limit
|
|
851
|
-
|
|
852
|
-
let cache: false | string = false
|
|
853
|
-
const captureStackTrace = () => {
|
|
854
|
-
// in case of an error, we want to append the definition stack to the call site stack,
|
|
855
|
-
// so we can see where the handler was defined too
|
|
853
|
+
let cache: false | string = false
|
|
854
|
+
const captureStackTrace = () => {
|
|
855
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
856
|
+
// so we can see where the handler was defined too
|
|
856
857
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
if (errorCall.stack) {
|
|
861
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
862
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
863
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
864
|
-
if (!endStackDef.includes(`(`)) {
|
|
865
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
858
|
+
if (cache !== false) {
|
|
859
|
+
return cache
|
|
866
860
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
861
|
+
if (errorCall.stack) {
|
|
862
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
863
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
864
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
865
|
+
if (!endStackDef.includes(`(`)) {
|
|
866
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
867
|
+
}
|
|
868
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
869
|
+
if (!endStackCall.includes(`(`)) {
|
|
870
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
871
|
+
}
|
|
872
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
873
|
+
return cache
|
|
870
874
|
}
|
|
871
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
872
|
-
return cache
|
|
873
875
|
}
|
|
874
|
-
}
|
|
875
876
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
877
|
+
const command = Effect.withSpan(
|
|
878
|
+
exec(...args),
|
|
879
|
+
id,
|
|
880
|
+
{ captureStackTrace }
|
|
881
|
+
)
|
|
881
882
|
|
|
882
|
-
|
|
883
|
-
|
|
883
|
+
return runFork(command)
|
|
884
|
+
}, { action })
|
|
884
885
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
886
|
+
const handleEffect = Object.assign((...args: Args) => {
|
|
887
|
+
// we capture the call site stack here
|
|
888
|
+
const limit = Error.stackTraceLimit
|
|
889
|
+
Error.stackTraceLimit = 2
|
|
890
|
+
const errorCall = new Error()
|
|
891
|
+
Error.stackTraceLimit = limit
|
|
891
892
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
893
|
+
let cache: false | string = false
|
|
894
|
+
const captureStackTrace = () => {
|
|
895
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
896
|
+
// so we can see where the handler was defined too
|
|
896
897
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
if (errorCall.stack) {
|
|
901
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
902
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
903
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
904
|
-
if (!endStackDef.includes(`(`)) {
|
|
905
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
898
|
+
if (cache !== false) {
|
|
899
|
+
return cache
|
|
906
900
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
901
|
+
if (errorCall.stack) {
|
|
902
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
903
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
904
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
905
|
+
if (!endStackDef.includes(`(`)) {
|
|
906
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
907
|
+
}
|
|
908
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
909
|
+
if (!endStackCall.includes(`(`)) {
|
|
910
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
911
|
+
}
|
|
912
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
913
|
+
return cache
|
|
910
914
|
}
|
|
911
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
912
|
-
return cache
|
|
913
915
|
}
|
|
914
|
-
}
|
|
915
916
|
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
917
|
+
const command = Effect.withSpan(
|
|
918
|
+
exec(...args),
|
|
919
|
+
id,
|
|
920
|
+
{ captureStackTrace }
|
|
921
|
+
)
|
|
921
922
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
923
|
+
return Effect.currentSpan.pipe(
|
|
924
|
+
Effect.option,
|
|
925
|
+
Effect.map((span) =>
|
|
926
|
+
runFork(Option.isSome(span) ? command.pipe(Effect.withParentSpan(span.value)) : command)
|
|
927
|
+
)
|
|
926
928
|
)
|
|
927
|
-
)
|
|
928
|
-
}, { action })
|
|
929
|
+
}, { action })
|
|
929
930
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
931
|
+
const compose = Object.assign((...args: Args) => {
|
|
932
|
+
// we capture the call site stack here
|
|
933
|
+
const limit = Error.stackTraceLimit
|
|
934
|
+
Error.stackTraceLimit = 2
|
|
935
|
+
const errorCall = new Error()
|
|
936
|
+
Error.stackTraceLimit = limit
|
|
936
937
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
938
|
+
let cache: false | string = false
|
|
939
|
+
const captureStackTrace = () => {
|
|
940
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
941
|
+
// so we can see where the handler was defined too
|
|
941
942
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
945
|
-
if (errorCall.stack) {
|
|
946
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
947
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
948
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
949
|
-
if (!endStackDef.includes(`(`)) {
|
|
950
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
943
|
+
if (cache !== false) {
|
|
944
|
+
return cache
|
|
951
945
|
}
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
946
|
+
if (errorCall.stack) {
|
|
947
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
948
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
949
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
950
|
+
if (!endStackDef.includes(`(`)) {
|
|
951
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
952
|
+
}
|
|
953
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
954
|
+
if (!endStackCall.includes(`(`)) {
|
|
955
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
956
|
+
}
|
|
957
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
958
|
+
return cache
|
|
955
959
|
}
|
|
956
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
957
|
-
return cache
|
|
958
960
|
}
|
|
959
|
-
}
|
|
960
961
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
962
|
+
const command = Effect.withSpan(
|
|
963
|
+
exec(...args),
|
|
964
|
+
id,
|
|
965
|
+
{ captureStackTrace }
|
|
966
|
+
)
|
|
966
967
|
|
|
967
|
-
|
|
968
|
-
|
|
968
|
+
return command
|
|
969
|
+
}, { action })
|
|
969
970
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
971
|
+
const compose2 = Object.assign((...args: Args) => {
|
|
972
|
+
// we capture the call site stack here
|
|
973
|
+
const limit = Error.stackTraceLimit
|
|
974
|
+
Error.stackTraceLimit = 2
|
|
975
|
+
const errorCall = new Error()
|
|
976
|
+
Error.stackTraceLimit = limit
|
|
976
977
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
978
|
+
let cache: false | string = false
|
|
979
|
+
const captureStackTrace = () => {
|
|
980
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
981
|
+
// so we can see where the handler was defined too
|
|
981
982
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
if (errorCall.stack) {
|
|
986
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
987
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
988
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
989
|
-
if (!endStackDef.includes(`(`)) {
|
|
990
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
983
|
+
if (cache !== false) {
|
|
984
|
+
return cache
|
|
991
985
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
986
|
+
if (errorCall.stack) {
|
|
987
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
988
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
989
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
990
|
+
if (!endStackDef.includes(`(`)) {
|
|
991
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
992
|
+
}
|
|
993
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
994
|
+
if (!endStackCall.includes(`(`)) {
|
|
995
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
996
|
+
}
|
|
997
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
998
|
+
return cache
|
|
995
999
|
}
|
|
996
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
997
|
-
return cache
|
|
998
1000
|
}
|
|
999
|
-
}
|
|
1000
1001
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1002
|
+
const command = Effect.withSpan(
|
|
1003
|
+
exec(...args).pipe(Effect.flatten),
|
|
1004
|
+
id,
|
|
1005
|
+
{ captureStackTrace }
|
|
1006
|
+
)
|
|
1006
1007
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1008
|
+
return command
|
|
1009
|
+
}, { action })
|
|
1010
|
+
|
|
1011
|
+
return reactive({
|
|
1012
|
+
id,
|
|
1013
|
+
namespaced: context.namespaced,
|
|
1014
|
+
namespace: context.namespace,
|
|
1015
|
+
result,
|
|
1016
|
+
waiting,
|
|
1017
|
+
action,
|
|
1018
|
+
handle,
|
|
1019
|
+
handleEffect,
|
|
1020
|
+
compose,
|
|
1021
|
+
compose2,
|
|
1022
|
+
exec
|
|
1023
|
+
})
|
|
1024
|
+
}, context)
|
|
1023
1025
|
}
|
|
1024
1026
|
}
|
|
1025
1027
|
|
|
@@ -1236,26 +1238,26 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1236
1238
|
fn: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
1237
1239
|
const make = makeCommand(runtime)
|
|
1238
1240
|
return <const Id extends string>(id: Id): Commander.Gen<RT, Id> & Commander.NonGen<RT, Id> =>
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1241
|
+
Object.assign((
|
|
1242
|
+
fn: any,
|
|
1243
|
+
...combinators: any[]
|
|
1244
|
+
): any => {
|
|
1245
|
+
// we capture the definition stack here, so we can append it to later stack traces
|
|
1246
|
+
const limit = Error.stackTraceLimit
|
|
1247
|
+
Error.stackTraceLimit = 2
|
|
1248
|
+
const errorDef = new Error()
|
|
1249
|
+
Error.stackTraceLimit = limit
|
|
1248
1250
|
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1251
|
+
return make(id, errorDef)(
|
|
1252
|
+
Effect.fnUntraced(
|
|
1253
|
+
// fnUntraced only supports generators as first arg, so we convert to generator if needed
|
|
1254
|
+
isGeneratorFunction(fn) ? fn : function*(...args) {
|
|
1255
|
+
return yield* fn(...args)
|
|
1256
|
+
},
|
|
1257
|
+
...combinators as [any]
|
|
1258
|
+
) as any
|
|
1259
|
+
)
|
|
1260
|
+
}, makeContext(id))
|
|
1259
1261
|
},
|
|
1260
1262
|
|
|
1261
1263
|
alt2: ((rt: any) => {
|
|
@@ -1266,7 +1268,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1266
1268
|
const context = makeContext(id)
|
|
1267
1269
|
const idCmd = cmd(id)
|
|
1268
1270
|
// TODO: implement proper tracing stack
|
|
1269
|
-
return (cb: any) =>
|
|
1271
|
+
return Object.assign((cb: any) =>
|
|
1270
1272
|
idCmd(cb(
|
|
1271
1273
|
Object.assign(
|
|
1272
1274
|
(fn: any, ...combinators: any[]) =>
|
|
@@ -1282,7 +1284,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1282
1284
|
? { mutate: "mutate" in _id ? _id.mutate : typeof _id === "function" ? _id : undefined }
|
|
1283
1285
|
: {}
|
|
1284
1286
|
)
|
|
1285
|
-
))
|
|
1287
|
+
)), context)
|
|
1286
1288
|
}
|
|
1287
1289
|
}) as unknown as <RT>(
|
|
1288
1290
|
runtime: Runtime.Runtime<RT>
|
|
@@ -1291,21 +1293,25 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1291
1293
|
| Id
|
|
1292
1294
|
| { id: Id; mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR> }
|
|
1293
1295
|
| ((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & { id: Id }
|
|
1294
|
-
) =>
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1296
|
+
) =>
|
|
1297
|
+
& Commander.CommandContextLocal<Id>
|
|
1298
|
+
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext>(
|
|
1299
|
+
handler: (
|
|
1300
|
+
ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id> & {
|
|
1301
|
+
// todo: only if we passed in one
|
|
1302
|
+
mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>
|
|
1303
|
+
}
|
|
1304
|
+
) => (...args: Args) => Effect.Effect<A, E, R>
|
|
1305
|
+
) => Commander.CommandOut<Args, A, E, R, Id>),
|
|
1302
1306
|
|
|
1303
1307
|
/** @experimental */
|
|
1304
1308
|
alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Id extends string>(
|
|
1305
1309
|
id: Id
|
|
1306
|
-
) =>
|
|
1307
|
-
|
|
1308
|
-
|
|
1310
|
+
) =>
|
|
1311
|
+
& Commander.CommandContextLocal<Id>
|
|
1312
|
+
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext>(
|
|
1313
|
+
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
1314
|
+
) => Commander.CommandOut<Args, A, E, R, Id>),
|
|
1309
1315
|
|
|
1310
1316
|
/** @experimental */
|
|
1311
1317
|
wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
@@ -1314,28 +1320,31 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1314
1320
|
mutation:
|
|
1315
1321
|
| { mutate: (...args: Args) => Effect.Effect<A, E, R>; id: Id }
|
|
1316
1322
|
| ((...args: Args) => Effect.Effect<A, E, R>) & { id: Id }
|
|
1317
|
-
):
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1323
|
+
):
|
|
1324
|
+
& Commander.CommandContextLocal<Id>
|
|
1325
|
+
& Commander.GenWrap<RT, Id, Args, A, E, R>
|
|
1326
|
+
& Commander.NonGenWrap<RT, Id, Args, A, E, R> =>
|
|
1327
|
+
Object.assign((
|
|
1328
|
+
...combinators: any[]
|
|
1329
|
+
): any => {
|
|
1330
|
+
// we capture the definition stack here, so we can append it to later stack traces
|
|
1331
|
+
const limit = Error.stackTraceLimit
|
|
1332
|
+
Error.stackTraceLimit = 2
|
|
1333
|
+
const errorDef = new Error()
|
|
1334
|
+
Error.stackTraceLimit = limit
|
|
1326
1335
|
|
|
1327
|
-
|
|
1336
|
+
const mutate = "mutate" in mutation ? mutation.mutate : mutation
|
|
1328
1337
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1338
|
+
return make(mutation.id, errorDef)(
|
|
1339
|
+
Effect.fnUntraced(
|
|
1340
|
+
// fnUntraced only supports generators as first arg, so we convert to generator if needed
|
|
1341
|
+
isGeneratorFunction(mutate) ? mutate : function*(...args: Args) {
|
|
1342
|
+
return yield* mutate(...args)
|
|
1343
|
+
},
|
|
1344
|
+
...combinators as [any]
|
|
1345
|
+
) as any
|
|
1346
|
+
)
|
|
1347
|
+
}, makeContext(mutation.id))
|
|
1339
1348
|
}
|
|
1340
1349
|
}
|
|
1341
1350
|
})
|