@contractspec/integration.providers-impls 1.57.0 → 1.58.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/dist/analytics.d.ts +1 -8
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +3 -3
- package/dist/calendar.d.ts +1 -8
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +3 -3
- package/dist/database.d.ts +1 -8
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +3 -3
- package/dist/email.d.ts +1 -8
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3 -3
- package/dist/embedding.d.ts +1 -8
- package/dist/embedding.d.ts.map +1 -1
- package/dist/embedding.js +3 -3
- package/dist/impls/elevenlabs-voice.d.ts +14 -18
- package/dist/impls/elevenlabs-voice.d.ts.map +1 -1
- package/dist/impls/elevenlabs-voice.js +98 -88
- package/dist/impls/fal-voice.d.ts +22 -26
- package/dist/impls/fal-voice.d.ts.map +1 -1
- package/dist/impls/fal-voice.js +103 -78
- package/dist/impls/fathom-meeting-recorder.d.ts +35 -39
- package/dist/impls/fathom-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.js +285 -142
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts +4 -8
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js +102 -38
- package/dist/impls/fathom-meeting-recorder.types.d.ts +16 -20
- package/dist/impls/fathom-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.types.js +1 -0
- package/dist/impls/fathom-meeting-recorder.utils.d.ts +10 -14
- package/dist/impls/fathom-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.utils.js +58 -41
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts +3 -7
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js +25 -20
- package/dist/impls/fireflies-meeting-recorder.d.ts +21 -25
- package/dist/impls/fireflies-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.js +272 -149
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts +3 -6
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js +10 -8
- package/dist/impls/fireflies-meeting-recorder.types.d.ts +26 -29
- package/dist/impls/fireflies-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.types.js +1 -0
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts +4 -7
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js +34 -27
- package/dist/impls/gcs-storage.d.ts +18 -22
- package/dist/impls/gcs-storage.d.ts.map +1 -1
- package/dist/impls/gcs-storage.js +92 -84
- package/dist/impls/gmail-inbound.d.ts +20 -24
- package/dist/impls/gmail-inbound.d.ts.map +1 -1
- package/dist/impls/gmail-inbound.js +212 -185
- package/dist/impls/gmail-outbound.d.ts +12 -16
- package/dist/impls/gmail-outbound.d.ts.map +1 -1
- package/dist/impls/gmail-outbound.js +126 -92
- package/dist/impls/google-calendar.d.ts +17 -21
- package/dist/impls/google-calendar.d.ts.map +1 -1
- package/dist/impls/google-calendar.js +182 -145
- package/dist/impls/gradium-voice.d.ts +20 -22
- package/dist/impls/gradium-voice.d.ts.map +1 -1
- package/dist/impls/gradium-voice.js +85 -74
- package/dist/impls/granola-meeting-recorder.d.ts +31 -24
- package/dist/impls/granola-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.js +511 -143
- package/dist/impls/granola-meeting-recorder.mcp.d.ts +25 -0
- package/dist/impls/granola-meeting-recorder.mcp.d.ts.map +1 -0
- package/dist/impls/granola-meeting-recorder.mcp.js +279 -0
- package/dist/impls/granola-meeting-recorder.types.d.ts +60 -49
- package/dist/impls/granola-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.types.js +1 -0
- package/dist/impls/index.d.ts +28 -28
- package/dist/impls/index.d.ts.map +1 -0
- package/dist/impls/index.js +4659 -29
- package/dist/impls/jira.d.ts +18 -22
- package/dist/impls/jira.d.ts.map +1 -1
- package/dist/impls/jira.js +112 -101
- package/dist/impls/linear.d.ts +17 -21
- package/dist/impls/linear.d.ts.map +1 -1
- package/dist/impls/linear.js +78 -69
- package/dist/impls/mistral-embedding.d.ts +17 -21
- package/dist/impls/mistral-embedding.d.ts.map +1 -1
- package/dist/impls/mistral-embedding.js +41 -39
- package/dist/impls/mistral-llm.d.ts +25 -29
- package/dist/impls/mistral-llm.d.ts.map +1 -1
- package/dist/impls/mistral-llm.js +266 -244
- package/dist/impls/notion.d.ts +20 -24
- package/dist/impls/notion.d.ts.map +1 -1
- package/dist/impls/notion.js +145 -110
- package/dist/impls/posthog-reader.d.ts +18 -22
- package/dist/impls/posthog-reader.d.ts.map +1 -1
- package/dist/impls/posthog-reader.js +148 -129
- package/dist/impls/posthog-utils.d.ts +4 -7
- package/dist/impls/posthog-utils.d.ts.map +1 -1
- package/dist/impls/posthog-utils.js +31 -22
- package/dist/impls/posthog.d.ts +33 -37
- package/dist/impls/posthog.d.ts.map +1 -1
- package/dist/impls/posthog.js +320 -119
- package/dist/impls/postmark-email.d.ts +13 -17
- package/dist/impls/postmark-email.d.ts.map +1 -1
- package/dist/impls/postmark-email.js +55 -50
- package/dist/impls/powens-client.d.ts +111 -114
- package/dist/impls/powens-client.d.ts.map +1 -1
- package/dist/impls/powens-client.js +194 -170
- package/dist/impls/powens-openbanking.d.ts +22 -26
- package/dist/impls/powens-openbanking.d.ts.map +1 -1
- package/dist/impls/powens-openbanking.js +425 -217
- package/dist/impls/provider-factory.d.ts +29 -33
- package/dist/impls/provider-factory.d.ts.map +1 -1
- package/dist/impls/provider-factory.js +4072 -275
- package/dist/impls/qdrant-vector.d.ts +18 -22
- package/dist/impls/qdrant-vector.d.ts.map +1 -1
- package/dist/impls/qdrant-vector.js +76 -69
- package/dist/impls/stripe-payments.d.ts +22 -26
- package/dist/impls/stripe-payments.d.ts.map +1 -1
- package/dist/impls/stripe-payments.js +219 -193
- package/dist/impls/supabase-psql.d.ts +21 -25
- package/dist/impls/supabase-psql.d.ts.map +1 -1
- package/dist/impls/supabase-psql.js +138 -98
- package/dist/impls/supabase-vector.d.ts +29 -33
- package/dist/impls/supabase-vector.d.ts.map +1 -1
- package/dist/impls/supabase-vector.js +278 -103
- package/dist/impls/tldv-meeting-recorder.d.ts +18 -22
- package/dist/impls/tldv-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/tldv-meeting-recorder.js +142 -127
- package/dist/impls/twilio-sms.d.ts +14 -17
- package/dist/impls/twilio-sms.d.ts.map +1 -1
- package/dist/impls/twilio-sms.js +62 -55
- package/dist/index.d.ts +15 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4700 -107
- package/dist/llm.d.ts +1 -8
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +3 -3
- package/dist/meeting-recorder.d.ts +1 -8
- package/dist/meeting-recorder.d.ts.map +1 -1
- package/dist/meeting-recorder.js +3 -3
- package/dist/node/analytics.js +2 -0
- package/dist/node/calendar.js +2 -0
- package/dist/node/database.js +2 -0
- package/dist/node/email.js +2 -0
- package/dist/node/embedding.js +2 -0
- package/dist/node/impls/elevenlabs-voice.js +102 -0
- package/dist/node/impls/fal-voice.js +112 -0
- package/dist/node/impls/fathom-meeting-recorder.js +287 -0
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +105 -0
- package/dist/node/impls/fathom-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fathom-meeting-recorder.utils.js +72 -0
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +29 -0
- package/dist/node/impls/fireflies-meeting-recorder.js +274 -0
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +85 -0
- package/dist/node/impls/fireflies-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +42 -0
- package/dist/node/impls/gcs-storage.js +97 -0
- package/dist/node/impls/gmail-inbound.js +227 -0
- package/dist/node/impls/gmail-outbound.js +139 -0
- package/dist/node/impls/google-calendar.js +191 -0
- package/dist/node/impls/gradium-voice.js +90 -0
- package/dist/node/impls/granola-meeting-recorder.js +512 -0
- package/dist/node/impls/granola-meeting-recorder.mcp.js +278 -0
- package/dist/node/impls/granola-meeting-recorder.types.js +0 -0
- package/dist/node/impls/index.js +4658 -0
- package/dist/node/impls/jira.js +124 -0
- package/dist/node/impls/linear.js +83 -0
- package/dist/node/impls/mistral-embedding.js +43 -0
- package/dist/node/impls/mistral-llm.js +269 -0
- package/dist/node/impls/notion.js +160 -0
- package/dist/node/impls/posthog-reader.js +159 -0
- package/dist/node/impls/posthog-utils.js +38 -0
- package/dist/node/impls/posthog.js +322 -0
- package/dist/node/impls/postmark-email.js +60 -0
- package/dist/node/impls/powens-client.js +195 -0
- package/dist/node/impls/powens-openbanking.js +426 -0
- package/dist/node/impls/provider-factory.js +4080 -0
- package/dist/node/impls/qdrant-vector.js +78 -0
- package/dist/node/impls/stripe-payments.js +228 -0
- package/dist/node/impls/supabase-psql.js +150 -0
- package/dist/node/impls/supabase-vector.js +323 -0
- package/dist/node/impls/tldv-meeting-recorder.js +145 -0
- package/dist/node/impls/twilio-sms.js +65 -0
- package/dist/node/index.js +4699 -0
- package/dist/node/llm.js +2 -0
- package/dist/node/meeting-recorder.js +2 -0
- package/dist/node/openbanking.js +2 -0
- package/dist/node/payments.js +2 -0
- package/dist/node/project-management.js +2 -0
- package/dist/node/runtime.js +0 -0
- package/dist/node/secrets/provider.js +11 -0
- package/dist/node/sms.js +2 -0
- package/dist/node/storage.js +2 -0
- package/dist/node/vector-store.js +2 -0
- package/dist/node/voice.js +2 -0
- package/dist/openbanking.d.ts +1 -8
- package/dist/openbanking.d.ts.map +1 -1
- package/dist/openbanking.js +3 -3
- package/dist/payments.d.ts +1 -8
- package/dist/payments.d.ts.map +1 -1
- package/dist/payments.js +3 -3
- package/dist/project-management.d.ts +1 -8
- package/dist/project-management.d.ts.map +1 -1
- package/dist/project-management.js +3 -3
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/secrets/provider.d.ts +3 -2
- package/dist/secrets/provider.d.ts.map +1 -0
- package/dist/secrets/provider.js +12 -3
- package/dist/sms.d.ts +1 -8
- package/dist/sms.d.ts.map +1 -1
- package/dist/sms.js +3 -3
- package/dist/storage.d.ts +1 -8
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -3
- package/dist/vector-store.d.ts +1 -8
- package/dist/vector-store.d.ts.map +1 -1
- package/dist/vector-store.js +3 -3
- package/dist/voice.d.ts +1 -8
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +3 -3
- package/package.json +405 -114
- package/dist/_virtual/_rolldown/runtime.js +0 -36
- package/dist/impls/elevenlabs-voice.js.map +0 -1
- package/dist/impls/fal-voice.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/gcs-storage.js.map +0 -1
- package/dist/impls/gmail-inbound.js.map +0 -1
- package/dist/impls/gmail-outbound.js.map +0 -1
- package/dist/impls/google-calendar.js.map +0 -1
- package/dist/impls/gradium-voice.js.map +0 -1
- package/dist/impls/granola-meeting-recorder.js.map +0 -1
- package/dist/impls/jira.js.map +0 -1
- package/dist/impls/linear.js.map +0 -1
- package/dist/impls/mistral-embedding.js.map +0 -1
- package/dist/impls/mistral-llm.js.map +0 -1
- package/dist/impls/notion.js.map +0 -1
- package/dist/impls/posthog-reader.js.map +0 -1
- package/dist/impls/posthog-utils.js.map +0 -1
- package/dist/impls/posthog.js.map +0 -1
- package/dist/impls/postmark-email.js.map +0 -1
- package/dist/impls/powens-client.js.map +0 -1
- package/dist/impls/powens-openbanking.js.map +0 -1
- package/dist/impls/provider-factory.js.map +0 -1
- package/dist/impls/qdrant-vector.js.map +0 -1
- package/dist/impls/stripe-payments.js.map +0 -1
- package/dist/impls/supabase-psql.js.map +0 -1
- package/dist/impls/supabase-vector.js.map +0 -1
- package/dist/impls/tldv-meeting-recorder.js.map +0 -1
- package/dist/impls/twilio-sms.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,203 +1,229 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/impls/stripe-payments.ts
|
|
1
3
|
import Stripe from "stripe";
|
|
4
|
+
var API_VERSION = "2026-01-28.clover";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
6
|
+
class StripePaymentsProvider {
|
|
7
|
+
stripe;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.stripe = options.stripe ?? new Stripe(options.apiKey, {
|
|
10
|
+
apiVersion: API_VERSION
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async createCustomer(input) {
|
|
14
|
+
const customer = await this.stripe.customers.create({
|
|
15
|
+
email: input.email,
|
|
16
|
+
name: input.name,
|
|
17
|
+
description: input.description,
|
|
18
|
+
metadata: input.metadata
|
|
19
|
+
});
|
|
20
|
+
return this.toCustomer(customer);
|
|
21
|
+
}
|
|
22
|
+
async getCustomer(customerId) {
|
|
23
|
+
const customer = await this.stripe.customers.retrieve(customerId);
|
|
24
|
+
if (customer.deleted)
|
|
25
|
+
return null;
|
|
26
|
+
return this.toCustomer(customer);
|
|
27
|
+
}
|
|
28
|
+
async createPaymentIntent(input) {
|
|
29
|
+
const intent = await this.stripe.paymentIntents.create({
|
|
30
|
+
amount: input.amount.amount,
|
|
31
|
+
currency: input.amount.currency,
|
|
32
|
+
customer: input.customerId,
|
|
33
|
+
description: input.description,
|
|
34
|
+
capture_method: input.captureMethod ?? "automatic",
|
|
35
|
+
confirmation_method: input.confirmationMethod ?? "automatic",
|
|
36
|
+
automatic_payment_methods: { enabled: true },
|
|
37
|
+
metadata: input.metadata,
|
|
38
|
+
return_url: input.returnUrl,
|
|
39
|
+
statement_descriptor: input.statementDescriptor
|
|
40
|
+
});
|
|
41
|
+
return this.toPaymentIntent(intent);
|
|
42
|
+
}
|
|
43
|
+
async capturePayment(paymentIntentId, input) {
|
|
44
|
+
const intent = await this.stripe.paymentIntents.capture(paymentIntentId, input?.amount ? { amount_to_capture: input.amount.amount } : undefined);
|
|
45
|
+
return this.toPaymentIntent(intent);
|
|
46
|
+
}
|
|
47
|
+
async cancelPaymentIntent(paymentIntentId) {
|
|
48
|
+
const intent = await this.stripe.paymentIntents.cancel(paymentIntentId);
|
|
49
|
+
return this.toPaymentIntent(intent);
|
|
50
|
+
}
|
|
51
|
+
async refundPayment(input) {
|
|
52
|
+
const refund = await this.stripe.refunds.create({
|
|
53
|
+
payment_intent: input.paymentIntentId,
|
|
54
|
+
amount: input.amount?.amount,
|
|
55
|
+
reason: mapRefundReason(input.reason),
|
|
56
|
+
metadata: input.metadata
|
|
57
|
+
});
|
|
58
|
+
const paymentIntentId = typeof refund.payment_intent === "string" ? refund.payment_intent : refund.payment_intent?.id ?? "";
|
|
59
|
+
return {
|
|
60
|
+
id: refund.id,
|
|
61
|
+
paymentIntentId,
|
|
62
|
+
amount: {
|
|
63
|
+
amount: refund.amount ?? 0,
|
|
64
|
+
currency: refund.currency?.toUpperCase() ?? "USD"
|
|
65
|
+
},
|
|
66
|
+
status: mapRefundStatus(refund.status),
|
|
67
|
+
reason: refund.reason ?? undefined,
|
|
68
|
+
metadata: this.toMetadata(refund.metadata),
|
|
69
|
+
createdAt: refund.created ? new Date(refund.created * 1000) : undefined
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async listInvoices(query) {
|
|
73
|
+
const requestedStatus = query?.status?.[0];
|
|
74
|
+
const stripeStatus = requestedStatus && requestedStatus !== "deleted" ? requestedStatus : undefined;
|
|
75
|
+
const response = await this.stripe.invoices.list({
|
|
76
|
+
customer: query?.customerId,
|
|
77
|
+
status: stripeStatus,
|
|
78
|
+
limit: query?.limit,
|
|
79
|
+
starting_after: query?.startingAfter
|
|
80
|
+
});
|
|
81
|
+
return response.data.map((invoice) => this.toInvoice(invoice));
|
|
82
|
+
}
|
|
83
|
+
async listTransactions(query) {
|
|
84
|
+
const response = await this.stripe.charges.list({
|
|
85
|
+
customer: query?.customerId,
|
|
86
|
+
payment_intent: query?.paymentIntentId,
|
|
87
|
+
limit: query?.limit,
|
|
88
|
+
starting_after: query?.startingAfter
|
|
89
|
+
});
|
|
90
|
+
return response.data.map((charge) => ({
|
|
91
|
+
id: charge.id,
|
|
92
|
+
paymentIntentId: typeof charge.payment_intent === "string" ? charge.payment_intent : charge.payment_intent?.id,
|
|
93
|
+
amount: {
|
|
94
|
+
amount: charge.amount,
|
|
95
|
+
currency: charge.currency?.toUpperCase() ?? "USD"
|
|
96
|
+
},
|
|
97
|
+
type: "capture",
|
|
98
|
+
status: mapChargeStatus(charge.status),
|
|
99
|
+
description: charge.description ?? undefined,
|
|
100
|
+
createdAt: new Date(charge.created * 1000),
|
|
101
|
+
metadata: this.mergeMetadata(this.toMetadata(charge.metadata), {
|
|
102
|
+
balanceTransaction: typeof charge.balance_transaction === "string" ? charge.balance_transaction : undefined
|
|
103
|
+
})
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
toCustomer(customer) {
|
|
107
|
+
const metadata = this.toMetadata(customer.metadata);
|
|
108
|
+
const updatedAtValue = metadata?.updatedAt;
|
|
109
|
+
return {
|
|
110
|
+
id: customer.id,
|
|
111
|
+
email: customer.email ?? undefined,
|
|
112
|
+
name: customer.name ?? undefined,
|
|
113
|
+
metadata,
|
|
114
|
+
createdAt: customer.created ? new Date(customer.created * 1000) : undefined,
|
|
115
|
+
updatedAt: updatedAtValue ? new Date(updatedAtValue) : undefined
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
toPaymentIntent(intent) {
|
|
119
|
+
const metadata = this.toMetadata(intent.metadata);
|
|
120
|
+
return {
|
|
121
|
+
id: intent.id,
|
|
122
|
+
amount: this.toMoney(intent.amount_received ?? intent.amount ?? 0, intent.currency),
|
|
123
|
+
status: mapPaymentIntentStatus(intent.status),
|
|
124
|
+
customerId: typeof intent.customer === "string" ? intent.customer : intent.customer?.id,
|
|
125
|
+
description: intent.description ?? undefined,
|
|
126
|
+
clientSecret: intent.client_secret ?? undefined,
|
|
127
|
+
metadata,
|
|
128
|
+
createdAt: new Date(intent.created * 1000),
|
|
129
|
+
updatedAt: intent.canceled_at != null ? new Date(intent.canceled_at * 1000) : new Date(intent.created * 1000)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
toInvoice(invoice) {
|
|
133
|
+
const metadata = this.toMetadata(invoice.metadata);
|
|
134
|
+
return {
|
|
135
|
+
id: invoice.id,
|
|
136
|
+
number: invoice.number ?? undefined,
|
|
137
|
+
status: invoice.status ?? "draft",
|
|
138
|
+
amountDue: this.toMoney(invoice.amount_due ?? 0, invoice.currency),
|
|
139
|
+
amountPaid: this.toMoney(invoice.amount_paid ?? 0, invoice.currency),
|
|
140
|
+
customerId: typeof invoice.customer === "string" ? invoice.customer : invoice.customer?.id,
|
|
141
|
+
dueDate: invoice.due_date ? new Date(invoice.due_date * 1000) : undefined,
|
|
142
|
+
hostedInvoiceUrl: invoice.hosted_invoice_url ?? undefined,
|
|
143
|
+
metadata,
|
|
144
|
+
createdAt: invoice.created ? new Date(invoice.created * 1000) : undefined,
|
|
145
|
+
updatedAt: invoice.status_transitions?.finalized_at ? new Date(invoice.status_transitions.finalized_at * 1000) : undefined
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
toMoney(amount, currency) {
|
|
149
|
+
return {
|
|
150
|
+
amount,
|
|
151
|
+
currency: currency?.toUpperCase() ?? "USD"
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
toMetadata(metadata) {
|
|
155
|
+
if (!metadata)
|
|
156
|
+
return;
|
|
157
|
+
const entries = Object.entries(metadata).filter((entry) => typeof entry[1] === "string");
|
|
158
|
+
if (entries.length === 0)
|
|
159
|
+
return;
|
|
160
|
+
return Object.fromEntries(entries);
|
|
161
|
+
}
|
|
162
|
+
mergeMetadata(base, extras) {
|
|
163
|
+
const filteredExtras = Object.entries(extras).filter((entry) => typeof entry[1] === "string");
|
|
164
|
+
if (!base && filteredExtras.length === 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
...base ?? {},
|
|
169
|
+
...Object.fromEntries(filteredExtras)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
161
173
|
function mapRefundReason(reason) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
if (!reason)
|
|
175
|
+
return;
|
|
176
|
+
const allowed = [
|
|
177
|
+
"duplicate",
|
|
178
|
+
"fraudulent",
|
|
179
|
+
"requested_by_customer"
|
|
180
|
+
];
|
|
181
|
+
return allowed.includes(reason) ? reason : undefined;
|
|
168
182
|
}
|
|
169
183
|
function mapPaymentIntentStatus(status) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
switch (status) {
|
|
185
|
+
case "requires_payment_method":
|
|
186
|
+
return "requires_payment_method";
|
|
187
|
+
case "requires_confirmation":
|
|
188
|
+
return "requires_confirmation";
|
|
189
|
+
case "requires_action":
|
|
190
|
+
case "requires_capture":
|
|
191
|
+
return "requires_action";
|
|
192
|
+
case "processing":
|
|
193
|
+
return "processing";
|
|
194
|
+
case "succeeded":
|
|
195
|
+
return "succeeded";
|
|
196
|
+
case "canceled":
|
|
197
|
+
return "canceled";
|
|
198
|
+
default:
|
|
199
|
+
return "requires_payment_method";
|
|
200
|
+
}
|
|
180
201
|
}
|
|
181
202
|
function mapRefundStatus(status) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
203
|
+
switch (status) {
|
|
204
|
+
case "pending":
|
|
205
|
+
case "succeeded":
|
|
206
|
+
case "failed":
|
|
207
|
+
case "canceled":
|
|
208
|
+
return status;
|
|
209
|
+
default:
|
|
210
|
+
return "pending";
|
|
211
|
+
}
|
|
189
212
|
}
|
|
190
213
|
function mapChargeStatus(status) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
214
|
+
switch (status) {
|
|
215
|
+
case "pending":
|
|
216
|
+
case "processing":
|
|
217
|
+
return "pending";
|
|
218
|
+
case "succeeded":
|
|
219
|
+
return "succeeded";
|
|
220
|
+
case "failed":
|
|
221
|
+
case "canceled":
|
|
222
|
+
return "failed";
|
|
223
|
+
default:
|
|
224
|
+
return "pending";
|
|
225
|
+
}
|
|
199
226
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
//# sourceMappingURL=stripe-payments.js.map
|
|
227
|
+
export {
|
|
228
|
+
StripePaymentsProvider
|
|
229
|
+
};
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
db?: PostgresJsDatabase<Record<string, never>>;
|
|
13
|
-
createDrizzle?: (client: Sql) => PostgresJsDatabase<Record<string, never>>;
|
|
1
|
+
import { type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
2
|
+
import { type Sql } from 'postgres';
|
|
3
|
+
import type { DatabaseProvider, DatabaseQueryResult, DatabaseRow, DatabaseStatementParam } from '../database';
|
|
4
|
+
export type SupabasePostgresSslMode = 'require' | 'allow' | 'prefer';
|
|
5
|
+
export interface SupabasePostgresProviderOptions {
|
|
6
|
+
connectionString?: string;
|
|
7
|
+
maxConnections?: number;
|
|
8
|
+
sslMode?: SupabasePostgresSslMode;
|
|
9
|
+
client?: Sql;
|
|
10
|
+
db?: PostgresJsDatabase<Record<string, never>>;
|
|
11
|
+
createDrizzle?: (client: Sql) => PostgresJsDatabase<Record<string, never>>;
|
|
14
12
|
}
|
|
15
|
-
declare class SupabasePostgresProvider implements
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
export declare class SupabasePostgresProvider implements DatabaseProvider {
|
|
14
|
+
private readonly client;
|
|
15
|
+
private readonly db;
|
|
16
|
+
private readonly ownsClient;
|
|
17
|
+
private readonly createDrizzle;
|
|
18
|
+
constructor(options?: SupabasePostgresProviderOptions);
|
|
19
|
+
query<TRow extends DatabaseRow = DatabaseRow>(statement: string, params?: readonly DatabaseStatementParam[]): Promise<DatabaseQueryResult<TRow>>;
|
|
20
|
+
execute(statement: string, params?: readonly DatabaseStatementParam[]): Promise<void>;
|
|
21
|
+
transaction<T>(run: (database: DatabaseProvider) => Promise<T>): Promise<T>;
|
|
22
|
+
close(): Promise<void>;
|
|
25
23
|
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { SupabasePostgresProvider, SupabasePostgresProviderOptions, SupabasePostgresSslMode };
|
|
28
24
|
//# sourceMappingURL=supabase-psql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase-psql.d.ts","
|
|
1
|
+
{"version":3,"file":"supabase-psql.d.ts","sourceRoot":"","sources":["../../src/impls/supabase-psql.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAiB,EAAE,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,+BAA+B;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,EAAE,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;CAC5E;AAED,qBAAa,wBAAyB,YAAW,gBAAgB;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAM;IAC7B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA4C;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAEiB;gBAEnC,OAAO,GAAE,+BAAoC;IAmCnD,KAAK,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW,EAChD,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,SAAS,sBAAsB,EAAO,GAC7C,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAU/B,OAAO,CACX,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,SAAS,sBAAsB,EAAO,GAC7C,OAAO,CAAC,IAAI,CAAC;IAKV,WAAW,CAAC,CAAC,EACjB,GAAG,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC9C,OAAO,CAAC,CAAC,CAAC;IAYP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|