@kairos-es/core 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (120) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/AppendCondition.js +1 -3
  3. package/dist/cjs/AppendCondition.js.map +1 -1
  4. package/dist/cjs/AppendIsOwned.js +6 -6
  5. package/dist/cjs/AppendIsOwned.js.map +1 -1
  6. package/dist/cjs/ContractStore.js +13 -4
  7. package/dist/cjs/ContractStore.js.map +1 -1
  8. package/dist/cjs/DcbEventStore.js +1 -1
  9. package/dist/cjs/DcbEventStore.js.map +1 -1
  10. package/dist/cjs/Event.js +87 -11
  11. package/dist/cjs/Event.js.map +1 -1
  12. package/dist/cjs/Projection.js +15 -9
  13. package/dist/cjs/Projection.js.map +1 -1
  14. package/dist/cjs/Query.js +59 -3
  15. package/dist/cjs/Query.js.map +1 -1
  16. package/dist/cjs/SubscribeMachine.js +20 -22
  17. package/dist/cjs/SubscribeMachine.js.map +1 -1
  18. package/dist/cjs/inMemory.js +113 -43
  19. package/dist/cjs/inMemory.js.map +1 -1
  20. package/dist/cjs/retryOnConflict.js +4 -10
  21. package/dist/cjs/retryOnConflict.js.map +1 -1
  22. package/dist/cjs/testing.js +2 -2
  23. package/dist/cjs/testing.js.map +1 -1
  24. package/dist/{dts → dts-cjs}/AppendCondition.d.ts +5 -7
  25. package/dist/{dts → dts-cjs}/AppendCondition.d.ts.map +1 -1
  26. package/dist/{dts → dts-cjs}/AppendIsOwned.d.ts +6 -6
  27. package/dist/{dts → dts-cjs}/AppendIsOwned.d.ts.map +1 -1
  28. package/dist/{dts → dts-cjs}/ContractStore.d.ts +7 -4
  29. package/dist/dts-cjs/ContractStore.d.ts.map +1 -0
  30. package/dist/{dts → dts-cjs}/DcbEventStore.d.ts +2 -2
  31. package/dist/{dts → dts-cjs}/DcbEventStore.d.ts.map +1 -1
  32. package/dist/dts-cjs/Event.d.ts +174 -0
  33. package/dist/dts-cjs/Event.d.ts.map +1 -0
  34. package/dist/{dts → dts-cjs}/Projection.d.ts +1 -1
  35. package/dist/{dts → dts-cjs}/Projection.d.ts.map +1 -1
  36. package/dist/{dts → dts-cjs}/Query.d.ts +19 -5
  37. package/dist/dts-cjs/Query.d.ts.map +1 -0
  38. package/dist/{dts → dts-cjs}/SubscribeMachine.d.ts +11 -15
  39. package/dist/dts-cjs/SubscribeMachine.d.ts.map +1 -0
  40. package/dist/{dts → dts-cjs}/inMemory.d.ts.map +1 -1
  41. package/dist/{dts → dts-cjs}/index.d.ts +1 -1
  42. package/dist/dts-cjs/package.json +3 -0
  43. package/dist/{dts → dts-cjs}/retryOnConflict.d.ts +1 -7
  44. package/dist/dts-cjs/retryOnConflict.d.ts.map +1 -0
  45. package/dist/{dts → dts-cjs}/testing.d.ts +1 -1
  46. package/dist/dts-esm/AppendCondition.d.ts +21 -0
  47. package/dist/dts-esm/AppendCondition.d.ts.map +1 -0
  48. package/dist/dts-esm/AppendIsOwned.d.ts +78 -0
  49. package/dist/dts-esm/AppendIsOwned.d.ts.map +1 -0
  50. package/dist/dts-esm/ContractStore.d.ts +62 -0
  51. package/dist/dts-esm/ContractStore.d.ts.map +1 -0
  52. package/dist/dts-esm/DcbEventStore.d.ts +64 -0
  53. package/dist/dts-esm/DcbEventStore.d.ts.map +1 -0
  54. package/dist/dts-esm/Event.d.ts +174 -0
  55. package/dist/dts-esm/Event.d.ts.map +1 -0
  56. package/dist/dts-esm/Projection.d.ts +124 -0
  57. package/dist/dts-esm/Projection.d.ts.map +1 -0
  58. package/dist/dts-esm/Query.d.ts +180 -0
  59. package/dist/dts-esm/Query.d.ts.map +1 -0
  60. package/dist/dts-esm/SubscribeMachine.d.ts +175 -0
  61. package/dist/dts-esm/SubscribeMachine.d.ts.map +1 -0
  62. package/dist/dts-esm/errors.d.ts +17 -0
  63. package/dist/dts-esm/errors.d.ts.map +1 -0
  64. package/dist/dts-esm/inMemory.d.ts +76 -0
  65. package/dist/dts-esm/inMemory.d.ts.map +1 -0
  66. package/dist/dts-esm/index.d.ts +40 -0
  67. package/dist/dts-esm/index.d.ts.map +1 -0
  68. package/dist/dts-esm/package.json +3 -0
  69. package/dist/dts-esm/retryOnConflict.d.ts +64 -0
  70. package/dist/dts-esm/retryOnConflict.d.ts.map +1 -0
  71. package/dist/dts-esm/testing.d.ts +39 -0
  72. package/dist/dts-esm/testing.d.ts.map +1 -0
  73. package/dist/esm/AppendCondition.js +1 -3
  74. package/dist/esm/AppendCondition.js.map +1 -1
  75. package/dist/esm/AppendIsOwned.js +6 -6
  76. package/dist/esm/AppendIsOwned.js.map +1 -1
  77. package/dist/esm/ContractStore.js +13 -4
  78. package/dist/esm/ContractStore.js.map +1 -1
  79. package/dist/esm/DcbEventStore.js +1 -1
  80. package/dist/esm/DcbEventStore.js.map +1 -1
  81. package/dist/esm/Event.js +87 -11
  82. package/dist/esm/Event.js.map +1 -1
  83. package/dist/esm/Projection.js +15 -9
  84. package/dist/esm/Projection.js.map +1 -1
  85. package/dist/esm/Query.js +56 -1
  86. package/dist/esm/Query.js.map +1 -1
  87. package/dist/esm/SubscribeMachine.js +21 -23
  88. package/dist/esm/SubscribeMachine.js.map +1 -1
  89. package/dist/esm/inMemory.js +114 -44
  90. package/dist/esm/inMemory.js.map +1 -1
  91. package/dist/esm/index.js +1 -1
  92. package/dist/esm/retryOnConflict.js +4 -10
  93. package/dist/esm/retryOnConflict.js.map +1 -1
  94. package/dist/esm/testing.js +2 -2
  95. package/dist/esm/testing.js.map +1 -1
  96. package/package.json +21 -11
  97. package/src/AppendCondition.ts +1 -1
  98. package/src/AppendIsOwned.ts +7 -7
  99. package/src/ContractStore.ts +25 -8
  100. package/src/DcbEventStore.ts +3 -3
  101. package/src/Event.ts +108 -11
  102. package/src/Projection.ts +19 -8
  103. package/src/Query.ts +74 -1
  104. package/src/SubscribeMachine.ts +38 -31
  105. package/src/inMemory.ts +123 -51
  106. package/src/index.ts +1 -1
  107. package/src/retryOnConflict.ts +6 -11
  108. package/src/testing.ts +2 -2
  109. package/testing/package.json +1 -1
  110. package/dist/dts/ContractStore.d.ts.map +0 -1
  111. package/dist/dts/Event.d.ts +0 -104
  112. package/dist/dts/Event.d.ts.map +0 -1
  113. package/dist/dts/Query.d.ts.map +0 -1
  114. package/dist/dts/SubscribeMachine.d.ts.map +0 -1
  115. package/dist/dts/retryOnConflict.d.ts.map +0 -1
  116. /package/dist/{dts → dts-cjs}/errors.d.ts +0 -0
  117. /package/dist/{dts → dts-cjs}/errors.d.ts.map +0 -0
  118. /package/dist/{dts → dts-cjs}/inMemory.d.ts +0 -0
  119. /package/dist/{dts → dts-cjs}/index.d.ts.map +0 -0
  120. /package/dist/{dts → dts-cjs}/testing.d.ts.map +0 -0
package/dist/esm/Event.js CHANGED
@@ -6,17 +6,34 @@
6
6
  * payloads into these bytes. Ordering is by `position` alone; `occurredAt` is
7
7
  * producer-supplied domain time and is informational only.
8
8
  */
9
- import { Schema } from 'effect';
9
+ import { BigInt as BigInt_, Effect, Option, Schema, SchemaIssue, SchemaTransformation } from 'effect';
10
10
  /**
11
11
  * A position in the single global event log: a branded, non-negative `bigint`.
12
12
  *
13
13
  * The log is 64-bit (`bigserial` in Postgres) and exceeds JS `number` safety at
14
14
  * 2^53, so positions are a `bigint`. They are compared, never arithmetic'd.
15
- * `Schema.BigInt` encodes to a decimal string (JSON-safe) and decodes to
15
+ * Encoded, a position is a decimal string (JSON-safe, `String(b)`); decoded, a
16
16
  * `bigint`. `0n` is the "before the first event" sentinel used by `after` and by
17
17
  * an empty store's head.
18
+ *
19
+ * The string-to-`bigint` step is hand-built rather than Effect 4's
20
+ * `Schema.BigIntFromString`, because that schema accepts only `^-?\d+$` and so
21
+ * refuses inputs the encoded side has always admitted — `" 5"`, `"+5"`,
22
+ * `"0x10"`. The decode here is the global `BigInt(s)` behind a blank-string
23
+ * refusal, which is `BigInt.fromString` and is exactly what Effect 3's
24
+ * `Schema.BigInt` ran, so a position string any earlier release decoded still
25
+ * decodes to the same value. The non-negative check then runs on the `bigint`,
26
+ * as it always did.
18
27
  */
19
- export const Position = /*#__PURE__*/Schema.BigInt.pipe(/*#__PURE__*/Schema.nonNegativeBigInt(), /*#__PURE__*/Schema.brand('Position'));
28
+ export const Position = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.decodeTo(Schema.BigInt, /*#__PURE__*/SchemaTransformation.transformEffect({
29
+ decode: (s, options) => Option.match(BigInt_.fromString(s), {
30
+ onNone: () => Effect.fail(new SchemaIssue.InvalidValue({
31
+ message: `Unable to decode ${JSON.stringify(s)} into a bigint`
32
+ }, s, options)),
33
+ onSome: Effect.succeed
34
+ }),
35
+ encode: b => Effect.succeed(String(b))
36
+ })), /*#__PURE__*/Schema.check(/*#__PURE__*/Schema.isGreaterThanOrEqualToBigInt(0n)), /*#__PURE__*/Schema.brand('Position'));
20
37
  /** The sentinel position meaning "before the first event". */
21
38
  export const ORIGIN = /*#__PURE__*/Position.make(0n);
22
39
  /**
@@ -25,9 +42,9 @@ export const ORIGIN = /*#__PURE__*/Position.make(0n);
25
42
  * event sourcing; a query matches an event when the event carries all of an
26
43
  * item's tags (superset test).
27
44
  */
28
- export const Tag = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.pattern(/^[^:]+:.+/, {
45
+ export const Tag = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.check(/*#__PURE__*/Schema.isPattern(/^[^:]+:.+/, {
29
46
  identifier: 'Tag'
30
- }), /*#__PURE__*/Schema.brand('Tag'));
47
+ })), /*#__PURE__*/Schema.brand('Tag'));
31
48
  export const tagIdentity = key => {
32
49
  if (key.length === 0 || key.includes(':')) {
33
50
  throw new Error(`tagIdentity: key must be non-empty and contain no ':' (got ${JSON.stringify(key)})`);
@@ -52,26 +69,85 @@ export const tagIdentity = key => {
52
69
  * error channel (`read` keeps `E = never`). Constructed at call sites with
53
70
  * `ReadLimit.make(n)`.
54
71
  */
55
- export const ReadLimit = /*#__PURE__*/Schema.Int.pipe(/*#__PURE__*/Schema.greaterThanOrEqualTo(0), /*#__PURE__*/Schema.brand('ReadLimit'));
72
+ export const ReadLimit = /*#__PURE__*/Schema.Int.pipe(/*#__PURE__*/Schema.check(/*#__PURE__*/Schema.isGreaterThanOrEqualTo(0)), /*#__PURE__*/Schema.brand('ReadLimit'));
56
73
  /**
57
74
  * An event type name, a branded non-empty string. Versioning is by convention
58
75
  * in the name (e.g. `course-registered.v2`); only non-emptiness is enforced.
59
76
  */
60
- export const EventType = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.nonEmptyString(), /*#__PURE__*/Schema.brand('EventType'));
77
+ export const EventType = /*#__PURE__*/Schema.String.pipe(/*#__PURE__*/Schema.check(/*#__PURE__*/Schema.isNonEmpty()), /*#__PURE__*/Schema.brand('EventType'));
78
+ /**
79
+ * An event's metadata: a flat bag of strings carrying the circumstances under
80
+ * which the event was RECORDED, never anything the business asserts (ADR-0017).
81
+ * Payload is what happened; metadata is the context of the recording — a
82
+ * `traceparent`, a correlation or causation id, a deployment revision.
83
+ *
84
+ * Values are strings, not `unknown`, for cross-engine parity rather than taste:
85
+ * both SQL engines carry the bag as a JSON document, and `JSON.stringify` drops
86
+ * `undefined`, throws on `bigint` and turns `NaN` into `null`, none of which the
87
+ * in-memory oracle does.
88
+ *
89
+ * The key schema carries no refinement, deliberately: a refinement on a
90
+ * `Schema.Record` key acts as a FILTER on decode, silently dropping a key that
91
+ * fails it rather than failing the decode. Constraining keys, if ever wanted,
92
+ * has to be a validating step of its own.
93
+ *
94
+ * Two engine limits a consumer must know, because the bag is typically filled
95
+ * from outside the application at a request edge. Postgres refuses a NUL
96
+ * character (U+0000) and an unpaired surrogate in any string it stores, so an
97
+ * event whose bag holds one fails to append there while the in-memory and
98
+ * SQLite engines accept it; sanitise untrusted values before they reach the
99
+ * bag. And key ORDER is not preserved: Postgres stores an object's keys in an
100
+ * order of its own, so compare bags as unordered and never rely on the order
101
+ * `Object.keys` returns.
102
+ *
103
+ * Metadata is never part of a `Query` or an `AppendCondition` — a store refuses
104
+ * either when it carries a key the grammar does not define, so a metadata
105
+ * predicate cannot be written and silently ignored — never reaches a codec's
106
+ * `tagsFor`, and no store offers a way to rewrite it once appended. ADR-0017
107
+ * owns why each of those is mechanical rather than preferential.
108
+ *
109
+ * ## The one home of the shape rule
110
+ *
111
+ * The bag is a JSON OBJECT whose every value is a STRING, and this schema is
112
+ * where that rule is stated. At runtime it is checked in ONE place, at write: the
113
+ * codec's `toEvent` decodes every bag through this schema and refuses one that
114
+ * fails on its own error channel, so a value smuggled past the type (through an
115
+ * `any`) stops there. The schema judges a bag's OWN enumerable keys, so an object
116
+ * that keeps its entries anywhere else — a `Map`, a `Date` — reads as the empty
117
+ * bag rather than failing. A store checks no values: an event built by hand and handed
118
+ * to `append` directly carries whatever it carries, and what each engine then does
119
+ * with a non-string value differs — one may store it and read it back differently
120
+ * from another, and a `bigint` makes a SQL engine's append fail. Each
121
+ * SQL engine keeps a container check of its own on read — the column must hold a
122
+ * JSON object — because that defends against a writer outside the library and is
123
+ * about the column, not the values. A VALUE check must never be added on read
124
+ * alone: it would make an event the store accepted unreadable for ever, so a
125
+ * value check belongs at write or nowhere.
126
+ */
127
+ export const Metadata = /*#__PURE__*/Schema.Record(Schema.String, Schema.String);
61
128
  /**
62
129
  * An event as stored: an opaque payload plus its type, tags, a
63
- * producer-supplied `uuid`, and producer-supplied `occurredAt` domain time.
130
+ * producer-supplied `uuid`, producer-supplied `occurredAt` domain time, and its
131
+ * `metadata` bag.
64
132
  *
65
133
  * `data` is `Uint8Array` (opaque bytes); the store does not interpret it.
66
134
  * `uuid` is producer-supplied to keep `core` deterministic (no RNG in core).
135
+ * It is checked for UUID SHAPE only (`isGUID`), not for a version nibble: a
136
+ * stricter check would refuse ids an existing log already holds.
67
137
  * `occurredAt` is informational only; ordering is by position alone.
138
+ * `metadata` mirrors `tags` rather than `data`: REQUIRED, with an empty bag
139
+ * legal. Required because an absent-versus-empty divergence between engines is
140
+ * invisible to `toEqual`, which ignores `undefined` properties, so an optional
141
+ * field could drift across the three engines with the round-trip suite green.
142
+ * Core only carries it; the codec's `toEvent` is where it is resolved.
68
143
  */
69
144
  export const DcbEvent = /*#__PURE__*/Schema.Struct({
70
145
  type: EventType,
71
- data: Schema.Uint8ArrayFromSelf,
146
+ data: Schema.Uint8Array,
72
147
  tags: /*#__PURE__*/Schema.Array(Tag),
73
- uuid: Schema.UUID,
74
- occurredAt: Schema.DateTimeUtc
148
+ uuid: /*#__PURE__*/Schema.String.check(/*#__PURE__*/Schema.isGUID()),
149
+ occurredAt: Schema.DateTimeUtcFromString,
150
+ metadata: Metadata
75
151
  });
76
152
  /** A persisted event: the event together with the position it was written at. */
77
153
  export const SequencedEvent = /*#__PURE__*/Schema.Struct({
@@ -1 +1 @@
1
- {"version":3,"file":"Event.js","names":["Schema","Position","BigInt","pipe","nonNegativeBigInt","brand","ORIGIN","make","Tag","String","pattern","identifier","tagIdentity","key","length","includes","Error","JSON","stringify","value","ReadLimit","Int","greaterThanOrEqualTo","EventType","nonEmptyString","DcbEvent","Struct","type","data","Uint8ArrayFromSelf","tags","Array","uuid","UUID","occurredAt","DateTimeUtc","SequencedEvent","event","position"],"sources":["../../src/Event.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,SAASA,MAAM,QAAQ,QAAQ;AAE/B;;;;;;;;;AASA,OAAO,MAAMC,QAAQ,gBAAGD,MAAM,CAACE,MAAM,CAACC,IAAI,cACxCH,MAAM,CAACI,iBAAiB,EAAE,eAC1BJ,MAAM,CAACK,KAAK,CAAC,UAAU,CAAC,CACzB;AAGD;AACA,OAAO,MAAMC,MAAM,gBAAaL,QAAQ,CAACM,IAAI,CAAC,EAAE,CAAC;AAEjD;;;;;;AAMA,OAAO,MAAMC,GAAG,gBAAGR,MAAM,CAACS,MAAM,CAACN,IAAI,cACnCH,MAAM,CAACU,OAAO,CAAC,WAAW,EAAE;EAAEC,UAAU,EAAE;AA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;EACvBwB,IAAI,EAAEhC,MAAM,CAACiC,IAAI;EACjBC,UAAU,EAAElC,MAAM,CAACmC;CACpB,CAAC;AAGF;AACA,OAAO,MAAMC,cAAc,gBAAGpC,MAAM,CAAC0B,MAAM,CAAC;EAC1CW,KAAK,EAAEZ,QAAQ;EACfa,QAAQ,EAAErC;CACX,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Event.js","names":["BigInt","BigInt_","Effect","Option","Schema","SchemaIssue","SchemaTransformation","Position","String","pipe","decodeTo","transformEffect","decode","s","options","match","fromString","onNone","fail","InvalidValue","message","JSON","stringify","onSome","succeed","encode","b","check","isGreaterThanOrEqualToBigInt","brand","ORIGIN","make","Tag","isPattern","identifier","tagIdentity","key","length","includes","Error","value","ReadLimit","Int","isGreaterThanOrEqualTo","EventType","isNonEmpty","Metadata","Record","DcbEvent","Struct","type","data","Uint8Array","tags","Array","uuid","isGUID","occurredAt","DateTimeUtcFromString","metadata","SequencedEvent","event","position"],"sources":["../../src/Event.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,SACEA,MAAM,IAAIC,OAAO,EACjBC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,WAAW,EACXC,oBAAoB,QACf,QAAQ;AAEf;;;;;;;;;;;;;;;;;;AAkBA,OAAO,MAAMC,QAAQ,gBAAGH,MAAM,CAACI,MAAM,CAACC,IAAI,cACxCL,MAAM,CAACM,QAAQ,CACbN,MAAM,CAACJ,MAAM,eACbM,oBAAoB,CAACK,eAAe,CAAiB;EACnDC,MAAM,EAAEA,CAACC,CAAC,EAAEC,OAAO,KACjBX,MAAM,CAACY,KAAK,CAACd,OAAO,CAACe,UAAU,CAACH,CAAC,CAAC,EAAE;IAClCI,MAAM,EAAEA,CAAA,KACNf,MAAM,CAACgB,IAAI,CACT,IAAIb,WAAW,CAACc,YAAY,CAC1B;MACEC,OAAO,EAAE,oBAAoBC,IAAI,CAACC,SAAS,CAACT,CAAC,CAAC;KAC/C,EACDA,CA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,CAAC;AAED;;;;;;;;;;AAUA,OAAO,MAAMC,SAAS,gBAAGrC,MAAM,CAACsC,GAAG,CAACjC,IAAI,cACtCL,MAAM,CAACuB,KAAK,cAACvB,MAAM,CAACuC,sBAAsB,CAAC,CAAC,CAAC,CAAC,eAC9CvC,MAAM,CAACyB,KAAK,CAAC,WAAW,CAAC,CAC1B;AAGD;;;;AAIA,OAAO,MAAMe,SAAS,gBAAGxC,MAAM,CAACI,MAAM,CAACC,IAAI,cACzCL,MAAM,CAACuB,KAAK,cAACvB,MAAM,CAACyC,UAAU,EAAE,CAAC,eACjCzC,MAAM,CAACyB,KAAK,CAAC,WAAW,CAAC,CAC1B;AAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,OAAO,MAAMiB,QAAQ,gBAAG1C,MAAM,CAAC2C,MAAM,CAAC3C,MAAM,CAACI,MAAM,EAAEJ,MAAM,CAACI,MAAM,CAAC;AAGnE;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMwC,QAAQ,gBAAG5C,MAAM,CAAC6C,MAAM,CAAC;EACpCC,IAAI,EAAEN,SAAS;EACfO,IAAI,EAAE/C,MAAM,CAACgD,UAAU;EACvBC,IAAI,eAAEjD,MAAM,CAACkD,KAAK,CAACtB,GAAG,CAAC;EACvBuB,IAAI,eAAEnD,MAAM,CAACI,MAAM,CAACmB,KAAK,cAACvB,MAAM,CAACoD,MAAM,EAAE,CAAC;EAC1CC,UAAU,EAAErD,MAAM,CAACsD,qBAAqB;EACxCC,QAAQ,EAAEb;CACX,CAAC;AAGF;AACA,OAAO,MAAMc,cAAc,gBAAGxD,MAAM,CAAC6C,MAAM,CAAC;EAC1CY,KAAK,EAAEb,QAAQ;EACfc,QAAQ,EAAEvD;CACX,CAAC","ignoreList":[]}
@@ -18,15 +18,21 @@ export const AnyProjection = {
18
18
  */
19
19
  of: projection => projection
20
20
  };
21
- /** Merge two queries by OR-ing their items; either wildcard yields a wildcard. */
22
- const mergeQuery = (left, right) => {
23
- if (left.items.length === 0 || right.items.length === 0) {
24
- return WILDCARD;
25
- }
26
- return {
27
- items: [...left.items, ...right.items]
28
- };
29
- };
21
+ /**
22
+ * Merge two queries by OR-ing their items; either wildcard yields a wildcard.
23
+ *
24
+ * Every other key on either envelope is carried into the result. The grammar's
25
+ * envelope has no key but `items`, so anything else is a key the store boundary
26
+ * refuses (`servableQueryFault`); a merge that rebuilt the envelope from `items`
27
+ * alone would drop that key before the boundary saw it, and a slice composed with
28
+ * another would then have its smuggled predicate ignored in silence — the outcome
29
+ * the refusal exists to prevent.
30
+ */
31
+ const mergeQuery = (left, right) => ({
32
+ ...left,
33
+ ...right,
34
+ items: left.items.length === 0 || right.items.length === 0 ? WILDCARD.items : [...left.items, ...right.items]
35
+ });
30
36
  /**
31
37
  * OR-merge a list of queries into one. The empty list is the wildcard.
32
38
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Projection.js","names":["matchesSequenced","WILDCARD","items","AnyProjection","of","projection","mergeQuery","left","right","length","unionQueries","queries","reduce","acc","q","composeProjections","projections","keys","Object","initialState","fromEntries","map","key","mergedQuery","query","evolve","state","decoded","next","sequenced"],"sources":["../../src/Projection.ts"],"sourcesContent":[null],"mappings":"AA4BA,SAASA,gBAAgB,QAAQ,YAAS;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAU;EAAEC,KAAK,EAAE;AAAE,CAAE;AAqDrC,OAAO,MAAMC,aAAa,GAAG;EAC3B;;;;;;;EAOAC,EAAE,EAAMC,UAAyB,IAC/BA;CACM;AAaV;AACA,MAAMC,UAAU,GAAGA,CAACC,IAAW,EAAEC,KAAY,KAAW;EACtD,IAAID,IAAI,CAACL,KAAK,CAACO,MAAM,KAAK,CAAC,IAAID,KAAK,CAACN,KAAK,CAACO,MAAM,KAAK,CAAC,EAAE;IACvD,OAAOR,QAAQ;EACjB;EACA,OAAO;IAAEC,KAAK,EAAE,CAAC,GAAGK,IAAI,CAACL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":3,"file":"Projection.js","names":["matchesSequenced","WILDCARD","items","AnyProjection","of","projection","mergeQuery","left","right","length","unionQueries","queries","reduce","acc","q","composeProjections","projections","keys","Object","initialState","fromEntries","map","key","mergedQuery","query","evolve","state","decoded","next","sequenced"],"sources":["../../src/Projection.ts"],"sourcesContent":[null],"mappings":"AA4BA,SAASA,gBAAgB,QAAQ,YAAS;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAU;EAAEC,KAAK,EAAE;AAAE,CAAE;AAqDrC,OAAO,MAAMC,aAAa,GAAG;EAC3B;;;;;;;EAOAC,EAAE,EAAMC,UAAyB,IAC/BA;CACM;AAaV;;;;;;;;;;AAUA,MAAMC,UAAU,GAAGA,CAACC,IAAW,EAAEC,KAAY,MAAa;EACxD,GAAGD,IAAI;EACP,GAAGC,KAAK;EACRN,KAAK,EACHK,IAAI,CAACL,KAAK,CAACO,MAAM,KAAK,CAAC,IAAID,KAAK,CAACN,KAAK,CAACO,MAAM,KAAK,CAAC,GAC/CR,QAAQ,CAACC,KAAK,GACd,CAAC,GAAGK,IAAI,CAACL,KAAK,EAAE,GAAGM,KAAK,CAACN,KAAK;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;AAeA,OAAO,MAAMQ,YAAY,GAAIC,OAA6B,IACxDA,OAAO,CAACF,MAAM,KAAK,CAAC,GAChBR,QAAQ,GACRU,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,KAAKR,UAAU,CAACO,GAAG,EAAEC,CAAC,CAAC,CAAC;AAEpD;;;;;;;;;;;AAWA,OAAO,MAAMC,kBAAkB,GAC7BC,WAAc,IACmB;EACjC,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,WAAW,CAAoC;EAExE,MAAMG,YAAY,GAAGD,MAAM,CAACE,WAAW,CACrCH,IAAI,CAACI,GAAG,CAAEC,GAAG,IAAK,CAACA,GAAG,EAAEN,WAAW,CAACM,GAAG,CAAC,CAACH,YAAY,CAAC,CAAC,CACnC;EAEtB,MAAMI,WAAW,GAAGb,YAAY,CAACO,IAAI,CAACI,GAAG,CAAEC,GAAG,IAAKN,WAAW,CAACM,GAAG,CAAC,CAACE,KAAK,CAAC,CAAC;EAE3E,OAAO;IACLL,YAAY;IACZK,KAAK,EAAED,WAAW;IAClBE,MAAM,EAAEA,CAACC,KAAK,EAAEC,OAAO,KAAI;MACzB,MAAMC,IAAI,GAAG;QAAE,GAAGF;MAAK,CAAuC;MAC9D,KAAK,MAAMJ,GAAG,IAAIL,IAAI,EAAE;QACtB,MAAMZ,UAAU,GAAGW,WAAW,CAACM,GAAG,CAAC;QACnC,IAAI,CAACtB,gBAAgB,CAAC2B,OAAO,CAACE,SAAS,EAAExB,UAAU,CAACmB,KAAK,CAAC,EAAE;UAC1D;QACF;QACAI,IAAI,CAACN,GAAG,CAAC,GAAGjB,UAAU,CAACoB,MAAM,CAACC,KAAK,CAACJ,GAAG,CAAC,EAAEK,OAAO,CAEhD;MACH;MACA,OAAOC,IAAI;IACb;GACD;AACH,CAAC","ignoreList":[]}
package/dist/esm/Query.js CHANGED
@@ -68,6 +68,9 @@ export const matchesSequenced = (sequenced, query) => matchesQuery(sequenced.eve
68
68
  * (`Query.ts` module docs) but which plain-data assembly — e.g. decision-model
69
69
  * composition, `Projection.ts:31-36` — can still bypass.
70
70
  *
71
+ * A query, or any of its items, carrying a key the grammar does not define is
72
+ * refused before anything else is judged (`unknownKeyFault` below says why).
73
+ *
71
74
  * The servable grammar is exactly one of:
72
75
  * - the wildcard (`items.length === 0`), which matches every event;
73
76
  * - a *single* item (`items.length === 1`), any types/tags, including a
@@ -93,6 +96,54 @@ export const assertServableQuery = query => {
93
96
  throw new Error(fault);
94
97
  }
95
98
  };
99
+ /**
100
+ * The refusal of a key `schemaFields` does not define, or `undefined` when `value`
101
+ * carries none. `where` names the level for the message.
102
+ *
103
+ * ## Why an unknown key is refused rather than ignored
104
+ *
105
+ * A `Query` is plain data, so nothing at runtime stops a caller adding a key the
106
+ * grammar does not have — a `metadata` predicate on an item is the one this repo
107
+ * expects, since metadata is the field an author most plausibly wants to filter on
108
+ * and must not (ADR-0017). Ignored, that key is a predicate the author believes they
109
+ * wrote and no engine honours, and on the append side it is worse: the Postgres
110
+ * guard embeds its match as literal plpgsql text that no type reaches, so a key a
111
+ * read path one day learned to honour would still be dropped by the guard, and the
112
+ * optimistic-concurrency check would escape in silence. Refusing every key the
113
+ * grammar does not define closes that route — a SMUGGLED key — at the one boundary
114
+ * every engine shares, before any engine could disagree. "Every key" means every
115
+ * key `Object.keys` returns: an own, enumerable, string key, which is what a plain
116
+ * object literal or a spread builds. A symbol key, a non-enumerable key or an
117
+ * inherited one is not judged, and no engine reads one either. Core's own query
118
+ * merge (`unionQueries`, `composeProjections`) carries an envelope's unknown key
119
+ * into the merged query rather than dropping it, so composing slices cannot launder
120
+ * a smuggled key past this check.
121
+ *
122
+ * It does not close the neighbouring one, and cannot: a field ADDED to the grammar's
123
+ * schema is a known key from that edit on and passes here, while the plpgsql guard
124
+ * still has to be taught it by hand. That exposure is the Postgres guard's, and its
125
+ * own comment in that engine's DDL says so.
126
+ *
127
+ * The known keys are read off the SCHEMA's own `fields` rather than listed here, so
128
+ * a field added to the grammar is admitted by the same edit that adds it. Only key
129
+ * NAMES are judged: an exact-optional key written as `undefined` is a known key and
130
+ * passes, because which values a key admits is the type's business, not this rule's.
131
+ */
132
+ const unknownKeyFault = (where, value, schemaFields) => {
133
+ const unknown = Object.keys(value).find(key => !Object.hasOwn(schemaFields, key));
134
+ return unknown === undefined ? undefined : `assertServableQuery: ${where} carries the key ${JSON.stringify(unknown)}, which ` + 'the query grammar does not define; an unknown key would be silently ignored ' + 'by every engine rather than honoured, so it is refused';
135
+ };
136
+ /**
137
+ * The unknown-key half of `servableQueryFault`, on its own: the refusal of a key the
138
+ * grammar does not define on the envelope or on any item, or `undefined`.
139
+ *
140
+ * It is the same rule and not a second statement of it — `servableQueryFault` calls
141
+ * this first. It is exported because ONE caller has to tell the two halves apart:
142
+ * the codec's read ledger refuses an unservable SHAPE on its own error channel, and
143
+ * must not report an unknown key as one. An unknown key is not something a slice's
144
+ * tags can fix, so the ledger leaves it to the store, which refuses it as a defect.
145
+ */
146
+ export const unknownQueryKeyFault = query => unknownKeyFault('a query', query, Query.fields) ?? query.items.reduce((fault, item) => fault ?? unknownKeyFault('a query item', item, QueryItem.fields), undefined);
96
147
  /**
97
148
  * The servable grammar as a TOTAL function: the reason `query` cannot be served,
98
149
  * or `undefined` when it can.
@@ -114,6 +165,10 @@ export const assertServableQuery = query => {
114
165
  * reason), so a fault is one exit route and one return type.
115
166
  */
116
167
  export const servableQueryFault = query => {
168
+ const unknownKey = unknownQueryKeyFault(query);
169
+ if (unknownKey !== undefined) {
170
+ return unknownKey;
171
+ }
117
172
  const {
118
173
  items
119
174
  } = query;
@@ -170,7 +225,7 @@ export const classifyServableQuery = query => {
170
225
  }
171
226
  const only = query.items.length === 1 ? query.items[0] : undefined;
172
227
  if (only !== undefined && only.tags.length === 0) {
173
- return Arr.isNonEmptyReadonlyArray(only.types) ? {
228
+ return Arr.isReadonlyArrayNonEmpty(only.types) ? {
174
229
  kind: 'typeOnly',
175
230
  types: only.types
176
231
  } : {
@@ -1 +1 @@
1
- {"version":3,"file":"Query.js","names":["Array","Arr","Schema","EventType","Tag","QueryItem","Struct","types","tags","Query","items","matchesQueryItem","event","item","typeOk","length","includes","type","eventTags","Set","every","tag","has","matchesQuery","query","some","matchesSequenced","sequenced","assertServableQuery","fault","servableQueryFault","undefined","Error","classifyServableQuery","kind","only","isNonEmptyReadonlyArray","fields","all","or"],"sources":["../../src/Query.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAASA,KAAK,IAAIC,GAAG,EAAEC,MAAM,QAAQ,QAAQ;AAC7C,SAAwBC,SAAS,EAAuBC,GAAG,QAAQ,YAAS;AAE5E;;;;AAIA,OAAO,MAAMC,SAAS,gBAAGH,MAAM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I,GAAIwB,MAGb,KAAiB;EAChB9B,KAAK,EAAE8B,MAAM,CAAC9B,KAAK,IAAI,EAAE;EACzBC,IAAI,EAAE6B,MAAM,CAAC7B;CACd,CAAC;AAEF;AACA,MAAM8B,GAAG,GAAGA,CAAA,MAAc;EAAE5B,KAAK,EAAE;AAAE,CAAE,CAAC;AAExC;;;;AAIA,MAAMF,IAAI,GAAGA,CACXA,IAA2C,EAC3CD,KAAgC,MACrB;EACXG,KAAK,EAAE,CAACG,IAAI,CAAC;IAAEL,IAAI;IAAE,IAAID,KAAK,KAAKwB,SAAS,GAAG,EAAE,GAAG;MAAExB;IAAK,CAAE;EAAC,CAAE,CAAC;CAClE,CAAC;AAEF;;;;;AAKA,MAAMA,KAAK,GACTA,KAAwD,KAC7C;EAAEG,KAAK,EAAE,CAAC;IAAEH,KAAK;IAAEC,IAAI,EAAE;EAAE,CAAE;AAAC,CAAE,CAAC;AAE9C;;;;;AAKA,MAAM+B,EAAE,GACN7B,KAAwD,KAC7C;EACXA;CACD,CAAC;AAEF;AACA,OAAO,MAAMc,KAAK,GAAG;EACnBc,GAAG;EACHzB,IAAI;EACJ0B,EAAE;EACF/B,IAAI;EACJD;CACQ","ignoreList":[]}
1
+ {"version":3,"file":"Query.js","names":["Array","Arr","Schema","EventType","Tag","QueryItem","Struct","types","tags","Query","items","matchesQueryItem","event","item","typeOk","length","includes","type","eventTags","Set","every","tag","has","matchesQuery","query","some","matchesSequenced","sequenced","assertServableQuery","fault","servableQueryFault","undefined","Error","unknownKeyFault","where","value","schemaFields","unknown","Object","keys","find","key","hasOwn","JSON","stringify","unknownQueryKeyFault","fields","reduce","unknownKey","classifyServableQuery","kind","only","isReadonlyArrayNonEmpty","all","or"],"sources":["../../src/Query.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAASA,KAAK,IAAIC,GAAG,EAAEC,MAAM,QAAQ,QAAQ;AAC7C,SAAwBC,SAAS,EAAuBC,GAAG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AAE,CAACG,IAAI,CAAC;IAAEL,IAAI;IAAE,IAAID,KAAK,KAAKwB,SAAS,GAAG,EAAE,GAAG;MAAExB;IAAK,CAAE;EAAC,CAAE,CAAC;CAClE,CAAC;AAEF;;;;;AAKA,MAAMA,KAAK,GACTA,KAAwD,KAC7C;EAAEG,KAAK,EAAE,CAAC;IAAEH,KAAK;IAAEC,IAAI,EAAE;EAAE,CAAE;AAAC,CAAE,CAAC;AAE9C;;;;;AAKA,MAAM8C,EAAE,GACN5C,KAAwD,KAC7C;EACXA;CACD,CAAC;AAEF;AACA,OAAO,MAAMc,KAAK,GAAG;EACnB6B,GAAG;EACHxC,IAAI;EACJyC,EAAE;EACF9C,IAAI;EACJD;CACQ","ignoreList":[]}
@@ -68,7 +68,7 @@
68
68
  * memory alone, and it lands hardest on the durable-log-with-in-memory-view mode,
69
69
  * where an ephemeral view re-catches-up the entire log on every boot.
70
70
  */
71
- import { Chunk, Effect, Option, Queue, Schedule, Schema, Stream } from 'effect';
71
+ import { Effect, Option, Queue, Schedule, Schema, Stream } from 'effect';
72
72
  import { ORIGIN, ReadLimit } from "./Event.js";
73
73
  /**
74
74
  * A short catch-up page size default for the reconcile loop. Reads page by page
@@ -107,12 +107,12 @@ export const DEFAULT_POLL_INTERVAL_MILLIS = 1000;
107
107
  * the key NAME, the VALIDATION and the DEFAULT from one place, so a caller who has
108
108
  * tuned one engine's subscribe reads another's without translating, and the two
109
109
  * cannot drift in what they ACCEPT any more than in what they assume. Two engines
110
- * hand-authoring the identical `Schema.optionalWith(…)` twice were identical only
110
+ * hand-authoring the identical `Schema.optionalKey(…)` twice were identical only
111
111
  * by inspection.
112
112
  *
113
113
  * The bounds differ between the two because the quantities do. `pollInterval` is a
114
- * duration, so a fraction of a millisecond is meaningful and only `positive` and
115
- * `finite` matter: at zero or below the loop would spin without ever waiting for a
114
+ * duration, so a fraction of a millisecond is meaningful and only `isGreaterThan(0)`
115
+ * and `isFinite` matter: at zero or below the loop would spin without ever waiting for a
116
116
  * wake, and at `Infinity` the periodic re-read — the half that carries delivery —
117
117
  * would never come, which silently converts the wake source from an optimisation
118
118
  * into the guarantee. `catchUpPageSize` is a COUNT, so it must be an integer
@@ -120,17 +120,13 @@ export const DEFAULT_POLL_INTERVAL_MILLIS = 1000;
120
120
  * length against it to decide the tail is drained, and a page of zero would report
121
121
  * "drained" forever without reading anything.
122
122
  *
123
- * `exact: true` on both keeps the decoded type at `key?: T` rather than
123
+ * `optionalKey` on both keeps the decoded type at `key?: T` rather than
124
124
  * `T | undefined`, matching the repo's `exactOptionalPropertyTypes` discipline — an
125
125
  * absent key, never an explicit `undefined`.
126
126
  */
127
127
  export const subscriptionTuningFields = {
128
- pollInterval: /*#__PURE__*/Schema.optionalWith(/*#__PURE__*/Schema.Number.pipe(/*#__PURE__*/Schema.positive(), /*#__PURE__*/Schema.finite()), {
129
- exact: true
130
- }),
131
- catchUpPageSize: /*#__PURE__*/Schema.optionalWith(/*#__PURE__*/Schema.Int.pipe(/*#__PURE__*/Schema.positive()), {
132
- exact: true
133
- })
128
+ pollInterval: /*#__PURE__*/Schema.optionalKey(/*#__PURE__*/Schema.Number.check(/*#__PURE__*/Schema.isGreaterThan(0), /*#__PURE__*/Schema.isFinite())),
129
+ catchUpPageSize: /*#__PURE__*/Schema.optionalKey(/*#__PURE__*/Schema.Int.check(/*#__PURE__*/Schema.isGreaterThan(0)))
134
130
  };
135
131
  /**
136
132
  * Retry a TRANSIENT poll fault (an `E` from one reconcile read) on a capped
@@ -139,16 +135,16 @@ export const subscriptionTuningFields = {
139
135
  * past the cap propagates (the decorator dies it) — infrastructure stays off the
140
136
  * contract channel while the stream survives ordinary transients.
141
137
  */
142
- const POLL_RETRY_SCHEDULE = /*#__PURE__*/Schedule.exponential('100 millis', 2).pipe(/*#__PURE__*/Schedule.union(/*#__PURE__*/Schedule.spaced('2 seconds')), /*#__PURE__*/Schedule.intersect(/*#__PURE__*/Schedule.recurs(20)));
138
+ const POLL_RETRY_SCHEDULE = /*#__PURE__*/Schedule.max([/*#__PURE__*/Schedule.min([/*#__PURE__*/Schedule.exponential('100 millis', 2), /*#__PURE__*/Schedule.spaced('2 seconds')]), /*#__PURE__*/Schedule.recurs(20)]);
143
139
  /**
144
140
  * Build the subscription `Stream`: catch up from `after`, then track the live tail.
145
- * The cursor threads through the `unfoldChunkEffect` unfold state, starting at
146
- * `after` and advancing to the last delivered position each batch; the stream never
147
- * completes on its own (always `Option.some`), so the enclosing scope interrupts it
148
- * on close. An `E` mid-stream stays on the channel; `makeContractStore` dies it
141
+ * The cursor threads through the `Stream.paginate` state, starting at `after` and
142
+ * advancing to the last delivered position each batch; the stream never completes
143
+ * on its own (the next state is always `Option.some`), so the enclosing scope
144
+ * interrupts it on close. An `E` mid-stream stays on the channel; `makeContractStore` dies it
149
145
  * (subscribe is `E = never` on the contract).
150
146
  */
151
- export const subscribeStream = (deps, after) => Stream.unwrapScoped(Effect.gen(function* () {
147
+ export const subscribeStream = (deps, after) => Stream.unwrap(Effect.gen(function* () {
152
148
  // The wake primitive: a sliding(1) queue holding at most one pending
153
149
  // signal. The wake source `offer`s an opaque wake on every notification;
154
150
  // the poll loop `take`s (with a timeout). The lost-wakeup guard is
@@ -164,7 +160,7 @@ export const subscribeStream = (deps, after) => Stream.unwrapScoped(Effect.gen(f
164
160
  // silently-dropped (and later re-established) wake source loses no
165
161
  // positions. Absent a wake source entirely, `Stream.never` makes this a
166
162
  // fibre that parks forever and delivery falls to the poll alone.
167
- const listener = (deps.listen ?? Stream.never).pipe(Stream.tap(() => Queue.offer(wake, undefined)), Stream.retry(Schedule.exponential('50 millis').pipe(Schedule.union(Schedule.spaced('1 seconds')))));
163
+ const listener = (deps.listen ?? Stream.never).pipe(Stream.tap(() => Queue.offer(wake, undefined)), Stream.retry(Schedule.min([Schedule.exponential('50 millis'), Schedule.spaced('1 seconds')])));
168
164
  // Drain the wake source into the wake queue on a background fibre; the
169
165
  // scope releases it. We never read its elements directly — every
170
166
  // notification is an opaque wake signal.
@@ -196,7 +192,7 @@ export const subscribeStream = (deps, after) => Stream.unwrapScoped(Effect.gen(f
196
192
  }).pipe(Effect.retry(POLL_RETRY_SCHEDULE));
197
193
  /**
198
194
  * Produce the NEXT non-empty batch from a cursor position, together with
199
- * the advanced cursor — a pure `Position → Effect<[Chunk, next]>`. The
195
+ * the advanced cursor — a pure `Position → Effect<[events, next]>`. The
200
196
  * `> boundary` de-dup is enforced by `fetch`'s exclusive lower bound, so a
201
197
  * live re-read after a wake never re-emits an already-delivered position.
202
198
  *
@@ -204,24 +200,26 @@ export const subscribeStream = (deps, after) => Stream.unwrapScoped(Effect.gen(f
204
200
  * the cursor. If a drain yields nothing, wait for a wake but only up to the
205
201
  * poll interval, then loop and re-read ANYWAY — the periodic position-based
206
202
  * poll that makes delivery correct independently of any wake. This effect
207
- * only completes by returning a non-empty chunk; the scope interrupts it on
203
+ * only completes by returning a non-empty batch; the scope interrupts it on
208
204
  * close.
209
205
  */
210
206
  const nextBatch = from => Effect.gen(function* () {
211
207
  while (true) {
212
- yield* Queue.takeAll(wake);
208
+ // `Queue.clear` and not `Queue.takeAll`: the drain must NOT wait, and
209
+ // `takeAll` suspends until at least one signal is present.
210
+ yield* Queue.clear(wake);
213
211
  const {
214
212
  events,
215
213
  last
216
214
  } = yield* drainFrom(from);
217
215
  if (events.length > 0) {
218
- return [Chunk.fromIterable(events), last];
216
+ return [events, last];
219
217
  }
220
218
  // Nothing new: block on a wake, but only up to the poll interval — on
221
219
  // timeout we fall through and the loop re-reads regardless.
222
220
  yield* Effect.ignore(Effect.timeout(Queue.take(wake), deps.pollInterval));
223
221
  }
224
222
  });
225
- return Stream.unfoldChunkEffect(after ?? ORIGIN, from => Effect.map(nextBatch(from), Option.some));
223
+ return Stream.paginate(after ?? ORIGIN, from => Effect.map(nextBatch(from), ([events, last]) => [events, Option.some(last)]));
226
224
  }));
227
225
  //# sourceMappingURL=SubscribeMachine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubscribeMachine.js","names":["Chunk","Effect","Option","Queue","Schedule","Schema","Stream","ORIGIN","ReadLimit","DEFAULT_CATCH_UP_PAGE_SIZE","DEFAULT_POLL_INTERVAL_MILLIS","subscriptionTuningFields","pollInterval","optionalWith","Number","pipe","positive","finite","exact","catchUpPageSize","Int","POLL_RETRY_SCHEDULE","exponential","union","spaced","intersect","recurs","subscribeStream","deps","after","unwrapScoped","gen","wake","sliding","listener","listen","never","tap","offer","undefined","retry","runDrain","forkScoped","drainFrom","from","collected","cursor","events","fetch","make","event","push","lastEvent","at","length","position","last","nextBatch","takeAll","fromIterable","ignore","timeout","take","unfoldChunkEffect","map","some"],"sources":["../../src/SubscribeMachine.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SACEA,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,MAAM,EAENC,MAAM,QACD,QAAQ;AAEf,SAASC,MAAM,EAAEC,SAAS,QAAQ,YAAS;AAE3C;;;;;;;AAOA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;AAE7C;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMC,4BAA4B,GAAG,IAAI;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,YAAY,eAAEP,MAAM,CAACQ,YAAY,cAC/BR,MAAM,CAACS,MAAM,CAACC,IAAI,cAACV,MAAM,CAACW,QAAQ,EAAE,eAAEX,MAAM,CAACY,MAAM,EAAE,CAAC,EACtD;IAAEC,KAAK,EAAE;EAAI,CAAE,CAChB;EACDC,eAAe,eAAEd,MAAM,CAACQ,YAAY,cAACR,MAAM,CAACe,GAAG,CAACL,IAAI,cAACV,MAAM,CAACW,QAAQ,EAAE,CAAC,EAAE;IACvEE,KAAK,EAAE;GACR;CACO;AAEV;;;;;;;AAOA,MAA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AON,MAAM,CAACyD,iBAAiB,CAAClC,KAAK,IAAItB,MAAM,EAAGqC,IAAI,IACpD3C,MAAM,CAAC+D,GAAG,CAACP,SAAS,CAACb,IAAI,CAAC,EAAE1C,MAAM,CAAC+D,IAAI,CAAC,CACzC;AACH,CAAC,CAAC,CACH","ignoreList":[]}
1
+ {"version":3,"file":"SubscribeMachine.js","names":["Effect","Option","Queue","Schedule","Schema","Stream","ORIGIN","ReadLimit","DEFAULT_CATCH_UP_PAGE_SIZE","DEFAULT_POLL_INTERVAL_MILLIS","subscriptionTuningFields","pollInterval","optionalKey","Number","check","isGreaterThan","isFinite","catchUpPageSize","Int","POLL_RETRY_SCHEDULE","max","min","exponential","spaced","recurs","subscribeStream","deps","after","unwrap","gen","wake","sliding","listener","listen","never","pipe","tap","offer","undefined","retry","runDrain","forkScoped","drainFrom","from","collected","cursor","events","fetch","make","event","push","lastEvent","at","length","position","last","nextBatch","clear","ignore","timeout","take","paginate","map","some"],"sources":["../../src/SubscribeMachine.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,SACEA,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,MAAM,EAENC,MAAM,QACD,QAAQ;AAEf,SAASC,MAAM,EAAEC,SAAS,QAAQ,YAAS;AAE3C;;;;;;;AAOA,OAAO,MAAMC,0BAA0B,GAAG,GAAG;AAE7C;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAMC,4BAA4B,GAAG,IAAI;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,YAAY,eAAEP,MAAM,CAACQ,WAAW,cAC9BR,MAAM,CAACS,MAAM,CAACC,KAAK,cAACV,MAAM,CAACW,aAAa,CAAC,CAAC,CAAC,eAAEX,MAAM,CAACY,QAAQ,EAAE,CAAC,CACh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