Skip to content
Myr

projection-memory.test.ts

This file

Path

packages/project/test/projection-memory.test.ts

54 lines · 1.7 KiB · TypeScript

Last changed by

Merge build/comments-project into mainoscabrielbefore adoption49efd2a

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 1why, one step back
1/**

Merge build/comments-project into mainoscabrielbefore adoption49efd2a

lines 2–3why, one step back
2 * Every project's outbox names its rows by event number alone
3 * (`projected:<seq>`), so the projection must key events by project too.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 4–15why, one step back
4 */
5import { describe, expect, it } from "@effect/vitest";6import { ProjectEvent } from "@repo/protocol/domain/event";7import { AskId, ProjectName } from "@repo/protocol/ids";8import { DateTime, Effect } from "effect";910import { projectedRows } from "../src/outbox.ts";11import { Projection } from "../src/projection.ts";12import { ProjectedRows, ProjectionMemory } from "../src/projection/memory.ts";1314const now = DateTime.makeUnsafe("2026-10-07T09:00:00Z");15

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 16why, one step back
16const datekit = ProjectName.make("alice/datekit");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

line 17why, one step back
17

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 18why, one step back
18const burrow = ProjectName.make("alice/burrow");

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 19–54why, one step back
19
20const released = (ask: string, seq: number) =>21 ProjectEvent.cases.Released.make({ ask: AskId.make(ask), at: now, seq });2223describe("the memory projection", () => {24 it.effect("keeps two projects' events that share a number, each once", () =>25 Effect.gen(function* () {26 const projection = yield* Projection;2728 const datekitRows = yield* projectedRows(29 datekit,30 [released("parse-iso-week", 1)],31 now32 );3334 const burrowRows = yield* projectedRows(35 burrow,36 [released("migrate-legacy-fetch", 1)],37 now38 );3940 yield* projection.apply(datekitRows);41 yield* projection.apply(burrowRows);42 yield* projection.apply([...datekitRows, ...burrowRows]);4344 const kept = yield* (yield* ProjectedRows).events;4546 expect(47 kept.map(({ event, project }) => [project, event.seq])48 ).toStrictEqual([49 [datekit, 1],50 [burrow, 1],51 ]);52 }).pipe(Effect.provide(ProjectionMemory))53 );54});