@dxos/feed 0.8.4-main.9735255 → 0.8.4-main.c85a9c8dae
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 +6 -2
- package/dist/lib/neutral/chunk-2ENONWPH.mjs +703 -0
- package/dist/lib/neutral/chunk-2ENONWPH.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +13 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +173 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/errors.d.ts +39 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/feed-store.d.ts +92 -9
- package/dist/types/src/feed-store.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/sync-client.d.ts +53 -0
- package/dist/types/src/sync-client.d.ts.map +1 -0
- package/dist/types/src/sync-server.d.ts +27 -0
- package/dist/types/src/sync-server.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +78 -0
- package/dist/types/src/testing/test-builder.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -13
- package/src/errors.ts +20 -0
- package/src/feed-store.test.ts +394 -39
- package/src/feed-store.ts +445 -140
- package/src/index.ts +3 -1
- package/src/sync-client.ts +188 -0
- package/src/sync-server.ts +92 -0
- package/src/sync.test.ts +151 -91
- package/src/testing/index.ts +1 -1
- package/src/testing/test-builder.ts +223 -0
- package/dist/lib/browser/index.mjs +0 -342
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs +0 -1
- package/dist/lib/node-esm/index.mjs +0 -344
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -2
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/protocol.d.ts +0 -120
- package/dist/types/src/protocol.d.ts.map +0 -1
- package/src/protocol.ts +0 -110
- /package/dist/lib/{browser/testing → neutral}/index.mjs.map +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type * as SqlClient from '@effect/sql/SqlClient';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import { type FeedProtocol } from '@dxos/protocols';
|
|
4
|
+
import type { SqlTransaction } from '@dxos/sql-sqlite';
|
|
5
|
+
import type { FeedStore } from './feed-store';
|
|
6
|
+
type ProtocolMessage = FeedProtocol.ProtocolMessage;
|
|
7
|
+
export type SyncServerOptions = {
|
|
8
|
+
/** This server's peer id. Set as senderPeerId on all replies. */
|
|
9
|
+
peerId: string;
|
|
10
|
+
feedStore: FeedStore;
|
|
11
|
+
/** 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
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Server-side sync: receives protocol messages, runs query/append against the store, sends responses.
|
|
16
|
+
* Reusable for many peers: sets senderPeerId = peerId and recipientPeerId = incoming message's senderPeerId on replies.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SyncServer {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(options: SyncServerOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Receive a message from a client. Handles QueryRequest and AppendRequest; sends response via sendMessage with correct peer ids.
|
|
23
|
+
*/
|
|
24
|
+
handleMessage(message: ProtocolMessage): Effect.Effect<void, unknown, SqlClient.SqlClient | SqlTransaction.SqlTransaction>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=sync-server.d.ts.map
|
|
@@ -0,0 +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,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './test-builder';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type * as SqlClient from '@effect/sql/SqlClient';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
4
|
+
import { Resource } from '@dxos/context';
|
|
5
|
+
import { type SpaceId } from '@dxos/keys';
|
|
6
|
+
import { FeedProtocol } from '@dxos/protocols';
|
|
7
|
+
import { SqlTransaction } from '@dxos/sql-sqlite';
|
|
8
|
+
import * as SqlExport from '@dxos/sql-sqlite/SqlExport';
|
|
9
|
+
import { FeedStore } from '../feed-store';
|
|
10
|
+
import { SyncClient } from '../sync-client';
|
|
11
|
+
import { SyncServer } from '../sync-server';
|
|
12
|
+
type ProtocolMessage = FeedProtocol.ProtocolMessage;
|
|
13
|
+
type AppendRequest = FeedProtocol.AppendRequest;
|
|
14
|
+
type QueryRequest = FeedProtocol.QueryRequest;
|
|
15
|
+
export declare class TestBuilder extends Resource {
|
|
16
|
+
#private;
|
|
17
|
+
constructor({ numPeers, spaceId, feedNamespace, logSql, }: {
|
|
18
|
+
numPeers: number;
|
|
19
|
+
spaceId: SpaceId;
|
|
20
|
+
feedNamespace?: string;
|
|
21
|
+
logSql?: boolean;
|
|
22
|
+
});
|
|
23
|
+
get peers(): TestPeer[];
|
|
24
|
+
get server(): TestPeer;
|
|
25
|
+
protected _open(): Promise<void>;
|
|
26
|
+
protected _close(): Promise<void>;
|
|
27
|
+
pull(client: TestPeer, { limit }?: {
|
|
28
|
+
limit?: number;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
done: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
push(client: TestPeer, { limit }?: {
|
|
33
|
+
limit?: number;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
done: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export declare class TestPeer extends Resource {
|
|
39
|
+
#private;
|
|
40
|
+
constructor({ isServer, actorId, serverPeerId, sendMessage, logSql, }: {
|
|
41
|
+
isServer: boolean;
|
|
42
|
+
actorId: string;
|
|
43
|
+
serverPeerId?: string;
|
|
44
|
+
sendMessage: (msg: ProtocolMessage) => Effect.Effect<void, unknown, never>;
|
|
45
|
+
logSql?: boolean;
|
|
46
|
+
});
|
|
47
|
+
get peerId(): string;
|
|
48
|
+
get feedStore(): FeedStore;
|
|
49
|
+
get runtime(): ManagedRuntime.ManagedRuntime<SqlClient.SqlClient | SqlTransaction.SqlTransaction | SqlExport.SqlExport, never>;
|
|
50
|
+
get syncClient(): SyncClient | undefined;
|
|
51
|
+
get syncServer(): SyncServer | undefined;
|
|
52
|
+
protected _open(): Promise<void>;
|
|
53
|
+
protected _close(): Promise<void>;
|
|
54
|
+
export(): Promise<Uint8Array>;
|
|
55
|
+
getSyncState({ spaceId, feedNamespace }: {
|
|
56
|
+
spaceId: SpaceId;
|
|
57
|
+
feedNamespace: string;
|
|
58
|
+
}): Promise<number>;
|
|
59
|
+
query(req: QueryRequest): Promise<FeedProtocol.QueryResponse>;
|
|
60
|
+
append(req: AppendRequest): Promise<FeedProtocol.AppendResponse>;
|
|
61
|
+
appendLocal(req: Parameters<FeedStore['appendLocal']>[0]): Promise<FeedProtocol.Block[]>;
|
|
62
|
+
pull({ spaceId, feedNamespace, limit }: {
|
|
63
|
+
spaceId: SpaceId;
|
|
64
|
+
feedNamespace: string;
|
|
65
|
+
limit?: number;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
done: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
push({ spaceId, feedNamespace, limit }: {
|
|
70
|
+
spaceId: SpaceId;
|
|
71
|
+
feedNamespace: string;
|
|
72
|
+
limit?: number;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
done: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=test-builder.d.ts.map
|
|
@@ -0,0 +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,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