diff --git a/command-snapshot.json b/command-snapshot.json index f9597b9..7180171 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -76,7 +76,7 @@ "command": "orchestrator:rules:eval", "flagAliases": [], "flagChars": ["d", "o", "r", "v"], - "flags": ["api-version", "document", "flags-dir", "json", "rules", "target-org", "variables"], + "flags": ["api-version", "document", "flags-dir", "json", "rules", "target-org", "values"], "plugin": "@salesforce/plugin-orchestrator" }, { diff --git a/messages/orchestrator.rules.eval.md b/messages/orchestrator.rules.eval.md index 53853e9..1524081 100644 --- a/messages/orchestrator.rules.eval.md +++ b/messages/orchestrator.rules.eval.md @@ -30,13 +30,13 @@ Path to JSON document file to transform. Path to the JSON document file (dashboard, lens, etc.) that will be transformed by the rules. -# flags.variables.summary +# flags.values.summary -Path to Analytics variables.json file. +Path to values JSON file. -# flags.variables.description +# flags.values.description -Path to the variables.json file containing variable definitions used in transformations. The file should contain a flat JSON object with key-value pairs. The CLI will automatically wrap these in the required Variables structure. +Path to the JSON file containing values used in transformations. Can contain any JSON structure that matches your transformation rules. # flags.rules.summary @@ -49,7 +49,7 @@ Path to the rules.json file containing transformation rules and macro definition # examples - Test JSON transformation with Analytics files: - <%= config.bin %> <%= command.id %> --document ./dashboard.json --variables ./variables.json --rules ./rules.json --target-org myorg + <%= config.bin %> <%= command.id %> --document ./dashboard.json --values ./values.json --rules ./rules.json --target-org myorg - Test with specific API version: - <%= config.bin %> <%= command.id %> --document ./dashboard.json --variables ./variables.json --rules ./rules.json --target-org myorg --api-version 60.0 + <%= config.bin %> <%= command.id %> --document ./dashboard.json --values ./values.json --rules ./rules.json --target-org myorg --api-version 60.0 diff --git a/src/commands/orchestrator/rules/eval.ts b/src/commands/orchestrator/rules/eval.ts index 94abe2d..45cf94e 100644 --- a/src/commands/orchestrator/rules/eval.ts +++ b/src/commands/orchestrator/rules/eval.ts @@ -36,11 +36,7 @@ type TransformationPayload = { namespace: string; }; }; - values: { - Variables: { - hello: string; - }; - }; + values: Record; definition: { rules: Array<{ name: string; @@ -91,10 +87,10 @@ export default class TemplateEval extends SfCommand { description: messages.getMessage('flags.document.description'), required: true, }), - variables: Flags.file({ + values: Flags.file({ char: 'v', - summary: messages.getMessage('flags.variables.summary'), - description: messages.getMessage('flags.variables.description'), + summary: messages.getMessage('flags.values.summary'), + description: messages.getMessage('flags.values.description'), required: true, }), rules: Flags.file({ @@ -159,16 +155,16 @@ export default class TemplateEval extends SfCommand { } } - private async getTemplatePayload(flags: { document: string; variables: string; rules: string }): Promise<{ + private async getTemplatePayload(flags: { document: string; values: string; rules: string }): Promise<{ template: TemplateInfo; payload: TransformationPayload; }> { - return this.getDirectFilePayload(flags.document, flags.variables, flags.rules); + return this.getDirectFilePayload(flags.document, flags.values, flags.rules); } private async getDirectFilePayload( documentFile: string, - variablesFile: string, + valuesFile: string, rulesFile: string ): Promise<{ template: TemplateInfo; @@ -180,12 +176,10 @@ export default class TemplateEval extends SfCommand { const documentContent = await fs.readFile(documentFile, 'utf8'); const document = JSON.parse(documentContent) as unknown; - // Read variables file - this.log(`Loading variables: ${variablesFile}`); - const variablesContent = await fs.readFile(variablesFile, 'utf8'); - const variablesData = JSON.parse(variablesContent) as Record; - - const values = { Variables: variablesData }; + // Read values file + this.log(`Loading values: ${valuesFile}`); + const valuesContent = await fs.readFile(valuesFile, 'utf8'); + const values = JSON.parse(valuesContent) as Record; // Read rules file this.log(`Loading rules: ${rulesFile}`); @@ -200,7 +194,7 @@ export default class TemplateEval extends SfCommand { }, payload: { document: document as TransformationPayload['document'], - values: values as TransformationPayload['values'], + values, definition: definition as TransformationPayload['definition'], }, };