failover-sdk
Version:
One-line API failover with zero downtime. Native Rust performance with TypeScript interface.
351 lines • 8.37 kB
TypeScript
export interface FallbackRequest {
service: string;
operation: string;
method: string;
url: string;
headers: Record<string, string>;
body?: string;
}
export interface FallbackResponse {
status: number;
headers: Record<string, string>;
body: string;
provider_used: string;
attempt_count: number;
total_duration_ms: number;
debug_info?: {
failover_triggered: boolean;
failed_providers: string[];
retry_attempts: number;
};
}
export interface PaymentsHelper {
stripe: StripeHelper;
square: SquareHelper;
adyen: AdyenHelper;
paypal: PayPalHelper;
}
export interface EmailHelper {
sendgrid: SendGridHelper;
mailgun: MailgunHelper;
postmark: PostmarkHelper;
amazonses: AmazonSESHelper;
resend: ResendHelper;
}
export interface StripeHelper {
charges: {
create(params: StripeChargeCreateParams): Promise<StripeCharge>;
retrieve(id: string): Promise<StripeCharge>;
};
refunds: {
create(params: StripeRefundCreateParams): Promise<StripeRefund>;
};
paymentIntents: {
create(params: StripePaymentIntentParams): Promise<StripePaymentIntent>;
confirm(id: string, params?: StripePaymentIntentConfirmParams): Promise<StripePaymentIntent>;
};
}
export interface SquareHelper {
payments: {
create(params: SquarePaymentCreateParams): Promise<SquarePayment>;
};
refunds: {
create(params: SquareRefundCreateParams): Promise<SquareRefund>;
};
}
export interface AdyenHelper {
payments: {
create(params: AdyenPaymentParams): Promise<AdyenPaymentResponse>;
};
refunds: {
create(paymentId: string, params: AdyenRefundParams): Promise<AdyenRefundResponse>;
};
}
export interface PayPalHelper {
orders: {
create(params: PayPalOrderParams): Promise<PayPalOrder>;
capture(id: string): Promise<PayPalOrder>;
};
payments: {
refund(captureId: string, params: PayPalRefundParams): Promise<PayPalRefund>;
};
}
export interface SendGridHelper {
send(params: SendGridEmailParams): Promise<SendGridResponse>;
}
export interface MailgunHelper {
send(domain: string, params: MailgunEmailParams): Promise<MailgunResponse>;
}
export interface PostmarkHelper {
send(params: PostmarkEmailParams): Promise<PostmarkResponse>;
}
export interface AmazonSESHelper {
send(params: AmazonSESEmailParams): Promise<AmazonSESResponse>;
}
export interface ResendHelper {
send(params: ResendEmailParams): Promise<ResendResponse>;
batch(params: ResendBatchParams): Promise<ResendBatchResponse>;
}
export interface StripeChargeCreateParams {
amount: number;
currency: string;
source: string;
description?: string;
metadata?: Record<string, string>;
}
export interface StripeCharge {
id: string;
object: 'charge';
amount: number;
currency: string;
description?: string;
paid: boolean;
status: string;
}
export interface StripeRefundCreateParams {
charge: string;
amount?: number;
reason?: string;
}
export interface StripeRefund {
id: string;
object: 'refund';
amount: number;
charge: string;
status: string;
}
export interface StripePaymentIntentParams {
amount: number;
currency: string;
payment_method?: string;
confirm?: boolean;
}
export interface StripePaymentIntent {
id: string;
object: 'payment_intent';
amount: number;
currency: string;
status: string;
}
export interface StripePaymentIntentConfirmParams {
payment_method?: string;
}
export interface SquarePaymentCreateParams {
source_id: string;
amount_money: {
amount: number;
currency: string;
};
idempotency_key: string;
}
export interface SquarePayment {
id: string;
status: string;
amount_money: {
amount: number;
currency: string;
};
}
export interface SquareRefundCreateParams {
payment_id: string;
amount_money: {
amount: number;
currency: string;
};
idempotency_key: string;
}
export interface SquareRefund {
id: string;
status: string;
amount_money: {
amount: number;
currency: string;
};
}
export interface AdyenPaymentParams {
amount: {
value: number;
currency: string;
};
reference: string;
paymentMethod: Record<string, unknown>;
returnUrl?: string;
merchantAccount: string;
}
export interface AdyenPaymentResponse {
pspReference: string;
resultCode: string;
amount: {
value: number;
currency: string;
};
}
export interface AdyenRefundParams {
amount: {
value: number;
currency: string;
};
reference: string;
merchantAccount: string;
}
export interface AdyenRefundResponse {
pspReference: string;
response: string;
}
export interface PayPalOrderParams {
intent: 'CAPTURE' | 'AUTHORIZE';
purchase_units: Array<{
amount: {
currency_code: string;
value: string;
};
}>;
}
export interface PayPalOrder {
id: string;
status: string;
links: Array<{
href: string;
rel: string;
method: string;
}>;
}
export interface PayPalRefundParams {
amount: {
value: string;
currency_code: string;
};
}
export interface PayPalRefund {
id: string;
status: string;
amount: {
value: string;
currency_code: string;
};
}
export interface SendGridEmailParams {
personalizations: Array<{
to: Array<{
email: string;
name?: string;
}>;
cc?: Array<{
email: string;
name?: string;
}>;
bcc?: Array<{
email: string;
name?: string;
}>;
subject?: string;
}>;
from: {
email: string;
name?: string;
};
reply_to?: {
email: string;
name?: string;
};
subject: string;
content: Array<{
type: 'text/plain' | 'text/html';
value: string;
}>;
}
export interface SendGridResponse {
message_id?: string;
}
export interface MailgunEmailParams {
from: string;
to: string | string[];
cc?: string | string[];
bcc?: string | string[];
subject: string;
text?: string;
html?: string;
}
export interface MailgunResponse {
id: string;
message: string;
}
export interface PostmarkEmailParams {
From: string;
To: string;
Cc?: string;
Bcc?: string;
Subject: string;
HtmlBody?: string;
TextBody?: string;
MessageStream?: string;
}
export interface PostmarkResponse {
MessageID: string;
SubmittedAt: string;
To: string;
}
export interface AmazonSESEmailParams {
Source: string;
Destination: {
ToAddresses: string[];
CcAddresses?: string[];
BccAddresses?: string[];
};
Message: {
Subject: {
Data: string;
Charset?: string;
};
Body: {
Text?: {
Data: string;
Charset?: string;
};
Html?: {
Data: string;
Charset?: string;
};
};
};
}
export interface AmazonSESResponse {
MessageId: string;
}
export interface ResendEmailParams {
from: string;
to: string | string[];
cc?: string | string[];
bcc?: string | string[];
reply_to?: string | string[];
subject: string;
html?: string;
text?: string;
tags?: Array<{
name: string;
value: string;
}>;
headers?: Record<string, string>;
attachments?: Array<{
filename: string;
content: string;
content_type?: string;
}>;
}
export interface ResendResponse {
id: string;
}
export interface ResendBatchParams {
emails: ResendEmailParams[];
}
export interface ResendBatchResponse {
data: Array<{
id: string;
}>;
}
export declare function payments(): PaymentsHelper;
export declare function email(): EmailHelper;
export declare function custom(serviceName: string): {
request<T = unknown>(operation: string, method: string, url: string, headers: Record<string, string>, body?: unknown): Promise<T>;
};
//# sourceMappingURL=providers.d.ts.map