feat: make notifyBotToken/adminUserId optional
The client never sends pairing notifications (the server does); these Discord fields were required but unused. Make them optional + drop from the config schema's required list. Back-compat: still accepted if set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
export interface YonexusClientConfig {
|
||||
mainHost: string;
|
||||
identifier: string;
|
||||
notifyBotToken: string;
|
||||
adminUserId: string;
|
||||
/**
|
||||
* Optional. The client never sends pairing notifications (the server
|
||||
* does); accepted for back-compat but no longer required.
|
||||
*/
|
||||
notifyBotToken?: string;
|
||||
adminUserId?: string;
|
||||
}
|
||||
|
||||
export class YonexusClientConfigError extends Error {
|
||||
@@ -44,15 +48,9 @@ export function validateYonexusClientConfig(raw: unknown): YonexusClientConfig {
|
||||
issues.push("identifier is required");
|
||||
}
|
||||
|
||||
// Optional (back-compat): the client does not send notifications.
|
||||
const rawNotifyBotToken = source.notifyBotToken;
|
||||
if (!isNonEmptyString(rawNotifyBotToken)) {
|
||||
issues.push("notifyBotToken is required");
|
||||
}
|
||||
|
||||
const rawAdminUserId = source.adminUserId;
|
||||
if (!isNonEmptyString(rawAdminUserId)) {
|
||||
issues.push("adminUserId is required");
|
||||
}
|
||||
|
||||
if (issues.length > 0) {
|
||||
throw new YonexusClientConfigError(issues);
|
||||
@@ -60,13 +58,15 @@ export function validateYonexusClientConfig(raw: unknown): YonexusClientConfig {
|
||||
|
||||
const mainHost = (rawMainHost as string).trim();
|
||||
const identifier = (rawIdentifier as string).trim();
|
||||
const notifyBotToken = (rawNotifyBotToken as string).trim();
|
||||
const adminUserId = (rawAdminUserId as string).trim();
|
||||
|
||||
return {
|
||||
mainHost,
|
||||
identifier,
|
||||
notifyBotToken,
|
||||
adminUserId
|
||||
notifyBotToken: isNonEmptyString(rawNotifyBotToken)
|
||||
? rawNotifyBotToken.trim()
|
||||
: undefined,
|
||||
adminUserId: isNonEmptyString(rawAdminUserId)
|
||||
? rawAdminUserId.trim()
|
||||
: undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
"notifyBotToken": { "type": "string" },
|
||||
"adminUserId": { "type": "string" }
|
||||
},
|
||||
"required": ["mainHost", "identifier", "notifyBotToken", "adminUserId"]
|
||||
"required": ["mainHost", "identifier"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user