@dxos/teleport-extension-object-sync 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.mjs +688 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/src/blob-store.d.ts +8 -0
- package/dist/types/src/blob-store.d.ts.map +1 -1
- package/dist/types/src/sqlite-blob-store.d.ts +6 -1
- package/dist/types/src/sqlite-blob-store.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/blob-store.ts +9 -0
- package/src/sqlite-blob-store.ts +18 -1
- package/dist/lib/neutral/index.mjs +0 -676
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/teleport-extension-object-sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Teleport extension to synchronize opaque data objects.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"source": "./src/index.ts",
|
|
18
18
|
"types": "./dist/types/src/index.d.ts",
|
|
19
|
-
"
|
|
19
|
+
"import": "./dist/lib/index.mjs"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@effect/sql": "0.51.1",
|
|
29
29
|
"effect": "3.21.4",
|
|
30
|
-
"@dxos/async": "0.
|
|
31
|
-
"@dxos/context": "0.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/sql-sqlite": "0.
|
|
41
|
-
"@dxos/teleport": "0.
|
|
42
|
-
"@dxos/util": "0.
|
|
30
|
+
"@dxos/async": "0.11.0",
|
|
31
|
+
"@dxos/context": "0.11.0",
|
|
32
|
+
"@dxos/effect": "0.11.0",
|
|
33
|
+
"@dxos/crypto": "0.11.0",
|
|
34
|
+
"@dxos/invariant": "0.11.0",
|
|
35
|
+
"@dxos/node-std": "0.11.0",
|
|
36
|
+
"@dxos/log": "0.11.0",
|
|
37
|
+
"@dxos/keys": "0.11.0",
|
|
38
|
+
"@dxos/random-access-storage": "0.11.0",
|
|
39
|
+
"@dxos/protocols": "0.11.0",
|
|
40
|
+
"@dxos/sql-sqlite": "0.11.0",
|
|
41
|
+
"@dxos/teleport": "0.11.0",
|
|
42
|
+
"@dxos/util": "0.11.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
package/src/blob-store.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as EffectContext from 'effect/Context';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
|
|
7
8
|
import { synchronized } from '@dxos/async';
|
|
@@ -32,6 +33,14 @@ export interface BlobStoreApi {
|
|
|
32
33
|
list(): Promise<BlobMeta[]>;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Effect service tag for {@link BlobStoreApi}.
|
|
38
|
+
*/
|
|
39
|
+
export class BlobStoreApiService extends EffectContext.Tag('@dxos/teleport-extension-object-sync/BlobStoreApi')<
|
|
40
|
+
BlobStoreApiService,
|
|
41
|
+
BlobStoreApi
|
|
42
|
+
>() {}
|
|
43
|
+
|
|
35
44
|
const BlobMetaCodec = schema.getCodecForType('dxos.echo.blob.BlobMeta');
|
|
36
45
|
|
|
37
46
|
export class BlobStore implements BlobStoreApi {
|
package/src/sqlite-blob-store.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as SqlClient from '@effect/sql/SqlClient';
|
|
6
6
|
import type * as SqlError from '@effect/sql/SqlError';
|
|
7
7
|
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
8
9
|
|
|
9
10
|
import { synchronized } from '@dxos/async';
|
|
10
11
|
import { subtleCrypto } from '@dxos/crypto';
|
|
@@ -17,7 +18,7 @@ import { type BlobChunk } from '@dxos/protocols/proto/dxos/mesh/teleport/blobsyn
|
|
|
17
18
|
import { SqlTransaction } from '@dxos/sql-sqlite';
|
|
18
19
|
import { BitField, arrayToBuffer } from '@dxos/util';
|
|
19
20
|
|
|
20
|
-
import { type BlobStoreApi, DEFAULT_CHUNK_SIZE, type GetOptions } from './blob-store';
|
|
21
|
+
import { type BlobStoreApi, BlobStoreApiService, DEFAULT_CHUNK_SIZE, type GetOptions } from './blob-store';
|
|
21
22
|
|
|
22
23
|
const BlobMetaCodec = schema.getCodecForType('dxos.echo.blob.BlobMeta');
|
|
23
24
|
|
|
@@ -226,3 +227,19 @@ export class SqliteBlobStore implements BlobStoreApi {
|
|
|
226
227
|
return rows[0].data;
|
|
227
228
|
}
|
|
228
229
|
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Effect Layer constructing a {@link SqliteBlobStore} from the ambient SQL runtime.
|
|
233
|
+
*/
|
|
234
|
+
export const SqliteBlobStoreLayer = (): Layer.Layer<
|
|
235
|
+
BlobStoreApiService,
|
|
236
|
+
never,
|
|
237
|
+
SqlClient.SqlClient | SqlTransactionTag
|
|
238
|
+
> =>
|
|
239
|
+
Layer.effect(
|
|
240
|
+
BlobStoreApiService,
|
|
241
|
+
Effect.gen(function* () {
|
|
242
|
+
const runtime = yield* RuntimeProvider.currentRuntime<SqlClient.SqlClient | SqlTransactionTag>();
|
|
243
|
+
return new SqliteBlobStore({ runtime });
|
|
244
|
+
}),
|
|
245
|
+
);
|