@shivaedev/contract 0.35.0 → 0.36.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.36.0 - 2026-11-04
4
+
5
+ ### Added
6
+
7
+ - Declare the host build-version stream shared by server and browser clients.
8
+
9
+ ### Fixed
10
+
11
+ - emit portable declarations for exported contracts with declared subjects.
12
+
13
+ ### Breaking
14
+
15
+ - TypeScript source exports now use `@shivaedev/source` instead of `source`. Replace `source` with `@shivaedev/source` in Node `--conditions`, TypeScript `customConditions`, and Vite/Vitest `resolve.conditions`. Bare `source` selects built JavaScript; no compatibility alias is provided.
16
+
3
17
  ## 0.35.0 - 2026-11-04
4
18
 
5
19
  ### Added
package/README.md CHANGED
@@ -100,10 +100,10 @@ import { command } from "@shivaedev/contract/operation.ts";
100
100
  import { selfSubject } from "@shivaedev/identity/subject.ts";
101
101
 
102
102
  const Save = command("save", { invalidates: () => [] });
103
- const Account = contract("account", { commands: [Save], subject: selfSubject });
103
+ export const Account = contract("account", { commands: [Save], subject: selfSubject });
104
104
  ```
105
105
 
106
- The client calls `account.save` without an account id. The session host installs the resolver; handlers read `Subject` from the request environment. See [identity's subject guide](https://github.com/ShivaeDev/platform/tree/main/packages/identity#declared-request-subjects) for delegated selection and refusal declarations.
106
+ Contracts with declared subjects can be exported from published packages with TypeScript declaration output. The client calls `account.save` without an account id. The session host installs the resolver; handlers read `Subject` from the request environment. See [identity's subject guide](https://github.com/ShivaeDev/platform/tree/main/packages/identity#declared-request-subjects) for delegated selection and refusal declarations.
107
107
 
108
108
  ### Expected failures
109
109
 
@@ -1,12 +1,7 @@
1
- import { Effect, type Stream } from "effect";
2
1
  import * as Reactivity from "effect/reactivity/Reactivity";
3
- import type { Key } from "@shivaedev/changes/keys.ts";
4
- import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
5
- import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
6
- import type { QueryReadDenied } from "#readPolicyErrors.ts";
7
2
  export declare const LiveServer: import("effect/Context").Service<"@shivaedev/contract/LiveServer", Readonly<{
8
- readonly resync: () => Effect.Effect<number, never, never>;
9
- readonly stream: (keys: readonly Key[]) => Effect.Effect<Stream.Stream<{
3
+ readonly resync: () => import("effect/Effect").Effect<number, never, never>;
4
+ readonly stream: (keys: readonly import("@shivaedev/changes/keys.ts").Key[]) => import("effect/Effect").Effect<import("effect/Stream").Stream<{
10
5
  readonly _tag: "Changed";
11
6
  readonly keys: readonly ({
12
7
  readonly _tag: "Bucket";
@@ -25,7 +20,7 @@ export declare const LiveServer: import("effect/Context").Service<"@shivaedev/co
25
20
  } | {
26
21
  readonly _tag: "Resync";
27
22
  }, never, never>, never, never>;
28
- readonly subscribe: <E, R, TRead extends QueryRerun<unknown, unknown> | undefined = undefined>(subscription: QuerySubscription<E, R>, read?: (TRead & (QueryRerun<E, R> | undefined)) | undefined) => Effect.Effect<Stream.Stream<TRead extends undefined ? SubscriptionHint : QueryUpdate, E | QueryReadDenied, R>>;
23
+ readonly subscribe: <E, R, TRead extends import("./querySubscription.ts").QueryRerun<unknown, unknown> | undefined = undefined>(subscription: import("./querySubscription.ts").QuerySubscription<E, R>, read?: (TRead & (import("./querySubscription.ts").QueryRerun<E, R> | undefined)) | undefined) => import("effect/Effect").Effect<import("effect/Stream").Stream<TRead extends undefined ? import("./queryUpdate.ts").SubscriptionHint : import("./queryUpdate.ts").QueryUpdate, E | import("./readPolicyErrors.ts").QueryReadDenied, R>>;
29
24
  }>> & {
30
25
  readonly layer: import("effect/Layer").Layer<"@shivaedev/contract/LiveServer", never, Reactivity.Reactivity>;
31
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"LiveServer.d.ts","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAItD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;yBAIF,CAAC,EAAE,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,4BAChE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,kEAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,SAAS,GAAG,gBAAgB,GAAG,WAAW,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC;;;CAWjH,CAAC"}
1
+ {"version":3,"file":"LiveServer.d.ts","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAQ3D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CASrB,CAAC"}
@@ -1,21 +1,18 @@
1
- import { Effect } from "effect";
2
1
  import * as Reactivity from "effect/reactivity/Reactivity";
3
2
  import { defineService } from "@shivaedev/service/defineService.ts";
4
3
  import { genericMethod } from "@shivaedev/service/genericMethod.ts";
4
+ import { resync } from "#internal/live-server/resync.ts";
5
+ import { stream } from "#internal/live-server/stream.ts";
6
+ import { subscribe } from "#internal/live-server/subscribe.ts";
5
7
  import { makeLiveServer } from "#makeLiveServer.ts";
6
8
  export const LiveServer = defineService({
7
9
  id: "@shivaedev/contract/LiveServer",
8
10
  initialize: makeLiveServer,
9
- methods: (server) => {
10
- function subscribe(subscription, read) {
11
- return Effect.succeed(read === undefined ? server.subscribe(subscription) : server.subscribe(subscription, read));
12
- }
13
- return {
14
- resync: () => server.resync,
15
- stream: (keys) => Effect.succeed(server.stream(keys)),
16
- subscribe: genericMethod(subscribe),
17
- };
18
- },
11
+ methods: (server) => ({
12
+ resync: resync(server),
13
+ stream: stream(server),
14
+ subscribe: genericMethod(subscribe(server)),
15
+ }),
19
16
  requires: [Reactivity.Reactivity],
20
17
  });
21
18
  //# sourceMappingURL=LiveServer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LiveServer.js","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKpD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;IACvC,EAAE,EAAE,gCAAgC;IACpC,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;QAKnB,SAAS,SAAS,CAAO,YAAqC,EAAE,IAAuB;YACtF,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;QACnH,CAAC;QACD,OAAO;YACN,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM;YAC3B,MAAM,EAAE,CAAC,IAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC;SACnC,CAAC;IACH,CAAC;IACD,QAAQ,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;CACjC,CAAC,CAAC"}
1
+ {"version":3,"file":"LiveServer.js","sourceRoot":"","sources":["../src/LiveServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;IACvC,EAAE,EAAE,gCAAgC;IACpC,UAAU,EAAE,cAAc;IAC1B,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC3C,CAAC;IACF,QAAQ,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;CACjC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Effect } from "effect";
2
+ import type { makeLiveServer } from "#makeLiveServer.ts";
3
+ export declare function resync(server: Effect.Success<typeof makeLiveServer>): () => Effect.Effect<number, never, never>;
4
+ //# sourceMappingURL=resync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resync.d.ts","sourceRoot":"","sources":["../../../src/internal/live-server/resync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,cAAc,CAAC,6CAEnE"}
@@ -0,0 +1,4 @@
1
+ export function resync(server) {
2
+ return () => server.resync;
3
+ }
4
+ //# sourceMappingURL=resync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resync.js","sourceRoot":"","sources":["../../../src/internal/live-server/resync.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,MAAM,CAAC,MAA6C;IACnE,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Effect } from "effect";
2
+ import type { Key } from "@shivaedev/changes/keys.ts";
3
+ import type { makeLiveServer } from "#makeLiveServer.ts";
4
+ export declare function stream(server: Effect.Success<typeof makeLiveServer>): (keys: readonly Key[]) => Effect.Effect<import("effect/Stream").Stream<{
5
+ readonly _tag: "Changed";
6
+ readonly keys: readonly ({
7
+ readonly _tag: "Bucket";
8
+ readonly collection: string;
9
+ readonly field: string;
10
+ readonly value: string | number;
11
+ } | {
12
+ readonly _tag: "List";
13
+ readonly collection: string;
14
+ } | {
15
+ readonly _tag: "Item";
16
+ readonly collection: string;
17
+ readonly id: string | number;
18
+ })[];
19
+ readonly queryIndexes?: readonly number[] | undefined;
20
+ } | {
21
+ readonly _tag: "Resync";
22
+ }, never, never>, never, never>;
23
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/internal/live-server/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,cAAc,CAAC,UACrD,SAAS,GAAG,EAAE;;;;;;;;;;;;;;;;;;gCAC5B"}
@@ -0,0 +1,5 @@
1
+ import { Effect } from "effect";
2
+ export function stream(server) {
3
+ return (keys) => Effect.succeed(server.stream(keys));
4
+ }
5
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/internal/live-server/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,UAAU,MAAM,CAAC,MAA6C;IACnE,OAAO,CAAC,IAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Effect, type Stream } from "effect";
2
+ import type { makeLiveServer } from "#makeLiveServer.ts";
3
+ import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
4
+ import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
5
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
6
+ export declare function subscribe(server: Effect.Success<typeof makeLiveServer>): <E, R, TRead extends QueryRerun<unknown, unknown> | undefined = undefined>(subscription: QuerySubscription<E, R>, read?: (TRead & (QueryRerun<E, R> | undefined)) | undefined) => Effect.Effect<Stream.Stream<TRead extends undefined ? SubscriptionHint : QueryUpdate, E | QueryReadDenied, R>>;
7
+ //# sourceMappingURL=subscribe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../../src/internal/live-server/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,cAAc,CAAC,IAC1C,CAAC,EAAE,CAAC,EAAE,KAAK,SAAS,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,4BACzE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,kEAEnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS,SAAS,GAAG,gBAAgB,GAAG,WAAW,EAAE,CAAC,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC,CAKjH"}
@@ -0,0 +1,8 @@
1
+ import { Effect } from "effect";
2
+ export function subscribe(server) {
3
+ function subscribeToQueries(subscription, read) {
4
+ return Effect.succeed(read === undefined ? server.subscribe(subscription) : server.subscribe(subscription, read));
5
+ }
6
+ return subscribeToQueries;
7
+ }
8
+ //# sourceMappingURL=subscribe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../../src/internal/live-server/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAM7C,MAAM,UAAU,SAAS,CAAC,MAA6C;IAKtE,SAAS,kBAAkB,CAAO,YAAqC,EAAE,IAAuB;QAC/F,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IACnH,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { RpcMiddleware } from "effect/rpc";
2
2
  import type { SubjectDeclaration, SubjectProvides } from "#subject.ts";
3
3
  export declare const SUBJECT_TYPE_ID = "@shivaedev/contract/SubjectDeclaration";
4
- interface SubjectMiddleware<TSubject extends SubjectDeclaration> extends RpcMiddleware.AnyId {
4
+ export interface SubjectMiddleware<TSubject extends SubjectDeclaration> extends RpcMiddleware.AnyId {
5
5
  readonly [RpcMiddleware.TypeId]: {
6
6
  readonly provides: SubjectProvides<TSubject>;
7
7
  readonly requires: never;
@@ -12,5 +12,4 @@ interface SubjectMiddleware<TSubject extends SubjectDeclaration> extends RpcMidd
12
12
  export declare function subjectMiddleware<TSubject extends SubjectDeclaration>(name: string, subject: TSubject): RpcMiddleware.ServiceClass<SubjectMiddleware<TSubject>, `@shivaedev/contract/Subject/${string}`, SubjectProvides<TSubject>, TSubject["error"], never, never, false> & {
13
13
  "@shivaedev/contract/SubjectDeclaration": TSubject;
14
14
  };
15
- export {};
16
15
  //# sourceMappingURL=subjectMiddleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subjectMiddleware.d.ts","sourceRoot":"","sources":["../../src/internal/subjectMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAExE,UAAU,iBAAiB,CAAC,QAAQ,SAAS,kBAAkB,CAAE,SAAQ,aAAa,CAAC,KAAK;IAC3F,QAAQ,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;QAChC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC7C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC;KAC5B,CAAC;CACF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;;EAOrG"}
1
+ {"version":3,"file":"subjectMiddleware.d.ts","sourceRoot":"","sources":["../../src/internal/subjectMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,eAAe,2CAA2C,CAAC;AAExE,MAAM,WAAW,iBAAiB,CAAC,QAAQ,SAAS,kBAAkB,CAAE,SAAQ,aAAa,CAAC,KAAK;IAClG,QAAQ,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;QAChC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC7C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC;KAC5B,CAAC;CACF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;;EAOrG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/contract",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Typed query and command contracts over native Effect RPC and reactivity",
5
5
  "keywords": [
6
6
  "effect"
@@ -20,14 +20,14 @@
20
20
  "imports": {
21
21
  "#test/*": "./src/test-support/*",
22
22
  "#*.ts": {
23
- "source": "./src/*.ts",
23
+ "@shivaedev/source": "./src/*.ts",
24
24
  "types": "./dist/*.d.ts",
25
25
  "default": "./dist/*.js"
26
26
  }
27
27
  },
28
28
  "exports": {
29
29
  "./*.ts": {
30
- "source": "./src/*.ts",
30
+ "@shivaedev/source": "./src/*.ts",
31
31
  "types": "./dist/*.d.ts",
32
32
  "default": "./dist/*.js"
33
33
  },
@@ -43,22 +43,22 @@
43
43
  "README.md"
44
44
  ],
45
45
  "dependencies": {
46
- "@shivaedev/changes": "0.9.0",
47
- "@shivaedev/service": "0.6.2",
48
- "@shivaedev/types": "0.3.0"
46
+ "@shivaedev/changes": "0.10.0",
47
+ "@shivaedev/service": "0.7.0",
48
+ "@shivaedev/types": "0.4.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@effect/platform-node": "4.0.6",
52
52
  "@effect/vitest": "4.0.6",
53
- "@shivaedev/errors": "0.8.0",
54
- "@shivaedev/identity": "0.23.1",
55
- "@shivaedev/quality": "0.59.0",
56
- "@shivaedev/server": "0.23.0",
57
- "@shivaedev/sql": "0.36.1",
58
- "@shivaedev/test": "0.14.0",
59
- "@shivaedev/test-kits": "0.2.2",
60
- "@shivaedev/test-sql": "0.19.0",
61
- "@shivaedev/test-story": "0.37.1",
53
+ "@shivaedev/errors": "0.9.0",
54
+ "@shivaedev/identity": "0.24.0",
55
+ "@shivaedev/quality": "0.60.0",
56
+ "@shivaedev/server": "0.24.0",
57
+ "@shivaedev/sql": "0.37.0",
58
+ "@shivaedev/test": "0.15.0",
59
+ "@shivaedev/test-kits": "0.3.0",
60
+ "@shivaedev/test-sql": "0.20.0",
61
+ "@shivaedev/test-story": "0.38.0",
62
62
  "@types/node": "24.19.2",
63
63
  "effect": "4.0.6",
64
64
  "esbuild": "0.28.2",
package/src/LiveServer.ts CHANGED
@@ -1,29 +1,18 @@
1
- import { Effect, type Stream } from "effect";
2
1
  import * as Reactivity from "effect/reactivity/Reactivity";
3
- import type { Key } from "@shivaedev/changes/keys.ts";
4
2
  import { defineService } from "@shivaedev/service/defineService.ts";
5
3
  import { genericMethod } from "@shivaedev/service/genericMethod.ts";
4
+ import { resync } from "#internal/live-server/resync.ts";
5
+ import { stream } from "#internal/live-server/stream.ts";
6
+ import { subscribe } from "#internal/live-server/subscribe.ts";
6
7
  import { makeLiveServer } from "#makeLiveServer.ts";
7
- import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
8
- import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
9
- import type { QueryReadDenied } from "#readPolicyErrors.ts";
10
8
 
11
9
  export const LiveServer = defineService({
12
10
  id: "@shivaedev/contract/LiveServer",
13
11
  initialize: makeLiveServer,
14
- methods: (server) => {
15
- function subscribe<E, R, TRead extends QueryRerun<unknown, unknown> | undefined = undefined>(
16
- subscription: QuerySubscription<E, R>,
17
- read?: TRead & (QueryRerun<E, R> | undefined),
18
- ): Effect.Effect<Stream.Stream<TRead extends undefined ? SubscriptionHint : QueryUpdate, E | QueryReadDenied, R>>;
19
- function subscribe<E, R>(subscription: QuerySubscription<E, R>, read?: QueryRerun<E, R>) {
20
- return Effect.succeed(read === undefined ? server.subscribe(subscription) : server.subscribe(subscription, read));
21
- }
22
- return {
23
- resync: () => server.resync,
24
- stream: (keys: readonly Key[]) => Effect.succeed(server.stream(keys)),
25
- subscribe: genericMethod(subscribe),
26
- };
27
- },
12
+ methods: (server) => ({
13
+ resync: resync(server),
14
+ stream: stream(server),
15
+ subscribe: genericMethod(subscribe(server)),
16
+ }),
28
17
  requires: [Reactivity.Reactivity],
29
18
  });
@@ -0,0 +1,6 @@
1
+ import type { Effect } from "effect";
2
+ import type { makeLiveServer } from "#makeLiveServer.ts";
3
+
4
+ export function resync(server: Effect.Success<typeof makeLiveServer>) {
5
+ return () => server.resync;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Effect } from "effect";
2
+ import type { Key } from "@shivaedev/changes/keys.ts";
3
+ import type { makeLiveServer } from "#makeLiveServer.ts";
4
+
5
+ export function stream(server: Effect.Success<typeof makeLiveServer>) {
6
+ return (keys: readonly Key[]) => Effect.succeed(server.stream(keys));
7
+ }
@@ -0,0 +1,16 @@
1
+ import { Effect, type Stream } from "effect";
2
+ import type { makeLiveServer } from "#makeLiveServer.ts";
3
+ import type { QueryRerun, QuerySubscription } from "#querySubscription.ts";
4
+ import type { QueryUpdate, SubscriptionHint } from "#queryUpdate.ts";
5
+ import type { QueryReadDenied } from "#readPolicyErrors.ts";
6
+
7
+ export function subscribe(server: Effect.Success<typeof makeLiveServer>) {
8
+ function subscribeToQueries<E, R, TRead extends QueryRerun<unknown, unknown> | undefined = undefined>(
9
+ subscription: QuerySubscription<E, R>,
10
+ read?: TRead & (QueryRerun<E, R> | undefined),
11
+ ): Effect.Effect<Stream.Stream<TRead extends undefined ? SubscriptionHint : QueryUpdate, E | QueryReadDenied, R>>;
12
+ function subscribeToQueries<E, R>(subscription: QuerySubscription<E, R>, read?: QueryRerun<E, R>) {
13
+ return Effect.succeed(read === undefined ? server.subscribe(subscription) : server.subscribe(subscription, read));
14
+ }
15
+ return subscribeToQueries;
16
+ }
@@ -3,7 +3,7 @@ import type { SubjectDeclaration, SubjectProvides } from "#subject.ts";
3
3
 
4
4
  export const SUBJECT_TYPE_ID = "@shivaedev/contract/SubjectDeclaration";
5
5
 
6
- interface SubjectMiddleware<TSubject extends SubjectDeclaration> extends RpcMiddleware.AnyId {
6
+ export interface SubjectMiddleware<TSubject extends SubjectDeclaration> extends RpcMiddleware.AnyId {
7
7
  readonly [RpcMiddleware.TypeId]: {
8
8
  readonly provides: SubjectProvides<TSubject>;
9
9
  readonly requires: never;