Merge pull request #2562 from specklesystems/alessandro/web-1533-fix-unique-values-in-seed
chore(seed): fix seed using library to generate unique values
This commit is contained in:
Коммит
f5b262f4ea
|
@ -3,28 +3,36 @@ const { Users, ServerAcl } = require('@/modules/core/dbSchema')
|
|||
const { Roles } = require('@/modules/core/helpers/mainConstants')
|
||||
const { faker } = require('@faker-js/faker')
|
||||
const { range } = require('lodash')
|
||||
const { UniqueEnforcer } = require('enforce-unique')
|
||||
|
||||
const RETRY_COUNT = 3
|
||||
const UNIQUE_MAX_TIME = 500
|
||||
|
||||
const uniqueEnforcer = new UniqueEnforcer()
|
||||
|
||||
function createFakeUser() {
|
||||
return {
|
||||
id: faker.unique(faker.random.alphaNumeric, [10], { maxTime: UNIQUE_MAX_TIME }),
|
||||
name: faker.name.firstName() + ' ' + faker.name.lastName(),
|
||||
id: uniqueEnforcer.enforce(() => faker.string.alphanumeric(10), {
|
||||
maxTime: UNIQUE_MAX_TIME
|
||||
}),
|
||||
name: faker.person.firstName() + ' ' + faker.person.lastName(),
|
||||
bio: faker.lorem.lines(5),
|
||||
company: faker.company.companyName(),
|
||||
email: faker.unique(
|
||||
faker.internet.email,
|
||||
[
|
||||
faker.unique(faker.random.alphaNumeric, [10]),
|
||||
faker.unique(faker.random.alphaNumeric, [10])
|
||||
],
|
||||
{ maxTime: UNIQUE_MAX_TIME }
|
||||
company: faker.company.name(),
|
||||
email: uniqueEnforcer.enforce(
|
||||
() =>
|
||||
faker.internet.email({
|
||||
firstName: faker.string.alphanumeric(),
|
||||
lastName: faker.string.alphanumeric()
|
||||
}),
|
||||
{
|
||||
maxTime: UNIQUE_MAX_TIME,
|
||||
maxRetries: RETRY_COUNT
|
||||
}
|
||||
),
|
||||
verified: faker.datatype.boolean(),
|
||||
avatar: faker.random.alphaNumeric(255),
|
||||
avatar: faker.string.alphanumeric(255),
|
||||
ip: faker.internet.ipv4(),
|
||||
passwordDigest: faker.random.alphaNumeric(255)
|
||||
passwordDigest: faker.string.alphanumeric(255)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@
|
|||
"concurrently": "^7.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"deep-equal-in-any-order": "^1.1.15",
|
||||
"enforce-unique": "^1.3.0",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"http-proxy-middleware": "v3.0.0-beta.0",
|
||||
|
|
|
@ -15620,6 +15620,7 @@ __metadata:
|
|||
deep-equal-in-any-order: "npm:^1.1.15"
|
||||
dotenv: "npm:^8.2.0"
|
||||
ejs: "npm:^3.1.8"
|
||||
enforce-unique: "npm:^1.3.0"
|
||||
eslint: "npm:^8.11.0"
|
||||
eslint-config-prettier: "npm:^8.5.0"
|
||||
eventemitter2: "npm:^6.4.7"
|
||||
|
@ -28386,6 +28387,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"enforce-unique@npm:^1.3.0":
|
||||
version: 1.3.0
|
||||
resolution: "enforce-unique@npm:1.3.0"
|
||||
checksum: 10/c92da297787ff17ac1671c5c86ddc075308fb895fc0d728d2860ce152d1ab2f7b04d5c41ba4b86e75175c723b70aaf7f3d282930ec464fff3a96d3d8ddcdb4ba
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"enhanced-resolve@npm:^4.1.1":
|
||||
version: 4.5.0
|
||||
resolution: "enhanced-resolve@npm:4.5.0"
|
||||
|
|
Загрузка…
Ссылка в новой задаче