Skip to content

Commit 82d9cab

Browse files
chore: generate
1 parent fb43c15 commit 82d9cab

5 files changed

Lines changed: 19 additions & 40 deletions

File tree

packages/core/src/event.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ export function define<const Type extends string, Fields extends Schema.Struct.F
100100
) {
101101
registry.set(input.type, definition)
102102
}
103-
if (input.durable)
104-
durableRegistry.set(versionedType(input.type, input.durable.version), definition)
103+
if (input.durable) durableRegistry.set(versionedType(input.type, input.durable.version), definition)
105104
return definition as Schema.Schema<Payload<Definition<Type, Schema.Struct<Fields>>>> &
106105
Definition<Type, Schema.Struct<Fields>>
107106
}
@@ -126,10 +125,7 @@ export interface Interface {
126125
) => Effect.Effect<Payload<D>>
127126
readonly subscribe: <D extends Definition>(definition: D) => Stream.Stream<Payload<D>>
128127
readonly all: () => Stream.Stream<Payload>
129-
readonly durable: (input: {
130-
readonly aggregateID: string
131-
readonly after?: number
132-
}) => Stream.Stream<Payload>
128+
readonly durable: (input: { readonly aggregateID: string; readonly after?: number }) => Stream.Stream<Payload>
133129
/** @deprecated Use `all()` and consume the returned stream. */
134130
readonly listen: (listener: Subscriber) => Effect.Effect<Unsubscribe>
135131
readonly project: <D extends Definition>(definition: D, projector: Subscriber<D>) => Effect.Effect<void>
@@ -382,8 +378,7 @@ export const layerWith = (options?: LayerOptions) =>
382378
Effect.suspend(() => observer(event)).pipe(
383379
Effect.catchCauseIf(
384380
(cause) => !Cause.hasInterrupts(cause),
385-
(cause) =>
386-
Effect.logError("Event listener failed", { eventID: event.id, eventType: event.type, cause }),
381+
(cause) => Effect.logError("Event listener failed", { eventID: event.id, eventType: event.type, cause }),
387382
),
388383
)
389384

@@ -435,9 +430,9 @@ export const layerWith = (options?: LayerOptions) =>
435430
const payload = {
436431
id: event.id,
437432
type: definition.type,
438-
data: Schema.decodeUnknownSync(
439-
definition.data as Schema.Codec<unknown, unknown, never, never>,
440-
)(event.data),
433+
data: Schema.decodeUnknownSync(definition.data as Schema.Codec<unknown, unknown, never, never>)(
434+
event.data,
435+
),
441436
} as Payload
442437
const committed = yield* commitDurableEvent(payload, {
443438
seq: event.seq,
@@ -580,10 +575,7 @@ export const layerWith = (options?: LayerOptions) =>
580575
return subscription
581576
})
582577

583-
const durable = (input: {
584-
readonly aggregateID: string
585-
readonly after?: number
586-
}): Stream.Stream<Payload> =>
578+
const durable = (input: { readonly aggregateID: string; readonly after?: number }): Stream.Stream<Payload> =>
587579
Stream.unwrap(
588580
Effect.gen(function* () {
589581
const wakes = yield* subscribeDurable(input.aggregateID)

packages/core/src/session.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,7 @@ export const layer = Layer.effect(
340340
result
341341
.get(input.sessionID)
342342
.pipe(Effect.as(events.durable({ aggregateID: input.sessionID, after: input.after }))),
343-
).pipe(
344-
Stream.filter((event): event is SessionEvent.DurableEvent => isDurableSessionEvent(event)),
345-
),
343+
).pipe(Stream.filter((event): event is SessionEvent.DurableEvent => isDurableSessionEvent(event))),
346344
prompt: Effect.fn("V2Session.prompt")((input) =>
347345
Effect.uninterruptible(
348346
Effect.gen(function* () {

packages/core/src/session/projector.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ export const layer = Layer.effectDiscard(
351351
.run()
352352
.pipe(Effect.orDie)
353353
yield* run(db, event)
354-
if (event.durable === undefined)
355-
return yield* Effect.die("Durable Session event is missing aggregate sequence")
354+
if (event.durable === undefined) return yield* Effect.die("Durable Session event is missing aggregate sequence")
356355
yield* SessionContextEpoch.requestReplacement(db, event.data.sessionID, event.durable.seq)
357356
}),
358357
)
@@ -367,8 +366,7 @@ export const layer = Layer.effectDiscard(
367366
.pipe(Effect.orDie)
368367
if (existing) return yield* Effect.die(new PromptAlreadyProjected())
369368
yield* run(db, event)
370-
if (event.durable === undefined)
371-
return yield* Effect.die("Durable Session event is missing aggregate sequence")
369+
if (event.durable === undefined) return yield* Effect.die("Durable Session event is missing aggregate sequence")
372370
yield* SessionInput.projectLegacyPrompted(db, {
373371
id: messageID,
374372
sessionID: event.data.sessionID,
@@ -381,8 +379,7 @@ export const layer = Layer.effectDiscard(
381379
)
382380
yield* events.project(SessionEvent.PromptLifecycle.Admitted, (event) =>
383381
Effect.gen(function* () {
384-
if (event.durable === undefined)
385-
return yield* Effect.die("Durable Session event is missing aggregate sequence")
382+
if (event.durable === undefined) return yield* Effect.die("Durable Session event is missing aggregate sequence")
386383
yield* SessionInput.projectAdmitted(db, {
387384
admittedSeq: event.durable.seq,
388385
id: event.data.messageID,
@@ -395,8 +392,7 @@ export const layer = Layer.effectDiscard(
395392
)
396393
yield* events.project(SessionEvent.PromptLifecycle.Promoted, (event) =>
397394
Effect.gen(function* () {
398-
if (event.durable === undefined)
399-
return yield* Effect.die("Durable Session event is missing aggregate sequence")
395+
if (event.durable === undefined) return yield* Effect.die("Durable Session event is missing aggregate sequence")
400396
yield* insertMessage(
401397
db,
402398
event,

packages/core/test/event.test.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ describe("EventV2", () => {
399399
const events = yield* EventV2.Service
400400
const aggregateID = EventV2.ID.create()
401401
yield* events.publish(SyncMessage, { id: aggregateID, text: "zero" })
402-
const fiber = yield* events
403-
.durable({ aggregateID })
404-
.pipe(Stream.take(2), Stream.runCollect, Effect.forkScoped)
402+
const fiber = yield* events.durable({ aggregateID }).pipe(Stream.take(2), Stream.runCollect, Effect.forkScoped)
405403

406404
yield* events.publish(SyncMessage, { id: aggregateID, text: "one" })
407405

@@ -433,9 +431,7 @@ describe("EventV2", () => {
433431
yield* Effect.gen(function* () {
434432
const events = yield* EventV2.Service
435433
const aggregateID = EventV2.ID.create()
436-
const fiber = yield* events
437-
.durable({ aggregateID })
438-
.pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped)
434+
const fiber = yield* events.durable({ aggregateID }).pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped)
439435
yield* Deferred.await(readStarted)
440436

441437
pause = false
@@ -464,10 +460,7 @@ describe("EventV2", () => {
464460
}
465461

466462
expect(Array.from(yield* Fiber.join(fiber)).map((event) => [event.durable?.seq, event.data])).toEqual(
467-
Array.from({ length: count }, (_, index) => [
468-
index,
469-
{ id: aggregateID, text: String(index) },
470-
]),
463+
Array.from({ length: count }, (_, index) => [index, { id: aggregateID, text: String(index) }]),
471464
)
472465
}),
473466
)
@@ -476,9 +469,7 @@ describe("EventV2", () => {
476469
Effect.gen(function* () {
477470
const events = yield* EventV2.Service
478471
const aggregateID = EventV2.ID.create()
479-
const fiber = yield* events
480-
.durable({ aggregateID })
481-
.pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped)
472+
const fiber = yield* events.durable({ aggregateID }).pipe(Stream.take(1), Stream.runCollect, Effect.forkScoped)
482473
yield* Effect.yieldNow
483474

484475
yield* events.publish(Message, { text: "live only" })

packages/core/test/session-prompt.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ describe("SessionV2.prompt", () => {
199199
])
200200
expect(
201201
Array.from(
202-
yield* session.events({ sessionID, after: streamed[0]!.durable?.seq }).pipe(Stream.take(1), Stream.runCollect),
202+
yield* session
203+
.events({ sessionID, after: streamed[0]!.durable?.seq })
204+
.pipe(Stream.take(1), Stream.runCollect),
203205
).map((event) => [event.durable?.seq, event.type]),
204206
).toEqual([[1, "session.next.prompt.admitted"]])
205207
}),

0 commit comments

Comments
 (0)