forcedotcom/sf-skills / plugins/builder/consumer-goods/skills/consumer-goods-accruals-datakit-deploy
consumer-goods-accruals-datakit-deploy
VerifiedUse this skill to deploy the TPM Liability Accruals data kit end to end to a Salesforce org. Invoke when a customer or teammate wants to install the accrual engine, verify the Data Cloud connection, deploy the Data Kit components, and schedule the export and accrual calculation chain. Trigger phrases include: 'deploy the accrual data kit', 'set up liability accruals', 'install TPM accruals', 'headless accruals setup', 'configure the Data Cloud export connector', 'schedule the accrual chain'. Do NOT use for creating a Data Space alone (use platform-dataspace-access-configure), for generic Salesforce metadata deployment (use platform-metadata-deploy), for querying org data only (use platform-soql-query), or when setting up the data kit for the Trade Promotion Effectiveness (TPE) feature (use consumer-goods-tpe-datakit-deploy instead).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 18.9 KB |
| scripts/setup.jsexecutable | script | 10.9 KB |
| scripts/steps/00-check-prerequisites.js | script | 1.9 KB |
| scripts/steps/01-download-static-resource.js | script | 3.5 KB |
| scripts/steps/02-replace-org-id.js | script | 1.6 KB |
| scripts/steps/03-deploy-metadata.js | script | 1.1 KB |
| scripts/steps/04-deploy-engine.js | script | 6.7 KB |
| scripts/steps/05-deploy-tpm-accruals.js | script | 8.9 KB |
| scripts/steps/06-create-dataspace.js | script | 2.0 KB |
| scripts/steps/07-deploy-accruals-reports.js | script | 8.5 KB |
| scripts/steps/08-deploy-ui.js | script | 8.1 KB |
| scripts/steps/09-completion.js | script | 2.5 KB |
| scripts/steps/utils.js | script | 15.8 KB |
scripts/steps/04-deploy-engine.js
View on GitHubconst { execFileSync } = require('child_process');
const fs = require('fs');
const os = require('os');
const path = require('path');
const {
exec,
getOrgDetails,
getMaxCreatedDate,
getDeploymentLogForComponents,
getDeployedComponents,
waitForDeploymentCompletion,
} = require('./utils');
/**
* Build component specs (id + names to match in DataKitDeploymentLog) for each
* component in a deployment payload.
*/
function buildComponentSpecs(payload) {
const specs = [];
const components =
payload && payload.inputs && payload.inputs[0] && payload.inputs[0].dataKitComponentsInput
? payload.inputs[0].dataKitComponentsInput
: [];
components.forEach(component => {
if (component.dloConfig) {
specs.push({
id: component.dloConfig.apiName,
type: 'DataLakeObject',
names: [component.dloConfig.apiName, component.dloConfig.dataSourceObjectDevName].filter(Boolean),
});
} else if (component.dataTransformConfig) {
specs.push({
id: component.dataTransformConfig.apiName || component.dataTransformConfig.dataTransformDevName,
type: 'DataTransform',
names: [
component.dataTransformConfig.apiName,
component.dataTransformConfig.dataTransformDevName,
].filter(Boolean),
});
} else if (component.bundleConfig) {
specs.push({
id: component.bundleConfig.bundleName,
type: 'DataStreamBundle',
names: [component.bundleConfig.bundleName].filter(Boolean),
});
}
});
return specs;
}
/**
* Step 4: Deploy Liability Accruals Engine data kit
* @param {string} orgAlias - The Salesforce org alias
* @param {string} scriptsDir - Path to the scripts directory
* @param {string} orgId - The Salesforce org ID
* @param {string} namespace - Org namespace prefix (e.g. "cgcloud_dev__"), or '' for unmanaged orgs
* @param {boolean} dryRun - If true, skip actual deployment
*/
async function deployEngine(orgAlias, scriptsDir, orgId, namespace = '', dryRun = false) {
console.log('\n=== Step 4: Deploying Liability Accruals Engine ===');
const dataKitName = 'LiabilityAccrualsEngine';
const payloadPath = path.join(scriptsDir, 'engine-deployment-payload.json');
console.log(`Payload: ${payloadPath}`);
if (namespace) {
console.log(`Org namespace: ${namespace}`);
}
const payload = JSON.parse(fs.readFileSync(payloadPath, 'utf8'));
const originalPayload = JSON.parse(JSON.stringify(payload));
const allComponentSpecs = buildComponentSpecs(payload);
const deploymentLog = getDeploymentLogForComponents(orgAlias, allComponentSpecs);
const deployedIds = getDeployedComponents(deploymentLog, allComponentSpecs, namespace);
if (deployedIds.size > 0) {
console.log(`Found ${deployedIds.size} already deployed components:`);
deployedIds.forEach(comp => console.log(` - ${comp}`));
}
const components = payload.inputs[0].dataKitComponentsInput;
const componentsToSkip = new Set();
components.forEach((component, index) => {
let identifier = '';
if (component.dloConfig) {
identifier = component.dloConfig.apiName;
} else if (component.dataTransformConfig) {
identifier =
component.dataTransformConfig.apiName || component.dataTransformConfig.dataTransformDevName;
} else if (component.bundleConfig) {
identifier = component.bundleConfig.bundleName;
}
if (identifier && deployedIds.has(identifier)) {
componentsToSkip.add(index);
}
});
if (componentsToSkip.size > 0) {
console.log(`Skipping ${componentsToSkip.size} already deployed components`);
payload.inputs[0].dataKitComponentsInput = components.filter(
(_, index) => !componentsToSkip.has(index),
);
}
const componentCount = payload.inputs[0].dataKitComponentsInput.length;
if (componentCount === 0) {
console.log(`[OK] All components already deployed, skipping ${dataKitName}\n`);
return;
}
console.log(`${dryRun ? 'Would deploy' : 'Deploying'} ${componentCount} components...`);
const componentSpecs = buildComponentSpecs(payload);
const payloadString = JSON.stringify(payload);
const updatedPayloadString = payloadString.replace(/<SF_ORG_ID>/g, orgId.slice(0, 15));
const updatedPayload = JSON.parse(updatedPayloadString);
if (dryRun) {
console.log('[DRY RUN] Skipping deployment - components that would be deployed:');
componentSpecs.forEach(spec => console.log(` - [${spec.type}] ${spec.id}`));
console.log(`[DRY RUN] Payload file: ${payloadPath}`);
console.log('[OK] Step 4 completed (dry run)\n');
return;
}
const backupPath = payloadPath + '.backup';
fs.writeFileSync(backupPath, JSON.stringify(originalPayload, null, 2));
try {
const orgDetails = getOrgDetails(orgAlias);
const url = `${orgDetails.instanceUrl}/services/data/v62.0/actions/custom/flow/sfdatakit__DeployDataKitComponents`;
// Capture the Salesforce server timestamp before triggering deploy so the
// poller uses WHERE CreatedDate >= deploymentStartTime (immune to local clock-skew).
let deploymentStartTime = '';
try {
deploymentStartTime = getMaxCreatedDate(orgAlias);
} catch (_) {
// If server-time query fails, fall back to no filter — better than crashing
}
const headerFile = path.join(os.tmpdir(), `sf-auth-${process.pid}.txt`);
const bodyFile = path.join(os.tmpdir(), `sf-body-${process.pid}.json`);
let response;
try {
fs.writeFileSync(
headerFile,
`Authorization: Bearer ${orgDetails.accessToken}\n`,
{ mode: 0o600 },
);
fs.writeFileSync(bodyFile, JSON.stringify(updatedPayload), { mode: 0o600 });
response = execFileSync(
'curl',
[
'-s',
'-X',
'POST',
url,
'--header',
`@${headerFile}`,
'-H',
'Content-Type: application/json',
'--data',
`@${bodyFile}`,
],
{ encoding: 'utf8' },
);
} finally {
try { fs.unlinkSync(headerFile); } catch (e) { console.warn(`Warning: failed to delete auth header file ${headerFile}: ${e.message}`); }
try { fs.unlinkSync(bodyFile); } catch (e) { console.warn(`Warning: failed to delete body file ${bodyFile}: ${e.message}`); }
}
const result = JSON.parse(response);
console.log('Deployment initiated');
if (result.isSuccess === false || result.errors) {
console.error('Deployment API returned errors:', result);
throw new Error('Deployment failed');
}
await waitForDeploymentCompletion(orgAlias, componentSpecs, deploymentStartTime, namespace);
} finally {
fs.writeFileSync(payloadPath, JSON.stringify(originalPayload, null, 2));
try {
fs.unlinkSync(backupPath);
} catch (_) {}
}
}
module.exports = deployEngine;
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |