mcp-decisive
Version:
MCP server for WRAP decision-making framework with structured output
74 lines • 3.63 kB
JavaScript
import { ok, err } from 'neverthrow';
const IssueText = {
create: (value) => {
const errors = validateIssueText(value);
return errors.length > 0 ? err(errors) : ok(value.trim());
},
toString: (issueText) => issueText
};
const ContextText = {
create: (value) => {
const errors = validateContextText(value);
return errors.length > 0 ? err(errors) : ok(value.trim());
},
toString: (contextText) => contextText
};
const ConstraintText = {
create: (value) => {
const errors = validateConstraintText(value);
return errors.length > 0 ? err(errors) : ok(value.trim());
},
toString: (constraintText) => constraintText
};
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Business Rules - Domain Policies
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
const validateIssueText = (value) => {
if (!value || value.trim().length === 0) {
return [ValidationError.create('required', 'issue', '課題は必須です')];
}
if (value.length > 30) {
return [ValidationError.create('too_long', 'issue', '課題は30文字以内で入力してください')];
}
return [];
};
const validateContextText = (value) => {
if (!value || value.trim().length === 0) {
return [ValidationError.create('required', 'context', 'コンテキストは必須です')];
}
if (value.length > 60) {
return [ValidationError.create('too_long', 'context', 'コンテキストは60文字以内で入力してください')];
}
return [];
};
const validateConstraintText = (value) => {
if (!value || value.trim().length === 0) {
return [ValidationError.create('required', 'constraints', '制約は必須です')];
}
if (value.length > 60) {
return [ValidationError.create('too_long', 'constraints', '制約は60文字以内で入力してください')];
}
return [];
};
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Error Handling Utilities
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
const ValidationError = {
create: (type, field, message) => ({
type, field, message
})
};
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Public API - Term Model Interface
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/**
* Value Object Constructors
*/
export const Values = {
IssueText,
ContextText,
ConstraintText
};
// Export constructors directly
export { IssueText, ContextText, ConstraintText };
//# sourceMappingURL=issue-definition.js.map