@syncular/server 0.0.1-98 → 0.0.2-126

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 (106) hide show
  1. package/README.md +25 -0
  2. package/dist/blobs/adapters/filesystem.d.ts +31 -0
  3. package/dist/blobs/adapters/filesystem.d.ts.map +1 -0
  4. package/dist/blobs/adapters/filesystem.js +140 -0
  5. package/dist/blobs/adapters/filesystem.js.map +1 -0
  6. package/dist/blobs/adapters/s3.d.ts +3 -2
  7. package/dist/blobs/adapters/s3.d.ts.map +1 -1
  8. package/dist/blobs/adapters/s3.js +49 -0
  9. package/dist/blobs/adapters/s3.js.map +1 -1
  10. package/dist/blobs/index.d.ts +1 -0
  11. package/dist/blobs/index.d.ts.map +1 -1
  12. package/dist/blobs/index.js +1 -0
  13. package/dist/blobs/index.js.map +1 -1
  14. package/dist/compaction.d.ts +1 -1
  15. package/dist/compaction.js +1 -1
  16. package/dist/{shapes → handlers}/create-handler.d.ts +18 -5
  17. package/dist/handlers/create-handler.d.ts.map +1 -0
  18. package/dist/{shapes → handlers}/create-handler.js +54 -17
  19. package/dist/handlers/create-handler.js.map +1 -0
  20. package/dist/handlers/index.d.ts.map +1 -0
  21. package/dist/handlers/index.js.map +1 -0
  22. package/dist/handlers/registry.d.ts.map +1 -0
  23. package/dist/handlers/registry.js.map +1 -0
  24. package/dist/{shapes → handlers}/types.d.ts +7 -7
  25. package/dist/{shapes → handlers}/types.d.ts.map +1 -1
  26. package/dist/{shapes → handlers}/types.js.map +1 -1
  27. package/dist/helpers/conflict.d.ts +1 -1
  28. package/dist/helpers/conflict.d.ts.map +1 -1
  29. package/dist/helpers/emitted-change.d.ts +1 -1
  30. package/dist/helpers/emitted-change.d.ts.map +1 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/notify.d.ts +47 -0
  36. package/dist/notify.d.ts.map +1 -0
  37. package/dist/notify.js +85 -0
  38. package/dist/notify.js.map +1 -0
  39. package/dist/proxy/handler.d.ts +1 -1
  40. package/dist/proxy/handler.d.ts.map +1 -1
  41. package/dist/proxy/handler.js +7 -7
  42. package/dist/proxy/handler.js.map +1 -1
  43. package/dist/proxy/oplog.d.ts +1 -1
  44. package/dist/proxy/oplog.d.ts.map +1 -1
  45. package/dist/proxy/oplog.js +6 -6
  46. package/dist/proxy/oplog.js.map +1 -1
  47. package/dist/pull.d.ts +2 -2
  48. package/dist/pull.d.ts.map +1 -1
  49. package/dist/pull.js +48 -9
  50. package/dist/pull.js.map +1 -1
  51. package/dist/push.d.ts +2 -2
  52. package/dist/push.d.ts.map +1 -1
  53. package/dist/push.js +1 -1
  54. package/dist/push.js.map +1 -1
  55. package/dist/snapshot-chunks/db-metadata.d.ts.map +1 -1
  56. package/dist/snapshot-chunks/db-metadata.js +14 -3
  57. package/dist/snapshot-chunks/db-metadata.js.map +1 -1
  58. package/dist/snapshot-chunks/index.d.ts +0 -1
  59. package/dist/snapshot-chunks/index.d.ts.map +1 -1
  60. package/dist/snapshot-chunks/index.js +0 -1
  61. package/dist/snapshot-chunks/index.js.map +1 -1
  62. package/dist/subscriptions/resolve.d.ts +6 -6
  63. package/dist/subscriptions/resolve.d.ts.map +1 -1
  64. package/dist/subscriptions/resolve.js +53 -14
  65. package/dist/subscriptions/resolve.js.map +1 -1
  66. package/package.json +2 -2
  67. package/src/blobs/adapters/filesystem.test.ts +132 -0
  68. package/src/blobs/adapters/filesystem.ts +189 -0
  69. package/src/blobs/adapters/s3.test.ts +522 -0
  70. package/src/blobs/adapters/s3.ts +55 -2
  71. package/src/blobs/index.ts +1 -0
  72. package/src/compaction.ts +1 -1
  73. package/src/{shapes → handlers}/create-handler.ts +111 -21
  74. package/src/{shapes → handlers}/types.ts +10 -7
  75. package/src/helpers/conflict.ts +1 -1
  76. package/src/helpers/emitted-change.ts +1 -1
  77. package/src/index.ts +2 -1
  78. package/src/notify.test.ts +516 -0
  79. package/src/notify.ts +131 -0
  80. package/src/proxy/handler.test.ts +3 -3
  81. package/src/proxy/handler.ts +8 -8
  82. package/src/proxy/oplog.ts +7 -7
  83. package/src/pull.ts +66 -12
  84. package/src/push.ts +3 -3
  85. package/src/snapshot-chunks/db-metadata.test.ts +69 -0
  86. package/src/snapshot-chunks/db-metadata.ts +14 -3
  87. package/src/snapshot-chunks/index.ts +0 -1
  88. package/src/subscriptions/resolve.ts +73 -18
  89. package/dist/shapes/create-handler.d.ts.map +0 -1
  90. package/dist/shapes/create-handler.js.map +0 -1
  91. package/dist/shapes/index.d.ts.map +0 -1
  92. package/dist/shapes/index.js.map +0 -1
  93. package/dist/shapes/registry.d.ts.map +0 -1
  94. package/dist/shapes/registry.js.map +0 -1
  95. package/dist/snapshot-chunks/adapters/s3.d.ts +0 -74
  96. package/dist/snapshot-chunks/adapters/s3.d.ts.map +0 -1
  97. package/dist/snapshot-chunks/adapters/s3.js +0 -50
  98. package/dist/snapshot-chunks/adapters/s3.js.map +0 -1
  99. package/src/snapshot-chunks/adapters/s3.ts +0 -68
  100. /package/dist/{shapes → handlers}/index.d.ts +0 -0
  101. /package/dist/{shapes → handlers}/index.js +0 -0
  102. /package/dist/{shapes → handlers}/registry.d.ts +0 -0
  103. /package/dist/{shapes → handlers}/registry.js +0 -0
  104. /package/dist/{shapes → handlers}/types.js +0 -0
  105. /package/src/{shapes → handlers}/index.ts +0 -0
  106. /package/src/{shapes → handlers}/registry.ts +0 -0
@@ -1,74 +0,0 @@
1
- /**
2
- * @syncular/server - S3-compatible snapshot chunk storage adapter
3
- *
4
- * Stores snapshot chunk bodies in S3/R2/MinIO with metadata in database.
5
- */
6
- import type { BlobStorageAdapter } from '@syncular/core';
7
- import type { Kysely } from 'kysely';
8
- import type { SyncCoreDb } from '../../schema';
9
- export interface S3SnapshotChunkStorageOptions {
10
- /** Database instance for metadata */
11
- db: Kysely<SyncCoreDb>;
12
- /** S3 blob storage adapter */
13
- s3Adapter: BlobStorageAdapter;
14
- /** Optional key prefix for all chunks */
15
- keyPrefix?: string;
16
- }
17
- /**
18
- * Create S3-compatible snapshot chunk storage.
19
- *
20
- * Stores chunk bodies in S3/R2/MinIO and metadata in the database.
21
- * Supports presigned URLs for direct client downloads.
22
- *
23
- * @example
24
- * ```typescript
25
- * import { createS3BlobStorageAdapter } from '@syncular/server/blobs/adapters/s3';
26
- * import { createS3SnapshotChunkStorage } from '@syncular/server/snapshot-chunks/adapters/s3';
27
- *
28
- * const s3Adapter = createS3BlobStorageAdapter({
29
- * client: new S3Client({ region: 'us-east-1' }),
30
- * bucket: 'my-snapshot-chunks',
31
- * commands: { PutObjectCommand, GetObjectCommand, HeadObjectCommand, DeleteObjectCommand },
32
- * getSignedUrl,
33
- * });
34
- *
35
- * const chunkStorage = createS3SnapshotChunkStorage({
36
- * db: kysely,
37
- * s3Adapter,
38
- * keyPrefix: 'snapshots/',
39
- * });
40
- * ```
41
- */
42
- export declare function createS3SnapshotChunkStorage(options: S3SnapshotChunkStorageOptions): {
43
- name: string;
44
- storeChunk: (metadata: Omit<import("..").SnapshotChunkMetadata, "blobHash" | "byteLength" | "chunkId"> & {
45
- body: Uint8Array<ArrayBufferLike>;
46
- }) => Promise<{
47
- id: string;
48
- byteLength: number;
49
- sha256: string;
50
- encoding: "json-row-frame-v1";
51
- compression: "gzip";
52
- }>;
53
- storeChunkStream: (metadata: Omit<import("..").SnapshotChunkMetadata, "blobHash" | "byteLength" | "chunkId"> & {
54
- bodyStream: ReadableStream<Uint8Array<ArrayBufferLike>>;
55
- byteLength?: number | undefined;
56
- }) => Promise<{
57
- id: string;
58
- byteLength: number;
59
- sha256: string;
60
- encoding: "json-row-frame-v1";
61
- compression: "gzip";
62
- }>;
63
- readChunk: (chunkId: string) => Promise<Uint8Array<ArrayBufferLike> | null>;
64
- readChunkStream: (chunkId: string) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>> | null>;
65
- findChunk: (pageKey: import("..").SnapshotChunkPageKey) => Promise<{
66
- id: string;
67
- byteLength: number;
68
- sha256: string;
69
- encoding: "json-row-frame-v1";
70
- compression: "gzip";
71
- } | null>;
72
- cleanupExpired: (beforeIso: string) => Promise<number>;
73
- };
74
- //# sourceMappingURL=s3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"s3.d.ts","sourceRoot":"","sources":["../../../src/snapshot-chunks/adapters/s3.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,WAAW,6BAA6B;IAC5C,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IACvB,8BAA8B;IAC9B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBvC"}
@@ -1,50 +0,0 @@
1
- /**
2
- * @syncular/server - S3-compatible snapshot chunk storage adapter
3
- *
4
- * Stores snapshot chunk bodies in S3/R2/MinIO with metadata in database.
5
- */
6
- import { createDbMetadataChunkStorage } from '../db-metadata.js';
7
- /**
8
- * Create S3-compatible snapshot chunk storage.
9
- *
10
- * Stores chunk bodies in S3/R2/MinIO and metadata in the database.
11
- * Supports presigned URLs for direct client downloads.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { createS3BlobStorageAdapter } from '@syncular/server/blobs/adapters/s3';
16
- * import { createS3SnapshotChunkStorage } from '@syncular/server/snapshot-chunks/adapters/s3';
17
- *
18
- * const s3Adapter = createS3BlobStorageAdapter({
19
- * client: new S3Client({ region: 'us-east-1' }),
20
- * bucket: 'my-snapshot-chunks',
21
- * commands: { PutObjectCommand, GetObjectCommand, HeadObjectCommand, DeleteObjectCommand },
22
- * getSignedUrl,
23
- * });
24
- *
25
- * const chunkStorage = createS3SnapshotChunkStorage({
26
- * db: kysely,
27
- * s3Adapter,
28
- * keyPrefix: 'snapshots/',
29
- * });
30
- * ```
31
- */
32
- export function createS3SnapshotChunkStorage(options) {
33
- const { db, s3Adapter, keyPrefix } = options;
34
- // Wrap the S3 adapter to use prefixed keys
35
- const prefixedAdapter = keyPrefix
36
- ? {
37
- ...s3Adapter,
38
- name: `${s3Adapter.name}+prefixed`,
39
- // Keys are already handled by the S3 adapter, prefix is applied there
40
- }
41
- : s3Adapter;
42
- // Use the database metadata storage with S3 for bodies
43
- const storage = createDbMetadataChunkStorage({
44
- db,
45
- blobAdapter: prefixedAdapter,
46
- chunkIdPrefix: keyPrefix ? `${keyPrefix.replace(/\/$/, '')}_` : 'chunk_',
47
- });
48
- return storage;
49
- }
50
- //# sourceMappingURL=s3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"s3.js","sourceRoot":"","sources":["../../../src/snapshot-chunks/adapters/s3.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAW9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAsC,EACtC;IACA,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE7C,2CAA2C;IAC3C,MAAM,eAAe,GAAuB,SAAS;QACnD,CAAC,CAAC;YACE,GAAG,SAAS;YACZ,IAAI,EAAE,GAAG,SAAS,CAAC,IAAI,WAAW;YAClC,sEAAsE;SACvE;QACH,CAAC,CAAC,SAAS,CAAC;IAEd,uDAAuD;IACvD,MAAM,OAAO,GAAG,4BAA4B,CAAC;QAC3C,EAAE;QACF,WAAW,EAAE,eAAe;QAC5B,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ;KACzE,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AAAA,CAChB"}
@@ -1,68 +0,0 @@
1
- /**
2
- * @syncular/server - S3-compatible snapshot chunk storage adapter
3
- *
4
- * Stores snapshot chunk bodies in S3/R2/MinIO with metadata in database.
5
- */
6
-
7
- import type { BlobStorageAdapter } from '@syncular/core';
8
- import type { Kysely } from 'kysely';
9
- import type { SyncCoreDb } from '../../schema';
10
- import { createDbMetadataChunkStorage } from '../db-metadata';
11
-
12
- export interface S3SnapshotChunkStorageOptions {
13
- /** Database instance for metadata */
14
- db: Kysely<SyncCoreDb>;
15
- /** S3 blob storage adapter */
16
- s3Adapter: BlobStorageAdapter;
17
- /** Optional key prefix for all chunks */
18
- keyPrefix?: string;
19
- }
20
-
21
- /**
22
- * Create S3-compatible snapshot chunk storage.
23
- *
24
- * Stores chunk bodies in S3/R2/MinIO and metadata in the database.
25
- * Supports presigned URLs for direct client downloads.
26
- *
27
- * @example
28
- * ```typescript
29
- * import { createS3BlobStorageAdapter } from '@syncular/server/blobs/adapters/s3';
30
- * import { createS3SnapshotChunkStorage } from '@syncular/server/snapshot-chunks/adapters/s3';
31
- *
32
- * const s3Adapter = createS3BlobStorageAdapter({
33
- * client: new S3Client({ region: 'us-east-1' }),
34
- * bucket: 'my-snapshot-chunks',
35
- * commands: { PutObjectCommand, GetObjectCommand, HeadObjectCommand, DeleteObjectCommand },
36
- * getSignedUrl,
37
- * });
38
- *
39
- * const chunkStorage = createS3SnapshotChunkStorage({
40
- * db: kysely,
41
- * s3Adapter,
42
- * keyPrefix: 'snapshots/',
43
- * });
44
- * ```
45
- */
46
- export function createS3SnapshotChunkStorage(
47
- options: S3SnapshotChunkStorageOptions
48
- ) {
49
- const { db, s3Adapter, keyPrefix } = options;
50
-
51
- // Wrap the S3 adapter to use prefixed keys
52
- const prefixedAdapter: BlobStorageAdapter = keyPrefix
53
- ? {
54
- ...s3Adapter,
55
- name: `${s3Adapter.name}+prefixed`,
56
- // Keys are already handled by the S3 adapter, prefix is applied there
57
- }
58
- : s3Adapter;
59
-
60
- // Use the database metadata storage with S3 for bodies
61
- const storage = createDbMetadataChunkStorage({
62
- db,
63
- blobAdapter: prefixedAdapter,
64
- chunkIdPrefix: keyPrefix ? `${keyPrefix.replace(/\/$/, '')}_` : 'chunk_',
65
- });
66
-
67
- return storage;
68
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes