@contractspec/integration.providers-impls 2.10.0 → 3.1.1
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/README.md +66 -10
- package/dist/impls/async-event-queue.d.ts +8 -0
- package/dist/impls/async-event-queue.js +49 -0
- package/dist/impls/composio-fallback-resolver.d.ts +34 -0
- package/dist/impls/composio-fallback-resolver.js +580 -0
- package/dist/impls/composio-mcp.d.ts +22 -0
- package/dist/impls/composio-mcp.js +164 -0
- package/dist/impls/composio-proxies.d.ts +60 -0
- package/dist/impls/composio-proxies.js +311 -0
- package/dist/impls/composio-sdk.d.ts +25 -0
- package/dist/impls/composio-sdk.js +78 -0
- package/dist/impls/composio-types.d.ts +43 -0
- package/dist/impls/composio-types.js +54 -0
- package/dist/impls/elevenlabs-voice.js +2 -0
- package/dist/impls/fal-voice.js +2 -0
- package/dist/impls/fathom-meeting-recorder.js +2 -0
- package/dist/impls/fathom-meeting-recorder.mapper.js +2 -0
- package/dist/impls/fathom-meeting-recorder.utils.js +2 -0
- package/dist/impls/fathom-meeting-recorder.webhooks.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.queries.js +2 -0
- package/dist/impls/fireflies-meeting-recorder.utils.js +2 -0
- package/dist/impls/gcs-storage.js +2 -0
- package/dist/impls/gmail-inbound.js +2 -0
- package/dist/impls/gmail-outbound.js +2 -0
- package/dist/impls/google-calendar.js +2 -0
- package/dist/impls/gradium-voice.js +2 -0
- package/dist/impls/granola-meeting-recorder.js +2 -0
- package/dist/impls/granola-meeting-recorder.mcp.js +2 -0
- package/dist/impls/health/base-health-provider.d.ts +64 -13
- package/dist/impls/health/base-health-provider.js +508 -156
- package/dist/impls/health/hybrid-health-providers.d.ts +34 -0
- package/dist/impls/health/hybrid-health-providers.js +1090 -0
- package/dist/impls/health/official-health-providers.d.ts +78 -0
- package/dist/impls/health/official-health-providers.js +970 -0
- package/dist/impls/health/provider-normalizers.d.ts +28 -0
- package/dist/impls/health/provider-normalizers.js +289 -0
- package/dist/impls/health/providers.d.ts +2 -39
- package/dist/impls/health/providers.js +897 -184
- package/dist/impls/health-provider-factory.js +1011 -196
- package/dist/impls/index.d.ts +11 -0
- package/dist/impls/index.js +2588 -259
- package/dist/impls/jira.js +2 -0
- package/dist/impls/linear.js +2 -0
- package/dist/impls/messaging-github.d.ts +17 -0
- package/dist/impls/messaging-github.js +112 -0
- package/dist/impls/messaging-slack.d.ts +14 -0
- package/dist/impls/messaging-slack.js +82 -0
- package/dist/impls/messaging-whatsapp-meta.d.ts +13 -0
- package/dist/impls/messaging-whatsapp-meta.js +54 -0
- package/dist/impls/messaging-whatsapp-twilio.d.ts +13 -0
- package/dist/impls/messaging-whatsapp-twilio.js +84 -0
- package/dist/impls/mistral-conversational.d.ts +23 -0
- package/dist/impls/mistral-conversational.js +478 -0
- package/dist/impls/mistral-conversational.session.d.ts +32 -0
- package/dist/impls/mistral-conversational.session.js +208 -0
- package/dist/impls/mistral-embedding.js +2 -0
- package/dist/impls/mistral-llm.js +2 -0
- package/dist/impls/mistral-stt.d.ts +17 -0
- package/dist/impls/mistral-stt.js +169 -0
- package/dist/impls/notion.js +2 -0
- package/dist/impls/posthog-reader.js +2 -0
- package/dist/impls/posthog-utils.js +2 -0
- package/dist/impls/posthog.js +2 -0
- package/dist/impls/postmark-email.js +2 -0
- package/dist/impls/powens-client.js +2 -0
- package/dist/impls/powens-openbanking.js +2 -0
- package/dist/impls/provider-factory.d.ts +29 -1
- package/dist/impls/provider-factory.js +1985 -249
- package/dist/impls/qdrant-vector.js +2 -0
- package/dist/impls/stripe-payments.js +3 -1
- package/dist/impls/supabase-psql.js +2 -0
- package/dist/impls/supabase-vector.js +2 -0
- package/dist/impls/tldv-meeting-recorder.js +2 -0
- package/dist/impls/twilio-sms.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2615 -283
- package/dist/messaging.d.ts +1 -0
- package/dist/messaging.js +3 -0
- package/dist/node/impls/async-event-queue.js +49 -0
- package/dist/node/impls/composio-fallback-resolver.js +580 -0
- package/dist/node/impls/composio-mcp.js +164 -0
- package/dist/node/impls/composio-proxies.js +311 -0
- package/dist/node/impls/composio-sdk.js +78 -0
- package/dist/node/impls/composio-types.js +54 -0
- package/dist/node/impls/elevenlabs-voice.js +3 -0
- package/dist/node/impls/fal-voice.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.utils.js +3 -0
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +3 -0
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +3 -0
- package/dist/node/impls/gcs-storage.js +3 -0
- package/dist/node/impls/gmail-inbound.js +3 -0
- package/dist/node/impls/gmail-outbound.js +3 -0
- package/dist/node/impls/google-calendar.js +3 -0
- package/dist/node/impls/gradium-voice.js +3 -0
- package/dist/node/impls/granola-meeting-recorder.js +3 -0
- package/dist/node/impls/granola-meeting-recorder.mcp.js +3 -0
- package/dist/node/impls/health/base-health-provider.js +509 -156
- package/dist/node/impls/health/hybrid-health-providers.js +1090 -0
- package/dist/node/impls/health/official-health-providers.js +970 -0
- package/dist/node/impls/health/provider-normalizers.js +289 -0
- package/dist/node/impls/health/providers.js +898 -184
- package/dist/node/impls/health-provider-factory.js +1012 -196
- package/dist/node/impls/index.js +2589 -259
- package/dist/node/impls/jira.js +3 -0
- package/dist/node/impls/linear.js +3 -0
- package/dist/node/impls/messaging-github.js +112 -0
- package/dist/node/impls/messaging-slack.js +82 -0
- package/dist/node/impls/messaging-whatsapp-meta.js +54 -0
- package/dist/node/impls/messaging-whatsapp-twilio.js +84 -0
- package/dist/node/impls/mistral-conversational.js +478 -0
- package/dist/node/impls/mistral-conversational.session.js +208 -0
- package/dist/node/impls/mistral-embedding.js +3 -0
- package/dist/node/impls/mistral-llm.js +3 -0
- package/dist/node/impls/mistral-stt.js +169 -0
- package/dist/node/impls/notion.js +3 -0
- package/dist/node/impls/posthog-reader.js +3 -0
- package/dist/node/impls/posthog-utils.js +3 -0
- package/dist/node/impls/posthog.js +3 -0
- package/dist/node/impls/postmark-email.js +3 -0
- package/dist/node/impls/powens-client.js +3 -0
- package/dist/node/impls/powens-openbanking.js +3 -0
- package/dist/node/impls/provider-factory.js +1986 -249
- package/dist/node/impls/qdrant-vector.js +3 -0
- package/dist/node/impls/stripe-payments.js +4 -1
- package/dist/node/impls/supabase-psql.js +3 -0
- package/dist/node/impls/supabase-vector.js +3 -0
- package/dist/node/impls/tldv-meeting-recorder.js +3 -0
- package/dist/node/impls/twilio-sms.js +3 -0
- package/dist/node/index.js +2616 -283
- package/dist/node/messaging.js +2 -0
- package/dist/node/secrets/provider.js +3 -0
- package/dist/secrets/provider.js +2 -0
- package/package.json +219 -14
package/dist/node/impls/jira.js
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/messaging-github.ts
|
|
5
|
+
class GithubMessagingProvider {
|
|
6
|
+
token;
|
|
7
|
+
defaultOwner;
|
|
8
|
+
defaultRepo;
|
|
9
|
+
apiBaseUrl;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.token = options.token;
|
|
12
|
+
this.defaultOwner = options.defaultOwner;
|
|
13
|
+
this.defaultRepo = options.defaultRepo;
|
|
14
|
+
this.apiBaseUrl = options.apiBaseUrl ?? "https://api.github.com";
|
|
15
|
+
}
|
|
16
|
+
async sendMessage(input) {
|
|
17
|
+
const target = this.resolveTarget(input);
|
|
18
|
+
const response = await fetch(`${this.apiBaseUrl}/repos/${target.owner}/${target.repo}/issues/${target.issueNumber}/comments`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
authorization: `Bearer ${this.token}`,
|
|
22
|
+
accept: "application/vnd.github+json",
|
|
23
|
+
"content-type": "application/json"
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify({ body: input.text })
|
|
26
|
+
});
|
|
27
|
+
const body = await response.json();
|
|
28
|
+
if (!response.ok || !body.id) {
|
|
29
|
+
throw new Error(`GitHub sendMessage failed: ${body.message ?? `HTTP_${response.status}`}`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
id: String(body.id),
|
|
33
|
+
providerMessageId: body.node_id,
|
|
34
|
+
status: "sent",
|
|
35
|
+
sentAt: new Date,
|
|
36
|
+
metadata: {
|
|
37
|
+
url: body.html_url ?? "",
|
|
38
|
+
owner: target.owner,
|
|
39
|
+
repo: target.repo,
|
|
40
|
+
issueNumber: String(target.issueNumber)
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async updateMessage(messageId, input) {
|
|
45
|
+
const owner = input.metadata?.owner ?? this.defaultOwner;
|
|
46
|
+
const repo = input.metadata?.repo ?? this.defaultRepo;
|
|
47
|
+
if (!owner || !repo) {
|
|
48
|
+
throw new Error("GitHub updateMessage requires owner and repo metadata.");
|
|
49
|
+
}
|
|
50
|
+
const response = await fetch(`${this.apiBaseUrl}/repos/${owner}/${repo}/issues/comments/${messageId}`, {
|
|
51
|
+
method: "PATCH",
|
|
52
|
+
headers: {
|
|
53
|
+
authorization: `Bearer ${this.token}`,
|
|
54
|
+
accept: "application/vnd.github+json",
|
|
55
|
+
"content-type": "application/json"
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify({ body: input.text })
|
|
58
|
+
});
|
|
59
|
+
const body = await response.json();
|
|
60
|
+
if (!response.ok || !body.id) {
|
|
61
|
+
throw new Error(`GitHub updateMessage failed: ${body.message ?? `HTTP_${response.status}`}`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
id: String(body.id),
|
|
65
|
+
providerMessageId: body.node_id,
|
|
66
|
+
status: "sent",
|
|
67
|
+
sentAt: new Date,
|
|
68
|
+
metadata: {
|
|
69
|
+
url: body.html_url ?? "",
|
|
70
|
+
owner,
|
|
71
|
+
repo
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
resolveTarget(input) {
|
|
76
|
+
const parsedRecipient = parseRecipient(input.recipientId);
|
|
77
|
+
const owner = parsedRecipient?.owner ?? this.defaultOwner;
|
|
78
|
+
const repo = parsedRecipient?.repo ?? this.defaultRepo;
|
|
79
|
+
const issueNumber = parsedRecipient?.issueNumber ?? parseIssueNumber(input.threadId);
|
|
80
|
+
if (!owner || !repo || issueNumber == null) {
|
|
81
|
+
throw new Error("GitHub sendMessage requires owner/repo and issueNumber (use recipientId like owner/repo#123 or provide defaults + threadId).");
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
owner,
|
|
85
|
+
repo,
|
|
86
|
+
issueNumber
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function parseRecipient(value) {
|
|
91
|
+
if (!value)
|
|
92
|
+
return null;
|
|
93
|
+
const match = value.trim().match(/^([^/]+)\/([^#]+)#(\d+)$/);
|
|
94
|
+
if (!match)
|
|
95
|
+
return null;
|
|
96
|
+
const owner = match[1];
|
|
97
|
+
const repo = match[2];
|
|
98
|
+
const issueNumber = Number(match[3]);
|
|
99
|
+
if (!owner || !repo || !Number.isInteger(issueNumber)) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return { owner, repo, issueNumber };
|
|
103
|
+
}
|
|
104
|
+
function parseIssueNumber(value) {
|
|
105
|
+
if (!value)
|
|
106
|
+
return null;
|
|
107
|
+
const numeric = Number(value);
|
|
108
|
+
return Number.isInteger(numeric) ? numeric : null;
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
GithubMessagingProvider
|
|
112
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/messaging-slack.ts
|
|
5
|
+
class SlackMessagingProvider {
|
|
6
|
+
botToken;
|
|
7
|
+
defaultChannelId;
|
|
8
|
+
apiBaseUrl;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.botToken = options.botToken;
|
|
11
|
+
this.defaultChannelId = options.defaultChannelId;
|
|
12
|
+
this.apiBaseUrl = options.apiBaseUrl ?? "https://slack.com/api";
|
|
13
|
+
}
|
|
14
|
+
async sendMessage(input) {
|
|
15
|
+
const channel = input.channelId ?? input.recipientId ?? this.defaultChannelId;
|
|
16
|
+
if (!channel) {
|
|
17
|
+
throw new Error("Slack sendMessage requires channelId, recipientId, or defaultChannelId.");
|
|
18
|
+
}
|
|
19
|
+
const payload = {
|
|
20
|
+
channel,
|
|
21
|
+
text: input.text,
|
|
22
|
+
mrkdwn: input.markdown ?? true,
|
|
23
|
+
thread_ts: input.threadId
|
|
24
|
+
};
|
|
25
|
+
const response = await fetch(`${this.apiBaseUrl}/chat.postMessage`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: {
|
|
28
|
+
authorization: `Bearer ${this.botToken}`,
|
|
29
|
+
"content-type": "application/json"
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify(payload)
|
|
32
|
+
});
|
|
33
|
+
const body = await response.json();
|
|
34
|
+
if (!response.ok || !body.ok || !body.ts) {
|
|
35
|
+
throw new Error(`Slack sendMessage failed: ${body.error ?? `HTTP_${response.status}`}`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
id: `slack:${body.channel ?? channel}:${body.ts}`,
|
|
39
|
+
providerMessageId: body.ts,
|
|
40
|
+
status: "sent",
|
|
41
|
+
sentAt: new Date,
|
|
42
|
+
metadata: {
|
|
43
|
+
channelId: body.channel ?? channel
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async updateMessage(messageId, input) {
|
|
48
|
+
const channel = input.channelId ?? this.defaultChannelId;
|
|
49
|
+
if (!channel) {
|
|
50
|
+
throw new Error("Slack updateMessage requires channelId or defaultChannelId.");
|
|
51
|
+
}
|
|
52
|
+
const response = await fetch(`${this.apiBaseUrl}/chat.update`, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: {
|
|
55
|
+
authorization: `Bearer ${this.botToken}`,
|
|
56
|
+
"content-type": "application/json"
|
|
57
|
+
},
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
channel,
|
|
60
|
+
ts: messageId,
|
|
61
|
+
text: input.text,
|
|
62
|
+
mrkdwn: input.markdown ?? true
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
const body = await response.json();
|
|
66
|
+
if (!response.ok || !body.ok || !body.ts) {
|
|
67
|
+
throw new Error(`Slack updateMessage failed: ${body.error ?? `HTTP_${response.status}`}`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
id: `slack:${body.channel ?? channel}:${body.ts}`,
|
|
71
|
+
providerMessageId: body.ts,
|
|
72
|
+
status: "sent",
|
|
73
|
+
sentAt: new Date,
|
|
74
|
+
metadata: {
|
|
75
|
+
channelId: body.channel ?? channel
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
SlackMessagingProvider
|
|
82
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/messaging-whatsapp-meta.ts
|
|
5
|
+
class MetaWhatsappMessagingProvider {
|
|
6
|
+
accessToken;
|
|
7
|
+
phoneNumberId;
|
|
8
|
+
apiVersion;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.accessToken = options.accessToken;
|
|
11
|
+
this.phoneNumberId = options.phoneNumberId;
|
|
12
|
+
this.apiVersion = options.apiVersion ?? "v22.0";
|
|
13
|
+
}
|
|
14
|
+
async sendMessage(input) {
|
|
15
|
+
const to = input.recipientId;
|
|
16
|
+
if (!to) {
|
|
17
|
+
throw new Error("Meta WhatsApp sendMessage requires recipientId.");
|
|
18
|
+
}
|
|
19
|
+
const response = await fetch(`https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/messages`, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: {
|
|
22
|
+
authorization: `Bearer ${this.accessToken}`,
|
|
23
|
+
"content-type": "application/json"
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
messaging_product: "whatsapp",
|
|
27
|
+
to,
|
|
28
|
+
type: "text",
|
|
29
|
+
text: {
|
|
30
|
+
body: input.text,
|
|
31
|
+
preview_url: false
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
const body = await response.json();
|
|
36
|
+
const messageId = body.messages?.[0]?.id;
|
|
37
|
+
if (!response.ok || !messageId) {
|
|
38
|
+
const errorCode = body.error?.code != null ? String(body.error.code) : "";
|
|
39
|
+
throw new Error(`Meta WhatsApp sendMessage failed: ${body.error?.message ?? `HTTP_${response.status}`}${errorCode ? ` (${errorCode})` : ""}`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
id: messageId,
|
|
43
|
+
providerMessageId: messageId,
|
|
44
|
+
status: "sent",
|
|
45
|
+
sentAt: new Date,
|
|
46
|
+
metadata: {
|
|
47
|
+
phoneNumberId: this.phoneNumberId
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
MetaWhatsappMessagingProvider
|
|
54
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/impls/messaging-whatsapp-twilio.ts
|
|
5
|
+
import { Buffer } from "node:buffer";
|
|
6
|
+
|
|
7
|
+
class TwilioWhatsappMessagingProvider {
|
|
8
|
+
accountSid;
|
|
9
|
+
authToken;
|
|
10
|
+
fromNumber;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.accountSid = options.accountSid;
|
|
13
|
+
this.authToken = options.authToken;
|
|
14
|
+
this.fromNumber = options.fromNumber;
|
|
15
|
+
}
|
|
16
|
+
async sendMessage(input) {
|
|
17
|
+
const to = normalizeWhatsappAddress(input.recipientId);
|
|
18
|
+
const from = normalizeWhatsappAddress(input.channelId ?? this.fromNumber);
|
|
19
|
+
if (!to) {
|
|
20
|
+
throw new Error("Twilio WhatsApp sendMessage requires recipientId.");
|
|
21
|
+
}
|
|
22
|
+
if (!from) {
|
|
23
|
+
throw new Error("Twilio WhatsApp sendMessage requires channelId or configured fromNumber.");
|
|
24
|
+
}
|
|
25
|
+
const params = new URLSearchParams;
|
|
26
|
+
params.set("To", to);
|
|
27
|
+
params.set("From", from);
|
|
28
|
+
params.set("Body", input.text);
|
|
29
|
+
const auth = Buffer.from(`${this.accountSid}:${this.authToken}`).toString("base64");
|
|
30
|
+
const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${this.accountSid}/Messages.json`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: {
|
|
33
|
+
authorization: `Basic ${auth}`,
|
|
34
|
+
"content-type": "application/x-www-form-urlencoded"
|
|
35
|
+
},
|
|
36
|
+
body: params.toString()
|
|
37
|
+
});
|
|
38
|
+
const body = await response.json();
|
|
39
|
+
if (!response.ok || !body.sid) {
|
|
40
|
+
throw new Error(`Twilio WhatsApp sendMessage failed: ${body.error_message ?? `HTTP_${response.status}`}`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
id: body.sid,
|
|
44
|
+
providerMessageId: body.sid,
|
|
45
|
+
status: mapTwilioStatus(body.status),
|
|
46
|
+
sentAt: new Date,
|
|
47
|
+
errorCode: body.error_code != null ? String(body.error_code) : undefined,
|
|
48
|
+
errorMessage: body.error_message ?? undefined,
|
|
49
|
+
metadata: {
|
|
50
|
+
from,
|
|
51
|
+
to
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function normalizeWhatsappAddress(value) {
|
|
57
|
+
if (!value)
|
|
58
|
+
return null;
|
|
59
|
+
if (value.startsWith("whatsapp:"))
|
|
60
|
+
return value;
|
|
61
|
+
return `whatsapp:${value}`;
|
|
62
|
+
}
|
|
63
|
+
function mapTwilioStatus(status) {
|
|
64
|
+
switch (status) {
|
|
65
|
+
case "queued":
|
|
66
|
+
case "accepted":
|
|
67
|
+
case "scheduled":
|
|
68
|
+
return "queued";
|
|
69
|
+
case "sending":
|
|
70
|
+
return "sending";
|
|
71
|
+
case "delivered":
|
|
72
|
+
return "delivered";
|
|
73
|
+
case "failed":
|
|
74
|
+
case "undelivered":
|
|
75
|
+
case "canceled":
|
|
76
|
+
return "failed";
|
|
77
|
+
case "sent":
|
|
78
|
+
default:
|
|
79
|
+
return "sent";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
TwilioWhatsappMessagingProvider
|
|
84
|
+
};
|