@dxos/feed 0.8.4-main.6fa680abb7 → 0.8.4-main.765dc60934

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.
@@ -3,7 +3,7 @@ import {
3
3
  PositionConflictError,
4
4
  SyncClient,
5
5
  SyncServer
6
- } from "./chunk-2ENONWPH.mjs";
6
+ } from "./chunk-YYASRWLE.mjs";
7
7
  export {
8
8
  FeedStore,
9
9
  PositionConflictError,
@@ -1 +1 @@
1
- {"inputs":{"src/errors.ts":{"bytes":2072,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/feed-store.ts":{"bytes":80629,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/sync-server.ts":{"bytes":9233,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/sync-client.ts":{"bytes":21805,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Deferred","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":736,"imports":[{"path":"src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/sync-server.ts","kind":"import-statement","original":"./sync-server"},{"path":"src/sync-client.ts","kind":"import-statement","original":"./sync-client"}],"format":"esm"},"src/testing/test-builder.ts":{"bytes":23501,"imports":[{"path":"@effect/sql/Statement","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/ManagedRuntime","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/platform","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlExport","kind":"import-statement","external":true},{"path":"src/feed-store.ts","kind":"import-statement","original":"../feed-store"},{"path":"src/sync-client.ts","kind":"import-statement","original":"../sync-client"},{"path":"src/sync-server.ts","kind":"import-statement","original":"../sync-server"}],"format":"esm"},"src/testing/index.ts":{"bytes":470,"imports":[{"path":"src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-2ENONWPH.mjs","kind":"import-statement"}],"exports":["FeedStore","PositionConflictError","SyncClient","SyncServer"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":217},"dist/lib/neutral/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12000},"dist/lib/neutral/testing/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-2ENONWPH.mjs","kind":"import-statement"},{"path":"@effect/sql/Statement","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/ManagedRuntime","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/platform","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlExport","kind":"import-statement","external":true}],"exports":["TestBuilder","TestPeer"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-builder.ts":{"bytesInOutput":5173},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":5359},"dist/lib/neutral/chunk-2ENONWPH.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":55510},"dist/lib/neutral/chunk-2ENONWPH.mjs":{"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Deferred","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"exports":["FeedStore","PositionConflictError","SyncClient","SyncServer"],"inputs":{"src/errors.ts":{"bytesInOutput":382},"src/feed-store.ts":{"bytesInOutput":19744},"src/sync-server.ts":{"bytesInOutput":1660},"src/sync-client.ts":{"bytesInOutput":4700}},"bytes":26693}}}
1
+ {"inputs":{"src/errors.ts":{"bytes":1997,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/feed-store.ts":{"bytes":86376,"imports":[{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/sync-server.ts":{"bytes":17695,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/sync-client.ts":{"bytes":32331,"imports":[{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Deferred","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":658,"imports":[{"path":"src/feed-store.ts","kind":"import-statement","original":"./feed-store"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/sync-server.ts","kind":"import-statement","original":"./sync-server"},{"path":"src/sync-client.ts","kind":"import-statement","original":"./sync-client"}],"format":"esm"},"src/testing/test-builder.ts":{"bytes":23925,"imports":[{"path":"@effect/sql/Statement","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/ManagedRuntime","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/platform","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlExport","kind":"import-statement","external":true},{"path":"src/feed-store.ts","kind":"import-statement","original":"../feed-store"},{"path":"src/sync-client.ts","kind":"import-statement","original":"../sync-client"},{"path":"src/sync-server.ts","kind":"import-statement","original":"../sync-server"}],"format":"esm"},"src/testing/index.ts":{"bytes":388,"imports":[{"path":"src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-YYASRWLE.mjs","kind":"import-statement"}],"exports":["FeedStore","PositionConflictError","SyncClient","SyncServer"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":217},"dist/lib/neutral/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11479},"dist/lib/neutral/testing/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-YYASRWLE.mjs","kind":"import-statement"},{"path":"@effect/sql/Statement","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/ManagedRuntime","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/platform","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite/SqlExport","kind":"import-statement","external":true}],"exports":["TestBuilder","TestPeer"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-builder.ts":{"bytesInOutput":5447},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":5633},"dist/lib/neutral/chunk-YYASRWLE.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":66083},"dist/lib/neutral/chunk-YYASRWLE.mjs":{"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@effect/sql/SqlClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/sql-sqlite","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Array","kind":"import-statement","external":true},{"path":"effect/Deferred","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FeedStore","PositionConflictError","SyncClient","SyncServer"],"inputs":{"src/errors.ts":{"bytesInOutput":382},"src/feed-store.ts":{"bytesInOutput":21049},"src/sync-server.ts":{"bytesInOutput":4287},"src/sync-client.ts":{"bytesInOutput":8131}},"bytes":34056}}}
@@ -2,7 +2,7 @@ import {
2
2
  FeedStore,
3
3
  SyncClient,
4
4
  SyncServer
5
- } from "../chunk-2ENONWPH.mjs";
5
+ } from "../chunk-YYASRWLE.mjs";
6
6
 
7
7
  // src/testing/test-builder.ts
8
8
  import * as Statement from "@effect/sql/Statement";
@@ -10,12 +10,13 @@ import * as Array from "effect/Array";
10
10
  import * as Effect from "effect/Effect";
11
11
  import * as Layer from "effect/Layer";
12
12
  import * as ManagedRuntime from "effect/ManagedRuntime";
13
- import { Resource } from "@dxos/context";
13
+ import { Context, Resource } from "@dxos/context";
14
14
  import { RuntimeProvider } from "@dxos/effect";
15
15
  import { FeedProtocol } from "@dxos/protocols";
16
16
  import { SqlTransaction } from "@dxos/sql-sqlite";
17
17
  import { layerMemory } from "@dxos/sql-sqlite/platform";
18
18
  import * as SqlExport from "@dxos/sql-sqlite/SqlExport";
19
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/feed/src/testing/test-builder.ts";
19
20
  var WellKnownNamespaces = FeedProtocol.WellKnownNamespaces;
20
21
  var TestBuilder = class extends Resource {
21
22
  #peers = [];
@@ -29,7 +30,7 @@ var TestBuilder = class extends Resource {
29
30
  isServer: i === 0,
30
31
  actorId: `peer-${i}`,
31
32
  serverPeerId: i === 0 ? void 0 : "peer-0",
32
- sendMessage: (msg) => this.#routeMessage(msg),
33
+ sendMessage: (ctx, msg) => this.#routeMessage(ctx, msg),
33
34
  logSql
34
35
  }));
35
36
  }
@@ -60,12 +61,12 @@ var TestBuilder = class extends Resource {
60
61
  });
61
62
  }
62
63
  /** Route a message to the peer identified by recipientPeerId. Runs the recipient's handleMessage with that peer's runtime. */
63
- #routeMessage(msg) {
64
+ #routeMessage(ctx, msg) {
64
65
  const peer = this.#peers.find((p) => p.peerId === msg.recipientPeerId);
65
66
  if (peer == null) {
66
67
  return Effect.die(new Error(`TestPeer not found: ${msg.recipientPeerId}`));
67
68
  }
68
- const handleEffect = peer.syncServer != null ? peer.syncServer.handleMessage(msg) : peer.syncClient != null ? peer.syncClient.handleMessage(msg) : null;
69
+ const handleEffect = peer.syncServer != null ? peer.syncServer.handleMessage(ctx, msg) : peer.syncClient != null ? peer.syncClient.handleMessage(msg) : null;
69
70
  if (handleEffect == null) {
70
71
  return Effect.die(new Error(`TestPeer has no handler: ${msg.recipientPeerId}`));
71
72
  }
@@ -152,14 +153,14 @@ var TestPeer = class extends Resource {
152
153
  return this.#feedStore.appendLocal(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));
153
154
  }
154
155
  pull({ spaceId, feedNamespace, limit = 10 }) {
155
- return this.#client.pull({
156
+ return this.#client.pull(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153 }), {
156
157
  spaceId,
157
158
  feedNamespace,
158
159
  limit
159
160
  }).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));
160
161
  }
161
162
  push({ spaceId, feedNamespace, limit = 10 }) {
162
- return this.#client.push({
163
+ return this.#client.push(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 160 }), {
163
164
  spaceId,
164
165
  feedNamespace,
165
166
  limit
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/test-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as SqlClient from '@effect/sql/SqlClient';\nimport * as Statement from '@effect/sql/Statement';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { Resource } from '@dxos/context';\nimport { RuntimeProvider } from '@dxos/effect';\nimport { type SpaceId } from '@dxos/keys';\nimport { FeedProtocol } from '@dxos/protocols';\nimport { SqlTransaction } from '@dxos/sql-sqlite';\nimport { layerMemory } from '@dxos/sql-sqlite/platform';\nimport * as SqlExport from '@dxos/sql-sqlite/SqlExport';\n\nimport { FeedStore } from '../feed-store';\nimport { SyncClient } from '../sync-client';\nimport { SyncServer } from '../sync-server';\n\ntype ProtocolMessage = FeedProtocol.ProtocolMessage;\nconst WellKnownNamespaces = FeedProtocol.WellKnownNamespaces;\ntype AppendRequest = FeedProtocol.AppendRequest;\ntype QueryRequest = FeedProtocol.QueryRequest;\n\nexport class TestBuilder extends Resource {\n #peers: TestPeer[] = [];\n readonly #spaceId: SpaceId;\n readonly #feedNamespace: string;\n\n constructor({\n numPeers,\n spaceId,\n feedNamespace = WellKnownNamespaces.data,\n logSql = false,\n }: {\n numPeers: number;\n spaceId: SpaceId;\n feedNamespace?: string;\n logSql?: boolean;\n }) {\n super();\n this.#spaceId = spaceId;\n this.#feedNamespace = feedNamespace;\n this.#peers = Array.makeBy(\n numPeers,\n (i) =>\n new TestPeer({\n isServer: i === 0,\n actorId: `peer-${i}`,\n serverPeerId: i === 0 ? undefined : 'peer-0',\n sendMessage: (msg) => this.#routeMessage(msg),\n logSql,\n }),\n );\n }\n\n get peers() {\n return this.#peers;\n }\n\n get server() {\n return this.#peers[0];\n }\n\n protected override async _open(): Promise<void> {\n await Promise.all(this.#peers.map((peer) => peer.open()));\n }\n\n protected override async _close(): Promise<void> {\n await Promise.all(this.#peers.map((peer) => peer.close()));\n }\n\n async pull(client: TestPeer, { limit = 10 }: { limit?: number } = {}): Promise<{ done: boolean }> {\n return client.pull({ spaceId: this.#spaceId, feedNamespace: this.#feedNamespace, limit });\n }\n\n async push(client: TestPeer, { limit = 10 }: { limit?: number } = {}): Promise<{ done: boolean }> {\n return client.push({ spaceId: this.#spaceId, feedNamespace: this.#feedNamespace, limit });\n }\n\n /** Route a message to the peer identified by recipientPeerId. Runs the recipient's handleMessage with that peer's runtime. */\n #routeMessage(msg: ProtocolMessage): Effect.Effect<void, unknown, never> {\n const peer = this.#peers.find((p) => p.peerId === msg.recipientPeerId);\n if (peer == null) {\n return Effect.die(new Error(`TestPeer not found: ${msg.recipientPeerId}`));\n }\n const handleEffect =\n peer.syncServer != null\n ? peer.syncServer.handleMessage(msg)\n : peer.syncClient != null\n ? peer.syncClient.handleMessage(msg)\n : null;\n if (handleEffect == null) {\n return Effect.die(new Error(`TestPeer has no handler: ${msg.recipientPeerId}`));\n }\n return Effect.promise(() => RuntimeProvider.runPromise(peer.runtime.runtimeEffect)(handleEffect));\n }\n}\n\nconst loggingTransformer: Statement.Statement.Transformer = (stmt, _make, _, _span) =>\n Effect.sync(() => {\n const [sql, params] = stmt.compile();\n console.log(sql.trim());\n console.log(params);\n return stmt;\n });\n\nexport class TestPeer extends Resource {\n readonly #peerId: string;\n #feedStore: FeedStore;\n #runtime: ManagedRuntime.ManagedRuntime<\n SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction,\n never\n >;\n #client?: SyncClient;\n #server?: SyncServer;\n\n constructor({\n isServer,\n actorId,\n serverPeerId,\n sendMessage,\n logSql = false,\n }: {\n isServer: boolean;\n actorId: string;\n serverPeerId?: string;\n sendMessage: (msg: ProtocolMessage) => Effect.Effect<void, unknown, never>;\n logSql?: boolean;\n }) {\n super();\n this.#peerId = actorId;\n this.#feedStore = new FeedStore({ localActorId: actorId, assignPositions: isServer });\n const baseLayer = layerMemory.pipe(\n Layer.provide(logSql ? Statement.setTransformer(loggingTransformer) : Layer.empty),\n );\n const transactionLayer = SqlTransaction.layer.pipe(Layer.provide(baseLayer));\n this.#runtime = ManagedRuntime.make(Layer.merge(baseLayer, transactionLayer).pipe(Layer.orDie));\n if (isServer) {\n this.#server = new SyncServer({\n peerId: actorId,\n feedStore: this.#feedStore,\n sendMessage,\n });\n } else {\n this.#client = new SyncClient({\n peerId: actorId,\n serverPeerId: serverPeerId!,\n feedStore: this.#feedStore,\n sendMessage,\n });\n }\n }\n\n get peerId() {\n return this.#peerId;\n }\n\n get feedStore() {\n return this.#feedStore;\n }\n\n get runtime() {\n return this.#runtime;\n }\n\n get syncClient() {\n return this.#client;\n }\n\n get syncServer() {\n return this.#server;\n }\n\n protected override async _open(): Promise<void> {\n await this.#feedStore.migrate().pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n protected override async _close(): Promise<void> {\n await this.#runtime.dispose();\n }\n\n export(): Promise<Uint8Array> {\n return Effect.gen(function* () {\n const sql = yield* SqlExport.SqlExport;\n return yield* sql.export;\n }).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n getSyncState({ spaceId, feedNamespace }: { spaceId: SpaceId; feedNamespace: string }) {\n return this.#feedStore\n .getSyncState({ spaceId, feedNamespace })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n query(req: QueryRequest) {\n return this.#feedStore.query(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n append(req: AppendRequest) {\n return this.#feedStore.append(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n appendLocal(req: Parameters<FeedStore['appendLocal']>[0]) {\n return this.#feedStore.appendLocal(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n pull({ spaceId, feedNamespace, limit = 10 }: { spaceId: SpaceId; feedNamespace: string; limit?: number }) {\n return this.#client!\n .pull({ spaceId, feedNamespace, limit })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n push({ spaceId, feedNamespace, limit = 10 }: { spaceId: SpaceId; feedNamespace: string; limit?: number }) {\n return this.#client!\n .push({ spaceId, feedNamespace, limit })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n}\n"],
5
- "mappings": ";;;;;;;AAKA,YAAYA,eAAe;AAC3B,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAEhC,S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E,aAAa,CAAA;EACrG;EAEAlB,KAAK,EAAEvB,SAASC,eAAewB,QAAQ,GAAE,GAAiE;AACxG,WAAO,KAAK,QACTF,KAAK;MAAEvB;MAASC;MAAewB;IAAM,CAAA,EACrCkC,KAAKrB,gBAAgBC,WAAW,KAAK,SAASE,aAAa,CAAA;EAChE;EAEAf,KAAK,EAAE1B,SAASC,eAAewB,QAAQ,GAAE,GAAiE;AACxG,WAAO,KAAK,QACTC,KAAK;MAAE1B;MAASC;MAAewB;IAAM,CAAA,EACrCkC,KAAKrB,gBAAgBC,WAAW,KAAK,SAASE,aAAa,CAAA;EAChE;AACF;",
6
- "names": ["Statement", "Array", "Effect", "Layer", "ManagedRuntime", "Resource", "RuntimeProvider", "FeedProtocol", "SqlTransaction", "layerMemory", "SqlExport", "WellKnownNamespaces", "FeedProtocol", "TestBuilder", "Resource", "numPeers", "spaceId", "feedNamespace", "data", "logSql", "makeBy", "i", "TestPeer", "isServer", "actorId", "serverPeerId", "undefined", "sendMessage", "msg", "peers", "server", "_open", "Promise", "all", "map", "peer", "open", "_close", "close", "pull", "client", "limit", "push", "find", "p", "peerId", "recipientPeerId", "die", "Error", "handleEffect", "syncServer", "handleMessage", "syncClient", "promise", "RuntimeProvider", "runPromise", "runtime", "runtimeEffect", "loggingTransformer", "stmt", "_make", "_", "_span", "sync", "sql", "params", "compile", "console", "log", "trim", "FeedStore", "localActorId", "assignPositions", "baseLayer", "layerMemory", "pipe", "provide", "setTransformer", "empty", "transactionLayer", "SqlTransaction", "layer", "make", "merge", "orDie", "SyncServer", "feedStore", "SyncClient", "migrate", "dispose", "export", "gen", "SqlExport", "getSyncState", "query", "req", "append", "appendLocal"]
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport type * as SqlClient from '@effect/sql/SqlClient';\nimport * as Statement from '@effect/sql/Statement';\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { Context, Resource } from '@dxos/context';\nimport { RuntimeProvider } from '@dxos/effect';\nimport { type SpaceId } from '@dxos/keys';\nimport { FeedProtocol } from '@dxos/protocols';\nimport { SqlTransaction } from '@dxos/sql-sqlite';\nimport { layerMemory } from '@dxos/sql-sqlite/platform';\nimport * as SqlExport from '@dxos/sql-sqlite/SqlExport';\n\nimport { FeedStore } from '../feed-store';\nimport { SyncClient } from '../sync-client';\nimport { SyncServer } from '../sync-server';\n\ntype ProtocolMessage = FeedProtocol.ProtocolMessage;\nconst WellKnownNamespaces = FeedProtocol.WellKnownNamespaces;\ntype AppendRequest = FeedProtocol.AppendRequest;\ntype QueryRequest = FeedProtocol.QueryRequest;\n\nexport class TestBuilder extends Resource {\n #peers: TestPeer[] = [];\n readonly #spaceId: SpaceId;\n readonly #feedNamespace: string;\n\n constructor({\n numPeers,\n spaceId,\n feedNamespace = WellKnownNamespaces.data,\n logSql = false,\n }: {\n numPeers: number;\n spaceId: SpaceId;\n feedNamespace?: string;\n logSql?: boolean;\n }) {\n super();\n this.#spaceId = spaceId;\n this.#feedNamespace = feedNamespace;\n this.#peers = Array.makeBy(\n numPeers,\n (i) =>\n new TestPeer({\n isServer: i === 0,\n actorId: `peer-${i}`,\n serverPeerId: i === 0 ? undefined : 'peer-0',\n sendMessage: (ctx, msg) => this.#routeMessage(ctx, msg),\n logSql,\n }),\n );\n }\n\n get peers() {\n return this.#peers;\n }\n\n get server() {\n return this.#peers[0];\n }\n\n protected override async _open(): Promise<void> {\n await Promise.all(this.#peers.map((peer) => peer.open()));\n }\n\n protected override async _close(): Promise<void> {\n await Promise.all(this.#peers.map((peer) => peer.close()));\n }\n\n async pull(client: TestPeer, { limit = 10 }: { limit?: number } = {}): Promise<{ done: boolean }> {\n return client.pull({ spaceId: this.#spaceId, feedNamespace: this.#feedNamespace, limit });\n }\n\n async push(client: TestPeer, { limit = 10 }: { limit?: number } = {}): Promise<{ done: boolean }> {\n return client.push({ spaceId: this.#spaceId, feedNamespace: this.#feedNamespace, limit });\n }\n\n /** Route a message to the peer identified by recipientPeerId. Runs the recipient's handleMessage with that peer's runtime. */\n #routeMessage(ctx: Context, msg: ProtocolMessage): Effect.Effect<void, unknown, never> {\n const peer = this.#peers.find((p) => p.peerId === msg.recipientPeerId);\n if (peer == null) {\n return Effect.die(new Error(`TestPeer not found: ${msg.recipientPeerId}`));\n }\n const handleEffect =\n peer.syncServer != null\n ? peer.syncServer.handleMessage(ctx, msg)\n : peer.syncClient != null\n ? peer.syncClient.handleMessage(msg)\n : null;\n if (handleEffect == null) {\n return Effect.die(new Error(`TestPeer has no handler: ${msg.recipientPeerId}`));\n }\n return Effect.promise(() => RuntimeProvider.runPromise(peer.runtime.runtimeEffect)(handleEffect));\n }\n}\n\nconst loggingTransformer: Statement.Statement.Transformer = (stmt, _make, _, _span) =>\n Effect.sync(() => {\n const [sql, params] = stmt.compile();\n console.log(sql.trim());\n console.log(params);\n return stmt;\n });\n\nexport class TestPeer extends Resource {\n readonly #peerId: string;\n #feedStore: FeedStore;\n #runtime: ManagedRuntime.ManagedRuntime<\n SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction,\n never\n >;\n #client?: SyncClient;\n #server?: SyncServer;\n\n constructor({\n isServer,\n actorId,\n serverPeerId,\n sendMessage,\n logSql = false,\n }: {\n isServer: boolean;\n actorId: string;\n serverPeerId?: string;\n sendMessage: (ctx: Context, msg: ProtocolMessage) => Effect.Effect<void, unknown, never>;\n logSql?: boolean;\n }) {\n super();\n this.#peerId = actorId;\n this.#feedStore = new FeedStore({ localActorId: actorId, assignPositions: isServer });\n const baseLayer = layerMemory.pipe(\n Layer.provide(logSql ? Statement.setTransformer(loggingTransformer) : Layer.empty),\n );\n const transactionLayer = SqlTransaction.layer.pipe(Layer.provide(baseLayer));\n this.#runtime = ManagedRuntime.make(Layer.merge(baseLayer, transactionLayer).pipe(Layer.orDie));\n if (isServer) {\n this.#server = new SyncServer({\n peerId: actorId,\n feedStore: this.#feedStore,\n sendMessage,\n });\n } else {\n this.#client = new SyncClient({\n peerId: actorId,\n serverPeerId: serverPeerId!,\n feedStore: this.#feedStore,\n sendMessage,\n });\n }\n }\n\n get peerId() {\n return this.#peerId;\n }\n\n get feedStore() {\n return this.#feedStore;\n }\n\n get runtime() {\n return this.#runtime;\n }\n\n get syncClient() {\n return this.#client;\n }\n\n get syncServer() {\n return this.#server;\n }\n\n protected override async _open(): Promise<void> {\n await this.#feedStore.migrate().pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n protected override async _close(): Promise<void> {\n await this.#runtime.dispose();\n }\n\n export(): Promise<Uint8Array> {\n return Effect.gen(function* () {\n const sql = yield* SqlExport.SqlExport;\n return yield* sql.export;\n }).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n getSyncState({ spaceId, feedNamespace }: { spaceId: SpaceId; feedNamespace: string }) {\n return this.#feedStore\n .getSyncState({ spaceId, feedNamespace })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n query(req: QueryRequest) {\n return this.#feedStore.query(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n append(req: AppendRequest) {\n return this.#feedStore.append(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n appendLocal(req: Parameters<FeedStore['appendLocal']>[0]) {\n return this.#feedStore.appendLocal(req).pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n pull({ spaceId, feedNamespace, limit = 10 }: { spaceId: SpaceId; feedNamespace: string; limit?: number }) {\n return this.#client!\n .pull(Context.default(), { spaceId, feedNamespace, limit })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeEffect));\n }\n\n push({ spaceId, feedNamespace, limit = 10 }: { spaceId: SpaceId; feedNamespace: string; limit?: number }) {\n return this.#client!\n .push(Context.default(), { spaceId, feedNamespace, limit })\n .pipe(RuntimeProvider.runPromise(this.#runtime.runtimeE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AA,GAAAA;MAAeD;MAClDkC;MACL;IAEAO,CAAK,EAAErD,KAAAA,gBAASa,WAAuB,KAAiE,SAAE,aAAA,CAAA;;kBAE3Eb,eAAAA,QAAAA,GAAAA,GAAAA;WAASa,KAAAA,QAAAA,KAAAA,QAAAA,QAAAA,QAAAA,EAAAA,YAAAA,YAAAA,GAAAA,cAAAA,GAAAA,IAAAA,CAAAA,GAAAA;MAAeD;MAClDkC;MACL;IACF,CAAA,EAAA,KAAA,gBAAA,WAAA,KAAA,SAAA,aAAA,CAAA;;;",
6
+ "names": ["Statement", "Array", "Effect", "Layer", "ManagedRuntime", "Context", "Resource", "RuntimeProvider", "FeedProtocol", "SqlTransaction", "layerMemory", "SqlExport", "WellKnownNamespaces", "spaceId", "Array", "i", "serverPeerId", "sendMessage", "ctx", "logSql", "peers", "server", "_open", "_close", "pull", "limit", "feedNamespace", "Effect", "die", "Error", "recipientPeerId", "handleEffect", "peer", "syncServer", "handleMessage", "msg", "promise", "RuntimeProvider", "runtime", "trim", "console", "params", "stmt", "TestPeer", "actorId", "localActorId", "assignPositions", "isServer", "layerMemory", "ManagedRuntime", "Layer", "baseLayer", "transactionLayer", "SyncServer", "peerId", "feedStore", "syncClient", "export", "sql", "pipe", "runPromise", "getSyncState", "query", "req", "append", "appendLocal", "push"]
7
7
  }
@@ -1,27 +1,27 @@
1
1
  import { BaseError } from '@dxos/errors';
2
2
  declare const PositionConflictError_base: {
3
3
  new (options?: import("@dxos/errors").BaseErrorOptions): {
4
+ cause?: unknown;
5
+ stack?: string;
4
6
  name: "PositionConflictError";
5
7
  context: Record<string, unknown>;
6
8
  readonly message: string;
7
9
  readonly _tag: "PositionConflictError";
8
- stack?: string;
9
- cause?: unknown;
10
10
  };
11
+ isError(error: unknown): error is Error;
11
12
  name: "PositionConflictError";
12
13
  is(error: unknown): error is BaseError;
13
- wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, "cause"> & {
14
+ wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
14
15
  ifTypeDiffers?: boolean;
15
16
  }): (error: unknown) => {
17
+ cause?: unknown;
18
+ stack?: string;
16
19
  name: "PositionConflictError";
17
20
  context: Record<string, unknown>;
18
21
  readonly message: string;
19
22
  readonly _tag: "PositionConflictError";
20
- stack?: string;
21
- cause?: unknown;
22
23
  };
23
24
  extend<Name extends string = string>(name: Name, message?: string): any;
24
- isError(error: unknown): error is Error;
25
25
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
26
26
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
27
27
  stackTraceLimit: number;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;qBAgB8gB,CAAC;;;;;;;;;;;;;;;AAdxjB,qBAAa,qBAAsB,SAAQ,0BAAyC;gBACtE,IAAI,EAAE;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;KAClC;CAMF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,qBAAa,qBAAsB,SAAQ,0BAAyC;IAClF,YAAY,IAAI,EAAE;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;QACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;KAClC,EAKA;CACF"}
@@ -101,10 +101,21 @@ export declare class FeedStore {
101
101
  */
102
102
  setPosition: (request: {
103
103
  spaceId: string;
104
- blocks: (Pick<Block, "feedId" | "actorId" | "sequence" | "position"> & {
104
+ blocks: (Pick<Block, 'feedId' | 'actorId' | 'sequence' | 'position'> & {
105
105
  feedNamespace: string;
106
106
  })[];
107
107
  }) => Effect.Effect<void, SqlError.SqlError | PositionConflictError, SqlClient.SqlClient>;
108
+ /**
109
+ * Gets all feeds and their blocks for a space, organized by feed ID and namespace.
110
+ * Used for space archive export.
111
+ */
112
+ getAllFeedsForSpace: (opts: {
113
+ spaceId: SpaceId;
114
+ }) => Effect.Effect<Array<{
115
+ feedId: string;
116
+ feedNamespace: string;
117
+ blocks: Block[];
118
+ }>, SqlError.SqlError, SqlClient.SqlClient>;
108
119
  }
109
120
  export {};
110
121
  //# sourceMappingURL=feed-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feed-store.d.ts","sourceRoot":"","sources":["../../../src/feed-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,KAAK,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;AAChD,KAAK,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;AAClD,KAAK,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;AAShC,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB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AAM,YACK,aAAa,KACrB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,CAyFzD;IAE/C;;OAEG;IACH,WAAW;iBAEc,MAAM;gBAAU,MAAM;uBAAiB,MAAM;cAAQ,UAAU;wHAmHtF;IAEF;;OAEG;IACH,WAAW,YAAa;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC,GAAG;YAAE,aAAa,EAAE,MAAM,CAAA;SAAE,CAAC,EAAE,CAAC;KACrG,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,GAAG,qBAAqB,EAAE,SAAS,CAAC,SAAS,CAAC,CA0CnC;IAEpD;;;OAGG;IACH,mBAAmB,SAAU;QAC3B,OAAO,EAAE,OAAO,CAAC;KAClB,KAAG,MAAM,CAAC,MAAM,CACf,KAAK,CAAC;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,KAAK,EAAE,CAAC;KACjB,CAAC,EACF,QAAQ,CAAC,QAAQ,EACjB,SAAS,CAAC,SAAS,CACpB,CAgC2D;CAC7D"}
@@ -1,5 +1,6 @@
1
1
  import type * as SqlClient from '@effect/sql/SqlClient';
2
2
  import * as Effect from 'effect/Effect';
3
+ import { Context } from '@dxos/context';
3
4
  import type { SpaceId } from '@dxos/keys';
4
5
  import { type FeedProtocol } from '@dxos/protocols';
5
6
  import type { SqlTransaction } from '@dxos/sql-sqlite';
@@ -19,7 +20,7 @@ export type SyncClientOptions = {
19
20
  serverPeerId?: string;
20
21
  feedStore: FeedStore;
21
22
  /** Send a protocol message to the server. Returns Effect. */
22
- sendMessage: (message: RequestMessage) => Effect.Effect<void, unknown, never>;
23
+ sendMessage: (ctx: Context, message: RequestMessage) => Effect.Effect<void, unknown, never>;
23
24
  };
24
25
  /**
25
26
  * Client-side sync: pull/push by sending protocol messages and handling responses.
@@ -34,14 +35,14 @@ export declare class SyncClient {
34
35
  * Receive a message from the server. If a handler is registered for the message's requestId, complete it and remove; else noop.
35
36
  */
36
37
  handleMessage(message: ProtocolMessage): Effect.Effect<void, never, never>;
37
- pull(opts: {
38
+ pull(ctx: Context, opts: {
38
39
  spaceId: SpaceId;
39
40
  feedNamespace: string;
40
41
  limit?: number;
41
42
  }): Effect.Effect<{
42
43
  done: boolean;
43
44
  }, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
44
- push(opts: {
45
+ push(ctx: Context, opts: {
45
46
  spaceId: SpaceId;
46
47
  feedNamespace: string;
47
48
  limit?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"sync-client.d.ts","sourceRoot":"","sources":["../../../src/sync-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,KAAK,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;AAEpD,KAAK,mBAAmB,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC;AAC9E,KAAK,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC,CAAC;AAChF,KAAK,cAAc,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAKjE,MAAM,MAAM,iBAAi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,EAAE,OAAO,CAAA;KAAE,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,CA6EhG;IAED,IAAI,CACF,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE;QACJ,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,MAAM,CAAC,MAAM,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,CAmEhG;CAYF"}
@@ -1,5 +1,6 @@
1
1
  import type * as SqlClient from '@effect/sql/SqlClient';
2
2
  import * as Effect from 'effect/Effect';
3
+ import { Context } from '@dxos/context';
3
4
  import { type FeedProtocol } from '@dxos/protocols';
4
5
  import type { SqlTransaction } from '@dxos/sql-sqlite';
5
6
  import type { FeedStore } from './feed-store';
@@ -9,7 +10,7 @@ export type SyncServerOptions = {
9
10
  peerId: string;
10
11
  feedStore: FeedStore;
11
12
  /** Send a protocol message to a client. Receives full message (recipient is set by server). Returns Effect. */
12
- sendMessage: (message: ProtocolMessage) => Effect.Effect<void, unknown, never>;
13
+ sendMessage: (ctx: Context, message: ProtocolMessage) => Effect.Effect<void, unknown, never>;
13
14
  };
14
15
  /**
15
16
  * Server-side sync: receives protocol messages, runs query/append against the store, sends responses.
@@ -21,7 +22,7 @@ export declare class SyncServer {
21
22
  /**
22
23
  * Receive a message from a client. Handles QueryRequest and AppendRequest; sends response via sendMessage with correct peer ids.
23
24
  */
24
- handleMessage(message: ProtocolMessage): Effect.Effect<void, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
25
+ handleMessage(ctx: Context, message: ProtocolMessage): Effect.Effect<void, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
25
26
  }
26
27
  export {};
27
28
  //# sourceMappingURL=sync-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-server.d.ts","sourceRoot":"","sources":["../../../src/sync-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,KAAK,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;AAIpD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,+GAA+G;IAC/G,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;CAChF,CAAC;AAEF;;;GAGG;AACH,qBAAa,UAAU;;gBAKT,OAAO,EAAE,iBAAiB;IAMtC;;OAEG;IACH,aAAa,CACX,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC;CA8CrF"}
1
+ {"version":3,"file":"sync-server.d.ts","sourceRoot":"","sources":["../../../src/sync-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,KAAK,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;AAgBpD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,+GAA+G;IAC/G,WAAW,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;CAC9F,CAAC;AAEF;;;GAGG;AACH,qBAAa,UAAU;;IAKrB,YAAY,OAAO,EAAE,iBAAiB,EAIrC;IAED;;OAEG;IACH,aAAa,CACX,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,eAAe,GACvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,CAwFnF;CACF"}
@@ -1,7 +1,7 @@
1
1
  import type * as SqlClient from '@effect/sql/SqlClient';
2
2
  import * as Effect from 'effect/Effect';
3
3
  import * as ManagedRuntime from 'effect/ManagedRuntime';
4
- import { Resource } from '@dxos/context';
4
+ import { Context, Resource } from '@dxos/context';
5
5
  import { type SpaceId } from '@dxos/keys';
6
6
  import { FeedProtocol } from '@dxos/protocols';
7
7
  import { SqlTransaction } from '@dxos/sql-sqlite';
@@ -14,7 +14,7 @@ type AppendRequest = FeedProtocol.AppendRequest;
14
14
  type QueryRequest = FeedProtocol.QueryRequest;
15
15
  export declare class TestBuilder extends Resource {
16
16
  #private;
17
- constructor({ numPeers, spaceId, feedNamespace, logSql, }: {
17
+ constructor({ numPeers, spaceId, feedNamespace, logSql }: {
18
18
  numPeers: number;
19
19
  spaceId: SpaceId;
20
20
  feedNamespace?: string;
@@ -37,16 +37,16 @@ export declare class TestBuilder extends Resource {
37
37
  }
38
38
  export declare class TestPeer extends Resource {
39
39
  #private;
40
- constructor({ isServer, actorId, serverPeerId, sendMessage, logSql, }: {
40
+ constructor({ isServer, actorId, serverPeerId, sendMessage, logSql }: {
41
41
  isServer: boolean;
42
42
  actorId: string;
43
43
  serverPeerId?: string;
44
- sendMessage: (msg: ProtocolMessage) => Effect.Effect<void, unknown, never>;
44
+ sendMessage: (ctx: Context, msg: ProtocolMessage) => Effect.Effect<void, unknown, never>;
45
45
  logSql?: boolean;
46
46
  });
47
47
  get peerId(): string;
48
48
  get feedStore(): FeedStore;
49
- get runtime(): ManagedRuntime.ManagedRuntime<SqlClient.SqlClient | SqlTransaction.SqlTransaction | SqlExport.SqlExport, never>;
49
+ get runtime(): ManagedRuntime.ManagedRuntime<SqlClient.SqlClient | SqlExport.SqlExport | SqlTransaction.SqlTransaction, never>;
50
50
  get syncClient(): SyncClient | undefined;
51
51
  get syncServer(): SyncServer | undefined;
52
52
  protected _open(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,KAAK,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;AAEpD,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