diff --git a/lib/Endpoint.js b/lib/Endpoint.js index 81aff7ed0..32adb3a4a 100644 --- a/lib/Endpoint.js +++ b/lib/Endpoint.js @@ -46,7 +46,10 @@ module.exports = function(S) { } toObject() { - return S.utils.exportObject(_.cloneDeep(this)); + let clone = _.cloneDeep(this); + clone.endpointName = this.getName(); + clone.name = this.getFunction().getName(); // TODO Remove, legacy tight coupling of functions with endpoints. Make supplying this contingent on coupling? + return S.utils.exportObject(clone); } toObjectPopulated(options) { @@ -90,4 +93,4 @@ module.exports = function(S) { return Endpoint; -}; \ No newline at end of file +}; diff --git a/lib/Event.js b/lib/Event.js index f6a7515f4..31293b832 100644 --- a/lib/Event.js +++ b/lib/Event.js @@ -32,7 +32,10 @@ module.exports = function(S) { } toObject() { - return S.utils.exportObject(_.cloneDeep(this)); + let clone = _.cloneDeep(this); + clone.eventName = this.getName(); + clone.name = this.getFunction().getName(); // TODO Remove, legacy tight coupling of functions with endpoints. Make supplying this contingent on coupling? + return S.utils.exportObject(clone); } toObjectPopulated(options) { @@ -57,6 +60,10 @@ module.exports = function(S) { return _.assign(this, data); } + getName() { + return this.name; + } + getProject() { return S.getProject(); } @@ -73,4 +80,4 @@ module.exports = function(S) { return Event; -}; \ No newline at end of file +}; diff --git a/lib/actions/EndpointBuildApiGateway.js b/lib/actions/EndpointBuildApiGateway.js index ee23f042c..54da814b7 100644 --- a/lib/actions/EndpointBuildApiGateway.js +++ b/lib/actions/EndpointBuildApiGateway.js @@ -139,9 +139,6 @@ module.exports = function(S) { if (!_this.endpoint) BbPromise.reject(new SError(`Endpoint could not be found: ${_this.evt.options.endpointPath}#${_this.evt.options.endpointMethod}`)); - // Set name variable in endpoint - _this.endpoint.name = _this.endpoint.getFunction().name; // the name of the function is a reserved variable that may be used to populate a value within the endpoint - // Set function name _this.functionName = _this.endpoint.getFunction().getDeployedName({ stage: _this.evt.options.stage, diff --git a/lib/utils/index.js b/lib/utils/index.js index 73436ed7a..e6d0c31b3 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -336,7 +336,10 @@ module.exports = { } // Reserved Variables - if (variableName === 'name' && data.name) value = data.name; + if (variableName === 'name' && data.name) value = data.name; // TODO Remove legacy variable that is semantically the functionName? + if (variableName === 'functionName' && data.functionName) value = data.functionName; + if (variableName === 'endpointName' && data.endpointName) value = data.endpointName; + if (variableName === 'eventName' && data.eventName) value = data.eventName; // Populate if (!value && !value !== "") {