Initial commit
This commit is contained in:
commit
e3f0af2f94
1 changed files with 3857 additions and 0 deletions
37
src/config/utils.ts
Normal file
37
src/config/utils.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import type { GROUPS } from './groups';
|
||||
|
||||
function isValidGroupName(name: string): boolean {
|
||||
return /^[a-z][a-z0-9-]*[a-z]$/.test(name);
|
||||
}
|
||||
|
||||
export function defineGroups<
|
||||
const T extends readonly {
|
||||
name: Lowercase<string>;
|
||||
description: string;
|
||||
memberOf?: readonly (T[number]['name'])[];
|
||||
}[]
|
||||
>(groups: T) {
|
||||
for (const group of groups) {
|
||||
if (!isValidGroupName(group.name)) {
|
||||
throw new Error(
|
||||
`Invalid group name: ${group.name}. Must be lowercase alphanumeric with dashes, starting with a letter.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
export type GroupKey = (typeof GROUPS)[number]['name'];
|
||||
|
||||
export interface Group {
|
||||
name: GroupKey;
|
||||
description: string;
|
||||
memberOf?: readonly GroupKey[];
|
||||
}
|
||||
|
||||
export interface Member {
|
||||
github?: string;
|
||||
email?: `${string}@modelcontextprotocol.io`;
|
||||
memberOf: readonly GroupKey[];
|
||||
}
|
||||
Loading…
Reference in a new issue