diff --git a/package.json b/package.json index 4f7ec8e..e0e958a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@inquirer/prompts": "^7.2.0", "@oclif/core": "^4", "@oclif/multi-stage-output": "^0.7.12", - "@salesforce/agents": "^0.5.2", + "@salesforce/agents": "^0.5.3", "@salesforce/core": "^8.8.0", "@salesforce/kit": "^3.2.1", "@salesforce/sf-plugins-core": "^12.1.0", diff --git a/src/commands/agent/generate/test-set.ts b/src/commands/agent/generate/test-set.ts index c1de7a5..aeeca15 100644 --- a/src/commands/agent/generate/test-set.ts +++ b/src/commands/agent/generate/test-set.ts @@ -28,6 +28,10 @@ export type TestSetInputs = { topicSequenceExpectedValue: string; }; +function castArray(value: T | T[]): T[] { + return Array.isArray(value) ? value : [value]; +} + async function promptForTestCase(genAiPlugins: Record): Promise { const utterance = await input({ message: 'Utterance', @@ -96,7 +100,7 @@ async function promptForTestCase(genAiPlugins: Record): Promise< const genAiPluginXml = await readFile(genAiPlugins[topicSequenceExpectedValue], 'utf-8'); const parser = new XMLParser(); const parsed = parser.parse(genAiPluginXml) as { GenAiPlugin: { genAiFunctions: Array<{ functionName: string }> } }; - const actions = parsed.GenAiPlugin.genAiFunctions.map((f) => f.functionName); + const actions = castArray(parsed.GenAiPlugin.genAiFunctions).map((f) => f.functionName); let actionSequenceExpectedValue = await checkbox({ message: 'Expected action(s)', @@ -160,14 +164,22 @@ export default class AgentGenerateTestset extends SfCommand { public async run(): Promise { const testSetName = await input({ message: 'What is the name of this set of test cases', - // TODO: add back validation once we refine the regex - // validate(d: string): boolean | string { - // // check against FORTY_CHAR_API_NAME_REGEX - // if (!FORTY_CHAR_API_NAME_REGEX.test(d)) { - // return 'The non-namespaced portion an API name must begin with a letter, contain only letters, numbers, and underscores, not contain consecutive underscores, and not end with an underscore.'; - // } - // return true; - // }, + + validate(d: string): boolean | string { + // ensure that it's not empty + if (!d.length) { + return 'Name cannot be empty'; + } + + return true; + + // TODO: add back validation once we refine the regex + // check against FORTY_CHAR_API_NAME_REGEX + // if (!FORTY_CHAR_API_NAME_REGEX.test(d)) { + // return 'The non-namespaced portion an API name must begin with a letter, contain only letters, numbers, and underscores, not contain consecutive underscores, and not end with an underscore.'; + // } + // return true; + }, }); const genAiPluginDir = join('force-app', 'main', 'default', 'genAiPlugins'); diff --git a/yarn.lock b/yarn.lock index 01aa9b3..7dd2f42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1483,10 +1483,10 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@salesforce/agents@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.2.tgz#b60e7227a78e3c4431565ba6e3862aa97c65306f" - integrity sha512-Khr24nZlV875PPwrmFjfDBSMi7Hqfrb6+Y+d8I4OHMU7iP+U9lnvRAwczD9o+WB5gq6WSCkhgQY89QmAA55dKw== +"@salesforce/agents@^0.5.3": + version "0.5.3" + resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.5.3.tgz#e6761df2abebc2317495e1ee18df42e6766c21be" + integrity sha512-en/nJAKm5WRB6GwxE83H0dM3rlOr9nDrGEU7LsQHNkEwEZ/mPAk1MF9r/0KLE7iLuN8638HMmOTHd3jp6YghRw== dependencies: "@oclif/table" "^0.3.5" "@salesforce/core" "^8.8.0"