mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-11 23:49:02 +08:00
Merge branch 'main' into fix/preview_token
This commit is contained in:
commit
f45b3c0155
@ -100,7 +100,8 @@ export async function getACUC(
|
|||||||
? "auth_credit_usage_chunk_extract"
|
? "auth_credit_usage_chunk_extract"
|
||||||
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
|
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
|
||||||
while (retries < maxRetries) {
|
while (retries < maxRetries) {
|
||||||
const client = Math.random() > 0.75 ? supabase_rr_service : supabase_service;
|
const client =
|
||||||
|
Math.random() > 0.5 ? supabase_rr_service : supabase_service;
|
||||||
({ data, error } = await client.rpc(
|
({ data, error } = await client.rpc(
|
||||||
rpcName,
|
rpcName,
|
||||||
{ input_key: api_key },
|
{ input_key: api_key },
|
||||||
@ -200,6 +201,11 @@ export async function supaAuthenticateUser(
|
|||||||
let priceId: string | null = null;
|
let priceId: string | null = null;
|
||||||
let chunk: AuthCreditUsageChunk | null = null;
|
let chunk: AuthCreditUsageChunk | null = null;
|
||||||
let plan: PlanType = "free";
|
let plan: PlanType = "free";
|
||||||
|
if (token == "this_is_just_a_preview_token") {
|
||||||
|
throw new Error(
|
||||||
|
"Unauthenticated Playground calls are temporarily disabled due to abuse. Please sign up.",
|
||||||
|
);
|
||||||
|
}
|
||||||
if (token == process.env.PREVIEW_TOKEN) {
|
if (token == process.env.PREVIEW_TOKEN) {
|
||||||
if (mode == RateLimiterMode.CrawlStatus) {
|
if (mode == RateLimiterMode.CrawlStatus) {
|
||||||
rateLimiter = getRateLimiter(RateLimiterMode.CrawlStatus, token);
|
rateLimiter = getRateLimiter(RateLimiterMode.CrawlStatus, token);
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
import { configDotenv } from "dotenv";
|
import { configDotenv } from "dotenv";
|
||||||
import type { Job, JobState, Queue } from "bullmq";
|
import type { Job, JobState, Queue } from "bullmq";
|
||||||
import { logger } from "../../lib/logger";
|
import { logger } from "../../lib/logger";
|
||||||
import { supabase_service } from "../../services/supabase";
|
import { supabase_rr_service, supabase_service } from "../../services/supabase";
|
||||||
import { getConcurrencyLimitedJobs } from "../../lib/concurrency-limit";
|
import { getConcurrencyLimitedJobs } from "../../lib/concurrency-limit";
|
||||||
configDotenv();
|
configDotenv();
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ export async function crawlStatusController(
|
|||||||
let totalCount = jobIDs.length;
|
let totalCount = jobIDs.length;
|
||||||
|
|
||||||
if (totalCount === 0 && process.env.USE_DB_AUTHENTICATION === "true") {
|
if (totalCount === 0 && process.env.USE_DB_AUTHENTICATION === "true") {
|
||||||
const x = await supabase_service
|
const x = await supabase_rr_service
|
||||||
.from('firecrawl_jobs')
|
.from('firecrawl_jobs')
|
||||||
.select('*', { count: 'exact', head: true })
|
.select('*', { count: 'exact', head: true })
|
||||||
.eq("crawl_id", req.params.jobId)
|
.eq("crawl_id", req.params.jobId)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { supabase_service } from "../../services/supabase";
|
import { supabase_rr_service, supabase_service } from "../../services/supabase";
|
||||||
import { logger } from "../logger";
|
import { logger } from "../logger";
|
||||||
|
|
||||||
export async function getTeamIdSyncB(teamId: string) {
|
export async function getTeamIdSyncB(teamId: string) {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("eb-sync")
|
.from("eb-sync")
|
||||||
.select("team_id")
|
.select("team_id")
|
||||||
.eq("team_id", teamId)
|
.eq("team_id", teamId)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { supabase_service } from "../services/supabase";
|
import { supabase_rr_service, supabase_service } from "../services/supabase";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import * as Sentry from "@sentry/node";
|
|||||||
* @returns {any | null} Job
|
* @returns {any | null} Job
|
||||||
*/
|
*/
|
||||||
export const supabaseGetJobById = async (jobId: string) => {
|
export const supabaseGetJobById = async (jobId: string) => {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("firecrawl_jobs")
|
.from("firecrawl_jobs")
|
||||||
.select("*")
|
.select("*")
|
||||||
.eq("job_id", jobId)
|
.eq("job_id", jobId)
|
||||||
@ -31,7 +31,7 @@ export const supabaseGetJobById = async (jobId: string) => {
|
|||||||
* @returns {any[]} Jobs
|
* @returns {any[]} Jobs
|
||||||
*/
|
*/
|
||||||
export const supabaseGetJobsById = async (jobIds: string[]) => {
|
export const supabaseGetJobsById = async (jobIds: string[]) => {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("firecrawl_jobs")
|
.from("firecrawl_jobs")
|
||||||
.select()
|
.select()
|
||||||
.in("job_id", jobIds);
|
.in("job_id", jobIds);
|
||||||
@ -55,7 +55,7 @@ export const supabaseGetJobsById = async (jobIds: string[]) => {
|
|||||||
* @returns {any[]} Jobs
|
* @returns {any[]} Jobs
|
||||||
*/
|
*/
|
||||||
export const supabaseGetJobsByCrawlId = async (crawlId: string) => {
|
export const supabaseGetJobsByCrawlId = async (crawlId: string) => {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("firecrawl_jobs")
|
.from("firecrawl_jobs")
|
||||||
.select()
|
.select()
|
||||||
.eq("crawl_id", crawlId);
|
.eq("crawl_id", crawlId);
|
||||||
@ -74,7 +74,7 @@ export const supabaseGetJobsByCrawlId = async (crawlId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const supabaseGetJobByIdOnlyData = async (jobId: string) => {
|
export const supabaseGetJobByIdOnlyData = async (jobId: string) => {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("firecrawl_jobs")
|
.from("firecrawl_jobs")
|
||||||
.select("docs, team_id")
|
.select("docs, team_id")
|
||||||
.eq("job_id", jobId)
|
.eq("job_id", jobId)
|
||||||
|
@ -67,6 +67,7 @@ const urlBlocklist = [
|
|||||||
"vMdzZ33BXoyWVZnAPOBcrg==",
|
"vMdzZ33BXoyWVZnAPOBcrg==",
|
||||||
"l8GDVI8w/ueHnNzdN1ODuQ==",
|
"l8GDVI8w/ueHnNzdN1ODuQ==",
|
||||||
"+yz9bnYYMnC0trJZGJwf6Q==",
|
"+yz9bnYYMnC0trJZGJwf6Q==",
|
||||||
|
"oTdhIjEjqdT2pEvyxD1Ssg==",
|
||||||
]
|
]
|
||||||
|
|
||||||
const allowedKeywords = [
|
const allowedKeywords = [
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { AuthCreditUsageChunk } from "../../controllers/v1/types";
|
import { AuthCreditUsageChunk } from "../../controllers/v1/types";
|
||||||
import { getACUC } from "../../controllers/auth";
|
import { getACUC } from "../../controllers/auth";
|
||||||
import { redlock } from "../redlock";
|
import { redlock } from "../redlock";
|
||||||
import { supabase_service } from "../supabase";
|
import { supabase_rr_service, supabase_service } from "../supabase";
|
||||||
import { createPaymentIntent } from "./stripe";
|
import { createPaymentIntent } from "./stripe";
|
||||||
import { issueCredits } from "./issue_credits";
|
import { issueCredits } from "./issue_credits";
|
||||||
import { sendNotification, sendNotificationWithCustomDays } from "../notification/email_notification";
|
import { sendNotification, sendNotificationWithCustomDays } from "../notification/email_notification";
|
||||||
@ -124,7 +124,7 @@ export async function autoCharge(
|
|||||||
if (chunk.sub_user_id) {
|
if (chunk.sub_user_id) {
|
||||||
// Fetch the customer's Stripe information
|
// Fetch the customer's Stripe information
|
||||||
const { data: customer, error: customersError } =
|
const { data: customer, error: customersError } =
|
||||||
await supabase_service
|
await supabase_rr_service
|
||||||
.from("customers")
|
.from("customers")
|
||||||
.select("id, stripe_customer_id")
|
.select("id, stripe_customer_id")
|
||||||
.eq("id", chunk.sub_user_id)
|
.eq("id", chunk.sub_user_id)
|
||||||
|
@ -10,8 +10,8 @@ import { getACUC, setCachedACUC } from "../../controllers/auth";
|
|||||||
const BATCH_KEY = "billing_batch";
|
const BATCH_KEY = "billing_batch";
|
||||||
const BATCH_LOCK_KEY = "billing_batch_lock";
|
const BATCH_LOCK_KEY = "billing_batch_lock";
|
||||||
const BATCH_SIZE = 50; // Batch size for processing
|
const BATCH_SIZE = 50; // Batch size for processing
|
||||||
const BATCH_TIMEOUT = 15000; // 15 seconds processing interval
|
const BATCH_TIMEOUT = 30000; // 15 seconds processing interval
|
||||||
const LOCK_TIMEOUT = 30000; // 30 seconds lock timeout
|
const LOCK_TIMEOUT = 60000; // 30 seconds lock timeout
|
||||||
|
|
||||||
// Define interfaces for billing operations
|
// Define interfaces for billing operations
|
||||||
interface BillingOperation {
|
interface BillingOperation {
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import { NotificationType } from "../../types";
|
import { NotificationType } from "../../types";
|
||||||
import { withAuth } from "../../lib/withAuth";
|
import { withAuth } from "../../lib/withAuth";
|
||||||
import { sendNotification } from "../notification/email_notification";
|
import { sendNotification } from "../notification/email_notification";
|
||||||
import { supabase_service } from "../supabase";
|
import { supabase_rr_service, supabase_service } from "../supabase";
|
||||||
import { logger } from "../../lib/logger";
|
import { logger } from "../../lib/logger";
|
||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
import { AuthCreditUsageChunk } from "../../controllers/v1/types";
|
import { AuthCreditUsageChunk } from "../../controllers/v1/types";
|
||||||
import { getACUC, setCachedACUC } from "../../controllers/auth";
|
|
||||||
import { issueCredits } from "./issue_credits";
|
|
||||||
import { redlock } from "../redlock";
|
|
||||||
import { autoCharge } from "./auto_charge";
|
import { autoCharge } from "./auto_charge";
|
||||||
import { getValue, setValue } from "../redis";
|
import { getValue, setValue } from "../redis";
|
||||||
import { queueBillingOperation } from "./batch_billing";
|
import { queueBillingOperation } from "./batch_billing";
|
||||||
@ -117,7 +114,7 @@ export async function supaCheckTeamCredits(
|
|||||||
isAutoRechargeEnabled = parsedData.auto_recharge;
|
isAutoRechargeEnabled = parsedData.auto_recharge;
|
||||||
autoRechargeThreshold = parsedData.auto_recharge_threshold;
|
autoRechargeThreshold = parsedData.auto_recharge_threshold;
|
||||||
} else {
|
} else {
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("teams")
|
.from("teams")
|
||||||
.select("auto_recharge, auto_recharge_threshold")
|
.select("auto_recharge, auto_recharge_threshold")
|
||||||
.eq("id", team_id)
|
.eq("id", team_id)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import { supabase_service } from "../supabase";
|
import { supabase_rr_service, supabase_service } from "../supabase";
|
||||||
import { validate as isUuid } from "uuid";
|
import { validate as isUuid } from "uuid";
|
||||||
import { logger } from "../../../src/lib/logger";
|
import { logger } from "../../../src/lib/logger";
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export async function validateIdempotencyKey(req: Request): Promise<boolean> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, error } = await supabase_service
|
const { data, error } = await supabase_rr_service
|
||||||
.from("idempotency_keys")
|
.from("idempotency_keys")
|
||||||
.select("key")
|
.select("key")
|
||||||
.eq("key", idempotencyKey);
|
.eq("key", idempotencyKey);
|
||||||
|
@ -137,8 +137,8 @@ const RATE_LIMITS = {
|
|||||||
extract_pro: 1000,
|
extract_pro: 1000,
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
free: 5,
|
free: 0,
|
||||||
default: 5,
|
default: 0,
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
free: 100,
|
free: 100,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { logger } from "../lib/logger";
|
import { logger } from "../lib/logger";
|
||||||
import { supabase_service } from "./supabase";
|
import { supabase_rr_service, supabase_service } from "./supabase";
|
||||||
import { WebhookEventType } from "../types";
|
import { WebhookEventType } from "../types";
|
||||||
import { configDotenv } from "dotenv";
|
import { configDotenv } from "dotenv";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@ -36,7 +36,7 @@ export const callWebhook = async (
|
|||||||
// Only fetch the webhook URL from the database if the self-hosted webhook URL and specified webhook are not set
|
// Only fetch the webhook URL from the database if the self-hosted webhook URL and specified webhook are not set
|
||||||
// and the USE_DB_AUTHENTICATION environment variable is set to true
|
// and the USE_DB_AUTHENTICATION environment variable is set to true
|
||||||
if (!webhookUrl && useDbAuthentication) {
|
if (!webhookUrl && useDbAuthentication) {
|
||||||
const { data: webhooksData, error } = await supabase_service
|
const { data: webhooksData, error } = await supabase_rr_service
|
||||||
.from("webhooks")
|
.from("webhooks")
|
||||||
.select("url")
|
.select("url")
|
||||||
.eq("team_id", teamId)
|
.eq("team_id", teamId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user