/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/console/core/src/identifier.ts
33 строки
801 B
Victor Navarro
feat(go): referral support (#28345)
19 май 2026, 18:51
Не верифицирован
19 май 2026, 18:51
b32f071
Код
Авторство
О чём код?
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]) } }