mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-19 18:52:32 +02:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62278d110f | |||
| 71348f45b2 | |||
| 21eb4d2876 | |||
| 18270381c1 | |||
| 8e938a2723 | |||
| 197f8f7ba5 | |||
| 10b528642d | |||
| 60d6fff085 | |||
| c664b3da91 | |||
| 492282e758 | |||
| 47f4aefc25 | |||
| 7c0ff9ede7 | |||
| 44e81ea979 | |||
| 56dc10330a | |||
| eb8ad6a181 | |||
| 4edd2e4d32 | |||
| 813c3abe54 | |||
| 048e4fc73c | |||
| 923371e5b4 | |||
| 81430ba3d3 | |||
| e4aaadc9f9 | |||
| d04740fede | |||
| 4677a0d501 | |||
| b4463f0e1a | |||
| b7c0669c38 | |||
| 152d2fb1d6 | |||
| d374b4f66e | |||
| 192542629f |
@@ -77,7 +77,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
@@ -149,7 +149,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
@@ -204,7 +204,7 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
@@ -407,7 +407,7 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
- name: Login to GitHub Container Registry (for cosign)
|
||||
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
|
||||
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@1e223db275d687790206a7acac4d1a11bd6fe629 # v10.4.0
|
||||
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
||||
with:
|
||||
days-before-stale: 14
|
||||
days-before-close: 14
|
||||
|
||||
Generated
+2274
-3524
File diff suppressed because it is too large
Load Diff
+74
-74
@@ -32,49 +32,49 @@
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@asteasolutions/zod-to-openapi": "8.5.0",
|
||||
"@aws-sdk/client-s3": "3.1056.0",
|
||||
"@asteasolutions/zod-to-openapi": "9.1.0",
|
||||
"@aws-sdk/client-s3": "3.1111.0",
|
||||
"@devolutions/iron-remote-desktop": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-0.0.0.tgz",
|
||||
"@devolutions/iron-remote-desktop-rdp": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-rdp-0.0.1.tgz",
|
||||
"@headlessui/react": "2.2.10",
|
||||
"@hookform/resolvers": "5.4.0",
|
||||
"@hookform/resolvers": "5.9.0",
|
||||
"@monaco-editor/react": "4.7.0",
|
||||
"@node-rs/argon2": "2.0.2",
|
||||
"@node-rs/argon2": "2.1.0",
|
||||
"@novnc/novnc": "^1.7.0",
|
||||
"@oslojs/crypto": "1.0.1",
|
||||
"@oslojs/encoding": "1.1.0",
|
||||
"@radix-ui/react-avatar": "1.1.11",
|
||||
"@radix-ui/react-checkbox": "1.3.3",
|
||||
"@radix-ui/react-collapsible": "1.1.12",
|
||||
"@radix-ui/react-dialog": "1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "2.1.16",
|
||||
"@radix-ui/react-avatar": "1.2.6",
|
||||
"@radix-ui/react-checkbox": "1.3.11",
|
||||
"@radix-ui/react-collapsible": "1.1.20",
|
||||
"@radix-ui/react-dialog": "1.1.23",
|
||||
"@radix-ui/react-dropdown-menu": "2.1.24",
|
||||
"@radix-ui/react-icons": "1.3.2",
|
||||
"@radix-ui/react-label": "2.1.8",
|
||||
"@radix-ui/react-popover": "1.1.15",
|
||||
"@radix-ui/react-progress": "1.1.8",
|
||||
"@radix-ui/react-radio-group": "1.3.8",
|
||||
"@radix-ui/react-scroll-area": "1.2.10",
|
||||
"@radix-ui/react-select": "2.2.6",
|
||||
"@radix-ui/react-separator": "1.1.8",
|
||||
"@radix-ui/react-slot": "1.2.4",
|
||||
"@radix-ui/react-switch": "1.2.6",
|
||||
"@radix-ui/react-tabs": "1.1.13",
|
||||
"@radix-ui/react-toast": "1.2.15",
|
||||
"@radix-ui/react-tooltip": "1.2.8",
|
||||
"@radix-ui/react-label": "2.1.15",
|
||||
"@radix-ui/react-popover": "1.1.23",
|
||||
"@radix-ui/react-progress": "1.1.16",
|
||||
"@radix-ui/react-radio-group": "1.4.7",
|
||||
"@radix-ui/react-scroll-area": "1.2.18",
|
||||
"@radix-ui/react-select": "2.3.7",
|
||||
"@radix-ui/react-separator": "1.1.15",
|
||||
"@radix-ui/react-slot": "1.3.3",
|
||||
"@radix-ui/react-switch": "1.3.7",
|
||||
"@radix-ui/react-tabs": "1.1.21",
|
||||
"@radix-ui/react-toast": "1.2.23",
|
||||
"@radix-ui/react-tooltip": "1.2.16",
|
||||
"@react-email/body": "0.3.0",
|
||||
"@react-email/components": "1.0.12",
|
||||
"@react-email/render": "2.0.8",
|
||||
"@react-email/render": "2.1.0",
|
||||
"@react-email/tailwind": "2.0.7",
|
||||
"@simplewebauthn/browser": "13.3.0",
|
||||
"@simplewebauthn/server": "13.3.1",
|
||||
"@simplewebauthn/server": "13.3.2",
|
||||
"@tailwindcss/forms": "0.5.11",
|
||||
"@tanstack/react-query": "5.100.14",
|
||||
"@tanstack/react-table": "8.21.3",
|
||||
"@tanstack/react-query": "5.101.4",
|
||||
"@tanstack/react-table": "9.1.2",
|
||||
"@xterm/addon-fit": "^0.11.0",
|
||||
"@xterm/addon-web-links": "^0.12.0",
|
||||
"@xterm/xterm": "^6.0.0",
|
||||
"arctic": "3.7.0",
|
||||
"axios": "1.18.0",
|
||||
"axios": "1.19.0",
|
||||
"better-sqlite3": "11.9.1",
|
||||
"canvas-confetti": "1.9.4",
|
||||
"class-variance-authority": "0.7.1",
|
||||
@@ -86,62 +86,62 @@
|
||||
"d3": "7.9.0",
|
||||
"drizzle-orm": "0.45.2",
|
||||
"express": "5.2.1",
|
||||
"express-rate-limit": "8.5.2",
|
||||
"express-rate-limit": "8.6.2",
|
||||
"glob": "13.0.6",
|
||||
"gpt-tokenizer": "^3.4.0",
|
||||
"helmet": "8.2.0",
|
||||
"gpt-tokenizer": "^4.0.0",
|
||||
"helmet": "8.3.0",
|
||||
"http-errors": "2.0.1",
|
||||
"input-otp": "1.4.2",
|
||||
"ioredis": "5.11.0",
|
||||
"ioredis": "6.0.0",
|
||||
"jmespath": "0.16.0",
|
||||
"js-yaml": "4.3.0",
|
||||
"js-yaml": "5.3.0",
|
||||
"jsonwebtoken": "9.0.3",
|
||||
"lucide-react": "1.17.0",
|
||||
"maxmind": "5.0.6",
|
||||
"lucide-react": "1.31.0",
|
||||
"maxmind": "5.0.7",
|
||||
"moment": "2.30.1",
|
||||
"next": "16.2.11",
|
||||
"next-intl": "4.13.0",
|
||||
"next": "16.3.1",
|
||||
"next-intl": "4.13.6",
|
||||
"next-themes": "0.4.6",
|
||||
"nextjs-toploader": "3.9.17",
|
||||
"node-cache": "5.1.2",
|
||||
"nodemailer": "9.0.1",
|
||||
"nodemailer": "9.0.5",
|
||||
"oslo": "1.2.1",
|
||||
"pg": "8.21.0",
|
||||
"posthog-node": "5.35.6",
|
||||
"pg": "8.23.0",
|
||||
"posthog-node": "5.49.1",
|
||||
"qrcode.react": "4.2.0",
|
||||
"react": "19.2.6",
|
||||
"react-day-picker": "9.14.0",
|
||||
"react-dom": "19.2.6",
|
||||
"react": "19.2.8",
|
||||
"react-day-picker": "10.0.1",
|
||||
"react-dom": "19.2.8",
|
||||
"react-easy-sort": "1.8.0",
|
||||
"react-hook-form": "7.76.1",
|
||||
"react-icons": "5.6.0",
|
||||
"recharts": "3.8.1",
|
||||
"react-hook-form": "7.85.0",
|
||||
"react-icons": "5.7.0",
|
||||
"recharts": "3.10.1",
|
||||
"reodotdev": "1.1.0",
|
||||
"semver": "7.8.1",
|
||||
"semver": "7.8.5",
|
||||
"sshpk": "1.18.0",
|
||||
"stripe": "22.2.0",
|
||||
"stripe": "22.5.0",
|
||||
"swagger-ui-express": "5.0.1",
|
||||
"tailwind-merge": "3.6.0",
|
||||
"topojson-client": "3.1.0",
|
||||
"tw-animate-css": "1.4.0",
|
||||
"use-debounce": "10.1.1",
|
||||
"uuid": "14.0.0",
|
||||
"uuid": "14.0.1",
|
||||
"vaul": "1.1.2",
|
||||
"visionscarto-world-atlas": "1.0.0",
|
||||
"winston": "3.19.0",
|
||||
"winston-daily-rotate-file": "5.0.0",
|
||||
"ws": "8.21.0",
|
||||
"ws": "8.21.3",
|
||||
"yaml": "2.9.0",
|
||||
"yargs": "18.0.0",
|
||||
"yargs": "18.1.0",
|
||||
"zod": "4.4.3",
|
||||
"zod-validation-error": "5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@dotenvx/dotenvx": "1.69.1",
|
||||
"@dotenvx/dotenvx": "2.21.0",
|
||||
"@esbuild-plugins/tsconfig-paths": "0.1.2",
|
||||
"@react-email/ui": "^6.5.0",
|
||||
"@tailwindcss/postcss": "4.3.0",
|
||||
"@tanstack/react-query-devtools": "5.100.14",
|
||||
"@react-email/ui": "^6.9.2",
|
||||
"@tailwindcss/postcss": "4.3.3",
|
||||
"@tanstack/react-query-devtools": "5.101.4",
|
||||
"@types/better-sqlite3": "7.6.13",
|
||||
"@types/cookie-parser": "1.4.10",
|
||||
"@types/cors": "2.8.19",
|
||||
@@ -152,36 +152,36 @@
|
||||
"@types/jmespath": "0.15.2",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/jsonwebtoken": "9.0.10",
|
||||
"@types/node": "25.9.1",
|
||||
"@types/nodemailer": "8.0.0",
|
||||
"@types/node": "26.2.0",
|
||||
"@types/nodemailer": "8.0.1",
|
||||
"@types/nprogress": "0.2.3",
|
||||
"@types/pg": "8.20.0",
|
||||
"@types/react": "19.2.15",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"@types/semver": "7.7.1",
|
||||
"@types/sshpk": "1.17.4",
|
||||
"@types/pg": "8.21.0",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@types/semver": "7.8.0",
|
||||
"@types/sshpk": "1.17.5",
|
||||
"@types/swagger-ui-express": "4.1.8",
|
||||
"@types/topojson-client": "3.1.5",
|
||||
"@types/ws": "8.18.1",
|
||||
"@types/yargs": "17.0.35",
|
||||
"babel-plugin-react-compiler": "1.0.0",
|
||||
"drizzle-kit": "0.31.10",
|
||||
"esbuild": "0.28.0",
|
||||
"esbuild-node-externals": "1.22.0",
|
||||
"eslint": "10.4.0",
|
||||
"eslint-config-next": "16.2.6",
|
||||
"postcss": "8.5.15",
|
||||
"prettier": "3.8.3",
|
||||
"react-email": "6.5.0",
|
||||
"tailwindcss": "4.3.0",
|
||||
"tsc-alias": "1.8.17",
|
||||
"tsx": "4.22.3",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.60.0"
|
||||
"esbuild": "0.28.2",
|
||||
"esbuild-node-externals": "2.0.0",
|
||||
"eslint": "10.8.1",
|
||||
"eslint-config-next": "16.3.1",
|
||||
"postcss": "8.5.26",
|
||||
"prettier": "3.9.6",
|
||||
"react-email": "6.9.2",
|
||||
"tailwindcss": "4.3.3",
|
||||
"tsc-alias": "1.9.1",
|
||||
"tsx": "4.23.12",
|
||||
"typescript": "7.0.2",
|
||||
"typescript-eslint": "8.67.0"
|
||||
},
|
||||
"overrides": {
|
||||
"esbuild": "0.28.0",
|
||||
"esbuild": "0.28.2",
|
||||
"dompurify": "3.4.0",
|
||||
"postcss": "8.5.15"
|
||||
"postcss": "8.5.26"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
aiModels,
|
||||
aiUsageRecords,
|
||||
db,
|
||||
logsDb,
|
||||
userOrgRoles
|
||||
} from "@server/db";
|
||||
import { modelKeyMatches } from "@server/lib/aiModelKeyMatch";
|
||||
@@ -169,7 +168,7 @@ async function sumUsageAmount(
|
||||
): Promise<number> {
|
||||
const column =
|
||||
unit === "usd" ? aiUsageRecords.costUsd : aiUsageRecords.totalTokens;
|
||||
const [row] = await logsDb
|
||||
const [row] = await db
|
||||
.select({ total: sql<number>`coalesce(sum(${column}), 0)` })
|
||||
.from(aiUsageRecords)
|
||||
.where(where);
|
||||
@@ -201,7 +200,7 @@ export async function sumUsageForBudget(
|
||||
if (!model) {
|
||||
return 0;
|
||||
}
|
||||
const rows = await logsDb
|
||||
const rows = await db
|
||||
.select({
|
||||
requestedModel: aiUsageRecords.requestedModel,
|
||||
costUsd: aiUsageRecords.costUsd,
|
||||
@@ -497,7 +496,7 @@ async function flushUsageRecords() {
|
||||
|
||||
try {
|
||||
// Use a transaction to ensure all inserts succeed or fail together
|
||||
await logsDb.transaction(async (tx) => {
|
||||
await db.transaction(async (tx) => {
|
||||
// Batch insert in groups to avoid overwhelming the database
|
||||
const DB_BATCH_SIZE = 25;
|
||||
for (let i = 0; i < recordsToWrite.length; i += DB_BATCH_SIZE) {
|
||||
|
||||
@@ -312,7 +312,7 @@ async function enrichWithDetails(
|
||||
>();
|
||||
const sessionIds = logs.map((log) => log.sessionId);
|
||||
if (sessionIds.length > 0) {
|
||||
const usageDetails = await logsDb
|
||||
const usageDetails = await primaryDb
|
||||
.select({
|
||||
sessionId: aiUsageRecords.sessionId,
|
||||
promptTokens: aiUsageRecords.promptTokens,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
db,
|
||||
logsDb,
|
||||
aiUsageRecords,
|
||||
aiProviders,
|
||||
resources,
|
||||
@@ -79,22 +78,22 @@ async function query(data: Q) {
|
||||
uniqueUsers,
|
||||
uniqueVirtualApiKeys
|
||||
] = await Promise.all([
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ id: aiUsageRecords.providerId })
|
||||
.from(aiUsageRecords)
|
||||
.where(baseConditions)
|
||||
.limit(DISTINCT_LIMIT + 1),
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ model: aiUsageRecords.requestedModel })
|
||||
.from(aiUsageRecords)
|
||||
.where(baseConditions)
|
||||
.limit(DISTINCT_LIMIT + 1),
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ id: aiUsageRecords.resourceId })
|
||||
.from(aiUsageRecords)
|
||||
.where(and(baseConditions, not(isNull(aiUsageRecords.resourceId))))
|
||||
.limit(DISTINCT_LIMIT + 1),
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ id: aiUsageRecords.siteResourceId })
|
||||
.from(aiUsageRecords)
|
||||
.where(
|
||||
@@ -105,12 +104,12 @@ async function query(data: Q) {
|
||||
)
|
||||
)
|
||||
.limit(DISTINCT_LIMIT + 1),
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ userId: aiUsageRecords.userId })
|
||||
.from(aiUsageRecords)
|
||||
.where(and(baseConditions, not(isNull(aiUsageRecords.userId))))
|
||||
.limit(DISTINCT_LIMIT + 1),
|
||||
logsDb
|
||||
db
|
||||
.selectDistinct({ id: aiUsageRecords.virtualApiKeyId })
|
||||
.from(aiUsageRecords)
|
||||
.where(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { logsDb, aiUsageRecords } from "@server/db";
|
||||
import { db, aiUsageRecords } from "@server/db";
|
||||
import { registry } from "@server/openApi";
|
||||
import { NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
@@ -29,7 +29,7 @@ async function query(data: Q) {
|
||||
const roleUserIds = await resolveRoleUserIds(data.orgId, data.roleId);
|
||||
const baseConditions = buildAiUsageWhere(data, roleUserIds);
|
||||
|
||||
const [totalsRow] = await logsDb
|
||||
const [totalsRow] = await db
|
||||
.select({
|
||||
requests: count(),
|
||||
promptTokens: sql<number>`COALESCE(SUM(${aiUsageRecords.promptTokens}), 0)`,
|
||||
@@ -46,7 +46,7 @@ async function query(data: Q) {
|
||||
|
||||
const dayExpr = dayBucketExpr();
|
||||
|
||||
const requestsPerDay = await logsDb
|
||||
const requestsPerDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
requests: count()
|
||||
@@ -56,7 +56,7 @@ async function query(data: Q) {
|
||||
.groupBy(dayExpr)
|
||||
.orderBy(dayExpr);
|
||||
|
||||
const tokensPerDay = await logsDb
|
||||
const tokensPerDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
promptTokens: sql<number>`COALESCE(SUM(${aiUsageRecords.promptTokens}), 0)`,
|
||||
@@ -70,7 +70,7 @@ async function query(data: Q) {
|
||||
.groupBy(dayExpr)
|
||||
.orderBy(dayExpr);
|
||||
|
||||
const costPerDay = await logsDb
|
||||
const costPerDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
cost: sql<number>`COALESCE(SUM(${aiUsageRecords.costUsd}), 0)`
|
||||
@@ -80,7 +80,7 @@ async function query(data: Q) {
|
||||
.groupBy(dayExpr)
|
||||
.orderBy(dayExpr);
|
||||
|
||||
const modelByDay = await logsDb
|
||||
const modelByDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
model: aiUsageRecords.requestedModel,
|
||||
@@ -117,7 +117,7 @@ async function query(data: Q) {
|
||||
topModelsByTokens
|
||||
);
|
||||
|
||||
const topModelsRaw = await logsDb
|
||||
const topModelsRaw = await db
|
||||
.select({
|
||||
model: aiUsageRecords.requestedModel,
|
||||
requests: count(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db, logsDb, aiUsageRecords, aiProviders } from "@server/db";
|
||||
import { db, aiUsageRecords, aiProviders } from "@server/db";
|
||||
import { registry } from "@server/openApi";
|
||||
import { NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
@@ -29,7 +29,7 @@ async function query(data: Q) {
|
||||
const baseConditions = buildAiUsageWhere(data, roleUserIds);
|
||||
const dayExpr = dayBucketExpr();
|
||||
|
||||
const providerByDay = await logsDb
|
||||
const providerByDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
providerId: aiUsageRecords.providerId,
|
||||
@@ -69,7 +69,7 @@ async function query(data: Q) {
|
||||
topByTokens
|
||||
);
|
||||
|
||||
const topProvidersRaw = await logsDb
|
||||
const topProvidersRaw = await db
|
||||
.select({
|
||||
providerId: aiUsageRecords.providerId,
|
||||
requests: count(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db, logsDb, aiUsageRecords, resources, siteResources } from "@server/db";
|
||||
import { db, aiUsageRecords, resources, siteResources } from "@server/db";
|
||||
import { registry } from "@server/openApi";
|
||||
import { NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
@@ -39,7 +39,7 @@ async function query(data: Q) {
|
||||
const baseConditions = buildAiUsageWhere(data, roleUserIds);
|
||||
const dayExpr = dayBucketExpr();
|
||||
|
||||
const resourceByDay = await logsDb
|
||||
const resourceByDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
resourceId: aiUsageRecords.resourceId,
|
||||
@@ -80,7 +80,7 @@ async function query(data: Q) {
|
||||
topByTokens
|
||||
);
|
||||
|
||||
const topResourcesRaw = await logsDb
|
||||
const topResourcesRaw = await db
|
||||
.select({
|
||||
resourceId: aiUsageRecords.resourceId,
|
||||
siteResourceId: aiUsageRecords.siteResourceId,
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import {
|
||||
db,
|
||||
logsDb,
|
||||
aiUsageRecords,
|
||||
users,
|
||||
roles,
|
||||
userOrgRoles
|
||||
} from "@server/db";
|
||||
import { db, aiUsageRecords, users, roles, userOrgRoles } from "@server/db";
|
||||
import { registry } from "@server/openApi";
|
||||
import { NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
@@ -43,7 +36,7 @@ async function query(data: Q) {
|
||||
// userId, so role totals are derived by expanding each user's usage into
|
||||
// every role they hold in the org (per-role double counting for
|
||||
// multi-role users is expected/accepted).
|
||||
const userByDay = await logsDb
|
||||
const userByDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
userId: aiUsageRecords.userId,
|
||||
@@ -55,7 +48,7 @@ async function query(data: Q) {
|
||||
.groupBy(dayExpr, aiUsageRecords.userId)
|
||||
.orderBy(dayExpr);
|
||||
|
||||
const userTotalsRaw = await logsDb
|
||||
const userTotalsRaw = await db
|
||||
.select({
|
||||
userId: aiUsageRecords.userId,
|
||||
requests: count(),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { db, logsDb, aiUsageRecords, virtualApiKeys } from "@server/db";
|
||||
import { db, aiUsageRecords, virtualApiKeys } from "@server/db";
|
||||
import { registry } from "@server/openApi";
|
||||
import { NextFunction } from "express";
|
||||
import { Request, Response } from "express";
|
||||
@@ -31,7 +31,7 @@ async function query(data: Q) {
|
||||
const baseConditions = buildAiUsageWhere(data, roleUserIds);
|
||||
const dayExpr = dayBucketExpr();
|
||||
|
||||
const virtualApiKeyByDay = await logsDb
|
||||
const virtualApiKeyByDay = await db
|
||||
.select({
|
||||
day: dayExpr.as("day"),
|
||||
virtualApiKeyId: aiUsageRecords.virtualApiKeyId,
|
||||
@@ -43,7 +43,7 @@ async function query(data: Q) {
|
||||
.groupBy(dayExpr, aiUsageRecords.virtualApiKeyId)
|
||||
.orderBy(dayExpr);
|
||||
|
||||
const virtualApiKeyTotalsRaw = await logsDb
|
||||
const virtualApiKeyTotalsRaw = await db
|
||||
.select({
|
||||
virtualApiKeyId: aiUsageRecords.virtualApiKeyId,
|
||||
requests: count(),
|
||||
|
||||
@@ -6,7 +6,7 @@ import HttpCode from "@server/types/HttpCode";
|
||||
import { response } from "@server/lib/response";
|
||||
import { db } from "@server/db";
|
||||
import { passwordResetTokens, users } from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
import { alphabet, generateRandomString, sha256 } from "oslo/crypto";
|
||||
import { createDate } from "oslo";
|
||||
import logger from "@server/logger";
|
||||
@@ -49,7 +49,12 @@ export async function requestPasswordReset(
|
||||
const existingUser = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.email, email));
|
||||
.where(
|
||||
and(
|
||||
eq(users.email, email),
|
||||
eq(users.type, UserType.Internal)
|
||||
)
|
||||
);
|
||||
|
||||
if (!existingUser || !existingUser.length) {
|
||||
await randomDelay(2000);
|
||||
|
||||
@@ -18,6 +18,9 @@ export default async function migration() {
|
||||
try {
|
||||
await db.execute(sql`BEGIN`);
|
||||
|
||||
await db.execute(sql`
|
||||
`);
|
||||
|
||||
await db.execute(sql`
|
||||
CREATE TABLE "aiBudgetBreachEvents" (
|
||||
"id" serial PRIMARY KEY NOT NULL,
|
||||
@@ -451,14 +454,14 @@ export default async function migration() {
|
||||
throw new Error(fromZodError(parsedConfig.error).toString());
|
||||
}
|
||||
|
||||
traefikConfig.experimental.plugins.badger.version = "v1.6.1";
|
||||
traefikConfig.experimental.plugins.badger.version = "v1.6.0";
|
||||
|
||||
const updatedTraefikYaml = yaml.dump(traefikConfig);
|
||||
|
||||
fs.writeFileSync(traefikPath, updatedTraefikYaml, "utf8");
|
||||
|
||||
console.log(
|
||||
"Updated the version of Badger in your Traefik configuration to v1.6.1"
|
||||
"Updated the version of Badger in your Traefik configuration to v1.6.0"
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
|
||||
@@ -456,14 +456,14 @@ export default async function migration() {
|
||||
throw new Error(fromZodError(parsedConfig.error).toString());
|
||||
}
|
||||
|
||||
traefikConfig.experimental.plugins.badger.version = "v1.6.1";
|
||||
traefikConfig.experimental.plugins.badger.version = "v1.6.0";
|
||||
|
||||
const updatedTraefikYaml = yaml.dump(traefikConfig);
|
||||
|
||||
fs.writeFileSync(traefikPath, updatedTraefikYaml, "utf8");
|
||||
|
||||
console.log(
|
||||
"Updated the version of Badger in your Traefik configuration to v1.6.1"
|
||||
"Updated the version of Badger in your Traefik configuration to v1.6.0"
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user