alchemy 0.24.0 → 0.25.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.
- package/lib/aws/control/client.js +1 -1
- package/lib/aws/control/client.js.map +1 -1
- package/lib/aws/control/resource.d.ts.map +1 -1
- package/lib/aws/control/resource.js +2 -1
- package/lib/aws/control/resource.js.map +1 -1
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +1 -4
- package/lib/aws/function.js.map +1 -1
- package/lib/cloudflare/ai.d.ts +21 -0
- package/lib/cloudflare/ai.d.ts.map +1 -1
- package/lib/cloudflare/ai.js +21 -0
- package/lib/cloudflare/ai.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +3 -3
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +3 -3
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/do-state-store/index.d.ts +2 -0
- package/lib/cloudflare/do-state-store/index.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/index.js +2 -0
- package/lib/cloudflare/do-state-store/index.js.map +1 -0
- package/lib/cloudflare/do-state-store/internal.d.ts +19 -0
- package/lib/cloudflare/do-state-store/internal.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/internal.js +163 -0
- package/lib/cloudflare/do-state-store/internal.js.map +1 -0
- package/lib/cloudflare/do-state-store/store.d.ts +59 -0
- package/lib/cloudflare/do-state-store/store.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/store.js +120 -0
- package/lib/cloudflare/do-state-store/store.js.map +1 -0
- package/lib/cloudflare/do-state-store/types.d.ts +82 -0
- package/lib/cloudflare/do-state-store/types.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/types.js +1 -0
- package/lib/cloudflare/do-state-store/types.js.map +1 -0
- package/lib/cloudflare/do-state-store/worker.d.ts +27 -0
- package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/worker.js +170 -0
- package/lib/cloudflare/do-state-store/worker.js.map +1 -0
- package/lib/cloudflare/index.d.ts +1 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +1 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/pipeline.js +1 -1
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +14 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +17 -0
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/website.d.ts +30 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +8 -5
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +13 -3
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.js +1 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +40 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +40 -38
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.js +1 -1
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +30 -2
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +53 -0
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/fs/file-system-state-store.d.ts +3 -1
- package/lib/fs/file-system-state-store.d.ts.map +1 -1
- package/lib/fs/file-system-state-store.js +2 -2
- package/lib/fs/file-system-state-store.js.map +1 -1
- package/lib/stripe/card.d.ts +171 -0
- package/lib/stripe/card.d.ts.map +1 -0
- package/lib/stripe/card.js +148 -0
- package/lib/stripe/card.js.map +1 -0
- package/lib/stripe/client.d.ts +9 -0
- package/lib/stripe/client.d.ts.map +1 -0
- package/lib/stripe/client.js +94 -0
- package/lib/stripe/client.js.map +1 -0
- package/lib/stripe/coupon.d.ts +135 -0
- package/lib/stripe/coupon.d.ts.map +1 -0
- package/lib/stripe/coupon.js +161 -0
- package/lib/stripe/coupon.js.map +1 -0
- package/lib/stripe/customer.d.ts +269 -0
- package/lib/stripe/customer.d.ts.map +1 -0
- package/lib/stripe/customer.js +289 -0
- package/lib/stripe/customer.js.map +1 -0
- package/lib/stripe/entitlements-feature.d.ts +84 -0
- package/lib/stripe/entitlements-feature.d.ts.map +1 -0
- package/lib/stripe/entitlements-feature.js +102 -0
- package/lib/stripe/entitlements-feature.js.map +1 -0
- package/lib/stripe/file.d.ts +143 -0
- package/lib/stripe/file.d.ts.map +1 -0
- package/lib/stripe/file.js +97 -0
- package/lib/stripe/file.js.map +1 -0
- package/lib/stripe/index.d.ts +11 -0
- package/lib/stripe/index.d.ts.map +1 -1
- package/lib/stripe/index.js +11 -0
- package/lib/stripe/index.js.map +1 -1
- package/lib/stripe/meter.d.ts +10 -1
- package/lib/stripe/meter.d.ts.map +1 -1
- package/lib/stripe/meter.js +13 -7
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/portal-configuration.d.ts +286 -0
- package/lib/stripe/portal-configuration.d.ts.map +1 -0
- package/lib/stripe/portal-configuration.js +320 -0
- package/lib/stripe/portal-configuration.js.map +1 -0
- package/lib/stripe/price.d.ts +10 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +34 -13
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product-feature.d.ts +76 -0
- package/lib/stripe/product-feature.d.ts.map +1 -0
- package/lib/stripe/product-feature.js +74 -0
- package/lib/stripe/product-feature.js.map +1 -0
- package/lib/stripe/product.d.ts +10 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +33 -14
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/promotion-code.d.ts +138 -0
- package/lib/stripe/promotion-code.d.ts.map +1 -0
- package/lib/stripe/promotion-code.js +150 -0
- package/lib/stripe/promotion-code.js.map +1 -0
- package/lib/stripe/shipping-rate.d.ts +188 -0
- package/lib/stripe/shipping-rate.d.ts.map +1 -0
- package/lib/stripe/shipping-rate.js +198 -0
- package/lib/stripe/shipping-rate.js.map +1 -0
- package/lib/stripe/tax-rate.d.ts +130 -0
- package/lib/stripe/tax-rate.d.ts.map +1 -0
- package/lib/stripe/tax-rate.js +126 -0
- package/lib/stripe/tax-rate.js.map +1 -0
- package/lib/stripe/webhook.d.ts +10 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +59 -14
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +2 -6
- package/lib/test/bun.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +3 -7
- package/lib/test/vitest.js.map +1 -1
- package/lib/util/retry.d.ts +1 -1
- package/lib/util/retry.d.ts.map +1 -1
- package/lib/util/retry.js.map +1 -1
- package/package.json +3 -2
- package/src/aws/control/client.ts +1 -1
- package/src/aws/control/resource.ts +2 -1
- package/src/aws/function.ts +3 -6
- package/src/cloudflare/ai.ts +21 -0
- package/src/cloudflare/bindings.ts +3 -2
- package/src/cloudflare/bound.ts +3 -3
- package/src/cloudflare/do-state-store/index.ts +1 -0
- package/src/cloudflare/do-state-store/internal.ts +215 -0
- package/src/cloudflare/do-state-store/store.ts +188 -0
- package/src/cloudflare/do-state-store/types.ts +74 -0
- package/src/cloudflare/do-state-store/worker.ts +199 -0
- package/src/cloudflare/index.ts +1 -0
- package/src/cloudflare/pipeline.ts +1 -1
- package/src/cloudflare/queue-consumer.ts +59 -1
- package/src/cloudflare/website.ts +38 -6
- package/src/cloudflare/worker-assets.ts +15 -3
- package/src/cloudflare/worker-metadata.ts +1 -1
- package/src/cloudflare/worker.ts +66 -46
- package/src/cloudflare/wrangler.json.ts +1 -1
- package/src/cloudflare/zone.ts +75 -2
- package/src/fs/file-system-state-store.ts +7 -2
- package/src/stripe/card.ts +320 -0
- package/src/stripe/client.ts +145 -0
- package/src/stripe/coupon.ts +280 -0
- package/src/stripe/customer.ts +528 -0
- package/src/stripe/entitlements-feature.ts +169 -0
- package/src/stripe/file.ts +219 -0
- package/src/stripe/index.ts +11 -0
- package/src/stripe/meter.ts +23 -7
- package/src/stripe/portal-configuration.ts +609 -0
- package/src/stripe/price.ts +47 -14
- package/src/stripe/product-feature.ts +150 -0
- package/src/stripe/product.ts +48 -15
- package/src/stripe/promotion-code.ts +268 -0
- package/src/stripe/shipping-rate.ts +362 -0
- package/src/stripe/tax-rate.ts +218 -0
- package/src/stripe/webhook.ts +82 -15
- package/src/test/bun.ts +2 -7
- package/src/test/vitest.ts +3 -8
- package/src/util/retry.ts +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, handleStripeDeleteError } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create and manage Stripe customers
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a basic customer
|
|
8
|
+
* const basicCustomer = await Customer("basic-customer", {
|
|
9
|
+
* email: "john@example.com",
|
|
10
|
+
* name: "John Doe",
|
|
11
|
+
* description: "Premium customer",
|
|
12
|
+
* metadata: {
|
|
13
|
+
* tier: "premium",
|
|
14
|
+
* source: "website"
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a customer with full address information
|
|
20
|
+
* const customerWithAddress = await Customer("customer-with-address", {
|
|
21
|
+
* email: "jane@example.com",
|
|
22
|
+
* name: "Jane Smith",
|
|
23
|
+
* phone: "+1-555-123-4567",
|
|
24
|
+
* address: {
|
|
25
|
+
* line1: "123 Main St",
|
|
26
|
+
* line2: "Apt 4B",
|
|
27
|
+
* city: "San Francisco",
|
|
28
|
+
* state: "CA",
|
|
29
|
+
* postalCode: "94105",
|
|
30
|
+
* country: "US"
|
|
31
|
+
* },
|
|
32
|
+
* shipping: {
|
|
33
|
+
* name: "Jane Smith",
|
|
34
|
+
* address: {
|
|
35
|
+
* line1: "456 Oak Ave",
|
|
36
|
+
* city: "Oakland",
|
|
37
|
+
* state: "CA",
|
|
38
|
+
* postalCode: "94612",
|
|
39
|
+
* country: "US"
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Create a business customer with tax exemption
|
|
46
|
+
* const businessCustomer = await Customer("business-customer", {
|
|
47
|
+
* email: "billing@acmecorp.com",
|
|
48
|
+
* name: "Acme Corporation",
|
|
49
|
+
* description: "Enterprise customer",
|
|
50
|
+
* taxExempt: "exempt",
|
|
51
|
+
* invoicePrefix: "ACME",
|
|
52
|
+
* preferredLocales: ["en"],
|
|
53
|
+
* metadata: {
|
|
54
|
+
* type: "business",
|
|
55
|
+
* industry: "technology",
|
|
56
|
+
* employees: "500+"
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
export const Customer = Resource("stripe::Customer", async function (_id, props) {
|
|
61
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
62
|
+
if (this.phase === "delete") {
|
|
63
|
+
try {
|
|
64
|
+
if (this.output?.id) {
|
|
65
|
+
await stripe.customers.del(this.output.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
handleStripeDeleteError(error, "Customer", this.output?.id);
|
|
70
|
+
}
|
|
71
|
+
return this.destroy();
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
let customer;
|
|
75
|
+
if (this.phase === "update" && this.output?.id) {
|
|
76
|
+
const updateParams = {
|
|
77
|
+
address: props.address
|
|
78
|
+
? {
|
|
79
|
+
city: props.address.city,
|
|
80
|
+
country: props.address.country,
|
|
81
|
+
line1: props.address.line1,
|
|
82
|
+
line2: props.address.line2,
|
|
83
|
+
postal_code: props.address.postalCode,
|
|
84
|
+
state: props.address.state,
|
|
85
|
+
}
|
|
86
|
+
: undefined,
|
|
87
|
+
balance: props.balance,
|
|
88
|
+
coupon: props.coupon,
|
|
89
|
+
description: props.description,
|
|
90
|
+
email: props.email,
|
|
91
|
+
invoice_prefix: props.invoicePrefix,
|
|
92
|
+
metadata: props.metadata,
|
|
93
|
+
name: props.name,
|
|
94
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
95
|
+
phone: props.phone,
|
|
96
|
+
preferred_locales: props.preferredLocales,
|
|
97
|
+
promotion_code: props.promotionCode,
|
|
98
|
+
shipping: props.shipping,
|
|
99
|
+
source: props.source,
|
|
100
|
+
tax_exempt: props.taxExempt,
|
|
101
|
+
};
|
|
102
|
+
if (props.invoiceSettings) {
|
|
103
|
+
updateParams.invoice_settings = {
|
|
104
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
105
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
106
|
+
footer: props.invoiceSettings.footer,
|
|
107
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
108
|
+
? {
|
|
109
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
110
|
+
}
|
|
111
|
+
: null,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
customer = await stripe.customers.update(this.output.id, updateParams);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const createParams = {
|
|
118
|
+
address: props.address
|
|
119
|
+
? {
|
|
120
|
+
city: props.address.city,
|
|
121
|
+
country: props.address.country,
|
|
122
|
+
line1: props.address.line1,
|
|
123
|
+
line2: props.address.line2,
|
|
124
|
+
postal_code: props.address.postalCode,
|
|
125
|
+
state: props.address.state,
|
|
126
|
+
}
|
|
127
|
+
: undefined,
|
|
128
|
+
balance: props.balance,
|
|
129
|
+
coupon: props.coupon,
|
|
130
|
+
description: props.description,
|
|
131
|
+
email: props.email,
|
|
132
|
+
invoice_prefix: props.invoicePrefix,
|
|
133
|
+
metadata: props.metadata,
|
|
134
|
+
name: props.name,
|
|
135
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
136
|
+
payment_method: props.paymentMethod,
|
|
137
|
+
phone: props.phone,
|
|
138
|
+
preferred_locales: props.preferredLocales,
|
|
139
|
+
promotion_code: props.promotionCode,
|
|
140
|
+
shipping: props.shipping,
|
|
141
|
+
source: props.source,
|
|
142
|
+
tax_exempt: props.taxExempt,
|
|
143
|
+
test_clock: props.testClock,
|
|
144
|
+
};
|
|
145
|
+
if (props.invoiceSettings) {
|
|
146
|
+
createParams.invoice_settings = {
|
|
147
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
148
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
149
|
+
footer: props.invoiceSettings.footer,
|
|
150
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
151
|
+
? {
|
|
152
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
153
|
+
}
|
|
154
|
+
: null,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (props.adopt && props.email) {
|
|
158
|
+
const existingCustomers = await stripe.customers.list({
|
|
159
|
+
email: props.email,
|
|
160
|
+
limit: 1,
|
|
161
|
+
});
|
|
162
|
+
if (existingCustomers.data.length > 0) {
|
|
163
|
+
const existingCustomer = existingCustomers.data[0];
|
|
164
|
+
const adoptUpdateParams = {
|
|
165
|
+
address: props.address
|
|
166
|
+
? {
|
|
167
|
+
city: props.address.city,
|
|
168
|
+
country: props.address.country,
|
|
169
|
+
line1: props.address.line1,
|
|
170
|
+
line2: props.address.line2,
|
|
171
|
+
postal_code: props.address.postalCode,
|
|
172
|
+
state: props.address.state,
|
|
173
|
+
}
|
|
174
|
+
: undefined,
|
|
175
|
+
balance: props.balance,
|
|
176
|
+
coupon: props.coupon,
|
|
177
|
+
description: props.description,
|
|
178
|
+
email: props.email,
|
|
179
|
+
invoice_prefix: props.invoicePrefix,
|
|
180
|
+
metadata: props.metadata,
|
|
181
|
+
name: props.name,
|
|
182
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
183
|
+
phone: props.phone,
|
|
184
|
+
preferred_locales: props.preferredLocales,
|
|
185
|
+
promotion_code: props.promotionCode,
|
|
186
|
+
shipping: props.shipping,
|
|
187
|
+
source: props.source,
|
|
188
|
+
tax_exempt: props.taxExempt,
|
|
189
|
+
};
|
|
190
|
+
if (props.invoiceSettings) {
|
|
191
|
+
adoptUpdateParams.invoice_settings = {
|
|
192
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
193
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
194
|
+
footer: props.invoiceSettings.footer,
|
|
195
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
196
|
+
? {
|
|
197
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
198
|
+
}
|
|
199
|
+
: null,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
customer = await stripe.customers.update(existingCustomer.id, adoptUpdateParams);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
customer = await stripe.customers.create(createParams);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
customer = await stripe.customers.create(createParams);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return this({
|
|
213
|
+
id: customer.id,
|
|
214
|
+
object: customer.object,
|
|
215
|
+
address: customer.address
|
|
216
|
+
? {
|
|
217
|
+
city: customer.address.city || undefined,
|
|
218
|
+
country: customer.address.country || undefined,
|
|
219
|
+
line1: customer.address.line1 || undefined,
|
|
220
|
+
line2: customer.address.line2 || undefined,
|
|
221
|
+
postalCode: customer.address.postal_code || undefined,
|
|
222
|
+
state: customer.address.state || undefined,
|
|
223
|
+
}
|
|
224
|
+
: undefined,
|
|
225
|
+
balance: customer.balance || undefined,
|
|
226
|
+
created: customer.created,
|
|
227
|
+
currency: customer.currency || undefined,
|
|
228
|
+
defaultSource: typeof customer.default_source === "string"
|
|
229
|
+
? customer.default_source
|
|
230
|
+
: undefined,
|
|
231
|
+
delinquent: customer.delinquent || undefined,
|
|
232
|
+
description: customer.description || undefined,
|
|
233
|
+
discount: customer.discount || undefined,
|
|
234
|
+
email: customer.email || undefined,
|
|
235
|
+
invoicePrefix: customer.invoice_prefix || undefined,
|
|
236
|
+
invoiceSettings: customer.invoice_settings
|
|
237
|
+
? {
|
|
238
|
+
customFields: customer.invoice_settings.custom_fields?.map((field) => ({
|
|
239
|
+
name: field.name,
|
|
240
|
+
value: field.value,
|
|
241
|
+
})) || undefined,
|
|
242
|
+
defaultPaymentMethod: typeof customer.invoice_settings.default_payment_method ===
|
|
243
|
+
"string"
|
|
244
|
+
? customer.invoice_settings.default_payment_method
|
|
245
|
+
: customer.invoice_settings.default_payment_method?.id ||
|
|
246
|
+
undefined,
|
|
247
|
+
footer: customer.invoice_settings.footer || undefined,
|
|
248
|
+
renderingOptions: customer.invoice_settings.rendering_options
|
|
249
|
+
? {
|
|
250
|
+
amountTaxDisplay: customer.invoice_settings
|
|
251
|
+
.rendering_options.amount_tax_display,
|
|
252
|
+
}
|
|
253
|
+
: undefined,
|
|
254
|
+
}
|
|
255
|
+
: undefined,
|
|
256
|
+
livemode: customer.livemode,
|
|
257
|
+
metadata: customer.metadata || undefined,
|
|
258
|
+
name: customer.name || undefined,
|
|
259
|
+
nextInvoiceSequence: customer.next_invoice_sequence || undefined,
|
|
260
|
+
phone: customer.phone || undefined,
|
|
261
|
+
preferredLocales: customer.preferred_locales || undefined,
|
|
262
|
+
shipping: customer.shipping
|
|
263
|
+
? {
|
|
264
|
+
address: customer.shipping.address
|
|
265
|
+
? {
|
|
266
|
+
city: customer.shipping.address.city || undefined,
|
|
267
|
+
country: customer.shipping.address.country || undefined,
|
|
268
|
+
line1: customer.shipping.address.line1 || undefined,
|
|
269
|
+
line2: customer.shipping.address.line2 || undefined,
|
|
270
|
+
postalCode: customer.shipping.address.postal_code || undefined,
|
|
271
|
+
state: customer.shipping.address.state || undefined,
|
|
272
|
+
}
|
|
273
|
+
: undefined,
|
|
274
|
+
name: customer.shipping.name || undefined,
|
|
275
|
+
phone: customer.shipping.phone || undefined,
|
|
276
|
+
}
|
|
277
|
+
: undefined,
|
|
278
|
+
sources: customer.sources || undefined,
|
|
279
|
+
subscriptions: customer.subscriptions || undefined,
|
|
280
|
+
taxExempt: customer.tax_exempt || undefined,
|
|
281
|
+
taxIds: customer.tax_ids || undefined,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
console.error("Error creating/updating customer:", error);
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
//# sourceMappingURL=customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAuN1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAC9B,kBAAkB,EAClB,KAAK,WAEH,GAAW,EACX,KAAoB;IAEpB,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5D,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;gBACpB,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC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,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { Resource } from "../resource.ts";
|
|
3
|
+
import type { Secret } from "../secret.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for creating a Stripe entitlements feature
|
|
6
|
+
*/
|
|
7
|
+
export interface EntitlementsFeatureProps {
|
|
8
|
+
/**
|
|
9
|
+
* The feature's name, for your own purpose, not meant to be displayable to the customer
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* A unique key you provide as your own system identifier. This may be up to 80 characters
|
|
14
|
+
*/
|
|
15
|
+
lookupKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Set of key-value pairs that you can attach to an object
|
|
18
|
+
*/
|
|
19
|
+
metadata?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* API key to use (overrides environment variable)
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: Secret;
|
|
24
|
+
/**
|
|
25
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
26
|
+
*/
|
|
27
|
+
adopt?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Output from the Stripe entitlements feature
|
|
31
|
+
*/
|
|
32
|
+
export interface EntitlementsFeature extends Resource<"stripe::EntitlementsFeature">, EntitlementsFeatureProps {
|
|
33
|
+
/**
|
|
34
|
+
* The ID of the feature
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* String representing the object's type
|
|
39
|
+
*/
|
|
40
|
+
object: "entitlements.feature";
|
|
41
|
+
/**
|
|
42
|
+
* Has the value true if the object exists in live mode or the value false if the object exists in test mode
|
|
43
|
+
*/
|
|
44
|
+
livemode: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create and manage Stripe entitlements features
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Create a basic feature for API access
|
|
51
|
+
* const apiFeature = await EntitlementsFeature("api-access", {
|
|
52
|
+
* name: "API Access",
|
|
53
|
+
* lookupKey: "api_access_v1",
|
|
54
|
+
* metadata: {
|
|
55
|
+
* tier: "premium",
|
|
56
|
+
* category: "api"
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Create a feature for advanced analytics
|
|
62
|
+
* const analyticsFeature = await EntitlementsFeature("advanced-analytics", {
|
|
63
|
+
* name: "Advanced Analytics",
|
|
64
|
+
* lookupKey: "analytics_advanced",
|
|
65
|
+
* metadata: {
|
|
66
|
+
* tier: "enterprise",
|
|
67
|
+
* category: "analytics"
|
|
68
|
+
* }
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Create a feature for custom integrations
|
|
73
|
+
* const integrationsFeature = await EntitlementsFeature("custom-integrations", {
|
|
74
|
+
* name: "Custom Integrations",
|
|
75
|
+
* lookupKey: "integrations_custom",
|
|
76
|
+
* metadata: {
|
|
77
|
+
* tier: "enterprise",
|
|
78
|
+
* category: "integrations",
|
|
79
|
+
* limit: "unlimited"
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
*/
|
|
83
|
+
export declare const EntitlementsFeature: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<EntitlementsFeature>, _id: string, props: EntitlementsFeatureProps) => Promise<EntitlementsFeature>);
|
|
84
|
+
//# sourceMappingURL=entitlements-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements-feature.d.ts","sourceRoot":"","sources":["../../src/stripe/entitlements-feature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBACf,SAAQ,QAAQ,CAAC,6BAA6B,CAAC,EAC7C,wBAAwB;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,sBAAsB,CAAC;IAE/B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,mBAAmB,yFAGtB,OAAO,CAAC,mBAAmB,CAAC,OAC7B,MAAM,SACJ,wBAAwB,KAC9B,OAAO,CAAC,mBAAmB,CAAC,CAmEhC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, isStripeConflictError } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create and manage Stripe entitlements features
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a basic feature for API access
|
|
8
|
+
* const apiFeature = await EntitlementsFeature("api-access", {
|
|
9
|
+
* name: "API Access",
|
|
10
|
+
* lookupKey: "api_access_v1",
|
|
11
|
+
* metadata: {
|
|
12
|
+
* tier: "premium",
|
|
13
|
+
* category: "api"
|
|
14
|
+
* }
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Create a feature for advanced analytics
|
|
19
|
+
* const analyticsFeature = await EntitlementsFeature("advanced-analytics", {
|
|
20
|
+
* name: "Advanced Analytics",
|
|
21
|
+
* lookupKey: "analytics_advanced",
|
|
22
|
+
* metadata: {
|
|
23
|
+
* tier: "enterprise",
|
|
24
|
+
* category: "analytics"
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Create a feature for custom integrations
|
|
30
|
+
* const integrationsFeature = await EntitlementsFeature("custom-integrations", {
|
|
31
|
+
* name: "Custom Integrations",
|
|
32
|
+
* lookupKey: "integrations_custom",
|
|
33
|
+
* metadata: {
|
|
34
|
+
* tier: "enterprise",
|
|
35
|
+
* category: "integrations",
|
|
36
|
+
* limit: "unlimited"
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
*/
|
|
40
|
+
export const EntitlementsFeature = Resource("stripe::EntitlementsFeature", async function (_id, props) {
|
|
41
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
42
|
+
if (this.phase === "delete") {
|
|
43
|
+
return this.destroy();
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
let feature;
|
|
47
|
+
if (this.phase === "update" && this.output?.id) {
|
|
48
|
+
const updateParams = {
|
|
49
|
+
name: props.name,
|
|
50
|
+
metadata: props.metadata,
|
|
51
|
+
};
|
|
52
|
+
feature = await stripe.entitlements.features.update(this.output.id, updateParams);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const createParams = {
|
|
56
|
+
name: props.name,
|
|
57
|
+
metadata: props.metadata,
|
|
58
|
+
};
|
|
59
|
+
if (props.lookupKey) {
|
|
60
|
+
createParams.lookup_key = props.lookupKey;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
feature = await stripe.entitlements.features.create(createParams);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
67
|
+
const existingFeatures = await stripe.entitlements.features.list({
|
|
68
|
+
lookup_key: props.lookupKey,
|
|
69
|
+
limit: 1,
|
|
70
|
+
});
|
|
71
|
+
if (existingFeatures.data.length > 0) {
|
|
72
|
+
const existingFeature = existingFeatures.data[0];
|
|
73
|
+
const updateParams = {
|
|
74
|
+
name: props.name,
|
|
75
|
+
metadata: props.metadata,
|
|
76
|
+
};
|
|
77
|
+
feature = await stripe.entitlements.features.update(existingFeature.id, updateParams);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return this({
|
|
89
|
+
id: feature.id,
|
|
90
|
+
object: feature.object,
|
|
91
|
+
name: feature.name,
|
|
92
|
+
lookupKey: feature.lookup_key || undefined,
|
|
93
|
+
metadata: feature.metadata || undefined,
|
|
94
|
+
livemode: feature.livemode,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error("Error creating/updating entitlements feature:", error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=entitlements-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements-feature.js","sourceRoot":"","sources":["../../src/stripe/entitlements-feature.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAsDxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CACzC,6BAA6B,EAC7B,KAAK,WAEH,GAAW,EACX,KAA+B;IAE/B,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,MAAM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C;wBACrC,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBACjD,MAAM,YAAY,GAA4C;4BAC5D,IAAI,EAAE,KAAK,CAAC,IAAI;4BAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;yBACzB,CAAC;wBACF,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CACjD,eAAe,CAAC,EAAE,EAClB,YAAY,CACb,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,MAAM,KAAK,CAAC;oBACd,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;YACV,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS;YAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACvC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;QACtE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Context } from "../context.ts";
|
|
3
|
+
import { Resource } from "../resource.ts";
|
|
4
|
+
import type { Secret } from "../secret.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Properties for creating a Stripe file
|
|
7
|
+
*/
|
|
8
|
+
export interface FileProps {
|
|
9
|
+
/**
|
|
10
|
+
* A file to upload. The file should follow the specifications of RFC 2388
|
|
11
|
+
*/
|
|
12
|
+
file: any;
|
|
13
|
+
/**
|
|
14
|
+
* The purpose of the uploaded file
|
|
15
|
+
*/
|
|
16
|
+
purpose: Stripe.FileCreateParams.Purpose;
|
|
17
|
+
/**
|
|
18
|
+
* Optional parameters for the file link data
|
|
19
|
+
*/
|
|
20
|
+
fileLink?: {
|
|
21
|
+
/**
|
|
22
|
+
* Whether to create a file link for the uploaded file
|
|
23
|
+
*/
|
|
24
|
+
create: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The time at which the file link expires
|
|
27
|
+
*/
|
|
28
|
+
expiresAt?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Set of key-value pairs that you can attach to the file link
|
|
31
|
+
*/
|
|
32
|
+
metadata?: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* API key to use (overrides environment variable)
|
|
36
|
+
*/
|
|
37
|
+
apiKey?: Secret;
|
|
38
|
+
/**
|
|
39
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
40
|
+
*/
|
|
41
|
+
adopt?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Output from the Stripe file
|
|
45
|
+
*/
|
|
46
|
+
export interface File extends Resource<"stripe::File"> {
|
|
47
|
+
/**
|
|
48
|
+
* The ID of the file
|
|
49
|
+
*/
|
|
50
|
+
id: string;
|
|
51
|
+
/**
|
|
52
|
+
* String representing the object's type
|
|
53
|
+
*/
|
|
54
|
+
object: "file";
|
|
55
|
+
/**
|
|
56
|
+
* Time at which the object was created
|
|
57
|
+
*/
|
|
58
|
+
created: number;
|
|
59
|
+
/**
|
|
60
|
+
* The time at which the file expires and is no longer available
|
|
61
|
+
*/
|
|
62
|
+
expiresAt?: number;
|
|
63
|
+
/**
|
|
64
|
+
* A filename for the file, suitable for saving to a filesystem
|
|
65
|
+
*/
|
|
66
|
+
filename?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Any links that have been created for the file
|
|
69
|
+
*/
|
|
70
|
+
links?: {
|
|
71
|
+
object: "list";
|
|
72
|
+
data: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
object: "file_link";
|
|
75
|
+
created: number;
|
|
76
|
+
expired: boolean;
|
|
77
|
+
expiresAt?: number;
|
|
78
|
+
file: string;
|
|
79
|
+
livemode: boolean;
|
|
80
|
+
metadata: Record<string, string>;
|
|
81
|
+
url?: string;
|
|
82
|
+
}>;
|
|
83
|
+
hasMore: boolean;
|
|
84
|
+
url: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The purpose of the uploaded file
|
|
88
|
+
*/
|
|
89
|
+
purpose: Stripe.File.Purpose;
|
|
90
|
+
/**
|
|
91
|
+
* The size in bytes of the file object
|
|
92
|
+
*/
|
|
93
|
+
size: number;
|
|
94
|
+
/**
|
|
95
|
+
* A user friendly title for the document
|
|
96
|
+
*/
|
|
97
|
+
title?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The type of the file returned
|
|
100
|
+
*/
|
|
101
|
+
type?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The URL from which the file can be downloaded
|
|
104
|
+
*/
|
|
105
|
+
url?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Has the value true if the object exists in live mode or the value false if the object exists in test mode
|
|
108
|
+
*/
|
|
109
|
+
livemode: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create and manage Stripe files for uploads
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Upload a dispute evidence file
|
|
116
|
+
* const disputeEvidence = await File("dispute-evidence", {
|
|
117
|
+
* file: fs.readFileSync("./evidence.pdf"),
|
|
118
|
+
* purpose: "dispute_evidence"
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Upload an identity document
|
|
123
|
+
* const identityDocument = await File("identity-doc", {
|
|
124
|
+
* file: fs.readFileSync("./passport.jpg"),
|
|
125
|
+
* purpose: "identity_document"
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // Upload a business logo with file link
|
|
130
|
+
* const businessLogo = await File("business-logo", {
|
|
131
|
+
* file: fs.readFileSync("./logo.png"),
|
|
132
|
+
* purpose: "business_logo",
|
|
133
|
+
* fileLink: {
|
|
134
|
+
* create: true,
|
|
135
|
+
* expiresAt: Math.floor(Date.now() / 1000) + 86400,
|
|
136
|
+
* metadata: {
|
|
137
|
+
* brand: "company_logo"
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* });
|
|
141
|
+
*/
|
|
142
|
+
export declare const File: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<File>, _id: string, props: FileProps) => Promise<File>);
|
|
143
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/stripe/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC;IACV;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,MAAM,EAAE,OAAO,CAAC;QAChB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACnC,CAAC;IAEF;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MA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