GHHG10's picture
download
raw
801 Bytes
import { ulid } from "ulid"
import { z } from "zod"
export namespace Identifier {
const prefixes = {
account: "acc",
auth: "aut",
benchmark: "ben",
billing: "bil",
key: "key",
lite: "lit",
model: "mod",
payment: "pay",
provider: "prv",
referral: "ref",
subscription: "sub",
usage: "usg",
user: "usr",
workspace: "wrk",
} as const
export function create(prefix: keyof typeof prefixes, given?: string): string {
if (given) {
if (given.startsWith(prefixes[prefix])) return given
throw new Error(`ID ${given} does not start with ${prefixes[prefix]}`)
}
return [prefixes[prefix], ulid()].join("_")
}
export function schema(prefix: keyof typeof prefixes) {
return z.string().startsWith(prefixes[prefix])
}
}

Xet Storage Details

Size:
801 Bytes
·
Xet hash:
547179884f55b74b836c3a2a947e330438287e8b89bbd614fbc11fde18e5d38f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.