Skip to content

Commit 794291c

Browse files
refactor: remove uuid dependency
1 parent 833fe59 commit 794291c

File tree

10 files changed

+21
-26
lines changed

10 files changed

+21
-26
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"@types/node": "22.7.9",
2323
"@types/react": "^18.0.5",
2424
"@types/react-dom": "^18.0.1",
25-
"@types/uuid": "^8.3.4",
2625
"airtable": "^0.12.2",
2726
"axios": "^1.9.0",
2827
"bcrypt": "^5.1.1",
@@ -82,8 +81,6 @@
8281
"swagger-ui-express": "^5.0.1",
8382
"typedoc": "^0.23.8",
8483
"typescript": "^4.6.3",
85-
"uuid": "^8.3.2",
86-
"uuidv4": "^6.2.12",
8784
"web-vitals": "^2.1.4",
8885
"winston": "^3.5.1"
8986
},

server/src/api/record.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Robot from "../models/Robot";
77
import Run from "../models/Run";
88
const router = Router();
99
import { getDecryptedProxyConfig } from "../routes/proxy";
10-
import { v4 as uuid } from "uuid";
10+
import { randomUUID } from "crypto";
1111
import { createRemoteBrowserForRun, destroyRemoteBrowser } from "../browser-management/controller";
1212
import logger from "../logger";
1313
import { browserPool } from "../server";
@@ -489,7 +489,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
489489

490490
const browserId = createRemoteBrowserForRun(userId);
491491

492-
const runId = uuid();
492+
const runId = randomUUID();
493493

494494
const run = await Run.create({
495495
status: 'running',

server/src/browser-management/controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Holds the singleton instances of browser pool and socket.io server.
44
*/
55
import { Socket } from "socket.io";
6-
import { v4 as uuid } from "uuid";
6+
import { randomUUID } from "crypto";
77

88
import { createSocketConnection, createSocketConnectionForRun } from "../socket-connection/connection";
99
import { io, browserPool } from "../server";
@@ -21,7 +21,7 @@ import logger from "../logger";
2121
* @category BrowserManagement-Controller
2222
*/
2323
export const initializeRemoteBrowserForRecording = (userId: string, mode: string = "dom"): string => {
24-
const id = getActiveBrowserIdByState(userId, "recording") || uuid();
24+
const id = getActiveBrowserIdByState(userId, "recording") || randomUUID();
2525
createSocketConnection(
2626
io.of(id),
2727
userId,
@@ -67,7 +67,7 @@ export const createRemoteBrowserForRun = (userId: string): string => {
6767
throw new Error('userId is required');
6868
}
6969

70-
const id = uuid();
70+
const id = randomUUID();
7171

7272
const slotReserved = browserPool.reserveBrowserSlot(id, userId, "run");
7373
if (!slotReserved) {

server/src/routes/storage.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createRemoteBrowserForRun, destroyRemoteBrowser, getActiveBrowserIdBySt
44
import { chromium } from 'playwright-extra';
55
import stealthPlugin from 'puppeteer-extra-plugin-stealth';
66
import { browserPool } from "../server";
7-
import { v4 as uuid } from "uuid";
7+
import { randomUUID } from "crypto";
88
import moment from 'moment-timezone';
99
import cron from 'node-cron';
1010
import { getDecryptedProxyConfig } from './proxy';
@@ -394,11 +394,11 @@ router.post('/recordings/:id/duplicate', requireSignIn, async (req: Authenticate
394394
const currentTimestamp = new Date().toLocaleString();
395395

396396
const newRobot = await Robot.create({
397-
id: uuid(),
397+
id: randomUUID(),
398398
userId: originalRobot.userId,
399399
recording_meta: {
400400
...originalRobot.recording_meta,
401-
id: uuid(),
401+
id: randomUUID(),
402402
name: `${originalRobot.recording_meta.name} (${lastWord})`,
403403
createdAt: currentTimestamp,
404404
updatedAt: currentTimestamp,
@@ -518,7 +518,7 @@ router.put('/runs/:id', requireSignIn, async (req: AuthenticatedRequest, res) =>
518518
}
519519

520520
// Generate runId first
521-
const runId = uuid();
521+
const runId = randomUUID();
522522

523523
const canCreateBrowser = await browserPool.hasAvailableBrowserSlots(req.user.id, "run");
524524

@@ -607,7 +607,7 @@ router.put('/runs/:id', requireSignIn, async (req: AuthenticatedRequest, res) =>
607607
queued: false
608608
});
609609
} else {
610-
const browserId = uuid();
610+
const browserId = randomUUID();
611611

612612
await Run.create({
613613
status: 'queued',

server/src/routes/webhook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Router, Request, Response } from 'express';
22
import Robot from '../models/Robot';
33
import { requireSignIn } from '../middlewares/auth';
44
import axios from 'axios';
5-
import { v4 as uuid } from "uuid";
5+
import { randomUUID } from "crypto";
66

77
export const router = Router();
88

@@ -86,7 +86,7 @@ router.post('/add', requireSignIn, async (req: Request, res: Response) => {
8686

8787
const newWebhook: WebhookConfig = {
8888
...webhook,
89-
id: webhook.id || uuid(),
89+
id: webhook.id || randomUUID(),
9090
createdAt: new Date().toISOString(),
9191
updatedAt: new Date().toISOString(),
9292
lastCalledAt: null,

server/src/schedule-worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import logger from './logger';
66
import Robot from './models/Robot';
77
import { handleRunRecording } from './workflow-management/scheduler';
88
import { computeNextRun } from './utils/schedule';
9-
import { v4 as uuid } from "uuid";
9+
import { randomUUID } from "crypto";
1010

1111
if (!process.env.DB_USER || !process.env.DB_PASSWORD || !process.env.DB_HOST || !process.env.DB_PORT || !process.env.DB_NAME) {
1212
throw new Error('One or more required environment variables are missing.');
@@ -33,7 +33,7 @@ interface ScheduledWorkflowData {
3333
*/
3434
export async function scheduleWorkflow(id: string, userId: string, cronExpression: string, timezone: string): Promise<void> {
3535
try {
36-
const runId = uuid();
36+
const runId = crypto.randomUUID();
3737

3838
const queueName = `scheduled-workflow-${id}`;
3939

server/src/workflow-management/classes/Generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { CustomActions } from "../../../../src/shared/types";
1616
import Robot from "../../models/Robot";
1717
import { getBestSelectorForAction } from "../utils";
18-
import { v4 as uuid } from "uuid";
18+
import { randomUUID } from "crypto";
1919
import { capture } from "../../utils/analytics"
2020
import { decrypt, encrypt } from "../../utils/auth";
2121

@@ -904,7 +904,7 @@ export class WorkflowGenerator {
904904
} else {
905905
this.recordingMeta = {
906906
name: fileName,
907-
id: uuid(),
907+
id: randomUUID(),
908908
createdAt: this.recordingMeta.createdAt || new Date().toLocaleString(),
909909
pairs: recording.workflow.length,
910910
updatedAt: new Date().toLocaleString(),

server/src/workflow-management/scheduler/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { v4 as uuid } from "uuid";
1+
import { randomUUID } from "crypto";
22
import { chromium } from 'playwright-extra';
33
import stealthPlugin from 'puppeteer-extra-plugin-stealth';
44
import { io, Socket } from "socket.io-client";
@@ -47,7 +47,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
4747
}
4848

4949
const browserId = createRemoteBrowserForRun( userId);
50-
const runId = uuid();
50+
const runId = randomUUID();
5151

5252
const run = await Run.create({
5353
status: 'scheduled',
@@ -60,7 +60,7 @@ async function createWorkflowAndStoreMetadata(id: string, userId: string) {
6060
interpreterSettings: { maxConcurrency: 1, maxRepeats: 1, debug: true },
6161
log: '',
6262
runId,
63-
runByScheduleId: uuid(),
63+
runByScheduleId: randomUUID(),
6464
serializableOutput: {},
6565
binaryOutput: {},
6666
});

src/components/integration/IntegrationSettings.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import axios from "axios";
2929
import { useGlobalInfoStore } from "../../context/globalInfo";
3030
import { getStoredRecording } from "../../api/storage";
3131
import { apiUrl } from "../../apiConfig.js";
32-
import { v4 as uuid } from "uuid";
3332

3433
import Cookies from "js-cookie";
3534

@@ -197,7 +196,7 @@ export const IntegrationSettingsModal = ({
197196
setLoading(true);
198197
const webhookWithId = {
199198
...newWebhook,
200-
id: uuid(),
199+
id: crypto.randomUUID(),
201200
};
202201

203202
const response = await addWebhook(webhookWithId, recordingId);

src/components/robot/pages/RobotIntegrationPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import axios from "axios";
3333
import { useGlobalInfoStore } from "../../../context/globalInfo";
3434
import { getStoredRecording } from "../../../api/storage";
3535
import { apiUrl } from "../../../apiConfig.js";
36-
import { v4 as uuid } from "uuid";
3736
import { useTranslation } from "react-i18next";
3837
import { useNavigate, useParams, useLocation } from "react-router-dom";
3938
import {
@@ -202,7 +201,7 @@ export const RobotIntegrationPage = ({
202201
if (!recordingId) return;
203202
try {
204203
setLoading(true);
205-
const webhookWithId = { ...newWebhook, id: uuid() };
204+
const webhookWithId = { ...newWebhook, id: crypto.randomUUID() };
206205
const response = await addWebhook(webhookWithId, recordingId);
207206
if (response.ok) {
208207
setSettings((prev) => ({ ...prev, webhooks: [...(prev.webhooks || []), webhookWithId] }));

0 commit comments

Comments
 (0)