effect-app 4.0.0-beta.281 → 4.0.0-beta.282
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 +17 -0
- package/dist/Model/Repository/internal/internal.js +2 -2
- package/dist/Model/query/new-kid-interpreter.js +2 -2
- package/dist/QueueMaker.d.ts +8 -10
- package/dist/QueueMaker.d.ts.map +1 -1
- package/dist/QueueMaker.js +9 -2
- package/dist/Schema/Class.d.ts +1 -1
- package/dist/Schema/Class.d.ts.map +1 -1
- package/dist/Schema/Class.js +2 -2
- package/dist/Schema/ext.d.ts +1 -1
- package/dist/Schema/ext.d.ts.map +1 -1
- package/dist/Schema/moreStrings.d.ts +1 -1
- package/dist/Schema/moreStrings.d.ts.map +1 -1
- package/dist/Schema/numbers.d.ts +1 -1
- package/dist/Schema/numbers.d.ts.map +1 -1
- package/dist/Schema/schema.d.ts +1 -1
- package/dist/Schema/schema.d.ts.map +1 -1
- package/dist/Schema/schema.js +2 -2
- package/dist/Schema/strings.d.ts +1 -1
- package/dist/Schema/strings.d.ts.map +1 -1
- package/dist/Schema.d.ts +14 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +3 -2
- package/dist/SchemaAST.d.ts +23 -0
- package/dist/SchemaAST.d.ts.map +1 -0
- package/dist/SchemaAST.js +25 -0
- package/dist/client/makeClient.d.ts +19 -23
- package/dist/client/makeClient.d.ts.map +1 -1
- package/dist/client/makeClient.js +3 -10
- package/dist/rpc/Invalidation.d.ts +2 -2
- package/package.json +2 -2
- package/src/Model/Repository/internal/internal.ts +1 -1
- package/src/Model/query/new-kid-interpreter.ts +1 -1
- package/src/QueueMaker.ts +8 -16
- package/src/Schema/Class.ts +1 -1
- package/src/Schema/ext.ts +1 -1
- package/src/Schema/moreStrings.ts +1 -1
- package/src/Schema/numbers.ts +1 -1
- package/src/Schema/schema.ts +1 -1
- package/src/Schema/strings.ts +1 -1
- package/src/Schema.ts +14 -1
- package/src/SchemaAST.ts +29 -0
- package/src/client/makeClient.ts +12 -22
- package/test/dist/rpc.test.d.ts.map +1 -1
- package/test/rpc.test.ts +7 -8
package/src/Schema.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as S from "effect/Schema"
|
|
2
|
-
import * as SchemaAST from "
|
|
2
|
+
import * as SchemaAST from "./SchemaAST.ts"
|
|
3
3
|
import { type Simplify } from "effect/Struct"
|
|
4
4
|
import type * as Tracer from "effect/Tracer"
|
|
5
5
|
import type { RequiredKeys } from "effect/Types"
|
|
@@ -137,6 +137,19 @@ export * as SchemaParser from "./Schema/SchemaParser.ts"
|
|
|
137
137
|
|
|
138
138
|
export { Void as Void_ } from "effect/Schema"
|
|
139
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Schema for a TypeScript `void` return value — the single canonical `Void`
|
|
142
|
+
* used across the app, including RPC success schemas.
|
|
143
|
+
*
|
|
144
|
+
* Built from our overridden {@link SchemaAST.Void} AST node: accepts **any
|
|
145
|
+
* present value** at runtime and discards it to `undefined`, while keeping the
|
|
146
|
+
* decoded/encoded type as `void` (effect-smol PR #2475). Use {@link Void_}
|
|
147
|
+
* (effect's original) or `S.Undefined` when the input must be exactly
|
|
148
|
+
* `undefined`.
|
|
149
|
+
*/
|
|
150
|
+
export interface Void extends S.Void {}
|
|
151
|
+
export const Void: Void = S.make<S.Void>(new SchemaAST.Void())
|
|
152
|
+
|
|
140
153
|
// ---------------------------------------------------------------------------
|
|
141
154
|
// Struct / NonEmptyArray / Record
|
|
142
155
|
// ---------------------------------------------------------------------------
|
package/src/SchemaAST.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect"
|
|
2
|
+
import type * as Option from "effect/Option"
|
|
3
|
+
import { Void as BaseVoid } from "effect/SchemaAST"
|
|
4
|
+
|
|
5
|
+
export * from "effect/SchemaAST"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* AST node for a TypeScript `void` return value — overrides effect's
|
|
9
|
+
* `SchemaAST.Void` parser with TypeScript `void` semantics (the effect-smol
|
|
10
|
+
* PR #2475 / `b7d46ab` implementation).
|
|
11
|
+
*
|
|
12
|
+
* Runtime parsing accepts **any present value** and discards it, producing
|
|
13
|
+
* `undefined` — matching a `void` return whose result callers never observe.
|
|
14
|
+
* The decoded/encoded TypeScript representation stays `void`.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link void_} for the singleton instance.
|
|
17
|
+
*/
|
|
18
|
+
export class Void extends BaseVoid {
|
|
19
|
+
/** @internal — mirrors the PR's `fromAnyToConst(undefined)`. */
|
|
20
|
+
getParser() {
|
|
21
|
+
const succeed = Effect.succeedSome(undefined)
|
|
22
|
+
return (oinput: Option.Option<unknown>) => oinput._tag === "None" ? Effect.succeedNone : succeed
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const voidNode: Void = new Void()
|
|
27
|
+
|
|
28
|
+
/** Singleton {@link Void} AST node — overrides effect's `void` singleton. */
|
|
29
|
+
export { voidNode as void }
|
package/src/client/makeClient.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type * as Exit from "effect/Exit"
|
|
2
|
-
import * as SchemaTransformation from "effect/SchemaTransformation"
|
|
3
2
|
import { type GetContextConfig, type RpcContextMap } from "../rpc/RpcContextMap.ts"
|
|
4
3
|
import * as S from "../Schema.ts"
|
|
5
4
|
import { AST } from "../Schema.ts"
|
|
@@ -20,15 +19,6 @@ export interface ClientMiddleware<RequestContextMap extends Record<string, RpcCo
|
|
|
20
19
|
const merge = (a: any, b: Array<any>) =>
|
|
21
20
|
a !== undefined && b.length ? S.Union([a, ...b]) : a !== undefined ? a : b.length ? S.Union(b) : S.Never
|
|
22
21
|
|
|
23
|
-
/**
|
|
24
|
-
* Whatever the input, we will only decode or encode to void
|
|
25
|
-
*/
|
|
26
|
-
export const ForceVoid = S
|
|
27
|
-
.declare((_: unknown): _ is unknown => true)
|
|
28
|
-
.pipe(
|
|
29
|
-
S.decodeTo(S.Any, SchemaTransformation.transform<unknown, unknown>({ decode: () => void 0, encode: () => void 0 }))
|
|
30
|
-
)
|
|
31
|
-
|
|
32
22
|
type SchemaOrFields<T> = T extends S.Top ? T : T extends S.Struct.Fields ? S.Struct<T> : S.Void
|
|
33
23
|
|
|
34
24
|
type TaggedRequestSchema<Tag extends string, Payload extends S.Struct.Fields> = S.Struct<
|
|
@@ -46,7 +36,7 @@ type QueryOnlyResources<Resources> = {
|
|
|
46
36
|
type InputFromPayload<Payload extends S.Struct.Fields> = keyof Payload extends never ? void
|
|
47
37
|
: S.Struct<Payload>["Type"]
|
|
48
38
|
|
|
49
|
-
type OutputFromSuccess<Success extends S.Top> = Success extends typeof
|
|
39
|
+
type OutputFromSuccess<Success extends S.Top> = Success extends typeof S.Void ? void : Success["Type"]
|
|
50
40
|
|
|
51
41
|
type InvalidationResources = Record<string, Record<string, unknown>>
|
|
52
42
|
|
|
@@ -176,9 +166,9 @@ export const makeRpcClient = <
|
|
|
176
166
|
)
|
|
177
167
|
const successSchema = config?.success
|
|
178
168
|
? S.isSchema(config.success)
|
|
179
|
-
? AST.isVoid(config.success.ast) ?
|
|
169
|
+
? AST.isVoid(config.success.ast) ? S.Void : config.success
|
|
180
170
|
: S.Struct(config.success)
|
|
181
|
-
:
|
|
171
|
+
: S.Void
|
|
182
172
|
|
|
183
173
|
const finalConfig = (config as any)?.final
|
|
184
174
|
const finalSchema = finalConfig && S.isSchema(finalConfig) ? finalConfig : undefined
|
|
@@ -327,7 +317,7 @@ export const makeRpcClient = <
|
|
|
327
317
|
Self,
|
|
328
318
|
Tag,
|
|
329
319
|
Payload,
|
|
330
|
-
typeof
|
|
320
|
+
typeof S.Void,
|
|
331
321
|
ErrorResult<C & { error: Error }>,
|
|
332
322
|
Omit<
|
|
333
323
|
& Omit<C, "invalidatesQueries">
|
|
@@ -336,7 +326,7 @@ export const makeRpcClient = <
|
|
|
336
326
|
InvalidationConfigForCommand<
|
|
337
327
|
Resources,
|
|
338
328
|
Payload,
|
|
339
|
-
typeof
|
|
329
|
+
typeof S.Void,
|
|
340
330
|
ErrorResult<C & { error: Error }>
|
|
341
331
|
>
|
|
342
332
|
>,
|
|
@@ -372,11 +362,11 @@ export const makeRpcClient = <
|
|
|
372
362
|
Self,
|
|
373
363
|
Tag,
|
|
374
364
|
Payload,
|
|
375
|
-
typeof
|
|
365
|
+
typeof S.Void,
|
|
376
366
|
ErrorResult<C>,
|
|
377
367
|
Omit<
|
|
378
368
|
& Omit<C, "invalidatesQueries">
|
|
379
|
-
& Partial<InvalidationConfigForCommand<Resources, Payload, typeof
|
|
369
|
+
& Partial<InvalidationConfigForCommand<Resources, Payload, typeof S.Void, ErrorResult<C>>>,
|
|
380
370
|
"success" | "error" | "stream"
|
|
381
371
|
>,
|
|
382
372
|
ModuleName,
|
|
@@ -507,7 +497,7 @@ export const makeRpcClient = <
|
|
|
507
497
|
Self,
|
|
508
498
|
Tag,
|
|
509
499
|
Payload,
|
|
510
|
-
typeof
|
|
500
|
+
typeof S.Void,
|
|
511
501
|
ErrorResult<C & { error: Error }>,
|
|
512
502
|
Omit<
|
|
513
503
|
& Omit<C, "invalidatesQueries">
|
|
@@ -518,7 +508,7 @@ export const makeRpcClient = <
|
|
|
518
508
|
InvalidationConfigForCommand<
|
|
519
509
|
Resources,
|
|
520
510
|
Payload,
|
|
521
|
-
typeof
|
|
511
|
+
typeof S.Void,
|
|
522
512
|
ErrorResult<C & { error: Error }>
|
|
523
513
|
>
|
|
524
514
|
>,
|
|
@@ -549,11 +539,11 @@ export const makeRpcClient = <
|
|
|
549
539
|
Self,
|
|
550
540
|
Tag,
|
|
551
541
|
Payload,
|
|
552
|
-
typeof
|
|
542
|
+
typeof S.Void,
|
|
553
543
|
ErrorResult<C>,
|
|
554
544
|
Omit<
|
|
555
545
|
& Omit<C, "invalidatesQueries">
|
|
556
|
-
& Partial<InvalidationConfigForCommand<Resources, Payload, typeof
|
|
546
|
+
& Partial<InvalidationConfigForCommand<Resources, Payload, typeof S.Void, ErrorResult<C>>>,
|
|
557
547
|
"success" | "error" | "stream"
|
|
558
548
|
>,
|
|
559
549
|
ModuleName,
|
|
@@ -570,7 +560,7 @@ export const makeRpcClient = <
|
|
|
570
560
|
Self,
|
|
571
561
|
Tag,
|
|
572
562
|
Payload,
|
|
573
|
-
typeof
|
|
563
|
+
typeof S.Void,
|
|
574
564
|
ErrorResult<{}>,
|
|
575
565
|
Record<string, never>,
|
|
576
566
|
ModuleName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.test.d.ts","sourceRoot":"","sources":["../rpc.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"rpc.test.d.ts","sourceRoot":"","sources":["../rpc.test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAI0B,KAAK;;;;AAKpC,qBAAa,KAAM,SAAQ,UAQzB;CAAG"}
|
package/test/rpc.test.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type * as Effect from "effect/Effect"
|
|
|
2
2
|
import type * as Option from "effect/Option"
|
|
3
3
|
import { expect, test } from "vitest"
|
|
4
4
|
import { makeRpcClient, NotLoggedInError, UnauthorizedError } from "../src/client.js"
|
|
5
|
-
import { ForceVoid } from "../src/client/makeClient.js"
|
|
6
5
|
import { S } from "../src/index.js"
|
|
7
6
|
import { RpcContextMap } from "../src/rpc.js"
|
|
8
7
|
|
|
@@ -34,17 +33,17 @@ declare const _statsSuccess: typeof Stats.success.Type
|
|
|
34
33
|
declare const _statsError: typeof Stats.error.Type
|
|
35
34
|
declare const _statsRequestType: typeof Stats.type
|
|
36
35
|
|
|
37
|
-
test("
|
|
36
|
+
test("Void decodes and encodes as void", () => {
|
|
38
37
|
const statsFromMake = Stats.make({})
|
|
39
38
|
const statsFromMakeOption = Stats.makeOption({})
|
|
40
39
|
const statsFromMakeEffect = Stats.makeEffect({})
|
|
41
40
|
|
|
42
|
-
expect(S.decodeUnknownSync(
|
|
43
|
-
expect(S.is(
|
|
44
|
-
expect(S.decodeUnknownSync(
|
|
45
|
-
expect(S.is(
|
|
46
|
-
expect(S.encodeUnknownSync(
|
|
47
|
-
expect(S.encodeUnknownSync(S.toCodecJson(
|
|
41
|
+
expect(S.decodeUnknownSync(S.Void)(undefined)).toBe(undefined)
|
|
42
|
+
expect(S.is(S.Void)(undefined)).toBe(true)
|
|
43
|
+
expect(S.decodeUnknownSync(S.Void)("test")).toBe(undefined)
|
|
44
|
+
expect(S.is(S.Void)("test")).toBe(true)
|
|
45
|
+
expect(S.encodeUnknownSync(S.Void)("test")).toBe(undefined)
|
|
46
|
+
expect(S.encodeUnknownSync(S.toCodecJson(S.Void))("test")).toBe(null)
|
|
48
47
|
expectTypeOf<typeof _stats>().toEqualTypeOf<Stats>()
|
|
49
48
|
expectTypeOf<typeof _statsSuccess>().toEqualTypeOf<{
|
|
50
49
|
readonly usersActive24Hours: number
|