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

View File

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

View File

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

View File

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

View File

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