Skip to content

Commit f1bae95

Browse files
refactor: revision the use of crypto.randomUUID (#63)
React component props "key" are set into valid natural keys without surrogate random numbers and/or indexes in them
1 parent 7bd55ce commit f1bae95

File tree

43 files changed

+154
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+154
-140
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3-
"version": "2.11.1"
3+
"version": "2.11.1-feature-revision-use-crypto-random.0"
44
}

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
"rxjs": "^7.8.1",
101101
"start-server-and-test": "2.0.0",
102102
"ts-event-bus": "4.1.1",
103-
"ts-jest": "29.1.0"
103+
"ts-jest": "29.1.0",
104+
"uuid": "^11.1.0"
104105
},
105106
"devDependencies": {
106107
"@esbuild-plugins/node-globals-polyfill": "0.2.3",

packages/agents/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-ui-agents",
3-
"version": "2.11.1",
3+
"version": "2.11.1-feature-revision-use-crypto-random.0",
44
"license": "Apache-2.0",
55
"files": [
66
"/dist"

packages/agents/src/entities/settings.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type { AgentKey, NamespaceKey, SettingsKey, VersionKey, WorkspaceKey } from './keys'
17+
import type { AgentKey, NamespaceKey, VersionKey, WorkspaceKey } from './keys'
1818
import type { AutodiscoveryStatus } from './statuses'
1919
import { NONE_DISCOVERY_STATUS } from './statuses'
2020
import { ncCustomAgentsRequestJson, ncCustomAgentsRequestVoid } from '@apihub/utils/requests'
2121

2222
export type Settings = Readonly<{
23-
key: SettingsKey
2423
name: string
2524
versionKey: VersionKey
2625
previousVersionKey: VersionKey
@@ -41,7 +40,6 @@ export type SettingsDto = Readonly<{
4140
}>
4241

4342
export const EMPTY_SETTINGS: Settings = {
44-
key: '',
4543
name: '',
4644
versionKey: '',
4745
previousVersionKey: '',
@@ -53,7 +51,6 @@ export const EMPTY_SETTINGS: Settings = {
5351

5452
export function toSettings(value: SettingsDto): Settings {
5553
return {
56-
key: crypto.randomUUID(),
5754
name: value.name,
5855
versionKey: value.version,
5956
previousVersionKey: value.previousVersion,

packages/agents/src/entities/snapshot-publication-info.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type { AgentKey, NamespaceKey, SnapshotKey, SnapshotPublishInfoKey, WorkspaceKey } from './keys'
17+
import type { AgentKey, NamespaceKey, SnapshotKey, WorkspaceKey } from './keys'
1818
import type { ServicePublishInfo, ServicePublishInfoDto } from './service-publish-info'
1919
import { toServicePublishInfo } from './service-publish-info'
2020
import { ncCustomAgentsRequestJson } from '@apihub/utils/requests'
@@ -23,7 +23,6 @@ import { APIHUB_NC_BASE_PATH } from '@netcracker/qubership-apihub-ui-shared/util
2323
import type { ApiType } from '@netcracker/qubership-apihub-ui-shared/entities/api-types'
2424

2525
export type SnapshotPublicationInfo = Readonly<{
26-
key: SnapshotPublishInfoKey
2726
services: ReadonlyArray<ServicePublishInfo>
2827
apiTypes?: ApiType[]
2928
}>
@@ -34,13 +33,11 @@ export type SnapshotPublicationInfoDto = Readonly<{
3433
}>
3534

3635
export const EMPTY_SNAPSHOT_PUBLICATION_INFO: SnapshotPublicationInfo = {
37-
key: '',
3836
services: [],
3937
}
4038

4139
export function toSnapshotPublicationInfo(value: SnapshotPublicationInfoDto): SnapshotPublicationInfo {
4240
return {
43-
key: crypto.randomUUID(),
4441
services: value.services.map(toServicePublishInfo),
4542
apiTypes: value.apiTypes,
4643
}

packages/agents/src/entities/snapshots.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export type Snapshots = {
2525
}
2626

2727
export type Snapshot = Readonly<{
28-
key: SnapshotKey
2928
versionKey: VersionKey
3029
previousVersionKey?: VersionKey
3130
createdAt: string
@@ -56,7 +55,6 @@ export function toSnapshots(value: SnapshotsDto): Snapshots {
5655
packageKey: value.packageId,
5756
snapshots: value.snapshots.map(snapshot => {
5857
return ({
59-
key: crypto.randomUUID(),
6058
versionKey: snapshot.version,
6159
previousVersionKey: snapshot.previousVersion === '' ? undefined : snapshot.previousVersion,
6260
createdAt: snapshot.createdAt,

packages/agents/src/routes/root/NamespacePage/ServicesPage/ServicesPageBody/CreateSnapshotStep/useCreateSnapshot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import type { PublishConfig} from '@apihub/entities/publish-config'
2828
import { toPublishConfig } from '@apihub/entities/publish-config'
2929
import { WORKSPACE_SEARCH_PARAM } from '@netcracker/qubership-apihub-ui-shared/utils/search-params'
3030
import { useSearchParam } from '@netcracker/qubership-apihub-ui-shared/hooks/searchparams/useSearchParam'
31+
import { v4 as uuidv4 } from 'uuid'
3132

3233
export function useCreateSnapshot(): [CreateSnapshot, IsLoading, IsSuccess, IsError, Error | null] {
3334
const { agentId, namespaceKey } = useParams()
@@ -43,7 +44,7 @@ export function useCreateSnapshot(): [CreateSnapshot, IsLoading, IsSuccess, IsEr
4344
error,
4445
} = useMutation<PublishConfig, Error, CreateSnapshotPublicationOptions>({
4546
mutationFn: async ({ name, baseline, serviceKeys }) => {
46-
const builderId = crypto.randomUUID()
47+
const builderId = uuidv4()
4748

4849
const publishConfigDto = await publishSnapshot(
4950
agentId!,

packages/agents/src/routes/root/NamespacePage/ServicesPage/ServicesPageBody/PromoteVersionStep/usePromoteVersion.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type { ServiceKey, VersionKey } from '@netcracker/qubership-apihub-ui-sha
2525
import type { VersionStatus } from '@netcracker/qubership-apihub-ui-shared/entities/version-status'
2626
import { WORKSPACE_SEARCH_PARAM } from '@netcracker/qubership-apihub-ui-shared/utils/search-params'
2727
import { useSearchParam } from '@netcracker/qubership-apihub-ui-shared/hooks/searchparams/useSearchParam'
28+
import { v4 as uuidv4 } from 'uuid'
2829

2930
export function usePromoteVersion(): [PromoteVersion, IsLoading, IsSuccess, IsError, Error | null] {
3031
const { agentId, namespaceKey } = useParams()
@@ -33,7 +34,7 @@ export function usePromoteVersion(): [PromoteVersion, IsLoading, IsSuccess, IsEr
3334

3435
const { mutate, isLoading, isSuccess, isError, error } = useMutation<PublishConfig, Error, PromoteVersionOptions>({
3536
mutationFn: async ({ version, previousVersion, status, serviceKeys }) => {
36-
const builderId = crypto.randomUUID()
37+
const builderId = uuidv4()
3738

3839
const config = await publishSnapshot(
3940
agentId!,

packages/editor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netcracker/qubership-apihub-ui-editor",
3-
"version": "2.11.1",
3+
"version": "2.11.1-feature-revision-use-crypto-random.0",
44
"license": "Apache-2.0",
55
"files": [
66
"/dist"

0 commit comments

Comments
 (0)