Chore(medusa,utils,types,inventory,stock-location): remove core dependency modules (#3531)
This commit is contained in:
committed by
GitHub
parent
bfef22b33e
commit
4e9d257d3b
16
packages/utils/src/common/generate-entity-id.ts
Normal file
16
packages/utils/src/common/generate-entity-id.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ulid } from "ulid"
|
||||
|
||||
/**
|
||||
* Generate a composed id based on the input parameters and return either the is if it exists or the generated one.
|
||||
* @param idProperty
|
||||
* @param prefix
|
||||
*/
|
||||
export function generateEntityId(idProperty: string, prefix?: string): string {
|
||||
if (idProperty) {
|
||||
return idProperty
|
||||
}
|
||||
|
||||
const id = ulid()
|
||||
prefix = prefix ? `${prefix}_` : ""
|
||||
return `${prefix}${id}`
|
||||
}
|
||||
Reference in New Issue
Block a user