MCPcopy Create free account
hub / github.com/anomalyco/opencode / replay

Function replay

packages/core/src/event.ts:441–478  ·  view source on GitHub ↗
(
        event: SerializedEvent,
        options?: { readonly publish?: boolean; readonly ownerID?: string; readonly strictOwner?: boolean },
      )

Source from the content-addressed store, hash-verified

439 }
440
441 function replay(
442 event: SerializedEvent,
443 options?: { readonly publish?: boolean; readonly ownerID?: string; readonly strictOwner?: boolean },
444 ) {
445 return Effect.gen(function* () {
446 const definition = Durable.get(event.type)
447 if (!definition?.durable) {
448 yield* Effect.die(
449 new InvalidDurableEventError({ type: event.type, message: `Unknown durable event type ${event.type}` }),
450 )
451 } else {
452 const payload = {
453 id: event.id,
454 type: definition.type,
455 data: Schema.decodeUnknownSync(definition.data)(event.data),
456 } as Payload
457 const committed = yield* commitDurableEvent(definition, payload, {
458 seq: event.seq,
459 aggregateID: event.aggregateID,
460 ownerID: options?.ownerID,
461 strictOwner: options?.strictOwner,
462 })
463 if (committed && options?.publish) {
464 yield* notify(
465 {
466 ...payload,
467 durable: {
468 aggregateID: committed.aggregateID,
469 seq: committed.seq,
470 version: definition.durable.version,
471 },
472 },
473 true,
474 )
475 }
476 }
477 })
478 }
479
480 function replayAll(
481 events: SerializedEvent[],

Callers 1

replayAllFunction · 0.70

Calls 3

commitDurableEventFunction · 0.85
notifyFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected