effect-app 4.0.0-beta.280 → 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.
Files changed (48) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/Model/Repository/internal/internal.js +2 -2
  3. package/dist/Model/query/new-kid-interpreter.js +2 -2
  4. package/dist/QueueMaker.d.ts +8 -10
  5. package/dist/QueueMaker.d.ts.map +1 -1
  6. package/dist/QueueMaker.js +9 -2
  7. package/dist/RequestContext.d.ts +11 -8
  8. package/dist/RequestContext.d.ts.map +1 -1
  9. package/dist/Schema/Class.d.ts +1 -1
  10. package/dist/Schema/Class.d.ts.map +1 -1
  11. package/dist/Schema/Class.js +2 -2
  12. package/dist/Schema/ext.d.ts +1 -1
  13. package/dist/Schema/ext.d.ts.map +1 -1
  14. package/dist/Schema/moreStrings.d.ts +1 -1
  15. package/dist/Schema/moreStrings.d.ts.map +1 -1
  16. package/dist/Schema/numbers.d.ts +1 -1
  17. package/dist/Schema/numbers.d.ts.map +1 -1
  18. package/dist/Schema/schema.d.ts +1 -1
  19. package/dist/Schema/schema.d.ts.map +1 -1
  20. package/dist/Schema/schema.js +2 -2
  21. package/dist/Schema/strings.d.ts +1 -1
  22. package/dist/Schema/strings.d.ts.map +1 -1
  23. package/dist/Schema.d.ts +14 -1
  24. package/dist/Schema.d.ts.map +1 -1
  25. package/dist/Schema.js +3 -2
  26. package/dist/SchemaAST.d.ts +23 -0
  27. package/dist/SchemaAST.d.ts.map +1 -0
  28. package/dist/SchemaAST.js +25 -0
  29. package/dist/client/makeClient.d.ts +19 -23
  30. package/dist/client/makeClient.d.ts.map +1 -1
  31. package/dist/client/makeClient.js +3 -10
  32. package/dist/ids.d.ts +2 -2
  33. package/dist/rpc/Invalidation.d.ts +4 -4
  34. package/package.json +2 -2
  35. package/src/Model/Repository/internal/internal.ts +1 -1
  36. package/src/Model/query/new-kid-interpreter.ts +1 -1
  37. package/src/QueueMaker.ts +8 -16
  38. package/src/Schema/Class.ts +1 -1
  39. package/src/Schema/ext.ts +1 -1
  40. package/src/Schema/moreStrings.ts +1 -1
  41. package/src/Schema/numbers.ts +1 -1
  42. package/src/Schema/schema.ts +1 -1
  43. package/src/Schema/strings.ts +1 -1
  44. package/src/Schema.ts +14 -1
  45. package/src/SchemaAST.ts +29 -0
  46. package/src/client/makeClient.ts +12 -22
  47. package/test/dist/rpc.test.d.ts.map +1 -1
  48. package/test/rpc.test.ts +7 -8
package/src/QueueMaker.ts CHANGED
@@ -1,19 +1,11 @@
1
- import type * as Scope from "effect/Scope"
2
- import type { NonEmptyReadonlyArray } from "./Array.ts"
3
- import type * as Effect from "./Effect.ts"
4
1
  import { RequestContext } from "./RequestContext.ts"
5
2
 
6
- export interface QueueBase<Evt, DrainEvt> {
7
- drain: <DrainE, DrainR>(
8
- makeHandleEvent: (ks: DrainEvt) => Effect.Effect<void, DrainE, DrainR>,
9
- sessionId?: string
10
- ) => Effect.Effect<never, never, Scope.Scope | DrainR>
11
- publish: (
12
- ...messages: NonEmptyReadonlyArray<Evt>
13
- ) => Effect.Effect<void>
14
- }
15
-
16
- export interface QueueMakerOps {}
17
- export const QueueMaker: QueueMakerOps = {}
18
-
3
+ /**
4
+ * Per-message context envelope (tenant/store id, request metadata) carried
5
+ * alongside message-schema payloads. Alias of {@link RequestContext}.
6
+ *
7
+ * All that remains of the former queue machinery (SB/SQLite/mem `QueueMaker`
8
+ * implementations and the `QueueBase` interface) after the move to cluster
9
+ * entities — the message schemas that embed it still reference this envelope.
10
+ */
19
11
  export const QueueMeta = RequestContext
@@ -3,7 +3,7 @@ import type * as Cause from "effect/Cause"
3
3
  import * as Effect from "effect/Effect"
4
4
  import * as Option from "effect/Option"
5
5
  import * as S from "effect/Schema"
6
- import * as SchemaAST from "effect/SchemaAST"
6
+ import * as SchemaAST from "../SchemaAST.ts"
7
7
  import * as SchemaGetter from "effect/SchemaGetter"
8
8
  import * as SchemaIssue from "effect/SchemaIssue"
9
9
  import * as SchemaTransformation from "effect/SchemaTransformation"
package/src/Schema/ext.ts CHANGED
@@ -37,7 +37,7 @@ import * as Function from "effect/Function"
37
37
  import * as Option from "effect/Option"
38
38
  import * as S from "effect/Schema"
39
39
  import { isDateValid } from "effect/Schema"
40
- import type * as SchemaAST from "effect/SchemaAST"
40
+ import type * as SchemaAST from "../SchemaAST.ts"
41
41
  import * as SchemaIssue from "effect/SchemaIssue"
42
42
  import * as SchemaTransformation from "effect/SchemaTransformation"
43
43
  import { type NonEmptyReadonlyArray } from "../Array.ts"
@@ -14,7 +14,7 @@ import type * as B from "effect/Brand"
14
14
  import * as Effect from "effect/Effect"
15
15
  import { pipe } from "effect/Function"
16
16
  import * as S from "effect/Schema"
17
- import type * as SchemaAST from "effect/SchemaAST"
17
+ import type * as SchemaAST from "../SchemaAST.ts"
18
18
  import type { Simplify } from "effect/Types"
19
19
  import { customRandom, nanoid, urlAlphabet } from "nanoid"
20
20
  import validator from "validator"
@@ -11,7 +11,7 @@
11
11
  import { extendM } from "effect-app/utils"
12
12
  import * as Effect from "effect/Effect"
13
13
  import * as S from "effect/Schema"
14
- import type * as SchemaAST from "effect/SchemaAST"
14
+ import type * as SchemaAST from "../SchemaAST.ts"
15
15
  import type { Simplify } from "effect/Types"
16
16
  import { type BrandedSchema, fromBrand, nominal } from "./brand.ts"
17
17
  import { withDefaultMake } from "./ext.ts"
@@ -1,5 +1,5 @@
1
1
  import * as B from "effect/Brand"
2
- import * as AST from "effect/SchemaAST"
2
+ import * as AST from "../SchemaAST.ts"
3
3
  import * as P from "effect/SchemaParser"
4
4
 
5
5
  export { AST, B, P }
@@ -1,6 +1,6 @@
1
1
  import type * as B from "effect/Brand"
2
2
  import * as S from "effect/Schema"
3
- import type * as SchemaAST from "effect/SchemaAST"
3
+ import type * as SchemaAST from "../SchemaAST.ts"
4
4
  import type { Simplify } from "effect/Types"
5
5
  import { type BrandedSchema, fromBrand, nominal } from "./brand.ts"
6
6
  import { withDefaultMake } from "./ext.ts"
package/src/Schema.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as S from "effect/Schema"
2
- import * as SchemaAST from "effect/SchemaAST"
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
  // ---------------------------------------------------------------------------
@@ -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 }
@@ -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 ForceVoid ? void : Success["Type"]
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) ? ForceVoid : config.success
169
+ ? AST.isVoid(config.success.ast) ? S.Void : config.success
180
170
  : S.Struct(config.success)
181
- : ForceVoid
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 ForceVoid,
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 ForceVoid,
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 ForceVoid,
365
+ typeof S.Void,
376
366
  ErrorResult<C>,
377
367
  Omit<
378
368
  & Omit<C, "invalidatesQueries">
379
- & Partial<InvalidationConfigForCommand<Resources, Payload, typeof ForceVoid, ErrorResult<C>>>,
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 ForceVoid,
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 ForceVoid,
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 ForceVoid,
542
+ typeof S.Void,
553
543
  ErrorResult<C>,
554
544
  Omit<
555
545
  & Omit<C, "invalidatesQueries">
556
- & Partial<InvalidationConfigForCommand<Resources, Payload, typeof ForceVoid, ErrorResult<C>>>,
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 ForceVoid,
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;AAErF,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"}
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("ForceVoid decodes and encodes as void", () => {
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(ForceVoid)(undefined)).toBe(undefined)
43
- expect(S.is(ForceVoid)(undefined)).toBe(true)
44
- expect(S.decodeUnknownSync(ForceVoid)("test")).toBe(undefined)
45
- expect(S.is(ForceVoid)("test")).toBe(true)
46
- expect(S.encodeUnknownSync(ForceVoid)("test")).toBe(undefined)
47
- expect(S.encodeUnknownSync(S.toCodecJson(ForceVoid))("test")).toBe(null)
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