1 import { ulid } from "ulid"
2
3 /**
4 * Generate a composed id based on the input parameters and return either the is if it exists or the generated one.
5 * @param idProperty
6 * @param prefix
7 */
8 export function generateEntityId(idProperty?: string, prefix?: string): string {
9 if (idProperty) {
10 return idProperty
11 }
12
13 const id = ulid()
14 prefix = prefix ? `${prefix}_` : ""
15 return `${prefix}${id}`
16 }