Skip to content

Commit fb49425

Browse files
chore: update MD defininition?
1 parent c03587b commit fb49425

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/commands/agent/generate/template.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ import type {
2323
Bot,
2424
BotVersion,
2525
BotTemplate,
26-
GenAiPlanner,
2726
BotDialogGroup,
27+
GenAiPlannerBundle,
2828
ConversationDefinitionGoal,
2929
ConversationVariable,
3030
} from '@salesforce/types/metadata';
3131

32-
export type GenAiPlannerBundleExt = {
33-
GenAiPlannerBundle: GenAiPlanner & { botTemplate?: string };
34-
};
35-
3632
export type BotTemplateExt = {
3733
'?xml': { '@_version': '1.0'; '@_encoding': 'UTF-8' };
3834
BotTemplate: Omit<BotTemplate, 'botDialogGroups' | 'conversationGoals' | 'conversationVariables'> & {
@@ -114,18 +110,18 @@ export default class AgentGenerateTemplate extends SfCommand<AgentGenerateTempla
114110
// Parse the metadata files as JSON
115111
const botJson = xmlToJson<BotExt>(join(botDir, `${botName}.bot-meta.xml`), parser);
116112
const botVersionJson = xmlToJson<BotVersionExt>(join(botDir, `v${botVersion}.botVersion-meta.xml`), parser);
117-
const genAiPlannerBundleMetaJson = xmlToJson<GenAiPlannerBundleExt>(
113+
const genAiPlannerBundleMetaJson = xmlToJson<GenAiPlannerBundle>(
118114
join(genAiPlannerBundleDir, botName, `${botName}.genAiPlannerBundle`),
119115
parser
120116
);
121117

122118
// Modify the metadata files for final output
123119
// TODO: Confirm this name (might be conversationDefinitionPlanners)
124-
genAiPlannerBundleMetaJson.GenAiPlannerBundle.botTemplate = finalFilename;
120+
genAiPlannerBundleMetaJson.botTemplate = finalFilename;
125121
const botTemplate = convertBotToBotTemplate(botJson, botVersionJson, finalFilename, botTemplateFilePath);
126122

127123
// Build and save the metadata files
128-
jsonToXml<GenAiPlannerBundleExt>(clonedGenAiPlannerBundleFilePath, genAiPlannerBundleMetaJson, builder);
124+
jsonToXml<GenAiPlannerBundle>(clonedGenAiPlannerBundleFilePath, genAiPlannerBundleMetaJson, builder);
129125
jsonToXml<BotTemplateExt>(botTemplateFilePath, botTemplate, builder);
130126

131127
this.log(`\nSaved BotTemplate to:\n - ${botTemplateFilePath}`);

test/nuts/shared-setup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { join } from 'node:path';
18-
import { Duration, TestSession } from '@salesforce/cli-plugins-testkit';
18+
import { Duration, TestSession, execCmd } from '@salesforce/cli-plugins-testkit';
1919
import { ComponentSetBuilder, RequestStatus, type ScopedPostDeploy } from '@salesforce/source-deploy-retrieve';
2020
import { Org, SfError, User, Lifecycle, Connection } from '@salesforce/core';
2121
import { sleep, ensureArray } from '@salesforce/kit';
@@ -113,8 +113,9 @@ export async function getTestSession(): Promise<TestSession> {
113113

114114
// Create agent user using the new CLI command
115115
console.log('Creating agent user...');
116-
const agentUserResult = await session.exec<{ username: string }>(
117-
`org create agent-user --target-org ${defaultOrg.username} --json`
116+
const agentUserResult = execCmd<{ username: string }>(
117+
`org create agent-user --target-org ${defaultOrg.username} --json`,
118+
{ ensureExitCode: 0 }
118119
);
119120

120121
if (!agentUserResult.jsonOutput?.result?.username) {

test/nuts/template.nut.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ import { readFileSync } from 'node:fs';
1818
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
1919
import { XMLParser } from 'fast-xml-parser';
2020
import { expect } from 'chai';
21-
import {
22-
AgentGenerateTemplateResult,
23-
BotTemplateExt,
24-
GenAiPlannerBundleExt,
25-
} from '../../src/commands/agent/generate/template.js';
21+
import { GenAiPlannerBundle } from '@salesforce/types/metadata';
22+
import { AgentGenerateTemplateResult, BotTemplateExt } from '../../src/commands/agent/generate/template.js';
2623
import { getTestSession } from './shared-setup.js';
2724

2825
describe('agent generate template NUTs', function () {
@@ -123,10 +120,10 @@ describe('agent generate template NUTs', function () {
123120

124121
const generatedGenAiPlannerBundleFile = parser.parse(
125122
readFileSync(generatedGenAiPlannerBundleFilePath, 'utf-8')
126-
) as GenAiPlannerBundleExt;
123+
) as GenAiPlannerBundle;
127124
const mockGenAiPlannerBundleFile = parser.parse(
128125
readFileSync(mockGenAiPlannerBundleFilePath, 'utf-8')
129-
) as GenAiPlannerBundleExt;
126+
) as GenAiPlannerBundle;
130127
expect(generatedGenAiPlannerBundleFile).to.deep.equal(mockGenAiPlannerBundleFile);
131128
});
132129
});

0 commit comments

Comments
 (0)