@effect-app/vue 4.0.0-beta.53 → 4.0.0-beta.55
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 +15 -0
- package/dist/commander.d.ts +8 -8
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +7 -7
- package/dist/confirm.d.ts +2 -2
- package/dist/confirm.d.ts.map +1 -1
- package/dist/confirm.js +3 -3
- package/dist/intl.d.ts +2 -2
- package/dist/intl.d.ts.map +1 -1
- package/dist/intl.js +4 -4
- package/dist/makeClient.d.ts +6 -6
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +3 -3
- package/dist/query.d.ts +9 -13
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +8 -17
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/toast.d.ts +3 -3
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +5 -5
- package/dist/withToast.d.ts +2 -2
- package/dist/withToast.d.ts.map +1 -1
- package/dist/withToast.js +3 -3
- package/package.json +2 -2
- package/src/commander.ts +11 -11
- package/src/confirm.ts +2 -2
- package/src/intl.ts +3 -3
- package/src/makeClient.ts +5 -5
- package/src/query.ts +29 -37
- package/src/runtime.ts +7 -7
- package/src/toast.ts +4 -4
- package/src/withToast.ts +2 -2
package/dist/toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAU,MAAM,YAAY,CAAA;AAGpD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AACrC,MAAM,MAAM,SA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;;;;;AAI9B,qBAAa,KACX,SAAQ,UAAoG;CAE7G"}
|
package/dist/toast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Effect, Option
|
|
2
|
-
import { proxify } from "effect-app/
|
|
3
|
-
export class CurrentToastId extends
|
|
1
|
+
import { Context, Effect, Option } from "effect-app";
|
|
2
|
+
import { proxify } from "effect-app/Context";
|
|
3
|
+
export class CurrentToastId extends Context.Opaque()("CurrentToastId") {
|
|
4
4
|
}
|
|
5
5
|
/** fallback to CurrentToastId when available unless id is explicitly set to a value or null */
|
|
6
6
|
export const wrap = (toast) => {
|
|
@@ -22,7 +22,7 @@ export const wrap = (toast) => {
|
|
|
22
22
|
dismiss: (toastId) => Effect.sync(() => toast.dismiss(toastId))
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
export class Toast extends proxify(
|
|
25
|
+
export class Toast extends proxify(Context.Opaque()("Toast"))() {
|
|
26
26
|
}
|
|
27
27
|
// const a = Layer.effect(Toast, Effect.sync(() => Toast.of(null as any)))
|
|
28
28
|
// const A = Toast.of({
|
|
@@ -38,4 +38,4 @@ export class Toast extends proxify(ServiceMap.Opaque()("Toast"))() {
|
|
|
38
38
|
// const toast = yield* Toast
|
|
39
39
|
// toast.error("test")
|
|
40
40
|
// })
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdG9hc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sWUFBWSxDQUFBO0FBQ3BELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQTtBQWM1QyxNQUFNLE9BQU8sY0FBZSxTQUFRL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TztRQUNMLEtBQUssRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQztRQUN4QixJQUFJLEVBQUUsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUM7UUFDdEIsT0FBTyxFQUFFLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDO1FBQzVCLE9BQU8sRUFBRSxJQUFJLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQztRQUM1QixPQUFPLEVBQUUsQ0FBQyxPQUFnQixFQUFFLEVBQUUsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7S0FDekUsQ0FBQTtBQUNILENBQUMsQ0FBQTtBQUVELE1BQU0sT0FBTyxLQUNYLFNBQVEsT0FBTyxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQWtDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBa0M7Q0FFN0c7QUFFRCwwRUFBMEU7QUFFMUUsdUJBQXVCO0FBQ3ZCLDhDQUE4QztBQUM5Qyw2Q0FBNkM7QUFDN0MsZ0RBQWdEO0FBQ2hELGdEQUFnRDtBQUNoRCwrQ0FBK0M7QUFDL0MsS0FBSztBQUVMLCtCQUErQjtBQUUvQiwrQ0FBK0M7QUFFL0Msc0NBQXNDO0FBQ3RDLCtCQUErQjtBQUMvQix3QkFBd0I7QUFDeEIsS0FBSyJ9
|
package/dist/withToast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Layer, type Option
|
|
1
|
+
import { Context, Effect, Layer, type Option } from "effect-app";
|
|
2
2
|
import { Toast } from "./toast.js";
|
|
3
3
|
export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, SucR, ErrR> {
|
|
4
4
|
stableToastId?: undefined | string | ((...args: Args) => string | undefined);
|
|
@@ -13,7 +13,7 @@ export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, S
|
|
|
13
13
|
message: string;
|
|
14
14
|
}, never, ErrR>);
|
|
15
15
|
}
|
|
16
|
-
declare const WithToast_base:
|
|
16
|
+
declare const WithToast_base: Context.ServiceClass<WithToast, "WithToast", <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>) => (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR>> & {
|
|
17
17
|
readonly make: Effect.Effect<(<A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>) => (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR>), never, Toast>;
|
|
18
18
|
};
|
|
19
19
|
export declare class WithToast extends WithToast_base {
|
package/dist/withToast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withToast.d.ts","sourceRoot":"","sources":["../src/withToast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"withToast.d.ts","sourceRoot":"","sources":["../src/withToast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AAEvE,OAAO,EAAkB,KAAK,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACvF,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5E,OAA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C;mCAD7C,CAAC,EAAE,CAAC,EAAE,IAAI,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,UAAU,IAAI,UAAU,IAAI,mBACnE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;;AAJzD,qBAAa,SAAU,SAAQ,cAuD7B;IACA,MAAM,CAAC,QAAQ,CAAC,0BAA0B,uCAAgC;IAC1E,MAAM,CAAC,QAAQ,CAAC,OAAO,uCAAkC;IAEzD,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAI,CAAC,EAAE,CAAC,EAAE,IAAI,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,EACtG,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAClD,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,CACb;CAC/F"}
|
package/dist/withToast.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Cause, Effect, Layer
|
|
1
|
+
import { Cause, Context, Effect, Layer } from "effect-app";
|
|
2
2
|
import { wrapEffect } from "effect-app/utils";
|
|
3
3
|
import { CurrentToastId, Toast } from "./toast.js";
|
|
4
4
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
5
|
-
export class WithToast extends
|
|
5
|
+
export class WithToast extends Context.Service()("WithToast", {
|
|
6
6
|
make: Effect.gen(function* () {
|
|
7
7
|
const toast = yield* Toast;
|
|
8
8
|
return (options) => Effect.fnUntraced(function* (self, ...args) {
|
|
@@ -42,4 +42,4 @@ export class WithToast extends ServiceMap.Service()("WithToast", {
|
|
|
42
42
|
static Default = this.DefaultWithoutDependencies;
|
|
43
43
|
static handle = (options) => (self, ...args) => this.use((_) => _(options)(self, ...args));
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0aFRvYXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3dpdGhUb2FzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFlLE1BQU0sWUFBWSxDQUFBO0FBQ3ZFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQTtBQUM3QyxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssRUFBRSxNQUFNLFlBQVksQ0FBQTtBQWdDbEQsbUVBQW1FO0FBQ25FLE1BQU0sT0FBTyxTQUFVLFNBQVEsT0FBTyxDQUFDLE9BQU8sRUFBYSxDQUFDLFdBQVcsRUFBRTtJQUN2RSxJQUFJLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxRQUFRLENBQUM7UUFDeEIsTUFBTSxLQUFLLEdBQUcsS0FBSyxDQUFDLENBQUMsS0FBSyxDQUFBO1FBQzFCLE9BQU8sQ0FDTCxPQUFtRCxFQUNuRCxFQUFFLENBQ0YsTUFBTSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsRUFBQyxJQUE0QixFQUFFLEdBQUcsSUFBVTtZQUNyRSxNQUFNLFdBQVcsR0FBRyxPQUFPLENBQUMsT0FBTyxJQUFJLEtBQUssQ0FBQTtZQUU1QyxNQUFNLGFBQWEsR0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FPLEdBQUcsSUFBSSxDQUFDLDBCQUEwQixDQUFBO0lBRXpELE1BQU0sQ0FBVSxNQUFNLEdBQUcsQ0FDdkIsT0FBbUQsRUFDdUQsRUFBRSxDQUM5RyxDQUFDLElBQUksRUFBRSxHQUFHLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFrQyxPQUFPLENBQUMsQ0FBQyxJQUFJLEVBQUUsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.55",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/effect-ts-app/libs/tree/main/packages/vue",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@vueuse/core": "^14.2.1",
|
|
12
12
|
"change-case": "^5.4.4",
|
|
13
13
|
"query-string": "^9.3.1",
|
|
14
|
-
"effect-app": "4.0.0-beta.
|
|
14
|
+
"effect-app": "4.0.0-beta.55"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@effect/atom-vue": "^4.0.0-beta.43",
|
package/src/commander.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { asResult, type MissingDependencies, reportRuntimeError } from "@effect-app/vue"
|
|
3
3
|
import { reportMessage } from "@effect-app/vue/errorReporter"
|
|
4
|
-
import { Cause, Effect, type Exit, type Fiber, flow, Layer, Match, MutableHashMap, Option, Predicate, S
|
|
4
|
+
import { Cause, Context, Effect, type Exit, type Fiber, flow, Layer, Match, MutableHashMap, Option, Predicate, S } from "effect-app"
|
|
5
5
|
import { SupportedErrors } from "effect-app/client"
|
|
6
6
|
import { OperationFailure, OperationSuccess } from "effect-app/Operations"
|
|
7
7
|
import { isGeneratorFunction, wrapEffect } from "effect-app/utils"
|
|
@@ -66,7 +66,7 @@ export const DefaultIntl = {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export class CommandContext extends
|
|
69
|
+
export class CommandContext extends Context.Service<CommandContext, {
|
|
70
70
|
id: string
|
|
71
71
|
i18nKey: string
|
|
72
72
|
action: string
|
|
@@ -96,7 +96,7 @@ export declare namespace Commander {
|
|
|
96
96
|
& NonGen<RT, Id, I18nKey, State>
|
|
97
97
|
& CommandContextLocal<Id, I18nKey>
|
|
98
98
|
& {
|
|
99
|
-
state:
|
|
99
|
+
state: Context.Service<`Commander.Command.${Id}.state`, State>
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export type CommanderFn<RT, Id extends string, I18nKey extends string, State extends IntlRecord | undefined> =
|
|
@@ -116,7 +116,7 @@ export declare namespace Commander {
|
|
|
116
116
|
& GenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
|
|
117
117
|
& NonGenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
|
|
118
118
|
& {
|
|
119
|
-
state:
|
|
119
|
+
state: Context.Service<`Commander.Command.${Id}.state`, State>
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export interface CommandContextLocal<Id extends string, I18nKey extends string> {
|
|
@@ -1323,7 +1323,7 @@ const getStateValues = <const Id extends string, const I18nKey extends string, S
|
|
|
1323
1323
|
// class preserves JSDoc throughout..
|
|
1324
1324
|
export class CommanderImpl<RT, RTHooks> {
|
|
1325
1325
|
constructor(
|
|
1326
|
-
private readonly rt:
|
|
1326
|
+
private readonly rt: Context.Context<RT>,
|
|
1327
1327
|
private readonly intl: I18n,
|
|
1328
1328
|
private readonly hooks: Layer.Layer<RTHooks, never, RT>
|
|
1329
1329
|
) {
|
|
@@ -1385,7 +1385,7 @@ export class CommanderImpl<RT, RTHooks> {
|
|
|
1385
1385
|
}
|
|
1386
1386
|
|
|
1387
1387
|
const key = `Commander.Command.${id}.state` as const
|
|
1388
|
-
const stateTag =
|
|
1388
|
+
const stateTag = Context.Service<typeof key, State>(key)
|
|
1389
1389
|
|
|
1390
1390
|
const makeContext_ = () => this.makeContext(id, { ...options, state: state?.value })
|
|
1391
1391
|
const initialContext = makeContext_()
|
|
@@ -1654,7 +1654,7 @@ export class CommanderImpl<RT, RTHooks> {
|
|
|
1654
1654
|
id: Id | { id: Id },
|
|
1655
1655
|
options?: FnOptions<Id, I18nKey, State>
|
|
1656
1656
|
): Commander.Gen<RT | RTHooks, Id, I18nKey, State> & Commander.NonGen<RT | RTHooks, Id, I18nKey, State> & {
|
|
1657
|
-
state:
|
|
1657
|
+
state: Context.Service<`Commander.Command.${Id}.state`, State>
|
|
1658
1658
|
} =>
|
|
1659
1659
|
Object.assign(
|
|
1660
1660
|
(
|
|
@@ -1679,7 +1679,7 @@ export class CommanderImpl<RT, RTHooks> {
|
|
|
1679
1679
|
},
|
|
1680
1680
|
makeBaseInfo(typeof id === "string" ? id : id.id, options),
|
|
1681
1681
|
{
|
|
1682
|
-
state:
|
|
1682
|
+
state: Context.Service<`Commander.Command.${Id}.state`, State>(
|
|
1683
1683
|
`Commander.Command.${typeof id === "string" ? id : id.id}.state`
|
|
1684
1684
|
)
|
|
1685
1685
|
}
|
|
@@ -1814,7 +1814,7 @@ export class CommanderImpl<RT, RTHooks> {
|
|
|
1814
1814
|
},
|
|
1815
1815
|
makeBaseInfo(mutation.id, options),
|
|
1816
1816
|
{
|
|
1817
|
-
state:
|
|
1817
|
+
state: Context.Service<`Commander.Command.${Id}.state`, State>(
|
|
1818
1818
|
`Commander.Command.${mutation.id}.state`
|
|
1819
1819
|
)
|
|
1820
1820
|
}
|
|
@@ -1822,10 +1822,10 @@ export class CommanderImpl<RT, RTHooks> {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
|
|
1824
1824
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
1825
|
-
export class Commander extends
|
|
1825
|
+
export class Commander extends Context.Service<Commander>()("Commander", {
|
|
1826
1826
|
make: Effect.gen(function*() {
|
|
1827
1827
|
const i18n = yield* I18n
|
|
1828
|
-
return <RT, RTHooks>(rt:
|
|
1828
|
+
return <RT, RTHooks>(rt: Context.Context<RT>, rtHooks: Layer.Layer<RTHooks, never, RT>) =>
|
|
1829
1829
|
new CommanderImpl(rt, i18n, rtHooks)
|
|
1830
1830
|
})
|
|
1831
1831
|
}) {
|
package/src/confirm.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Effect, Layer
|
|
1
|
+
import { Context, Effect, Layer } from "effect-app"
|
|
2
2
|
import { I18n } from "./intl.js"
|
|
3
3
|
|
|
4
4
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
5
|
-
export class Confirm extends
|
|
5
|
+
export class Confirm extends Context.Service<Confirm>()("Confirm", {
|
|
6
6
|
make: Effect.gen(function*() {
|
|
7
7
|
const { intl } = yield* I18n
|
|
8
8
|
|
package/src/intl.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { proxify } from "effect-app/
|
|
1
|
+
import { Context } from "effect-app"
|
|
2
|
+
import { proxify } from "effect-app/Context"
|
|
3
3
|
import { type MakeIntlReturn } from "./makeIntl.js"
|
|
4
4
|
|
|
5
|
-
export class I18n extends proxify(
|
|
5
|
+
export class I18n extends proxify(Context.Opaque<I18n, ReturnType<MakeIntlReturn<string>["useIntl"]>>()("I18n"))<
|
|
6
6
|
I18n,
|
|
7
7
|
ReturnType<MakeIntlReturn<string>["useIntl"]>
|
|
8
8
|
>() {
|
package/src/makeClient.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { type InvalidateOptions, type InvalidateQueryFilters, isCancelledError, type QueryObserverResult, type RefetchOptions, type UseQueryReturnType } from "@tanstack/vue-query"
|
|
3
3
|
import { camelCase } from "change-case"
|
|
4
|
-
import { Cause, Data, Effect, Exit, Layer, type ManagedRuntime, Match, Option, S,
|
|
4
|
+
import { Cause, Context, Data, Effect, Exit, Layer, type ManagedRuntime, Match, Option, S, Struct } from "effect-app"
|
|
5
5
|
import { type ApiClientFactory, type Req } from "effect-app/client"
|
|
6
6
|
import type { RequestHandler, RequestHandlers, RequestHandlerWithInput, Requests } from "effect-app/client/clientFor"
|
|
7
7
|
import { ErrorSilenced, type SupportedErrors } from "effect-app/client/errors"
|
|
@@ -392,7 +392,7 @@ export const useMutationInt = (): typeof _useMutation => {
|
|
|
392
392
|
|
|
393
393
|
export class LegacyMutationImpl<RT> {
|
|
394
394
|
constructor(
|
|
395
|
-
private readonly getRuntime: () =>
|
|
395
|
+
private readonly getRuntime: () => Context.Context<RT>,
|
|
396
396
|
private readonly toast: Toast,
|
|
397
397
|
private readonly intl: I18n
|
|
398
398
|
) {}
|
|
@@ -1070,12 +1070,12 @@ export class LegacyMutationImpl<RT> {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
|
|
1072
1072
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
1073
|
-
export class LegacyMutation extends
|
|
1073
|
+
export class LegacyMutation extends Context.Service<LegacyMutation>()("LegacyMutation", {
|
|
1074
1074
|
make: Effect.gen(function*() {
|
|
1075
1075
|
const intl = yield* I18n
|
|
1076
1076
|
const toast = yield* Toast
|
|
1077
1077
|
|
|
1078
|
-
return <R>(getRuntime: () =>
|
|
1078
|
+
return <R>(getRuntime: () => Context.Context<R>) => new LegacyMutationImpl(getRuntime, toast, intl)
|
|
1079
1079
|
})
|
|
1080
1080
|
}) {
|
|
1081
1081
|
static readonly DefaultWithoutDependencies = Layer.effect(this, this.make)
|
|
@@ -1085,7 +1085,7 @@ export class LegacyMutation extends ServiceMap.Service<LegacyMutation>()("Legacy
|
|
|
1085
1085
|
export type ClientFrom<M extends Requests> = RequestHandlers<never, never, M, M["meta"]["moduleName"]>
|
|
1086
1086
|
|
|
1087
1087
|
export class QueryImpl<R> {
|
|
1088
|
-
constructor(readonly getRuntime: () =>
|
|
1088
|
+
constructor(readonly getRuntime: () => Context.Context<R>) {
|
|
1089
1089
|
this.useQuery = makeQuery(this.getRuntime)
|
|
1090
1090
|
}
|
|
1091
1091
|
/**
|
package/src/query.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
5
|
import { type DefaultError, type Enabled, type InitialDataFunction, type NonUndefinedGuard, type PlaceholderDataFunction, type QueryKey, type QueryObserverOptions, type QueryObserverResult, type RefetchOptions, useQuery as useTanstackQuery, useQueryClient, type UseQueryDefinedReturnType, type UseQueryReturnType } from "@tanstack/vue-query"
|
|
6
|
-
import { Array, Cause, Effect, Option, S
|
|
6
|
+
import { Array, Cause, type Context, Effect, Option, S } from "effect-app"
|
|
7
7
|
import { type Req } from "effect-app/client"
|
|
8
8
|
import type { RequestHandler, RequestHandlerWithInput } from "effect-app/client/clientFor"
|
|
9
|
-
import { ServiceUnavailableError } from "effect-app/client/errors"
|
|
9
|
+
import { CauseException, ServiceUnavailableError } from "effect-app/client/errors"
|
|
10
10
|
import { type Span } from "effect/Tracer"
|
|
11
11
|
import { isHttpClientError } from "effect/unstable/http/HttpClientError"
|
|
12
12
|
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
|
|
@@ -75,15 +75,7 @@ export interface CustomDefinedPlaceholderQueryOptions<
|
|
|
75
75
|
| PlaceholderDataFunction<NonFunctionGuard<TQueryData>, TError, NonFunctionGuard<TQueryData>, TQueryKey>
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export
|
|
79
|
-
readonly error: unknown
|
|
80
|
-
constructor(public effectCause: Cause.Cause<E>) {
|
|
81
|
-
super("Query failed with cause: " + Cause.squash(effectCause))
|
|
82
|
-
this.error = Cause.squash(effectCause)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
78
|
+
export const makeQuery = <R>(getRuntime: () => Context.Context<R>) => {
|
|
87
79
|
const useQuery_: {
|
|
88
80
|
<I, A, E, Request extends Req, Name extends string>(
|
|
89
81
|
q:
|
|
@@ -96,8 +88,8 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
96
88
|
): readonly [
|
|
97
89
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
98
90
|
ComputedRef<TData | undefined>,
|
|
99
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
100
|
-
UseQueryDefinedReturnType<TData,
|
|
91
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>, never, never>,
|
|
92
|
+
UseQueryDefinedReturnType<TData, CauseException<E>>
|
|
101
93
|
]
|
|
102
94
|
|
|
103
95
|
<TData = A>(
|
|
@@ -106,8 +98,8 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
106
98
|
): readonly [
|
|
107
99
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
108
100
|
ComputedRef<TData>,
|
|
109
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
110
|
-
UseQueryDefinedReturnType<TData,
|
|
101
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>, never, never>,
|
|
102
|
+
UseQueryDefinedReturnType<TData, CauseException<E>>
|
|
111
103
|
]
|
|
112
104
|
|
|
113
105
|
<TData = A>(
|
|
@@ -116,8 +108,8 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
116
108
|
): readonly [
|
|
117
109
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
118
110
|
ComputedRef<TData>,
|
|
119
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
120
|
-
UseQueryDefinedReturnType<TData,
|
|
111
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>, never, never>,
|
|
112
|
+
UseQueryDefinedReturnType<TData, CauseException<E>>
|
|
121
113
|
]
|
|
122
114
|
}
|
|
123
115
|
} = <I, A, E, Request extends Req, Name extends string>(
|
|
@@ -131,7 +123,7 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
131
123
|
options?: any
|
|
132
124
|
// TODO
|
|
133
125
|
) => {
|
|
134
|
-
// we wrap into
|
|
126
|
+
// we wrap into CauseException because we want to keep the full cause of the failure.
|
|
135
127
|
const runPromise = makeRunPromise(getRuntime())
|
|
136
128
|
const arr = arg
|
|
137
129
|
const req: { value: I } = !arg
|
|
@@ -156,14 +148,14 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
156
148
|
throwOnError: false
|
|
157
149
|
}
|
|
158
150
|
|
|
159
|
-
const r = useTanstackQuery<A,
|
|
151
|
+
const r = useTanstackQuery<A, CauseException<E>, TData>(
|
|
160
152
|
Effect.isEffect(handler)
|
|
161
153
|
? {
|
|
162
154
|
...defaultOptions,
|
|
163
155
|
...options,
|
|
164
156
|
retry: (retryCount, error) => {
|
|
165
|
-
if (error instanceof
|
|
166
|
-
if (!isHttpClientError(error.
|
|
157
|
+
if (error instanceof CauseException) {
|
|
158
|
+
if (!isHttpClientError(error.cause) && !S.is(ServiceUnavailableError)(error.cause)) {
|
|
167
159
|
return false
|
|
168
160
|
}
|
|
169
161
|
}
|
|
@@ -186,8 +178,8 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
186
178
|
...defaultOptions,
|
|
187
179
|
...options,
|
|
188
180
|
retry: (retryCount, error) => {
|
|
189
|
-
if (error instanceof
|
|
190
|
-
if (!isHttpClientError(error.
|
|
181
|
+
if (error instanceof CauseException) {
|
|
182
|
+
if (!isHttpClientError(error.cause) && !S.is(ServiceUnavailableError)(error.cause)) {
|
|
191
183
|
return false
|
|
192
184
|
}
|
|
193
185
|
}
|
|
@@ -235,13 +227,13 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
235
227
|
}
|
|
236
228
|
|
|
237
229
|
function swrToQuery<E, A>(r: {
|
|
238
|
-
error:
|
|
230
|
+
error: CauseException<E> | undefined
|
|
239
231
|
data: A | undefined
|
|
240
232
|
isValidating: boolean
|
|
241
233
|
}): AsyncResult.AsyncResult<A, E> {
|
|
242
234
|
if (r.error !== undefined) {
|
|
243
235
|
return AsyncResult.failureWithPrevious(
|
|
244
|
-
r.error.
|
|
236
|
+
r.error.originalCause,
|
|
245
237
|
{
|
|
246
238
|
previous: r.data === undefined ? Option.none() : Option.some(AsyncResult.success(r.data)),
|
|
247
239
|
waiting: r.isValidating
|
|
@@ -268,11 +260,11 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
268
260
|
* Effect results are passed to the caller, including errors.
|
|
269
261
|
*/
|
|
270
262
|
<TData = A>(
|
|
271
|
-
options: CustomDefinedInitialQueryOptions<A,
|
|
263
|
+
options: CustomDefinedInitialQueryOptions<A, CauseException<E>, TData>
|
|
272
264
|
): readonly [
|
|
273
265
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
274
266
|
ComputedRef<TData>,
|
|
275
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
267
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>>,
|
|
276
268
|
UseQueryReturnType<any, any>
|
|
277
269
|
]
|
|
278
270
|
<TData = A>(
|
|
@@ -280,17 +272,17 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
280
272
|
): readonly [
|
|
281
273
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
282
274
|
ComputedRef<TData>,
|
|
283
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
284
|
-
UseQueryDefinedReturnType<TData,
|
|
275
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>, never, never>,
|
|
276
|
+
UseQueryDefinedReturnType<TData, CauseException<E>>
|
|
285
277
|
]
|
|
286
278
|
// optional options, optional A
|
|
287
279
|
/**
|
|
288
280
|
* Effect results are passed to the caller, including errors.
|
|
289
281
|
*/
|
|
290
|
-
<TData = A>(options?: CustomUndefinedInitialQueryOptions<A,
|
|
282
|
+
<TData = A>(options?: CustomUndefinedInitialQueryOptions<A, CauseException<E>, TData>): readonly [
|
|
291
283
|
ComputedRef<AsyncResult.AsyncResult<A, E>>,
|
|
292
284
|
ComputedRef<A | undefined>,
|
|
293
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
285
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>>,
|
|
294
286
|
UseQueryReturnType<any, any>
|
|
295
287
|
]
|
|
296
288
|
}
|
|
@@ -307,11 +299,11 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
307
299
|
*/
|
|
308
300
|
<TData = A>(
|
|
309
301
|
arg: Arg | WatchSource<Arg>,
|
|
310
|
-
options: CustomDefinedInitialQueryOptions<A,
|
|
302
|
+
options: CustomDefinedInitialQueryOptions<A, CauseException<E>, TData>
|
|
311
303
|
): readonly [
|
|
312
304
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
313
305
|
ComputedRef<TData>,
|
|
314
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
306
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>>,
|
|
315
307
|
UseQueryReturnType<any, any>
|
|
316
308
|
]
|
|
317
309
|
// required options, with placeholderData
|
|
@@ -320,11 +312,11 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
320
312
|
*/
|
|
321
313
|
<TData = A>(
|
|
322
314
|
arg: Arg | WatchSource<Arg>,
|
|
323
|
-
options: CustomDefinedPlaceholderQueryOptions<A,
|
|
315
|
+
options: CustomDefinedPlaceholderQueryOptions<A, CauseException<E>, TData>
|
|
324
316
|
): readonly [
|
|
325
317
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
326
318
|
ComputedRef<TData>,
|
|
327
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
319
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>>,
|
|
328
320
|
UseQueryReturnType<any, any>
|
|
329
321
|
]
|
|
330
322
|
// optional options, optional A
|
|
@@ -333,11 +325,11 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
333
325
|
*/
|
|
334
326
|
<TData = A>(
|
|
335
327
|
arg: Arg | WatchSource<Arg>,
|
|
336
|
-
options?: CustomUndefinedInitialQueryOptions<A,
|
|
328
|
+
options?: CustomUndefinedInitialQueryOptions<A, CauseException<E>, TData>
|
|
337
329
|
): readonly [
|
|
338
330
|
ComputedRef<AsyncResult.AsyncResult<TData, E>>,
|
|
339
331
|
ComputedRef<TData | undefined>,
|
|
340
|
-
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData,
|
|
332
|
+
(options?: RefetchOptions) => Effect.Effect<QueryObserverResult<TData, CauseException<E>>>,
|
|
341
333
|
UseQueryReturnType<any, any>
|
|
342
334
|
]
|
|
343
335
|
}
|
package/src/runtime.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Exit, flow, ManagedRuntime } from "effect"
|
|
2
2
|
import { Effect, Layer, Logger } from "effect-app"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CauseException } from "effect-app/client/errors"
|
|
4
|
+
import { type Context } from "effect-app/Context"
|
|
5
5
|
|
|
6
6
|
export function makeAppRuntime<A, E>(layer: Layer.Layer<A, E>) {
|
|
7
7
|
return Effect.gen(function*() {
|
|
@@ -32,22 +32,22 @@ export function initializeAsync<A, E>(layer: Layer.Layer<A, E, never>) {
|
|
|
32
32
|
.runPromise(makeAppRuntime(layer))
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// we wrap into
|
|
36
|
-
export const makeRunPromise = <T>(services:
|
|
35
|
+
// we wrap into CauseException because we want to keep the full cause of the failure.
|
|
36
|
+
export const makeRunPromise = <T>(services: Context<T>) =>
|
|
37
37
|
flow(Effect.runPromiseExitWith(services), (_) =>
|
|
38
38
|
_.then(
|
|
39
39
|
Exit.match({
|
|
40
|
-
onFailure: (cause) => Promise.reject(new
|
|
40
|
+
onFailure: (cause) => Promise.reject(new CauseException(cause, "runPromise")),
|
|
41
41
|
onSuccess: (value) => Promise.resolve(value)
|
|
42
42
|
})
|
|
43
43
|
))
|
|
44
44
|
|
|
45
|
-
export const makeRunSync = <T>(services:
|
|
45
|
+
export const makeRunSync = <T>(services: Context<T>) =>
|
|
46
46
|
flow(
|
|
47
47
|
Effect.runSyncExitWith(services),
|
|
48
48
|
Exit.match({
|
|
49
49
|
onFailure: (cause) => {
|
|
50
|
-
throw new
|
|
50
|
+
throw new CauseException(cause, "runSync")
|
|
51
51
|
},
|
|
52
52
|
onSuccess: (value) => value
|
|
53
53
|
})
|
package/src/toast.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Effect, Option
|
|
2
|
-
import { proxify } from "effect-app/
|
|
1
|
+
import { Context, Effect, Option } from "effect-app"
|
|
2
|
+
import { proxify } from "effect-app/Context"
|
|
3
3
|
|
|
4
4
|
export type ToastId = string | number
|
|
5
5
|
export type ToastOpts = { id?: ToastId; timeout?: number }
|
|
@@ -13,7 +13,7 @@ export type UseToast = () => {
|
|
|
13
13
|
dismiss: (this: void, id: ToastId) => void
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class CurrentToastId extends
|
|
16
|
+
export class CurrentToastId extends Context.Opaque<CurrentToastId, { toastId: ToastId }>()("CurrentToastId") {}
|
|
17
17
|
|
|
18
18
|
/** fallback to CurrentToastId when available unless id is explicitly set to a value or null */
|
|
19
19
|
export const wrap = (toast: ReturnType<UseToast>) => {
|
|
@@ -42,7 +42,7 @@ export const wrap = (toast: ReturnType<UseToast>) => {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export class Toast
|
|
45
|
-
extends proxify(
|
|
45
|
+
extends proxify(Context.Opaque<Toast, ReturnType<typeof wrap>>()("Toast"))<Toast, ReturnType<typeof wrap>>()
|
|
46
46
|
{
|
|
47
47
|
}
|
|
48
48
|
|
package/src/withToast.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Effect, Layer, type Option
|
|
1
|
+
import { Cause, Context, Effect, Layer, type Option } from "effect-app"
|
|
2
2
|
import { wrapEffect } from "effect-app/utils"
|
|
3
3
|
import { CurrentToastId, Toast } from "./toast.js"
|
|
4
4
|
|
|
@@ -33,7 +33,7 @@ export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, S
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// @effect-diagnostics-next-line missingEffectServiceDependency:off
|
|
36
|
-
export class WithToast extends
|
|
36
|
+
export class WithToast extends Context.Service<WithToast>()("WithToast", {
|
|
37
37
|
make: Effect.gen(function*() {
|
|
38
38
|
const toast = yield* Toast
|
|
39
39
|
return <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(
|