@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.
Files changed (256) hide show
  1. package/dist/analytics.d.ts +1 -8
  2. package/dist/analytics.d.ts.map +1 -1
  3. package/dist/analytics.js +3 -3
  4. package/dist/calendar.d.ts +1 -8
  5. package/dist/calendar.d.ts.map +1 -1
  6. package/dist/calendar.js +3 -3
  7. package/dist/database.d.ts +1 -8
  8. package/dist/database.d.ts.map +1 -1
  9. package/dist/database.js +3 -3
  10. package/dist/email.d.ts +1 -8
  11. package/dist/email.d.ts.map +1 -1
  12. package/dist/email.js +3 -3
  13. package/dist/embedding.d.ts +1 -8
  14. package/dist/embedding.d.ts.map +1 -1
  15. package/dist/embedding.js +3 -3
  16. package/dist/impls/elevenlabs-voice.d.ts +14 -18
  17. package/dist/impls/elevenlabs-voice.d.ts.map +1 -1
  18. package/dist/impls/elevenlabs-voice.js +98 -88
  19. package/dist/impls/fal-voice.d.ts +22 -26
  20. package/dist/impls/fal-voice.d.ts.map +1 -1
  21. package/dist/impls/fal-voice.js +103 -78
  22. package/dist/impls/fathom-meeting-recorder.d.ts +35 -39
  23. package/dist/impls/fathom-meeting-recorder.d.ts.map +1 -1
  24. package/dist/impls/fathom-meeting-recorder.js +285 -142
  25. package/dist/impls/fathom-meeting-recorder.mapper.d.ts +4 -8
  26. package/dist/impls/fathom-meeting-recorder.mapper.d.ts.map +1 -1
  27. package/dist/impls/fathom-meeting-recorder.mapper.js +102 -38
  28. package/dist/impls/fathom-meeting-recorder.types.d.ts +16 -20
  29. package/dist/impls/fathom-meeting-recorder.types.d.ts.map +1 -1
  30. package/dist/impls/fathom-meeting-recorder.types.js +1 -0
  31. package/dist/impls/fathom-meeting-recorder.utils.d.ts +10 -14
  32. package/dist/impls/fathom-meeting-recorder.utils.d.ts.map +1 -1
  33. package/dist/impls/fathom-meeting-recorder.utils.js +58 -41
  34. package/dist/impls/fathom-meeting-recorder.webhooks.d.ts +3 -7
  35. package/dist/impls/fathom-meeting-recorder.webhooks.d.ts.map +1 -1
  36. package/dist/impls/fathom-meeting-recorder.webhooks.js +25 -20
  37. package/dist/impls/fireflies-meeting-recorder.d.ts +21 -25
  38. package/dist/impls/fireflies-meeting-recorder.d.ts.map +1 -1
  39. package/dist/impls/fireflies-meeting-recorder.js +272 -149
  40. package/dist/impls/fireflies-meeting-recorder.queries.d.ts +3 -6
  41. package/dist/impls/fireflies-meeting-recorder.queries.d.ts.map +1 -1
  42. package/dist/impls/fireflies-meeting-recorder.queries.js +10 -8
  43. package/dist/impls/fireflies-meeting-recorder.types.d.ts +26 -29
  44. package/dist/impls/fireflies-meeting-recorder.types.d.ts.map +1 -1
  45. package/dist/impls/fireflies-meeting-recorder.types.js +1 -0
  46. package/dist/impls/fireflies-meeting-recorder.utils.d.ts +4 -7
  47. package/dist/impls/fireflies-meeting-recorder.utils.d.ts.map +1 -1
  48. package/dist/impls/fireflies-meeting-recorder.utils.js +34 -27
  49. package/dist/impls/gcs-storage.d.ts +18 -22
  50. package/dist/impls/gcs-storage.d.ts.map +1 -1
  51. package/dist/impls/gcs-storage.js +92 -84
  52. package/dist/impls/gmail-inbound.d.ts +20 -24
  53. package/dist/impls/gmail-inbound.d.ts.map +1 -1
  54. package/dist/impls/gmail-inbound.js +212 -185
  55. package/dist/impls/gmail-outbound.d.ts +12 -16
  56. package/dist/impls/gmail-outbound.d.ts.map +1 -1
  57. package/dist/impls/gmail-outbound.js +126 -92
  58. package/dist/impls/google-calendar.d.ts +17 -21
  59. package/dist/impls/google-calendar.d.ts.map +1 -1
  60. package/dist/impls/google-calendar.js +182 -145
  61. package/dist/impls/gradium-voice.d.ts +20 -22
  62. package/dist/impls/gradium-voice.d.ts.map +1 -1
  63. package/dist/impls/gradium-voice.js +85 -74
  64. package/dist/impls/granola-meeting-recorder.d.ts +31 -24
  65. package/dist/impls/granola-meeting-recorder.d.ts.map +1 -1
  66. package/dist/impls/granola-meeting-recorder.js +511 -143
  67. package/dist/impls/granola-meeting-recorder.mcp.d.ts +25 -0
  68. package/dist/impls/granola-meeting-recorder.mcp.d.ts.map +1 -0
  69. package/dist/impls/granola-meeting-recorder.mcp.js +279 -0
  70. package/dist/impls/granola-meeting-recorder.types.d.ts +60 -49
  71. package/dist/impls/granola-meeting-recorder.types.d.ts.map +1 -1
  72. package/dist/impls/granola-meeting-recorder.types.js +1 -0
  73. package/dist/impls/index.d.ts +28 -28
  74. package/dist/impls/index.d.ts.map +1 -0
  75. package/dist/impls/index.js +4659 -29
  76. package/dist/impls/jira.d.ts +18 -22
  77. package/dist/impls/jira.d.ts.map +1 -1
  78. package/dist/impls/jira.js +112 -101
  79. package/dist/impls/linear.d.ts +17 -21
  80. package/dist/impls/linear.d.ts.map +1 -1
  81. package/dist/impls/linear.js +78 -69
  82. package/dist/impls/mistral-embedding.d.ts +17 -21
  83. package/dist/impls/mistral-embedding.d.ts.map +1 -1
  84. package/dist/impls/mistral-embedding.js +41 -39
  85. package/dist/impls/mistral-llm.d.ts +25 -29
  86. package/dist/impls/mistral-llm.d.ts.map +1 -1
  87. package/dist/impls/mistral-llm.js +266 -244
  88. package/dist/impls/notion.d.ts +20 -24
  89. package/dist/impls/notion.d.ts.map +1 -1
  90. package/dist/impls/notion.js +145 -110
  91. package/dist/impls/posthog-reader.d.ts +18 -22
  92. package/dist/impls/posthog-reader.d.ts.map +1 -1
  93. package/dist/impls/posthog-reader.js +148 -129
  94. package/dist/impls/posthog-utils.d.ts +4 -7
  95. package/dist/impls/posthog-utils.d.ts.map +1 -1
  96. package/dist/impls/posthog-utils.js +31 -22
  97. package/dist/impls/posthog.d.ts +33 -37
  98. package/dist/impls/posthog.d.ts.map +1 -1
  99. package/dist/impls/posthog.js +320 -119
  100. package/dist/impls/postmark-email.d.ts +13 -17
  101. package/dist/impls/postmark-email.d.ts.map +1 -1
  102. package/dist/impls/postmark-email.js +55 -50
  103. package/dist/impls/powens-client.d.ts +111 -114
  104. package/dist/impls/powens-client.d.ts.map +1 -1
  105. package/dist/impls/powens-client.js +194 -170
  106. package/dist/impls/powens-openbanking.d.ts +22 -26
  107. package/dist/impls/powens-openbanking.d.ts.map +1 -1
  108. package/dist/impls/powens-openbanking.js +425 -217
  109. package/dist/impls/provider-factory.d.ts +29 -33
  110. package/dist/impls/provider-factory.d.ts.map +1 -1
  111. package/dist/impls/provider-factory.js +4072 -275
  112. package/dist/impls/qdrant-vector.d.ts +18 -22
  113. package/dist/impls/qdrant-vector.d.ts.map +1 -1
  114. package/dist/impls/qdrant-vector.js +76 -69
  115. package/dist/impls/stripe-payments.d.ts +22 -26
  116. package/dist/impls/stripe-payments.d.ts.map +1 -1
  117. package/dist/impls/stripe-payments.js +219 -193
  118. package/dist/impls/supabase-psql.d.ts +21 -25
  119. package/dist/impls/supabase-psql.d.ts.map +1 -1
  120. package/dist/impls/supabase-psql.js +138 -98
  121. package/dist/impls/supabase-vector.d.ts +29 -33
  122. package/dist/impls/supabase-vector.d.ts.map +1 -1
  123. package/dist/impls/supabase-vector.js +278 -103
  124. package/dist/impls/tldv-meeting-recorder.d.ts +18 -22
  125. package/dist/impls/tldv-meeting-recorder.d.ts.map +1 -1
  126. package/dist/impls/tldv-meeting-recorder.js +142 -127
  127. package/dist/impls/twilio-sms.d.ts +14 -17
  128. package/dist/impls/twilio-sms.d.ts.map +1 -1
  129. package/dist/impls/twilio-sms.js +62 -55
  130. package/dist/index.d.ts +15 -64
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +4700 -107
  133. package/dist/llm.d.ts +1 -8
  134. package/dist/llm.d.ts.map +1 -1
  135. package/dist/llm.js +3 -3
  136. package/dist/meeting-recorder.d.ts +1 -8
  137. package/dist/meeting-recorder.d.ts.map +1 -1
  138. package/dist/meeting-recorder.js +3 -3
  139. package/dist/node/analytics.js +2 -0
  140. package/dist/node/calendar.js +2 -0
  141. package/dist/node/database.js +2 -0
  142. package/dist/node/email.js +2 -0
  143. package/dist/node/embedding.js +2 -0
  144. package/dist/node/impls/elevenlabs-voice.js +102 -0
  145. package/dist/node/impls/fal-voice.js +112 -0
  146. package/dist/node/impls/fathom-meeting-recorder.js +287 -0
  147. package/dist/node/impls/fathom-meeting-recorder.mapper.js +105 -0
  148. package/dist/node/impls/fathom-meeting-recorder.types.js +0 -0
  149. package/dist/node/impls/fathom-meeting-recorder.utils.js +72 -0
  150. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +29 -0
  151. package/dist/node/impls/fireflies-meeting-recorder.js +274 -0
  152. package/dist/node/impls/fireflies-meeting-recorder.queries.js +85 -0
  153. package/dist/node/impls/fireflies-meeting-recorder.types.js +0 -0
  154. package/dist/node/impls/fireflies-meeting-recorder.utils.js +42 -0
  155. package/dist/node/impls/gcs-storage.js +97 -0
  156. package/dist/node/impls/gmail-inbound.js +227 -0
  157. package/dist/node/impls/gmail-outbound.js +139 -0
  158. package/dist/node/impls/google-calendar.js +191 -0
  159. package/dist/node/impls/gradium-voice.js +90 -0
  160. package/dist/node/impls/granola-meeting-recorder.js +512 -0
  161. package/dist/node/impls/granola-meeting-recorder.mcp.js +278 -0
  162. package/dist/node/impls/granola-meeting-recorder.types.js +0 -0
  163. package/dist/node/impls/index.js +4658 -0
  164. package/dist/node/impls/jira.js +124 -0
  165. package/dist/node/impls/linear.js +83 -0
  166. package/dist/node/impls/mistral-embedding.js +43 -0
  167. package/dist/node/impls/mistral-llm.js +269 -0
  168. package/dist/node/impls/notion.js +160 -0
  169. package/dist/node/impls/posthog-reader.js +159 -0
  170. package/dist/node/impls/posthog-utils.js +38 -0
  171. package/dist/node/impls/posthog.js +322 -0
  172. package/dist/node/impls/postmark-email.js +60 -0
  173. package/dist/node/impls/powens-client.js +195 -0
  174. package/dist/node/impls/powens-openbanking.js +426 -0
  175. package/dist/node/impls/provider-factory.js +4080 -0
  176. package/dist/node/impls/qdrant-vector.js +78 -0
  177. package/dist/node/impls/stripe-payments.js +228 -0
  178. package/dist/node/impls/supabase-psql.js +150 -0
  179. package/dist/node/impls/supabase-vector.js +323 -0
  180. package/dist/node/impls/tldv-meeting-recorder.js +145 -0
  181. package/dist/node/impls/twilio-sms.js +65 -0
  182. package/dist/node/index.js +4699 -0
  183. package/dist/node/llm.js +2 -0
  184. package/dist/node/meeting-recorder.js +2 -0
  185. package/dist/node/openbanking.js +2 -0
  186. package/dist/node/payments.js +2 -0
  187. package/dist/node/project-management.js +2 -0
  188. package/dist/node/runtime.js +0 -0
  189. package/dist/node/secrets/provider.js +11 -0
  190. package/dist/node/sms.js +2 -0
  191. package/dist/node/storage.js +2 -0
  192. package/dist/node/vector-store.js +2 -0
  193. package/dist/node/voice.js +2 -0
  194. package/dist/openbanking.d.ts +1 -8
  195. package/dist/openbanking.d.ts.map +1 -1
  196. package/dist/openbanking.js +3 -3
  197. package/dist/payments.d.ts +1 -8
  198. package/dist/payments.d.ts.map +1 -1
  199. package/dist/payments.js +3 -3
  200. package/dist/project-management.d.ts +1 -8
  201. package/dist/project-management.d.ts.map +1 -1
  202. package/dist/project-management.js +3 -3
  203. package/dist/runtime.d.ts +2 -2
  204. package/dist/runtime.d.ts.map +1 -0
  205. package/dist/runtime.js +1 -0
  206. package/dist/secrets/provider.d.ts +3 -2
  207. package/dist/secrets/provider.d.ts.map +1 -0
  208. package/dist/secrets/provider.js +12 -3
  209. package/dist/sms.d.ts +1 -8
  210. package/dist/sms.d.ts.map +1 -1
  211. package/dist/sms.js +3 -3
  212. package/dist/storage.d.ts +1 -8
  213. package/dist/storage.d.ts.map +1 -1
  214. package/dist/storage.js +3 -3
  215. package/dist/vector-store.d.ts +1 -8
  216. package/dist/vector-store.d.ts.map +1 -1
  217. package/dist/vector-store.js +3 -3
  218. package/dist/voice.d.ts +1 -8
  219. package/dist/voice.d.ts.map +1 -1
  220. package/dist/voice.js +3 -3
  221. package/package.json +405 -114
  222. package/dist/_virtual/_rolldown/runtime.js +0 -36
  223. package/dist/impls/elevenlabs-voice.js.map +0 -1
  224. package/dist/impls/fal-voice.js.map +0 -1
  225. package/dist/impls/fathom-meeting-recorder.js.map +0 -1
  226. package/dist/impls/fathom-meeting-recorder.mapper.js.map +0 -1
  227. package/dist/impls/fathom-meeting-recorder.utils.js.map +0 -1
  228. package/dist/impls/fathom-meeting-recorder.webhooks.js.map +0 -1
  229. package/dist/impls/fireflies-meeting-recorder.js.map +0 -1
  230. package/dist/impls/fireflies-meeting-recorder.queries.js.map +0 -1
  231. package/dist/impls/fireflies-meeting-recorder.utils.js.map +0 -1
  232. package/dist/impls/gcs-storage.js.map +0 -1
  233. package/dist/impls/gmail-inbound.js.map +0 -1
  234. package/dist/impls/gmail-outbound.js.map +0 -1
  235. package/dist/impls/google-calendar.js.map +0 -1
  236. package/dist/impls/gradium-voice.js.map +0 -1
  237. package/dist/impls/granola-meeting-recorder.js.map +0 -1
  238. package/dist/impls/jira.js.map +0 -1
  239. package/dist/impls/linear.js.map +0 -1
  240. package/dist/impls/mistral-embedding.js.map +0 -1
  241. package/dist/impls/mistral-llm.js.map +0 -1
  242. package/dist/impls/notion.js.map +0 -1
  243. package/dist/impls/posthog-reader.js.map +0 -1
  244. package/dist/impls/posthog-utils.js.map +0 -1
  245. package/dist/impls/posthog.js.map +0 -1
  246. package/dist/impls/postmark-email.js.map +0 -1
  247. package/dist/impls/powens-client.js.map +0 -1
  248. package/dist/impls/powens-openbanking.js.map +0 -1
  249. package/dist/impls/provider-factory.js.map +0 -1
  250. package/dist/impls/qdrant-vector.js.map +0 -1
  251. package/dist/impls/stripe-payments.js.map +0 -1
  252. package/dist/impls/supabase-psql.js.map +0 -1
  253. package/dist/impls/supabase-vector.js.map +0 -1
  254. package/dist/impls/tldv-meeting-recorder.js.map +0 -1
  255. package/dist/impls/twilio-sms.js.map +0 -1
  256. 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
- //#region src/impls/stripe-payments.ts
4
- const API_VERSION = "2026-01-28.clover";
5
- var StripePaymentsProvider = class {
6
- stripe;
7
- constructor(options) {
8
- this.stripe = options.stripe ?? new Stripe(options.apiKey, { apiVersion: API_VERSION });
9
- }
10
- async createCustomer(input) {
11
- const customer = await this.stripe.customers.create({
12
- email: input.email,
13
- name: input.name,
14
- description: input.description,
15
- metadata: input.metadata
16
- });
17
- return this.toCustomer(customer);
18
- }
19
- async getCustomer(customerId) {
20
- const customer = await this.stripe.customers.retrieve(customerId);
21
- if (customer.deleted) return null;
22
- return this.toCustomer(customer);
23
- }
24
- async createPaymentIntent(input) {
25
- const intent = await this.stripe.paymentIntents.create({
26
- amount: input.amount.amount,
27
- currency: input.amount.currency,
28
- customer: input.customerId,
29
- description: input.description,
30
- capture_method: input.captureMethod ?? "automatic",
31
- confirmation_method: input.confirmationMethod ?? "automatic",
32
- automatic_payment_methods: { enabled: true },
33
- metadata: input.metadata,
34
- return_url: input.returnUrl,
35
- statement_descriptor: input.statementDescriptor
36
- });
37
- return this.toPaymentIntent(intent);
38
- }
39
- async capturePayment(paymentIntentId, input) {
40
- const intent = await this.stripe.paymentIntents.capture(paymentIntentId, input?.amount ? { amount_to_capture: input.amount.amount } : void 0);
41
- return this.toPaymentIntent(intent);
42
- }
43
- async cancelPaymentIntent(paymentIntentId) {
44
- const intent = await this.stripe.paymentIntents.cancel(paymentIntentId);
45
- return this.toPaymentIntent(intent);
46
- }
47
- async refundPayment(input) {
48
- const refund = await this.stripe.refunds.create({
49
- payment_intent: input.paymentIntentId,
50
- amount: input.amount?.amount,
51
- reason: mapRefundReason(input.reason),
52
- metadata: input.metadata
53
- });
54
- const paymentIntentId = typeof refund.payment_intent === "string" ? refund.payment_intent : refund.payment_intent?.id ?? "";
55
- return {
56
- id: refund.id,
57
- paymentIntentId,
58
- amount: {
59
- amount: refund.amount ?? 0,
60
- currency: refund.currency?.toUpperCase() ?? "USD"
61
- },
62
- status: mapRefundStatus(refund.status),
63
- reason: refund.reason ?? void 0,
64
- metadata: this.toMetadata(refund.metadata),
65
- createdAt: refund.created ? /* @__PURE__ */ new Date(refund.created * 1e3) : void 0
66
- };
67
- }
68
- async listInvoices(query) {
69
- const requestedStatus = query?.status?.[0];
70
- const stripeStatus = requestedStatus && requestedStatus !== "deleted" ? requestedStatus : void 0;
71
- return (await this.stripe.invoices.list({
72
- customer: query?.customerId,
73
- status: stripeStatus,
74
- limit: query?.limit,
75
- starting_after: query?.startingAfter
76
- })).data.map((invoice) => this.toInvoice(invoice));
77
- }
78
- async listTransactions(query) {
79
- return (await this.stripe.charges.list({
80
- customer: query?.customerId,
81
- payment_intent: query?.paymentIntentId,
82
- limit: query?.limit,
83
- starting_after: query?.startingAfter
84
- })).data.map((charge) => ({
85
- id: charge.id,
86
- paymentIntentId: typeof charge.payment_intent === "string" ? charge.payment_intent : charge.payment_intent?.id,
87
- amount: {
88
- amount: charge.amount,
89
- currency: charge.currency?.toUpperCase() ?? "USD"
90
- },
91
- type: "capture",
92
- status: mapChargeStatus(charge.status),
93
- description: charge.description ?? void 0,
94
- createdAt: /* @__PURE__ */ new Date(charge.created * 1e3),
95
- metadata: this.mergeMetadata(this.toMetadata(charge.metadata), { balanceTransaction: typeof charge.balance_transaction === "string" ? charge.balance_transaction : void 0 })
96
- }));
97
- }
98
- toCustomer(customer) {
99
- const metadata = this.toMetadata(customer.metadata);
100
- const updatedAtValue = metadata?.updatedAt;
101
- return {
102
- id: customer.id,
103
- email: customer.email ?? void 0,
104
- name: customer.name ?? void 0,
105
- metadata,
106
- createdAt: customer.created ? /* @__PURE__ */ new Date(customer.created * 1e3) : void 0,
107
- updatedAt: updatedAtValue ? new Date(updatedAtValue) : void 0
108
- };
109
- }
110
- toPaymentIntent(intent) {
111
- const metadata = this.toMetadata(intent.metadata);
112
- return {
113
- id: intent.id,
114
- amount: this.toMoney(intent.amount_received ?? intent.amount ?? 0, intent.currency),
115
- status: mapPaymentIntentStatus(intent.status),
116
- customerId: typeof intent.customer === "string" ? intent.customer : intent.customer?.id,
117
- description: intent.description ?? void 0,
118
- clientSecret: intent.client_secret ?? void 0,
119
- metadata,
120
- createdAt: /* @__PURE__ */ new Date(intent.created * 1e3),
121
- updatedAt: intent.canceled_at != null ? /* @__PURE__ */ new Date(intent.canceled_at * 1e3) : /* @__PURE__ */ new Date(intent.created * 1e3)
122
- };
123
- }
124
- toInvoice(invoice) {
125
- const metadata = this.toMetadata(invoice.metadata);
126
- return {
127
- id: invoice.id,
128
- number: invoice.number ?? void 0,
129
- status: invoice.status ?? "draft",
130
- amountDue: this.toMoney(invoice.amount_due ?? 0, invoice.currency),
131
- amountPaid: this.toMoney(invoice.amount_paid ?? 0, invoice.currency),
132
- customerId: typeof invoice.customer === "string" ? invoice.customer : invoice.customer?.id,
133
- dueDate: invoice.due_date ? /* @__PURE__ */ new Date(invoice.due_date * 1e3) : void 0,
134
- hostedInvoiceUrl: invoice.hosted_invoice_url ?? void 0,
135
- metadata,
136
- createdAt: invoice.created ? /* @__PURE__ */ new Date(invoice.created * 1e3) : void 0,
137
- updatedAt: invoice.status_transitions?.finalized_at ? /* @__PURE__ */ new Date(invoice.status_transitions.finalized_at * 1e3) : void 0
138
- };
139
- }
140
- toMoney(amount, currency) {
141
- return {
142
- amount,
143
- currency: currency?.toUpperCase() ?? "USD"
144
- };
145
- }
146
- toMetadata(metadata) {
147
- if (!metadata) return void 0;
148
- const entries = Object.entries(metadata).filter((entry) => typeof entry[1] === "string");
149
- if (entries.length === 0) return void 0;
150
- return Object.fromEntries(entries);
151
- }
152
- mergeMetadata(base, extras) {
153
- const filteredExtras = Object.entries(extras).filter((entry) => typeof entry[1] === "string");
154
- if (!base && filteredExtras.length === 0) return;
155
- return {
156
- ...base ?? {},
157
- ...Object.fromEntries(filteredExtras)
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
- if (!reason) return void 0;
163
- return [
164
- "duplicate",
165
- "fraudulent",
166
- "requested_by_customer"
167
- ].includes(reason) ? reason : void 0;
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
- switch (status) {
171
- case "requires_payment_method": return "requires_payment_method";
172
- case "requires_confirmation": return "requires_confirmation";
173
- case "requires_action":
174
- case "requires_capture": return "requires_action";
175
- case "processing": return "processing";
176
- case "succeeded": return "succeeded";
177
- case "canceled": return "canceled";
178
- default: return "requires_payment_method";
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
- switch (status) {
183
- case "pending":
184
- case "succeeded":
185
- case "failed":
186
- case "canceled": return status;
187
- default: return "pending";
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
- switch (status) {
192
- case "pending":
193
- case "processing": return "pending";
194
- case "succeeded": return "succeeded";
195
- case "failed":
196
- case "canceled": return "failed";
197
- default: return "pending";
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
- //#endregion
202
- export { StripePaymentsProvider };
203
- //# sourceMappingURL=stripe-payments.js.map
227
+ export {
228
+ StripePaymentsProvider
229
+ };
@@ -1,28 +1,24 @@
1
- import { database_d_exports } from "../database.js";
2
- import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
3
- import { Sql } from "postgres";
4
-
5
- //#region src/impls/supabase-psql.d.ts
6
- type SupabasePostgresSslMode = 'require' | 'allow' | 'prefer';
7
- interface SupabasePostgresProviderOptions {
8
- connectionString?: string;
9
- maxConnections?: number;
10
- sslMode?: SupabasePostgresSslMode;
11
- client?: Sql;
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 database_d_exports.DatabaseProvider {
16
- private readonly client;
17
- private readonly db;
18
- private readonly ownsClient;
19
- private readonly createDrizzle;
20
- constructor(options?: SupabasePostgresProviderOptions);
21
- query<TRow extends database_d_exports.DatabaseRow = database_d_exports.DatabaseRow>(statement: string, params?: readonly database_d_exports.DatabaseStatementParam[]): Promise<database_d_exports.DatabaseQueryResult<TRow>>;
22
- execute(statement: string, params?: readonly database_d_exports.DatabaseStatementParam[]): Promise<void>;
23
- transaction<T>(run: (database: database_d_exports.DatabaseProvider) => Promise<T>): Promise<T>;
24
- close(): Promise<void>;
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","names":[],"sources":["../../src/impls/supabase-psql.ts"],"mappings":";;;;;KAaY,uBAAA;AAAA,UAEK,+BAAA;EACf,gBAAA;EACA,cAAA;EACA,OAAA,GAAU,uBAAA;EACV,MAAA,GAAS,GAAA;EACT,EAAA,GAAK,kBAAA,CAAmB,MAAA;EACxB,aAAA,IAAiB,MAAA,EAAQ,GAAA,KAAQ,kBAAA,CAAmB,MAAA;AAAA;AAAA,cAGzC,wBAAA,YAAoC,kBAAA,CAAA,gBAAA;EAAA,iBAC9B,MAAA;EAAA,iBACA,EAAA;EAAA,iBACA,UAAA;EAAA,iBACA,aAAA;cAIL,OAAA,GAAS,+BAAA;EAmCf,KAAA,cAAmB,kBAAA,CAAA,WAAA,GAAc,kBAAA,CAAA,WAAA,CAAA,CACrC,SAAA,UACA,MAAA,YAAiB,kBAAA,CAAA,sBAAA,KAChB,OAAA,CAAQ,kBAAA,CAAA,mBAAA,CAAoB,IAAA;EAUzB,OAAA,CACJ,SAAA,UACA,MAAA,YAAiB,kBAAA,CAAA,sBAAA,KAChB,OAAA;EAKG,WAAA,GAAA,CACJ,GAAA,GAAM,QAAA,EAAU,kBAAA,CAAA,gBAAA,KAAqB,OAAA,CAAQ,CAAA,IAC5C,OAAA,CAAQ,CAAA;EAYL,KAAA,CAAA,GAAS,OAAA;AAAA"}
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"}