Skip to content

Commit f208037

Browse files
authored
refactor: Replace uuid dependency with native UUID (#10416)
1 parent d7d5ae5 commit f208037

File tree

7 files changed

+7
-37
lines changed

7 files changed

+7
-37
lines changed

package-lock.json

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"redis": "5.11.0",
5959
"semver": "7.7.4",
6060
"tv4": "1.3.0",
61-
"uuid": "13.0.0",
6261
"winston": "3.19.0",
6362
"winston-daily-rotate-file": "5.0.0",
6463
"ws": "8.20.0"

spec/Idempotency.spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ const Definitions = require('../lib/Options/Definitions');
44
const request = require('../lib/request');
55
const rest = require('../lib/rest');
66
const auth = require('../lib/Auth');
7-
let uuidv4;
7+
const { randomUUID: uuidv4 } = require('crypto');
88

99
describe('Idempotency', () => {
10-
beforeAll(async () => {
11-
({ v4: uuidv4 } = await import('uuid'));
12-
});
1310
// Parameters
1411
/** Enable TTL expiration simulated by removing entry instead of waiting for MongoDB TTL monitor which
1512
runs only every 60s, so it can take up to 119s until entry removal - ain't nobody got time for that */

spec/MongoStorageAdapter.spec.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const request = require('../lib/request');
77
const Config = require('../lib/Config');
88
const TestUtils = require('../lib/TestUtils');
99
const Utils = require('../lib/Utils');
10-
let uuidv4;
10+
const { randomUUID: uuidv4 } = require('crypto');
1111

1212
const fakeClient = {
1313
s: { options: { dbName: null } },
@@ -17,9 +17,6 @@ const fakeClient = {
1717
// These tests are specific to the mongo storage adapter + mongo storage format
1818
// and will eventually be moved into their own repo
1919
describe_only_db('mongo')('MongoStorageAdapter', () => {
20-
beforeAll(async () => {
21-
({ v4: uuidv4 } = await import('uuid'));
22-
});
2320
beforeEach(async () => {
2421
await new MongoStorageAdapter({ uri: databaseURI }).deleteAllClasses();
2522
Config.get(Parse.applicationId).schemaCache.clear();

spec/ParseGraphQLServer.spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const {
3030
const { ParseServer } = require('../');
3131
const { ParseGraphQLServer } = require('../lib/GraphQL/ParseGraphQLServer');
3232
const { ReadPreference, Collection } = require('mongodb');
33-
let uuidv4;
33+
const { randomUUID: uuidv4 } = require('crypto');
3434

3535
function handleError(e) {
3636
if (e && e.networkError && e.networkError.result && e.networkError.result.errors) {
@@ -45,10 +45,6 @@ describe('ParseGraphQLServer', () => {
4545
let parseGraphQLServer;
4646
let loggerErrorSpy;
4747

48-
beforeAll(async () => {
49-
({ v4: uuidv4 } = await import('uuid'));
50-
});
51-
5248
beforeEach(async () => {
5349
parseServer = await global.reconfigureServer({
5450
maintenanceKey: 'test2',

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Parse from 'parse/node';
55
// @flow-disable-next
66
import _ from 'lodash';
77
// @flow-disable-next
8-
import { v4 as uuidv4 } from 'uuid';
8+
import { randomUUID } from 'crypto';
99
import sql from './sql';
1010
import { StorageAdapter } from '../StorageAdapter';
1111
import type { SchemaType, QueryType, QueryOptions } from '../StorageAdapter';
@@ -915,7 +915,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
915915
this._client = client;
916916
this._onchange = () => { };
917917
this._pgp = pgp;
918-
this._uuid = uuidv4();
918+
this._uuid = randomUUID();
919919
this.canSortOnJoinTables = false;
920920
}
921921

src/LiveQuery/ParseLiveQueryServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { matchesQuery, queryHash } from './QueryTools';
1010
import { ParsePubSub } from './ParsePubSub';
1111
import SchemaController from '../Controllers/SchemaController';
1212
import _ from 'lodash';
13-
import { v4 as uuidv4 } from 'uuid';
13+
import { randomUUID } from 'crypto';
1414
import {
1515
runLiveQueryEventHandlers,
1616
getTrigger,
@@ -906,7 +906,7 @@ class ParseLiveQueryServer {
906906
return;
907907
}
908908
const hasMasterKey = this._hasMasterKey(request, this.keyPairs);
909-
const clientId = uuidv4();
909+
const clientId = randomUUID();
910910
const client = new Client(
911911
clientId,
912912
parseWebsocket,

0 commit comments

Comments
 (0)