@contractspec/integration.providers-impls 3.8.8 → 3.8.10
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 +17 -17
|
@@ -1,188 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/impls/supabase-psql.ts
|
|
5
|
-
import { Buffer } from "node: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
|
-
|
|
152
|
-
// src/impls/supabase-vector.ts
|
|
153
|
-
class SupabaseVectorProvider {
|
|
154
|
-
database;
|
|
155
|
-
createTableIfMissing;
|
|
156
|
-
distanceMetric;
|
|
157
|
-
quotedSchema;
|
|
158
|
-
qualifiedTable;
|
|
159
|
-
collectionIndex;
|
|
160
|
-
namespaceIndex;
|
|
161
|
-
ensureTablePromise;
|
|
162
|
-
constructor(options) {
|
|
163
|
-
this.database = options.database ?? new SupabasePostgresProvider({
|
|
164
|
-
connectionString: options.connectionString,
|
|
165
|
-
maxConnections: options.maxConnections,
|
|
166
|
-
sslMode: options.sslMode
|
|
167
|
-
});
|
|
168
|
-
this.createTableIfMissing = options.createTableIfMissing ?? true;
|
|
169
|
-
this.distanceMetric = options.distanceMetric ?? "cosine";
|
|
170
|
-
const schema = sanitizeIdentifier(options.schema ?? "public", "schema");
|
|
171
|
-
const table = sanitizeIdentifier(options.table ?? "contractspec_vectors", "table");
|
|
172
|
-
this.quotedSchema = quoteIdentifier(schema);
|
|
173
|
-
this.qualifiedTable = `${this.quotedSchema}.${quoteIdentifier(table)}`;
|
|
174
|
-
this.collectionIndex = quoteIdentifier(`${table}_collection_idx`);
|
|
175
|
-
this.namespaceIndex = quoteIdentifier(`${table}_namespace_idx`);
|
|
176
|
-
}
|
|
177
|
-
async upsert(request) {
|
|
178
|
-
if (request.documents.length === 0) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (this.createTableIfMissing) {
|
|
182
|
-
await this.ensureTable();
|
|
183
|
-
}
|
|
184
|
-
for (const document of request.documents) {
|
|
185
|
-
await this.database.execute(`INSERT INTO ${this.qualifiedTable}
|
|
1
|
+
import{createRequire as $}from"node:module";var M=$(import.meta.url);import{Buffer as D}from"node:buffer";import{sql as n}from"drizzle-orm";import{drizzle as m}from"drizzle-orm/postgres-js";import I from"postgres";class d{client;db;ownsClient;createDrizzle;constructor(e={}){if(this.createDrizzle=e.createDrizzle??((t)=>m(t)),e.db){if(!e.client)throw Error("SupabasePostgresProvider requires a postgres client when db is provided.");this.client=e.client,this.db=e.db,this.ownsClient=!1;return}if(e.client)this.client=e.client,this.ownsClient=!1;else{if(!e.connectionString)throw Error("SupabasePostgresProvider requires either a connectionString or a client.");this.client=I(e.connectionString,{max:e.maxConnections,prepare:!1,ssl:x(e.sslMode)}),this.ownsClient=!0}this.db=this.createDrizzle(this.client)}async query(e,t=[]){let a=p(e,t),s=await this.db.execute(a),c=R(s);return{rows:c,rowCount:c.length}}async execute(e,t=[]){let a=p(e,t);await this.db.execute(a)}async transaction(e){return this.client.begin(async(a)=>{let s=new d({client:a,db:this.createDrizzle(a),createDrizzle:this.createDrizzle});return e(s)})}async close(){if(this.ownsClient)await this.client.end({timeout:5})}}function p(e,t){let a=[],s=/\$(\d+)/g,c=0;for(let r of e.matchAll(s)){let l=r[0],T=r[1],h=r.index;if(T==null||h==null)continue;let o=Number(T)-1;if(!Number.isInteger(o)||o<0||o>=t.length)throw Error(`SQL placeholder ${l} is out of bounds for ${t.length} parameter(s).`);let u=e.slice(c,h);if(u.length>0)a.push(n.raw(u));let E=t[o];if(E===void 0)throw Error(`SQL placeholder ${l} is missing a parameter value.`);let N=L(E);a.push(n`${N}`),c=h+l.length}let i=e.slice(c);if(i.length>0)a.push(n.raw(i));if(a.length===0)return n.raw("");return n.join(a)}function L(e){if(typeof e==="bigint")return e.toString();if(e instanceof Uint8Array)return D.from(e);if(O(e))return JSON.stringify(e);return e}function R(e){if(!Array.isArray(e))return[];return e}function O(e){if(e==null||typeof e!=="object")return!1;if(Array.isArray(e))return!1;if(e instanceof Date)return!1;if(e instanceof Uint8Array)return!1;return!0}function x(e){switch(e){case"allow":return!1;case"prefer":return"prefer";case"require":default:return"require"}}class g{database;createTableIfMissing;distanceMetric;quotedSchema;qualifiedTable;collectionIndex;namespaceIndex;ensureTablePromise;constructor(e){this.database=e.database??new d({connectionString:e.connectionString,maxConnections:e.maxConnections,sslMode:e.sslMode}),this.createTableIfMissing=e.createTableIfMissing??!0,this.distanceMetric=e.distanceMetric??"cosine";let t=S(e.schema??"public","schema"),a=S(e.table??"contractspec_vectors","table");this.quotedSchema=b(t),this.qualifiedTable=`${this.quotedSchema}.${b(a)}`,this.collectionIndex=b(`${a}_collection_idx`),this.namespaceIndex=b(`${a}_namespace_idx`)}async upsert(e){if(e.documents.length===0)return;if(this.createTableIfMissing)await this.ensureTable();for(let t of e.documents)await this.database.execute(`INSERT INTO ${this.qualifiedTable}
|
|
186
2
|
(collection, id, embedding, payload, namespace, expires_at, updated_at)
|
|
187
3
|
VALUES ($1, $2, $3::vector, $4::jsonb, $5, $6, now())
|
|
188
4
|
ON CONFLICT (collection, id)
|
|
@@ -191,75 +7,21 @@ class SupabaseVectorProvider {
|
|
|
191
7
|
payload = EXCLUDED.payload,
|
|
192
8
|
namespace = EXCLUDED.namespace,
|
|
193
9
|
expires_at = EXCLUDED.expires_at,
|
|
194
|
-
updated_at = now();`,
|
|
195
|
-
request.collection,
|
|
196
|
-
document.id,
|
|
197
|
-
toVectorLiteral(document.vector),
|
|
198
|
-
document.payload ? JSON.stringify(document.payload) : null,
|
|
199
|
-
document.namespace ?? null,
|
|
200
|
-
document.expiresAt ?? null
|
|
201
|
-
]);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
async search(query) {
|
|
205
|
-
const operator = this.distanceOperator;
|
|
206
|
-
const results = await this.database.query(`SELECT
|
|
10
|
+
updated_at = now();`,[e.collection,t.id,f(t.vector),t.payload?JSON.stringify(t.payload):null,t.namespace??null,t.expiresAt??null])}async search(e){let t=this.distanceOperator,s=(await this.database.query(`SELECT
|
|
207
11
|
id,
|
|
208
12
|
payload,
|
|
209
13
|
namespace,
|
|
210
|
-
(embedding ${
|
|
14
|
+
(embedding ${t} $3::vector) AS distance
|
|
211
15
|
FROM ${this.qualifiedTable}
|
|
212
16
|
WHERE collection = $1
|
|
213
17
|
AND ($2::text IS NULL OR namespace = $2)
|
|
214
18
|
AND (expires_at IS NULL OR expires_at > now())
|
|
215
19
|
AND ($4::jsonb IS NULL OR payload @> $4::jsonb)
|
|
216
|
-
ORDER BY embedding ${
|
|
217
|
-
LIMIT $5;`, [
|
|
218
|
-
query.collection,
|
|
219
|
-
query.namespace ?? null,
|
|
220
|
-
toVectorLiteral(query.vector),
|
|
221
|
-
query.filter ? JSON.stringify(query.filter) : null,
|
|
222
|
-
query.topK
|
|
223
|
-
]);
|
|
224
|
-
const mapped = results.rows.map((row) => {
|
|
225
|
-
const distance = Number(row.distance);
|
|
226
|
-
return {
|
|
227
|
-
id: row.id,
|
|
228
|
-
score: distanceToScore(distance, this.distanceMetric),
|
|
229
|
-
payload: isRecord(row.payload) ? row.payload : undefined,
|
|
230
|
-
namespace: row.namespace ?? undefined
|
|
231
|
-
};
|
|
232
|
-
});
|
|
233
|
-
const scoreThreshold = query.scoreThreshold;
|
|
234
|
-
if (scoreThreshold == null) {
|
|
235
|
-
return mapped;
|
|
236
|
-
}
|
|
237
|
-
return mapped.filter((result) => result.score >= scoreThreshold);
|
|
238
|
-
}
|
|
239
|
-
async delete(request) {
|
|
240
|
-
if (request.ids.length === 0) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const params = [
|
|
244
|
-
request.collection,
|
|
245
|
-
request.ids,
|
|
246
|
-
request.namespace ?? null
|
|
247
|
-
];
|
|
248
|
-
await this.database.execute(`DELETE FROM ${this.qualifiedTable}
|
|
20
|
+
ORDER BY embedding ${t} $3::vector
|
|
21
|
+
LIMIT $5;`,[e.collection,e.namespace??null,f(e.vector),e.filter?JSON.stringify(e.filter):null,e.topK])).rows.map((i)=>{let r=Number(i.distance);return{id:i.id,score:w(r,this.distanceMetric),payload:y(i.payload)?i.payload:void 0,namespace:i.namespace??void 0}}),c=e.scoreThreshold;if(c==null)return s;return s.filter((i)=>i.score>=c)}async delete(e){if(e.ids.length===0)return;let t=[e.collection,e.ids,e.namespace??null];await this.database.execute(`DELETE FROM ${this.qualifiedTable}
|
|
249
22
|
WHERE collection = $1
|
|
250
23
|
AND id = ANY($2::text[])
|
|
251
|
-
AND ($3::text IS NULL OR namespace = $3);`,
|
|
252
|
-
}
|
|
253
|
-
async ensureTable() {
|
|
254
|
-
if (!this.ensureTablePromise) {
|
|
255
|
-
this.ensureTablePromise = this.createTable();
|
|
256
|
-
}
|
|
257
|
-
await this.ensureTablePromise;
|
|
258
|
-
}
|
|
259
|
-
async createTable() {
|
|
260
|
-
await this.database.execute("CREATE EXTENSION IF NOT EXISTS vector;");
|
|
261
|
-
await this.database.execute(`CREATE SCHEMA IF NOT EXISTS ${this.quotedSchema};`);
|
|
262
|
-
await this.database.execute(`CREATE TABLE IF NOT EXISTS ${this.qualifiedTable} (
|
|
24
|
+
AND ($3::text IS NULL OR namespace = $3);`,t)}async ensureTable(){if(!this.ensureTablePromise)this.ensureTablePromise=this.createTable();await this.ensureTablePromise}async createTable(){await this.database.execute("CREATE EXTENSION IF NOT EXISTS vector;"),await this.database.execute(`CREATE SCHEMA IF NOT EXISTS ${this.quotedSchema};`),await this.database.execute(`CREATE TABLE IF NOT EXISTS ${this.qualifiedTable} (
|
|
263
25
|
collection text NOT NULL,
|
|
264
26
|
id text NOT NULL,
|
|
265
27
|
embedding vector NOT NULL,
|
|
@@ -269,58 +31,6 @@ class SupabaseVectorProvider {
|
|
|
269
31
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
270
32
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
271
33
|
PRIMARY KEY (collection, id)
|
|
272
|
-
);`)
|
|
273
|
-
|
|
274
|
-
ON ${this.qualifiedTable} (
|
|
275
|
-
await this.database.execute(`CREATE INDEX IF NOT EXISTS ${this.namespaceIndex}
|
|
276
|
-
ON ${this.qualifiedTable} (namespace);`);
|
|
277
|
-
}
|
|
278
|
-
get distanceOperator() {
|
|
279
|
-
switch (this.distanceMetric) {
|
|
280
|
-
case "l2":
|
|
281
|
-
return "<->";
|
|
282
|
-
case "inner_product":
|
|
283
|
-
return "<#>";
|
|
284
|
-
case "cosine":
|
|
285
|
-
default:
|
|
286
|
-
return "<=>";
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function sanitizeIdentifier(value, label) {
|
|
291
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
|
|
292
|
-
throw new Error(`SupabaseVectorProvider ${label} "${value}" is invalid.`);
|
|
293
|
-
}
|
|
294
|
-
return value;
|
|
295
|
-
}
|
|
296
|
-
function quoteIdentifier(value) {
|
|
297
|
-
return `"${value.replaceAll('"', '""')}"`;
|
|
298
|
-
}
|
|
299
|
-
function toVectorLiteral(vector) {
|
|
300
|
-
if (vector.length === 0) {
|
|
301
|
-
throw new Error("Supabase vectors must contain at least one dimension.");
|
|
302
|
-
}
|
|
303
|
-
for (const value of vector) {
|
|
304
|
-
if (!Number.isFinite(value)) {
|
|
305
|
-
throw new Error(`Supabase vectors must be finite numbers. Found "${value}".`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return `[${vector.join(",")}]`;
|
|
309
|
-
}
|
|
310
|
-
function isRecord(value) {
|
|
311
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
312
|
-
}
|
|
313
|
-
function distanceToScore(distance, metric) {
|
|
314
|
-
switch (metric) {
|
|
315
|
-
case "inner_product":
|
|
316
|
-
return -distance;
|
|
317
|
-
case "l2":
|
|
318
|
-
return 1 / (1 + distance);
|
|
319
|
-
case "cosine":
|
|
320
|
-
default:
|
|
321
|
-
return 1 - distance;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
export {
|
|
325
|
-
SupabaseVectorProvider
|
|
326
|
-
};
|
|
34
|
+
);`),await this.database.execute(`CREATE INDEX IF NOT EXISTS ${this.collectionIndex}
|
|
35
|
+
ON ${this.qualifiedTable} (collection);`),await this.database.execute(`CREATE INDEX IF NOT EXISTS ${this.namespaceIndex}
|
|
36
|
+
ON ${this.qualifiedTable} (namespace);`)}get distanceOperator(){switch(this.distanceMetric){case"l2":return"<->";case"inner_product":return"<#>";case"cosine":default:return"<=>"}}}function S(e,t){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e))throw Error(`SupabaseVectorProvider ${t} "${e}" is invalid.`);return e}function b(e){return`"${e.replaceAll('"','""')}"`}function f(e){if(e.length===0)throw Error("Supabase vectors must contain at least one dimension.");for(let t of e)if(!Number.isFinite(t))throw Error(`Supabase vectors must be finite numbers. Found "${t}".`);return`[${e.join(",")}]`}function y(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function w(e,t){switch(t){case"inner_product":return-e;case"l2":return 1/(1+e);case"cosine":default:return 1-e}}export{g as SupabaseVectorProvider};
|
|
@@ -1,148 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/impls/tldv-meeting-recorder.ts
|
|
5
|
-
var DEFAULT_BASE_URL = "https://pasta.tldv.io/v1alpha1";
|
|
6
|
-
|
|
7
|
-
class TldvMeetingRecorderProvider {
|
|
8
|
-
apiKey;
|
|
9
|
-
baseUrl;
|
|
10
|
-
defaultPageSize;
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.apiKey = options.apiKey;
|
|
13
|
-
this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
14
|
-
this.defaultPageSize = options.pageSize;
|
|
15
|
-
}
|
|
16
|
-
async listMeetings(params) {
|
|
17
|
-
const page = params.cursor ? Number(params.cursor) : 1;
|
|
18
|
-
const limit = params.pageSize ?? this.defaultPageSize ?? 50;
|
|
19
|
-
const query = new URLSearchParams;
|
|
20
|
-
query.set("page", String(Number.isFinite(page) ? page : 1));
|
|
21
|
-
query.set("limit", String(limit));
|
|
22
|
-
if (params.query)
|
|
23
|
-
query.set("query", params.query);
|
|
24
|
-
if (params.from)
|
|
25
|
-
query.set("from", params.from);
|
|
26
|
-
if (params.to)
|
|
27
|
-
query.set("to", params.to);
|
|
28
|
-
if (params.organizerEmail)
|
|
29
|
-
query.set("organizer", params.organizerEmail);
|
|
30
|
-
if (params.participantEmail)
|
|
31
|
-
query.set("participant", params.participantEmail);
|
|
32
|
-
const data = await this.request(`/meetings?${query.toString()}`);
|
|
33
|
-
const nextPage = data.page < data.pages ? data.page + 1 : undefined;
|
|
34
|
-
return {
|
|
35
|
-
meetings: data.results.map((meeting) => this.mapMeeting(meeting, params)),
|
|
36
|
-
nextCursor: nextPage ? String(nextPage) : undefined,
|
|
37
|
-
hasMore: Boolean(nextPage)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
async getMeeting(params) {
|
|
41
|
-
const meeting = await this.request(`/meetings/${encodeURIComponent(params.meetingId)}`);
|
|
42
|
-
return this.mapMeeting(meeting, params);
|
|
43
|
-
}
|
|
44
|
-
async getTranscript(params) {
|
|
45
|
-
const response = await this.request(`/meetings/${encodeURIComponent(params.meetingId)}/transcript`);
|
|
46
|
-
const segments = response.data.map((segment, index) => this.mapTranscriptSegment(segment, index));
|
|
47
|
-
return {
|
|
48
|
-
id: response.id,
|
|
49
|
-
meetingId: response.meetingId,
|
|
50
|
-
tenantId: params.tenantId,
|
|
51
|
-
connectionId: params.connectionId ?? "unknown",
|
|
52
|
-
externalId: response.id,
|
|
53
|
-
format: "segments",
|
|
54
|
-
text: segments.map((segment) => segment.text).join(`
|
|
55
|
-
`),
|
|
56
|
-
segments,
|
|
57
|
-
metadata: {
|
|
58
|
-
providerMeetingId: response.meetingId
|
|
59
|
-
},
|
|
60
|
-
raw: response.data
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async parseWebhook(request) {
|
|
64
|
-
const payload = request.parsedBody ?? JSON.parse(request.rawBody);
|
|
65
|
-
const body = payload;
|
|
66
|
-
return {
|
|
67
|
-
providerKey: "meeting-recorder.tldv",
|
|
68
|
-
eventType: body.event,
|
|
69
|
-
meetingId: body.data?.id ?? body.data?.meetingId,
|
|
70
|
-
receivedAt: body.executedAt,
|
|
71
|
-
payload
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
mapMeeting(meeting, params) {
|
|
75
|
-
const connectionId = params.connectionId ?? "unknown";
|
|
76
|
-
const invitees = meeting.invitees?.map((invitee) => this.mapInvitee(invitee)).filter(Boolean);
|
|
77
|
-
return {
|
|
78
|
-
id: meeting.id,
|
|
79
|
-
tenantId: params.tenantId,
|
|
80
|
-
connectionId,
|
|
81
|
-
externalId: meeting.id,
|
|
82
|
-
title: meeting.name,
|
|
83
|
-
organizer: this.mapInvitee(meeting.organizer, "organizer"),
|
|
84
|
-
invitees: invitees?.length ? invitees : undefined,
|
|
85
|
-
participants: invitees?.length ? invitees : undefined,
|
|
86
|
-
scheduledStartAt: meeting.happenedAt,
|
|
87
|
-
recordingStartAt: meeting.happenedAt,
|
|
88
|
-
durationSeconds: meeting.duration,
|
|
89
|
-
meetingUrl: meeting.url,
|
|
90
|
-
transcriptAvailable: true,
|
|
91
|
-
sourcePlatform: "tldv",
|
|
92
|
-
metadata: {
|
|
93
|
-
template: meeting.template,
|
|
94
|
-
extraProperties: meeting.extraProperties
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
mapInvitee(invitee, role = "attendee") {
|
|
99
|
-
if (!invitee)
|
|
100
|
-
return;
|
|
101
|
-
return {
|
|
102
|
-
name: invitee.name ?? undefined,
|
|
103
|
-
email: invitee.email ?? undefined,
|
|
104
|
-
role
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
mapTranscriptSegment(segment, index) {
|
|
108
|
-
return {
|
|
109
|
-
index,
|
|
110
|
-
speakerName: segment.speaker ?? undefined,
|
|
111
|
-
text: segment.text,
|
|
112
|
-
startTimeMs: parseSeconds(segment.startTime),
|
|
113
|
-
endTimeMs: parseSeconds(segment.endTime)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
async request(path) {
|
|
117
|
-
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
118
|
-
headers: {
|
|
119
|
-
"Content-Type": "application/json",
|
|
120
|
-
"x-api-key": this.apiKey
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
if (!response.ok) {
|
|
124
|
-
const message = await safeReadError(response);
|
|
125
|
-
throw new Error(`tl;dv API error (${response.status}): ${message}`);
|
|
126
|
-
}
|
|
127
|
-
return await response.json();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function parseSeconds(value) {
|
|
131
|
-
if (value == null)
|
|
132
|
-
return;
|
|
133
|
-
const num = typeof value === "number" ? value : Number(value);
|
|
134
|
-
if (!Number.isFinite(num))
|
|
135
|
-
return;
|
|
136
|
-
return num * 1000;
|
|
137
|
-
}
|
|
138
|
-
async function safeReadError(response) {
|
|
139
|
-
try {
|
|
140
|
-
const data = await response.json();
|
|
141
|
-
return data?.message ?? response.statusText;
|
|
142
|
-
} catch {
|
|
143
|
-
return response.statusText;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
export {
|
|
147
|
-
TldvMeetingRecorderProvider
|
|
148
|
-
};
|
|
1
|
+
import{createRequire as o}from"node:module";var m=o(import.meta.url);class g{apiKey;baseUrl;defaultPageSize;constructor(e){this.apiKey=e.apiKey,this.baseUrl=e.baseUrl??"https://pasta.tldv.io/v1alpha1",this.defaultPageSize=e.pageSize}async listMeetings(e){let t=e.cursor?Number(e.cursor):1,r=e.pageSize??this.defaultPageSize??50,n=new URLSearchParams;if(n.set("page",String(Number.isFinite(t)?t:1)),n.set("limit",String(r)),e.query)n.set("query",e.query);if(e.from)n.set("from",e.from);if(e.to)n.set("to",e.to);if(e.organizerEmail)n.set("organizer",e.organizerEmail);if(e.participantEmail)n.set("participant",e.participantEmail);let i=await this.request(`/meetings?${n.toString()}`),a=i.page<i.pages?i.page+1:void 0;return{meetings:i.results.map((d)=>this.mapMeeting(d,e)),nextCursor:a?String(a):void 0,hasMore:Boolean(a)}}async getMeeting(e){let t=await this.request(`/meetings/${encodeURIComponent(e.meetingId)}`);return this.mapMeeting(t,e)}async getTranscript(e){let t=await this.request(`/meetings/${encodeURIComponent(e.meetingId)}/transcript`),r=t.data.map((n,i)=>this.mapTranscriptSegment(n,i));return{id:t.id,meetingId:t.meetingId,tenantId:e.tenantId,connectionId:e.connectionId??"unknown",externalId:t.id,format:"segments",text:r.map((n)=>n.text).join(`
|
|
2
|
+
`),segments:r,metadata:{providerMeetingId:t.meetingId},raw:t.data}}async parseWebhook(e){let t=e.parsedBody??JSON.parse(e.rawBody),r=t;return{providerKey:"meeting-recorder.tldv",eventType:r.event,meetingId:r.data?.id??r.data?.meetingId,receivedAt:r.executedAt,payload:t}}mapMeeting(e,t){let r=t.connectionId??"unknown",n=e.invitees?.map((i)=>this.mapInvitee(i)).filter(Boolean);return{id:e.id,tenantId:t.tenantId,connectionId:r,externalId:e.id,title:e.name,organizer:this.mapInvitee(e.organizer,"organizer"),invitees:n?.length?n:void 0,participants:n?.length?n:void 0,scheduledStartAt:e.happenedAt,recordingStartAt:e.happenedAt,durationSeconds:e.duration,meetingUrl:e.url,transcriptAvailable:!0,sourcePlatform:"tldv",metadata:{template:e.template,extraProperties:e.extraProperties}}}mapInvitee(e,t="attendee"){if(!e)return;return{name:e.name??void 0,email:e.email??void 0,role:t}}mapTranscriptSegment(e,t){return{index:t,speakerName:e.speaker??void 0,text:e.text,startTimeMs:s(e.startTime),endTimeMs:s(e.endTime)}}async request(e){let t=await fetch(`${this.baseUrl}${e}`,{headers:{"Content-Type":"application/json","x-api-key":this.apiKey}});if(!t.ok){let r=await c(t);throw Error(`tl;dv API error (${t.status}): ${r}`)}return await t.json()}}function s(e){if(e==null)return;let t=typeof e==="number"?e:Number(e);if(!Number.isFinite(t))return;return t*1000}async function c(e){try{return(await e.json())?.message??e.statusText}catch{return e.statusText}}export{g as TldvMeetingRecorderProvider};
|
|
@@ -1,68 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/impls/twilio-sms.ts
|
|
5
|
-
import Twilio from "twilio";
|
|
6
|
-
|
|
7
|
-
class TwilioSmsProvider {
|
|
8
|
-
client;
|
|
9
|
-
fromNumber;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.client = options.client ?? Twilio(options.accountSid, options.authToken);
|
|
12
|
-
this.fromNumber = options.fromNumber;
|
|
13
|
-
}
|
|
14
|
-
async sendSms(input) {
|
|
15
|
-
const message = await this.client.messages.create({
|
|
16
|
-
to: input.to,
|
|
17
|
-
from: input.from ?? this.fromNumber,
|
|
18
|
-
body: input.body
|
|
19
|
-
});
|
|
20
|
-
return {
|
|
21
|
-
id: message.sid,
|
|
22
|
-
to: message.to ?? input.to,
|
|
23
|
-
from: message.from ?? input.from ?? this.fromNumber ?? "",
|
|
24
|
-
body: message.body ?? input.body,
|
|
25
|
-
status: mapStatus(message.status),
|
|
26
|
-
sentAt: message.dateCreated ? new Date(message.dateCreated) : undefined,
|
|
27
|
-
deliveredAt: message.status === "delivered" && message.dateUpdated ? new Date(message.dateUpdated) : undefined,
|
|
28
|
-
price: message.price ? Number(message.price) : undefined,
|
|
29
|
-
priceCurrency: message.priceUnit ?? undefined,
|
|
30
|
-
errorCode: message.errorCode ? String(message.errorCode) : undefined,
|
|
31
|
-
errorMessage: message.errorMessage ?? undefined
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
async getDeliveryStatus(messageId) {
|
|
35
|
-
const message = await this.client.messages(messageId).fetch();
|
|
36
|
-
return {
|
|
37
|
-
status: mapStatus(message.status),
|
|
38
|
-
errorCode: message.errorCode ? String(message.errorCode) : undefined,
|
|
39
|
-
errorMessage: message.errorMessage ?? undefined,
|
|
40
|
-
updatedAt: message.dateUpdated ? new Date(message.dateUpdated) : new Date
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function mapStatus(status) {
|
|
45
|
-
switch (status) {
|
|
46
|
-
case "queued":
|
|
47
|
-
case "accepted":
|
|
48
|
-
case "scheduled":
|
|
49
|
-
return "queued";
|
|
50
|
-
case "sending":
|
|
51
|
-
case "processing":
|
|
52
|
-
return "sending";
|
|
53
|
-
case "sent":
|
|
54
|
-
return "sent";
|
|
55
|
-
case "delivered":
|
|
56
|
-
return "delivered";
|
|
57
|
-
case "undelivered":
|
|
58
|
-
return "undelivered";
|
|
59
|
-
case "failed":
|
|
60
|
-
case "canceled":
|
|
61
|
-
return "failed";
|
|
62
|
-
default:
|
|
63
|
-
return "queued";
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
TwilioSmsProvider
|
|
68
|
-
};
|
|
1
|
+
import{createRequire as s}from"node:module";var a=s(import.meta.url);import d from"twilio";class i{client;fromNumber;constructor(r){this.client=r.client??d(r.accountSid,r.authToken),this.fromNumber=r.fromNumber}async sendSms(r){let e=await this.client.messages.create({to:r.to,from:r.from??this.fromNumber,body:r.body});return{id:e.sid,to:e.to??r.to,from:e.from??r.from??this.fromNumber??"",body:e.body??r.body,status:t(e.status),sentAt:e.dateCreated?new Date(e.dateCreated):void 0,deliveredAt:e.status==="delivered"&&e.dateUpdated?new Date(e.dateUpdated):void 0,price:e.price?Number(e.price):void 0,priceCurrency:e.priceUnit??void 0,errorCode:e.errorCode?String(e.errorCode):void 0,errorMessage:e.errorMessage??void 0}}async getDeliveryStatus(r){let e=await this.client.messages(r).fetch();return{status:t(e.status),errorCode:e.errorCode?String(e.errorCode):void 0,errorMessage:e.errorMessage??void 0,updatedAt:e.dateUpdated?new Date(e.dateUpdated):new Date}}}function t(r){switch(r){case"queued":case"accepted":case"scheduled":return"queued";case"sending":case"processing":return"sending";case"sent":return"sent";case"delivered":return"delivered";case"undelivered":return"undelivered";case"failed":case"canceled":return"failed";default:return"queued"}}export{i as TwilioSmsProvider};
|