@dxos/feed 0.8.4-main.ef1bc66f44 → 0.8.4-main.fcc0d83b33
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/README.md +0 -1
- package/dist/lib/neutral/{chunk-Q5PE2Q5P.mjs → chunk-PENEKCN2.mjs} +110 -103
- package/dist/lib/neutral/chunk-PENEKCN2.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +1 -5
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +8 -7
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/errors.d.ts +17 -57
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/feed-store.d.ts +39 -4
- package/dist/types/src/feed-store.d.ts.map +1 -1
- package/dist/types/src/sync-client.d.ts +4 -3
- package/dist/types/src/sync-client.d.ts.map +1 -1
- package/dist/types/src/sync-server.d.ts +3 -2
- package/dist/types/src/sync-server.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +5 -5
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -20
- package/src/errors.ts +4 -17
- package/src/feed-store.test.ts +206 -97
- package/src/feed-store.ts +125 -115
- package/src/sync-client.ts +26 -15
- package/src/sync-server.ts +8 -4
- package/src/testing/test-builder.ts +11 -11
- package/dist/lib/neutral/chunk-Q5PE2Q5P.mjs.map +0 -7
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;AAKA,YAAYA,eAAe;AAC3B,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,SAASC,gBAAgB;
|
|
6
|
-
"names": ["Statement", "Array", "Effect", "Layer", "ManagedRuntime", "Resource", "RuntimeProvider", "FeedProtocol", "SqlTransaction", "layerMemory", "SqlExport", "WellKnownNamespaces", "
|
|
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.runtimeEffect));\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAKA,YAAYA,eAAe;AAC3B,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,oBAAoB;AAEhC,SAASC,SAASC,gBAAgB;AAClC,SAASC,uBAAuB;AAEhC,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;AAC5B,YAAYC,eAAe;AAO3B,IAAA,eAAMC;IAKJ,sBAAwB,aAAA;AACf,IAAkB,cAAlB,cAAkB,SAAA;EAClB,SAAA,CAAA;EAET;;cAYO,EAAA,UAAWC,SAAAA,gBAAAA,oBAAAA,MAAAA,SAAAA,MAAAA,GAAAA;AAChB,UAAK;AACL,SAAK,WAASC;0BAIEC;kBACA,aAAOA,UAAG,CAAA,MAAA,IAAA,SAAA;MACpBC,UAAAA,MAAcD;MACdE,SAAAA,QAAcC,CAAAA;MACdC,cAAAA,MAAAA,IAAAA,SAAAA;MACF,aAAA,CAAA,KAAA,QAAA,KAAA,cAAA,KAAA,GAAA;MAEN;IAEIC,CAAAA,CAAAA;;EAEJ,IAAA,QAAA;AAEIC,WAAAA,KAAS;;EAEb,IAAA,SAAA;AAEA,WAAyBC,KAAuB,OAAA,CAAA;;EAEhD,MAAA,QAAA;AAEA,UAAyBC,QAAwB,IAAA,KAAA,OAAA,IAAA,CAAA,SAAA,KAAA,KAAA,CAAA,CAAA;;EAEjD,MAAA,SAAA;AAEA,UAAMC,QAAqB,IAAIC,KAAAA,OAAgC,IAAK,CAAA,SAA8B,KAAA,MAAA,CAAA,CAAA;;aAC3EZ,QAAS,EAAI,QAAC,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AAAA,YAAuB,GAAE,EAA+D,KAAE,gBAAA,WAAA,KAAA,SAAA,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;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,67 +1,27 @@
|
|
|
1
1
|
import { BaseError } from '@dxos/errors';
|
|
2
|
-
declare const
|
|
3
|
-
new (
|
|
4
|
-
"__#1@#code": string;
|
|
5
|
-
"__#1@#context": Record<string, unknown>;
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly code: string;
|
|
8
|
-
readonly context: Record<string, unknown>;
|
|
9
|
-
message: string;
|
|
10
|
-
stack?: string;
|
|
2
|
+
declare const PositionConflictError_base: {
|
|
3
|
+
new (options?: import("@dxos/errors").BaseErrorOptions): {
|
|
11
4
|
cause?: unknown;
|
|
12
|
-
};
|
|
13
|
-
code: string;
|
|
14
|
-
is(error: unknown): error is BaseError;
|
|
15
|
-
extend(code: string): any;
|
|
16
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
17
|
-
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
18
|
-
stackTraceLimit: number;
|
|
19
|
-
};
|
|
20
|
-
export declare class DuplicateBlockPositionError extends DuplicateBlockPositionError_base {
|
|
21
|
-
constructor(args: {
|
|
22
|
-
feedId: string;
|
|
23
|
-
position: number;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
declare const DuplicateBlockLamportTimestampError_base: {
|
|
27
|
-
new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
|
|
28
|
-
"__#1@#code": string;
|
|
29
|
-
"__#1@#context": Record<string, unknown>;
|
|
30
|
-
readonly name: string;
|
|
31
|
-
readonly code: string;
|
|
32
|
-
readonly context: Record<string, unknown>;
|
|
33
|
-
message: string;
|
|
34
5
|
stack?: string;
|
|
35
|
-
|
|
6
|
+
name: "PositionConflictError";
|
|
7
|
+
context: Record<string, unknown>;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly _tag: "PositionConflictError";
|
|
36
10
|
};
|
|
37
|
-
|
|
11
|
+
isError(error: unknown): error is Error;
|
|
12
|
+
name: "PositionConflictError";
|
|
38
13
|
is(error: unknown): error is BaseError;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
stackTraceLimit: number;
|
|
43
|
-
};
|
|
44
|
-
export declare class DuplicateBlockLamportTimestampError extends DuplicateBlockLamportTimestampError_base {
|
|
45
|
-
constructor(args: {
|
|
46
|
-
feedId: string;
|
|
47
|
-
actorId: string;
|
|
48
|
-
sequence: number;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
declare const PositionConflictError_base: {
|
|
52
|
-
new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
|
|
53
|
-
"__#1@#code": string;
|
|
54
|
-
"__#1@#context": Record<string, unknown>;
|
|
55
|
-
readonly name: string;
|
|
56
|
-
readonly code: string;
|
|
57
|
-
readonly context: Record<string, unknown>;
|
|
58
|
-
message: string;
|
|
59
|
-
stack?: string;
|
|
14
|
+
wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
|
|
15
|
+
ifTypeDiffers?: boolean;
|
|
16
|
+
}): (error: unknown) => {
|
|
60
17
|
cause?: unknown;
|
|
18
|
+
stack?: string;
|
|
19
|
+
name: "PositionConflictError";
|
|
20
|
+
context: Record<string, unknown>;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly _tag: "PositionConflictError";
|
|
61
23
|
};
|
|
62
|
-
|
|
63
|
-
is(error: unknown): error is BaseError;
|
|
64
|
-
extend(code: string): any;
|
|
24
|
+
extend<Name extends string = string>(name: Name, message?: string): any;
|
|
65
25
|
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
66
26
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
67
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
|
|
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"}
|
|
@@ -5,7 +5,7 @@ import { Event } from '@dxos/async';
|
|
|
5
5
|
import { type SpaceId } from '@dxos/keys';
|
|
6
6
|
import { FeedProtocol } from '@dxos/protocols';
|
|
7
7
|
import { SqlTransaction } from '@dxos/sql-sqlite';
|
|
8
|
-
import {
|
|
8
|
+
import { PositionConflictError } from './errors';
|
|
9
9
|
type AppendRequest = FeedProtocol.AppendRequest;
|
|
10
10
|
type AppendResponse = FeedProtocol.AppendResponse;
|
|
11
11
|
type Block = FeedProtocol.Block;
|
|
@@ -59,10 +59,34 @@ export declare class FeedStore {
|
|
|
59
59
|
feedNamespace: string;
|
|
60
60
|
lastPulledPosition: number;
|
|
61
61
|
}) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the number of stored blocks for a single feed in a space/namespace.
|
|
64
|
+
* Intended as a low-level primitive for callers (for example Cloudflare Worker code)
|
|
65
|
+
* that need to make retention decisions under constrained storage resources.
|
|
66
|
+
*/
|
|
67
|
+
countBlocks: (opts: {
|
|
68
|
+
spaceId: SpaceId;
|
|
69
|
+
feedNamespace: string;
|
|
70
|
+
feedId: string;
|
|
71
|
+
}) => Effect.Effect<number, SqlError.SqlError, SqlClient.SqlClient>;
|
|
72
|
+
/**
|
|
73
|
+
* Deletes the oldest blocks for a single feed in a space/namespace.
|
|
74
|
+
* This API intentionally does not enforce any retention policy (such as max size);
|
|
75
|
+
* callers decide when and how much to prune, which is useful for constrained
|
|
76
|
+
* environments like Cloudflare Workers.
|
|
77
|
+
*
|
|
78
|
+
* @returns Number of deleted rows.
|
|
79
|
+
*/
|
|
80
|
+
deleteOldestBlocks: (opts: {
|
|
81
|
+
spaceId: SpaceId;
|
|
82
|
+
feedNamespace: string;
|
|
83
|
+
feedId: string;
|
|
84
|
+
count: number;
|
|
85
|
+
}) => Effect.Effect<number, SqlError.SqlError, SqlClient.SqlClient>;
|
|
62
86
|
/**
|
|
63
87
|
* Appends blocks for a space/namespace and optionally assigns global positions.
|
|
64
88
|
*/
|
|
65
|
-
append: (request: AppendRequest) => Effect.Effect<AppendResponse, SqlError.SqlError
|
|
89
|
+
append: (request: AppendRequest) => Effect.Effect<AppendResponse, SqlError.SqlError, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
|
|
66
90
|
/**
|
|
67
91
|
* Creates local blocks with sequential predecessors and appends grouped batches.
|
|
68
92
|
*/
|
|
@@ -71,16 +95,27 @@ export declare class FeedStore {
|
|
|
71
95
|
feedId: string;
|
|
72
96
|
feedNamespace: string;
|
|
73
97
|
data: Uint8Array;
|
|
74
|
-
}[]) => Effect.Effect<FeedProtocol.Block[],
|
|
98
|
+
}[]) => Effect.Effect<FeedProtocol.Block[], SqlError.SqlError, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
|
|
75
99
|
/**
|
|
76
100
|
* Sets positions for existing blocks while preventing conflicting reassignments.
|
|
77
101
|
*/
|
|
78
102
|
setPosition: (request: {
|
|
79
103
|
spaceId: string;
|
|
80
|
-
blocks: (Pick<Block,
|
|
104
|
+
blocks: (Pick<Block, 'feedId' | 'actorId' | 'sequence' | 'position'> & {
|
|
81
105
|
feedNamespace: string;
|
|
82
106
|
})[];
|
|
83
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>;
|
|
84
119
|
}
|
|
85
120
|
export {};
|
|
86
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,
|
|
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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AAS,CAAC,SAAS,CAAC,CAuBN;IAE3D;;OAEG;IACH,MAAM,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,CAiCnC;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,CA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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,kBAAk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AAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,CA+CnF;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 |
|
|
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;
|
|
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,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAElD,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;A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