@rdlabo/workers-hono-kit 0.1.0 → 0.2.1
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.
- package/README.md +126 -11
- package/dist/ai/gateway.d.ts +54 -16
- package/dist/ai/gateway.js +37 -12
- package/dist/aws/cloudfront.d.ts +23 -5
- package/dist/aws/cloudfront.js +45 -6
- package/dist/aws/secrets-manager.d.ts +38 -4
- package/dist/aws/secrets-manager.js +48 -3
- package/dist/cache/kv-cache.d.ts +173 -10
- package/dist/cache/kv-cache.js +139 -7
- package/dist/db/connection.d.ts +56 -14
- package/dist/db/connection.js +39 -13
- package/dist/db/database.d.ts +160 -24
- package/dist/db/database.js +51 -7
- package/dist/db/index.d.ts +21 -10
- package/dist/db/index.js +17 -8
- package/dist/db/jst.d.ts +89 -6
- package/dist/db/jst.js +89 -23
- package/dist/db/orm-config.d.ts +61 -19
- package/dist/db/orm-config.js +43 -14
- package/dist/db/retry.d.ts +25 -3
- package/dist/db/retry.js +25 -3
- package/dist/db/write-result.d.ts +27 -4
- package/dist/db/write-result.js +22 -1
- package/dist/firebase/firebase-verifier.d.ts +53 -4
- package/dist/firebase/identity-toolkit.d.ts +54 -5
- package/dist/firebase/identity-toolkit.js +51 -0
- package/dist/firebase/jose-firebase-verifier.d.ts +81 -9
- package/dist/firebase/jose-firebase-verifier.js +68 -7
- package/dist/firebase/remote-verifier.d.ts +43 -5
- package/dist/firebase/remote-verifier.js +60 -11
- package/dist/http/app-env.d.ts +41 -8
- package/dist/http/app-env.js +38 -8
- package/dist/http/app-info.d.ts +25 -3
- package/dist/http/app-info.js +16 -2
- package/dist/http/http-status.d.ts +12 -3
- package/dist/http/http-status.js +12 -3
- package/dist/http/nest-error.d.ts +90 -29
- package/dist/http/nest-error.js +59 -18
- package/dist/http/user-protocol.d.ts +23 -3
- package/dist/http/user-protocol.js +14 -2
- package/dist/index.d.ts +41 -30
- package/dist/index.js +29 -21
- package/dist/middleware/auth.d.ts +75 -14
- package/dist/middleware/auth.js +31 -7
- package/dist/middleware/finalize-response.d.ts +30 -0
- package/dist/middleware/finalize-response.js +41 -12
- package/dist/middleware/validation.d.ts +83 -9
- package/dist/middleware/validation.js +52 -9
- package/dist/middleware/zod-coerce.d.ts +56 -2
- package/dist/middleware/zod-coerce.js +68 -9
- package/dist/stripe/client.d.ts +46 -9
- package/dist/stripe/client.js +41 -3
- package/dist/testing/auth.d.ts +60 -12
- package/dist/testing/auth.js +58 -10
- package/dist/testing/configurable-fake.d.ts +20 -9
- package/dist/testing/configurable-fake.js +23 -11
- package/dist/testing/db.d.ts +81 -12
- package/dist/testing/db.js +23 -1
- package/dist/testing/fakes.d.ts +79 -11
- package/dist/testing/fakes.js +70 -8
- package/dist/testing/index.d.ts +15 -8
- package/dist/testing/index.js +15 -10
- package/dist/testing/stripe-fixtures.d.ts +93 -3
- package/dist/testing/stripe-fixtures.js +93 -3
- package/package.json +19 -9
- package/src/ai/gateway.ts +66 -27
- package/src/aws/cloudfront.ts +46 -6
- package/src/aws/secrets-manager.ts +56 -7
- package/src/cache/kv-cache.ts +194 -12
- package/src/db/connection.ts +56 -14
- package/src/db/database.ts +163 -27
- package/src/db/index.ts +21 -12
- package/src/db/jst.ts +89 -23
- package/src/db/orm-config.ts +61 -19
- package/src/db/retry.ts +25 -3
- package/src/db/write-result.ts +27 -4
- package/src/firebase/firebase-verifier.ts +53 -4
- package/src/firebase/identity-toolkit.ts +57 -5
- package/src/firebase/jose-firebase-verifier.ts +81 -11
- package/src/firebase/remote-verifier.ts +61 -12
- package/src/http/app-env.ts +41 -8
- package/src/http/app-info.ts +25 -3
- package/src/http/http-status.ts +12 -3
- package/src/http/nest-error.ts +106 -37
- package/src/http/user-protocol.ts +23 -3
- package/src/index.ts +47 -33
- package/src/middleware/auth.ts +79 -17
- package/src/middleware/finalize-response.ts +41 -12
- package/src/middleware/validation.ts +89 -15
- package/src/middleware/zod-coerce.ts +68 -9
- package/src/stripe/client.ts +46 -9
- package/src/testing/auth.ts +60 -12
- package/src/testing/configurable-fake.ts +23 -11
- package/src/testing/db.ts +82 -13
- package/src/testing/fakes.ts +80 -12
- package/src/testing/index.ts +18 -13
- package/src/testing/stripe-fixtures.ts +93 -3
package/src/testing/fakes.ts
CHANGED
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
import type { Pool } from 'mysql2/promise';
|
|
2
|
-
import { databaseFrom } from '../db/database';
|
|
3
|
-
import type { DisposableDatabase } from '../db/database';
|
|
4
|
-
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier';
|
|
2
|
+
import { databaseFrom } from '../db/database.js';
|
|
3
|
+
import type { DisposableDatabase } from '../db/database.js';
|
|
4
|
+
import type { DecodedIdToken, FirebaseVerifier } from '../firebase/firebase-verifier.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* In-memory {@link FirebaseVerifier} implementation for offline route tests.
|
|
8
|
+
*
|
|
9
|
+
* Seed fake identities with {@link FakeFirebaseVerifier.register | register(token, { uid })}, then
|
|
10
|
+
* verification resolves the registered decoded token instead of calling a real Firebase backend.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const firebase = new FakeFirebaseVerifier();
|
|
15
|
+
* firebase.register('tok-1', { uid: 'uid-1' });
|
|
16
|
+
* const decoded = await firebase.verifyIdToken('tok-1'); // { uid: 'uid-1' }
|
|
17
|
+
* ```
|
|
9
18
|
*/
|
|
10
19
|
export class FakeFirebaseVerifier implements FirebaseVerifier {
|
|
11
20
|
private readonly tokens = new Map<string, DecodedIdToken>();
|
|
21
|
+
/** UIDs passed to {@link FakeFirebaseVerifier.deleteUser}, in call order, for assertions. */
|
|
12
22
|
readonly deleted: string[] = [];
|
|
13
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Register a fake decoded token so that {@link FakeFirebaseVerifier.verifyIdToken} resolves it.
|
|
26
|
+
*
|
|
27
|
+
* @param token - Token string clients will present.
|
|
28
|
+
* @param record - Decoded token returned on verification (must include `uid`).
|
|
29
|
+
*/
|
|
14
30
|
register(token: string, record: DecodedIdToken): void {
|
|
15
31
|
this.tokens.set(token, record);
|
|
16
32
|
}
|
|
17
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the decoded token previously registered for `idToken`.
|
|
36
|
+
*
|
|
37
|
+
* @param idToken - Token string to verify.
|
|
38
|
+
* @returns The registered decoded token.
|
|
39
|
+
* @throws Error if the token was never registered.
|
|
40
|
+
*/
|
|
18
41
|
async verifyIdToken(idToken: string): Promise<DecodedIdToken> {
|
|
19
42
|
const record = this.tokens.get(idToken);
|
|
20
43
|
if (!record) {
|
|
@@ -23,25 +46,57 @@ export class FakeFirebaseVerifier implements FirebaseVerifier {
|
|
|
23
46
|
return record;
|
|
24
47
|
}
|
|
25
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Return a minimal user record echoing the requested UID.
|
|
51
|
+
*
|
|
52
|
+
* @param uid - UID to look up.
|
|
53
|
+
* @returns An object containing the `uid` (never `null` in this fake).
|
|
54
|
+
*/
|
|
26
55
|
async getUser(uid: string): Promise<{ uid: string; email?: string } | null> {
|
|
27
56
|
return { uid };
|
|
28
57
|
}
|
|
29
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Record a user deletion by appending the UID to {@link FakeFirebaseVerifier.deleted}.
|
|
61
|
+
*
|
|
62
|
+
* @param uid - UID being deleted.
|
|
63
|
+
*/
|
|
30
64
|
async deleteUser(uid: string): Promise<void> {
|
|
31
65
|
this.deleted.push(uid);
|
|
32
66
|
}
|
|
33
67
|
}
|
|
34
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Options for {@link createPoolDatabase}.
|
|
71
|
+
*
|
|
72
|
+
* @typeParam TDrizzle - The Drizzle instance type, supplied by the consumer so that type identity is
|
|
73
|
+
* not coupled to this package's copy of `drizzle-orm`.
|
|
74
|
+
*/
|
|
35
75
|
export interface CreatePoolDatabaseOptions<TDrizzle> {
|
|
36
|
-
/**
|
|
76
|
+
/** Test pool used as both primary and replica. */
|
|
37
77
|
pool: Pool;
|
|
38
|
-
/**
|
|
78
|
+
/** Drizzle instance built by the consumer with its own `drizzle-orm`, e.g. `drizzle(pool, { schema, ... })`. */
|
|
39
79
|
orm: TDrizzle;
|
|
40
80
|
}
|
|
41
81
|
|
|
42
82
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
83
|
+
* Create a `Database` backed by a single pool used as both primary and replica, suitable for tests.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* `dispose()` ends the pool. The `orm` is provided by the caller (rather than constructed here) so
|
|
87
|
+
* the returned database uses the consumer's own `drizzle-orm` types, avoiding type-identity clashes
|
|
88
|
+
* across duplicated `drizzle-orm` installs.
|
|
89
|
+
*
|
|
90
|
+
* @typeParam TDrizzle - The Drizzle instance type provided by the consumer.
|
|
91
|
+
* @param options - Pool and Drizzle instance. See {@link CreatePoolDatabaseOptions}.
|
|
92
|
+
* @returns A {@link DisposableDatabase} whose `dispose()` closes the pool.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const pool = testDb.createTestPool();
|
|
96
|
+
* const db = createPoolDatabase({ pool, orm: drizzle(pool, { schema }) });
|
|
97
|
+
* // ... run tests ...
|
|
98
|
+
* await db.dispose();
|
|
99
|
+
* ```
|
|
45
100
|
*/
|
|
46
101
|
export function createPoolDatabase<TDrizzle>(
|
|
47
102
|
options: CreatePoolDatabaseOptions<TDrizzle>,
|
|
@@ -57,9 +112,22 @@ export function createPoolDatabase<TDrizzle>(
|
|
|
57
112
|
}
|
|
58
113
|
|
|
59
114
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
115
|
+
* Create a no-op `Database` stub for routes that never touch the database (e.g. plain GET handlers).
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* `read` resolves to an empty array, while `write` and `transaction` throw so that any unexpected
|
|
119
|
+
* database access is caught as a misuse. `dispose` is a no-op, so this can stand in for a
|
|
120
|
+
* {@link DisposableDatabase} backing (e.g. a Hyperdrive- or pool-based one) without changes.
|
|
121
|
+
*
|
|
122
|
+
* @typeParam TDrizzle - The Drizzle instance type the consumer expects (defaults to `unknown`).
|
|
123
|
+
* @returns A {@link DisposableDatabase} that reads empty and throws on writes/transactions.
|
|
124
|
+
* @throws Error from `write`/`transaction` if they are accessed.
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const db = createNoopDatabase();
|
|
128
|
+
* await db.read('SELECT 1'); // []
|
|
129
|
+
* await db.write(async (dz) => dz); // throws: noopDatabase.write accessed unexpectedly
|
|
130
|
+
* ```
|
|
63
131
|
*/
|
|
64
132
|
export function createNoopDatabase<TDrizzle = unknown>(): DisposableDatabase<TDrizzle> {
|
|
65
133
|
return {
|
package/src/testing/index.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Shared test infrastructure for Hono on Cloudflare Workers projects (depends on `mysql2`/`drizzle-orm`).
|
|
3
|
+
*
|
|
4
|
+
* Test-only helpers that are never loaded at runtime. This subpath consolidates the duplicated
|
|
5
|
+
* test boilerplate (test DB setup, in-memory fakes, auth header builders, Stripe fixtures) that
|
|
6
|
+
* tends to be copy-pasted across projects into a single, importable surface.
|
|
7
|
+
*/
|
|
3
8
|
|
|
4
|
-
export { createTestDb } from './db';
|
|
5
|
-
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db';
|
|
9
|
+
export { createTestDb } from './db.js';
|
|
10
|
+
export type { TestDb, CreateTestDbOptions, TestDbConnection } from './db.js';
|
|
6
11
|
|
|
7
|
-
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes';
|
|
8
|
-
export type { CreatePoolDatabaseOptions } from './fakes';
|
|
9
|
-
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database';
|
|
12
|
+
export { FakeFirebaseVerifier, createPoolDatabase, createNoopDatabase } from './fakes.js';
|
|
13
|
+
export type { CreatePoolDatabaseOptions } from './fakes.js';
|
|
14
|
+
export type { Database, DisposableDatabase, QueryRunner, TxOf } from '../db/database.js';
|
|
10
15
|
|
|
11
|
-
//
|
|
12
|
-
export { authHeaders, registerFirebaseToken, provisionUser } from './auth';
|
|
16
|
+
// Authentication test helpers (route-spec header builders and user provisioning).
|
|
17
|
+
export { authHeaders, registerFirebaseToken, provisionUser } from './auth.js';
|
|
13
18
|
|
|
14
|
-
//
|
|
15
|
-
export { configurableFake } from './configurable-fake';
|
|
19
|
+
// Test double helper (partial-implementation fake that throws explicitly on unconfigured members).
|
|
20
|
+
export { configurableFake } from './configurable-fake.js';
|
|
16
21
|
|
|
17
|
-
//
|
|
22
|
+
// Test fixture factories for Stripe objects.
|
|
18
23
|
export {
|
|
19
24
|
fakeApiList,
|
|
20
25
|
fakePaymentIntent,
|
|
@@ -23,4 +28,4 @@ export {
|
|
|
23
28
|
fakeCustomer,
|
|
24
29
|
fakePrice,
|
|
25
30
|
fakeSubscription,
|
|
26
|
-
} from './stripe-fixtures';
|
|
31
|
+
} from './stripe-fixtures.js';
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import type Stripe from 'stripe';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Test fixture factories for Stripe objects.
|
|
5
|
+
*
|
|
6
|
+
* The real SDK types are enormous, so each factory builds only the fields tests typically read,
|
|
7
|
+
* fills them with reasonable defaults, lets you override via `over`, and casts to the Stripe type
|
|
8
|
+
* once at the end. This consolidates the duplicated hand-built dummy `PaymentIntent`/`Event`/... that
|
|
9
|
+
* billing tests tend to reconstruct in every project.
|
|
7
10
|
*/
|
|
8
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Build a fake Stripe `ApiList` wrapping the given data.
|
|
14
|
+
*
|
|
15
|
+
* @remarks Defaults: `object: 'list'`, `has_more: false`, `url: '/v1/_test'`.
|
|
16
|
+
* @typeParam T - Element type of the list.
|
|
17
|
+
* @param data - Items to place in `data`.
|
|
18
|
+
* @param over - Field overrides merged last.
|
|
19
|
+
* @returns A `Stripe.ApiList<T>` fixture.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const list = fakeApiList([fakePaymentIntent()]);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
9
25
|
export function fakeApiList<T>(data: T[], over: Partial<Stripe.ApiList<T>> = {}): Stripe.ApiList<T> {
|
|
10
26
|
return {
|
|
11
27
|
object: 'list',
|
|
@@ -16,6 +32,18 @@ export function fakeApiList<T>(data: T[], over: Partial<Stripe.ApiList<T>> = {})
|
|
|
16
32
|
};
|
|
17
33
|
}
|
|
18
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Build a fake Stripe `PaymentIntent`.
|
|
37
|
+
*
|
|
38
|
+
* @remarks Defaults: `id: 'pi_test_1'`, `object: 'payment_intent'`, `amount: 1000`, `currency: 'jpy'`,
|
|
39
|
+
* `status: 'succeeded'`, `created: 1_700_000_000`.
|
|
40
|
+
* @param over - Field overrides merged last.
|
|
41
|
+
* @returns A `Stripe.PaymentIntent` fixture.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const pi = fakePaymentIntent({ status: 'requires_payment_method' });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
19
47
|
export function fakePaymentIntent(over: Partial<Stripe.PaymentIntent> = {}): Stripe.PaymentIntent {
|
|
20
48
|
return {
|
|
21
49
|
id: 'pi_test_1',
|
|
@@ -28,6 +56,20 @@ export function fakePaymentIntent(over: Partial<Stripe.PaymentIntent> = {}): Str
|
|
|
28
56
|
} as Stripe.PaymentIntent;
|
|
29
57
|
}
|
|
30
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Build a fake Stripe webhook `Event` wrapping the given payload.
|
|
61
|
+
*
|
|
62
|
+
* @remarks Defaults: `id: 'evt_test_1'`, `object: 'event'`, `api_version: '2024-06-20'`,
|
|
63
|
+
* `created: 1_700_000_000`, `livemode: false`. The payload is placed at `data.object`.
|
|
64
|
+
* @param type - Event type (e.g. `'payment_intent.succeeded'`), assigned to `type`.
|
|
65
|
+
* @param dataObject - The object placed at `data.object`.
|
|
66
|
+
* @param over - Field overrides merged last.
|
|
67
|
+
* @returns A `Stripe.Event` fixture.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const event = fakeStripeEvent('payment_intent.succeeded', fakePaymentIntent());
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
31
73
|
export function fakeStripeEvent(type: string, dataObject: unknown, over: Partial<Stripe.Event> = {}): Stripe.Event {
|
|
32
74
|
return {
|
|
33
75
|
id: 'evt_test_1',
|
|
@@ -41,6 +83,18 @@ export function fakeStripeEvent(type: string, dataObject: unknown, over: Partial
|
|
|
41
83
|
} as Stripe.Event;
|
|
42
84
|
}
|
|
43
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Build a fake Stripe `Checkout.Session`.
|
|
88
|
+
*
|
|
89
|
+
* @remarks Defaults: `id: 'cs_test_1'`, `object: 'checkout.session'`,
|
|
90
|
+
* `url: 'https://checkout.stripe.test/cs_test_1'`, `mode: 'subscription'`, `status: 'open'`.
|
|
91
|
+
* @param over - Field overrides merged last.
|
|
92
|
+
* @returns A `Stripe.Checkout.Session` fixture.
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const session = fakeCheckoutSession({ status: 'complete' });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
44
98
|
export function fakeCheckoutSession(over: Partial<Stripe.Checkout.Session> = {}): Stripe.Checkout.Session {
|
|
45
99
|
return {
|
|
46
100
|
id: 'cs_test_1',
|
|
@@ -52,6 +106,18 @@ export function fakeCheckoutSession(over: Partial<Stripe.Checkout.Session> = {})
|
|
|
52
106
|
} as Stripe.Checkout.Session;
|
|
53
107
|
}
|
|
54
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Build a fake Stripe `Customer`.
|
|
111
|
+
*
|
|
112
|
+
* @remarks Defaults: `id: 'cus_test_1'`, `object: 'customer'`, `created: 1_700_000_000`,
|
|
113
|
+
* `livemode: false`.
|
|
114
|
+
* @param over - Field overrides merged last.
|
|
115
|
+
* @returns A `Stripe.Customer` fixture.
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const customer = fakeCustomer({ email: 'a@example.com' });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
55
121
|
export function fakeCustomer(over: Partial<Stripe.Customer> = {}): Stripe.Customer {
|
|
56
122
|
return {
|
|
57
123
|
id: 'cus_test_1',
|
|
@@ -62,6 +128,18 @@ export function fakeCustomer(over: Partial<Stripe.Customer> = {}): Stripe.Custom
|
|
|
62
128
|
} as Stripe.Customer;
|
|
63
129
|
}
|
|
64
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Build a fake Stripe `Price`.
|
|
133
|
+
*
|
|
134
|
+
* @remarks Defaults: `id: 'price_test_1'`, `object: 'price'`, `active: true`, `currency: 'jpy'`,
|
|
135
|
+
* `unit_amount: 1000`.
|
|
136
|
+
* @param over - Field overrides merged last.
|
|
137
|
+
* @returns A `Stripe.Price` fixture.
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* const price = fakePrice({ unit_amount: 2000 });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
65
143
|
export function fakePrice(over: Partial<Stripe.Price> = {}): Stripe.Price {
|
|
66
144
|
return {
|
|
67
145
|
id: 'price_test_1',
|
|
@@ -73,6 +151,18 @@ export function fakePrice(over: Partial<Stripe.Price> = {}): Stripe.Price {
|
|
|
73
151
|
} as Stripe.Price;
|
|
74
152
|
}
|
|
75
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Build a fake Stripe `Subscription`.
|
|
156
|
+
*
|
|
157
|
+
* @remarks Defaults: `id: 'sub_test_1'`, `object: 'subscription'`, `status: 'active'`,
|
|
158
|
+
* `customer: 'cus_test_1'`, `created: 1_700_000_000`.
|
|
159
|
+
* @param over - Field overrides merged last.
|
|
160
|
+
* @returns A `Stripe.Subscription` fixture.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const sub = fakeSubscription({ status: 'canceled' });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
76
166
|
export function fakeSubscription(over: Partial<Stripe.Subscription> = {}): Stripe.Subscription {
|
|
77
167
|
return {
|
|
78
168
|
id: 'sub_test_1',
|