@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.
Files changed (63) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/errorReporter.d.ts +2 -2
  3. package/dist/errorReporter.d.ts.map +1 -1
  4. package/dist/errorReporter.js +9 -9
  5. package/dist/experimental/commander.d.ts +46 -66
  6. package/dist/experimental/commander.d.ts.map +1 -1
  7. package/dist/experimental/commander.js +27 -29
  8. package/dist/experimental/confirm.d.ts +11 -5
  9. package/dist/experimental/confirm.d.ts.map +1 -1
  10. package/dist/experimental/confirm.js +19 -6
  11. package/dist/experimental/intl.d.ts +2 -21
  12. package/dist/experimental/intl.d.ts.map +1 -1
  13. package/dist/experimental/intl.js +4 -4
  14. package/dist/experimental/makeUseCommand.js +2 -2
  15. package/dist/experimental/toast.d.ts +3 -35
  16. package/dist/experimental/toast.d.ts.map +1 -1
  17. package/dist/experimental/toast.js +19 -5
  18. package/dist/experimental/withToast.d.ts +6 -4
  19. package/dist/experimental/withToast.d.ts.map +1 -1
  20. package/dist/experimental/withToast.js +10 -8
  21. package/dist/form.d.ts +2 -2
  22. package/dist/form.d.ts.map +1 -1
  23. package/dist/form.js +47 -47
  24. package/dist/lib.d.ts.map +1 -1
  25. package/dist/lib.js +11 -9
  26. package/dist/makeClient.d.ts +24 -21
  27. package/dist/makeClient.d.ts.map +1 -1
  28. package/dist/makeClient.js +28 -29
  29. package/dist/mutate.d.ts.map +1 -1
  30. package/dist/mutate.js +7 -7
  31. package/dist/query.d.ts +6 -4
  32. package/dist/query.d.ts.map +1 -1
  33. package/dist/query.js +26 -17
  34. package/dist/routeParams.d.ts +2 -4
  35. package/dist/routeParams.d.ts.map +1 -1
  36. package/dist/routeParams.js +3 -15
  37. package/dist/runtime.d.ts +1 -1
  38. package/dist/runtime.d.ts.map +1 -1
  39. package/dist/runtime.js +4 -4
  40. package/package.json +22 -22
  41. package/src/errorReporter.ts +11 -11
  42. package/src/experimental/commander.ts +81 -84
  43. package/src/experimental/confirm.ts +21 -6
  44. package/src/experimental/intl.ts +3 -3
  45. package/src/experimental/makeUseCommand.ts +1 -1
  46. package/src/experimental/toast.ts +23 -4
  47. package/src/experimental/withToast.ts +10 -7
  48. package/src/form.ts +56 -64
  49. package/src/lib.ts +10 -8
  50. package/src/makeClient.ts +61 -54
  51. package/src/mutate.ts +6 -7
  52. package/src/query.ts +28 -21
  53. package/src/routeParams.ts +9 -23
  54. package/src/runtime.ts +6 -6
  55. package/test/Mutation.test.ts +41 -42
  56. package/test/dist/form.test.d.ts.map +1 -1
  57. package/test/dist/stubs.d.ts +111 -53
  58. package/test/dist/stubs.d.ts.map +1 -1
  59. package/test/dist/stubs.js +8 -8
  60. package/test/form-validation-errors.test.ts +102 -43
  61. package/test/form.test.ts +7 -6
  62. package/test/stubs.ts +43 -41
  63. 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
- Toast.Toast.toLayer(Effect.sync(() => {
19
- const dismiss = (id: Toast.ToastId) => {
20
- const idx = toasts.findIndex((_) => _.id === id)
21
- if (idx > -1) {
22
- const toast = toasts[idx]
23
- clearTimeout(toast.timeoutId)
24
- toasts.splice(idx, 1)
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
- const fakeToast = (message: string, options?: Toast.ToastOpts) => {
28
- const id = options?.id ?? Math.random().toString(36).substring(2, 15)
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
- options = { ...options, id }
32
- const idx = toasts.findIndex((_) => _.id === id)
33
- if (idx > -1) {
34
- const toast = toasts[idx]
35
- clearTimeout(toast.timeoutId)
36
- Object.assign(toast, { message, options })
37
- toast.timeoutId = setTimeout(() => {
38
- toasts.splice(idx, 1)
39
- }, options?.timeout ?? 3000)
40
- } else {
41
- const toast: any = { id, message, options }
42
- toast.timeoutId = setTimeout(() => {
43
- toasts.splice(idx, 1)
44
- }, options?.timeout ?? 3000)
45
- toasts.push(toast)
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 id
48
- }
49
- return Toast.wrap({
50
- error: fakeToast,
51
- warning: fakeToast,
52
- success: fakeToast,
53
- info: fakeToast,
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.toLayer(
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
- success: S.NumberFromString as S.Schema<number, string, "dep-a">,
103
- failure: S.String as S.Schema<string, string, "dep-b">
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"