Replace custom code with uuid library (#355)
This commit is contained in:
Родитель
c5034fd746
Коммит
5418e5b05b
|
@ -311,6 +311,15 @@
|
|||
"integrity": "sha512-EquzRwzAAs04anQ8/6MYXFKvHoD+MIlF+gu87EDda7dN9zrKvQYHsc9VFAPB1xY4tUHQVvBMtjsHrvof2EE1Mg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/uuid": {
|
||||
"version": "3.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz",
|
||||
"integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/z-schema": {
|
||||
"version": "3.16.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/z-schema/-/z-schema-3.16.31.tgz",
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"@types/sinon": "7.0.10",
|
||||
"@types/tunnel": "^0.0.0",
|
||||
"@types/underscore": "^1.8.8",
|
||||
"@types/uuid": "3.4.4",
|
||||
"abort-controller": "3.0.0",
|
||||
"cross-env": "5.2.0",
|
||||
"dotenv": "8.0.0",
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import uuid from "uuid/v4";
|
||||
import { ChangeFeedIterator } from "../../ChangeFeedIterator";
|
||||
import { ChangeFeedOptions } from "../../ChangeFeedOptions";
|
||||
import { ClientContext } from "../../ClientContext";
|
||||
import { generateGuidId, getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common";
|
||||
import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common";
|
||||
import { extractPartitionKey } from "../../extractPartitionKey";
|
||||
import { FetchFunctionCallback, SqlQuerySpec } from "../../queryExecutionContext";
|
||||
import { QueryIterator } from "../../queryIterator";
|
||||
|
@ -189,7 +190,7 @@ export class Items {
|
|||
// Generate random document id if the id is missing in the payload and
|
||||
// options.disableAutomaticIdGeneration != true
|
||||
if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) {
|
||||
body.id = generateGuidId();
|
||||
body.id = uuid();
|
||||
}
|
||||
|
||||
const err = {};
|
||||
|
@ -241,7 +242,7 @@ export class Items {
|
|||
// Generate random document id if the id is missing in the payload and
|
||||
// options.disableAutomaticIdGeneration != true
|
||||
if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) {
|
||||
body.id = generateGuidId();
|
||||
body.id = uuid();
|
||||
}
|
||||
|
||||
const err = {};
|
||||
|
|
|
@ -93,41 +93,6 @@ export function getHexaDigit() {
|
|||
return Math.floor(Math.random() * 16).toString(16);
|
||||
}
|
||||
|
||||
// TODO: replace with well known library?
|
||||
export function generateGuidId() {
|
||||
let id = "";
|
||||
|
||||
for (let i = 0; i < 8; i++) {
|
||||
id += getHexaDigit();
|
||||
}
|
||||
|
||||
id += "-";
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
id += getHexaDigit();
|
||||
}
|
||||
|
||||
id += "-";
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
id += getHexaDigit();
|
||||
}
|
||||
|
||||
id += "-";
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
id += getHexaDigit();
|
||||
}
|
||||
|
||||
id += "-";
|
||||
|
||||
for (let i = 0; i < 12; i++) {
|
||||
id += getHexaDigit();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
export function parsePath(path: string) {
|
||||
const pathParts = [];
|
||||
let currentIndex = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче