g1t/packages/contracts/src/names.ts

18 lines795 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Initial g1t: services, event bus, intents and attempts1// Namespaces follow GitHub's rules (no leading, trailing or doubled hyphens),
2// so "--" can never appear inside one.
3const NAMESPACE = /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/;
4const REPO_NAME = /^[a-z0-9._-]{1,100}$/;
5
6/** Routes and reserved words that may not be registered as usernames. */
7const RESERVED = new Set([
8 "api", "mcp", "login", "logout", "register", "new", "settings", "search",
Device sign-in replaces registering and minting tokens over the API9 "admin", "auth", "attempts", "verify", "forgot", "reset", "device", "oauth", "assets", "docs", "explore", "g1t", "about",
Initial g1t: services, event bus, intents and attempts10]);
11
12export function isValidNamespace(value: string): boolean {
13 return NAMESPACE.test(value) && !RESERVED.has(value);
14}
15
16export function isValidRepoName(value: string): boolean {
17 return REPO_NAME.test(value) && !value.startsWith(".") && !value.endsWith(".git");
18}