Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@
],
"plugin": "@salesforce/plugin-orchestrator"
},
{
"alias": [],
"command": "orchestrator:rules:eval",
"flagAliases": [],
"flagChars": ["o", "r", "t", "v"],
"flags": ["api-version", "flags-dir", "json", "rules", "target-org", "template-info", "variables"],
"plugin": "@salesforce/plugin-orchestrator"
},
{
"alias": [],
"command": "orchestrator:template:create",
Expand All @@ -95,20 +103,12 @@
"flags": ["api-version", "flags-dir", "json", "target-org", "template-id", "template-name"],
"plugin": "@salesforce/plugin-orchestrator"
},
{
"alias": [],
"command": "orchestrator:template:eval",
"flagAliases": [],
"flagChars": ["d", "o", "r", "v"],
"flags": ["api-version", "definition-file", "document-file", "flags-dir", "json", "target-org", "values-file"],
"plugin": "@salesforce/plugin-orchestrator"
},
{
"alias": [],
"command": "orchestrator:template:list",
"flagAliases": [],
"flagChars": ["o"],
"flags": ["api-version", "flags-dir", "json", "target-org"],
"flags": ["all", "api-version", "flags-dir", "json", "target-org"],
"plugin": "@salesforce/plugin-orchestrator"
},
{
Expand Down
22 changes: 22 additions & 0 deletions messages/appframework.list.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ List all available templates in the target org.

Templates are reusable configurations that define the structure and settings for creating orchestrated apps. Use this command to discover available templates in your org before creating new apps.

By default, this command only shows custom templates created in your org. Standard Salesforce-provided templates are filtered out to reduce noise. Use the --all flag to include all templates including the standard ones.

Templates are displayed in a table format showing their name, label, ID, type, and other metadata. This information helps you choose the right template for your orchestrated app development.

You must have Data Cloud and Tableau Next enabled in your org and the AppFrameworkViewApp user permission to view templates. This command works with production orgs, sandboxes, and scratch orgs.
Expand All @@ -28,6 +30,14 @@ You must have Data Cloud and Tableau Next enabled in your org and the AppFramewo

<%= config.bin %> <%= command.id %> --target-org mySandbox --api-version 60.0

- List all templates including standard Salesforce templates:

<%= config.bin %> <%= command.id %> --all

- List all templates in a specific org:

<%= config.bin %> <%= command.id %> --target-org myOrg --all

# flags.target-org.summary

Login username or alias for the target org.
Expand All @@ -44,6 +54,14 @@ Override the API version used for API requests.

Override the API version used for orchestrator API requests. Use this flag to specify a particular API version when the default version doesn't work with your org's configuration.

# flags.all.summary

Show all templates including standard Salesforce templates.

# flags.all.description

By default, this command only shows custom templates created in your org. Use this flag to include the standard Salesforce-provided templates (those starting with 'sfdc_internal\_\_') in the results.

# templatesFound

Found %s templates:
Expand All @@ -52,6 +70,10 @@ Found %s templates:

No templates found.

# noCustomTemplatesFound

No custom templates found. Use --all to include standard Salesforce templates.

# fetchingTemplates

Fetching templates...
Expand Down
55 changes: 55 additions & 0 deletions messages/orchestrator.rules.eval.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# summary

Test JSON transformation rules using the jsonxform/transformation endpoint.

# description

Preview how transformation rules will modify JSON documents before deploying templates. This command uses a sample transformation to test the jsonxform/transformation endpoint with built-in User and Org context variables.

# flags.target-org.summary

Username or alias for the target org; overrides default target org.

# flags.target-org.description

The username or alias of the target org where the jsonxform/transformation endpoint will be called. This org provides the User and Org context variables used in the transformation.

# flags.api-version.summary

Override the api version used for api requests made by this command.

# flags.api-version.description

API version to use for the transformation request. Defaults to the org's configured API version.

# flags.template-info.summary

Path to Analytics template-info.json file.

# flags.template-info.description

Path to the template-info.json file containing the base JSON document structure that will be transformed.

# flags.variables.summary

Path to Analytics variables.json file.

# flags.variables.description

Path to the variables.json file containing variable definitions used in transformations.

# flags.rules.summary

Path to Analytics rules.json file.

# flags.rules.description

Path to the rules.json file containing transformation rules and macro definitions.

# examples

- Test JSON transformation with Analytics template files:
<%= config.bin %> <%= command.id %> --template-info ./template-info.json --variables ./variables.json --rules ./rules.json --target-org myorg

- Test with specific API version:
<%= config.bin %> <%= command.id %> --template-info ./template-info.json --variables ./variables.json --rules ./rules.json --target-org myorg --api-version 60.0
58 changes: 0 additions & 58 deletions messages/orchestrator.template.eval.md

This file was deleted.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@salesforce/plugin-orchestrator",
"description": "Plugin for working with SalesForce analytic apps, templates, assets and services.",
"version": "1.1.0",
"version": "1.1.1",
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
Expand Down Expand Up @@ -62,6 +62,9 @@
"subtopics": {
"app": {
"external": true
},
"rules": {
"external": true
}
}
},
Expand All @@ -71,6 +74,9 @@
"orchestrator:template": {
"description": "Work with templates"
},
"orchestrator:rules": {
"description": "Work with transformation rules"
},
"template": {
"description": "description for template"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages, Connection } from '@salesforce/core';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-orchestrator', 'orchestrator.template.eval');
const messages = Messages.loadMessages('@salesforce/plugin-orchestrator', 'orchestrator.rules.eval');

type TransformationPayload = {
document: {
Expand Down Expand Up @@ -85,23 +85,23 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
summary: messages.getMessage('flags.api-version.summary'),
description: messages.getMessage('flags.api-version.description'),
}),
'document-file': Flags.file({
char: 'd',
summary: messages.getMessage('flags.document-file.summary'),
description: messages.getMessage('flags.document-file.description'),
'template-info': Flags.file({
char: 't',
summary: messages.getMessage('flags.template-info.summary'),
description: messages.getMessage('flags.template-info.description'),
required: true,
}),
'values-file': Flags.file({
variables: Flags.file({
char: 'v',
summary: messages.getMessage('flags.values-file.summary'),
description: messages.getMessage('flags.values-file.description'),
dependsOn: ['document-file'],
summary: messages.getMessage('flags.variables.summary'),
description: messages.getMessage('flags.variables.description'),
required: true,
}),
'definition-file': Flags.file({
rules: Flags.file({
char: 'r',
summary: messages.getMessage('flags.definition-file.summary'),
description: messages.getMessage('flags.definition-file.description'),
dependsOn: ['document-file'],
summary: messages.getMessage('flags.rules.summary'),
description: messages.getMessage('flags.rules.description'),
required: true,
}),
};

Expand Down Expand Up @@ -159,51 +159,41 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
}
}

private async getTemplatePayload(flags: {
'document-file': string;
'values-file'?: string;
'definition-file'?: string;
}): Promise<{
private async getTemplatePayload(flags: { 'template-info': string; variables: string; rules: string }): Promise<{
template: TemplateInfo;
payload: TransformationPayload;
}> {
return this.getDirectFilePayload(flags['document-file'], flags['values-file'], flags['definition-file']);
return this.getDirectFilePayload(flags['template-info'], flags['variables'], flags['rules']);
}

private async getDirectFilePayload(
documentFile: string,
valuesFile?: string,
definitionFile?: string
templateInfoFile: string,
variablesFile: string,
rulesFile: string
): Promise<{
template: TemplateInfo;
payload: TransformationPayload;
}> {
this.log(`Loading document: ${documentFile}`);

// Read and parse the document file
const documentContent = await fs.readFile(documentFile, 'utf8');
const document = JSON.parse(documentContent) as unknown;

// Read values file if provided, otherwise use empty object
let values = { Variables: { hello: 'world' } };
if (valuesFile) {
this.log(`Loading values: ${valuesFile}`);
const valuesContent = await fs.readFile(valuesFile, 'utf8');
values = JSON.parse(valuesContent) as typeof values;
}
this.log(`Loading template info: ${templateInfoFile}`);

// Read definition file if provided, otherwise use empty rules
let definition = { rules: [] };
if (definitionFile) {
this.log(`Loading definition: ${definitionFile}`);
const definitionContent = await fs.readFile(definitionFile, 'utf8');
definition = JSON.parse(definitionContent) as typeof definition;
}
// Read and parse the template-info file
const templateInfoContent = await fs.readFile(templateInfoFile, 'utf8');
const document = JSON.parse(templateInfoContent) as unknown;

// Read variables file
this.log(`Loading variables: ${variablesFile}`);
const variablesContent = await fs.readFile(variablesFile, 'utf8');
const values = JSON.parse(variablesContent) as { Variables: Record<string, unknown> };

// Read rules file
this.log(`Loading rules: ${rulesFile}`);
const rulesContent = await fs.readFile(rulesFile, 'utf8');
const definition = JSON.parse(rulesContent) as { rules: unknown[] };

return {
template: {
name: 'Direct Files',
path: documentFile,
path: templateInfoFile,
source: 'local' as const,
},
payload: {
Expand Down
15 changes: 13 additions & 2 deletions src/commands/orchestrator/template/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export default class ListTemplate extends SfCommand<TemplateData[]> {
summary: messages.getMessage('flags.api-version.summary'),
description: messages.getMessage('flags.api-version.description'),
}),
all: Flags.boolean({
summary: messages.getMessage('flags.all.summary'),
description: messages.getMessage('flags.all.description'),
default: false,
}),
};

public async run(): Promise<TemplateData[]> {
Expand All @@ -56,12 +61,18 @@ export default class ListTemplate extends SfCommand<TemplateData[]> {
const rawTemplates = await appFrameworkTemplate.list();
this.spinner.stop();

const templates = TemplateListUtil.processTemplates(rawTemplates);
let templates = TemplateListUtil.processTemplates(rawTemplates);

// Filter out standard templates by default unless --all flag is used
if (!flags.all) {
templates = templates.filter((template) => !template.name?.startsWith('sfdc_internal__'));
}

if (templates.length > 0) {
TemplateDisplayUtil.displayTemplateList(this, templates);
} else {
this.log(messages.getMessage('noResultsFound'));
const messageKey = flags.all ? 'noResultsFound' : 'noCustomTemplatesFound';
this.log(messages.getMessage(messageKey));
}

return templates;
Expand Down
Loading
Loading