@streamsy/core 0.15.0 → 0.17.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/README.md +4 -284
- package/dist/{create-validation-DzLxKiux.js → create-validation-NKP81BC0.js} +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -2
- package/dist/{http-YoA8cUTN.js → http-aCMEaxro.js} +2 -2
- package/dist/index-DIx4D2t0.d.ts +836 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +134 -224
- package/dist/internal/index.d.ts +284 -25
- package/dist/internal/index.js +12 -3
- package/dist/{layer-DjKTdIY5.js → layer-DTOhxWkw.js} +21 -19
- package/dist/{layer-J6sV3UXD.js → layer-Dv_LBCgD.js} +15 -8
- package/dist/{program-BlfAJNlD.js → program-gGLU50A1.js} +16 -11
- package/dist/protocol/index.d.ts +1 -2
- package/dist/protocol/index.js +3 -3
- package/dist/read-message-DP1UpEFl.js +660 -0
- package/dist/remote/index.d.ts +5 -3
- package/dist/remote/index.js +158 -28
- package/dist/{projection-marks-BEZv8qDJ.d.ts → storage-xTb82JxJ.d.ts} +376 -397
- package/dist/{streamsy-HKC10a_V.js → streamsy-DiAjZWlT.js} +336 -174
- package/dist/testing/index.d.ts +7 -7
- package/dist/testing/index.js +28 -21
- package/package.json +4 -4
- package/dist/boundary-f1biibJ1.js +0 -371
- package/dist/index-BtVxu6VJ.d.ts +0 -774
- package/dist/route-internal-DNL0oGTN.js +0 -93
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
|
-
import {
|
|
2
|
+
import { I as isProtocolError, L as StreamsReader, Q as StreamId, R as StreamsWriter, V as isStreamsyOffset, v as AppendResult, y as CreateResult, z as ZERO_OFFSET } from "./streamsy-DiAjZWlT.js";
|
|
3
3
|
import { t as generateCursor } from "./cursor-generator-DySXZ93b.js";
|
|
4
4
|
import { Array, Clock, Context, DateTime, Deferred, Effect, Layer, Match, Option, Random, Record, Ref, Schedule, Stream } from "effect";
|
|
5
5
|
import { HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
@@ -208,7 +208,7 @@ function toResponse$1(result, location) {
|
|
|
208
208
|
const created = CreateResult.$is("Created")(result);
|
|
209
209
|
const headers = new Headers({
|
|
210
210
|
"content-type": result.contentType,
|
|
211
|
-
"stream-next-offset": result.
|
|
211
|
+
"stream-next-offset": result.offset
|
|
212
212
|
});
|
|
213
213
|
if (created) headers.set("location", location);
|
|
214
214
|
if (result.closed) headers.set("stream-closed", "true");
|
|
@@ -258,7 +258,7 @@ function parseHeaders(request) {
|
|
|
258
258
|
response: responses$3.badRequest("Invalid producer headers")
|
|
259
259
|
};
|
|
260
260
|
const expectedOffset = request.headers.get("stream-expected-offset") ?? void 0;
|
|
261
|
-
if (expectedOffset !== void 0 && !
|
|
261
|
+
if (expectedOffset !== void 0 && !isStreamsyOffset(expectedOffset)) return {
|
|
262
262
|
ok: false,
|
|
263
263
|
response: responses$3.badRequest("Invalid expected offset")
|
|
264
264
|
};
|
|
@@ -400,11 +400,12 @@ function bytesToBase64(bytes) {
|
|
|
400
400
|
}
|
|
401
401
|
// src/http/read-query-parser.ts
|
|
402
402
|
const readQueryParser = (isValidOffset) => ({ parse(url) {
|
|
403
|
-
const
|
|
403
|
+
const requested = url.searchParams.get("offset") ?? void 0;
|
|
404
404
|
const liveParam = url.searchParams.get("live");
|
|
405
405
|
const cursor = url.searchParams.get("cursor") ?? void 0;
|
|
406
406
|
const live = liveParam === "long-poll" || liveParam === "sse" || liveParam === "websocket" ? liveParam : void 0;
|
|
407
|
-
|
|
407
|
+
const offset = requested === void 0 || requested === "-1" || requested === "now" || isValidOffset(requested) ? requested : null;
|
|
408
|
+
if (offset === null) return {
|
|
408
409
|
ok: false,
|
|
409
410
|
response: new Response("Invalid offset format", { status: 400 })
|
|
410
411
|
};
|
|
@@ -441,7 +442,10 @@ function dataEvent(messages, options) {
|
|
|
441
442
|
chunks.push(encode("data:]\n"));
|
|
442
443
|
} else {
|
|
443
444
|
const text = Array.join(Array.map(messages, (msg) => decoder.decode(msg.data)), "");
|
|
444
|
-
for (const line of text.split(/\r\n|\r|\n/))
|
|
445
|
+
for (const line of text.split(/\r\n|\r|\n/)) {
|
|
446
|
+
const separator = line.startsWith(" ") ? " " : "";
|
|
447
|
+
chunks.push(encode(`data:${separator}${line}\n`));
|
|
448
|
+
}
|
|
445
449
|
}
|
|
446
450
|
chunks.push(encode("\n"));
|
|
447
451
|
return chunks;
|
|
@@ -629,7 +633,7 @@ function upgradeRequired() {
|
|
|
629
633
|
const responses$2 = responses_exports;
|
|
630
634
|
const bodyCodec = message_body_codec_exports;
|
|
631
635
|
const etags = etag_builder_exports;
|
|
632
|
-
const queryParser = readQueryParser(
|
|
636
|
+
const queryParser = readQueryParser(isStreamsyOffset);
|
|
633
637
|
/**
|
|
634
638
|
* The reply a parked long poll gives when the host drains: no messages, the
|
|
635
639
|
* requested offset, and a fresh cursor. The HTTP layer turns it into the same
|
|
@@ -640,10 +644,11 @@ const drainReply = Effect.fn("Http.drainReply")(function* (reader, id, offset, c
|
|
|
640
644
|
const head = yield* reader.head(id);
|
|
641
645
|
const now = yield* Clock.currentTimeMillis;
|
|
642
646
|
const random = yield* Random.next;
|
|
647
|
+
const nextOffset = Match.value(offset).pipe(Match.when("now", () => head.offset), Match.when("-1", () => ZERO_OFFSET), Match.orElse((at) => at));
|
|
643
648
|
return {
|
|
644
649
|
contentType: head.contentType,
|
|
645
650
|
messages: [],
|
|
646
|
-
nextOffset
|
|
651
|
+
nextOffset,
|
|
647
652
|
upToDate: true,
|
|
648
653
|
closed: false,
|
|
649
654
|
timedOut: true,
|
|
@@ -680,7 +685,7 @@ const read$1 = Effect.fn("Http.read")(function* (reader, id, url, requestHeaders
|
|
|
680
685
|
const signal = yield* Effect.serviceOption(ShutdownSignal);
|
|
681
686
|
if (query.live === "sse" && offset) {
|
|
682
687
|
const meta = yield* reader.head(id);
|
|
683
|
-
return sse(reader, id, meta.contentType, offset === "now" ? meta.
|
|
688
|
+
return sse(reader, id, meta.contentType, offset === "now" ? meta.offset : offset, query.cursor, sseDeadlineMs, Option.getOrUndefined(signal));
|
|
684
689
|
}
|
|
685
690
|
const live = query.live === "long-poll" && offset !== void 0;
|
|
686
691
|
const result = live && offset !== void 0 ? yield* longPoll(reader, id, offset, query.cursor, signal) : yield* reader.read(id, { offset }).pipe(Effect.map((batch) => ({
|
|
@@ -730,7 +735,7 @@ function read(id, options = {}) {
|
|
|
730
735
|
const meta = yield* reader.head(id);
|
|
731
736
|
const headers = new Headers({
|
|
732
737
|
"content-type": meta.contentType,
|
|
733
|
-
"stream-next-offset": meta.
|
|
738
|
+
"stream-next-offset": meta.offset,
|
|
734
739
|
"cache-control": "no-store"
|
|
735
740
|
});
|
|
736
741
|
if (meta.closed) headers.set("stream-closed", "true");
|
|
@@ -756,7 +761,7 @@ function protocolErrorResponse(error, context) {
|
|
|
756
761
|
StreamGone: () => context.method === "HEAD" ? responses$1.noStore(responses$1.gone()) : responses$1.gone(),
|
|
757
762
|
ForkSourceNotFound: ({ source }) => responses$1.notFound(`Source stream not found: ${source}`),
|
|
758
763
|
CreateConflict: conflict,
|
|
759
|
-
AppendConflict: conflict,
|
|
764
|
+
AppendConflict: ({ message, reason }) => responses$1.conflict(message, reason === void 0 ? void 0 : { "stream-conflict-reason": reason }),
|
|
760
765
|
InvalidReadRequest: badRequest,
|
|
761
766
|
InvalidForkRequest: badRequest,
|
|
762
767
|
InvalidCreateRequest: badRequest,
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { J as layer_d_exports, V as streams_d_exports, Z as route_d_exports, w as RoutesOptions } from "../index-BtVxu6VJ.js";
|
|
1
|
+
import { H as streams_d_exports, J as layer_d_exports, Z as route_d_exports, it as Writer, nt as StreamsReader, rt as StreamsWriter, tt as Reader, w as RoutesOptions } from "../index-DIx4D2t0.js";
|
|
3
2
|
import { HttpRouter } from "effect/http";
|
|
4
3
|
/** Raw protocol route for adapters and wire conformance tests. */
|
|
5
4
|
export declare const routes: (options?: Omit<RoutesOptions, "access">) => import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", StreamsReader> | HttpRouter.Request<"Requires", StreamsWriter>>;
|
package/dist/protocol/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as layer_exports } from "../layer-
|
|
3
|
-
import { t as app } from "../program-
|
|
1
|
+
import { L as StreamsReader, R as StreamsWriter, d as route_exports, u as streams_exports } from "../streamsy-DiAjZWlT.js";
|
|
2
|
+
import { n as layer_exports } from "../layer-DTOhxWkw.js";
|
|
3
|
+
import { t as app } from "../program-gGLU50A1.js";
|
|
4
4
|
import { HttpRouter } from "effect/http";
|
|
5
5
|
// src/protocol/routes.ts
|
|
6
6
|
/** Raw protocol route for adapters and wire conformance tests. */
|