chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:34:48 +08:00
commit 77bb5bf71f
3762 changed files with 353249 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import { prefixToObjectMap } from '@bpinternal/const'
import * as uuid from 'uuid'
const ULID_LENGTH = 26 // Reference: https://github.com/ulid/spec#canonical-string-representation
export function isValidID(id: string) {
// Note: UUIDs were used first and then prefixed ULIDs were introduced.
return isPrefixedULID(id) || uuid.validate(id)
}
export function isPrefixedULID(id: string) {
const [prefix, identifier] = id.split('_')
if (!(prefix && identifier)) {
return false
}
if (!Object.keys(prefixToObjectMap).includes(prefix)) {
return false
}
if (identifier.length < ULID_LENGTH) {
return false
}
return true
}