├── .gitignore ├── BucketConfig.js ├── LICENSE ├── Permissions.js ├── README.md ├── S3.js ├── Transformer.js ├── index.js ├── package-lock.json ├── package.json ├── spec ├── BucketConfig_spec.js └── fixtures │ ├── configurations.json │ ├── notifications.json │ └── notifications_with_configurations.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /BucketConfig.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const S3 = require('./S3.js') 4 | 5 | class BucketConfig { 6 | constructor(config, serverless, options) { 7 | this.config = config 8 | this.options = options; 9 | this.s3 = new S3() 10 | this.serverless = serverless 11 | if (serverless != undefined){ 12 | this.service = serverless.service.getServiceObject().name 13 | this.stage = serverless.service.provider.stage 14 | } 15 | } 16 | 17 | getConfig() { 18 | return this.config 19 | } 20 | //update the current configuration with the ones stored in serverless.yml 21 | update(fileConfig) { 22 | this.addNewNotifications(fileConfig) 23 | this.removeObsoleteNotifications(fileConfig) 24 | } 25 | 26 | remove(functionNames, region) { 27 | functionNames.forEach(name => { 28 | let re = new RegExp(`^arn:[cn\-]?aws:lambda:${region}:[0-9]+:function:${name}$`, 'i'); 29 | this.config.results.LambdaFunctionConfigurations = 30 | this.config.results.LambdaFunctionConfigurations.filter(function (e) { 31 | return !re.test(e.LambdaFunctionArn); 32 | }); 33 | }) 34 | } 35 | 36 | addNewNotifications(fileConfig) { 37 | fileConfig.events.forEach((event) => { 38 | if (this.isNew(event)) this.addNewNotification(event) 39 | }) 40 | } 41 | 42 | isNew(event) { 43 | let id = this.s3.getId(event) 44 | let found = this.config.results.LambdaFunctionConfigurations.find(function(e) { 45 | return e.Id == id 46 | }) 47 | return found == undefined 48 | } 49 | 50 | addNewNotification(event) { 51 | let id = this.s3.getId(event) 52 | 53 | this.config.results.LambdaFunctionConfigurations.push({ 54 | Id: id, 55 | LambdaFunctionArn: event.arn, 56 | Events: event.existingS3.events, 57 | Filter: this.notificationFilterFrom(event) 58 | }) 59 | } 60 | 61 | notificationFilterFrom(event) { 62 | let filter = undefined 63 | 64 | if(event.existingS3.rules && event.existingS3.rules.length !== 0) { 65 | filter = { 66 | Key: { 67 | FilterRules: event.existingS3.rules.map( rule => { 68 | const key = Object.keys(rule)[0]; 69 | return { 70 | Name: key, 71 | Value: rule[key] 72 | } 73 | }) 74 | } 75 | } 76 | } 77 | 78 | return filter 79 | } 80 | 81 | removeObsoleteNotifications(fileConfig) { 82 | let notifications = this.config 83 | .results 84 | .LambdaFunctionConfigurations 85 | .filter(n => this.isActive(n, fileConfig)) 86 | this.config.results.LambdaFunctionConfigurations = notifications 87 | } 88 | 89 | isActive(notification, fileConfig) { 90 | return this.inConfig(notification, fileConfig) || this.notRelevant(notification, fileConfig) 91 | } 92 | 93 | inConfig(notification, fileConfig) { 94 | let found = fileConfig.events.find((event) => { 95 | let id = this.s3.getId(event) 96 | return id == notification.Id && this.relevantARN(event.arn) 97 | }) 98 | return found != undefined 99 | } 100 | 101 | notRelevant(notification, fileConfig) { 102 | return (this.relevantARN(notification.LambdaFunctionArn) == null) || !notification.Id.startsWith("exS3-v2") 103 | } 104 | 105 | relevantARN(arn) { 106 | const aliasPart = (this.options && this.options.alias) ? `.*:${this.options.alias}` : ''; 107 | let re = new RegExp(this.service + "-" + this.stage + aliasPart, 'gi') 108 | return arn.match(re) 109 | } 110 | } 111 | 112 | module.exports = BucketConfig 113 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 matt-filion, Ibotta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Permissions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | class LambdaPermissions { 4 | 5 | constructor(options, provider) { 6 | this.options = options; 7 | this.provider = provider; 8 | } 9 | 10 | getId(functionName,bucketName) { 11 | const aliasName = this.options.alias ? `-${this.options.alias}` : ''; 12 | const id = `exS3-v2-${functionName}${aliasName}-${bucketName.replace(/[\.\:\*]/g,'')}`; 13 | if (id.length < 100) { return id } 14 | return id.substring(0,68) + require('crypto').createHash('md5').update(id).digest("hex") 15 | } 16 | 17 | createPolicy(functionName,bucketName,passthrough){ 18 | let region = (this.provider.sdk && this.provider.sdk.config && this.provider.sdk.config.region) || undefined; 19 | const payload = { 20 | Action: "lambda:InvokeFunction", 21 | FunctionName: functionName, 22 | Principal: 's3.amazonaws.com', 23 | StatementId: this.getId(functionName,bucketName), 24 | SourceArn: `arn:${(region && /^cn\-/.test(region)) ? 'aws-cn' : 'aws'}:s3:::${bucketName}` 25 | }; 26 | if (this.options.alias) { 27 | payload['Qualifier'] = this.options.alias; 28 | } 29 | return this.provider.request('Lambda', 'addPermission', payload) 30 | .then( () => this.getPolicy(functionName, passthrough) ) 31 | } 32 | 33 | getPolicy(functionName,passthrough) { 34 | const payload = {FunctionName: functionName}; 35 | if (this.options.alias) { 36 | payload['Qualifier'] = this.options.alias; 37 | } 38 | return this.provider.request('Lambda', 'getPolicy', payload) 39 | .then( results => Object.assign({},{ statement: this.getStatement(this.asJson(results.Policy),passthrough), passthrough }) ) 40 | .catch( error => Object.assign({}, { error:error.message, passthrough } ) ); 41 | } 42 | 43 | getStatement(policy,event) { 44 | const policyId = this.getId(event.name, event.existingS3.bucket); 45 | console.log("policyId",policyId); 46 | return policy.Statement.find( statement => statement.Sid === policyId ); 47 | } 48 | 49 | asJson(value){ 50 | return typeof value === 'string' ? JSON.parse(value) : value 51 | } 52 | } 53 | 54 | module.exports.Lambda = LambdaPermissions; 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ----- 2 | # DEPRECATED 3 | 4 | This functionality is now native to serverless. See the docs at https://serverless.com/framework/docs/providers/aws/events/s3#using-existing-buckets for more information. 5 | 6 | ----- 7 | 8 | # Why? 9 | 10 | Overcomes the CloudFormation limitation on attaching an event to an uncontrolled bucket, for Serverless.com 1.11.0+. See [this stackoverflow issue](http://serverfault.com/questions/610788/using-cloudformation-with-an-existing-s3-bucket) for more information. 11 | 12 | # How? 13 | 14 | **1. NPM dependency** 15 | 16 | ``` 17 | > npm install --save-dev serverless-plugin-existing-s3 18 | ``` 19 | 20 | **Declare the plugin in your serverless.yml** 21 | 22 | ```serverless.yml 23 | 24 | plugins: 25 | - serverless-plugin-existing-s3 26 | 27 | ``` 28 | 29 | **2. Give your deploy permission to access the bucket.** 30 | The BUCKET_NAME variable within provider.iamRoleStatements.Resource.Fn::Join needs to be replaced with the name of the bucket you want to attach your event(s) to. If there are multiple buckets you want to attach events to add a new item for each bucket. 31 | 32 | ```serverless.yml 33 | provider: 34 | name: aws 35 | runtime: nodejs4.3 36 | iamRoleStatements: 37 | ... 38 | - Effect: "Allow" 39 | Action: 40 | - "s3:GetBucketNotification" 41 | - "s3:PutBucketNotification" 42 | Resource: 43 | Fn::Join: 44 | - "" 45 | - - "arn:aws:s3:::BUCKET_NAME or *" 46 | ``` 47 | 48 | **3. Attach an event to your target function.** 49 | Add an -existingS3 event definition under 'events' of your function declaration. The 'events' value is optional under your -existingS3 event and if omitted, it will default to a single entry for "s3:ObjectCreated:\*". 50 | 51 | The rules property is optional and can contain either a prefix, suffix or both of these properties as a rule for when the event will trigger. 52 | 53 | Note: The bucketEvents and eventRules attributes introduced in 1.0.1 will still work, but will likely be deprecated in the future. 54 | 55 | ```serverless.yml 56 | 57 | functions: 58 | someFunction: 59 | handler: index.handler 60 | events: 61 | - existingS3: 62 | bucket: BUCKET_NAME 63 | events: 64 | - s3:ObjectCreated:* 65 | rules: 66 | - prefix: images/ 67 | - suffix: .jpg 68 | ``` 69 | 70 | **Multiple Prefixes** 71 | As identified with [issue 62](https://github.com/matt-filion/serverless-external-s3-event/issues/62). 72 | 73 | ``` 74 | functions: 75 | myAmazingLambdaFunction: 76 | handler: lambda-to-be-triggered-by-s3.handler 77 | events: 78 | - existingS3: 79 | bucket: 'my-bucket' 80 | events: 81 | - s3:ObjectCreated:* 82 | rules: 83 | - prefix: some/prefix 84 | - existingS3: 85 | bucket: 'my-bucket' 86 | events: 87 | - s3:ObjectCreated:* 88 | rules: 89 | - prefix: someother/prefix 90 | ``` 91 | 92 | **Run the command.** 93 | _I could not figure out how to hook into the existing deploy behaviors built into Serverless.com's deploy command. So as a result you have to run a separate command AFTER you do `sls deploy`._ 94 | 95 | ``` 96 | > sls deploy 97 | Serverless: Zipping service... 98 | Serverless: Uploading CloudFormation file to S3... 99 | Serverless: Removing old service versions... 100 | Serverless: Uploading .zip file to S3... 101 | Serverless: Updating Stack... 102 | Serverless: Checking stack update progress... 103 | .. 104 | Serverless: Deployment successful! 105 | 106 | Service Information 107 | service: service-name 108 | stage: stage 109 | region: region 110 | endpoints: 111 | None 112 | functions: 113 | someFunction: arn:aws:lambda:region:accountid:function:service-name-stage-someFunction 114 | 115 | > sls s3deploy 116 | Attaching event(s) to: someFunction 117 | Done. 118 | 119 | ``` 120 | 121 | **Command line options** 122 | 123 | - `--alias`: Use this option to specify the lambda function's alias to be set as the event handler. This is optional and if omitted, the lambda function without a qualifier will be used (the `$LATEST` version). Here's an example on how to use it: 124 | 125 | ``` 126 | > sls deploy --stage dev --alias dev 127 | > sls s3deploy --stage dev --alias dev 128 | > sls s3eventremove --stage dev --alias dev 129 | ``` 130 | 131 | # I haz an errawr 132 | 133 | The only one I see, and quite regularly during my testing, is a result of having the wrong bucket name configured in the serverless.yml, either in the IAM configuration providing permissions or in the function definition where I'm attaching the event. Make sure your bucket names are right. 134 | 135 | If you are really stuck, open an issue at https://github.com/matt-filion/serverless-external-s3-event/issues 136 | 137 | # Contributing 138 | 139 | You can run test by running 140 | 141 | ``` 142 | yarn install 143 | yarn test 144 | ``` 145 | -------------------------------------------------------------------------------- /S3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const crypto = require('crypto'); 4 | 5 | class S3 { 6 | constructor(serverless,options,provider){ 7 | this.serverless = serverless; 8 | this.provider = provider; 9 | this.options = options; 10 | } 11 | 12 | getId(event) { 13 | const eventTypes = event.existingS3.events ? 14 | Array.isArray(event.existingS3.events) ? event.existingS3.events : [event.existingS3.events] 15 | : ['s3:ObjectCreated:*']; 16 | const rules = event.existingS3.rules ? event.existingS3.rules.sort( (a,b) => Object.keys(a) - Object.keys(b) ) : []; 17 | const md5Data = `${event.arn}_${eventTypes.join('OR').replace(/[\.\:\*]/g,'')}_${rules.map(rule => JSON.stringify(rule)).join('-')}`; 18 | const md5 = crypto.createHash('md5').update(md5Data).digest("hex"); 19 | return `exS3-v2--${md5}`; 20 | } 21 | 22 | getLambdaNotifications(bucket){ 23 | return this.provider.request('S3', 'getBucketNotificationConfiguration', { Bucket: bucket }) 24 | .then( results => { 25 | return {bucket, results:results}; 26 | }) 27 | } 28 | 29 | putLambdaNotification(bucketConfig) { 30 | const payload = { 31 | Bucket: bucketConfig.bucket, 32 | NotificationConfiguration: bucketConfig.results 33 | } 34 | 35 | return this.provider.request('S3', 'putBucketNotificationConfiguration', payload) 36 | .catch( error => { 37 | if(this.options['continue-on-error']) { 38 | this.serverless.cli.log(`\t ERROR: ${payload.Bucket} ${error.message}`); 39 | } else { 40 | return Promise.reject(`${payload.Bucket} ${error.message}`); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = S3; 47 | -------------------------------------------------------------------------------- /Transformer.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Get it, cuz he is a 'transformer'.... 4 | */ 5 | class OptimusPrime { 6 | constructor(lambdaPermissions){ 7 | this.lambdaPermissions = lambdaPermissions; 8 | } 9 | 10 | functionsToEvents(functions) { 11 | const names = Object.keys(functions); 12 | return names 13 | 14 | /* 15 | * Looking at each function defined in the serverless.yml file this will transform/map 16 | * into the BucketNotificationConfiguration's that are needed for each S3 bucket 17 | */ 18 | .map( name => functions[name] ) 19 | 20 | /* 21 | * Each event can be targeted at a different bucket, so here I break them out into their own 22 | * item combined with the data from the parent. 23 | */ 24 | .map( funktion => funktion.events.map( event => Object.assign(event,{handler: funktion.handler,name: funktion.name})) ) 25 | 26 | /* 27 | * Flatten the nested arrays. 28 | */ 29 | .reduce( (accumulator,current) => accumulator.concat(current), []) 30 | 31 | /* 32 | * Get rid of any event that is not for existingS3, since its not actionable for this plugin. 33 | */ 34 | .filter( event => event.existingS3 ) 35 | 36 | /* 37 | * For each defined function, get the current policy defined for that function. The policy of 38 | * each function must permit S3 to invoke it. 39 | */ 40 | .map( event => this.lambdaPermissions.getPolicy(event.name, event) ) 41 | } 42 | 43 | eventsToBucketGroups(events){ 44 | return events 45 | /* 46 | * Clear out any events that it has been determined cannot be 47 | * attached to S3 buckets. 48 | */ 49 | .filter( event => !event.remove ) 50 | 51 | /* 52 | * Update the ARN for each function using the policies found for each function. 53 | */ 54 | .map( result => { 55 | const event = result.passthrough; 56 | const statement = result.statement; 57 | 58 | event.arn = statement.Resource; 59 | 60 | return event; 61 | }) 62 | /* 63 | * Merge the events into groups for each bucket, as that will be the unit of work 64 | * going forward. 65 | */ 66 | .reduce( (accumulator,event) => { 67 | let bucketGroup = accumulator.find( group => group.name === event.existingS3.bucket ) 68 | if(!bucketGroup) { 69 | bucketGroup = { 70 | name: event.existingS3.bucket, 71 | events: [] 72 | } 73 | accumulator.push(bucketGroup); 74 | } 75 | bucketGroup.events.push(event); 76 | return accumulator; 77 | }, []) 78 | } 79 | 80 | } 81 | 82 | 83 | module.exports = OptimusPrime; -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Permissions = require('./Permissions'); 4 | const S3 = require('./S3'); 5 | const Transformer = require('./Transformer'); 6 | const BucketConfig = require('./BucketConfig'); 7 | 8 | 9 | class S3Deploy { 10 | 11 | constructor(serverless,options) { 12 | 13 | this.serverless = serverless; 14 | this.options = options; 15 | this.provider = this.serverless.getProvider('aws'); 16 | if (!(this.provider.sdk && this.provider.sdk.config && this.provider.sdk.config.region)) { 17 | this.provider.sdk.config.region = this.serverless.service.provider.region; 18 | } 19 | this.s3Facade = new S3(this.serverless,this.options,this.provider); 20 | this.lambdaPermissions = new Permissions.Lambda(this.options, this.provider); 21 | this.transformer = new Transformer(this.lambdaPermissions); 22 | this.commands = { 23 | s3deploy: { 24 | lifecycleEvents: [ 25 | 'init', 26 | 'functions', 27 | 's3' 28 | ], 29 | usage: 'Add lambda notifications to S3 buckets not defined in serverless.yml', 30 | options: { 31 | 'continue-on-error' : { 32 | usage: 'Can be used to attempt a partial deploy, where not all functions are available/deployed. They will be skipped and not attmepted.' 33 | }, 34 | help: { 35 | usage: 'See https://github.com/matt-filion/serverless-external-s3-event for detailed documentation.' 36 | } 37 | } 38 | }, 39 | s3eventremove: { 40 | lifecycleEvents: ['remove'], 41 | usage: 'remove lambda notifications to S3 buckets defined in serverless.yml', 42 | } 43 | }; 44 | 45 | this.hooks = { 46 | 'before:s3deploy:functions':this.beforeFunctions.bind(this), 47 | 's3deploy:functions': this.functions.bind(this), 48 | 49 | 'before:s3deploy:s3':this.beforeS3.bind(this), 50 | 's3deploy:s3': this.s3.bind(this), 51 | 52 | 's3eventremove:remove': this.s3remove.bind(this), 53 | }; 54 | 55 | this.bucketNotifications; 56 | this.currentBucketNotifications; 57 | 58 | } 59 | 60 | /* 61 | * Looks at the serverless.yml file for the project the plugin is defined within and 62 | * builds the AWS payload needed for each S3 bucket configured for externalS3 events. 63 | */ 64 | beforeFunctions(){ 65 | 66 | this.serverless.cli.log("beforeFunctions --> building ... "); 67 | 68 | this.events = this.transformer.functionsToEvents(this.serverless.service.functions); 69 | 70 | this.serverless.cli.log(`beforeFunctions <-- Complete, built ${this.events.length} events.`); 71 | } 72 | 73 | functions(){ 74 | this.serverless.cli.log("functions --> prepare to be executed by s3 buckets ... "); 75 | 76 | let count = 0; 77 | 78 | return Promise.all( this.events ) 79 | .then( results => results.map( result => { 80 | 81 | const event = result.passthrough; 82 | 83 | /* 84 | * If we get a 'funciton not found' error message then sls deploy has likely not been 85 | * executed. I suppose it could also be 'permissions', but that would require someone 86 | * create a wonkey AIM definition in serverless.yml. 87 | */ 88 | if(result.error && result.error.toLowerCase().startsWith('function not found')){ 89 | if(this.options['continue-on-error']) { 90 | this.serverless.cli.log(`\t ERROR: It looks like the function ${event.name} has not yet beend deployed, it will be excluded.`); 91 | event.remove = true; 92 | return Promise.resolve(event); 93 | } else { 94 | throw `It looks like the function ${event.name} has not yet beend deployed (it may not be the only one). You must use 'sls deploy' before doing 'sls s3deploy'.`; 95 | } 96 | } 97 | 98 | /* 99 | * No permissions have been added to this function for any S3 bucket, so create the policy 100 | * and return the event when it executes successfully. 101 | */ 102 | if(result.error && 'the resource you requested does not exist.' === result.error.toLowerCase()){ 103 | return this.lambdaPermissions.createPolicy(event.name,event.existingS3.bucket,event); 104 | } 105 | 106 | /* 107 | * If there is no policy on the lambda function allowing the S3 bucket to invoke it 108 | * then add it. These policies are named specifically for this lambda function so 109 | * existing 'should' be sufficient in ensureing its proper. 110 | */ 111 | if(!result.statement) { 112 | return this.lambdaPermissions.createPolicy(event.name,event.existingS3.bucket,event); 113 | } 114 | 115 | return Promise.resolve(result); 116 | }) 117 | ) 118 | .then( results => Promise.all(results) ) 119 | 120 | /* 121 | * Transform results 122 | */ 123 | .then( events => this.transformer.eventsToBucketGroups(events) ) 124 | .then( bucketNotifications => { 125 | this.bucketNotifications = bucketNotifications; 126 | this.serverless.cli.log(`functions <-- built ${count} events across ${bucketNotifications.length} buckets. `); 127 | }) 128 | } 129 | 130 | beforeS3(){ 131 | this.serverless.cli.log("beforeS3 --> "); 132 | 133 | /* 134 | * Load the current notification configruartions for each bucket that is impacted. This will be used 135 | * to filter out changes that have already been applied to the bucket. 136 | */ 137 | const promises = this.bucketNotifications.map( bucketConfiguration => this.s3Facade.getLambdaNotifications(bucketConfiguration.name) ) 138 | 139 | return Promise.all(promises) 140 | .then( results => { 141 | this.currentBucketNotifications = results; 142 | this.serverless.cli.log("beforeS3 <-- "); 143 | }); 144 | 145 | } 146 | 147 | s3(){ 148 | 149 | if(this.bucketNotifications && this.bucketNotifications.length !== 0) { 150 | 151 | this.serverless.cli.log("s3 --> initiate requests ..."); 152 | 153 | const promises = this.bucketNotifications 154 | .filter( bucketConfig => bucketConfig.events.length !== 0) 155 | .map( bucketConfigurationFromFile => { 156 | 157 | const existingS3Notifications = this.currentBucketNotifications.find( currentNotification => currentNotification.bucket === bucketConfigurationFromFile.name ); 158 | 159 | let bucketConfig = new BucketConfig(existingS3Notifications, this.serverless, this.options) 160 | 161 | bucketConfig.update(bucketConfigurationFromFile) 162 | 163 | return bucketConfig.getConfig() 164 | }) 165 | .map( bucketConfig => this.s3Facade.putLambdaNotification(bucketConfig) ) 166 | 167 | return Promise.all(promises) 168 | .then( results => this.serverless.cli.log(`s3 <-- Complete ${results.length} updates.`) ); 169 | 170 | } 171 | } 172 | 173 | s3remove() { 174 | const region = this.provider.sdk.config.region; 175 | const funcToDelete = Object.values(this.serverless.service.functions) 176 | .map( funktion => funktion.name ); 177 | 178 | this.serverless.cli.log(`remove --> Start`); 179 | 180 | return Promise.resolve(Object.values(this.serverless.service.functions)) 181 | // aggregate from functions to bucket base 182 | .then( funktions => funktions.reduce((accumulator,current) => accumulator.concat(current.events), []) 183 | .filter( event => event.existingS3 ) 184 | .map( event => this.s3Facade.getLambdaNotifications(event.existingS3.bucket) ) 185 | ) 186 | .then( results => Promise.all(results) ) 187 | // start remove function notification 188 | .then( results => results 189 | .map( bucketNotification => { 190 | const bucketConfig = new BucketConfig(bucketNotification, this.serverless, this.options) 191 | 192 | const removed = bucketConfig.remove(funcToDelete, region); 193 | 194 | return this.s3Facade.putLambdaNotification(bucketConfig.getConfig()); 195 | }) 196 | ) 197 | .then( puts => Promise.all(puts) ) 198 | .then( () => this.serverless.cli.log(`remove <-- Done`) ); 199 | 200 | } 201 | } 202 | 203 | module.exports = S3Deploy; 204 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-plugin-existing-s3", 3 | "version": "2.4.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@sinonjs/commons": { 8 | "version": "1.3.0", 9 | "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.3.0.tgz", 10 | "integrity": "sha512-j4ZwhaHmwsCb4DlDOIWnI5YyKDNMoNThsmwEpfHx6a1EpsGZ9qYLxP++LMlmBRjtGptGHFsGItJ768snllFWpA==", 11 | "dev": true, 12 | "requires": { 13 | "type-detect": "4.0.8" 14 | } 15 | }, 16 | "@sinonjs/formatio": { 17 | "version": "2.0.0", 18 | "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", 19 | "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==", 20 | "dev": true, 21 | "requires": { 22 | "samsam": "1.3.0" 23 | } 24 | }, 25 | "@sinonjs/samsam": { 26 | "version": "3.2.0", 27 | "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.2.0.tgz", 28 | "integrity": "sha512-j5F1rScewLtx6pbTK0UAjA3jJj4RYiSKOix53YWv+Jzy/AZ69qHxUpU8fwVLjyKbEEud9QrLpv6Ggs7WqTimYw==", 29 | "dev": true, 30 | "requires": { 31 | "@sinonjs/commons": "^1.0.2", 32 | "array-from": "^2.1.1", 33 | "lodash": "^4.17.11" 34 | } 35 | }, 36 | "@sinonjs/text-encoding": { 37 | "version": "0.7.1", 38 | "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", 39 | "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", 40 | "dev": true 41 | }, 42 | "array-from": { 43 | "version": "2.1.1", 44 | "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", 45 | "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", 46 | "dev": true 47 | }, 48 | "assertion-error": { 49 | "version": "1.1.0", 50 | "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", 51 | "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", 52 | "dev": true 53 | }, 54 | "balanced-match": { 55 | "version": "1.0.0", 56 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 57 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 58 | "dev": true 59 | }, 60 | "brace-expansion": { 61 | "version": "1.1.11", 62 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 63 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 64 | "dev": true, 65 | "requires": { 66 | "balanced-match": "^1.0.0", 67 | "concat-map": "0.0.1" 68 | } 69 | }, 70 | "browser-stdout": { 71 | "version": "1.3.1", 72 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 73 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 74 | "dev": true 75 | }, 76 | "chai": { 77 | "version": "4.1.2", 78 | "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", 79 | "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", 80 | "dev": true, 81 | "requires": { 82 | "assertion-error": "^1.0.1", 83 | "check-error": "^1.0.1", 84 | "deep-eql": "^3.0.0", 85 | "get-func-name": "^2.0.0", 86 | "pathval": "^1.0.0", 87 | "type-detect": "^4.0.0" 88 | } 89 | }, 90 | "check-error": { 91 | "version": "1.0.2", 92 | "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", 93 | "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", 94 | "dev": true 95 | }, 96 | "commander": { 97 | "version": "2.11.0", 98 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", 99 | "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", 100 | "dev": true 101 | }, 102 | "concat-map": { 103 | "version": "0.0.1", 104 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 105 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 106 | "dev": true 107 | }, 108 | "debug": { 109 | "version": "3.1.0", 110 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 111 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 112 | "dev": true, 113 | "requires": { 114 | "ms": "2.0.0" 115 | } 116 | }, 117 | "deep-eql": { 118 | "version": "3.0.1", 119 | "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", 120 | "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", 121 | "dev": true, 122 | "requires": { 123 | "type-detect": "^4.0.0" 124 | } 125 | }, 126 | "diff": { 127 | "version": "3.5.0", 128 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 129 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 130 | "dev": true 131 | }, 132 | "escape-string-regexp": { 133 | "version": "1.0.5", 134 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 135 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 136 | "dev": true 137 | }, 138 | "fs.realpath": { 139 | "version": "1.0.0", 140 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 141 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 142 | "dev": true 143 | }, 144 | "get-func-name": { 145 | "version": "2.0.0", 146 | "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", 147 | "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", 148 | "dev": true 149 | }, 150 | "glob": { 151 | "version": "7.1.2", 152 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 153 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 154 | "dev": true, 155 | "requires": { 156 | "fs.realpath": "^1.0.0", 157 | "inflight": "^1.0.4", 158 | "inherits": "2", 159 | "minimatch": "^3.0.4", 160 | "once": "^1.3.0", 161 | "path-is-absolute": "^1.0.0" 162 | } 163 | }, 164 | "growl": { 165 | "version": "1.10.3", 166 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", 167 | "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", 168 | "dev": true 169 | }, 170 | "has-flag": { 171 | "version": "2.0.0", 172 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", 173 | "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", 174 | "dev": true 175 | }, 176 | "he": { 177 | "version": "1.1.1", 178 | "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", 179 | "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", 180 | "dev": true 181 | }, 182 | "inflight": { 183 | "version": "1.0.6", 184 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 185 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 186 | "dev": true, 187 | "requires": { 188 | "once": "^1.3.0", 189 | "wrappy": "1" 190 | } 191 | }, 192 | "inherits": { 193 | "version": "2.0.3", 194 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 195 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 196 | "dev": true 197 | }, 198 | "isarray": { 199 | "version": "0.0.1", 200 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", 201 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", 202 | "dev": true 203 | }, 204 | "just-extend": { 205 | "version": "4.0.2", 206 | "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", 207 | "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", 208 | "dev": true 209 | }, 210 | "lodash": { 211 | "version": "4.17.11", 212 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", 213 | "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", 214 | "dev": true 215 | }, 216 | "lodash.get": { 217 | "version": "4.4.2", 218 | "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", 219 | "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", 220 | "dev": true 221 | }, 222 | "lolex": { 223 | "version": "2.3.2", 224 | "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", 225 | "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", 226 | "dev": true 227 | }, 228 | "minimatch": { 229 | "version": "3.0.4", 230 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 231 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 232 | "dev": true, 233 | "requires": { 234 | "brace-expansion": "^1.1.7" 235 | } 236 | }, 237 | "minimist": { 238 | "version": "0.0.8", 239 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 240 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 241 | "dev": true 242 | }, 243 | "mkdirp": { 244 | "version": "0.5.1", 245 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 246 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 247 | "dev": true, 248 | "requires": { 249 | "minimist": "0.0.8" 250 | } 251 | }, 252 | "mocha": { 253 | "version": "5.0.4", 254 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.4.tgz", 255 | "integrity": "sha512-nMOpAPFosU1B4Ix1jdhx5e3q7XO55ic5a8cgYvW27CequcEY+BabS0kUVL1Cw1V5PuVHZWeNRWFLmEPexo79VA==", 256 | "dev": true, 257 | "requires": { 258 | "browser-stdout": "1.3.1", 259 | "commander": "2.11.0", 260 | "debug": "3.1.0", 261 | "diff": "3.5.0", 262 | "escape-string-regexp": "1.0.5", 263 | "glob": "7.1.2", 264 | "growl": "1.10.3", 265 | "he": "1.1.1", 266 | "mkdirp": "0.5.1", 267 | "supports-color": "4.4.0" 268 | } 269 | }, 270 | "ms": { 271 | "version": "2.0.0", 272 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 273 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", 274 | "dev": true 275 | }, 276 | "nise": { 277 | "version": "1.4.10", 278 | "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.10.tgz", 279 | "integrity": "sha512-sa0RRbj53dovjc7wombHmVli9ZihXbXCQ2uH3TNm03DyvOSIQbxg+pbqDKrk2oxMK1rtLGVlKxcB9rrc6X5YjA==", 280 | "dev": true, 281 | "requires": { 282 | "@sinonjs/formatio": "^3.1.0", 283 | "@sinonjs/text-encoding": "^0.7.1", 284 | "just-extend": "^4.0.2", 285 | "lolex": "^2.3.2", 286 | "path-to-regexp": "^1.7.0" 287 | }, 288 | "dependencies": { 289 | "@sinonjs/formatio": { 290 | "version": "3.1.0", 291 | "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.1.0.tgz", 292 | "integrity": "sha512-ZAR2bPHOl4Xg6eklUGpsdiIJ4+J1SNag1DHHrG/73Uz/nVwXqjgUtRPLoS+aVyieN9cSbc0E4LsU984tWcDyNg==", 293 | "dev": true, 294 | "requires": { 295 | "@sinonjs/samsam": "^2 || ^3" 296 | } 297 | } 298 | } 299 | }, 300 | "once": { 301 | "version": "1.4.0", 302 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 303 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 304 | "dev": true, 305 | "requires": { 306 | "wrappy": "1" 307 | } 308 | }, 309 | "path-is-absolute": { 310 | "version": "1.0.1", 311 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 312 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 313 | "dev": true 314 | }, 315 | "path-to-regexp": { 316 | "version": "1.7.0", 317 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", 318 | "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", 319 | "dev": true, 320 | "requires": { 321 | "isarray": "0.0.1" 322 | } 323 | }, 324 | "pathval": { 325 | "version": "1.1.0", 326 | "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", 327 | "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", 328 | "dev": true 329 | }, 330 | "samsam": { 331 | "version": "1.3.0", 332 | "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", 333 | "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", 334 | "dev": true 335 | }, 336 | "sinon": { 337 | "version": "4.4.8", 338 | "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.4.8.tgz", 339 | "integrity": "sha512-EWZf/D5BN/BbDFPmwY2abw6wgELVmk361self+lcwEmVw0WWUxURp2S/YoDB2WG/xurFVzKQglMARweYRWM6Hw==", 340 | "dev": true, 341 | "requires": { 342 | "@sinonjs/formatio": "^2.0.0", 343 | "diff": "^3.1.0", 344 | "lodash.get": "^4.4.2", 345 | "lolex": "^2.2.0", 346 | "nise": "^1.2.0", 347 | "supports-color": "^5.1.0", 348 | "type-detect": "^4.0.5" 349 | }, 350 | "dependencies": { 351 | "has-flag": { 352 | "version": "3.0.0", 353 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 354 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 355 | "dev": true 356 | }, 357 | "supports-color": { 358 | "version": "5.3.0", 359 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", 360 | "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", 361 | "dev": true, 362 | "requires": { 363 | "has-flag": "^3.0.0" 364 | } 365 | } 366 | } 367 | }, 368 | "supports-color": { 369 | "version": "4.4.0", 370 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", 371 | "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", 372 | "dev": true, 373 | "requires": { 374 | "has-flag": "^2.0.0" 375 | } 376 | }, 377 | "type-detect": { 378 | "version": "4.0.8", 379 | "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", 380 | "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", 381 | "dev": true 382 | }, 383 | "wrappy": { 384 | "version": "1.0.2", 385 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 386 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 387 | "dev": true 388 | } 389 | } 390 | } 391 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serverless-plugin-existing-s3", 3 | "version": "2.4.0", 4 | "description": "Attach Lambda events to an existing S3 bucket, for Serverless.com 1.11.0+.", 5 | "main": "index.js", 6 | "homepage": "https://github.com/matt-filion/serverless-external-s3-event", 7 | "dependencies": {}, 8 | "devDependencies": { 9 | "chai": "^4.1.2", 10 | "mocha": "^5.0.4", 11 | "sinon": "^4.4.3" 12 | }, 13 | "maintainers": [ 14 | { 15 | "name": "Matt Filion", 16 | "email": "matt.filion@gmail.com" 17 | } 18 | ], 19 | "files": [ 20 | "index.js", 21 | "README.md", 22 | "LICENSE", 23 | "package.json", 24 | "Permissions.js", 25 | "S3.js", 26 | "Transformer.js", 27 | "BucketConfig.js" 28 | ], 29 | "contributors": [ 30 | { 31 | "name": "Matt Filion", 32 | "email": "matt.filion@gmail.com" 33 | }, 34 | { 35 | "name": "Justin Hart", 36 | "email": "npm@onyxraven.com" 37 | } 38 | ], 39 | "repository": { 40 | "type": "git", 41 | "url": "https://github.com/matt-filion/serverless-external-s3-event" 42 | }, 43 | "bugs": { 44 | "url": "https://github.com/matt-filion/serverless-external-s3-event/issues" 45 | }, 46 | "author": { 47 | "name": "Matt Filion", 48 | "email": "matt.filion@gmail.com" 49 | }, 50 | "private": false, 51 | "licenses": [ 52 | { 53 | "type": "MIT", 54 | "url": "http://github.com/jeremyosborne/packagejsonexample/blob/master/LICENSE.txt" 55 | } 56 | ], 57 | "keywords": [ 58 | "s3", 59 | "event", 60 | "notifications", 61 | "serverless", 62 | "serverless.com" 63 | ], 64 | "scripts": { 65 | "test": "mocha spec" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /spec/BucketConfig_spec.js: -------------------------------------------------------------------------------- 1 | const BucketConfig = require('../BucketConfig') 2 | const chai = require('chai') 3 | const sinon = require('sinon') 4 | 5 | const notifications = require('./fixtures/notifications.json') 6 | const notificationsWithConfigurations = require('./fixtures/notifications_with_configurations.json') 7 | const configurations = require('./fixtures/configurations.json') 8 | 9 | const expect = chai.expect 10 | 11 | describe('BucketConfig', function() { 12 | describe('addNewNotifications', function() { 13 | it('adds notifications existing only in the file to the config', function() { 14 | let bucketConfig = new BucketConfig(notifications.added) 15 | bucketConfig.addNewNotifications(configurations.added) 16 | expect(bucketConfig.getConfig()).to.deep.eq(notificationsWithConfigurations.added) 17 | }) 18 | }) 19 | 20 | describe('addNewNotificationsWithAliases', function() { 21 | it('adds notifications to aliased lambdas existing only in the file to the config', function() { 22 | let bucketConfig = new BucketConfig(notifications.addedWithAliases) 23 | bucketConfig.addNewNotifications(configurations.addedWithAliases) 24 | expect(bucketConfig.getConfig()).to.deep.eq(notificationsWithConfigurations.addedWithAliases) 25 | }) 26 | }) 27 | 28 | describe('removeObsoleteNotifications', function() { 29 | it('removes relevant notifications not in the config file', function() { 30 | let bucketConfig = new BucketConfig(notifications.obsolete, { 31 | "service": { 32 | "getServiceObject": sinon.stub().returns({ "name": "serverless-test" }), 33 | "provider": { "stage": "production" } 34 | } 35 | }) 36 | bucketConfig.removeObsoleteNotifications(configurations.obsolete) 37 | expect(bucketConfig.getConfig()).to.deep.eq(notificationsWithConfigurations.obsolete) 38 | }) 39 | }) 40 | 41 | describe('removeObsoleteNotificationsWithAliases', function() { 42 | it('removes relevant notifications not in the config file, taking into account aliases', function() { 43 | let bucketConfig = new BucketConfig(notifications.obsoleteWithAliases, { 44 | "service": { 45 | "getServiceObject": sinon.stub().returns({ "name": "serverless-test" }), 46 | "provider": { "stage": "production" } 47 | } 48 | }, { alias: 'test_alias' }) 49 | bucketConfig.removeObsoleteNotifications(configurations.obsoleteWithAliases) 50 | expect(bucketConfig.getConfig()).to.deep.eq(notificationsWithConfigurations.obsoleteWithAliases) 51 | }) 52 | }) 53 | }) 54 | 55 | -------------------------------------------------------------------------------- /spec/fixtures/configurations.json: -------------------------------------------------------------------------------- 1 | { 2 | "added": { 3 | "name": "s3-serverless-test", 4 | "events": [ 5 | { 6 | "existingS3": { 7 | "bucket": "s3-serverless-test", 8 | "events": [ 9 | "s3:ObjectCreated:*" 10 | ], 11 | "rules": [ 12 | { 13 | "Prefix": "automated/" 14 | }, 15 | { 16 | "Suffix": ".txt" 17 | } 18 | ] 19 | }, 20 | "handler": "handler.handle", 21 | "name": "serverless-test-production-serverless-deploy-test", 22 | "arn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test" 23 | } 24 | ] 25 | }, 26 | "addedWithAliases": { 27 | "name": "s3-serverless-test", 28 | "events": [ 29 | { 30 | "existingS3": { 31 | "bucket": "s3-serverless-test", 32 | "events": [ 33 | "s3:ObjectCreated:*" 34 | ], 35 | "rules": [ 36 | { 37 | "Prefix": "automated/" 38 | }, 39 | { 40 | "Suffix": ".txt" 41 | } 42 | ] 43 | }, 44 | "handler": "handler.handle", 45 | "name": "serverless-test-production-serverless-deploy-test", 46 | "arn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test:test_alias" 47 | } 48 | ] 49 | }, 50 | "obsolete": { 51 | "name": "s3-serverless-test", 52 | "events": [ 53 | { 54 | "existingS3": { 55 | "bucket": "s3-serverless-test", 56 | "events": [ 57 | "s3:ObjectCreated:*" 58 | ], 59 | "rules": [ 60 | { 61 | "Prefix": "automated/" 62 | }, 63 | { 64 | "Suffix": ".txt" 65 | } 66 | ] 67 | }, 68 | "handler": "handler.handle", 69 | "name": "serverless-test-production-serverless-second-test", 70 | "arn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test" 71 | } 72 | ] 73 | }, 74 | "obsoleteWithAliases": { 75 | "name": "s3-serverless-test", 76 | "events": [ 77 | { 78 | "existingS3": { 79 | "bucket": "s3-serverless-test", 80 | "events": [ 81 | "s3:ObjectCreated:*" 82 | ], 83 | "rules": [ 84 | { 85 | "Prefix": "automated/" 86 | }, 87 | { 88 | "Suffix": ".txt" 89 | } 90 | ] 91 | }, 92 | "handler": "handler.handle", 93 | "name": "serverless-test-production-serverless-second-test", 94 | "arn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test:test_alias" 95 | } 96 | ] 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /spec/fixtures/notifications.json: -------------------------------------------------------------------------------- 1 | { 2 | "added": { 3 | "bucket": "s3-serverless-test", 4 | "results": { 5 | "TopicConfigurations": [], 6 | "QueueConfigurations": [], 7 | "LambdaFunctionConfigurations": [ 8 | { 9 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 10 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test", 11 | "Events": [ 12 | "s3:ObjectCreated:*" 13 | ], 14 | "Filter": { 15 | "Key": { 16 | "FilterRules": [ 17 | { 18 | "Name": "Prefix", 19 | "Value": "automated/" 20 | }, 21 | { 22 | "Name": "Suffix", 23 | "Value": ".gz" 24 | } 25 | ] 26 | } 27 | } 28 | }, 29 | { 30 | "Id": "exS3-v2--12e4385ca3170e0460cad7afa8c9f8ed", 31 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test2-production-serverless-second-test", 32 | "Events": [ 33 | "s3:ObjectCreated:*" 34 | ], 35 | "Filter": { 36 | "Key": { 37 | "FilterRules": [ 38 | { 39 | "Name": "Prefix", 40 | "Value": "automated/" 41 | }, 42 | { 43 | "Name": "Suffix", 44 | "Value": ".txt" 45 | } 46 | ] 47 | } 48 | } 49 | } 50 | ] 51 | } 52 | }, 53 | "addedWithAliases": { 54 | "bucket": "s3-serverless-test", 55 | "results": { 56 | "TopicConfigurations": [], 57 | "QueueConfigurations": [], 58 | "LambdaFunctionConfigurations": [ 59 | { 60 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 61 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test:test_alias", 62 | "Events": [ 63 | "s3:ObjectCreated:*" 64 | ], 65 | "Filter": { 66 | "Key": { 67 | "FilterRules": [ 68 | { 69 | "Name": "Prefix", 70 | "Value": "automated/" 71 | }, 72 | { 73 | "Name": "Suffix", 74 | "Value": ".gz" 75 | } 76 | ] 77 | } 78 | } 79 | }, 80 | { 81 | "Id": "exS3-v2--12e4385ca3170e0460cad7afa8c9f8ed", 82 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test2-production-serverless-second-test:test_alias", 83 | "Events": [ 84 | "s3:ObjectCreated:*" 85 | ], 86 | "Filter": { 87 | "Key": { 88 | "FilterRules": [ 89 | { 90 | "Name": "Prefix", 91 | "Value": "automated/" 92 | }, 93 | { 94 | "Name": "Suffix", 95 | "Value": ".txt" 96 | } 97 | ] 98 | } 99 | } 100 | } 101 | ] 102 | } 103 | }, 104 | "obsolete": { 105 | "bucket": "s3-serverless-test", 106 | "results": { 107 | "TopicConfigurations": [], 108 | "QueueConfigurations": [], 109 | "LambdaFunctionConfigurations": [ 110 | { 111 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 112 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test", 113 | "Events": [ 114 | "s3:ObjectCreated:*" 115 | ], 116 | "Filter": { 117 | "Key": { 118 | "FilterRules": [ 119 | { 120 | "Name": "Prefix", 121 | "Value": "automated/" 122 | }, 123 | { 124 | "Name": "Suffix", 125 | "Value": ".gz" 126 | } 127 | ] 128 | } 129 | } 130 | }, 131 | { 132 | "Id": "exS3-v2--9ffc698932e20da8219cfc206538963d", 133 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test", 134 | "Events": [ 135 | "s3:ObjectCreated:*" 136 | ], 137 | "Filter": { 138 | "Key": { 139 | "FilterRules": [ 140 | { 141 | "Name": "Prefix", 142 | "Value": "automated/" 143 | }, 144 | { 145 | "Name": "Suffix", 146 | "Value": ".txt" 147 | } 148 | ] 149 | } 150 | } 151 | } 152 | ] 153 | } 154 | }, 155 | "obsoleteWithAliases": { 156 | "bucket": "s3-serverless-test", 157 | "results": { 158 | "TopicConfigurations": [], 159 | "QueueConfigurations": [], 160 | "LambdaFunctionConfigurations": [ 161 | { 162 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 163 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test:test_alias", 164 | "Events": [ 165 | "s3:ObjectCreated:*" 166 | ], 167 | "Filter": { 168 | "Key": { 169 | "FilterRules": [ 170 | { 171 | "Name": "Prefix", 172 | "Value": "automated/" 173 | }, 174 | { 175 | "Name": "Suffix", 176 | "Value": ".gz" 177 | } 178 | ] 179 | } 180 | } 181 | }, 182 | { 183 | "Id": "exS3-v2--a1711f05b474ec45be127a5a0ca5dc1a", 184 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test:test_alias", 185 | "Events": [ 186 | "s3:ObjectCreated:*" 187 | ], 188 | "Filter": { 189 | "Key": { 190 | "FilterRules": [ 191 | { 192 | "Name": "Prefix", 193 | "Value": "automated/" 194 | }, 195 | { 196 | "Name": "Suffix", 197 | "Value": ".txt" 198 | } 199 | ] 200 | } 201 | } 202 | } 203 | ] 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /spec/fixtures/notifications_with_configurations.json: -------------------------------------------------------------------------------- 1 | { 2 | "added": { 3 | "bucket": "s3-serverless-test", 4 | "results": { 5 | "TopicConfigurations": [], 6 | "QueueConfigurations": [], 7 | "LambdaFunctionConfigurations": [ 8 | { 9 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 10 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test", 11 | "Events": [ 12 | "s3:ObjectCreated:*" 13 | ], 14 | "Filter": { 15 | "Key": { 16 | "FilterRules": [ 17 | { 18 | "Name": "Prefix", 19 | "Value": "automated/" 20 | }, 21 | { 22 | "Name": "Suffix", 23 | "Value": ".gz" 24 | } 25 | ] 26 | } 27 | } 28 | }, 29 | { 30 | "Id": "exS3-v2--12e4385ca3170e0460cad7afa8c9f8ed", 31 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test2-production-serverless-second-test", 32 | "Events": [ 33 | "s3:ObjectCreated:*" 34 | ], 35 | "Filter": { 36 | "Key": { 37 | "FilterRules": [ 38 | { 39 | "Name": "Prefix", 40 | "Value": "automated/" 41 | }, 42 | { 43 | "Name": "Suffix", 44 | "Value": ".txt" 45 | } 46 | ] 47 | } 48 | } 49 | }, 50 | { 51 | "Id": "exS3-v2--5a8adf25194cb17403b36945c2efbf8a", 52 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test", 53 | "Events": [ 54 | "s3:ObjectCreated:*" 55 | ], 56 | "Filter": { 57 | "Key": { 58 | "FilterRules": [ 59 | { 60 | "Name": "Prefix", 61 | "Value": "automated/" 62 | }, 63 | { 64 | "Name": "Suffix", 65 | "Value": ".txt" 66 | } 67 | ] 68 | } 69 | } 70 | } 71 | ] 72 | } 73 | }, 74 | "addedWithAliases": { 75 | "bucket": "s3-serverless-test", 76 | "results": { 77 | "TopicConfigurations": [], 78 | "QueueConfigurations": [], 79 | "LambdaFunctionConfigurations": [ 80 | { 81 | "Id": "exS3-v2--a1a71fe0a56f35d8a5514afbe33a187d", 82 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test:test_alias", 83 | "Events": [ 84 | "s3:ObjectCreated:*" 85 | ], 86 | "Filter": { 87 | "Key": { 88 | "FilterRules": [ 89 | { 90 | "Name": "Prefix", 91 | "Value": "automated/" 92 | }, 93 | { 94 | "Name": "Suffix", 95 | "Value": ".gz" 96 | } 97 | ] 98 | } 99 | } 100 | }, 101 | { 102 | "Id": "exS3-v2--12e4385ca3170e0460cad7afa8c9f8ed", 103 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test2-production-serverless-second-test:test_alias", 104 | "Events": [ 105 | "s3:ObjectCreated:*" 106 | ], 107 | "Filter": { 108 | "Key": { 109 | "FilterRules": [ 110 | { 111 | "Name": "Prefix", 112 | "Value": "automated/" 113 | }, 114 | { 115 | "Name": "Suffix", 116 | "Value": ".txt" 117 | } 118 | ] 119 | } 120 | } 121 | }, 122 | { 123 | "Id": "exS3-v2--27a754a85801dbc9434e1b64597d45c5", 124 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-deploy-test:test_alias", 125 | "Events": [ 126 | "s3:ObjectCreated:*" 127 | ], 128 | "Filter": { 129 | "Key": { 130 | "FilterRules": [ 131 | { 132 | "Name": "Prefix", 133 | "Value": "automated/" 134 | }, 135 | { 136 | "Name": "Suffix", 137 | "Value": ".txt" 138 | } 139 | ] 140 | } 141 | } 142 | } 143 | ] 144 | } 145 | }, 146 | "obsolete": { 147 | "bucket": "s3-serverless-test", 148 | "results": { 149 | "TopicConfigurations": [], 150 | "QueueConfigurations": [], 151 | "LambdaFunctionConfigurations": [ 152 | { 153 | "Id": "exS3-v2--9ffc698932e20da8219cfc206538963d", 154 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test", 155 | "Events": [ 156 | "s3:ObjectCreated:*" 157 | ], 158 | "Filter": { 159 | "Key": { 160 | "FilterRules": [ 161 | { 162 | "Name": "Prefix", 163 | "Value": "automated/" 164 | }, 165 | { 166 | "Name": "Suffix", 167 | "Value": ".txt" 168 | } 169 | ] 170 | } 171 | } 172 | } 173 | ] 174 | } 175 | }, 176 | "obsoleteWithAliases": { 177 | "bucket": "s3-serverless-test", 178 | "results": { 179 | "TopicConfigurations": [], 180 | "QueueConfigurations": [], 181 | "LambdaFunctionConfigurations": [ 182 | { 183 | "Id": "exS3-v2--a1711f05b474ec45be127a5a0ca5dc1a", 184 | "LambdaFunctionArn": "arn:aws:lambda:us-east-1:01234:function:serverless-test-production-serverless-second-test:test_alias", 185 | "Events": [ 186 | "s3:ObjectCreated:*" 187 | ], 188 | "Filter": { 189 | "Key": { 190 | "FilterRules": [ 191 | { 192 | "Name": "Prefix", 193 | "Value": "automated/" 194 | }, 195 | { 196 | "Name": "Suffix", 197 | "Value": ".txt" 198 | } 199 | ] 200 | } 201 | } 202 | } 203 | ] 204 | } 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@sinonjs/formatio@^2.0.0": 6 | version "2.0.0" 7 | resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-2.0.0.tgz#84db7e9eb5531df18a8c5e0bfb6e449e55e654b2" 8 | dependencies: 9 | samsam "1.3.0" 10 | 11 | "@std/esm@^0.23.3": 12 | version "0.23.4" 13 | resolved "https://registry.yarnpkg.com/@std/esm/-/esm-0.23.4.tgz#e047aeb8a79bbea1d2f62f862de5d88c8faafd37" 14 | 15 | assertion-error@^1.0.1: 16 | version "1.1.0" 17 | resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" 18 | 19 | balanced-match@^1.0.0: 20 | version "1.0.0" 21 | resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" 22 | 23 | brace-expansion@^1.1.7: 24 | version "1.1.11" 25 | resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" 26 | dependencies: 27 | balanced-match "^1.0.0" 28 | concat-map "0.0.1" 29 | 30 | browser-stdout@1.3.1: 31 | version "1.3.1" 32 | resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" 33 | 34 | chai@^4.1.2: 35 | version "4.1.2" 36 | resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" 37 | dependencies: 38 | assertion-error "^1.0.1" 39 | check-error "^1.0.1" 40 | deep-eql "^3.0.0" 41 | get-func-name "^2.0.0" 42 | pathval "^1.0.0" 43 | type-detect "^4.0.0" 44 | 45 | check-error@^1.0.1: 46 | version "1.0.2" 47 | resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" 48 | 49 | commander@2.11.0: 50 | version "2.11.0" 51 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" 52 | 53 | concat-map@0.0.1: 54 | version "0.0.1" 55 | resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" 56 | 57 | debug@3.1.0: 58 | version "3.1.0" 59 | resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" 60 | dependencies: 61 | ms "2.0.0" 62 | 63 | deep-eql@^3.0.0: 64 | version "3.0.1" 65 | resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" 66 | dependencies: 67 | type-detect "^4.0.0" 68 | 69 | diff@3.5.0, diff@^3.1.0: 70 | version "3.5.0" 71 | resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" 72 | 73 | escape-string-regexp@1.0.5: 74 | version "1.0.5" 75 | resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 76 | 77 | fs.realpath@^1.0.0: 78 | version "1.0.0" 79 | resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" 80 | 81 | get-func-name@^2.0.0: 82 | version "2.0.0" 83 | resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" 84 | 85 | glob@7.1.2: 86 | version "7.1.2" 87 | resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" 88 | dependencies: 89 | fs.realpath "^1.0.0" 90 | inflight "^1.0.4" 91 | inherits "2" 92 | minimatch "^3.0.4" 93 | once "^1.3.0" 94 | path-is-absolute "^1.0.0" 95 | 96 | growl@1.10.3: 97 | version "1.10.3" 98 | resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f" 99 | 100 | has-flag@^2.0.0: 101 | version "2.0.0" 102 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" 103 | 104 | has-flag@^3.0.0: 105 | version "3.0.0" 106 | resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 107 | 108 | he@1.1.1: 109 | version "1.1.1" 110 | resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" 111 | 112 | inflight@^1.0.4: 113 | version "1.0.6" 114 | resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" 115 | dependencies: 116 | once "^1.3.0" 117 | wrappy "1" 118 | 119 | inherits@2: 120 | version "2.0.3" 121 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" 122 | 123 | isarray@0.0.1: 124 | version "0.0.1" 125 | resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" 126 | 127 | just-extend@^1.1.27: 128 | version "1.1.27" 129 | resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-1.1.27.tgz#ec6e79410ff914e472652abfa0e603c03d60e905" 130 | 131 | lodash.get@^4.4.2: 132 | version "4.4.2" 133 | resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" 134 | 135 | lolex@^2.2.0, lolex@^2.3.2: 136 | version "2.3.2" 137 | resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.3.2.tgz#85f9450425103bf9e7a60668ea25dc43274ca807" 138 | 139 | minimatch@^3.0.4: 140 | version "3.0.4" 141 | resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" 142 | dependencies: 143 | brace-expansion "^1.1.7" 144 | 145 | minimist@0.0.8: 146 | version "0.0.8" 147 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" 148 | 149 | mkdirp@0.5.1: 150 | version "0.5.1" 151 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" 152 | dependencies: 153 | minimist "0.0.8" 154 | 155 | mocha@^5.0.4: 156 | version "5.0.4" 157 | resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.0.4.tgz#6b7aa328472da1088e69d47e75925fd3a3bb63c6" 158 | dependencies: 159 | browser-stdout "1.3.1" 160 | commander "2.11.0" 161 | debug "3.1.0" 162 | diff "3.5.0" 163 | escape-string-regexp "1.0.5" 164 | glob "7.1.2" 165 | growl "1.10.3" 166 | he "1.1.1" 167 | mkdirp "0.5.1" 168 | supports-color "4.4.0" 169 | 170 | ms@2.0.0: 171 | version "2.0.0" 172 | resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" 173 | 174 | nise@^1.2.0: 175 | version "1.3.0" 176 | resolved "https://registry.yarnpkg.com/nise/-/nise-1.3.0.tgz#7d6d506e64a0e37959495157f30a799c0436df72" 177 | dependencies: 178 | "@sinonjs/formatio" "^2.0.0" 179 | just-extend "^1.1.27" 180 | lolex "^2.3.2" 181 | path-to-regexp "^1.7.0" 182 | text-encoding "^0.6.4" 183 | 184 | once@^1.3.0: 185 | version "1.4.0" 186 | resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" 187 | dependencies: 188 | wrappy "1" 189 | 190 | path-is-absolute@^1.0.0: 191 | version "1.0.1" 192 | resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" 193 | 194 | path-to-regexp@^1.7.0: 195 | version "1.7.0" 196 | resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" 197 | dependencies: 198 | isarray "0.0.1" 199 | 200 | pathval@^1.0.0: 201 | version "1.1.0" 202 | resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" 203 | 204 | samsam@1.3.0: 205 | version "1.3.0" 206 | resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" 207 | 208 | sinon@^4.4.3: 209 | version "4.4.3" 210 | resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.4.3.tgz#f21f08a2fa8cc013c5720751b02c4484a9af31fc" 211 | dependencies: 212 | "@sinonjs/formatio" "^2.0.0" 213 | "@std/esm" "^0.23.3" 214 | diff "^3.1.0" 215 | lodash.get "^4.4.2" 216 | lolex "^2.2.0" 217 | nise "^1.2.0" 218 | supports-color "^5.1.0" 219 | type-detect "^4.0.5" 220 | 221 | supports-color@4.4.0: 222 | version "4.4.0" 223 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" 224 | dependencies: 225 | has-flag "^2.0.0" 226 | 227 | supports-color@^5.1.0: 228 | version "5.3.0" 229 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0" 230 | dependencies: 231 | has-flag "^3.0.0" 232 | 233 | text-encoding@^0.6.4: 234 | version "0.6.4" 235 | resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" 236 | 237 | type-detect@^4.0.0, type-detect@^4.0.5: 238 | version "4.0.8" 239 | resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" 240 | 241 | wrappy@1: 242 | version "1.0.2" 243 | resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" 244 | --------------------------------------------------------------------------------