integrate-sdk 0.9.54-dev.0 → 0.9.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/adapters/index.js +2364 -0
  2. package/dist/adapters/solid-start.js +2364 -0
  3. package/dist/adapters/svelte-kit.js +2364 -0
  4. package/dist/database/adapters/drizzle.d.ts +23 -0
  5. package/dist/database/adapters/drizzle.d.ts.map +1 -0
  6. package/dist/database/adapters/drizzle.js +646 -0
  7. package/dist/database/adapters/mongodb.d.ts +17 -0
  8. package/dist/database/adapters/mongodb.d.ts.map +1 -0
  9. package/dist/database/adapters/mongodb.js +643 -0
  10. package/dist/database/adapters/prisma.d.ts +18 -0
  11. package/dist/database/adapters/prisma.d.ts.map +1 -0
  12. package/dist/database/adapters/prisma.js +679 -0
  13. package/dist/database/index.d.ts +9 -0
  14. package/dist/database/index.d.ts.map +1 -0
  15. package/dist/database/index.js +1128 -0
  16. package/dist/server.js +3515 -1
  17. package/dist/src/config/types.d.ts +25 -1
  18. package/dist/src/config/types.d.ts.map +1 -1
  19. package/dist/src/database/adapters/drizzle.d.ts +23 -0
  20. package/dist/src/database/adapters/drizzle.d.ts.map +1 -0
  21. package/dist/src/database/adapters/mongodb.d.ts +17 -0
  22. package/dist/src/database/adapters/mongodb.d.ts.map +1 -0
  23. package/dist/src/database/adapters/prisma.d.ts +18 -0
  24. package/dist/src/database/adapters/prisma.d.ts.map +1 -0
  25. package/dist/src/database/factory.d.ts +9 -0
  26. package/dist/src/database/factory.d.ts.map +1 -0
  27. package/dist/src/database/index.d.ts +9 -0
  28. package/dist/src/database/index.d.ts.map +1 -0
  29. package/dist/src/database/schemas/drizzle.d.ts +508 -0
  30. package/dist/src/database/schemas/drizzle.d.ts.map +1 -0
  31. package/dist/src/database/token-store.d.ts +18 -0
  32. package/dist/src/database/token-store.d.ts.map +1 -0
  33. package/dist/src/database/trigger-store.d.ts +23 -0
  34. package/dist/src/database/trigger-store.d.ts.map +1 -0
  35. package/dist/src/database/types.d.ts +132 -0
  36. package/dist/src/database/types.d.ts.map +1 -0
  37. package/dist/src/integrations/integration-docs-metadata.d.ts +40 -0
  38. package/dist/src/integrations/integration-docs-metadata.d.ts.map +1 -0
  39. package/dist/src/server.d.ts +4 -3
  40. package/dist/src/server.d.ts.map +1 -1
  41. package/package.json +32 -5
@@ -0,0 +1,1128 @@
1
+ // src/database/token-store.ts
2
+ var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
3
+ var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
4
+ function getRowUpdatedAtMs(row) {
5
+ return row.updatedAt instanceof Date ? row.updatedAt.getTime() : 0;
6
+ }
7
+ function normalizeAccountEmail(value) {
8
+ if (!value)
9
+ return null;
10
+ const normalized = value.trim().toLowerCase();
11
+ return normalized.length > 0 ? normalized : null;
12
+ }
13
+ function normalizeAccountEmailHint(value) {
14
+ const normalized = normalizeAccountEmail(value);
15
+ if (!normalized)
16
+ return null;
17
+ return normalized.includes("@") ? normalized : null;
18
+ }
19
+ function normalizeAccountIdentifier(value) {
20
+ return normalizeAccountEmail(value);
21
+ }
22
+ function normalizeAccountIdHint(value) {
23
+ if (!value)
24
+ return null;
25
+ const normalized = value.trim().toLowerCase();
26
+ return normalized.length > 0 ? normalized : null;
27
+ }
28
+ function normalizeProviderTokenType(value) {
29
+ const normalized = value?.trim();
30
+ return normalized && normalized.length > 0 ? normalized : "Bearer";
31
+ }
32
+ function hasMeaningfulExpiresAt(value) {
33
+ if (!value)
34
+ return false;
35
+ const ms = value.getTime();
36
+ return Number.isFinite(ms) && ms >= MIN_MEANINGFUL_EXPIRY_MS;
37
+ }
38
+ function hasUsableAccessToken(row, now = Date.now(), bufferMs = USABLE_ACCESS_TOKEN_BUFFER_MS) {
39
+ if (!row.accessToken)
40
+ return false;
41
+ const expiresAt = row.expiresAt;
42
+ if (!hasMeaningfulExpiresAt(expiresAt))
43
+ return true;
44
+ return expiresAt.getTime() > now + bufferMs;
45
+ }
46
+ function isLikelyUsableToken(row, now = Date.now()) {
47
+ return hasUsableAccessToken(row, now) || Boolean(row.refreshToken);
48
+ }
49
+ function parseScopes(scope) {
50
+ if (!scope)
51
+ return;
52
+ const scopes = scope.split(" ").map((item) => item.trim()).filter((item) => item.length > 0);
53
+ return scopes.length > 0 ? scopes : undefined;
54
+ }
55
+ function choosePreferredTokenRow(rows) {
56
+ if (rows.length === 0)
57
+ return;
58
+ const sorted = [...rows].sort((left, right) => getRowUpdatedAtMs(right) - getRowUpdatedAtMs(left));
59
+ return sorted.find((row) => hasUsableAccessToken(row)) ?? sorted.find((row) => Boolean(row.refreshToken)) ?? sorted[0];
60
+ }
61
+ function selectProviderTokenRow(rows, email, accountId) {
62
+ if (rows.length === 0) {
63
+ return;
64
+ }
65
+ const normalizedEmail = normalizeAccountEmailHint(email);
66
+ const normalizedAccountId = normalizeAccountIdHint(accountId);
67
+ if (normalizedAccountId && normalizedEmail) {
68
+ const exactBoth = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedAccountId && normalizeAccountEmail(row.accountEmail) === normalizedEmail);
69
+ if (exactBoth.length > 0) {
70
+ return choosePreferredTokenRow(exactBoth);
71
+ }
72
+ }
73
+ if (normalizedAccountId) {
74
+ const exactAccountId = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedAccountId);
75
+ if (exactAccountId.length > 0) {
76
+ return choosePreferredTokenRow(exactAccountId);
77
+ }
78
+ }
79
+ if (normalizedEmail) {
80
+ const exactEmail = rows.filter((row) => normalizeAccountEmail(row.accountEmail) === normalizedEmail);
81
+ if (exactEmail.length > 0) {
82
+ return choosePreferredTokenRow(exactEmail);
83
+ }
84
+ } else if (email) {
85
+ const normalizedIdentifier = normalizeAccountIdentifier(email);
86
+ if (normalizedIdentifier) {
87
+ const identifierMatches = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedIdentifier);
88
+ if (identifierMatches.length > 0) {
89
+ return choosePreferredTokenRow(identifierMatches);
90
+ }
91
+ }
92
+ }
93
+ if (normalizedAccountId || normalizedEmail) {
94
+ const legacyRows = rows.filter((row) => !normalizeAccountIdHint(row.accountId) && !normalizeAccountEmail(row.accountEmail));
95
+ if (legacyRows.length === 1) {
96
+ return choosePreferredTokenRow(legacyRows);
97
+ }
98
+ return;
99
+ }
100
+ return choosePreferredTokenRow(rows);
101
+ }
102
+ function providerTokenRecordToData(row) {
103
+ const expiresAt = hasMeaningfulExpiresAt(row.expiresAt) ? row.expiresAt : null;
104
+ const expiresIn = expiresAt ? Math.max(0, Math.floor((expiresAt.getTime() - Date.now()) / 1000)) : 3600;
105
+ return {
106
+ accessToken: row.accessToken,
107
+ refreshToken: row.refreshToken ?? undefined,
108
+ tokenType: normalizeProviderTokenType(row.tokenType),
109
+ expiresIn,
110
+ expiresAt: expiresAt?.toISOString(),
111
+ scopes: parseScopes(row.scope),
112
+ email: row.accountEmail ?? undefined,
113
+ accountId: row.accountId ?? undefined
114
+ };
115
+ }
116
+ function defaultResolveAccountIdentity(provider, tokenData, emailHint) {
117
+ const accountEmail = normalizeAccountEmail(emailHint ?? tokenData.email ?? null);
118
+ let accountId = normalizeAccountIdHint(tokenData.accountId ?? null);
119
+ if (!accountId && accountEmail) {
120
+ accountId = `${provider}:${accountEmail}`;
121
+ }
122
+ return { accountEmail, accountId };
123
+ }
124
+
125
+ // src/database/trigger-store.ts
126
+ function toIsoString(value) {
127
+ if (!value)
128
+ return null;
129
+ if (value instanceof Date) {
130
+ return Number.isNaN(value.getTime()) ? null : value.toISOString();
131
+ }
132
+ const parsed = new Date(value);
133
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
134
+ }
135
+ function toDbSchedule(value) {
136
+ if (value.scheduleType && value.scheduleValue) {
137
+ return {
138
+ scheduleType: value.scheduleType,
139
+ scheduleValue: value.scheduleValue
140
+ };
141
+ }
142
+ if (value.schedule.type === "once") {
143
+ const runAt = toIsoString(value.schedule.runAt);
144
+ if (!runAt) {
145
+ throw new Error("Invalid trigger once schedule");
146
+ }
147
+ return {
148
+ scheduleType: "once",
149
+ scheduleValue: runAt
150
+ };
151
+ }
152
+ return {
153
+ scheduleType: "cron",
154
+ scheduleValue: value.schedule.expression
155
+ };
156
+ }
157
+ function toSdkSchedule(row) {
158
+ if (row.scheduleType === "once") {
159
+ return {
160
+ type: "once",
161
+ runAt: row.scheduleValue
162
+ };
163
+ }
164
+ return {
165
+ type: "cron",
166
+ expression: row.scheduleValue
167
+ };
168
+ }
169
+ function toSdkTrigger(row) {
170
+ return {
171
+ id: row.id,
172
+ userId: row.userId ?? undefined,
173
+ name: row.name ?? undefined,
174
+ description: row.description ?? undefined,
175
+ toolName: row.toolName,
176
+ toolArguments: row.toolArguments ?? {},
177
+ schedule: toSdkSchedule(row),
178
+ status: row.status,
179
+ provider: row.provider ?? undefined,
180
+ createdAt: row.createdAt.toISOString(),
181
+ updatedAt: row.updatedAt.toISOString(),
182
+ lastRunAt: toIsoString(row.lastRunAt) ?? undefined,
183
+ nextRunAt: toIsoString(row.nextRunAt) ?? undefined,
184
+ runCount: row.runCount,
185
+ lastError: row.lastError ?? undefined,
186
+ lastResult: row.lastResult ?? undefined
187
+ };
188
+ }
189
+ function toDbTriggerUpdates(updates) {
190
+ const dbUpdates = {
191
+ updatedAt: new Date
192
+ };
193
+ if (updates.name !== undefined)
194
+ dbUpdates.name = updates.name ?? null;
195
+ if (updates.description !== undefined) {
196
+ dbUpdates.description = updates.description ?? null;
197
+ }
198
+ if (updates.toolArguments !== undefined) {
199
+ dbUpdates.toolArguments = updates.toolArguments;
200
+ }
201
+ if (updates.status !== undefined)
202
+ dbUpdates.status = updates.status;
203
+ if (updates.provider !== undefined)
204
+ dbUpdates.provider = updates.provider ?? null;
205
+ if (updates.lastError !== undefined)
206
+ dbUpdates.lastError = updates.lastError ?? null;
207
+ if (updates.lastResult !== undefined) {
208
+ dbUpdates.lastResult = updates.lastResult ?? null;
209
+ }
210
+ if (updates.lastRunAt !== undefined) {
211
+ dbUpdates.lastRunAt = updates.lastRunAt ? new Date(updates.lastRunAt) : null;
212
+ }
213
+ if (updates.nextRunAt !== undefined) {
214
+ dbUpdates.nextRunAt = updates.nextRunAt ? new Date(updates.nextRunAt) : null;
215
+ }
216
+ if (updates.runCount !== undefined)
217
+ dbUpdates.runCount = updates.runCount;
218
+ if (updates.schedule) {
219
+ if (updates.schedule.type === "once") {
220
+ dbUpdates.scheduleType = "once";
221
+ dbUpdates.scheduleValue = new Date(updates.schedule.runAt).toISOString();
222
+ } else {
223
+ dbUpdates.scheduleType = "cron";
224
+ dbUpdates.scheduleValue = updates.schedule.expression;
225
+ }
226
+ }
227
+ return dbUpdates;
228
+ }
229
+ function flattenedTriggerToCreateInput(triggerData, contextUserId) {
230
+ const schedule = toDbSchedule(triggerData);
231
+ return {
232
+ id: triggerData.id,
233
+ userId: contextUserId ?? triggerData.userId ?? null,
234
+ name: triggerData.name ?? null,
235
+ description: triggerData.description ?? null,
236
+ toolName: triggerData.toolName,
237
+ toolArguments: triggerData.toolArguments ?? {},
238
+ scheduleType: schedule.scheduleType,
239
+ scheduleValue: schedule.scheduleValue,
240
+ status: triggerData.status ?? "active",
241
+ provider: triggerData.provider ?? null,
242
+ nextRunAt: triggerData.nextRunAt ? new Date(triggerData.nextRunAt) : null
243
+ };
244
+ }
245
+
246
+ // src/database/factory.ts
247
+ function log(debug, message, error) {
248
+ if (!debug)
249
+ return;
250
+ if (error !== undefined) {
251
+ console.error(`[Integrate SDK] ${message}`, error);
252
+ return;
253
+ }
254
+ console.log(`[Integrate SDK] ${message}`);
255
+ }
256
+ async function authorizeTriggerRow(row, context, hooks) {
257
+ if (!row)
258
+ return null;
259
+ const repaired = hooks?.authorizeTrigger ? await hooks.authorizeTrigger(row, context) : row;
260
+ if (!repaired)
261
+ return null;
262
+ if (context?.userId && repaired.userId !== context.userId) {
263
+ return null;
264
+ }
265
+ return repaired;
266
+ }
267
+ function createDatabaseAdapterCallbacks(options) {
268
+ const { driver, hooks, debugLogs } = options;
269
+ const getProviderToken = async (provider, email, context) => {
270
+ const userId = context?.userId;
271
+ if (!userId) {
272
+ return;
273
+ }
274
+ const accountEmailHint = normalizeAccountEmailHint(email) ?? normalizeAccountEmailHint(typeof context?.accountEmail === "string" ? context.accountEmail : null);
275
+ const accountIdHint = normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null);
276
+ try {
277
+ const rows = await driver.tokens.listProviderTokens(userId, provider);
278
+ const selectedRow = selectProviderTokenRow(rows, accountEmailHint ?? undefined, accountIdHint ?? undefined);
279
+ if (!selectedRow) {
280
+ return;
281
+ }
282
+ return providerTokenRecordToData(selectedRow);
283
+ } catch (error) {
284
+ log(debugLogs, "Error fetching provider token:", error);
285
+ return;
286
+ }
287
+ };
288
+ const setProviderToken = async (provider, tokenData, email, context) => {
289
+ const userId = context?.userId;
290
+ if (!userId) {
291
+ console.error("[Integrate SDK] Cannot save token: No userId in context");
292
+ return;
293
+ }
294
+ const accountEmail = normalizeAccountEmailHint(email) ?? normalizeAccountEmail(tokenData?.email ?? null);
295
+ if (tokenData === null) {
296
+ try {
297
+ await driver.tokens.deleteProviderTokens({
298
+ userId,
299
+ provider,
300
+ accountEmail,
301
+ accountId: normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null)
302
+ });
303
+ await hooks?.onTokenChange?.({ userId, provider, action: "remove" });
304
+ } catch (error) {
305
+ log(debugLogs, "Error deleting provider token:", error);
306
+ throw error;
307
+ }
308
+ return;
309
+ }
310
+ try {
311
+ const resolvedIdentity = hooks?.resolveAccountIdentity ? await hooks.resolveAccountIdentity(provider, tokenData, accountEmail, context) : defaultResolveAccountIdentity(provider, tokenData, accountEmail);
312
+ const resolvedAccountEmail = resolvedIdentity.accountEmail;
313
+ const resolvedAccountId = normalizeAccountIdHint(resolvedIdentity.accountId) ?? normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null) ?? null;
314
+ const rows = await driver.tokens.listProviderTokens(userId, provider);
315
+ let existing = selectProviderTokenRow(rows, resolvedAccountEmail ?? accountEmail ?? undefined, resolvedAccountId ?? undefined) ?? rows.find((row) => {
316
+ const sameEmail = resolvedAccountEmail && normalizeAccountEmail(row.accountEmail) === resolvedAccountEmail;
317
+ const sameAccountId = resolvedAccountId && normalizeAccountIdHint(row.accountId) === resolvedAccountId;
318
+ return Boolean(sameEmail || sameAccountId);
319
+ }) ?? (rows.length === 1 ? rows[0] : undefined);
320
+ const parsedExpiresAt = tokenData.expiresAt ? new Date(tokenData.expiresAt) : null;
321
+ const expiresAt = hasMeaningfulExpiresAt(parsedExpiresAt) ? parsedExpiresAt : null;
322
+ const scope = tokenData.scopes?.join(" ") ?? null;
323
+ const saved = await driver.tokens.upsertProviderToken({
324
+ existingId: existing?.id,
325
+ id: existing?.id ?? `${userId}-${provider}-${resolvedAccountEmail ?? "default"}-${Date.now()}`,
326
+ userId,
327
+ provider,
328
+ accountEmail: resolvedAccountEmail,
329
+ accountId: resolvedAccountId,
330
+ accessToken: tokenData.accessToken,
331
+ refreshToken: tokenData.refreshToken ?? null,
332
+ tokenType: normalizeProviderTokenType(tokenData.tokenType),
333
+ expiresAt,
334
+ scope
335
+ });
336
+ await driver.tokens.deleteDuplicateProviderTokens({
337
+ keepId: saved.id,
338
+ userId,
339
+ provider,
340
+ accountEmail: resolvedAccountEmail,
341
+ accountId: resolvedAccountId
342
+ });
343
+ await hooks?.onTokenChange?.({ userId, provider, action: "set" });
344
+ } catch (error) {
345
+ log(debugLogs, "Error saving provider token:", error);
346
+ throw error;
347
+ }
348
+ };
349
+ const removeProviderToken = async (provider, email, context) => {
350
+ const userId = context?.userId;
351
+ if (!userId) {
352
+ console.error("[Integrate SDK] Cannot delete token: No userId in context");
353
+ return;
354
+ }
355
+ try {
356
+ await driver.tokens.deleteProviderTokens({
357
+ userId,
358
+ provider,
359
+ accountEmail: normalizeAccountEmail(email)
360
+ });
361
+ await hooks?.onTokenChange?.({ userId, provider, action: "remove" });
362
+ } catch (error) {
363
+ log(debugLogs, "Error deleting provider token:", error);
364
+ throw error;
365
+ }
366
+ };
367
+ const callbacks = {
368
+ getProviderToken,
369
+ setProviderToken,
370
+ removeProviderToken
371
+ };
372
+ if (driver.triggers) {
373
+ const triggerDriver = driver.triggers;
374
+ const triggers = {
375
+ create: async (triggerData, context) => {
376
+ try {
377
+ const created = await triggerDriver.createTrigger(flattenedTriggerToCreateInput(triggerData, context?.userId));
378
+ return toSdkTrigger(created);
379
+ } catch (error) {
380
+ log(debugLogs, "Error creating trigger:", error);
381
+ throw error;
382
+ }
383
+ },
384
+ get: async (triggerId, context) => {
385
+ try {
386
+ const found = await triggerDriver.getTriggerById(triggerId);
387
+ const authorized = await authorizeTriggerRow(found, context, hooks);
388
+ return authorized ? toSdkTrigger(authorized) : null;
389
+ } catch (error) {
390
+ log(debugLogs, "Error getting trigger:", error);
391
+ throw error;
392
+ }
393
+ },
394
+ list: async (params, context) => {
395
+ try {
396
+ const { rows, total } = await triggerDriver.listTriggers({
397
+ userId: context?.userId,
398
+ status: params.status,
399
+ toolName: params.toolName,
400
+ limit: params.limit ?? 20,
401
+ offset: params.offset ?? 0
402
+ });
403
+ const triggers2 = [];
404
+ for (const row of rows) {
405
+ const authorized = await authorizeTriggerRow(row, context, hooks);
406
+ if (authorized) {
407
+ triggers2.push(toSdkTrigger(authorized));
408
+ }
409
+ }
410
+ return { triggers: triggers2, total };
411
+ } catch (error) {
412
+ log(debugLogs, "Error listing triggers:", error);
413
+ throw error;
414
+ }
415
+ },
416
+ update: async (triggerId, updates, context) => {
417
+ try {
418
+ const existing = await triggerDriver.getTriggerById(triggerId);
419
+ const authorized = await authorizeTriggerRow(existing, context, hooks);
420
+ if (!authorized) {
421
+ throw new Error(`Trigger not found: ${triggerId}`);
422
+ }
423
+ const updated = await triggerDriver.updateTrigger(authorized.id, toDbTriggerUpdates(updates));
424
+ if (!updated) {
425
+ throw new Error(`Trigger not found: ${triggerId}`);
426
+ }
427
+ return toSdkTrigger(updated);
428
+ } catch (error) {
429
+ log(debugLogs, "Error updating trigger:", error);
430
+ throw error;
431
+ }
432
+ },
433
+ delete: async (triggerId, context) => {
434
+ try {
435
+ const existing = await triggerDriver.getTriggerById(triggerId);
436
+ const authorized = await authorizeTriggerRow(existing, context, hooks);
437
+ if (!authorized) {
438
+ return;
439
+ }
440
+ await triggerDriver.deleteTrigger(authorized.id);
441
+ } catch (error) {
442
+ log(debugLogs, "Error deleting trigger:", error);
443
+ throw error;
444
+ }
445
+ }
446
+ };
447
+ callbacks.triggers = triggers;
448
+ }
449
+ return callbacks;
450
+ }
451
+ function createDatabaseAdapterFactory(createDriver, options) {
452
+ return () => createDatabaseAdapterCallbacks({
453
+ driver: createDriver(),
454
+ hooks: options?.hooks,
455
+ debugLogs: options?.debugLogs
456
+ });
457
+ }
458
+ // src/database/adapters/drizzle.ts
459
+ import { and, count, desc, eq, ne, or } from "drizzle-orm";
460
+ function mapProviderTokenRow(row) {
461
+ return {
462
+ id: String(row.id),
463
+ userId: String(row.userId),
464
+ provider: String(row.provider),
465
+ accountEmail: row.accountEmail ?? null,
466
+ accountId: row.accountId ?? null,
467
+ accessToken: String(row.accessToken),
468
+ refreshToken: row.refreshToken ?? null,
469
+ tokenType: String(row.tokenType ?? "Bearer"),
470
+ expiresAt: row.expiresAt ?? null,
471
+ scope: row.scope ?? null,
472
+ createdAt: row.createdAt,
473
+ updatedAt: row.updatedAt
474
+ };
475
+ }
476
+ function mapTriggerRow(row) {
477
+ return {
478
+ id: String(row.id),
479
+ userId: row.userId ?? null,
480
+ name: row.name ?? null,
481
+ description: row.description ?? null,
482
+ toolName: String(row.toolName),
483
+ toolArguments: row.toolArguments ?? {},
484
+ scheduleType: row.scheduleType,
485
+ scheduleValue: String(row.scheduleValue),
486
+ status: String(row.status),
487
+ provider: row.provider ?? null,
488
+ lastRunAt: row.lastRunAt ?? null,
489
+ nextRunAt: row.nextRunAt ?? null,
490
+ runCount: Number(row.runCount ?? 0),
491
+ lastError: row.lastError ?? null,
492
+ lastResult: row.lastResult ?? null,
493
+ createdAt: row.createdAt,
494
+ updatedAt: row.updatedAt
495
+ };
496
+ }
497
+ function createDrizzleTokenDriver(db, table) {
498
+ const t = table;
499
+ return {
500
+ async listProviderTokens(userId, provider) {
501
+ const rows = await db.select().from(table).where(and(eq(t.userId, userId), eq(t.provider, provider))).orderBy(desc(t.updatedAt)).limit(32);
502
+ return rows.map((row) => mapProviderTokenRow(row));
503
+ },
504
+ async upsertProviderToken(input) {
505
+ const now = new Date;
506
+ const values = {
507
+ id: input.existingId ?? input.id,
508
+ userId: input.userId,
509
+ provider: input.provider,
510
+ accountEmail: input.accountEmail,
511
+ accountId: input.accountId,
512
+ accessToken: input.accessToken,
513
+ refreshToken: input.refreshToken,
514
+ tokenType: input.tokenType,
515
+ expiresAt: input.expiresAt,
516
+ scope: input.scope,
517
+ updatedAt: now,
518
+ ...input.existingId ? {} : { createdAt: now }
519
+ };
520
+ if (input.existingId) {
521
+ const [updated] = await db.update(table).set(values).where(eq(t.id, input.existingId)).returning();
522
+ return mapProviderTokenRow(updated);
523
+ }
524
+ const [created] = await db.insert(table).values(values).returning();
525
+ return mapProviderTokenRow(created);
526
+ },
527
+ async deleteProviderTokens(input) {
528
+ const conditions = [
529
+ eq(t.userId, input.userId),
530
+ eq(t.provider, input.provider)
531
+ ];
532
+ if (input.accountEmail) {
533
+ conditions.push(eq(t.accountEmail, input.accountEmail));
534
+ } else if (input.accountId) {
535
+ conditions.push(eq(t.accountId, input.accountId));
536
+ }
537
+ await db.delete(table).where(and(...conditions));
538
+ },
539
+ async deleteDuplicateProviderTokens(input) {
540
+ const normalizedEmail = normalizeAccountEmail(input.accountEmail);
541
+ const normalizedAccountId = normalizeAccountIdHint(input.accountId);
542
+ if (!normalizedEmail && !normalizedAccountId) {
543
+ return;
544
+ }
545
+ const duplicateConditions = [
546
+ eq(t.userId, input.userId),
547
+ eq(t.provider, input.provider),
548
+ ne(t.id, input.keepId)
549
+ ];
550
+ const identityConditions = [];
551
+ if (normalizedEmail) {
552
+ identityConditions.push(eq(t.accountEmail, normalizedEmail));
553
+ }
554
+ if (normalizedAccountId) {
555
+ identityConditions.push(eq(t.accountId, normalizedAccountId));
556
+ }
557
+ if (identityConditions.length === 0) {
558
+ return;
559
+ }
560
+ await db.delete(table).where(and(...duplicateConditions, or(...identityConditions)));
561
+ }
562
+ };
563
+ }
564
+ function createDrizzleTriggerDriver(db, table) {
565
+ const t = table;
566
+ return {
567
+ async createTrigger(input) {
568
+ const now = new Date;
569
+ const [created] = await db.insert(table).values({
570
+ id: input.id,
571
+ userId: input.userId,
572
+ name: input.name ?? null,
573
+ description: input.description ?? null,
574
+ toolName: input.toolName,
575
+ toolArguments: input.toolArguments,
576
+ scheduleType: input.scheduleType,
577
+ scheduleValue: input.scheduleValue,
578
+ status: input.status,
579
+ provider: input.provider ?? null,
580
+ nextRunAt: input.nextRunAt ?? null,
581
+ createdAt: now,
582
+ updatedAt: now
583
+ }).returning();
584
+ return mapTriggerRow(created);
585
+ },
586
+ async getTriggerById(triggerId) {
587
+ const [found] = await db.select().from(table).where(eq(t.id, triggerId)).limit(1);
588
+ return found ? mapTriggerRow(found) : null;
589
+ },
590
+ async listTriggers(query) {
591
+ const conditions = [];
592
+ if (query.userId) {
593
+ conditions.push(eq(t.userId, query.userId));
594
+ }
595
+ if (query.status) {
596
+ conditions.push(eq(t.status, query.status));
597
+ }
598
+ if (query.toolName) {
599
+ conditions.push(eq(t.toolName, query.toolName));
600
+ }
601
+ const whereClause = conditions.length > 0 ? and(...conditions) : undefined;
602
+ const rows = await db.select().from(table).where(whereClause).limit(query.limit).offset(query.offset);
603
+ const [totalResult] = await db.select({ count: count() }).from(table).where(whereClause);
604
+ return {
605
+ rows: rows.map((row) => mapTriggerRow(row)),
606
+ total: Number(totalResult?.count ?? 0)
607
+ };
608
+ },
609
+ async updateTrigger(triggerId, updates) {
610
+ const [updated] = await db.update(table).set(updates).where(eq(t.id, triggerId)).returning();
611
+ return updated ? mapTriggerRow(updated) : null;
612
+ },
613
+ async deleteTrigger(triggerId) {
614
+ await db.delete(table).where(eq(t.id, triggerId));
615
+ }
616
+ };
617
+ }
618
+ function createDrizzleDatabaseDriver(db, schema) {
619
+ const driver = {
620
+ tokens: createDrizzleTokenDriver(db, schema.providerToken)
621
+ };
622
+ if (schema.trigger) {
623
+ driver.triggers = createDrizzleTriggerDriver(db, schema.trigger);
624
+ }
625
+ return driver;
626
+ }
627
+ function drizzleAdapter(db, config) {
628
+ config.provider;
629
+ const driver = () => createDrizzleDatabaseDriver(db, config.schema);
630
+ return createDatabaseAdapterFactory(driver, {
631
+ hooks: config.hooks,
632
+ debugLogs: config.debugLogs
633
+ });
634
+ }
635
+ function drizzleAdapterCallbacks(db, config) {
636
+ return createDatabaseAdapterCallbacks({
637
+ driver: createDrizzleDatabaseDriver(db, config.schema),
638
+ hooks: config.hooks,
639
+ debugLogs: config.debugLogs
640
+ });
641
+ }
642
+ // src/database/adapters/prisma.ts
643
+ var DEFAULT_MODEL_NAMES = {
644
+ providerToken: "providerToken",
645
+ trigger: "trigger"
646
+ };
647
+ function getModel(client, name) {
648
+ const model = client[name];
649
+ if (!model) {
650
+ throw new Error(`[Integrate SDK] Prisma model "${name}" was not found on the client`);
651
+ }
652
+ return model;
653
+ }
654
+ function mapProviderTokenRow2(row) {
655
+ return {
656
+ id: String(row.id),
657
+ userId: String(row.userId),
658
+ provider: String(row.provider),
659
+ accountEmail: row.accountEmail ?? null,
660
+ accountId: row.accountId ?? null,
661
+ accessToken: String(row.accessToken),
662
+ refreshToken: row.refreshToken ?? null,
663
+ tokenType: String(row.tokenType ?? "Bearer"),
664
+ expiresAt: row.expiresAt ?? null,
665
+ scope: row.scope ?? null,
666
+ createdAt: row.createdAt,
667
+ updatedAt: row.updatedAt
668
+ };
669
+ }
670
+ function mapTriggerRow2(row) {
671
+ return {
672
+ id: String(row.id),
673
+ userId: row.userId ?? null,
674
+ name: row.name ?? null,
675
+ description: row.description ?? null,
676
+ toolName: String(row.toolName),
677
+ toolArguments: row.toolArguments ?? {},
678
+ scheduleType: row.scheduleType,
679
+ scheduleValue: String(row.scheduleValue),
680
+ status: String(row.status),
681
+ provider: row.provider ?? null,
682
+ lastRunAt: row.lastRunAt ?? null,
683
+ nextRunAt: row.nextRunAt ?? null,
684
+ runCount: Number(row.runCount ?? 0),
685
+ lastError: row.lastError ?? null,
686
+ lastResult: row.lastResult ?? null,
687
+ createdAt: row.createdAt,
688
+ updatedAt: row.updatedAt
689
+ };
690
+ }
691
+ function createPrismaTokenDriver(prisma, modelName) {
692
+ const model = () => getModel(prisma, modelName);
693
+ return {
694
+ async listProviderTokens(userId, provider) {
695
+ const rows = await model().findMany({
696
+ where: { userId, provider },
697
+ orderBy: { updatedAt: "desc" },
698
+ take: 32
699
+ });
700
+ return rows.map((row) => mapProviderTokenRow2(row));
701
+ },
702
+ async upsertProviderToken(input) {
703
+ const now = new Date;
704
+ const data = {
705
+ userId: input.userId,
706
+ provider: input.provider,
707
+ accountEmail: input.accountEmail,
708
+ accountId: input.accountId,
709
+ accessToken: input.accessToken,
710
+ refreshToken: input.refreshToken,
711
+ tokenType: input.tokenType,
712
+ expiresAt: input.expiresAt,
713
+ scope: input.scope,
714
+ updatedAt: now
715
+ };
716
+ if (input.existingId) {
717
+ const updated = await model().update({
718
+ where: { id: input.existingId },
719
+ data
720
+ });
721
+ return mapProviderTokenRow2(updated);
722
+ }
723
+ const created = await model().create({
724
+ data: {
725
+ id: input.id,
726
+ ...data,
727
+ createdAt: now
728
+ }
729
+ });
730
+ return mapProviderTokenRow2(created);
731
+ },
732
+ async deleteProviderTokens(input) {
733
+ const where = {
734
+ userId: input.userId,
735
+ provider: input.provider
736
+ };
737
+ if (input.accountEmail) {
738
+ where.accountEmail = input.accountEmail;
739
+ } else if (input.accountId) {
740
+ where.accountId = input.accountId;
741
+ }
742
+ await model().deleteMany({ where });
743
+ },
744
+ async deleteDuplicateProviderTokens(input) {
745
+ const normalizedEmail = normalizeAccountEmail(input.accountEmail);
746
+ const normalizedAccountId = normalizeAccountIdHint(input.accountId);
747
+ if (!normalizedEmail && !normalizedAccountId) {
748
+ return;
749
+ }
750
+ const orConditions = [];
751
+ if (normalizedEmail) {
752
+ orConditions.push({ accountEmail: normalizedEmail });
753
+ }
754
+ if (normalizedAccountId) {
755
+ orConditions.push({ accountId: normalizedAccountId });
756
+ }
757
+ await model().deleteMany({
758
+ where: {
759
+ userId: input.userId,
760
+ provider: input.provider,
761
+ id: { not: input.keepId },
762
+ OR: orConditions
763
+ }
764
+ });
765
+ }
766
+ };
767
+ }
768
+ function createPrismaTriggerDriver(prisma, modelName) {
769
+ const model = () => getModel(prisma, modelName);
770
+ return {
771
+ async createTrigger(input) {
772
+ const now = new Date;
773
+ const created = await model().create({
774
+ data: {
775
+ id: input.id,
776
+ userId: input.userId,
777
+ name: input.name ?? null,
778
+ description: input.description ?? null,
779
+ toolName: input.toolName,
780
+ toolArguments: input.toolArguments,
781
+ scheduleType: input.scheduleType,
782
+ scheduleValue: input.scheduleValue,
783
+ status: input.status,
784
+ provider: input.provider ?? null,
785
+ nextRunAt: input.nextRunAt ?? null,
786
+ createdAt: now,
787
+ updatedAt: now
788
+ }
789
+ });
790
+ return mapTriggerRow2(created);
791
+ },
792
+ async getTriggerById(triggerId) {
793
+ const found = await model().findFirst({ where: { id: triggerId } });
794
+ return found ? mapTriggerRow2(found) : null;
795
+ },
796
+ async listTriggers(query) {
797
+ const where = {};
798
+ if (query.userId)
799
+ where.userId = query.userId;
800
+ if (query.status)
801
+ where.status = query.status;
802
+ if (query.toolName)
803
+ where.toolName = query.toolName;
804
+ const [rows, total] = await Promise.all([
805
+ model().findMany({
806
+ where,
807
+ take: query.limit,
808
+ skip: query.offset,
809
+ orderBy: { updatedAt: "desc" }
810
+ }),
811
+ model().count({ where })
812
+ ]);
813
+ return {
814
+ rows: rows.map((row) => mapTriggerRow2(row)),
815
+ total
816
+ };
817
+ },
818
+ async updateTrigger(triggerId, updates) {
819
+ try {
820
+ const updated = await model().update({
821
+ where: { id: triggerId },
822
+ data: updates
823
+ });
824
+ return mapTriggerRow2(updated);
825
+ } catch {
826
+ return null;
827
+ }
828
+ },
829
+ async deleteTrigger(triggerId) {
830
+ await model().delete({ where: { id: triggerId } });
831
+ }
832
+ };
833
+ }
834
+ function createPrismaDatabaseDriver(prisma, config) {
835
+ const modelNames = {
836
+ ...DEFAULT_MODEL_NAMES,
837
+ ...config.modelNames
838
+ };
839
+ const driver = {
840
+ tokens: createPrismaTokenDriver(prisma, modelNames.providerToken)
841
+ };
842
+ if (config.modelNames?.trigger !== null) {
843
+ driver.triggers = createPrismaTriggerDriver(prisma, modelNames.trigger);
844
+ }
845
+ return driver;
846
+ }
847
+ function prismaAdapter(prisma, config) {
848
+ config.provider;
849
+ return createDatabaseAdapterFactory(() => createPrismaDatabaseDriver(prisma, config), {
850
+ hooks: config.hooks,
851
+ debugLogs: config.debugLogs
852
+ });
853
+ }
854
+ function prismaAdapterCallbacks(prisma, config) {
855
+ return createDatabaseAdapterCallbacks({
856
+ driver: createPrismaDatabaseDriver(prisma, config),
857
+ hooks: config.hooks,
858
+ debugLogs: config.debugLogs
859
+ });
860
+ }
861
+ // src/database/adapters/mongodb.ts
862
+ var DEFAULT_COLLECTIONS = {
863
+ providerTokens: "provider_tokens",
864
+ triggers: "triggers"
865
+ };
866
+ function mapProviderTokenDoc(doc) {
867
+ return {
868
+ id: String(doc.id),
869
+ userId: String(doc.userId),
870
+ provider: String(doc.provider),
871
+ accountEmail: doc.accountEmail ?? null,
872
+ accountId: doc.accountId ?? null,
873
+ accessToken: String(doc.accessToken),
874
+ refreshToken: doc.refreshToken ?? null,
875
+ tokenType: String(doc.tokenType ?? "Bearer"),
876
+ expiresAt: doc.expiresAt ? new Date(doc.expiresAt) : null,
877
+ scope: doc.scope ?? null,
878
+ createdAt: new Date(doc.createdAt),
879
+ updatedAt: new Date(doc.updatedAt)
880
+ };
881
+ }
882
+ function mapTriggerDoc(doc) {
883
+ return {
884
+ id: String(doc.id),
885
+ userId: doc.userId ?? null,
886
+ name: doc.name ?? null,
887
+ description: doc.description ?? null,
888
+ toolName: String(doc.toolName),
889
+ toolArguments: doc.toolArguments ?? {},
890
+ scheduleType: doc.scheduleType,
891
+ scheduleValue: String(doc.scheduleValue),
892
+ status: String(doc.status),
893
+ provider: doc.provider ?? null,
894
+ lastRunAt: doc.lastRunAt ? new Date(doc.lastRunAt) : null,
895
+ nextRunAt: doc.nextRunAt ? new Date(doc.nextRunAt) : null,
896
+ runCount: Number(doc.runCount ?? 0),
897
+ lastError: doc.lastError ?? null,
898
+ lastResult: doc.lastResult ?? null,
899
+ createdAt: new Date(doc.createdAt),
900
+ updatedAt: new Date(doc.updatedAt)
901
+ };
902
+ }
903
+ function createMongoTokenDriver(db, collectionName) {
904
+ const collection = () => db.collection(collectionName);
905
+ return {
906
+ async listProviderTokens(userId, provider) {
907
+ const docs = await collection().find({ userId, provider }).sort({ updatedAt: -1 }).limit(32).toArray();
908
+ return docs.map((doc) => mapProviderTokenDoc(doc));
909
+ },
910
+ async upsertProviderToken(input) {
911
+ const now = new Date;
912
+ const id = input.existingId ?? input.id;
913
+ const doc = {
914
+ id,
915
+ userId: input.userId,
916
+ provider: input.provider,
917
+ accountEmail: input.accountEmail,
918
+ accountId: input.accountId,
919
+ accessToken: input.accessToken,
920
+ refreshToken: input.refreshToken,
921
+ tokenType: input.tokenType,
922
+ expiresAt: input.expiresAt,
923
+ scope: input.scope,
924
+ updatedAt: now,
925
+ ...input.existingId ? {} : { createdAt: now }
926
+ };
927
+ await collection().updateOne({ id }, { $set: doc }, { upsert: true });
928
+ const saved = await collection().findOne({ id });
929
+ return mapProviderTokenDoc(saved);
930
+ },
931
+ async deleteProviderTokens(input) {
932
+ const filter = {
933
+ userId: input.userId,
934
+ provider: input.provider
935
+ };
936
+ if (input.accountEmail) {
937
+ filter.accountEmail = input.accountEmail;
938
+ } else if (input.accountId) {
939
+ filter.accountId = input.accountId;
940
+ }
941
+ await collection().deleteMany(filter);
942
+ },
943
+ async deleteDuplicateProviderTokens(input) {
944
+ const normalizedEmail = normalizeAccountEmail(input.accountEmail);
945
+ const normalizedAccountId = normalizeAccountIdHint(input.accountId);
946
+ if (!normalizedEmail && !normalizedAccountId) {
947
+ return;
948
+ }
949
+ const orConditions = [];
950
+ if (normalizedEmail) {
951
+ orConditions.push({ accountEmail: normalizedEmail });
952
+ }
953
+ if (normalizedAccountId) {
954
+ orConditions.push({ accountId: normalizedAccountId });
955
+ }
956
+ await collection().deleteMany({
957
+ userId: input.userId,
958
+ provider: input.provider,
959
+ id: { $ne: input.keepId },
960
+ $or: orConditions
961
+ });
962
+ }
963
+ };
964
+ }
965
+ function createMongoTriggerDriver(db, collectionName) {
966
+ const collection = () => db.collection(collectionName);
967
+ return {
968
+ async createTrigger(input) {
969
+ const now = new Date;
970
+ const doc = {
971
+ id: input.id,
972
+ userId: input.userId,
973
+ name: input.name ?? null,
974
+ description: input.description ?? null,
975
+ toolName: input.toolName,
976
+ toolArguments: input.toolArguments,
977
+ scheduleType: input.scheduleType,
978
+ scheduleValue: input.scheduleValue,
979
+ status: input.status,
980
+ provider: input.provider ?? null,
981
+ nextRunAt: input.nextRunAt ?? null,
982
+ createdAt: now,
983
+ updatedAt: now
984
+ };
985
+ await collection().insertOne(doc);
986
+ return mapTriggerDoc(doc);
987
+ },
988
+ async getTriggerById(triggerId) {
989
+ const found = await collection().findOne({ id: triggerId });
990
+ return found ? mapTriggerDoc(found) : null;
991
+ },
992
+ async listTriggers(query) {
993
+ const filter = {};
994
+ if (query.userId)
995
+ filter.userId = query.userId;
996
+ if (query.status)
997
+ filter.status = query.status;
998
+ if (query.toolName)
999
+ filter.toolName = query.toolName;
1000
+ const [docs, total] = await Promise.all([
1001
+ collection().find(filter).sort({ updatedAt: -1 }).skip(query.offset).limit(query.limit).toArray(),
1002
+ collection().countDocuments(filter)
1003
+ ]);
1004
+ return {
1005
+ rows: docs.map((doc) => mapTriggerDoc(doc)),
1006
+ total
1007
+ };
1008
+ },
1009
+ async updateTrigger(triggerId, updates) {
1010
+ const result = await collection().findOneAndUpdate({ id: triggerId }, { $set: updates }, { returnDocument: "after" });
1011
+ return result ? mapTriggerDoc(result) : null;
1012
+ },
1013
+ async deleteTrigger(triggerId) {
1014
+ await collection().deleteOne({ id: triggerId });
1015
+ }
1016
+ };
1017
+ }
1018
+ function createMongoDatabaseDriver(db, config) {
1019
+ const names = {
1020
+ ...DEFAULT_COLLECTIONS,
1021
+ ...config.collectionNames
1022
+ };
1023
+ const driver = {
1024
+ tokens: createMongoTokenDriver(db, names.providerTokens)
1025
+ };
1026
+ if (config.collectionNames?.triggers !== null) {
1027
+ driver.triggers = createMongoTriggerDriver(db, names.triggers);
1028
+ }
1029
+ return driver;
1030
+ }
1031
+ function mongodbAdapter(db, config = {}) {
1032
+ return createDatabaseAdapterFactory(() => createMongoDatabaseDriver(db, config), {
1033
+ hooks: config.hooks,
1034
+ debugLogs: config.debugLogs
1035
+ });
1036
+ }
1037
+ function mongodbAdapterCallbacks(db, config = {}) {
1038
+ return createDatabaseAdapterCallbacks({
1039
+ driver: createMongoDatabaseDriver(db, config),
1040
+ hooks: config.hooks,
1041
+ debugLogs: config.debugLogs
1042
+ });
1043
+ }
1044
+ // src/database/schemas/drizzle.ts
1045
+ import { sql } from "drizzle-orm";
1046
+ import {
1047
+ index,
1048
+ integer,
1049
+ jsonb,
1050
+ pgTable,
1051
+ text,
1052
+ timestamp,
1053
+ uniqueIndex
1054
+ } from "drizzle-orm/pg-core";
1055
+ var integrateProviderToken = pgTable("provider_token", {
1056
+ id: text("id").primaryKey(),
1057
+ userId: text("user_id").notNull(),
1058
+ provider: text("provider").notNull(),
1059
+ accountEmail: text("account_email"),
1060
+ accountId: text("account_id"),
1061
+ accessToken: text("access_token").notNull(),
1062
+ refreshToken: text("refresh_token"),
1063
+ tokenType: text("token_type").notNull().default("Bearer"),
1064
+ expiresAt: timestamp("expires_at"),
1065
+ scope: text("scope"),
1066
+ createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
1067
+ updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
1068
+ }, (table) => [
1069
+ index("provider_token_user_id_idx").on(table.userId),
1070
+ index("provider_token_provider_idx").on(table.provider),
1071
+ index("provider_token_user_provider_idx").on(table.userId, table.provider),
1072
+ uniqueIndex("provider_token_user_provider_account_email_uidx").on(table.userId, table.provider, table.accountEmail)
1073
+ ]);
1074
+ var integrateTrigger = pgTable("trigger", {
1075
+ id: text("id").primaryKey(),
1076
+ userId: text("user_id"),
1077
+ name: text("name"),
1078
+ description: text("description"),
1079
+ toolName: text("tool_name").notNull(),
1080
+ toolArguments: jsonb("tool_arguments").notNull(),
1081
+ scheduleType: text("schedule_type").notNull(),
1082
+ scheduleValue: text("schedule_value").notNull(),
1083
+ status: text("status").notNull().default("active"),
1084
+ provider: text("provider"),
1085
+ lastRunAt: timestamp("last_run_at", { mode: "date", precision: 3 }),
1086
+ nextRunAt: timestamp("next_run_at", { mode: "date", precision: 3 }),
1087
+ runCount: integer("run_count").notNull().default(0),
1088
+ lastError: text("last_error"),
1089
+ lastResult: jsonb("last_result"),
1090
+ createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
1091
+ updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
1092
+ }, (table) => [
1093
+ index("trigger_user_id_idx").on(table.userId),
1094
+ index("trigger_status_idx").on(table.status),
1095
+ index("trigger_next_run_at_idx").on(table.nextRunAt)
1096
+ ]);
1097
+ export {
1098
+ toSdkTrigger,
1099
+ toSdkSchedule,
1100
+ toDbTriggerUpdates,
1101
+ toDbSchedule,
1102
+ selectProviderTokenRow,
1103
+ providerTokenRecordToData,
1104
+ prismaAdapterCallbacks,
1105
+ prismaAdapter,
1106
+ parseScopes,
1107
+ normalizeProviderTokenType,
1108
+ normalizeAccountIdentifier,
1109
+ normalizeAccountIdHint,
1110
+ normalizeAccountEmailHint,
1111
+ normalizeAccountEmail,
1112
+ mongodbAdapterCallbacks,
1113
+ mongodbAdapter,
1114
+ isLikelyUsableToken,
1115
+ integrateTrigger,
1116
+ integrateProviderToken,
1117
+ hasUsableAccessToken,
1118
+ hasMeaningfulExpiresAt,
1119
+ flattenedTriggerToCreateInput,
1120
+ drizzleAdapterCallbacks,
1121
+ drizzleAdapter,
1122
+ defaultResolveAccountIdentity,
1123
+ createPrismaDatabaseDriver,
1124
+ createMongoDatabaseDriver,
1125
+ createDrizzleDatabaseDriver,
1126
+ createDatabaseAdapterFactory,
1127
+ createDatabaseAdapterCallbacks
1128
+ };