@devlab.group/agent-commerce 2.5.0 → 2.6.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 (100) hide show
  1. package/README.md +63 -11
  2. package/dist/ap2.d.ts +19 -6
  3. package/dist/ap2.js +56 -18
  4. package/dist/ap2.js.map +1 -1
  5. package/dist/{chunk-FKQK5XZA.js → chunk-DRLBML7Z.js} +13 -11
  6. package/dist/chunk-DRLBML7Z.js.map +1 -0
  7. package/dist/{chunk-VUCMBGUR.js → chunk-G3EYYHKF.js} +3 -3
  8. package/dist/{chunk-VUCMBGUR.js.map → chunk-G3EYYHKF.js.map} +1 -1
  9. package/dist/{chunk-3OTCFFFT.js → chunk-M52FBNJX.js} +3 -5
  10. package/dist/chunk-M52FBNJX.js.map +1 -0
  11. package/dist/chunk-M6BSXXTF.js +8 -0
  12. package/dist/chunk-M6BSXXTF.js.map +1 -0
  13. package/dist/{chunk-4K7FIBJM.js → chunk-M6MQ3FYS.js} +3 -3
  14. package/dist/{chunk-4K7FIBJM.js.map → chunk-M6MQ3FYS.js.map} +1 -1
  15. package/dist/chunk-M6WW6QIT.js +18 -0
  16. package/dist/chunk-M6WW6QIT.js.map +1 -0
  17. package/dist/cli/{ap2-YAPLERSC.js → ap2-2YMYA2H6.js} +57 -20
  18. package/dist/cli/ap2-2YMYA2H6.js.map +1 -0
  19. package/dist/cli/{chunk-5R7DM5LM.js → chunk-3NOMLMJW.js} +26 -26
  20. package/dist/cli/chunk-3NOMLMJW.js.map +1 -0
  21. package/dist/cli/chunk-4KLYFXMW.js +8 -0
  22. package/dist/cli/{chunk-M7NXVRU5.js.map → chunk-4KLYFXMW.js.map} +1 -1
  23. package/dist/cli/chunk-6R6WJ4FD.js +18 -0
  24. package/dist/cli/chunk-6R6WJ4FD.js.map +1 -0
  25. package/dist/cli/{chunk-2J2IQQ4X.js → chunk-AZL7RPFU.js} +37 -32
  26. package/dist/cli/chunk-AZL7RPFU.js.map +1 -0
  27. package/dist/cli/{chunk-JFVRG2HH.js → chunk-DHFMIBPG.js} +7 -7
  28. package/dist/cli/chunk-DHFMIBPG.js.map +1 -0
  29. package/dist/cli/{chunk-IDY2735M.js → chunk-GET3CZGR.js} +2 -2
  30. package/dist/cli/chunk-GET3CZGR.js.map +1 -0
  31. package/dist/cli/{chunk-QLUCNPRT.js → chunk-NSYSMDQN.js} +831 -169
  32. package/dist/cli/chunk-NSYSMDQN.js.map +1 -0
  33. package/dist/cli/{chunk-Z34UMZBB.js → chunk-PTL7SNOI.js} +83 -57
  34. package/dist/cli/chunk-PTL7SNOI.js.map +1 -0
  35. package/dist/cli/{chunk-2UPPX3FJ.js → chunk-TFV3K6YS.js} +75 -13
  36. package/dist/cli/chunk-TFV3K6YS.js.map +1 -0
  37. package/dist/cli/{chunk-NIU5EMSB.js → chunk-VJH6RYRK.js} +5 -5
  38. package/dist/cli/{chunk-NIU5EMSB.js.map → chunk-VJH6RYRK.js.map} +1 -1
  39. package/dist/cli/{chunk-QA2OPHBF.js → chunk-YOF7IK4V.js} +14 -13
  40. package/dist/cli/chunk-YOF7IK4V.js.map +1 -0
  41. package/dist/cli/{chunk-4H2QLHQI.js → chunk-YWG2ZN3L.js} +3 -3
  42. package/dist/cli/{chunk-4H2QLHQI.js.map → chunk-YWG2ZN3L.js.map} +1 -1
  43. package/dist/cli/config-3K65QJ22.js +12 -0
  44. package/dist/cli/{config-BWFMN2ZB.js.map → config-3K65QJ22.js.map} +1 -1
  45. package/dist/cli/index.js +524 -230
  46. package/dist/cli/index.js.map +1 -1
  47. package/dist/cli/{mcp-KZEMXLHR.js → mcp-6F64A7KE.js} +4 -4
  48. package/dist/cli/{mcp-KZEMXLHR.js.map → mcp-6F64A7KE.js.map} +1 -1
  49. package/dist/cli/payment-providers-2ITS6KNR.js +6 -0
  50. package/dist/cli/{payment-providers-SZL36H3Y.js.map → payment-providers-2ITS6KNR.js.map} +1 -1
  51. package/dist/cli/{provider-6TKB5ADJ.js → provider-5BGG5YKQ.js} +34 -16
  52. package/dist/cli/provider-5BGG5YKQ.js.map +1 -0
  53. package/dist/cli/receipts-I4IIE7U6.js +8 -0
  54. package/dist/cli/{receipts-ZGLJWMQG.js.map → receipts-I4IIE7U6.js.map} +1 -1
  55. package/dist/cli/reconcile-55WNCSFC.js +4 -0
  56. package/dist/cli/{reconcile-IC22MJD5.js.map → reconcile-55WNCSFC.js.map} +1 -1
  57. package/dist/cli/{run-ZTYPQI4D.js → run-2P6ZGFUE.js} +220 -73
  58. package/dist/cli/run-2P6ZGFUE.js.map +1 -0
  59. package/dist/cli/{x402-WLYBLODI.js → x402-4LPIIELI.js} +8 -8
  60. package/dist/cli/{x402-WLYBLODI.js.map → x402-4LPIIELI.js.map} +1 -1
  61. package/dist/index.d.ts +104 -201
  62. package/dist/index.js +1048 -262
  63. package/dist/index.js.map +1 -1
  64. package/dist/logger-CllGwQ8i.d.ts +19 -0
  65. package/dist/mcp.d.ts +3 -1
  66. package/dist/mcp.js +2 -1
  67. package/dist/mcp.js.map +1 -1
  68. package/dist/mpp.d.ts +2 -1
  69. package/dist/mpp.js +31 -12
  70. package/dist/mpp.js.map +1 -1
  71. package/dist/{protocol-adapter-DEXpdp8m.d.ts → protocol-adapter-1WbtM3xG.d.ts} +5 -132
  72. package/dist/{runtime-Dz2fSO-P.d.ts → runtime-B-kARa2f.d.ts} +5 -20
  73. package/dist/store-kIIMpUA-.d.ts +372 -0
  74. package/dist/testing.d.ts +51 -0
  75. package/dist/testing.js +1896 -0
  76. package/dist/testing.js.map +1 -0
  77. package/dist/transaction-Dv0UFGg5.d.ts +129 -0
  78. package/dist/{types-j7MnUXYN.d.ts → types-DWqjz81-.d.ts} +5 -2
  79. package/dist/x402.d.ts +2 -1
  80. package/dist/x402.js +5 -4
  81. package/dist/x402.js.map +1 -1
  82. package/package.json +5 -1
  83. package/dist/chunk-3OTCFFFT.js.map +0 -1
  84. package/dist/chunk-FKQK5XZA.js.map +0 -1
  85. package/dist/cli/ap2-YAPLERSC.js.map +0 -1
  86. package/dist/cli/chunk-2J2IQQ4X.js.map +0 -1
  87. package/dist/cli/chunk-2UPPX3FJ.js.map +0 -1
  88. package/dist/cli/chunk-5R7DM5LM.js.map +0 -1
  89. package/dist/cli/chunk-IDY2735M.js.map +0 -1
  90. package/dist/cli/chunk-JFVRG2HH.js.map +0 -1
  91. package/dist/cli/chunk-M7NXVRU5.js +0 -8
  92. package/dist/cli/chunk-QA2OPHBF.js.map +0 -1
  93. package/dist/cli/chunk-QLUCNPRT.js.map +0 -1
  94. package/dist/cli/chunk-Z34UMZBB.js.map +0 -1
  95. package/dist/cli/config-BWFMN2ZB.js +0 -12
  96. package/dist/cli/payment-providers-SZL36H3Y.js +0 -6
  97. package/dist/cli/provider-6TKB5ADJ.js.map +0 -1
  98. package/dist/cli/receipts-ZGLJWMQG.js +0 -8
  99. package/dist/cli/reconcile-IC22MJD5.js +0 -4
  100. package/dist/cli/run-ZTYPQI4D.js.map +0 -1
@@ -0,0 +1,372 @@
1
+ import { k as AuthorizationMethodName, I as IsoTimestamp, K as ProtocolName, l as AuthorizationRecord, t as PaymentAttempt, p as CommerceReceipt, u as PaymentAttemptResolution, g as AdapterDescriptor, h as AdapterHealth } from './runtime-B-kARa2f.js';
2
+ import { A as AuthorizationHoldState, a as CommerceEvent, P as PersistenceFailure, c as Transaction, e as TransactionState } from './transaction-Dv0UFGg5.js';
3
+
4
+ /**
5
+ * Protocol-neutral records for the receipt store's optional methods:
6
+ * idempotency claims, authorization holds and pending tasks. Adapters and
7
+ * authorization providers map their own data to these types at their boundaries.
8
+ */
9
+
10
+ /** Experimental: may change in a minor release */
11
+ interface IdempotencyScope {
12
+ /** The gateway's public base URL, which survives a credential rotation */
13
+ readonly deployment: string;
14
+ /** The concrete endpoint path, so a client may reuse one key across operations */
15
+ readonly endpoint: string;
16
+ readonly key: string;
17
+ }
18
+ /** Result of claiming an idempotency key. Experimental: may change in a minor release */
19
+ type IdempotencyClaim =
20
+ /** The caller owns the key and must perform the operation */
21
+ {
22
+ readonly kind: 'reserved';
23
+ }
24
+ /** Same fingerprint; an earlier claim is still in flight */
25
+ | {
26
+ readonly kind: 'in-flight';
27
+ }
28
+ /** Same fingerprint; an earlier attempt's outcome is unknown */
29
+ | {
30
+ readonly kind: 'unresolved';
31
+ }
32
+ /** A different fingerprint, regardless of the claim's state */
33
+ | {
34
+ readonly kind: 'conflict';
35
+ }
36
+ /** Same fingerprint; replay the stored response */
37
+ | {
38
+ readonly kind: 'replay';
39
+ readonly status: number;
40
+ readonly body: unknown;
41
+ };
42
+ /**
43
+ * An idempotency claim's outcome. `body` must be JSON-serializable.
44
+ * Experimental: may change in a minor release.
45
+ */
46
+ type IdempotencyUpdate =
47
+ /** Store the response for later claims with the same fingerprint to replay */
48
+ {
49
+ readonly kind: 'completed';
50
+ readonly status: number;
51
+ readonly body: unknown;
52
+ }
53
+ /** Keep the claim without a response and refuse retries: the operation may have run */
54
+ | {
55
+ readonly kind: 'unresolved';
56
+ }
57
+ /** Delete only if no backend call ran or the backend deduplicates by this key */
58
+ | {
59
+ readonly kind: 'released';
60
+ };
61
+ /** Experimental: may change in a minor release */
62
+ interface AuthorizationHoldReservation {
63
+ readonly method: AuthorizationMethodName;
64
+ /** Identifies one authorization, unique across the store. AP2: the issuer-signed token's digest */
65
+ readonly reference: string;
66
+ /** Identifies a binding with at most one unreleased hold. AP2: the checkout JWT's `jti` */
67
+ readonly bindingReference: string;
68
+ readonly resourceId: string;
69
+ readonly requestId: string;
70
+ /** Non-secret operator identifiers, such as issuers; never presentations or signatures */
71
+ readonly metadata?: Readonly<Record<string, string>>;
72
+ }
73
+ /** Experimental: may change in a minor release */
74
+ type AuthorizationHoldResult = {
75
+ readonly kind: 'reserved';
76
+ }
77
+ /** The reference or its binding is already held; refuse the authorization */
78
+ | {
79
+ readonly kind: 'replayed';
80
+ readonly state: AuthorizationHoldState;
81
+ };
82
+ /** Experimental: may change in a minor release */
83
+ interface AuthorizationHold extends AuthorizationHoldReservation {
84
+ readonly state: AuthorizationHoldState;
85
+ readonly createdAt: IsoTimestamp;
86
+ readonly updatedAt: IsoTimestamp;
87
+ }
88
+ /**
89
+ * A purchase awaiting its payment message. Experimental: may change in a
90
+ * minor release.
91
+ */
92
+ interface PendingTask {
93
+ /** Unique across the store */
94
+ readonly id: string;
95
+ readonly protocol: ProtocolName;
96
+ readonly resourceId: string;
97
+ /**
98
+ * JSON-serializable purchase input with reserved fields removed. Must not
99
+ * contain payment proofs or authorization presentations.
100
+ */
101
+ readonly input: Readonly<Record<string, unknown>>;
102
+ /** JSON-serializable data that only the adapter interprets */
103
+ readonly adapterData?: Readonly<Record<string, unknown>>;
104
+ /** Set and bounded by the caller */
105
+ readonly expiresAt: IsoTimestamp;
106
+ }
107
+
108
+ /**
109
+ * Persistence boundary for receipts, events and payment attempts, implemented
110
+ * by src/storage/receipts. Core depends only on this interface, never on
111
+ * SQLite.
112
+ */
113
+
114
+ interface PaymentAttemptReservation {
115
+ readonly requestId: string;
116
+ readonly resourceId: string;
117
+ readonly provider: string;
118
+ /** Must be unique across the store; see `PaymentResult.replayKey` */
119
+ readonly replayKey: string;
120
+ readonly amount: string;
121
+ readonly currency: string;
122
+ readonly payer?: string;
123
+ readonly payee?: string;
124
+ /**
125
+ * Reclaim this `replayKey` if the same `provider` rejected it, which
126
+ * settled nothing. Set only for rails whose authorizations remain reusable
127
+ * until settled.
128
+ */
129
+ readonly reclaimRejected?: boolean;
130
+ /**
131
+ * Journal data to write atomically with the reservation. Stores without
132
+ * journal support ignore it.
133
+ */
134
+ readonly transaction?: NewTransaction;
135
+ }
136
+ /**
137
+ * Data for a journal row opened with a replay reservation. Journal stores
138
+ * must initialize an included authorization hold as `reserved`. The reservation
139
+ * supplies the request, resource, provider, replay key, amount, currency and
140
+ * payee.
141
+ */
142
+ interface NewTransaction {
143
+ readonly id: string;
144
+ readonly protocol: ProtocolName;
145
+ readonly network?: string;
146
+ readonly asset?: string;
147
+ readonly locator?: Readonly<Record<string, unknown>>;
148
+ readonly expiresAt?: IsoTimestamp;
149
+ readonly authorization?: AuthorizationRecord & {
150
+ readonly reservationId: string;
151
+ };
152
+ readonly inputDigest?: string;
153
+ readonly configDigest: string;
154
+ }
155
+ /** A journal update after replay reservation */
156
+ type TransactionStep = {
157
+ readonly transactionId: string;
158
+ readonly at: IsoTimestamp;
159
+ } & ({
160
+ readonly kind: 'settling';
161
+ } | {
162
+ readonly kind: 'hold';
163
+ readonly hold: AuthorizationHoldState;
164
+ } | {
165
+ readonly kind: 'backend-dispatched';
166
+ readonly deadlineAt: IsoTimestamp;
167
+ } | {
168
+ readonly kind: 'backend-result';
169
+ readonly status: number;
170
+ readonly errorCode?: string;
171
+ } | {
172
+ readonly kind: 'receipt';
173
+ readonly receiptId: string;
174
+ } | {
175
+ readonly kind: 'completed';
176
+ readonly persistenceFailures?: readonly PersistenceFailure[];
177
+ });
178
+ interface TransactionListOptions extends ListOptions {
179
+ /** Opaque cursor from a previous page's `nextCursor` */
180
+ readonly cursor?: string;
181
+ readonly state?: TransactionState;
182
+ /** When true, exclude `delivered` and `payment-failed` states */
183
+ readonly unresolved?: boolean;
184
+ /** When true, filter for `reserved` or `uncertain` authorization holds */
185
+ readonly pendingHold?: boolean;
186
+ }
187
+ /** Transactions in newest-first order */
188
+ interface TransactionPage {
189
+ readonly transactions: readonly Transaction[];
190
+ /**
191
+ * Continue with this cursor even when filtering returns fewer than `limit`
192
+ * transactions, including an empty page. Pagination ends when it is absent.
193
+ */
194
+ readonly nextCursor?: string;
195
+ }
196
+ interface PaymentAttemptResolveRequest {
197
+ readonly attemptId: string;
198
+ /** Update only if the attempt still has this status and no resolution */
199
+ readonly expectedStatus: PaymentAttempt['status'];
200
+ readonly status: 'settled' | 'rejected';
201
+ readonly rejectionReason?: string;
202
+ readonly resolution: PaymentAttemptResolution;
203
+ }
204
+ interface PaymentAttemptUpdate {
205
+ readonly replayKey: string;
206
+ readonly status: PaymentAttempt['status'];
207
+ readonly externalReference?: string;
208
+ readonly rejectionReason?: string;
209
+ }
210
+ interface ListOptions {
211
+ readonly limit?: number;
212
+ readonly requestId?: string;
213
+ }
214
+ interface ReceiptListOptions extends ListOptions {
215
+ /**
216
+ * When true, return only receipts counted by {@link ReceiptStore.countUndeliveredReceipts}.
217
+ * Stores ignoring this flag also return delivered receipts.
218
+ */
219
+ readonly undelivered?: boolean;
220
+ }
221
+ interface PaymentAttemptListOptions extends ListOptions {
222
+ /**
223
+ * When true, return only attempts counted by {@link ReceiptStore.countUncertainPaymentAttempts}.
224
+ * Stores that ignore this flag do not filter by settlement status.
225
+ */
226
+ readonly uncertain?: boolean;
227
+ }
228
+ interface ReceiptStore {
229
+ init(): Promise<void>;
230
+ /** Append a canonical event. Must not throw into the caller's flow */
231
+ appendEvent(event: CommerceEvent): Promise<void>;
232
+ /**
233
+ * Atomically reserve a payment authorization before settlement. If its
234
+ * `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
235
+ * with the existing attempt's `PaymentAttempt.status` in
236
+ * `details.attemptStatus` when available.
237
+ *
238
+ * With `reclaimRejected`, replace the same provider's `rejected` attempt,
239
+ * which settled nothing. Only one concurrent claim can replace it with the
240
+ * new reservation.
241
+ */
242
+ reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
243
+ /** Must not change an attempt that has a resolution; the SQLite store throws `STORAGE_ERROR` */
244
+ updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
245
+ saveReceipt(receipt: CommerceReceipt): Promise<void>;
246
+ getReceipt(id: string): Promise<CommerceReceipt | undefined>;
247
+ listReceipts(options?: ReceiptListOptions): Promise<readonly CommerceReceipt[]>;
248
+ /**
249
+ * Total receipts held. `listReceipts` clamps every page, so counting a list's
250
+ * length would stop at the clamp.
251
+ */
252
+ countReceipts(): Promise<number>;
253
+ /**
254
+ * Receipts whose delivery failed: `backendStatus` outside 2xx, including 0
255
+ * when no status is known. Counted rather than listed for the same reason as
256
+ * {@link countReceipts}.
257
+ *
258
+ * In practice this is "paid but undelivered": the pipeline writes a receipt
259
+ * for a failed delivery only after a settled payment, so a free resource
260
+ * whose backend fails leaves no row here. It is the row a merchant must
261
+ * notice, because settlement is final and the gateway issues no refunds.
262
+ */
263
+ countUndeliveredReceipts(): Promise<number>;
264
+ /**
265
+ * Counts `settlement-uncertain` and legacy `failed` payment attempts.
266
+ * Funds may have moved, but the pipeline withholds delivery and writes no
267
+ * receipt for an uncertain settlement. {@link countUndeliveredReceipts}
268
+ * therefore misses these attempts. Reconcile them on chain using
269
+ * `externalReference` when it holds a transaction hash.
270
+ */
271
+ countUncertainPaymentAttempts(): Promise<number>;
272
+ listEvents(options?: ListOptions): Promise<readonly CommerceEvent[]>;
273
+ listPaymentAttempts(options?: PaymentAttemptListOptions): Promise<readonly PaymentAttempt[]>;
274
+ /**
275
+ * Record a journal step. Journal methods are optional for compatibility with
276
+ * stores that do not support the journal. Implementations must also recompute
277
+ * a transaction's cached state atomically with payment-attempt updates.
278
+ */
279
+ recordTransactionStep?(step: TransactionStep): Promise<void>;
280
+ getTransaction?(id: string): Promise<Transaction | undefined>;
281
+ listTransactions?(options?: TransactionListOptions): Promise<TransactionPage>;
282
+ getPaymentAttempt?(id: string): Promise<PaymentAttempt | undefined>;
283
+ /**
284
+ * Returns the current attempt holding `replayKey`, excluding attempts
285
+ * replaced by a reclaim. If a rejected proof carries this key, the pipeline
286
+ * uses the lookup to return `PAYMENT_REPLAYED` while its attempt is unfinished.
287
+ * Experimental: may change in a minor release.
288
+ */
289
+ findPaymentAttemptByReplayKey?(replayKey: string): Promise<PaymentAttempt | undefined>;
290
+ /**
291
+ * Compare-and-set: return `false` without writing if the attempt's status
292
+ * differs from `expectedStatus` or it already has a resolution
293
+ */
294
+ resolvePaymentAttempt?(request: PaymentAttemptResolveRequest): Promise<boolean>;
295
+ /**
296
+ * Idempotency claims for protocol adapters. A store must implement all three
297
+ * methods or none. Experimental: may change in a minor release.
298
+ *
299
+ * Atomically claim `scope` after deleting `completed` claims whose
300
+ * `expiresAt` has passed. Other states do not expire. Return `reserved` for
301
+ * a new scope, or `conflict` for a different `fingerprint`, regardless of
302
+ * the existing claim's state.
303
+ */
304
+ claimIdempotencyKey?(scope: IdempotencyScope, fingerprint: string, expiresAt: IsoTimestamp): Promise<IdempotencyClaim>;
305
+ /** Record a claim's outcome. Experimental: may change in a minor release */
306
+ updateIdempotencyKey?(scope: IdempotencyScope, update: IdempotencyUpdate): Promise<void>;
307
+ /**
308
+ * Call at startup before accepting claims. Mark every `in-flight` claim
309
+ * `unresolved`, or delete them if `release` is true. Return the number
310
+ * changed. Assumes one gateway per store. Experimental: may change in a
311
+ * minor release.
312
+ */
313
+ recoverIdempotencyKeys?(options: {
314
+ readonly release: boolean;
315
+ }): Promise<number>;
316
+ /**
317
+ * Authorization holds for authorization providers. A store must implement
318
+ * all four methods or none. Experimental: may change in a minor release.
319
+ *
320
+ * Atomically reserve a hold. Return `replayed` with the existing holder's
321
+ * state if this reference, or another with the same `bindingReference`, is
322
+ * not `released`. A released reference can be reserved again by the new
323
+ * `requestId`.
324
+ */
325
+ reserveAuthorizationHold?(reservation: AuthorizationHoldReservation): Promise<AuthorizationHoldResult>;
326
+ /**
327
+ * Move a `reserved` or `uncertain` hold to `to`. This method leaves
328
+ * `consumed` and `released` holds unchanged. When supplied, `requestId`
329
+ * restricts changes to that request's hold. Return true when the hold is
330
+ * in `to`, including on repeated calls. If `requestId` no longer holds the
331
+ * reference, leave the current hold unchanged and return true only when
332
+ * `to` is `released`. Return false otherwise. Experimental: may change in
333
+ * a minor release.
334
+ */
335
+ transitionAuthorizationHold?(reference: string, to: Exclude<AuthorizationHoldState, 'reserved'>, requestId?: string): Promise<boolean>;
336
+ /** Experimental: may change in a minor release */
337
+ getAuthorizationHoldState?(reference: string): Promise<AuthorizationHoldState | undefined>;
338
+ /**
339
+ * List `reserved` holds last updated before `updatedBefore`, oldest first,
340
+ * whose request has no current or replaced payment attempt. The pipeline
341
+ * reserves an attempt before settlement, so after the request ends it cannot
342
+ * settle a payment for such a hold. Experimental: may change in a minor
343
+ * release.
344
+ */
345
+ listOrphanAuthorizationHolds?(options: {
346
+ readonly updatedBefore: IsoTimestamp;
347
+ readonly limit?: number;
348
+ }): Promise<readonly AuthorizationHold[]>;
349
+ /**
350
+ * Pending tasks for protocol adapters. A store must implement all three
351
+ * methods or none. Experimental: may change in a minor release.
352
+ *
353
+ * Delete expired tasks, then store `task`, replacing any task with the same
354
+ * ID. Return false without storing when `maxTasks` unexpired tasks exist.
355
+ */
356
+ putPendingTask?(task: PendingTask, options: {
357
+ readonly maxTasks: number;
358
+ }): Promise<boolean>;
359
+ /** Return undefined for a missing or expired task. Experimental: may change in a minor release */
360
+ getPendingTask?(id: string): Promise<PendingTask | undefined>;
361
+ /**
362
+ * Atomically delete and return the task. Return undefined if it has expired
363
+ * or a concurrent or earlier call already took it. Experimental: may change
364
+ * in a minor release.
365
+ */
366
+ takePendingTask?(id: string): Promise<PendingTask | undefined>;
367
+ readonly descriptor: AdapterDescriptor;
368
+ health(): Promise<AdapterHealth>;
369
+ close(): Promise<void>;
370
+ }
371
+
372
+ export type { AuthorizationHold as A, IdempotencyClaim as I, ListOptions as L, NewTransaction as N, PaymentAttemptListOptions as P, ReceiptStore as R, TransactionListOptions as T, AuthorizationHoldReservation as a, AuthorizationHoldResult as b, IdempotencyScope as c, IdempotencyUpdate as d, PaymentAttemptReservation as e, PaymentAttemptResolveRequest as f, PaymentAttemptUpdate as g, PendingTask as h, ReceiptListOptions as i, TransactionPage as j, TransactionStep as k };
@@ -0,0 +1,51 @@
1
+ import { Clock } from './index.js';
2
+ import { ReceiptStore } from './index.js';
3
+ import './transaction-Dv0UFGg5.js';
4
+
5
+ /**
6
+ * Receipt store conformance cases for use with any test runner. Each case has
7
+ * a name, an optional skip reason and a `run()` using `node:assert/strict`.
8
+ * For example, wrap them with Vitest:
9
+ *
10
+ * ```ts
11
+ * const cases = await receiptStoreConformanceCases(open);
12
+ * for (const c of cases) it.skipIf(c.skip !== undefined)(c.name, () => c.run());
13
+ * ```
14
+ */
15
+
16
+ /** Experimental: may change in a minor release */
17
+ interface ConformanceContext {
18
+ /** Pass it to the store: expiry cases move it instead of waiting */
19
+ readonly clock: Clock;
20
+ }
21
+ /** Experimental: may change in a minor release */
22
+ interface ConformanceStore {
23
+ /** A new, empty store; the suite calls `init()` and `close()` */
24
+ readonly store: ReceiptStore;
25
+ /**
26
+ * Close the current store and return a new one using the same data.
27
+ * Durability cases are skipped when this function is absent.
28
+ */
29
+ readonly reopen?: () => Promise<ReceiptStore>;
30
+ }
31
+ /**
32
+ * Creates stores for capability discovery and individual cases. Experimental:
33
+ * may change in a minor release.
34
+ */
35
+ type ConformanceStoreFactory = (context: ConformanceContext) => ConformanceStore | Promise<ConformanceStore>;
36
+ /** Experimental: may change in a minor release */
37
+ interface ConformanceCase {
38
+ readonly name: string;
39
+ /** Why the case does not apply to this store. Report it as skipped, never as passed */
40
+ readonly skip?: string;
41
+ run(): Promise<void>;
42
+ }
43
+ /**
44
+ * Build cases for the stores `open` creates. Probe one store to identify its
45
+ * optional methods and whether the factory supports reopening. Experimental:
46
+ * may change in a minor release.
47
+ */
48
+ declare function receiptStoreConformanceCases(open: ConformanceStoreFactory): Promise<readonly ConformanceCase[]>;
49
+
50
+ export { receiptStoreConformanceCases };
51
+ export type { ConformanceCase, ConformanceContext, ConformanceStore, ConformanceStoreFactory };