@dxos/echo-pipeline 0.5.1-main.a94bc56 → 0.5.1-main.ac072cc

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.
Files changed (57) hide show
  1. package/dist/lib/browser/{chunk-KMWJLYEQ.mjs → chunk-RESTOZPT.mjs} +17 -17
  2. package/dist/lib/browser/{chunk-KMWJLYEQ.mjs.map → chunk-RESTOZPT.mjs.map} +2 -2
  3. package/dist/lib/browser/index.mjs +402 -149
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +2 -8
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/{chunk-YZA42CKA.cjs → chunk-D25ZFWEF.cjs} +20 -20
  9. package/dist/lib/node/{chunk-YZA42CKA.cjs.map → chunk-D25ZFWEF.cjs.map} +2 -2
  10. package/dist/lib/node/index.cjs +412 -166
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +13 -18
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/types/src/automerge/automerge-doc-loader.d.ts +1 -1
  16. package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
  17. package/dist/types/src/automerge/automerge-host.d.ts +14 -5
  18. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  19. package/dist/types/src/automerge/echo-network-adapter.d.ts +26 -0
  20. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -0
  21. package/dist/types/src/automerge/echo-replicator.d.ts +43 -0
  22. package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -0
  23. package/dist/types/src/automerge/index.d.ts +1 -2
  24. package/dist/types/src/automerge/index.d.ts.map +1 -1
  25. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +1 -1
  26. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
  27. package/dist/types/src/automerge/migrations.d.ts +1 -1
  28. package/dist/types/src/automerge/migrations.d.ts.map +1 -1
  29. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  30. package/dist/types/src/testing/index.d.ts +0 -1
  31. package/dist/types/src/testing/index.d.ts.map +1 -1
  32. package/package.json +33 -30
  33. package/src/automerge/automerge-doc-loader.test.ts +1 -1
  34. package/src/automerge/automerge-doc-loader.ts +4 -3
  35. package/src/automerge/automerge-host.test.ts +11 -3
  36. package/src/automerge/automerge-host.ts +62 -10
  37. package/src/automerge/automerge-repo.test.ts +1 -1
  38. package/src/automerge/echo-network-adapter.ts +155 -0
  39. package/src/automerge/echo-replicator.ts +56 -0
  40. package/src/automerge/index.ts +1 -2
  41. package/src/automerge/leveldb-storage-adapter.ts +1 -2
  42. package/src/automerge/migrations.ts +1 -1
  43. package/src/automerge/storage-adapter.test.ts +1 -1
  44. package/src/pipeline/pipeline.ts +1 -0
  45. package/src/testing/index.ts +0 -1
  46. package/dist/types/src/automerge/level.test.d.ts +0 -2
  47. package/dist/types/src/automerge/level.test.d.ts.map +0 -1
  48. package/dist/types/src/automerge/reference.d.ts +0 -15
  49. package/dist/types/src/automerge/reference.d.ts.map +0 -1
  50. package/dist/types/src/automerge/types.d.ts +0 -73
  51. package/dist/types/src/automerge/types.d.ts.map +0 -1
  52. package/dist/types/src/testing/level.d.ts +0 -3
  53. package/dist/types/src/testing/level.d.ts.map +0 -1
  54. package/src/automerge/level.test.ts +0 -114
  55. package/src/automerge/reference.ts +0 -31
  56. package/src/automerge/types.ts +0 -86
  57. package/src/testing/level.ts +0 -12
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { Event } from '@dxos/async';
6
- import { type Doc, next as automerge, getBackend, type Heads } from '@dxos/automerge/automerge';
6
+ import { type Doc, next as automerge, getBackend, type Heads, getHeads } from '@dxos/automerge/automerge';
7
7
  import {
8
8
  type DocHandle,
9
9
  Repo,
@@ -14,9 +14,13 @@ import {
14
14
  } from '@dxos/automerge/automerge-repo';
15
15
  import { type Stream } from '@dxos/codec-protobuf';
16
16
  import { Context, type Lifecycle } from '@dxos/context';
17
+ import { type SpaceDoc } from '@dxos/echo-protocol';
18
+ import { type IndexMetadataStore } from '@dxos/indexing';
17
19
  import { invariant } from '@dxos/invariant';
18
20
  import { PublicKey } from '@dxos/keys';
21
+ import { type SubLevelDB } from '@dxos/kv-store';
19
22
  import { log } from '@dxos/log';
23
+ import { idCodec } from '@dxos/protocols';
20
24
  import {
21
25
  type FlushRequest,
22
26
  type HostInfo,
@@ -28,11 +32,12 @@ import { type AutomergeReplicator } from '@dxos/teleport-extension-automerge-rep
28
32
  import { trace } from '@dxos/tracing';
29
33
  import { ComplexMap, ComplexSet, defaultMap, mapValues } from '@dxos/util';
30
34
 
31
- import { LevelDBStorageAdapter, type StorageCallbacks } from './leveldb-storage-adapter';
35
+ import { EchoNetworkAdapter } from './echo-network-adapter';
36
+ import { type EchoReplicator } from './echo-replicator';
37
+ import { type BeforeSaveParams, LevelDBStorageAdapter } from './leveldb-storage-adapter';
32
38
  import { LocalHostNetworkAdapter } from './local-host-network-adapter';
33
39
  import { MeshNetworkAdapter } from './mesh-network-adapter';
34
40
  import { levelMigration } from './migrations';
35
- import { type SpaceDoc, type SubLevelDB } from './types';
36
41
 
37
42
  // TODO: Remove
38
43
  export type { DocumentId };
@@ -43,15 +48,17 @@ export type AutomergeHostParams = {
43
48
  * For migration purposes.
44
49
  */
45
50
  directory?: Directory;
46
- storageCallbacks?: StorageCallbacks;
51
+
52
+ indexMetadataStore: IndexMetadataStore;
47
53
  };
48
54
 
49
55
  @trace.resource()
50
56
  export class AutomergeHost {
57
+ private readonly _indexMetadataStore: IndexMetadataStore;
51
58
  private readonly _ctx = new Context();
52
59
  private readonly _directory?: Directory;
53
60
  private readonly _db: SubLevelDB;
54
- private readonly _storageCallbacks?: StorageCallbacks;
61
+ private readonly _echoNetworkAdapter = new EchoNetworkAdapter();
55
62
 
56
63
  private _repo!: Repo;
57
64
  private _meshNetwork!: MeshNetworkAdapter;
@@ -68,10 +75,10 @@ export class AutomergeHost {
68
75
 
69
76
  public _requestedDocs = new Set<string>();
70
77
 
71
- constructor({ directory, db, storageCallbacks }: AutomergeHostParams) {
78
+ constructor({ directory, db, indexMetadataStore }: AutomergeHostParams) {
72
79
  this._directory = directory;
73
80
  this._db = db;
74
- this._storageCallbacks = storageCallbacks;
81
+ this._indexMetadataStore = indexMetadataStore;
75
82
  }
76
83
 
77
84
  async open() {
@@ -79,16 +86,20 @@ export class AutomergeHost {
79
86
  this._directory && (await levelMigration({ db: this._db, directory: this._directory }));
80
87
  this._storage = new LevelDBStorageAdapter({
81
88
  db: this._db,
82
- callbacks: this._storageCallbacks,
89
+ callbacks: {
90
+ beforeSave: async (params) => this._beforeSave(params),
91
+ afterSave: async () => this._afterSave(),
92
+ },
83
93
  });
84
94
  await this._storage.open?.();
85
95
  this._peerId = `host-${PublicKey.random().toHex()}` as PeerId;
86
96
 
87
97
  this._meshNetwork = new MeshNetworkAdapter();
88
98
  this._clientNetwork = new LocalHostNetworkAdapter();
99
+
89
100
  this._repo = new Repo({
90
101
  peerId: this._peerId as PeerId,
91
- network: [this._clientNetwork, this._meshNetwork],
102
+ network: [this._clientNetwork, this._meshNetwork, this._echoNetworkAdapter],
92
103
  storage: this._storage,
93
104
 
94
105
  // TODO(dmaretskyi): Share based on HALO permissions and space affinity.
@@ -102,6 +113,11 @@ export class AutomergeHost {
102
113
  return false;
103
114
  }
104
115
 
116
+ const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
117
+ if ((peerMetadata as any)?.dxos_peerSource === 'EchoNetworkAdapter') {
118
+ return this._echoNetworkAdapter.shouldAdvertize(peerId, { documentId });
119
+ }
120
+
105
121
  const doc = this._repo.handles[documentId]?.docSync();
106
122
  if (!doc) {
107
123
  const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
@@ -119,7 +135,7 @@ export class AutomergeHost {
119
135
  const authorizedDevices = this._authorizedDevices.get(PublicKey.from(spaceKey));
120
136
 
121
137
  // TODO(mykola): Hack, stop abusing `peerMetadata` field.
122
- const deviceKeyHex = (this.repo.peerMetadataByPeerId[peerId] as any)?.dxos_deviceKey;
138
+ const deviceKeyHex = (peerMetadata as any)?.dxos_deviceKey;
123
139
  if (!deviceKeyHex) {
124
140
  log('device key not found for share policy check', { peerId, documentId });
125
141
  return false;
@@ -144,13 +160,16 @@ export class AutomergeHost {
144
160
  });
145
161
  this._clientNetwork.ready();
146
162
  this._meshNetwork.ready();
163
+ await this._echoNetworkAdapter.open();
147
164
 
148
165
  await this._clientNetwork.whenConnected();
166
+ await this._echoNetworkAdapter.whenConnected();
149
167
  }
150
168
 
151
169
  async close() {
152
170
  await this._storage.close?.();
153
171
  await this._clientNetwork.close();
172
+ await this._echoNetworkAdapter.close();
154
173
  await this._ctx.dispose();
155
174
  }
156
175
 
@@ -158,6 +177,39 @@ export class AutomergeHost {
158
177
  return this._repo;
159
178
  }
160
179
 
180
+ async addReplicator(replicator: EchoReplicator) {
181
+ await this._echoNetworkAdapter.addReplicator(replicator);
182
+ }
183
+
184
+ async removeReplicator(replicator: EchoReplicator) {
185
+ await this._echoNetworkAdapter.removeReplicator(replicator);
186
+ }
187
+
188
+ private async _beforeSave({ path, batch }: BeforeSaveParams) {
189
+ const handle = this._repo.handles[path[0] as DocumentId];
190
+ if (!handle) {
191
+ return;
192
+ }
193
+ const doc = handle.docSync();
194
+ if (!doc) {
195
+ return;
196
+ }
197
+
198
+ const lastAvailableHash = getHeads(doc);
199
+
200
+ const objectIds = Object.keys(doc.objects ?? {});
201
+ const encodedIds = objectIds.map((objectId) => idCodec.encode({ documentId: handle.documentId, objectId }));
202
+ const idToLastHash = new Map(encodedIds.map((id) => [id, lastAvailableHash]));
203
+ this._indexMetadataStore.markDirty(idToLastHash, batch);
204
+ }
205
+
206
+ /**
207
+ * Called by AutomergeStorageAdapter after levelDB batch commit.
208
+ */
209
+ private async _afterSave() {
210
+ this._indexMetadataStore.notifyMarkedDirty();
211
+ }
212
+
161
213
  @trace.info({ depth: null })
162
214
  private _automergeDocs() {
163
215
  return mapValues(this._repo.handles, (handle) => ({
@@ -7,10 +7,10 @@ import { expect } from 'chai';
7
7
  import { change, clone, from, getBackend, getHeads } from '@dxos/automerge/automerge';
8
8
  import { Repo } from '@dxos/automerge/automerge-repo';
9
9
  import { randomBytes } from '@dxos/crypto';
10
+ import { createTestLevel } from '@dxos/kv-store/testing';
10
11
  import { describe, openAndClose, test } from '@dxos/test';
11
12
 
12
13
  import { LevelDBStorageAdapter } from './leveldb-storage-adapter';
13
- import { createTestLevel } from '../testing';
14
14
 
15
15
  describe('AutomergeRepo', () => {
16
16
  test('flush', async () => {
@@ -0,0 +1,155 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Trigger, synchronized } from '@dxos/async';
6
+ import { type Message, NetworkAdapter, type PeerId, type PeerMetadata } from '@dxos/automerge/automerge-repo';
7
+ import { LifecycleState } from '@dxos/context';
8
+ import { invariant } from '@dxos/invariant';
9
+ import { log } from '@dxos/log';
10
+
11
+ import { type EchoReplicator, type ReplicatorConnection, type ShouldAdvertizeParams } from './echo-replicator';
12
+
13
+ /**
14
+ * Manages a set of {@link EchoReplicator} instances.
15
+ */
16
+ export class EchoNetworkAdapter extends NetworkAdapter {
17
+ private readonly _replicators = new Set<EchoReplicator>();
18
+ /**
19
+ * Remote peer id -> connection.
20
+ */
21
+ private readonly _connections = new Map<PeerId, ConnectionEntry>();
22
+ private _lifecycleState: LifecycleState = LifecycleState.CLOSED;
23
+ private readonly _connected = new Trigger();
24
+
25
+ override connect(peerId: PeerId, peerMetadata?: PeerMetadata | undefined): void {
26
+ this.peerId = peerId;
27
+ this.peerMetadata = peerMetadata;
28
+ this._connected.wake();
29
+ }
30
+
31
+ override send(message: Message): void {
32
+ const connectionEntry = this._connections.get(message.targetId);
33
+ if (!connectionEntry) {
34
+ throw new Error('Connection not found.');
35
+ }
36
+
37
+ // TODO(dmaretskyi): Find a way to enforce backpressure on AM-repo.
38
+ connectionEntry.writer.write(message).catch((err) => {
39
+ if (connectionEntry.isOpen) {
40
+ log.catch(err);
41
+ }
42
+ });
43
+ }
44
+
45
+ override disconnect(): void {
46
+ // No-op
47
+ }
48
+
49
+ @synchronized
50
+ async open() {
51
+ invariant(this._lifecycleState === LifecycleState.CLOSED);
52
+ this._lifecycleState = LifecycleState.OPEN;
53
+
54
+ this.emit('ready', {
55
+ network: this,
56
+ });
57
+ }
58
+
59
+ @synchronized
60
+ async close() {
61
+ invariant(this._lifecycleState === LifecycleState.OPEN);
62
+
63
+ for (const replicator of this._replicators) {
64
+ await replicator.disconnect();
65
+ }
66
+ this._replicators.clear();
67
+
68
+ this._lifecycleState = LifecycleState.CLOSED;
69
+ }
70
+
71
+ async whenConnected() {
72
+ await this._connected.wait({ timeout: 10_000 });
73
+ }
74
+
75
+ @synchronized
76
+ async addReplicator(replicator: EchoReplicator) {
77
+ invariant(this.peerId);
78
+ invariant(!this._replicators.has(replicator));
79
+
80
+ await replicator.connect({
81
+ peerId: this.peerId,
82
+ onConnectionOpen: this._onConnectionOpen.bind(this),
83
+ onConnectionClosed: this._onConnectionClosed.bind(this),
84
+ });
85
+ }
86
+
87
+ @synchronized
88
+ async removeReplicator(replicator: EchoReplicator) {
89
+ invariant(this._replicators.has(replicator));
90
+ await replicator.disconnect();
91
+ }
92
+
93
+ async shouldAdvertize(peerId: PeerId, params: ShouldAdvertizeParams): Promise<boolean> {
94
+ const connection = this._connections.get(peerId);
95
+ if (!connection) {
96
+ return false;
97
+ }
98
+
99
+ return connection.connection.shouldAdvertize(params);
100
+ }
101
+
102
+ private _onConnectionOpen(connection: ReplicatorConnection) {
103
+ invariant(!this._connections.has(connection.peerId as PeerId));
104
+ const reader = connection.readable.getReader();
105
+ const writer = connection.writable.getWriter();
106
+ const connectionEntry: ConnectionEntry = { connection, reader, writer, isOpen: true };
107
+ this._connections.set(connection.peerId as PeerId, connectionEntry);
108
+
109
+ queueMicrotask(async () => {
110
+ try {
111
+ while (true) {
112
+ // TODO(dmaretskyi): Find a way to enforce backpressure on AM-repo.
113
+ const { done, value } = await reader.read();
114
+ if (done) {
115
+ break;
116
+ }
117
+
118
+ this.emit('message', value);
119
+ }
120
+ } catch (err) {
121
+ if (connectionEntry.isOpen) {
122
+ log.catch(err);
123
+ }
124
+ }
125
+ });
126
+
127
+ this.emit('peer-candidate', {
128
+ peerId: connection.peerId as PeerId,
129
+ peerMetadata: {
130
+ // TODO(dmaretskyi): Refactor this.
131
+ dxos_peerSource: 'EchoNetworkAdapter',
132
+ } as any,
133
+ });
134
+ }
135
+
136
+ private _onConnectionClosed(connection: ReplicatorConnection) {
137
+ const entry = this._connections.get(connection.peerId as PeerId);
138
+ invariant(entry);
139
+
140
+ entry.isOpen = false;
141
+ this.emit('peer-disconnected', { peerId: connection.peerId as PeerId });
142
+
143
+ void entry.reader.cancel().catch((err) => log.catch(err));
144
+ void entry.writer.abort().catch((err) => log.catch(err));
145
+
146
+ this._connections.delete(connection.peerId as PeerId);
147
+ }
148
+ }
149
+
150
+ type ConnectionEntry = {
151
+ connection: ReplicatorConnection;
152
+ reader: ReadableStreamDefaultReader<Message>;
153
+ writer: WritableStreamDefaultWriter<Message>;
154
+ isOpen: boolean;
155
+ };
@@ -0,0 +1,56 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Message } from '@dxos/automerge/automerge-repo';
6
+
7
+ export interface EchoReplicator {
8
+ /**
9
+ * Called on when replicator is added to EchoHost.
10
+ */
11
+ connect(context: EchoReplicatorContext): Promise<void>;
12
+
13
+ /**
14
+ * Called on when replicator is removed from EchoHost.
15
+ */
16
+ disconnect(): Promise<void>;
17
+ }
18
+
19
+ export interface EchoReplicatorContext {
20
+ /**
21
+ * Our own peer id.
22
+ */
23
+ get peerId(): string;
24
+
25
+ onConnectionOpen(connection: ReplicatorConnection): void;
26
+
27
+ onConnectionClosed(connection: ReplicatorConnection): void;
28
+ }
29
+
30
+ export interface ReplicatorConnection {
31
+ /**
32
+ * Remove peer id.
33
+ */
34
+ get peerId(): string;
35
+
36
+ /**
37
+ * Stream to read messages coming from the remote peer.
38
+ */
39
+ readable: ReadableStream<Message>;
40
+
41
+ /**
42
+ * Stream to write messages to the remote peer.
43
+ */
44
+ writable: WritableStream<Message>;
45
+
46
+ /**
47
+ * @returns true if the document should be advertized to this peer.
48
+ *
49
+ * The remote peer can still request the document by it's id bypassing this check.
50
+ */
51
+ shouldAdvertize(params: ShouldAdvertizeParams): Promise<boolean>;
52
+ }
53
+
54
+ export type ShouldAdvertizeParams = {
55
+ documentId: string;
56
+ };
@@ -8,5 +8,4 @@ export * from './automerge-doc-loader';
8
8
  export * from './leveldb-storage-adapter';
9
9
  export * from './local-host-network-adapter';
10
10
  export * from './mesh-network-adapter';
11
- export * from './types';
12
- export * from './reference';
11
+ export * from './echo-replicator';
@@ -6,10 +6,9 @@ import { type MixedEncoding } from 'level-transcoder';
6
6
 
7
7
  import { type StorageAdapterInterface, type Chunk, type StorageKey } from '@dxos/automerge/automerge-repo';
8
8
  import { LifecycleState, Resource } from '@dxos/context';
9
+ import { type BatchLevel, type SubLevelDB } from '@dxos/kv-store';
9
10
  import { type MaybePromise } from '@dxos/util';
10
11
 
11
- import { type BatchLevel, type SubLevelDB } from './types';
12
-
13
12
  export type LevelDBStorageAdapterParams = {
14
13
  db: SubLevelDB;
15
14
  callbacks?: StorageCallbacks;
@@ -4,12 +4,12 @@
4
4
 
5
5
  import { type StorageKey } from '@dxos/automerge/automerge-repo';
6
6
  import { IndexedDBStorageAdapter } from '@dxos/automerge/automerge-repo-storage-indexeddb';
7
+ import { type SubLevelDB } from '@dxos/kv-store';
7
8
  import { log } from '@dxos/log';
8
9
  import { StorageType, type Directory } from '@dxos/random-access-storage';
9
10
 
10
11
  import { AutomergeStorageAdapter } from './automerge-storage-adapter';
11
12
  import { encodingOptions } from './leveldb-storage-adapter';
12
- import { type SubLevelDB } from './types';
13
13
 
14
14
  export const levelMigration = async ({ db, directory }: { db: SubLevelDB; directory: Directory }) => {
15
15
  // Note: Make automigration from previous storage to leveldb here.
@@ -6,13 +6,13 @@ import { expect } from 'chai';
6
6
 
7
7
  import { type StorageAdapterInterface } from '@dxos/automerge/automerge-repo';
8
8
  import { PublicKey } from '@dxos/keys';
9
+ import { createTestLevel } from '@dxos/kv-store/testing';
9
10
  import { StorageType, createStorage } from '@dxos/random-access-storage';
10
11
  import { afterTest, describe, openAndClose, test } from '@dxos/test';
11
12
  import { type MaybePromise } from '@dxos/util';
12
13
 
13
14
  import { AutomergeStorageAdapter } from './automerge-storage-adapter';
14
15
  import { LevelDBStorageAdapter } from './leveldb-storage-adapter';
15
- import { createTestLevel } from '../testing';
16
16
 
17
17
  const runTests = (
18
18
  testNamespace: string,
@@ -172,6 +172,7 @@ export class PipelineState {
172
172
  }
173
173
  }
174
174
 
175
+ // TODO(mykola): Extract to `@dxos/echo-protocol`
175
176
  export interface PipelineAccessor {
176
177
  state: PipelineState;
177
178
  writer: FeedWriter<FeedMessage.Payload>;
@@ -5,4 +5,3 @@
5
5
  export * from './change-metadata';
6
6
  export * from './test-agent-builder';
7
7
  export * from './test-feed-builder';
8
- export * from './level';
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=level.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"level.test.d.ts","sourceRoot":"","sources":["../../../../src/automerge/level.test.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- import { Reference } from '@dxos/echo-schema';
2
- export declare const REFERENCE_TYPE_TAG = "dxos.echo.model.document.Reference";
3
- /**
4
- * Reference as it is stored in Automerge document.
5
- */
6
- export type EncodedReferenceObject = {
7
- '@type': typeof REFERENCE_TYPE_TAG;
8
- itemId: string | null;
9
- protocol: string | null;
10
- host: string | null;
11
- };
12
- export declare const encodeReference: (reference: Reference) => EncodedReferenceObject;
13
- export declare const decodeReference: (value: any) => Reference;
14
- export declare const isEncodedReferenceObject: (value: any) => value is EncodedReferenceObject;
15
- //# sourceMappingURL=reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../../src/automerge/reference.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,kBAAkB,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe,cAAe,SAAS,KAAG,sBAMrD,CAAC;AAEH,eAAO,MAAM,eAAe,UAAW,GAAG,cACyC,CAAC;AAEpF,eAAO,MAAM,wBAAwB,UAAW,GAAG,oCACmC,CAAC"}
@@ -1,73 +0,0 @@
1
- /// <reference types="node" />
2
- import { type AbstractChainedBatch, type AbstractSublevel } from 'abstract-level';
3
- import { type Level } from 'level';
4
- import { type EncodedReferenceObject } from './reference';
5
- export type SpaceState = {
6
- rootUrl?: string;
7
- };
8
- export interface SpaceDoc {
9
- access?: {
10
- spaceKey: string;
11
- };
12
- /**
13
- * Objects inlined in the current document.
14
- */
15
- objects?: {
16
- [key: string]: ObjectStructure;
17
- };
18
- /**
19
- * Object id points to an automerge doc url where the object is embedded.
20
- */
21
- links?: {
22
- [echoId: string]: string;
23
- };
24
- }
25
- /**
26
- * Representation of an ECHO object in an AM document.
27
- */
28
- export type ObjectStructure = {
29
- data: Record<string, any>;
30
- meta: ObjectMeta;
31
- system: ObjectSystem;
32
- };
33
- /**
34
- * Echo object metadata.
35
- */
36
- export type ObjectMeta = {
37
- /**
38
- * Foreign keys.
39
- */
40
- keys: ForeignKey[];
41
- };
42
- /**
43
- * Reference to an object in a foreign database.
44
- */
45
- export type ForeignKey = {
46
- /**
47
- * Name of the foreign database/system.
48
- * E.g. `github.com`.
49
- */
50
- source?: string;
51
- /**
52
- * Id within the foreign database.
53
- */
54
- id?: string;
55
- };
56
- /**
57
- * Automerge object system properties.
58
- * (Is automerge specific.)
59
- */
60
- export type ObjectSystem = {
61
- /**
62
- * Deletion marker.
63
- */
64
- deleted?: boolean;
65
- /**
66
- * Object reference ('protobuf' protocol) type.
67
- */
68
- type?: EncodedReferenceObject;
69
- };
70
- export type LevelDB = Level<string, string>;
71
- export type SubLevelDB = AbstractSublevel<any, string | Buffer | Uint8Array, string, any>;
72
- export type BatchLevel = AbstractChainedBatch<any, string, string>;
73
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/automerge/types.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,UAAU,GAAG;IAEvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;KAChC,CAAC;IACF;;OAEG;IACH,KAAK,CAAC,EAAE;QACN,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;KAC1B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1F,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type LevelDB } from '../automerge/types';
2
- export declare const createTestLevel: (path?: string) => LevelDB;
3
- //# sourceMappingURL=level.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../../src/testing/level.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,eAAe,qBAAuD,OAClD,CAAC"}