@syncular/server-workers 0.33.0 → 0.35.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/realtime-do.d.ts +10 -3
- package/dist/realtime-do.js +14 -1
- package/package.json +4 -4
- package/src/realtime-do.ts +27 -2
package/dist/realtime-do.d.ts
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
* partition serialization may call `/__wake` after its own commit so sockets
|
|
72
72
|
* re-pull. See `durableObjectRealtimeNotifier` for that caller side.
|
|
73
73
|
*/
|
|
74
|
-
import { D1ServerStorage, type PruneOptions, type RealtimeHubConfig, type RemoteOperationRegistry } from '@syncular/server';
|
|
74
|
+
import { D1ServerStorage, type EraseScopeValueOptions, type EraseScopeValueResult, type PruneOptions, type RealtimeHubConfig, type RemoteOperationRegistry, type RemoteOperationResolver } from '@syncular/server';
|
|
75
75
|
export interface DurableObjectStateLike {
|
|
76
76
|
acceptWebSocket(ws: WebSocketLike, tags?: string[]): void;
|
|
77
77
|
getWebSockets(tag?: string): WebSocketLike[];
|
|
@@ -120,9 +120,11 @@ export type RealtimeDOConfig = ({
|
|
|
120
120
|
/**
|
|
121
121
|
* Registered remote queries and commands (REMOTE.md). The Worker forwards
|
|
122
122
|
* `POST <mount>/operations` here, so a command applies on the partition
|
|
123
|
-
* FIFO and fans out to the partition's sockets like a pushed commit.
|
|
123
|
+
* FIFO and fans out to the partition's sockets like a pushed commit. A
|
|
124
|
+
* `RemoteOperationResolver` chooses the registry, the commit actor, and
|
|
125
|
+
* the scope resolver per request (REMOTE.md §5.1).
|
|
124
126
|
*/
|
|
125
|
-
readonly operations?: RemoteOperationRegistry;
|
|
127
|
+
readonly operations?: RemoteOperationRegistry | RemoteOperationResolver;
|
|
126
128
|
};
|
|
127
129
|
/**
|
|
128
130
|
* The subset of `RealtimeHubConfig` the DO host supplies (storage is wired by
|
|
@@ -179,6 +181,11 @@ export declare class SyncularRealtimeHost {
|
|
|
179
181
|
fetch(request: Request): Promise<Response>;
|
|
180
182
|
/** Trusted maintenance shares the partition FIFO with HTTP/socket writes. */
|
|
181
183
|
pruneCommitLog(options: Omit<PruneOptions, 'storage'>): Promise<number>;
|
|
184
|
+
/**
|
|
185
|
+
* §4.6.1 scope-value erasure on the partition FIFO: one budgeted step per
|
|
186
|
+
* call, its delete commit fanned out to connected sockets.
|
|
187
|
+
*/
|
|
188
|
+
eraseScopeValue(options: EraseScopeValueOptions): Promise<EraseScopeValueResult>;
|
|
182
189
|
/** Hibernation callback: an inbound frame. */
|
|
183
190
|
webSocketMessage(ws: WebSocketLike, message: ArrayBuffer | string): Promise<void>;
|
|
184
191
|
/** Hibernation callback: the socket closed. */
|
package/dist/realtime-do.js
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
* partition serialization may call `/__wake` after its own commit so sockets
|
|
72
72
|
* re-pull. See `durableObjectRealtimeNotifier` for that caller side.
|
|
73
73
|
*/
|
|
74
|
-
import { adapterSyncError, composeEvents, createRealtimeHub, D1ServerStorage, errorBody, handleRemoteOperation, handleSyncRequest, pruneCommitLog, RingBufferEvents, SSP2_CONTENT_TYPE, SyncError, SyncularAdmin, } from '@syncular/server';
|
|
74
|
+
import { adapterSyncError, composeEvents, createRealtimeHub, D1ServerStorage, errorBody, eraseScopeValue, handleRemoteOperation, handleSyncRequest, pruneCommitLog, RingBufferEvents, SSP2_CONTENT_TYPE, SyncError, SyncularAdmin, } from '@syncular/server';
|
|
75
75
|
import { createSyncularAdminRoutes } from '@syncular/server-hono';
|
|
76
76
|
function isAttachment(value) {
|
|
77
77
|
return (typeof value === 'object' &&
|
|
@@ -199,6 +199,19 @@ export class SyncularRealtimeHost {
|
|
|
199
199
|
return pruneCommitLog({ ...options, storage: this.#storage });
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* §4.6.1 scope-value erasure on the partition FIFO: one budgeted step per
|
|
204
|
+
* call, its delete commit fanned out to connected sockets.
|
|
205
|
+
*/
|
|
206
|
+
eraseScopeValue(options) {
|
|
207
|
+
return this.#serializePartition(async () => {
|
|
208
|
+
await this.#storage.migrate();
|
|
209
|
+
return eraseScopeValue(this.#getHub().requestContextFor({
|
|
210
|
+
partition: options.partition,
|
|
211
|
+
actorId: options.actorId ?? 'syncular.erase',
|
|
212
|
+
}), options);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
202
215
|
#serializePartition(operation) {
|
|
203
216
|
const run = async () => {
|
|
204
217
|
await this.#rehydrateSockets();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/server-workers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Cloudflare Workers adapter for the Syncular sync server",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"!dist/**/*.test.d.ts"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@syncular/server": "0.
|
|
49
|
-
"@syncular/server-hono": "0.
|
|
48
|
+
"@syncular/server": "0.35.0",
|
|
49
|
+
"@syncular/server-hono": "0.35.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@syncular/core": "0.
|
|
52
|
+
"@syncular/core": "0.35.0",
|
|
53
53
|
"miniflare": "4.20260701.0"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/realtime-do.ts
CHANGED
|
@@ -77,6 +77,9 @@ import {
|
|
|
77
77
|
createRealtimeHub,
|
|
78
78
|
D1ServerStorage,
|
|
79
79
|
errorBody,
|
|
80
|
+
eraseScopeValue,
|
|
81
|
+
type EraseScopeValueOptions,
|
|
82
|
+
type EraseScopeValueResult,
|
|
80
83
|
handleRemoteOperation,
|
|
81
84
|
handleSyncRequest,
|
|
82
85
|
pruneCommitLog,
|
|
@@ -85,6 +88,7 @@ import {
|
|
|
85
88
|
type RealtimeHubConfig,
|
|
86
89
|
type RealtimeSession,
|
|
87
90
|
type RemoteOperationRegistry,
|
|
91
|
+
type RemoteOperationResolver,
|
|
88
92
|
RingBufferEvents,
|
|
89
93
|
SSP2_CONTENT_TYPE,
|
|
90
94
|
SyncError,
|
|
@@ -149,9 +153,11 @@ export type RealtimeDOConfig = (
|
|
|
149
153
|
/**
|
|
150
154
|
* Registered remote queries and commands (REMOTE.md). The Worker forwards
|
|
151
155
|
* `POST <mount>/operations` here, so a command applies on the partition
|
|
152
|
-
* FIFO and fans out to the partition's sockets like a pushed commit.
|
|
156
|
+
* FIFO and fans out to the partition's sockets like a pushed commit. A
|
|
157
|
+
* `RemoteOperationResolver` chooses the registry, the commit actor, and
|
|
158
|
+
* the scope resolver per request (REMOTE.md §5.1).
|
|
153
159
|
*/
|
|
154
|
-
readonly operations?: RemoteOperationRegistry;
|
|
160
|
+
readonly operations?: RemoteOperationRegistry | RemoteOperationResolver;
|
|
155
161
|
};
|
|
156
162
|
|
|
157
163
|
/**
|
|
@@ -323,6 +329,25 @@ export class SyncularRealtimeHost {
|
|
|
323
329
|
});
|
|
324
330
|
}
|
|
325
331
|
|
|
332
|
+
/**
|
|
333
|
+
* §4.6.1 scope-value erasure on the partition FIFO: one budgeted step per
|
|
334
|
+
* call, its delete commit fanned out to connected sockets.
|
|
335
|
+
*/
|
|
336
|
+
eraseScopeValue(
|
|
337
|
+
options: EraseScopeValueOptions,
|
|
338
|
+
): Promise<EraseScopeValueResult> {
|
|
339
|
+
return this.#serializePartition(async () => {
|
|
340
|
+
await this.#storage.migrate();
|
|
341
|
+
return eraseScopeValue(
|
|
342
|
+
this.#getHub().requestContextFor({
|
|
343
|
+
partition: options.partition,
|
|
344
|
+
actorId: options.actorId ?? 'syncular.erase',
|
|
345
|
+
}),
|
|
346
|
+
options,
|
|
347
|
+
);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
326
351
|
#serializePartition<T>(operation: () => Promise<T>): Promise<T> {
|
|
327
352
|
const run = async (): Promise<T> => {
|
|
328
353
|
await this.#rehydrateSockets();
|