@effect-app/vue 2.71.0 → 2.72.1

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/src/makeClient.ts CHANGED
@@ -837,6 +837,8 @@ export class LegacyMutation extends Effect.Service<LegacyMutation>()("LegacyMuta
837
837
  })
838
838
  }) {}
839
839
 
840
+ export type ClientFrom<M extends Requests> = RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
841
+
840
842
  const mkQuery = <R>(getRuntime: () => Runtime.Runtime<R>) => {
841
843
  // making sure names do not collide with auto exports in nuxt apps, please do not rename..
842
844
  /**
@@ -1065,7 +1067,7 @@ export const makeClient = <RT, RE, RL>(
1065
1067
  // - reduce duplication for Types
1066
1068
 
1067
1069
  const mapQuery = <M extends Requests>(
1068
- client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
1070
+ client: ClientFrom<M>
1069
1071
  ) => {
1070
1072
  const queries = Struct.keys(client).reduce(
1071
1073
  (acc, key) => {
@@ -1100,7 +1102,7 @@ export const makeClient = <RT, RE, RL>(
1100
1102
  }
1101
1103
 
1102
1104
  const mapMutation = <M extends Requests>(
1103
- client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
1105
+ client: ClientFrom<M>
1104
1106
  ) => {
1105
1107
  const Command = useCommand()
1106
1108
  const wrap = Command.wrap
@@ -1123,24 +1125,24 @@ export const makeClient = <RT, RE, RL>(
1123
1125
  & ReturnType<typeof useMutation<I, E, A, R, Request, Id>>
1124
1126
  & (typeof client[Key] extends
1125
1127
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1126
- ? Commander.CommandContextLocal<Id>
1128
+ ? Commander.CommandContextLocal<Id, Id>
1127
1129
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1128
- ? Commander.CommandContextLocal<Id>
1130
+ ? Commander.CommandContextLocal<Id, Id>
1129
1131
  : never)
1130
1132
  : typeof client[Key] extends RequestHandler<infer A, infer E, infer R, infer Request, infer Id> ?
1131
1133
  & ReturnType<typeof useMutation<E, A, R, Request, Id>>
1132
1134
  & (typeof client[Key] extends
1133
1135
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1134
- ? Commander.CommandContextLocal<Id>
1136
+ ? Commander.CommandContextLocal<Id, Id>
1135
1137
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1136
- ? Commander.CommandContextLocal<Id>
1138
+ ? Commander.CommandContextLocal<Id, Id>
1137
1139
  : never)
1138
1140
  : never)
1139
1141
  & (typeof client[Key] extends
1140
1142
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1141
- ? Commander.CommandContextLocal<Id>
1143
+ ? Commander.CommandContextLocal<Id, Id>
1142
1144
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1143
- ? Commander.CommandContextLocal<Id>
1145
+ ? Commander.CommandContextLocal<Id, Id>
1144
1146
  : never)
1145
1147
  & (typeof client[Key] extends
1146
1148
  RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id>
@@ -1151,15 +1153,15 @@ export const makeClient = <RT, RE, RL>(
1151
1153
  & {
1152
1154
  wrap: typeof client[Key] extends
1153
1155
  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>
1156
+ ? ReturnType<typeof wrap<Id, [I], A, E, never, Id>> & Commander.CommandContextLocal<Id, Id>
1155
1157
  : 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>
1158
+ ? ReturnType<typeof wrap<Id, [], A, E, never, Id>> & Commander.CommandContextLocal<Id, Id>
1157
1159
  : never
1158
1160
  fn: typeof client[Key] extends
1159
1161
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1160
- ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
1162
+ ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id, Id>
1161
1163
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1162
- ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
1164
+ ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id, Id>
1163
1165
  : never
1164
1166
  }
1165
1167
  }
@@ -1170,14 +1172,15 @@ export const makeClient = <RT, RE, RL>(
1170
1172
  // make available .query, .suspense and .mutate for each operation
1171
1173
  // and a .helpers with all mutations and queries
1172
1174
  const mapClient = <M extends Requests>(
1173
- queryInvalidation?: QueryInvalidation<M>
1175
+ queryInvalidation?: (client: ClientFrom<M>) => QueryInvalidation<M>
1174
1176
  ) =>
1175
1177
  (
1176
- client: RequestHandlers<never, never, Omit<M, "meta">, M["meta"]["moduleName"]>
1178
+ client: ClientFrom<M>
1177
1179
  ) => {
1178
1180
  const Command = useCommand()
1179
1181
  const wrap = Command.wrap
1180
1182
  const fn_ = Command.fn
1183
+ const invalidation = queryInvalidation?.(client)
1181
1184
  const extended = Struct.keys(client).reduce(
1182
1185
  (acc, key) => {
1183
1186
  const fn = fn_(client[key].id)
@@ -1189,7 +1192,7 @@ export const makeClient = <RT, RE, RL>(
1189
1192
  }
1190
1193
  const mutate = useMutation(
1191
1194
  client[key] as any,
1192
- queryInvalidation?.[key] ? { queryInvalidation: queryInvalidation[key] } : undefined
1195
+ invalidation?.[key] ? { queryInvalidation: invalidation[key] } : undefined
1193
1196
  )
1194
1197
  ;(acc as any)[key] = Object.assign(mutate, { wrap: wrap({ mutate, id: awesome.id }), fn }, awesome, fn)
1195
1198
  return acc
@@ -1198,15 +1201,15 @@ export const makeClient = <RT, RE, RL>(
1198
1201
  [Key in keyof typeof client]:
1199
1202
  & (typeof client[Key] extends
1200
1203
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1201
- ? Commander.CommandContextLocal<Id>
1204
+ ? Commander.CommandContextLocal<Id, Id>
1202
1205
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1203
- ? Commander.CommandContextLocal<Id>
1206
+ ? Commander.CommandContextLocal<Id, Id>
1204
1207
  : never)
1205
1208
  & (typeof client[Key] extends
1206
1209
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1207
- ? Commander.CommandContextLocal<Id>
1210
+ ? Commander.CommandContextLocal<Id, Id>
1208
1211
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1209
- ? Commander.CommandContextLocal<Id>
1212
+ ? Commander.CommandContextLocal<Id, Id>
1210
1213
  : never)
1211
1214
  & (typeof client[Key] extends
1212
1215
  RequestHandlerWithInput<infer I, infer A, infer E, infer R, infer Request, infer Id>
@@ -1217,15 +1220,15 @@ export const makeClient = <RT, RE, RL>(
1217
1220
  & {
1218
1221
  wrap: typeof client[Key] extends
1219
1222
  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>
1223
+ ? ReturnType<typeof wrap<Id, [I], A, E, never, Id>> & Commander.CommandContextLocal<Id, Id>
1221
1224
  : 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>
1225
+ ? ReturnType<typeof wrap<Id, [], A, E, never, Id>> & Commander.CommandContextLocal<Id, Id>
1223
1226
  : never
1224
1227
  fn: typeof client[Key] extends
1225
1228
  RequestHandlerWithInput<infer _I, infer _A, infer _E, infer _R, infer _Request, infer Id>
1226
- ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
1229
+ ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id, Id>
1227
1230
  : typeof client[Key] extends RequestHandler<infer _A, infer _E, infer _R, infer _Request, infer Id>
1228
- ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id>
1231
+ ? ReturnType<typeof fn_<Id>> & Commander.CommandContextLocal<Id, Id>
1229
1232
  : never
1230
1233
  }
1231
1234
  & typeof client[Key]
@@ -1258,7 +1261,7 @@ export const makeClient = <RT, RE, RL>(
1258
1261
  // todo; invalidateQueries should perhaps be configured in the Request impl themselves?
1259
1262
  const clientFor = <M extends Requests>(
1260
1263
  m: M,
1261
- queryInvalidation?: QueryInvalidation<M>
1264
+ queryInvalidation?: (client: ClientFrom<M>) => QueryInvalidation<M>
1262
1265
  ) => getBaseMrt().runSync(clientFor_(m).pipe(Effect.map(mapClient(queryInvalidation))))
1263
1266
 
1264
1267
  const legacy = {
@@ -9,8 +9,8 @@ export declare const useExperimental: (options?: {
9
9
  messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
10
10
  toasts: any[];
11
11
  }) => {
12
- confirmOrInterrupt: (message?: string | undefined) => Effect.Effect<void, never, import("../src/experimental/intl.js").I18n | import("../src/experimental/confirm.js").Confirm | import("../src/experimental/commander.js").CommandContext>;
13
- confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/intl.js").I18n | import("../src/experimental/confirm.js").Confirm | import("../src/experimental/commander.js").CommandContext>;
12
+ confirmOrInterrupt: (message?: string | undefined) => Effect.Effect<void, never, import("../src/experimental/commander.js").CommandContext | import("../src/experimental/intl.js").I18n | import("../src/experimental/confirm.js").Confirm>;
13
+ confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/commander.js").CommandContext | import("../src/experimental/intl.js").I18n | import("../src/experimental/confirm.js").Confirm>;
14
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
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
16
  level: "warn";
@@ -21,23 +21,23 @@ export declare const useExperimental: (options?: {
21
21
  errorRenderer?: (e: E_1, action: string, ...args: Args_2) => string | undefined;
22
22
  onWaiting?: null | undefined | string | ((action: string, ...args: Args_2) => string | null | undefined);
23
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, customI18nKey?: string) => 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, const I18nKey extends string = Id>(id: Id, customI18nKey?: I18nKey | undefined) => 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>) & {
24
+ }) => (self: Effect.Effect<A, E_1, R_2>, ...args: Args_2) => Effect.Effect<A, E_1, import("../src/experimental/commander.js").CommandContext | import("../src/experimental/intl.js").I18n | R_2 | import("../src/experimental/withToast.js").WithToast>;
25
+ alt: <const Id extends string, const I18nKey extends string = Id>(id: Id, customI18nKey?: I18nKey | undefined) => Commander.CommandContextLocal<Id, I18nKey> & (<Args_3 extends Array<unknown>, A, E_2, R_3 extends Toast.Toast | I18n | WithToast | 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, I18nKey>);
26
+ fn: <const Id extends string, const I18nKey_1 extends string = Id>(id: Id, customI18nKey?: I18nKey_1 | undefined) => Commander.Gen<Toast.Toast | I18n | WithToast, Id, I18nKey_1> & Commander.NonGen<Toast.Toast | I18n | WithToast, Id, I18nKey_1>;
27
+ wrap: <const Id extends string, Args_3 extends Array<unknown>, A_1, E_3, R_4, I18nKey_2 extends string = Id>(mutation: (((...args: Args_3) => Effect.Effect<A_1, E_3, R_4>) & {
28
28
  id: Id;
29
29
  }) | {
30
30
  mutate: (...args: Args_3) => Effect.Effect<A_1, E_3, R_4>;
31
31
  id: Id;
32
- }, customI18nKey?: string) => 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>) & {
32
+ }, customI18nKey?: I18nKey_2 | undefined) => Commander.CommandContextLocal<Id, I18nKey_2> & Commander.GenWrap<Toast.Toast | I18n | WithToast, Id, I18nKey_2, Args_3, A_1, E_3, R_4> & Commander.NonGenWrap<Toast.Toast | I18n | WithToast, Id, I18nKey_2, Args_3, A_1, E_3, R_4>;
33
+ alt2: <const Id extends string, MutArgs extends Array<unknown>, MutA, MutE, MutR, const I18nKey_3 extends string = Id>(id: Id | (((...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>) & {
34
34
  id: Id;
35
35
  }) | {
36
36
  id: Id;
37
37
  mutate: (...args: MutArgs) => Effect.Effect<MutA, MutE, MutR>;
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> & {
38
+ }, customI18nKey?: I18nKey_3 | undefined) => Commander.CommandContextLocal<Id, I18nKey_3> & (<Args_4 extends Array<unknown>, A_2, E_4, R_5 extends Toast.Toast | I18n | WithToast | import("../src/experimental/commander.js").CommandContext>(handler: (ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id, I18nKey_3> & {
39
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>);
40
+ }) => (...args: Args_4) => Effect.Effect<A_2, E_4, R_5>) => Commander.CommandOut<Args_4, A_2, E_4, R_5, Id, I18nKey_3>);
41
41
  _tag: "Commander";
42
42
  };
43
43
  //# sourceMappingURL=stubs.d.ts.map