@effect-app/vue 4.0.0-beta.120 → 4.0.0-beta.122
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 +16 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +2 -2
- package/dist/confirm.d.ts +2 -2
- package/dist/confirm.d.ts.map +1 -1
- package/dist/confirm.js +9 -13
- package/dist/errorReporter.d.ts +3 -3
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +12 -18
- package/dist/makeClient.d.ts +8 -11
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +4 -8
- package/dist/makeUseCommand.d.ts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +14 -16
- package/package.json +11 -11
- package/src/commander.ts +4 -5
- package/src/confirm.ts +8 -12
- package/src/errorReporter.ts +60 -72
- package/src/makeClient.ts +4 -19
- package/src/runtime.ts +15 -17
- package/test/dist/stubs.d.ts +7 -7
- package/test/makeClient.test.ts +1 -0
package/src/makeClient.ts
CHANGED
|
@@ -74,9 +74,6 @@ export interface MutationExtensions<RT, Id extends string, I, A, E, R> {
|
|
|
74
74
|
* The Mutation function will be taken as the first member of the Command, the Command required input will be the Mutation input.
|
|
75
75
|
* see Command.wrap for details */
|
|
76
76
|
wrap: Commander.CommanderWrap<RT, Id, Id, undefined, I, A, E, R>
|
|
77
|
-
/** Defines a Command based on this mutation, taking the `id` of the mutation as the `id` of the Command.
|
|
78
|
-
* see Command.fn for details */
|
|
79
|
-
fn: Commander.CommanderFn<RT, Id, Id, undefined>
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
/** my other doc */
|
|
@@ -87,7 +84,7 @@ export interface MutationExtWithInput<
|
|
|
87
84
|
A,
|
|
88
85
|
E,
|
|
89
86
|
R
|
|
90
|
-
> extends
|
|
87
|
+
> extends MutationExtensions<RT, Id, I, A, E, R> {
|
|
91
88
|
/**
|
|
92
89
|
* Call the endpoint with input
|
|
93
90
|
* Invalidate queries based on namespace of this mutation.
|
|
@@ -107,12 +104,7 @@ export interface MutationExt<
|
|
|
107
104
|
A,
|
|
108
105
|
E,
|
|
109
106
|
R
|
|
110
|
-
> extends
|
|
111
|
-
Commander.CommandContextLocal<Id, Id>,
|
|
112
|
-
Commander.CommanderWrap<RT, Id, Id, undefined, void, A, E, R>,
|
|
113
|
-
MutationExtensions<RT, Id, void, A, E, R>,
|
|
114
|
-
Effect.Effect<A, E, R>
|
|
115
|
-
{
|
|
107
|
+
> extends MutationExtensions<RT, Id, void, A, E, R>, Effect.Effect<A, E, R> {
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
export type MutationWithExtensions<RT, Req> = Req extends
|
|
@@ -444,13 +436,8 @@ export const makeClient = <RT_, RTHooks>(
|
|
|
444
436
|
const mutations = Struct.keys(client).reduce(
|
|
445
437
|
(acc, key) => {
|
|
446
438
|
const mut: any = mutation(client[key] as any)
|
|
447
|
-
const fn = Command.fn(client[key].id)
|
|
448
439
|
const wrap = Command.wrap({ mutate: Effect.isEffect(mut) ? () => mut : mut, id: client[key].id })
|
|
449
|
-
;(acc as any)[camelCase(key) + "Mutation"] = Object.assign(
|
|
450
|
-
mut,
|
|
451
|
-
fn, // to get the i18n key etc.
|
|
452
|
-
{ wrap, fn }
|
|
453
|
-
)
|
|
440
|
+
;(acc as any)[camelCase(key) + "Mutation"] = Object.assign(mut, { wrap })
|
|
454
441
|
return acc
|
|
455
442
|
},
|
|
456
443
|
{} as {
|
|
@@ -485,10 +472,8 @@ export const makeClient = <RT_, RTHooks>(
|
|
|
485
472
|
(mutate) =>
|
|
486
473
|
Object.assign(
|
|
487
474
|
mutate,
|
|
488
|
-
fn, // to get the i18n key etc.
|
|
489
475
|
{
|
|
490
|
-
wrap: Command.wrap({ mutate: Effect.isEffect(mutate) ? () => mutate : mutate, id: client[key].id })
|
|
491
|
-
fn
|
|
476
|
+
wrap: Command.wrap({ mutate: Effect.isEffect(mutate) ? () => mutate : mutate, id: client[key].id })
|
|
492
477
|
}
|
|
493
478
|
)
|
|
494
479
|
)
|
package/src/runtime.ts
CHANGED
|
@@ -3,24 +3,22 @@ import { Effect, Layer, Logger } from "effect-app"
|
|
|
3
3
|
import { CauseException } from "effect-app/client/errors"
|
|
4
4
|
import { type Context } from "effect-app/Context"
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
6
|
+
export const makeAppRuntime = Effect.fnUntraced(function*<A, E>(layer: Layer.Layer<A, E>) {
|
|
7
|
+
const l = layer.pipe(
|
|
8
|
+
Layer.provide(Logger.layer([Logger.consolePretty()]))
|
|
9
|
+
) as Layer.Layer<A, never>
|
|
10
|
+
const mrt = ManagedRuntime.make(l)
|
|
11
|
+
yield* mrt.contextEffect
|
|
12
|
+
return Object.assign(mrt, {
|
|
13
|
+
[Symbol.dispose]() {
|
|
14
|
+
return Effect.runSync(mrt.disposeEffect)
|
|
15
|
+
},
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
17
|
+
[Symbol.asyncDispose]() {
|
|
18
|
+
return mrt.dispose()
|
|
19
|
+
}
|
|
20
|
+
}) // as we initialise here, there is no more error left.
|
|
21
|
+
})
|
|
24
22
|
|
|
25
23
|
export function initializeSync<A, E>(layer: Layer.Layer<A, E, never>) {
|
|
26
24
|
const runtime = Effect.runSync(makeAppRuntime(layer))
|
package/test/dist/stubs.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const fakeIntlLayer: (messages?: Record<string, string> | Record<
|
|
|
12
12
|
export declare const useExperimental: (options?: {
|
|
13
13
|
messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
|
|
14
14
|
toasts: any[];
|
|
15
|
-
}) => import("../src/makeUseCommand.js").CommanderResolved<Toast.Toast |
|
|
15
|
+
}) => import("../src/makeUseCommand.js").CommanderResolved<I18n | Toast.Toast | WithToast, never>;
|
|
16
16
|
declare const RequestContextMap_base: (new () => {
|
|
17
17
|
readonly config: {};
|
|
18
18
|
}) & {
|
|
@@ -361,13 +361,13 @@ export declare const useClient: (options?: {
|
|
|
361
361
|
messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
|
|
362
362
|
toasts: any[];
|
|
363
363
|
}) => {
|
|
364
|
-
Command: import("../src/makeUseCommand.js").CommanderResolved<
|
|
365
|
-
useCommand: () => import("../src/makeUseCommand.js").CommanderResolved<
|
|
366
|
-
clientFor: <M extends import("effect-app/client").RequestsAny>(m: M, queryInvalidation?: ((client: import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>) => import("../src/makeClient.js").QueryInvalidation<M>) | undefined) => { [Key in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>]: import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key] & import("../src/makeClient.js").RequestWithExtensions<
|
|
367
|
-
mutate: import("../src/makeClient.js").MutationWithExtensions<
|
|
364
|
+
Command: import("../src/makeUseCommand.js").CommanderResolved<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, never>;
|
|
365
|
+
useCommand: () => import("../src/makeUseCommand.js").CommanderResolved<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, never>;
|
|
366
|
+
clientFor: <M extends import("effect-app/client").RequestsAny>(m: M, queryInvalidation?: ((client: import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>) => import("../src/makeClient.js").QueryInvalidation<M>) | undefined) => { [Key in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>]: import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key] & import("../src/makeClient.js").RequestWithExtensions<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key]> & {
|
|
367
|
+
mutate: import("../src/makeClient.js").MutationWithExtensions<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key]>;
|
|
368
368
|
Input: import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key] extends import("effect-app/client").RequestHandlerWithInput<infer I, any, any, any, any, any> ? I : never;
|
|
369
|
-
} & import("../src/makeClient.js").Queries<
|
|
370
|
-
helpers: { [Key_1 in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>> as `${import("../src/makeClient.js").ToCamel<string & Key_1>}Request`]: import("../src/makeClient.js").RequestWithExtensions<
|
|
369
|
+
} & import("../src/makeClient.js").Queries<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key]>; } & {
|
|
370
|
+
helpers: { [Key_1 in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>> as `${import("../src/makeClient.js").ToCamel<string & Key_1>}Request`]: import("../src/makeClient.js").RequestWithExtensions<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key_1]>; } & { [Key_2 in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>> as `${import("../src/makeClient.js").ToCamel<string & Key_2>}Mutation`]: import("../src/makeClient.js").MutationWithExtensions<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key_2]>; } & { [Key_3 in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>> as `${import("../src/makeClient.js").ToCamel<string & Key_3>}Query`]: import("../src/makeClient.js").Queries<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key_3]>["query"]; } & { [Key_4 in keyof import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>> as `${import("../src/makeClient.js").ToCamel<string & Key_4>}SuspenseQuery`]: import("../src/makeClient.js").Queries<(ApiClientFactory | Commander | (I18n | Toast.Toast)) | WithToast, import("effect-app/client").RequestHandlers<never, never, M, import("effect-app/client").ExtractModuleName<M>>[Key_4]>["suspense"]; };
|
|
371
371
|
};
|
|
372
372
|
};
|
|
373
373
|
export {};
|
package/test/makeClient.test.ts
CHANGED
|
@@ -87,6 +87,7 @@ it.skip("works", () => {
|
|
|
87
87
|
const f0 = client.GetSomething2WithDependencies.fn(null as any)
|
|
88
88
|
|
|
89
89
|
const g = client.GetSomething2.mutate.wrap(null as any)
|
|
90
|
+
// @ts-expect-error mutate no longer exposes fn, use client.GetSomething2.fn
|
|
90
91
|
const h = client.GetSomething2.mutate.fn(null as any)
|
|
91
92
|
|
|
92
93
|
expect(true).toBe(true)
|