diff --git a/webapp/common-typescript/@dbeaver/js-helpers/package.json b/webapp/common-typescript/@dbeaver/js-helpers/package.json index 4c67c20560..7ff6753137 100644 --- a/webapp/common-typescript/@dbeaver/js-helpers/package.json +++ b/webapp/common-typescript/@dbeaver/js-helpers/package.json @@ -36,6 +36,7 @@ "color": "^5.0.2", "p-debounce": "^5", "p-memoize": "^8.0.0", - "quick-lru": "^7.1.0" + "quick-lru": "^7.1.0", + "uuid": "^14" } } diff --git a/webapp/common-typescript/@dbeaver/js-helpers/src/index.ts b/webapp/common-typescript/@dbeaver/js-helpers/src/index.ts index 8a8f1be87e..ba96d752a7 100644 --- a/webapp/common-typescript/@dbeaver/js-helpers/src/index.ts +++ b/webapp/common-typescript/@dbeaver/js-helpers/src/index.ts @@ -17,3 +17,6 @@ export * from './mutex.js'; export * from './reorderArray.js'; export * from './getLocalizedDisplayName.js'; export * from './formatNumber.js'; +export * from './isNumber.js'; +export * from './replaceMiddle.js'; +export * from './uuid_.js'; diff --git a/webapp/common-typescript/@dbeaver/js-helpers/src/isNumber.ts b/webapp/common-typescript/@dbeaver/js-helpers/src/isNumber.ts new file mode 100644 index 0000000000..9e04cce5ba --- /dev/null +++ b/webapp/common-typescript/@dbeaver/js-helpers/src/isNumber.ts @@ -0,0 +1,10 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2026 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +export function isNumber(value: unknown): value is number { + return !isNaN(parseFloat(value as string)) && isFinite(value as number); +} diff --git a/webapp/common-typescript/@dbeaver/js-helpers/src/replaceMiddle.ts b/webapp/common-typescript/@dbeaver/js-helpers/src/replaceMiddle.ts new file mode 100644 index 0000000000..aa624b568e --- /dev/null +++ b/webapp/common-typescript/@dbeaver/js-helpers/src/replaceMiddle.ts @@ -0,0 +1,15 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2026 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +export function replaceMiddle(value: string, newMiddle: string, sideLength: number, limiter: number): string { + if (value.length < limiter) { + return value; + } + + return value.substring(0, sideLength) + newMiddle + value.substring(value.length - sideLength); +} diff --git a/webapp/common-typescript/@dbeaver/js-helpers/src/uuid_.ts b/webapp/common-typescript/@dbeaver/js-helpers/src/uuid_.ts new file mode 100644 index 0000000000..db66f7aba9 --- /dev/null +++ b/webapp/common-typescript/@dbeaver/js-helpers/src/uuid_.ts @@ -0,0 +1,15 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2026 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +import { v4 as uuidv4, type Version1Options, type Version4Options } from 'uuid'; + +export type V4Options = Version4Options; +export type V1Options = Version1Options; + +export function uuid(options?: Version4Options): string { + return uuidv4(options); +} diff --git a/webapp/packages/core-utils/package.json b/webapp/packages/core-utils/package.json index f9da96eaac..efee180a30 100644 --- a/webapp/packages/core-utils/package.json +++ b/webapp/packages/core-utils/package.json @@ -30,7 +30,6 @@ "modern-screenshot": "4.6.8", "tslib": "^2", "underscore": "^1", - "uuid": "^14", "vitest": "^4", "whatwg-mimetype": "^5", "zod": "^4", diff --git a/webapp/packages/core-utils/src/isNumber.ts b/webapp/packages/core-utils/src/isNumber.ts index 810d19247f..8f5991ab20 100644 --- a/webapp/packages/core-utils/src/isNumber.ts +++ b/webapp/packages/core-utils/src/isNumber.ts @@ -5,6 +5,4 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -export function isNumber(value: any): value is number { - return !isNaN(parseFloat(value)) && isFinite(value); -} +export { isNumber } from '@dbeaver/js-helpers'; diff --git a/webapp/packages/core-utils/src/replaceMiddle.ts b/webapp/packages/core-utils/src/replaceMiddle.ts index 0fb317d882..267f5e8c26 100644 --- a/webapp/packages/core-utils/src/replaceMiddle.ts +++ b/webapp/packages/core-utils/src/replaceMiddle.ts @@ -1,15 +1,8 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2026 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ - -export function replaceMiddle(value: string, newMiddle: string, sideLength: number, limiter: number): string { - if (value.length < limiter) { - return value; - } - - return value.substr(0, sideLength) + newMiddle + value.substr(value.length - sideLength); -} +export { replaceMiddle } from '@dbeaver/js-helpers'; diff --git a/webapp/packages/core-utils/src/uuid_.ts b/webapp/packages/core-utils/src/uuid_.ts index 19a08a6691..d7304bd752 100644 --- a/webapp/packages/core-utils/src/uuid_.ts +++ b/webapp/packages/core-utils/src/uuid_.ts @@ -1,15 +1,8 @@ /* * CloudBeaver - Cloud Database Manager - * Copyright (C) 2020-2024 DBeaver Corp and others + * Copyright (C) 2020-2026 DBeaver Corp and others * * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -import { v4 as uuidv4, type Version1Options, type Version4Options } from 'uuid'; - -export type V4Options = Version4Options; -export type V1Options = Version1Options; - -export function uuid(options?: Version4Options): string { - return uuidv4(options); -} +export { uuid, type V4Options, type V1Options } from '@dbeaver/js-helpers'; diff --git a/webapp/yarn.lock b/webapp/yarn.lock index 0d08e16e85..cebd1ba6a6 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -2317,7 +2317,6 @@ __metadata: tslib: "npm:^2" typescript: "npm:^5" underscore: "npm:^1" - uuid: "npm:^14" vitest: "npm:^4" whatwg-mimetype: "npm:^5" zod: "npm:^4" @@ -5082,6 +5081,7 @@ __metadata: quick-lru: "npm:^7.1.0" rimraf: "npm:^6" typescript: "npm:^5" + uuid: "npm:^14" vitest: "npm:^4" languageName: unknown linkType: soft