@deliverr/serverless-offline-step-functions
Version:
Serverless Offline Plugin to Support Step Functions for Local Development
37 lines (36 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayloadTemplate = void 0;
class PayloadTemplate {
isPathKey(path) {
return path.endsWith('.$');
}
isContextObjectPath(path) {
return path.startsWith('$$.');
}
processPayloadTemplateEntry(key, value, inputJson) {
if (this.isPathKey(key)) {
return this.processPathKey(key, value, inputJson);
}
if (typeof value === 'object' && value !== null) {
return {
[key]: this.processPayloadTemplate(inputJson, value),
};
}
return { [key]: value };
}
processPayloadTemplate(inputJson, payload) {
if (!payload) {
return {};
}
let output = {};
Object.entries(payload).forEach(([key, value]) => {
output = {
...output,
...this.processPayloadTemplateEntry(key, value, inputJson),
};
});
return output;
}
}
exports.PayloadTemplate = PayloadTemplate;