@streamsy/core 0.16.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/dist/{create-validation-C_aJJm5u.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-BNYNMGuk.js → http-aCMEaxro.js} +2 -2
- package/dist/{index-D-n48qXe.d.ts → index-DIx4D2t0.d.ts} +329 -152
- package/dist/index.d.ts +3 -3
- package/dist/index.js +52 -184
- package/dist/internal/index.d.ts +254 -26
- package/dist/internal/index.js +12 -3
- package/dist/{layer-pomDIajD.js → layer-DTOhxWkw.js} +19 -19
- package/dist/{layer-C-8GAL_W.js → layer-Dv_LBCgD.js} +15 -8
- package/dist/{program-DhW5In9U.js → program-gGLU50A1.js} +11 -9
- 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 +2 -2
- package/dist/remote/index.js +8 -8
- package/dist/{projection-marks-DcO_5VNd.d.ts → storage-xTb82JxJ.d.ts} +301 -462
- package/dist/{streamsy-IBFULoEr.js → streamsy-DiAjZWlT.js} +321 -94
- package/dist/testing/index.d.ts +7 -7
- package/dist/testing/index.js +28 -22
- package/package.json +4 -4
- package/dist/boundary-BTrhL8De.js +0 -371
- package/dist/read-message-CGHhOCMc.js +0 -193
package/dist/internal/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { a as compileSegments,
|
|
2
|
-
import { a as CommitHooks, c as OwnerRecords, i as ProjectionMarks, o as commitHookRegistry, r as memoryProjectionMarks, s as OWNER_RECORDS_LIST_UNSUPPORTED, t as enlist } from "../boundary-BTrhL8De.js";
|
|
1
|
+
import { C as memoryProjectionMarks, O as commitHookRegistry, _ as decorateOwner, a as compileSegments, b as ownerParts, d as CurrentOwner, g as buildStorageOwner, h as OwnerSlot, l as resolveParams, m as OwnerBackend, n as decodeStateWire, p as isForeignOwner, s as isSingletonRoute, t as decodeMessage, u as throwInvalidStreamParams, v as memoryEnlist, x as MemoryEnlistFault, y as newOwnerId } from "../read-message-DP1UpEFl.js";
|
|
3
2
|
import { n as offsetsOf, t as attachOffsets } from "../read-offsets-CQ4VkAs8.js";
|
|
4
3
|
import { Array, Effect } from "effect";
|
|
4
|
+
// src/internal/owner-records.ts
|
|
5
|
+
/** The `StorageFault.operation` of an owner store that cannot list its records. */
|
|
6
|
+
const OWNER_RECORDS_LIST_UNSUPPORTED = "records.list.unsupported";
|
|
5
7
|
// src/internal/limits.ts
|
|
6
8
|
/**
|
|
7
9
|
* The MySQL producer key holds a stream id and at most this many producer id
|
|
@@ -26,4 +28,11 @@ const fitKey = (key, limit, readable = key) => {
|
|
|
26
28
|
const prefix = Array.join(Array.take(codePoints(readable), limit - DIGEST_LENGTH), "");
|
|
27
29
|
return Effect.map(sha256Hex(key), (digest) => `${prefix}#${digest}`);
|
|
28
30
|
};
|
|
29
|
-
|
|
31
|
+
// src/internal/bind-declaration.ts
|
|
32
|
+
/**
|
|
33
|
+
* Bind any declaration for `params`: its `singleton` for a singleton, `at(params)` otherwise.
|
|
34
|
+
* A singleton ignores `params`, as its route reads none. `at` may throw a `RangeError` whose
|
|
35
|
+
* `cause` is an `InvalidStreamParams`; wrap the call in `resolveParams` for request values.
|
|
36
|
+
*/
|
|
37
|
+
const bindDeclaration = (declaration, params) => "singleton" in declaration ? declaration.singleton : declaration.at(params);
|
|
38
|
+
export { CurrentOwner, MAX_PRODUCER_ID_LENGTH, MemoryEnlistFault, OWNER_RECORDS_LIST_UNSUPPORTED, OwnerBackend, OwnerSlot, attachOffsets, bindDeclaration, buildStorageOwner, commitHookRegistry, compileSegments, decodeMessage, decodeStateWire, decorateOwner, fitKey, isForeignOwner, isSingletonRoute, memoryEnlist, memoryProjectionMarks, newOwnerId, offsetsOf, ownerParts, resolveParams, throwInvalidStreamParams };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
import { n as validateCreateOptions, r as frameMessages, t as frameCreateMessages } from "./create-validation-
|
|
2
|
+
import { A as ProducerGap, B as compare, C as InvalidAppendRequest, D as InvalidReadRequest, E as InvalidForkRequest, F as StreamNotFound, J as ProducerState, L as StreamsReader, M as StreamBusy, N as StreamClosed, O as NotSupported, P as StreamGone, Q as StreamId, R as StreamsWriter, S as ForkSourceNotFound, T as InvalidEpochSeq, U as next, V as isStreamsyOffset, X as StoredMessage, Y as RecordPatch, b as AppendConflict, et as StreamRecord, j as StaleEpoch, k as OffsetMismatch, n as bind, q as ProducerId, tt as StreamsyOffset, v as AppendResult, x as CreateConflict, y as CreateResult, z as ZERO_OFFSET } from "./streamsy-DiAjZWlT.js";
|
|
3
|
+
import { b as ownerParts, k as StorageOwner } from "./read-message-DP1UpEFl.js";
|
|
4
|
+
import { n as validateCreateOptions, r as frameMessages, t as frameCreateMessages } from "./create-validation-NKP81BC0.js";
|
|
5
5
|
import { t as attachOffsets } from "./read-offsets-CQ4VkAs8.js";
|
|
6
6
|
import { t as generateCursor } from "./cursor-generator-DySXZ93b.js";
|
|
7
7
|
import { Array, Clock, Context, Data, Effect, Layer, Match, Option, Predicate, Random, Result, Schema, Stream } from "effect";
|
|
@@ -17,14 +17,14 @@ const Operation = Schema.Union([
|
|
|
17
17
|
initialMessages: Schema.Array(StoredMessage),
|
|
18
18
|
forkSource: Schema.optionalKey(Schema.Struct({
|
|
19
19
|
id: StreamId,
|
|
20
|
-
liveAtOffset:
|
|
20
|
+
liveAtOffset: StreamsyOffset
|
|
21
21
|
}))
|
|
22
22
|
}),
|
|
23
23
|
Schema.TaggedStruct("Append", {
|
|
24
24
|
streamId: StreamId,
|
|
25
25
|
messages: Schema.Array(StoredMessage),
|
|
26
26
|
patch: RecordPatch,
|
|
27
|
-
expectedOffset: Schema.optionalKey(
|
|
27
|
+
expectedOffset: Schema.optionalKey(StreamsyOffset),
|
|
28
28
|
expectedClosed: Schema.optionalKey(Schema.Boolean),
|
|
29
29
|
producer: Schema.optionalKey(ProducerPrecondition)
|
|
30
30
|
}),
|
|
@@ -134,7 +134,7 @@ var ForkPlanBuilder = class {
|
|
|
134
134
|
message: `Source stream is soft-deleted: ${sourcePath}`
|
|
135
135
|
}) });
|
|
136
136
|
const forkOffset = options.forkOffset ?? source.currentOffset;
|
|
137
|
-
if (!
|
|
137
|
+
if (!isStreamsyOffset(forkOffset)) return ForkBuildResult.Rejected({ error: new InvalidForkRequest({
|
|
138
138
|
id: targetId,
|
|
139
139
|
message: "Invalid Stream-Fork-Offset format"
|
|
140
140
|
}) });
|
|
@@ -158,7 +158,7 @@ var ForkPlanBuilder = class {
|
|
|
158
158
|
const expiry = resolveForkExpiry(options, source);
|
|
159
159
|
const fork = {
|
|
160
160
|
forkedFrom: sourcePath,
|
|
161
|
-
forkOffset:
|
|
161
|
+
forkOffset: StreamsyOffset.make(forkOffset)
|
|
162
162
|
};
|
|
163
163
|
if (subOffset !== void 0 && subOffset > 0) fork.forkSubOffset = subOffset;
|
|
164
164
|
const baseRecord = this.deps.newRecord(targetId, contentType, {
|
|
@@ -177,13 +177,13 @@ var ForkPlanBuilder = class {
|
|
|
177
177
|
initialMessages,
|
|
178
178
|
forkSource: {
|
|
179
179
|
id: sourcePath,
|
|
180
|
-
liveAtOffset:
|
|
180
|
+
liveAtOffset: StreamsyOffset.make(forkOffset)
|
|
181
181
|
}
|
|
182
182
|
});
|
|
183
183
|
return ForkBuildResult.Fork({
|
|
184
184
|
plan,
|
|
185
185
|
toResult: (record) => CreateResult.Created({
|
|
186
|
-
|
|
186
|
+
offset: record.currentOffset,
|
|
187
187
|
contentType,
|
|
188
188
|
closed: record.lifecycle.closed
|
|
189
189
|
})
|
|
@@ -256,7 +256,7 @@ const touch = Effect.fn("Protocol.touch")(function* (storage, record) {
|
|
|
256
256
|
});
|
|
257
257
|
/** One host-triggered sweep; the host owns scheduling and cancellation. */
|
|
258
258
|
const expireDue = Effect.fn("Protocol.expireDue")(function* () {
|
|
259
|
-
const storage = yield*
|
|
259
|
+
const { storage } = ownerParts(yield* StorageOwner);
|
|
260
260
|
const now = yield* Clock.currentTimeMillis;
|
|
261
261
|
while (true) {
|
|
262
262
|
const deadline = yield* storage.nextExpiry;
|
|
@@ -303,7 +303,7 @@ const existingResult = Effect.fn("Protocol.existingResult")(function* (record, o
|
|
|
303
303
|
message: "Stream exists with different configuration"
|
|
304
304
|
});
|
|
305
305
|
return CreateResult.Exists({
|
|
306
|
-
|
|
306
|
+
offset: record.currentOffset,
|
|
307
307
|
contentType: record.config.contentType,
|
|
308
308
|
closed: record.lifecycle.closed
|
|
309
309
|
});
|
|
@@ -322,7 +322,7 @@ const create = Effect.fn("Protocol.create")(function* (storage, id, options = {}
|
|
|
322
322
|
const sourceId = StreamId.make(options.forkedFrom);
|
|
323
323
|
const source = yield* expireIfNeeded(storage, sourceId);
|
|
324
324
|
const after = options.forkOffset;
|
|
325
|
-
const tail = options.forkSubOffset && after &&
|
|
325
|
+
const tail = options.forkSubOffset && after && isStreamsyOffset(after) ? [...yield* storage.messages(sourceId, { after })] : void 0;
|
|
326
326
|
const built = new ForkPlanBuilder({
|
|
327
327
|
clock: { now: () => now },
|
|
328
328
|
newRecord: (target, type, opts, fork) => newRecord(target, type, opts, now, fork)
|
|
@@ -359,7 +359,7 @@ const create = Effect.fn("Protocol.create")(function* (storage, id, options = {}
|
|
|
359
359
|
return yield* storage.mutate({ operations: [plan] }).pipe(Effect.uninterruptible, Effect.map((result) => {
|
|
360
360
|
const record = result.results[0].record;
|
|
361
361
|
return CreateResult.Created({
|
|
362
|
-
|
|
362
|
+
offset: record.currentOffset,
|
|
363
363
|
contentType: record.config.contentType,
|
|
364
364
|
closed: record.lifecycle.closed
|
|
365
365
|
});
|
|
@@ -514,20 +514,20 @@ const head = Effect.fn("Protocol.head")(function* (storage, id) {
|
|
|
514
514
|
if (record.lifecycle.softDeleted) return yield* new StreamGone({ id });
|
|
515
515
|
return {
|
|
516
516
|
contentType: record.config.contentType,
|
|
517
|
-
|
|
517
|
+
offset: record.currentOffset,
|
|
518
518
|
ttlSeconds: record.config.ttlSeconds,
|
|
519
519
|
expiresAt: record.config.expiresAt,
|
|
520
520
|
closed: record.lifecycle.closed
|
|
521
521
|
};
|
|
522
522
|
});
|
|
523
|
-
const validateOffset = (id, offset) => offset === void 0 || offset === "-1" || offset === "now" ||
|
|
523
|
+
const validateOffset = (id, offset) => offset === void 0 || offset === "-1" || offset === "now" || isStreamsyOffset(offset) ? Effect.void : Effect.fail(new InvalidReadRequest({
|
|
524
524
|
id,
|
|
525
525
|
message: "Invalid offset format"
|
|
526
526
|
}));
|
|
527
527
|
const readRecord = Effect.fn("Protocol.readRecord")(function* (storage, record, options, limit) {
|
|
528
528
|
const from = options.offset === "now" ? record.currentOffset : options.offset;
|
|
529
529
|
const normalized = !from || from === "-1" ? void 0 : from;
|
|
530
|
-
const after = normalized === void 0 ? void 0 :
|
|
530
|
+
const after = normalized === void 0 ? void 0 : StreamsyOffset.make(normalized);
|
|
531
531
|
yield* touch(storage, record);
|
|
532
532
|
const messages = yield* storage.messages(record.id, {
|
|
533
533
|
after,
|
|
@@ -565,7 +565,7 @@ const readNext = Effect.fn("Protocol.readNext")(function* (storage, id, options,
|
|
|
565
565
|
if (Option.isNone(found)) return yield* new StreamNotFound({ id });
|
|
566
566
|
const record = found.value;
|
|
567
567
|
if (record.lifecycle.softDeleted) return yield* new StreamGone({ id });
|
|
568
|
-
const from = options.offset === "now" ? record.currentOffset :
|
|
568
|
+
const from = options.offset === "now" ? record.currentOffset : isStreamsyOffset(options.offset) ? options.offset : ZERO_OFFSET;
|
|
569
569
|
const initial = yield* readRecord(storage, record, { offset: from });
|
|
570
570
|
const cursor = Effect.gen(function* () {
|
|
571
571
|
const now = yield* Clock.currentTimeMillis;
|
|
@@ -596,7 +596,7 @@ var layer_exports = /* @__PURE__ */ __exportAll({
|
|
|
596
596
|
layer: () => layer
|
|
597
597
|
});
|
|
598
598
|
const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
599
|
-
const storage = yield*
|
|
599
|
+
const { storage } = ownerParts(yield* StorageOwner);
|
|
600
600
|
const timeout = options.longPollTimeoutMs ?? 3e4;
|
|
601
601
|
if (!Number.isFinite(timeout) || timeout <= 0) return yield* Effect.die(/* @__PURE__ */ new RangeError("longPollTimeoutMs must be positive"));
|
|
602
602
|
const readLimit = options.readLimit ?? 1e3;
|
|
@@ -625,6 +625,6 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
|
625
625
|
}));
|
|
626
626
|
})
|
|
627
627
|
});
|
|
628
|
-
return Context.make(StreamsReader,
|
|
628
|
+
return Context.make(StreamsReader, reader).pipe(Context.add(StreamsWriter, writer));
|
|
629
629
|
}));
|
|
630
630
|
export { MutationRejected as a, OperationResult as c, ProducerPrecondition as d, MutationApplied as i, OperationResults as l, layer_exports as n, Mutations as o, Mutation as r, Operation as s, layer as t, Operations as u };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import {
|
|
5
|
-
import { Array, Context, Effect, Layer, Option, Order, Predicate, PubSub, Queue, Schedule, Stream } from "effect";
|
|
1
|
+
import { z as ZERO_OFFSET } from "./streamsy-DiAjZWlT.js";
|
|
2
|
+
import { D as patchRecord, E as indexDeadlines, S as makeBoundary, T as copyRecord, g as buildStorageOwner, k as StorageOwner, m as OwnerBackend, w as copyMessage } from "./read-message-DP1UpEFl.js";
|
|
3
|
+
import { a as MutationRejected, l as OperationResults, o as Mutations, u as Operations } from "./layer-DTOhxWkw.js";
|
|
4
|
+
import { Array, Effect, Layer, Option, Order, Predicate, PubSub, Queue, Schedule, Stream } from "effect";
|
|
6
5
|
// src/storage/memory/lineage.ts
|
|
7
6
|
/** Synchronous port of cascade-reclaim and chained message composition.
|
|
8
7
|
* Called only inside the memory mutation lock or synchronous read snapshot.
|
|
@@ -127,7 +126,7 @@ function reject(state, operation, index) {
|
|
|
127
126
|
if (actual?.epoch !== expected?.epoch || actual?.lastSeq !== expected?.lastSeq) return rejected("producer");
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
const layer = (options = {}) => Layer.
|
|
129
|
+
const layer = (options = {}) => Layer.effect(StorageOwner, Effect.gen(function* () {
|
|
131
130
|
const chain = !options.constrained;
|
|
132
131
|
const interval = options.pollIntervalMs ?? 25;
|
|
133
132
|
if (!Number.isFinite(interval) || interval <= 0) return yield* Effect.die(/* @__PURE__ */ new RangeError("pollIntervalMs must be positive"));
|
|
@@ -190,7 +189,7 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
|
190
189
|
changed
|
|
191
190
|
};
|
|
192
191
|
};
|
|
193
|
-
const storage =
|
|
192
|
+
const storage = {
|
|
194
193
|
capabilities: {
|
|
195
194
|
fork: chain ? "chain" : "copy",
|
|
196
195
|
atomicScope: chain ? "store" : "stream",
|
|
@@ -217,7 +216,15 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
|
217
216
|
changes: (id) => changes(committed, bus, id, chain, interval),
|
|
218
217
|
committed: PubSub.subscribe(feed),
|
|
219
218
|
nextExpiry: owner.access((state) => Option.fromUndefinedOr(state.deadlines[0]).pipe(Option.map((deadline) => ({ ...deadline }))))
|
|
219
|
+
};
|
|
220
|
+
return buildStorageOwner({
|
|
221
|
+
label: "memory",
|
|
222
|
+
storage,
|
|
223
|
+
records: owner.records,
|
|
224
|
+
hooks: owner.hooks,
|
|
225
|
+
marks: owner.marks,
|
|
226
|
+
backend: OwnerBackend.Memory({ enlist: owner.enlist }),
|
|
227
|
+
withTransaction: owner.withTransaction
|
|
220
228
|
});
|
|
221
|
-
return Context.make(Storage, attachOwner(storage, ownerOf(owner.boundary))).pipe(Context.add(CommitBoundary, owner.boundary), Context.add(OwnerRecords, owner.records), Context.add(CommitHooks, owner.hooks), Context.add(ProjectionMarks, owner.marks));
|
|
222
229
|
}));
|
|
223
230
|
export { layer as t };
|
|
@@ -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
|
};
|
|
@@ -632,7 +633,7 @@ function upgradeRequired() {
|
|
|
632
633
|
const responses$2 = responses_exports;
|
|
633
634
|
const bodyCodec = message_body_codec_exports;
|
|
634
635
|
const etags = etag_builder_exports;
|
|
635
|
-
const queryParser = readQueryParser(
|
|
636
|
+
const queryParser = readQueryParser(isStreamsyOffset);
|
|
636
637
|
/**
|
|
637
638
|
* The reply a parked long poll gives when the host drains: no messages, the
|
|
638
639
|
* requested offset, and a fresh cursor. The HTTP layer turns it into the same
|
|
@@ -643,10 +644,11 @@ const drainReply = Effect.fn("Http.drainReply")(function* (reader, id, offset, c
|
|
|
643
644
|
const head = yield* reader.head(id);
|
|
644
645
|
const now = yield* Clock.currentTimeMillis;
|
|
645
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));
|
|
646
648
|
return {
|
|
647
649
|
contentType: head.contentType,
|
|
648
650
|
messages: [],
|
|
649
|
-
nextOffset
|
|
651
|
+
nextOffset,
|
|
650
652
|
upToDate: true,
|
|
651
653
|
closed: false,
|
|
652
654
|
timedOut: true,
|
|
@@ -683,7 +685,7 @@ const read$1 = Effect.fn("Http.read")(function* (reader, id, url, requestHeaders
|
|
|
683
685
|
const signal = yield* Effect.serviceOption(ShutdownSignal);
|
|
684
686
|
if (query.live === "sse" && offset) {
|
|
685
687
|
const meta = yield* reader.head(id);
|
|
686
|
-
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));
|
|
687
689
|
}
|
|
688
690
|
const live = query.live === "long-poll" && offset !== void 0;
|
|
689
691
|
const result = live && offset !== void 0 ? yield* longPoll(reader, id, offset, query.cursor, signal) : yield* reader.read(id, { offset }).pipe(Effect.map((batch) => ({
|
|
@@ -733,7 +735,7 @@ function read(id, options = {}) {
|
|
|
733
735
|
const meta = yield* reader.head(id);
|
|
734
736
|
const headers = new Headers({
|
|
735
737
|
"content-type": meta.contentType,
|
|
736
|
-
"stream-next-offset": meta.
|
|
738
|
+
"stream-next-offset": meta.offset,
|
|
737
739
|
"cache-control": "no-store"
|
|
738
740
|
});
|
|
739
741
|
if (meta.closed) headers.set("stream-closed", "true");
|
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-D-n48qXe.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. */
|