@contractspec/integration.providers-impls 3.8.9 → 3.8.11
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.js +1 -2
- package/dist/calendar.js +1 -2
- package/dist/database.js +1 -2
- package/dist/email.js +1 -2
- package/dist/embedding.js +1 -2
- package/dist/health.js +1 -2
- package/dist/impls/async-event-queue.js +1 -48
- package/dist/impls/composio-fallback-resolver.js +1 -579
- package/dist/impls/composio-mcp.js +1 -163
- package/dist/impls/composio-proxies.js +1 -310
- package/dist/impls/composio-sdk.js +1 -77
- package/dist/impls/composio-types.js +1 -53
- package/dist/impls/elevenlabs-voice.js +1 -104
- package/dist/impls/fal-voice.js +1 -117
- package/dist/impls/fathom-meeting-recorder.js +2 -289
- package/dist/impls/fathom-meeting-recorder.mapper.js +1 -107
- package/dist/impls/fathom-meeting-recorder.utils.js +1 -74
- package/dist/impls/fathom-meeting-recorder.webhooks.js +1 -31
- package/dist/impls/fireflies-meeting-recorder.js +5 -203
- package/dist/impls/fireflies-meeting-recorder.queries.js +4 -14
- package/dist/impls/fireflies-meeting-recorder.utils.js +1 -44
- package/dist/impls/gcs-storage.js +1 -99
- package/dist/impls/gmail-inbound.js +1 -229
- package/dist/impls/gmail-outbound.js +25 -137
- package/dist/impls/google-calendar.js +1 -193
- package/dist/impls/gradium-voice.js +1 -95
- package/dist/impls/granola-meeting-recorder.js +3 -514
- package/dist/impls/granola-meeting-recorder.mcp.js +1 -280
- package/dist/impls/health/base-health-provider.js +1 -617
- package/dist/impls/health/hybrid-health-providers.js +1 -1089
- package/dist/impls/health/official-health-providers.js +1 -969
- package/dist/impls/health/provider-normalizers.js +1 -288
- package/dist/impls/health/providers.js +1 -1095
- package/dist/impls/health-provider-factory.js +1 -1309
- package/dist/impls/index.js +42 -7448
- package/dist/impls/jira.js +1 -126
- package/dist/impls/linear.js +1 -85
- package/dist/impls/messaging-github.js +1 -111
- package/dist/impls/messaging-slack.js +1 -81
- package/dist/impls/messaging-telegram.js +1 -48
- package/dist/impls/messaging-whatsapp-meta.js +1 -53
- package/dist/impls/messaging-whatsapp-twilio.js +1 -83
- package/dist/impls/mistral-conversational.js +2 -477
- package/dist/impls/mistral-conversational.session.js +2 -207
- package/dist/impls/mistral-embedding.js +1 -45
- package/dist/impls/mistral-llm.js +1 -271
- package/dist/impls/mistral-stt.js +1 -168
- package/dist/impls/notion.js +1 -162
- package/dist/impls/posthog-reader.js +1 -161
- package/dist/impls/posthog-utils.js +1 -40
- package/dist/impls/posthog.js +1 -324
- package/dist/impls/postmark-email.js +1 -62
- package/dist/impls/powens-client.js +1 -197
- package/dist/impls/powens-openbanking.js +1 -428
- package/dist/impls/provider-factory.js +18 -6268
- package/dist/impls/qdrant-vector.js +1 -80
- package/dist/impls/stripe-payments.js +1 -230
- package/dist/impls/supabase-psql.js +1 -152
- package/dist/impls/supabase-vector.js +9 -298
- package/dist/impls/tldv-meeting-recorder.js +2 -147
- package/dist/impls/twilio-sms.js +1 -67
- package/dist/index.js +42 -7495
- package/dist/llm.js +1 -2
- package/dist/meeting-recorder.js +1 -2
- package/dist/messaging.js +1 -2
- package/dist/node/analytics.js +1 -2
- package/dist/node/calendar.js +1 -2
- package/dist/node/database.js +1 -2
- package/dist/node/email.js +1 -2
- package/dist/node/embedding.js +1 -2
- package/dist/node/health.js +1 -2
- package/dist/node/impls/async-event-queue.js +1 -49
- package/dist/node/impls/composio-fallback-resolver.js +1 -580
- package/dist/node/impls/composio-mcp.js +1 -164
- package/dist/node/impls/composio-proxies.js +1 -311
- package/dist/node/impls/composio-sdk.js +1 -78
- package/dist/node/impls/composio-types.js +1 -54
- package/dist/node/impls/elevenlabs-voice.js +1 -105
- package/dist/node/impls/fal-voice.js +1 -118
- package/dist/node/impls/fathom-meeting-recorder.js +2 -290
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +1 -108
- package/dist/node/impls/fathom-meeting-recorder.utils.js +1 -75
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +1 -32
- package/dist/node/impls/fireflies-meeting-recorder.js +5 -204
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +4 -15
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +1 -45
- package/dist/node/impls/gcs-storage.js +1 -100
- package/dist/node/impls/gmail-inbound.js +1 -230
- package/dist/node/impls/gmail-outbound.js +25 -138
- package/dist/node/impls/google-calendar.js +1 -194
- package/dist/node/impls/gradium-voice.js +1 -96
- package/dist/node/impls/granola-meeting-recorder.js +3 -515
- package/dist/node/impls/granola-meeting-recorder.mcp.js +1 -281
- package/dist/node/impls/health/base-health-provider.js +1 -618
- package/dist/node/impls/health/hybrid-health-providers.js +1 -1090
- package/dist/node/impls/health/official-health-providers.js +1 -970
- package/dist/node/impls/health/provider-normalizers.js +1 -289
- package/dist/node/impls/health/providers.js +1 -1096
- package/dist/node/impls/health-provider-factory.js +1 -1310
- package/dist/node/impls/index.js +42 -7449
- package/dist/node/impls/jira.js +1 -127
- package/dist/node/impls/linear.js +1 -86
- package/dist/node/impls/messaging-github.js +1 -112
- package/dist/node/impls/messaging-slack.js +1 -82
- package/dist/node/impls/messaging-telegram.js +1 -49
- package/dist/node/impls/messaging-whatsapp-meta.js +1 -54
- package/dist/node/impls/messaging-whatsapp-twilio.js +1 -84
- package/dist/node/impls/mistral-conversational.js +2 -478
- package/dist/node/impls/mistral-conversational.session.js +2 -208
- package/dist/node/impls/mistral-embedding.js +1 -46
- package/dist/node/impls/mistral-llm.js +1 -272
- package/dist/node/impls/mistral-stt.js +1 -169
- package/dist/node/impls/notion.js +1 -163
- package/dist/node/impls/posthog-reader.js +1 -162
- package/dist/node/impls/posthog-utils.js +1 -41
- package/dist/node/impls/posthog.js +1 -325
- package/dist/node/impls/postmark-email.js +1 -63
- package/dist/node/impls/powens-client.js +1 -198
- package/dist/node/impls/powens-openbanking.js +1 -429
- package/dist/node/impls/provider-factory.js +18 -6269
- package/dist/node/impls/qdrant-vector.js +1 -81
- package/dist/node/impls/stripe-payments.js +1 -231
- package/dist/node/impls/supabase-psql.js +1 -153
- package/dist/node/impls/supabase-vector.js +9 -299
- package/dist/node/impls/tldv-meeting-recorder.js +2 -148
- package/dist/node/impls/twilio-sms.js +1 -68
- package/dist/node/index.js +42 -7496
- package/dist/node/llm.js +1 -2
- package/dist/node/meeting-recorder.js +1 -2
- package/dist/node/messaging.js +1 -2
- package/dist/node/openbanking.js +1 -2
- package/dist/node/payments.js +1 -2
- package/dist/node/project-management.js +1 -2
- package/dist/node/secrets/provider.js +1 -14
- package/dist/node/sms.js +1 -2
- package/dist/node/storage.js +1 -2
- package/dist/node/vector-store.js +1 -2
- package/dist/node/voice.js +1 -2
- package/dist/openbanking.js +1 -2
- package/dist/payments.js +1 -2
- package/dist/project-management.js +1 -2
- package/dist/secrets/provider.js +1 -13
- package/dist/sms.js +1 -2
- package/dist/storage.js +1 -2
- package/dist/vector-store.js +1 -2
- package/dist/voice.js +1 -2
- package/package.json +16 -16
|
@@ -1,81 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/impls/qdrant-vector.ts
|
|
5
|
-
import { QdrantClient } from "@qdrant/js-client-rest";
|
|
6
|
-
|
|
7
|
-
class QdrantVectorProvider {
|
|
8
|
-
client;
|
|
9
|
-
createCollectionIfMissing;
|
|
10
|
-
distance;
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.client = options.client ?? new QdrantClient({
|
|
13
|
-
url: options.url,
|
|
14
|
-
apiKey: options.apiKey,
|
|
15
|
-
...options.clientParams
|
|
16
|
-
});
|
|
17
|
-
this.createCollectionIfMissing = options.createCollectionIfMissing ?? true;
|
|
18
|
-
this.distance = options.distance ?? "Cosine";
|
|
19
|
-
}
|
|
20
|
-
async upsert(request) {
|
|
21
|
-
if (request.documents.length === 0)
|
|
22
|
-
return;
|
|
23
|
-
const firstDocument = request.documents[0];
|
|
24
|
-
if (!firstDocument)
|
|
25
|
-
return;
|
|
26
|
-
const vectorSize = firstDocument.vector.length;
|
|
27
|
-
if (this.createCollectionIfMissing) {
|
|
28
|
-
await this.ensureCollection(request.collection, vectorSize);
|
|
29
|
-
}
|
|
30
|
-
const points = request.documents.map((document) => ({
|
|
31
|
-
id: document.id,
|
|
32
|
-
vector: document.vector,
|
|
33
|
-
payload: {
|
|
34
|
-
...document.payload,
|
|
35
|
-
...document.namespace ? { namespace: document.namespace } : {},
|
|
36
|
-
...document.expiresAt ? { expiresAt: document.expiresAt.toISOString() } : {}
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
await this.client.upsert(request.collection, {
|
|
40
|
-
wait: true,
|
|
41
|
-
points
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
async search(query) {
|
|
45
|
-
const results = await this.client.search(query.collection, {
|
|
46
|
-
vector: query.vector,
|
|
47
|
-
limit: query.topK,
|
|
48
|
-
filter: query.filter,
|
|
49
|
-
score_threshold: query.scoreThreshold,
|
|
50
|
-
with_payload: true,
|
|
51
|
-
with_vector: false
|
|
52
|
-
});
|
|
53
|
-
return results.map((item) => ({
|
|
54
|
-
id: String(item.id),
|
|
55
|
-
score: item.score,
|
|
56
|
-
payload: item.payload ?? undefined,
|
|
57
|
-
namespace: typeof item.payload === "object" && item.payload !== null ? item.payload.namespace : undefined
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
async delete(request) {
|
|
61
|
-
await this.client.delete(request.collection, {
|
|
62
|
-
wait: true,
|
|
63
|
-
points: request.ids
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
async ensureCollection(collectionName, vectorSize) {
|
|
67
|
-
try {
|
|
68
|
-
await this.client.getCollection(collectionName);
|
|
69
|
-
} catch (_error) {
|
|
70
|
-
await this.client.createCollection(collectionName, {
|
|
71
|
-
vectors: {
|
|
72
|
-
size: vectorSize,
|
|
73
|
-
distance: this.distance
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export {
|
|
80
|
-
QdrantVectorProvider
|
|
81
|
-
};
|
|
2
|
+
var s=import.meta.require;import{QdrantClient as n}from"@qdrant/js-client-rest";class o{client;createCollectionIfMissing;distance;constructor(e){this.client=e.client??new n({url:e.url,apiKey:e.apiKey,...e.clientParams}),this.createCollectionIfMissing=e.createCollectionIfMissing??!0,this.distance=e.distance??"Cosine"}async upsert(e){if(e.documents.length===0)return;let i=e.documents[0];if(!i)return;let t=i.vector.length;if(this.createCollectionIfMissing)await this.ensureCollection(e.collection,t);let a=e.documents.map((r)=>({id:r.id,vector:r.vector,payload:{...r.payload,...r.namespace?{namespace:r.namespace}:{},...r.expiresAt?{expiresAt:r.expiresAt.toISOString()}:{}}}));await this.client.upsert(e.collection,{wait:!0,points:a})}async search(e){return(await this.client.search(e.collection,{vector:e.vector,limit:e.topK,filter:e.filter,score_threshold:e.scoreThreshold,with_payload:!0,with_vector:!1})).map((t)=>({id:String(t.id),score:t.score,payload:t.payload??void 0,namespace:typeof t.payload==="object"&&t.payload!==null?t.payload.namespace:void 0}))}async delete(e){await this.client.delete(e.collection,{wait:!0,points:e.ids})}async ensureCollection(e,i){try{await this.client.getCollection(e)}catch(t){await this.client.createCollection(e,{vectors:{size:i,distance:this.distance}})}}}export{o as QdrantVectorProvider};
|
|
@@ -1,231 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/impls/stripe-payments.ts
|
|
5
|
-
import Stripe from "stripe";
|
|
6
|
-
var API_VERSION = "2026-02-25.clover";
|
|
7
|
-
|
|
8
|
-
class StripePaymentsProvider {
|
|
9
|
-
stripe;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.stripe = options.stripe ?? new Stripe(options.apiKey, {
|
|
12
|
-
apiVersion: API_VERSION
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async createCustomer(input) {
|
|
16
|
-
const customer = await this.stripe.customers.create({
|
|
17
|
-
email: input.email,
|
|
18
|
-
name: input.name,
|
|
19
|
-
description: input.description,
|
|
20
|
-
metadata: input.metadata
|
|
21
|
-
});
|
|
22
|
-
return this.toCustomer(customer);
|
|
23
|
-
}
|
|
24
|
-
async getCustomer(customerId) {
|
|
25
|
-
const customer = await this.stripe.customers.retrieve(customerId);
|
|
26
|
-
if (customer.deleted)
|
|
27
|
-
return null;
|
|
28
|
-
return this.toCustomer(customer);
|
|
29
|
-
}
|
|
30
|
-
async createPaymentIntent(input) {
|
|
31
|
-
const intent = await this.stripe.paymentIntents.create({
|
|
32
|
-
amount: input.amount.amount,
|
|
33
|
-
currency: input.amount.currency,
|
|
34
|
-
customer: input.customerId,
|
|
35
|
-
description: input.description,
|
|
36
|
-
capture_method: input.captureMethod ?? "automatic",
|
|
37
|
-
confirmation_method: input.confirmationMethod ?? "automatic",
|
|
38
|
-
automatic_payment_methods: { enabled: true },
|
|
39
|
-
metadata: input.metadata,
|
|
40
|
-
return_url: input.returnUrl,
|
|
41
|
-
statement_descriptor: input.statementDescriptor
|
|
42
|
-
});
|
|
43
|
-
return this.toPaymentIntent(intent);
|
|
44
|
-
}
|
|
45
|
-
async capturePayment(paymentIntentId, input) {
|
|
46
|
-
const intent = await this.stripe.paymentIntents.capture(paymentIntentId, input?.amount ? { amount_to_capture: input.amount.amount } : undefined);
|
|
47
|
-
return this.toPaymentIntent(intent);
|
|
48
|
-
}
|
|
49
|
-
async cancelPaymentIntent(paymentIntentId) {
|
|
50
|
-
const intent = await this.stripe.paymentIntents.cancel(paymentIntentId);
|
|
51
|
-
return this.toPaymentIntent(intent);
|
|
52
|
-
}
|
|
53
|
-
async refundPayment(input) {
|
|
54
|
-
const refund = await this.stripe.refunds.create({
|
|
55
|
-
payment_intent: input.paymentIntentId,
|
|
56
|
-
amount: input.amount?.amount,
|
|
57
|
-
reason: mapRefundReason(input.reason),
|
|
58
|
-
metadata: input.metadata
|
|
59
|
-
});
|
|
60
|
-
const paymentIntentId = typeof refund.payment_intent === "string" ? refund.payment_intent : refund.payment_intent?.id ?? "";
|
|
61
|
-
return {
|
|
62
|
-
id: refund.id,
|
|
63
|
-
paymentIntentId,
|
|
64
|
-
amount: {
|
|
65
|
-
amount: refund.amount ?? 0,
|
|
66
|
-
currency: refund.currency?.toUpperCase() ?? "USD"
|
|
67
|
-
},
|
|
68
|
-
status: mapRefundStatus(refund.status),
|
|
69
|
-
reason: refund.reason ?? undefined,
|
|
70
|
-
metadata: this.toMetadata(refund.metadata),
|
|
71
|
-
createdAt: refund.created ? new Date(refund.created * 1000) : undefined
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
async listInvoices(query) {
|
|
75
|
-
const requestedStatus = query?.status?.[0];
|
|
76
|
-
const stripeStatus = requestedStatus && requestedStatus !== "deleted" ? requestedStatus : undefined;
|
|
77
|
-
const response = await this.stripe.invoices.list({
|
|
78
|
-
customer: query?.customerId,
|
|
79
|
-
status: stripeStatus,
|
|
80
|
-
limit: query?.limit,
|
|
81
|
-
starting_after: query?.startingAfter
|
|
82
|
-
});
|
|
83
|
-
return response.data.map((invoice) => this.toInvoice(invoice));
|
|
84
|
-
}
|
|
85
|
-
async listTransactions(query) {
|
|
86
|
-
const response = await this.stripe.charges.list({
|
|
87
|
-
customer: query?.customerId,
|
|
88
|
-
payment_intent: query?.paymentIntentId,
|
|
89
|
-
limit: query?.limit,
|
|
90
|
-
starting_after: query?.startingAfter
|
|
91
|
-
});
|
|
92
|
-
return response.data.map((charge) => ({
|
|
93
|
-
id: charge.id,
|
|
94
|
-
paymentIntentId: typeof charge.payment_intent === "string" ? charge.payment_intent : charge.payment_intent?.id,
|
|
95
|
-
amount: {
|
|
96
|
-
amount: charge.amount,
|
|
97
|
-
currency: charge.currency?.toUpperCase() ?? "USD"
|
|
98
|
-
},
|
|
99
|
-
type: "capture",
|
|
100
|
-
status: mapChargeStatus(charge.status),
|
|
101
|
-
description: charge.description ?? undefined,
|
|
102
|
-
createdAt: new Date(charge.created * 1000),
|
|
103
|
-
metadata: this.mergeMetadata(this.toMetadata(charge.metadata), {
|
|
104
|
-
balanceTransaction: typeof charge.balance_transaction === "string" ? charge.balance_transaction : undefined
|
|
105
|
-
})
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
toCustomer(customer) {
|
|
109
|
-
const metadata = this.toMetadata(customer.metadata);
|
|
110
|
-
const updatedAtValue = metadata?.updatedAt;
|
|
111
|
-
return {
|
|
112
|
-
id: customer.id,
|
|
113
|
-
email: customer.email ?? undefined,
|
|
114
|
-
name: customer.name ?? undefined,
|
|
115
|
-
metadata,
|
|
116
|
-
createdAt: customer.created ? new Date(customer.created * 1000) : undefined,
|
|
117
|
-
updatedAt: updatedAtValue ? new Date(updatedAtValue) : undefined
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
toPaymentIntent(intent) {
|
|
121
|
-
const metadata = this.toMetadata(intent.metadata);
|
|
122
|
-
return {
|
|
123
|
-
id: intent.id,
|
|
124
|
-
amount: this.toMoney(intent.amount_received ?? intent.amount ?? 0, intent.currency),
|
|
125
|
-
status: mapPaymentIntentStatus(intent.status),
|
|
126
|
-
customerId: typeof intent.customer === "string" ? intent.customer : intent.customer?.id,
|
|
127
|
-
description: intent.description ?? undefined,
|
|
128
|
-
clientSecret: intent.client_secret ?? undefined,
|
|
129
|
-
metadata,
|
|
130
|
-
createdAt: new Date(intent.created * 1000),
|
|
131
|
-
updatedAt: intent.canceled_at != null ? new Date(intent.canceled_at * 1000) : new Date(intent.created * 1000)
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
toInvoice(invoice) {
|
|
135
|
-
const metadata = this.toMetadata(invoice.metadata);
|
|
136
|
-
return {
|
|
137
|
-
id: invoice.id,
|
|
138
|
-
number: invoice.number ?? undefined,
|
|
139
|
-
status: invoice.status ?? "draft",
|
|
140
|
-
amountDue: this.toMoney(invoice.amount_due ?? 0, invoice.currency),
|
|
141
|
-
amountPaid: this.toMoney(invoice.amount_paid ?? 0, invoice.currency),
|
|
142
|
-
customerId: typeof invoice.customer === "string" ? invoice.customer : invoice.customer?.id,
|
|
143
|
-
dueDate: invoice.due_date ? new Date(invoice.due_date * 1000) : undefined,
|
|
144
|
-
hostedInvoiceUrl: invoice.hosted_invoice_url ?? undefined,
|
|
145
|
-
metadata,
|
|
146
|
-
createdAt: invoice.created ? new Date(invoice.created * 1000) : undefined,
|
|
147
|
-
updatedAt: invoice.status_transitions?.finalized_at ? new Date(invoice.status_transitions.finalized_at * 1000) : undefined
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
toMoney(amount, currency) {
|
|
151
|
-
return {
|
|
152
|
-
amount,
|
|
153
|
-
currency: currency?.toUpperCase() ?? "USD"
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
toMetadata(metadata) {
|
|
157
|
-
if (!metadata)
|
|
158
|
-
return;
|
|
159
|
-
const entries = Object.entries(metadata).filter((entry) => typeof entry[1] === "string");
|
|
160
|
-
if (entries.length === 0)
|
|
161
|
-
return;
|
|
162
|
-
return Object.fromEntries(entries);
|
|
163
|
-
}
|
|
164
|
-
mergeMetadata(base, extras) {
|
|
165
|
-
const filteredExtras = Object.entries(extras).filter((entry) => typeof entry[1] === "string");
|
|
166
|
-
if (!base && filteredExtras.length === 0) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
...base ?? {},
|
|
171
|
-
...Object.fromEntries(filteredExtras)
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function mapRefundReason(reason) {
|
|
176
|
-
if (!reason)
|
|
177
|
-
return;
|
|
178
|
-
const allowed = [
|
|
179
|
-
"duplicate",
|
|
180
|
-
"fraudulent",
|
|
181
|
-
"requested_by_customer"
|
|
182
|
-
];
|
|
183
|
-
return allowed.includes(reason) ? reason : undefined;
|
|
184
|
-
}
|
|
185
|
-
function mapPaymentIntentStatus(status) {
|
|
186
|
-
switch (status) {
|
|
187
|
-
case "requires_payment_method":
|
|
188
|
-
return "requires_payment_method";
|
|
189
|
-
case "requires_confirmation":
|
|
190
|
-
return "requires_confirmation";
|
|
191
|
-
case "requires_action":
|
|
192
|
-
case "requires_capture":
|
|
193
|
-
return "requires_action";
|
|
194
|
-
case "processing":
|
|
195
|
-
return "processing";
|
|
196
|
-
case "succeeded":
|
|
197
|
-
return "succeeded";
|
|
198
|
-
case "canceled":
|
|
199
|
-
return "canceled";
|
|
200
|
-
default:
|
|
201
|
-
return "requires_payment_method";
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function mapRefundStatus(status) {
|
|
205
|
-
switch (status) {
|
|
206
|
-
case "pending":
|
|
207
|
-
case "succeeded":
|
|
208
|
-
case "failed":
|
|
209
|
-
case "canceled":
|
|
210
|
-
return status;
|
|
211
|
-
default:
|
|
212
|
-
return "pending";
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function mapChargeStatus(status) {
|
|
216
|
-
switch (status) {
|
|
217
|
-
case "pending":
|
|
218
|
-
case "processing":
|
|
219
|
-
return "pending";
|
|
220
|
-
case "succeeded":
|
|
221
|
-
return "succeeded";
|
|
222
|
-
case "failed":
|
|
223
|
-
case "canceled":
|
|
224
|
-
return "failed";
|
|
225
|
-
default:
|
|
226
|
-
return "pending";
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
export {
|
|
230
|
-
StripePaymentsProvider
|
|
231
|
-
};
|
|
2
|
+
var c=import.meta.require;import s from"stripe";class i{stripe;constructor(t){this.stripe=t.stripe??new s(t.apiKey,{apiVersion:"2026-03-25.dahlia"})}async createCustomer(t){let e=await this.stripe.customers.create({email:t.email,name:t.name,description:t.description,metadata:t.metadata});return this.toCustomer(e)}async getCustomer(t){let e=await this.stripe.customers.retrieve(t);if(e.deleted)return null;return this.toCustomer(e)}async createPaymentIntent(t){let e=await this.stripe.paymentIntents.create({amount:t.amount.amount,currency:t.amount.currency,customer:t.customerId,description:t.description,capture_method:t.captureMethod??"automatic",confirmation_method:t.confirmationMethod??"automatic",automatic_payment_methods:{enabled:!0},metadata:t.metadata,return_url:t.returnUrl,statement_descriptor:t.statementDescriptor});return this.toPaymentIntent(e)}async capturePayment(t,e){let n=await this.stripe.paymentIntents.capture(t,e?.amount?{amount_to_capture:e.amount.amount}:void 0);return this.toPaymentIntent(n)}async cancelPaymentIntent(t){let e=await this.stripe.paymentIntents.cancel(t);return this.toPaymentIntent(e)}async refundPayment(t){let e=await this.stripe.refunds.create({payment_intent:t.paymentIntentId,amount:t.amount?.amount,reason:d(t.reason),metadata:t.metadata}),n=typeof e.payment_intent==="string"?e.payment_intent:e.payment_intent?.id??"";return{id:e.id,paymentIntentId:n,amount:{amount:e.amount??0,currency:e.currency?.toUpperCase()??"USD"},status:o(e.status),reason:e.reason??void 0,metadata:this.toMetadata(e.metadata),createdAt:e.created?new Date(e.created*1000):void 0}}async listInvoices(t){let e=t?.status?.[0],n=e&&e!=="deleted"?e:void 0;return(await this.stripe.invoices.list({customer:t?.customerId,status:n,limit:t?.limit,starting_after:t?.startingAfter})).data.map((r)=>this.toInvoice(r))}async listTransactions(t){return(await this.stripe.charges.list({customer:t?.customerId,payment_intent:t?.paymentIntentId,limit:t?.limit,starting_after:t?.startingAfter})).data.map((n)=>({id:n.id,paymentIntentId:typeof n.payment_intent==="string"?n.payment_intent:n.payment_intent?.id,amount:{amount:n.amount,currency:n.currency?.toUpperCase()??"USD"},type:"capture",status:m(n.status),description:n.description??void 0,createdAt:new Date(n.created*1000),metadata:this.mergeMetadata(this.toMetadata(n.metadata),{balanceTransaction:typeof n.balance_transaction==="string"?n.balance_transaction:void 0})}))}toCustomer(t){let e=this.toMetadata(t.metadata),n=e?.updatedAt;return{id:t.id,email:t.email??void 0,name:t.name??void 0,metadata:e,createdAt:t.created?new Date(t.created*1000):void 0,updatedAt:n?new Date(n):void 0}}toPaymentIntent(t){let e=this.toMetadata(t.metadata);return{id:t.id,amount:this.toMoney(t.amount_received??t.amount??0,t.currency),status:u(t.status),customerId:typeof t.customer==="string"?t.customer:t.customer?.id,description:t.description??void 0,clientSecret:t.client_secret??void 0,metadata:e,createdAt:new Date(t.created*1000),updatedAt:t.canceled_at!=null?new Date(t.canceled_at*1000):new Date(t.created*1000)}}toInvoice(t){let e=this.toMetadata(t.metadata);return{id:t.id,number:t.number??void 0,status:t.status??"draft",amountDue:this.toMoney(t.amount_due??0,t.currency),amountPaid:this.toMoney(t.amount_paid??0,t.currency),customerId:typeof t.customer==="string"?t.customer:t.customer?.id,dueDate:t.due_date?new Date(t.due_date*1000):void 0,hostedInvoiceUrl:t.hosted_invoice_url??void 0,metadata:e,createdAt:t.created?new Date(t.created*1000):void 0,updatedAt:t.status_transitions?.finalized_at?new Date(t.status_transitions.finalized_at*1000):void 0}}toMoney(t,e){return{amount:t,currency:e?.toUpperCase()??"USD"}}toMetadata(t){if(!t)return;let e=Object.entries(t).filter((n)=>typeof n[1]==="string");if(e.length===0)return;return Object.fromEntries(e)}mergeMetadata(t,e){let n=Object.entries(e).filter((a)=>typeof a[1]==="string");if(!t&&n.length===0)return;return{...t??{},...Object.fromEntries(n)}}}function d(t){if(!t)return;return["duplicate","fraudulent","requested_by_customer"].includes(t)?t:void 0}function u(t){switch(t){case"requires_payment_method":return"requires_payment_method";case"requires_confirmation":return"requires_confirmation";case"requires_action":case"requires_capture":return"requires_action";case"processing":return"processing";case"succeeded":return"succeeded";case"canceled":return"canceled";default:return"requires_payment_method"}}function o(t){switch(t){case"pending":case"succeeded":case"failed":case"canceled":return t;default:return"pending"}}function m(t){switch(t){case"pending":case"processing":return"pending";case"succeeded":return"succeeded";case"failed":case"canceled":return"failed";default:return"pending"}}export{i as StripePaymentsProvider};
|
|
@@ -1,153 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
// src/impls/supabase-psql.ts
|
|
5
|
-
import { Buffer } from "buffer";
|
|
6
|
-
import { sql as drizzleSql } from "drizzle-orm";
|
|
7
|
-
import { drizzle } from "drizzle-orm/postgres-js";
|
|
8
|
-
import postgres from "postgres";
|
|
9
|
-
|
|
10
|
-
class SupabasePostgresProvider {
|
|
11
|
-
client;
|
|
12
|
-
db;
|
|
13
|
-
ownsClient;
|
|
14
|
-
createDrizzle;
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
this.createDrizzle = options.createDrizzle ?? ((client) => drizzle(client));
|
|
17
|
-
if (options.db) {
|
|
18
|
-
if (!options.client) {
|
|
19
|
-
throw new Error("SupabasePostgresProvider requires a postgres client when db is provided.");
|
|
20
|
-
}
|
|
21
|
-
this.client = options.client;
|
|
22
|
-
this.db = options.db;
|
|
23
|
-
this.ownsClient = false;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (options.client) {
|
|
27
|
-
this.client = options.client;
|
|
28
|
-
this.ownsClient = false;
|
|
29
|
-
} else {
|
|
30
|
-
if (!options.connectionString) {
|
|
31
|
-
throw new Error("SupabasePostgresProvider requires either a connectionString or a client.");
|
|
32
|
-
}
|
|
33
|
-
this.client = postgres(options.connectionString, {
|
|
34
|
-
max: options.maxConnections,
|
|
35
|
-
prepare: false,
|
|
36
|
-
ssl: resolveSslMode(options.sslMode)
|
|
37
|
-
});
|
|
38
|
-
this.ownsClient = true;
|
|
39
|
-
}
|
|
40
|
-
this.db = this.createDrizzle(this.client);
|
|
41
|
-
}
|
|
42
|
-
async query(statement, params = []) {
|
|
43
|
-
const query = buildParameterizedSql(statement, params);
|
|
44
|
-
const result = await this.db.execute(query);
|
|
45
|
-
const rows = asRows(result);
|
|
46
|
-
return {
|
|
47
|
-
rows,
|
|
48
|
-
rowCount: rows.length
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async execute(statement, params = []) {
|
|
52
|
-
const query = buildParameterizedSql(statement, params);
|
|
53
|
-
await this.db.execute(query);
|
|
54
|
-
}
|
|
55
|
-
async transaction(run) {
|
|
56
|
-
const transactionResult = this.client.begin(async (transactionClient) => {
|
|
57
|
-
const transactionalProvider = new SupabasePostgresProvider({
|
|
58
|
-
client: transactionClient,
|
|
59
|
-
db: this.createDrizzle(transactionClient),
|
|
60
|
-
createDrizzle: this.createDrizzle
|
|
61
|
-
});
|
|
62
|
-
return run(transactionalProvider);
|
|
63
|
-
});
|
|
64
|
-
return transactionResult;
|
|
65
|
-
}
|
|
66
|
-
async close() {
|
|
67
|
-
if (this.ownsClient) {
|
|
68
|
-
await this.client.end({ timeout: 5 });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function buildParameterizedSql(statement, params) {
|
|
73
|
-
const segments = [];
|
|
74
|
-
const pattern = /\$(\d+)/g;
|
|
75
|
-
let cursor = 0;
|
|
76
|
-
for (const match of statement.matchAll(pattern)) {
|
|
77
|
-
const token = match[0];
|
|
78
|
-
const indexPart = match[1];
|
|
79
|
-
const start = match.index;
|
|
80
|
-
if (indexPart == null || start == null)
|
|
81
|
-
continue;
|
|
82
|
-
const parameterIndex = Number(indexPart) - 1;
|
|
83
|
-
if (!Number.isInteger(parameterIndex) || parameterIndex < 0 || parameterIndex >= params.length) {
|
|
84
|
-
throw new Error(`SQL placeholder ${token} is out of bounds for ${params.length} parameter(s).`);
|
|
85
|
-
}
|
|
86
|
-
const staticSegment = statement.slice(cursor, start);
|
|
87
|
-
if (staticSegment.length > 0) {
|
|
88
|
-
segments.push(drizzleSql.raw(staticSegment));
|
|
89
|
-
}
|
|
90
|
-
const parameterValue = params[parameterIndex];
|
|
91
|
-
if (parameterValue === undefined) {
|
|
92
|
-
throw new Error(`SQL placeholder ${token} is missing a parameter value.`);
|
|
93
|
-
}
|
|
94
|
-
const normalizedValue = normalizeParam(parameterValue);
|
|
95
|
-
segments.push(drizzleSql`${normalizedValue}`);
|
|
96
|
-
cursor = start + token.length;
|
|
97
|
-
}
|
|
98
|
-
const tailSegment = statement.slice(cursor);
|
|
99
|
-
if (tailSegment.length > 0) {
|
|
100
|
-
segments.push(drizzleSql.raw(tailSegment));
|
|
101
|
-
}
|
|
102
|
-
if (segments.length === 0) {
|
|
103
|
-
return drizzleSql.raw("");
|
|
104
|
-
}
|
|
105
|
-
return drizzleSql.join(segments);
|
|
106
|
-
}
|
|
107
|
-
function normalizeParam(value) {
|
|
108
|
-
if (typeof value === "bigint") {
|
|
109
|
-
return value.toString();
|
|
110
|
-
}
|
|
111
|
-
if (value instanceof Uint8Array) {
|
|
112
|
-
return Buffer.from(value);
|
|
113
|
-
}
|
|
114
|
-
if (isPlainObject(value)) {
|
|
115
|
-
return JSON.stringify(value);
|
|
116
|
-
}
|
|
117
|
-
return value;
|
|
118
|
-
}
|
|
119
|
-
function asRows(result) {
|
|
120
|
-
if (!Array.isArray(result)) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
function isPlainObject(value) {
|
|
126
|
-
if (value == null || typeof value !== "object") {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (Array.isArray(value)) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
if (value instanceof Date) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
if (value instanceof Uint8Array) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
function resolveSslMode(mode) {
|
|
141
|
-
switch (mode) {
|
|
142
|
-
case "allow":
|
|
143
|
-
return false;
|
|
144
|
-
case "prefer":
|
|
145
|
-
return "prefer";
|
|
146
|
-
case "require":
|
|
147
|
-
default:
|
|
148
|
-
return "require";
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
export {
|
|
152
|
-
SupabasePostgresProvider
|
|
153
|
-
};
|
|
2
|
+
var k=import.meta.require;import{Buffer as _}from"buffer";import{sql as H}from"drizzle-orm";import{drizzle as $}from"drizzle-orm/postgres-js";import B from"postgres";class Y{client;db;ownsClient;createDrizzle;constructor(A={}){if(this.createDrizzle=A.createDrizzle??((E)=>$(E)),A.db){if(!A.client)throw Error("SupabasePostgresProvider requires a postgres client when db is provided.");this.client=A.client,this.db=A.db,this.ownsClient=!1;return}if(A.client)this.client=A.client,this.ownsClient=!1;else{if(!A.connectionString)throw Error("SupabasePostgresProvider requires either a connectionString or a client.");this.client=B(A.connectionString,{max:A.maxConnections,prepare:!1,ssl:j(A.sslMode)}),this.ownsClient=!0}this.db=this.createDrizzle(this.client)}async query(A,E=[]){let D=X(A,E),G=await this.db.execute(D),F=O(G);return{rows:F,rowCount:F.length}}async execute(A,E=[]){let D=X(A,E);await this.db.execute(D)}async transaction(A){return this.client.begin(async(D)=>{let G=new Y({client:D,db:this.createDrizzle(D),createDrizzle:this.createDrizzle});return A(G)})}async close(){if(this.ownsClient)await this.client.end({timeout:5})}}function X(A,E){let D=[],G=/\$(\d+)/g,F=0;for(let K of A.matchAll(G)){let L=K[0],T=K[1],N=K.index;if(T==null||N==null)continue;let J=Number(T)-1;if(!Number.isInteger(J)||J<0||J>=E.length)throw Error(`SQL placeholder ${L} is out of bounds for ${E.length} parameter(s).`);let U=A.slice(F,N);if(U.length>0)D.push(H.raw(U));let W=E[J];if(W===void 0)throw Error(`SQL placeholder ${L} is missing a parameter value.`);let Z=M(W);D.push(H`${Z}`),F=N+L.length}let Q=A.slice(F);if(Q.length>0)D.push(H.raw(Q));if(D.length===0)return H.raw("");return H.join(D)}function M(A){if(typeof A==="bigint")return A.toString();if(A instanceof Uint8Array)return _.from(A);if(R(A))return JSON.stringify(A);return A}function O(A){if(!Array.isArray(A))return[];return A}function R(A){if(A==null||typeof A!=="object")return!1;if(Array.isArray(A))return!1;if(A instanceof Date)return!1;if(A instanceof Uint8Array)return!1;return!0}function j(A){switch(A){case"allow":return!1;case"prefer":return"prefer";case"require":default:return"require"}}export{Y as SupabasePostgresProvider};
|