@entifix/testing-unit 0.13.0 → 0.15.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.
Files changed (51) hide show
  1. package/dist/contracts/index.d.ts +2 -1
  2. package/dist/contracts/index.d.ts.map +1 -1
  3. package/dist/contracts/index.js +2 -1
  4. package/dist/contracts/index.js.map +1 -1
  5. package/dist/contracts/push-channel.contract.d.ts +45 -0
  6. package/dist/contracts/push-channel.contract.d.ts.map +1 -0
  7. package/dist/contracts/push-channel.contract.js +135 -0
  8. package/dist/contracts/push-channel.contract.js.map +1 -0
  9. package/dist/contracts/server-push.contract.d.ts +44 -0
  10. package/dist/contracts/server-push.contract.d.ts.map +1 -0
  11. package/dist/contracts/server-push.contract.js +273 -0
  12. package/dist/contracts/server-push.contract.js.map +1 -0
  13. package/dist/contracts/transaction-ports.contract.d.ts +1 -15
  14. package/dist/contracts/transaction-ports.contract.d.ts.map +1 -1
  15. package/dist/contracts/transaction-ports.contract.js +1 -87
  16. package/dist/contracts/transaction-ports.contract.js.map +1 -1
  17. package/dist/doubles/entity-facet-counter.d.ts +2 -2
  18. package/dist/doubles/entity-facet-counter.d.ts.map +1 -1
  19. package/dist/doubles/entity-facet-counter.js.map +1 -1
  20. package/dist/doubles/entity-repository.js.map +1 -1
  21. package/dist/doubles/server-push.d.ts +16 -0
  22. package/dist/doubles/server-push.d.ts.map +1 -0
  23. package/dist/doubles/server-push.js +38 -0
  24. package/dist/doubles/server-push.js.map +1 -0
  25. package/dist/doubles/transaction-ports.d.ts +3 -44
  26. package/dist/doubles/transaction-ports.d.ts.map +1 -1
  27. package/dist/doubles/transaction-ports.js +1 -134
  28. package/dist/doubles/transaction-ports.js.map +1 -1
  29. package/dist/drivers/fake-mongo.d.ts +1 -1
  30. package/dist/drivers/fake-mongo.js.map +1 -1
  31. package/dist/drivers/fake-redis.d.ts +4 -6
  32. package/dist/drivers/fake-redis.d.ts.map +1 -1
  33. package/dist/drivers/fake-redis.js +4 -6
  34. package/dist/drivers/fake-redis.js.map +1 -1
  35. package/dist/drivers/fake-sql.d.ts +1 -1
  36. package/dist/drivers/fake-sql.js.map +1 -1
  37. package/dist/effect/run.d.ts +1 -1
  38. package/dist/effect/run.js +1 -1
  39. package/dist/effect/run.js.map +1 -1
  40. package/dist/http/entity-handlers.d.ts +1 -1
  41. package/dist/http/entity-handlers.js +1 -1
  42. package/dist/http/entity-handlers.js.map +1 -1
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -0
  46. package/dist/index.js.map +1 -1
  47. package/package.json +7 -7
  48. package/dist/contracts/saga-store.contract.d.ts +0 -13
  49. package/dist/contracts/saga-store.contract.d.ts.map +0 -1
  50. package/dist/contracts/saga-store.contract.js +0 -142
  51. package/dist/contracts/saga-store.contract.js.map +0 -1
@@ -1,93 +1,7 @@
1
1
  import { registerEvent } from '@entifix/core';
2
- import { Duration, Effect, Exit, Fiber, Schema } from 'effect';
3
- import { TestClock } from 'effect/testing';
2
+ import { Effect, Schema } from 'effect';
4
3
  import { describe, expect, it } from 'vitest';
5
- /**
6
- * Runs an Effect test on a `TestClock`, so a retry budget measured in seconds
7
- * costs none of the wall clock.
8
- */ const effectIt = {
9
- effect: (name, body)=>it(name, ()=>Effect.runPromise(body().pipe(Effect.provide(TestClock.layer()), Effect.scoped)))
10
- };
11
4
  const run = (effect)=>Effect.runPromise(effect);
12
- /**
13
- * What every {@link LockService} must guarantee: exclusivity while held,
14
- * availability after release, and a release that only frees the caller's own
15
- * lock. The last one is why `release` takes a handle rather than a key — a lock
16
- * that lapsed and was re-acquired by someone else must not be freed by the
17
- * previous holder.
18
- */ export const describeLockServiceContract = (name, makeLockService)=>{
19
- describe(`LockService contract: ${name}`, ()=>{
20
- it('acquires an uncontended key', async ()=>{
21
- const locks = await makeLockService();
22
- const handle = await run(locks.acquire('contract:free'));
23
- expect(handle.key).toBe('contract:free');
24
- expect(handle.token).toBeTruthy();
25
- });
26
- // An implementation may retry before giving up (the Redis adapter waits out
27
- // a bounded budget), so this runs on a TestClock: the assertion is about
28
- // exclusivity, and it should not cost seconds of wall clock to make.
29
- effectIt.effect('refuses a key that is already held', ()=>Effect.gen(function*() {
30
- const locks = yield* Effect.promise(async ()=>makeLockService());
31
- yield* locks.acquire('contract:taken');
32
- const fiber = yield* Effect.forkChild(locks.acquire('contract:taken'));
33
- yield* TestClock.adjust(Duration.minutes(1));
34
- const exit = yield* Fiber.await(fiber);
35
- expect(Exit.isFailure(exit)).toBe(true);
36
- }));
37
- it('makes the key available again after release', async ()=>{
38
- const locks = await makeLockService();
39
- const handle = await run(locks.acquire('contract:cycle'));
40
- await run(locks.release(handle));
41
- const reacquired = await run(locks.acquire('contract:cycle'));
42
- expect(reacquired.key).toBe('contract:cycle');
43
- });
44
- effectIt.effect('ignores a release whose token does not match', ()=>Effect.gen(function*() {
45
- const locks = yield* Effect.promise(async ()=>makeLockService());
46
- const handle = yield* locks.acquire('contract:stolen');
47
- yield* locks.release({
48
- key: handle.key,
49
- token: 'not-mine'
50
- });
51
- // Still held, so a fresh acquisition must fail.
52
- const fiber = yield* Effect.forkChild(locks.acquire('contract:stolen'));
53
- yield* TestClock.adjust(Duration.minutes(1));
54
- const exit = yield* Fiber.await(fiber);
55
- expect(Exit.isFailure(exit)).toBe(true);
56
- }));
57
- });
58
- };
59
- /**
60
- * What every {@link SequenceService} must guarantee: strictly increasing values
61
- * per name, never repeating, with names independent of one another. This is the
62
- * property incremental codes rest on.
63
- */ export const describeSequenceServiceContract = (name, makeSequenceService)=>{
64
- describe(`SequenceService contract: ${name}`, ()=>{
65
- it('starts at 1', async ()=>{
66
- const sequences = await makeSequenceService();
67
- expect(await run(sequences.next('contract:fresh'))).toBe(1);
68
- });
69
- it('never returns the same value twice for a name', async ()=>{
70
- const sequences = await makeSequenceService();
71
- const drawn = [
72
- await run(sequences.next('contract:codes')),
73
- await run(sequences.next('contract:codes')),
74
- await run(sequences.next('contract:codes'))
75
- ];
76
- expect(drawn).toEqual([
77
- 1,
78
- 2,
79
- 3
80
- ]);
81
- expect(new Set(drawn).size).toBe(drawn.length);
82
- });
83
- it('keeps separate names independent', async ()=>{
84
- const sequences = await makeSequenceService();
85
- await run(sequences.next('contract:a'));
86
- await run(sequences.next('contract:a'));
87
- expect(await run(sequences.next('contract:b'))).toBe(1);
88
- });
89
- });
90
- };
91
5
  /** Every subscription in this contract, unless a test says otherwise. */ const ANY_WIDGET_EVENT = 'contract.widget.*';
92
6
  /**
93
7
  * A `work` subscription for `pattern`. The mode and the ceiling are broker
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contracts/transaction-ports.contract.ts"],"sourcesContent":["import { type DomainEvent, registerEvent } from '@entifix/core';\nimport type {\n EventBus,\n LockService,\n SequenceService,\n Subscription,\n TransactionInbox,\n} from '@entifix/transactions';\nimport { Duration, Effect, Exit, Fiber, Schema } from 'effect';\nimport { TestClock } from 'effect/testing';\nimport { describe, expect, it } from 'vitest';\n\n/**\n * Runs an Effect test on a `TestClock`, so a retry budget measured in seconds\n * costs none of the wall clock.\n */\nconst effectIt = {\n effect: (name: string, body: () => Effect.Effect<unknown, unknown>) =>\n it(name, () =>\n Effect.runPromise(\n body().pipe(Effect.provide(TestClock.layer()), Effect.scoped),\n ),\n ),\n};\n\nconst run = <TValue, TError>(effect: Effect.Effect<TValue, TError>) =>\n Effect.runPromise(effect);\n\n/**\n * What every {@link LockService} must guarantee: exclusivity while held,\n * availability after release, and a release that only frees the caller's own\n * lock. The last one is why `release` takes a handle rather than a key — a lock\n * that lapsed and was re-acquired by someone else must not be freed by the\n * previous holder.\n */\nexport const describeLockServiceContract = (\n name: string,\n makeLockService: () => LockService | Promise<LockService>,\n): void => {\n describe(`LockService contract: ${name}`, () => {\n it('acquires an uncontended key', async () => {\n const locks = await makeLockService();\n\n const handle = await run(locks.acquire('contract:free'));\n\n expect(handle.key).toBe('contract:free');\n expect(handle.token).toBeTruthy();\n });\n\n // An implementation may retry before giving up (the Redis adapter waits out\n // a bounded budget), so this runs on a TestClock: the assertion is about\n // exclusivity, and it should not cost seconds of wall clock to make.\n effectIt.effect('refuses a key that is already held', () =>\n Effect.gen(function* () {\n const locks = yield* Effect.promise(async () => makeLockService());\n yield* locks.acquire('contract:taken');\n\n const fiber = yield* Effect.forkChild(locks.acquire('contract:taken'));\n yield* TestClock.adjust(Duration.minutes(1));\n const exit = yield* Fiber.await(fiber);\n\n expect(Exit.isFailure(exit)).toBe(true);\n }),\n );\n\n it('makes the key available again after release', async () => {\n const locks = await makeLockService();\n const handle = await run(locks.acquire('contract:cycle'));\n\n await run(locks.release(handle));\n const reacquired = await run(locks.acquire('contract:cycle'));\n\n expect(reacquired.key).toBe('contract:cycle');\n });\n\n effectIt.effect('ignores a release whose token does not match', () =>\n Effect.gen(function* () {\n const locks = yield* Effect.promise(async () => makeLockService());\n const handle = yield* locks.acquire('contract:stolen');\n\n yield* locks.release({ key: handle.key, token: 'not-mine' });\n\n // Still held, so a fresh acquisition must fail.\n const fiber = yield* Effect.forkChild(locks.acquire('contract:stolen'));\n yield* TestClock.adjust(Duration.minutes(1));\n const exit = yield* Fiber.await(fiber);\n\n expect(Exit.isFailure(exit)).toBe(true);\n }),\n );\n });\n};\n\n/**\n * What every {@link SequenceService} must guarantee: strictly increasing values\n * per name, never repeating, with names independent of one another. This is the\n * property incremental codes rest on.\n */\nexport const describeSequenceServiceContract = (\n name: string,\n makeSequenceService: () => SequenceService | Promise<SequenceService>,\n): void => {\n describe(`SequenceService contract: ${name}`, () => {\n it('starts at 1', async () => {\n const sequences = await makeSequenceService();\n\n expect(await run(sequences.next('contract:fresh'))).toBe(1);\n });\n\n it('never returns the same value twice for a name', async () => {\n const sequences = await makeSequenceService();\n\n const drawn = [\n await run(sequences.next('contract:codes')),\n await run(sequences.next('contract:codes')),\n await run(sequences.next('contract:codes')),\n ];\n\n expect(drawn).toEqual([1, 2, 3]);\n expect(new Set(drawn).size).toBe(drawn.length);\n });\n\n it('keeps separate names independent', async () => {\n const sequences = await makeSequenceService();\n await run(sequences.next('contract:a'));\n await run(sequences.next('contract:a'));\n\n expect(await run(sequences.next('contract:b'))).toBe(1);\n });\n });\n};\n\nexport interface EventBusContractHarness {\n bus: EventBus;\n /** Delivers `event` to whatever subscribed, as the broker would. */\n deliver(event: DomainEvent): Promise<void>;\n /** Everything the bus published, decoded back into events. */\n published(): DomainEvent[];\n}\n\n/** Every subscription in this contract, unless a test says otherwise. */\nconst ANY_WIDGET_EVENT = 'contract.widget.*';\n\n/**\n * A `work` subscription for `pattern`. The mode and the ceiling are broker\n * facts with no bearing on routing, so a test about routing states them once\n * here rather than repeating them at every call.\n */\nconst on = (pattern: string): Subscription => ({\n slice: 'contract',\n pattern,\n mode: 'work',\n maxAttempts: 5,\n});\n\n/**\n * A handler that records what it is given. Shared by both routing tests so the\n * \"nothing was delivered\" case asserts on the *same* handler the positive case\n * proves works — otherwise it could pass against a handler that was simply\n * never wired up.\n */\nconst collectInto = (sink: DomainEvent[]) => (event: DomainEvent) =>\n Effect.sync(() => {\n sink.push(event);\n });\n\n// A transport encodes and decodes through the registry, so the suite's own\n// event is registered like any other — audience-free, since nothing here\n// delivers to a person.\nregisterEvent(\n 'contract.widget.created',\n Schema.Struct({ entity: Schema.String }),\n { audience: 'none' },\n);\n\nconst anEvent = (\n id: string,\n name = 'contract.widget.created',\n): DomainEvent => ({\n name,\n id,\n source: 'contract-slice',\n at: new Date('2026-01-01T00:00:00.000Z').toISOString(),\n correlationId: id,\n data: { entity: 'contract-widget' },\n});\n\n/**\n * What every {@link EventBus} must guarantee: what goes out comes back\n * unchanged, subscribers receive deliveries, and a subscriber receives only what\n * its pattern matches. The transports differ wildly (an array here, a topic\n * exchange in RabbitMQ) — the observable contract does not.\n */\nexport const describeEventBusContract = (\n name: string,\n makeHarness: () => EventBusContractHarness | Promise<EventBusContractHarness>,\n): void => {\n describe(`EventBus contract: ${name}`, () => {\n it('publishes an event verbatim', async () => {\n const harness = await makeHarness();\n const event = anEvent('tx-1');\n\n await run(harness.bus.publish(event));\n\n expect(harness.published()).toEqual([event]);\n });\n\n it('delivers published events to a subscriber', async () => {\n const harness = await makeHarness();\n const received: DomainEvent[] = [];\n await run(\n harness.bus.subscribe(on(ANY_WIDGET_EVENT), collectInto(received)),\n );\n\n await harness.deliver(anEvent('tx-2'));\n\n expect(received.map(event => event.id)).toEqual(['tx-2']);\n });\n\n // Routing is the transport's job. A bus that hands every subscriber every\n // event lets a consumer pass while receiving traffic it never bound to —\n // which is precisely the fault the fanout exchange had.\n it('delivers nothing to a subscriber whose pattern does not match', async () => {\n const harness = await makeHarness();\n const received: DomainEvent[] = [];\n await run(\n harness.bus.subscribe(on('contract.other.*'), collectInto(received)),\n );\n\n await harness.deliver(anEvent('tx-5'));\n\n expect(received).toEqual([]);\n });\n\n it('preserves publication order', async () => {\n const harness = await makeHarness();\n\n await run(harness.bus.publish(anEvent('tx-3')));\n await run(harness.bus.publish(anEvent('tx-4')));\n\n expect(harness.published().map(event => event.id)).toEqual([\n 'tx-3',\n 'tx-4',\n ]);\n });\n });\n};\n\n/**\n * What every {@link TransactionInbox} must guarantee: a first claim is granted,\n * every repeat of it is refused, and one consumer's claim says nothing about\n * another's.\n *\n * That last one is the property with teeth. Two consumers legitimately process\n * the same event — the saga tracker's fold and the SSE hub both bind\n * `transaction.*` — so an implementation keyed on `eventId` alone passes the\n * first two cases and silently starves every consumer but the first. It looks\n * like exactly-once from inside one consumer, which is why it is asserted here\n * rather than left to each adapter's own spec.\n */\nexport const describeTransactionInboxContract = (\n name: string,\n makeInbox: (consumer: string) => TransactionInbox | Promise<TransactionInbox>,\n): void => {\n describe(`TransactionInbox contract: ${name}`, () => {\n it('grants a first claim', async () => {\n const inbox = await makeInbox('contract.consumer');\n\n expect(await run(inbox.claim('tx-1:completed'))).toBe('claimed');\n });\n\n it('refuses a redelivery of the same event', async () => {\n const inbox = await makeInbox('contract.consumer');\n await run(inbox.claim('tx-2:completed'));\n\n expect(await run(inbox.claim('tx-2:completed'))).toBe('duplicate');\n });\n\n it('refuses every repeat, not only the second', async () => {\n const inbox = await makeInbox('contract.consumer');\n await run(inbox.claim('tx-3:completed'));\n\n expect(await run(inbox.claim('tx-3:completed'))).toBe('duplicate');\n expect(await run(inbox.claim('tx-3:completed'))).toBe('duplicate');\n });\n\n it('claims each step of one transaction separately', async () => {\n // `<transactionId>:<step>`, never the transaction id alone: one\n // transaction emits up to three messages, and keying on the correlation\n // id would make `completed` read as a redelivery of `accepted`.\n const inbox = await makeInbox('contract.consumer');\n\n expect(await run(inbox.claim('tx-4:accepted'))).toBe('claimed');\n expect(await run(inbox.claim('tx-4:completed'))).toBe('claimed');\n });\n\n it('does not let one consumer consume another consumer’s claim', async () => {\n const first = await makeInbox('contract.first');\n const second = await makeInbox('contract.second');\n await run(first.claim('tx-5:completed'));\n\n expect(await run(second.claim('tx-5:completed'))).toBe('claimed');\n });\n });\n};\n"],"names":["registerEvent","Duration","Effect","Exit","Fiber","Schema","TestClock","describe","expect","it","effectIt","effect","name","body","runPromise","pipe","provide","layer","scoped","run","describeLockServiceContract","makeLockService","locks","handle","acquire","key","toBe","token","toBeTruthy","gen","promise","fiber","forkChild","adjust","minutes","exit","await","isFailure","release","reacquired","describeSequenceServiceContract","makeSequenceService","sequences","next","drawn","toEqual","Set","size","length","ANY_WIDGET_EVENT","on","pattern","slice","mode","maxAttempts","collectInto","sink","event","sync","push","Struct","entity","String","audience","anEvent","id","source","at","Date","toISOString","correlationId","data","describeEventBusContract","makeHarness","harness","bus","publish","published","received","subscribe","deliver","map","describeTransactionInboxContract","makeInbox","inbox","claim","first","second"],"mappings":"AAAA,SAA2BA,aAAa,QAAQ,gBAAgB;AAQhE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,QAAQ,SAAS;AAC/D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAS;AAE9C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,KAAK,CAAC;YAEtB7E,OAAO,MAAMW,IAAIiE,MAAMC,KAAK,CAAC,oBAAoB3D,IAAI,CAAC;YACtDlB,OAAO,MAAMW,IAAIiE,MAAMC,KAAK,CAAC,oBAAoB3D,IAAI,CAAC;QACxD;QAEAjB,GAAG,kDAAkD;YACnD,gEAAgE;YAChE,wEAAwE;YACxE,gEAAgE;YAChE,MAAM2E,QAAQ,MAAMD,UAAU;YAE9B3E,OAAO,MAAMW,IAAIiE,MAAMC,KAAK,CAAC,mBAAmB3D,IAAI,CAAC;YACrDlB,OAAO,MAAMW,IAAIiE,MAAMC,KAAK,CAAC,oBAAoB3D,IAAI,CAAC;QACxD;QAEAjB,GAAG,8DAA8D;YAC/D,MAAM6E,QAAQ,MAAMH,UAAU;YAC9B,MAAMI,SAAS,MAAMJ,UAAU;YAC/B,MAAMhE,IAAImE,MAAMD,KAAK,CAAC;YAEtB7E,OAAO,MAAMW,IAAIoE,OAAOF,KAAK,CAAC,oBAAoB3D,IAAI,CAAC;QACzD;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/contracts/transaction-ports.contract.ts"],"sourcesContent":["import { type DomainEvent, registerEvent } from '@entifix/core';\nimport type {\n EventBus,\n Subscription,\n TransactionInbox,\n} from '@entifix/transactions';\nimport { Effect, Schema } from 'effect';\nimport { describe, expect, it } from 'vitest';\n\nconst run = <TValue, TError>(effect: Effect.Effect<TValue, TError>) =>\n Effect.runPromise(effect);\n\nexport interface EventBusContractHarness {\n bus: EventBus;\n /** Delivers `event` to whatever subscribed, as the broker would. */\n deliver(event: DomainEvent): Promise<void>;\n /** Everything the bus published, decoded back into events. */\n published(): DomainEvent[];\n}\n\n/** Every subscription in this contract, unless a test says otherwise. */\nconst ANY_WIDGET_EVENT = 'contract.widget.*';\n\n/**\n * A `work` subscription for `pattern`. The mode and the ceiling are broker\n * facts with no bearing on routing, so a test about routing states them once\n * here rather than repeating them at every call.\n */\nconst on = (pattern: string): Subscription => ({\n slice: 'contract',\n pattern,\n mode: 'work',\n maxAttempts: 5,\n});\n\n/**\n * A handler that records what it is given. Shared by both routing tests so the\n * \"nothing was delivered\" case asserts on the *same* handler the positive case\n * proves works — otherwise it could pass against a handler that was simply\n * never wired up.\n */\nconst collectInto = (sink: DomainEvent[]) => (event: DomainEvent) =>\n Effect.sync(() => {\n sink.push(event);\n });\n\n// A transport encodes and decodes through the registry, so the suite's own\n// event is registered like any other — audience-free, since nothing here\n// delivers to a person.\nregisterEvent(\n 'contract.widget.created',\n Schema.Struct({ entity: Schema.String }),\n { audience: 'none' },\n);\n\nconst anEvent = (\n id: string,\n name = 'contract.widget.created',\n): DomainEvent => ({\n name,\n id,\n source: 'contract-slice',\n at: new Date('2026-01-01T00:00:00.000Z').toISOString(),\n correlationId: id,\n data: { entity: 'contract-widget' },\n});\n\n/**\n * What every {@link EventBus} must guarantee: what goes out comes back\n * unchanged, subscribers receive deliveries, and a subscriber receives only what\n * its pattern matches. The transports differ wildly (an array here, a topic\n * exchange in RabbitMQ) — the observable contract does not.\n */\nexport const describeEventBusContract = (\n name: string,\n makeHarness: () => EventBusContractHarness | Promise<EventBusContractHarness>,\n): void => {\n describe(`EventBus contract: ${name}`, () => {\n it('publishes an event verbatim', async () => {\n const harness = await makeHarness();\n const event = anEvent('tx-1');\n\n await run(harness.bus.publish(event));\n\n expect(harness.published()).toEqual([event]);\n });\n\n it('delivers published events to a subscriber', async () => {\n const harness = await makeHarness();\n const received: DomainEvent[] = [];\n await run(\n harness.bus.subscribe(on(ANY_WIDGET_EVENT), collectInto(received)),\n );\n\n await harness.deliver(anEvent('tx-2'));\n\n expect(received.map(event => event.id)).toEqual(['tx-2']);\n });\n\n // Routing is the transport's job. A bus that hands every subscriber every\n // event lets a consumer pass while receiving traffic it never bound to —\n // which is precisely the fault the fanout exchange had.\n it('delivers nothing to a subscriber whose pattern does not match', async () => {\n const harness = await makeHarness();\n const received: DomainEvent[] = [];\n await run(\n harness.bus.subscribe(on('contract.other.*'), collectInto(received)),\n );\n\n await harness.deliver(anEvent('tx-5'));\n\n expect(received).toEqual([]);\n });\n\n it('preserves publication order', async () => {\n const harness = await makeHarness();\n\n await run(harness.bus.publish(anEvent('tx-3')));\n await run(harness.bus.publish(anEvent('tx-4')));\n\n expect(harness.published().map(event => event.id)).toEqual([\n 'tx-3',\n 'tx-4',\n ]);\n });\n });\n};\n\n/**\n * What every {@link TransactionInbox} must guarantee: a first claim is granted,\n * every repeat of it is refused, and one consumer's claim says nothing about\n * another's.\n *\n * That last one is the property with teeth. Two consumers legitimately process\n * the same event — the saga tracker's fold and the SSE hub both bind\n * `transaction.*` — so an implementation keyed on `eventId` alone passes the\n * first two cases and silently starves every consumer but the first. It looks\n * like exactly-once from inside one consumer, which is why it is asserted here\n * rather than left to each adapter's own spec.\n */\nexport const describeTransactionInboxContract = (\n name: string,\n makeInbox: (consumer: string) => TransactionInbox | Promise<TransactionInbox>,\n): void => {\n describe(`TransactionInbox contract: ${name}`, () => {\n it('grants a first claim', async () => {\n const inbox = await makeInbox('contract.consumer');\n\n expect(await run(inbox.claim('tx-1:completed'))).toBe('claimed');\n });\n\n it('refuses a redelivery of the same event', async () => {\n const inbox = await makeInbox('contract.consumer');\n await run(inbox.claim('tx-2:completed'));\n\n expect(await run(inbox.claim('tx-2:completed'))).toBe('duplicate');\n });\n\n it('refuses every repeat, not only the second', async () => {\n const inbox = await makeInbox('contract.consumer');\n await run(inbox.claim('tx-3:completed'));\n\n expect(await run(inbox.claim('tx-3:completed'))).toBe('duplicate');\n expect(await run(inbox.claim('tx-3:completed'))).toBe('duplicate');\n });\n\n it('claims each step of one transaction separately', async () => {\n // `<transactionId>:<step>`, never the transaction id alone: one\n // transaction emits up to three messages, and keying on the correlation\n // id would make `completed` read as a redelivery of `accepted`.\n const inbox = await makeInbox('contract.consumer');\n\n expect(await run(inbox.claim('tx-4:accepted'))).toBe('claimed');\n expect(await run(inbox.claim('tx-4:completed'))).toBe('claimed');\n });\n\n it('does not let one consumer consume another consumer’s claim', async () => {\n const first = await makeInbox('contract.first');\n const second = await makeInbox('contract.second');\n await run(first.claim('tx-5:completed'));\n\n expect(await run(second.claim('tx-5:completed'))).toBe('claimed');\n });\n });\n};\n"],"names":["registerEvent","Effect","Schema","describe","expect","it","run","effect","runPromise","ANY_WIDGET_EVENT","on","pattern","slice","mode","maxAttempts","collectInto","sink","event","sync","push","Struct","entity","String","audience","anEvent","id","name","source","at","Date","toISOString","correlationId","data","describeEventBusContract","makeHarness","harness","bus","publish","published","toEqual","received","subscribe","deliver","map","describeTransactionInboxContract","makeInbox","inbox","claim","toBe","first","second"],"mappings":"AAAA,SAA2BA,aAAa,QAAQ,gBAAgB;AAMhE,SAASC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AACxC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAS;AAE9C,MAAMC,MAAM,CAAiBC,SAC3BN,OAAOO,UAAU,CAACD;AAUpB,uEAAuE,GACvE,MAAME,mBAAmB;AAEzB;;;;CAIC,GACD,MAAMC,KAAK,CAACC,UAAmC,CAAA;QAC7CC,OAAO;QACPD;QACAE,MAAM;QACNC,aAAa;IACf,CAAA;AAEA;;;;;CAKC,GACD,MAAMC,cAAc,CAACC,OAAwB,CAACC,QAC5ChB,OAAOiB,IAAI,CAAC;YACVF,KAAKG,IAAI,CAACF;QACZ;AAEF,2EAA2E;AAC3E,yEAAyE;AACzE,wBAAwB;AACxBjB,cACE,2BACAE,OAAOkB,MAAM,CAAC;IAAEC,QAAQnB,OAAOoB,MAAM;AAAC,IACtC;IAAEC,UAAU;AAAO;AAGrB,MAAMC,UAAU,CACdC,IACAC,OAAO,yBAAyB,GACf,CAAA;QACjBA;QACAD;QACAE,QAAQ;QACRC,IAAI,IAAIC,KAAK,4BAA4BC,WAAW;QACpDC,eAAeN;QACfO,MAAM;YAAEX,QAAQ;QAAkB;IACpC,CAAA;AAEA;;;;;CAKC,GACD,OAAO,MAAMY,2BAA2B,CACtCP,MACAQ;IAEA/B,SA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1C,SAAS,CAAC,2BAA2B,EAAEuB,MAAM,EAAE;QAC7CrB,GAAG,wBAAwB;YACzB,MAAMyC,QAAQ,MAAMD,UAAU;YAE9BzC,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,oBAAoBC,IAAI,CAAC;QACxD;QAEA3C,GAAG,0CAA0C;YAC3C,MAAMyC,QAAQ,MAAMD,UAAU;YAC9B,MAAMvC,IAAIwC,MAAMC,KAAK,CAAC;YAEtB3C,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,oBAAoBC,IAAI,CAAC;QACxD;QAEA3C,GAAG,6CAA6C;YAC9C,MAAMyC,QAAQ,MAAMD,UAAU;YAC9B,MAAMvC,IAAIwC,MAAMC,KAAK,CAAC;YAEtB3C,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,oBAAoBC,IAAI,CAAC;YACtD5C,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,oBAAoBC,IAAI,CAAC;QACxD;QAEA3C,GAAG,kDAAkD;YACnD,gEAAgE;YAChE,wEAAwE;YACxE,gEAAgE;YAChE,MAAMyC,QAAQ,MAAMD,UAAU;YAE9BzC,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,mBAAmBC,IAAI,CAAC;YACrD5C,OAAO,MAAME,IAAIwC,MAAMC,KAAK,CAAC,oBAAoBC,IAAI,CAAC;QACxD;QAEA3C,GAAG,8DAA8D;YAC/D,MAAM4C,QAAQ,MAAMJ,UAAU;YAC9B,MAAMK,SAAS,MAAML,UAAU;YAC/B,MAAMvC,IAAI2C,MAAMF,KAAK,CAAC;YAEtB3C,OAAO,MAAME,IAAI4C,OAAOH,KAAK,CAAC,oBAAoBC,IAAI,CAAC;QACzD;IACF;AACF,EAAE"}
@@ -1,11 +1,11 @@
1
1
  import type { EntityFacetCounter } from '@entifix/business';
2
- import { type EntifixError, type Entity } from '@entifix/core';
2
+ import { type EntifixFailure, type Entity } from '@entifix/core';
3
3
  export interface InMemoryEntityFacetCounter extends EntityFacetCounter {
4
4
  /**
5
5
  * Makes the next count fail with `error`, so a caller's degraded path is
6
6
  * reachable without reaching for a mocking library.
7
7
  */
8
- failNext(error: EntifixError): void;
8
+ failNext(error: EntifixFailure): void;
9
9
  }
10
10
  /**
11
11
  * An {@link EntityFacetCounter} over records held in memory, counted by the
@@ -1 +1 @@
1
- {"version":3,"file":"entity-facet-counter.d.ts","sourceRoot":"","sources":["../../src/doubles/entity-facet-counter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,SAAS,MAAM,EAAE,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,KAChE,0BAsBF,CAAC"}
1
+ {"version":3,"file":"entity-facet-counter.d.ts","sourceRoot":"","sources":["../../src/doubles/entity-facet-counter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,SAAS,MAAM,EAAE,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,KAChE,0BAsBF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/doubles/entity-facet-counter.ts"],"sourcesContent":["import type { EntityFacetCounter } from '@entifix/business';\nimport {\n countFacets,\n type EntifixError,\n type Entity,\n type EntityFacetQuery,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nexport interface InMemoryEntityFacetCounter extends EntityFacetCounter {\n /**\n * Makes the next count fail with `error`, so a caller's degraded path is\n * reachable without reaching for a mocking library.\n */\n failNext(error: EntifixError): void;\n}\n\n/**\n * An {@link EntityFacetCounter} over records held in memory, counted by the\n * same rules as every other in-memory query.\n *\n * `source` is either the records themselves or anything holding them — an\n * `InMemoryEntityRepository` — read on every count, so a spec that saves\n * through the repository sees the counts move.\n */\nexport const makeInMemoryFacetCounter = (\n source: readonly Entity[] | { readonly items: readonly Entity[] },\n): InMemoryEntityFacetCounter => {\n let pendingFailure: EntifixError | undefined;\n const records = () => ('items' in source ? source.items : source);\n\n return {\n count: <TEntity extends Entity>(\n queries: readonly EntityFacetQuery<TEntity>[],\n ) =>\n Effect.suspend(() => {\n if (pendingFailure !== undefined) {\n const error = pendingFailure;\n pendingFailure = undefined;\n return Effect.fail(error);\n }\n return Effect.succeed(\n countFacets(records() as readonly TEntity[], queries),\n );\n }),\n failNext: error => {\n pendingFailure = error;\n },\n };\n};\n"],"names":["countFacets","Effect","makeInMemoryFacetCounter","source","pendingFailure","records","items","count","queries","suspend","undefined","error","fail","succeed","failNext"],"mappings":"AACA,SACEA,WAAW,QAIN,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAUhC;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA2B,CACtCC;IAEA,IAAIC;IACJ,MAAMC,UAAU,IAAO,WAAWF,SAASA,OAAOG,KAAK,GAAGH;IAE1D,OAAO;QACLI,OAAO,CACLC,UAEAP,OAAOQ,OAAO,CAAC;gBACb,IAAIL,mBAAmBM,WAAW;oBAChC,MAAMC,QAAQP;oBACdA,iBAAiBM;oBACjB,OAAOT,OAAOW,IAAI,CAACD;gBACrB;gBACA,OAAOV,OAAOY,OAAO,CACnBb,YAAYK,WAAiCG;YAEjD;QACFM,UAAUH,CAAAA;YACRP,iBAAiBO;QACnB;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/doubles/entity-facet-counter.ts"],"sourcesContent":["import type { EntityFacetCounter } from '@entifix/business';\nimport {\n countFacets,\n type EntifixFailure,\n type Entity,\n type EntityFacetQuery,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nexport interface InMemoryEntityFacetCounter extends EntityFacetCounter {\n /**\n * Makes the next count fail with `error`, so a caller's degraded path is\n * reachable without reaching for a mocking library.\n */\n failNext(error: EntifixFailure): void;\n}\n\n/**\n * An {@link EntityFacetCounter} over records held in memory, counted by the\n * same rules as every other in-memory query.\n *\n * `source` is either the records themselves or anything holding them — an\n * `InMemoryEntityRepository` — read on every count, so a spec that saves\n * through the repository sees the counts move.\n */\nexport const makeInMemoryFacetCounter = (\n source: readonly Entity[] | { readonly items: readonly Entity[] },\n): InMemoryEntityFacetCounter => {\n let pendingFailure: EntifixFailure | undefined;\n const records = () => ('items' in source ? source.items : source);\n\n return {\n count: <TEntity extends Entity>(\n queries: readonly EntityFacetQuery<TEntity>[],\n ) =>\n Effect.suspend(() => {\n if (pendingFailure !== undefined) {\n const error = pendingFailure;\n pendingFailure = undefined;\n return Effect.fail(error);\n }\n return Effect.succeed(\n countFacets(records() as readonly TEntity[], queries),\n );\n }),\n failNext: error => {\n pendingFailure = error;\n },\n };\n};\n"],"names":["countFacets","Effect","makeInMemoryFacetCounter","source","pendingFailure","records","items","count","queries","suspend","undefined","error","fail","succeed","failNext"],"mappings":"AACA,SACEA,WAAW,QAIN,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAUhC;;;;;;;CAOC,GACD,OAAO,MAAMC,2BAA2B,CACtCC;IAEA,IAAIC;IACJ,MAAMC,UAAU,IAAO,WAAWF,SAASA,OAAOG,KAAK,GAAGH;IAE1D,OAAO;QACLI,OAAO,CACLC,UAEAP,OAAOQ,OAAO,CAAC;gBACb,IAAIL,mBAAmBM,WAAW;oBAChC,MAAMC,QAAQP;oBACdA,iBAAiBM;oBACjB,OAAOT,OAAOW,IAAI,CAACD;gBACrB;gBACA,OAAOV,OAAOY,OAAO,CACnBb,YAAYK,WAAiCG;YAEjD;QACFM,UAAUH,CAAAA;YACRP,iBAAiBO;QACnB;IACF;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/doubles/entity-repository.ts"],"sourcesContent":["import type { EntityRepository, RepositoryFailure } from '@entifix/business';\nimport {\n applyFiltering,\n applySorting,\n deserializeSingleEntity,\n type EntifixError,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityLoadRequest,\n type EntityPage,\n extractMetaAccessors,\n NotFound,\n serializeEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\n/**\n * A copy of `entity` that shares no state with it.\n *\n * Through the entity's own mapping — serialize, then deserialize — because that\n * is what a real adapter does to every record on the way in and out: a caller\n * can never hold the instance the store keeps, and a member the mapping drops\n * (`hidden`, `readonly`) does not survive a save here either. A class that\n * declares no accessors has no mapping to go through, so it is copied member by\n * member instead; plain spec fixtures are the case this keeps working.\n */\nconst copyOf = <TEntity extends Entity>(\n entity: TEntity,\n): Effect.Effect<TEntity, EntifixError> => {\n const entityConstructor = entity.constructor as EntityConstructor<TEntity>;\n if (extractMetaAccessors(entityConstructor).length === 0) {\n return Effect.succeed(\n Object.assign(\n Object.create(Object.getPrototypeOf(entity) as object) as TEntity,\n entity,\n ),\n );\n }\n // `undefined` only comes back for `null`/`undefined` input, and\n // `serializeEntity` always hands over an object.\n return deserializeSingleEntity(\n entityConstructor,\n serializeEntity(entityConstructor, entity),\n ) as Effect.Effect<TEntity, EntifixError>;\n};\n\nexport interface InMemoryEntityRepository extends EntityRepository {\n /** Everything currently stored, in insertion order. */\n readonly items: Entity[];\n /** Replaces the contents, discarding whatever was there. */\n seed(items: Entity[]): void;\n /**\n * Makes the next call to any method fail with `error`, so error branches are\n * reachable without reaching for a mocking library.\n */\n failNext(error: RepositoryFailure): void;\n}\n\n/**\n * In-memory {@link EntityRepository}: the default double for anything that\n * depends on persistence.\n *\n * Its semantics deliberately mirror `makeMongoRepository` — the same filtering\n * and sorting rules, which it takes from core's in-memory query evaluation\n * rather than keeping a copy of its own, same 1-based paging with a default page size of 10, same\n * \"entity not found\" failure, same id minting on create — and\n * `describeEntityRepositoryContract` holds both to that shared contract.\n */\nexport const makeInMemoryEntityRepository = (\n seed: Entity[] = [],\n): InMemoryEntityRepository => {\n let items = [...seed];\n let pendingFailure: RepositoryFailure | undefined;\n\n /** Consumes a queued failure, if one was armed. */\n const guard = <TValue>(\n run: () => Effect.Effect<TValue, RepositoryFailure>,\n ): Effect.Effect<TValue, RepositoryFailure> => {\n if (pendingFailure !== undefined) {\n const failure = pendingFailure;\n pendingFailure = undefined;\n return Effect.fail(failure);\n }\n return run();\n };\n\n const load = <TEntity extends Entity>(request: EntityLoadRequest<TEntity>) =>\n guard(() => {\n const matched = applySorting(\n applyFiltering(items as TEntity[], request.filtering),\n request.sorting,\n );\n const page = request.page ?? 1;\n const pageSize = request.pageSize ?? 10;\n const start = (page - 1) * pageSize;\n\n return Effect.forEach(\n matched.slice(start, start + pageSize),\n copyOf,\n ).pipe(\n Effect.map(\n copies =>\n ({\n items: copies,\n total: matched.length,\n request,\n }) satisfies EntityPage<TEntity>,\n ),\n );\n });\n\n const get = <TEntity extends Entity>(id: EntityId) =>\n guard(() => {\n const found = items.find(item => item.id === id);\n return found === undefined\n ? Effect.fail(new NotFound({}))\n : copyOf(found as TEntity);\n });\n\n const save = <TEntity extends Entity>(entity: TEntity) =>\n guard(() => {\n // A create arrives without an id, so the store mints one — same rule the\n // Mongo adapter follows. The Web Crypto global rather than `node:crypto`,\n // because a browser bundle cannot resolve a `node:` import and an example\n // with no backend runs this repository in the page.\n entity.id = entity.id ?? globalThis.crypto.randomUUID();\n // The store keeps its own copy and hands back another, so neither the\n // caller's instance nor the returned one can change the record without a\n // second save — which a real adapter guarantees by construction.\n return copyOf(entity).pipe(\n Effect.tap(stored =>\n Effect.sync(() => {\n const index = items.findIndex(item => item.id === stored.id);\n if (index === -1) {\n items.push(stored);\n } else {\n items[index] = stored;\n }\n }),\n ),\n Effect.flatMap(copyOf),\n );\n });\n\n const remove = <TEntity extends Entity>(entityOrId: EntityId | TEntity) =>\n guard(() => {\n const id =\n entityOrId != null && typeof entityOrId === 'object'\n ? entityOrId.id\n : entityOrId;\n items = items.filter(item => item.id !== id);\n return Effect.succeed(undefined);\n });\n\n return {\n load,\n get,\n save,\n delete: remove,\n get items() {\n return items;\n },\n seed: (next: Entity[]) => {\n items = [...next];\n },\n failNext: (error: RepositoryFailure) => {\n pendingFailure = error;\n },\n // Each method closes over its own state, so nothing is required from the\n // Effect environment; that is assignable to the interface's channel.\n } as unknown as InMemoryEntityRepository;\n};\n"],"names":["applyFiltering","applySorting","deserializeSingleEntity","extractMetaAccessors","NotFound","serializeEntity","Effect","copyOf","entity","entityConstructor","length","succeed","Object","assign","create","getPrototypeOf","makeInMemoryEntityRepository","seed","items","pendingFailure","guard","run","undefined","failure","fail","load","request","matched","filtering","sorting","page","pageSize","start","forEach","slice","pipe","map","copies","total","get","id","found","find","item","save","globalThis","crypto","randomUUID","tap","stored","sync","index","findIndex","push","flatMap","remove","entityOrId","filter","delete","next","failNext","error"],"mappings":"AACA,SACEA,cAAc,EACdC,YAAY,EACZC,uBAAuB,EAOvBC,oBAAoB,EACpBC,QAAQ,EACRC,eAAe,QACV,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC;;;;;;;;;CASC,GACD,MAAMC,SAAS,CACbC;IAEA,MAAMC,oBAAoBD,OAAO,WAAW;IAC5C,IAAIL,qBAAqBM,mBAAmBC,MAAM,KAAK,GAAG;QACxD,OAAOJ,OAAOK,OAAO,CACnBC,OAAOC,MAAM,CACXD,OAAOE,MAAM,CAACF,OAAOG,cAAc,CAACP,UACpCA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AOgC,EAAE,IAAGhC,aAAAA,OAAOgC,EAAE,YAAThC,aAAaqC,WAAWC,MAAM,CAACC,UAAU;YACrD,sEAAsE;YACtE,yEAAyE;YACzE,iEAAiE;YACjE,OAAOxC,OAAOC,QAAQ2B,IAAI,CACxB7B,OAAO0C,GAAG,CAACC,CAAAA,SACT3C,OAAO4C,IAAI,CAAC;oBACV,MAAMC,QAAQjC,MAAMkC,SAAS,CAACT,CAAAA,OAAQA,KAAKH,EAAE,KAAKS,OAAOT,EAAE;oBAC3D,IAAIW,UAAU,CAAC,GAAG;wBAChBjC,MAAMmC,IAAI,CAACJ;oBACb,OAAO;wBACL/B,KAAK,CAACiC,MAAM,GAAGF;oBACjB;gBACF,KAEF3C,OAAOgD,OAAO,CAAC/C;QAEnB;IAEF,MAAMgD,SAAS,CAAyBC,aACtCpC,MAAM;YACJ,MAAMoB,KACJgB,cAAc,QAAQ,OAAOA,eAAe,WACxCA,WAAWhB,EAAE,GACbgB;YACNtC,QAAQA,MAAMuC,MAAM,CAACd,CAAAA,OAAQA,KAAKH,EAAE,KAAKA;YACzC,OAAOlC,OAAOK,OAAO,CAACW;QACxB;IAEF,OAAO;QACLG;QACAc;QACAK;QACAc,QAAQH;QACR,IAAIrC;YACF,OAAOA;QACT;QACAD,MAAM,CAAC0C;YACLzC,QAAQ;mBAAIyC;aAAK;QACnB;QACAC,UAAU,CAACC;YACT1C,iBAAiB0C;QACnB;IAGF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/doubles/entity-repository.ts"],"sourcesContent":["import type { EntityRepository, RepositoryFailure } from '@entifix/business';\nimport {\n applyFiltering,\n applySorting,\n deserializeSingleEntity,\n type EntifixFailure,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityLoadRequest,\n type EntityPage,\n extractMetaAccessors,\n NotFound,\n serializeEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\n/**\n * A copy of `entity` that shares no state with it.\n *\n * Through the entity's own mapping — serialize, then deserialize — because that\n * is what a real adapter does to every record on the way in and out: a caller\n * can never hold the instance the store keeps, and a member the mapping drops\n * (`hidden`, `readonly`) does not survive a save here either. A class that\n * declares no accessors has no mapping to go through, so it is copied member by\n * member instead; plain spec fixtures are the case this keeps working.\n */\nconst copyOf = <TEntity extends Entity>(\n entity: TEntity,\n): Effect.Effect<TEntity, EntifixFailure> => {\n const entityConstructor = entity.constructor as EntityConstructor<TEntity>;\n if (extractMetaAccessors(entityConstructor).length === 0) {\n return Effect.succeed(\n Object.assign(\n Object.create(Object.getPrototypeOf(entity) as object) as TEntity,\n entity,\n ),\n );\n }\n // `undefined` only comes back for `null`/`undefined` input, and\n // `serializeEntity` always hands over an object.\n return deserializeSingleEntity(\n entityConstructor,\n serializeEntity(entityConstructor, entity),\n ) as Effect.Effect<TEntity, EntifixFailure>;\n};\n\nexport interface InMemoryEntityRepository extends EntityRepository {\n /** Everything currently stored, in insertion order. */\n readonly items: Entity[];\n /** Replaces the contents, discarding whatever was there. */\n seed(items: Entity[]): void;\n /**\n * Makes the next call to any method fail with `error`, so error branches are\n * reachable without reaching for a mocking library.\n */\n failNext(error: RepositoryFailure): void;\n}\n\n/**\n * In-memory {@link EntityRepository}: the default double for anything that\n * depends on persistence.\n *\n * Its semantics deliberately mirror `makeMongoRepository` — the same filtering\n * and sorting rules, which it takes from core's in-memory query evaluation\n * rather than keeping a copy of its own, same 1-based paging with a default page size of 10, same\n * \"entity not found\" failure, same id minting on create — and\n * `describeEntityRepositoryContract` holds both to that shared contract.\n */\nexport const makeInMemoryEntityRepository = (\n seed: Entity[] = [],\n): InMemoryEntityRepository => {\n let items = [...seed];\n let pendingFailure: RepositoryFailure | undefined;\n\n /** Consumes a queued failure, if one was armed. */\n const guard = <TValue>(\n run: () => Effect.Effect<TValue, RepositoryFailure>,\n ): Effect.Effect<TValue, RepositoryFailure> => {\n if (pendingFailure !== undefined) {\n const failure = pendingFailure;\n pendingFailure = undefined;\n return Effect.fail(failure);\n }\n return run();\n };\n\n const load = <TEntity extends Entity>(request: EntityLoadRequest<TEntity>) =>\n guard(() => {\n const matched = applySorting(\n applyFiltering(items as TEntity[], request.filtering),\n request.sorting,\n );\n const page = request.page ?? 1;\n const pageSize = request.pageSize ?? 10;\n const start = (page - 1) * pageSize;\n\n return Effect.forEach(\n matched.slice(start, start + pageSize),\n copyOf,\n ).pipe(\n Effect.map(\n copies =>\n ({\n items: copies,\n total: matched.length,\n request,\n }) satisfies EntityPage<TEntity>,\n ),\n );\n });\n\n const get = <TEntity extends Entity>(id: EntityId) =>\n guard(() => {\n const found = items.find(item => item.id === id);\n return found === undefined\n ? Effect.fail(new NotFound({}))\n : copyOf(found as TEntity);\n });\n\n const save = <TEntity extends Entity>(entity: TEntity) =>\n guard(() => {\n // A create arrives without an id, so the store mints one — same rule the\n // Mongo adapter follows. The Web Crypto global rather than `node:crypto`,\n // because a browser bundle cannot resolve a `node:` import and an example\n // with no backend runs this repository in the page.\n entity.id = entity.id ?? globalThis.crypto.randomUUID();\n // The store keeps its own copy and hands back another, so neither the\n // caller's instance nor the returned one can change the record without a\n // second save — which a real adapter guarantees by construction.\n return copyOf(entity).pipe(\n Effect.tap(stored =>\n Effect.sync(() => {\n const index = items.findIndex(item => item.id === stored.id);\n if (index === -1) {\n items.push(stored);\n } else {\n items[index] = stored;\n }\n }),\n ),\n Effect.flatMap(copyOf),\n );\n });\n\n const remove = <TEntity extends Entity>(entityOrId: EntityId | TEntity) =>\n guard(() => {\n const id =\n entityOrId != null && typeof entityOrId === 'object'\n ? entityOrId.id\n : entityOrId;\n items = items.filter(item => item.id !== id);\n return Effect.succeed(undefined);\n });\n\n return {\n load,\n get,\n save,\n delete: remove,\n get items() {\n return items;\n },\n seed: (next: Entity[]) => {\n items = [...next];\n },\n failNext: (error: RepositoryFailure) => {\n pendingFailure = error;\n },\n // Each method closes over its own state, so nothing is required from the\n // Effect environment; that is assignable to the interface's channel.\n } as unknown as InMemoryEntityRepository;\n};\n"],"names":["applyFiltering","applySorting","deserializeSingleEntity","extractMetaAccessors","NotFound","serializeEntity","Effect","copyOf","entity","entityConstructor","length","succeed","Object","assign","create","getPrototypeOf","makeInMemoryEntityRepository","seed","items","pendingFailure","guard","run","undefined","failure","fail","load","request","matched","filtering","sorting","page","pageSize","start","forEach","slice","pipe","map","copies","total","get","id","found","find","item","save","globalThis","crypto","randomUUID","tap","stored","sync","index","findIndex","push","flatMap","remove","entityOrId","filter","delete","next","failNext","error"],"mappings":"AACA,SACEA,cAAc,EACdC,YAAY,EACZC,uBAAuB,EAOvBC,oBAAoB,EACpBC,QAAQ,EACRC,eAAe,QACV,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC;;;;;;;;;CASC,GACD,MAAMC,SAAS,CACbC;IAEA,MAAMC,oBAAoBD,OAAO,WAAW;IAC5C,IAAIL,qBAAqBM,mBAAmBC,MAAM,KAAK,GAAG;QACxD,OAAOJ,OAAOK,OAAO,CACnBC,OAAOC,MAAM,CACXD,OAAOE,MAAM,CAACF,OAAOG,cAAc,CAACP,UACpCA;IAGN;IACA,gEAAgE;IAChE,iDAAiD;IACjD,OAAON,wBACLO,mBACAJ,gBAAgBI,mBAAmBD;AAEvC;AAcA;;;;;;;;;CASC,GACD,OAAO,MAAMQ,+BAA+B,CAC1CC,OAAiB,EAAE;IAEnB,IAAIC,QAAQ;WAAID;KAAK;IACrB,IAAIE;IAEJ,iDAAiD,GACjD,MAAMC,QAAQ,CACZC;QAEA,IAAIF,mBAAmBG,WAAW;YAChC,MAAMC,UAAUJ;YAChBA,iBAAiBG;YACjB,OAAOhB,OAAOkB,IAAI,CAACD;QACrB;QACA,OAAOF;IACT;IAEA,MAAMI,OAAO,CAAyBC,UACpCN,MAAM;gBAKSM,eACIA;YALjB,MAAMC,UAAU1B,aACdD,eAAekB,OAAoBQ,QAAQE,SAAS,GACpDF,QAAQG,OAAO;YAEjB,MAAMC,QAAOJ,gBAAAA,QAAQI,IAAI,YAAZJ,gBAAgB;YAC7B,MAAMK,YAAWL,oBAAA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ACbgB;YACNtC,QAAQA,MAAMuC,MAAM,CAACd,CAAAA,OAAQA,KAAKH,EAAE,KAAKA;YACzC,OAAOlC,OAAOK,OAAO,CAACW;QACxB;IAEF,OAAO;QACLG;QACAc;QACAK;QACAc,QAAQH;QACR,IAAIrC;YACF,OAAOA;QACT;QACAD,MAAM,CAAC0C;YACLzC,QAAQ;mBAAIyC;aAAK;QACnB;QACAC,UAAU,CAACC;YACT1C,iBAAiB0C;QACnB;IAGF;AACF,EAAE"}
@@ -0,0 +1,16 @@
1
+ import { type DomainEvent } from '@entifix/core';
2
+ import { Effect, type Scope } from 'effect';
3
+ import type { ServerPushContractOptions, ServerPushUnderTest } from '../contracts/server-push.contract.js';
4
+ /** An in-memory push port that also remembers everything published to it. */
5
+ export interface InMemoryServerPush extends ServerPushUnderTest {
6
+ /** Every event published, in order, whether or not anyone received it. */
7
+ readonly published: () => readonly DomainEvent[];
8
+ }
9
+ /**
10
+ * A push port for a host's specs: each open connection gets its own queue,
11
+ * filtered by topic and audience exactly as the real hub does, and every
12
+ * publish is recorded so a spec can assert what a projection pushed without
13
+ * opening a stream.
14
+ */
15
+ export declare const makeInMemoryServerPush: ({ topicsOf, admits, resume, }: ServerPushContractOptions) => Effect.Effect<InMemoryServerPush, never, Scope.Scope>;
16
+ //# sourceMappingURL=server-push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-push.d.ts","sourceRoot":"","sources":["../../src/doubles/server-push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,MAAM,EAAS,KAAK,KAAK,EAAU,MAAM,QAAQ,CAAC;AAE3D,OAAO,KAAK,EAGV,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,SAAS,WAAW,EAAE,CAAC;CAClD;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,+BAKpC,yBAAyB,KAAG,MAAM,CAAC,MAAM,CAC1C,kBAAkB,EAClB,KAAK,EACL,KAAK,CAAC,KAAK,CAgDT,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { audienceAdmits } from '@entifix/core';
2
+ import { Effect, Queue, Stream } from 'effect';
3
+ /**
4
+ * A push port for a host's specs: each open connection gets its own queue,
5
+ * filtered by topic and audience exactly as the real hub does, and every
6
+ * publish is recorded so a spec can assert what a projection pushed without
7
+ * opening a stream.
8
+ */ export const makeInMemoryServerPush = ({ topicsOf, admits = (event, connection)=>audienceAdmits(event.audience, connection.recipient), resume = (_cursor, topics)=>Stream.make({
9
+ _tag: 'resync',
10
+ topics
11
+ }) })=>Effect.sync(()=>{
12
+ const published = [];
13
+ const open = new Map();
14
+ return {
15
+ published: ()=>[
16
+ ...published
17
+ ],
18
+ publish: (event)=>Effect.suspend(()=>{
19
+ published.push(event);
20
+ return Effect.forEach(Array.from(open), ([queue, connection])=>{
21
+ const topics = topicsOf(event).filter((topic)=>connection.topics.includes(topic));
22
+ return topics.length > 0 && admits(event, connection) ? Queue.offer(queue, {
23
+ _tag: 'event',
24
+ event,
25
+ topics
26
+ }) : Effect.void;
27
+ }, {
28
+ discard: true
29
+ });
30
+ }),
31
+ open: (connection)=>Stream.unwrap(Effect.map(Effect.acquireRelease(Effect.tap(Queue.unbounded(), (queue)=>Effect.sync(()=>open.set(queue, connection))), (queue)=>Effect.sync(()=>open.delete(queue))), (queue)=>{
32
+ const live = Stream.fromQueue(queue);
33
+ return connection.cursor === undefined ? live : Stream.concat(resume(connection.cursor, connection.topics), live);
34
+ }))
35
+ };
36
+ });
37
+
38
+ //# sourceMappingURL=server-push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/doubles/server-push.ts"],"sourcesContent":["import { audienceAdmits, type DomainEvent } from '@entifix/core';\nimport { Effect, Queue, type Scope, Stream } from 'effect';\n\nimport type {\n PushConnectionUnderTest,\n PushMessageUnderTest,\n ServerPushContractOptions,\n ServerPushUnderTest,\n} from '../contracts/server-push.contract.js';\n\n/** An in-memory push port that also remembers everything published to it. */\nexport interface InMemoryServerPush extends ServerPushUnderTest {\n /** Every event published, in order, whether or not anyone received it. */\n readonly published: () => readonly DomainEvent[];\n}\n\n/**\n * A push port for a host's specs: each open connection gets its own queue,\n * filtered by topic and audience exactly as the real hub does, and every\n * publish is recorded so a spec can assert what a projection pushed without\n * opening a stream.\n */\nexport const makeInMemoryServerPush = ({\n topicsOf,\n admits = (event, connection) =>\n audienceAdmits(event.audience, connection.recipient),\n resume = (_cursor, topics) => Stream.make({ _tag: 'resync', topics }),\n}: ServerPushContractOptions): Effect.Effect<\n InMemoryServerPush,\n never,\n Scope.Scope\n> =>\n Effect.sync(() => {\n const published: DomainEvent[] = [];\n const open = new Map<\n Queue.Queue<PushMessageUnderTest>,\n PushConnectionUnderTest\n >();\n\n return {\n published: () => [...published],\n publish: event =>\n Effect.suspend(() => {\n published.push(event);\n return Effect.forEach(\n Array.from(open),\n ([queue, connection]) => {\n const topics = topicsOf(event).filter(topic =>\n connection.topics.includes(topic),\n );\n return topics.length > 0 && admits(event, connection)\n ? Queue.offer(queue, { _tag: 'event', event, topics })\n : Effect.void;\n },\n { discard: true },\n );\n }),\n open: connection =>\n Stream.unwrap(\n Effect.map(\n Effect.acquireRelease(\n Effect.tap(Queue.unbounded<PushMessageUnderTest>(), queue =>\n Effect.sync(() => open.set(queue, connection)),\n ),\n queue => Effect.sync(() => open.delete(queue)),\n ),\n queue => {\n const live = Stream.fromQueue(queue);\n return connection.cursor === undefined\n ? live\n : Stream.concat(\n resume(connection.cursor, connection.topics),\n live,\n );\n },\n ),\n ),\n };\n });\n"],"names":["audienceAdmits","Effect","Queue","Stream","makeInMemoryServerPush","topicsOf","admits","event","connection","audience","recipient","resume","_cursor","topics","make","_tag","sync","published","open","Map","publish","suspend","push","forEach","Array","from","queue","filter","topic","includes","length","offer","void","discard","unwrap","map","acquireRelease","tap","unbounded","set","delete","live","fromQueue","cursor","undefined","concat"],"mappings":"AAAA,SAASA,cAAc,QAA0B,gBAAgB;AACjE,SAASC,MAAM,EAAEC,KAAK,EAAcC,MAAM,QAAQ,SAAS;AAe3D;;;;;CAKC,GACD,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,QAAQ,EACRC,SAAS,CAACC,OAAOC,aACfR,eAAeO,MAAME,QAAQ,EAAED,WAAWE,SAAS,CAAC,EACtDC,SAAS,CAACC,SAASC,SAAWV,OAAOW,IAAI,CAAC;QAAEC,MAAM;QAAUF;IAAO,EAAE,EAC3C,GAK1BZ,OAAOe,IAAI,CAAC;QACV,MAAMC,YAA2B,EAAE;QACnC,MAAMC,OAAO,IAAIC;QAKjB,OAAO;YACLF,WAAW,IAAM;uBAAIA;iBAAU;YAC/BG,SAASb,CAAAA,QACPN,OAAOoB,OAAO,CAAC;oBACbJ,UAAUK,IAAI,CAACf;oBACf,OAAON,OAAOsB,OAAO,CACnBC,MAAMC,IAAI,CAACP,OACX,CAAC,CAACQ,OAAOlB,WAAW;wBAClB,MAAMK,SAASR,SAASE,OAAOoB,MAAM,CAACC,CAAAA,QACpCpB,WAAWK,MAAM,CAACgB,QAAQ,CAACD;wBAE7B,OAAOf,OAAOiB,MAAM,GAAG,KAAKxB,OAAOC,OAAOC,cACtCN,MAAM6B,KAAK,CAACL,OAAO;4BAAEX,MAAM;4BAASR;4BAAOM;wBAAO,KAClDZ,OAAO+B,IAAI;oBACjB,GACA;wBAAEC,SAAS;oBAAK;gBAEpB;YACFf,MAAMV,CAAAA,aACJL,OAAO+B,MAAM,CACXjC,OAAOkC,GAAG,CACRlC,OAAOmC,cAAc,CACnBnC,OAAOoC,GAAG,CAACnC,MAAMoC,SAAS,IAA0BZ,CAAAA,QAClDzB,OAAOe,IAAI,CAAC,IAAME,KAAKqB,GAAG,CAACb,OAAOlB,eAEpCkB,CAAAA,QAASzB,OAAOe,IAAI,CAAC,IAAME,KAAKsB,MAAM,CAACd,UAEzCA,CAAAA;oBACE,MAAMe,OAAOtC,OAAOuC,SAAS,CAAChB;oBAC9B,OAAOlB,WAAWmC,MAAM,KAAKC,YACzBH,OACAtC,OAAO0C,MAAM,CACXlC,OAAOH,WAAWmC,MAAM,EAAEnC,WAAWK,MAAM,GAC3C4B;gBAER;QAGR;IACF,GAAG"}
@@ -1,36 +1,6 @@
1
- import { type DomainEvent, type TransitionalFailure } from '@entifix/core';
2
- import type { EventBus, LockService, SagaInstance, SagaStore, SequenceService, TransactionInbox } from '@entifix/transactions';
1
+ import { type DomainEvent, type EntifixFailure } from '@entifix/core';
2
+ import type { EventBus, TransactionInbox } from '@entifix/transactions';
3
3
  import { Effect } from 'effect';
4
- export interface InMemoryLockService extends LockService {
5
- /** Keys currently held, in acquisition order. */
6
- readonly held: string[];
7
- /** Every acquire/release in the order it happened. */
8
- readonly log: ReadonlyArray<{
9
- action: 'acquire' | 'release';
10
- key: string;
11
- }>;
12
- /**
13
- * Marks `key` as already taken by someone else, so the next `acquire` fails
14
- * with {@link Contention} — the 409 path of the transaction facade.
15
- */
16
- contendOn(key: string): void;
17
- }
18
- /**
19
- * In-memory {@link LockService}. Acquisition is immediate and uncontended
20
- * unless {@link InMemoryLockService.contendOn} says otherwise, and `release`
21
- * only frees a lock whose token matches — the compare-and-delete rule the Redis
22
- * adapter enforces with a Lua script.
23
- */
24
- export declare const makeInMemoryLockService: () => InMemoryLockService;
25
- export interface InMemorySequenceService extends SequenceService {
26
- /** The current value of every sequence drawn from so far. */
27
- readonly values: Readonly<Record<string, number>>;
28
- }
29
- /**
30
- * In-memory {@link SequenceService} — a plain counter per name. Atomicity is
31
- * what the Redis `INCR` adapter buys; single-threaded JS gives it for free here.
32
- */
33
- export declare const makeInMemorySequenceService: () => InMemorySequenceService;
34
4
  export interface RecordingEventBus extends EventBus {
35
5
  /** Every event published, in order. */
36
6
  readonly published: DomainEvent[];
@@ -40,7 +10,7 @@ export interface RecordingEventBus extends EventBus {
40
10
  * broker's job in production, so a double that ignored it would let a
41
11
  * consumer pass its tests while receiving traffic it never bound to.
42
12
  */
43
- deliver(event: DomainEvent): Effect.Effect<void, TransitionalFailure>;
13
+ deliver(event: DomainEvent): Effect.Effect<void, EntifixFailure>;
44
14
  /** Makes the next `publish` fail, for the broker-unavailable branch. */
45
15
  failNextPublish(): void;
46
16
  }
@@ -67,15 +37,4 @@ export declare const makeInMemoryInboxes: () => {
67
37
  eventId: string;
68
38
  }[];
69
39
  };
70
- export interface InMemorySagaStore extends SagaStore {
71
- /** Every instance, as stored — for a spec to assert on state, not calls. */
72
- readonly instances: readonly SagaInstance[];
73
- }
74
- /**
75
- * In-memory {@link SagaStore}, with the Mongo adapter's semantics: `start`
76
- * never overwrites, outcomes append, and a resume claim only takes an
77
- * unfinished instance whose `updatedAt` is past the deadline — counting the
78
- * attempt and re-stamping it, so the next sweep does not find it again.
79
- */
80
- export declare const makeInMemorySagaStore: () => InMemorySagaStore;
81
40
  //# sourceMappingURL=transaction-ports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-ports.d.ts","sourceRoot":"","sources":["../../src/doubles/transaction-ports.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,mBAAmB,EAEzB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,QAAQ,EAER,WAAW,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;QAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;QAAC,GAAG,EAAE,MA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,CAAC;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC;IAClC;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACjE,wEAAwE;IACxE,eAAe,IAAI,IAAI,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,iBAwCxC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;IAI5B,0DAA0D;oBAC1C,MAAM,KAAG,gBAAgB;qBAS3B,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE;CAOjE,CAAC"}
@@ -1,71 +1,5 @@
1
- import { _ as _extends } from "@swc/helpers/_/_extends";
2
- import { Contention, matchesEventPattern, Unavailable } from '@entifix/core';
1
+ import { matchesEventPattern, Unavailable } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
- /**
5
- * In-memory {@link LockService}. Acquisition is immediate and uncontended
6
- * unless {@link InMemoryLockService.contendOn} says otherwise, and `release`
7
- * only frees a lock whose token matches — the compare-and-delete rule the Redis
8
- * adapter enforces with a Lua script.
9
- */ export const makeInMemoryLockService = ()=>{
10
- const tokens = new Map();
11
- const contended = new Set();
12
- const log = [];
13
- let counter = 0;
14
- return {
15
- acquire: (key)=>Effect.suspend(()=>{
16
- if (contended.has(key) || tokens.has(key)) {
17
- return Effect.fail(new Contention());
18
- }
19
- const token = `token-${counter += 1}`;
20
- tokens.set(key, token);
21
- log.push({
22
- action: 'acquire',
23
- key
24
- });
25
- return Effect.succeed({
26
- key,
27
- token
28
- });
29
- }),
30
- release: (handle)=>Effect.sync(()=>{
31
- if (tokens.get(handle.key) === handle.token) {
32
- tokens.delete(handle.key);
33
- log.push({
34
- action: 'release',
35
- key: handle.key
36
- });
37
- }
38
- }),
39
- get held () {
40
- return [
41
- ...tokens.keys()
42
- ];
43
- },
44
- get log () {
45
- return log;
46
- },
47
- contendOn: (key)=>{
48
- contended.add(key);
49
- }
50
- };
51
- };
52
- /**
53
- * In-memory {@link SequenceService} — a plain counter per name. Atomicity is
54
- * what the Redis `INCR` adapter buys; single-threaded JS gives it for free here.
55
- */ export const makeInMemorySequenceService = ()=>{
56
- const sequences = new Map();
57
- return {
58
- next: (name)=>Effect.sync(()=>{
59
- var _sequences_get;
60
- const next = ((_sequences_get = sequences.get(name)) != null ? _sequences_get : 0) + 1;
61
- sequences.set(name, next);
62
- return next;
63
- }),
64
- get values () {
65
- return Object.fromEntries(sequences);
66
- }
67
- };
68
- };
69
3
  /**
70
4
  * In-memory {@link EventBus} that records what was published rather than
71
5
  * asserting on it. Prefer reading `bus.published` in a test over a mock's call
@@ -140,72 +74,5 @@ import { Effect } from 'effect';
140
74
  }
141
75
  };
142
76
  };
143
- /**
144
- * In-memory {@link SagaStore}, with the Mongo adapter's semantics: `start`
145
- * never overwrites, outcomes append, and a resume claim only takes an
146
- * unfinished instance whose `updatedAt` is past the deadline — counting the
147
- * attempt and re-stamping it, so the next sweep does not find it again.
148
- */ export const makeInMemorySagaStore = ()=>{
149
- const instances = new Map();
150
- const stamp = ()=>new Date().toISOString();
151
- const unfinished = (entry)=>entry.state === 'RUNNING' || entry.state === 'COMPENSATING';
152
- const pastDeadline = (entry, olderThanMs)=>entry.updatedAt < new Date(Date.now() - olderThanMs).toISOString();
153
- const update = (sagaId, change)=>Effect.sync(()=>{
154
- const current = instances.get(sagaId);
155
- if (current !== undefined) {
156
- instances.set(sagaId, _extends({}, change(current), {
157
- updatedAt: stamp()
158
- }));
159
- }
160
- });
161
- return {
162
- start: (started)=>Effect.sync(()=>{
163
- if (!instances.has(started.sagaId)) {
164
- instances.set(started.sagaId, _extends({}, started, {
165
- updatedAt: stamp()
166
- }));
167
- }
168
- }),
169
- beginStep: (sagaId, stepIndex)=>update(sagaId, (entry)=>_extends({}, entry, {
170
- stepIndex
171
- })),
172
- recordOutcome: (sagaId, outcome)=>update(sagaId, (entry)=>_extends({}, entry, {
173
- outcomes: [
174
- ...entry.outcomes,
175
- outcome
176
- ]
177
- })),
178
- settle: (sagaId, state, error)=>update(sagaId, (entry)=>_extends({}, entry, {
179
- state,
180
- error
181
- })),
182
- markCompensated: (sagaId, stepId)=>update(sagaId, (entry)=>_extends({}, entry, {
183
- outcomes: entry.outcomes.map((outcome)=>outcome.stepId === stepId ? _extends({}, outcome, {
184
- compensated: true
185
- }) : outcome)
186
- })),
187
- get: (sagaId)=>Effect.sync(()=>instances.get(sagaId)),
188
- findStale: (olderThanMs)=>Effect.sync(()=>[
189
- ...instances.values()
190
- ].filter((entry)=>unfinished(entry) && pastDeadline(entry, olderThanMs))),
191
- claimForResume: (sagaId, olderThanMs)=>Effect.sync(()=>{
192
- const current = instances.get(sagaId);
193
- if (current === undefined || !unfinished(current) || !pastDeadline(current, olderThanMs)) {
194
- return undefined;
195
- }
196
- const claimed = _extends({}, current, {
197
- resumeAttempts: current.resumeAttempts + 1,
198
- updatedAt: stamp()
199
- });
200
- instances.set(sagaId, claimed);
201
- return claimed;
202
- }),
203
- get instances () {
204
- return [
205
- ...instances.values()
206
- ];
207
- }
208
- };
209
- };
210
77
 
211
78
  //# sourceMappingURL=transaction-ports.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/doubles/transaction-ports.ts"],"sourcesContent":["import {\n Contention,\n type DomainEvent,\n matchesEventPattern,\n type TransitionalFailure,\n Unavailable,\n} from '@entifix/core';\nimport type {\n EventBus,\n LockHandle,\n LockService,\n SagaInstance,\n SagaStore,\n SequenceService,\n TransactionInbox,\n} from '@entifix/transactions';\nimport { Effect } from 'effect';\n\nexport interface InMemoryLockService extends LockService {\n /** Keys currently held, in acquisition order. */\n readonly held: string[];\n /** Every acquire/release in the order it happened. */\n readonly log: ReadonlyArray<{ action: 'acquire' | 'release'; key: string }>;\n /**\n * Marks `key` as already taken by someone else, so the next `acquire` fails\n * with {@link Contention} — the 409 path of the transaction facade.\n */\n contendOn(key: string): void;\n}\n\n/**\n * In-memory {@link LockService}. Acquisition is immediate and uncontended\n * unless {@link InMemoryLockService.contendOn} says otherwise, and `release`\n * only frees a lock whose token matches — the compare-and-delete rule the Redis\n * adapter enforces with a Lua script.\n */\nexport const makeInMemoryLockService = (): InMemoryLockService => {\n const tokens = new Map<string, string>();\n const contended = new Set<string>();\n const log: Array<{ action: 'acquire' | 'release'; key: string }> = [];\n let counter = 0;\n\n return {\n acquire: key =>\n Effect.suspend(() => {\n if (contended.has(key) || tokens.has(key)) {\n return Effect.fail(new Contention());\n }\n const token = `token-${(counter += 1)}`;\n tokens.set(key, token);\n log.push({ action: 'acquire', key });\n return Effect.succeed({ key, token });\n }),\n release: (handle: LockHandle) =>\n Effect.sync(() => {\n if (tokens.get(handle.key) === handle.token) {\n tokens.delete(handle.key);\n log.push({ action: 'release', key: handle.key });\n }\n }),\n get held() {\n return [...tokens.keys()];\n },\n get log() {\n return log;\n },\n contendOn: key => {\n contended.add(key);\n },\n };\n};\n\nexport interface InMemorySequenceService extends SequenceService {\n /** The current value of every sequence drawn from so far. */\n readonly values: Readonly<Record<string, number>>;\n}\n\n/**\n * In-memory {@link SequenceService} — a plain counter per name. Atomicity is\n * what the Redis `INCR` adapter buys; single-threaded JS gives it for free here.\n */\nexport const makeInMemorySequenceService = (): InMemorySequenceService => {\n const sequences = new Map<string, number>();\n\n return {\n next: name =>\n Effect.sync(() => {\n const next = (sequences.get(name) ?? 0) + 1;\n sequences.set(name, next);\n return next;\n }),\n get values() {\n return Object.fromEntries(sequences);\n },\n };\n};\n\nexport interface RecordingEventBus extends EventBus {\n /** Every event published, in order. */\n readonly published: DomainEvent[];\n /**\n * Pushes an event to the subscribers whose pattern matches it, as a topic\n * exchange would. Deliberately not \"to all subscribers\": routing is the\n * broker's job in production, so a double that ignored it would let a\n * consumer pass its tests while receiving traffic it never bound to.\n */\n deliver(event: DomainEvent): Effect.Effect<void, TransitionalFailure>;\n /** Makes the next `publish` fail, for the broker-unavailable branch. */\n failNextPublish(): void;\n}\n\n/**\n * In-memory {@link EventBus} that records what was published rather than\n * asserting on it. Prefer reading `bus.published` in a test over a mock's call\n * assertions: the expectation then reads as state, not as a spy protocol.\n */\nexport const makeRecordingEventBus = (): RecordingEventBus => {\n const published: DomainEvent[] = [];\n const handlers: Array<{\n pattern: string;\n handle: (event: DomainEvent) => Effect.Effect<void, TransitionalFailure>;\n }> = [];\n let failNext = false;\n\n return {\n publish: event =>\n Effect.suspend(() => {\n if (failNext) {\n failNext = false;\n return Effect.fail(new Unavailable({ dependency: 'bus' }));\n }\n published.push(event);\n return Effect.void;\n }),\n subscribe: (subscription, handle) =>\n Effect.sync(() => {\n // Only the pattern is retained: queue durability and the delivery\n // ceiling are broker facts with no in-memory analogue, and faking them\n // would assert against the double rather than against a broker.\n handlers.push({ pattern: subscription.pattern, handle });\n }),\n deliver: event =>\n Effect.forEach(\n handlers.filter(({ pattern }) =>\n matchesEventPattern(pattern, event.name),\n ),\n ({ handle }) => handle(event),\n { discard: true },\n ),\n get published() {\n return published;\n },\n failNextPublish: () => {\n failNext = true;\n },\n };\n};\n\n/**\n * An in-memory {@link TransactionInbox}, one per consumer, over a shared claim\n * set.\n *\n * Sharing the set across the inboxes one factory hands out is what makes the\n * contract's \"one consumer cannot consume another's claim\" case a real\n * assertion, rather than one the double satisfies by only ever having seen a\n * single consumer.\n */\nexport const makeInMemoryInboxes = () => {\n const claimed = new Set<string>();\n\n return {\n /** An inbox for `consumer`, over the shared claim set. */\n for: (consumer: string): TransactionInbox => ({\n claim: eventId =>\n Effect.sync(() => {\n const key = JSON.stringify([consumer, eventId]);\n if (claimed.has(key)) return 'duplicate' as const;\n claimed.add(key);\n return 'claimed' as const;\n }),\n }),\n get claims(): readonly { consumer: string; eventId: string }[] {\n return [...claimed].map(key => {\n const [consumer, eventId] = JSON.parse(key) as [string, string];\n return { consumer, eventId };\n });\n },\n };\n};\n\nexport interface InMemorySagaStore extends SagaStore {\n /** Every instance, as stored — for a spec to assert on state, not calls. */\n readonly instances: readonly SagaInstance[];\n}\n\n/**\n * In-memory {@link SagaStore}, with the Mongo adapter's semantics: `start`\n * never overwrites, outcomes append, and a resume claim only takes an\n * unfinished instance whose `updatedAt` is past the deadline — counting the\n * attempt and re-stamping it, so the next sweep does not find it again.\n */\nexport const makeInMemorySagaStore = (): InMemorySagaStore => {\n const instances = new Map<string, SagaInstance>();\n const stamp = () => new Date().toISOString();\n const unfinished = (entry: SagaInstance) =>\n entry.state === 'RUNNING' || entry.state === 'COMPENSATING';\n const pastDeadline = (entry: SagaInstance, olderThanMs: number) =>\n entry.updatedAt < new Date(Date.now() - olderThanMs).toISOString();\n const update = (\n sagaId: string,\n change: (entry: SagaInstance) => SagaInstance,\n ) =>\n Effect.sync(() => {\n const current = instances.get(sagaId);\n if (current !== undefined) {\n instances.set(sagaId, { ...change(current), updatedAt: stamp() });\n }\n });\n\n return {\n start: started =>\n Effect.sync(() => {\n if (!instances.has(started.sagaId)) {\n instances.set(started.sagaId, { ...started, updatedAt: stamp() });\n }\n }),\n beginStep: (sagaId, stepIndex) =>\n update(sagaId, entry => ({ ...entry, stepIndex })),\n recordOutcome: (sagaId, outcome) =>\n update(sagaId, entry => ({\n ...entry,\n outcomes: [...entry.outcomes, outcome],\n })),\n settle: (sagaId, state, error) =>\n update(sagaId, entry => ({ ...entry, state, error })),\n markCompensated: (sagaId, stepId) =>\n update(sagaId, entry => ({\n ...entry,\n outcomes: entry.outcomes.map(outcome =>\n outcome.stepId === stepId\n ? { ...outcome, compensated: true }\n : outcome,\n ),\n })),\n get: sagaId => Effect.sync(() => instances.get(sagaId)),\n findStale: olderThanMs =>\n Effect.sync(() =>\n [...instances.values()].filter(\n entry => unfinished(entry) && pastDeadline(entry, olderThanMs),\n ),\n ),\n claimForResume: (sagaId, olderThanMs) =>\n Effect.sync(() => {\n const current = instances.get(sagaId);\n if (\n current === undefined ||\n !unfinished(current) ||\n !pastDeadline(current, olderThanMs)\n ) {\n return undefined;\n }\n const claimed = {\n ...current,\n resumeAttempts: current.resumeAttempts + 1,\n updatedAt: stamp(),\n };\n instances.set(sagaId, claimed);\n return claimed;\n }),\n get instances() {\n return [...instances.values()];\n },\n };\n};\n"],"names":["Contention","matchesEventPattern","Unavailable","Effect","makeInMemoryLockService","tokens","Map","contended","Set","log","counter","acquire","key","suspend","has","fail","token","set","push","action","succeed","release","handle","sync","get","delete","held","keys","contendOn","add","makeInMemorySequenceService","sequences","next","name","values","Object","fromEntries","makeRecordingEventBus","published","handlers","failNext","publish","event","dependency","void","subscribe","subscription","pattern","deliver","forEach","filter","discard","failNextPublish","makeInMemoryInboxes","claimed","for","consumer","claim","eventId","JSON","stringify","claims","map","parse","makeInMemorySagaStore","instances","stamp","Date","toISOString","unfinished","entry","state","pastDeadline","olderThanMs","updatedAt","now","update","sagaId","change","current","undefined","start","started","beginStep","stepIndex","recordOutcome","outcome","outcomes","settle","error","markCompensated","stepId","compensated","findStale","claimForResume","resumeAttempts"],"mappings":";AAAA,SACEA,UAAU,EAEVC,mBAAmB,EAEnBC,WAAW,QACN,gBAAgB;AAUvB,SAASC,MAAM,QAAQ,SAAS;AAchC;;;;;CAKC,GACD,OAAO,MAAMC,0BAA0B;IACrC,MAAMC,SAAS,IAAIC;IACnB,MAAMC,YAAY,IAAIC;IACtB,MAAMC,MAA6D,EAAE;IACrE,IAAIC,UAAU;IAEd,OAAO;QACLC,SAASC,CAAAA,MACPT,OAAOU,OAAO,CAAC;gBACb,IAAIN,UAAUO,GAAG,CAACF,QAAQP,OAAOS,GAAG,CAACF,MAAM;oBACzC,OAAOT,OAAOY,IAAI,CAAC,IAAIf;gBACzB;gBACA,MAAMgB,QAAQ,CAA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UAAU/B,MAAM;iBAAG,CAACgB,MAAM,CAC5BoB,CAAAA,QAASD,WAAWC,UAAUE,aAAaF,OAAOG;QAGxDqB,gBAAgB,CAACjB,QAAQJ,cACvBtE,OAAOoB,IAAI,CAAC;gBACV,MAAMwD,UAAUd,UAAUzC,GAAG,CAACqD;gBAC9B,IACEE,YAAYC,aACZ,CAACX,WAAWU,YACZ,CAACP,aAAaO,SAASN,cACvB;oBACA,OAAOO;gBACT;gBACA,MAAM1B,UAAU,aACXyB;oBACHgB,gBAAgBhB,QAAQgB,cAAc,GAAG;oBACzCrB,WAAWR;;gBAEbD,UAAUhD,GAAG,CAAC4D,QAAQvB;gBACtB,OAAOA;YACT;QACF,IAAIW;YACF,OAAO;mBAAIA,UAAU/B,MAAM;aAAG;QAChC;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/doubles/transaction-ports.ts"],"sourcesContent":["import {\n type DomainEvent,\n type EntifixFailure,\n matchesEventPattern,\n Unavailable,\n} from '@entifix/core';\nimport type { EventBus, TransactionInbox } from '@entifix/transactions';\nimport { Effect } from 'effect';\n\nexport interface RecordingEventBus extends EventBus {\n /** Every event published, in order. */\n readonly published: DomainEvent[];\n /**\n * Pushes an event to the subscribers whose pattern matches it, as a topic\n * exchange would. Deliberately not \"to all subscribers\": routing is the\n * broker's job in production, so a double that ignored it would let a\n * consumer pass its tests while receiving traffic it never bound to.\n */\n deliver(event: DomainEvent): Effect.Effect<void, EntifixFailure>;\n /** Makes the next `publish` fail, for the broker-unavailable branch. */\n failNextPublish(): void;\n}\n\n/**\n * In-memory {@link EventBus} that records what was published rather than\n * asserting on it. Prefer reading `bus.published` in a test over a mock's call\n * assertions: the expectation then reads as state, not as a spy protocol.\n */\nexport const makeRecordingEventBus = (): RecordingEventBus => {\n const published: DomainEvent[] = [];\n const handlers: Array<{\n pattern: string;\n handle: (event: DomainEvent) => Effect.Effect<void, EntifixFailure>;\n }> = [];\n let failNext = false;\n\n return {\n publish: event =>\n Effect.suspend(() => {\n if (failNext) {\n failNext = false;\n return Effect.fail(new Unavailable({ dependency: 'bus' }));\n }\n published.push(event);\n return Effect.void;\n }),\n subscribe: (subscription, handle) =>\n Effect.sync(() => {\n // Only the pattern is retained: queue durability and the delivery\n // ceiling are broker facts with no in-memory analogue, and faking them\n // would assert against the double rather than against a broker.\n handlers.push({ pattern: subscription.pattern, handle });\n }),\n deliver: event =>\n Effect.forEach(\n handlers.filter(({ pattern }) =>\n matchesEventPattern(pattern, event.name),\n ),\n ({ handle }) => handle(event),\n { discard: true },\n ),\n get published() {\n return published;\n },\n failNextPublish: () => {\n failNext = true;\n },\n };\n};\n\n/**\n * An in-memory {@link TransactionInbox}, one per consumer, over a shared claim\n * set.\n *\n * Sharing the set across the inboxes one factory hands out is what makes the\n * contract's \"one consumer cannot consume another's claim\" case a real\n * assertion, rather than one the double satisfies by only ever having seen a\n * single consumer.\n */\nexport const makeInMemoryInboxes = () => {\n const claimed = new Set<string>();\n\n return {\n /** An inbox for `consumer`, over the shared claim set. */\n for: (consumer: string): TransactionInbox => ({\n claim: eventId =>\n Effect.sync(() => {\n const key = JSON.stringify([consumer, eventId]);\n if (claimed.has(key)) return 'duplicate' as const;\n claimed.add(key);\n return 'claimed' as const;\n }),\n }),\n get claims(): readonly { consumer: string; eventId: string }[] {\n return [...claimed].map(key => {\n const [consumer, eventId] = JSON.parse(key) as [string, string];\n return { consumer, eventId };\n });\n },\n };\n};\n"],"names":["matchesEventPattern","Unavailable","Effect","makeRecordingEventBus","published","handlers","failNext","publish","event","suspend","fail","dependency","push","void","subscribe","subscription","handle","sync","pattern","deliver","forEach","filter","name","discard","failNextPublish","makeInMemoryInboxes","claimed","Set","for","consumer","claim","eventId","key","JSON","stringify","has","add","claims","map","parse"],"mappings":"AAAA,SAGEA,mBAAmB,EACnBC,WAAW,QACN,gBAAgB;AAEvB,SAASC,MAAM,QAAQ,SAAS;AAgBhC;;;;CAIC,GACD,OAAO,MAAMC,wBAAwB;IACnC,MAAMC,YAA2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AEH;oBAAUE;gBAAQ;YAC7B;QACF;IACF;AACF,EAAE"}
@@ -21,7 +21,7 @@ export interface FakeMongoDb {
21
21
  read(collection: string): Document[];
22
22
  /**
23
23
  * Makes every subsequent driver call reject with `error`, so the adapter's
24
- * `EntifixConnError` mapping is reachable. Pass `undefined` to restore.
24
+ * `Unavailable` mapping is reachable. Pass `undefined` to restore.
25
25
  */
26
26
  failWith(error: unknown): void;
27
27
  /**