@effect-app/vue 2.67.7 → 2.69.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.
- package/CHANGELOG.md +12 -0
- package/dist/experimental/commander.d.ts +23 -33
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +125 -111
- package/dist/experimental/confirm.d.ts +1 -0
- package/dist/experimental/confirm.d.ts.map +1 -1
- package/dist/experimental/confirm.js +3 -2
- package/dist/experimental/makeUseCommand.d.ts +23 -24
- package/dist/experimental/makeUseCommand.d.ts.map +1 -1
- package/dist/experimental/makeUseCommand.js +4 -3
- package/dist/makeClient.d.ts +314 -107
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +75 -4
- package/package.json +2 -1
- package/src/experimental/commander.ts +218 -207
- package/src/experimental/confirm.ts +2 -1
- package/src/experimental/makeUseCommand.ts +3 -2
- package/src/makeClient.ts +264 -6
- package/test/dist/stubs.d.ts +24 -25
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +2 -2
- package/test/stubs.ts +2 -2
package/src/makeClient.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import * as Result from "@effect-atom/atom/Result"
|
|
3
|
-
import { type InitialDataFunction, isCancelledError, type QueryObserverResult, type RefetchOptions, type UseQueryReturnType } from "@tanstack/vue-query"
|
|
3
|
+
import { type InitialDataFunction, type InvalidateOptions, type InvalidateQueryFilters, isCancelledError, type QueryObserverResult, type RefetchOptions, type UseQueryReturnType } from "@tanstack/vue-query"
|
|
4
4
|
import { Cause, Effect, Exit, Layer, ManagedRuntime, Match, Option, Runtime, S, Struct } from "effect-app"
|
|
5
|
-
import type { RequestHandler, RequestHandlerWithInput, TaggedRequestClassAny } from "effect-app/client/clientFor"
|
|
5
|
+
import type { RequestHandler, RequestHandlers, RequestHandlerWithInput, Requests, TaggedRequestClassAny } from "effect-app/client/clientFor"
|
|
6
6
|
import { ErrorSilenced, type SupportedErrors } from "effect-app/client/errors"
|
|
7
7
|
import { constant, identity, pipe, tuple } from "effect-app/Function"
|
|
8
8
|
import { type OperationFailure, OperationSuccess } from "effect-app/Operations"
|
|
9
9
|
import type { Schema } from "effect-app/Schema"
|
|
10
10
|
import { dropUndefinedT } from "effect-app/utils"
|
|
11
|
+
import { type RuntimeFiber } from "effect/Fiber"
|
|
11
12
|
import { computed, type ComputedRef, getCurrentInstance, onBeforeUnmount, onUnmounted, type Ref, ref, watch, type WatchSource } from "vue"
|
|
12
13
|
import { reportMessage } from "./errorReporter.js"
|
|
13
14
|
import { Commander } from "./experimental/commander.js"
|
|
@@ -19,6 +20,9 @@ import { reportRuntimeError } from "./lib.js"
|
|
|
19
20
|
import { asResult, makeMutation, type MutationOptions, type MutationOptionsBase, mutationResultToVue, type Res } from "./mutate.js"
|
|
20
21
|
import { type CustomDefinedInitialQueryOptions, type CustomUndefinedInitialQueryOptions, type KnownFiberFailure, makeQuery } from "./query.js"
|
|
21
22
|
|
|
23
|
+
import { camelCase } from "change-case"
|
|
24
|
+
import { type ApiClientFactory } from "effect-app/client"
|
|
25
|
+
|
|
22
26
|
const mapHandler = <A, E, R, I = void, A2 = A, E2 = E, R2 = R>(
|
|
23
27
|
handler: Effect.Effect<A, E, R> | ((i: I) => Effect.Effect<A, E, R>),
|
|
24
28
|
map: (self: Effect.Effect<A, E, R>, i: I) => Effect.Effect<A2, E2, R2>
|
|
@@ -975,8 +979,9 @@ const managedRuntimeRt = <A, E>(mrt: ManagedRuntime.ManagedRuntime<A, E>) => mrt
|
|
|
975
979
|
|
|
976
980
|
type Base = I18n | Toast
|
|
977
981
|
export const makeClient = <RT, RE, RL>(
|
|
978
|
-
getBaseMrt: () => ManagedRuntime.ManagedRuntime<RT, never>,
|
|
979
|
-
rootLayer: Layer.Layer<RL | Base, RE
|
|
982
|
+
getBaseMrt: () => ManagedRuntime.ManagedRuntime<RT | ApiClientFactory, never>,
|
|
983
|
+
rootLayer: Layer.Layer<RL | Base, RE>,
|
|
984
|
+
clientFor_: ReturnType<typeof ApiClientFactory["makeFor"]>
|
|
980
985
|
) => {
|
|
981
986
|
const getBaseRt = () => managedRuntimeRt(getBaseMrt())
|
|
982
987
|
|
|
@@ -1050,9 +1055,262 @@ export const makeClient = <RT, RE, RL>(
|
|
|
1050
1055
|
},
|
|
1051
1056
|
{} as { [K in keyof mut]: mut[K] }
|
|
1052
1057
|
)
|
|
1058
|
+
const query = mkQuery(getBaseRt)
|
|
1059
|
+
const useQuery = query.useQuery
|
|
1060
|
+
const useSuspenseQuery = query.useSuspenseQuery
|
|
1061
|
+
|
|
1062
|
+
// Glorious rpc client helpers
|
|
1063
|
+
// TODO:
|
|
1064
|
+
// - reusable; extract to lib
|
|
1065
|
+
// - reduce duplication for Types
|
|
1066
|
+
|
|
1067
|
+
const mapQuery = <M extends Requests>(
|
|
1068
|
+
client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
|
|
1069
|
+
) => {
|
|
1070
|
+
const queries = Struct.keys(client).reduce(
|
|
1071
|
+
(acc, key) => {
|
|
1072
|
+
;(acc as any)[camelCase(key) + "Query"] = Object.assign(useQuery(client[key] as any), {
|
|
1073
|
+
id: client[key].id
|
|
1074
|
+
})
|
|
1075
|
+
;(acc as any)[camelCase(key) + "SuspenseQuery"] = Object.assign(useSuspenseQuery(client[key] as any), {
|
|
1076
|
+
id: client[key].id
|
|
1077
|
+
})
|
|
1078
|
+
return acc
|
|
1079
|
+
},
|
|
1080
|
+
{} as
|
|
1081
|
+
& {
|
|
1082
|
+
[Key in keyof typeof client as `${ToCamel<string & Key>}Query`]: typeof client[Key] extends
|
|
1083
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer Request, infer Id>
|
|
1084
|
+
? ReturnType<typeof useQuery<I, E, A, Request, Id>> & { id: Id }
|
|
1085
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer Request, infer Id>
|
|
1086
|
+
? ReturnType<typeof useQuery<E, A, Request, Id>> & { id: Id }
|
|
1087
|
+
: never
|
|
1088
|
+
}
|
|
1089
|
+
// todo: or suspense as an Option?
|
|
1090
|
+
& {
|
|
1091
|
+
[Key in keyof typeof client as `${ToCamel<string & Key>}SuspenseQuery`]: typeof client[Key] extends
|
|
1092
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer Request, infer Id>
|
|
1093
|
+
? ReturnType<typeof useSuspenseQuery<I, E, A, Request, Id>> & { id: Id }
|
|
1094
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer Request, infer Id>
|
|
1095
|
+
? ReturnType<typeof useSuspenseQuery<E, A, Request, Id>> & { id: Id }
|
|
1096
|
+
: never
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
1099
|
+
return queries
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
const mapMutation = <M extends Requests>(
|
|
1103
|
+
client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
|
|
1104
|
+
) => {
|
|
1105
|
+
const Command = useCommand()
|
|
1106
|
+
const wrap = Command.wrap
|
|
1107
|
+
const fn_ = Command.fn
|
|
1108
|
+
const mutations = Struct.keys(client).reduce(
|
|
1109
|
+
(acc, key) => {
|
|
1110
|
+
const mut = useMutation(client[key] as any)
|
|
1111
|
+
const fn = fn_(client[key].id)
|
|
1112
|
+
;(acc as any)[camelCase(key) + "Mutation"] = Object.assign(
|
|
1113
|
+
mut,
|
|
1114
|
+
{ wrap: wrap(mut), fn },
|
|
1115
|
+
wrap
|
|
1116
|
+
)
|
|
1117
|
+
return acc
|
|
1118
|
+
},
|
|
1119
|
+
{} as {
|
|
1120
|
+
[Key in keyof typeof client as `${ToCamel<string & Key>}Mutation`]:
|
|
1121
|
+
& (typeof client[Key] extends
|
|
1122
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id> ?
|
|
1123
|
+
& ReturnType<typeof useMutation<I, E, A, R, Request, Id>>
|
|
1124
|
+
& (typeof client[Key] extends
|
|
1125
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1126
|
+
? Commander.CommandContextLocal<Id>
|
|
1127
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1128
|
+
? Commander.CommandContextLocal<Id>
|
|
1129
|
+
: never)
|
|
1130
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer R, infer Request, infer Id> ?
|
|
1131
|
+
& ReturnType<typeof useMutation<E, A, R, Request, Id>>
|
|
1132
|
+
& (typeof client[Key] extends
|
|
1133
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1134
|
+
? Commander.CommandContextLocal<Id>
|
|
1135
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1136
|
+
? Commander.CommandContextLocal<Id>
|
|
1137
|
+
: never)
|
|
1138
|
+
: never)
|
|
1139
|
+
& (typeof client[Key] extends
|
|
1140
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1141
|
+
? Commander.CommandContextLocal<Id>
|
|
1142
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1143
|
+
? Commander.CommandContextLocal<Id>
|
|
1144
|
+
: never)
|
|
1145
|
+
& (typeof client[Key] extends
|
|
1146
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id>
|
|
1147
|
+
? ReturnType<typeof useMutation<I, E, A, R, Request, Id>>
|
|
1148
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer R, infer Request, infer Id>
|
|
1149
|
+
? ReturnType<typeof useMutation<E, A, R, Request, Id>>
|
|
1150
|
+
: never)
|
|
1151
|
+
& {
|
|
1152
|
+
wrap: typeof client[Key] extends
|
|
1153
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer _Request, infer Id>
|
|
1154
|
+
? ReturnType<typeof wrap<Id, [I], A, E, never>> & Commander.CommandContextLocal<Id>
|
|
1155
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer _Request, infer Id>
|
|
1156
|
+
? ReturnType<typeof wrap<Id, [], A, E, never>> & Commander.CommandContextLocal<Id>
|
|
1157
|
+
: never
|
|
1158
|
+
fn: typeof client[Key] extends
|
|
1159
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1160
|
+
? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
|
|
1161
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1162
|
+
? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
|
|
1163
|
+
: never
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
)
|
|
1167
|
+
return mutations
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// make available .query, .suspense and .mutate for each operation
|
|
1171
|
+
// and a .helpers with all mutations and queries
|
|
1172
|
+
const mapClient = <M extends Requests>(
|
|
1173
|
+
queryInvalidation?: QueryInvalidation<M>
|
|
1174
|
+
) =>
|
|
1175
|
+
(
|
|
1176
|
+
client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
|
|
1177
|
+
) => {
|
|
1178
|
+
const Command = useCommand()
|
|
1179
|
+
const wrap = Command.wrap
|
|
1180
|
+
const fn_ = Command.fn
|
|
1181
|
+
const extended = Struct.keys(client).reduce(
|
|
1182
|
+
(acc, key) => {
|
|
1183
|
+
const fn = fn_(client[key].id)
|
|
1184
|
+
const awesome = {
|
|
1185
|
+
...client[key],
|
|
1186
|
+
...fn,
|
|
1187
|
+
query: useQuery(client[key] as any),
|
|
1188
|
+
suspense: useSuspenseQuery(client[key] as any)
|
|
1189
|
+
}
|
|
1190
|
+
const mutate = useMutation(
|
|
1191
|
+
client[key] as any,
|
|
1192
|
+
queryInvalidation?.[key] ? { queryInvalidation: queryInvalidation[key] } : undefined
|
|
1193
|
+
)
|
|
1194
|
+
;(acc as any)[key] = Object.assign(mutate, { wrap: wrap({ mutate, id: awesome.id }), fn }, awesome, fn)
|
|
1195
|
+
return acc
|
|
1196
|
+
},
|
|
1197
|
+
{} as {
|
|
1198
|
+
[Key in keyof typeof client]:
|
|
1199
|
+
& (typeof client[Key] extends
|
|
1200
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1201
|
+
? Commander.CommandContextLocal<Id>
|
|
1202
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1203
|
+
? Commander.CommandContextLocal<Id>
|
|
1204
|
+
: never)
|
|
1205
|
+
& (typeof client[Key] extends
|
|
1206
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1207
|
+
? Commander.CommandContextLocal<Id>
|
|
1208
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1209
|
+
? Commander.CommandContextLocal<Id>
|
|
1210
|
+
: never)
|
|
1211
|
+
& (typeof client[Key] extends
|
|
1212
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id>
|
|
1213
|
+
? ReturnType<typeof useMutation<I, E, A, R, Request, Id>>
|
|
1214
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer R, infer Request, infer Id>
|
|
1215
|
+
? ReturnType<typeof useMutation<E, A, R, Request, Id>>
|
|
1216
|
+
: never)
|
|
1217
|
+
& {
|
|
1218
|
+
wrap: typeof client[Key] extends
|
|
1219
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer _Request, infer Id>
|
|
1220
|
+
? ReturnType<typeof wrap<Id, [I], A, E, never>> & Commander.CommandContextLocal<Id>
|
|
1221
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer _Request, infer Id>
|
|
1222
|
+
? ReturnType<typeof wrap<Id, [], A, E, never>> & Commander.CommandContextLocal<Id>
|
|
1223
|
+
: never
|
|
1224
|
+
fn: typeof client[Key] extends
|
|
1225
|
+
RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1226
|
+
? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
|
|
1227
|
+
: typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
|
|
1228
|
+
? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
|
|
1229
|
+
: never
|
|
1230
|
+
}
|
|
1231
|
+
& typeof client[Key]
|
|
1232
|
+
& {
|
|
1233
|
+
query: typeof client[Key] extends
|
|
1234
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer Request, infer Id>
|
|
1235
|
+
? ReturnType<typeof useQuery<I, E, A, Request, Id>>
|
|
1236
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer Request, infer Id>
|
|
1237
|
+
? ReturnType<typeof useQuery<E, A, Request, Id>>
|
|
1238
|
+
: never
|
|
1239
|
+
// TODO or suspense as Option?
|
|
1240
|
+
suspense: typeof client[Key] extends
|
|
1241
|
+
RequestHandlerWithInput<infer I, infer A, infer E, infer _R, infer Request, infer Id>
|
|
1242
|
+
? ReturnType<typeof useSuspenseQuery<I, E, A, Request, Id>>
|
|
1243
|
+
: typeof client[Key] extends RequestHandler<infer A, infer E, infer _R, infer Request, infer Id>
|
|
1244
|
+
? ReturnType<typeof useSuspenseQuery<E, A, Request, Id>>
|
|
1245
|
+
: never
|
|
1246
|
+
// mutate: typeof client[Key] extends
|
|
1247
|
+
// RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id>
|
|
1248
|
+
// ? ReturnType<typeof useMutation<I, E, A, R, Request, Id>>
|
|
1249
|
+
// : typeof client[Key] extends RequestHandler<infer A, infer E, infer R, infer Request, infer Id>
|
|
1250
|
+
// ? ReturnType<typeof useMutation<E, A, R, Request, Id>>
|
|
1251
|
+
// : never
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
)
|
|
1255
|
+
return Object.assign(extended, { helpers: { ...mapMutation(client), ...mapQuery(client) } })
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// todo; invalidateQueries should perhaps be configured in the Request impl themselves?
|
|
1259
|
+
const clientFor = <M extends Requests>(
|
|
1260
|
+
m: M,
|
|
1261
|
+
queryInvalidation?: QueryInvalidation<M>
|
|
1262
|
+
) => getBaseMrt().runSync(clientFor_(m).pipe(Effect.map(mapClient(queryInvalidation))))
|
|
1263
|
+
|
|
1264
|
+
const legacy = {
|
|
1265
|
+
/** @deprecated use OmegaForm */
|
|
1266
|
+
buildFormFromSchema: mutations.buildFormFromSchema,
|
|
1267
|
+
/** @deprecated use Command pattern */
|
|
1268
|
+
makeUseAndHandleMutation: mutations.makeUseAndHandleMutation,
|
|
1269
|
+
/** @deprecated use Command pattern */
|
|
1270
|
+
useAndHandleMutation: mutations.useAndHandleMutation,
|
|
1271
|
+
/** @deprecated use Command pattern */
|
|
1272
|
+
useSafeMutation: mutations.useSafeMutation,
|
|
1273
|
+
/** @deprecated use Command pattern */
|
|
1274
|
+
useSafeMutationWithState: mutations.useSafeMutationWithState,
|
|
1275
|
+
/** @deprecated use .query on the clientFor(x).Action */
|
|
1276
|
+
useQuery,
|
|
1277
|
+
/** @deprecated use .suspense on the clientFor(x).Action */
|
|
1278
|
+
useSuspenseQuery
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1053
1281
|
return {
|
|
1054
1282
|
useCommand,
|
|
1055
|
-
|
|
1056
|
-
|
|
1283
|
+
clientFor,
|
|
1284
|
+
legacy
|
|
1057
1285
|
}
|
|
1058
1286
|
}
|
|
1287
|
+
|
|
1288
|
+
export type QueryInvalidation<M> = {
|
|
1289
|
+
[K in keyof M]?: (defaultKey: string[], name: string) => {
|
|
1290
|
+
filters?: InvalidateQueryFilters | undefined
|
|
1291
|
+
options?: InvalidateOptions | undefined
|
|
1292
|
+
}[]
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
export type ToCamel<S extends string | number | symbol> = S extends string
|
|
1296
|
+
? S extends `${infer Head}_${infer Tail}` ? `${Uncapitalize<Head>}${Capitalize<ToCamel<Tail>>}`
|
|
1297
|
+
: Uncapitalize<S>
|
|
1298
|
+
: never
|
|
1299
|
+
|
|
1300
|
+
export interface CommandBase<I extends ReadonlyArray<any>, A = void> {
|
|
1301
|
+
handle: (...input: I) => A
|
|
1302
|
+
waiting: boolean
|
|
1303
|
+
action: string
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// export interface Command<I extends ReadonlyArray<any>> extends CommandBase<I, void> {}
|
|
1307
|
+
|
|
1308
|
+
export interface EffectCommand<I extends ReadonlyArray<any>, A = unknown, E = unknown>
|
|
1309
|
+
extends CommandBase<I, RuntimeFiber<A, E>>
|
|
1310
|
+
{}
|
|
1311
|
+
|
|
1312
|
+
export interface UnaryCommand<I, A = unknown, E = unknown> extends CommandBase<[I], RuntimeFiber<A, E>> {}
|
|
1313
|
+
|
|
1314
|
+
export interface CommandFromRequest<I extends abstract new(...args: any) => any, A = unknown, E = unknown>
|
|
1315
|
+
extends UnaryCommand<ConstructorParameters<I>[0], A, E>
|
|
1316
|
+
{}
|
package/test/dist/stubs.d.ts
CHANGED
|
@@ -9,36 +9,35 @@ export declare const useExperimental: (options?: {
|
|
|
9
9
|
messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
|
|
10
10
|
toasts: any[];
|
|
11
11
|
}) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
confirmOrInterrupt: (message?: string | undefined) => Effect.Effect<void, never, import("../src/experimental/confirm.js").Confirm | import("../src/experimental/intl.js").I18n | import("../src/experimental/commander.js").CommandContext>;
|
|
13
|
+
confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/confirm.js").Confirm | import("../src/experimental/intl.js").I18n | import("../src/experimental/commander.js").CommandContext>;
|
|
14
|
+
updateAction: <Args extends Array<unknown>>(update: (currentActionId: string, ...args: Args) => string) => <A, E, R_1>(_: Effect.Effect<A, E, R_1>, ...input: Args) => Effect.Effect<A, E, import("../src/experimental/commander.js").CommandContext | R_1>;
|
|
15
|
+
defaultFailureMessageHandler: <E_1, Args extends Array<unknown>, AME, AMR>(actionMaker: string | ((o: import("effect/Option").Option<E_1>, ...args: Args) => string) | ((o: import("effect/Option").Option<E_1>, ...args: Args) => Effect.Effect<string, AME, AMR>), errorRenderer?: (e: E_1, action: string, ...args: Args) => string | undefined) => (o: import("effect/Option").Option<E_1>, ...args: Args) => Effect.Effect<string | {
|
|
16
|
+
level: "warn";
|
|
17
|
+
message: string;
|
|
18
|
+
}, AME, import("../src/experimental/intl.js").I18n | AMR>;
|
|
19
|
+
renderError: Effect.Effect<(<E_1, Args_1 extends readonly any[]>(action: string, errorRenderer?: (e: E_1, action: string, ...args: Args_1) => string | undefined) => (e: E_1, ...args: Args_1) => string), never, import("../src/experimental/intl.js").I18n>;
|
|
20
|
+
withDefaultToast: <A, E_1, R_2, Args_2 extends Array<unknown>>(options?: {
|
|
21
|
+
errorRenderer?: (e: E_1, action: string, ...args: Args_2) => string | undefined;
|
|
22
|
+
onWaiting?: null | undefined | string | ((action: string, ...args: Args_2) => string | null | undefined);
|
|
23
|
+
onSuccess?: null | undefined | string | ((a: A, action: string, ...args: Args_2) => string | null | undefined);
|
|
24
|
+
}) => (self: Effect.Effect<A, E_1, R_2>, ...args: Args_2) => Effect.Effect<A, E_1, import("../src/experimental/intl.js").I18n | import("../src/experimental/withToast.js").WithToast | import("../src/experimental/commander.js").CommandContext | R_2>;
|
|
25
|
+
alt: <const Id extends string>(id: Id) => Commander.CommandContextLocal<Id> & (<Args_3 extends Array<unknown>, A, E_2, R_3 extends I18n | WithToast | Toast.Toast | import("../src/experimental/commander.js").CommandContext>(handler: (...args: Args_3) => Effect.Effect<A, E_2, R_3>) => Commander.CommandOut<Args_3, A, E_2, R_3, Id>);
|
|
26
|
+
fn: <const Id extends string>(id: Id) => Commander.Gen<I18n | WithToast | Toast.Toast, Id> & Commander.NonGen<I18n | WithToast | Toast.Toast, Id>;
|
|
27
|
+
wrap: <const Id extends string, Args_3 extends Array<unknown>, A_1, E_3, R_4>(mutation: (((...args: Args_3) => Effect.Effect<A_1, E_3, R_4>) & {
|
|
16
28
|
id: Id;
|
|
17
|
-
} |
|
|
29
|
+
}) | {
|
|
30
|
+
mutate: (...args: Args_3) => Effect.Effect<A_1, E_3, R_4>;
|
|
18
31
|
id: Id;
|
|
19
|
-
})
|
|
20
|
-
alt2: <const Id extends string, MutArgs extends Array<unknown>, MutA, MutE, MutR>(id: Id | {
|
|
32
|
+
}) => Commander.CommandContextLocal<Id> & Commander.GenWrap<I18n | WithToast | Toast.Toast, Id, Args_3, A_1, E_3, R_4> & Commander.NonGenWrap<I18n | WithToast | Toast.Toast, Id, Args_3, A_1, E_3, R_4>;
|
|
33
|
+
alt2: <const Id extends string, MutArgs extends Array<unknown>, MutA, MutE, MutR>(id: Id | (((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & {
|
|
21
34
|
id: Id;
|
|
22
|
-
|
|
23
|
-
} | (((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & {
|
|
35
|
+
}) | {
|
|
24
36
|
id: Id;
|
|
25
|
-
})) => Commander.CommandContextLocal<Id> & (<Args_1 extends Array<unknown>, A_2, E_2, R_3 extends Toast.Toast | WithToast | import("../src/experimental/commander.js").CommandContext>(handler: (ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id> & {
|
|
26
37
|
mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>;
|
|
27
|
-
}) => (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/commander.js").CommandContext>;
|
|
31
|
-
updateAction: <Args_1 extends Array<unknown>>(update: (currentActionId: string, ...args: Args_1) => string) => <A_4, E_4, R_5>(_: Effect.Effect<A_4, E_4, R_5>, ...input: Args_1) => Effect.Effect<A_4, E_4, import("../src/experimental/commander.js").CommandContext | R_5>;
|
|
32
|
-
defaultFailureMessageHandler: <E_5, Args_1 extends Array<unknown>, AME, AMR>(actionMaker: string | ((o: import("effect/Option").Option<E_5>, ...args: Args_1) => string) | ((o: import("effect/Option").Option<E_5>, ...args: Args_1) => Effect.Effect<string, AME, AMR>), errorRenderer?: ((e: E_5, action: string, ...args: Args_1) => string | undefined) | undefined) => (o: import("effect/Option").Option<E_5>, ...args: Args_1) => Effect.Effect<string | {
|
|
33
|
-
level: "warn";
|
|
34
|
-
message: string;
|
|
35
|
-
}, AME, AMR>;
|
|
36
|
-
renderError: <E_5, Args_2 extends readonly any[]>(action: string, errorRenderer?: ((e: E_5, action: string, ...args: Args_2) => string | undefined) | undefined) => (e: E_5, ...args: Args_2) => string;
|
|
37
|
-
withDefaultToast: <A_4, E_5, R_6, Args_3 extends Array<unknown>>(options?: {
|
|
38
|
-
errorRenderer?: (e: E_5, action: string, ...args: Args_3) => string | undefined;
|
|
39
|
-
onWaiting?: string | ((action: string, ...args: Args_3) => string | null | undefined) | null | undefined;
|
|
40
|
-
onSuccess?: string | ((a: A_4, action: string, ...args: Args_3) => string | null | undefined) | null | undefined;
|
|
41
|
-
} | undefined) => (self: Effect.Effect<A_4, E_5, R_6>, ...args: Args_3) => Effect.Effect<A_4, E_5, import("../src/experimental/commander.js").CommandContext | R_6>;
|
|
38
|
+
}) => Commander.CommandContextLocal<Id> & (<Args_4 extends Array<unknown>, A_2, E_4, R_5 extends I18n | WithToast | Toast.Toast | import("../src/experimental/commander.js").CommandContext>(handler: (ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id> & {
|
|
39
|
+
mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>;
|
|
40
|
+
}) => (...args: Args_4) => Effect.Effect<A_2, E_4, R_5>) => Commander.CommandOut<Args_4, A_2, E_4, R_5, Id>);
|
|
42
41
|
_tag: "Commander";
|
|
43
42
|
};
|
|
44
43
|
//# sourceMappingURL=stubs.d.ts.map
|
package/test/dist/stubs.d.ts.map
CHANGED
|
@@ -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
|
|
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;gCArEhG,CAAC;qBAIN,CAAC;kFAKL,GAAG,mEACmB,GAAI;+IAMV,GAAI,mEAGsB,GAAI,8DACV,CAAC,2BAA0B,GAAI,+EAGvD,GAAI;;;;kGAMJ,CAAC,2BAA2B,GAAG,iDAE7B,GAAI;0EAIR,CAAN;qBAAyB,CAAC,2BACN,GAAI;iBAGlB,CAAC,gDAGE,GAAG;iBAGV,CAAH,sDAKE,GAAI;6CAAyF,GAAI;;;;;;;;;;;;;;;;;;CA4BrG,CAAA"}
|
package/test/dist/stubs.js
CHANGED
|
@@ -63,7 +63,7 @@ export const useExperimental = (options) => {
|
|
|
63
63
|
const FakeToastLayer = fakeToastLayer(options?.toasts);
|
|
64
64
|
const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer]));
|
|
65
65
|
const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer));
|
|
66
|
-
const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer);
|
|
66
|
+
const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer, FakeIntlLayer);
|
|
67
67
|
return Effect.runSync(makeUseCommand().pipe(Effect.provide(layers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QTtJQUU1RixPQUFPLE1BQU0sQ0FBQyxPQUFPLENBQUMsY0FBYyxFQUFrQyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQTtBQUN0RyxDQUFDLENBQUEifQ==
|
package/test/stubs.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const useExperimental = (
|
|
|
76
76
|
const FakeToastLayer = fakeToastLayer(options?.toasts)
|
|
77
77
|
const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer]))
|
|
78
78
|
const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer))
|
|
79
|
-
const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer)
|
|
79
|
+
const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer, FakeIntlLayer)
|
|
80
80
|
|
|
81
|
-
return Effect.runSync(makeUseCommand<WithToast | Toast.Toast>().pipe(Effect.provide(layers)))
|
|
81
|
+
return Effect.runSync(makeUseCommand<WithToast | Toast.Toast | I18n>().pipe(Effect.provide(layers)))
|
|
82
82
|
}
|