iterate 0.3.0 → 0.4.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 (241) hide show
  1. package/README.md +164 -82
  2. package/dist/{next/api.d.ts → api.d.ts} +197 -33
  3. package/dist/{next/app-server.d.ts → app-server.d.ts} +7 -0
  4. package/dist/{next/app-server.mjs → app-server.mjs} +17 -15
  5. package/dist/app-server.mjs.map +1 -0
  6. package/dist/{next/app-session.mjs → app-session.mjs} +12 -15
  7. package/dist/app-session.mjs.map +1 -0
  8. package/dist/{next/app.mjs → app.mjs} +53 -14
  9. package/dist/app.mjs.map +1 -0
  10. package/dist/{next/client → client}/live-state.d.ts +11 -11
  11. package/dist/client/oauth.d.ts +17 -0
  12. package/dist/{next/client → client}/react.d.ts +10 -42
  13. package/dist/{next/client → client}/socket.d.ts +1 -0
  14. package/dist/client.mjs +156 -4
  15. package/dist/client.mjs.map +1 -0
  16. package/dist/{next/expression.d.ts → expression.d.ts} +11 -69
  17. package/dist/{next/expression.mjs → expression.mjs} +11 -109
  18. package/dist/expression.mjs.map +1 -0
  19. package/dist/lib-BWr-5mFO.mjs +36 -0
  20. package/dist/lib-BWr-5mFO.mjs.map +1 -0
  21. package/dist/{next/lib.d.ts → lib.d.ts} +16 -2
  22. package/dist/{next/lib.mjs → lib.mjs} +32 -3
  23. package/dist/lib.mjs.map +1 -0
  24. package/dist/node.d.ts +15 -3
  25. package/dist/node.mjs +36 -174
  26. package/dist/node.mjs.map +1 -1
  27. package/dist/{next/oauth-scopes.mjs → oauth-scopes.mjs} +1 -1
  28. package/dist/oauth-scopes.mjs.map +1 -0
  29. package/dist/{next/oauth.mjs → oauth.mjs} +14 -2
  30. package/dist/oauth.mjs.map +1 -0
  31. package/dist/principal.d.ts +8 -0
  32. package/dist/principal.mjs +8 -0
  33. package/dist/principal.mjs.map +1 -0
  34. package/dist/project-ingress.d.ts +58 -0
  35. package/dist/project-ingress.mjs +104 -0
  36. package/dist/project-ingress.mjs.map +1 -0
  37. package/dist/{next/react.mjs → react.mjs} +12 -12
  38. package/dist/react.mjs.map +1 -0
  39. package/dist/sdk/auth.d.ts +25 -0
  40. package/dist/sdk/index.d.ts +155 -0
  41. package/dist/sdk/record-pipelined-steps.d.ts +19 -0
  42. package/dist/sdk.mjs +245 -2
  43. package/dist/sdk.mjs.map +1 -0
  44. package/dist/{next/stream → stream}/processor.d.ts +28 -23
  45. package/dist/{next/stream → stream}/processor.mjs +48 -25
  46. package/dist/stream/processor.mjs.map +1 -0
  47. package/dist/{next/stream → stream}/run.d.ts +9 -6
  48. package/dist/{next/stream → stream}/run.mjs +13 -8
  49. package/dist/stream/run.mjs.map +1 -0
  50. package/dist/stream/test-support.d.ts +45 -0
  51. package/dist/stream/test-support.mjs +196 -0
  52. package/dist/stream/test-support.mjs.map +1 -0
  53. package/package.json +65 -219
  54. package/THIRD_PARTY_NOTICES.md +0 -55
  55. package/bin/iterate.js +0 -94
  56. package/dist/api-url-B6404M82.mjs +0 -17
  57. package/dist/api-url-B6404M82.mjs.map +0 -1
  58. package/dist/app-ref-BipL0feU.mjs +0 -35
  59. package/dist/app-ref-BipL0feU.mjs.map +0 -1
  60. package/dist/app-ref-C1CrgXqX.mjs +0 -7
  61. package/dist/app-ref-C1CrgXqX.mjs.map +0 -1
  62. package/dist/app-ref-DYai_om1.mjs +0 -7
  63. package/dist/app-ref-DYai_om1.mjs.map +0 -1
  64. package/dist/cli-D0c-pDL_.mjs +0 -1010
  65. package/dist/cli-D0c-pDL_.mjs.map +0 -1
  66. package/dist/client.d.ts +0 -3
  67. package/dist/cloudflare-BTm90gQ4.mjs +0 -951
  68. package/dist/cloudflare-BTm90gQ4.mjs.map +0 -1
  69. package/dist/contract-s4FW4eES.mjs +0 -309
  70. package/dist/contract-s4FW4eES.mjs.map +0 -1
  71. package/dist/document-review/index.d.ts +0 -5
  72. package/dist/document-review/types.d.ts +0 -107
  73. package/dist/document-review.mjs +0 -7015
  74. package/dist/document-review.mjs.map +0 -1
  75. package/dist/durable-object-processor-durability-CNsTjAJS.mjs +0 -205
  76. package/dist/durable-object-processor-durability-CNsTjAJS.mjs.map +0 -1
  77. package/dist/idempotency-DleloJNt.mjs +0 -28
  78. package/dist/idempotency-DleloJNt.mjs.map +0 -1
  79. package/dist/index.d.mts +0 -5
  80. package/dist/index.mjs +0 -8
  81. package/dist/index.mjs.map +0 -1
  82. package/dist/itx/api-url.d.ts +0 -6
  83. package/dist/itx/itx-node-client.d.ts +0 -65
  84. package/dist/itx/itx-session.d.ts +0 -215
  85. package/dist/itx/owned-rpc-session.d.ts +0 -14
  86. package/dist/itx/query-client.d.ts +0 -10
  87. package/dist/itx-api.generated.d.ts +0 -6195
  88. package/dist/itx-session-sjud8GiT.mjs +0 -534
  89. package/dist/itx-session-sjud8GiT.mjs.map +0 -1
  90. package/dist/live-state-BJNqOwFw.mjs +0 -299
  91. package/dist/live-state-BJNqOwFw.mjs.map +0 -1
  92. package/dist/next/app-server.mjs.map +0 -1
  93. package/dist/next/app-session.mjs.map +0 -1
  94. package/dist/next/app.mjs.map +0 -1
  95. package/dist/next/client/oauth.d.ts +0 -12
  96. package/dist/next/client.mjs +0 -156
  97. package/dist/next/client.mjs.map +0 -1
  98. package/dist/next/expression.mjs.map +0 -1
  99. package/dist/next/lib.mjs.map +0 -1
  100. package/dist/next/oauth-scopes.mjs.map +0 -1
  101. package/dist/next/oauth.mjs.map +0 -1
  102. package/dist/next/principal.d.ts +0 -64
  103. package/dist/next/principal.mjs +0 -98
  104. package/dist/next/principal.mjs.map +0 -1
  105. package/dist/next/project-ingress.d.ts +0 -37
  106. package/dist/next/project-ingress.mjs +0 -75
  107. package/dist/next/project-ingress.mjs.map +0 -1
  108. package/dist/next/react.mjs.map +0 -1
  109. package/dist/next/sdk/auth.d.ts +0 -5
  110. package/dist/next/sdk/index.d.ts +0 -112
  111. package/dist/next/sdk.mjs +0 -139
  112. package/dist/next/sdk.mjs.map +0 -1
  113. package/dist/next/stream/processor.mjs.map +0 -1
  114. package/dist/next/stream/run.mjs.map +0 -1
  115. package/dist/next-node.d.ts +0 -15
  116. package/dist/next-node.mjs +0 -51
  117. package/dist/next-node.mjs.map +0 -1
  118. package/dist/processor-host-capabilities-BMFH3KTM.mjs +0 -56
  119. package/dist/processor-host-capabilities-BMFH3KTM.mjs.map +0 -1
  120. package/dist/processors/cloudflare.d.ts +0 -3
  121. package/dist/processors/durable-object-processor-durability.d.ts +0 -79
  122. package/dist/processors/event-consumption-metrics.d.ts +0 -82
  123. package/dist/processors/idempotency.d.ts +0 -13
  124. package/dist/processors/index.d.ts +0 -12
  125. package/dist/processors/processor-contracts.d.ts +0 -342
  126. package/dist/processors/processor-facet.d.ts +0 -186
  127. package/dist/processors/processor-host-capabilities.d.ts +0 -60
  128. package/dist/processors/prompt-sections.d.ts +0 -17
  129. package/dist/processors/rpc-types.d.ts +0 -515
  130. package/dist/processors/schemas.d.ts +0 -102
  131. package/dist/processors/stream-handle.d.ts +0 -45
  132. package/dist/processors/stream-processor-keepalive.d.ts +0 -95
  133. package/dist/processors/stream-processor-registry.d.ts +0 -233
  134. package/dist/processors/stream-processor-runner.d.ts +0 -289
  135. package/dist/processors/stream-processor.d.ts +0 -339
  136. package/dist/processors/stream-runtime-metrics.d.ts +0 -107
  137. package/dist/processors/testing.d.ts +0 -302
  138. package/dist/processors-BoNyeBfQ.mjs +0 -10
  139. package/dist/processors-BoNyeBfQ.mjs.map +0 -1
  140. package/dist/processors-cloudflare.mjs +0 -3
  141. package/dist/processors-testing.mjs +0 -435
  142. package/dist/processors-testing.mjs.map +0 -1
  143. package/dist/processors.mjs +0 -52
  144. package/dist/processors.mjs.map +0 -1
  145. package/dist/protocol-DnK_f2m6.mjs +0 -251
  146. package/dist/protocol-DnK_f2m6.mjs.map +0 -1
  147. package/dist/sdk/capnweb/index.d.ts +0 -2
  148. package/dist/sdk/capnweb/live-state/compact.d.ts +0 -5
  149. package/dist/sdk/capnweb/live-state/diff.d.ts +0 -41
  150. package/dist/sdk/capnweb/live-state/engine.d.ts +0 -44
  151. package/dist/sdk/capnweb/live-state/index.d.ts +0 -41
  152. package/dist/sdk/capnweb/live-state/protocol.d.ts +0 -87
  153. package/dist/sdk/capnweb/live-state/retain.d.ts +0 -23
  154. package/dist/sdk/capnweb/live-state/store.d.ts +0 -20
  155. package/dist/sdk/capnweb/live-state/types.d.ts +0 -11
  156. package/dist/sdk/capnweb/react.d.ts +0 -45
  157. package/dist/sdk/capnweb/react.mjs +0 -316
  158. package/dist/sdk/capnweb/react.mjs.map +0 -1
  159. package/dist/sdk/capnweb.mjs +0 -4
  160. package/dist/sdk/itx/react.d.ts +0 -191
  161. package/dist/sdk/itx/react.mjs +0 -383
  162. package/dist/sdk/itx/react.mjs.map +0 -1
  163. package/dist/sdk-DMB-IM11.mjs +0 -933
  164. package/dist/sdk-DMB-IM11.mjs.map +0 -1
  165. package/dist/sdk.d.ts +0 -339
  166. package/dist/serve-itx.d.ts +0 -46
  167. package/dist/starter-apps/flake-dashboard/app-ref.d.ts +0 -31
  168. package/dist/starter-apps/flake-dashboard/configured-worker.mjs +0 -1055
  169. package/dist/starter-apps/flake-dashboard/configured-worker.mjs.map +0 -1
  170. package/dist/starter-apps/flake-dashboard/contract.d.ts +0 -4839
  171. package/dist/starter-apps/flake-dashboard/contract.mjs +0 -2
  172. package/dist/starter-apps/flake-dashboard/index.d.ts +0 -17
  173. package/dist/starter-apps/flake-dashboard/index.mjs +0 -56
  174. package/dist/starter-apps/flake-dashboard/index.mjs.map +0 -1
  175. package/dist/starter-apps/flake-dashboard/worker.d.ts +0 -4607
  176. package/dist/starter-apps/github-ai-linter/ai-linter.d.ts +0 -8914
  177. package/dist/starter-apps/github-ai-linter/configured-worker.mjs +0 -17987
  178. package/dist/starter-apps/github-ai-linter/configured-worker.mjs.map +0 -1
  179. package/dist/starter-apps/github-ai-linter/contract.d.ts +0 -9193
  180. package/dist/starter-apps/github-ai-linter/index.d.ts +0 -10
  181. package/dist/starter-apps/github-ai-linter/index.mjs +0 -36
  182. package/dist/starter-apps/github-ai-linter/index.mjs.map +0 -1
  183. package/dist/starter-apps/github-ai-linter/prompt.d.ts +0 -13
  184. package/dist/starter-apps/github-ai-linter/review-bot.d.ts +0 -808
  185. package/dist/starter-apps/github-ai-linter/rules.d.ts +0 -34
  186. package/dist/starter-apps/github-ai-linter/worker-ref.d.ts +0 -19
  187. package/dist/starter-apps/github-ai-linter/worker.d.ts +0 -19
  188. package/dist/starter-apps/github-ai-linter/worker.mjs +0 -947
  189. package/dist/starter-apps/github-ai-linter/worker.mjs.map +0 -1
  190. package/dist/starter-apps/guestbook/app-ref.d.ts +0 -27
  191. package/dist/starter-apps/guestbook/client.d.ts +0 -7
  192. package/dist/starter-apps/guestbook/client.mjs +0 -59
  193. package/dist/starter-apps/guestbook/configured-worker.mjs +0 -205
  194. package/dist/starter-apps/guestbook/configured-worker.mjs.map +0 -1
  195. package/dist/starter-apps/guestbook/index.d.ts +0 -9
  196. package/dist/starter-apps/guestbook/index.mjs +0 -31
  197. package/dist/starter-apps/guestbook/index.mjs.map +0 -1
  198. package/dist/starter-apps/guestbook/processor.d.ts +0 -2267
  199. package/dist/starter-apps/guestbook/worker.d.ts +0 -26
  200. package/dist/starter-apps/guestbook/worker.mjs +0 -191
  201. package/dist/starter-apps/guestbook/worker.mjs.map +0 -1
  202. package/dist/starter-apps/media/configured-worker.mjs +0 -577
  203. package/dist/starter-apps/media/configured-worker.mjs.map +0 -1
  204. package/dist/starter-apps/media/index.mjs +0 -36
  205. package/dist/starter-apps/media/index.mjs.map +0 -1
  206. package/dist/starter-apps/media/ref.mjs +0 -20
  207. package/dist/starter-apps/media/ref.mjs.map +0 -1
  208. package/dist/starter-apps/media/worker.mjs +0 -579
  209. package/dist/starter-apps/media/worker.mjs.map +0 -1
  210. package/dist/starter-apps/notes/configured-worker.mjs +0 -6134
  211. package/dist/starter-apps/notes/configured-worker.mjs.map +0 -1
  212. package/dist/starter-apps/notes/index.mjs +0 -23
  213. package/dist/starter-apps/notes/index.mjs.map +0 -1
  214. package/dist/starter-apps/notes/ref.mjs +0 -21
  215. package/dist/starter-apps/notes/ref.mjs.map +0 -1
  216. package/dist/starter-apps/notes/worker.mjs +0 -427
  217. package/dist/starter-apps/notes/worker.mjs.map +0 -1
  218. package/dist/starter-apps/todo/client.mjs +0 -59
  219. package/dist/starter-apps/todo/configured-worker.mjs +0 -2864
  220. package/dist/starter-apps/todo/configured-worker.mjs.map +0 -1
  221. package/dist/starter-apps/todo/index.d.ts +0 -8
  222. package/dist/starter-apps/todo/index.mjs +0 -29
  223. package/dist/starter-apps/todo/index.mjs.map +0 -1
  224. package/dist/stream-processor-keepalive-DAQTP6m3.mjs +0 -2082
  225. package/dist/stream-processor-keepalive-DAQTP6m3.mjs.map +0 -1
  226. package/dist/usingCtx-mZx5nsAW.mjs +0 -11800
  227. package/dist/usingCtx-mZx5nsAW.mjs.map +0 -1
  228. package/dist/worker-ref-DZxPDmb_.mjs +0 -390
  229. package/dist/worker-ref-DZxPDmb_.mjs.map +0 -1
  230. package/dist/worker.d.mts +0 -33
  231. package/dist/worker.mjs +0 -18
  232. package/dist/worker.mjs.map +0 -1
  233. package/menubar/Iterate.entitlements +0 -12
  234. package/menubar/Iterate.swift +0 -914
  235. package/menubar/IterateIcon.swift +0 -145
  236. package/menubar/README.md +0 -28
  237. package/menubar/build-menubar-app.sh +0 -59
  238. /package/dist/{next/api.mjs → api.mjs} +0 -0
  239. /package/dist/{next/app-session.d.ts → app-session.d.ts} +0 -0
  240. /package/dist/{next/app.d.ts → app.d.ts} +0 -0
  241. /package/dist/{next/oauth-scopes.d.ts → oauth-scopes.d.ts} +0 -0
@@ -1,302 +0,0 @@
1
- import type { StreamEvent, StreamEventInput } from "./schemas.ts";
2
- import type { StreamEventReadInput } from "./rpc-types.ts";
3
- import type { ConsumedInput, ProcessorState, ResolvedEvent } from "./processor-contracts.ts";
4
- import type { RegisteredProcessorReads } from "./stream-processor-registry.ts";
5
- import type { ProcessorStream } from "./stream-handle.ts";
6
- import type { StreamProcessor, StreamProcessorContract } from "./stream-processor.ts";
7
- import type { ProcessorProgressStore } from "./stream-processor-runner.ts";
8
- import { StreamProcessorRunner } from "./stream-processor-runner.ts";
9
- export declare class MemoryStream implements ProcessorStream {
10
- events: StreamEvent[];
11
- streamId: `${string}-${string}-${string}-${string}-${string}`;
12
- /** Injectable clock for createdAt stamps; harnesses point it at virtual time. */
13
- now: () => number;
14
- /** Simulate a transient Stream DO outage: appends of this type throw. */
15
- failAppendsOfType: string | undefined;
16
- /**
17
- * OPT-IN ASYNCHRONOUS COMMIT. Undefined — the default — is today's behaviour
18
- * and every existing suite's behaviour.
19
- *
20
- * `append` below validates and publishes in its own SYNCHRONOUS body: it is
21
- * declared `async`, but nothing inside it awaits, so the events are in
22
- * `this.events` and their offsets are taken before the returned promise is
23
- * even handed back. Two call sites therefore commit in the order they
24
- * CALLED, whoever awaited and whoever did not. That determinism is what
25
- * makes scenario steps reproducible and it is why ~250 suites rest on it.
26
- *
27
- * It is also a lie about production. A real append is an RPC to the Stream
28
- * Durable Object; two of them can be in flight at once, and the one issued
29
- * first is not guaranteed to commit first. Every ordering bug of that shape
30
- * — an un-awaited append racing an awaited one, and the un-awaited one
31
- * losing — is structurally invisible here.
32
- *
33
- * Set this and an append waits for the returned promise before it validates
34
- * anything or takes an offset, so offsets are assigned at COMMIT the way the
35
- * Durable Object assigns them. Return `undefined` to let a batch commit at
36
- * once, which is what keeps the cost of the mode to the batches a test
37
- * actually cares about.
38
- *
39
- * A test is expected to DECIDE which of two in-flight appends wins rather
40
- * than to wait and see: a race whose loser cannot be pinned is a flake, not
41
- * a test. Whatever the hook waits on must be bounded, because the fix for
42
- * such a bug is usually to make the overtake impossible — and then a hook
43
- * that waits for it forever hangs the suite that proves it.
44
- */
45
- holdAppend: ((events: readonly StreamEventInput[]) => Promise<void> | undefined) | undefined;
46
- /** Set by MemoryStreamNetwork.get(); a detached stream answers `at()` with itself. */
47
- network: MemoryStreamNetwork | undefined;
48
- readonly path: string;
49
- constructor(path?: string);
50
- __describe(): Promise<{
51
- instructions: string;
52
- types: string;
53
- children: {};
54
- }>;
55
- kill(): Promise<void>;
56
- append(...inputs: StreamEventInput[]): Promise<StreamEvent[]>;
57
- appendIfStreamId(args: {
58
- streamId: string;
59
- events: StreamEventInput[];
60
- }): Promise<StreamEvent[]>;
61
- at(path?: string): MemoryStream;
62
- getEvent(input: {
63
- offset: number;
64
- } | {
65
- idempotencyKey: string;
66
- }): Promise<StreamEvent | undefined>;
67
- getEvents(input?: StreamEventReadInput): Promise<StreamEvent[]>;
68
- getEventPage(input?: StreamEventReadInput): Promise<{
69
- streamId: `${string}-${string}-${string}-${string}-${string}`;
70
- streamMaxOffset: number;
71
- events: {
72
- type: string;
73
- offset: number;
74
- createdAt: string;
75
- path: string;
76
- payload?: Record<string, unknown> | undefined;
77
- metadata?: Record<string, unknown> | undefined;
78
- source?: {
79
- processor?: {
80
- slug: string;
81
- version: string;
82
- stream: {
83
- path: string;
84
- projectId: string | null;
85
- streamId: string;
86
- };
87
- whileProcessing?: {
88
- offset: number;
89
- type: string;
90
- } | undefined;
91
- } | undefined;
92
- copiedFrom?: {
93
- name: string;
94
- streamId: string;
95
- streamCreatedAt: string;
96
- cursorChangedAtSourceOffset: number;
97
- createdAt: string;
98
- offset: number;
99
- path: string;
100
- projectId: string | null;
101
- type: string;
102
- }[] | undefined;
103
- } | undefined;
104
- idempotencyKey?: string | undefined;
105
- ephemeral?: true | undefined;
106
- }[];
107
- }>;
108
- readEvents(input?: StreamEventReadInput): {
109
- next: () => Promise<{
110
- type: string;
111
- offset: number;
112
- createdAt: string;
113
- path: string;
114
- payload?: Record<string, unknown> | undefined;
115
- metadata?: Record<string, unknown> | undefined;
116
- source?: {
117
- processor?: {
118
- slug: string;
119
- version: string;
120
- stream: {
121
- path: string;
122
- projectId: string | null;
123
- streamId: string;
124
- };
125
- whileProcessing?: {
126
- offset: number;
127
- type: string;
128
- } | undefined;
129
- } | undefined;
130
- copiedFrom?: {
131
- name: string;
132
- streamId: string;
133
- streamCreatedAt: string;
134
- cursorChangedAtSourceOffset: number;
135
- createdAt: string;
136
- offset: number;
137
- path: string;
138
- projectId: string | null;
139
- type: string;
140
- }[] | undefined;
141
- } | undefined;
142
- idempotencyKey?: string | undefined;
143
- ephemeral?: true | undefined;
144
- }[]>;
145
- [Symbol.dispose](): void;
146
- };
147
- waitForEvent(input: {
148
- afterOffset?: number;
149
- eventTypes?: readonly string[];
150
- predicate?: (event: StreamEvent) => boolean | Promise<boolean>;
151
- timeoutMs: number;
152
- }): Promise<StreamEvent>;
153
- getProcessorRuntimeState(): Promise<null>;
154
- runtimeState(): Promise<{
155
- coreProcessorState: null;
156
- runtime: {
157
- connections: {};
158
- sending: {};
159
- metrics: {
160
- measuredSince: string;
161
- reportedAt: string;
162
- ingress: {
163
- perSecond5s: number;
164
- bytesPerSecond5s: number;
165
- lastMinute: {
166
- count: number;
167
- bytes: number;
168
- perSecond: number;
169
- };
170
- series: {
171
- counts: any[];
172
- bytes: any[];
173
- };
174
- };
175
- egress: {
176
- perSecond5s: number;
177
- bytesPerSecond5s: number;
178
- lastMinute: {
179
- count: number;
180
- bytes: number;
181
- perSecond: number;
182
- };
183
- series: {
184
- counts: any[];
185
- bytes: any[];
186
- };
187
- };
188
- };
189
- storageSizeBytes: number;
190
- };
191
- }>;
192
- }
193
- /**
194
- * In-memory network of streams keyed by path, so router tests can observe
195
- * the cross-stream forwards (`stream.at(path).append(...)`) next to
196
- * same-stream appends. `now` feeds every member stream's createdAt stamp, so
197
- * freshness checks (such as webhook acknowledgement horizons) can be tested on both sides
198
- * of the horizon. `eventsAt` never creates a stream — `network.streams.size`
199
- * assertions ("nothing was forwarded anywhere") stay honest.
200
- */
201
- export declare class MemoryStreamNetwork {
202
- readonly streams: Map<string, MemoryStream>;
203
- readonly now: () => number;
204
- constructor(now?: () => number);
205
- get(path: string): MemoryStream;
206
- eventsAt(path: string): StreamEvent[];
207
- }
208
- /**
209
- * One scenario step. Three built-in kinds plus a function escape hatch:
210
- *
211
- * - `["append", ...events]` — typed appends (the contract's `consumes`
212
- * vocabulary: what the outside world can put on this processor's stream);
213
- * - `["advanceTime", ms]` — move the virtual clock, releasing any harness
214
- * `sleep(...)` calls that come due;
215
- * - `["crash"]` — abandon the incarnation like an eviction (runtime state and
216
- * pending closures die; stream, progress, and clock survive);
217
- * - `async () => ...` — anything processor-specific (resolve a fake transport,
218
- * assert mid-scenario).
219
- *
220
- * After every step the harness drives delivery to a fixpoint, so each step
221
- * observes the stream consequences of the previous one.
222
- */
223
- export type HarnessStep<Contract extends StreamProcessorContract> = readonly ["append", ...ConsumedInput<Contract>[]] | readonly ["advanceTime", number] | readonly ["crash"] | (() => unknown);
224
- /** The durable substrate shared across incarnations (and zombie twins). */
225
- export type HarnessSubstrate = {
226
- clock: {
227
- now: number;
228
- };
229
- stream: MemoryStream;
230
- progress: ProcessorProgressStore<unknown>;
231
- };
232
- /** What {@link makeProcessorHarness}'s factory receives: base deps plus the
233
- * harness's virtual clock/sleep, for processors that take injectable time. */
234
- export type HarnessProcessorDeps<Contract extends StreamProcessorContract> = {
235
- stream: ProcessorStream;
236
- path: string;
237
- projectId: string | null;
238
- now: () => number;
239
- sleep: (ms: number) => Promise<void>;
240
- reads: Pick<RegisteredProcessorReads<ProcessorState<Contract>>, "snapshot" | "waitUntilEvent">;
241
- };
242
- export type ProcessorHarness<Contract extends StreamProcessorContract, Processor extends StreamProcessor<Contract, object> = StreamProcessor<Contract, object>> = {
243
- clock: {
244
- now: number;
245
- };
246
- stream: MemoryStream;
247
- substrate: HarnessSubstrate;
248
- /** The current incarnation's runner, for tests that need its full surface.
249
- * A method (not a property) so suites can spread the harness into a wider
250
- * object without freezing a pre-crash incarnation. */
251
- runner(): StreamProcessorRunner<Contract>;
252
- /** The current incarnation's processor instance. */
253
- processor(): Processor;
254
- /** Run steps in order, driving delivery to a fixpoint after each. */
255
- play(...steps: HarnessStep<Contract>[]): Promise<void>;
256
- /** Typed append (the contract's `consumes` vocabulary) + drive to fixpoint. */
257
- append(...events: ConsumedInput<Contract>[]): Promise<void>;
258
- /** Advance the virtual clock, release due sleeps, drive to fixpoint. */
259
- advanceTime(ms: number): Promise<void>;
260
- /** Abandon this incarnation like an eviction; a fresh one takes over the
261
- * same stream/progress/clock. Does NOT deliver — the successor first acts
262
- * on the next step, exactly like a real revival. */
263
- crash(): void;
264
- /** Drive delivery to a fixpoint: repeated catch-up passes (with microtask
265
- * drains between them, so settled background work can land its appends)
266
- * until the stream head stops moving. */
267
- settle(): Promise<void>;
268
- /** The runner's committed reduced state. */
269
- state(): ProcessorState<Contract>;
270
- /** All committed stream rows. */
271
- events(): StreamEvent[];
272
- /** Committed rows of one event type, typed when the contract resolves it. */
273
- events<Type extends string>(type: Type): ResolvedEvent<Contract, Type>[];
274
- };
275
- /** In-memory {@link ProcessorProgressStore} with the DO store's fencing check,
276
- * so progress survives `crash()` into the successor incarnation. Exported so
277
- * suites can hand a harness a FRESH store over an existing stream — a full
278
- * replay from offset zero, which is both the re-reduce-from-scratch recipe and the harshest
279
- * at-least-once redelivery test (every per-event append re-runs).
280
- *
281
- * The contract is required because progress and recovery share the same
282
- * per-processor Durable Object keys. A generic placeholder slug would let the
283
- * runner commit progress under one key while recovery looks under another.
284
- */
285
- export declare function makeMemoryProgressStore(contract: Pick<StreamProcessorContract, "slug">): ProcessorProgressStore<unknown>;
286
- /**
287
- * Build a {@link ProcessorHarness}: the real runner, ProcessorKeepalive, and
288
- * Durable Object durability adapters over an in-memory stream/KV/alarm
289
- * substrate. `crash()` is eviction: delivery stays detached until a new
290
- * append wakes it or a due keepalive alarm appends the revival fact. Pass
291
- * another harness's `substrate` to run a second incarnation over the same
292
- * durable state (the zombie-race setup).
293
- *
294
- * Appends commit synchronously unless a suite opts out through
295
- * `harness.stream.holdAppend` — the one seam for reproducing a processor that
296
- * appends the same lane from two places and orders only one of them.
297
- */
298
- export declare function makeProcessorHarness<Contract extends StreamProcessorContract, Processor extends StreamProcessor<Contract, object> = StreamProcessor<Contract, object>>(args: {
299
- createProcessor: (deps: HarnessProcessorDeps<Contract>) => Processor;
300
- path?: string;
301
- substrate?: HarnessSubstrate;
302
- }): ProcessorHarness<Contract, Processor>;
@@ -1,10 +0,0 @@
1
- import "./usingCtx-mZx5nsAW.mjs";
2
- //#region src/processors/idempotency.ts
3
- const IDEMPOTENCY_CONFLICT_FRAGMENT = " already names a different event at offset ";
4
- function isIdempotencyConflict(error) {
5
- return (error instanceof Error ? error.message : String(error)).includes(IDEMPOTENCY_CONFLICT_FRAGMENT);
6
- }
7
- //#endregion
8
- export { isIdempotencyConflict as t };
9
-
10
- //# sourceMappingURL=processors-BoNyeBfQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processors-BoNyeBfQ.mjs","names":[],"sources":["../src/processors/idempotency.ts"],"sourcesContent":["// The Stream DO's idempotency semantics, importable: a same-key append is a\n// dedup ONLY when its body is structurally identical — otherwise it must be\n// rejected. Lives here so the production Stream Durable Object and the\n// MemoryStream test double share ONE predicate and cannot drift.\n\ntype EventBody = {\n type: string;\n payload?: unknown;\n metadata?: unknown;\n ephemeral?: boolean | undefined;\n};\n\n// The wording is a live wire contract: the rejection crosses Workers RPC,\n// which preserves the message but not class identity, so deployed processors\n// classify the conflict by this text. Mint with the builder, match with the\n// predicate — never spell the wording anywhere else.\nconst IDEMPOTENCY_CONFLICT_FRAGMENT = \" already names a different event at offset \";\n\nexport function idempotencyConflictMessage(idempotencyKey: string, existingOffset: number) {\n return `idempotency key \"${idempotencyKey}\"${IDEMPOTENCY_CONFLICT_FRAGMENT}${existingOffset}`;\n}\n\nexport function isIdempotencyConflict(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n return message.includes(IDEMPOTENCY_CONFLICT_FRAGMENT);\n}\n\n/** Whether a requested append names the SAME event an idempotency key already committed. */\nexport function sameIdempotentEvent(existing: EventBody, requested: EventBody): boolean {\n return (\n existing.type === requested.type &&\n jsonValuesEqual(existing.payload, requested.payload) &&\n jsonValuesEqual(existing.metadata, requested.metadata) &&\n existing.ephemeral === requested.ephemeral\n );\n}\n\n/** Structural JSON equality (key-order-insensitive). */\nexport function jsonValuesEqual(left: unknown, right: unknown): boolean {\n if (Object.is(left, right)) return true;\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((value, index) => jsonValuesEqual(value, right[index]))\n );\n }\n if (typeof left === \"object\" && typeof right === \"object\" && left !== null && right !== null) {\n const leftKeys = Object.keys(left).sort();\n const rightKeys = Object.keys(right).sort();\n if (leftKeys.length !== rightKeys.length) return false;\n return leftKeys.every(\n (key, index) =>\n key === rightKeys[index] &&\n jsonValuesEqual(\n (left as Record<string, unknown>)[key],\n (right as Record<string, unknown>)[key],\n ),\n );\n }\n return false;\n}\n"],"mappings":";;AAgBA,MAAM,gCAAgC;AAMtC,SAAgB,sBAAsB,OAAgB;CAEpD,QADgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAA,CACtD,SAAS,6BAA6B;AACvD"}
@@ -1,3 +0,0 @@
1
- import { a as createStreamProcessorRegistry, i as plainAlarmInvocationInfo, n as ProcessorFacet, r as facetProcessorDurableObjectState, t as FACET_IDENTITY_KEY } from "./cloudflare-BTm90gQ4.mjs";
2
- import { i as processorProgressKey, n as durableObjectRecovery, r as processorKeepaliveKey, t as durableObjectProgressStore } from "./durable-object-processor-durability-CNsTjAJS.mjs";
3
- export { FACET_IDENTITY_KEY, ProcessorFacet, createStreamProcessorRegistry, durableObjectProgressStore, durableObjectRecovery, facetProcessorDurableObjectState, plainAlarmInvocationInfo, processorKeepaliveKey, processorProgressKey };