fix(platform): replace Math.random() IDs with crypto.randomUUID() in 5 P2 modules

This commit is contained in:
saravanakumardb1 2026-03-01 17:42:28 -08:00
parent a2461fc26a
commit bd7e78641e
5 changed files with 10 additions and 5 deletions

View File

@ -3,6 +3,7 @@
*/ */
import { getRegisteredContainer } from '@bytelyst/cosmos'; import { getRegisteredContainer } from '@bytelyst/cosmos';
import crypto from 'node:crypto';
import type { ChangelogEntryDoc, CreateChangelogInput, UpdateChangelogInput } from './types.js'; import type { ChangelogEntryDoc, CreateChangelogInput, UpdateChangelogInput } from './types.js';
function getContainer() { function getContainer() {
@ -15,7 +16,7 @@ export async function createEntry(
): Promise<ChangelogEntryDoc> { ): Promise<ChangelogEntryDoc> {
const now = new Date().toISOString(); const now = new Date().toISOString();
const doc: ChangelogEntryDoc = { const doc: ChangelogEntryDoc = {
id: `cl-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: `cl_${crypto.randomUUID()}`,
productId, productId,
version: input.version, version: input.version,
title: input.title, title: input.title,

View File

@ -3,6 +3,7 @@
*/ */
import { getRegisteredContainer } from '@bytelyst/cosmos'; import { getRegisteredContainer } from '@bytelyst/cosmos';
import crypto from 'node:crypto';
import type { import type {
ExperimentDoc, ExperimentDoc,
ExperimentAssignmentDoc, ExperimentAssignmentDoc,
@ -72,7 +73,7 @@ export async function createExperiment(
): Promise<ExperimentDoc> { ): Promise<ExperimentDoc> {
const now = new Date().toISOString(); const now = new Date().toISOString();
const doc: ExperimentDoc = { const doc: ExperimentDoc = {
id: `exp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: `exp_${crypto.randomUUID()}`,
productId, productId,
key: input.key, key: input.key,
name: input.name, name: input.name,

View File

@ -3,6 +3,7 @@
*/ */
import { getRegisteredContainer } from '@bytelyst/cosmos'; import { getRegisteredContainer } from '@bytelyst/cosmos';
import crypto from 'node:crypto';
import type { import type {
FeedbackDoc, FeedbackDoc,
CreateFeedbackInput, CreateFeedbackInput,
@ -21,7 +22,7 @@ export async function createFeedback(
): Promise<FeedbackDoc> { ): Promise<FeedbackDoc> {
const now = new Date().toISOString(); const now = new Date().toISOString();
const doc: FeedbackDoc = { const doc: FeedbackDoc = {
id: `fb-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: `fb_${crypto.randomUUID()}`,
productId, productId,
userId, userId,
type: input.type, type: input.type,

View File

@ -3,6 +3,7 @@
*/ */
import { getRegisteredContainer } from '@bytelyst/cosmos'; import { getRegisteredContainer } from '@bytelyst/cosmos';
import crypto from 'node:crypto';
import type { ImpersonationSessionDoc, StartImpersonationInput } from './types.js'; import type { ImpersonationSessionDoc, StartImpersonationInput } from './types.js';
function getContainer() { function getContainer() {
@ -16,7 +17,7 @@ export async function startImpersonation(
): Promise<ImpersonationSessionDoc> { ): Promise<ImpersonationSessionDoc> {
const now = new Date().toISOString(); const now = new Date().toISOString();
const doc: ImpersonationSessionDoc = { const doc: ImpersonationSessionDoc = {
id: `imp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: `imp_${crypto.randomUUID()}`,
productId, productId,
adminUserId, adminUserId,
targetUserId: input.targetUserId, targetUserId: input.targetUserId,

View File

@ -3,6 +3,7 @@
*/ */
import { getRegisteredContainer } from '@bytelyst/cosmos'; import { getRegisteredContainer } from '@bytelyst/cosmos';
import crypto from 'node:crypto';
import type { import type {
PushTriggerDoc, PushTriggerDoc,
CreateTriggerInput, CreateTriggerInput,
@ -27,7 +28,7 @@ export async function createTrigger(
const now = new Date().toISOString(); const now = new Date().toISOString();
const doc: PushTriggerDoc = { const doc: PushTriggerDoc = {
id: `pt-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: `pt_${crypto.randomUUID()}`,
productId, productId,
userId: input.userId, userId: input.userId,
type: input.type, type: input.type,