@effect-app/vue 4.0.0-beta.22 → 4.0.0-beta.221

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 (106) hide show
  1. package/CHANGELOG.md +1613 -0
  2. package/dist/commander.d.ts +634 -0
  3. package/dist/commander.d.ts.map +1 -0
  4. package/dist/commander.js +1070 -0
  5. package/dist/confirm.d.ts +21 -0
  6. package/dist/confirm.d.ts.map +1 -0
  7. package/dist/confirm.js +26 -0
  8. package/dist/errorReporter.d.ts +7 -5
  9. package/dist/errorReporter.d.ts.map +1 -1
  10. package/dist/errorReporter.js +14 -19
  11. package/dist/form.d.ts +15 -6
  12. package/dist/form.d.ts.map +1 -1
  13. package/dist/form.js +46 -13
  14. package/dist/index.d.ts +1 -1
  15. package/dist/intl.d.ts +15 -0
  16. package/dist/intl.d.ts.map +1 -0
  17. package/dist/intl.js +9 -0
  18. package/dist/lib.d.ts +8 -10
  19. package/dist/lib.d.ts.map +1 -1
  20. package/dist/lib.js +35 -10
  21. package/dist/makeClient.d.ts +156 -339
  22. package/dist/makeClient.d.ts.map +1 -1
  23. package/dist/makeClient.js +225 -376
  24. package/dist/makeContext.d.ts +1 -1
  25. package/dist/makeContext.d.ts.map +1 -1
  26. package/dist/makeIntl.d.ts +1 -1
  27. package/dist/makeIntl.d.ts.map +1 -1
  28. package/dist/makeUseCommand.d.ts +9 -0
  29. package/dist/makeUseCommand.d.ts.map +1 -0
  30. package/dist/makeUseCommand.js +13 -0
  31. package/dist/mutate.d.ts +54 -34
  32. package/dist/mutate.d.ts.map +1 -1
  33. package/dist/mutate.js +139 -46
  34. package/dist/query.d.ts +20 -39
  35. package/dist/query.d.ts.map +1 -1
  36. package/dist/query.js +133 -72
  37. package/dist/routeParams.d.ts +3 -2
  38. package/dist/routeParams.d.ts.map +1 -1
  39. package/dist/routeParams.js +4 -3
  40. package/dist/runtime.d.ts +10 -6
  41. package/dist/runtime.d.ts.map +1 -1
  42. package/dist/runtime.js +32 -18
  43. package/dist/toast.d.ts +51 -0
  44. package/dist/toast.d.ts.map +1 -0
  45. package/dist/toast.js +34 -0
  46. package/dist/withToast.d.ts +30 -0
  47. package/dist/withToast.d.ts.map +1 -0
  48. package/dist/withToast.js +64 -0
  49. package/examples/streamMutation.ts +72 -0
  50. package/package.json +48 -50
  51. package/src/commander.ts +3406 -0
  52. package/src/{experimental/confirm.ts → confirm.ts} +12 -14
  53. package/src/errorReporter.ts +65 -75
  54. package/src/form.ts +61 -18
  55. package/src/intl.ts +12 -0
  56. package/src/lib.ts +48 -20
  57. package/src/makeClient.ts +574 -1134
  58. package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +8 -5
  59. package/src/mutate.ts +268 -127
  60. package/src/query.ts +203 -183
  61. package/src/routeParams.ts +3 -2
  62. package/src/runtime.ts +46 -21
  63. package/src/{experimental/toast.ts → toast.ts} +15 -27
  64. package/src/{experimental/withToast.ts → withToast.ts} +46 -12
  65. package/test/Mutation.test.ts +181 -24
  66. package/test/dist/form.test.d.ts.map +1 -1
  67. package/test/dist/lib.test.d.ts.map +1 -0
  68. package/test/dist/streamFinal.test.d.ts.map +1 -0
  69. package/test/dist/streamFn.test.d.ts.map +1 -0
  70. package/test/dist/stubs.d.ts +3531 -122
  71. package/test/dist/stubs.d.ts.map +1 -1
  72. package/test/dist/stubs.js +187 -32
  73. package/test/form-validation-errors.test.ts +25 -20
  74. package/test/form.test.ts +22 -3
  75. package/test/lib.test.ts +240 -0
  76. package/test/makeClient.test.ts +292 -38
  77. package/test/streamFinal.test.ts +64 -0
  78. package/test/streamFn.test.ts +457 -0
  79. package/test/stubs.ts +223 -43
  80. package/tsconfig.examples.json +20 -0
  81. package/tsconfig.json +0 -1
  82. package/tsconfig.json.bak +5 -2
  83. package/tsconfig.src.json +34 -34
  84. package/tsconfig.test.json +2 -2
  85. package/vitest.config.ts +5 -5
  86. package/dist/experimental/commander.d.ts +0 -359
  87. package/dist/experimental/commander.d.ts.map +0 -1
  88. package/dist/experimental/commander.js +0 -557
  89. package/dist/experimental/confirm.d.ts +0 -19
  90. package/dist/experimental/confirm.d.ts.map +0 -1
  91. package/dist/experimental/confirm.js +0 -28
  92. package/dist/experimental/intl.d.ts +0 -16
  93. package/dist/experimental/intl.d.ts.map +0 -1
  94. package/dist/experimental/intl.js +0 -5
  95. package/dist/experimental/makeUseCommand.d.ts +0 -8
  96. package/dist/experimental/makeUseCommand.d.ts.map +0 -1
  97. package/dist/experimental/makeUseCommand.js +0 -13
  98. package/dist/experimental/toast.d.ts +0 -47
  99. package/dist/experimental/toast.d.ts.map +0 -1
  100. package/dist/experimental/toast.js +0 -41
  101. package/dist/experimental/withToast.d.ts +0 -25
  102. package/dist/experimental/withToast.d.ts.map +0 -1
  103. package/dist/experimental/withToast.js +0 -45
  104. package/eslint.config.mjs +0 -24
  105. package/src/experimental/commander.ts +0 -1835
  106. package/src/experimental/intl.ts +0 -9
@@ -1,8 +1,10 @@
1
- import { Effect, Layer, ServiceMap } from "effect-app"
1
+ import * as Context from "effect-app/Context"
2
+ import * as Effect from "effect-app/Effect"
3
+ import * as Layer from "effect-app/Layer"
2
4
  import { I18n } from "./intl.js"
3
5
 
4
6
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
5
- export class Confirm extends ServiceMap.Service<Confirm>()("Confirm", {
7
+ export class Confirm extends Context.Service<Confirm>()("Confirm", {
6
8
  make: Effect.gen(function*() {
7
9
  const { intl } = yield* I18n
8
10
 
@@ -21,16 +23,12 @@ export class Confirm extends ServiceMap.Service<Confirm>()("Confirm", {
21
23
  static readonly DefaultWithoutDependencies = Layer.effect(this, this.make)
22
24
  static readonly Default = this.DefaultWithoutDependencies
23
25
 
24
- static confirm(message?: string) {
25
- return Effect.gen(function*() {
26
- const c = yield* Confirm
27
- return yield* c.confirm(message)
28
- })
29
- }
30
- static confirmOrInterrupt(message?: string) {
31
- return Effect.gen(function*() {
32
- const c = yield* Confirm
33
- return yield* c.confirmOrInterrupt(message)
34
- })
35
- }
26
+ static readonly confirm = Effect.fnUntraced(function*(message?: string) {
27
+ const c = yield* Confirm
28
+ return yield* c.confirm(message)
29
+ })
30
+ static readonly confirmOrInterrupt = Effect.fnUntraced(function*(message?: string) {
31
+ const c = yield* Confirm
32
+ return yield* c.confirmOrInterrupt(message)
33
+ })
36
34
  }
@@ -1,9 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
3
3
  import * as Sentry from "@sentry/browser"
4
- import { Cause, Effect, type LogLevel } from "effect-app"
5
4
  import { CauseException, tryToJson, tryToReport } from "effect-app/client/errors"
5
+ import * as Effect from "effect-app/Effect"
6
6
  import { dropUndefined, LogLevelToSentry } from "effect-app/utils"
7
+ import * as Cause from "effect/Cause"
8
+ import type * as LogLevel from "effect/LogLevel"
7
9
 
8
10
  export const tryCauseException = <E>(cause: Cause.Cause<E>, name: string): CauseException<E> => {
9
11
  try {
@@ -13,45 +15,41 @@ export const tryCauseException = <E>(cause: Cause.Cause<E>, name: string): Cause
13
15
  }
14
16
  }
15
17
 
16
- export function reportError(
17
- name: string
18
- ) {
19
- return (
20
- cause: Cause.Cause<unknown>,
21
- extras?: Record<string, unknown>,
22
- level: LogLevel.Severity = "Error"
23
- ): Effect.Effect<unknown, never, never> =>
24
- Effect
25
- .gen(function*() {
26
- if (Cause.hasInterruptsOnly(cause)) {
27
- yield* Effect.logDebug("Interrupted").pipe(Effect.annotateLogs("extras", JSON.stringify(extras ?? {})))
28
- return Cause.squash(cause)
29
- }
30
-
31
- const error = tryCauseException(cause, name)
32
- yield* reportSentry(error, extras, LogLevelToSentry(level))
33
- yield* Effect
34
- .logWithLevel(level)("Reporting error", cause)
35
- .pipe(
36
- Effect.annotateLogs(dropUndefined({
37
- extras,
38
- error: tryToReport(error),
39
- cause: tryToJson(cause),
40
- __error_name__: name
41
- })),
42
- Effect.catchCause((cause) => Effect.logWarning("Failed to log error", cause)),
43
- Effect.catchCause(() => Effect.logFatal("Failed to log error cause"))
44
- )
18
+ export function reportError(name: string) {
19
+ return Effect.fnUntraced(
20
+ function*(
21
+ cause: Cause.Cause<unknown>,
22
+ extras?: Record<string, unknown>,
23
+ level: LogLevel.Severity = "Error"
24
+ ) {
25
+ if (Cause.hasInterruptsOnly(cause)) {
26
+ yield* Effect.logDebug("Interrupted").pipe(Effect.annotateLogs("extras", JSON.stringify(extras ?? {})))
27
+ return Cause.squash(cause)
28
+ }
45
29
 
46
- return error
47
- })
48
- .pipe(
49
- Effect.tapCause((cause) =>
50
- Effect.logError("Failed to report error", cause).pipe(
51
- Effect.tapCause(() => Effect.logFatal("Failed to log error cause"))
52
- )
30
+ const error = tryCauseException(cause, name)
31
+ yield* reportSentry(error, extras, LogLevelToSentry(level))
32
+ yield* Effect
33
+ .logWithLevel(level)("Reporting error", cause)
34
+ .pipe(
35
+ Effect.annotateLogs(dropUndefined({
36
+ extras,
37
+ error: tryToReport(error),
38
+ cause: tryToJson(cause),
39
+ __error_name__: name
40
+ })),
41
+ Effect.catchCause((cause) => Effect.logWarning("Failed to log error", cause)),
42
+ Effect.catchCause(() => Effect.logFatal("Failed to log error cause"))
53
43
  )
54
- )
44
+
45
+ return error
46
+ },
47
+ (effect) =>
48
+ Effect.tapCause(effect, (cause) =>
49
+ Effect.logError("Failed to report error", cause).pipe(
50
+ Effect.tapCause(() => Effect.logFatal("Failed to log error cause"))
51
+ ))
52
+ )
55
53
  }
56
54
 
57
55
  function reportSentry(
@@ -63,39 +61,33 @@ function reportSentry(
63
61
  const scope = new Sentry.Scope()
64
62
  scope.setLevel(level)
65
63
  if (extras) scope.setContext("extras", extras)
66
- scope.setContext("error", tryToReport(error) as any)
67
- scope.setContext("cause", tryToJson(error.originalCause) as any)
64
+ scope.setContext("error", tryToReport(error))
65
+ scope.setContext("cause", tryToJson(error.originalCause))
68
66
  Sentry.captureException(error, scope)
69
67
  })
70
68
  }
71
69
 
72
- export function logError<E>(
73
- name: string
74
- ) {
75
- return (cause: Cause.Cause<E>, extras?: Record<string, unknown>) =>
76
- Effect
77
- .gen(function*() {
78
- if (Cause.hasInterruptsOnly(cause)) {
79
- yield* Effect.logDebug("Interrupted").pipe(Effect.annotateLogs(dropUndefined({ extras })))
80
- return
81
- }
82
- yield* Effect
83
- .logWarning("Logging error", cause)
84
- .pipe(
85
- Effect.annotateLogs(dropUndefined({
86
- extras,
87
- cause: tryToJson(cause),
88
- __error_name__: name
89
- }))
90
- )
91
- })
92
- .pipe(
93
- Effect.tapCause((cause) =>
94
- Effect.logError("Failed to log error", cause).pipe(
95
- Effect.tapCause(() => Effect.logFatal("Failed to log error cause"))
96
- )
97
- )
98
- )
70
+ export function logError<E>(name: string) {
71
+ return Effect.fnUntraced(
72
+ function*(cause: Cause.Cause<E>, extras?: Record<string, unknown>) {
73
+ if (Cause.hasInterruptsOnly(cause)) {
74
+ yield* Effect.logDebug("Interrupted").pipe(Effect.annotateLogs(dropUndefined({ extras })))
75
+ return
76
+ }
77
+ yield* Effect
78
+ .logWarning("Logging error", cause)
79
+ .pipe(Effect.annotateLogs(dropUndefined({
80
+ extras,
81
+ cause: tryToJson(cause),
82
+ __error_name__: name
83
+ })))
84
+ },
85
+ (effect) =>
86
+ Effect.tapCause(effect, (cause) =>
87
+ Effect.logError("Failed to log error", cause).pipe(
88
+ Effect.tapCause(() => Effect.logFatal("Failed to log error cause"))
89
+ ))
90
+ )
99
91
  }
100
92
 
101
93
  export function captureException(error: unknown, extras?: Record<string, unknown>) {
@@ -105,12 +97,10 @@ export function captureException(error: unknown, extras?: Record<string, unknown
105
97
  console.error(error, extras)
106
98
  }
107
99
 
108
- export function reportMessage(message: string, extras?: Record<string, unknown>) {
109
- return Effect.gen(function*() {
110
- const scope = new Sentry.Scope()
111
- if (extras) scope.setContext("extras", extras)
112
- Sentry.captureMessage(message, scope)
100
+ export const reportMessage = Effect.fnUntraced(function*(message: string, extras?: Record<string, unknown>) {
101
+ const scope = new Sentry.Scope()
102
+ if (extras) scope.setContext("extras", extras)
103
+ Sentry.captureMessage(message, scope)
113
104
 
114
- console.warn(message, extras)
115
- })
116
- }
105
+ console.warn(message, extras)
106
+ })
package/src/form.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { createIntl, type IntlFormatters } from "@formatjs/intl"
2
- import type {} from "intl-messageformat"
3
- import { Cause, Exit, Option, pipe, S } from "effect-app"
2
+
3
+ import * as Option from "effect-app/Option"
4
+ import * as S from "effect-app/Schema"
4
5
  import type { Unbranded } from "effect-app/Schema/brand"
5
6
  import type { IsUnion } from "effect-app/utils"
7
+ import * as Cause from "effect/Cause"
8
+ import * as Exit from "effect/Exit"
9
+ import { pipe } from "effect/Function"
6
10
  import { capitalize, ref } from "vue"
7
11
 
8
12
  // type GetSchemaFromProp<T> = T extends Field<infer S, any, any, any> ? S
@@ -22,7 +26,8 @@ function getObjectsAST(ast: S.AST.AST): S.AST.Objects | null {
22
26
  return null
23
27
  }
24
28
 
25
- export function convertIn(v: string | null, type?: "text" | "float" | "int") {
29
+ /** @deprecated Use OmegaForm instead */
30
+ export function convertIn(v: number | string | null, type?: "text" | "float" | "int") {
26
31
  return v === null ? "" : type === "text" ? v : `${v}`
27
32
  }
28
33
 
@@ -30,8 +35,10 @@ export function convertIn(v: string | null, type?: "text" | "float" | "int") {
30
35
  * Makes sure our international number format is converted to js int/float format.
31
36
  * Right now assumes . for thousands and , for decimal.
32
37
  */
38
+ /** @deprecated Use OmegaForm instead */
33
39
  export const prepareNumberForLocale = (v: string) => v.replace(/\./g, "").replace(/,/g, ".")
34
40
 
41
+ /** @deprecated Use OmegaForm instead */
35
42
  export function convertOutInt(v: string, type?: "text" | "float" | "int") {
36
43
  v = v == null ? v : v.trim()
37
44
  const c = v === ""
@@ -49,6 +56,7 @@ export function convertOutInt(v: string, type?: "text" | "float" | "int") {
49
56
  return c
50
57
  }
51
58
 
59
+ /** @deprecated Use OmegaForm instead */
52
60
  export function convertOut(v: string, set: (v: {} | null) => void, type?: "text" | "float" | "int") {
53
61
  return set(convertOutInt(v, type))
54
62
  }
@@ -72,7 +80,8 @@ export interface DiscriminatedUnionFieldInfo<T> {
72
80
  }
73
81
 
74
82
  export type NestedFieldInfoKey<Key> = [Key] extends [Record<PropertyKey, any>]
75
- ? Unbranded<Key> extends Record<PropertyKey, any> ? NestedFieldInfo<Key>
83
+ ? Unbranded<Key> extends (string | number | boolean | bigint | symbol) ? FieldInfo<Key>
84
+ : Unbranded<Key> extends Record<PropertyKey, any> ? NestedFieldInfo<Key>
76
85
  : FieldInfo<Key>
77
86
  : FieldInfo<Key>
78
87
 
@@ -143,10 +152,18 @@ function handlePropertySignature(
143
152
  const typeLiteral = getObjectsAST(ps.type)
144
153
 
145
154
  const tagPropertySignature = typeLiteral?.propertySignatures.find((_) => _.name === "_tag")
146
- const tagLiteral = tagPropertySignature
147
- && S.AST.isLiteral(tagPropertySignature.type)
148
- && typeof tagPropertySignature.type.literal === "string"
149
- ? tagPropertySignature.type.literal
155
+ // unwrap single-element Union to Literal (S.Struct({ _tag: S.Literal("x") }) wraps as Union([Literal("x")]))
156
+ const tagType = tagPropertySignature
157
+ ? S.AST.isUnion(tagPropertySignature.type)
158
+ && tagPropertySignature.type.types.length === 1
159
+ && S.AST.isLiteral(tagPropertySignature.type.types[0]!)
160
+ ? tagPropertySignature.type.types[0]
161
+ : tagPropertySignature.type
162
+ : undefined
163
+ const tagLiteral = tagType
164
+ && S.AST.isLiteral(tagType)
165
+ && typeof tagType.literal === "string"
166
+ ? tagType.literal
150
167
  : void 0
151
168
 
152
169
  const toRet = handlePropertySignature(ps)
@@ -189,6 +206,7 @@ function handlePropertySignature(
189
206
  }
190
207
  }
191
208
 
209
+ /** @deprecated Use OmegaForm instead */
192
210
  export function buildFieldInfoFromFields<
193
211
  From extends Record<PropertyKey, any>,
194
212
  To extends Record<PropertyKey, any>
@@ -198,6 +216,7 @@ export function buildFieldInfoFromFields<
198
216
  return buildFieldInfoFromFieldsRoot(schema).fields
199
217
  }
200
218
 
219
+ /** @deprecated Use OmegaForm instead */
201
220
  export function buildFieldInfoFromFieldsRoot<
202
221
  From extends Record<PropertyKey, any>,
203
222
  To extends Record<PropertyKey, any>,
@@ -235,7 +254,9 @@ abstract class PhantomTypeParameter<
235
254
 
236
255
  const defaultIntl = createIntl({ locale: "en" })
237
256
 
257
+ /** @deprecated Use OmegaForm instead */
238
258
  export const translate = ref<IntlFormatters["formatMessage"]>(defaultIntl.formatMessage)
259
+ /** @deprecated Use OmegaForm instead */
239
260
  export const customSchemaErrors = ref<Map<S.AST.AST | string, (message: string, e: unknown, v: unknown) => string>>(
240
261
  new Map()
241
262
  )
@@ -246,12 +267,12 @@ function buildFieldInfo(
246
267
  const propertyKey = property.name
247
268
  const schema = S.make<S.Codec<unknown>>(property.type)
248
269
  const metadata = getMetadataFromSchema(property.type)
249
- const parse = S.decodeUnknownExit(schema as S.Codec<unknown> & { readonly DecodingServices: never })
270
+ const parse = S.decodeUnknownExit(schema)
250
271
 
251
272
  const nullableOrUndefined = S.AST.isUnion(property.type)
252
273
  && (property.type.types.includes(S.Null.ast) || property.type.types.some((_) => _._tag === "Undefined"))
253
274
  const realSelf = nullableOrUndefined && S.AST.isUnion(property.type)
254
- ? property.type.types.filter((_) => _ !== S.Null.ast && _._tag !== "Undefined")[0]!
275
+ ? property.type.types.find((_) => _ !== S.Null.ast && _._tag !== "Undefined")!
255
276
  : property.type
256
277
  const id = S.AST.resolveIdentifier(property.type)
257
278
  const id2 = S.AST.resolveIdentifier(realSelf)
@@ -269,7 +290,7 @@ function buildFieldInfo(
269
290
  }
270
291
 
271
292
  // parse specific error types for better translation support
272
- const integerMatch = err.match(/Expected.*integer.*actual\s+(.+)/i)
293
+ const integerMatch = err.match(/Expected.*integer.*(?:actual|got)\s+([^)]+)/i)
273
294
  if (integerMatch) {
274
295
  return translate.value(
275
296
  { defaultMessage: "Expected an integer, actual {actualValue}", id: "validation.integer.expected" },
@@ -277,7 +298,7 @@ function buildFieldInfo(
277
298
  )
278
299
  }
279
300
 
280
- const numberMatch = err.match(/Expected.*number.*actual\s+(.+)/i)
301
+ const numberMatch = err.match(/Expected.*number.*(?:actual|got)\s+([^)]+)/i)
281
302
  if (numberMatch) {
282
303
  return translate.value(
283
304
  { defaultMessage: "Expected a number, actual {actualValue}", id: "validation.number.expected" },
@@ -368,7 +389,7 @@ function buildFieldInfo(
368
389
  : metadata.type === "float" || metadata.type === "int"
369
390
  ? numberRules
370
391
  : []) as UnknownRule[],
371
- parseRule as UnknownRule
392
+ parseRule
372
393
  ]
373
394
 
374
395
  const info = {
@@ -398,6 +419,7 @@ function buildFieldInfo(
398
419
  return info as any
399
420
  }
400
421
 
422
+ /** @deprecated Use OmegaForm instead */
401
423
  export function getMetadataFromSchema(
402
424
  ast: S.AST.AST
403
425
  ): {
@@ -411,22 +433,43 @@ export function getMetadataFromSchema(
411
433
  required: boolean
412
434
  description?: string
413
435
  } {
436
+ const findJsonSchemaType = (
437
+ schema: any,
438
+ target: "number" | "integer"
439
+ ): boolean => {
440
+ if (!schema || typeof schema !== "object") {
441
+ return false
442
+ }
443
+
444
+ if (schema.type === target) {
445
+ return true
446
+ }
447
+
448
+ if (Array.isArray(schema.type) && schema.type.includes(target)) {
449
+ return true
450
+ }
451
+
452
+ return ["anyOf", "oneOf", "allOf"].some((key) =>
453
+ Array.isArray(schema[key]) && schema[key].some((member: any) => findJsonSchemaType(member, target))
454
+ )
455
+ }
456
+
414
457
  const nullable = S.AST.isUnion(ast) && ast.types.includes(S.Null.ast)
415
458
  const realSelf = nullable && S.AST.isUnion(ast)
416
- ? ast.types.filter((_) => _ !== S.Null.ast)[0]!
459
+ ? ast.types.find((_) => _ !== S.Null.ast)!
417
460
  : ast
418
461
 
419
462
  let jschema: any
420
463
  try {
421
464
  const doc = S.toJsonSchemaDocument(S.make<S.Codec<unknown>>(realSelf))
422
465
  jschema = doc.schema as any
423
- const defs = doc.definitions as Record<string, any>
466
+ const defs = doc.definitions
424
467
  // resolve $ref against definitions
425
468
  while (jschema["$ref"] && jschema["$ref"].startsWith("#/$defs/")) {
426
469
  const { $ref: _, ...rest } = jschema
427
470
  jschema = { ...defs[jschema["$ref"].replace("#/$defs/", "")], ...rest }
428
471
  }
429
- } catch (_err) {
472
+ } catch {
430
473
  jschema = {}
431
474
  }
432
475
  // or we need to add these info directly in the refinement like the minimum
@@ -440,8 +483,8 @@ export function getMetadataFromSchema(
440
483
  // "title": "Int"
441
484
  // }
442
485
  // }
443
- const isNumber = jschema.type === "number" || jschema.type === "integer"
444
- const isInt = jschema.type === "integer"
486
+ const isInt = findJsonSchemaType(jschema, "integer")
487
+ const isNumber = isInt || findJsonSchemaType(jschema, "number")
445
488
  return {
446
489
  type: isInt ? "int" as const : isNumber ? "float" as const : "text" as const,
447
490
  minimum: jschema.minimum,
package/src/intl.ts ADDED
@@ -0,0 +1,12 @@
1
+ import * as Context from "effect-app/Context"
2
+ import { accessCn, accessFn } from "effect-app/Context"
3
+ import { type MakeIntlReturn } from "./makeIntl.js"
4
+
5
+ type I18nShape = ReturnType<MakeIntlReturn<string>["useIntl"]>
6
+
7
+ export class I18n extends Context.Opaque<I18n, I18nShape>()("I18n") {
8
+ static readonly locale = accessCn(this, "locale")
9
+ static readonly trans = accessFn(this, "trans")
10
+ static readonly formatMessage = accessFn(this, "formatMessage")
11
+ static readonly intl = accessCn(this, "intl")
12
+ }
package/src/lib.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { type Pausable, useIntervalFn, type UseIntervalFnOptions } from "@vueuse/core"
2
- import { Cause, type Effect, pipe } from "effect-app"
3
- import { type Req } from "effect-app/client"
4
- import type { ClientForOptions, RequestHandler, RequestHandlerWithInput } from "effect-app/client/clientFor"
2
+ import type { Req } from "effect-app/client"
3
+ import type { RequestHandlerWithInput } from "effect-app/client/clientFor"
4
+ import type * as Effect from "effect-app/Effect"
5
+ import * as Cause from "effect/Cause"
5
6
  import { isHttpClientError } from "effect/unstable/http/HttpClientError"
6
- import type { MaybeRefOrGetter } from "vue"
7
+ import { isProxy, isReactive, isRef, type MaybeRefOrGetter, toRaw } from "vue"
7
8
  import { reportError } from "./errorReporter.js"
8
9
 
9
10
  export * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
@@ -31,15 +32,7 @@ const determineLevel = (cause: Cause.Cause<unknown>) => {
31
32
  export const reportRuntimeError = (cause: Cause.Cause<unknown>, extras?: Record<string, unknown>) =>
32
33
  reportRuntimeError_(cause, extras, determineLevel(cause))
33
34
 
34
- // $Project/$Configuration.Index
35
- // -> "$Project", "$Configuration", "Index"
36
- export const makeQueryKey = ({ id, options }: { id: string; options?: ClientForOptions }) =>
37
- pipe(
38
- id.split("/"),
39
- (split) => split.filter((_) => !options || !options?.skipQueryKey?.includes(_)).map((_) => "$" + _)
40
- )
41
- .join(".")
42
- .split(".")
35
+ export { makeQueryKey } from "effect-app/client"
43
36
 
44
37
  export function pauseWhileProcessing(
45
38
  iv: Pausable,
@@ -75,13 +68,48 @@ export const mapHandler: {
75
68
  self: RequestHandlerWithInput<I, A, E, R, Request, Name>,
76
69
  map: (handler: (i: I) => Effect.Effect<A, E, R>) => (i: I) => Effect.Effect<A2, E2, R2>
77
70
  ): RequestHandlerWithInput<I, A2, E2, R2, Request, Name>
78
- <E, A, R, E2, A2, R2, Request extends Req, Name extends string>(
79
- self: RequestHandler<A, E, R, Request, Name>,
80
- map: (handler: Effect.Effect<A, E, R>) => Effect.Effect<A2, E2, R2>
81
- ): RequestHandler<A2, E2, R2, Request, Name>
82
71
  } = (self: any, map: any): any => ({
83
72
  ...self,
84
- handler: typeof self.handler === "function"
85
- ? (i: any) => map(self.handler as (i: any) => Effect.Effect<any, any, any>)(i)
86
- : map(self.handler)
73
+ handler: (i: any) => map(self.handler as (i: any) => Effect.Effect<any, any, any>)(i)
87
74
  })
75
+
76
+ export function deepToRaw<T>(sourceObj: T): T {
77
+ const objectIterator = (input: any): any => {
78
+ if (isRef(input)) {
79
+ return objectIterator(input.value)
80
+ }
81
+
82
+ const rawInput = isReactive(input) || isProxy(input)
83
+ ? toRaw(input)
84
+ : input
85
+
86
+ if (Array.isArray(rawInput)) {
87
+ return rawInput.map((item) => objectIterator(item))
88
+ }
89
+
90
+ if (rawInput instanceof Map) {
91
+ return new Map(
92
+ Array.from(rawInput.entries(), ([key, value]) => [objectIterator(key), objectIterator(value)])
93
+ )
94
+ }
95
+
96
+ if (rawInput instanceof Set) {
97
+ return new Set(Array.from(rawInput.values(), (value) => objectIterator(value)))
98
+ }
99
+
100
+ if (rawInput instanceof Date) {
101
+ return new Date(rawInput)
102
+ }
103
+
104
+ if (rawInput && typeof rawInput === "object") {
105
+ return Object.keys(rawInput).reduce((acc, key) => {
106
+ acc[key] = objectIterator(rawInput[key])
107
+ return acc
108
+ }, {} as Record<string, unknown>)
109
+ }
110
+
111
+ return rawInput
112
+ }
113
+
114
+ return objectIterator(sourceObj)
115
+ }