Skip to content

Commit

Permalink
fix: add genAiFunction bundle type W-17750901 (#1499)
Browse files Browse the repository at this point in the history
* fix: add genAiFunction bundle type

* test: add UT

* test: add snapshot files
  • Loading branch information
WillieRuemmele authored Feb 4, 2025
1 parent b88281c commit fcf6662
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/filePathGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const filePathsFromMetadataComponent = (
['WaveTemplateBundle', [join(packageDirWithTypeDir, `${fullName}${sep}template-info.json`)]],
['LightningComponentBundle', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.js${META_XML_SUFFIX}`)]],
['AuraDefinitionBundle', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.cmp${META_XML_SUFFIX}`)]],
['GenAiFunction', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.genAiFunction${META_XML_SUFFIX}`)]],
[
'AppFrameworkTemplateBundle',
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Answers questions about company policies and procedures, troubleshooting steps, or product information. For example: “What is your return policy?” “How do I fix an issue?” or “What features does a product have?”</description>
<invocationTarget>knowledgeSearch</invocationTarget>
<invocationTargetType>standardInvocableAction</invocationTargetType>
<isConfirmationRequired>false</isConfirmationRequired>
<masterLabel>CustomKnowledgeAction_1738700253695</masterLabel>
</GenAiFunction>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"required": ["query"],
"unevaluatedProperties": false,
"properties": {
"query": {
"title": "Query",
"description": "Required. A string created by generative AI to be used in the knowledge article search.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsUrl": {
"title": "Citations Url",
"description": "The URL to use for citations for custom Agents.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"ragFeatureConfigId": {
"title": "RAG Feature Configuration Id",
"description": "The RAG Feature ID to use for grounding this copilot action invocation.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsEnabled": {
"title": "Citations Enabled",
"description": "Whether or not citations are enabled.",
"const": false,
"lightning:type": "lightning__booleanType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"mode": {
"title": "The mode to run in.",
"description": "The mode to use (Professor/Smart/Basic). Determines which prompt template to use.",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
},
"retrieverMode": {
"title": "The retriever mode to use.",
"description": "The retriever mode to use (Simple/Augmented). Determines whether to do query regeneration",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
}
},
"lightning:type": "lightning__objectType"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"unevaluatedProperties": false,
"properties": {
"knowledgeSummary": {
"title": "Knowledge Summary",
"description": "A string formatted as rich text that includes a summary of the information retrieved from the knowledge articles and citations to those articles.",
"lightning:type": "lightning__richTextType",
"lightning:isPII": false,
"copilotAction:isDisplayable": true,
"copilotAction:isUsedByPlanner": true
}
},
"lightning:type": "lightning__objectType"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>force-app</members>
<name>GenAiFunction</name>
</types>
<version>59.0</version>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Answers questions about company policies and procedures, troubleshooting steps, or product information. For example: “What is your return policy?” “How do I fix an issue?” or “What features does a product have?”</description>
<invocationTarget>knowledgeSearch</invocationTarget>
<invocationTargetType>standardInvocableAction</invocationTargetType>
<isConfirmationRequired>false</isConfirmationRequired>
<masterLabel>CustomKnowledgeAction_1738700253695</masterLabel>
</GenAiFunction>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"required": ["query"],
"unevaluatedProperties": false,
"properties": {
"query": {
"title": "Query",
"description": "Required. A string created by generative AI to be used in the knowledge article search.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsUrl": {
"title": "Citations Url",
"description": "The URL to use for citations for custom Agents.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"ragFeatureConfigId": {
"title": "RAG Feature Configuration Id",
"description": "The RAG Feature ID to use for grounding this copilot action invocation.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsEnabled": {
"title": "Citations Enabled",
"description": "Whether or not citations are enabled.",
"const": false,
"lightning:type": "lightning__booleanType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"mode": {
"title": "The mode to run in.",
"description": "The mode to use (Professor/Smart/Basic). Determines which prompt template to use.",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
},
"retrieverMode": {
"title": "The retriever mode to use.",
"description": "The retriever mode to use (Simple/Augmented). Determines whether to do query regeneration",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
}
},
"lightning:type": "lightning__objectType"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"unevaluatedProperties": false,
"properties": {
"knowledgeSummary": {
"title": "Knowledge Summary",
"description": "A string formatted as rich text that includes a summary of the information retrieved from the knowledge articles and citations to those articles.",
"lightning:type": "lightning__richTextType",
"lightning:isPII": false,
"copilotAction:isDisplayable": true,
"copilotAction:isUsedByPlanner": true
}
},
"lightning:type": "lightning__objectType"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Answers questions about company policies and procedures, troubleshooting steps, or product information. For example: “What is your return policy?” “How do I fix an issue?” or “What features does a product have?”</description>
<invocationTarget>knowledgeSearch</invocationTarget>
<invocationTargetType>standardInvocableAction</invocationTargetType>
<isConfirmationRequired>false</isConfirmationRequired>
<masterLabel>CustomKnowledgeAction_1738700253695</masterLabel>
</GenAiFunction>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"required": ["query"],
"unevaluatedProperties": false,
"properties": {
"query": {
"title": "Query",
"description": "Required. A string created by generative AI to be used in the knowledge article search.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsUrl": {
"title": "Citations Url",
"description": "The URL to use for citations for custom Agents.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"ragFeatureConfigId": {
"title": "RAG Feature Configuration Id",
"description": "The RAG Feature ID to use for grounding this copilot action invocation.",
"const": "",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"citationsEnabled": {
"title": "Citations Enabled",
"description": "Whether or not citations are enabled.",
"const": false,
"lightning:type": "lightning__booleanType",
"lightning:isPII": false,
"copilotAction:isUserInput": true
},
"mode": {
"title": "The mode to run in.",
"description": "The mode to use (Professor/Smart/Basic). Determines which prompt template to use.",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
},
"retrieverMode": {
"title": "The retriever mode to use.",
"description": "The retriever mode to use (Simple/Augmented). Determines whether to do query regeneration",
"lightning:type": "lightning__textType",
"lightning:isPII": false,
"copilotAction:isUserInput": false
}
},
"lightning:type": "lightning__objectType"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"unevaluatedProperties": false,
"properties": {
"knowledgeSummary": {
"title": "Knowledge Summary",
"description": "A string formatted as rich text that includes a summary of the information retrieved from the knowledge articles and citations to those articles.",
"lightning:type": "lightning__richTextType",
"lightning:isPII": false,
"copilotAction:isDisplayable": true,
"copilotAction:isUsedByPlanner": true
}
},
"lightning:type": "lightning__objectType"
}
9 changes: 9 additions & 0 deletions test/snapshot/sampleProjects/genAiFunctions/sfdx-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"packageDirectories": [
{
"default": true,
"path": "force-app"
}
],
"sourceApiVersion": "59.0"
}
52 changes: 52 additions & 0 deletions test/snapshot/sampleProjects/genAiFunctions/snapshot.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import {
FORCE_APP,
dirsAreIdentical,
fileSnap,
mdapiToSource,
sourceToMdapi,
MDAPI_OUT,
} from '../../helper/conversions';

// we don't want failing tests outputting over each other
/* eslint-disable no-await-in-loop */

describe('genAiFunctions', () => {
const testDir = path.join('test', 'snapshot', 'sampleProjects', 'genAiFunctions');
let sourceFiles: string[];
let mdFiles: string[];

before(async () => {
await fs.promises.mkdir(path.join(testDir, FORCE_APP), { recursive: true });
sourceFiles = await mdapiToSource(testDir);
mdFiles = await sourceToMdapi(testDir);
});
it('verify source files', async () => {
for (const file of sourceFiles) {
await fileSnap(file, testDir);
}
await dirsAreIdentical(
path.join(testDir, FORCE_APP),
path.join(testDir, '__snapshots__', 'verify-source-files.expected', FORCE_APP)
);
});
it('verify md files', async () => {
for (const file of mdFiles) {
await fileSnap(file, testDir);
}
});

after(async () => {
await Promise.all([
fs.promises.rm(path.join(testDir, FORCE_APP), { recursive: true, force: true }),
fs.promises.rm(path.join(testDir, MDAPI_OUT), { recursive: true, force: true }),
]);
});
});
22 changes: 22 additions & 0 deletions test/utils/filePathGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@ const testData = {
},
],
},
genAiFunction: {
fullName: 'CustomKnowledgeAction_1738700253695',
typeName: 'genAiFunction',
expectedFilePaths: [
getFilePath(
'genAiFunctions/CustomKnowledgeAction_1738700253695/CustomKnowledgeAction_1738700253695.genAiFunction-meta.xml'
),
],
expectedComponents: [
{
name: 'CustomKnowledgeAction_1738700253695',
type: registryAccess.getTypeByName('GenAiFunction'),
xml: getFilePath(
'genAiFunctions/CustomKnowledgeAction_1738700253695/CustomKnowledgeAction_1738700253695.genAiFunction-meta.xml'
),
},
],
},
};

describe('generating virtual tree from component name/type', () => {
Expand Down Expand Up @@ -310,6 +328,10 @@ describe('generating virtual tree from component name/type', () => {
runTest(testData.bundleLwc);
});

it('genAiFunction', () => {
runTest(testData.genAiFunction);
});

it('aura', () => {
runTest(testData.bundleAura);
});
Expand Down

0 comments on commit fcf6662

Please sign in to comment.