Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit653b67b

Browse files
chore: remove uuid from the backend (#10807)
Backend only of:#10806This PR drops the uuid package from node modules and replaces it withstandard randomUUID usage that is available from 14.17 onwards, and wehave a minimum requirement of node 20 at Unleash.[Node.js crypto](https://nodejs.org/api/crypto.html#cryptorandomuuidoptions)[Web crypto](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID)Co-authored-by: Anastasiia Hladina <anastasiia.hladina@gmail.com>
1 parent4ff41fa commit653b67b

14 files changed

+90
-105
lines changed

‎package.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@
129129
"ts-toolbelt":"^9.6.0",
130130
"type-is":"^2.0.0",
131131
"ulidx":"^2.4.1",
132-
"unleash-client":"^6.8.0-beta.0",
133-
"uuid":"^11.0.0"
132+
"unleash-client":"^6.8.0-beta.0"
134133
},
135134
"devDependencies": {
136135
"@apidevtools/swagger-parser":"10.1.1",
@@ -161,7 +160,6 @@
161160
"@types/stoppable":"1.1.3",
162161
"@types/supertest":"6.0.3",
163162
"@types/type-is":"1.6.7",
164-
"@types/uuid":"9.0.8",
165163
"@vitest/coverage-v8":"^3.1.3",
166164
"@vitest/ui":"^3.1.3",
167165
"concurrently":"^9.0.0",

‎src/lib/db/feature-environment-store.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import metricsHelper from '../util/metrics-helper.js';
88
import{DB_TIME}from'../metric-events.js';
99
importtype{IFeatureEnvironment,IVariant}from'../types/model.js';
1010
importNotFoundErrorfrom'../error/notfound-error.js';
11-
import{v4asuuidv4}from'uuid';
1211
importtype{Db}from'./db.js';
1312
importtype{IUnleashConfig}from'../types/index.js';
13+
import{randomId}from'../util/index.js';
1414

1515
constT={
1616
featureEnvs:'feature_environments',
@@ -495,7 +495,7 @@ export class FeatureEnvironmentStore implements IFeatureEnvironmentStore {
495495
constclonedStrategyRows=sourceFeatureStrategies.map(
496496
(featureStrategy)=>({
497497
...featureStrategy,
498-
id:uuidv4(),
498+
id:randomId(),
499499
environment:destinationEnvironment,
500500
parameters:JSON.stringify(featureStrategy.parameters),
501501
constraints:JSON.stringify(featureStrategy.constraints),

‎src/lib/error/unleash-error.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import{v4asuuidV4}from'uuid';
21
importtype{FromSchema}from'json-schema-to-ts';
2+
import{randomId}from'../util/random-id.js';
33

44
exportconstUnleashApiErrorTypes=[
55
'ContentTypeError',
@@ -48,7 +48,7 @@ export abstract class UnleashError extends Error {
4848

4949
constructor(message:string,name?:string){
5050
super();
51-
this.id=uuidV4();
51+
this.id=randomId();
5252
this.name=name||this.constructor.name;
5353
super.message=message;
5454
}

‎src/lib/features/dependent-features/dependent.features.e2e.test.ts‎

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import{v4asuuidv4}from'uuid';
21
importdbInit,{
32
typeITestDb,
43
}from'../../../test/e2e/helpers/database-init.js';
@@ -13,7 +12,7 @@ import {
1312
FEATURE_DEPENDENCY_ADDED,
1413
FEATURE_DEPENDENCY_REMOVED,
1514
}from'../../events/index.js';
16-
import{DEFAULT_ENV}from'../../util/index.js';
15+
import{DEFAULT_ENV,randomId}from'../../util/index.js';
1716
importtype{IEventStore}from'../../server-impl.js';
1817

1918
letapp:IUnleashTest;
@@ -169,9 +168,9 @@ const checkDependenciesExist = async (expectedCode = 200) => {
169168
};
170169

171170
test('should add and delete feature dependencies',async()=>{
172-
constparent=uuidv4();
173-
constchild=uuidv4();
174-
constchild2=uuidv4();
171+
constparent=randomId();
172+
constchild=randomId();
173+
constchild2=randomId();
175174
awaitapp.createFeature(parent);
176175
awaitapp.createFeature(child);
177176
awaitapp.createFeature(child2);
@@ -209,10 +208,10 @@ test('should add and delete feature dependencies', async () => {
209208
});
210209

211210
test('should sort potential parent features alphabetically',async()=>{
212-
constparent1=`a${uuidv4()}`;
213-
constparent2=`c${uuidv4()}`;
214-
constparent3=`b${uuidv4()}`;
215-
constchild=uuidv4();
211+
constparent1=`a${randomId()}`;
212+
constparent2=`c${randomId()}`;
213+
constparent3=`b${randomId()}`;
214+
constchild=randomId();
216215
awaitapp.createFeature(parent1);
217216
awaitapp.createFeature(parent2);
218217
awaitapp.createFeature(parent3);
@@ -223,7 +222,7 @@ test('should sort potential parent features alphabetically', async () => {
223222
});
224223

225224
test('should sort potential parent variants',async()=>{
226-
constparent=uuidv4();
225+
constparent=randomId();
227226
awaitapp.createFeature(parent);
228227
awaitaddFeatureEnvironmentVariant(parent,'e');
229228
awaitaddStrategyVariants(parent,['c','a','d']);
@@ -235,9 +234,9 @@ test('should sort potential parent variants', async () => {
235234
});
236235

237236
test('should not allow to add grandparent',async()=>{
238-
constgrandparent=uuidv4();
239-
constparent=uuidv4();
240-
constchild=uuidv4();
237+
constgrandparent=randomId();
238+
constparent=randomId();
239+
constchild=randomId();
241240
awaitapp.createFeature(grandparent);
242241
awaitapp.createFeature(parent);
243242
awaitapp.createFeature(child);
@@ -255,9 +254,9 @@ test('should not allow to add grandparent', async () => {
255254
});
256255

257256
test('should not allow to add grandchild',async()=>{
258-
constgrandparent=uuidv4();
259-
constparent=uuidv4();
260-
constchild=uuidv4();
257+
constgrandparent=randomId();
258+
constparent=randomId();
259+
constchild=randomId();
261260
awaitapp.createFeature(grandparent);
262261
awaitapp.createFeature(parent);
263262
awaitapp.createFeature(child);
@@ -276,8 +275,8 @@ test('should not allow to add grandchild', async () => {
276275
});
277276

278277
test('should not allow to add non-existent parent dependency',async()=>{
279-
constparent=uuidv4();
280-
constchild=uuidv4();
278+
constparent=randomId();
279+
constchild=randomId();
281280
awaitapp.createFeature(child);
282281

283282
awaitaddFeatureDependency(
@@ -290,8 +289,8 @@ test('should not allow to add non-existent parent dependency', async () => {
290289
});
291290

292291
test('should not allow to add archived parent dependency',async()=>{
293-
constparent=uuidv4();
294-
constchild=uuidv4();
292+
constparent=randomId();
293+
constchild=randomId();
295294
awaitapp.createFeature(child);
296295
awaitapp.createFeature(parent);
297296
awaitapp.archiveFeature(parent);
@@ -306,8 +305,8 @@ test('should not allow to add archived parent dependency', async () => {
306305
});
307306

308307
test('should check if any dependencies exist',async()=>{
309-
constparent=uuidv4();
310-
constchild=uuidv4();
308+
constparent=randomId();
309+
constchild=randomId();
311310
awaitapp.createFeature(child);
312311
awaitapp.createFeature(parent);
313312

@@ -323,7 +322,7 @@ test('should check if any dependencies exist', async () => {
323322
});
324323

325324
test('should not allow to add dependency to self',async()=>{
326-
constparent=uuidv4();
325+
constparent=randomId();
327326
awaitapp.createFeature(parent);
328327

329328
awaitaddFeatureDependency(
@@ -336,8 +335,8 @@ test('should not allow to add dependency to self', async () => {
336335
});
337336

338337
test('should not allow to add dependency to feature from another project',async()=>{
339-
constchild=uuidv4();
340-
constparent=uuidv4();
338+
constchild=randomId();
339+
constparent=randomId();
341340
awaitapp.createFeature(parent);
342341
awaitcreateProject('another-project');
343342
awaitapp.createFeature(child,'another-project');
@@ -351,8 +350,8 @@ test('should not allow to add dependency to feature from another project', async
351350
);
352351
});
353352
test('should create feature-dependency-removed when archiving and has dependency',async()=>{
354-
constchild=uuidv4();
355-
constparent=uuidv4();
353+
constchild=randomId();
354+
constparent=randomId();
356355
awaitapp.createFeature(parent);
357356
awaitapp.createFeature(child);
358357

@@ -369,8 +368,8 @@ test('should create feature-dependency-removed when archiving and has dependency
369368
});
370369

371370
test('should not create feature-dependency-removed when archiving and no dependency',async()=>{
372-
constchild=uuidv4();
373-
constparent=uuidv4();
371+
constchild=randomId();
372+
constparent=randomId();
374373
awaitapp.createFeature(parent);
375374
awaitapp.createFeature(child);
376375

‎src/lib/features/feature-toggle/feature-toggle-strategies-store.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import{Knex}from'knex';
22
importtypeEventEmitterfrom'events';
3-
import{v4asuuidv4}from'uuid';
43
importmetricsHelperfrom'../../util/metrics-helper.js';
54
import{DB_TIME}from'../../metric-events.js';
65
importtype{Logger,LogProvider}from'../../logger.js';
@@ -24,6 +23,7 @@ import {
2423
ensureStringValue,
2524
generateImageUrl,
2625
mapValues,
26+
randomId,
2727
}from'../../util/index.js';
2828
importtype{IFeatureProjectUserParams}from'./feature-toggle-controller.js';
2929
importtype{Db}from'../../db/db.js';
@@ -238,7 +238,7 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
238238
strategyConfig.environment,
239239
));
240240
conststrategyRow=mapInput({
241-
id:uuidv4(),
241+
id:randomId(),
242242
...strategyConfig,
243243
sortOrder,
244244
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp