@shivaedev/contract 0.30.2 → 0.31.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.
- package/CHANGELOG.md +11 -0
- package/README.md +29 -29
- package/dist/bind.d.ts +5 -5
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js.map +1 -1
- package/dist/clientOptions.d.ts +3 -0
- package/dist/clientOptions.d.ts.map +1 -1
- package/dist/internal/changesSuccess.d.ts +2 -1
- package/dist/internal/changesSuccess.d.ts.map +1 -1
- package/dist/internal/changesSuccess.js +2 -0
- package/dist/internal/changesSuccess.js.map +1 -1
- package/dist/internal/liveAttempt.d.ts +13 -0
- package/dist/internal/liveAttempt.d.ts.map +1 -0
- package/dist/internal/liveAttempt.js +28 -0
- package/dist/internal/liveAttempt.js.map +1 -0
- package/dist/internal/queryDelivery.d.ts +2 -20
- package/dist/internal/queryDelivery.d.ts.map +1 -1
- package/dist/internal/queryDelivery.js.map +1 -1
- package/dist/internal/queryHints.d.ts +3 -2
- package/dist/internal/queryHints.d.ts.map +1 -1
- package/dist/internal/queryHints.js +1 -1
- package/dist/internal/queryHints.js.map +1 -1
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +16 -24
- package/dist/live.js.map +1 -1
- package/dist/makeLiveServer.d.ts +2 -2
- package/dist/makeLiveServer.d.ts.map +1 -1
- package/dist/makeLiveServer.js +4 -3
- package/dist/makeLiveServer.js.map +1 -1
- package/dist/publicConfig.d.ts +1 -1
- package/dist/publicConfig.d.ts.map +1 -1
- package/dist/querySubscription.d.ts +2 -1
- package/dist/querySubscription.d.ts.map +1 -1
- package/dist/querySubscription.js +4 -1
- package/dist/querySubscription.js.map +1 -1
- package/dist/queryUpdate.d.ts +3 -1
- package/dist/queryUpdate.d.ts.map +1 -1
- package/dist/testing.d.ts +4 -40
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +9 -9
- package/src/bind.ts +9 -8
- package/src/clientOptions.ts +3 -0
- package/src/internal/changesSuccess.ts +3 -1
- package/src/internal/liveAttempt.ts +44 -0
- package/src/internal/queryDelivery.ts +2 -3
- package/src/internal/queryHints.ts +3 -2
- package/src/live.ts +20 -27
- package/src/makeLiveServer.ts +11 -5
- package/src/querySubscription.ts +5 -1
- package/src/queryUpdate.ts +3 -1
- package/src/testing.ts +5 -5
package/src/queryUpdate.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LiveHint } from "#live.ts";
|
|
2
|
+
import type { QueryReadDenied } from "#readPolicyErrors.ts";
|
|
2
3
|
|
|
3
4
|
export interface QueryResult {
|
|
4
5
|
readonly _tag: "Result";
|
|
@@ -6,4 +7,5 @@ export interface QueryResult {
|
|
|
6
7
|
readonly queryIndex: number;
|
|
7
8
|
readonly value: unknown;
|
|
8
9
|
}
|
|
9
|
-
export type
|
|
10
|
+
export type SubscriptionHint = LiveHint | QueryReadDenied;
|
|
11
|
+
export type QueryUpdate = SubscriptionHint | QueryResult;
|
package/src/testing.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Deferred, type Duration, Effect, Fiber, Layer, Queue, Stream, SubscriptionRef } from "effect";
|
|
2
2
|
import { type Rpc, RpcClient, type RpcGroup, type RpcMessage, RpcSerialization, RpcServer } from "effect/rpc";
|
|
3
3
|
import type { Key } from "@shivaedev/changes/keys.ts";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SubscriptionHint } from "#queryUpdate.ts";
|
|
5
5
|
|
|
6
6
|
export interface HintViewer<E> {
|
|
7
7
|
readonly finished: Effect.Effect<void, E>;
|
|
8
|
-
readonly hints: SubscriptionRef.SubscriptionRef<readonly
|
|
8
|
+
readonly hints: SubscriptionRef.SubscriptionRef<readonly SubscriptionHint[]>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const watchHints = Effect.fn("Live.watchHints")(function* <E, R>(stream: Stream.Stream<
|
|
12
|
-
const hints = yield* SubscriptionRef.make<readonly
|
|
11
|
+
export const watchHints = Effect.fn("Live.watchHints")(function* <E, R>(stream: Stream.Stream<SubscriptionHint, E, R>) {
|
|
12
|
+
const hints = yield* SubscriptionRef.make<readonly SubscriptionHint[]>([]);
|
|
13
13
|
const ready = yield* Deferred.make<void>();
|
|
14
14
|
const fiber = yield* stream.pipe(
|
|
15
15
|
Stream.runForEach((hint) =>
|
|
@@ -37,7 +37,7 @@ export const heard = Effect.fn("Live.heard")(function* <E>(
|
|
|
37
37
|
);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
function namesKeys(hint:
|
|
40
|
+
function namesKeys(hint: SubscriptionHint, keys: readonly Key[]): boolean {
|
|
41
41
|
return hint._tag === "Changed" && keys.every((key) => hint.keys.some((actual) => JSON.stringify(actual) === JSON.stringify(key)));
|
|
42
42
|
}
|
|
43
43
|
|