aws-collection-stream
Advanced tools
Comparing version 0.0.7 to 0.0.8
29
index.js
@@ -5,3 +5,11 @@ const H = require ( 'highland' ); | ||
const serviceSpecificEdgeCaseTransform = serviceHostName => { | ||
return { | ||
'cloudfront.amazonaws.com': R.prop ( 'DistributionList' ) | ||
}[serviceHostName] || R.identity; | ||
}; | ||
const caughtWrap = ( { serviceObject, serviceMethod } ) => { | ||
const ecTransform = serviceSpecificEdgeCaseTransform ( serviceObject.endpoint.hostname ); | ||
return parms => { | ||
@@ -17,5 +25,6 @@ return H.wrapCallback ( ( parms, callback ) => { | ||
push ( null, 'ThrottlingException' ) : | ||
push ( error ) ) | ||
push ( error ) | ||
) | ||
.flatMap ( e => { | ||
if ( R.type ( e ) === 'String' && e === 'ThrottlingException' ) { | ||
if ( e === 'ThrottlingException' ) { | ||
return H ( ( push, next ) => setTimeout ( () => next ( | ||
@@ -26,3 +35,3 @@ caughtWrap ( { serviceObject, serviceMethod } )( parms ) | ||
return H ( [ e ] ); | ||
return H ( [ ecTransform ( e ) ] ); | ||
} ); | ||
@@ -32,2 +41,12 @@ }; | ||
const nextTokenKey = { | ||
isValid: key => key.toLowerCase () === 'nexttoken' || key === 'NextMarker' || key === 'Marker' || key === 'LastEvaluatedTableName', | ||
transformForNextRequest: key => { | ||
return { | ||
NextMarker: 'Marker', | ||
LastEvaluatedTableName: 'ExclusiveStartTableName' | ||
}[key] || key; | ||
} | ||
}; | ||
const awsCollectionStream = ( { | ||
@@ -42,3 +61,3 @@ serviceObject, | ||
...parms, | ||
[nextTokenKeyName === 'NextMarker' ? 'Marker' : nextTokenKeyName]: nextToken | ||
[nextTokenKey.transformForNextRequest ( nextTokenKeyName )]: nextToken | ||
} ) | ||
@@ -78,3 +97,3 @@ .flatMap ( ( { [collectionName]: collection, [nextTokenKeyName]: nextToken } ) => nextToken ? H ( collection ) | ||
const collectionName = R.find ( key => R.type ( result[key] ) === 'Array', R.keys ( result ) ); | ||
const nextTokenKeyName = R.find ( key => key.toLowerCase () === 'nexttoken' || key === 'NextMarker' || key === 'Marker', R.keys ( result ) ); | ||
const nextTokenKeyName = R.find ( nextTokenKey.isValid, R.keys ( result ) ); | ||
@@ -81,0 +100,0 @@ if ( nextTokenKeyName ) { |
{ | ||
"name": "aws-collection-stream", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Takes care of any paginated AWS SDK call, and return the output as a highland.js stream of objects.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5398
101