@stripe/extensibility-test-helpers 0.2.7

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/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2026 Stripe, Inc. (https://stripe.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,218 @@
1
+ /**
2
+ * `@stripe/extensibility-test-helpers`
3
+ *
4
+ * Generic test client for Stripe resources.
5
+ *
6
+ * Works with both CustomObject subclasses and API objects like Customer.
7
+ * Backend implementations can be swapped for local testing vs sandbox.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
12
+ /**
13
+ * Backend interface for storage/API operations.
14
+ * Implement for different environments (local, sandbox, production).
15
+ * @public
16
+ */
17
+ export declare interface Backend {
18
+ /**
19
+ * Creates a new resource of the given object type.
20
+ * @param objectType - The Stripe object type string (e.g. `"customer"`).
21
+ * @param data - Fields to set on the new resource.
22
+ * @returns The created resource with a generated `id`.
23
+ */
24
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
25
+ /**
26
+ * Retrieves a resource by ID.
27
+ * @param objectType - The Stripe object type string.
28
+ * @param id - The resource ID.
29
+ * @returns The matching resource.
30
+ */
31
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
32
+ /**
33
+ * Updates an existing resource by merging the provided fields.
34
+ * @param objectType - The Stripe object type string.
35
+ * @param id - The resource ID.
36
+ * @param data - Fields to merge into the existing resource.
37
+ * @returns The updated resource.
38
+ */
39
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
40
+ /**
41
+ * Deletes a resource by ID.
42
+ * @param objectType - The Stripe object type string.
43
+ * @param id - The resource ID.
44
+ */
45
+ delete(objectType: string, id: string): Promise<void>;
46
+ /**
47
+ * Lists resources of the given object type with optional pagination.
48
+ * @param objectType - The Stripe object type string.
49
+ * @param params - Optional pagination parameters.
50
+ * @returns A paginated list response.
51
+ */
52
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
53
+ }
54
+
55
+ /**
56
+ * Input type for create - user-provided fields only.
57
+ *
58
+ * @public
59
+ */
60
+ export declare type CreateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
61
+
62
+ /**
63
+ * List pagination params.
64
+ * @public
65
+ */
66
+ export declare interface ListParams {
67
+ /** Maximum number of items to return. Defaults to `10`. */
68
+ limit?: number;
69
+ /** Return items after the item with this ID (exclusive). Use for forward pagination. */
70
+ startingAfter?: string;
71
+ /** Return items before the item with this ID (exclusive). Use for backward pagination. */
72
+ endingBefore?: string;
73
+ }
74
+
75
+ /**
76
+ * Paginated list response.
77
+ * @public
78
+ */
79
+ export declare interface ListResponse<T> {
80
+ /** The items in the current page. */
81
+ data: T[];
82
+ /** Whether additional items exist beyond this page. */
83
+ hasMore: boolean;
84
+ }
85
+
86
+ /**
87
+ * In-memory {@link Backend} implementation for use in unit tests.
88
+ *
89
+ * Each instance maintains its own isolated store. Use a shared instance
90
+ * when you need multiple clients to see the same data.
91
+ * @public
92
+ */
93
+ export declare class LocalBackend implements Backend {
94
+ private store;
95
+ private idCounter;
96
+ private getCollection;
97
+ private generateId;
98
+ /** {@inheritDoc Backend.create} */
99
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
100
+ /** {@inheritDoc Backend.retrieve} */
101
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
102
+ /** {@inheritDoc Backend.update} */
103
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
104
+ /** {@inheritDoc Backend.delete} */
105
+ delete(objectType: string, id: string): Promise<void>;
106
+ /** {@inheritDoc Backend.list} */
107
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
108
+ /** Resets all stored objects and the ID counter. Useful in `beforeEach` hooks. */
109
+ clear(): void;
110
+ }
111
+
112
+ /**
113
+ * A class constructor that produces instances of T.
114
+ * @public
115
+ */
116
+ export declare type ResourceClass<T extends StripeResource> = new (...args: unknown[]) => T;
117
+
118
+ /**
119
+ * Minimal interface for any Stripe resource.
120
+ * Both CustomObject and API objects satisfy this.
121
+ * @public
122
+ */
123
+ export declare interface StripeResource {
124
+ /** Unique identifier for the resource. */
125
+ id: string;
126
+ /** String identifying the object type, e.g. `"customer"` or `"custom_object.order"`. */
127
+ object: string;
128
+ }
129
+
130
+ /**
131
+ * Generic test client for any Stripe resource.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const locations = new TestClient(Location);
136
+ * const customers = new TestClient(Customer);
137
+ *
138
+ * const loc = await locations.create({ address: '123 Main' });
139
+ * const cust = await customers.create({ email: 'test@example.com' });
140
+ * ```
141
+ * @public
142
+ */
143
+ export declare class TestClient<T extends StripeResource> {
144
+ private ResourceClass;
145
+ private static sharedBackend;
146
+ private objectType;
147
+ private backend;
148
+ constructor(ResourceClass: ResourceClass<T>, options?: TestClientOptions);
149
+ /**
150
+ * Derive object type by instantiating the class and reading its `object` field.
151
+ *
152
+ * This works for classes that set `object` in their constructor or as a field
153
+ * initializer (e.g. `object = 'test.resource'`). It does **not** work for
154
+ * custom object classes that extend `BaseObject`, because `BaseObject.object`
155
+ * is only set after the build-time code transform runs — plain construction
156
+ * leaves it undefined. For those classes, pass `objectType` explicitly in the
157
+ * constructor options.
158
+ */
159
+ private deriveObjectType;
160
+ /**
161
+ * Hydrate plain data into a class instance.
162
+ * Returns an instance with the class's prototype (so methods work).
163
+ */
164
+ private hydrate;
165
+ /**
166
+ * Creates a new resource and returns it as a hydrated class instance.
167
+ *
168
+ * Injects standard platform field defaults (`created`, `updated`, `livemode`)
169
+ * before the caller's data, so the returned instance has the same shape a real
170
+ * Stripe backend would produce. Callers can override any default via `data`.
171
+ *
172
+ * @param data - Fields to set on the new resource (excluding `id` and `object`).
173
+ */
174
+ create(data: CreateInput<T>): Promise<T>;
175
+ /**
176
+ * Retrieves a resource by ID and returns it as a hydrated class instance.
177
+ * @param id - The resource ID.
178
+ */
179
+ retrieve(id: string): Promise<T>;
180
+ /**
181
+ * Merges the provided fields into an existing resource and returns the updated instance.
182
+ * @param id - The resource ID.
183
+ * @param data - Fields to merge into the existing resource (excluding `id` and `object`).
184
+ */
185
+ update(id: string, data: UpdateInput<T>): Promise<T>;
186
+ /**
187
+ * Deletes a resource by ID.
188
+ * @param id - The resource ID.
189
+ */
190
+ delete(id: string): Promise<void>;
191
+ /**
192
+ * Lists resources with optional pagination, returning hydrated class instances.
193
+ * @param params - Optional pagination parameters.
194
+ */
195
+ list(params?: ListParams): Promise<ListResponse<T>>;
196
+ /** Clear all test data across all object types */
197
+ static clearAll(): void;
198
+ }
199
+
200
+ /**
201
+ * Options for constructing a {@link TestClient}.
202
+ * @public
203
+ */
204
+ export declare interface TestClientOptions {
205
+ /** Explicit object type (if auto-derive doesn't work) */
206
+ objectType?: string;
207
+ /** Custom backend (defaults to shared LocalBackend) */
208
+ backend?: Backend;
209
+ }
210
+
211
+ /**
212
+ * Input type for update - partial user fields.
213
+ *
214
+ * @public
215
+ */
216
+ export declare type UpdateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
217
+
218
+ export { }
@@ -0,0 +1,218 @@
1
+ /**
2
+ * `@stripe/extensibility-test-helpers`
3
+ *
4
+ * Generic test client for Stripe resources.
5
+ *
6
+ * Works with both CustomObject subclasses and API objects like Customer.
7
+ * Backend implementations can be swapped for local testing vs sandbox.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
12
+ /**
13
+ * Backend interface for storage/API operations.
14
+ * Implement for different environments (local, sandbox, production).
15
+ * @public
16
+ */
17
+ export declare interface Backend {
18
+ /**
19
+ * Creates a new resource of the given object type.
20
+ * @param objectType - The Stripe object type string (e.g. `"customer"`).
21
+ * @param data - Fields to set on the new resource.
22
+ * @returns The created resource with a generated `id`.
23
+ */
24
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
25
+ /**
26
+ * Retrieves a resource by ID.
27
+ * @param objectType - The Stripe object type string.
28
+ * @param id - The resource ID.
29
+ * @returns The matching resource.
30
+ */
31
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
32
+ /**
33
+ * Updates an existing resource by merging the provided fields.
34
+ * @param objectType - The Stripe object type string.
35
+ * @param id - The resource ID.
36
+ * @param data - Fields to merge into the existing resource.
37
+ * @returns The updated resource.
38
+ */
39
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
40
+ /**
41
+ * Deletes a resource by ID.
42
+ * @param objectType - The Stripe object type string.
43
+ * @param id - The resource ID.
44
+ */
45
+ delete(objectType: string, id: string): Promise<void>;
46
+ /**
47
+ * Lists resources of the given object type with optional pagination.
48
+ * @param objectType - The Stripe object type string.
49
+ * @param params - Optional pagination parameters.
50
+ * @returns A paginated list response.
51
+ */
52
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
53
+ }
54
+
55
+ /**
56
+ * Input type for create - user-provided fields only.
57
+ *
58
+ * @public
59
+ */
60
+ export declare type CreateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
61
+
62
+ /**
63
+ * List pagination params.
64
+ * @public
65
+ */
66
+ export declare interface ListParams {
67
+ /** Maximum number of items to return. Defaults to `10`. */
68
+ limit?: number;
69
+ /** Return items after the item with this ID (exclusive). Use for forward pagination. */
70
+ startingAfter?: string;
71
+ /** Return items before the item with this ID (exclusive). Use for backward pagination. */
72
+ endingBefore?: string;
73
+ }
74
+
75
+ /**
76
+ * Paginated list response.
77
+ * @public
78
+ */
79
+ export declare interface ListResponse<T> {
80
+ /** The items in the current page. */
81
+ data: T[];
82
+ /** Whether additional items exist beyond this page. */
83
+ hasMore: boolean;
84
+ }
85
+
86
+ /**
87
+ * In-memory {@link Backend} implementation for use in unit tests.
88
+ *
89
+ * Each instance maintains its own isolated store. Use a shared instance
90
+ * when you need multiple clients to see the same data.
91
+ * @public
92
+ */
93
+ export declare class LocalBackend implements Backend {
94
+ private store;
95
+ private idCounter;
96
+ private getCollection;
97
+ private generateId;
98
+ /** {@inheritDoc Backend.create} */
99
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
100
+ /** {@inheritDoc Backend.retrieve} */
101
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
102
+ /** {@inheritDoc Backend.update} */
103
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
104
+ /** {@inheritDoc Backend.delete} */
105
+ delete(objectType: string, id: string): Promise<void>;
106
+ /** {@inheritDoc Backend.list} */
107
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
108
+ /** Resets all stored objects and the ID counter. Useful in `beforeEach` hooks. */
109
+ clear(): void;
110
+ }
111
+
112
+ /**
113
+ * A class constructor that produces instances of T.
114
+ * @public
115
+ */
116
+ export declare type ResourceClass<T extends StripeResource> = new (...args: unknown[]) => T;
117
+
118
+ /**
119
+ * Minimal interface for any Stripe resource.
120
+ * Both CustomObject and API objects satisfy this.
121
+ * @public
122
+ */
123
+ export declare interface StripeResource {
124
+ /** Unique identifier for the resource. */
125
+ id: string;
126
+ /** String identifying the object type, e.g. `"customer"` or `"custom_object.order"`. */
127
+ object: string;
128
+ }
129
+
130
+ /**
131
+ * Generic test client for any Stripe resource.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const locations = new TestClient(Location);
136
+ * const customers = new TestClient(Customer);
137
+ *
138
+ * const loc = await locations.create({ address: '123 Main' });
139
+ * const cust = await customers.create({ email: 'test@example.com' });
140
+ * ```
141
+ * @public
142
+ */
143
+ export declare class TestClient<T extends StripeResource> {
144
+ private ResourceClass;
145
+ private static sharedBackend;
146
+ private objectType;
147
+ private backend;
148
+ constructor(ResourceClass: ResourceClass<T>, options?: TestClientOptions);
149
+ /**
150
+ * Derive object type by instantiating the class and reading its `object` field.
151
+ *
152
+ * This works for classes that set `object` in their constructor or as a field
153
+ * initializer (e.g. `object = 'test.resource'`). It does **not** work for
154
+ * custom object classes that extend `BaseObject`, because `BaseObject.object`
155
+ * is only set after the build-time code transform runs — plain construction
156
+ * leaves it undefined. For those classes, pass `objectType` explicitly in the
157
+ * constructor options.
158
+ */
159
+ private deriveObjectType;
160
+ /**
161
+ * Hydrate plain data into a class instance.
162
+ * Returns an instance with the class's prototype (so methods work).
163
+ */
164
+ private hydrate;
165
+ /**
166
+ * Creates a new resource and returns it as a hydrated class instance.
167
+ *
168
+ * Injects standard platform field defaults (`created`, `updated`, `livemode`)
169
+ * before the caller's data, so the returned instance has the same shape a real
170
+ * Stripe backend would produce. Callers can override any default via `data`.
171
+ *
172
+ * @param data - Fields to set on the new resource (excluding `id` and `object`).
173
+ */
174
+ create(data: CreateInput<T>): Promise<T>;
175
+ /**
176
+ * Retrieves a resource by ID and returns it as a hydrated class instance.
177
+ * @param id - The resource ID.
178
+ */
179
+ retrieve(id: string): Promise<T>;
180
+ /**
181
+ * Merges the provided fields into an existing resource and returns the updated instance.
182
+ * @param id - The resource ID.
183
+ * @param data - Fields to merge into the existing resource (excluding `id` and `object`).
184
+ */
185
+ update(id: string, data: UpdateInput<T>): Promise<T>;
186
+ /**
187
+ * Deletes a resource by ID.
188
+ * @param id - The resource ID.
189
+ */
190
+ delete(id: string): Promise<void>;
191
+ /**
192
+ * Lists resources with optional pagination, returning hydrated class instances.
193
+ * @param params - Optional pagination parameters.
194
+ */
195
+ list(params?: ListParams): Promise<ListResponse<T>>;
196
+ /** Clear all test data across all object types */
197
+ static clearAll(): void;
198
+ }
199
+
200
+ /**
201
+ * Options for constructing a {@link TestClient}.
202
+ * @public
203
+ */
204
+ export declare interface TestClientOptions {
205
+ /** Explicit object type (if auto-derive doesn't work) */
206
+ objectType?: string;
207
+ /** Custom backend (defaults to shared LocalBackend) */
208
+ backend?: Backend;
209
+ }
210
+
211
+ /**
212
+ * Input type for update - partial user fields.
213
+ *
214
+ * @public
215
+ */
216
+ export declare type UpdateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
217
+
218
+ export { }
@@ -0,0 +1,218 @@
1
+ /**
2
+ * `@stripe/extensibility-test-helpers`
3
+ *
4
+ * Generic test client for Stripe resources.
5
+ *
6
+ * Works with both CustomObject subclasses and API objects like Customer.
7
+ * Backend implementations can be swapped for local testing vs sandbox.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+
12
+ /**
13
+ * Backend interface for storage/API operations.
14
+ * Implement for different environments (local, sandbox, production).
15
+ * @public
16
+ */
17
+ export declare interface Backend {
18
+ /**
19
+ * Creates a new resource of the given object type.
20
+ * @param objectType - The Stripe object type string (e.g. `"customer"`).
21
+ * @param data - Fields to set on the new resource.
22
+ * @returns The created resource with a generated `id`.
23
+ */
24
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
25
+ /**
26
+ * Retrieves a resource by ID.
27
+ * @param objectType - The Stripe object type string.
28
+ * @param id - The resource ID.
29
+ * @returns The matching resource.
30
+ */
31
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
32
+ /**
33
+ * Updates an existing resource by merging the provided fields.
34
+ * @param objectType - The Stripe object type string.
35
+ * @param id - The resource ID.
36
+ * @param data - Fields to merge into the existing resource.
37
+ * @returns The updated resource.
38
+ */
39
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
40
+ /**
41
+ * Deletes a resource by ID.
42
+ * @param objectType - The Stripe object type string.
43
+ * @param id - The resource ID.
44
+ */
45
+ delete(objectType: string, id: string): Promise<void>;
46
+ /**
47
+ * Lists resources of the given object type with optional pagination.
48
+ * @param objectType - The Stripe object type string.
49
+ * @param params - Optional pagination parameters.
50
+ * @returns A paginated list response.
51
+ */
52
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
53
+ }
54
+
55
+ /**
56
+ * Input type for create - user-provided fields only.
57
+ *
58
+ * @public
59
+ */
60
+ export declare type CreateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
61
+
62
+ /**
63
+ * List pagination params.
64
+ * @public
65
+ */
66
+ export declare interface ListParams {
67
+ /** Maximum number of items to return. Defaults to `10`. */
68
+ limit?: number;
69
+ /** Return items after the item with this ID (exclusive). Use for forward pagination. */
70
+ startingAfter?: string;
71
+ /** Return items before the item with this ID (exclusive). Use for backward pagination. */
72
+ endingBefore?: string;
73
+ }
74
+
75
+ /**
76
+ * Paginated list response.
77
+ * @public
78
+ */
79
+ export declare interface ListResponse<T> {
80
+ /** The items in the current page. */
81
+ data: T[];
82
+ /** Whether additional items exist beyond this page. */
83
+ hasMore: boolean;
84
+ }
85
+
86
+ /**
87
+ * In-memory {@link Backend} implementation for use in unit tests.
88
+ *
89
+ * Each instance maintains its own isolated store. Use a shared instance
90
+ * when you need multiple clients to see the same data.
91
+ * @public
92
+ */
93
+ export declare class LocalBackend implements Backend {
94
+ private store;
95
+ private idCounter;
96
+ private getCollection;
97
+ private generateId;
98
+ /** {@inheritDoc Backend.create} */
99
+ create<T extends StripeResource>(objectType: string, data: Record<string, unknown>): Promise<T>;
100
+ /** {@inheritDoc Backend.retrieve} */
101
+ retrieve<T extends StripeResource>(objectType: string, id: string): Promise<T>;
102
+ /** {@inheritDoc Backend.update} */
103
+ update<T extends StripeResource>(objectType: string, id: string, data: Record<string, unknown>): Promise<T>;
104
+ /** {@inheritDoc Backend.delete} */
105
+ delete(objectType: string, id: string): Promise<void>;
106
+ /** {@inheritDoc Backend.list} */
107
+ list<T extends StripeResource>(objectType: string, params?: ListParams): Promise<ListResponse<T>>;
108
+ /** Resets all stored objects and the ID counter. Useful in `beforeEach` hooks. */
109
+ clear(): void;
110
+ }
111
+
112
+ /**
113
+ * A class constructor that produces instances of T.
114
+ * @public
115
+ */
116
+ export declare type ResourceClass<T extends StripeResource> = new (...args: unknown[]) => T;
117
+
118
+ /**
119
+ * Minimal interface for any Stripe resource.
120
+ * Both CustomObject and API objects satisfy this.
121
+ * @public
122
+ */
123
+ export declare interface StripeResource {
124
+ /** Unique identifier for the resource. */
125
+ id: string;
126
+ /** String identifying the object type, e.g. `"customer"` or `"custom_object.order"`. */
127
+ object: string;
128
+ }
129
+
130
+ /**
131
+ * Generic test client for any Stripe resource.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const locations = new TestClient(Location);
136
+ * const customers = new TestClient(Customer);
137
+ *
138
+ * const loc = await locations.create({ address: '123 Main' });
139
+ * const cust = await customers.create({ email: 'test@example.com' });
140
+ * ```
141
+ * @public
142
+ */
143
+ export declare class TestClient<T extends StripeResource> {
144
+ private ResourceClass;
145
+ private static sharedBackend;
146
+ private objectType;
147
+ private backend;
148
+ constructor(ResourceClass: ResourceClass<T>, options?: TestClientOptions);
149
+ /**
150
+ * Derive object type by instantiating the class and reading its `object` field.
151
+ *
152
+ * This works for classes that set `object` in their constructor or as a field
153
+ * initializer (e.g. `object = 'test.resource'`). It does **not** work for
154
+ * custom object classes that extend `BaseObject`, because `BaseObject.object`
155
+ * is only set after the build-time code transform runs — plain construction
156
+ * leaves it undefined. For those classes, pass `objectType` explicitly in the
157
+ * constructor options.
158
+ */
159
+ private deriveObjectType;
160
+ /**
161
+ * Hydrate plain data into a class instance.
162
+ * Returns an instance with the class's prototype (so methods work).
163
+ */
164
+ private hydrate;
165
+ /**
166
+ * Creates a new resource and returns it as a hydrated class instance.
167
+ *
168
+ * Injects standard platform field defaults (`created`, `updated`, `livemode`)
169
+ * before the caller's data, so the returned instance has the same shape a real
170
+ * Stripe backend would produce. Callers can override any default via `data`.
171
+ *
172
+ * @param data - Fields to set on the new resource (excluding `id` and `object`).
173
+ */
174
+ create(data: CreateInput<T>): Promise<T>;
175
+ /**
176
+ * Retrieves a resource by ID and returns it as a hydrated class instance.
177
+ * @param id - The resource ID.
178
+ */
179
+ retrieve(id: string): Promise<T>;
180
+ /**
181
+ * Merges the provided fields into an existing resource and returns the updated instance.
182
+ * @param id - The resource ID.
183
+ * @param data - Fields to merge into the existing resource (excluding `id` and `object`).
184
+ */
185
+ update(id: string, data: UpdateInput<T>): Promise<T>;
186
+ /**
187
+ * Deletes a resource by ID.
188
+ * @param id - The resource ID.
189
+ */
190
+ delete(id: string): Promise<void>;
191
+ /**
192
+ * Lists resources with optional pagination, returning hydrated class instances.
193
+ * @param params - Optional pagination parameters.
194
+ */
195
+ list(params?: ListParams): Promise<ListResponse<T>>;
196
+ /** Clear all test data across all object types */
197
+ static clearAll(): void;
198
+ }
199
+
200
+ /**
201
+ * Options for constructing a {@link TestClient}.
202
+ * @public
203
+ */
204
+ export declare interface TestClientOptions {
205
+ /** Explicit object type (if auto-derive doesn't work) */
206
+ objectType?: string;
207
+ /** Custom backend (defaults to shared LocalBackend) */
208
+ backend?: Backend;
209
+ }
210
+
211
+ /**
212
+ * Input type for update - partial user fields.
213
+ *
214
+ * @public
215
+ */
216
+ export declare type UpdateInput<T extends StripeResource> = Partial<Omit<T, 'id' | 'object'>>;
217
+
218
+ export { }