@arcote.tech/arc-host 0.7.14 → 0.7.16
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/index.js +49 -149
- package/dist/index.js.map +5 -5
- package/dist/src/create-server.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/middleware/http.d.ts +0 -5
- package/dist/src/middleware/http.d.ts.map +1 -1
- package/dist/src/middleware/index.d.ts +2 -2
- package/dist/src/middleware/index.d.ts.map +1 -1
- package/dist/src/middleware/live-query.integration.test.d.ts +2 -0
- package/dist/src/middleware/live-query.integration.test.d.ts.map +1 -0
- package/dist/src/middleware/ws.d.ts.map +1 -1
- package/dist/src/types.d.ts +20 -2
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/create-server.ts +0 -2
- package/src/index.ts +1 -3
- package/src/middleware/http.ts +0 -119
- package/src/middleware/index.ts +1 -3
- package/src/middleware/live-query.integration.test.ts +432 -0
- package/src/middleware/ws.ts +81 -78
- package/src/types.ts +16 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/create-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE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
|
|
|
1
1
|
export { createArcServer } from "./create-server";
|
|
2
2
|
export type { ArcServer, ArcServerConfig } from "./create-server";
|
|
3
|
-
export { arcHttpHandlers, arcWsHandlers, cleanupClientSubs,
|
|
3
|
+
export { arcHttpHandlers, arcWsHandlers, cleanupClientSubs, commandHandler, eventSyncHandler, executeCommandHandler, healthHandler, queryHandler, querySubscriptionHandler, requestSyncHandler, routeHandler, scopeAuthHandler, syncEventsHandler, } from "./middleware";
|
|
4
4
|
export type { ArcHttpHandler, ArcRequestContext, ArcWsContext, ArcWsHandler, } from "./middleware";
|
|
5
5
|
export { ConnectionManager } from "./connection-manager";
|
|
6
6
|
export { ContextHandler } from "./context-handler";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlE,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC"}
|
|
@@ -4,12 +4,7 @@ import type { ArcHttpHandler } from "./types";
|
|
|
4
4
|
export declare function healthHandler(cm: ConnectionManager): ArcHttpHandler;
|
|
5
5
|
export declare function commandHandler(ch: ContextHandler): ArcHttpHandler;
|
|
6
6
|
export declare function queryHandler(ch: ContextHandler): ArcHttpHandler;
|
|
7
|
-
export declare function streamHandler(ch: ContextHandler): ArcHttpHandler;
|
|
8
7
|
export declare function eventSyncHandler(ch: ContextHandler): ArcHttpHandler;
|
|
9
8
|
export declare function routeHandler(ch: ContextHandler): ArcHttpHandler;
|
|
10
9
|
export declare function arcHttpHandlers(ch: ContextHandler, cm: ConnectionManager): ArcHttpHandler[];
|
|
11
|
-
/**
|
|
12
|
-
* Cleanup all active SSE stream connections.
|
|
13
|
-
*/
|
|
14
|
-
export declare function cleanupStreams(): void;
|
|
15
10
|
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/middleware/http.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAC;AAoCjE,wBAAgB,aAAa,CAAC,EAAE,EAAE,iBAAiB,GAAG,cAAc,CAQnE;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CA+BjE;AAMD,wBAAgB,YAAY,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CAoC/D;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/middleware/http.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAC;AAoCjE,wBAAgB,aAAa,CAAC,EAAE,EAAE,iBAAiB,GAAG,cAAc,CAQnE;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CA+BjE;AAMD,wBAAgB,YAAY,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CAoC/D;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CA4BnE;AAMD,wBAAgB,YAAY,CAAC,EAAE,EAAE,cAAc,GAAG,cAAc,CA8G/D;AAMD,wBAAgB,eAAe,CAC7B,EAAE,EAAE,cAAc,EAClB,EAAE,EAAE,iBAAiB,GACpB,cAAc,EAAE,CAQlB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { ArcHttpHandler, ArcRequestContext, ArcWsContext, ArcWsHandler, } from "./types";
|
|
2
|
-
export { arcHttpHandlers,
|
|
3
|
-
export { arcWsHandlers, cleanupClientSubs, executeCommandHandler, requestSyncHandler, scopeAuthHandler, syncEventsHandler,
|
|
2
|
+
export { arcHttpHandlers, commandHandler, eventSyncHandler, healthHandler, queryHandler, routeHandler, } from "./http";
|
|
3
|
+
export { arcWsHandlers, cleanupClientSubs, executeCommandHandler, querySubscriptionHandler, requestSyncHandler, scopeAuthHandler, syncEventsHandler, } from "./ws";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,eAAe,EACf,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-query.integration.test.d.ts","sourceRoot":"","sources":["../../../src/middleware/live-query.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/middleware/ws.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../../src/middleware/ws.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAMxD;AAMD,wBAAgB,gBAAgB,IAAI,YAAY,CAc/C;AAMD,wBAAgB,iBAAiB,IAAI,YAAY,CA4ChD;AAMD,wBAAgB,kBAAkB,IAAI,YAAY,CAmCjD;AAMD,wBAAgB,qBAAqB,IAAI,YAAY,CA6BpD;AAMD,wBAAgB,wBAAwB,IAAI,YAAY,CAkFvD;AAMD,wBAAgB,aAAa,IAAI,YAAY,EAAE,CAQ9C"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ export interface ConnectedClient {
|
|
|
42
42
|
lastHostEventId: string | null;
|
|
43
43
|
/** WebSocket instance */
|
|
44
44
|
ws: any;
|
|
45
|
+
/**
|
|
46
|
+
* True for local-mode clients (they sent request-sync / sync-events).
|
|
47
|
+
* Only these receive domain-event broadcasts — streaming clients are
|
|
48
|
+
* served by view snapshots + deltas instead.
|
|
49
|
+
*/
|
|
50
|
+
wantsEventSync?: boolean;
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* Auth context snapshot captured at event emission time.
|
|
@@ -126,8 +132,20 @@ export type HostToClientMessage = {
|
|
|
126
132
|
type: "error";
|
|
127
133
|
message: string;
|
|
128
134
|
} | {
|
|
129
|
-
type: "query-
|
|
135
|
+
type: "query-snapshot";
|
|
130
136
|
subscriptionId: string;
|
|
131
|
-
|
|
137
|
+
result: any;
|
|
138
|
+
} | {
|
|
139
|
+
type: "query-changes";
|
|
140
|
+
subscriptionId: string;
|
|
141
|
+
changes: Array<{
|
|
142
|
+
type: "set";
|
|
143
|
+
id: string;
|
|
144
|
+
item: any;
|
|
145
|
+
index: number;
|
|
146
|
+
} | {
|
|
147
|
+
type: "delete";
|
|
148
|
+
id: string;
|
|
149
|
+
}>;
|
|
132
150
|
};
|
|
133
151
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uBAAuB;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,+BAA+B;IAC/B,gBAA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C;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC;CACb,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,KAAK,CACV;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACrD;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CACjC,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.7.
|
|
7
|
+
"version": "0.7.16",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@arcote.tech/arc-adapter-db-sqlite": "^0.7.
|
|
11
|
+
"@arcote.tech/arc-adapter-db-sqlite": "^0.7.16",
|
|
12
12
|
"croner": "^9.0.0",
|
|
13
13
|
"jsonwebtoken": "^9.0.2"
|
|
14
14
|
},
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@types/bun": "^1.2.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@arcote.tech/arc": "^0.7.
|
|
28
|
-
"@arcote.tech/arc-otel": "^0.7.
|
|
27
|
+
"@arcote.tech/arc": "^0.7.16",
|
|
28
|
+
"@arcote.tech/arc-otel": "^0.7.16"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"@arcote.tech/arc-otel": {
|
package/src/create-server.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
arcHttpHandlers,
|
|
10
10
|
arcWsHandlers,
|
|
11
11
|
cleanupClientSubs,
|
|
12
|
-
cleanupStreams,
|
|
13
12
|
} from "./middleware";
|
|
14
13
|
import type {
|
|
15
14
|
ArcHttpHandler,
|
|
@@ -300,7 +299,6 @@ export async function createArcServer(
|
|
|
300
299
|
cronScheduler,
|
|
301
300
|
stop: () => {
|
|
302
301
|
cronScheduler.stop();
|
|
303
|
-
cleanupStreams();
|
|
304
302
|
server.stop();
|
|
305
303
|
},
|
|
306
304
|
};
|
package/src/index.ts
CHANGED
|
@@ -7,18 +7,16 @@ export {
|
|
|
7
7
|
arcHttpHandlers,
|
|
8
8
|
arcWsHandlers,
|
|
9
9
|
cleanupClientSubs,
|
|
10
|
-
cleanupStreams,
|
|
11
10
|
commandHandler,
|
|
12
11
|
eventSyncHandler,
|
|
13
12
|
executeCommandHandler,
|
|
14
13
|
healthHandler,
|
|
15
14
|
queryHandler,
|
|
15
|
+
querySubscriptionHandler,
|
|
16
16
|
requestSyncHandler,
|
|
17
17
|
routeHandler,
|
|
18
18
|
scopeAuthHandler,
|
|
19
|
-
streamHandler,
|
|
20
19
|
syncEventsHandler,
|
|
21
|
-
querySubscriptionHandler,
|
|
22
20
|
} from "./middleware";
|
|
23
21
|
export type {
|
|
24
22
|
ArcHttpHandler,
|
package/src/middleware/http.ts
CHANGED
|
@@ -127,116 +127,6 @@ export function queryHandler(ch: ContextHandler): ArcHttpHandler {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
// Stream — GET /stream/:viewName (SSE)
|
|
132
|
-
// ---------------------------------------------------------------------------
|
|
133
|
-
|
|
134
|
-
interface StreamConnection {
|
|
135
|
-
id: string;
|
|
136
|
-
controller: ReadableStreamDefaultController<Uint8Array>;
|
|
137
|
-
unsubscribe: () => void;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
let streamIdCounter = 0;
|
|
141
|
-
const streamConnections = new Map<string, StreamConnection>();
|
|
142
|
-
|
|
143
|
-
export function streamHandler(ch: ContextHandler): ArcHttpHandler {
|
|
144
|
-
return (_req, url, ctx) => {
|
|
145
|
-
if (!url.pathname.startsWith("/stream/") || _req.method !== "GET")
|
|
146
|
-
return null;
|
|
147
|
-
|
|
148
|
-
const viewName = url.pathname.split("/stream/")[1];
|
|
149
|
-
if (!viewName) {
|
|
150
|
-
return new Response("Invalid stream path", {
|
|
151
|
-
status: 400,
|
|
152
|
-
headers: ctx.corsHeaders,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const findOptions: any = {};
|
|
157
|
-
const whereParam = url.searchParams.get("where");
|
|
158
|
-
if (whereParam) {
|
|
159
|
-
try {
|
|
160
|
-
findOptions.where = JSON.parse(whereParam);
|
|
161
|
-
} catch {
|
|
162
|
-
return new Response("Invalid 'where' parameter", {
|
|
163
|
-
status: 400,
|
|
164
|
-
headers: ctx.corsHeaders,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
const orderByParam = url.searchParams.get("orderBy");
|
|
169
|
-
if (orderByParam) {
|
|
170
|
-
try {
|
|
171
|
-
findOptions.orderBy = JSON.parse(orderByParam);
|
|
172
|
-
} catch {
|
|
173
|
-
return new Response("Invalid 'orderBy' parameter", {
|
|
174
|
-
status: 400,
|
|
175
|
-
headers: ctx.corsHeaders,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const limitParam = url.searchParams.get("limit");
|
|
180
|
-
if (limitParam) findOptions.limit = parseInt(limitParam, 10);
|
|
181
|
-
|
|
182
|
-
const streamId = `stream_${++streamIdCounter}_${Date.now()}`;
|
|
183
|
-
const rawToken = ctx.rawToken;
|
|
184
|
-
|
|
185
|
-
const stream = new ReadableStream<Uint8Array>({
|
|
186
|
-
start(controller) {
|
|
187
|
-
const scoped = new ScopedModel(ch.getModel(), "stream");
|
|
188
|
-
if (rawToken) scoped.setToken(rawToken);
|
|
189
|
-
|
|
190
|
-
const descriptor = { element: viewName, method: "find", args: [findOptions] };
|
|
191
|
-
|
|
192
|
-
const sendData = async () => {
|
|
193
|
-
try {
|
|
194
|
-
const data = await scoped.callQuery(descriptor);
|
|
195
|
-
controller.enqueue(
|
|
196
|
-
new TextEncoder().encode(
|
|
197
|
-
`data: ${JSON.stringify({ type: "data", data })}\n\n`,
|
|
198
|
-
),
|
|
199
|
-
);
|
|
200
|
-
} catch {
|
|
201
|
-
unsubscribe();
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// Initial data
|
|
206
|
-
sendData();
|
|
207
|
-
|
|
208
|
-
// Subscribe to changes
|
|
209
|
-
const unsubscribe = ch
|
|
210
|
-
.getEventPublisher()
|
|
211
|
-
.subscribe("*", () => sendData());
|
|
212
|
-
|
|
213
|
-
streamConnections.set(streamId, { id: streamId, controller, unsubscribe });
|
|
214
|
-
controller.enqueue(
|
|
215
|
-
new TextEncoder().encode(
|
|
216
|
-
`data: ${JSON.stringify({ type: "connected", streamId })}\n\n`,
|
|
217
|
-
),
|
|
218
|
-
);
|
|
219
|
-
},
|
|
220
|
-
cancel() {
|
|
221
|
-
const conn = streamConnections.get(streamId);
|
|
222
|
-
if (conn) {
|
|
223
|
-
conn.unsubscribe();
|
|
224
|
-
streamConnections.delete(streamId);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return new Response(stream, {
|
|
230
|
-
headers: {
|
|
231
|
-
...ctx.corsHeaders,
|
|
232
|
-
"Content-Type": "text/event-stream",
|
|
233
|
-
"Cache-Control": "no-cache",
|
|
234
|
-
Connection: "keep-alive",
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
|
|
240
130
|
// ---------------------------------------------------------------------------
|
|
241
131
|
// Event Sync — POST /sync/events
|
|
242
132
|
// ---------------------------------------------------------------------------
|
|
@@ -399,16 +289,7 @@ export function arcHttpHandlers(
|
|
|
399
289
|
healthHandler(cm),
|
|
400
290
|
commandHandler(ch),
|
|
401
291
|
queryHandler(ch),
|
|
402
|
-
streamHandler(ch),
|
|
403
292
|
eventSyncHandler(ch),
|
|
404
293
|
routeHandler(ch),
|
|
405
294
|
];
|
|
406
295
|
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Cleanup all active SSE stream connections.
|
|
410
|
-
*/
|
|
411
|
-
export function cleanupStreams(): void {
|
|
412
|
-
for (const conn of streamConnections.values()) conn.unsubscribe();
|
|
413
|
-
streamConnections.clear();
|
|
414
|
-
}
|
package/src/middleware/index.ts
CHANGED
|
@@ -7,21 +7,19 @@ export type {
|
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
arcHttpHandlers,
|
|
10
|
-
cleanupStreams,
|
|
11
10
|
commandHandler,
|
|
12
11
|
eventSyncHandler,
|
|
13
12
|
healthHandler,
|
|
14
13
|
queryHandler,
|
|
15
14
|
routeHandler,
|
|
16
|
-
streamHandler,
|
|
17
15
|
} from "./http";
|
|
18
16
|
|
|
19
17
|
export {
|
|
20
18
|
arcWsHandlers,
|
|
21
19
|
cleanupClientSubs,
|
|
22
20
|
executeCommandHandler,
|
|
21
|
+
querySubscriptionHandler,
|
|
23
22
|
requestSyncHandler,
|
|
24
23
|
scopeAuthHandler,
|
|
25
24
|
syncEventsHandler,
|
|
26
|
-
querySubscriptionHandler,
|
|
27
25
|
} from "./ws";
|