@beignet/core 0.0.12 → 0.0.14

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 (56) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +159 -9
  3. package/dist/client/client.d.ts.map +1 -1
  4. package/dist/client/client.js +29 -1
  5. package/dist/client/client.js.map +1 -1
  6. package/dist/entitlements/index.d.ts +234 -0
  7. package/dist/entitlements/index.d.ts.map +1 -0
  8. package/dist/entitlements/index.js +172 -0
  9. package/dist/entitlements/index.js.map +1 -0
  10. package/dist/error-reporting/index.d.ts +131 -0
  11. package/dist/error-reporting/index.d.ts.map +1 -0
  12. package/dist/error-reporting/index.js +112 -0
  13. package/dist/error-reporting/index.js.map +1 -0
  14. package/dist/flags/index.d.ts +293 -0
  15. package/dist/flags/index.d.ts.map +1 -0
  16. package/dist/flags/index.js +204 -0
  17. package/dist/flags/index.js.map +1 -0
  18. package/dist/locks/index.d.ts +155 -0
  19. package/dist/locks/index.d.ts.map +1 -0
  20. package/dist/locks/index.js +248 -0
  21. package/dist/locks/index.js.map +1 -0
  22. package/dist/payments/index.d.ts +430 -0
  23. package/dist/payments/index.d.ts.map +1 -0
  24. package/dist/payments/index.js +230 -0
  25. package/dist/payments/index.js.map +1 -0
  26. package/dist/ports/index.d.ts +61 -1
  27. package/dist/ports/index.d.ts.map +1 -1
  28. package/dist/ports/index.js +33 -0
  29. package/dist/ports/index.js.map +1 -1
  30. package/dist/ports/policy.d.ts +104 -0
  31. package/dist/ports/policy.d.ts.map +1 -1
  32. package/dist/ports/policy.js +102 -7
  33. package/dist/ports/policy.js.map +1 -1
  34. package/dist/search/index.d.ts +175 -0
  35. package/dist/search/index.d.ts.map +1 -0
  36. package/dist/search/index.js +344 -0
  37. package/dist/search/index.js.map +1 -0
  38. package/dist/server/server.d.ts.map +1 -1
  39. package/dist/server/server.js +9 -1
  40. package/dist/server/server.js.map +1 -1
  41. package/dist/testing/index.d.ts +46 -1
  42. package/dist/testing/index.d.ts.map +1 -1
  43. package/dist/testing/index.js +33 -1
  44. package/dist/testing/index.js.map +1 -1
  45. package/package.json +25 -1
  46. package/src/client/client.ts +33 -1
  47. package/src/entitlements/index.ts +479 -0
  48. package/src/error-reporting/index.ts +273 -0
  49. package/src/flags/index.ts +608 -0
  50. package/src/locks/index.ts +440 -0
  51. package/src/payments/index.ts +699 -0
  52. package/src/ports/index.ts +194 -0
  53. package/src/ports/policy.ts +272 -7
  54. package/src/search/index.ts +632 -0
  55. package/src/server/server.ts +15 -0
  56. package/src/testing/index.ts +83 -1
@@ -0,0 +1,248 @@
1
+ /**
2
+ * @beignet/core/locks
3
+ *
4
+ * Provider-neutral distributed lock and lease primitives for Beignet apps.
5
+ */
6
+ import { createProvider, createProviderInstrumentation, } from "../providers/index.js";
7
+ /**
8
+ * Error thrown when a lease option is invalid.
9
+ */
10
+ export class LeaseOptionsError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = "LeaseOptionsError";
14
+ }
15
+ }
16
+ /**
17
+ * Create an in-memory locks port for tests and single-process development.
18
+ */
19
+ export function createMemoryLocks(options = {}) {
20
+ const leases = new Map();
21
+ const now = options.now ?? (() => new Date());
22
+ const sleep = options.sleep ?? defaultSleep;
23
+ const createOwnerToken = options.createOwnerToken ?? createRandomToken;
24
+ let nextFencingToken = 1;
25
+ const port = {
26
+ leases,
27
+ async acquire(key, acquireOptions) {
28
+ validateAcquireOptions(key, acquireOptions);
29
+ const waitMs = acquireOptions.waitMs ?? 0;
30
+ const retryDelayMs = acquireOptions.retryDelayMs ?? 50;
31
+ const deadline = now().getTime() + waitMs;
32
+ const ownerToken = acquireOptions.ownerToken ?? createOwnerToken();
33
+ while (true) {
34
+ pruneExpired(key, leases, now);
35
+ if (!leases.has(key)) {
36
+ const record = {
37
+ key,
38
+ ownerToken,
39
+ expiresAt: new Date(now().getTime() + acquireOptions.ttlMs),
40
+ ttlMs: acquireOptions.ttlMs,
41
+ fencingToken: nextFencingToken++,
42
+ metadata: acquireOptions.metadata,
43
+ };
44
+ leases.set(key, record);
45
+ return {
46
+ acquired: true,
47
+ lease: createMemoryLease(port, record, now),
48
+ };
49
+ }
50
+ if (waitMs <= 0) {
51
+ return { acquired: false, reason: "unavailable" };
52
+ }
53
+ const remainingMs = deadline - now().getTime();
54
+ if (remainingMs <= 0) {
55
+ pruneExpired(key, leases, now);
56
+ if (!leases.has(key))
57
+ continue;
58
+ return { acquired: false, reason: "timeout" };
59
+ }
60
+ await sleep(Math.min(retryDelayMs, remainingMs));
61
+ }
62
+ },
63
+ async withLease(key, acquireOptions, fn) {
64
+ const result = await port.acquire(key, acquireOptions);
65
+ if (!result.acquired)
66
+ return undefined;
67
+ try {
68
+ return await fn({ lease: result.lease });
69
+ }
70
+ finally {
71
+ await result.lease.release();
72
+ }
73
+ },
74
+ restore(key, ownerToken) {
75
+ if (!key)
76
+ throw new LeaseOptionsError("Lease key is required.");
77
+ if (!ownerToken) {
78
+ throw new LeaseOptionsError("Lease owner token is required.");
79
+ }
80
+ return createMemoryLease(port, {
81
+ key,
82
+ ownerToken,
83
+ expiresAt: new Date(0),
84
+ ttlMs: 1,
85
+ fencingToken: 0,
86
+ }, now);
87
+ },
88
+ async forceRelease(key) {
89
+ pruneExpired(key, leases, now);
90
+ return leases.delete(key);
91
+ },
92
+ reset() {
93
+ leases.clear();
94
+ nextFencingToken = 1;
95
+ },
96
+ };
97
+ return port;
98
+ }
99
+ /**
100
+ * Create a provider that contributes an in-memory locks port.
101
+ */
102
+ export function createMemoryLocksProvider(options = {}) {
103
+ const { name = "memory-locks", ...locksOptions } = options;
104
+ return createProvider({
105
+ name,
106
+ metadata: {
107
+ ports: ["locks"],
108
+ watchers: ["locks"],
109
+ },
110
+ setup({ ports }) {
111
+ const instrumentation = createProviderInstrumentation(ports, {
112
+ providerName: name,
113
+ watcher: "locks",
114
+ });
115
+ const locks = createMemoryLocks(locksOptions);
116
+ return {
117
+ ports: {
118
+ locks: instrumentLocks(locks, instrumentation),
119
+ },
120
+ };
121
+ },
122
+ });
123
+ }
124
+ /**
125
+ * Convenience helper for any lock port.
126
+ */
127
+ export function acquireLease(locks, key, options) {
128
+ return locks.acquire(key, options);
129
+ }
130
+ /**
131
+ * Convenience helper for any lock port.
132
+ */
133
+ export function withLease(locks, key, options, fn) {
134
+ return locks.withLease(key, options, fn);
135
+ }
136
+ function createMemoryLease(port, record, now) {
137
+ const lease = {
138
+ key: record.key,
139
+ ownerToken: record.ownerToken,
140
+ expiresAt: record.expiresAt,
141
+ fencingToken: record.fencingToken,
142
+ async renew(options) {
143
+ const active = port.leases.get(record.key);
144
+ if (!active ||
145
+ active.ownerToken !== record.ownerToken ||
146
+ active.expiresAt.getTime() <= now().getTime()) {
147
+ port.leases.delete(record.key);
148
+ return false;
149
+ }
150
+ const ttlMs = options?.ttlMs ?? active.ttlMs;
151
+ if (!Number.isFinite(ttlMs) || ttlMs <= 0) {
152
+ throw new LeaseOptionsError("Lease ttlMs must be a positive number.");
153
+ }
154
+ active.ttlMs = ttlMs;
155
+ active.expiresAt = new Date(now().getTime() + ttlMs);
156
+ lease.expiresAt = active.expiresAt;
157
+ return true;
158
+ },
159
+ async release() {
160
+ const active = port.leases.get(record.key);
161
+ if (!active || active.ownerToken !== record.ownerToken) {
162
+ return false;
163
+ }
164
+ if (active.expiresAt.getTime() <= now().getTime()) {
165
+ port.leases.delete(record.key);
166
+ return false;
167
+ }
168
+ return port.leases.delete(record.key);
169
+ },
170
+ };
171
+ return lease;
172
+ }
173
+ function instrumentLocks(locks, instrumentation) {
174
+ const acquire = async (key, options) => {
175
+ const startedAt = Date.now();
176
+ const result = await locks.acquire(key, options);
177
+ instrumentation.custom({
178
+ name: "locks.acquire",
179
+ label: "Lock acquire",
180
+ summary: result.acquired ? "Lease acquired" : "Lease not acquired",
181
+ details: {
182
+ key,
183
+ acquired: result.acquired,
184
+ reason: result.acquired ? undefined : result.reason,
185
+ ttlMs: options.ttlMs,
186
+ waitMs: options.waitMs ?? 0,
187
+ durationMs: Date.now() - startedAt,
188
+ },
189
+ });
190
+ return result;
191
+ };
192
+ return {
193
+ acquire,
194
+ async withLease(key, options, fn) {
195
+ const result = await acquire(key, options);
196
+ if (!result.acquired)
197
+ return undefined;
198
+ try {
199
+ return await fn({ lease: result.lease });
200
+ }
201
+ finally {
202
+ await result.lease.release();
203
+ }
204
+ },
205
+ restore(key, ownerToken) {
206
+ return locks.restore(key, ownerToken);
207
+ },
208
+ async forceRelease(key) {
209
+ const released = await locks.forceRelease(key);
210
+ instrumentation.custom({
211
+ name: "locks.forceRelease",
212
+ label: "Lock force release",
213
+ summary: released ? "Lease force released" : "Lease not found",
214
+ details: { key, released },
215
+ });
216
+ return released;
217
+ },
218
+ };
219
+ }
220
+ function validateAcquireOptions(key, options) {
221
+ if (!key)
222
+ throw new LeaseOptionsError("Lease key is required.");
223
+ if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0) {
224
+ throw new LeaseOptionsError("Lease ttlMs must be a positive number.");
225
+ }
226
+ if (options.waitMs !== undefined && options.waitMs < 0) {
227
+ throw new LeaseOptionsError("Lease waitMs must be zero or greater.");
228
+ }
229
+ if (options.retryDelayMs !== undefined && options.retryDelayMs <= 0) {
230
+ throw new LeaseOptionsError("Lease retryDelayMs must be positive.");
231
+ }
232
+ }
233
+ function pruneExpired(key, leases, now) {
234
+ const active = leases.get(key);
235
+ if (active && active.expiresAt.getTime() <= now().getTime()) {
236
+ leases.delete(key);
237
+ }
238
+ }
239
+ function createRandomToken() {
240
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
241
+ return crypto.randomUUID();
242
+ }
243
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
244
+ }
245
+ function defaultSleep(ms) {
246
+ return new Promise((resolve) => setTimeout(resolve, ms));
247
+ }
248
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locks/index.ts"],"names":[],"mappings":"A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AC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,YAAY,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,430 @@
1
+ /**
2
+ * @beignet/core/payments
3
+ *
4
+ * Provider-neutral payments primitives for Beignet applications.
5
+ */
6
+ /**
7
+ * Value or promise of that value.
8
+ */
9
+ export type MaybePromise<T> = T | Promise<T>;
10
+ /**
11
+ * String metadata attached to provider-owned payment objects.
12
+ */
13
+ export type PaymentMetadata = Record<string, string>;
14
+ /**
15
+ * Checkout modes understood by Beignet's provider-neutral payment port.
16
+ */
17
+ export type PaymentCheckoutMode = "payment" | "subscription";
18
+ /**
19
+ * Hosted checkout line item.
20
+ */
21
+ export interface PaymentCheckoutLineItem {
22
+ /**
23
+ * Provider price identifier.
24
+ */
25
+ priceId: string;
26
+ /**
27
+ * Quantity for this price. Defaults to the provider's default behavior.
28
+ */
29
+ quantity?: number;
30
+ }
31
+ /**
32
+ * Input for creating a hosted checkout session.
33
+ */
34
+ export interface CreateCheckoutSessionInput {
35
+ /**
36
+ * One-time payment or subscription checkout.
37
+ */
38
+ mode: PaymentCheckoutMode;
39
+ /**
40
+ * Line items to include in checkout.
41
+ */
42
+ lineItems: readonly PaymentCheckoutLineItem[];
43
+ /**
44
+ * URL the provider redirects to after successful checkout.
45
+ */
46
+ successUrl: string;
47
+ /**
48
+ * URL the provider redirects to when checkout is canceled.
49
+ */
50
+ cancelUrl: string;
51
+ /**
52
+ * Existing provider customer ID, when known.
53
+ */
54
+ customerId?: string;
55
+ /**
56
+ * App-owned reference copied into the provider session.
57
+ */
58
+ clientReferenceId?: string;
59
+ /**
60
+ * Provider metadata.
61
+ */
62
+ metadata?: PaymentMetadata;
63
+ /**
64
+ * Provider idempotency key for this external call.
65
+ */
66
+ idempotencyKey?: string;
67
+ }
68
+ /**
69
+ * Hosted checkout session returned by a payment provider.
70
+ */
71
+ export interface CheckoutSession {
72
+ /**
73
+ * Provider session ID.
74
+ */
75
+ id: string;
76
+ /**
77
+ * Provider name.
78
+ */
79
+ provider: string;
80
+ /**
81
+ * Checkout mode.
82
+ */
83
+ mode: PaymentCheckoutMode;
84
+ /**
85
+ * Hosted checkout URL, when the provider returns one.
86
+ */
87
+ url?: string;
88
+ /**
89
+ * Client secret, when the provider supports embedded checkout.
90
+ */
91
+ clientSecret?: string;
92
+ /**
93
+ * Provider customer ID, when known.
94
+ */
95
+ customerId?: string;
96
+ /**
97
+ * Provider status, when known.
98
+ */
99
+ status?: string;
100
+ /**
101
+ * Provider metadata.
102
+ */
103
+ metadata?: PaymentMetadata;
104
+ /**
105
+ * Raw provider response for app-owned escape hatches.
106
+ */
107
+ raw?: unknown;
108
+ }
109
+ /**
110
+ * Input for creating a billing portal session.
111
+ */
112
+ export interface CreateBillingPortalSessionInput {
113
+ /**
114
+ * Provider customer ID.
115
+ */
116
+ customerId: string;
117
+ /**
118
+ * URL the provider redirects to after leaving the portal.
119
+ */
120
+ returnUrl: string;
121
+ /**
122
+ * Provider idempotency key for this external call.
123
+ */
124
+ idempotencyKey?: string;
125
+ }
126
+ /**
127
+ * Billing portal session returned by a payment provider.
128
+ */
129
+ export interface BillingPortalSession {
130
+ /**
131
+ * Provider session ID.
132
+ */
133
+ id: string;
134
+ /**
135
+ * Provider name.
136
+ */
137
+ provider: string;
138
+ /**
139
+ * Hosted portal URL.
140
+ */
141
+ url: string;
142
+ /**
143
+ * Provider customer ID.
144
+ */
145
+ customerId: string;
146
+ /**
147
+ * Raw provider response for app-owned escape hatches.
148
+ */
149
+ raw?: unknown;
150
+ }
151
+ /**
152
+ * Refund reasons common to hosted payment providers.
153
+ */
154
+ export type PaymentRefundReason = "duplicate" | "fraudulent" | "requested_by_customer";
155
+ /**
156
+ * Input for creating a refund.
157
+ */
158
+ export interface CreateRefundInput {
159
+ /**
160
+ * Provider payment ID, such as a payment intent ID.
161
+ */
162
+ paymentId: string;
163
+ /**
164
+ * Amount in the provider's smallest currency unit. Omit for a full refund.
165
+ */
166
+ amount?: number;
167
+ /**
168
+ * Reason for the refund.
169
+ */
170
+ reason?: PaymentRefundReason;
171
+ /**
172
+ * Provider metadata.
173
+ */
174
+ metadata?: PaymentMetadata;
175
+ /**
176
+ * Provider idempotency key for this external call.
177
+ */
178
+ idempotencyKey?: string;
179
+ }
180
+ /**
181
+ * Refund returned by a payment provider.
182
+ */
183
+ export interface Refund {
184
+ /**
185
+ * Provider refund ID.
186
+ */
187
+ id: string;
188
+ /**
189
+ * Provider name.
190
+ */
191
+ provider: string;
192
+ /**
193
+ * Provider payment ID that was refunded.
194
+ */
195
+ paymentId: string;
196
+ /**
197
+ * Refunded amount in the provider's smallest currency unit, when known.
198
+ */
199
+ amount?: number;
200
+ /**
201
+ * Currency code, when known.
202
+ */
203
+ currency?: string;
204
+ /**
205
+ * Provider refund status, when known.
206
+ */
207
+ status?: string;
208
+ /**
209
+ * Provider metadata.
210
+ */
211
+ metadata?: PaymentMetadata;
212
+ /**
213
+ * Raw provider response for app-owned escape hatches.
214
+ */
215
+ raw?: unknown;
216
+ }
217
+ /**
218
+ * Raw webhook payload accepted by payment providers.
219
+ */
220
+ export type PaymentWebhookRawBody = string | Uint8Array | ArrayBuffer;
221
+ /**
222
+ * Input for verifying and parsing a provider webhook.
223
+ */
224
+ export interface VerifyPaymentWebhookInput {
225
+ /**
226
+ * Raw request body. Do not pass a parsed JSON body.
227
+ */
228
+ rawBody: PaymentWebhookRawBody;
229
+ /**
230
+ * Provider signature header value.
231
+ */
232
+ signature: string;
233
+ }
234
+ /**
235
+ * Normalized provider webhook event.
236
+ */
237
+ export interface PaymentWebhookEvent {
238
+ /**
239
+ * Provider event ID.
240
+ */
241
+ id: string;
242
+ /**
243
+ * Provider event type, such as "checkout.session.completed".
244
+ */
245
+ type: string;
246
+ /**
247
+ * Provider name.
248
+ */
249
+ provider: string;
250
+ /**
251
+ * Event creation time, when known.
252
+ */
253
+ createdAt?: Date;
254
+ /**
255
+ * Whether the event came from live mode, when the provider exposes it.
256
+ */
257
+ livemode?: boolean;
258
+ /**
259
+ * Provider event data object.
260
+ */
261
+ data: unknown;
262
+ /**
263
+ * Raw provider event for app-owned escape hatches.
264
+ */
265
+ raw?: unknown;
266
+ }
267
+ /**
268
+ * App-facing payments port.
269
+ *
270
+ * Implement this with hosted payment providers such as Stripe. Application
271
+ * billing logic should depend on this interface instead of provider SDKs.
272
+ */
273
+ export interface PaymentsPort {
274
+ /**
275
+ * Create a hosted checkout session.
276
+ */
277
+ createCheckoutSession(input: CreateCheckoutSessionInput): Promise<CheckoutSession>;
278
+ /**
279
+ * Create a hosted billing portal session.
280
+ */
281
+ createBillingPortalSession(input: CreateBillingPortalSessionInput): Promise<BillingPortalSession>;
282
+ /**
283
+ * Create a refund.
284
+ */
285
+ createRefund(input: CreateRefundInput): Promise<Refund>;
286
+ /**
287
+ * Verify and parse a provider webhook.
288
+ */
289
+ verifyWebhook(input: VerifyPaymentWebhookInput): Promise<PaymentWebhookEvent>;
290
+ }
291
+ /**
292
+ * Error thrown by payment helpers and provider adapters.
293
+ */
294
+ export declare class PaymentProviderError extends Error {
295
+ /**
296
+ * Provider name when known.
297
+ */
298
+ readonly provider?: string;
299
+ /**
300
+ * Operation that failed.
301
+ */
302
+ readonly operation: string;
303
+ /**
304
+ * Provider error code when known.
305
+ */
306
+ readonly code?: string;
307
+ /**
308
+ * Original provider error when available.
309
+ */
310
+ readonly cause?: unknown;
311
+ constructor(args: {
312
+ provider?: string;
313
+ operation: string;
314
+ message: string;
315
+ code?: string;
316
+ cause?: unknown;
317
+ });
318
+ }
319
+ /**
320
+ * Captured checkout session created by the memory payments adapter.
321
+ */
322
+ export type MemoryCheckoutSession = CheckoutSession & {
323
+ input: CreateCheckoutSessionInput;
324
+ createdAt: Date;
325
+ };
326
+ /**
327
+ * Captured billing portal session created by the memory payments adapter.
328
+ */
329
+ export type MemoryBillingPortalSession = BillingPortalSession & {
330
+ input: CreateBillingPortalSessionInput;
331
+ createdAt: Date;
332
+ };
333
+ /**
334
+ * Captured refund created by the memory payments adapter.
335
+ */
336
+ export type MemoryRefund = Refund & {
337
+ input: CreateRefundInput;
338
+ createdAt: Date;
339
+ };
340
+ /**
341
+ * In-memory payments port for tests and local examples.
342
+ */
343
+ export interface MemoryPaymentsPort extends PaymentsPort {
344
+ /**
345
+ * Captured checkout sessions.
346
+ */
347
+ readonly checkoutSessions: readonly MemoryCheckoutSession[];
348
+ /**
349
+ * Captured billing portal sessions.
350
+ */
351
+ readonly billingPortalSessions: readonly MemoryBillingPortalSession[];
352
+ /**
353
+ * Captured refunds.
354
+ */
355
+ readonly refunds: readonly MemoryRefund[];
356
+ /**
357
+ * Webhook events that were verified by the memory adapter.
358
+ */
359
+ readonly webhookEvents: readonly PaymentWebhookEvent[];
360
+ /**
361
+ * Queue a webhook event to be returned by the next `verifyWebhook(...)` call.
362
+ */
363
+ queueWebhookEvent(event: PaymentWebhookEvent): void;
364
+ /**
365
+ * Clear captured state.
366
+ */
367
+ clear(): void;
368
+ }
369
+ /**
370
+ * Options for `createMemoryPayments(...)`.
371
+ */
372
+ export interface CreateMemoryPaymentsOptions {
373
+ /**
374
+ * Clock used for captured payment objects.
375
+ */
376
+ now?: () => Date;
377
+ /**
378
+ * ID factory used for captured payment objects.
379
+ */
380
+ id?: (prefix: string) => string;
381
+ /**
382
+ * Observer called after a checkout session is created.
383
+ */
384
+ onCheckoutSessionCreated?: (session: MemoryCheckoutSession) => MaybePromise<void>;
385
+ /**
386
+ * Observer called after a billing portal session is created.
387
+ */
388
+ onBillingPortalSessionCreated?: (session: MemoryBillingPortalSession) => MaybePromise<void>;
389
+ /**
390
+ * Observer called after a refund is created.
391
+ */
392
+ onRefundCreated?: (refund: MemoryRefund) => MaybePromise<void>;
393
+ /**
394
+ * Observer called after a webhook event is verified.
395
+ */
396
+ onWebhookVerified?: (event: PaymentWebhookEvent) => MaybePromise<void>;
397
+ }
398
+ /**
399
+ * Create an in-memory payments port for tests, local development, and
400
+ * examples.
401
+ *
402
+ * The memory adapter does not contact a payment provider or validate webhook
403
+ * signatures. Queue webhook events explicitly with `queueWebhookEvent(...)`.
404
+ */
405
+ export declare function createMemoryPayments(options?: CreateMemoryPaymentsOptions): MemoryPaymentsPort;
406
+ /**
407
+ * Options for the memory payments provider.
408
+ */
409
+ export interface MemoryPaymentsProviderOptions extends CreateMemoryPaymentsOptions {
410
+ /**
411
+ * Provider name. Defaults to "memory-payments".
412
+ */
413
+ name?: string;
414
+ }
415
+ /**
416
+ * Ports contributed by the memory payments provider.
417
+ */
418
+ export interface MemoryPaymentsProviderPorts {
419
+ /**
420
+ * Beignet payments port.
421
+ */
422
+ payments: PaymentsPort;
423
+ }
424
+ /**
425
+ * Create a provider that contributes an in-memory payments port.
426
+ */
427
+ export declare function createMemoryPaymentsProvider(options?: MemoryPaymentsProviderOptions): import("../providers/provider.js").ServiceProvider<unknown, import("@standard-schema/spec").StandardSchemaV1<void, void>, {
428
+ payments: PaymentsPort;
429
+ }, unknown, void>;
430
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/payments/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,C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