@effect-app/vue 2.93.8 → 4.0.0-beta.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 +22 -0
- package/dist/errorReporter.d.ts +2 -2
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +9 -9
- package/dist/experimental/commander.d.ts +46 -66
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +27 -29
- package/dist/experimental/confirm.d.ts +11 -5
- package/dist/experimental/confirm.d.ts.map +1 -1
- package/dist/experimental/confirm.js +19 -6
- package/dist/experimental/intl.d.ts +2 -21
- package/dist/experimental/intl.d.ts.map +1 -1
- package/dist/experimental/intl.js +4 -4
- package/dist/experimental/makeUseCommand.js +2 -2
- package/dist/experimental/toast.d.ts +3 -35
- package/dist/experimental/toast.d.ts.map +1 -1
- package/dist/experimental/toast.js +19 -5
- package/dist/experimental/withToast.d.ts +6 -4
- package/dist/experimental/withToast.d.ts.map +1 -1
- package/dist/experimental/withToast.js +10 -8
- package/dist/form.d.ts +2 -2
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +47 -47
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +11 -9
- package/dist/makeClient.d.ts +24 -21
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +28 -29
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +7 -7
- package/dist/query.d.ts +6 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +26 -17
- package/dist/routeParams.d.ts +2 -4
- package/dist/routeParams.d.ts.map +1 -1
- package/dist/routeParams.js +3 -15
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -4
- package/package.json +22 -22
- package/src/errorReporter.ts +11 -11
- package/src/experimental/commander.ts +81 -84
- package/src/experimental/confirm.ts +21 -6
- package/src/experimental/intl.ts +3 -3
- package/src/experimental/makeUseCommand.ts +1 -1
- package/src/experimental/toast.ts +23 -4
- package/src/experimental/withToast.ts +10 -7
- package/src/form.ts +56 -64
- package/src/lib.ts +10 -8
- package/src/makeClient.ts +61 -54
- package/src/mutate.ts +6 -7
- package/src/query.ts +28 -21
- package/src/routeParams.ts +9 -23
- package/src/runtime.ts +6 -6
- package/test/Mutation.test.ts +41 -42
- package/test/dist/form.test.d.ts.map +1 -1
- package/test/dist/stubs.d.ts +111 -53
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +8 -8
- package/test/form-validation-errors.test.ts +102 -43
- package/test/form.test.ts +7 -6
- package/test/stubs.ts +43 -41
- package/tsconfig.json +1 -25
package/test/stubs.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { FetchHttpClient } from "@effect/platform"
|
|
3
2
|
import { type MessageFormatElement } from "@formatjs/icu-messageformat-parser"
|
|
4
3
|
import * as Intl from "@formatjs/intl"
|
|
5
4
|
import { Effect, Layer, ManagedRuntime, Option, S } from "effect-app"
|
|
6
5
|
import { ApiClientFactory, makeRpcClient } from "effect-app/client"
|
|
7
6
|
import { RpcContextMap } from "effect-app/rpc"
|
|
7
|
+
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient"
|
|
8
8
|
import { ref } from "vue"
|
|
9
9
|
import { Commander } from "../src/experimental/commander.js"
|
|
10
10
|
import { I18n } from "../src/experimental/intl.js"
|
|
@@ -15,45 +15,48 @@ import { LegacyMutation, makeClient } from "../src/makeClient.js"
|
|
|
15
15
|
import { type MakeIntlReturn } from "../src/makeIntl.js"
|
|
16
16
|
|
|
17
17
|
const fakeToastLayer = (toasts: any[] = []) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
Layer.effect(
|
|
19
|
+
Toast.Toast,
|
|
20
|
+
Effect.sync(() => {
|
|
21
|
+
const dismiss = (id: Toast.ToastId) => {
|
|
22
|
+
const idx = toasts.findIndex((_) => _.id === id)
|
|
23
|
+
if (idx > -1) {
|
|
24
|
+
const toast = toasts[idx]
|
|
25
|
+
clearTimeout(toast.timeoutId)
|
|
26
|
+
toasts.splice(idx, 1)
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.log(`Toast [${id}]: ${message}`, options)
|
|
29
|
+
const fakeToast = (message: string, options?: Toast.ToastOpts) => {
|
|
30
|
+
const id = options?.id ?? Math.random().toString(36).substring(2, 15)
|
|
31
|
+
console.log(`Toast [${id}]: ${message}`, options)
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
options = { ...options, id }
|
|
34
|
+
const idx = toasts.findIndex((_) => _.id === id)
|
|
35
|
+
if (idx > -1) {
|
|
36
|
+
const toast = toasts[idx]
|
|
37
|
+
clearTimeout(toast.timeoutId)
|
|
38
|
+
Object.assign(toast, { message, options })
|
|
39
|
+
toast.timeoutId = setTimeout(() => {
|
|
40
|
+
toasts.splice(idx, 1)
|
|
41
|
+
}, options?.timeout ?? 3000)
|
|
42
|
+
} else {
|
|
43
|
+
const toast: any = { id, message, options }
|
|
44
|
+
toast.timeoutId = setTimeout(() => {
|
|
45
|
+
toasts.splice(idx, 1)
|
|
46
|
+
}, options?.timeout ?? 3000)
|
|
47
|
+
toasts.push(toast)
|
|
48
|
+
}
|
|
49
|
+
return id
|
|
46
50
|
}
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
dismiss
|
|
51
|
+
return Toast.Toast.of(Toast.wrap({
|
|
52
|
+
error: fakeToast,
|
|
53
|
+
warning: fakeToast,
|
|
54
|
+
success: fakeToast,
|
|
55
|
+
info: fakeToast,
|
|
56
|
+
dismiss
|
|
57
|
+
})) as any
|
|
55
58
|
})
|
|
56
|
-
|
|
59
|
+
)
|
|
57
60
|
|
|
58
61
|
export const makeFakeIntl = (messages: Record<string, string> | Record<string, MessageFormatElement[]> = {}) => {
|
|
59
62
|
const locale = ref("en" as const)
|
|
@@ -74,9 +77,7 @@ export const makeFakeIntl = (messages: Record<string, string> | Record<string, M
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
export const fakeIntlLayer = (messages: Record<string, string> | Record<string, MessageFormatElement[]> = {}) =>
|
|
77
|
-
I18n.
|
|
78
|
-
Effect.sync(() => makeFakeIntl(messages))
|
|
79
|
-
)
|
|
80
|
+
Layer.effect(I18n, Effect.sync(() => I18n.of(makeFakeIntl(messages))))
|
|
80
81
|
|
|
81
82
|
export const useExperimental = (
|
|
82
83
|
options?: { messages?: Record<string, string> | Record<string, MessageFormatElement[]>; toasts: any[] }
|
|
@@ -99,8 +100,9 @@ export class GetSomething2 extends Req<GetSomething2>()("GetSomething2", {
|
|
|
99
100
|
export class GetSomething2WithDependencies extends Req<GetSomething2WithDependencies>()("GetSomething2", {
|
|
100
101
|
id: S.String
|
|
101
102
|
}, {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
// this is intentilally fake, to simulate a codec that requires a dependency
|
|
104
|
+
success: S.NumberFromString as S.Codec<number, string, "dep-a">,
|
|
105
|
+
error: S.String
|
|
104
106
|
}) {}
|
|
105
107
|
|
|
106
108
|
export const Something = { GetSomething2, GetSomething2WithDependencies, meta: { moduleName: "Something" as const } }
|
package/tsconfig.json
CHANGED
|
@@ -14,31 +14,7 @@
|
|
|
14
14
|
"isolatedModules": true,
|
|
15
15
|
"esModuleInterop": true,
|
|
16
16
|
"skipLibCheck": true,
|
|
17
|
-
"plugins": [
|
|
18
|
-
{
|
|
19
|
-
"name": "ts-plugin-sort-import-suggestions",
|
|
20
|
-
"moveUpPatterns": [
|
|
21
|
-
"\\.{1,2}/",
|
|
22
|
-
"^(?:\\.\\./)+",
|
|
23
|
-
"^#",
|
|
24
|
-
"^@/",
|
|
25
|
-
"effect",
|
|
26
|
-
"^@effect/"
|
|
27
|
-
],
|
|
28
|
-
"moveDownPatterns": [
|
|
29
|
-
"^node_modules/"
|
|
30
|
-
],
|
|
31
|
-
"overrides": {
|
|
32
|
-
"effect-app": []
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"name": "@effect/language-service",
|
|
37
|
-
"diagnosticSeverity": {
|
|
38
|
-
"missingEffectServiceDependency": "error"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
],
|
|
17
|
+
"plugins": [],
|
|
42
18
|
"module": "Node16",
|
|
43
19
|
"lib": [
|
|
44
20
|
"ES2023"
|