alchemy 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/lib/aws/function.d.ts.map +1 -1
  2. package/lib/aws/function.js +1 -4
  3. package/lib/aws/function.js.map +1 -1
  4. package/lib/cloudflare/bindings.d.ts +3 -3
  5. package/lib/cloudflare/bindings.d.ts.map +1 -1
  6. package/lib/cloudflare/bindings.js.map +1 -1
  7. package/lib/cloudflare/bound.d.ts +3 -3
  8. package/lib/cloudflare/bound.d.ts.map +1 -1
  9. package/lib/cloudflare/do-state-store/index.d.ts +2 -0
  10. package/lib/cloudflare/do-state-store/index.d.ts.map +1 -0
  11. package/lib/cloudflare/do-state-store/index.js +2 -0
  12. package/lib/cloudflare/do-state-store/index.js.map +1 -0
  13. package/lib/cloudflare/do-state-store/internal.d.ts +19 -0
  14. package/lib/cloudflare/do-state-store/internal.d.ts.map +1 -0
  15. package/lib/cloudflare/do-state-store/internal.js +163 -0
  16. package/lib/cloudflare/do-state-store/internal.js.map +1 -0
  17. package/lib/cloudflare/do-state-store/store.d.ts +59 -0
  18. package/lib/cloudflare/do-state-store/store.d.ts.map +1 -0
  19. package/lib/cloudflare/do-state-store/store.js +120 -0
  20. package/lib/cloudflare/do-state-store/store.js.map +1 -0
  21. package/lib/cloudflare/do-state-store/types.d.ts +82 -0
  22. package/lib/cloudflare/do-state-store/types.d.ts.map +1 -0
  23. package/lib/cloudflare/do-state-store/types.js +1 -0
  24. package/lib/cloudflare/do-state-store/types.js.map +1 -0
  25. package/lib/cloudflare/do-state-store/worker.d.ts +27 -0
  26. package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -0
  27. package/lib/cloudflare/do-state-store/worker.js +170 -0
  28. package/lib/cloudflare/do-state-store/worker.js.map +1 -0
  29. package/lib/cloudflare/index.d.ts +1 -0
  30. package/lib/cloudflare/index.d.ts.map +1 -1
  31. package/lib/cloudflare/index.js +1 -0
  32. package/lib/cloudflare/index.js.map +1 -1
  33. package/lib/cloudflare/pipeline.js +1 -1
  34. package/lib/cloudflare/pipeline.js.map +1 -1
  35. package/lib/cloudflare/queue-consumer.d.ts +14 -1
  36. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  37. package/lib/cloudflare/queue-consumer.js +17 -0
  38. package/lib/cloudflare/queue-consumer.js.map +1 -1
  39. package/lib/cloudflare/website.d.ts +30 -1
  40. package/lib/cloudflare/website.d.ts.map +1 -1
  41. package/lib/cloudflare/website.js +8 -5
  42. package/lib/cloudflare/website.js.map +1 -1
  43. package/lib/cloudflare/worker-metadata.js +1 -1
  44. package/lib/cloudflare/worker-metadata.js.map +1 -1
  45. package/lib/cloudflare/worker.d.ts +40 -1
  46. package/lib/cloudflare/worker.d.ts.map +1 -1
  47. package/lib/cloudflare/worker.js +40 -38
  48. package/lib/cloudflare/worker.js.map +1 -1
  49. package/lib/cloudflare/wrangler.json.js +1 -1
  50. package/lib/cloudflare/wrangler.json.js.map +1 -1
  51. package/lib/fs/file-system-state-store.d.ts +3 -1
  52. package/lib/fs/file-system-state-store.d.ts.map +1 -1
  53. package/lib/fs/file-system-state-store.js +2 -2
  54. package/lib/fs/file-system-state-store.js.map +1 -1
  55. package/lib/stripe/card.d.ts +171 -0
  56. package/lib/stripe/card.d.ts.map +1 -0
  57. package/lib/stripe/card.js +148 -0
  58. package/lib/stripe/card.js.map +1 -0
  59. package/lib/stripe/client.d.ts +9 -0
  60. package/lib/stripe/client.d.ts.map +1 -0
  61. package/lib/stripe/client.js +94 -0
  62. package/lib/stripe/client.js.map +1 -0
  63. package/lib/stripe/coupon.d.ts +135 -0
  64. package/lib/stripe/coupon.d.ts.map +1 -0
  65. package/lib/stripe/coupon.js +161 -0
  66. package/lib/stripe/coupon.js.map +1 -0
  67. package/lib/stripe/customer.d.ts +269 -0
  68. package/lib/stripe/customer.d.ts.map +1 -0
  69. package/lib/stripe/customer.js +289 -0
  70. package/lib/stripe/customer.js.map +1 -0
  71. package/lib/stripe/entitlements-feature.d.ts +84 -0
  72. package/lib/stripe/entitlements-feature.d.ts.map +1 -0
  73. package/lib/stripe/entitlements-feature.js +102 -0
  74. package/lib/stripe/entitlements-feature.js.map +1 -0
  75. package/lib/stripe/file.d.ts +143 -0
  76. package/lib/stripe/file.d.ts.map +1 -0
  77. package/lib/stripe/file.js +97 -0
  78. package/lib/stripe/file.js.map +1 -0
  79. package/lib/stripe/index.d.ts +11 -0
  80. package/lib/stripe/index.d.ts.map +1 -1
  81. package/lib/stripe/index.js +11 -0
  82. package/lib/stripe/index.js.map +1 -1
  83. package/lib/stripe/meter.d.ts +10 -1
  84. package/lib/stripe/meter.d.ts.map +1 -1
  85. package/lib/stripe/meter.js +13 -7
  86. package/lib/stripe/meter.js.map +1 -1
  87. package/lib/stripe/portal-configuration.d.ts +286 -0
  88. package/lib/stripe/portal-configuration.d.ts.map +1 -0
  89. package/lib/stripe/portal-configuration.js +320 -0
  90. package/lib/stripe/portal-configuration.js.map +1 -0
  91. package/lib/stripe/price.d.ts +10 -1
  92. package/lib/stripe/price.d.ts.map +1 -1
  93. package/lib/stripe/price.js +34 -13
  94. package/lib/stripe/price.js.map +1 -1
  95. package/lib/stripe/product-feature.d.ts +76 -0
  96. package/lib/stripe/product-feature.d.ts.map +1 -0
  97. package/lib/stripe/product-feature.js +74 -0
  98. package/lib/stripe/product-feature.js.map +1 -0
  99. package/lib/stripe/product.d.ts +10 -1
  100. package/lib/stripe/product.d.ts.map +1 -1
  101. package/lib/stripe/product.js +33 -14
  102. package/lib/stripe/product.js.map +1 -1
  103. package/lib/stripe/promotion-code.d.ts +138 -0
  104. package/lib/stripe/promotion-code.d.ts.map +1 -0
  105. package/lib/stripe/promotion-code.js +150 -0
  106. package/lib/stripe/promotion-code.js.map +1 -0
  107. package/lib/stripe/shipping-rate.d.ts +188 -0
  108. package/lib/stripe/shipping-rate.d.ts.map +1 -0
  109. package/lib/stripe/shipping-rate.js +198 -0
  110. package/lib/stripe/shipping-rate.js.map +1 -0
  111. package/lib/stripe/tax-rate.d.ts +130 -0
  112. package/lib/stripe/tax-rate.d.ts.map +1 -0
  113. package/lib/stripe/tax-rate.js +126 -0
  114. package/lib/stripe/tax-rate.js.map +1 -0
  115. package/lib/stripe/webhook.d.ts +10 -1
  116. package/lib/stripe/webhook.d.ts.map +1 -1
  117. package/lib/stripe/webhook.js +59 -14
  118. package/lib/stripe/webhook.js.map +1 -1
  119. package/lib/test/bun.d.ts.map +1 -1
  120. package/lib/test/bun.js +2 -6
  121. package/lib/test/bun.js.map +1 -1
  122. package/lib/test/vitest.d.ts.map +1 -1
  123. package/lib/test/vitest.js +3 -7
  124. package/lib/test/vitest.js.map +1 -1
  125. package/lib/util/retry.d.ts +1 -1
  126. package/lib/util/retry.d.ts.map +1 -1
  127. package/lib/util/retry.js.map +1 -1
  128. package/package.json +2 -1
  129. package/src/aws/function.ts +3 -6
  130. package/src/cloudflare/bindings.ts +3 -2
  131. package/src/cloudflare/bound.ts +3 -3
  132. package/src/cloudflare/do-state-store/index.ts +1 -0
  133. package/src/cloudflare/do-state-store/internal.ts +215 -0
  134. package/src/cloudflare/do-state-store/store.ts +188 -0
  135. package/src/cloudflare/do-state-store/types.ts +74 -0
  136. package/src/cloudflare/do-state-store/worker.ts +199 -0
  137. package/src/cloudflare/index.ts +1 -0
  138. package/src/cloudflare/pipeline.ts +1 -1
  139. package/src/cloudflare/queue-consumer.ts +59 -1
  140. package/src/cloudflare/website.ts +38 -6
  141. package/src/cloudflare/worker-metadata.ts +1 -1
  142. package/src/cloudflare/worker.ts +66 -46
  143. package/src/cloudflare/wrangler.json.ts +1 -1
  144. package/src/fs/file-system-state-store.ts +7 -2
  145. package/src/stripe/card.ts +320 -0
  146. package/src/stripe/client.ts +145 -0
  147. package/src/stripe/coupon.ts +280 -0
  148. package/src/stripe/customer.ts +528 -0
  149. package/src/stripe/entitlements-feature.ts +169 -0
  150. package/src/stripe/file.ts +219 -0
  151. package/src/stripe/index.ts +11 -0
  152. package/src/stripe/meter.ts +23 -7
  153. package/src/stripe/portal-configuration.ts +609 -0
  154. package/src/stripe/price.ts +47 -14
  155. package/src/stripe/product-feature.ts +150 -0
  156. package/src/stripe/product.ts +48 -15
  157. package/src/stripe/promotion-code.ts +268 -0
  158. package/src/stripe/shipping-rate.ts +362 -0
  159. package/src/stripe/tax-rate.ts +218 -0
  160. package/src/stripe/webhook.ts +82 -15
  161. package/src/test/bun.ts +2 -7
  162. package/src/test/vitest.ts +3 -8
  163. package/src/util/retry.ts +1 -1
@@ -0,0 +1,150 @@
1
+ import { Resource } from "../resource.js";
2
+ import { createStripeClient, handleStripeDeleteError, isStripeConflictError, } from "./client.js";
3
+ /**
4
+ * Create and manage Stripe promotion codes for coupons
5
+ *
6
+ * @example
7
+ * // Create a basic promotion code
8
+ * const basicPromoCode = await PromotionCode("summer-promo", {
9
+ * coupon: "SUMMER25",
10
+ * code: "SAVE25NOW",
11
+ * active: true,
12
+ * metadata: {
13
+ * campaign: "summer_sale",
14
+ * channel: "email"
15
+ * }
16
+ * });
17
+ *
18
+ * @example
19
+ * // Create a customer-specific promotion code
20
+ * const customerPromoCode = await PromotionCode("vip-discount", {
21
+ * coupon: "VIP15",
22
+ * code: "VIP15OFF",
23
+ * customer: "cus_xyz123",
24
+ * maxRedemptions: 1,
25
+ * expiresAt: Math.floor(Date.now() / 1000) + 86400 * 30,
26
+ * metadata: {
27
+ * type: "vip_exclusive",
28
+ * tier: "gold"
29
+ * }
30
+ * });
31
+ *
32
+ * @example
33
+ * // Create a promotion code with restrictions
34
+ * const restrictedPromoCode = await PromotionCode("first-time-buyer", {
35
+ * coupon: "WELCOME10",
36
+ * code: "FIRSTTIME10",
37
+ * restrictions: {
38
+ * firstTimeTransaction: true,
39
+ * minimumAmount: 5000,
40
+ * minimumAmountCurrency: "usd"
41
+ * },
42
+ * maxRedemptions: 1000,
43
+ * metadata: {
44
+ * campaign: "new_customer_acquisition",
45
+ * minimum_order: "50_usd"
46
+ * }
47
+ * });
48
+ */
49
+ export const PromotionCode = Resource("stripe::PromotionCode", async function (_id, props) {
50
+ const stripe = createStripeClient({ apiKey: props.apiKey });
51
+ if (this.phase === "delete") {
52
+ try {
53
+ if (this.output?.id) {
54
+ await stripe.promotionCodes.update(this.output.id, { active: false });
55
+ }
56
+ }
57
+ catch (error) {
58
+ handleStripeDeleteError(error, "PromotionCode", this.output?.id);
59
+ }
60
+ return this.destroy();
61
+ }
62
+ try {
63
+ let promotionCode;
64
+ if (this.phase === "update" && this.output?.id) {
65
+ const updateParams = {
66
+ active: props.active,
67
+ metadata: props.metadata,
68
+ };
69
+ promotionCode = await stripe.promotionCodes.update(this.output.id, updateParams);
70
+ }
71
+ else {
72
+ const createParams = {
73
+ coupon: props.coupon,
74
+ code: props.code,
75
+ active: props.active,
76
+ customer: props.customer,
77
+ expires_at: props.expiresAt,
78
+ max_redemptions: props.maxRedemptions,
79
+ metadata: props.metadata,
80
+ };
81
+ if (props.restrictions) {
82
+ createParams.restrictions = {
83
+ first_time_transaction: props.restrictions.firstTimeTransaction,
84
+ minimum_amount: props.restrictions.minimumAmount,
85
+ minimum_amount_currency: props.restrictions.minimumAmountCurrency,
86
+ };
87
+ }
88
+ try {
89
+ promotionCode = await stripe.promotionCodes.create(createParams);
90
+ }
91
+ catch (error) {
92
+ if (isStripeConflictError(error) && props.adopt) {
93
+ if (props.code) {
94
+ const existingPromotionCodes = await stripe.promotionCodes.list({
95
+ code: props.code,
96
+ limit: 1,
97
+ });
98
+ if (existingPromotionCodes.data.length > 0) {
99
+ const existingPromotionCode = existingPromotionCodes.data[0];
100
+ const updateParams = {
101
+ active: props.active,
102
+ metadata: props.metadata,
103
+ };
104
+ promotionCode = await stripe.promotionCodes.update(existingPromotionCode.id, updateParams);
105
+ }
106
+ else {
107
+ throw error;
108
+ }
109
+ }
110
+ else {
111
+ throw error;
112
+ }
113
+ }
114
+ else {
115
+ throw error;
116
+ }
117
+ }
118
+ }
119
+ return this({
120
+ id: promotionCode.id,
121
+ object: promotionCode.object,
122
+ coupon: typeof promotionCode.coupon === "string"
123
+ ? promotionCode.coupon
124
+ : promotionCode.coupon.id,
125
+ code: promotionCode.code,
126
+ active: promotionCode.active,
127
+ customer: typeof promotionCode.customer === "string"
128
+ ? promotionCode.customer
129
+ : promotionCode.customer?.id,
130
+ expiresAt: promotionCode.expires_at || undefined,
131
+ maxRedemptions: promotionCode.max_redemptions || undefined,
132
+ metadata: promotionCode.metadata || undefined,
133
+ restrictions: promotionCode.restrictions
134
+ ? {
135
+ firstTimeTransaction: promotionCode.restrictions.first_time_transaction || undefined,
136
+ minimumAmount: promotionCode.restrictions.minimum_amount || undefined,
137
+ minimumAmountCurrency: promotionCode.restrictions.minimum_amount_currency || undefined,
138
+ }
139
+ : undefined,
140
+ created: promotionCode.created,
141
+ livemode: promotionCode.livemode,
142
+ timesRedeemed: promotionCode.times_redeemed,
143
+ });
144
+ }
145
+ catch (error) {
146
+ console.error("Error creating/updating promotion code:", error);
147
+ throw error;
148
+ }
149
+ });
150
+ //# sourceMappingURL=promotion-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion-code.js","sourceRoot":"","sources":["../../src/stripe/promotion-code.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAgGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CACnC,uBAAuB,EACvB,KAAK,WAEH,GAAW,EACX,KAAyB;IAEzB,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,CA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C,MAAM;gBACtB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;YAC7B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,QAAQ,EACN,OAAO,aAAa,CAAC,QAAQ,KAAK,QAAQ;gBACxC,CAAC,CAAC,aAAa,CAAC,QAAQ;gBACxB,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE;YAChC,SAAS,EAAE,aAAa,CAAC,UAAU,IAAI,SAAS;YAChD,cAAc,EAAE,aAAa,CAAC,eAAe,IAAI,SAAS;YAC1D,QAAQ,EAAE,aAAa,CAAC,QAAQ,IAAI,SAAS;YAC7C,YAAY,EAAE,aAAa,CAAC,YAAY;gBACtC,CAAC,CAAC;oBACE,oBAAoB,EAClB,aAAa,CAAC,YAAY,CAAC,sBAAsB,IAAI,SAAS;oBAChE,aAAa,EACX,aAAa,CAAC,YAAY,CAAC,cAAc,IAAI,SAAS;oBACxD,qBAAqB,EACnB,aAAa,CAAC,YAAY,CAAC,uBAAuB,IAAI,SAAS;iBAClE;gBACH,CAAC,CAAC,SAAS;YACb,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,QAAQ,EAAE,aAAa,CAAC,QAAQ;YAChC,aAAa,EAAE,aAAa,CAAC,cAAc;SAC5C,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -0,0 +1,188 @@
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
+ * Delivery estimate for shipping rate
7
+ */
8
+ export interface ShippingRateDeliveryEstimate {
9
+ /**
10
+ * The lower bound of the estimated range
11
+ */
12
+ minimum?: {
13
+ /**
14
+ * A unit of time
15
+ */
16
+ unit: Stripe.ShippingRateCreateParams.DeliveryEstimate.Minimum.Unit;
17
+ /**
18
+ * Must be greater than 0
19
+ */
20
+ value: number;
21
+ };
22
+ /**
23
+ * The upper bound of the estimated range
24
+ */
25
+ maximum?: {
26
+ /**
27
+ * A unit of time
28
+ */
29
+ unit: Stripe.ShippingRateCreateParams.DeliveryEstimate.Maximum.Unit;
30
+ /**
31
+ * Must be greater than 0
32
+ */
33
+ value: number;
34
+ };
35
+ }
36
+ /**
37
+ * Fixed amount configuration for shipping rate
38
+ */
39
+ export interface ShippingRateFixedAmount {
40
+ /**
41
+ * A non-negative integer in cents representing how much to charge
42
+ */
43
+ amount: number;
44
+ /**
45
+ * Three-letter ISO currency code, in lowercase
46
+ */
47
+ currency: string;
48
+ /**
49
+ * Shipping rates defined in each available currency option
50
+ */
51
+ currencyOptions?: Record<string, {
52
+ /**
53
+ * A non-negative integer in cents representing how much to charge
54
+ */
55
+ amount: number;
56
+ /**
57
+ * Specifies whether the rate is considered inclusive or exclusive of taxes
58
+ */
59
+ taxBehavior?: Stripe.ShippingRateCreateParams.FixedAmount.CurrencyOptions.TaxBehavior;
60
+ }>;
61
+ }
62
+ /**
63
+ * Properties for creating a Stripe shipping rate
64
+ */
65
+ export interface ShippingRateProps {
66
+ /**
67
+ * The name of the shipping rate, meant to be displayable to the customer
68
+ */
69
+ displayName: string;
70
+ /**
71
+ * Describes a fixed amount to charge for shipping
72
+ */
73
+ fixedAmount?: ShippingRateFixedAmount;
74
+ /**
75
+ * The estimated range for how long shipping will take
76
+ */
77
+ deliveryEstimate?: ShippingRateDeliveryEstimate;
78
+ /**
79
+ * Set of key-value pairs that you can attach to an object
80
+ */
81
+ metadata?: Record<string, string>;
82
+ /**
83
+ * Whether the shipping rate can be used for new purchases
84
+ */
85
+ active?: boolean;
86
+ /**
87
+ * Specifies whether the rate is considered inclusive or exclusive of taxes
88
+ */
89
+ taxBehavior?: Stripe.ShippingRateCreateParams.TaxBehavior;
90
+ /**
91
+ * A tax code ID
92
+ */
93
+ taxCode?: string;
94
+ /**
95
+ * The type of calculation to use on the shipping rate
96
+ */
97
+ type?: "fixed_amount";
98
+ /**
99
+ * API key to use (overrides environment variable)
100
+ */
101
+ apiKey?: Secret;
102
+ /**
103
+ * If true, adopt existing resource if creation fails due to conflict
104
+ */
105
+ adopt?: boolean;
106
+ }
107
+ /**
108
+ * Output from the Stripe shipping rate
109
+ */
110
+ export interface ShippingRate extends Resource<"stripe::ShippingRate">, ShippingRateProps {
111
+ /**
112
+ * The ID of the shipping rate
113
+ */
114
+ id: string;
115
+ /**
116
+ * String representing the object's type
117
+ */
118
+ object: "shipping_rate";
119
+ /**
120
+ * Time at which the object was created
121
+ */
122
+ created: number;
123
+ /**
124
+ * Has the value true if the object exists in live mode or the value false if the object exists in test mode
125
+ */
126
+ livemode: boolean;
127
+ }
128
+ /**
129
+ * Create and manage Stripe shipping rates
130
+ *
131
+ * @example
132
+ * // Create a standard shipping rate
133
+ * const standardShipping = await ShippingRate("standard-shipping", {
134
+ * displayName: "Standard Shipping",
135
+ * type: "fixed_amount",
136
+ * fixedAmount: {
137
+ * amount: 500,
138
+ * currency: "usd"
139
+ * },
140
+ * deliveryEstimate: {
141
+ * minimum: { unit: "business_day", value: 5 },
142
+ * maximum: { unit: "business_day", value: 7 }
143
+ * },
144
+ * taxBehavior: "exclusive"
145
+ * });
146
+ *
147
+ * @example
148
+ * // Create an express shipping rate
149
+ * const expressShipping = await ShippingRate("express-shipping", {
150
+ * displayName: "Express Shipping",
151
+ * type: "fixed_amount",
152
+ * fixedAmount: {
153
+ * amount: 1500,
154
+ * currency: "usd"
155
+ * },
156
+ * deliveryEstimate: {
157
+ * minimum: { unit: "business_day", value: 1 },
158
+ * maximum: { unit: "business_day", value: 2 }
159
+ * },
160
+ * taxBehavior: "exclusive",
161
+ * metadata: {
162
+ * priority: "high",
163
+ * service_level: "express"
164
+ * }
165
+ * });
166
+ *
167
+ * @example
168
+ * // Create a free shipping rate
169
+ * const freeShipping = await ShippingRate("free-shipping", {
170
+ * displayName: "Free Shipping",
171
+ * type: "fixed_amount",
172
+ * fixedAmount: {
173
+ * amount: 0,
174
+ * currency: "usd"
175
+ * },
176
+ * deliveryEstimate: {
177
+ * minimum: { unit: "business_day", value: 7 },
178
+ * maximum: { unit: "business_day", value: 10 }
179
+ * },
180
+ * taxBehavior: "unspecified",
181
+ * metadata: {
182
+ * promotion: "free_shipping_over_50",
183
+ * cost_center: "marketing"
184
+ * }
185
+ * });
186
+ */
187
+ export declare const ShippingRate: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<ShippingRate>, _id: string, props: ShippingRateProps) => Promise<ShippingRate>);
188
+ //# sourceMappingURL=shipping-rate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shipping-rate.d.ts","sourceRoot":"","sources":["../../src/stripe/shipping-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,4BAA4B;IAC3C;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC;QACpE;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC;QACpE;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IAC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AAO,MAAM,YAAY,yFAGf,OAAO,CAAC,YAAY,CAAC,OACtB,MAAM,SACJ,iBAAiB,KACvB,OAAO,CAAC,YAAY,CAAC,CAwJzB,CAAC"}
@@ -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;YACH,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;gBACpB,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uBAAuB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,CAAC;QACH,IAAI,YAAiC,CAAC;QAEtC,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;YAC/C,MAAM,YAAY,GAAQ;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY,EAAE,KAAK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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