| 1 | import * as Layer from "effect/Layer"; |
| 2 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 3 | import { CredentialsStoreLive } from "../Auth/Credentials.ts"; |
| 4 | import { ProfileStoreLive } from "../Auth/Profile.ts"; |
| 5 | import * as Provider from "../Provider.ts"; |
| 6 | import { Account, AccountProvider } from "./Account.ts"; |
| 7 | import { |
| 8 | AccountExternalAccount, |
| 9 | AccountExternalAccountProvider, |
| 10 | } from "./AccountExternalAccount.ts"; |
| 11 | import { AccountPerson, AccountPersonProvider } from "./AccountPerson.ts"; |
| 12 | import { Alert, AlertProvider } from "./Alert.ts"; |
| 13 | import { ApplePayDomain, ApplePayDomainProvider } from "./ApplePayDomain.ts"; |
| 14 | import { AppsSecret, AppsSecretProvider } from "./AppsSecret.ts"; |
| 15 | import { StripeAuth } from "./AuthProvider.ts"; |
| 16 | import { BillingMeter, BillingMeterProvider } from "./BillingMeter.ts"; |
| 17 | import { |
| 18 | BillingPortalConfiguration, |
| 19 | BillingPortalConfigurationProvider, |
| 20 | } from "./BillingPortalConfiguration.ts"; |
| 21 | import { Coupon, CouponProvider } from "./Coupon.ts"; |
| 22 | import { CreateAccountHttp } from "./CreateAccountHttp.ts"; |
| 23 | import { CreateAccountLinkHttp } from "./CreateAccountLinkHttp.ts"; |
| 24 | import { CreateAppsSecretHttp } from "./CreateAppsSecretHttp.ts"; |
| 25 | import { CreateCreditGrantHttp } from "./CreateCreditGrantHttp.ts"; |
| 26 | import { CreateCustomerHttp } from "./CreateCustomerHttp.ts"; |
| 27 | import { CreateFileLinkHttp } from "./CreateFileLinkHttp.ts"; |
| 28 | import { CreateIssuingCardHttp } from "./CreateIssuingCardHttp.ts"; |
| 29 | import { CreateIssuingCardholderHttp } from "./CreateIssuingCardholderHttp.ts"; |
| 30 | import { CreateTerminalReaderHttp } from "./CreateTerminalReaderHttp.ts"; |
| 31 | import { CreditGrant, CreditGrantProvider } from "./CreditGrant.ts"; |
| 32 | import * as Credentials from "./Credentials.ts"; |
| 33 | import { Customer, CustomerProvider } from "./Customer.ts"; |
| 34 | import { CustomerTaxId, CustomerTaxIdProvider } from "./CustomerTaxId.ts"; |
| 35 | import { |
| 36 | EntitlementsFeature, |
| 37 | EntitlementsFeatureProvider, |
| 38 | } from "./EntitlementsFeature.ts"; |
| 39 | import { FileLink, FileLinkProvider } from "./FileLink.ts"; |
| 40 | import { IssuingCard, IssuingCardProvider } from "./IssuingCard.ts"; |
| 41 | import { |
| 42 | IssuingCardholder, |
| 43 | IssuingCardholderProvider, |
| 44 | } from "./IssuingCardholder.ts"; |
| 45 | import { |
| 46 | IssuingPersonalizationDesign, |
| 47 | IssuingPersonalizationDesignProvider, |
| 48 | } from "./IssuingPersonalizationDesign.ts"; |
| 49 | import { PaymentLink, PaymentLinkProvider } from "./PaymentLink.ts"; |
| 50 | import { |
| 51 | PaymentMethodConfiguration, |
| 52 | PaymentMethodConfigurationProvider, |
| 53 | } from "./PaymentMethodConfiguration.ts"; |
| 54 | import { |
| 55 | PaymentMethodDomain, |
| 56 | PaymentMethodDomainProvider, |
| 57 | } from "./PaymentMethodDomain.ts"; |
| 58 | import { Plan, PlanProvider } from "./Plan.ts"; |
| 59 | import { Price, PriceProvider } from "./Price.ts"; |
| 60 | import { Product, ProductProvider } from "./Product.ts"; |
| 61 | import { ProductFeature, ProductFeatureProvider } from "./ProductFeature.ts"; |
| 62 | import { PromotionCode, PromotionCodeProvider } from "./PromotionCode.ts"; |
| 63 | import { RadarValueList, RadarValueListProvider } from "./RadarValueList.ts"; |
| 64 | import { |
| 65 | RadarValueListItem, |
| 66 | RadarValueListItemProvider, |
| 67 | } from "./RadarValueListItem.ts"; |
| 68 | import { |
| 69 | RestrictedApiKey, |
| 70 | RestrictedApiKeyProvider, |
| 71 | } from "./RestrictedApiKey.ts"; |
| 72 | import { RetrieveAccountExternalAccountHttp } from "./RetrieveAccountExternalAccountHttp.ts"; |
| 73 | import { RetrieveAccountHttp } from "./RetrieveAccountHttp.ts"; |
| 74 | import { RetrieveAccountPersonHttp } from "./RetrieveAccountPersonHttp.ts"; |
| 75 | import { RetrieveAlertHttp } from "./RetrieveAlertHttp.ts"; |
| 76 | import { RetrieveApplePayDomainHttp } from "./RetrieveApplePayDomainHttp.ts"; |
| 77 | import { RetrieveAppsSecretHttp } from "./RetrieveAppsSecretHttp.ts"; |
| 78 | import { RetrieveBillingMeterHttp } from "./RetrieveBillingMeterHttp.ts"; |
| 79 | import { RetrieveBillingPortalConfigurationHttp } from "./RetrieveBillingPortalConfigurationHttp.ts"; |
| 80 | import { RetrieveCouponHttp } from "./RetrieveCouponHttp.ts"; |
| 81 | import { RetrieveCreditGrantHttp } from "./RetrieveCreditGrantHttp.ts"; |
| 82 | import { RetrieveCustomerHttp } from "./RetrieveCustomerHttp.ts"; |
| 83 | import { RetrieveCustomerTaxIdHttp } from "./RetrieveCustomerTaxIdHttp.ts"; |
| 84 | import { RetrieveEntitlementsFeatureHttp } from "./RetrieveEntitlementsFeatureHttp.ts"; |
| 85 | import { RetrieveFileLinkHttp } from "./RetrieveFileLinkHttp.ts"; |
| 86 | import { RetrieveIssuingCardHttp } from "./RetrieveIssuingCardHttp.ts"; |
| 87 | import { RetrieveIssuingCardholderHttp } from "./RetrieveIssuingCardholderHttp.ts"; |
| 88 | import { RetrieveIssuingPersonalizationDesignHttp } from "./RetrieveIssuingPersonalizationDesignHttp.ts"; |
| 89 | import { RetrievePaymentLinkHttp } from "./RetrievePaymentLinkHttp.ts"; |
| 90 | import { RetrievePaymentMethodConfigurationHttp } from "./RetrievePaymentMethodConfigurationHttp.ts"; |
| 91 | import { RetrievePaymentMethodDomainHttp } from "./RetrievePaymentMethodDomainHttp.ts"; |
| 92 | import { RetrievePlanHttp } from "./RetrievePlanHttp.ts"; |
| 93 | import { RetrievePriceHttp } from "./RetrievePriceHttp.ts"; |
| 94 | import { RetrieveProductFeatureHttp } from "./RetrieveProductFeatureHttp.ts"; |
| 95 | import { RetrieveProductHttp } from "./RetrieveProductHttp.ts"; |
| 96 | import { RetrievePromotionCodeHttp } from "./RetrievePromotionCodeHttp.ts"; |
| 97 | import { RetrieveRadarValueListHttp } from "./RetrieveRadarValueListHttp.ts"; |
| 98 | import { RetrieveRadarValueListItemHttp } from "./RetrieveRadarValueListItemHttp.ts"; |
| 99 | import { RetrieveShippingRateHttp } from "./RetrieveShippingRateHttp.ts"; |
| 100 | import { RetrieveTaxRateHttp } from "./RetrieveTaxRateHttp.ts"; |
| 101 | import { RetrieveTaxRegistrationHttp } from "./RetrieveTaxRegistrationHttp.ts"; |
| 102 | import { RetrieveTaxSettingsHttp } from "./RetrieveTaxSettingsHttp.ts"; |
| 103 | import { RetrieveTerminalConfigurationHttp } from "./RetrieveTerminalConfigurationHttp.ts"; |
| 104 | import { RetrieveTerminalLocationHttp } from "./RetrieveTerminalLocationHttp.ts"; |
| 105 | import { RetrieveTerminalReaderHttp } from "./RetrieveTerminalReaderHttp.ts"; |
| 106 | import { RetrieveWebhookEndpointHttp } from "./RetrieveWebhookEndpointHttp.ts"; |
| 107 | import { ShippingRate, ShippingRateProvider } from "./ShippingRate.ts"; |
| 108 | import { TaxRate, TaxRateProvider } from "./TaxRate.ts"; |
| 109 | import { TaxRegistration, TaxRegistrationProvider } from "./TaxRegistration.ts"; |
| 110 | import { TaxSettings, TaxSettingsProvider } from "./TaxSettings.ts"; |
| 111 | import { |
| 112 | TerminalConfiguration, |
| 113 | TerminalConfigurationProvider, |
| 114 | } from "./TerminalConfiguration.ts"; |
| 115 | import { |
| 116 | TerminalLocation, |
| 117 | TerminalLocationProvider, |
| 118 | } from "./TerminalLocation.ts"; |
| 119 | import { TerminalReader, TerminalReaderProvider } from "./TerminalReader.ts"; |
| 120 | import { UpdateAccountHttp } from "./UpdateAccountHttp.ts"; |
| 121 | import { UpdateCreditGrantHttp } from "./UpdateCreditGrantHttp.ts"; |
| 122 | import { UpdateCustomerHttp } from "./UpdateCustomerHttp.ts"; |
| 123 | import { UpdateFileLinkHttp } from "./UpdateFileLinkHttp.ts"; |
| 124 | import { UpdateIssuingCardHttp } from "./UpdateIssuingCardHttp.ts"; |
| 125 | import { UpdateIssuingCardholderHttp } from "./UpdateIssuingCardholderHttp.ts"; |
| 126 | import { UpdateTaxSettingsHttp } from "./UpdateTaxSettingsHttp.ts"; |
| 127 | import { UpdateTerminalReaderHttp } from "./UpdateTerminalReaderHttp.ts"; |
| 128 | import { WebhookEndpoint, WebhookEndpointProvider } from "./WebhookEndpoint.ts"; |
| 129 | |
| 130 | export class Providers extends Provider.ProviderCollection<Providers>()( |
| 131 | "Stripe", |
| 132 | ) {} |
| 133 | |
| 134 | export type ProviderRequirements = Layer.Services<ReturnType<typeof providers>>; |
| 135 | |
| 136 | /** |
| 137 | * Build a layer that registers all Stripe resource providers, the Stripe |
| 138 | * `AuthProvider`, the resolved `Credentials`, and an `HttpClient`. Include |
| 139 | * this from your stack alongside other cloud `providers()` layers. |
| 140 | * |
| 141 | * Resource providers are inserted into {@link Provider.collection} as they |
| 142 | * land. |
| 143 | * |
| 144 | * @example |
| 145 | * ```typescript |
| 146 | * import * as Alchemy from "alchemy"; |
| 147 | * import * as Stripe from "alchemy/Stripe"; |
| 148 | * import * as Effect from "effect/Effect"; |
| 149 | * |
| 150 | * export default Alchemy.Stack( |
| 151 | * "MyStack", |
| 152 | * { |
| 153 | * providers: Stripe.providers(), |
| 154 | * state: Alchemy.localState(), |
| 155 | * }, |
| 156 | * Effect.gen(function* () { |
| 157 | * return {}; |
| 158 | * }), |
| 159 | * ); |
| 160 | * ``` |
| 161 | */ |
| 162 | export const providers = () => |
| 163 | Layer.effect( |
| 164 | Providers, |
| 165 | Provider.collection([ |
| 166 | Account, |
| 167 | AccountExternalAccount, |
| 168 | AccountPerson, |
| 169 | Alert, |
| 170 | ApplePayDomain, |
| 171 | AppsSecret, |
| 172 | BillingMeter, |
| 173 | BillingPortalConfiguration, |
| 174 | Coupon, |
| 175 | CreditGrant, |
| 176 | Customer, |
| 177 | CustomerTaxId, |
| 178 | EntitlementsFeature, |
| 179 | FileLink, |
| 180 | IssuingCard, |
| 181 | IssuingCardholder, |
| 182 | IssuingPersonalizationDesign, |
| 183 | PaymentLink, |
| 184 | PaymentMethodConfiguration, |
| 185 | PaymentMethodDomain, |
| 186 | Plan, |
| 187 | Price, |
| 188 | Product, |
| 189 | ProductFeature, |
| 190 | PromotionCode, |
| 191 | RadarValueList, |
| 192 | RadarValueListItem, |
| 193 | RestrictedApiKey, |
| 194 | ShippingRate, |
| 195 | TaxRate, |
| 196 | TaxRegistration, |
| 197 | TaxSettings, |
| 198 | TerminalConfiguration, |
| 199 | TerminalLocation, |
| 200 | TerminalReader, |
| 201 | WebhookEndpoint, |
| 202 | ]), |
| 203 | ).pipe( |
| 204 | Layer.provide( |
| 205 | Layer.mergeAll( |
| 206 | AccountProvider(), |
| 207 | AccountExternalAccountProvider(), |
| 208 | AccountPersonProvider(), |
| 209 | AlertProvider(), |
| 210 | ApplePayDomainProvider(), |
| 211 | AppsSecretProvider(), |
| 212 | BillingMeterProvider(), |
| 213 | BillingPortalConfigurationProvider(), |
| 214 | CouponProvider(), |
| 215 | CreditGrantProvider(), |
| 216 | CustomerProvider(), |
| 217 | CustomerTaxIdProvider(), |
| 218 | EntitlementsFeatureProvider(), |
| 219 | FileLinkProvider(), |
| 220 | IssuingCardProvider(), |
| 221 | IssuingCardholderProvider(), |
| 222 | IssuingPersonalizationDesignProvider(), |
| 223 | PaymentLinkProvider(), |
| 224 | PaymentMethodConfigurationProvider(), |
| 225 | PaymentMethodDomainProvider(), |
| 226 | PlanProvider(), |
| 227 | PriceProvider(), |
| 228 | ProductProvider(), |
| 229 | ProductFeatureProvider(), |
| 230 | PromotionCodeProvider(), |
| 231 | RadarValueListProvider(), |
| 232 | RadarValueListItemProvider(), |
| 233 | RestrictedApiKeyProvider(), |
| 234 | ShippingRateProvider(), |
| 235 | TaxRateProvider(), |
| 236 | TaxRegistrationProvider(), |
| 237 | TaxSettingsProvider(), |
| 238 | TerminalConfigurationProvider(), |
| 239 | TerminalLocationProvider(), |
| 240 | TerminalReaderProvider(), |
| 241 | WebhookEndpointProvider(), |
| 242 | ), |
| 243 | ), |
| 244 | Layer.provideMerge( |
| 245 | Layer.mergeAll( |
| 246 | CreateAccountHttp, |
| 247 | CreateAccountLinkHttp, |
| 248 | CreateAppsSecretHttp, |
| 249 | CreateCreditGrantHttp, |
| 250 | CreateCustomerHttp, |
| 251 | CreateFileLinkHttp, |
| 252 | CreateIssuingCardHttp, |
| 253 | CreateIssuingCardholderHttp, |
| 254 | CreateTerminalReaderHttp, |
| 255 | RetrieveAccountExternalAccountHttp, |
| 256 | RetrieveAccountHttp, |
| 257 | RetrieveAccountPersonHttp, |
| 258 | RetrieveAlertHttp, |
| 259 | RetrieveApplePayDomainHttp, |
| 260 | RetrieveAppsSecretHttp, |
| 261 | RetrieveBillingMeterHttp, |
| 262 | RetrieveBillingPortalConfigurationHttp, |
| 263 | RetrieveCouponHttp, |
| 264 | RetrieveCreditGrantHttp, |
| 265 | RetrieveCustomerHttp, |
| 266 | RetrieveCustomerTaxIdHttp, |
| 267 | RetrieveEntitlementsFeatureHttp, |
| 268 | RetrieveFileLinkHttp, |
| 269 | RetrieveIssuingCardHttp, |
| 270 | RetrieveIssuingCardholderHttp, |
| 271 | RetrieveIssuingPersonalizationDesignHttp, |
| 272 | RetrievePaymentLinkHttp, |
| 273 | RetrievePaymentMethodConfigurationHttp, |
| 274 | RetrievePaymentMethodDomainHttp, |
| 275 | RetrievePlanHttp, |
| 276 | RetrievePriceHttp, |
| 277 | RetrieveProductFeatureHttp, |
| 278 | RetrieveProductHttp, |
| 279 | RetrievePromotionCodeHttp, |
| 280 | RetrieveRadarValueListHttp, |
| 281 | RetrieveRadarValueListItemHttp, |
| 282 | RetrieveShippingRateHttp, |
| 283 | RetrieveTaxRateHttp, |
| 284 | RetrieveTaxRegistrationHttp, |
| 285 | RetrieveTaxSettingsHttp, |
| 286 | RetrieveTerminalConfigurationHttp, |
| 287 | RetrieveTerminalLocationHttp, |
| 288 | RetrieveTerminalReaderHttp, |
| 289 | RetrieveWebhookEndpointHttp, |
| 290 | UpdateAccountHttp, |
| 291 | UpdateCreditGrantHttp, |
| 292 | UpdateCustomerHttp, |
| 293 | UpdateFileLinkHttp, |
| 294 | UpdateIssuingCardHttp, |
| 295 | UpdateIssuingCardholderHttp, |
| 296 | UpdateTaxSettingsHttp, |
| 297 | UpdateTerminalReaderHttp, |
| 298 | ), |
| 299 | ), |
| 300 | Layer.provideMerge(Credentials.fromAuthProvider()), |
| 301 | Layer.provideMerge(StripeAuth), |
| 302 | Layer.provideMerge(ProfileStoreLive), |
| 303 | Layer.provideMerge(CredentialsStoreLive), |
| 304 | Layer.provideMerge(FetchHttpClient.layer), |
| 305 | Layer.orDie, |
| 306 | ); |