@lssm/integration.providers-impls 0.0.0-canary-20251217062139 → 0.0.0-canary-20251217072406
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/_virtual/rolldown_runtime.js +42 -1
- package/dist/impls/elevenlabs-voice.js +95 -1
- package/dist/impls/gcs-storage.js +88 -1
- package/dist/impls/gmail-inbound.js +200 -1
- package/dist/impls/gmail-outbound.js +104 -5
- package/dist/impls/google-calendar.js +154 -1
- package/dist/impls/index.js +16 -1
- package/dist/impls/mistral-embedding.js +41 -1
- package/dist/impls/mistral-llm.js +247 -1
- package/dist/impls/postmark-email.js +55 -1
- package/dist/impls/powens-client.js +171 -1
- package/dist/impls/powens-openbanking.js +218 -1
- package/dist/impls/provider-factory.js +142 -1
- package/dist/impls/qdrant-vector.js +69 -1
- package/dist/impls/stripe-payments.js +202 -1
- package/dist/impls/twilio-sms.js +58 -1
- package/dist/index.js +17 -1
- package/dist/runtime/dist/secrets/provider.js +58 -1
- package/dist/secrets/provider.js +3 -1
- package/package.json +5 -5
|
@@ -1 +1,202 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
|
|
3
|
+
//#region src/impls/stripe-payments.ts
|
|
4
|
+
const API_VERSION = "2025-10-29.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
|
+
};
|
|
161
|
+
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;
|
|
168
|
+
}
|
|
169
|
+
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
|
+
}
|
|
180
|
+
}
|
|
181
|
+
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
|
+
}
|
|
189
|
+
}
|
|
190
|
+
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
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
export { StripePaymentsProvider };
|
package/dist/impls/twilio-sms.js
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Twilio from "twilio";
|
|
2
|
+
|
|
3
|
+
//#region src/impls/twilio-sms.ts
|
|
4
|
+
var TwilioSmsProvider = class {
|
|
5
|
+
client;
|
|
6
|
+
fromNumber;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.client = options.client ?? Twilio(options.accountSid, options.authToken);
|
|
9
|
+
this.fromNumber = options.fromNumber;
|
|
10
|
+
}
|
|
11
|
+
async sendSms(input) {
|
|
12
|
+
const message = await this.client.messages.create({
|
|
13
|
+
to: input.to,
|
|
14
|
+
from: input.from ?? this.fromNumber,
|
|
15
|
+
body: input.body
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
id: message.sid,
|
|
19
|
+
to: message.to ?? input.to,
|
|
20
|
+
from: message.from ?? input.from ?? this.fromNumber ?? "",
|
|
21
|
+
body: message.body ?? input.body,
|
|
22
|
+
status: mapStatus(message.status),
|
|
23
|
+
sentAt: message.dateCreated ? new Date(message.dateCreated) : void 0,
|
|
24
|
+
deliveredAt: message.status === "delivered" && message.dateUpdated ? new Date(message.dateUpdated) : void 0,
|
|
25
|
+
price: message.price ? Number(message.price) : void 0,
|
|
26
|
+
priceCurrency: message.priceUnit ?? void 0,
|
|
27
|
+
errorCode: message.errorCode ? String(message.errorCode) : void 0,
|
|
28
|
+
errorMessage: message.errorMessage ?? void 0
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async getDeliveryStatus(messageId) {
|
|
32
|
+
const message = await this.client.messages(messageId).fetch();
|
|
33
|
+
return {
|
|
34
|
+
status: mapStatus(message.status),
|
|
35
|
+
errorCode: message.errorCode ? String(message.errorCode) : void 0,
|
|
36
|
+
errorMessage: message.errorMessage ?? void 0,
|
|
37
|
+
updatedAt: message.dateUpdated ? new Date(message.dateUpdated) : /* @__PURE__ */ new Date()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function mapStatus(status) {
|
|
42
|
+
switch (status) {
|
|
43
|
+
case "queued":
|
|
44
|
+
case "accepted":
|
|
45
|
+
case "scheduled": return "queued";
|
|
46
|
+
case "sending":
|
|
47
|
+
case "processing": return "sending";
|
|
48
|
+
case "sent": return "sent";
|
|
49
|
+
case "delivered": return "delivered";
|
|
50
|
+
case "undelivered": return "undelivered";
|
|
51
|
+
case "failed":
|
|
52
|
+
case "canceled": return "failed";
|
|
53
|
+
default: return "queued";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { TwilioSmsProvider };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MistralLLMProvider } from "./impls/mistral-llm.js";
|
|
2
|
+
import { MistralEmbeddingProvider } from "./impls/mistral-embedding.js";
|
|
3
|
+
import { QdrantVectorProvider } from "./impls/qdrant-vector.js";
|
|
4
|
+
import { GoogleCloudStorageProvider } from "./impls/gcs-storage.js";
|
|
5
|
+
import { StripePaymentsProvider } from "./impls/stripe-payments.js";
|
|
6
|
+
import { PostmarkEmailProvider } from "./impls/postmark-email.js";
|
|
7
|
+
import { TwilioSmsProvider } from "./impls/twilio-sms.js";
|
|
8
|
+
import { ElevenLabsVoiceProvider } from "./impls/elevenlabs-voice.js";
|
|
9
|
+
import { PowensClient, PowensClientError } from "./impls/powens-client.js";
|
|
10
|
+
import { PowensOpenBankingProvider } from "./impls/powens-openbanking.js";
|
|
11
|
+
import { IntegrationProviderFactory } from "./impls/provider-factory.js";
|
|
12
|
+
import { GmailInboundProvider } from "./impls/gmail-inbound.js";
|
|
13
|
+
import { GmailOutboundProvider } from "./impls/gmail-outbound.js";
|
|
14
|
+
import { GoogleCalendarProvider } from "./impls/google-calendar.js";
|
|
15
|
+
import "./impls/index.js";
|
|
16
|
+
|
|
17
|
+
export { ElevenLabsVoiceProvider, GmailInboundProvider, GmailOutboundProvider, GoogleCalendarProvider, GoogleCloudStorageProvider, IntegrationProviderFactory, MistralEmbeddingProvider, MistralLLMProvider, PostmarkEmailProvider, PowensClient, PowensClientError, PowensOpenBankingProvider, QdrantVectorProvider, StripePaymentsProvider, TwilioSmsProvider };
|
|
@@ -1 +1,58 @@
|
|
|
1
|
-
import{Buffer
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
//#region ../runtime/dist/secrets/provider.js
|
|
4
|
+
var SecretProviderError = class extends Error {
|
|
5
|
+
provider;
|
|
6
|
+
reference;
|
|
7
|
+
code;
|
|
8
|
+
cause;
|
|
9
|
+
constructor(params) {
|
|
10
|
+
super(params.message);
|
|
11
|
+
this.name = "SecretProviderError";
|
|
12
|
+
this.provider = params.provider;
|
|
13
|
+
this.reference = params.reference;
|
|
14
|
+
this.code = params.code ?? "UNKNOWN";
|
|
15
|
+
this.cause = params.cause;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function parseSecretUri(reference) {
|
|
19
|
+
if (!reference) throw new SecretProviderError({
|
|
20
|
+
message: "Secret reference cannot be empty",
|
|
21
|
+
provider: "unknown",
|
|
22
|
+
reference,
|
|
23
|
+
code: "INVALID"
|
|
24
|
+
});
|
|
25
|
+
const [scheme, rest] = reference.split("://");
|
|
26
|
+
if (!scheme || !rest) throw new SecretProviderError({
|
|
27
|
+
message: `Invalid secret reference: ${reference}`,
|
|
28
|
+
provider: "unknown",
|
|
29
|
+
reference,
|
|
30
|
+
code: "INVALID"
|
|
31
|
+
});
|
|
32
|
+
const queryIndex = rest.indexOf("?");
|
|
33
|
+
if (queryIndex === -1) return {
|
|
34
|
+
provider: scheme,
|
|
35
|
+
path: rest
|
|
36
|
+
};
|
|
37
|
+
const path = rest.slice(0, queryIndex);
|
|
38
|
+
const query = rest.slice(queryIndex + 1);
|
|
39
|
+
return {
|
|
40
|
+
provider: scheme,
|
|
41
|
+
path,
|
|
42
|
+
extras: Object.fromEntries(query.split("&").filter(Boolean).map((pair) => {
|
|
43
|
+
const [keyRaw, valueRaw] = pair.split("=");
|
|
44
|
+
const key = keyRaw ?? "";
|
|
45
|
+
const value = valueRaw ?? "";
|
|
46
|
+
return [decodeURIComponent(key), decodeURIComponent(value)];
|
|
47
|
+
}))
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function normalizeSecretPayload(payload) {
|
|
51
|
+
if (payload.data instanceof Uint8Array) return payload.data;
|
|
52
|
+
if (payload.encoding === "base64") return Buffer.from(payload.data, "base64");
|
|
53
|
+
if (payload.encoding === "binary") return Buffer.from(payload.data, "binary");
|
|
54
|
+
return Buffer.from(payload.data, "utf-8");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { SecretProviderError, normalizeSecretPayload, parseSecretUri };
|
package/dist/secrets/provider.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { SecretProviderError, normalizeSecretPayload, parseSecretUri } from "../runtime/dist/secrets/provider.js";
|
|
2
|
+
|
|
3
|
+
export { SecretProviderError, normalizeSecretPayload, parseSecretUri };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/integration.providers-impls",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251217072406",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"test": "bun test"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lssm/lib.contracts": "0.0.0-canary-
|
|
27
|
-
"@lssm/integration.runtime": "0.0.0-canary-
|
|
26
|
+
"@lssm/lib.contracts": "0.0.0-canary-20251217072406",
|
|
27
|
+
"@lssm/integration.runtime": "0.0.0-canary-20251217072406",
|
|
28
28
|
"@elevenlabs/elevenlabs-js": "^2.27.0",
|
|
29
29
|
"@google-cloud/storage": "^7.18.0",
|
|
30
30
|
"@mistralai/mistralai": "^1.2.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"zod": "^4.1.13"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
40
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
39
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251217072406",
|
|
40
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251217072406",
|
|
41
41
|
"tsdown": "^0.17.4",
|
|
42
42
|
"typescript": "^5.9.3"
|
|
43
43
|
},
|