Migrate message ids to UUIDv7

This commit is contained in:
Fedor Indutny
2024-10-07 20:17:03 -07:00
committed by GitHub
parent c1b5811c39
commit 60d7cbff3e
24 changed files with 203 additions and 147 deletions

View File

@@ -16,3 +16,19 @@ export const isValidUuid = (value: unknown): value is string => {
return UUID_REGEXP.test(value);
};
const UUID_V7_REGEXP =
/^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
export const isValidUuidV7 = (value: unknown): value is string => {
if (typeof value !== 'string') {
return false;
}
// Zero UUID is a valid uuid.
if (value === '00000000-0000-0000-0000-000000000000') {
return true;
}
return UUID_V7_REGEXP.test(value);
};