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,198 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, handleStripeDeleteError, isStripeConflictError, } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create and manage Stripe shipping rates
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a standard shipping rate
|
|
8
|
+
* const standardShipping = await ShippingRate("standard-shipping", {
|
|
9
|
+
* displayName: "Standard Shipping",
|
|
10
|
+
* type: "fixed_amount",
|
|
11
|
+
* fixedAmount: {
|
|
12
|
+
* amount: 500,
|
|
13
|
+
* currency: "usd"
|
|
14
|
+
* },
|
|
15
|
+
* deliveryEstimate: {
|
|
16
|
+
* minimum: { unit: "business_day", value: 5 },
|
|
17
|
+
* maximum: { unit: "business_day", value: 7 }
|
|
18
|
+
* },
|
|
19
|
+
* taxBehavior: "exclusive"
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Create an express shipping rate
|
|
24
|
+
* const expressShipping = await ShippingRate("express-shipping", {
|
|
25
|
+
* displayName: "Express Shipping",
|
|
26
|
+
* type: "fixed_amount",
|
|
27
|
+
* fixedAmount: {
|
|
28
|
+
* amount: 1500,
|
|
29
|
+
* currency: "usd"
|
|
30
|
+
* },
|
|
31
|
+
* deliveryEstimate: {
|
|
32
|
+
* minimum: { unit: "business_day", value: 1 },
|
|
33
|
+
* maximum: { unit: "business_day", value: 2 }
|
|
34
|
+
* },
|
|
35
|
+
* taxBehavior: "exclusive",
|
|
36
|
+
* metadata: {
|
|
37
|
+
* priority: "high",
|
|
38
|
+
* service_level: "express"
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Create a free shipping rate
|
|
44
|
+
* const freeShipping = await ShippingRate("free-shipping", {
|
|
45
|
+
* displayName: "Free Shipping",
|
|
46
|
+
* type: "fixed_amount",
|
|
47
|
+
* fixedAmount: {
|
|
48
|
+
* amount: 0,
|
|
49
|
+
* currency: "usd"
|
|
50
|
+
* },
|
|
51
|
+
* deliveryEstimate: {
|
|
52
|
+
* minimum: { unit: "business_day", value: 7 },
|
|
53
|
+
* maximum: { unit: "business_day", value: 10 }
|
|
54
|
+
* },
|
|
55
|
+
* taxBehavior: "unspecified",
|
|
56
|
+
* metadata: {
|
|
57
|
+
* promotion: "free_shipping_over_50",
|
|
58
|
+
* cost_center: "marketing"
|
|
59
|
+
* }
|
|
60
|
+
* });
|
|
61
|
+
*/
|
|
62
|
+
export const ShippingRate = Resource("stripe::ShippingRate", async function (_id, props) {
|
|
63
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
64
|
+
if (this.phase === "delete") {
|
|
65
|
+
try {
|
|
66
|
+
if (this.output?.id) {
|
|
67
|
+
await stripe.shippingRates.update(this.output.id, { active: false });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
handleStripeDeleteError(error, "ShippingRate", this.output?.id);
|
|
72
|
+
}
|
|
73
|
+
return this.destroy();
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
let shippingRate;
|
|
77
|
+
if (this.phase === "update" && this.output?.id) {
|
|
78
|
+
const updateParams = {
|
|
79
|
+
metadata: props.metadata,
|
|
80
|
+
tax_behavior: props.taxBehavior,
|
|
81
|
+
};
|
|
82
|
+
if (props.active !== undefined)
|
|
83
|
+
updateParams.active = props.active;
|
|
84
|
+
shippingRate = await stripe.shippingRates.update(this.output.id, updateParams);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const createParams = {
|
|
88
|
+
display_name: props.displayName,
|
|
89
|
+
metadata: props.metadata,
|
|
90
|
+
tax_behavior: props.taxBehavior,
|
|
91
|
+
tax_code: props.taxCode,
|
|
92
|
+
type: props.type,
|
|
93
|
+
};
|
|
94
|
+
if (props.fixedAmount) {
|
|
95
|
+
createParams.fixed_amount = {
|
|
96
|
+
amount: props.fixedAmount.amount,
|
|
97
|
+
currency: props.fixedAmount.currency,
|
|
98
|
+
currency_options: props.fixedAmount.currencyOptions
|
|
99
|
+
? Object.fromEntries(Object.entries(props.fixedAmount.currencyOptions).map(([key, value]) => [
|
|
100
|
+
key,
|
|
101
|
+
{
|
|
102
|
+
amount: value.amount,
|
|
103
|
+
tax_behavior: value.taxBehavior,
|
|
104
|
+
},
|
|
105
|
+
]))
|
|
106
|
+
: undefined,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (props.deliveryEstimate) {
|
|
110
|
+
createParams.delivery_estimate = {
|
|
111
|
+
minimum: props.deliveryEstimate.minimum
|
|
112
|
+
? {
|
|
113
|
+
unit: props.deliveryEstimate.minimum.unit,
|
|
114
|
+
value: props.deliveryEstimate.minimum.value,
|
|
115
|
+
}
|
|
116
|
+
: undefined,
|
|
117
|
+
maximum: props.deliveryEstimate.maximum
|
|
118
|
+
? {
|
|
119
|
+
unit: props.deliveryEstimate.maximum.unit,
|
|
120
|
+
value: props.deliveryEstimate.maximum.value,
|
|
121
|
+
}
|
|
122
|
+
: undefined,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
try {
|
|
127
|
+
shippingRate = await stripe.shippingRates.create(createParams);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
131
|
+
throw new Error("ShippingRate adoption is not supported - shipping rates cannot be uniquely identified for adoption");
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
140
|
+
throw new Error("ShippingRate adoption is not supported - shipping rates cannot be uniquely identified for adoption");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return this({
|
|
148
|
+
id: shippingRate.id,
|
|
149
|
+
object: shippingRate.object,
|
|
150
|
+
displayName: shippingRate.display_name || "",
|
|
151
|
+
fixedAmount: shippingRate.fixed_amount
|
|
152
|
+
? {
|
|
153
|
+
amount: shippingRate.fixed_amount.amount,
|
|
154
|
+
currency: shippingRate.fixed_amount.currency,
|
|
155
|
+
currencyOptions: shippingRate.fixed_amount.currency_options
|
|
156
|
+
? Object.fromEntries(Object.entries(shippingRate.fixed_amount.currency_options).map(([key, value]) => [
|
|
157
|
+
key,
|
|
158
|
+
{
|
|
159
|
+
amount: value.amount,
|
|
160
|
+
taxBehavior: value.tax_behavior,
|
|
161
|
+
},
|
|
162
|
+
]))
|
|
163
|
+
: undefined,
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
166
|
+
deliveryEstimate: shippingRate.delivery_estimate
|
|
167
|
+
? {
|
|
168
|
+
minimum: shippingRate.delivery_estimate.minimum
|
|
169
|
+
? {
|
|
170
|
+
unit: shippingRate.delivery_estimate.minimum.unit,
|
|
171
|
+
value: shippingRate.delivery_estimate.minimum.value,
|
|
172
|
+
}
|
|
173
|
+
: undefined,
|
|
174
|
+
maximum: shippingRate.delivery_estimate.maximum
|
|
175
|
+
? {
|
|
176
|
+
unit: shippingRate.delivery_estimate.maximum.unit,
|
|
177
|
+
value: shippingRate.delivery_estimate.maximum.value,
|
|
178
|
+
}
|
|
179
|
+
: undefined,
|
|
180
|
+
}
|
|
181
|
+
: undefined,
|
|
182
|
+
metadata: shippingRate.metadata || undefined,
|
|
183
|
+
active: shippingRate.active,
|
|
184
|
+
taxBehavior: shippingRate.tax_behavior || undefined,
|
|
185
|
+
taxCode: typeof shippingRate.tax_code === "string"
|
|
186
|
+
? shippingRate.tax_code
|
|
187
|
+
: undefined,
|
|
188
|
+
type: shippingRate.type || undefined,
|
|
189
|
+
created: shippingRate.created,
|
|
190
|
+
livemode: shippingRate.livemode,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.error("Error creating/updating shipping rate:", error);
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
//# sourceMappingURL=shipping-rate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shipping-rate.js","sourceRoot":"","sources":["../../src/stripe/shipping-rate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAwIrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAClC,sBAAsB,EACtB,KAAK,WAEH,GAAW,EACX,KAAwB;IAExB,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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iBAAiB,CAAC,OAAO,CAAC,IAAI;4BACjD,KAAK,EAAE,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK;yBACpD;wBACH,CAAC,CAAC,SAAS;oBACb,OAAO,EAAE,YAAY,CAAC,iBAAiB,CAAC,OAAO;wBAC7C,CAAC,CAAC;4BACE,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI;4BACjD,KAAK,EAAE,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK;yBACpD;wBACH,CAAC,CAAC,SAAS;iBACd;gBACH,CAAC,CAAC,SAAS;YACb,QAAQ,EAAE,YAAY,CAAC,QAAQ,IAAI,SAAS;YAC5C,MAAM,EAAE,YAAY,CAAC,MAAM;YAC3B,WAAW,EAAE,YAAY,CAAC,YAAY,IAAI,SAAS;YACnD,OAAO,EACL,OAAO,YAAY,CAAC,QAAQ,KAAK,QAAQ;gBACvC,CAAC,CAAC,YAAY,CAAC,QAAQ;gBACvB,CAAC,CAAC,SAAS;YACf,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,SAAS;YACpC,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,QAAQ,EAAE,YAAY,CAAC,QAAQ;SAChC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QAC/D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
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 tax rate
|
|
7
|
+
*/
|
|
8
|
+
export interface TaxRateProps {
|
|
9
|
+
/**
|
|
10
|
+
* The display name of the tax rate, which will be shown to users
|
|
11
|
+
*/
|
|
12
|
+
displayName: string;
|
|
13
|
+
/**
|
|
14
|
+
* This represents the tax rate percent out of 100
|
|
15
|
+
*/
|
|
16
|
+
percentage: number;
|
|
17
|
+
/**
|
|
18
|
+
* This specifies if the tax rate is inclusive or exclusive
|
|
19
|
+
*/
|
|
20
|
+
inclusive: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Flag determining whether the tax rate is active or inactive
|
|
23
|
+
*/
|
|
24
|
+
active?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Two-letter country code (ISO 3166-1 alpha-2)
|
|
27
|
+
*/
|
|
28
|
+
country?: string;
|
|
29
|
+
/**
|
|
30
|
+
* An arbitrary string attached to the tax rate for your internal use only
|
|
31
|
+
*/
|
|
32
|
+
description?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The jurisdiction for the tax rate
|
|
35
|
+
*/
|
|
36
|
+
jurisdiction?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Set of key-value pairs that you can attach to an object
|
|
39
|
+
*/
|
|
40
|
+
metadata?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* ISO 3166-2 subdivision code, without country prefix
|
|
43
|
+
*/
|
|
44
|
+
state?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The high-level tax type, such as vat or sales_tax
|
|
47
|
+
*/
|
|
48
|
+
taxType?: Stripe.TaxRateCreateParams.TaxType;
|
|
49
|
+
/**
|
|
50
|
+
* API key to use (overrides environment variable)
|
|
51
|
+
*/
|
|
52
|
+
apiKey?: Secret;
|
|
53
|
+
/**
|
|
54
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
55
|
+
*/
|
|
56
|
+
adopt?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Output from the Stripe tax rate
|
|
60
|
+
*/
|
|
61
|
+
export interface TaxRate extends Resource<"stripe::TaxRate">, TaxRateProps {
|
|
62
|
+
/**
|
|
63
|
+
* The ID of the tax rate
|
|
64
|
+
*/
|
|
65
|
+
id: string;
|
|
66
|
+
/**
|
|
67
|
+
* String representing the object's type
|
|
68
|
+
*/
|
|
69
|
+
object: "tax_rate";
|
|
70
|
+
/**
|
|
71
|
+
* Time at which the object was created
|
|
72
|
+
*/
|
|
73
|
+
created: number;
|
|
74
|
+
/**
|
|
75
|
+
* Has the value true if the object exists in live mode or the value false if the object exists in test mode
|
|
76
|
+
*/
|
|
77
|
+
livemode: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create and manage Stripe tax rates
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Create a basic sales tax rate
|
|
84
|
+
* const salesTax = await TaxRate("ca-sales-tax", {
|
|
85
|
+
* displayName: "CA Sales Tax",
|
|
86
|
+
* percentage: 8.5,
|
|
87
|
+
* inclusive: false,
|
|
88
|
+
* active: true,
|
|
89
|
+
* country: "US",
|
|
90
|
+
* state: "CA",
|
|
91
|
+
* description: "California sales tax",
|
|
92
|
+
* taxType: "sales_tax"
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // Create a VAT tax rate
|
|
97
|
+
* const vatTax = await TaxRate("uk-vat", {
|
|
98
|
+
* displayName: "UK VAT",
|
|
99
|
+
* percentage: 20.0,
|
|
100
|
+
* inclusive: true,
|
|
101
|
+
* active: true,
|
|
102
|
+
* country: "GB",
|
|
103
|
+
* description: "United Kingdom Value Added Tax",
|
|
104
|
+
* taxType: "vat",
|
|
105
|
+
* metadata: {
|
|
106
|
+
* region: "europe",
|
|
107
|
+
* tax_authority: "hmrc"
|
|
108
|
+
* }
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Create a city tax rate
|
|
113
|
+
* const cityTax = await TaxRate("nyc-tax", {
|
|
114
|
+
* displayName: "NYC Local Tax",
|
|
115
|
+
* percentage: 4.5,
|
|
116
|
+
* inclusive: false,
|
|
117
|
+
* active: true,
|
|
118
|
+
* country: "US",
|
|
119
|
+
* state: "NY",
|
|
120
|
+
* jurisdiction: "New York City",
|
|
121
|
+
* description: "New York City local sales tax",
|
|
122
|
+
* taxType: "sales_tax",
|
|
123
|
+
* metadata: {
|
|
124
|
+
* locality: "nyc",
|
|
125
|
+
* tax_level: "city"
|
|
126
|
+
* }
|
|
127
|
+
* });
|
|
128
|
+
*/
|
|
129
|
+
export declare const TaxRate: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<TaxRate>, _id: string, props: TaxRateProps) => Promise<TaxRate>);
|
|
130
|
+
//# sourceMappingURL=tax-rate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax-rate.d.ts","sourceRoot":"","sources":["../../src/stripe/tax-rate.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;AAO3C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,OAAQ,SAAQ,QAAQ,CAAC,iBAAiB,CAAC,EAAE,YAAY;IACxE;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,OAAO,yFAGV,OAAO,CAAC,OAAO,CAAC,OACjB,MAAM,SACJ,YAAY,KAClB,OAAO,CAAC,OAAO,CAAC,CA0EpB,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, handleStripeDeleteError, isStripeConflictError, } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create and manage Stripe tax rates
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a basic sales tax rate
|
|
8
|
+
* const salesTax = await TaxRate("ca-sales-tax", {
|
|
9
|
+
* displayName: "CA Sales Tax",
|
|
10
|
+
* percentage: 8.5,
|
|
11
|
+
* inclusive: false,
|
|
12
|
+
* active: true,
|
|
13
|
+
* country: "US",
|
|
14
|
+
* state: "CA",
|
|
15
|
+
* description: "California sales tax",
|
|
16
|
+
* taxType: "sales_tax"
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a VAT tax rate
|
|
21
|
+
* const vatTax = await TaxRate("uk-vat", {
|
|
22
|
+
* displayName: "UK VAT",
|
|
23
|
+
* percentage: 20.0,
|
|
24
|
+
* inclusive: true,
|
|
25
|
+
* active: true,
|
|
26
|
+
* country: "GB",
|
|
27
|
+
* description: "United Kingdom Value Added Tax",
|
|
28
|
+
* taxType: "vat",
|
|
29
|
+
* metadata: {
|
|
30
|
+
* region: "europe",
|
|
31
|
+
* tax_authority: "hmrc"
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Create a city tax rate
|
|
37
|
+
* const cityTax = await TaxRate("nyc-tax", {
|
|
38
|
+
* displayName: "NYC Local Tax",
|
|
39
|
+
* percentage: 4.5,
|
|
40
|
+
* inclusive: false,
|
|
41
|
+
* active: true,
|
|
42
|
+
* country: "US",
|
|
43
|
+
* state: "NY",
|
|
44
|
+
* jurisdiction: "New York City",
|
|
45
|
+
* description: "New York City local sales tax",
|
|
46
|
+
* taxType: "sales_tax",
|
|
47
|
+
* metadata: {
|
|
48
|
+
* locality: "nyc",
|
|
49
|
+
* tax_level: "city"
|
|
50
|
+
* }
|
|
51
|
+
* });
|
|
52
|
+
*/
|
|
53
|
+
export const TaxRate = Resource("stripe::TaxRate", async function (_id, props) {
|
|
54
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
55
|
+
if (this.phase === "delete") {
|
|
56
|
+
try {
|
|
57
|
+
if (this.output?.id) {
|
|
58
|
+
await stripe.taxRates.update(this.output.id, { active: false });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
handleStripeDeleteError(error, "TaxRate", this.output?.id);
|
|
63
|
+
}
|
|
64
|
+
return this.destroy();
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
let taxRate;
|
|
68
|
+
if (this.phase === "update" && this.output?.id) {
|
|
69
|
+
taxRate = await stripe.taxRates.update(this.output.id, {
|
|
70
|
+
active: props.active,
|
|
71
|
+
country: props.country,
|
|
72
|
+
description: props.description,
|
|
73
|
+
display_name: props.displayName,
|
|
74
|
+
jurisdiction: props.jurisdiction,
|
|
75
|
+
metadata: props.metadata,
|
|
76
|
+
state: props.state,
|
|
77
|
+
tax_type: props.taxType,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
try {
|
|
82
|
+
taxRate = await stripe.taxRates.create({
|
|
83
|
+
display_name: props.displayName,
|
|
84
|
+
percentage: props.percentage,
|
|
85
|
+
inclusive: props.inclusive,
|
|
86
|
+
active: props.active,
|
|
87
|
+
country: props.country,
|
|
88
|
+
description: props.description,
|
|
89
|
+
jurisdiction: props.jurisdiction,
|
|
90
|
+
metadata: props.metadata,
|
|
91
|
+
state: props.state,
|
|
92
|
+
tax_type: props.taxType,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
97
|
+
throw new Error("TaxRate adoption is not supported - tax rates cannot be uniquely identified for adoption");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return this({
|
|
105
|
+
id: taxRate.id,
|
|
106
|
+
object: taxRate.object,
|
|
107
|
+
displayName: taxRate.display_name,
|
|
108
|
+
percentage: taxRate.percentage,
|
|
109
|
+
inclusive: taxRate.inclusive,
|
|
110
|
+
active: taxRate.active,
|
|
111
|
+
country: taxRate.country || undefined,
|
|
112
|
+
description: taxRate.description || undefined,
|
|
113
|
+
jurisdiction: taxRate.jurisdiction || undefined,
|
|
114
|
+
metadata: taxRate.metadata || undefined,
|
|
115
|
+
state: taxRate.state || undefined,
|
|
116
|
+
taxType: taxRate.tax_type || undefined,
|
|
117
|
+
created: taxRate.created,
|
|
118
|
+
livemode: taxRate.livemode,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
console.error("Error creating/updating tax rate:", error);
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=tax-rate.js.map
|
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SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;YACrC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,SAAS;YAC7C,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,SAAS;YAC/C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACvC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS;YACjC,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;YACtC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
|
package/lib/stripe/webhook.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Stripe from "stripe";
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
2
|
import type { Context } from "../context.ts";
|
|
3
3
|
import { Resource } from "../resource.ts";
|
|
4
|
+
import type { Secret } from "../secret.ts";
|
|
4
5
|
export type EnabledEvent = Stripe.WebhookEndpointUpdateParams.EnabledEvent;
|
|
5
6
|
/**
|
|
6
7
|
* Properties for creating a Stripe webhook endpoint
|
|
@@ -34,6 +35,14 @@ export interface WebhookEndpointProps {
|
|
|
34
35
|
* Webhook endpoint metadata
|
|
35
36
|
*/
|
|
36
37
|
metadata?: Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* API key to use (overrides environment variable)
|
|
40
|
+
*/
|
|
41
|
+
apiKey?: Secret;
|
|
42
|
+
/**
|
|
43
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
44
|
+
*/
|
|
45
|
+
adopt?: boolean;
|
|
37
46
|
}
|
|
38
47
|
/**
|
|
39
48
|
* Output from the Stripe webhook endpoint
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/stripe/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/stripe/webhook.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;AAO3C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,2BAA2B,CAAC,YAAY,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,aAAa,EAAE,YAAY,EAAE,CAAC;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;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,eACf,SAAQ,QAAQ,CAAC,yBAAyB,CAAC,EACzC,oBAAoB;IACtB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,eAAe,yFAGlB,OAAO,CAAC,eAAe,CAAC,OACzB,MAAM,SACJ,oBAAoB,8BAsI9B,CAAC"}
|
package/lib/stripe/webhook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Stripe from "stripe";
|
|
2
1
|
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, handleStripeDeleteError, isStripeConflictError, } from "./client.js";
|
|
3
3
|
/**
|
|
4
4
|
* Create and manage Stripe webhook endpoints
|
|
5
5
|
*
|
|
@@ -46,13 +46,7 @@ import { Resource } from "../resource.js";
|
|
|
46
46
|
* });
|
|
47
47
|
*/
|
|
48
48
|
export const WebhookEndpoint = Resource("stripe::WebhookEndpoint", async function (_id, props) {
|
|
49
|
-
|
|
50
|
-
const apiKey = process.env.STRIPE_API_KEY;
|
|
51
|
-
if (!apiKey) {
|
|
52
|
-
throw new Error("STRIPE_API_KEY environment variable is required");
|
|
53
|
-
}
|
|
54
|
-
// Initialize Stripe client
|
|
55
|
-
const stripe = new Stripe(apiKey);
|
|
49
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
56
50
|
if (this.phase === "delete") {
|
|
57
51
|
try {
|
|
58
52
|
// Get the webhook ID from the stored output
|
|
@@ -61,8 +55,7 @@ export const WebhookEndpoint = Resource("stripe::WebhookEndpoint", async functio
|
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
57
|
catch (error) {
|
|
64
|
-
|
|
65
|
-
console.error("Error deleting webhook:", error);
|
|
58
|
+
handleStripeDeleteError(error, "WebhookEndpoint", this.output?.id);
|
|
66
59
|
}
|
|
67
60
|
return this.destroy();
|
|
68
61
|
}
|
|
@@ -70,22 +63,74 @@ export const WebhookEndpoint = Resource("stripe::WebhookEndpoint", async functio
|
|
|
70
63
|
let webhook;
|
|
71
64
|
if (this.phase === "update" && this.output?.id) {
|
|
72
65
|
// Update existing webhook
|
|
73
|
-
|
|
66
|
+
const updateParams = {
|
|
74
67
|
url: props.url,
|
|
75
68
|
enabled_events: props.enabledEvents,
|
|
76
69
|
description: props.description,
|
|
77
70
|
disabled: props.active === false,
|
|
78
71
|
metadata: props.metadata,
|
|
79
|
-
}
|
|
72
|
+
};
|
|
73
|
+
webhook = await stripe.webhookEndpoints.update(this.output.id, updateParams);
|
|
80
74
|
}
|
|
81
75
|
else {
|
|
82
76
|
// Create new webhook
|
|
83
|
-
|
|
77
|
+
const createParams = {
|
|
84
78
|
url: props.url,
|
|
85
79
|
enabled_events: props.enabledEvents,
|
|
86
80
|
description: props.description,
|
|
87
81
|
metadata: props.metadata,
|
|
88
|
-
}
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
try {
|
|
85
|
+
webhook = await stripe.webhookEndpoints.create(createParams);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
89
|
+
const existingWebhooks = await stripe.webhookEndpoints.list({
|
|
90
|
+
limit: 100,
|
|
91
|
+
});
|
|
92
|
+
const existingWebhook = existingWebhooks.data.find((w) => w.url === props.url);
|
|
93
|
+
if (existingWebhook) {
|
|
94
|
+
const updateParams = {
|
|
95
|
+
url: props.url,
|
|
96
|
+
enabled_events: props.enabledEvents,
|
|
97
|
+
description: props.description,
|
|
98
|
+
metadata: props.metadata,
|
|
99
|
+
};
|
|
100
|
+
webhook = await stripe.webhookEndpoints.update(existingWebhook.id, updateParams);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (isStripeConflictError(error) && props.adopt) {
|
|
113
|
+
const existingWebhooks = await stripe.webhookEndpoints.list({
|
|
114
|
+
limit: 100,
|
|
115
|
+
});
|
|
116
|
+
const existingWebhook = existingWebhooks.data.find((w) => w.url === props.url);
|
|
117
|
+
if (existingWebhook) {
|
|
118
|
+
const updateParams = {
|
|
119
|
+
url: props.url,
|
|
120
|
+
enabled_events: props.enabledEvents,
|
|
121
|
+
description: props.description,
|
|
122
|
+
metadata: props.metadata,
|
|
123
|
+
};
|
|
124
|
+
webhook = await stripe.webhookEndpoints.update(existingWebhook.id, updateParams);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
89
134
|
// For connect parameter, need to handle it separately if it exists
|
|
90
135
|
if (props.connect !== undefined) {
|
|
91
136
|
// Note: connect is specified at creation time and cannot be updated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/stripe/webhook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/stripe/webhook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAgGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CACrC,yBAAyB,EACzB,KAAK,WAEH,GAAW,EACX,KAA2B;IAE3B,MAAM,MAAM,GAAG,kBAAkB,CAAC,E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H,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,KAAK,IAAI,GAAG;IACV;;;;;OAKG;IACH,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3E;;;;;;OAMG;IACH,CACE,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,EAClC,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAAC;IAER;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjC,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAErD,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEpD;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,IAAI,CAiFzE"}
|
package/lib/test/bun.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { afterAll, beforeAll, it } from "bun:test";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { alchemy } from "../alchemy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { DOStateStore } from "../cloudflare/index.js";
|
|
6
6
|
import { Scope } from "../scope.js";
|
|
7
7
|
/**
|
|
8
8
|
* Add test functionality to alchemy instance
|
|
@@ -38,11 +38,7 @@ export function test(meta, defaultOptions) {
|
|
|
38
38
|
if (defaultOptions.stateStore === undefined &&
|
|
39
39
|
// process.env.CI &&
|
|
40
40
|
process.env.ALCHEMY_STATE_STORE === "cloudflare") {
|
|
41
|
-
defaultOptions.stateStore = (scope) => new
|
|
42
|
-
apiKey: alchemy.secret(process.env.CLOUDFLARE_API_KEY),
|
|
43
|
-
email: process.env.CLOUDFLARE_EMAIL,
|
|
44
|
-
bucketName: process.env.CLOUDFLARE_BUCKET_NAME,
|
|
45
|
-
});
|
|
41
|
+
defaultOptions.stateStore = (scope) => new DOStateStore(scope);
|
|
46
42
|
}
|
|
47
43
|
// Add skipIf functionality
|
|
48
44
|
test.skipIf = it.skipIf.bind(it);
|