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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,16 @@ var MyAliasActionName = CfnLambda.SDKAlias({ // Like Create, Update, Delete
'TheSDKMethod',
'**UsedBeforeMapKeys**'
],
returnKeys: [
returnAttrs: [
'KeysFrom',
'SDKReturnValue',
'ToUseWithCfn',
'Fn::GetAttr'
'Fn::GetAttr',
'You.Can.Access.Nested.Properties.As.Well'
],
ignoreErrorCodes: [IntegerCodeToIgnore, ExWouldBe404ForDeleteOps],
physicalIdAs: 'UsePhysicalIdAsThisKeyInSDKCall',
// physicalIdAs: 'OrUseNested.Property.Using.Dot.Notation'
});

// Then...
Expand Down
26 changes: 21 additions & 5 deletions src/SDKAlias.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,27 @@ function isIgnorable(ignorableErrorCodes, errObject) {


function accessFunction(key) {
return function(data) {
return data == null
? undefined
: data[key];
var actualKey = key;
var getDataSimple = function(data) {
return data == null ?
undefined :
data[actualKey];
};

function getDataRecursive(data) {
if (actualKey.includes('.')) {
var pathTokens = actualKey.split('.'),
firstElem = pathTokens[0],
childData = data[firstElem],
childPath = pathTokens.slice(1).join('.');

actualKey = childPath;
return getDataRecursive(childData);
}
return getDataSimple(data);
};

return getDataRecursive;
}

function forcePaths(params, pathSet, translator) {
Expand Down Expand Up @@ -187,7 +203,7 @@ function noop() {

function keyFilter(includedKeySet, hash) {
return includedKeySet.reduce(function(fHash, key) {
fHash[key] = hash[key];
fHash[key] = accessFunction(key)(hash);
return fHash;
}, {});
}