@syncular/server 0.0.1-60
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/blobs/adapters/database.d.ts +83 -0
- package/dist/blobs/adapters/database.d.ts.map +1 -0
- package/dist/blobs/adapters/database.js +180 -0
- package/dist/blobs/adapters/database.js.map +1 -0
- package/dist/blobs/adapters/s3.d.ts +82 -0
- package/dist/blobs/adapters/s3.d.ts.map +1 -0
- package/dist/blobs/adapters/s3.js +170 -0
- package/dist/blobs/adapters/s3.js.map +1 -0
- package/dist/blobs/index.d.ts +9 -0
- package/dist/blobs/index.d.ts.map +1 -0
- package/dist/blobs/index.js +9 -0
- package/dist/blobs/index.js.map +1 -0
- package/dist/blobs/manager.d.ts +195 -0
- package/dist/blobs/manager.d.ts.map +1 -0
- package/dist/blobs/manager.js +440 -0
- package/dist/blobs/manager.js.map +1 -0
- package/dist/blobs/migrate.d.ts +27 -0
- package/dist/blobs/migrate.d.ts.map +1 -0
- package/dist/blobs/migrate.js +119 -0
- package/dist/blobs/migrate.js.map +1 -0
- package/dist/blobs/types.d.ts +54 -0
- package/dist/blobs/types.d.ts.map +1 -0
- package/dist/blobs/types.js +5 -0
- package/dist/blobs/types.js.map +1 -0
- package/dist/clients.d.ts +14 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +7 -0
- package/dist/clients.js.map +1 -0
- package/dist/compaction.d.ts +27 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +49 -0
- package/dist/compaction.js.map +1 -0
- package/dist/dialect/index.d.ts +5 -0
- package/dist/dialect/index.d.ts.map +1 -0
- package/dist/dialect/index.js +5 -0
- package/dist/dialect/index.js.map +1 -0
- package/dist/dialect/types.d.ts +170 -0
- package/dist/dialect/types.d.ts.map +1 -0
- package/dist/dialect/types.js +8 -0
- package/dist/dialect/types.js.map +1 -0
- package/dist/helpers/conflict.d.ts +52 -0
- package/dist/helpers/conflict.d.ts.map +1 -0
- package/dist/helpers/conflict.js +49 -0
- package/dist/helpers/conflict.js.map +1 -0
- package/dist/helpers/emitted-change.d.ts +56 -0
- package/dist/helpers/emitted-change.d.ts.map +1 -0
- package/dist/helpers/emitted-change.js +46 -0
- package/dist/helpers/emitted-change.js.map +1 -0
- package/dist/helpers/index.d.ts +10 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +10 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/paginate.d.ts +49 -0
- package/dist/helpers/paginate.d.ts.map +1 -0
- package/dist/helpers/paginate.js +54 -0
- package/dist/helpers/paginate.js.map +1 -0
- package/dist/helpers/scope-strings.d.ts +74 -0
- package/dist/helpers/scope-strings.d.ts.map +1 -0
- package/dist/helpers/scope-strings.js +82 -0
- package/dist/helpers/scope-strings.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +14 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +13 -0
- package/dist/migrate.js.map +1 -0
- package/dist/proxy/handler.d.ts +42 -0
- package/dist/proxy/handler.d.ts.map +1 -0
- package/dist/proxy/handler.js +99 -0
- package/dist/proxy/handler.js.map +1 -0
- package/dist/proxy/index.d.ts +9 -0
- package/dist/proxy/index.d.ts.map +1 -0
- package/dist/proxy/index.js +14 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/proxy/mutation-detector.d.ts +31 -0
- package/dist/proxy/mutation-detector.d.ts.map +1 -0
- package/dist/proxy/mutation-detector.js +61 -0
- package/dist/proxy/mutation-detector.js.map +1 -0
- package/dist/proxy/oplog.d.ts +30 -0
- package/dist/proxy/oplog.d.ts.map +1 -0
- package/dist/proxy/oplog.js +110 -0
- package/dist/proxy/oplog.js.map +1 -0
- package/dist/proxy/registry.d.ts +35 -0
- package/dist/proxy/registry.d.ts.map +1 -0
- package/dist/proxy/registry.js +49 -0
- package/dist/proxy/registry.js.map +1 -0
- package/dist/proxy/types.d.ts +44 -0
- package/dist/proxy/types.d.ts.map +1 -0
- package/dist/proxy/types.js +7 -0
- package/dist/proxy/types.js.map +1 -0
- package/dist/prune.d.ts +37 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +112 -0
- package/dist/prune.js.map +1 -0
- package/dist/pull.d.ts +31 -0
- package/dist/pull.d.ts.map +1 -0
- package/dist/pull.js +414 -0
- package/dist/pull.js.map +1 -0
- package/dist/push.d.ts +33 -0
- package/dist/push.d.ts.map +1 -0
- package/dist/push.js +329 -0
- package/dist/push.js.map +1 -0
- package/dist/realtime/in-memory.d.ts +13 -0
- package/dist/realtime/in-memory.d.ts.map +1 -0
- package/dist/realtime/in-memory.js +28 -0
- package/dist/realtime/in-memory.js.map +1 -0
- package/dist/realtime/index.d.ts +3 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +2 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/types.d.ts +50 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/types.js +7 -0
- package/dist/realtime/types.js.map +1 -0
- package/dist/schema.d.ts +164 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +10 -0
- package/dist/schema.js.map +1 -0
- package/dist/shapes/create-handler.d.ts +119 -0
- package/dist/shapes/create-handler.d.ts.map +1 -0
- package/dist/shapes/create-handler.js +327 -0
- package/dist/shapes/create-handler.js.map +1 -0
- package/dist/shapes/index.d.ts +4 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +4 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/registry.d.ts +20 -0
- package/dist/shapes/registry.d.ts.map +1 -0
- package/dist/shapes/registry.js +88 -0
- package/dist/shapes/registry.js.map +1 -0
- package/dist/shapes/types.d.ts +204 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +2 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/snapshot-chunks/adapters/s3.d.ts +63 -0
- package/dist/snapshot-chunks/adapters/s3.d.ts.map +1 -0
- package/dist/snapshot-chunks/adapters/s3.js +50 -0
- package/dist/snapshot-chunks/adapters/s3.js.map +1 -0
- package/dist/snapshot-chunks/db-metadata.d.ts +33 -0
- package/dist/snapshot-chunks/db-metadata.d.ts.map +1 -0
- package/dist/snapshot-chunks/db-metadata.js +169 -0
- package/dist/snapshot-chunks/db-metadata.js.map +1 -0
- package/dist/snapshot-chunks/index.d.ts +9 -0
- package/dist/snapshot-chunks/index.d.ts.map +1 -0
- package/dist/snapshot-chunks/index.js +9 -0
- package/dist/snapshot-chunks/index.js.map +1 -0
- package/dist/snapshot-chunks/types.d.ts +65 -0
- package/dist/snapshot-chunks/types.d.ts.map +1 -0
- package/dist/snapshot-chunks/types.js +8 -0
- package/dist/snapshot-chunks/types.js.map +1 -0
- package/dist/snapshot-chunks.d.ts +59 -0
- package/dist/snapshot-chunks.d.ts.map +1 -0
- package/dist/snapshot-chunks.js +202 -0
- package/dist/snapshot-chunks.js.map +1 -0
- package/dist/stats.d.ts +19 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +57 -0
- package/dist/stats.js.map +1 -0
- package/dist/subscriptions/index.d.ts +2 -0
- package/dist/subscriptions/index.d.ts.map +1 -0
- package/dist/subscriptions/index.js +2 -0
- package/dist/subscriptions/index.js.map +1 -0
- package/dist/subscriptions/resolve.d.ts +35 -0
- package/dist/subscriptions/resolve.d.ts.map +1 -0
- package/dist/subscriptions/resolve.js +134 -0
- package/dist/subscriptions/resolve.js.map +1 -0
- package/package.json +80 -0
- package/src/blobs/adapters/database.ts +290 -0
- package/src/blobs/adapters/s3.ts +271 -0
- package/src/blobs/index.ts +9 -0
- package/src/blobs/manager.ts +600 -0
- package/src/blobs/migrate.ts +150 -0
- package/src/blobs/types.ts +70 -0
- package/src/clients.ts +21 -0
- package/src/compaction.ts +77 -0
- package/src/dialect/index.ts +5 -0
- package/src/dialect/types.ts +222 -0
- package/src/helpers/conflict.ts +64 -0
- package/src/helpers/emitted-change.ts +69 -0
- package/src/helpers/index.ts +10 -0
- package/src/helpers/paginate.ts +82 -0
- package/src/helpers/scope-strings.ts +101 -0
- package/src/index.ts +28 -0
- package/src/migrate.ts +20 -0
- package/src/proxy/handler.ts +152 -0
- package/src/proxy/index.ts +18 -0
- package/src/proxy/mutation-detector.ts +83 -0
- package/src/proxy/oplog.ts +144 -0
- package/src/proxy/registry.ts +56 -0
- package/src/proxy/types.ts +46 -0
- package/src/prune.ts +200 -0
- package/src/pull.ts +551 -0
- package/src/push.ts +457 -0
- package/src/realtime/in-memory.ts +33 -0
- package/src/realtime/index.ts +5 -0
- package/src/realtime/types.ts +55 -0
- package/src/schema.ts +172 -0
- package/src/shapes/create-handler.ts +590 -0
- package/src/shapes/index.ts +3 -0
- package/src/shapes/registry.ts +109 -0
- package/src/shapes/types.ts +267 -0
- package/src/snapshot-chunks/adapters/s3.ts +68 -0
- package/src/snapshot-chunks/db-metadata.ts +238 -0
- package/src/snapshot-chunks/index.ts +9 -0
- package/src/snapshot-chunks/types.ts +79 -0
- package/src/snapshot-chunks.ts +301 -0
- package/src/stats.ts +104 -0
- package/src/subscriptions/index.ts +1 -0
- package/src/subscriptions/resolve.ts +185 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Emitted change builder
|
|
3
|
+
*
|
|
4
|
+
* Helper for creating emitted changes in server table handlers.
|
|
5
|
+
*/
|
|
6
|
+
import type { StoredScopes } from '@syncular/core';
|
|
7
|
+
import type { EmittedChange } from '../shapes/types';
|
|
8
|
+
export interface CreateEmittedChangeArgs {
|
|
9
|
+
/** Table name */
|
|
10
|
+
table: string;
|
|
11
|
+
/** Row primary key */
|
|
12
|
+
rowId: string;
|
|
13
|
+
/** Operation type */
|
|
14
|
+
op: 'upsert' | 'delete';
|
|
15
|
+
/** Row data (null for delete) */
|
|
16
|
+
row: unknown | null;
|
|
17
|
+
/** Row version (null if not versioned) */
|
|
18
|
+
version: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Scope values for this change (stored as JSONB).
|
|
21
|
+
* Example: { user_id: 'U1', project_id: 'P1' }
|
|
22
|
+
*/
|
|
23
|
+
scopes: StoredScopes;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create an emitted change for broadcasting to subscribed clients.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const handler: ServerTableHandler = {
|
|
31
|
+
* table: 'tasks',
|
|
32
|
+
* async applyOperation(ctx, op, opIndex) {
|
|
33
|
+
* // ... apply the operation ...
|
|
34
|
+
*
|
|
35
|
+
* const newVersion = await getTaskVersion(ctx.db, op.row_id);
|
|
36
|
+
* const updatedRow = await getTask(ctx.db, op.row_id);
|
|
37
|
+
*
|
|
38
|
+
* return {
|
|
39
|
+
* result: { opIndex, status: 'applied', newVersion },
|
|
40
|
+
* emittedChanges: [
|
|
41
|
+
* createEmittedChange({
|
|
42
|
+
* table: 'tasks',
|
|
43
|
+
* rowId: op.row_id,
|
|
44
|
+
* op: 'upsert',
|
|
45
|
+
* row: updatedRow,
|
|
46
|
+
* version: newVersion,
|
|
47
|
+
* scopes: { user_id: updatedRow.user_id },
|
|
48
|
+
* }),
|
|
49
|
+
* ],
|
|
50
|
+
* };
|
|
51
|
+
* },
|
|
52
|
+
* };
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function createEmittedChange(args: CreateEmittedChangeArgs): EmittedChange;
|
|
56
|
+
//# sourceMappingURL=emitted-change.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitted-change.d.ts","sourceRoot":"","sources":["../../src/helpers/emitted-change.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxB,iCAAiC;IACjC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IACpB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,uBAAuB,GAC5B,aAAa,CASf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Emitted change builder
|
|
3
|
+
*
|
|
4
|
+
* Helper for creating emitted changes in server table handlers.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create an emitted change for broadcasting to subscribed clients.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const handler: ServerTableHandler = {
|
|
12
|
+
* table: 'tasks',
|
|
13
|
+
* async applyOperation(ctx, op, opIndex) {
|
|
14
|
+
* // ... apply the operation ...
|
|
15
|
+
*
|
|
16
|
+
* const newVersion = await getTaskVersion(ctx.db, op.row_id);
|
|
17
|
+
* const updatedRow = await getTask(ctx.db, op.row_id);
|
|
18
|
+
*
|
|
19
|
+
* return {
|
|
20
|
+
* result: { opIndex, status: 'applied', newVersion },
|
|
21
|
+
* emittedChanges: [
|
|
22
|
+
* createEmittedChange({
|
|
23
|
+
* table: 'tasks',
|
|
24
|
+
* rowId: op.row_id,
|
|
25
|
+
* op: 'upsert',
|
|
26
|
+
* row: updatedRow,
|
|
27
|
+
* version: newVersion,
|
|
28
|
+
* scopes: { user_id: updatedRow.user_id },
|
|
29
|
+
* }),
|
|
30
|
+
* ],
|
|
31
|
+
* };
|
|
32
|
+
* },
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function createEmittedChange(args) {
|
|
37
|
+
return {
|
|
38
|
+
table: args.table,
|
|
39
|
+
row_id: args.rowId,
|
|
40
|
+
op: args.op,
|
|
41
|
+
row_json: args.op === 'delete' ? null : args.row,
|
|
42
|
+
row_version: args.version,
|
|
43
|
+
scopes: args.scopes,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=emitted-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitted-change.js","sourceRoot":"","sources":["../../src/helpers/emitted-change.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAA6B,EACd;IACf,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,KAAK;QAClB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,QAAQ,EAAE,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG;QAChD,WAAW,EAAE,IAAI,CAAC,OAAO;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Helper utilities
|
|
3
|
+
*
|
|
4
|
+
* Convenience helpers for implementing server table handlers.
|
|
5
|
+
*/
|
|
6
|
+
export * from './conflict';
|
|
7
|
+
export * from './emitted-change';
|
|
8
|
+
export * from './paginate';
|
|
9
|
+
export * from './scope-strings';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Helper utilities
|
|
3
|
+
*
|
|
4
|
+
* Convenience helpers for implementing server table handlers.
|
|
5
|
+
*/
|
|
6
|
+
export * from './conflict';
|
|
7
|
+
export * from './emitted-change';
|
|
8
|
+
export * from './paginate';
|
|
9
|
+
export * from './scope-strings';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Pagination helper
|
|
3
|
+
*
|
|
4
|
+
* Simplifies cursor-based pagination for snapshot queries.
|
|
5
|
+
*/
|
|
6
|
+
import type { SelectQueryBuilder } from 'kysely';
|
|
7
|
+
export interface PaginateOptions {
|
|
8
|
+
/** Cursor value to start from (null for first page) */
|
|
9
|
+
cursor: string | null;
|
|
10
|
+
/** Number of rows per page */
|
|
11
|
+
limit: number;
|
|
12
|
+
/** Column to use for cursor-based pagination (default: 'id') */
|
|
13
|
+
cursorColumn?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface PaginateResult<T> {
|
|
16
|
+
/** Rows for this page */
|
|
17
|
+
rows: T[];
|
|
18
|
+
/** Cursor for next page (null if no more pages) */
|
|
19
|
+
nextCursor: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Apply cursor-based pagination to a Kysely query.
|
|
23
|
+
*
|
|
24
|
+
* This helper simplifies implementing snapshot pagination by:
|
|
25
|
+
* - Applying cursor filter if provided
|
|
26
|
+
* - Ordering by the cursor column
|
|
27
|
+
* - Fetching limit + 1 to determine if there's a next page
|
|
28
|
+
* - Computing the next cursor
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const handler: ServerTableHandler = {
|
|
33
|
+
* table: 'tasks',
|
|
34
|
+
* async snapshot(ctx) {
|
|
35
|
+
* const query = ctx.db
|
|
36
|
+
* .selectFrom('tasks')
|
|
37
|
+
* .selectAll()
|
|
38
|
+
* .where('user_id', '=', ctx.actorId);
|
|
39
|
+
*
|
|
40
|
+
* return paginate(query, {
|
|
41
|
+
* cursor: ctx.cursor,
|
|
42
|
+
* limit: ctx.limit,
|
|
43
|
+
* });
|
|
44
|
+
* },
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function paginate<T>(query: SelectQueryBuilder<any, any, T>, options: PaginateOptions): Promise<PaginateResult<T>>;
|
|
49
|
+
//# sourceMappingURL=paginate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.d.ts","sourceRoot":"","sources":["../../src/helpers/paginate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,yBAAyB;IACzB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,mDAAmD;IACnD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,KAAK,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EACtC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CA2B5B"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Pagination helper
|
|
3
|
+
*
|
|
4
|
+
* Simplifies cursor-based pagination for snapshot queries.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Apply cursor-based pagination to a Kysely query.
|
|
8
|
+
*
|
|
9
|
+
* This helper simplifies implementing snapshot pagination by:
|
|
10
|
+
* - Applying cursor filter if provided
|
|
11
|
+
* - Ordering by the cursor column
|
|
12
|
+
* - Fetching limit + 1 to determine if there's a next page
|
|
13
|
+
* - Computing the next cursor
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const handler: ServerTableHandler = {
|
|
18
|
+
* table: 'tasks',
|
|
19
|
+
* async snapshot(ctx) {
|
|
20
|
+
* const query = ctx.db
|
|
21
|
+
* .selectFrom('tasks')
|
|
22
|
+
* .selectAll()
|
|
23
|
+
* .where('user_id', '=', ctx.actorId);
|
|
24
|
+
*
|
|
25
|
+
* return paginate(query, {
|
|
26
|
+
* cursor: ctx.cursor,
|
|
27
|
+
* limit: ctx.limit,
|
|
28
|
+
* });
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export async function paginate(query, options) {
|
|
34
|
+
const { cursor, limit, cursorColumn = 'id' } = options;
|
|
35
|
+
// Apply cursor filter if resuming from a previous page
|
|
36
|
+
let q = query;
|
|
37
|
+
if (cursor) {
|
|
38
|
+
q = q.where(cursorColumn, '>', cursor);
|
|
39
|
+
}
|
|
40
|
+
// Order by cursor column and fetch limit + 1 to check for more pages
|
|
41
|
+
const rows = await q
|
|
42
|
+
.orderBy(cursorColumn, 'asc')
|
|
43
|
+
.limit(limit + 1)
|
|
44
|
+
.execute();
|
|
45
|
+
// Determine if there are more pages
|
|
46
|
+
const hasMore = rows.length > limit;
|
|
47
|
+
const pageRows = hasMore ? rows.slice(0, limit) : rows;
|
|
48
|
+
// Compute next cursor from last row
|
|
49
|
+
const nextCursor = hasMore
|
|
50
|
+
? (pageRows[pageRows.length - 1]?.[cursorColumn] ?? null)
|
|
51
|
+
: null;
|
|
52
|
+
return { rows: pageRows, nextCursor };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=paginate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../src/helpers/paginate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAsC,EACtC,OAAwB,EACI;IAC5B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEvD,uDAAuD;IACvD,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,IAAI,MAAM,EAAE,CAAC;QACX,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,CAAa,CAAC;IACrD,CAAC;IAED,qEAAqE;IACrE,MAAM,IAAI,GAAG,MAAM,CAAC;SACjB,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;SAC5B,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;SAChB,OAAO,EAAE,CAAC;IAEb,oCAAoC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEvD,oCAAoC;IACpC,MAAM,UAAU,GAAG,OAAO;QACxB,CAAC,CAAC,CAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAA6B,EAAE,CAC5D,YAAY,CACF,IAAI,IAAI,CAAC;QACvB,CAAC,CAAC,IAAI,CAAC;IAET,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAAA,CACvC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Scope string utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for creating and parsing scope strings.
|
|
5
|
+
* Scope strings identify partitions of data for sync subscriptions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Result from parsing a scope key
|
|
9
|
+
*/
|
|
10
|
+
interface ParsedScopeKey {
|
|
11
|
+
/** The prefix (first segment) */
|
|
12
|
+
prefix: string;
|
|
13
|
+
/** The remaining values (segments after prefix) */
|
|
14
|
+
values: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a scope string from a prefix and values.
|
|
18
|
+
*
|
|
19
|
+
* Scope strings use colon separators: `prefix:value1:value2`
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Simple scope string
|
|
24
|
+
* createScopeKey('user', 'alice')
|
|
25
|
+
* // => 'user:alice'
|
|
26
|
+
*
|
|
27
|
+
* // Multi-value scope string
|
|
28
|
+
* createScopeKey('user', 'alice', 'project', 'proj-1')
|
|
29
|
+
* // => 'user:alice:project:proj-1'
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function createScopeKey(prefix: string, ...values: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Parse a scope string into its prefix and values.
|
|
35
|
+
*
|
|
36
|
+
* Returns null if the key is invalid or doesn't match the expected prefix.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Parse any scope string
|
|
41
|
+
* parseScopeKey('user:alice')
|
|
42
|
+
* // => { prefix: 'user', values: ['alice'] }
|
|
43
|
+
*
|
|
44
|
+
* // Parse with expected prefix
|
|
45
|
+
* parseScopeKey('user:alice', 'user')
|
|
46
|
+
* // => { prefix: 'user', values: ['alice'] }
|
|
47
|
+
*
|
|
48
|
+
* // Returns null if prefix doesn't match
|
|
49
|
+
* parseScopeKey('user:alice', 'project')
|
|
50
|
+
* // => null
|
|
51
|
+
*
|
|
52
|
+
* // Multi-value scope string
|
|
53
|
+
* parseScopeKey('user:alice:project:proj-1')
|
|
54
|
+
* // => { prefix: 'user', values: ['alice', 'project', 'proj-1'] }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseScopeKey(key: string, expectedPrefix?: string): ParsedScopeKey | null;
|
|
58
|
+
/**
|
|
59
|
+
* Extract a specific value from a scope string by index.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Get first value after prefix
|
|
64
|
+
* getScopeKeyValue('user:alice:project:proj-1', 0)
|
|
65
|
+
* // => 'alice'
|
|
66
|
+
*
|
|
67
|
+
* // Get second value
|
|
68
|
+
* getScopeKeyValue('user:alice:project:proj-1', 2)
|
|
69
|
+
* // => 'proj-1'
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function getScopeKeyValue(key: string, valueIndex: number): string | null;
|
|
73
|
+
export type { ParsedScopeKey };
|
|
74
|
+
//# sourceMappingURL=scope-strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-strings.d.ts","sourceRoot":"","sources":["../../src/helpers/scope-strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,UAAU,cAAc;IACtB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,cAAc,CAAC,EAAE,MAAM,GACtB,cAAc,GAAG,IAAI,CAWvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAIf;AAED,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Scope string utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for creating and parsing scope strings.
|
|
5
|
+
* Scope strings identify partitions of data for sync subscriptions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Create a scope string from a prefix and values.
|
|
9
|
+
*
|
|
10
|
+
* Scope strings use colon separators: `prefix:value1:value2`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Simple scope string
|
|
15
|
+
* createScopeKey('user', 'alice')
|
|
16
|
+
* // => 'user:alice'
|
|
17
|
+
*
|
|
18
|
+
* // Multi-value scope string
|
|
19
|
+
* createScopeKey('user', 'alice', 'project', 'proj-1')
|
|
20
|
+
* // => 'user:alice:project:proj-1'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function createScopeKey(prefix, ...values) {
|
|
24
|
+
return [prefix, ...values].join(':');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse a scope string into its prefix and values.
|
|
28
|
+
*
|
|
29
|
+
* Returns null if the key is invalid or doesn't match the expected prefix.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Parse any scope string
|
|
34
|
+
* parseScopeKey('user:alice')
|
|
35
|
+
* // => { prefix: 'user', values: ['alice'] }
|
|
36
|
+
*
|
|
37
|
+
* // Parse with expected prefix
|
|
38
|
+
* parseScopeKey('user:alice', 'user')
|
|
39
|
+
* // => { prefix: 'user', values: ['alice'] }
|
|
40
|
+
*
|
|
41
|
+
* // Returns null if prefix doesn't match
|
|
42
|
+
* parseScopeKey('user:alice', 'project')
|
|
43
|
+
* // => null
|
|
44
|
+
*
|
|
45
|
+
* // Multi-value scope string
|
|
46
|
+
* parseScopeKey('user:alice:project:proj-1')
|
|
47
|
+
* // => { prefix: 'user', values: ['alice', 'project', 'proj-1'] }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function parseScopeKey(key, expectedPrefix) {
|
|
51
|
+
const parts = key.split(':');
|
|
52
|
+
if (parts.length < 1)
|
|
53
|
+
return null;
|
|
54
|
+
const [prefix, ...values] = parts;
|
|
55
|
+
if (!prefix)
|
|
56
|
+
return null;
|
|
57
|
+
// Check expected prefix if provided
|
|
58
|
+
if (expectedPrefix && prefix !== expectedPrefix)
|
|
59
|
+
return null;
|
|
60
|
+
return { prefix, values };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Extract a specific value from a scope string by index.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* // Get first value after prefix
|
|
68
|
+
* getScopeKeyValue('user:alice:project:proj-1', 0)
|
|
69
|
+
* // => 'alice'
|
|
70
|
+
*
|
|
71
|
+
* // Get second value
|
|
72
|
+
* getScopeKeyValue('user:alice:project:proj-1', 2)
|
|
73
|
+
* // => 'proj-1'
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function getScopeKeyValue(key, valueIndex) {
|
|
77
|
+
const parsed = parseScopeKey(key);
|
|
78
|
+
if (!parsed)
|
|
79
|
+
return null;
|
|
80
|
+
return parsed.values[valueIndex] ?? null;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=scope-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-strings.js","sourceRoot":"","sources":["../../src/helpers/scope-strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,GAAG,MAAgB,EAAU;IAC1E,OAAO,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAAA,CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAW,EACX,cAAuB,EACA;IACvB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;IAClC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,oCAAoC;IACpC,IAAI,cAAc,IAAI,MAAM,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAAA,CAC3B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,UAAkB,EACH;IACf,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC;AAAA,CAC1C"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Server-side sync infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Commit-log based sync with:
|
|
5
|
+
* - commit log + change log
|
|
6
|
+
* - scopes + subscriptions (partial sync + auth)
|
|
7
|
+
* - commit-level idempotency
|
|
8
|
+
* - blob/media storage
|
|
9
|
+
*/
|
|
10
|
+
export * from '@syncular/core';
|
|
11
|
+
export * from './blobs';
|
|
12
|
+
export * from './clients';
|
|
13
|
+
export * from './compaction';
|
|
14
|
+
export * from './dialect';
|
|
15
|
+
export * from './helpers';
|
|
16
|
+
export * from './migrate';
|
|
17
|
+
export * from './proxy';
|
|
18
|
+
export * from './prune';
|
|
19
|
+
export * from './pull';
|
|
20
|
+
export * from './push';
|
|
21
|
+
export * from './realtime';
|
|
22
|
+
export * from './schema';
|
|
23
|
+
export * from './shapes';
|
|
24
|
+
export * from './snapshot-chunks';
|
|
25
|
+
export type { SnapshotChunkStorage } from './snapshot-chunks/types';
|
|
26
|
+
export * from './stats';
|
|
27
|
+
export * from './subscriptions';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Server-side sync infrastructure
|
|
3
|
+
*
|
|
4
|
+
* Commit-log based sync with:
|
|
5
|
+
* - commit log + change log
|
|
6
|
+
* - scopes + subscriptions (partial sync + auth)
|
|
7
|
+
* - commit-level idempotency
|
|
8
|
+
* - blob/media storage
|
|
9
|
+
*/
|
|
10
|
+
export * from '@syncular/core';
|
|
11
|
+
export * from './blobs';
|
|
12
|
+
export * from './clients';
|
|
13
|
+
export * from './compaction';
|
|
14
|
+
export * from './dialect';
|
|
15
|
+
export * from './helpers';
|
|
16
|
+
export * from './migrate';
|
|
17
|
+
export * from './proxy';
|
|
18
|
+
export * from './prune';
|
|
19
|
+
export * from './pull';
|
|
20
|
+
export * from './push';
|
|
21
|
+
export * from './realtime';
|
|
22
|
+
export * from './schema';
|
|
23
|
+
export * from './shapes';
|
|
24
|
+
export * from './snapshot-chunks';
|
|
25
|
+
export * from './stats';
|
|
26
|
+
export * from './subscriptions';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAElC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Schema setup
|
|
3
|
+
*/
|
|
4
|
+
import type { Kysely } from 'kysely';
|
|
5
|
+
import type { ServerSyncDialect } from './dialect/types';
|
|
6
|
+
import type { SyncCoreDb } from './schema';
|
|
7
|
+
/**
|
|
8
|
+
* Ensures the sync schema exists in the database.
|
|
9
|
+
* Safe to call multiple times (idempotent).
|
|
10
|
+
*
|
|
11
|
+
* @typeParam DB - Your database type that extends SyncCoreDb
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureSyncSchema<DB extends SyncCoreDb>(db: Kysely<DB>, dialect: ServerSyncDialect): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,SAAS,UAAU,EAC1D,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Schema setup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Ensures the sync schema exists in the database.
|
|
6
|
+
* Safe to call multiple times (idempotent).
|
|
7
|
+
*
|
|
8
|
+
* @typeParam DB - Your database type that extends SyncCoreDb
|
|
9
|
+
*/
|
|
10
|
+
export async function ensureSyncSchema(db, dialect) {
|
|
11
|
+
await dialect.ensureSyncSchema(db);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,EAAc,EACd,OAA0B,EACX;IACf,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAAA,CACpC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncular/server - Proxy Query Handler
|
|
3
|
+
*
|
|
4
|
+
* Executes proxied queries with automatic oplog generation for mutations.
|
|
5
|
+
*/
|
|
6
|
+
import type { Kysely } from 'kysely';
|
|
7
|
+
import type { ServerSyncDialect } from '../dialect/types';
|
|
8
|
+
import type { SyncCoreDb } from '../schema';
|
|
9
|
+
import type { ProxyTableRegistry } from './registry';
|
|
10
|
+
import type { ProxyQueryContext } from './types';
|
|
11
|
+
export interface ExecuteProxyQueryArgs<DB extends SyncCoreDb = SyncCoreDb> {
|
|
12
|
+
/** Database connection or transaction */
|
|
13
|
+
db: Kysely<DB>;
|
|
14
|
+
/** Server sync dialect */
|
|
15
|
+
dialect: ServerSyncDialect;
|
|
16
|
+
/** Proxy table registry for oplog generation */
|
|
17
|
+
shapes: ProxyTableRegistry;
|
|
18
|
+
/** Query context (actor/client IDs) */
|
|
19
|
+
ctx: ProxyQueryContext;
|
|
20
|
+
/** SQL query string */
|
|
21
|
+
sqlQuery: string;
|
|
22
|
+
/** Query parameters */
|
|
23
|
+
parameters: readonly unknown[];
|
|
24
|
+
}
|
|
25
|
+
export interface ExecuteProxyQueryResult {
|
|
26
|
+
/** Query result rows (for SELECT or RETURNING) */
|
|
27
|
+
rows?: unknown[];
|
|
28
|
+
/** Number of affected rows (for mutations) */
|
|
29
|
+
rowCount?: number;
|
|
30
|
+
/** Commit sequence if oplog was created */
|
|
31
|
+
commitSeq?: number;
|
|
32
|
+
/** Affected tables if oplog was created */
|
|
33
|
+
affectedTables?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Execute a proxied query with automatic oplog generation for mutations.
|
|
37
|
+
*
|
|
38
|
+
* - Read queries: Execute directly and return rows
|
|
39
|
+
* - Mutations: Append RETURNING *, execute, create oplog entries
|
|
40
|
+
*/
|
|
41
|
+
export declare function executeProxyQuery<DB extends SyncCoreDb>(args: ExecuteProxyQueryArgs<DB>): Promise<ExecuteProxyQueryResult>;
|
|
42
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/proxy/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAO5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,qBAAqB,CAAC,EAAE,SAAS,UAAU,GAAG,UAAU;IACvE,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACf,0BAA0B;IAC1B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,gDAAgD;IAChD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,uCAAuC;IACvC,GAAG,EAAE,iBAAiB,CAAC;IACvB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,UAAU,EAAE,SAAS,OAAO,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC,kDAAkD;IAClD,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAiDD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,SAAS,UAAU,EAC3D,IAAI,EAAE,qBAAqB,CAAC,EAAE,CAAC,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAmDlC"}
|