@confect/js 9.2.4 → 10.0.0-next.1

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/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "@confect/js",
3
3
  "description": "JavaScript client bindings for any JS runtime",
4
- "version": "9.2.4",
4
+ "version": "10.0.0-next.1",
5
5
  "author": "RJ Dellecese",
6
6
  "bugs": {
7
7
  "url": "https://github.com/rjdellecese/confect/issues"
8
8
  },
9
9
  "devDependencies": {
10
- "@effect/vitest": "0.29.0",
11
- "@types/node": "26.1.1",
12
- "effect": "3.21.2",
13
- "tsdown": "0.22.7",
14
- "typescript": "6.0.3",
15
- "unrun": "0.3.1",
16
- "vitest": "4.1.10"
10
+ "@effect/vitest": "4.0.0-beta.98",
11
+ "@types/node": "25.3.3",
12
+ "effect": "4.0.0-beta.98",
13
+ "tsdown": "0.20.3",
14
+ "typescript": "5.9.3",
15
+ "vitest": "3.2.4"
17
16
  },
18
17
  "engines": {
19
18
  "node": ">=22"
@@ -43,8 +42,8 @@
43
42
  "module": "./dist/index.js",
44
43
  "peerDependencies": {
45
44
  "convex": "^1.32.0",
46
- "effect": "^3.21.2",
47
- "@confect/core": "^9.2.4"
45
+ "effect": "^4.0.0-beta.98",
46
+ "@confect/core": "^10.0.0-next.1"
48
47
  },
49
48
  "repository": {
50
49
  "type": "git",
package/src/HttpClient.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import * as Ref from "@confect/core/Ref";
2
2
  import { ConvexHttpClient } from "convex/browser";
3
- import type { ParseResult } from "effect";
4
3
  import * as Context from "effect/Context";
5
4
  import * as Effect from "effect/Effect";
6
5
  import * as Layer from "effect/Layer";
7
6
  import * as Schema from "effect/Schema";
8
7
 
9
- export class HttpClientError extends Schema.TaggedError<HttpClientError>()(
8
+ export class HttpClientError extends Schema.TaggedErrorClass<HttpClientError>()(
10
9
  "HttpClientError",
11
10
  {
12
11
  cause: Schema.Unknown,
@@ -37,7 +36,7 @@ const make = (
37
36
  ...rest: Ref.OptionalArgs<Query>
38
37
  ): Effect.Effect<
39
38
  Ref.Returns<Query>,
40
- Ref.Error<Query> | HttpClientError | ParseResult.ParseError
39
+ Ref.Error<Query> | HttpClientError | Schema.SchemaError
41
40
  > => {
42
41
  const args = (rest[0] ?? {}) as Ref.Args<Query>;
43
42
  return Ref.runWithCodec(
@@ -54,7 +53,7 @@ const make = (
54
53
  ...rest: Ref.OptionalArgs<Mutation>
55
54
  ): Effect.Effect<
56
55
  Ref.Returns<Mutation>,
57
- Ref.Error<Mutation> | HttpClientError | ParseResult.ParseError
56
+ Ref.Error<Mutation> | HttpClientError | Schema.SchemaError
58
57
  > => {
59
58
  const args = (rest[0] ?? {}) as Ref.Args<Mutation>;
60
59
  return Ref.runWithCodec(
@@ -71,7 +70,7 @@ const make = (
71
70
  ...rest: Ref.OptionalArgs<Action>
72
71
  ): Effect.Effect<
73
72
  Ref.Returns<Action>,
74
- Ref.Error<Action> | HttpClientError | ParseResult.ParseError
73
+ Ref.Error<Action> | HttpClientError | Schema.SchemaError
75
74
  > => {
76
75
  const args = (rest[0] ?? {}) as Ref.Args<Action>;
77
76
  return Ref.runWithCodec(
@@ -96,7 +95,7 @@ const make = (
96
95
  /**
97
96
  * A Confect client which uses HTTP to communicate with your Convex backend. Works in any JS runtime that supports `fetch`. Wraps [ConvexHttpClient](https://docs.convex.dev/api/classes/browser.ConvexHttpClient).
98
97
  */
99
- export const HttpClient = Context.GenericTag<ReturnType<typeof make>>(
98
+ export const HttpClient = Context.Service<ReturnType<typeof make>>(
100
99
  "@confect/js/HttpClient",
101
100
  );
102
101
 
@@ -1,13 +1,14 @@
1
1
  import * as Ref from "@confect/core/Ref";
2
2
  import { ConvexClient } from "convex/browser";
3
- import type { ParseResult } from "effect";
3
+ import * as Cause from "effect/Cause";
4
4
  import * as Context from "effect/Context";
5
5
  import * as Effect from "effect/Effect";
6
6
  import * as Layer from "effect/Layer";
7
+ import * as Queue from "effect/Queue";
7
8
  import * as Schema from "effect/Schema";
8
9
  import * as Stream from "effect/Stream";
9
10
 
10
- export class WebSocketClientError extends Schema.TaggedError<WebSocketClientError>()(
11
+ export class WebSocketClientError extends Schema.TaggedErrorClass<WebSocketClientError>()(
11
12
  "WebSocketClientError",
12
13
  {
13
14
  cause: Schema.Unknown,
@@ -51,7 +52,7 @@ const make = (
51
52
  ...rest: Ref.OptionalArgs<Query>
52
53
  ): Effect.Effect<
53
54
  Ref.Returns<Query>,
54
- Ref.Error<Query> | WebSocketClientError | ParseResult.ParseError
55
+ Ref.Error<Query> | WebSocketClientError | Schema.SchemaError
55
56
  > => {
56
57
  const args = (rest[0] ?? {}) as Ref.Args<Query>;
57
58
  return Ref.runWithCodec(
@@ -68,7 +69,7 @@ const make = (
68
69
  ...rest: Ref.OptionalArgs<Mutation>
69
70
  ): Effect.Effect<
70
71
  Ref.Returns<Mutation>,
71
- Ref.Error<Mutation> | WebSocketClientError | ParseResult.ParseError
72
+ Ref.Error<Mutation> | WebSocketClientError | Schema.SchemaError
72
73
  > => {
73
74
  const args = (rest[0] ?? {}) as Ref.Args<Mutation>;
74
75
  return Ref.runWithCodec(
@@ -85,7 +86,7 @@ const make = (
85
86
  ...rest: Ref.OptionalArgs<Action>
86
87
  ): Effect.Effect<
87
88
  Ref.Returns<Action>,
88
- Ref.Error<Action> | WebSocketClientError | ParseResult.ParseError
89
+ Ref.Error<Action> | WebSocketClientError | Schema.SchemaError
89
90
  > => {
90
91
  const args = (rest[0] ?? {}) as Ref.Args<Action>;
91
92
  return Ref.runWithCodec(
@@ -102,29 +103,29 @@ const make = (
102
103
  ...rest: Ref.OptionalArgs<Query>
103
104
  ): Stream.Stream<
104
105
  Ref.Returns<Query>,
105
- Ref.Error<Query> | WebSocketClientError | ParseResult.ParseError
106
+ Ref.Error<Query> | WebSocketClientError | Schema.SchemaError
106
107
  > => {
107
108
  const args = (rest[0] ?? {}) as Ref.Args<Query>;
108
109
  const functionReference = Ref.getFunctionReference(ref);
109
110
  const onError = Ref.decodeErrorOrElse(ref, mapUnknownError);
110
111
 
111
- return Stream.unwrapScoped(
112
+ return Stream.unwrap(
112
113
  Effect.gen(function* () {
113
114
  const encodedArgs = yield* Ref.encodeArgs(ref, args);
114
115
 
115
- return Stream.asyncScoped<
116
+ return Stream.callback<
116
117
  unknown,
117
118
  Ref.Error<Query> | WebSocketClientError
118
- >((emit) =>
119
+ >((queue) =>
119
120
  Effect.gen(function* () {
120
121
  const unsubscribe = convexClient.onUpdate(
121
122
  functionReference,
122
123
  encodedArgs,
123
124
  (result) => {
124
- emit.single(result);
125
+ Queue.offerUnsafe(queue, result);
125
126
  },
126
127
  (error) => {
127
- emit.fail(onError(error));
128
+ Queue.failCauseUnsafe(queue, Cause.fail(onError(error)));
128
129
  },
129
130
  );
130
131
  yield* Effect.addFinalizer(() =>
@@ -154,8 +155,8 @@ const make = (
154
155
  /**
155
156
  * A Confect client which uses a WebSocket to communicate with your Convex backend and supports reactive query subscriptions. The WebSocket connection is managed by the layer's scope and closed automatically when the scope ends. Wraps [ConvexClient](https://docs.convex.dev/api/classes/browser.ConvexClient).
156
157
  */
157
- export const WebSocketClient = Context.GenericTag<
158
- Effect.Effect.Success<ReturnType<typeof make>>
158
+ export const WebSocketClient = Context.Service<
159
+ Effect.Success<ReturnType<typeof make>>
159
160
  >("@confect/js/WebSocketClient");
160
161
 
161
162
  export type WebSocketClient = typeof WebSocketClient.Identifier;
@@ -163,4 +164,4 @@ export type WebSocketClient = typeof WebSocketClient.Identifier;
163
164
  export const layer = (
164
165
  address: string,
165
166
  options?: ConstructorParameters<typeof ConvexClient>[1],
166
- ) => Layer.scoped(WebSocketClient, make(address, options));
167
+ ) => Layer.effect(WebSocketClient, make(address, options));