@crvouga/mockingbird-service-stripe 0.1.0 → 0.1.2

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 (142) hide show
  1. package/README.md +21 -15
  2. package/dist/index.d.ts +362 -16
  3. package/dist/index.js +5264 -167
  4. package/dist/index.js.map +7 -1
  5. package/package.json +10 -9
  6. package/dist/account.d.ts +0 -8
  7. package/dist/account.d.ts.map +0 -1
  8. package/dist/account.js +0 -13
  9. package/dist/account.js.map +0 -1
  10. package/dist/charges.d.ts +0 -4
  11. package/dist/charges.d.ts.map +0 -1
  12. package/dist/charges.js +0 -89
  13. package/dist/charges.js.map +0 -1
  14. package/dist/checkout-sessions.d.ts +0 -5
  15. package/dist/checkout-sessions.d.ts.map +0 -1
  16. package/dist/checkout-sessions.js +0 -303
  17. package/dist/checkout-sessions.js.map +0 -1
  18. package/dist/constants.d.ts +0 -3
  19. package/dist/constants.d.ts.map +0 -1
  20. package/dist/constants.js +0 -3
  21. package/dist/constants.js.map +0 -1
  22. package/dist/coupons.d.ts +0 -4
  23. package/dist/coupons.d.ts.map +0 -1
  24. package/dist/coupons.js +0 -158
  25. package/dist/coupons.js.map +0 -1
  26. package/dist/customers.d.ts +0 -4
  27. package/dist/customers.d.ts.map +0 -1
  28. package/dist/customers.js +0 -218
  29. package/dist/customers.js.map +0 -1
  30. package/dist/disputes.d.ts +0 -4
  31. package/dist/disputes.d.ts.map +0 -1
  32. package/dist/disputes.js +0 -36
  33. package/dist/disputes.js.map +0 -1
  34. package/dist/errors.d.ts +0 -29
  35. package/dist/errors.d.ts.map +0 -1
  36. package/dist/errors.js +0 -74
  37. package/dist/errors.js.map +0 -1
  38. package/dist/events.d.ts +0 -4
  39. package/dist/events.d.ts.map +0 -1
  40. package/dist/events.js +0 -76
  41. package/dist/events.js.map +0 -1
  42. package/dist/expand.d.ts +0 -11
  43. package/dist/expand.d.ts.map +0 -1
  44. package/dist/expand.js +0 -45
  45. package/dist/expand.js.map +0 -1
  46. package/dist/fields.d.ts +0 -25
  47. package/dist/fields.d.ts.map +0 -1
  48. package/dist/fields.js +0 -117
  49. package/dist/fields.js.map +0 -1
  50. package/dist/generated/openapi.d.ts +0 -7
  51. package/dist/generated/openapi.d.ts.map +0 -1
  52. package/dist/generated/openapi.js +0 -5
  53. package/dist/generated/openapi.js.map +0 -1
  54. package/dist/index.d.ts.map +0 -1
  55. package/dist/internal.d.ts +0 -134
  56. package/dist/internal.d.ts.map +0 -1
  57. package/dist/internal.js +0 -460
  58. package/dist/internal.js.map +0 -1
  59. package/dist/invoice-items.d.ts +0 -4
  60. package/dist/invoice-items.d.ts.map +0 -1
  61. package/dist/invoice-items.js +0 -179
  62. package/dist/invoice-items.js.map +0 -1
  63. package/dist/invoices.d.ts +0 -4
  64. package/dist/invoices.d.ts.map +0 -1
  65. package/dist/invoices.js +0 -312
  66. package/dist/invoices.js.map +0 -1
  67. package/dist/list.d.ts +0 -24
  68. package/dist/list.d.ts.map +0 -1
  69. package/dist/list.js +0 -68
  70. package/dist/list.js.map +0 -1
  71. package/dist/params.d.ts +0 -29
  72. package/dist/params.d.ts.map +0 -1
  73. package/dist/params.js +0 -165
  74. package/dist/params.js.map +0 -1
  75. package/dist/payment-intents.d.ts +0 -4
  76. package/dist/payment-intents.d.ts.map +0 -1
  77. package/dist/payment-intents.js +0 -232
  78. package/dist/payment-intents.js.map +0 -1
  79. package/dist/payment-methods.d.ts +0 -4
  80. package/dist/payment-methods.d.ts.map +0 -1
  81. package/dist/payment-methods.js +0 -99
  82. package/dist/payment-methods.js.map +0 -1
  83. package/dist/prices.d.ts +0 -4
  84. package/dist/prices.d.ts.map +0 -1
  85. package/dist/prices.js +0 -176
  86. package/dist/prices.js.map +0 -1
  87. package/dist/products.d.ts +0 -6
  88. package/dist/products.d.ts.map +0 -1
  89. package/dist/products.js +0 -202
  90. package/dist/products.js.map +0 -1
  91. package/dist/promotion-codes.d.ts +0 -4
  92. package/dist/promotion-codes.d.ts.map +0 -1
  93. package/dist/promotion-codes.js +0 -193
  94. package/dist/promotion-codes.js.map +0 -1
  95. package/dist/qa-corpus.d.ts +0 -26
  96. package/dist/qa-corpus.d.ts.map +0 -1
  97. package/dist/qa-corpus.js +0 -42
  98. package/dist/qa-corpus.js.map +0 -1
  99. package/dist/refunds.d.ts +0 -4
  100. package/dist/refunds.d.ts.map +0 -1
  101. package/dist/refunds.js +0 -125
  102. package/dist/refunds.js.map +0 -1
  103. package/dist/render.d.ts +0 -60
  104. package/dist/render.d.ts.map +0 -1
  105. package/dist/render.js +0 -426
  106. package/dist/render.js.map +0 -1
  107. package/dist/reshape-qa.d.ts +0 -8
  108. package/dist/reshape-qa.d.ts.map +0 -1
  109. package/dist/reshape-qa.js +0 -102
  110. package/dist/reshape-qa.js.map +0 -1
  111. package/dist/search.d.ts +0 -32
  112. package/dist/search.d.ts.map +0 -1
  113. package/dist/search.js +0 -64
  114. package/dist/search.js.map +0 -1
  115. package/dist/setup-intents.d.ts +0 -4
  116. package/dist/setup-intents.d.ts.map +0 -1
  117. package/dist/setup-intents.js +0 -129
  118. package/dist/setup-intents.js.map +0 -1
  119. package/dist/state.d.ts +0 -485
  120. package/dist/state.d.ts.map +0 -1
  121. package/dist/state.js +0 -143
  122. package/dist/state.js.map +0 -1
  123. package/dist/subscription-schedules.d.ts +0 -4
  124. package/dist/subscription-schedules.d.ts.map +0 -1
  125. package/dist/subscription-schedules.js +0 -122
  126. package/dist/subscription-schedules.js.map +0 -1
  127. package/dist/subscriptions.d.ts +0 -23
  128. package/dist/subscriptions.d.ts.map +0 -1
  129. package/dist/subscriptions.js +0 -260
  130. package/dist/subscriptions.js.map +0 -1
  131. package/dist/test-tokens.d.ts +0 -27
  132. package/dist/test-tokens.d.ts.map +0 -1
  133. package/dist/test-tokens.js +0 -61
  134. package/dist/test-tokens.js.map +0 -1
  135. package/dist/url.d.ts +0 -6
  136. package/dist/url.d.ts.map +0 -1
  137. package/dist/url.js +0 -38
  138. package/dist/url.js.map +0 -1
  139. package/dist/version.d.ts +0 -3
  140. package/dist/version.d.ts.map +0 -1
  141. package/dist/version.js +0 -3
  142. package/dist/version.js.map +0 -1
package/README.md CHANGED
@@ -25,8 +25,8 @@ npm install -D @crvouga/mockingbird-service-stripe
25
25
  ```
26
26
 
27
27
  ESM only. Requires Node >= 22 or Bun >= 1.2. No native dependencies: state lives in an in-memory
28
- SQLite engine (`@crvouga/mockingbird-service-sqlite`, pure TypeScript). To serve it over HTTP also
29
- install an adapter: `@crvouga/mockingbird-adapter-node` or `@crvouga/mockingbird-adapter-bun`.
28
+ SQLite engine (pure TypeScript, bundled in). To serve it over HTTP use `Bun.serve` under Bun, or
29
+ install `@hono/node-server` under Node.
30
30
 
31
31
  ## Usage
32
32
 
@@ -75,11 +75,14 @@ console.log(((await listed.json()) as { data: unknown[] }).data.length) // 1
75
75
  ### Over HTTP
76
76
 
77
77
  ```ts
78
- import { serve } from "@crvouga/mockingbird-adapter-bun"
79
78
  import { StripeAPI } from "@crvouga/mockingbird-service-stripe"
80
79
 
81
80
  const stripe = new StripeAPI()
82
- const server = serve(stripe, { port: 0, hostname: "127.0.0.1" }) // port 0 = ephemeral
81
+ const server = Bun.serve({
82
+ port: 0, // ephemeral
83
+ hostname: "127.0.0.1",
84
+ fetch: (request) => stripe.fetch(request),
85
+ })
83
86
  const baseUrl = `http://127.0.0.1:${server.port}`
84
87
 
85
88
  const response = await fetch(`${baseUrl}/v1/products?limit=3`, {
@@ -90,13 +93,15 @@ console.log(response.status) // 200
90
93
  server.stop()
91
94
  ```
92
95
 
93
- On Node use `@crvouga/mockingbird-adapter-node`, whose `serve` is async and returns a
94
- `node:http` server:
96
+ On Node use any Fetch-style server, e.g. `@hono/node-server` (`npm install -D @hono/node-server`),
97
+ whose callback receives the bound port:
95
98
 
96
99
  ```js
97
- import { serve } from "@crvouga/mockingbird-adapter-node"
98
- const server = await serve(stripe, { port: 0, host: "127.0.0.1" })
99
- const { port } = server.address()
100
+ import { serve } from "@hono/node-server"
101
+ const server = serve(
102
+ { fetch: (request) => stripe.fetch(request), port: 0, hostname: "127.0.0.1" },
103
+ (info) => console.log(`http://127.0.0.1:${info.port}`),
104
+ )
100
105
  // ... later: server.close()
101
106
  ```
102
107
 
@@ -111,7 +116,7 @@ import Stripe from "stripe"
111
116
  const client = new Stripe("sk_test_mockingbird", {
112
117
  apiVersion: "2024-06-20",
113
118
  host: "127.0.0.1",
114
- port: server.port, // from serve() above
119
+ port: server.port, // from Bun.serve() above
115
120
  protocol: "http",
116
121
  })
117
122
  await client.customers.create({ email: "qa@example.com" })
@@ -184,7 +189,7 @@ QA corpus used by the parity suites.
184
189
 
185
190
  | Export | Description |
186
191
  | --- | --- |
187
- | `StripeAPI` | Class. `new StripeAPI(options?)`; implements `FetchAPI` (`fetch(request: Request): Promise<Response>`). |
192
+ | `StripeAPI` | Class. `new StripeAPI(options?)`; implements the Fetch contract `fetch(request: Request): Promise<Response>`. |
188
193
  | `accountOfKey` | `(key: string) => string` — the opaque `acct_...` partition id for an API key (use it to filter `webhookEvents`). |
189
194
  | `accountOf` | `(request: Request) => string` — the partition id for a request's bearer key. |
190
195
  | `STRIPE_NAMESPACE` | `"stripe"` — SQLite namespace holding every Stripe record when sharing a `sqlite` client. |
@@ -199,7 +204,7 @@ QA corpus used by the parity suites.
199
204
  | `QA_TEST_CARD_TOKENS` | Test card tokens the suites use (`tok_visa`, decline tokens, ...). |
200
205
  | `QA_SEARCH_QUERIES` | Search queries the suites issue against `/v1/customers/search`. |
201
206
  | `QA_COUPON_CODES` | Coupon / promotion codes used by the coupon flows. |
202
- | `reshapeQaCommand` | Parity-walk hook that pins sampled commands onto QA corpus values (for `@crvouga/mockingbird-parity`). |
207
+ | `reshapeQaCommand` | Parity-walk hook that pins sampled commands onto QA corpus values (for the repo's parity runner). |
203
208
 
204
209
  `StripeAPI` members:
205
210
 
@@ -226,8 +231,9 @@ type WebhookPublisher = (event: StripeWebhookEvent) => void
226
231
  type OperationId / SupportedOperationId // string unions of operationIds / supportedOperationIds
227
232
  ```
228
233
 
229
- `SqliteClient` is the port from `@crvouga/mockingbird-sqlite`; `Database` from
230
- `@crvouga/mockingbird-service-sqlite` satisfies it, as do better-sqlite3 and wrapped `bun:sqlite`.
234
+ `SqliteClient` is the storage port bundled with this package (`exec`, `prepare(sql).run/all/get`,
235
+ `transaction`); `Database` from `@crvouga/mockingbird-service-sqlite` satisfies it, as do
236
+ better-sqlite3 and wrapped `bun:sqlite`.
231
237
 
232
238
  ## Development
233
239
 
@@ -251,4 +257,4 @@ PORT=12111 MOCKINGBIRD_STRIPE_WEBHOOK_TARGETS='[{"apiKey":"sk_test_mso","url":"h
251
257
 
252
258
  Live parity needs a real `sk_test_` key and mutates a shared test account.
253
259
 
254
- Part of [mockingbird](https://github.com/crvouga/mockingbird) — agent integration guide: [`@crvouga/mockingbird`](https://github.com/crvouga/mockingbird/tree/main/packages/facade#readme).
260
+ Part of [mockingbird](https://github.com/crvouga/mockingbird) — agent integration guide: [README](https://github.com/crvouga/mockingbird#readme) · [llms.txt](https://github.com/crvouga/mockingbird/blob/main/llms.txt).
package/dist/index.d.ts CHANGED
@@ -1,16 +1,360 @@
1
- import type { FetchAPI } from "@crvouga/mockingbird-core";
2
- import { type APIOptions } from "@crvouga/mockingbird-service";
3
- import type { SqliteClient } from "@crvouga/mockingbird-sqlite";
4
- import type { Hono } from "hono";
5
- import type { StripeWebhookEvent, WebhookPublisher } from "./internal.js";
6
- export { accountOf, accountOfKey } from "./account.js";
7
- export { STRIPE_NAMESPACE } from "./constants.js";
8
- export type { OperationId, SupportedOperationId } from "./generated/openapi.js";
9
- export { document, operationIds, supportedOperationIds } from "./generated/openapi.js";
10
- export type { StripeWebhookEvent, WebhookPublisher } from "./internal.js";
11
- export { QA_AMOUNTS, QA_COUPON_CODES, QA_CUSTOMER, QA_METADATA, QA_SEARCH_QUERIES, QA_SURFACE_OPS, QA_TEST_CARD_TOKENS, QA_TEST_PAYMENT_METHODS, } from "./qa-corpus.js";
12
- export { reshapeQaCommand } from "./reshape-qa.js";
13
- export type StripeAPIOptions = APIOptions & {
1
+ import { Hono } from 'hono';
2
+
3
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
4
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
5
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
6
+ type SqliteRunResult$1 = {
7
+ changes: number;
8
+ lastInsertRowid: number | bigint;
9
+ };
10
+ /**
11
+ * Prepared statement bound to a {@link SqliteClient}.
12
+ *
13
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
14
+ */
15
+ interface SqliteStatement$1 {
16
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
17
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
18
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
19
+ }
20
+ /**
21
+ * Sync SQLite client port owned by Mockingbird.
22
+ *
23
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
24
+ * `bun:sqlite` instances all work when they expose this surface.
25
+ */
26
+ interface SqliteClient$1 {
27
+ exec(sql: string): void;
28
+ prepare(sql: string): SqliteStatement$1;
29
+ transaction<T>(fn: () => T): T;
30
+ }
31
+
32
+ /** Options every provider constructor accepts. */
33
+ type APIOptions = {
34
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
35
+ sqlite?: SqliteClient$1;
36
+ /** Clock used for `created`-style fields. Default `Date.now`. */
37
+ now?: () => number;
38
+ };
39
+
40
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
41
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
42
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
43
+ type SqliteRunResult = {
44
+ changes: number;
45
+ lastInsertRowid: number | bigint;
46
+ };
47
+ /**
48
+ * Prepared statement bound to a {@link SqliteClient}.
49
+ *
50
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
51
+ */
52
+ interface SqliteStatement {
53
+ run(...params: SqliteValue[]): SqliteRunResult;
54
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
55
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
56
+ }
57
+ /**
58
+ * Sync SQLite client port owned by Mockingbird.
59
+ *
60
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
61
+ * `bun:sqlite` instances all work when they expose this surface.
62
+ */
63
+ interface SqliteClient {
64
+ exec(sql: string): void;
65
+ prepare(sql: string): SqliteStatement;
66
+ transaction<T>(fn: () => T): T;
67
+ }
68
+
69
+ type WebhookDeliveryAttemptRecord = {
70
+ message_id: string;
71
+ account: string;
72
+ attempt: number;
73
+ scheduled_at: string;
74
+ timeout_ms: number;
75
+ acknowledged: boolean;
76
+ };
77
+
78
+ /**
79
+ * Anything that can answer a Fetch `Request` with a `Response`.
80
+ *
81
+ * Every Mockingbird service implements this, and every runtime adapter consumes it.
82
+ * It is the only contract shared across the whole graph.
83
+ */
84
+ interface FetchAPI {
85
+ fetch(request: Request): Promise<Response>;
86
+ }
87
+
88
+ /** What the server publishes when the mock records an event. */
89
+ type StripeWebhookEvent = {
90
+ type: string;
91
+ account: string;
92
+ body: string;
93
+ };
94
+ type WebhookPublisher = (event: StripeWebhookEvent) => void;
95
+
96
+ /**
97
+ * Real Stripe partitions objects by account; the mock partitions by the bearer key that created
98
+ * them, so two different test keys are two accounts and a PC object is `resource_missing` on the
99
+ * MSO account. The key itself is never stored — only this deterministic, opaque token.
100
+ */
101
+ declare const accountOfKey: (key: string) => string;
102
+ declare const accountOf: (request: Request) => string;
103
+
104
+ /** SQLite namespace holding every Stripe record, sequence and event. */
105
+ declare const STRIPE_NAMESPACE = "stripe";
106
+
107
+ /**
108
+ * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
109
+ * Unknown keys (including `x-*` extensions) are preserved on every object.
110
+ */
111
+ type JsonPrimitive = string | number | boolean | null;
112
+ type JsonValue = JsonPrimitive | JsonValue[] | {
113
+ [key: string]: JsonValue;
114
+ };
115
+ type ReferenceObject = {
116
+ $ref: string;
117
+ description?: string;
118
+ summary?: string;
119
+ };
120
+ type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
121
+ type SchemaObject = {
122
+ $ref?: string;
123
+ type?: SchemaType | SchemaType[];
124
+ title?: string;
125
+ description?: string;
126
+ format?: string;
127
+ enum?: JsonValue[];
128
+ const?: JsonValue;
129
+ default?: JsonValue;
130
+ example?: JsonValue;
131
+ examples?: JsonValue[];
132
+ nullable?: boolean;
133
+ deprecated?: boolean;
134
+ readOnly?: boolean;
135
+ writeOnly?: boolean;
136
+ minimum?: number;
137
+ maximum?: number;
138
+ exclusiveMinimum?: number;
139
+ exclusiveMaximum?: number;
140
+ multipleOf?: number;
141
+ minLength?: number;
142
+ maxLength?: number;
143
+ pattern?: string;
144
+ minItems?: number;
145
+ maxItems?: number;
146
+ uniqueItems?: boolean;
147
+ items?: SchemaObject;
148
+ prefixItems?: SchemaObject[];
149
+ minProperties?: number;
150
+ maxProperties?: number;
151
+ required?: string[];
152
+ properties?: Record<string, SchemaObject>;
153
+ additionalProperties?: boolean | SchemaObject;
154
+ propertyNames?: SchemaObject;
155
+ oneOf?: SchemaObject[];
156
+ anyOf?: SchemaObject[];
157
+ allOf?: SchemaObject[];
158
+ not?: SchemaObject;
159
+ discriminator?: {
160
+ propertyName: string;
161
+ mapping?: Record<string, string>;
162
+ };
163
+ [extension: `x-${string}`]: unknown;
164
+ };
165
+ type ParameterLocation = "path" | "query" | "header" | "cookie";
166
+ type ParameterObject = {
167
+ name: string;
168
+ in: ParameterLocation;
169
+ description?: string;
170
+ required?: boolean;
171
+ deprecated?: boolean;
172
+ style?: string;
173
+ explode?: boolean;
174
+ schema?: SchemaObject;
175
+ content?: Record<string, MediaTypeObject>;
176
+ example?: JsonValue;
177
+ [extension: `x-${string}`]: unknown;
178
+ };
179
+ type MediaTypeObject = {
180
+ schema?: SchemaObject;
181
+ example?: JsonValue;
182
+ examples?: Record<string, unknown>;
183
+ encoding?: Record<string, unknown>;
184
+ [extension: `x-${string}`]: unknown;
185
+ };
186
+ type RequestBodyObject = {
187
+ description?: string;
188
+ required?: boolean;
189
+ content: Record<string, MediaTypeObject>;
190
+ [extension: `x-${string}`]: unknown;
191
+ };
192
+ type HeaderObject = {
193
+ description?: string;
194
+ required?: boolean;
195
+ schema?: SchemaObject;
196
+ [extension: `x-${string}`]: unknown;
197
+ };
198
+ type ResponseObject = {
199
+ description: string;
200
+ headers?: Record<string, HeaderObject | ReferenceObject>;
201
+ content?: Record<string, MediaTypeObject>;
202
+ [extension: `x-${string}`]: unknown;
203
+ };
204
+ type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
205
+ type SecurityRequirementObject = Record<string, string[]>;
206
+ type OperationObject = {
207
+ operationId?: string;
208
+ summary?: string;
209
+ description?: string;
210
+ tags?: string[];
211
+ deprecated?: boolean;
212
+ parameters?: Array<ParameterObject | ReferenceObject>;
213
+ requestBody?: RequestBodyObject | ReferenceObject;
214
+ responses: ResponsesObject;
215
+ security?: SecurityRequirementObject[];
216
+ [extension: `x-${string}`]: unknown;
217
+ };
218
+ declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
219
+ type HttpMethod = (typeof HTTP_METHODS)[number];
220
+ type PathItemObject = {
221
+ summary?: string;
222
+ description?: string;
223
+ parameters?: Array<ParameterObject | ReferenceObject>;
224
+ [extension: `x-${string}`]: unknown;
225
+ } & Partial<Record<HttpMethod, OperationObject>>;
226
+ type SecuritySchemeObject = {
227
+ type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
228
+ description?: string;
229
+ name?: string;
230
+ in?: ParameterLocation;
231
+ scheme?: string;
232
+ bearerFormat?: string;
233
+ flows?: Record<string, unknown>;
234
+ openIdConnectUrl?: string;
235
+ [extension: `x-${string}`]: unknown;
236
+ };
237
+ type ComponentsObject = {
238
+ schemas?: Record<string, SchemaObject>;
239
+ responses?: Record<string, ResponseObject>;
240
+ parameters?: Record<string, ParameterObject>;
241
+ requestBodies?: Record<string, RequestBodyObject>;
242
+ headers?: Record<string, HeaderObject>;
243
+ securitySchemes?: Record<string, SecuritySchemeObject>;
244
+ [extension: `x-${string}`]: unknown;
245
+ };
246
+ type ServerObject = {
247
+ url: string;
248
+ description?: string;
249
+ variables?: Record<string, unknown>;
250
+ [extension: `x-${string}`]: unknown;
251
+ };
252
+ type InfoObject = {
253
+ title: string;
254
+ version: string;
255
+ description?: string;
256
+ [extension: `x-${string}`]: unknown;
257
+ };
258
+ type OpenAPIDocument = {
259
+ openapi: string;
260
+ info: InfoObject;
261
+ servers?: ServerObject[];
262
+ paths: Record<string, PathItemObject>;
263
+ components?: ComponentsObject;
264
+ security?: SecurityRequirementObject[];
265
+ tags?: Array<{
266
+ name: string;
267
+ description?: string;
268
+ }>;
269
+ [extension: `x-${string}`]: unknown;
270
+ };
271
+
272
+ declare const document: OpenAPIDocument;
273
+ type OperationId = "GetBalanceTransactions" | "GetBalanceTransactionsId" | "GetCharges" | "PostCharges" | "GetChargesCharge" | "PostChargesCharge" | "GetCheckoutSessions" | "PostCheckoutSessions" | "GetCheckoutSessionsSession" | "PostCheckoutSessionsSession" | "PostCheckoutSessionsSessionExpire" | "GetCheckoutSessionsSessionLineItems" | "GetCoupons" | "PostCoupons" | "GetCouponsCoupon" | "PostCouponsCoupon" | "DeleteCouponsCoupon" | "GetCustomers" | "PostCustomers" | "GetCustomersCustomer" | "PostCustomersCustomer" | "DeleteCustomersCustomer" | "GetCustomersCustomerBalanceTransactions" | "PostCustomersCustomerBalanceTransactions" | "GetCustomersSearch" | "GetDisputes" | "GetDisputesDispute" | "PostDisputesDispute" | "GetEvents" | "GetEventsId" | "GetInvoiceitems" | "PostInvoiceitems" | "GetInvoiceitemsInvoiceitem" | "PostInvoiceitemsInvoiceitem" | "DeleteInvoiceitemsInvoiceitem" | "GetInvoices" | "PostInvoices" | "GetInvoicesInvoice" | "PostInvoicesInvoice" | "DeleteInvoicesInvoice" | "PostInvoicesInvoiceFinalize" | "GetInvoicesInvoiceLines" | "PostInvoicesInvoicePay" | "GetInvoicesUpcoming" | "GetPaymentIntents" | "PostPaymentIntents" | "GetPaymentIntentsIntent" | "PostPaymentIntentsIntent" | "PostPaymentIntentsIntentCancel" | "PostPaymentIntentsIntentCapture" | "PostPaymentIntentsIntentConfirm" | "GetPaymentIntentsSearch" | "GetPaymentMethods" | "PostPaymentMethods" | "GetPaymentMethodsPaymentMethod" | "PostPaymentMethodsPaymentMethod" | "PostPaymentMethodsPaymentMethodAttach" | "PostPaymentMethodsPaymentMethodDetach" | "GetPrices" | "PostPrices" | "GetPricesPrice" | "PostPricesPrice" | "GetProducts" | "PostProducts" | "GetProductsId" | "PostProductsId" | "DeleteProductsId" | "GetProductsSearch" | "GetPromotionCodes" | "PostPromotionCodes" | "GetPromotionCodesPromotionCode" | "PostPromotionCodesPromotionCode" | "GetRefunds" | "PostRefunds" | "GetRefundsRefund" | "PostRefundsRefund" | "GetSetupIntents" | "PostSetupIntents" | "GetSetupIntentsIntent" | "PostSetupIntentsIntent" | "PostSetupIntentsIntentCancel" | "PostSetupIntentsIntentConfirm" | "GetSubscriptionItems" | "PostSubscriptionItems" | "GetSubscriptionItemsItem" | "PostSubscriptionItemsItem" | "DeleteSubscriptionItemsItem" | "GetSubscriptionSchedules" | "PostSubscriptionSchedules" | "GetSubscriptionSchedulesSchedule" | "PostSubscriptionSchedulesSchedule" | "PostSubscriptionSchedulesScheduleCancel" | "PostSubscriptionSchedulesScheduleRelease" | "GetSubscriptions" | "PostSubscriptions" | "GetSubscriptionsSubscriptionExposedId" | "PostSubscriptionsSubscriptionExposedId" | "DeleteSubscriptionsSubscriptionExposedId" | "GetTestHelpersTestClocks" | "PostTestHelpersTestClocks" | "GetTestHelpersTestClocksTestClock" | "DeleteTestHelpersTestClocksTestClock" | "PostTestHelpersTestClocksTestClockAdvance" | "GetWebhookEndpoints" | "PostWebhookEndpoints" | "GetWebhookEndpointsWebhookEndpoint" | "PostWebhookEndpointsWebhookEndpoint" | "DeleteWebhookEndpointsWebhookEndpoint";
274
+ type SupportedOperationId = "GetCharges" | "GetChargesCharge" | "GetCheckoutSessions" | "PostCheckoutSessions" | "GetCheckoutSessionsSession" | "PostCheckoutSessionsSessionExpire" | "GetCheckoutSessionsSessionLineItems" | "GetCoupons" | "PostCoupons" | "GetCouponsCoupon" | "PostCouponsCoupon" | "GetCustomers" | "PostCustomers" | "GetCustomersCustomer" | "PostCustomersCustomer" | "DeleteCustomersCustomer" | "GetCustomersCustomerBalanceTransactions" | "PostCustomersCustomerBalanceTransactions" | "GetCustomersSearch" | "GetDisputes" | "GetDisputesDispute" | "GetEvents" | "GetEventsId" | "GetInvoiceitems" | "PostInvoiceitems" | "GetInvoiceitemsInvoiceitem" | "PostInvoiceitemsInvoiceitem" | "DeleteInvoiceitemsInvoiceitem" | "GetInvoices" | "PostInvoices" | "GetInvoicesInvoice" | "PostInvoicesInvoice" | "DeleteInvoicesInvoice" | "PostInvoicesInvoiceFinalize" | "GetInvoicesInvoiceLines" | "PostInvoicesInvoicePay" | "GetInvoicesUpcoming" | "GetPaymentIntents" | "PostPaymentIntents" | "GetPaymentIntentsIntent" | "PostPaymentIntentsIntent" | "PostPaymentIntentsIntentCancel" | "PostPaymentIntentsIntentCapture" | "PostPaymentIntentsIntentConfirm" | "GetPaymentIntentsSearch" | "GetPaymentMethods" | "PostPaymentMethods" | "GetPaymentMethodsPaymentMethod" | "PostPaymentMethodsPaymentMethod" | "PostPaymentMethodsPaymentMethodAttach" | "PostPaymentMethodsPaymentMethodDetach" | "GetPrices" | "PostPrices" | "GetPricesPrice" | "PostPricesPrice" | "GetProducts" | "PostProducts" | "GetProductsId" | "PostProductsId" | "DeleteProductsId" | "GetProductsSearch" | "GetPromotionCodes" | "PostPromotionCodes" | "GetPromotionCodesPromotionCode" | "PostPromotionCodesPromotionCode" | "GetRefunds" | "PostRefunds" | "GetRefundsRefund" | "PostRefundsRefund" | "GetSetupIntents" | "PostSetupIntents" | "GetSetupIntentsIntent" | "PostSetupIntentsIntent" | "PostSetupIntentsIntentCancel" | "PostSetupIntentsIntentConfirm" | "GetSubscriptionItems" | "GetSubscriptionItemsItem" | "GetSubscriptionSchedules" | "PostSubscriptionSchedules" | "GetSubscriptionSchedulesSchedule" | "PostSubscriptionSchedulesSchedule" | "PostSubscriptionSchedulesScheduleCancel" | "PostSubscriptionSchedulesScheduleRelease" | "GetSubscriptions" | "PostSubscriptions" | "GetSubscriptionsSubscriptionExposedId" | "PostSubscriptionsSubscriptionExposedId" | "DeleteSubscriptionsSubscriptionExposedId";
275
+ declare const operationIds: readonly ["GetBalanceTransactions", "GetBalanceTransactionsId", "GetCharges", "PostCharges", "GetChargesCharge", "PostChargesCharge", "GetCheckoutSessions", "PostCheckoutSessions", "GetCheckoutSessionsSession", "PostCheckoutSessionsSession", "PostCheckoutSessionsSessionExpire", "GetCheckoutSessionsSessionLineItems", "GetCoupons", "PostCoupons", "GetCouponsCoupon", "PostCouponsCoupon", "DeleteCouponsCoupon", "GetCustomers", "PostCustomers", "GetCustomersCustomer", "PostCustomersCustomer", "DeleteCustomersCustomer", "GetCustomersCustomerBalanceTransactions", "PostCustomersCustomerBalanceTransactions", "GetCustomersSearch", "GetDisputes", "GetDisputesDispute", "PostDisputesDispute", "GetEvents", "GetEventsId", "GetInvoiceitems", "PostInvoiceitems", "GetInvoiceitemsInvoiceitem", "PostInvoiceitemsInvoiceitem", "DeleteInvoiceitemsInvoiceitem", "GetInvoices", "PostInvoices", "GetInvoicesInvoice", "PostInvoicesInvoice", "DeleteInvoicesInvoice", "PostInvoicesInvoiceFinalize", "GetInvoicesInvoiceLines", "PostInvoicesInvoicePay", "GetInvoicesUpcoming", "GetPaymentIntents", "PostPaymentIntents", "GetPaymentIntentsIntent", "PostPaymentIntentsIntent", "PostPaymentIntentsIntentCancel", "PostPaymentIntentsIntentCapture", "PostPaymentIntentsIntentConfirm", "GetPaymentIntentsSearch", "GetPaymentMethods", "PostPaymentMethods", "GetPaymentMethodsPaymentMethod", "PostPaymentMethodsPaymentMethod", "PostPaymentMethodsPaymentMethodAttach", "PostPaymentMethodsPaymentMethodDetach", "GetPrices", "PostPrices", "GetPricesPrice", "PostPricesPrice", "GetProducts", "PostProducts", "GetProductsId", "PostProductsId", "DeleteProductsId", "GetProductsSearch", "GetPromotionCodes", "PostPromotionCodes", "GetPromotionCodesPromotionCode", "PostPromotionCodesPromotionCode", "GetRefunds", "PostRefunds", "GetRefundsRefund", "PostRefundsRefund", "GetSetupIntents", "PostSetupIntents", "GetSetupIntentsIntent", "PostSetupIntentsIntent", "PostSetupIntentsIntentCancel", "PostSetupIntentsIntentConfirm", "GetSubscriptionItems", "PostSubscriptionItems", "GetSubscriptionItemsItem", "PostSubscriptionItemsItem", "DeleteSubscriptionItemsItem", "GetSubscriptionSchedules", "PostSubscriptionSchedules", "GetSubscriptionSchedulesSchedule", "PostSubscriptionSchedulesSchedule", "PostSubscriptionSchedulesScheduleCancel", "PostSubscriptionSchedulesScheduleRelease", "GetSubscriptions", "PostSubscriptions", "GetSubscriptionsSubscriptionExposedId", "PostSubscriptionsSubscriptionExposedId", "DeleteSubscriptionsSubscriptionExposedId", "GetTestHelpersTestClocks", "PostTestHelpersTestClocks", "GetTestHelpersTestClocksTestClock", "DeleteTestHelpersTestClocksTestClock", "PostTestHelpersTestClocksTestClockAdvance", "GetWebhookEndpoints", "PostWebhookEndpoints", "GetWebhookEndpointsWebhookEndpoint", "PostWebhookEndpointsWebhookEndpoint", "DeleteWebhookEndpointsWebhookEndpoint"];
276
+ declare const supportedOperationIds: readonly ["GetCharges", "GetChargesCharge", "GetCheckoutSessions", "PostCheckoutSessions", "GetCheckoutSessionsSession", "PostCheckoutSessionsSessionExpire", "GetCheckoutSessionsSessionLineItems", "GetCoupons", "PostCoupons", "GetCouponsCoupon", "PostCouponsCoupon", "GetCustomers", "PostCustomers", "GetCustomersCustomer", "PostCustomersCustomer", "DeleteCustomersCustomer", "GetCustomersCustomerBalanceTransactions", "PostCustomersCustomerBalanceTransactions", "GetCustomersSearch", "GetDisputes", "GetDisputesDispute", "GetEvents", "GetEventsId", "GetInvoiceitems", "PostInvoiceitems", "GetInvoiceitemsInvoiceitem", "PostInvoiceitemsInvoiceitem", "DeleteInvoiceitemsInvoiceitem", "GetInvoices", "PostInvoices", "GetInvoicesInvoice", "PostInvoicesInvoice", "DeleteInvoicesInvoice", "PostInvoicesInvoiceFinalize", "GetInvoicesInvoiceLines", "PostInvoicesInvoicePay", "GetInvoicesUpcoming", "GetPaymentIntents", "PostPaymentIntents", "GetPaymentIntentsIntent", "PostPaymentIntentsIntent", "PostPaymentIntentsIntentCancel", "PostPaymentIntentsIntentCapture", "PostPaymentIntentsIntentConfirm", "GetPaymentIntentsSearch", "GetPaymentMethods", "PostPaymentMethods", "GetPaymentMethodsPaymentMethod", "PostPaymentMethodsPaymentMethod", "PostPaymentMethodsPaymentMethodAttach", "PostPaymentMethodsPaymentMethodDetach", "GetPrices", "PostPrices", "GetPricesPrice", "PostPricesPrice", "GetProducts", "PostProducts", "GetProductsId", "PostProductsId", "DeleteProductsId", "GetProductsSearch", "GetPromotionCodes", "PostPromotionCodes", "GetPromotionCodesPromotionCode", "PostPromotionCodesPromotionCode", "GetRefunds", "PostRefunds", "GetRefundsRefund", "PostRefundsRefund", "GetSetupIntents", "PostSetupIntents", "GetSetupIntentsIntent", "PostSetupIntentsIntent", "PostSetupIntentsIntentCancel", "PostSetupIntentsIntentConfirm", "GetSubscriptionItems", "GetSubscriptionItemsItem", "GetSubscriptionSchedules", "PostSubscriptionSchedules", "GetSubscriptionSchedulesSchedule", "PostSubscriptionSchedulesSchedule", "PostSubscriptionSchedulesScheduleCancel", "PostSubscriptionSchedulesScheduleRelease", "GetSubscriptions", "PostSubscriptions", "GetSubscriptionsSubscriptionExposedId", "PostSubscriptionsSubscriptionExposedId", "DeleteSubscriptionsSubscriptionExposedId"];
277
+
278
+ /**
279
+ * The Stripe surface the QA suites exercise: every operation the vendored contract marks
280
+ * supported (the unsupported ones answer a Stripe-shaped error by design and are listed with
281
+ * reasons in SUPPORT.md). Derived from the document so the list can never drift from the contract.
282
+ */
283
+ declare const QA_SURFACE_OPS: readonly string[];
284
+ /** Pinned values the suites use, so offline walks exercise realistic shapes. */
285
+ declare const QA_METADATA: {
286
+ readonly intent: "e2e-test";
287
+ readonly source: "e2e-test";
288
+ readonly userId: "1001";
289
+ };
290
+ declare const QA_AMOUNTS: readonly [1000, 15000, 17999];
291
+ declare const QA_CUSTOMER: {
292
+ readonly email: "qa+e2e@test.example.com";
293
+ readonly name: "Ada Lovelace";
294
+ readonly phone: "+15555550123";
295
+ };
296
+ /** Test payment methods and card tokens the suites attach by id. */
297
+ declare const QA_TEST_PAYMENT_METHODS: readonly ["pm_card_visa", "pm_card_mastercard", "pm_card_authenticationRequired"];
298
+ declare const QA_TEST_CARD_TOKENS: readonly ["tok_visa", "tok_mastercard", "tok_chargeDeclinedInsufficientFunds", "tok_chargeDeclinedExpiredCard", "tok_chargeCustomerFail"];
299
+ /** Search queries the suites issue, covering every metadata key their handlers read. */
300
+ declare const QA_SEARCH_QUERIES: readonly ["metadata['userId']:'1001'", "metadata['paymentId']:'1001'", "metadata['billingInvoiceId']:'inv_1001'", "email:'qa+e2e@test.example.com'"];
301
+ /** Coupon / promotion-code fixture values used by the shop and coupon flows. */
302
+ declare const QA_COUPON_CODES: readonly ["QA10", "QA-FREE-BLOODWORK"];
303
+
304
+ type Violation = "wrong-type" | "string-too-long" | "string-too-short" | "number-too-large" | "number-too-small" | "not-in-enum" | "missing-required" | "unexpected-property" | "array-too-long" | "array-too-short" | "bad-format";
305
+ type Mutation = {
306
+ /** Location of the mutated value in generated *values* (not schema keywords). */
307
+ valuePath: Array<string | number>;
308
+ violation: Violation;
309
+ detail: string;
310
+ };
311
+
312
+ /**
313
+ * One generated API call. Concrete ids never appear here: resource references are
314
+ * {@link Placeholder}s resolved per side at execution time, which is what lets the same command
315
+ * run against the real API and the mock.
316
+ */
317
+ type LogicalCommand = {
318
+ operationId: string;
319
+ /** Path, query and header parameter values by name. */
320
+ parameters: Record<string, unknown>;
321
+ body: unknown;
322
+ mediaType: string | undefined;
323
+ /** Set when the body was deliberately mutated to violate its schema. */
324
+ invalid: Mutation | undefined;
325
+ };
326
+
327
+ /** Mutable walk state consulted by {@link DynamicWeightFn}. */
328
+ type ExploreState = {
329
+ /** operationId → times exercised in this walk. */
330
+ coverage: Record<string, number>;
331
+ /** Recent operationIds (oldest → newest), typically capped. */
332
+ history: readonly string[];
333
+ /** Active resource counts by type (user, order, …). */
334
+ resourceCounts: Record<string, number>;
335
+ phase: "warmup" | "compare" | "walk";
336
+ step: number;
337
+ maxSteps: number;
338
+ /** Optional observed GET cache size — used to unlock geo/scheduling reads. */
339
+ observationCacheSize?: number;
340
+ };
341
+ /** Mulberry32 PRNG — deterministic from a 32-bit seed. */
342
+ declare const createExploreRng: (seed: number) => {
343
+ /** Uniform float in [0, 1). */
344
+ next: () => number;
345
+ /** Uniform int in [0, max] inclusive. */
346
+ nextInt: (max: number) => number;
347
+ };
348
+ type ExploreRng = ReturnType<typeof createExploreRng>;
349
+
350
+ /**
351
+ * Pin sampled commands onto the values the QA suites actually send, so offline seedParity walks
352
+ * stay deterministic and hit the same code paths a real run does: amounts and currency from the
353
+ * corpus, the metadata keys the backend reads, and the documented test payment methods.
354
+ */
355
+ declare const reshapeQaCommand: (command: LogicalCommand, _state: ExploreState, rng: ExploreRng) => LogicalCommand;
356
+
357
+ type StripeAPIOptions = APIOptions & {
14
358
  /** Called with every event the mock records, so a server can deliver it. */
15
359
  onWebhook?: WebhookPublisher;
16
360
  };
@@ -19,7 +363,7 @@ export type StripeAPIOptions = APIOptions & {
19
363
  * behave like two accounts. Pass `sqlite` to share a client across services; omit it to get a
20
364
  * fresh `@crvouga/mockingbird-service-sqlite` database.
21
365
  */
22
- export declare class StripeAPI implements FetchAPI {
366
+ declare class StripeAPI implements FetchAPI {
23
367
  readonly app: Hono;
24
368
  readonly sqlite: SqliteClient;
25
369
  private readonly service;
@@ -37,7 +381,9 @@ export declare class StripeAPI implements FetchAPI {
37
381
  * (`accountOfKey("sk_test_…")`); omit it for every partition the instance has seen.
38
382
  */
39
383
  webhookEvents(account?: string): StripeWebhookEvent[];
40
- webhookDeliveryAttempts(account?: string): import("./state.js").WebhookDeliveryAttemptRecord[];
384
+ webhookDeliveryAttempts(account?: string): WebhookDeliveryAttemptRecord[];
41
385
  reset(): Promise<void>;
42
386
  }
43
- //# sourceMappingURL=index.d.ts.map
387
+
388
+ export { QA_AMOUNTS, QA_COUPON_CODES, QA_CUSTOMER, QA_METADATA, QA_SEARCH_QUERIES, QA_SURFACE_OPS, QA_TEST_CARD_TOKENS, QA_TEST_PAYMENT_METHODS, STRIPE_NAMESPACE, StripeAPI, accountOf, accountOfKey, document, operationIds, reshapeQaCommand, supportedOperationIds };
389
+ export type { FetchAPI, OperationId, SqliteClient, StripeAPIOptions, StripeWebhookEvent, SupportedOperationId, WebhookPublisher };