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.
- package/dist/adapters/index.js +2364 -0
- package/dist/adapters/solid-start.js +2364 -0
- package/dist/adapters/svelte-kit.js +2364 -0
- package/dist/database/adapters/drizzle.d.ts +23 -0
- package/dist/database/adapters/drizzle.d.ts.map +1 -0
- package/dist/database/adapters/drizzle.js +646 -0
- package/dist/database/adapters/mongodb.d.ts +17 -0
- package/dist/database/adapters/mongodb.d.ts.map +1 -0
- package/dist/database/adapters/mongodb.js +643 -0
- package/dist/database/adapters/prisma.d.ts +18 -0
- package/dist/database/adapters/prisma.d.ts.map +1 -0
- package/dist/database/adapters/prisma.js +679 -0
- package/dist/database/index.d.ts +9 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +1128 -0
- package/dist/server.js +3515 -1
- package/dist/src/config/types.d.ts +25 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/database/adapters/drizzle.d.ts +23 -0
- package/dist/src/database/adapters/drizzle.d.ts.map +1 -0
- package/dist/src/database/adapters/mongodb.d.ts +17 -0
- package/dist/src/database/adapters/mongodb.d.ts.map +1 -0
- package/dist/src/database/adapters/prisma.d.ts +18 -0
- package/dist/src/database/adapters/prisma.d.ts.map +1 -0
- package/dist/src/database/factory.d.ts +9 -0
- package/dist/src/database/factory.d.ts.map +1 -0
- package/dist/src/database/index.d.ts +9 -0
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/schemas/drizzle.d.ts +508 -0
- package/dist/src/database/schemas/drizzle.d.ts.map +1 -0
- package/dist/src/database/token-store.d.ts +18 -0
- package/dist/src/database/token-store.d.ts.map +1 -0
- package/dist/src/database/trigger-store.d.ts +23 -0
- package/dist/src/database/trigger-store.d.ts.map +1 -0
- package/dist/src/database/types.d.ts +132 -0
- package/dist/src/database/types.d.ts.map +1 -0
- package/dist/src/integrations/integration-docs-metadata.d.ts +40 -0
- package/dist/src/integrations/integration-docs-metadata.d.ts.map +1 -0
- package/dist/src/server.d.ts +4 -3
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +32 -5
package/dist/server.js
CHANGED
|
@@ -21233,10 +21233,3496 @@ function zohoSprintsIntegration(config = {}) {
|
|
|
21233
21233
|
}
|
|
21234
21234
|
};
|
|
21235
21235
|
}
|
|
21236
|
+
// src/database/token-store.ts
|
|
21237
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
21238
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
21239
|
+
function getRowUpdatedAtMs(row) {
|
|
21240
|
+
return row.updatedAt instanceof Date ? row.updatedAt.getTime() : 0;
|
|
21241
|
+
}
|
|
21242
|
+
function normalizeAccountEmail(value) {
|
|
21243
|
+
if (!value)
|
|
21244
|
+
return null;
|
|
21245
|
+
const normalized = value.trim().toLowerCase();
|
|
21246
|
+
return normalized.length > 0 ? normalized : null;
|
|
21247
|
+
}
|
|
21248
|
+
function normalizeAccountEmailHint(value) {
|
|
21249
|
+
const normalized = normalizeAccountEmail(value);
|
|
21250
|
+
if (!normalized)
|
|
21251
|
+
return null;
|
|
21252
|
+
return normalized.includes("@") ? normalized : null;
|
|
21253
|
+
}
|
|
21254
|
+
function normalizeAccountIdentifier(value) {
|
|
21255
|
+
return normalizeAccountEmail(value);
|
|
21256
|
+
}
|
|
21257
|
+
function normalizeAccountIdHint(value) {
|
|
21258
|
+
if (!value)
|
|
21259
|
+
return null;
|
|
21260
|
+
const normalized = value.trim().toLowerCase();
|
|
21261
|
+
return normalized.length > 0 ? normalized : null;
|
|
21262
|
+
}
|
|
21263
|
+
function normalizeProviderTokenType(value) {
|
|
21264
|
+
const normalized = value?.trim();
|
|
21265
|
+
return normalized && normalized.length > 0 ? normalized : "Bearer";
|
|
21266
|
+
}
|
|
21267
|
+
function hasMeaningfulExpiresAt(value) {
|
|
21268
|
+
if (!value)
|
|
21269
|
+
return false;
|
|
21270
|
+
const ms = value.getTime();
|
|
21271
|
+
return Number.isFinite(ms) && ms >= MIN_MEANINGFUL_EXPIRY_MS;
|
|
21272
|
+
}
|
|
21273
|
+
function hasUsableAccessToken(row, now = Date.now(), bufferMs = USABLE_ACCESS_TOKEN_BUFFER_MS) {
|
|
21274
|
+
if (!row.accessToken)
|
|
21275
|
+
return false;
|
|
21276
|
+
const expiresAt = row.expiresAt;
|
|
21277
|
+
if (!hasMeaningfulExpiresAt(expiresAt))
|
|
21278
|
+
return true;
|
|
21279
|
+
return expiresAt.getTime() > now + bufferMs;
|
|
21280
|
+
}
|
|
21281
|
+
function isLikelyUsableToken(row, now = Date.now()) {
|
|
21282
|
+
return hasUsableAccessToken(row, now) || Boolean(row.refreshToken);
|
|
21283
|
+
}
|
|
21284
|
+
function parseScopes(scope) {
|
|
21285
|
+
if (!scope)
|
|
21286
|
+
return;
|
|
21287
|
+
const scopes = scope.split(" ").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
21288
|
+
return scopes.length > 0 ? scopes : undefined;
|
|
21289
|
+
}
|
|
21290
|
+
function choosePreferredTokenRow(rows) {
|
|
21291
|
+
if (rows.length === 0)
|
|
21292
|
+
return;
|
|
21293
|
+
const sorted = [...rows].sort((left, right) => getRowUpdatedAtMs(right) - getRowUpdatedAtMs(left));
|
|
21294
|
+
return sorted.find((row) => hasUsableAccessToken(row)) ?? sorted.find((row) => Boolean(row.refreshToken)) ?? sorted[0];
|
|
21295
|
+
}
|
|
21296
|
+
function selectProviderTokenRow(rows, email, accountId) {
|
|
21297
|
+
if (rows.length === 0) {
|
|
21298
|
+
return;
|
|
21299
|
+
}
|
|
21300
|
+
const normalizedEmail = normalizeAccountEmailHint(email);
|
|
21301
|
+
const normalizedAccountId = normalizeAccountIdHint(accountId);
|
|
21302
|
+
if (normalizedAccountId && normalizedEmail) {
|
|
21303
|
+
const exactBoth = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedAccountId && normalizeAccountEmail(row.accountEmail) === normalizedEmail);
|
|
21304
|
+
if (exactBoth.length > 0) {
|
|
21305
|
+
return choosePreferredTokenRow(exactBoth);
|
|
21306
|
+
}
|
|
21307
|
+
}
|
|
21308
|
+
if (normalizedAccountId) {
|
|
21309
|
+
const exactAccountId = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedAccountId);
|
|
21310
|
+
if (exactAccountId.length > 0) {
|
|
21311
|
+
return choosePreferredTokenRow(exactAccountId);
|
|
21312
|
+
}
|
|
21313
|
+
}
|
|
21314
|
+
if (normalizedEmail) {
|
|
21315
|
+
const exactEmail = rows.filter((row) => normalizeAccountEmail(row.accountEmail) === normalizedEmail);
|
|
21316
|
+
if (exactEmail.length > 0) {
|
|
21317
|
+
return choosePreferredTokenRow(exactEmail);
|
|
21318
|
+
}
|
|
21319
|
+
} else if (email) {
|
|
21320
|
+
const normalizedIdentifier = normalizeAccountIdentifier(email);
|
|
21321
|
+
if (normalizedIdentifier) {
|
|
21322
|
+
const identifierMatches = rows.filter((row) => normalizeAccountIdHint(row.accountId) === normalizedIdentifier);
|
|
21323
|
+
if (identifierMatches.length > 0) {
|
|
21324
|
+
return choosePreferredTokenRow(identifierMatches);
|
|
21325
|
+
}
|
|
21326
|
+
}
|
|
21327
|
+
}
|
|
21328
|
+
if (normalizedAccountId || normalizedEmail) {
|
|
21329
|
+
const legacyRows = rows.filter((row) => !normalizeAccountIdHint(row.accountId) && !normalizeAccountEmail(row.accountEmail));
|
|
21330
|
+
if (legacyRows.length === 1) {
|
|
21331
|
+
return choosePreferredTokenRow(legacyRows);
|
|
21332
|
+
}
|
|
21333
|
+
return;
|
|
21334
|
+
}
|
|
21335
|
+
return choosePreferredTokenRow(rows);
|
|
21336
|
+
}
|
|
21337
|
+
function providerTokenRecordToData(row) {
|
|
21338
|
+
const expiresAt = hasMeaningfulExpiresAt(row.expiresAt) ? row.expiresAt : null;
|
|
21339
|
+
const expiresIn = expiresAt ? Math.max(0, Math.floor((expiresAt.getTime() - Date.now()) / 1000)) : 3600;
|
|
21340
|
+
return {
|
|
21341
|
+
accessToken: row.accessToken,
|
|
21342
|
+
refreshToken: row.refreshToken ?? undefined,
|
|
21343
|
+
tokenType: normalizeProviderTokenType(row.tokenType),
|
|
21344
|
+
expiresIn,
|
|
21345
|
+
expiresAt: expiresAt?.toISOString(),
|
|
21346
|
+
scopes: parseScopes(row.scope),
|
|
21347
|
+
email: row.accountEmail ?? undefined,
|
|
21348
|
+
accountId: row.accountId ?? undefined
|
|
21349
|
+
};
|
|
21350
|
+
}
|
|
21351
|
+
function defaultResolveAccountIdentity(provider, tokenData, emailHint) {
|
|
21352
|
+
const accountEmail = normalizeAccountEmail(emailHint ?? tokenData.email ?? null);
|
|
21353
|
+
let accountId = normalizeAccountIdHint(tokenData.accountId ?? null);
|
|
21354
|
+
if (!accountId && accountEmail) {
|
|
21355
|
+
accountId = `${provider}:${accountEmail}`;
|
|
21356
|
+
}
|
|
21357
|
+
return { accountEmail, accountId };
|
|
21358
|
+
}
|
|
21359
|
+
|
|
21360
|
+
// src/database/trigger-store.ts
|
|
21361
|
+
function toIsoString(value) {
|
|
21362
|
+
if (!value)
|
|
21363
|
+
return null;
|
|
21364
|
+
if (value instanceof Date) {
|
|
21365
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
21366
|
+
}
|
|
21367
|
+
const parsed = new Date(value);
|
|
21368
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
|
21369
|
+
}
|
|
21370
|
+
function toDbSchedule(value) {
|
|
21371
|
+
if (value.scheduleType && value.scheduleValue) {
|
|
21372
|
+
return {
|
|
21373
|
+
scheduleType: value.scheduleType,
|
|
21374
|
+
scheduleValue: value.scheduleValue
|
|
21375
|
+
};
|
|
21376
|
+
}
|
|
21377
|
+
if (value.schedule.type === "once") {
|
|
21378
|
+
const runAt = toIsoString(value.schedule.runAt);
|
|
21379
|
+
if (!runAt) {
|
|
21380
|
+
throw new Error("Invalid trigger once schedule");
|
|
21381
|
+
}
|
|
21382
|
+
return {
|
|
21383
|
+
scheduleType: "once",
|
|
21384
|
+
scheduleValue: runAt
|
|
21385
|
+
};
|
|
21386
|
+
}
|
|
21387
|
+
return {
|
|
21388
|
+
scheduleType: "cron",
|
|
21389
|
+
scheduleValue: value.schedule.expression
|
|
21390
|
+
};
|
|
21391
|
+
}
|
|
21392
|
+
function toSdkSchedule(row) {
|
|
21393
|
+
if (row.scheduleType === "once") {
|
|
21394
|
+
return {
|
|
21395
|
+
type: "once",
|
|
21396
|
+
runAt: row.scheduleValue
|
|
21397
|
+
};
|
|
21398
|
+
}
|
|
21399
|
+
return {
|
|
21400
|
+
type: "cron",
|
|
21401
|
+
expression: row.scheduleValue
|
|
21402
|
+
};
|
|
21403
|
+
}
|
|
21404
|
+
function toSdkTrigger(row) {
|
|
21405
|
+
return {
|
|
21406
|
+
id: row.id,
|
|
21407
|
+
userId: row.userId ?? undefined,
|
|
21408
|
+
name: row.name ?? undefined,
|
|
21409
|
+
description: row.description ?? undefined,
|
|
21410
|
+
toolName: row.toolName,
|
|
21411
|
+
toolArguments: row.toolArguments ?? {},
|
|
21412
|
+
schedule: toSdkSchedule(row),
|
|
21413
|
+
status: row.status,
|
|
21414
|
+
provider: row.provider ?? undefined,
|
|
21415
|
+
createdAt: row.createdAt.toISOString(),
|
|
21416
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
21417
|
+
lastRunAt: toIsoString(row.lastRunAt) ?? undefined,
|
|
21418
|
+
nextRunAt: toIsoString(row.nextRunAt) ?? undefined,
|
|
21419
|
+
runCount: row.runCount,
|
|
21420
|
+
lastError: row.lastError ?? undefined,
|
|
21421
|
+
lastResult: row.lastResult ?? undefined
|
|
21422
|
+
};
|
|
21423
|
+
}
|
|
21424
|
+
function toDbTriggerUpdates(updates) {
|
|
21425
|
+
const dbUpdates = {
|
|
21426
|
+
updatedAt: new Date
|
|
21427
|
+
};
|
|
21428
|
+
if (updates.name !== undefined)
|
|
21429
|
+
dbUpdates.name = updates.name ?? null;
|
|
21430
|
+
if (updates.description !== undefined) {
|
|
21431
|
+
dbUpdates.description = updates.description ?? null;
|
|
21432
|
+
}
|
|
21433
|
+
if (updates.toolArguments !== undefined) {
|
|
21434
|
+
dbUpdates.toolArguments = updates.toolArguments;
|
|
21435
|
+
}
|
|
21436
|
+
if (updates.status !== undefined)
|
|
21437
|
+
dbUpdates.status = updates.status;
|
|
21438
|
+
if (updates.provider !== undefined)
|
|
21439
|
+
dbUpdates.provider = updates.provider ?? null;
|
|
21440
|
+
if (updates.lastError !== undefined)
|
|
21441
|
+
dbUpdates.lastError = updates.lastError ?? null;
|
|
21442
|
+
if (updates.lastResult !== undefined) {
|
|
21443
|
+
dbUpdates.lastResult = updates.lastResult ?? null;
|
|
21444
|
+
}
|
|
21445
|
+
if (updates.lastRunAt !== undefined) {
|
|
21446
|
+
dbUpdates.lastRunAt = updates.lastRunAt ? new Date(updates.lastRunAt) : null;
|
|
21447
|
+
}
|
|
21448
|
+
if (updates.nextRunAt !== undefined) {
|
|
21449
|
+
dbUpdates.nextRunAt = updates.nextRunAt ? new Date(updates.nextRunAt) : null;
|
|
21450
|
+
}
|
|
21451
|
+
if (updates.runCount !== undefined)
|
|
21452
|
+
dbUpdates.runCount = updates.runCount;
|
|
21453
|
+
if (updates.schedule) {
|
|
21454
|
+
if (updates.schedule.type === "once") {
|
|
21455
|
+
dbUpdates.scheduleType = "once";
|
|
21456
|
+
dbUpdates.scheduleValue = new Date(updates.schedule.runAt).toISOString();
|
|
21457
|
+
} else {
|
|
21458
|
+
dbUpdates.scheduleType = "cron";
|
|
21459
|
+
dbUpdates.scheduleValue = updates.schedule.expression;
|
|
21460
|
+
}
|
|
21461
|
+
}
|
|
21462
|
+
return dbUpdates;
|
|
21463
|
+
}
|
|
21464
|
+
function flattenedTriggerToCreateInput(triggerData, contextUserId) {
|
|
21465
|
+
const schedule = toDbSchedule(triggerData);
|
|
21466
|
+
return {
|
|
21467
|
+
id: triggerData.id,
|
|
21468
|
+
userId: contextUserId ?? triggerData.userId ?? null,
|
|
21469
|
+
name: triggerData.name ?? null,
|
|
21470
|
+
description: triggerData.description ?? null,
|
|
21471
|
+
toolName: triggerData.toolName,
|
|
21472
|
+
toolArguments: triggerData.toolArguments ?? {},
|
|
21473
|
+
scheduleType: schedule.scheduleType,
|
|
21474
|
+
scheduleValue: schedule.scheduleValue,
|
|
21475
|
+
status: triggerData.status ?? "active",
|
|
21476
|
+
provider: triggerData.provider ?? null,
|
|
21477
|
+
nextRunAt: triggerData.nextRunAt ? new Date(triggerData.nextRunAt) : null
|
|
21478
|
+
};
|
|
21479
|
+
}
|
|
21480
|
+
|
|
21481
|
+
// src/database/factory.ts
|
|
21482
|
+
function log(debug, message, error) {
|
|
21483
|
+
if (!debug)
|
|
21484
|
+
return;
|
|
21485
|
+
if (error !== undefined) {
|
|
21486
|
+
console.error(`[Integrate SDK] ${message}`, error);
|
|
21487
|
+
return;
|
|
21488
|
+
}
|
|
21489
|
+
console.log(`[Integrate SDK] ${message}`);
|
|
21490
|
+
}
|
|
21491
|
+
async function authorizeTriggerRow(row, context, hooks) {
|
|
21492
|
+
if (!row)
|
|
21493
|
+
return null;
|
|
21494
|
+
const repaired = hooks?.authorizeTrigger ? await hooks.authorizeTrigger(row, context) : row;
|
|
21495
|
+
if (!repaired)
|
|
21496
|
+
return null;
|
|
21497
|
+
if (context?.userId && repaired.userId !== context.userId) {
|
|
21498
|
+
return null;
|
|
21499
|
+
}
|
|
21500
|
+
return repaired;
|
|
21501
|
+
}
|
|
21502
|
+
function createDatabaseAdapterCallbacks(options) {
|
|
21503
|
+
const { driver, hooks, debugLogs } = options;
|
|
21504
|
+
const getProviderToken = async (provider, email, context) => {
|
|
21505
|
+
const userId = context?.userId;
|
|
21506
|
+
if (!userId) {
|
|
21507
|
+
return;
|
|
21508
|
+
}
|
|
21509
|
+
const accountEmailHint = normalizeAccountEmailHint(email) ?? normalizeAccountEmailHint(typeof context?.accountEmail === "string" ? context.accountEmail : null);
|
|
21510
|
+
const accountIdHint = normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null);
|
|
21511
|
+
try {
|
|
21512
|
+
const rows = await driver.tokens.listProviderTokens(userId, provider);
|
|
21513
|
+
const selectedRow = selectProviderTokenRow(rows, accountEmailHint ?? undefined, accountIdHint ?? undefined);
|
|
21514
|
+
if (!selectedRow) {
|
|
21515
|
+
return;
|
|
21516
|
+
}
|
|
21517
|
+
return providerTokenRecordToData(selectedRow);
|
|
21518
|
+
} catch (error) {
|
|
21519
|
+
log(debugLogs, "Error fetching provider token:", error);
|
|
21520
|
+
return;
|
|
21521
|
+
}
|
|
21522
|
+
};
|
|
21523
|
+
const setProviderToken = async (provider, tokenData, email, context) => {
|
|
21524
|
+
const userId = context?.userId;
|
|
21525
|
+
if (!userId) {
|
|
21526
|
+
console.error("[Integrate SDK] Cannot save token: No userId in context");
|
|
21527
|
+
return;
|
|
21528
|
+
}
|
|
21529
|
+
const accountEmail = normalizeAccountEmailHint(email) ?? normalizeAccountEmail(tokenData?.email ?? null);
|
|
21530
|
+
if (tokenData === null) {
|
|
21531
|
+
try {
|
|
21532
|
+
await driver.tokens.deleteProviderTokens({
|
|
21533
|
+
userId,
|
|
21534
|
+
provider,
|
|
21535
|
+
accountEmail,
|
|
21536
|
+
accountId: normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null)
|
|
21537
|
+
});
|
|
21538
|
+
await hooks?.onTokenChange?.({ userId, provider, action: "remove" });
|
|
21539
|
+
} catch (error) {
|
|
21540
|
+
log(debugLogs, "Error deleting provider token:", error);
|
|
21541
|
+
throw error;
|
|
21542
|
+
}
|
|
21543
|
+
return;
|
|
21544
|
+
}
|
|
21545
|
+
try {
|
|
21546
|
+
const resolvedIdentity = hooks?.resolveAccountIdentity ? await hooks.resolveAccountIdentity(provider, tokenData, accountEmail, context) : defaultResolveAccountIdentity(provider, tokenData, accountEmail);
|
|
21547
|
+
const resolvedAccountEmail = resolvedIdentity.accountEmail;
|
|
21548
|
+
const resolvedAccountId = normalizeAccountIdHint(resolvedIdentity.accountId) ?? normalizeAccountIdHint(typeof context?.accountId === "string" ? context.accountId : null) ?? null;
|
|
21549
|
+
const rows = await driver.tokens.listProviderTokens(userId, provider);
|
|
21550
|
+
let existing = selectProviderTokenRow(rows, resolvedAccountEmail ?? accountEmail ?? undefined, resolvedAccountId ?? undefined) ?? rows.find((row) => {
|
|
21551
|
+
const sameEmail = resolvedAccountEmail && normalizeAccountEmail(row.accountEmail) === resolvedAccountEmail;
|
|
21552
|
+
const sameAccountId = resolvedAccountId && normalizeAccountIdHint(row.accountId) === resolvedAccountId;
|
|
21553
|
+
return Boolean(sameEmail || sameAccountId);
|
|
21554
|
+
}) ?? (rows.length === 1 ? rows[0] : undefined);
|
|
21555
|
+
const parsedExpiresAt = tokenData.expiresAt ? new Date(tokenData.expiresAt) : null;
|
|
21556
|
+
const expiresAt = hasMeaningfulExpiresAt(parsedExpiresAt) ? parsedExpiresAt : null;
|
|
21557
|
+
const scope = tokenData.scopes?.join(" ") ?? null;
|
|
21558
|
+
const saved = await driver.tokens.upsertProviderToken({
|
|
21559
|
+
existingId: existing?.id,
|
|
21560
|
+
id: existing?.id ?? `${userId}-${provider}-${resolvedAccountEmail ?? "default"}-${Date.now()}`,
|
|
21561
|
+
userId,
|
|
21562
|
+
provider,
|
|
21563
|
+
accountEmail: resolvedAccountEmail,
|
|
21564
|
+
accountId: resolvedAccountId,
|
|
21565
|
+
accessToken: tokenData.accessToken,
|
|
21566
|
+
refreshToken: tokenData.refreshToken ?? null,
|
|
21567
|
+
tokenType: normalizeProviderTokenType(tokenData.tokenType),
|
|
21568
|
+
expiresAt,
|
|
21569
|
+
scope
|
|
21570
|
+
});
|
|
21571
|
+
await driver.tokens.deleteDuplicateProviderTokens({
|
|
21572
|
+
keepId: saved.id,
|
|
21573
|
+
userId,
|
|
21574
|
+
provider,
|
|
21575
|
+
accountEmail: resolvedAccountEmail,
|
|
21576
|
+
accountId: resolvedAccountId
|
|
21577
|
+
});
|
|
21578
|
+
await hooks?.onTokenChange?.({ userId, provider, action: "set" });
|
|
21579
|
+
} catch (error) {
|
|
21580
|
+
log(debugLogs, "Error saving provider token:", error);
|
|
21581
|
+
throw error;
|
|
21582
|
+
}
|
|
21583
|
+
};
|
|
21584
|
+
const removeProviderToken = async (provider, email, context) => {
|
|
21585
|
+
const userId = context?.userId;
|
|
21586
|
+
if (!userId) {
|
|
21587
|
+
console.error("[Integrate SDK] Cannot delete token: No userId in context");
|
|
21588
|
+
return;
|
|
21589
|
+
}
|
|
21590
|
+
try {
|
|
21591
|
+
await driver.tokens.deleteProviderTokens({
|
|
21592
|
+
userId,
|
|
21593
|
+
provider,
|
|
21594
|
+
accountEmail: normalizeAccountEmail(email)
|
|
21595
|
+
});
|
|
21596
|
+
await hooks?.onTokenChange?.({ userId, provider, action: "remove" });
|
|
21597
|
+
} catch (error) {
|
|
21598
|
+
log(debugLogs, "Error deleting provider token:", error);
|
|
21599
|
+
throw error;
|
|
21600
|
+
}
|
|
21601
|
+
};
|
|
21602
|
+
const callbacks = {
|
|
21603
|
+
getProviderToken,
|
|
21604
|
+
setProviderToken,
|
|
21605
|
+
removeProviderToken
|
|
21606
|
+
};
|
|
21607
|
+
if (driver.triggers) {
|
|
21608
|
+
const triggerDriver = driver.triggers;
|
|
21609
|
+
const triggers = {
|
|
21610
|
+
create: async (triggerData, context) => {
|
|
21611
|
+
try {
|
|
21612
|
+
const created = await triggerDriver.createTrigger(flattenedTriggerToCreateInput(triggerData, context?.userId));
|
|
21613
|
+
return toSdkTrigger(created);
|
|
21614
|
+
} catch (error) {
|
|
21615
|
+
log(debugLogs, "Error creating trigger:", error);
|
|
21616
|
+
throw error;
|
|
21617
|
+
}
|
|
21618
|
+
},
|
|
21619
|
+
get: async (triggerId, context) => {
|
|
21620
|
+
try {
|
|
21621
|
+
const found = await triggerDriver.getTriggerById(triggerId);
|
|
21622
|
+
const authorized = await authorizeTriggerRow(found, context, hooks);
|
|
21623
|
+
return authorized ? toSdkTrigger(authorized) : null;
|
|
21624
|
+
} catch (error) {
|
|
21625
|
+
log(debugLogs, "Error getting trigger:", error);
|
|
21626
|
+
throw error;
|
|
21627
|
+
}
|
|
21628
|
+
},
|
|
21629
|
+
list: async (params, context) => {
|
|
21630
|
+
try {
|
|
21631
|
+
const { rows, total } = await triggerDriver.listTriggers({
|
|
21632
|
+
userId: context?.userId,
|
|
21633
|
+
status: params.status,
|
|
21634
|
+
toolName: params.toolName,
|
|
21635
|
+
limit: params.limit ?? 20,
|
|
21636
|
+
offset: params.offset ?? 0
|
|
21637
|
+
});
|
|
21638
|
+
const triggers2 = [];
|
|
21639
|
+
for (const row of rows) {
|
|
21640
|
+
const authorized = await authorizeTriggerRow(row, context, hooks);
|
|
21641
|
+
if (authorized) {
|
|
21642
|
+
triggers2.push(toSdkTrigger(authorized));
|
|
21643
|
+
}
|
|
21644
|
+
}
|
|
21645
|
+
return { triggers: triggers2, total };
|
|
21646
|
+
} catch (error) {
|
|
21647
|
+
log(debugLogs, "Error listing triggers:", error);
|
|
21648
|
+
throw error;
|
|
21649
|
+
}
|
|
21650
|
+
},
|
|
21651
|
+
update: async (triggerId, updates, context) => {
|
|
21652
|
+
try {
|
|
21653
|
+
const existing = await triggerDriver.getTriggerById(triggerId);
|
|
21654
|
+
const authorized = await authorizeTriggerRow(existing, context, hooks);
|
|
21655
|
+
if (!authorized) {
|
|
21656
|
+
throw new Error(`Trigger not found: ${triggerId}`);
|
|
21657
|
+
}
|
|
21658
|
+
const updated = await triggerDriver.updateTrigger(authorized.id, toDbTriggerUpdates(updates));
|
|
21659
|
+
if (!updated) {
|
|
21660
|
+
throw new Error(`Trigger not found: ${triggerId}`);
|
|
21661
|
+
}
|
|
21662
|
+
return toSdkTrigger(updated);
|
|
21663
|
+
} catch (error) {
|
|
21664
|
+
log(debugLogs, "Error updating trigger:", error);
|
|
21665
|
+
throw error;
|
|
21666
|
+
}
|
|
21667
|
+
},
|
|
21668
|
+
delete: async (triggerId, context) => {
|
|
21669
|
+
try {
|
|
21670
|
+
const existing = await triggerDriver.getTriggerById(triggerId);
|
|
21671
|
+
const authorized = await authorizeTriggerRow(existing, context, hooks);
|
|
21672
|
+
if (!authorized) {
|
|
21673
|
+
return;
|
|
21674
|
+
}
|
|
21675
|
+
await triggerDriver.deleteTrigger(authorized.id);
|
|
21676
|
+
} catch (error) {
|
|
21677
|
+
log(debugLogs, "Error deleting trigger:", error);
|
|
21678
|
+
throw error;
|
|
21679
|
+
}
|
|
21680
|
+
}
|
|
21681
|
+
};
|
|
21682
|
+
callbacks.triggers = triggers;
|
|
21683
|
+
}
|
|
21684
|
+
return callbacks;
|
|
21685
|
+
}
|
|
21686
|
+
function createDatabaseAdapterFactory(createDriver, options) {
|
|
21687
|
+
return () => createDatabaseAdapterCallbacks({
|
|
21688
|
+
driver: createDriver(),
|
|
21689
|
+
hooks: options?.hooks,
|
|
21690
|
+
debugLogs: options?.debugLogs
|
|
21691
|
+
});
|
|
21692
|
+
}
|
|
21693
|
+
// node_modules/drizzle-orm/entity.js
|
|
21694
|
+
var entityKind = Symbol.for("drizzle:entityKind");
|
|
21695
|
+
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
21696
|
+
function is(value, type) {
|
|
21697
|
+
if (!value || typeof value !== "object") {
|
|
21698
|
+
return false;
|
|
21699
|
+
}
|
|
21700
|
+
if (value instanceof type) {
|
|
21701
|
+
return true;
|
|
21702
|
+
}
|
|
21703
|
+
if (!Object.prototype.hasOwnProperty.call(type, entityKind)) {
|
|
21704
|
+
throw new Error(`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
|
|
21705
|
+
}
|
|
21706
|
+
let cls = Object.getPrototypeOf(value).constructor;
|
|
21707
|
+
if (cls) {
|
|
21708
|
+
while (cls) {
|
|
21709
|
+
if (entityKind in cls && cls[entityKind] === type[entityKind]) {
|
|
21710
|
+
return true;
|
|
21711
|
+
}
|
|
21712
|
+
cls = Object.getPrototypeOf(cls);
|
|
21713
|
+
}
|
|
21714
|
+
}
|
|
21715
|
+
return false;
|
|
21716
|
+
}
|
|
21717
|
+
|
|
21718
|
+
// node_modules/drizzle-orm/column.js
|
|
21719
|
+
class Column {
|
|
21720
|
+
constructor(table, config) {
|
|
21721
|
+
this.table = table;
|
|
21722
|
+
this.config = config;
|
|
21723
|
+
this.name = config.name;
|
|
21724
|
+
this.keyAsName = config.keyAsName;
|
|
21725
|
+
this.notNull = config.notNull;
|
|
21726
|
+
this.default = config.default;
|
|
21727
|
+
this.defaultFn = config.defaultFn;
|
|
21728
|
+
this.onUpdateFn = config.onUpdateFn;
|
|
21729
|
+
this.hasDefault = config.hasDefault;
|
|
21730
|
+
this.primary = config.primaryKey;
|
|
21731
|
+
this.isUnique = config.isUnique;
|
|
21732
|
+
this.uniqueName = config.uniqueName;
|
|
21733
|
+
this.uniqueType = config.uniqueType;
|
|
21734
|
+
this.dataType = config.dataType;
|
|
21735
|
+
this.columnType = config.columnType;
|
|
21736
|
+
this.generated = config.generated;
|
|
21737
|
+
this.generatedIdentity = config.generatedIdentity;
|
|
21738
|
+
}
|
|
21739
|
+
static [entityKind] = "Column";
|
|
21740
|
+
name;
|
|
21741
|
+
keyAsName;
|
|
21742
|
+
primary;
|
|
21743
|
+
notNull;
|
|
21744
|
+
default;
|
|
21745
|
+
defaultFn;
|
|
21746
|
+
onUpdateFn;
|
|
21747
|
+
hasDefault;
|
|
21748
|
+
isUnique;
|
|
21749
|
+
uniqueName;
|
|
21750
|
+
uniqueType;
|
|
21751
|
+
dataType;
|
|
21752
|
+
columnType;
|
|
21753
|
+
enumValues = undefined;
|
|
21754
|
+
generated = undefined;
|
|
21755
|
+
generatedIdentity = undefined;
|
|
21756
|
+
config;
|
|
21757
|
+
mapFromDriverValue(value) {
|
|
21758
|
+
return value;
|
|
21759
|
+
}
|
|
21760
|
+
mapToDriverValue(value) {
|
|
21761
|
+
return value;
|
|
21762
|
+
}
|
|
21763
|
+
shouldDisableInsert() {
|
|
21764
|
+
return this.config.generated !== undefined && this.config.generated.type !== "byDefault";
|
|
21765
|
+
}
|
|
21766
|
+
}
|
|
21767
|
+
|
|
21768
|
+
// node_modules/drizzle-orm/column-builder.js
|
|
21769
|
+
class ColumnBuilder {
|
|
21770
|
+
static [entityKind] = "ColumnBuilder";
|
|
21771
|
+
config;
|
|
21772
|
+
constructor(name, dataType, columnType) {
|
|
21773
|
+
this.config = {
|
|
21774
|
+
name,
|
|
21775
|
+
keyAsName: name === "",
|
|
21776
|
+
notNull: false,
|
|
21777
|
+
default: undefined,
|
|
21778
|
+
hasDefault: false,
|
|
21779
|
+
primaryKey: false,
|
|
21780
|
+
isUnique: false,
|
|
21781
|
+
uniqueName: undefined,
|
|
21782
|
+
uniqueType: undefined,
|
|
21783
|
+
dataType,
|
|
21784
|
+
columnType,
|
|
21785
|
+
generated: undefined
|
|
21786
|
+
};
|
|
21787
|
+
}
|
|
21788
|
+
$type() {
|
|
21789
|
+
return this;
|
|
21790
|
+
}
|
|
21791
|
+
notNull() {
|
|
21792
|
+
this.config.notNull = true;
|
|
21793
|
+
return this;
|
|
21794
|
+
}
|
|
21795
|
+
default(value) {
|
|
21796
|
+
this.config.default = value;
|
|
21797
|
+
this.config.hasDefault = true;
|
|
21798
|
+
return this;
|
|
21799
|
+
}
|
|
21800
|
+
$defaultFn(fn) {
|
|
21801
|
+
this.config.defaultFn = fn;
|
|
21802
|
+
this.config.hasDefault = true;
|
|
21803
|
+
return this;
|
|
21804
|
+
}
|
|
21805
|
+
$default = this.$defaultFn;
|
|
21806
|
+
$onUpdateFn(fn) {
|
|
21807
|
+
this.config.onUpdateFn = fn;
|
|
21808
|
+
this.config.hasDefault = true;
|
|
21809
|
+
return this;
|
|
21810
|
+
}
|
|
21811
|
+
$onUpdate = this.$onUpdateFn;
|
|
21812
|
+
primaryKey() {
|
|
21813
|
+
this.config.primaryKey = true;
|
|
21814
|
+
this.config.notNull = true;
|
|
21815
|
+
return this;
|
|
21816
|
+
}
|
|
21817
|
+
setName(name) {
|
|
21818
|
+
if (this.config.name !== "")
|
|
21819
|
+
return;
|
|
21820
|
+
this.config.name = name;
|
|
21821
|
+
}
|
|
21822
|
+
}
|
|
21823
|
+
|
|
21824
|
+
// node_modules/drizzle-orm/table.utils.js
|
|
21825
|
+
var TableName = Symbol.for("drizzle:Name");
|
|
21826
|
+
|
|
21827
|
+
// node_modules/drizzle-orm/pg-core/foreign-keys.js
|
|
21828
|
+
class ForeignKeyBuilder {
|
|
21829
|
+
static [entityKind] = "PgForeignKeyBuilder";
|
|
21830
|
+
reference;
|
|
21831
|
+
_onUpdate = "no action";
|
|
21832
|
+
_onDelete = "no action";
|
|
21833
|
+
constructor(config, actions) {
|
|
21834
|
+
this.reference = () => {
|
|
21835
|
+
const { name, columns, foreignColumns } = config();
|
|
21836
|
+
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
|
|
21837
|
+
};
|
|
21838
|
+
if (actions) {
|
|
21839
|
+
this._onUpdate = actions.onUpdate;
|
|
21840
|
+
this._onDelete = actions.onDelete;
|
|
21841
|
+
}
|
|
21842
|
+
}
|
|
21843
|
+
onUpdate(action) {
|
|
21844
|
+
this._onUpdate = action === undefined ? "no action" : action;
|
|
21845
|
+
return this;
|
|
21846
|
+
}
|
|
21847
|
+
onDelete(action) {
|
|
21848
|
+
this._onDelete = action === undefined ? "no action" : action;
|
|
21849
|
+
return this;
|
|
21850
|
+
}
|
|
21851
|
+
build(table) {
|
|
21852
|
+
return new ForeignKey(table, this);
|
|
21853
|
+
}
|
|
21854
|
+
}
|
|
21855
|
+
|
|
21856
|
+
class ForeignKey {
|
|
21857
|
+
constructor(table, builder) {
|
|
21858
|
+
this.table = table;
|
|
21859
|
+
this.reference = builder.reference;
|
|
21860
|
+
this.onUpdate = builder._onUpdate;
|
|
21861
|
+
this.onDelete = builder._onDelete;
|
|
21862
|
+
}
|
|
21863
|
+
static [entityKind] = "PgForeignKey";
|
|
21864
|
+
reference;
|
|
21865
|
+
onUpdate;
|
|
21866
|
+
onDelete;
|
|
21867
|
+
getName() {
|
|
21868
|
+
const { name, columns, foreignColumns } = this.reference();
|
|
21869
|
+
const columnNames = columns.map((column) => column.name);
|
|
21870
|
+
const foreignColumnNames = foreignColumns.map((column) => column.name);
|
|
21871
|
+
const chunks = [
|
|
21872
|
+
this.table[TableName],
|
|
21873
|
+
...columnNames,
|
|
21874
|
+
foreignColumns[0].table[TableName],
|
|
21875
|
+
...foreignColumnNames
|
|
21876
|
+
];
|
|
21877
|
+
return name ?? `${chunks.join("_")}_fk`;
|
|
21878
|
+
}
|
|
21879
|
+
}
|
|
21880
|
+
|
|
21881
|
+
// node_modules/drizzle-orm/tracing-utils.js
|
|
21882
|
+
function iife(fn, ...args) {
|
|
21883
|
+
return fn(...args);
|
|
21884
|
+
}
|
|
21885
|
+
|
|
21886
|
+
// node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
21887
|
+
function uniqueKeyName(table, columns) {
|
|
21888
|
+
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
21889
|
+
}
|
|
21890
|
+
|
|
21891
|
+
// node_modules/drizzle-orm/pg-core/utils/array.js
|
|
21892
|
+
function parsePgArrayValue(arrayString, startFrom, inQuotes) {
|
|
21893
|
+
for (let i = startFrom;i < arrayString.length; i++) {
|
|
21894
|
+
const char = arrayString[i];
|
|
21895
|
+
if (char === "\\") {
|
|
21896
|
+
i++;
|
|
21897
|
+
continue;
|
|
21898
|
+
}
|
|
21899
|
+
if (char === '"') {
|
|
21900
|
+
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
|
|
21901
|
+
}
|
|
21902
|
+
if (inQuotes) {
|
|
21903
|
+
continue;
|
|
21904
|
+
}
|
|
21905
|
+
if (char === "," || char === "}") {
|
|
21906
|
+
return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
|
|
21907
|
+
}
|
|
21908
|
+
}
|
|
21909
|
+
return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
|
|
21910
|
+
}
|
|
21911
|
+
function parsePgNestedArray(arrayString, startFrom = 0) {
|
|
21912
|
+
const result = [];
|
|
21913
|
+
let i = startFrom;
|
|
21914
|
+
let lastCharIsComma = false;
|
|
21915
|
+
while (i < arrayString.length) {
|
|
21916
|
+
const char = arrayString[i];
|
|
21917
|
+
if (char === ",") {
|
|
21918
|
+
if (lastCharIsComma || i === startFrom) {
|
|
21919
|
+
result.push("");
|
|
21920
|
+
}
|
|
21921
|
+
lastCharIsComma = true;
|
|
21922
|
+
i++;
|
|
21923
|
+
continue;
|
|
21924
|
+
}
|
|
21925
|
+
lastCharIsComma = false;
|
|
21926
|
+
if (char === "\\") {
|
|
21927
|
+
i += 2;
|
|
21928
|
+
continue;
|
|
21929
|
+
}
|
|
21930
|
+
if (char === '"') {
|
|
21931
|
+
const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
|
|
21932
|
+
result.push(value2);
|
|
21933
|
+
i = startFrom2;
|
|
21934
|
+
continue;
|
|
21935
|
+
}
|
|
21936
|
+
if (char === "}") {
|
|
21937
|
+
return [result, i + 1];
|
|
21938
|
+
}
|
|
21939
|
+
if (char === "{") {
|
|
21940
|
+
const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
|
|
21941
|
+
result.push(value2);
|
|
21942
|
+
i = startFrom2;
|
|
21943
|
+
continue;
|
|
21944
|
+
}
|
|
21945
|
+
const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
|
|
21946
|
+
result.push(value);
|
|
21947
|
+
i = newStartFrom;
|
|
21948
|
+
}
|
|
21949
|
+
return [result, i];
|
|
21950
|
+
}
|
|
21951
|
+
function parsePgArray(arrayString) {
|
|
21952
|
+
const [result] = parsePgNestedArray(arrayString, 1);
|
|
21953
|
+
return result;
|
|
21954
|
+
}
|
|
21955
|
+
function makePgArray(array2) {
|
|
21956
|
+
return `{${array2.map((item) => {
|
|
21957
|
+
if (Array.isArray(item)) {
|
|
21958
|
+
return makePgArray(item);
|
|
21959
|
+
}
|
|
21960
|
+
if (typeof item === "string") {
|
|
21961
|
+
return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
21962
|
+
}
|
|
21963
|
+
return `${item}`;
|
|
21964
|
+
}).join(",")}}`;
|
|
21965
|
+
}
|
|
21966
|
+
|
|
21967
|
+
// node_modules/drizzle-orm/pg-core/columns/common.js
|
|
21968
|
+
class PgColumnBuilder extends ColumnBuilder {
|
|
21969
|
+
foreignKeyConfigs = [];
|
|
21970
|
+
static [entityKind] = "PgColumnBuilder";
|
|
21971
|
+
array(size) {
|
|
21972
|
+
return new PgArrayBuilder(this.config.name, this, size);
|
|
21973
|
+
}
|
|
21974
|
+
references(ref, actions = {}) {
|
|
21975
|
+
this.foreignKeyConfigs.push({ ref, actions });
|
|
21976
|
+
return this;
|
|
21977
|
+
}
|
|
21978
|
+
unique(name, config) {
|
|
21979
|
+
this.config.isUnique = true;
|
|
21980
|
+
this.config.uniqueName = name;
|
|
21981
|
+
this.config.uniqueType = config?.nulls;
|
|
21982
|
+
return this;
|
|
21983
|
+
}
|
|
21984
|
+
generatedAlwaysAs(as) {
|
|
21985
|
+
this.config.generated = {
|
|
21986
|
+
as,
|
|
21987
|
+
type: "always",
|
|
21988
|
+
mode: "stored"
|
|
21989
|
+
};
|
|
21990
|
+
return this;
|
|
21991
|
+
}
|
|
21992
|
+
buildForeignKeys(column, table) {
|
|
21993
|
+
return this.foreignKeyConfigs.map(({ ref, actions }) => {
|
|
21994
|
+
return iife((ref2, actions2) => {
|
|
21995
|
+
const builder = new ForeignKeyBuilder(() => {
|
|
21996
|
+
const foreignColumn = ref2();
|
|
21997
|
+
return { columns: [column], foreignColumns: [foreignColumn] };
|
|
21998
|
+
});
|
|
21999
|
+
if (actions2.onUpdate) {
|
|
22000
|
+
builder.onUpdate(actions2.onUpdate);
|
|
22001
|
+
}
|
|
22002
|
+
if (actions2.onDelete) {
|
|
22003
|
+
builder.onDelete(actions2.onDelete);
|
|
22004
|
+
}
|
|
22005
|
+
return builder.build(table);
|
|
22006
|
+
}, ref, actions);
|
|
22007
|
+
});
|
|
22008
|
+
}
|
|
22009
|
+
buildExtraConfigColumn(table) {
|
|
22010
|
+
return new ExtraConfigColumn(table, this.config);
|
|
22011
|
+
}
|
|
22012
|
+
}
|
|
22013
|
+
|
|
22014
|
+
class PgColumn extends Column {
|
|
22015
|
+
constructor(table, config) {
|
|
22016
|
+
if (!config.uniqueName) {
|
|
22017
|
+
config.uniqueName = uniqueKeyName(table, [config.name]);
|
|
22018
|
+
}
|
|
22019
|
+
super(table, config);
|
|
22020
|
+
this.table = table;
|
|
22021
|
+
}
|
|
22022
|
+
static [entityKind] = "PgColumn";
|
|
22023
|
+
}
|
|
22024
|
+
|
|
22025
|
+
class ExtraConfigColumn extends PgColumn {
|
|
22026
|
+
static [entityKind] = "ExtraConfigColumn";
|
|
22027
|
+
getSQLType() {
|
|
22028
|
+
return this.getSQLType();
|
|
22029
|
+
}
|
|
22030
|
+
indexConfig = {
|
|
22031
|
+
order: this.config.order ?? "asc",
|
|
22032
|
+
nulls: this.config.nulls ?? "last",
|
|
22033
|
+
opClass: this.config.opClass
|
|
22034
|
+
};
|
|
22035
|
+
defaultConfig = {
|
|
22036
|
+
order: "asc",
|
|
22037
|
+
nulls: "last",
|
|
22038
|
+
opClass: undefined
|
|
22039
|
+
};
|
|
22040
|
+
asc() {
|
|
22041
|
+
this.indexConfig.order = "asc";
|
|
22042
|
+
return this;
|
|
22043
|
+
}
|
|
22044
|
+
desc() {
|
|
22045
|
+
this.indexConfig.order = "desc";
|
|
22046
|
+
return this;
|
|
22047
|
+
}
|
|
22048
|
+
nullsFirst() {
|
|
22049
|
+
this.indexConfig.nulls = "first";
|
|
22050
|
+
return this;
|
|
22051
|
+
}
|
|
22052
|
+
nullsLast() {
|
|
22053
|
+
this.indexConfig.nulls = "last";
|
|
22054
|
+
return this;
|
|
22055
|
+
}
|
|
22056
|
+
op(opClass) {
|
|
22057
|
+
this.indexConfig.opClass = opClass;
|
|
22058
|
+
return this;
|
|
22059
|
+
}
|
|
22060
|
+
}
|
|
22061
|
+
|
|
22062
|
+
class IndexedColumn {
|
|
22063
|
+
static [entityKind] = "IndexedColumn";
|
|
22064
|
+
constructor(name, keyAsName, type, indexConfig) {
|
|
22065
|
+
this.name = name;
|
|
22066
|
+
this.keyAsName = keyAsName;
|
|
22067
|
+
this.type = type;
|
|
22068
|
+
this.indexConfig = indexConfig;
|
|
22069
|
+
}
|
|
22070
|
+
name;
|
|
22071
|
+
keyAsName;
|
|
22072
|
+
type;
|
|
22073
|
+
indexConfig;
|
|
22074
|
+
}
|
|
22075
|
+
|
|
22076
|
+
class PgArrayBuilder extends PgColumnBuilder {
|
|
22077
|
+
static [entityKind] = "PgArrayBuilder";
|
|
22078
|
+
constructor(name, baseBuilder, size) {
|
|
22079
|
+
super(name, "array", "PgArray");
|
|
22080
|
+
this.config.baseBuilder = baseBuilder;
|
|
22081
|
+
this.config.size = size;
|
|
22082
|
+
}
|
|
22083
|
+
build(table) {
|
|
22084
|
+
const baseColumn = this.config.baseBuilder.build(table);
|
|
22085
|
+
return new PgArray(table, this.config, baseColumn);
|
|
22086
|
+
}
|
|
22087
|
+
}
|
|
22088
|
+
|
|
22089
|
+
class PgArray extends PgColumn {
|
|
22090
|
+
constructor(table, config, baseColumn, range) {
|
|
22091
|
+
super(table, config);
|
|
22092
|
+
this.baseColumn = baseColumn;
|
|
22093
|
+
this.range = range;
|
|
22094
|
+
this.size = config.size;
|
|
22095
|
+
}
|
|
22096
|
+
size;
|
|
22097
|
+
static [entityKind] = "PgArray";
|
|
22098
|
+
getSQLType() {
|
|
22099
|
+
return `${this.baseColumn.getSQLType()}[${typeof this.size === "number" ? this.size : ""}]`;
|
|
22100
|
+
}
|
|
22101
|
+
mapFromDriverValue(value) {
|
|
22102
|
+
if (typeof value === "string") {
|
|
22103
|
+
value = parsePgArray(value);
|
|
22104
|
+
}
|
|
22105
|
+
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
|
22106
|
+
}
|
|
22107
|
+
mapToDriverValue(value, isNestedArray = false) {
|
|
22108
|
+
const a = value.map((v) => v === null ? null : is(this.baseColumn, PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v));
|
|
22109
|
+
if (isNestedArray)
|
|
22110
|
+
return a;
|
|
22111
|
+
return makePgArray(a);
|
|
22112
|
+
}
|
|
22113
|
+
}
|
|
22114
|
+
|
|
22115
|
+
// node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
22116
|
+
class PgEnumObjectColumn extends PgColumn {
|
|
22117
|
+
static [entityKind] = "PgEnumObjectColumn";
|
|
22118
|
+
enum;
|
|
22119
|
+
enumValues = this.config.enum.enumValues;
|
|
22120
|
+
constructor(table, config) {
|
|
22121
|
+
super(table, config);
|
|
22122
|
+
this.enum = config.enum;
|
|
22123
|
+
}
|
|
22124
|
+
getSQLType() {
|
|
22125
|
+
return this.enum.enumName;
|
|
22126
|
+
}
|
|
22127
|
+
}
|
|
22128
|
+
var isPgEnumSym = Symbol.for("drizzle:isPgEnum");
|
|
22129
|
+
function isPgEnum(obj) {
|
|
22130
|
+
return !!obj && typeof obj === "function" && isPgEnumSym in obj && obj[isPgEnumSym] === true;
|
|
22131
|
+
}
|
|
22132
|
+
class PgEnumColumn extends PgColumn {
|
|
22133
|
+
static [entityKind] = "PgEnumColumn";
|
|
22134
|
+
enum = this.config.enum;
|
|
22135
|
+
enumValues = this.config.enum.enumValues;
|
|
22136
|
+
constructor(table, config) {
|
|
22137
|
+
super(table, config);
|
|
22138
|
+
this.enum = config.enum;
|
|
22139
|
+
}
|
|
22140
|
+
getSQLType() {
|
|
22141
|
+
return this.enum.enumName;
|
|
22142
|
+
}
|
|
22143
|
+
}
|
|
22144
|
+
|
|
22145
|
+
// node_modules/drizzle-orm/subquery.js
|
|
22146
|
+
class Subquery {
|
|
22147
|
+
static [entityKind] = "Subquery";
|
|
22148
|
+
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
22149
|
+
this._ = {
|
|
22150
|
+
brand: "Subquery",
|
|
22151
|
+
sql,
|
|
22152
|
+
selectedFields: fields,
|
|
22153
|
+
alias,
|
|
22154
|
+
isWith,
|
|
22155
|
+
usedTables
|
|
22156
|
+
};
|
|
22157
|
+
}
|
|
22158
|
+
}
|
|
22159
|
+
|
|
22160
|
+
// node_modules/drizzle-orm/version.js
|
|
22161
|
+
var version = "0.44.7";
|
|
22162
|
+
|
|
22163
|
+
// node_modules/drizzle-orm/tracing.js
|
|
22164
|
+
var otel;
|
|
22165
|
+
var rawTracer;
|
|
22166
|
+
var tracer = {
|
|
22167
|
+
startActiveSpan(name, fn) {
|
|
22168
|
+
if (!otel) {
|
|
22169
|
+
return fn();
|
|
22170
|
+
}
|
|
22171
|
+
if (!rawTracer) {
|
|
22172
|
+
rawTracer = otel.trace.getTracer("drizzle-orm", version);
|
|
22173
|
+
}
|
|
22174
|
+
return iife((otel2, rawTracer2) => rawTracer2.startActiveSpan(name, (span) => {
|
|
22175
|
+
try {
|
|
22176
|
+
return fn(span);
|
|
22177
|
+
} catch (e) {
|
|
22178
|
+
span.setStatus({
|
|
22179
|
+
code: otel2.SpanStatusCode.ERROR,
|
|
22180
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
22181
|
+
});
|
|
22182
|
+
throw e;
|
|
22183
|
+
} finally {
|
|
22184
|
+
span.end();
|
|
22185
|
+
}
|
|
22186
|
+
}), otel, rawTracer);
|
|
22187
|
+
}
|
|
22188
|
+
};
|
|
22189
|
+
|
|
22190
|
+
// node_modules/drizzle-orm/view-common.js
|
|
22191
|
+
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
22192
|
+
|
|
22193
|
+
// node_modules/drizzle-orm/table.js
|
|
22194
|
+
var Schema = Symbol.for("drizzle:Schema");
|
|
22195
|
+
var Columns = Symbol.for("drizzle:Columns");
|
|
22196
|
+
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
22197
|
+
var OriginalName = Symbol.for("drizzle:OriginalName");
|
|
22198
|
+
var BaseName = Symbol.for("drizzle:BaseName");
|
|
22199
|
+
var IsAlias = Symbol.for("drizzle:IsAlias");
|
|
22200
|
+
var ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
|
22201
|
+
var IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
|
22202
|
+
|
|
22203
|
+
class Table {
|
|
22204
|
+
static [entityKind] = "Table";
|
|
22205
|
+
static Symbol = {
|
|
22206
|
+
Name: TableName,
|
|
22207
|
+
Schema,
|
|
22208
|
+
OriginalName,
|
|
22209
|
+
Columns,
|
|
22210
|
+
ExtraConfigColumns,
|
|
22211
|
+
BaseName,
|
|
22212
|
+
IsAlias,
|
|
22213
|
+
ExtraConfigBuilder
|
|
22214
|
+
};
|
|
22215
|
+
[TableName];
|
|
22216
|
+
[OriginalName];
|
|
22217
|
+
[Schema];
|
|
22218
|
+
[Columns];
|
|
22219
|
+
[ExtraConfigColumns];
|
|
22220
|
+
[BaseName];
|
|
22221
|
+
[IsAlias] = false;
|
|
22222
|
+
[IsDrizzleTable] = true;
|
|
22223
|
+
[ExtraConfigBuilder] = undefined;
|
|
22224
|
+
constructor(name, schema, baseName) {
|
|
22225
|
+
this[TableName] = this[OriginalName] = name;
|
|
22226
|
+
this[Schema] = schema;
|
|
22227
|
+
this[BaseName] = baseName;
|
|
22228
|
+
}
|
|
22229
|
+
}
|
|
22230
|
+
|
|
22231
|
+
// node_modules/drizzle-orm/sql/sql.js
|
|
22232
|
+
function isSQLWrapper(value) {
|
|
22233
|
+
return value !== null && value !== undefined && typeof value.getSQL === "function";
|
|
22234
|
+
}
|
|
22235
|
+
function mergeQueries(queries) {
|
|
22236
|
+
const result = { sql: "", params: [] };
|
|
22237
|
+
for (const query of queries) {
|
|
22238
|
+
result.sql += query.sql;
|
|
22239
|
+
result.params.push(...query.params);
|
|
22240
|
+
if (query.typings?.length) {
|
|
22241
|
+
if (!result.typings) {
|
|
22242
|
+
result.typings = [];
|
|
22243
|
+
}
|
|
22244
|
+
result.typings.push(...query.typings);
|
|
22245
|
+
}
|
|
22246
|
+
}
|
|
22247
|
+
return result;
|
|
22248
|
+
}
|
|
22249
|
+
|
|
22250
|
+
class StringChunk {
|
|
22251
|
+
static [entityKind] = "StringChunk";
|
|
22252
|
+
value;
|
|
22253
|
+
constructor(value) {
|
|
22254
|
+
this.value = Array.isArray(value) ? value : [value];
|
|
22255
|
+
}
|
|
22256
|
+
getSQL() {
|
|
22257
|
+
return new SQL([this]);
|
|
22258
|
+
}
|
|
22259
|
+
}
|
|
22260
|
+
|
|
22261
|
+
class SQL {
|
|
22262
|
+
constructor(queryChunks) {
|
|
22263
|
+
this.queryChunks = queryChunks;
|
|
22264
|
+
for (const chunk of queryChunks) {
|
|
22265
|
+
if (is(chunk, Table)) {
|
|
22266
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
22267
|
+
this.usedTables.push(schemaName === undefined ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
|
|
22268
|
+
}
|
|
22269
|
+
}
|
|
22270
|
+
}
|
|
22271
|
+
static [entityKind] = "SQL";
|
|
22272
|
+
decoder = noopDecoder;
|
|
22273
|
+
shouldInlineParams = false;
|
|
22274
|
+
usedTables = [];
|
|
22275
|
+
append(query) {
|
|
22276
|
+
this.queryChunks.push(...query.queryChunks);
|
|
22277
|
+
return this;
|
|
22278
|
+
}
|
|
22279
|
+
toQuery(config) {
|
|
22280
|
+
return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
|
|
22281
|
+
const query = this.buildQueryFromSourceParams(this.queryChunks, config);
|
|
22282
|
+
span?.setAttributes({
|
|
22283
|
+
"drizzle.query.text": query.sql,
|
|
22284
|
+
"drizzle.query.params": JSON.stringify(query.params)
|
|
22285
|
+
});
|
|
22286
|
+
return query;
|
|
22287
|
+
});
|
|
22288
|
+
}
|
|
22289
|
+
buildQueryFromSourceParams(chunks, _config) {
|
|
22290
|
+
const config = Object.assign({}, _config, {
|
|
22291
|
+
inlineParams: _config.inlineParams || this.shouldInlineParams,
|
|
22292
|
+
paramStartIndex: _config.paramStartIndex || { value: 0 }
|
|
22293
|
+
});
|
|
22294
|
+
const {
|
|
22295
|
+
casing,
|
|
22296
|
+
escapeName,
|
|
22297
|
+
escapeParam,
|
|
22298
|
+
prepareTyping,
|
|
22299
|
+
inlineParams,
|
|
22300
|
+
paramStartIndex
|
|
22301
|
+
} = config;
|
|
22302
|
+
return mergeQueries(chunks.map((chunk) => {
|
|
22303
|
+
if (is(chunk, StringChunk)) {
|
|
22304
|
+
return { sql: chunk.value.join(""), params: [] };
|
|
22305
|
+
}
|
|
22306
|
+
if (is(chunk, Name)) {
|
|
22307
|
+
return { sql: escapeName(chunk.value), params: [] };
|
|
22308
|
+
}
|
|
22309
|
+
if (chunk === undefined) {
|
|
22310
|
+
return { sql: "", params: [] };
|
|
22311
|
+
}
|
|
22312
|
+
if (Array.isArray(chunk)) {
|
|
22313
|
+
const result = [new StringChunk("(")];
|
|
22314
|
+
for (const [i, p] of chunk.entries()) {
|
|
22315
|
+
result.push(p);
|
|
22316
|
+
if (i < chunk.length - 1) {
|
|
22317
|
+
result.push(new StringChunk(", "));
|
|
22318
|
+
}
|
|
22319
|
+
}
|
|
22320
|
+
result.push(new StringChunk(")"));
|
|
22321
|
+
return this.buildQueryFromSourceParams(result, config);
|
|
22322
|
+
}
|
|
22323
|
+
if (is(chunk, SQL)) {
|
|
22324
|
+
return this.buildQueryFromSourceParams(chunk.queryChunks, {
|
|
22325
|
+
...config,
|
|
22326
|
+
inlineParams: inlineParams || chunk.shouldInlineParams
|
|
22327
|
+
});
|
|
22328
|
+
}
|
|
22329
|
+
if (is(chunk, Table)) {
|
|
22330
|
+
const schemaName = chunk[Table.Symbol.Schema];
|
|
22331
|
+
const tableName = chunk[Table.Symbol.Name];
|
|
22332
|
+
return {
|
|
22333
|
+
sql: schemaName === undefined || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
|
|
22334
|
+
params: []
|
|
22335
|
+
};
|
|
22336
|
+
}
|
|
22337
|
+
if (is(chunk, Column)) {
|
|
22338
|
+
const columnName = casing.getColumnCasing(chunk);
|
|
22339
|
+
if (_config.invokeSource === "indexes") {
|
|
22340
|
+
return { sql: escapeName(columnName), params: [] };
|
|
22341
|
+
}
|
|
22342
|
+
const schemaName = chunk.table[Table.Symbol.Schema];
|
|
22343
|
+
return {
|
|
22344
|
+
sql: chunk.table[IsAlias] || schemaName === undefined ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
|
|
22345
|
+
params: []
|
|
22346
|
+
};
|
|
22347
|
+
}
|
|
22348
|
+
if (is(chunk, View)) {
|
|
22349
|
+
const schemaName = chunk[ViewBaseConfig].schema;
|
|
22350
|
+
const viewName = chunk[ViewBaseConfig].name;
|
|
22351
|
+
return {
|
|
22352
|
+
sql: schemaName === undefined || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
|
|
22353
|
+
params: []
|
|
22354
|
+
};
|
|
22355
|
+
}
|
|
22356
|
+
if (is(chunk, Param)) {
|
|
22357
|
+
if (is(chunk.value, Placeholder)) {
|
|
22358
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
22359
|
+
}
|
|
22360
|
+
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
|
22361
|
+
if (is(mappedValue, SQL)) {
|
|
22362
|
+
return this.buildQueryFromSourceParams([mappedValue], config);
|
|
22363
|
+
}
|
|
22364
|
+
if (inlineParams) {
|
|
22365
|
+
return { sql: this.mapInlineParam(mappedValue, config), params: [] };
|
|
22366
|
+
}
|
|
22367
|
+
let typings = ["none"];
|
|
22368
|
+
if (prepareTyping) {
|
|
22369
|
+
typings = [prepareTyping(chunk.encoder)];
|
|
22370
|
+
}
|
|
22371
|
+
return { sql: escapeParam(paramStartIndex.value++, mappedValue), params: [mappedValue], typings };
|
|
22372
|
+
}
|
|
22373
|
+
if (is(chunk, Placeholder)) {
|
|
22374
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
22375
|
+
}
|
|
22376
|
+
if (is(chunk, SQL.Aliased) && chunk.fieldAlias !== undefined) {
|
|
22377
|
+
return { sql: escapeName(chunk.fieldAlias), params: [] };
|
|
22378
|
+
}
|
|
22379
|
+
if (is(chunk, Subquery)) {
|
|
22380
|
+
if (chunk._.isWith) {
|
|
22381
|
+
return { sql: escapeName(chunk._.alias), params: [] };
|
|
22382
|
+
}
|
|
22383
|
+
return this.buildQueryFromSourceParams([
|
|
22384
|
+
new StringChunk("("),
|
|
22385
|
+
chunk._.sql,
|
|
22386
|
+
new StringChunk(") "),
|
|
22387
|
+
new Name(chunk._.alias)
|
|
22388
|
+
], config);
|
|
22389
|
+
}
|
|
22390
|
+
if (isPgEnum(chunk)) {
|
|
22391
|
+
if (chunk.schema) {
|
|
22392
|
+
return { sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName), params: [] };
|
|
22393
|
+
}
|
|
22394
|
+
return { sql: escapeName(chunk.enumName), params: [] };
|
|
22395
|
+
}
|
|
22396
|
+
if (isSQLWrapper(chunk)) {
|
|
22397
|
+
if (chunk.shouldOmitSQLParens?.()) {
|
|
22398
|
+
return this.buildQueryFromSourceParams([chunk.getSQL()], config);
|
|
22399
|
+
}
|
|
22400
|
+
return this.buildQueryFromSourceParams([
|
|
22401
|
+
new StringChunk("("),
|
|
22402
|
+
chunk.getSQL(),
|
|
22403
|
+
new StringChunk(")")
|
|
22404
|
+
], config);
|
|
22405
|
+
}
|
|
22406
|
+
if (inlineParams) {
|
|
22407
|
+
return { sql: this.mapInlineParam(chunk, config), params: [] };
|
|
22408
|
+
}
|
|
22409
|
+
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
|
22410
|
+
}));
|
|
22411
|
+
}
|
|
22412
|
+
mapInlineParam(chunk, { escapeString }) {
|
|
22413
|
+
if (chunk === null) {
|
|
22414
|
+
return "null";
|
|
22415
|
+
}
|
|
22416
|
+
if (typeof chunk === "number" || typeof chunk === "boolean") {
|
|
22417
|
+
return chunk.toString();
|
|
22418
|
+
}
|
|
22419
|
+
if (typeof chunk === "string") {
|
|
22420
|
+
return escapeString(chunk);
|
|
22421
|
+
}
|
|
22422
|
+
if (typeof chunk === "object") {
|
|
22423
|
+
const mappedValueAsString = chunk.toString();
|
|
22424
|
+
if (mappedValueAsString === "[object Object]") {
|
|
22425
|
+
return escapeString(JSON.stringify(chunk));
|
|
22426
|
+
}
|
|
22427
|
+
return escapeString(mappedValueAsString);
|
|
22428
|
+
}
|
|
22429
|
+
throw new Error("Unexpected param value: " + chunk);
|
|
22430
|
+
}
|
|
22431
|
+
getSQL() {
|
|
22432
|
+
return this;
|
|
22433
|
+
}
|
|
22434
|
+
as(alias) {
|
|
22435
|
+
if (alias === undefined) {
|
|
22436
|
+
return this;
|
|
22437
|
+
}
|
|
22438
|
+
return new SQL.Aliased(this, alias);
|
|
22439
|
+
}
|
|
22440
|
+
mapWith(decoder) {
|
|
22441
|
+
this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
|
|
22442
|
+
return this;
|
|
22443
|
+
}
|
|
22444
|
+
inlineParams() {
|
|
22445
|
+
this.shouldInlineParams = true;
|
|
22446
|
+
return this;
|
|
22447
|
+
}
|
|
22448
|
+
if(condition) {
|
|
22449
|
+
return condition ? this : undefined;
|
|
22450
|
+
}
|
|
22451
|
+
}
|
|
22452
|
+
|
|
22453
|
+
class Name {
|
|
22454
|
+
constructor(value) {
|
|
22455
|
+
this.value = value;
|
|
22456
|
+
}
|
|
22457
|
+
static [entityKind] = "Name";
|
|
22458
|
+
brand;
|
|
22459
|
+
getSQL() {
|
|
22460
|
+
return new SQL([this]);
|
|
22461
|
+
}
|
|
22462
|
+
}
|
|
22463
|
+
function isDriverValueEncoder(value) {
|
|
22464
|
+
return typeof value === "object" && value !== null && "mapToDriverValue" in value && typeof value.mapToDriverValue === "function";
|
|
22465
|
+
}
|
|
22466
|
+
var noopDecoder = {
|
|
22467
|
+
mapFromDriverValue: (value) => value
|
|
22468
|
+
};
|
|
22469
|
+
var noopEncoder = {
|
|
22470
|
+
mapToDriverValue: (value) => value
|
|
22471
|
+
};
|
|
22472
|
+
var noopMapper = {
|
|
22473
|
+
...noopDecoder,
|
|
22474
|
+
...noopEncoder
|
|
22475
|
+
};
|
|
22476
|
+
|
|
22477
|
+
class Param {
|
|
22478
|
+
constructor(value, encoder = noopEncoder) {
|
|
22479
|
+
this.value = value;
|
|
22480
|
+
this.encoder = encoder;
|
|
22481
|
+
}
|
|
22482
|
+
static [entityKind] = "Param";
|
|
22483
|
+
brand;
|
|
22484
|
+
getSQL() {
|
|
22485
|
+
return new SQL([this]);
|
|
22486
|
+
}
|
|
22487
|
+
}
|
|
22488
|
+
function sql(strings, ...params) {
|
|
22489
|
+
const queryChunks = [];
|
|
22490
|
+
if (params.length > 0 || strings.length > 0 && strings[0] !== "") {
|
|
22491
|
+
queryChunks.push(new StringChunk(strings[0]));
|
|
22492
|
+
}
|
|
22493
|
+
for (const [paramIndex, param2] of params.entries()) {
|
|
22494
|
+
queryChunks.push(param2, new StringChunk(strings[paramIndex + 1]));
|
|
22495
|
+
}
|
|
22496
|
+
return new SQL(queryChunks);
|
|
22497
|
+
}
|
|
22498
|
+
((sql2) => {
|
|
22499
|
+
function empty() {
|
|
22500
|
+
return new SQL([]);
|
|
22501
|
+
}
|
|
22502
|
+
sql2.empty = empty;
|
|
22503
|
+
function fromList(list) {
|
|
22504
|
+
return new SQL(list);
|
|
22505
|
+
}
|
|
22506
|
+
sql2.fromList = fromList;
|
|
22507
|
+
function raw(str) {
|
|
22508
|
+
return new SQL([new StringChunk(str)]);
|
|
22509
|
+
}
|
|
22510
|
+
sql2.raw = raw;
|
|
22511
|
+
function join(chunks, separator) {
|
|
22512
|
+
const result = [];
|
|
22513
|
+
for (const [i, chunk] of chunks.entries()) {
|
|
22514
|
+
if (i > 0 && separator !== undefined) {
|
|
22515
|
+
result.push(separator);
|
|
22516
|
+
}
|
|
22517
|
+
result.push(chunk);
|
|
22518
|
+
}
|
|
22519
|
+
return new SQL(result);
|
|
22520
|
+
}
|
|
22521
|
+
sql2.join = join;
|
|
22522
|
+
function identifier(value) {
|
|
22523
|
+
return new Name(value);
|
|
22524
|
+
}
|
|
22525
|
+
sql2.identifier = identifier;
|
|
22526
|
+
function placeholder2(name2) {
|
|
22527
|
+
return new Placeholder(name2);
|
|
22528
|
+
}
|
|
22529
|
+
sql2.placeholder = placeholder2;
|
|
22530
|
+
function param2(value, encoder) {
|
|
22531
|
+
return new Param(value, encoder);
|
|
22532
|
+
}
|
|
22533
|
+
sql2.param = param2;
|
|
22534
|
+
})(sql || (sql = {}));
|
|
22535
|
+
((SQL2) => {
|
|
22536
|
+
|
|
22537
|
+
class Aliased {
|
|
22538
|
+
constructor(sql2, fieldAlias) {
|
|
22539
|
+
this.sql = sql2;
|
|
22540
|
+
this.fieldAlias = fieldAlias;
|
|
22541
|
+
}
|
|
22542
|
+
static [entityKind] = "SQL.Aliased";
|
|
22543
|
+
isSelectionField = false;
|
|
22544
|
+
getSQL() {
|
|
22545
|
+
return this.sql;
|
|
22546
|
+
}
|
|
22547
|
+
clone() {
|
|
22548
|
+
return new Aliased(this.sql, this.fieldAlias);
|
|
22549
|
+
}
|
|
22550
|
+
}
|
|
22551
|
+
SQL2.Aliased = Aliased;
|
|
22552
|
+
})(SQL || (SQL = {}));
|
|
22553
|
+
|
|
22554
|
+
class Placeholder {
|
|
22555
|
+
constructor(name2) {
|
|
22556
|
+
this.name = name2;
|
|
22557
|
+
}
|
|
22558
|
+
static [entityKind] = "Placeholder";
|
|
22559
|
+
getSQL() {
|
|
22560
|
+
return new SQL([this]);
|
|
22561
|
+
}
|
|
22562
|
+
}
|
|
22563
|
+
var IsDrizzleView = Symbol.for("drizzle:IsDrizzleView");
|
|
22564
|
+
|
|
22565
|
+
class View {
|
|
22566
|
+
static [entityKind] = "View";
|
|
22567
|
+
[ViewBaseConfig];
|
|
22568
|
+
[IsDrizzleView] = true;
|
|
22569
|
+
constructor({ name: name2, schema, selectedFields, query }) {
|
|
22570
|
+
this[ViewBaseConfig] = {
|
|
22571
|
+
name: name2,
|
|
22572
|
+
originalName: name2,
|
|
22573
|
+
schema,
|
|
22574
|
+
selectedFields,
|
|
22575
|
+
query,
|
|
22576
|
+
isExisting: !query,
|
|
22577
|
+
isAlias: false
|
|
22578
|
+
};
|
|
22579
|
+
}
|
|
22580
|
+
getSQL() {
|
|
22581
|
+
return new SQL([this]);
|
|
22582
|
+
}
|
|
22583
|
+
}
|
|
22584
|
+
Column.prototype.getSQL = function() {
|
|
22585
|
+
return new SQL([this]);
|
|
22586
|
+
};
|
|
22587
|
+
Table.prototype.getSQL = function() {
|
|
22588
|
+
return new SQL([this]);
|
|
22589
|
+
};
|
|
22590
|
+
Subquery.prototype.getSQL = function() {
|
|
22591
|
+
return new SQL([this]);
|
|
22592
|
+
};
|
|
22593
|
+
|
|
22594
|
+
// node_modules/drizzle-orm/utils.js
|
|
22595
|
+
function getColumnNameAndConfig(a, b) {
|
|
22596
|
+
return {
|
|
22597
|
+
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
22598
|
+
config: typeof a === "object" ? a : b
|
|
22599
|
+
};
|
|
22600
|
+
}
|
|
22601
|
+
var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
|
|
22602
|
+
|
|
22603
|
+
// node_modules/drizzle-orm/pg-core/columns/int.common.js
|
|
22604
|
+
class PgIntColumnBaseBuilder extends PgColumnBuilder {
|
|
22605
|
+
static [entityKind] = "PgIntColumnBaseBuilder";
|
|
22606
|
+
generatedAlwaysAsIdentity(sequence) {
|
|
22607
|
+
if (sequence) {
|
|
22608
|
+
const { name, ...options } = sequence;
|
|
22609
|
+
this.config.generatedIdentity = {
|
|
22610
|
+
type: "always",
|
|
22611
|
+
sequenceName: name,
|
|
22612
|
+
sequenceOptions: options
|
|
22613
|
+
};
|
|
22614
|
+
} else {
|
|
22615
|
+
this.config.generatedIdentity = {
|
|
22616
|
+
type: "always"
|
|
22617
|
+
};
|
|
22618
|
+
}
|
|
22619
|
+
this.config.hasDefault = true;
|
|
22620
|
+
this.config.notNull = true;
|
|
22621
|
+
return this;
|
|
22622
|
+
}
|
|
22623
|
+
generatedByDefaultAsIdentity(sequence) {
|
|
22624
|
+
if (sequence) {
|
|
22625
|
+
const { name, ...options } = sequence;
|
|
22626
|
+
this.config.generatedIdentity = {
|
|
22627
|
+
type: "byDefault",
|
|
22628
|
+
sequenceName: name,
|
|
22629
|
+
sequenceOptions: options
|
|
22630
|
+
};
|
|
22631
|
+
} else {
|
|
22632
|
+
this.config.generatedIdentity = {
|
|
22633
|
+
type: "byDefault"
|
|
22634
|
+
};
|
|
22635
|
+
}
|
|
22636
|
+
this.config.hasDefault = true;
|
|
22637
|
+
this.config.notNull = true;
|
|
22638
|
+
return this;
|
|
22639
|
+
}
|
|
22640
|
+
}
|
|
22641
|
+
|
|
22642
|
+
// node_modules/drizzle-orm/pg-core/columns/bigint.js
|
|
22643
|
+
class PgBigInt53Builder extends PgIntColumnBaseBuilder {
|
|
22644
|
+
static [entityKind] = "PgBigInt53Builder";
|
|
22645
|
+
constructor(name) {
|
|
22646
|
+
super(name, "number", "PgBigInt53");
|
|
22647
|
+
}
|
|
22648
|
+
build(table) {
|
|
22649
|
+
return new PgBigInt53(table, this.config);
|
|
22650
|
+
}
|
|
22651
|
+
}
|
|
22652
|
+
|
|
22653
|
+
class PgBigInt53 extends PgColumn {
|
|
22654
|
+
static [entityKind] = "PgBigInt53";
|
|
22655
|
+
getSQLType() {
|
|
22656
|
+
return "bigint";
|
|
22657
|
+
}
|
|
22658
|
+
mapFromDriverValue(value) {
|
|
22659
|
+
if (typeof value === "number") {
|
|
22660
|
+
return value;
|
|
22661
|
+
}
|
|
22662
|
+
return Number(value);
|
|
22663
|
+
}
|
|
22664
|
+
}
|
|
22665
|
+
|
|
22666
|
+
class PgBigInt64Builder extends PgIntColumnBaseBuilder {
|
|
22667
|
+
static [entityKind] = "PgBigInt64Builder";
|
|
22668
|
+
constructor(name) {
|
|
22669
|
+
super(name, "bigint", "PgBigInt64");
|
|
22670
|
+
}
|
|
22671
|
+
build(table) {
|
|
22672
|
+
return new PgBigInt64(table, this.config);
|
|
22673
|
+
}
|
|
22674
|
+
}
|
|
22675
|
+
|
|
22676
|
+
class PgBigInt64 extends PgColumn {
|
|
22677
|
+
static [entityKind] = "PgBigInt64";
|
|
22678
|
+
getSQLType() {
|
|
22679
|
+
return "bigint";
|
|
22680
|
+
}
|
|
22681
|
+
mapFromDriverValue(value) {
|
|
22682
|
+
return BigInt(value);
|
|
22683
|
+
}
|
|
22684
|
+
}
|
|
22685
|
+
function bigint2(a, b) {
|
|
22686
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
22687
|
+
if (config.mode === "number") {
|
|
22688
|
+
return new PgBigInt53Builder(name);
|
|
22689
|
+
}
|
|
22690
|
+
return new PgBigInt64Builder(name);
|
|
22691
|
+
}
|
|
22692
|
+
|
|
22693
|
+
// node_modules/drizzle-orm/pg-core/columns/bigserial.js
|
|
22694
|
+
class PgBigSerial53Builder extends PgColumnBuilder {
|
|
22695
|
+
static [entityKind] = "PgBigSerial53Builder";
|
|
22696
|
+
constructor(name) {
|
|
22697
|
+
super(name, "number", "PgBigSerial53");
|
|
22698
|
+
this.config.hasDefault = true;
|
|
22699
|
+
this.config.notNull = true;
|
|
22700
|
+
}
|
|
22701
|
+
build(table) {
|
|
22702
|
+
return new PgBigSerial53(table, this.config);
|
|
22703
|
+
}
|
|
22704
|
+
}
|
|
22705
|
+
|
|
22706
|
+
class PgBigSerial53 extends PgColumn {
|
|
22707
|
+
static [entityKind] = "PgBigSerial53";
|
|
22708
|
+
getSQLType() {
|
|
22709
|
+
return "bigserial";
|
|
22710
|
+
}
|
|
22711
|
+
mapFromDriverValue(value) {
|
|
22712
|
+
if (typeof value === "number") {
|
|
22713
|
+
return value;
|
|
22714
|
+
}
|
|
22715
|
+
return Number(value);
|
|
22716
|
+
}
|
|
22717
|
+
}
|
|
22718
|
+
|
|
22719
|
+
class PgBigSerial64Builder extends PgColumnBuilder {
|
|
22720
|
+
static [entityKind] = "PgBigSerial64Builder";
|
|
22721
|
+
constructor(name) {
|
|
22722
|
+
super(name, "bigint", "PgBigSerial64");
|
|
22723
|
+
this.config.hasDefault = true;
|
|
22724
|
+
}
|
|
22725
|
+
build(table) {
|
|
22726
|
+
return new PgBigSerial64(table, this.config);
|
|
22727
|
+
}
|
|
22728
|
+
}
|
|
22729
|
+
|
|
22730
|
+
class PgBigSerial64 extends PgColumn {
|
|
22731
|
+
static [entityKind] = "PgBigSerial64";
|
|
22732
|
+
getSQLType() {
|
|
22733
|
+
return "bigserial";
|
|
22734
|
+
}
|
|
22735
|
+
mapFromDriverValue(value) {
|
|
22736
|
+
return BigInt(value);
|
|
22737
|
+
}
|
|
22738
|
+
}
|
|
22739
|
+
function bigserial(a, b) {
|
|
22740
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
22741
|
+
if (config.mode === "number") {
|
|
22742
|
+
return new PgBigSerial53Builder(name);
|
|
22743
|
+
}
|
|
22744
|
+
return new PgBigSerial64Builder(name);
|
|
22745
|
+
}
|
|
22746
|
+
|
|
22747
|
+
// node_modules/drizzle-orm/pg-core/columns/boolean.js
|
|
22748
|
+
class PgBooleanBuilder extends PgColumnBuilder {
|
|
22749
|
+
static [entityKind] = "PgBooleanBuilder";
|
|
22750
|
+
constructor(name) {
|
|
22751
|
+
super(name, "boolean", "PgBoolean");
|
|
22752
|
+
}
|
|
22753
|
+
build(table) {
|
|
22754
|
+
return new PgBoolean(table, this.config);
|
|
22755
|
+
}
|
|
22756
|
+
}
|
|
22757
|
+
|
|
22758
|
+
class PgBoolean extends PgColumn {
|
|
22759
|
+
static [entityKind] = "PgBoolean";
|
|
22760
|
+
getSQLType() {
|
|
22761
|
+
return "boolean";
|
|
22762
|
+
}
|
|
22763
|
+
}
|
|
22764
|
+
function boolean2(name) {
|
|
22765
|
+
return new PgBooleanBuilder(name ?? "");
|
|
22766
|
+
}
|
|
22767
|
+
|
|
22768
|
+
// node_modules/drizzle-orm/pg-core/columns/char.js
|
|
22769
|
+
class PgCharBuilder extends PgColumnBuilder {
|
|
22770
|
+
static [entityKind] = "PgCharBuilder";
|
|
22771
|
+
constructor(name, config) {
|
|
22772
|
+
super(name, "string", "PgChar");
|
|
22773
|
+
this.config.length = config.length;
|
|
22774
|
+
this.config.enumValues = config.enum;
|
|
22775
|
+
}
|
|
22776
|
+
build(table) {
|
|
22777
|
+
return new PgChar(table, this.config);
|
|
22778
|
+
}
|
|
22779
|
+
}
|
|
22780
|
+
|
|
22781
|
+
class PgChar extends PgColumn {
|
|
22782
|
+
static [entityKind] = "PgChar";
|
|
22783
|
+
length = this.config.length;
|
|
22784
|
+
enumValues = this.config.enumValues;
|
|
22785
|
+
getSQLType() {
|
|
22786
|
+
return this.length === undefined ? `char` : `char(${this.length})`;
|
|
22787
|
+
}
|
|
22788
|
+
}
|
|
22789
|
+
function char(a, b = {}) {
|
|
22790
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
22791
|
+
return new PgCharBuilder(name, config);
|
|
22792
|
+
}
|
|
22793
|
+
|
|
22794
|
+
// node_modules/drizzle-orm/pg-core/columns/cidr.js
|
|
22795
|
+
class PgCidrBuilder extends PgColumnBuilder {
|
|
22796
|
+
static [entityKind] = "PgCidrBuilder";
|
|
22797
|
+
constructor(name) {
|
|
22798
|
+
super(name, "string", "PgCidr");
|
|
22799
|
+
}
|
|
22800
|
+
build(table) {
|
|
22801
|
+
return new PgCidr(table, this.config);
|
|
22802
|
+
}
|
|
22803
|
+
}
|
|
22804
|
+
|
|
22805
|
+
class PgCidr extends PgColumn {
|
|
22806
|
+
static [entityKind] = "PgCidr";
|
|
22807
|
+
getSQLType() {
|
|
22808
|
+
return "cidr";
|
|
22809
|
+
}
|
|
22810
|
+
}
|
|
22811
|
+
function cidr(name) {
|
|
22812
|
+
return new PgCidrBuilder(name ?? "");
|
|
22813
|
+
}
|
|
22814
|
+
|
|
22815
|
+
// node_modules/drizzle-orm/pg-core/columns/custom.js
|
|
22816
|
+
class PgCustomColumnBuilder extends PgColumnBuilder {
|
|
22817
|
+
static [entityKind] = "PgCustomColumnBuilder";
|
|
22818
|
+
constructor(name, fieldConfig, customTypeParams) {
|
|
22819
|
+
super(name, "custom", "PgCustomColumn");
|
|
22820
|
+
this.config.fieldConfig = fieldConfig;
|
|
22821
|
+
this.config.customTypeParams = customTypeParams;
|
|
22822
|
+
}
|
|
22823
|
+
build(table) {
|
|
22824
|
+
return new PgCustomColumn(table, this.config);
|
|
22825
|
+
}
|
|
22826
|
+
}
|
|
22827
|
+
|
|
22828
|
+
class PgCustomColumn extends PgColumn {
|
|
22829
|
+
static [entityKind] = "PgCustomColumn";
|
|
22830
|
+
sqlName;
|
|
22831
|
+
mapTo;
|
|
22832
|
+
mapFrom;
|
|
22833
|
+
constructor(table, config) {
|
|
22834
|
+
super(table, config);
|
|
22835
|
+
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
|
22836
|
+
this.mapTo = config.customTypeParams.toDriver;
|
|
22837
|
+
this.mapFrom = config.customTypeParams.fromDriver;
|
|
22838
|
+
}
|
|
22839
|
+
getSQLType() {
|
|
22840
|
+
return this.sqlName;
|
|
22841
|
+
}
|
|
22842
|
+
mapFromDriverValue(value) {
|
|
22843
|
+
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
|
22844
|
+
}
|
|
22845
|
+
mapToDriverValue(value) {
|
|
22846
|
+
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
|
22847
|
+
}
|
|
22848
|
+
}
|
|
22849
|
+
function customType(customTypeParams) {
|
|
22850
|
+
return (a, b) => {
|
|
22851
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
22852
|
+
return new PgCustomColumnBuilder(name, config, customTypeParams);
|
|
22853
|
+
};
|
|
22854
|
+
}
|
|
22855
|
+
|
|
22856
|
+
// node_modules/drizzle-orm/pg-core/columns/date.common.js
|
|
22857
|
+
class PgDateColumnBaseBuilder extends PgColumnBuilder {
|
|
22858
|
+
static [entityKind] = "PgDateColumnBaseBuilder";
|
|
22859
|
+
defaultNow() {
|
|
22860
|
+
return this.default(sql`now()`);
|
|
22861
|
+
}
|
|
22862
|
+
}
|
|
22863
|
+
|
|
22864
|
+
// node_modules/drizzle-orm/pg-core/columns/date.js
|
|
22865
|
+
class PgDateBuilder extends PgDateColumnBaseBuilder {
|
|
22866
|
+
static [entityKind] = "PgDateBuilder";
|
|
22867
|
+
constructor(name) {
|
|
22868
|
+
super(name, "date", "PgDate");
|
|
22869
|
+
}
|
|
22870
|
+
build(table) {
|
|
22871
|
+
return new PgDate(table, this.config);
|
|
22872
|
+
}
|
|
22873
|
+
}
|
|
22874
|
+
|
|
22875
|
+
class PgDate extends PgColumn {
|
|
22876
|
+
static [entityKind] = "PgDate";
|
|
22877
|
+
getSQLType() {
|
|
22878
|
+
return "date";
|
|
22879
|
+
}
|
|
22880
|
+
mapFromDriverValue(value) {
|
|
22881
|
+
return new Date(value);
|
|
22882
|
+
}
|
|
22883
|
+
mapToDriverValue(value) {
|
|
22884
|
+
return value.toISOString();
|
|
22885
|
+
}
|
|
22886
|
+
}
|
|
22887
|
+
|
|
22888
|
+
class PgDateStringBuilder extends PgDateColumnBaseBuilder {
|
|
22889
|
+
static [entityKind] = "PgDateStringBuilder";
|
|
22890
|
+
constructor(name) {
|
|
22891
|
+
super(name, "string", "PgDateString");
|
|
22892
|
+
}
|
|
22893
|
+
build(table) {
|
|
22894
|
+
return new PgDateString(table, this.config);
|
|
22895
|
+
}
|
|
22896
|
+
}
|
|
22897
|
+
|
|
22898
|
+
class PgDateString extends PgColumn {
|
|
22899
|
+
static [entityKind] = "PgDateString";
|
|
22900
|
+
getSQLType() {
|
|
22901
|
+
return "date";
|
|
22902
|
+
}
|
|
22903
|
+
}
|
|
22904
|
+
function date2(a, b) {
|
|
22905
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
22906
|
+
if (config?.mode === "date") {
|
|
22907
|
+
return new PgDateBuilder(name);
|
|
22908
|
+
}
|
|
22909
|
+
return new PgDateStringBuilder(name);
|
|
22910
|
+
}
|
|
22911
|
+
|
|
22912
|
+
// node_modules/drizzle-orm/pg-core/columns/double-precision.js
|
|
22913
|
+
class PgDoublePrecisionBuilder extends PgColumnBuilder {
|
|
22914
|
+
static [entityKind] = "PgDoublePrecisionBuilder";
|
|
22915
|
+
constructor(name) {
|
|
22916
|
+
super(name, "number", "PgDoublePrecision");
|
|
22917
|
+
}
|
|
22918
|
+
build(table) {
|
|
22919
|
+
return new PgDoublePrecision(table, this.config);
|
|
22920
|
+
}
|
|
22921
|
+
}
|
|
22922
|
+
|
|
22923
|
+
class PgDoublePrecision extends PgColumn {
|
|
22924
|
+
static [entityKind] = "PgDoublePrecision";
|
|
22925
|
+
getSQLType() {
|
|
22926
|
+
return "double precision";
|
|
22927
|
+
}
|
|
22928
|
+
mapFromDriverValue(value) {
|
|
22929
|
+
if (typeof value === "string") {
|
|
22930
|
+
return Number.parseFloat(value);
|
|
22931
|
+
}
|
|
22932
|
+
return value;
|
|
22933
|
+
}
|
|
22934
|
+
}
|
|
22935
|
+
function doublePrecision(name) {
|
|
22936
|
+
return new PgDoublePrecisionBuilder(name ?? "");
|
|
22937
|
+
}
|
|
22938
|
+
|
|
22939
|
+
// node_modules/drizzle-orm/pg-core/columns/inet.js
|
|
22940
|
+
class PgInetBuilder extends PgColumnBuilder {
|
|
22941
|
+
static [entityKind] = "PgInetBuilder";
|
|
22942
|
+
constructor(name) {
|
|
22943
|
+
super(name, "string", "PgInet");
|
|
22944
|
+
}
|
|
22945
|
+
build(table) {
|
|
22946
|
+
return new PgInet(table, this.config);
|
|
22947
|
+
}
|
|
22948
|
+
}
|
|
22949
|
+
|
|
22950
|
+
class PgInet extends PgColumn {
|
|
22951
|
+
static [entityKind] = "PgInet";
|
|
22952
|
+
getSQLType() {
|
|
22953
|
+
return "inet";
|
|
22954
|
+
}
|
|
22955
|
+
}
|
|
22956
|
+
function inet(name) {
|
|
22957
|
+
return new PgInetBuilder(name ?? "");
|
|
22958
|
+
}
|
|
22959
|
+
|
|
22960
|
+
// node_modules/drizzle-orm/pg-core/columns/integer.js
|
|
22961
|
+
class PgIntegerBuilder extends PgIntColumnBaseBuilder {
|
|
22962
|
+
static [entityKind] = "PgIntegerBuilder";
|
|
22963
|
+
constructor(name) {
|
|
22964
|
+
super(name, "number", "PgInteger");
|
|
22965
|
+
}
|
|
22966
|
+
build(table) {
|
|
22967
|
+
return new PgInteger(table, this.config);
|
|
22968
|
+
}
|
|
22969
|
+
}
|
|
22970
|
+
|
|
22971
|
+
class PgInteger extends PgColumn {
|
|
22972
|
+
static [entityKind] = "PgInteger";
|
|
22973
|
+
getSQLType() {
|
|
22974
|
+
return "integer";
|
|
22975
|
+
}
|
|
22976
|
+
mapFromDriverValue(value) {
|
|
22977
|
+
if (typeof value === "string") {
|
|
22978
|
+
return Number.parseInt(value);
|
|
22979
|
+
}
|
|
22980
|
+
return value;
|
|
22981
|
+
}
|
|
22982
|
+
}
|
|
22983
|
+
function integer(name) {
|
|
22984
|
+
return new PgIntegerBuilder(name ?? "");
|
|
22985
|
+
}
|
|
22986
|
+
|
|
22987
|
+
// node_modules/drizzle-orm/pg-core/columns/interval.js
|
|
22988
|
+
class PgIntervalBuilder extends PgColumnBuilder {
|
|
22989
|
+
static [entityKind] = "PgIntervalBuilder";
|
|
22990
|
+
constructor(name, intervalConfig) {
|
|
22991
|
+
super(name, "string", "PgInterval");
|
|
22992
|
+
this.config.intervalConfig = intervalConfig;
|
|
22993
|
+
}
|
|
22994
|
+
build(table) {
|
|
22995
|
+
return new PgInterval(table, this.config);
|
|
22996
|
+
}
|
|
22997
|
+
}
|
|
22998
|
+
|
|
22999
|
+
class PgInterval extends PgColumn {
|
|
23000
|
+
static [entityKind] = "PgInterval";
|
|
23001
|
+
fields = this.config.intervalConfig.fields;
|
|
23002
|
+
precision = this.config.intervalConfig.precision;
|
|
23003
|
+
getSQLType() {
|
|
23004
|
+
const fields = this.fields ? ` ${this.fields}` : "";
|
|
23005
|
+
const precision = this.precision ? `(${this.precision})` : "";
|
|
23006
|
+
return `interval${fields}${precision}`;
|
|
23007
|
+
}
|
|
23008
|
+
}
|
|
23009
|
+
function interval(a, b = {}) {
|
|
23010
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23011
|
+
return new PgIntervalBuilder(name, config);
|
|
23012
|
+
}
|
|
23013
|
+
|
|
23014
|
+
// node_modules/drizzle-orm/pg-core/columns/json.js
|
|
23015
|
+
class PgJsonBuilder extends PgColumnBuilder {
|
|
23016
|
+
static [entityKind] = "PgJsonBuilder";
|
|
23017
|
+
constructor(name) {
|
|
23018
|
+
super(name, "json", "PgJson");
|
|
23019
|
+
}
|
|
23020
|
+
build(table) {
|
|
23021
|
+
return new PgJson(table, this.config);
|
|
23022
|
+
}
|
|
23023
|
+
}
|
|
23024
|
+
|
|
23025
|
+
class PgJson extends PgColumn {
|
|
23026
|
+
static [entityKind] = "PgJson";
|
|
23027
|
+
constructor(table, config) {
|
|
23028
|
+
super(table, config);
|
|
23029
|
+
}
|
|
23030
|
+
getSQLType() {
|
|
23031
|
+
return "json";
|
|
23032
|
+
}
|
|
23033
|
+
mapToDriverValue(value) {
|
|
23034
|
+
return JSON.stringify(value);
|
|
23035
|
+
}
|
|
23036
|
+
mapFromDriverValue(value) {
|
|
23037
|
+
if (typeof value === "string") {
|
|
23038
|
+
try {
|
|
23039
|
+
return JSON.parse(value);
|
|
23040
|
+
} catch {
|
|
23041
|
+
return value;
|
|
23042
|
+
}
|
|
23043
|
+
}
|
|
23044
|
+
return value;
|
|
23045
|
+
}
|
|
23046
|
+
}
|
|
23047
|
+
function json(name) {
|
|
23048
|
+
return new PgJsonBuilder(name ?? "");
|
|
23049
|
+
}
|
|
23050
|
+
|
|
23051
|
+
// node_modules/drizzle-orm/pg-core/columns/jsonb.js
|
|
23052
|
+
class PgJsonbBuilder extends PgColumnBuilder {
|
|
23053
|
+
static [entityKind] = "PgJsonbBuilder";
|
|
23054
|
+
constructor(name) {
|
|
23055
|
+
super(name, "json", "PgJsonb");
|
|
23056
|
+
}
|
|
23057
|
+
build(table) {
|
|
23058
|
+
return new PgJsonb(table, this.config);
|
|
23059
|
+
}
|
|
23060
|
+
}
|
|
23061
|
+
|
|
23062
|
+
class PgJsonb extends PgColumn {
|
|
23063
|
+
static [entityKind] = "PgJsonb";
|
|
23064
|
+
constructor(table, config) {
|
|
23065
|
+
super(table, config);
|
|
23066
|
+
}
|
|
23067
|
+
getSQLType() {
|
|
23068
|
+
return "jsonb";
|
|
23069
|
+
}
|
|
23070
|
+
mapToDriverValue(value) {
|
|
23071
|
+
return JSON.stringify(value);
|
|
23072
|
+
}
|
|
23073
|
+
mapFromDriverValue(value) {
|
|
23074
|
+
if (typeof value === "string") {
|
|
23075
|
+
try {
|
|
23076
|
+
return JSON.parse(value);
|
|
23077
|
+
} catch {
|
|
23078
|
+
return value;
|
|
23079
|
+
}
|
|
23080
|
+
}
|
|
23081
|
+
return value;
|
|
23082
|
+
}
|
|
23083
|
+
}
|
|
23084
|
+
function jsonb(name) {
|
|
23085
|
+
return new PgJsonbBuilder(name ?? "");
|
|
23086
|
+
}
|
|
23087
|
+
|
|
23088
|
+
// node_modules/drizzle-orm/pg-core/columns/line.js
|
|
23089
|
+
class PgLineBuilder extends PgColumnBuilder {
|
|
23090
|
+
static [entityKind] = "PgLineBuilder";
|
|
23091
|
+
constructor(name) {
|
|
23092
|
+
super(name, "array", "PgLine");
|
|
23093
|
+
}
|
|
23094
|
+
build(table) {
|
|
23095
|
+
return new PgLineTuple(table, this.config);
|
|
23096
|
+
}
|
|
23097
|
+
}
|
|
23098
|
+
|
|
23099
|
+
class PgLineTuple extends PgColumn {
|
|
23100
|
+
static [entityKind] = "PgLine";
|
|
23101
|
+
getSQLType() {
|
|
23102
|
+
return "line";
|
|
23103
|
+
}
|
|
23104
|
+
mapFromDriverValue(value) {
|
|
23105
|
+
const [a, b, c] = value.slice(1, -1).split(",");
|
|
23106
|
+
return [Number.parseFloat(a), Number.parseFloat(b), Number.parseFloat(c)];
|
|
23107
|
+
}
|
|
23108
|
+
mapToDriverValue(value) {
|
|
23109
|
+
return `{${value[0]},${value[1]},${value[2]}}`;
|
|
23110
|
+
}
|
|
23111
|
+
}
|
|
23112
|
+
|
|
23113
|
+
class PgLineABCBuilder extends PgColumnBuilder {
|
|
23114
|
+
static [entityKind] = "PgLineABCBuilder";
|
|
23115
|
+
constructor(name) {
|
|
23116
|
+
super(name, "json", "PgLineABC");
|
|
23117
|
+
}
|
|
23118
|
+
build(table) {
|
|
23119
|
+
return new PgLineABC(table, this.config);
|
|
23120
|
+
}
|
|
23121
|
+
}
|
|
23122
|
+
|
|
23123
|
+
class PgLineABC extends PgColumn {
|
|
23124
|
+
static [entityKind] = "PgLineABC";
|
|
23125
|
+
getSQLType() {
|
|
23126
|
+
return "line";
|
|
23127
|
+
}
|
|
23128
|
+
mapFromDriverValue(value) {
|
|
23129
|
+
const [a, b, c] = value.slice(1, -1).split(",");
|
|
23130
|
+
return { a: Number.parseFloat(a), b: Number.parseFloat(b), c: Number.parseFloat(c) };
|
|
23131
|
+
}
|
|
23132
|
+
mapToDriverValue(value) {
|
|
23133
|
+
return `{${value.a},${value.b},${value.c}}`;
|
|
23134
|
+
}
|
|
23135
|
+
}
|
|
23136
|
+
function line(a, b) {
|
|
23137
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23138
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
23139
|
+
return new PgLineBuilder(name);
|
|
23140
|
+
}
|
|
23141
|
+
return new PgLineABCBuilder(name);
|
|
23142
|
+
}
|
|
23143
|
+
|
|
23144
|
+
// node_modules/drizzle-orm/pg-core/columns/macaddr.js
|
|
23145
|
+
class PgMacaddrBuilder extends PgColumnBuilder {
|
|
23146
|
+
static [entityKind] = "PgMacaddrBuilder";
|
|
23147
|
+
constructor(name) {
|
|
23148
|
+
super(name, "string", "PgMacaddr");
|
|
23149
|
+
}
|
|
23150
|
+
build(table) {
|
|
23151
|
+
return new PgMacaddr(table, this.config);
|
|
23152
|
+
}
|
|
23153
|
+
}
|
|
23154
|
+
|
|
23155
|
+
class PgMacaddr extends PgColumn {
|
|
23156
|
+
static [entityKind] = "PgMacaddr";
|
|
23157
|
+
getSQLType() {
|
|
23158
|
+
return "macaddr";
|
|
23159
|
+
}
|
|
23160
|
+
}
|
|
23161
|
+
function macaddr(name) {
|
|
23162
|
+
return new PgMacaddrBuilder(name ?? "");
|
|
23163
|
+
}
|
|
23164
|
+
|
|
23165
|
+
// node_modules/drizzle-orm/pg-core/columns/macaddr8.js
|
|
23166
|
+
class PgMacaddr8Builder extends PgColumnBuilder {
|
|
23167
|
+
static [entityKind] = "PgMacaddr8Builder";
|
|
23168
|
+
constructor(name) {
|
|
23169
|
+
super(name, "string", "PgMacaddr8");
|
|
23170
|
+
}
|
|
23171
|
+
build(table) {
|
|
23172
|
+
return new PgMacaddr8(table, this.config);
|
|
23173
|
+
}
|
|
23174
|
+
}
|
|
23175
|
+
|
|
23176
|
+
class PgMacaddr8 extends PgColumn {
|
|
23177
|
+
static [entityKind] = "PgMacaddr8";
|
|
23178
|
+
getSQLType() {
|
|
23179
|
+
return "macaddr8";
|
|
23180
|
+
}
|
|
23181
|
+
}
|
|
23182
|
+
function macaddr8(name) {
|
|
23183
|
+
return new PgMacaddr8Builder(name ?? "");
|
|
23184
|
+
}
|
|
23185
|
+
|
|
23186
|
+
// node_modules/drizzle-orm/pg-core/columns/numeric.js
|
|
23187
|
+
class PgNumericBuilder extends PgColumnBuilder {
|
|
23188
|
+
static [entityKind] = "PgNumericBuilder";
|
|
23189
|
+
constructor(name, precision, scale) {
|
|
23190
|
+
super(name, "string", "PgNumeric");
|
|
23191
|
+
this.config.precision = precision;
|
|
23192
|
+
this.config.scale = scale;
|
|
23193
|
+
}
|
|
23194
|
+
build(table) {
|
|
23195
|
+
return new PgNumeric(table, this.config);
|
|
23196
|
+
}
|
|
23197
|
+
}
|
|
23198
|
+
|
|
23199
|
+
class PgNumeric extends PgColumn {
|
|
23200
|
+
static [entityKind] = "PgNumeric";
|
|
23201
|
+
precision;
|
|
23202
|
+
scale;
|
|
23203
|
+
constructor(table, config) {
|
|
23204
|
+
super(table, config);
|
|
23205
|
+
this.precision = config.precision;
|
|
23206
|
+
this.scale = config.scale;
|
|
23207
|
+
}
|
|
23208
|
+
mapFromDriverValue(value) {
|
|
23209
|
+
if (typeof value === "string")
|
|
23210
|
+
return value;
|
|
23211
|
+
return String(value);
|
|
23212
|
+
}
|
|
23213
|
+
getSQLType() {
|
|
23214
|
+
if (this.precision !== undefined && this.scale !== undefined) {
|
|
23215
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
23216
|
+
} else if (this.precision === undefined) {
|
|
23217
|
+
return "numeric";
|
|
23218
|
+
} else {
|
|
23219
|
+
return `numeric(${this.precision})`;
|
|
23220
|
+
}
|
|
23221
|
+
}
|
|
23222
|
+
}
|
|
23223
|
+
|
|
23224
|
+
class PgNumericNumberBuilder extends PgColumnBuilder {
|
|
23225
|
+
static [entityKind] = "PgNumericNumberBuilder";
|
|
23226
|
+
constructor(name, precision, scale) {
|
|
23227
|
+
super(name, "number", "PgNumericNumber");
|
|
23228
|
+
this.config.precision = precision;
|
|
23229
|
+
this.config.scale = scale;
|
|
23230
|
+
}
|
|
23231
|
+
build(table) {
|
|
23232
|
+
return new PgNumericNumber(table, this.config);
|
|
23233
|
+
}
|
|
23234
|
+
}
|
|
23235
|
+
|
|
23236
|
+
class PgNumericNumber extends PgColumn {
|
|
23237
|
+
static [entityKind] = "PgNumericNumber";
|
|
23238
|
+
precision;
|
|
23239
|
+
scale;
|
|
23240
|
+
constructor(table, config) {
|
|
23241
|
+
super(table, config);
|
|
23242
|
+
this.precision = config.precision;
|
|
23243
|
+
this.scale = config.scale;
|
|
23244
|
+
}
|
|
23245
|
+
mapFromDriverValue(value) {
|
|
23246
|
+
if (typeof value === "number")
|
|
23247
|
+
return value;
|
|
23248
|
+
return Number(value);
|
|
23249
|
+
}
|
|
23250
|
+
mapToDriverValue = String;
|
|
23251
|
+
getSQLType() {
|
|
23252
|
+
if (this.precision !== undefined && this.scale !== undefined) {
|
|
23253
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
23254
|
+
} else if (this.precision === undefined) {
|
|
23255
|
+
return "numeric";
|
|
23256
|
+
} else {
|
|
23257
|
+
return `numeric(${this.precision})`;
|
|
23258
|
+
}
|
|
23259
|
+
}
|
|
23260
|
+
}
|
|
23261
|
+
|
|
23262
|
+
class PgNumericBigIntBuilder extends PgColumnBuilder {
|
|
23263
|
+
static [entityKind] = "PgNumericBigIntBuilder";
|
|
23264
|
+
constructor(name, precision, scale) {
|
|
23265
|
+
super(name, "bigint", "PgNumericBigInt");
|
|
23266
|
+
this.config.precision = precision;
|
|
23267
|
+
this.config.scale = scale;
|
|
23268
|
+
}
|
|
23269
|
+
build(table) {
|
|
23270
|
+
return new PgNumericBigInt(table, this.config);
|
|
23271
|
+
}
|
|
23272
|
+
}
|
|
23273
|
+
|
|
23274
|
+
class PgNumericBigInt extends PgColumn {
|
|
23275
|
+
static [entityKind] = "PgNumericBigInt";
|
|
23276
|
+
precision;
|
|
23277
|
+
scale;
|
|
23278
|
+
constructor(table, config) {
|
|
23279
|
+
super(table, config);
|
|
23280
|
+
this.precision = config.precision;
|
|
23281
|
+
this.scale = config.scale;
|
|
23282
|
+
}
|
|
23283
|
+
mapFromDriverValue = BigInt;
|
|
23284
|
+
mapToDriverValue = String;
|
|
23285
|
+
getSQLType() {
|
|
23286
|
+
if (this.precision !== undefined && this.scale !== undefined) {
|
|
23287
|
+
return `numeric(${this.precision}, ${this.scale})`;
|
|
23288
|
+
} else if (this.precision === undefined) {
|
|
23289
|
+
return "numeric";
|
|
23290
|
+
} else {
|
|
23291
|
+
return `numeric(${this.precision})`;
|
|
23292
|
+
}
|
|
23293
|
+
}
|
|
23294
|
+
}
|
|
23295
|
+
function numeric(a, b) {
|
|
23296
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23297
|
+
const mode = config?.mode;
|
|
23298
|
+
return mode === "number" ? new PgNumericNumberBuilder(name, config?.precision, config?.scale) : mode === "bigint" ? new PgNumericBigIntBuilder(name, config?.precision, config?.scale) : new PgNumericBuilder(name, config?.precision, config?.scale);
|
|
23299
|
+
}
|
|
23300
|
+
|
|
23301
|
+
// node_modules/drizzle-orm/pg-core/columns/point.js
|
|
23302
|
+
class PgPointTupleBuilder extends PgColumnBuilder {
|
|
23303
|
+
static [entityKind] = "PgPointTupleBuilder";
|
|
23304
|
+
constructor(name) {
|
|
23305
|
+
super(name, "array", "PgPointTuple");
|
|
23306
|
+
}
|
|
23307
|
+
build(table) {
|
|
23308
|
+
return new PgPointTuple(table, this.config);
|
|
23309
|
+
}
|
|
23310
|
+
}
|
|
23311
|
+
|
|
23312
|
+
class PgPointTuple extends PgColumn {
|
|
23313
|
+
static [entityKind] = "PgPointTuple";
|
|
23314
|
+
getSQLType() {
|
|
23315
|
+
return "point";
|
|
23316
|
+
}
|
|
23317
|
+
mapFromDriverValue(value) {
|
|
23318
|
+
if (typeof value === "string") {
|
|
23319
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
23320
|
+
return [Number.parseFloat(x), Number.parseFloat(y)];
|
|
23321
|
+
}
|
|
23322
|
+
return [value.x, value.y];
|
|
23323
|
+
}
|
|
23324
|
+
mapToDriverValue(value) {
|
|
23325
|
+
return `(${value[0]},${value[1]})`;
|
|
23326
|
+
}
|
|
23327
|
+
}
|
|
23328
|
+
|
|
23329
|
+
class PgPointObjectBuilder extends PgColumnBuilder {
|
|
23330
|
+
static [entityKind] = "PgPointObjectBuilder";
|
|
23331
|
+
constructor(name) {
|
|
23332
|
+
super(name, "json", "PgPointObject");
|
|
23333
|
+
}
|
|
23334
|
+
build(table) {
|
|
23335
|
+
return new PgPointObject(table, this.config);
|
|
23336
|
+
}
|
|
23337
|
+
}
|
|
23338
|
+
|
|
23339
|
+
class PgPointObject extends PgColumn {
|
|
23340
|
+
static [entityKind] = "PgPointObject";
|
|
23341
|
+
getSQLType() {
|
|
23342
|
+
return "point";
|
|
23343
|
+
}
|
|
23344
|
+
mapFromDriverValue(value) {
|
|
23345
|
+
if (typeof value === "string") {
|
|
23346
|
+
const [x, y] = value.slice(1, -1).split(",");
|
|
23347
|
+
return { x: Number.parseFloat(x), y: Number.parseFloat(y) };
|
|
23348
|
+
}
|
|
23349
|
+
return value;
|
|
23350
|
+
}
|
|
23351
|
+
mapToDriverValue(value) {
|
|
23352
|
+
return `(${value.x},${value.y})`;
|
|
23353
|
+
}
|
|
23354
|
+
}
|
|
23355
|
+
function point(a, b) {
|
|
23356
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23357
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
23358
|
+
return new PgPointTupleBuilder(name);
|
|
23359
|
+
}
|
|
23360
|
+
return new PgPointObjectBuilder(name);
|
|
23361
|
+
}
|
|
23362
|
+
|
|
23363
|
+
// node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
|
|
23364
|
+
function hexToBytes(hex) {
|
|
23365
|
+
const bytes = [];
|
|
23366
|
+
for (let c = 0;c < hex.length; c += 2) {
|
|
23367
|
+
bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
|
|
23368
|
+
}
|
|
23369
|
+
return new Uint8Array(bytes);
|
|
23370
|
+
}
|
|
23371
|
+
function bytesToFloat64(bytes, offset) {
|
|
23372
|
+
const buffer = new ArrayBuffer(8);
|
|
23373
|
+
const view = new DataView(buffer);
|
|
23374
|
+
for (let i = 0;i < 8; i++) {
|
|
23375
|
+
view.setUint8(i, bytes[offset + i]);
|
|
23376
|
+
}
|
|
23377
|
+
return view.getFloat64(0, true);
|
|
23378
|
+
}
|
|
23379
|
+
function parseEWKB(hex) {
|
|
23380
|
+
const bytes = hexToBytes(hex);
|
|
23381
|
+
let offset = 0;
|
|
23382
|
+
const byteOrder = bytes[offset];
|
|
23383
|
+
offset += 1;
|
|
23384
|
+
const view = new DataView(bytes.buffer);
|
|
23385
|
+
const geomType = view.getUint32(offset, byteOrder === 1);
|
|
23386
|
+
offset += 4;
|
|
23387
|
+
let _srid;
|
|
23388
|
+
if (geomType & 536870912) {
|
|
23389
|
+
_srid = view.getUint32(offset, byteOrder === 1);
|
|
23390
|
+
offset += 4;
|
|
23391
|
+
}
|
|
23392
|
+
if ((geomType & 65535) === 1) {
|
|
23393
|
+
const x = bytesToFloat64(bytes, offset);
|
|
23394
|
+
offset += 8;
|
|
23395
|
+
const y = bytesToFloat64(bytes, offset);
|
|
23396
|
+
offset += 8;
|
|
23397
|
+
return [x, y];
|
|
23398
|
+
}
|
|
23399
|
+
throw new Error("Unsupported geometry type");
|
|
23400
|
+
}
|
|
23401
|
+
|
|
23402
|
+
// node_modules/drizzle-orm/pg-core/columns/postgis_extension/geometry.js
|
|
23403
|
+
class PgGeometryBuilder extends PgColumnBuilder {
|
|
23404
|
+
static [entityKind] = "PgGeometryBuilder";
|
|
23405
|
+
constructor(name) {
|
|
23406
|
+
super(name, "array", "PgGeometry");
|
|
23407
|
+
}
|
|
23408
|
+
build(table) {
|
|
23409
|
+
return new PgGeometry(table, this.config);
|
|
23410
|
+
}
|
|
23411
|
+
}
|
|
23412
|
+
|
|
23413
|
+
class PgGeometry extends PgColumn {
|
|
23414
|
+
static [entityKind] = "PgGeometry";
|
|
23415
|
+
getSQLType() {
|
|
23416
|
+
return "geometry(point)";
|
|
23417
|
+
}
|
|
23418
|
+
mapFromDriverValue(value) {
|
|
23419
|
+
return parseEWKB(value);
|
|
23420
|
+
}
|
|
23421
|
+
mapToDriverValue(value) {
|
|
23422
|
+
return `point(${value[0]} ${value[1]})`;
|
|
23423
|
+
}
|
|
23424
|
+
}
|
|
23425
|
+
|
|
23426
|
+
class PgGeometryObjectBuilder extends PgColumnBuilder {
|
|
23427
|
+
static [entityKind] = "PgGeometryObjectBuilder";
|
|
23428
|
+
constructor(name) {
|
|
23429
|
+
super(name, "json", "PgGeometryObject");
|
|
23430
|
+
}
|
|
23431
|
+
build(table) {
|
|
23432
|
+
return new PgGeometryObject(table, this.config);
|
|
23433
|
+
}
|
|
23434
|
+
}
|
|
23435
|
+
|
|
23436
|
+
class PgGeometryObject extends PgColumn {
|
|
23437
|
+
static [entityKind] = "PgGeometryObject";
|
|
23438
|
+
getSQLType() {
|
|
23439
|
+
return "geometry(point)";
|
|
23440
|
+
}
|
|
23441
|
+
mapFromDriverValue(value) {
|
|
23442
|
+
const parsed = parseEWKB(value);
|
|
23443
|
+
return { x: parsed[0], y: parsed[1] };
|
|
23444
|
+
}
|
|
23445
|
+
mapToDriverValue(value) {
|
|
23446
|
+
return `point(${value.x} ${value.y})`;
|
|
23447
|
+
}
|
|
23448
|
+
}
|
|
23449
|
+
function geometry(a, b) {
|
|
23450
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23451
|
+
if (!config?.mode || config.mode === "tuple") {
|
|
23452
|
+
return new PgGeometryBuilder(name);
|
|
23453
|
+
}
|
|
23454
|
+
return new PgGeometryObjectBuilder(name);
|
|
23455
|
+
}
|
|
23456
|
+
|
|
23457
|
+
// node_modules/drizzle-orm/pg-core/columns/real.js
|
|
23458
|
+
class PgRealBuilder extends PgColumnBuilder {
|
|
23459
|
+
static [entityKind] = "PgRealBuilder";
|
|
23460
|
+
constructor(name, length) {
|
|
23461
|
+
super(name, "number", "PgReal");
|
|
23462
|
+
this.config.length = length;
|
|
23463
|
+
}
|
|
23464
|
+
build(table) {
|
|
23465
|
+
return new PgReal(table, this.config);
|
|
23466
|
+
}
|
|
23467
|
+
}
|
|
23468
|
+
|
|
23469
|
+
class PgReal extends PgColumn {
|
|
23470
|
+
static [entityKind] = "PgReal";
|
|
23471
|
+
constructor(table, config) {
|
|
23472
|
+
super(table, config);
|
|
23473
|
+
}
|
|
23474
|
+
getSQLType() {
|
|
23475
|
+
return "real";
|
|
23476
|
+
}
|
|
23477
|
+
mapFromDriverValue = (value) => {
|
|
23478
|
+
if (typeof value === "string") {
|
|
23479
|
+
return Number.parseFloat(value);
|
|
23480
|
+
}
|
|
23481
|
+
return value;
|
|
23482
|
+
};
|
|
23483
|
+
}
|
|
23484
|
+
function real(name) {
|
|
23485
|
+
return new PgRealBuilder(name ?? "");
|
|
23486
|
+
}
|
|
23487
|
+
|
|
23488
|
+
// node_modules/drizzle-orm/pg-core/columns/serial.js
|
|
23489
|
+
class PgSerialBuilder extends PgColumnBuilder {
|
|
23490
|
+
static [entityKind] = "PgSerialBuilder";
|
|
23491
|
+
constructor(name) {
|
|
23492
|
+
super(name, "number", "PgSerial");
|
|
23493
|
+
this.config.hasDefault = true;
|
|
23494
|
+
this.config.notNull = true;
|
|
23495
|
+
}
|
|
23496
|
+
build(table) {
|
|
23497
|
+
return new PgSerial(table, this.config);
|
|
23498
|
+
}
|
|
23499
|
+
}
|
|
23500
|
+
|
|
23501
|
+
class PgSerial extends PgColumn {
|
|
23502
|
+
static [entityKind] = "PgSerial";
|
|
23503
|
+
getSQLType() {
|
|
23504
|
+
return "serial";
|
|
23505
|
+
}
|
|
23506
|
+
}
|
|
23507
|
+
function serial(name) {
|
|
23508
|
+
return new PgSerialBuilder(name ?? "");
|
|
23509
|
+
}
|
|
23510
|
+
|
|
23511
|
+
// node_modules/drizzle-orm/pg-core/columns/smallint.js
|
|
23512
|
+
class PgSmallIntBuilder extends PgIntColumnBaseBuilder {
|
|
23513
|
+
static [entityKind] = "PgSmallIntBuilder";
|
|
23514
|
+
constructor(name) {
|
|
23515
|
+
super(name, "number", "PgSmallInt");
|
|
23516
|
+
}
|
|
23517
|
+
build(table) {
|
|
23518
|
+
return new PgSmallInt(table, this.config);
|
|
23519
|
+
}
|
|
23520
|
+
}
|
|
23521
|
+
|
|
23522
|
+
class PgSmallInt extends PgColumn {
|
|
23523
|
+
static [entityKind] = "PgSmallInt";
|
|
23524
|
+
getSQLType() {
|
|
23525
|
+
return "smallint";
|
|
23526
|
+
}
|
|
23527
|
+
mapFromDriverValue = (value) => {
|
|
23528
|
+
if (typeof value === "string") {
|
|
23529
|
+
return Number(value);
|
|
23530
|
+
}
|
|
23531
|
+
return value;
|
|
23532
|
+
};
|
|
23533
|
+
}
|
|
23534
|
+
function smallint(name) {
|
|
23535
|
+
return new PgSmallIntBuilder(name ?? "");
|
|
23536
|
+
}
|
|
23537
|
+
|
|
23538
|
+
// node_modules/drizzle-orm/pg-core/columns/smallserial.js
|
|
23539
|
+
class PgSmallSerialBuilder extends PgColumnBuilder {
|
|
23540
|
+
static [entityKind] = "PgSmallSerialBuilder";
|
|
23541
|
+
constructor(name) {
|
|
23542
|
+
super(name, "number", "PgSmallSerial");
|
|
23543
|
+
this.config.hasDefault = true;
|
|
23544
|
+
this.config.notNull = true;
|
|
23545
|
+
}
|
|
23546
|
+
build(table) {
|
|
23547
|
+
return new PgSmallSerial(table, this.config);
|
|
23548
|
+
}
|
|
23549
|
+
}
|
|
23550
|
+
|
|
23551
|
+
class PgSmallSerial extends PgColumn {
|
|
23552
|
+
static [entityKind] = "PgSmallSerial";
|
|
23553
|
+
getSQLType() {
|
|
23554
|
+
return "smallserial";
|
|
23555
|
+
}
|
|
23556
|
+
}
|
|
23557
|
+
function smallserial(name) {
|
|
23558
|
+
return new PgSmallSerialBuilder(name ?? "");
|
|
23559
|
+
}
|
|
23560
|
+
|
|
23561
|
+
// node_modules/drizzle-orm/pg-core/columns/text.js
|
|
23562
|
+
class PgTextBuilder extends PgColumnBuilder {
|
|
23563
|
+
static [entityKind] = "PgTextBuilder";
|
|
23564
|
+
constructor(name, config) {
|
|
23565
|
+
super(name, "string", "PgText");
|
|
23566
|
+
this.config.enumValues = config.enum;
|
|
23567
|
+
}
|
|
23568
|
+
build(table) {
|
|
23569
|
+
return new PgText(table, this.config);
|
|
23570
|
+
}
|
|
23571
|
+
}
|
|
23572
|
+
|
|
23573
|
+
class PgText extends PgColumn {
|
|
23574
|
+
static [entityKind] = "PgText";
|
|
23575
|
+
enumValues = this.config.enumValues;
|
|
23576
|
+
getSQLType() {
|
|
23577
|
+
return "text";
|
|
23578
|
+
}
|
|
23579
|
+
}
|
|
23580
|
+
function text(a, b = {}) {
|
|
23581
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23582
|
+
return new PgTextBuilder(name, config);
|
|
23583
|
+
}
|
|
23584
|
+
|
|
23585
|
+
// node_modules/drizzle-orm/pg-core/columns/time.js
|
|
23586
|
+
class PgTimeBuilder extends PgDateColumnBaseBuilder {
|
|
23587
|
+
constructor(name, withTimezone, precision) {
|
|
23588
|
+
super(name, "string", "PgTime");
|
|
23589
|
+
this.withTimezone = withTimezone;
|
|
23590
|
+
this.precision = precision;
|
|
23591
|
+
this.config.withTimezone = withTimezone;
|
|
23592
|
+
this.config.precision = precision;
|
|
23593
|
+
}
|
|
23594
|
+
static [entityKind] = "PgTimeBuilder";
|
|
23595
|
+
build(table) {
|
|
23596
|
+
return new PgTime(table, this.config);
|
|
23597
|
+
}
|
|
23598
|
+
}
|
|
23599
|
+
|
|
23600
|
+
class PgTime extends PgColumn {
|
|
23601
|
+
static [entityKind] = "PgTime";
|
|
23602
|
+
withTimezone;
|
|
23603
|
+
precision;
|
|
23604
|
+
constructor(table, config) {
|
|
23605
|
+
super(table, config);
|
|
23606
|
+
this.withTimezone = config.withTimezone;
|
|
23607
|
+
this.precision = config.precision;
|
|
23608
|
+
}
|
|
23609
|
+
getSQLType() {
|
|
23610
|
+
const precision = this.precision === undefined ? "" : `(${this.precision})`;
|
|
23611
|
+
return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
23612
|
+
}
|
|
23613
|
+
}
|
|
23614
|
+
function time(a, b = {}) {
|
|
23615
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23616
|
+
return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
|
|
23617
|
+
}
|
|
21236
23618
|
|
|
23619
|
+
// node_modules/drizzle-orm/pg-core/columns/timestamp.js
|
|
23620
|
+
class PgTimestampBuilder extends PgDateColumnBaseBuilder {
|
|
23621
|
+
static [entityKind] = "PgTimestampBuilder";
|
|
23622
|
+
constructor(name, withTimezone, precision) {
|
|
23623
|
+
super(name, "date", "PgTimestamp");
|
|
23624
|
+
this.config.withTimezone = withTimezone;
|
|
23625
|
+
this.config.precision = precision;
|
|
23626
|
+
}
|
|
23627
|
+
build(table) {
|
|
23628
|
+
return new PgTimestamp(table, this.config);
|
|
23629
|
+
}
|
|
23630
|
+
}
|
|
23631
|
+
|
|
23632
|
+
class PgTimestamp extends PgColumn {
|
|
23633
|
+
static [entityKind] = "PgTimestamp";
|
|
23634
|
+
withTimezone;
|
|
23635
|
+
precision;
|
|
23636
|
+
constructor(table, config) {
|
|
23637
|
+
super(table, config);
|
|
23638
|
+
this.withTimezone = config.withTimezone;
|
|
23639
|
+
this.precision = config.precision;
|
|
23640
|
+
}
|
|
23641
|
+
getSQLType() {
|
|
23642
|
+
const precision = this.precision === undefined ? "" : ` (${this.precision})`;
|
|
23643
|
+
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
23644
|
+
}
|
|
23645
|
+
mapFromDriverValue = (value) => {
|
|
23646
|
+
return new Date(this.withTimezone ? value : value + "+0000");
|
|
23647
|
+
};
|
|
23648
|
+
mapToDriverValue = (value) => {
|
|
23649
|
+
return value.toISOString();
|
|
23650
|
+
};
|
|
23651
|
+
}
|
|
23652
|
+
|
|
23653
|
+
class PgTimestampStringBuilder extends PgDateColumnBaseBuilder {
|
|
23654
|
+
static [entityKind] = "PgTimestampStringBuilder";
|
|
23655
|
+
constructor(name, withTimezone, precision) {
|
|
23656
|
+
super(name, "string", "PgTimestampString");
|
|
23657
|
+
this.config.withTimezone = withTimezone;
|
|
23658
|
+
this.config.precision = precision;
|
|
23659
|
+
}
|
|
23660
|
+
build(table) {
|
|
23661
|
+
return new PgTimestampString(table, this.config);
|
|
23662
|
+
}
|
|
23663
|
+
}
|
|
23664
|
+
|
|
23665
|
+
class PgTimestampString extends PgColumn {
|
|
23666
|
+
static [entityKind] = "PgTimestampString";
|
|
23667
|
+
withTimezone;
|
|
23668
|
+
precision;
|
|
23669
|
+
constructor(table, config) {
|
|
23670
|
+
super(table, config);
|
|
23671
|
+
this.withTimezone = config.withTimezone;
|
|
23672
|
+
this.precision = config.precision;
|
|
23673
|
+
}
|
|
23674
|
+
getSQLType() {
|
|
23675
|
+
const precision = this.precision === undefined ? "" : `(${this.precision})`;
|
|
23676
|
+
return `timestamp${precision}${this.withTimezone ? " with time zone" : ""}`;
|
|
23677
|
+
}
|
|
23678
|
+
}
|
|
23679
|
+
function timestamp(a, b = {}) {
|
|
23680
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23681
|
+
if (config?.mode === "string") {
|
|
23682
|
+
return new PgTimestampStringBuilder(name, config.withTimezone ?? false, config.precision);
|
|
23683
|
+
}
|
|
23684
|
+
return new PgTimestampBuilder(name, config?.withTimezone ?? false, config?.precision);
|
|
23685
|
+
}
|
|
23686
|
+
|
|
23687
|
+
// node_modules/drizzle-orm/pg-core/columns/uuid.js
|
|
23688
|
+
class PgUUIDBuilder extends PgColumnBuilder {
|
|
23689
|
+
static [entityKind] = "PgUUIDBuilder";
|
|
23690
|
+
constructor(name) {
|
|
23691
|
+
super(name, "string", "PgUUID");
|
|
23692
|
+
}
|
|
23693
|
+
defaultRandom() {
|
|
23694
|
+
return this.default(sql`gen_random_uuid()`);
|
|
23695
|
+
}
|
|
23696
|
+
build(table) {
|
|
23697
|
+
return new PgUUID(table, this.config);
|
|
23698
|
+
}
|
|
23699
|
+
}
|
|
23700
|
+
|
|
23701
|
+
class PgUUID extends PgColumn {
|
|
23702
|
+
static [entityKind] = "PgUUID";
|
|
23703
|
+
getSQLType() {
|
|
23704
|
+
return "uuid";
|
|
23705
|
+
}
|
|
23706
|
+
}
|
|
23707
|
+
function uuid(name) {
|
|
23708
|
+
return new PgUUIDBuilder(name ?? "");
|
|
23709
|
+
}
|
|
23710
|
+
|
|
23711
|
+
// node_modules/drizzle-orm/pg-core/columns/varchar.js
|
|
23712
|
+
class PgVarcharBuilder extends PgColumnBuilder {
|
|
23713
|
+
static [entityKind] = "PgVarcharBuilder";
|
|
23714
|
+
constructor(name, config) {
|
|
23715
|
+
super(name, "string", "PgVarchar");
|
|
23716
|
+
this.config.length = config.length;
|
|
23717
|
+
this.config.enumValues = config.enum;
|
|
23718
|
+
}
|
|
23719
|
+
build(table) {
|
|
23720
|
+
return new PgVarchar(table, this.config);
|
|
23721
|
+
}
|
|
23722
|
+
}
|
|
23723
|
+
|
|
23724
|
+
class PgVarchar extends PgColumn {
|
|
23725
|
+
static [entityKind] = "PgVarchar";
|
|
23726
|
+
length = this.config.length;
|
|
23727
|
+
enumValues = this.config.enumValues;
|
|
23728
|
+
getSQLType() {
|
|
23729
|
+
return this.length === undefined ? `varchar` : `varchar(${this.length})`;
|
|
23730
|
+
}
|
|
23731
|
+
}
|
|
23732
|
+
function varchar(a, b = {}) {
|
|
23733
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23734
|
+
return new PgVarcharBuilder(name, config);
|
|
23735
|
+
}
|
|
23736
|
+
|
|
23737
|
+
// node_modules/drizzle-orm/pg-core/columns/vector_extension/bit.js
|
|
23738
|
+
class PgBinaryVectorBuilder extends PgColumnBuilder {
|
|
23739
|
+
static [entityKind] = "PgBinaryVectorBuilder";
|
|
23740
|
+
constructor(name, config) {
|
|
23741
|
+
super(name, "string", "PgBinaryVector");
|
|
23742
|
+
this.config.dimensions = config.dimensions;
|
|
23743
|
+
}
|
|
23744
|
+
build(table) {
|
|
23745
|
+
return new PgBinaryVector(table, this.config);
|
|
23746
|
+
}
|
|
23747
|
+
}
|
|
23748
|
+
|
|
23749
|
+
class PgBinaryVector extends PgColumn {
|
|
23750
|
+
static [entityKind] = "PgBinaryVector";
|
|
23751
|
+
dimensions = this.config.dimensions;
|
|
23752
|
+
getSQLType() {
|
|
23753
|
+
return `bit(${this.dimensions})`;
|
|
23754
|
+
}
|
|
23755
|
+
}
|
|
23756
|
+
function bit(a, b) {
|
|
23757
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23758
|
+
return new PgBinaryVectorBuilder(name, config);
|
|
23759
|
+
}
|
|
23760
|
+
|
|
23761
|
+
// node_modules/drizzle-orm/pg-core/columns/vector_extension/halfvec.js
|
|
23762
|
+
class PgHalfVectorBuilder extends PgColumnBuilder {
|
|
23763
|
+
static [entityKind] = "PgHalfVectorBuilder";
|
|
23764
|
+
constructor(name, config) {
|
|
23765
|
+
super(name, "array", "PgHalfVector");
|
|
23766
|
+
this.config.dimensions = config.dimensions;
|
|
23767
|
+
}
|
|
23768
|
+
build(table) {
|
|
23769
|
+
return new PgHalfVector(table, this.config);
|
|
23770
|
+
}
|
|
23771
|
+
}
|
|
23772
|
+
|
|
23773
|
+
class PgHalfVector extends PgColumn {
|
|
23774
|
+
static [entityKind] = "PgHalfVector";
|
|
23775
|
+
dimensions = this.config.dimensions;
|
|
23776
|
+
getSQLType() {
|
|
23777
|
+
return `halfvec(${this.dimensions})`;
|
|
23778
|
+
}
|
|
23779
|
+
mapToDriverValue(value) {
|
|
23780
|
+
return JSON.stringify(value);
|
|
23781
|
+
}
|
|
23782
|
+
mapFromDriverValue(value) {
|
|
23783
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
23784
|
+
}
|
|
23785
|
+
}
|
|
23786
|
+
function halfvec(a, b) {
|
|
23787
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23788
|
+
return new PgHalfVectorBuilder(name, config);
|
|
23789
|
+
}
|
|
23790
|
+
|
|
23791
|
+
// node_modules/drizzle-orm/pg-core/columns/vector_extension/sparsevec.js
|
|
23792
|
+
class PgSparseVectorBuilder extends PgColumnBuilder {
|
|
23793
|
+
static [entityKind] = "PgSparseVectorBuilder";
|
|
23794
|
+
constructor(name, config) {
|
|
23795
|
+
super(name, "string", "PgSparseVector");
|
|
23796
|
+
this.config.dimensions = config.dimensions;
|
|
23797
|
+
}
|
|
23798
|
+
build(table) {
|
|
23799
|
+
return new PgSparseVector(table, this.config);
|
|
23800
|
+
}
|
|
23801
|
+
}
|
|
23802
|
+
|
|
23803
|
+
class PgSparseVector extends PgColumn {
|
|
23804
|
+
static [entityKind] = "PgSparseVector";
|
|
23805
|
+
dimensions = this.config.dimensions;
|
|
23806
|
+
getSQLType() {
|
|
23807
|
+
return `sparsevec(${this.dimensions})`;
|
|
23808
|
+
}
|
|
23809
|
+
}
|
|
23810
|
+
function sparsevec(a, b) {
|
|
23811
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23812
|
+
return new PgSparseVectorBuilder(name, config);
|
|
23813
|
+
}
|
|
23814
|
+
|
|
23815
|
+
// node_modules/drizzle-orm/pg-core/columns/vector_extension/vector.js
|
|
23816
|
+
class PgVectorBuilder extends PgColumnBuilder {
|
|
23817
|
+
static [entityKind] = "PgVectorBuilder";
|
|
23818
|
+
constructor(name, config) {
|
|
23819
|
+
super(name, "array", "PgVector");
|
|
23820
|
+
this.config.dimensions = config.dimensions;
|
|
23821
|
+
}
|
|
23822
|
+
build(table) {
|
|
23823
|
+
return new PgVector(table, this.config);
|
|
23824
|
+
}
|
|
23825
|
+
}
|
|
23826
|
+
|
|
23827
|
+
class PgVector extends PgColumn {
|
|
23828
|
+
static [entityKind] = "PgVector";
|
|
23829
|
+
dimensions = this.config.dimensions;
|
|
23830
|
+
getSQLType() {
|
|
23831
|
+
return `vector(${this.dimensions})`;
|
|
23832
|
+
}
|
|
23833
|
+
mapToDriverValue(value) {
|
|
23834
|
+
return JSON.stringify(value);
|
|
23835
|
+
}
|
|
23836
|
+
mapFromDriverValue(value) {
|
|
23837
|
+
return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
|
|
23838
|
+
}
|
|
23839
|
+
}
|
|
23840
|
+
function vector(a, b) {
|
|
23841
|
+
const { name, config } = getColumnNameAndConfig(a, b);
|
|
23842
|
+
return new PgVectorBuilder(name, config);
|
|
23843
|
+
}
|
|
23844
|
+
|
|
23845
|
+
// node_modules/drizzle-orm/pg-core/columns/all.js
|
|
23846
|
+
function getPgColumnBuilders() {
|
|
23847
|
+
return {
|
|
23848
|
+
bigint: bigint2,
|
|
23849
|
+
bigserial,
|
|
23850
|
+
boolean: boolean2,
|
|
23851
|
+
char,
|
|
23852
|
+
cidr,
|
|
23853
|
+
customType,
|
|
23854
|
+
date: date2,
|
|
23855
|
+
doublePrecision,
|
|
23856
|
+
inet,
|
|
23857
|
+
integer,
|
|
23858
|
+
interval,
|
|
23859
|
+
json,
|
|
23860
|
+
jsonb,
|
|
23861
|
+
line,
|
|
23862
|
+
macaddr,
|
|
23863
|
+
macaddr8,
|
|
23864
|
+
numeric,
|
|
23865
|
+
point,
|
|
23866
|
+
geometry,
|
|
23867
|
+
real,
|
|
23868
|
+
serial,
|
|
23869
|
+
smallint,
|
|
23870
|
+
smallserial,
|
|
23871
|
+
text,
|
|
23872
|
+
time,
|
|
23873
|
+
timestamp,
|
|
23874
|
+
uuid,
|
|
23875
|
+
varchar,
|
|
23876
|
+
bit,
|
|
23877
|
+
halfvec,
|
|
23878
|
+
sparsevec,
|
|
23879
|
+
vector
|
|
23880
|
+
};
|
|
23881
|
+
}
|
|
23882
|
+
|
|
23883
|
+
// node_modules/drizzle-orm/pg-core/table.js
|
|
23884
|
+
var InlineForeignKeys = Symbol.for("drizzle:PgInlineForeignKeys");
|
|
23885
|
+
var EnableRLS = Symbol.for("drizzle:EnableRLS");
|
|
23886
|
+
|
|
23887
|
+
class PgTable extends Table {
|
|
23888
|
+
static [entityKind] = "PgTable";
|
|
23889
|
+
static Symbol = Object.assign({}, Table.Symbol, {
|
|
23890
|
+
InlineForeignKeys,
|
|
23891
|
+
EnableRLS
|
|
23892
|
+
});
|
|
23893
|
+
[InlineForeignKeys] = [];
|
|
23894
|
+
[EnableRLS] = false;
|
|
23895
|
+
[Table.Symbol.ExtraConfigBuilder] = undefined;
|
|
23896
|
+
[Table.Symbol.ExtraConfigColumns] = {};
|
|
23897
|
+
}
|
|
23898
|
+
function pgTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
|
|
23899
|
+
const rawTable = new PgTable(name, schema, baseName);
|
|
23900
|
+
const parsedColumns = typeof columns === "function" ? columns(getPgColumnBuilders()) : columns;
|
|
23901
|
+
const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
23902
|
+
const colBuilder = colBuilderBase;
|
|
23903
|
+
colBuilder.setName(name2);
|
|
23904
|
+
const column = colBuilder.build(rawTable);
|
|
23905
|
+
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
|
23906
|
+
return [name2, column];
|
|
23907
|
+
}));
|
|
23908
|
+
const builtColumnsForExtraConfig = Object.fromEntries(Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
|
23909
|
+
const colBuilder = colBuilderBase;
|
|
23910
|
+
colBuilder.setName(name2);
|
|
23911
|
+
const column = colBuilder.buildExtraConfigColumn(rawTable);
|
|
23912
|
+
return [name2, column];
|
|
23913
|
+
}));
|
|
23914
|
+
const table = Object.assign(rawTable, builtColumns);
|
|
23915
|
+
table[Table.Symbol.Columns] = builtColumns;
|
|
23916
|
+
table[Table.Symbol.ExtraConfigColumns] = builtColumnsForExtraConfig;
|
|
23917
|
+
if (extraConfig) {
|
|
23918
|
+
table[PgTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
|
23919
|
+
}
|
|
23920
|
+
return Object.assign(table, {
|
|
23921
|
+
enableRLS: () => {
|
|
23922
|
+
table[PgTable.Symbol.EnableRLS] = true;
|
|
23923
|
+
return table;
|
|
23924
|
+
}
|
|
23925
|
+
});
|
|
23926
|
+
}
|
|
23927
|
+
var pgTable = (name, columns, extraConfig) => {
|
|
23928
|
+
return pgTableWithSchema(name, columns, extraConfig, undefined);
|
|
23929
|
+
};
|
|
23930
|
+
|
|
23931
|
+
// node_modules/drizzle-orm/sql/expressions/conditions.js
|
|
23932
|
+
function bindIfParam(value, column) {
|
|
23933
|
+
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
23934
|
+
return new Param(value, column);
|
|
23935
|
+
}
|
|
23936
|
+
return value;
|
|
23937
|
+
}
|
|
23938
|
+
var eq = (left, right) => {
|
|
23939
|
+
return sql`${left} = ${bindIfParam(right, left)}`;
|
|
23940
|
+
};
|
|
23941
|
+
var ne = (left, right) => {
|
|
23942
|
+
return sql`${left} <> ${bindIfParam(right, left)}`;
|
|
23943
|
+
};
|
|
23944
|
+
function and(...unfilteredConditions) {
|
|
23945
|
+
const conditions = unfilteredConditions.filter((c) => c !== undefined);
|
|
23946
|
+
if (conditions.length === 0) {
|
|
23947
|
+
return;
|
|
23948
|
+
}
|
|
23949
|
+
if (conditions.length === 1) {
|
|
23950
|
+
return new SQL(conditions);
|
|
23951
|
+
}
|
|
23952
|
+
return new SQL([
|
|
23953
|
+
new StringChunk("("),
|
|
23954
|
+
sql.join(conditions, new StringChunk(" and ")),
|
|
23955
|
+
new StringChunk(")")
|
|
23956
|
+
]);
|
|
23957
|
+
}
|
|
23958
|
+
function or(...unfilteredConditions) {
|
|
23959
|
+
const conditions = unfilteredConditions.filter((c) => c !== undefined);
|
|
23960
|
+
if (conditions.length === 0) {
|
|
23961
|
+
return;
|
|
23962
|
+
}
|
|
23963
|
+
if (conditions.length === 1) {
|
|
23964
|
+
return new SQL(conditions);
|
|
23965
|
+
}
|
|
23966
|
+
return new SQL([
|
|
23967
|
+
new StringChunk("("),
|
|
23968
|
+
sql.join(conditions, new StringChunk(" or ")),
|
|
23969
|
+
new StringChunk(")")
|
|
23970
|
+
]);
|
|
23971
|
+
}
|
|
23972
|
+
|
|
23973
|
+
// node_modules/drizzle-orm/sql/expressions/select.js
|
|
23974
|
+
function desc(column) {
|
|
23975
|
+
return sql`${column} desc`;
|
|
23976
|
+
}
|
|
23977
|
+
|
|
23978
|
+
// node_modules/drizzle-orm/sql/functions/aggregate.js
|
|
23979
|
+
function count(expression) {
|
|
23980
|
+
return sql`count(${expression || sql.raw("*")})`.mapWith(Number);
|
|
23981
|
+
}
|
|
23982
|
+
|
|
23983
|
+
// src/database/adapters/drizzle.ts
|
|
23984
|
+
function mapProviderTokenRow(row) {
|
|
23985
|
+
return {
|
|
23986
|
+
id: String(row.id),
|
|
23987
|
+
userId: String(row.userId),
|
|
23988
|
+
provider: String(row.provider),
|
|
23989
|
+
accountEmail: row.accountEmail ?? null,
|
|
23990
|
+
accountId: row.accountId ?? null,
|
|
23991
|
+
accessToken: String(row.accessToken),
|
|
23992
|
+
refreshToken: row.refreshToken ?? null,
|
|
23993
|
+
tokenType: String(row.tokenType ?? "Bearer"),
|
|
23994
|
+
expiresAt: row.expiresAt ?? null,
|
|
23995
|
+
scope: row.scope ?? null,
|
|
23996
|
+
createdAt: row.createdAt,
|
|
23997
|
+
updatedAt: row.updatedAt
|
|
23998
|
+
};
|
|
23999
|
+
}
|
|
24000
|
+
function mapTriggerRow(row) {
|
|
24001
|
+
return {
|
|
24002
|
+
id: String(row.id),
|
|
24003
|
+
userId: row.userId ?? null,
|
|
24004
|
+
name: row.name ?? null,
|
|
24005
|
+
description: row.description ?? null,
|
|
24006
|
+
toolName: String(row.toolName),
|
|
24007
|
+
toolArguments: row.toolArguments ?? {},
|
|
24008
|
+
scheduleType: row.scheduleType,
|
|
24009
|
+
scheduleValue: String(row.scheduleValue),
|
|
24010
|
+
status: String(row.status),
|
|
24011
|
+
provider: row.provider ?? null,
|
|
24012
|
+
lastRunAt: row.lastRunAt ?? null,
|
|
24013
|
+
nextRunAt: row.nextRunAt ?? null,
|
|
24014
|
+
runCount: Number(row.runCount ?? 0),
|
|
24015
|
+
lastError: row.lastError ?? null,
|
|
24016
|
+
lastResult: row.lastResult ?? null,
|
|
24017
|
+
createdAt: row.createdAt,
|
|
24018
|
+
updatedAt: row.updatedAt
|
|
24019
|
+
};
|
|
24020
|
+
}
|
|
24021
|
+
function createDrizzleTokenDriver(db, table) {
|
|
24022
|
+
const t = table;
|
|
24023
|
+
return {
|
|
24024
|
+
async listProviderTokens(userId, provider) {
|
|
24025
|
+
const rows = await db.select().from(table).where(and(eq(t.userId, userId), eq(t.provider, provider))).orderBy(desc(t.updatedAt)).limit(32);
|
|
24026
|
+
return rows.map((row) => mapProviderTokenRow(row));
|
|
24027
|
+
},
|
|
24028
|
+
async upsertProviderToken(input) {
|
|
24029
|
+
const now = new Date;
|
|
24030
|
+
const values = {
|
|
24031
|
+
id: input.existingId ?? input.id,
|
|
24032
|
+
userId: input.userId,
|
|
24033
|
+
provider: input.provider,
|
|
24034
|
+
accountEmail: input.accountEmail,
|
|
24035
|
+
accountId: input.accountId,
|
|
24036
|
+
accessToken: input.accessToken,
|
|
24037
|
+
refreshToken: input.refreshToken,
|
|
24038
|
+
tokenType: input.tokenType,
|
|
24039
|
+
expiresAt: input.expiresAt,
|
|
24040
|
+
scope: input.scope,
|
|
24041
|
+
updatedAt: now,
|
|
24042
|
+
...input.existingId ? {} : { createdAt: now }
|
|
24043
|
+
};
|
|
24044
|
+
if (input.existingId) {
|
|
24045
|
+
const [updated] = await db.update(table).set(values).where(eq(t.id, input.existingId)).returning();
|
|
24046
|
+
return mapProviderTokenRow(updated);
|
|
24047
|
+
}
|
|
24048
|
+
const [created] = await db.insert(table).values(values).returning();
|
|
24049
|
+
return mapProviderTokenRow(created);
|
|
24050
|
+
},
|
|
24051
|
+
async deleteProviderTokens(input) {
|
|
24052
|
+
const conditions = [
|
|
24053
|
+
eq(t.userId, input.userId),
|
|
24054
|
+
eq(t.provider, input.provider)
|
|
24055
|
+
];
|
|
24056
|
+
if (input.accountEmail) {
|
|
24057
|
+
conditions.push(eq(t.accountEmail, input.accountEmail));
|
|
24058
|
+
} else if (input.accountId) {
|
|
24059
|
+
conditions.push(eq(t.accountId, input.accountId));
|
|
24060
|
+
}
|
|
24061
|
+
await db.delete(table).where(and(...conditions));
|
|
24062
|
+
},
|
|
24063
|
+
async deleteDuplicateProviderTokens(input) {
|
|
24064
|
+
const normalizedEmail = normalizeAccountEmail(input.accountEmail);
|
|
24065
|
+
const normalizedAccountId = normalizeAccountIdHint(input.accountId);
|
|
24066
|
+
if (!normalizedEmail && !normalizedAccountId) {
|
|
24067
|
+
return;
|
|
24068
|
+
}
|
|
24069
|
+
const duplicateConditions = [
|
|
24070
|
+
eq(t.userId, input.userId),
|
|
24071
|
+
eq(t.provider, input.provider),
|
|
24072
|
+
ne(t.id, input.keepId)
|
|
24073
|
+
];
|
|
24074
|
+
const identityConditions = [];
|
|
24075
|
+
if (normalizedEmail) {
|
|
24076
|
+
identityConditions.push(eq(t.accountEmail, normalizedEmail));
|
|
24077
|
+
}
|
|
24078
|
+
if (normalizedAccountId) {
|
|
24079
|
+
identityConditions.push(eq(t.accountId, normalizedAccountId));
|
|
24080
|
+
}
|
|
24081
|
+
if (identityConditions.length === 0) {
|
|
24082
|
+
return;
|
|
24083
|
+
}
|
|
24084
|
+
await db.delete(table).where(and(...duplicateConditions, or(...identityConditions)));
|
|
24085
|
+
}
|
|
24086
|
+
};
|
|
24087
|
+
}
|
|
24088
|
+
function createDrizzleTriggerDriver(db, table) {
|
|
24089
|
+
const t = table;
|
|
24090
|
+
return {
|
|
24091
|
+
async createTrigger(input) {
|
|
24092
|
+
const now = new Date;
|
|
24093
|
+
const [created] = await db.insert(table).values({
|
|
24094
|
+
id: input.id,
|
|
24095
|
+
userId: input.userId,
|
|
24096
|
+
name: input.name ?? null,
|
|
24097
|
+
description: input.description ?? null,
|
|
24098
|
+
toolName: input.toolName,
|
|
24099
|
+
toolArguments: input.toolArguments,
|
|
24100
|
+
scheduleType: input.scheduleType,
|
|
24101
|
+
scheduleValue: input.scheduleValue,
|
|
24102
|
+
status: input.status,
|
|
24103
|
+
provider: input.provider ?? null,
|
|
24104
|
+
nextRunAt: input.nextRunAt ?? null,
|
|
24105
|
+
createdAt: now,
|
|
24106
|
+
updatedAt: now
|
|
24107
|
+
}).returning();
|
|
24108
|
+
return mapTriggerRow(created);
|
|
24109
|
+
},
|
|
24110
|
+
async getTriggerById(triggerId) {
|
|
24111
|
+
const [found] = await db.select().from(table).where(eq(t.id, triggerId)).limit(1);
|
|
24112
|
+
return found ? mapTriggerRow(found) : null;
|
|
24113
|
+
},
|
|
24114
|
+
async listTriggers(query) {
|
|
24115
|
+
const conditions = [];
|
|
24116
|
+
if (query.userId) {
|
|
24117
|
+
conditions.push(eq(t.userId, query.userId));
|
|
24118
|
+
}
|
|
24119
|
+
if (query.status) {
|
|
24120
|
+
conditions.push(eq(t.status, query.status));
|
|
24121
|
+
}
|
|
24122
|
+
if (query.toolName) {
|
|
24123
|
+
conditions.push(eq(t.toolName, query.toolName));
|
|
24124
|
+
}
|
|
24125
|
+
const whereClause = conditions.length > 0 ? and(...conditions) : undefined;
|
|
24126
|
+
const rows = await db.select().from(table).where(whereClause).limit(query.limit).offset(query.offset);
|
|
24127
|
+
const [totalResult] = await db.select({ count: count() }).from(table).where(whereClause);
|
|
24128
|
+
return {
|
|
24129
|
+
rows: rows.map((row) => mapTriggerRow(row)),
|
|
24130
|
+
total: Number(totalResult?.count ?? 0)
|
|
24131
|
+
};
|
|
24132
|
+
},
|
|
24133
|
+
async updateTrigger(triggerId, updates) {
|
|
24134
|
+
const [updated] = await db.update(table).set(updates).where(eq(t.id, triggerId)).returning();
|
|
24135
|
+
return updated ? mapTriggerRow(updated) : null;
|
|
24136
|
+
},
|
|
24137
|
+
async deleteTrigger(triggerId) {
|
|
24138
|
+
await db.delete(table).where(eq(t.id, triggerId));
|
|
24139
|
+
}
|
|
24140
|
+
};
|
|
24141
|
+
}
|
|
24142
|
+
function createDrizzleDatabaseDriver(db, schema) {
|
|
24143
|
+
const driver = {
|
|
24144
|
+
tokens: createDrizzleTokenDriver(db, schema.providerToken)
|
|
24145
|
+
};
|
|
24146
|
+
if (schema.trigger) {
|
|
24147
|
+
driver.triggers = createDrizzleTriggerDriver(db, schema.trigger);
|
|
24148
|
+
}
|
|
24149
|
+
return driver;
|
|
24150
|
+
}
|
|
24151
|
+
function drizzleAdapter(db, config) {
|
|
24152
|
+
config.provider;
|
|
24153
|
+
const driver = () => createDrizzleDatabaseDriver(db, config.schema);
|
|
24154
|
+
return createDatabaseAdapterFactory(driver, {
|
|
24155
|
+
hooks: config.hooks,
|
|
24156
|
+
debugLogs: config.debugLogs
|
|
24157
|
+
});
|
|
24158
|
+
}
|
|
24159
|
+
function drizzleAdapterCallbacks(db, config) {
|
|
24160
|
+
return createDatabaseAdapterCallbacks({
|
|
24161
|
+
driver: createDrizzleDatabaseDriver(db, config.schema),
|
|
24162
|
+
hooks: config.hooks,
|
|
24163
|
+
debugLogs: config.debugLogs
|
|
24164
|
+
});
|
|
24165
|
+
}
|
|
24166
|
+
// src/database/adapters/prisma.ts
|
|
24167
|
+
var DEFAULT_MODEL_NAMES = {
|
|
24168
|
+
providerToken: "providerToken",
|
|
24169
|
+
trigger: "trigger"
|
|
24170
|
+
};
|
|
24171
|
+
function getModel(client, name) {
|
|
24172
|
+
const model = client[name];
|
|
24173
|
+
if (!model) {
|
|
24174
|
+
throw new Error(`[Integrate SDK] Prisma model "${name}" was not found on the client`);
|
|
24175
|
+
}
|
|
24176
|
+
return model;
|
|
24177
|
+
}
|
|
24178
|
+
function mapProviderTokenRow2(row) {
|
|
24179
|
+
return {
|
|
24180
|
+
id: String(row.id),
|
|
24181
|
+
userId: String(row.userId),
|
|
24182
|
+
provider: String(row.provider),
|
|
24183
|
+
accountEmail: row.accountEmail ?? null,
|
|
24184
|
+
accountId: row.accountId ?? null,
|
|
24185
|
+
accessToken: String(row.accessToken),
|
|
24186
|
+
refreshToken: row.refreshToken ?? null,
|
|
24187
|
+
tokenType: String(row.tokenType ?? "Bearer"),
|
|
24188
|
+
expiresAt: row.expiresAt ?? null,
|
|
24189
|
+
scope: row.scope ?? null,
|
|
24190
|
+
createdAt: row.createdAt,
|
|
24191
|
+
updatedAt: row.updatedAt
|
|
24192
|
+
};
|
|
24193
|
+
}
|
|
24194
|
+
function mapTriggerRow2(row) {
|
|
24195
|
+
return {
|
|
24196
|
+
id: String(row.id),
|
|
24197
|
+
userId: row.userId ?? null,
|
|
24198
|
+
name: row.name ?? null,
|
|
24199
|
+
description: row.description ?? null,
|
|
24200
|
+
toolName: String(row.toolName),
|
|
24201
|
+
toolArguments: row.toolArguments ?? {},
|
|
24202
|
+
scheduleType: row.scheduleType,
|
|
24203
|
+
scheduleValue: String(row.scheduleValue),
|
|
24204
|
+
status: String(row.status),
|
|
24205
|
+
provider: row.provider ?? null,
|
|
24206
|
+
lastRunAt: row.lastRunAt ?? null,
|
|
24207
|
+
nextRunAt: row.nextRunAt ?? null,
|
|
24208
|
+
runCount: Number(row.runCount ?? 0),
|
|
24209
|
+
lastError: row.lastError ?? null,
|
|
24210
|
+
lastResult: row.lastResult ?? null,
|
|
24211
|
+
createdAt: row.createdAt,
|
|
24212
|
+
updatedAt: row.updatedAt
|
|
24213
|
+
};
|
|
24214
|
+
}
|
|
24215
|
+
function createPrismaTokenDriver(prisma, modelName) {
|
|
24216
|
+
const model = () => getModel(prisma, modelName);
|
|
24217
|
+
return {
|
|
24218
|
+
async listProviderTokens(userId, provider) {
|
|
24219
|
+
const rows = await model().findMany({
|
|
24220
|
+
where: { userId, provider },
|
|
24221
|
+
orderBy: { updatedAt: "desc" },
|
|
24222
|
+
take: 32
|
|
24223
|
+
});
|
|
24224
|
+
return rows.map((row) => mapProviderTokenRow2(row));
|
|
24225
|
+
},
|
|
24226
|
+
async upsertProviderToken(input) {
|
|
24227
|
+
const now = new Date;
|
|
24228
|
+
const data = {
|
|
24229
|
+
userId: input.userId,
|
|
24230
|
+
provider: input.provider,
|
|
24231
|
+
accountEmail: input.accountEmail,
|
|
24232
|
+
accountId: input.accountId,
|
|
24233
|
+
accessToken: input.accessToken,
|
|
24234
|
+
refreshToken: input.refreshToken,
|
|
24235
|
+
tokenType: input.tokenType,
|
|
24236
|
+
expiresAt: input.expiresAt,
|
|
24237
|
+
scope: input.scope,
|
|
24238
|
+
updatedAt: now
|
|
24239
|
+
};
|
|
24240
|
+
if (input.existingId) {
|
|
24241
|
+
const updated = await model().update({
|
|
24242
|
+
where: { id: input.existingId },
|
|
24243
|
+
data
|
|
24244
|
+
});
|
|
24245
|
+
return mapProviderTokenRow2(updated);
|
|
24246
|
+
}
|
|
24247
|
+
const created = await model().create({
|
|
24248
|
+
data: {
|
|
24249
|
+
id: input.id,
|
|
24250
|
+
...data,
|
|
24251
|
+
createdAt: now
|
|
24252
|
+
}
|
|
24253
|
+
});
|
|
24254
|
+
return mapProviderTokenRow2(created);
|
|
24255
|
+
},
|
|
24256
|
+
async deleteProviderTokens(input) {
|
|
24257
|
+
const where = {
|
|
24258
|
+
userId: input.userId,
|
|
24259
|
+
provider: input.provider
|
|
24260
|
+
};
|
|
24261
|
+
if (input.accountEmail) {
|
|
24262
|
+
where.accountEmail = input.accountEmail;
|
|
24263
|
+
} else if (input.accountId) {
|
|
24264
|
+
where.accountId = input.accountId;
|
|
24265
|
+
}
|
|
24266
|
+
await model().deleteMany({ where });
|
|
24267
|
+
},
|
|
24268
|
+
async deleteDuplicateProviderTokens(input) {
|
|
24269
|
+
const normalizedEmail = normalizeAccountEmail(input.accountEmail);
|
|
24270
|
+
const normalizedAccountId = normalizeAccountIdHint(input.accountId);
|
|
24271
|
+
if (!normalizedEmail && !normalizedAccountId) {
|
|
24272
|
+
return;
|
|
24273
|
+
}
|
|
24274
|
+
const orConditions = [];
|
|
24275
|
+
if (normalizedEmail) {
|
|
24276
|
+
orConditions.push({ accountEmail: normalizedEmail });
|
|
24277
|
+
}
|
|
24278
|
+
if (normalizedAccountId) {
|
|
24279
|
+
orConditions.push({ accountId: normalizedAccountId });
|
|
24280
|
+
}
|
|
24281
|
+
await model().deleteMany({
|
|
24282
|
+
where: {
|
|
24283
|
+
userId: input.userId,
|
|
24284
|
+
provider: input.provider,
|
|
24285
|
+
id: { not: input.keepId },
|
|
24286
|
+
OR: orConditions
|
|
24287
|
+
}
|
|
24288
|
+
});
|
|
24289
|
+
}
|
|
24290
|
+
};
|
|
24291
|
+
}
|
|
24292
|
+
function createPrismaTriggerDriver(prisma, modelName) {
|
|
24293
|
+
const model = () => getModel(prisma, modelName);
|
|
24294
|
+
return {
|
|
24295
|
+
async createTrigger(input) {
|
|
24296
|
+
const now = new Date;
|
|
24297
|
+
const created = await model().create({
|
|
24298
|
+
data: {
|
|
24299
|
+
id: input.id,
|
|
24300
|
+
userId: input.userId,
|
|
24301
|
+
name: input.name ?? null,
|
|
24302
|
+
description: input.description ?? null,
|
|
24303
|
+
toolName: input.toolName,
|
|
24304
|
+
toolArguments: input.toolArguments,
|
|
24305
|
+
scheduleType: input.scheduleType,
|
|
24306
|
+
scheduleValue: input.scheduleValue,
|
|
24307
|
+
status: input.status,
|
|
24308
|
+
provider: input.provider ?? null,
|
|
24309
|
+
nextRunAt: input.nextRunAt ?? null,
|
|
24310
|
+
createdAt: now,
|
|
24311
|
+
updatedAt: now
|
|
24312
|
+
}
|
|
24313
|
+
});
|
|
24314
|
+
return mapTriggerRow2(created);
|
|
24315
|
+
},
|
|
24316
|
+
async getTriggerById(triggerId) {
|
|
24317
|
+
const found = await model().findFirst({ where: { id: triggerId } });
|
|
24318
|
+
return found ? mapTriggerRow2(found) : null;
|
|
24319
|
+
},
|
|
24320
|
+
async listTriggers(query) {
|
|
24321
|
+
const where = {};
|
|
24322
|
+
if (query.userId)
|
|
24323
|
+
where.userId = query.userId;
|
|
24324
|
+
if (query.status)
|
|
24325
|
+
where.status = query.status;
|
|
24326
|
+
if (query.toolName)
|
|
24327
|
+
where.toolName = query.toolName;
|
|
24328
|
+
const [rows, total] = await Promise.all([
|
|
24329
|
+
model().findMany({
|
|
24330
|
+
where,
|
|
24331
|
+
take: query.limit,
|
|
24332
|
+
skip: query.offset,
|
|
24333
|
+
orderBy: { updatedAt: "desc" }
|
|
24334
|
+
}),
|
|
24335
|
+
model().count({ where })
|
|
24336
|
+
]);
|
|
24337
|
+
return {
|
|
24338
|
+
rows: rows.map((row) => mapTriggerRow2(row)),
|
|
24339
|
+
total
|
|
24340
|
+
};
|
|
24341
|
+
},
|
|
24342
|
+
async updateTrigger(triggerId, updates) {
|
|
24343
|
+
try {
|
|
24344
|
+
const updated = await model().update({
|
|
24345
|
+
where: { id: triggerId },
|
|
24346
|
+
data: updates
|
|
24347
|
+
});
|
|
24348
|
+
return mapTriggerRow2(updated);
|
|
24349
|
+
} catch {
|
|
24350
|
+
return null;
|
|
24351
|
+
}
|
|
24352
|
+
},
|
|
24353
|
+
async deleteTrigger(triggerId) {
|
|
24354
|
+
await model().delete({ where: { id: triggerId } });
|
|
24355
|
+
}
|
|
24356
|
+
};
|
|
24357
|
+
}
|
|
24358
|
+
function createPrismaDatabaseDriver(prisma, config) {
|
|
24359
|
+
const modelNames = {
|
|
24360
|
+
...DEFAULT_MODEL_NAMES,
|
|
24361
|
+
...config.modelNames
|
|
24362
|
+
};
|
|
24363
|
+
const driver = {
|
|
24364
|
+
tokens: createPrismaTokenDriver(prisma, modelNames.providerToken)
|
|
24365
|
+
};
|
|
24366
|
+
if (config.modelNames?.trigger !== null) {
|
|
24367
|
+
driver.triggers = createPrismaTriggerDriver(prisma, modelNames.trigger);
|
|
24368
|
+
}
|
|
24369
|
+
return driver;
|
|
24370
|
+
}
|
|
24371
|
+
function prismaAdapter(prisma, config) {
|
|
24372
|
+
config.provider;
|
|
24373
|
+
return createDatabaseAdapterFactory(() => createPrismaDatabaseDriver(prisma, config), {
|
|
24374
|
+
hooks: config.hooks,
|
|
24375
|
+
debugLogs: config.debugLogs
|
|
24376
|
+
});
|
|
24377
|
+
}
|
|
24378
|
+
function prismaAdapterCallbacks(prisma, config) {
|
|
24379
|
+
return createDatabaseAdapterCallbacks({
|
|
24380
|
+
driver: createPrismaDatabaseDriver(prisma, config),
|
|
24381
|
+
hooks: config.hooks,
|
|
24382
|
+
debugLogs: config.debugLogs
|
|
24383
|
+
});
|
|
24384
|
+
}
|
|
24385
|
+
// src/database/adapters/mongodb.ts
|
|
24386
|
+
var DEFAULT_COLLECTIONS = {
|
|
24387
|
+
providerTokens: "provider_tokens",
|
|
24388
|
+
triggers: "triggers"
|
|
24389
|
+
};
|
|
24390
|
+
function mapProviderTokenDoc(doc) {
|
|
24391
|
+
return {
|
|
24392
|
+
id: String(doc.id),
|
|
24393
|
+
userId: String(doc.userId),
|
|
24394
|
+
provider: String(doc.provider),
|
|
24395
|
+
accountEmail: doc.accountEmail ?? null,
|
|
24396
|
+
accountId: doc.accountId ?? null,
|
|
24397
|
+
accessToken: String(doc.accessToken),
|
|
24398
|
+
refreshToken: doc.refreshToken ?? null,
|
|
24399
|
+
tokenType: String(doc.tokenType ?? "Bearer"),
|
|
24400
|
+
expiresAt: doc.expiresAt ? new Date(doc.expiresAt) : null,
|
|
24401
|
+
scope: doc.scope ?? null,
|
|
24402
|
+
createdAt: new Date(doc.createdAt),
|
|
24403
|
+
updatedAt: new Date(doc.updatedAt)
|
|
24404
|
+
};
|
|
24405
|
+
}
|
|
24406
|
+
function mapTriggerDoc(doc) {
|
|
24407
|
+
return {
|
|
24408
|
+
id: String(doc.id),
|
|
24409
|
+
userId: doc.userId ?? null,
|
|
24410
|
+
name: doc.name ?? null,
|
|
24411
|
+
description: doc.description ?? null,
|
|
24412
|
+
toolName: String(doc.toolName),
|
|
24413
|
+
toolArguments: doc.toolArguments ?? {},
|
|
24414
|
+
scheduleType: doc.scheduleType,
|
|
24415
|
+
scheduleValue: String(doc.scheduleValue),
|
|
24416
|
+
status: String(doc.status),
|
|
24417
|
+
provider: doc.provider ?? null,
|
|
24418
|
+
lastRunAt: doc.lastRunAt ? new Date(doc.lastRunAt) : null,
|
|
24419
|
+
nextRunAt: doc.nextRunAt ? new Date(doc.nextRunAt) : null,
|
|
24420
|
+
runCount: Number(doc.runCount ?? 0),
|
|
24421
|
+
lastError: doc.lastError ?? null,
|
|
24422
|
+
lastResult: doc.lastResult ?? null,
|
|
24423
|
+
createdAt: new Date(doc.createdAt),
|
|
24424
|
+
updatedAt: new Date(doc.updatedAt)
|
|
24425
|
+
};
|
|
24426
|
+
}
|
|
24427
|
+
function createMongoTokenDriver(db, collectionName) {
|
|
24428
|
+
const collection = () => db.collection(collectionName);
|
|
24429
|
+
return {
|
|
24430
|
+
async listProviderTokens(userId, provider) {
|
|
24431
|
+
const docs = await collection().find({ userId, provider }).sort({ updatedAt: -1 }).limit(32).toArray();
|
|
24432
|
+
return docs.map((doc) => mapProviderTokenDoc(doc));
|
|
24433
|
+
},
|
|
24434
|
+
async upsertProviderToken(input) {
|
|
24435
|
+
const now = new Date;
|
|
24436
|
+
const id = input.existingId ?? input.id;
|
|
24437
|
+
const doc = {
|
|
24438
|
+
id,
|
|
24439
|
+
userId: input.userId,
|
|
24440
|
+
provider: input.provider,
|
|
24441
|
+
accountEmail: input.accountEmail,
|
|
24442
|
+
accountId: input.accountId,
|
|
24443
|
+
accessToken: input.accessToken,
|
|
24444
|
+
refreshToken: input.refreshToken,
|
|
24445
|
+
tokenType: input.tokenType,
|
|
24446
|
+
expiresAt: input.expiresAt,
|
|
24447
|
+
scope: input.scope,
|
|
24448
|
+
updatedAt: now,
|
|
24449
|
+
...input.existingId ? {} : { createdAt: now }
|
|
24450
|
+
};
|
|
24451
|
+
await collection().updateOne({ id }, { $set: doc }, { upsert: true });
|
|
24452
|
+
const saved = await collection().findOne({ id });
|
|
24453
|
+
return mapProviderTokenDoc(saved);
|
|
24454
|
+
},
|
|
24455
|
+
async deleteProviderTokens(input) {
|
|
24456
|
+
const filter = {
|
|
24457
|
+
userId: input.userId,
|
|
24458
|
+
provider: input.provider
|
|
24459
|
+
};
|
|
24460
|
+
if (input.accountEmail) {
|
|
24461
|
+
filter.accountEmail = input.accountEmail;
|
|
24462
|
+
} else if (input.accountId) {
|
|
24463
|
+
filter.accountId = input.accountId;
|
|
24464
|
+
}
|
|
24465
|
+
await collection().deleteMany(filter);
|
|
24466
|
+
},
|
|
24467
|
+
async deleteDuplicateProviderTokens(input) {
|
|
24468
|
+
const normalizedEmail = normalizeAccountEmail(input.accountEmail);
|
|
24469
|
+
const normalizedAccountId = normalizeAccountIdHint(input.accountId);
|
|
24470
|
+
if (!normalizedEmail && !normalizedAccountId) {
|
|
24471
|
+
return;
|
|
24472
|
+
}
|
|
24473
|
+
const orConditions = [];
|
|
24474
|
+
if (normalizedEmail) {
|
|
24475
|
+
orConditions.push({ accountEmail: normalizedEmail });
|
|
24476
|
+
}
|
|
24477
|
+
if (normalizedAccountId) {
|
|
24478
|
+
orConditions.push({ accountId: normalizedAccountId });
|
|
24479
|
+
}
|
|
24480
|
+
await collection().deleteMany({
|
|
24481
|
+
userId: input.userId,
|
|
24482
|
+
provider: input.provider,
|
|
24483
|
+
id: { $ne: input.keepId },
|
|
24484
|
+
$or: orConditions
|
|
24485
|
+
});
|
|
24486
|
+
}
|
|
24487
|
+
};
|
|
24488
|
+
}
|
|
24489
|
+
function createMongoTriggerDriver(db, collectionName) {
|
|
24490
|
+
const collection = () => db.collection(collectionName);
|
|
24491
|
+
return {
|
|
24492
|
+
async createTrigger(input) {
|
|
24493
|
+
const now = new Date;
|
|
24494
|
+
const doc = {
|
|
24495
|
+
id: input.id,
|
|
24496
|
+
userId: input.userId,
|
|
24497
|
+
name: input.name ?? null,
|
|
24498
|
+
description: input.description ?? null,
|
|
24499
|
+
toolName: input.toolName,
|
|
24500
|
+
toolArguments: input.toolArguments,
|
|
24501
|
+
scheduleType: input.scheduleType,
|
|
24502
|
+
scheduleValue: input.scheduleValue,
|
|
24503
|
+
status: input.status,
|
|
24504
|
+
provider: input.provider ?? null,
|
|
24505
|
+
nextRunAt: input.nextRunAt ?? null,
|
|
24506
|
+
createdAt: now,
|
|
24507
|
+
updatedAt: now
|
|
24508
|
+
};
|
|
24509
|
+
await collection().insertOne(doc);
|
|
24510
|
+
return mapTriggerDoc(doc);
|
|
24511
|
+
},
|
|
24512
|
+
async getTriggerById(triggerId) {
|
|
24513
|
+
const found = await collection().findOne({ id: triggerId });
|
|
24514
|
+
return found ? mapTriggerDoc(found) : null;
|
|
24515
|
+
},
|
|
24516
|
+
async listTriggers(query) {
|
|
24517
|
+
const filter = {};
|
|
24518
|
+
if (query.userId)
|
|
24519
|
+
filter.userId = query.userId;
|
|
24520
|
+
if (query.status)
|
|
24521
|
+
filter.status = query.status;
|
|
24522
|
+
if (query.toolName)
|
|
24523
|
+
filter.toolName = query.toolName;
|
|
24524
|
+
const [docs, total] = await Promise.all([
|
|
24525
|
+
collection().find(filter).sort({ updatedAt: -1 }).skip(query.offset).limit(query.limit).toArray(),
|
|
24526
|
+
collection().countDocuments(filter)
|
|
24527
|
+
]);
|
|
24528
|
+
return {
|
|
24529
|
+
rows: docs.map((doc) => mapTriggerDoc(doc)),
|
|
24530
|
+
total
|
|
24531
|
+
};
|
|
24532
|
+
},
|
|
24533
|
+
async updateTrigger(triggerId, updates) {
|
|
24534
|
+
const result = await collection().findOneAndUpdate({ id: triggerId }, { $set: updates }, { returnDocument: "after" });
|
|
24535
|
+
return result ? mapTriggerDoc(result) : null;
|
|
24536
|
+
},
|
|
24537
|
+
async deleteTrigger(triggerId) {
|
|
24538
|
+
await collection().deleteOne({ id: triggerId });
|
|
24539
|
+
}
|
|
24540
|
+
};
|
|
24541
|
+
}
|
|
24542
|
+
function createMongoDatabaseDriver(db, config) {
|
|
24543
|
+
const names = {
|
|
24544
|
+
...DEFAULT_COLLECTIONS,
|
|
24545
|
+
...config.collectionNames
|
|
24546
|
+
};
|
|
24547
|
+
const driver = {
|
|
24548
|
+
tokens: createMongoTokenDriver(db, names.providerTokens)
|
|
24549
|
+
};
|
|
24550
|
+
if (config.collectionNames?.triggers !== null) {
|
|
24551
|
+
driver.triggers = createMongoTriggerDriver(db, names.triggers);
|
|
24552
|
+
}
|
|
24553
|
+
return driver;
|
|
24554
|
+
}
|
|
24555
|
+
function mongodbAdapter(db, config = {}) {
|
|
24556
|
+
return createDatabaseAdapterFactory(() => createMongoDatabaseDriver(db, config), {
|
|
24557
|
+
hooks: config.hooks,
|
|
24558
|
+
debugLogs: config.debugLogs
|
|
24559
|
+
});
|
|
24560
|
+
}
|
|
24561
|
+
function mongodbAdapterCallbacks(db, config = {}) {
|
|
24562
|
+
return createDatabaseAdapterCallbacks({
|
|
24563
|
+
driver: createMongoDatabaseDriver(db, config),
|
|
24564
|
+
hooks: config.hooks,
|
|
24565
|
+
debugLogs: config.debugLogs
|
|
24566
|
+
});
|
|
24567
|
+
}
|
|
24568
|
+
// node_modules/drizzle-orm/pg-core/indexes.js
|
|
24569
|
+
class IndexBuilderOn {
|
|
24570
|
+
constructor(unique, name) {
|
|
24571
|
+
this.unique = unique;
|
|
24572
|
+
this.name = name;
|
|
24573
|
+
}
|
|
24574
|
+
static [entityKind] = "PgIndexBuilderOn";
|
|
24575
|
+
on(...columns) {
|
|
24576
|
+
return new IndexBuilder(columns.map((it) => {
|
|
24577
|
+
if (is(it, SQL)) {
|
|
24578
|
+
return it;
|
|
24579
|
+
}
|
|
24580
|
+
it = it;
|
|
24581
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
24582
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
24583
|
+
return clonedIndexedColumn;
|
|
24584
|
+
}), this.unique, false, this.name);
|
|
24585
|
+
}
|
|
24586
|
+
onOnly(...columns) {
|
|
24587
|
+
return new IndexBuilder(columns.map((it) => {
|
|
24588
|
+
if (is(it, SQL)) {
|
|
24589
|
+
return it;
|
|
24590
|
+
}
|
|
24591
|
+
it = it;
|
|
24592
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
24593
|
+
it.indexConfig = it.defaultConfig;
|
|
24594
|
+
return clonedIndexedColumn;
|
|
24595
|
+
}), this.unique, true, this.name);
|
|
24596
|
+
}
|
|
24597
|
+
using(method, ...columns) {
|
|
24598
|
+
return new IndexBuilder(columns.map((it) => {
|
|
24599
|
+
if (is(it, SQL)) {
|
|
24600
|
+
return it;
|
|
24601
|
+
}
|
|
24602
|
+
it = it;
|
|
24603
|
+
const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
|
24604
|
+
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
|
24605
|
+
return clonedIndexedColumn;
|
|
24606
|
+
}), this.unique, true, this.name, method);
|
|
24607
|
+
}
|
|
24608
|
+
}
|
|
24609
|
+
|
|
24610
|
+
class IndexBuilder {
|
|
24611
|
+
static [entityKind] = "PgIndexBuilder";
|
|
24612
|
+
config;
|
|
24613
|
+
constructor(columns, unique, only, name, method = "btree") {
|
|
24614
|
+
this.config = {
|
|
24615
|
+
name,
|
|
24616
|
+
columns,
|
|
24617
|
+
unique,
|
|
24618
|
+
only,
|
|
24619
|
+
method
|
|
24620
|
+
};
|
|
24621
|
+
}
|
|
24622
|
+
concurrently() {
|
|
24623
|
+
this.config.concurrently = true;
|
|
24624
|
+
return this;
|
|
24625
|
+
}
|
|
24626
|
+
with(obj) {
|
|
24627
|
+
this.config.with = obj;
|
|
24628
|
+
return this;
|
|
24629
|
+
}
|
|
24630
|
+
where(condition) {
|
|
24631
|
+
this.config.where = condition;
|
|
24632
|
+
return this;
|
|
24633
|
+
}
|
|
24634
|
+
build(table) {
|
|
24635
|
+
return new Index(this.config, table);
|
|
24636
|
+
}
|
|
24637
|
+
}
|
|
24638
|
+
|
|
24639
|
+
class Index {
|
|
24640
|
+
static [entityKind] = "PgIndex";
|
|
24641
|
+
config;
|
|
24642
|
+
constructor(config, table) {
|
|
24643
|
+
this.config = { ...config, table };
|
|
24644
|
+
}
|
|
24645
|
+
}
|
|
24646
|
+
function index(name) {
|
|
24647
|
+
return new IndexBuilderOn(false, name);
|
|
24648
|
+
}
|
|
24649
|
+
function uniqueIndex(name) {
|
|
24650
|
+
return new IndexBuilderOn(true, name);
|
|
24651
|
+
}
|
|
24652
|
+
|
|
24653
|
+
// src/database/schemas/drizzle.ts
|
|
24654
|
+
var integrateProviderToken = pgTable("provider_token", {
|
|
24655
|
+
id: text("id").primaryKey(),
|
|
24656
|
+
userId: text("user_id").notNull(),
|
|
24657
|
+
provider: text("provider").notNull(),
|
|
24658
|
+
accountEmail: text("account_email"),
|
|
24659
|
+
accountId: text("account_id"),
|
|
24660
|
+
accessToken: text("access_token").notNull(),
|
|
24661
|
+
refreshToken: text("refresh_token"),
|
|
24662
|
+
tokenType: text("token_type").notNull().default("Bearer"),
|
|
24663
|
+
expiresAt: timestamp("expires_at"),
|
|
24664
|
+
scope: text("scope"),
|
|
24665
|
+
createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
24666
|
+
updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
24667
|
+
}, (table) => [
|
|
24668
|
+
index("provider_token_user_id_idx").on(table.userId),
|
|
24669
|
+
index("provider_token_provider_idx").on(table.provider),
|
|
24670
|
+
index("provider_token_user_provider_idx").on(table.userId, table.provider),
|
|
24671
|
+
uniqueIndex("provider_token_user_provider_account_email_uidx").on(table.userId, table.provider, table.accountEmail)
|
|
24672
|
+
]);
|
|
24673
|
+
var integrateTrigger = pgTable("trigger", {
|
|
24674
|
+
id: text("id").primaryKey(),
|
|
24675
|
+
userId: text("user_id"),
|
|
24676
|
+
name: text("name"),
|
|
24677
|
+
description: text("description"),
|
|
24678
|
+
toolName: text("tool_name").notNull(),
|
|
24679
|
+
toolArguments: jsonb("tool_arguments").notNull(),
|
|
24680
|
+
scheduleType: text("schedule_type").notNull(),
|
|
24681
|
+
scheduleValue: text("schedule_value").notNull(),
|
|
24682
|
+
status: text("status").notNull().default("active"),
|
|
24683
|
+
provider: text("provider"),
|
|
24684
|
+
lastRunAt: timestamp("last_run_at", { mode: "date", precision: 3 }),
|
|
24685
|
+
nextRunAt: timestamp("next_run_at", { mode: "date", precision: 3 }),
|
|
24686
|
+
runCount: integer("run_count").notNull().default(0),
|
|
24687
|
+
lastError: text("last_error"),
|
|
24688
|
+
lastResult: jsonb("last_result"),
|
|
24689
|
+
createdAt: timestamp("created_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
24690
|
+
updatedAt: timestamp("updated_at", { mode: "date", precision: 3 }).default(sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
24691
|
+
}, (table) => [
|
|
24692
|
+
index("trigger_user_id_idx").on(table.userId),
|
|
24693
|
+
index("trigger_status_idx").on(table.status),
|
|
24694
|
+
index("trigger_next_run_at_idx").on(table.nextRunAt)
|
|
24695
|
+
]);
|
|
21237
24696
|
// src/server.ts
|
|
21238
24697
|
var SERVER_LOG_CONTEXT3 = "server";
|
|
21239
24698
|
var logger203 = createLogger("MCPServer", SERVER_LOG_CONTEXT3);
|
|
24699
|
+
function mergeTriggerCallbacks(fromDatabase, explicit) {
|
|
24700
|
+
if (!fromDatabase && !explicit) {
|
|
24701
|
+
return;
|
|
24702
|
+
}
|
|
24703
|
+
return {
|
|
24704
|
+
create: explicit?.create ?? fromDatabase.create,
|
|
24705
|
+
get: explicit?.get ?? fromDatabase.get,
|
|
24706
|
+
list: explicit?.list ?? fromDatabase.list,
|
|
24707
|
+
update: explicit?.update ?? fromDatabase.update,
|
|
24708
|
+
delete: explicit?.delete ?? fromDatabase.delete,
|
|
24709
|
+
onComplete: explicit?.onComplete ?? fromDatabase?.onComplete,
|
|
24710
|
+
getCallbackUrl: explicit?.getCallbackUrl ?? fromDatabase?.getCallbackUrl
|
|
24711
|
+
};
|
|
24712
|
+
}
|
|
24713
|
+
function mergeDatabaseConfig(config) {
|
|
24714
|
+
if (!config.database) {
|
|
24715
|
+
return config;
|
|
24716
|
+
}
|
|
24717
|
+
const databaseCallbacks = config.database();
|
|
24718
|
+
return {
|
|
24719
|
+
...config,
|
|
24720
|
+
getProviderToken: config.getProviderToken ?? databaseCallbacks.getProviderToken,
|
|
24721
|
+
setProviderToken: config.setProviderToken ?? databaseCallbacks.setProviderToken,
|
|
24722
|
+
removeProviderToken: config.removeProviderToken ?? databaseCallbacks.removeProviderToken,
|
|
24723
|
+
triggers: mergeTriggerCallbacks(databaseCallbacks.triggers, config.triggers)
|
|
24724
|
+
};
|
|
24725
|
+
}
|
|
21240
24726
|
async function refreshTokenIfNeeded(provider, tokenData, providers, config, context) {
|
|
21241
24727
|
const credentials = providers[provider];
|
|
21242
24728
|
if (!credentials || !config.serverUrl) {
|
|
@@ -21360,7 +24846,8 @@ function getDefaultRedirectUri() {
|
|
|
21360
24846
|
}
|
|
21361
24847
|
return "http://localhost:3000/api/integrate/oauth/callback";
|
|
21362
24848
|
}
|
|
21363
|
-
function createMCPServer(
|
|
24849
|
+
function createMCPServer(inputConfig) {
|
|
24850
|
+
const config = mergeDatabaseConfig(inputConfig);
|
|
21364
24851
|
setLogLevel(config.debug ? "debug" : "error", SERVER_LOG_CONTEXT3);
|
|
21365
24852
|
if (typeof window !== "undefined") {
|
|
21366
24853
|
throw new Error("createMCPServer() should only be called on the server-side. " + "Use createMCPClient() for client-side code.");
|
|
@@ -22313,7 +25800,11 @@ export {
|
|
|
22313
25800
|
toTanStackStartHandler,
|
|
22314
25801
|
toSvelteKitHandler,
|
|
22315
25802
|
toSolidStartHandler,
|
|
25803
|
+
toSdkTrigger,
|
|
25804
|
+
toSdkSchedule,
|
|
22316
25805
|
toNextJsHandler,
|
|
25806
|
+
toDbTriggerUpdates,
|
|
25807
|
+
toDbSchedule,
|
|
22317
25808
|
tldrawIntegration,
|
|
22318
25809
|
tinkIntegration,
|
|
22319
25810
|
tiktokIntegration,
|
|
@@ -22340,6 +25831,7 @@ export {
|
|
|
22340
25831
|
sharepointIntegration,
|
|
22341
25832
|
sentryIntegration,
|
|
22342
25833
|
sendWebResponse,
|
|
25834
|
+
selectProviderTokenRow,
|
|
22343
25835
|
salesforceIntegration,
|
|
22344
25836
|
sageIntegration,
|
|
22345
25837
|
ringIntegration,
|
|
@@ -22349,6 +25841,9 @@ export {
|
|
|
22349
25841
|
rampIntegration,
|
|
22350
25842
|
railwayIntegration,
|
|
22351
25843
|
quickbooksIntegration,
|
|
25844
|
+
providerTokenRecordToData,
|
|
25845
|
+
prismaAdapterCallbacks,
|
|
25846
|
+
prismaAdapter,
|
|
22352
25847
|
powerpointIntegration,
|
|
22353
25848
|
postmanIntegration,
|
|
22354
25849
|
posthogIntegration,
|
|
@@ -22361,6 +25856,7 @@ export {
|
|
|
22361
25856
|
philipsHueIntegration,
|
|
22362
25857
|
phantomIntegration,
|
|
22363
25858
|
paypalIntegration,
|
|
25859
|
+
parseScopes,
|
|
22364
25860
|
paperIntegration,
|
|
22365
25861
|
pandadocIntegration,
|
|
22366
25862
|
outlookIntegration,
|
|
@@ -22370,9 +25866,16 @@ export {
|
|
|
22370
25866
|
onedriveIntegration,
|
|
22371
25867
|
oktaIntegration,
|
|
22372
25868
|
notionIntegration,
|
|
25869
|
+
normalizeProviderTokenType,
|
|
25870
|
+
normalizeAccountIdentifier,
|
|
25871
|
+
normalizeAccountIdHint,
|
|
25872
|
+
normalizeAccountEmailHint,
|
|
25873
|
+
normalizeAccountEmail,
|
|
22373
25874
|
netlifyIntegration,
|
|
22374
25875
|
netatmoIntegration,
|
|
22375
25876
|
neonIntegration,
|
|
25877
|
+
mongodbAdapterCallbacks,
|
|
25878
|
+
mongodbAdapter,
|
|
22376
25879
|
moneybirdIntegration,
|
|
22377
25880
|
mondayIntegration,
|
|
22378
25881
|
miroIntegration,
|
|
@@ -22394,10 +25897,15 @@ export {
|
|
|
22394
25897
|
klaviyoIntegration,
|
|
22395
25898
|
kickIntegration,
|
|
22396
25899
|
jiraIntegration,
|
|
25900
|
+
isLikelyUsableToken,
|
|
22397
25901
|
intercomIntegration,
|
|
25902
|
+
integrateTrigger,
|
|
25903
|
+
integrateProviderToken,
|
|
22398
25904
|
instagramIntegration,
|
|
22399
25905
|
hubspotIntegration,
|
|
22400
25906
|
homeConnectIntegration,
|
|
25907
|
+
hasUsableAccessToken,
|
|
25908
|
+
hasMeaningfulExpiresAt,
|
|
22401
25909
|
handleOpenAIResponse,
|
|
22402
25910
|
handleAnthropicMessage,
|
|
22403
25911
|
gtasksIntegration,
|
|
@@ -22434,6 +25942,7 @@ export {
|
|
|
22434
25942
|
freshserviceIntegration,
|
|
22435
25943
|
freeagentIntegration,
|
|
22436
25944
|
foursquareIntegration,
|
|
25945
|
+
flattenedTriggerToCreateInput,
|
|
22437
25946
|
fitbitIntegration,
|
|
22438
25947
|
firebaseIntegration,
|
|
22439
25948
|
figmaIntegration,
|
|
@@ -22451,9 +25960,12 @@ export {
|
|
|
22451
25960
|
ebayIntegration,
|
|
22452
25961
|
dropboxSignIntegration,
|
|
22453
25962
|
dropboxIntegration,
|
|
25963
|
+
drizzleAdapterCallbacks,
|
|
25964
|
+
drizzleAdapter,
|
|
22454
25965
|
docusignIntegration,
|
|
22455
25966
|
discordIntegration,
|
|
22456
25967
|
dhlIntegration,
|
|
25968
|
+
defaultResolveAccountIdentity,
|
|
22457
25969
|
deezerIntegration,
|
|
22458
25970
|
datadogIntegration,
|
|
22459
25971
|
databricksIntegration,
|
|
@@ -22463,6 +25975,8 @@ export {
|
|
|
22463
25975
|
createSimpleIntegration,
|
|
22464
25976
|
createNextOAuthHandler,
|
|
22465
25977
|
createMCPServer,
|
|
25978
|
+
createDatabaseAdapterFactory,
|
|
25979
|
+
createDatabaseAdapterCallbacks,
|
|
22466
25980
|
convexIntegration,
|
|
22467
25981
|
contentfulIntegration,
|
|
22468
25982
|
confluenceIntegration,
|