Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 25x 33x 33x 34x 5x 29x | // A brand-new entity/item may not have a real id yet when its first file is
// uploaded (the frontend generates ids up front — see UC-ENTITY-001.1), and
// API Gateway's request validator requires a well-formed UUID regardless.
// This mirrors the equivalent local helpers in ImageField.vue.
const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
export function createTempUuid(): string {
Eif (typeof globalThis.crypto?.randomUUID === 'function') {
return globalThis.crypto.randomUUID()
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.floor(Math.random() * 16)
const v = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
}
export function ensureUuid(value: string | undefined): string {
if (value && UUID_V4_REGEX.test(value)) {
return value
}
return createTempUuid()
}
|