diff --git a/config.js b/config.js index 8ca2fc5..0980217 100644 --- a/config.js +++ b/config.js @@ -1 +1 @@ -require('dotenv').config({ path: '.env' }) +require('dotenv').config({ path: '.env' }) diff --git a/index.js b/index.js index bc130ff..4e3db09 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/client') +module.exports = require('./lib/client') diff --git a/lib/broadcast.js b/lib/broadcast.js index c370142..2320829 100644 --- a/lib/broadcast.js +++ b/lib/broadcast.js @@ -1,15 +1,15 @@ -class Broadcast { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/broadcast/v1/broadcasts', - qs: options, - }) - } -} - -module.exports = Broadcast +class Broadcast { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/broadcast/v1/broadcasts', + qs: options, + }) + } +} + +module.exports = Broadcast diff --git a/lib/campaign.js b/lib/campaign.js index 91dd208..a111dd5 100644 --- a/lib/campaign.js +++ b/lib/campaign.js @@ -1,46 +1,46 @@ -class Campaign { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/email/public/v1/campaigns', - qs: options, - }) - } - - getById(options) { - return this.client._request({ - method: 'GET', - path: '/email/public/v1/campaigns/by-id', - qs: options, - }) - } - - getOne(id) { - if (!id || typeof id === 'function') { - const error = new Error('id parameter must be provided.') - if (typeof id === 'function') { - id(error) - } - return Promise.reject(error) - } - - return this.client._request({ - method: 'GET', - path: '/email/public/v1/campaigns/' + id, - }) - } - - events(options) { - return this.client._request({ - method: 'GET', - path: '/email/public/v1/events', - qs: options, - }) - } -} - -module.exports = Campaign +class Campaign { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/email/public/v1/campaigns', + qs: options, + }) + } + + getById(options) { + return this.client._request({ + method: 'GET', + path: '/email/public/v1/campaigns/by-id', + qs: options, + }) + } + + getOne(id) { + if (!id || typeof id === 'function') { + const error = new Error('id parameter must be provided.') + if (typeof id === 'function') { + id(error) + } + return Promise.reject(error) + } + + return this.client._request({ + method: 'GET', + path: '/email/public/v1/campaigns/' + id, + }) + } + + events(options) { + return this.client._request({ + method: 'GET', + path: '/email/public/v1/events', + qs: options, + }) + } +} + +module.exports = Campaign diff --git a/lib/client.js b/lib/client.js index b9c54c1..7604207 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,209 +1,211 @@ -const Broadcast = require('./broadcast') -const Campaign = require('./campaign') -const Company = require('./company') -const Contact = require('./contact') -const Page = require('./page') -const Deal = require('./deal') -const Engagement = require('./engagement') -const Email = require('./emails') -const File = require('./file') -const List = require('./list') -const Owner = require('./owner') -const OAuth = require('./oauth') -const Pipeline = require('./pipeline') -const Subscription = require('./subscription') -const Timeline = require('./timeline') -const Workflow = require('./workflow') -const _ = require('lodash') -const request = require('request-promise') -const EventEmitter = require('events').EventEmitter -const Bottleneck = require('bottleneck') - -const debug = require('debug')('hubspot:client') - -// define how long to wait API response before throwing a timeout error -const API_TIMEOUT = 15000 -const MAX_USE_PERCENT_DEFAULT = 90 - -class Client extends EventEmitter { - constructor(options = {}) { - super() - this.qs = {} - this.auth = undefined - this.setAuth(options) - this.setOAuth(options) - this.maxUsePercent = - typeof options.maxUsePercent !== 'undefined' - ? options.maxUsePercent - : MAX_USE_PERCENT_DEFAULT - this.baseUrl = options.baseUrl || 'http://api.hubapi.com' - this.apiTimeout = options.timeout || API_TIMEOUT - this.apiCalls = 0 - this.on('apiCall', params => { - debug('apiCall', _.pick(params, ['method', 'url'])) - this.apiCalls += 1 - }) - this.checkLimit = - options.checkLimit !== undefined ? options.checkLimit : true - this.limiter = new Bottleneck( - Object.assign( - { - maxConcurrent: 2, - minTime: 1000 / 9, - }, - options.limiter - ) - ) - - this.broadcasts = new Broadcast(this) - this.campaigns = new Campaign(this) - this.companies = new Company(this) - this.contacts = new Contact(this) - this.pages = new Page(this) - this.deals = new Deal(this) - this.emails = new Email(this) - this.engagements = new Engagement(this) - this.files = new File(this) - this.lists = new List(this) - this.oauth = new OAuth(this) - this.owners = new Owner(this) - this.pipelines = new Pipeline(this) - this.timelines = new Timeline(this) - this.subscriptions = new Subscription(this) - this.workflows = new Workflow(this) - } - - requestStats() { - return { - running: this.limiter.running(), - queued: this.limiter.queued(), - } - } - - setAccessToken(accessToken) { - this.accessToken = accessToken - this.auth = { bearer: accessToken } - } - - refreshAccessToken() { - return this.oauth.refreshAccessToken() - } - - setOAuth(options = {}) { - this.clientId = options.clientId - this.clientSecret = options.clientSecret - this.redirectUri = options.redirectUri - this.refreshToken = options.refreshToken - } - - setAuth(options = {}) { - if (options.apiKey) { - this.qs.hapikey = options.apiKey - } else if (options.accessToken) { - if (options.useOAuth1) { - this.qs.access_token = options.accessToken - } else { - // defaults to OAuth2 - this.setAccessToken(options.accessToken) - } - } - } - - _request(opts) { - const params = _.cloneDeep(opts) - if (this.auth) { - params.auth = this.auth - } - params.json = true - params.resolveWithFullResponse = true - - params.url = this.baseUrl + params.path - delete params.path - params.qs = Object.assign({}, this.qs, params.qs) - - params.qsStringifyOptions = { - arrayFormat: 'repeat', - } - - params.timeout = this.apiTimeout - - return this.checkApiLimit(params).then(() => { - this.emit('apiCall', params) - return this.limiter.schedule(() => - request(params) - .then(res => { - this.updateApiLimit(res) - return res - }) - .then(res => res.body) - ) // limit the number of concurrent requests - }) - } - - updateApiLimit(res) { - const { headers } = res - if (this.usageLimit === undefined) { - this.usageLimit = headers['x-hubspot-ratelimit-daily'] - } - if (this.usageLimit !== undefined) { - this.currentUsage = - this.usageLimit - headers['x-hubspot-ratelimit-daily-remaining'] - } - return Promise.resolve() - } - - checkApiLimit(params) { - return new Promise((resolve, reject) => { - if (this.auth) { - // don't check the api limit for the api call - resolve() - } - if (/integrations\/v1\/limit|oauth/.test(params.url)) { - // don't check the api limit for the api call - resolve() - } - if (!this.checkLimit) { - // don't check the api limit for the api call - resolve() - } - if (this.maxUsePercent === 0) { - // if maxUsePercent set to 0, do not check for the API limit (use at your own risk) - resolve() - } - if (this.currentUsage !== undefined) { - const usagePercent = (100.0 * this.currentUsage) / this.usageLimit - debug('usagePercent', usagePercent, 'apiCalls', this.apiCalls) - if (usagePercent > this.maxUsePercent) { - const err = new Error('Too close to the API limit') - err.usageLimit = this.usageLimit - err.currentUsage = this.currentUsage - err.usagePercent = usagePercent - reject(err) - } - } - resolve() - }) - } - - getApiLimit() { - this.limit = this.limit || {} - const collectedAt = this.limit.collectedAt || 0 - const recencyMinutes = (Date.now() - collectedAt) / (60 * 1000) - debug('recencyMinutes', recencyMinutes) - if (recencyMinutes < 5) { - return Promise.resolve(this.limit) - } - return this._request({ - method: 'GET', - path: '/integrations/v1/limit/daily', - }).then(results => { - this.limit = results.filter(r => r.name === 'api-calls-daily')[0] - return this.limit - }) - } -} - -module.exports = Client - -// Allow use of default import syntax in TypeScript -module.exports.default = Client +const Broadcast = require('./broadcast') +const Campaign = require('./campaign') +const Company = require('./company') +const Contact = require('./contact') +const Page = require('./page') +const Deal = require('./deal') +const Engagement = require('./engagement') +const Email = require('./emails') +const File = require('./file') +const Integrations = require('./integrations') +const List = require('./list') +const Owner = require('./owner') +const OAuth = require('./oauth') +const Pipeline = require('./pipeline') +const Subscription = require('./subscription') +const Timeline = require('./timeline') +const Workflow = require('./workflow') +const _ = require('lodash') +const request = require('request-promise') +const EventEmitter = require('events').EventEmitter +const Bottleneck = require('bottleneck') + +const debug = require('debug')('hubspot:client') + +// define how long to wait API response before throwing a timeout error +const API_TIMEOUT = 15000 +const MAX_USE_PERCENT_DEFAULT = 90 + +class Client extends EventEmitter { + constructor(options = {}) { + super() + this.qs = {} + this.auth = undefined + this.setAuth(options) + this.setOAuth(options) + this.maxUsePercent = + typeof options.maxUsePercent !== 'undefined' + ? options.maxUsePercent + : MAX_USE_PERCENT_DEFAULT + this.baseUrl = options.baseUrl || 'http://api.hubapi.com' + this.apiTimeout = options.timeout || API_TIMEOUT + this.apiCalls = 0 + this.on('apiCall', params => { + debug('apiCall', _.pick(params, ['method', 'url'])) + this.apiCalls += 1 + }) + this.checkLimit = + options.checkLimit !== undefined ? options.checkLimit : true + this.limiter = new Bottleneck( + Object.assign( + { + maxConcurrent: 2, + minTime: 1000 / 9, + }, + options.limiter + ) + ) + + this.broadcasts = new Broadcast(this) + this.campaigns = new Campaign(this) + this.companies = new Company(this) + this.contacts = new Contact(this) + this.pages = new Page(this) + this.deals = new Deal(this) + this.emails = new Email(this) + this.engagements = new Engagement(this) + this.files = new File(this) + this.integrations = new Integrations(this) + this.lists = new List(this) + this.oauth = new OAuth(this) + this.owners = new Owner(this) + this.pipelines = new Pipeline(this) + this.timelines = new Timeline(this) + this.subscriptions = new Subscription(this) + this.workflows = new Workflow(this) + } + + requestStats() { + return { + running: this.limiter.running(), + queued: this.limiter.queued(), + } + } + + setAccessToken(accessToken) { + this.accessToken = accessToken + this.auth = { bearer: accessToken } + } + + refreshAccessToken() { + return this.oauth.refreshAccessToken() + } + + setOAuth(options = {}) { + this.clientId = options.clientId + this.clientSecret = options.clientSecret + this.redirectUri = options.redirectUri + this.refreshToken = options.refreshToken + } + + setAuth(options = {}) { + if (options.apiKey) { + this.qs.hapikey = options.apiKey + } else if (options.accessToken) { + if (options.useOAuth1) { + this.qs.access_token = options.accessToken + } else { + // defaults to OAuth2 + this.setAccessToken(options.accessToken) + } + } + } + + _request(opts) { + const params = _.cloneDeep(opts) + if (this.auth) { + params.auth = this.auth + } + params.json = true + params.resolveWithFullResponse = true + + params.url = this.baseUrl + params.path + delete params.path + params.qs = Object.assign({}, this.qs, params.qs) + + params.qsStringifyOptions = { + arrayFormat: 'repeat', + } + + params.timeout = this.apiTimeout + + return this.checkApiLimit(params).then(() => { + this.emit('apiCall', params) + return this.limiter.schedule(() => + request(params) + .then(res => { + this.updateApiLimit(res) + return res + }) + .then(res => res.body) + ) // limit the number of concurrent requests + }) + } + + updateApiLimit(res) { + const { headers } = res + if (this.usageLimit === undefined) { + this.usageLimit = headers['x-hubspot-ratelimit-daily'] + } + if (this.usageLimit !== undefined) { + this.currentUsage = + this.usageLimit - headers['x-hubspot-ratelimit-daily-remaining'] + } + return Promise.resolve() + } + + checkApiLimit(params) { + return new Promise((resolve, reject) => { + if (this.auth) { + // don't check the api limit for the api call + resolve() + } + if (/integrations\/v1\/limit|oauth/.test(params.url)) { + // don't check the api limit for the api call + resolve() + } + if (!this.checkLimit) { + // don't check the api limit for the api call + resolve() + } + if (this.maxUsePercent === 0) { + // if maxUsePercent set to 0, do not check for the API limit (use at your own risk) + resolve() + } + if (this.currentUsage !== undefined) { + const usagePercent = (100.0 * this.currentUsage) / this.usageLimit + debug('usagePercent', usagePercent, 'apiCalls', this.apiCalls) + if (usagePercent > this.maxUsePercent) { + const err = new Error('Too close to the API limit') + err.usageLimit = this.usageLimit + err.currentUsage = this.currentUsage + err.usagePercent = usagePercent + reject(err) + } + } + resolve() + }) + } + + getApiLimit() { + this.limit = this.limit || {} + const collectedAt = this.limit.collectedAt || 0 + const recencyMinutes = (Date.now() - collectedAt) / (60 * 1000) + debug('recencyMinutes', recencyMinutes) + if (recencyMinutes < 5) { + return Promise.resolve(this.limit) + } + return this._request({ + method: 'GET', + path: '/integrations/v1/limit/daily', + }).then(results => { + this.limit = results.filter(r => r.name === 'api-calls-daily')[0] + return this.limit + }) + } +} + +module.exports = Client + +// Allow use of default import syntax in TypeScript +module.exports.default = Client diff --git a/lib/company.js b/lib/company.js index 4ed73a6..8a03e34 100644 --- a/lib/company.js +++ b/lib/company.js @@ -1,119 +1,119 @@ -const Property = require('./company_property') - -class Company { - constructor(client) { - this.client = client - this.properties = new Property(this.client) - } - - getById(id) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/' + id, - }) - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/paged', - qs: options, - qsStringifyOptions: { - arrayFormat: 'repeat', - }, - }) - } - - getAll(options) { - return this.get(options) - } - - getRecentlyCreated(options) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/recent/created', - qs: options, - }) - } - - getRecentlyModified(options) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/recent/modified', - qs: options, - }) - } - - getByDomain(domain) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/domain/' + domain, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/companies/v2/companies/', - body: data, - }) - } - - delete(id) { - return this.client._request({ - method: 'DELETE', - path: '/companies/v2/companies/' + id, - }) - } - - update(id, data) { - return this.client._request({ - method: 'PUT', - path: '/companies/v2/companies/' + id, - body: data, - }) - } - - updateBatch(data) { - return this.client._request({ - method: 'POST', - path: '/companies/v1/batch-async/update', - body: data, - }) - } - - addContactToCompany(data) { - if (!data || !data.companyId || !data.contactVid) { - return Promise.reject( - new Error('companyId and contactVid params must be provided') - ) - } - - return this.client._request({ - method: 'PUT', - path: - '/companies/v2/companies/' + - data.companyId + - '/contacts/' + - data.contactVid, - }) - } - - getContactIds(id, options) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/' + id + '/vids', - qs: options, - }) - } - - getContacts(id, options) { - return this.client._request({ - method: 'GET', - path: '/companies/v2/companies/' + id + '/contacts', - qs: options, - }) - } -} - -module.exports = Company +const Property = require('./company_property') + +class Company { + constructor(client) { + this.client = client + this.properties = new Property(this.client) + } + + getById(id) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/' + id, + }) + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/paged', + qs: options, + qsStringifyOptions: { + arrayFormat: 'repeat', + }, + }) + } + + getAll(options) { + return this.get(options) + } + + getRecentlyCreated(options) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/recent/created', + qs: options, + }) + } + + getRecentlyModified(options) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/recent/modified', + qs: options, + }) + } + + getByDomain(domain) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/domain/' + domain, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/companies/v2/companies/', + body: data, + }) + } + + delete(id) { + return this.client._request({ + method: 'DELETE', + path: '/companies/v2/companies/' + id, + }) + } + + update(id, data) { + return this.client._request({ + method: 'PUT', + path: '/companies/v2/companies/' + id, + body: data, + }) + } + + updateBatch(data) { + return this.client._request({ + method: 'POST', + path: '/companies/v1/batch-async/update', + body: data, + }) + } + + addContactToCompany(data) { + if (!data || !data.companyId || !data.contactVid) { + return Promise.reject( + new Error('companyId and contactVid params must be provided') + ) + } + + return this.client._request({ + method: 'PUT', + path: + '/companies/v2/companies/' + + data.companyId + + '/contacts/' + + data.contactVid, + }) + } + + getContactIds(id, options) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/' + id + '/vids', + qs: options, + }) + } + + getContacts(id, options) { + return this.client._request({ + method: 'GET', + path: '/companies/v2/companies/' + id + '/contacts', + qs: options, + }) + } +} + +module.exports = Company diff --git a/lib/company_property.js b/lib/company_property.js index 44da9d4..039ac9d 100644 --- a/lib/company_property.js +++ b/lib/company_property.js @@ -1,56 +1,56 @@ -const Group = require('./company_property_group') - -class Properties { - constructor(client) { - this.client = client - this.groups = new Group(this.client) - } - - getAll(options) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/companies/properties', - qs: options, - }) - } - - get(options) { - return this.getAll(options) - } - - getByName(name) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/companies/properties/named/' + name, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/companies/properties', - body: data, - }) - } - - update(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/companies/properties/named/' + name, - body: data, - }) - } - - upsert(data) { - return this.create(data).catch(err => { - if (err.statusCode === 409) { - // if 409, the property already exists, update it - return this.update(data.name, data) - } else { - throw err - } - }) - } -} - -module.exports = Properties +const Group = require('./company_property_group') + +class Properties { + constructor(client) { + this.client = client + this.groups = new Group(this.client) + } + + getAll(options) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/companies/properties', + qs: options, + }) + } + + get(options) { + return this.getAll(options) + } + + getByName(name) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/companies/properties/named/' + name, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/companies/properties', + body: data, + }) + } + + update(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/companies/properties/named/' + name, + body: data, + }) + } + + upsert(data) { + return this.create(data).catch(err => { + if (err.statusCode === 409) { + // if 409, the property already exists, update it + return this.update(data.name, data) + } else { + throw err + } + }) + } +} + +module.exports = Properties diff --git a/lib/company_property_group.js b/lib/company_property_group.js index 5562f09..8d356d4 100644 --- a/lib/company_property_group.js +++ b/lib/company_property_group.js @@ -1,46 +1,46 @@ -class Groups { - constructor(client) { - this.client = client - } - - getAll(options) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/companies/groups', - qs: options, - }) - } - - get(options) { - return this.getAll(options) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/companies/groups', - body: data, - }) - } - - update(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/companies/groups/named/' + name, - body: data, - }) - } - - upsert(data) { - return this.create(data).catch(err => { - if (err.statusCode === 409) { - // if 409, the property group already exists, update it - return this.update(data.name, data) - } else { - throw err - } - }) - } -} - -module.exports = Groups +class Groups { + constructor(client) { + this.client = client + } + + getAll(options) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/companies/groups', + qs: options, + }) + } + + get(options) { + return this.getAll(options) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/companies/groups', + body: data, + }) + } + + update(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/companies/groups/named/' + name, + body: data, + }) + } + + upsert(data) { + return this.create(data).catch(err => { + if (err.statusCode === 409) { + // if 409, the property group already exists, update it + return this.update(data.name, data) + } else { + throw err + } + }) + } +} + +module.exports = Groups diff --git a/lib/contact.js b/lib/contact.js index 6fb043a..52b573a 100644 --- a/lib/contact.js +++ b/lib/contact.js @@ -1,127 +1,127 @@ -const Property = require('./contact_property') - -class Contact { - constructor(client) { - this.client = client - this.properties = new Property(this.client) - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/all/contacts/all', - qs: options, - }) - } - - getAll(options) { - return this.get(options) - } - - getRecentlyModified(options) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/recently_updated/contacts/recent', - qs: options, - }) - } - - getRecentlyCreated(options) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/all/contacts/recent', - qs: options, - }) - } - - getByEmail(email) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/contact/email/' + email + '/profile', - }) - } - - getByEmailBatch(emails) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/contact/emails/batch', - qs: { email: emails }, - qsStringifyOptions: { indices: false }, - }) - } - - getById(id) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/contact/vid/' + id + '/profile', - }) - } - - getByIdBatch(ids) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/contact/vids/batch', - qs: { vid: ids }, - qsStringifyOptions: { indices: false }, - }) - } - - getByToken(token) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/contact/utk/' + token + '/profile', - }) - } - - delete(id) { - return this.client._request({ - method: 'DELETE', - path: '/contacts/v1/contact/vid/' + id, - }) - } - - update(id, data) { - return this.client._request({ - method: 'POST', - path: '/contacts/v1/contact/vid/' + id + '/profile', - body: data, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/contacts/v1/contact', - body: data, - }) - } - - createOrUpdate(email, data) { - return this.client._request({ - method: 'POST', - path: '/contacts/v1/contact/createOrUpdate/email/' + email, - body: data, - }) - } - - // note: response to successful batch update is undefined by design : http://developers.hubspot.com/docs/methods/contacts/batch_create_or_update - createOrUpdateBatch(data) { - return this.client._request({ - method: 'POST', - path: '/contacts/v1/contact/batch', - body: data, - }) - } - - search(query, options) { - if (!options) options = {} - options.q = query - return this.client._request({ - method: 'GET', - path: '/contacts/v1/search/query', - qs: options, - }) - } -} - -module.exports = Contact +const Property = require('./contact_property') + +class Contact { + constructor(client) { + this.client = client + this.properties = new Property(this.client) + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/all/contacts/all', + qs: options, + }) + } + + getAll(options) { + return this.get(options) + } + + getRecentlyModified(options) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/recently_updated/contacts/recent', + qs: options, + }) + } + + getRecentlyCreated(options) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/all/contacts/recent', + qs: options, + }) + } + + getByEmail(email) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/contact/email/' + email + '/profile', + }) + } + + getByEmailBatch(emails) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/contact/emails/batch', + qs: { email: emails }, + qsStringifyOptions: { indices: false }, + }) + } + + getById(id) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/contact/vid/' + id + '/profile', + }) + } + + getByIdBatch(ids) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/contact/vids/batch', + qs: { vid: ids }, + qsStringifyOptions: { indices: false }, + }) + } + + getByToken(token) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/contact/utk/' + token + '/profile', + }) + } + + delete(id) { + return this.client._request({ + method: 'DELETE', + path: '/contacts/v1/contact/vid/' + id, + }) + } + + update(id, data) { + return this.client._request({ + method: 'POST', + path: '/contacts/v1/contact/vid/' + id + '/profile', + body: data, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/contacts/v1/contact', + body: data, + }) + } + + createOrUpdate(email, data) { + return this.client._request({ + method: 'POST', + path: '/contacts/v1/contact/createOrUpdate/email/' + email, + body: data, + }) + } + + // note: response to successful batch update is undefined by design : http://developers.hubspot.com/docs/methods/contacts/batch_create_or_update + createOrUpdateBatch(data) { + return this.client._request({ + method: 'POST', + path: '/contacts/v1/contact/batch', + body: data, + }) + } + + search(query, options) { + if (!options) options = {} + options.q = query + return this.client._request({ + method: 'GET', + path: '/contacts/v1/search/query', + qs: options, + }) + } +} + +module.exports = Contact diff --git a/lib/contact_property.js b/lib/contact_property.js index 5324200..af142d3 100644 --- a/lib/contact_property.js +++ b/lib/contact_property.js @@ -1,90 +1,90 @@ -class Properties { - constructor(client) { - this.client = client - } - - getAll(options) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/contacts/properties', - qs: options, - }) - } - - get(options) { - return this.getAll(options) - } - - getByName(name) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/contacts/properties/named/' + name, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/contacts/properties', - body: data, - }) - } - - update(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/contacts/properties/named/' + name, - body: data, - }) - } - - delete(name) { - return this.client._request({ - method: 'DELETE', - path: '/properties/v1/contacts/properties/named/' + name, - }) - } - - upsert(data) { - return this.create(data).catch(err => { - if (err.statusCode === 409) { - // if 409, the property already exists, update it - return this.update(data.name, data) - } else { - throw err - } - }) - } - - getGroups() { - return this.client._request({ - method: 'GET', - path: '/properties/v1/contacts/groups', - }) - } - - createGroup(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/contacts/groups', - body: data, - }) - } - - updateGroup(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/contacts/groups/named/' + name, - body: data, - }) - } - - deleteGroup(name) { - return this.client._request({ - method: 'DELETE', - path: '/properties/v1/contacts/groups/named/' + name, - }) - } -} - -module.exports = Properties +class Properties { + constructor(client) { + this.client = client + } + + getAll(options) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/contacts/properties', + qs: options, + }) + } + + get(options) { + return this.getAll(options) + } + + getByName(name) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/contacts/properties/named/' + name, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/contacts/properties', + body: data, + }) + } + + update(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/contacts/properties/named/' + name, + body: data, + }) + } + + delete(name) { + return this.client._request({ + method: 'DELETE', + path: '/properties/v1/contacts/properties/named/' + name, + }) + } + + upsert(data) { + return this.create(data).catch(err => { + if (err.statusCode === 409) { + // if 409, the property already exists, update it + return this.update(data.name, data) + } else { + throw err + } + }) + } + + getGroups() { + return this.client._request({ + method: 'GET', + path: '/properties/v1/contacts/groups', + }) + } + + createGroup(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/contacts/groups', + body: data, + }) + } + + updateGroup(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/contacts/groups/named/' + name, + body: data, + }) + } + + deleteGroup(name) { + return this.client._request({ + method: 'DELETE', + path: '/properties/v1/contacts/groups/named/' + name, + }) + } +} + +module.exports = Properties diff --git a/lib/deal.js b/lib/deal.js index c5118ec..201ce7c 100644 --- a/lib/deal.js +++ b/lib/deal.js @@ -1,100 +1,100 @@ -const Property = require('./deal_property') - -class Deal { - constructor(client) { - this.client = client - this.properties = new Property(client) - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/deals/v1/deal/paged', - qs: options, - useQuerystring: true, - }) - } - - getRecentlyModified(options) { - return this.client._request({ - method: 'GET', - path: '/deals/v1/deal/recent/modified', - qs: options, - }) - } - - getRecentlyCreated(options) { - return this.client._request({ - method: 'GET', - path: '/deals/v1/deal/recent/created', - qs: options, - }) - } - - getById(id) { - return this.client._request({ - method: 'GET', - path: '/deals/v1/deal/' + id, - }) - } - - getAssociated(objectType, objectId, options) { - return this.client._request({ - method: 'GET', - path: - '/deals/v1/deal/associated/' + objectType + '/' + objectId + '/paged', - qs: options, - }) - } - - deleteById(id) { - return this.client._request({ - method: 'DELETE', - path: '/deals/v1/deal/' + id, - }) - } - - updateById(id, data) { - return this.client._request({ - method: 'PUT', - path: '/deals/v1/deal/' + id, - body: data, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/deals/v1/deal', - body: data, - }) - } - - associate(id, objectType, associatedObjectId) { - return this.client._request({ - method: 'PUT', - path: - '/deals/v1/deal/' + - id + - '/associations/' + - objectType + - '?id=' + - associatedObjectId, - }) - } - - removeAssociation(id, objectType, associatedObjectId) { - return this.client._request({ - method: 'DELETE', - path: - '/deals/v1/deal/' + - id + - '/associations/' + - objectType + - '?id=' + - associatedObjectId, - }) - } -} - -module.exports = Deal +const Property = require('./deal_property') + +class Deal { + constructor(client) { + this.client = client + this.properties = new Property(client) + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/deals/v1/deal/paged', + qs: options, + useQuerystring: true, + }) + } + + getRecentlyModified(options) { + return this.client._request({ + method: 'GET', + path: '/deals/v1/deal/recent/modified', + qs: options, + }) + } + + getRecentlyCreated(options) { + return this.client._request({ + method: 'GET', + path: '/deals/v1/deal/recent/created', + qs: options, + }) + } + + getById(id) { + return this.client._request({ + method: 'GET', + path: '/deals/v1/deal/' + id, + }) + } + + getAssociated(objectType, objectId, options) { + return this.client._request({ + method: 'GET', + path: + '/deals/v1/deal/associated/' + objectType + '/' + objectId + '/paged', + qs: options, + }) + } + + deleteById(id) { + return this.client._request({ + method: 'DELETE', + path: '/deals/v1/deal/' + id, + }) + } + + updateById(id, data) { + return this.client._request({ + method: 'PUT', + path: '/deals/v1/deal/' + id, + body: data, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/deals/v1/deal', + body: data, + }) + } + + associate(id, objectType, associatedObjectId) { + return this.client._request({ + method: 'PUT', + path: + '/deals/v1/deal/' + + id + + '/associations/' + + objectType + + '?id=' + + associatedObjectId, + }) + } + + removeAssociation(id, objectType, associatedObjectId) { + return this.client._request({ + method: 'DELETE', + path: + '/deals/v1/deal/' + + id + + '/associations/' + + objectType + + '?id=' + + associatedObjectId, + }) + } +} + +module.exports = Deal diff --git a/lib/deal_property.js b/lib/deal_property.js index 35dccdd..1a6db84 100644 --- a/lib/deal_property.js +++ b/lib/deal_property.js @@ -1,63 +1,63 @@ -const Group = require('./deal_property_group') - -class Properties { - constructor(client) { - this.client = client - this.groups = new Group(this.client) - } - - getAll(options) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/deals/properties', - qs: options, - }) - } - - get(options) { - return this.getAll(options) - } - - getByName(name) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/deals/properties/named/' + name, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/deals/properties', - body: data, - }) - } - - update(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/deals/properties/named/' + name, - body: data, - }) - } - - delete(name) { - return this.client._request({ - method: 'DELETE', - path: '/properties/v1/deals/properties/named/' + name, - }) - } - - upsert(data) { - return this.create(data).catch(err => { - if (err.statusCode === 409) { - // if 409, the property already exists, update it - return this.update(data.name, data) - } else { - throw err - } - }) - } -} - -module.exports = Properties +const Group = require('./deal_property_group') + +class Properties { + constructor(client) { + this.client = client + this.groups = new Group(this.client) + } + + getAll(options) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/deals/properties', + qs: options, + }) + } + + get(options) { + return this.getAll(options) + } + + getByName(name) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/deals/properties/named/' + name, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/deals/properties', + body: data, + }) + } + + update(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/deals/properties/named/' + name, + body: data, + }) + } + + delete(name) { + return this.client._request({ + method: 'DELETE', + path: '/properties/v1/deals/properties/named/' + name, + }) + } + + upsert(data) { + return this.create(data).catch(err => { + if (err.statusCode === 409) { + // if 409, the property already exists, update it + return this.update(data.name, data) + } else { + throw err + } + }) + } +} + +module.exports = Properties diff --git a/lib/deal_property_group.js b/lib/deal_property_group.js index 046e22f..a429f68 100644 --- a/lib/deal_property_group.js +++ b/lib/deal_property_group.js @@ -1,46 +1,46 @@ -class DealGroups { - constructor(client) { - this.client = client - } - - getAll(options) { - return this.client._request({ - method: 'GET', - path: '/properties/v1/deals/groups', - qs: options, - }) - } - - get(options) { - return this.getAll(options) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/properties/v1/deals/groups', - body: data, - }) - } - - update(name, data) { - return this.client._request({ - method: 'PUT', - path: '/properties/v1/deals/groups/named/' + name, - body: data, - }) - } - - upsert(data) { - return this.create(data).catch(err => { - if (err.statusCode === 409) { - // if 409, the property group already exists, update it - return this.update(data.name, data) - } else { - throw err - } - }) - } -} - -module.exports = DealGroups +class DealGroups { + constructor(client) { + this.client = client + } + + getAll(options) { + return this.client._request({ + method: 'GET', + path: '/properties/v1/deals/groups', + qs: options, + }) + } + + get(options) { + return this.getAll(options) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/properties/v1/deals/groups', + body: data, + }) + } + + update(name, data) { + return this.client._request({ + method: 'PUT', + path: '/properties/v1/deals/groups/named/' + name, + body: data, + }) + } + + upsert(data) { + return this.create(data).catch(err => { + if (err.statusCode === 409) { + // if 409, the property group already exists, update it + return this.update(data.name, data) + } else { + throw err + } + }) + } +} + +module.exports = DealGroups diff --git a/lib/emails.js b/lib/emails.js index 1e759a9..7135855 100644 --- a/lib/emails.js +++ b/lib/emails.js @@ -1,15 +1,15 @@ -class Email { - constructor(client) { - this.client = client - } - - sendTransactionalEmail(data) { - return this.client._request({ - method: 'POST', - path: '/email/public/v1/singleEmail/send', - body: data, - }) - } -} - -module.exports = Email +class Email { + constructor(client) { + this.client = client + } + + sendTransactionalEmail(data) { + return this.client._request({ + method: 'POST', + path: '/email/public/v1/singleEmail/send', + body: data, + }) + } +} + +module.exports = Email diff --git a/lib/engagement.js b/lib/engagement.js index acd9eb3..4a04f0b 100644 --- a/lib/engagement.js +++ b/lib/engagement.js @@ -1,51 +1,51 @@ -class Engagement { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/engagements/v1/engagements/paged', - qs: options, - }) - } - - getRecentlyModified(options) { - return this.client._request({ - method: 'GET', - path: '/engagements/v1/engagements/recent/modified', - qs: options, - }) - } - - getAssociated(objectType, objectId, options) { - return this.client._request({ - method: 'GET', - path: - '/engagements/v1/engagements/associated/' + - objectType + - '/' + - objectId + - '/paged', - qs: options, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/engagements/v1/engagements', - body: data, - }) - } - - getCallDispositions() { - return this.client._request({ - method: 'GET', - path: '/calling/v1/dispositions', - }) - } -} - -module.exports = Engagement +class Engagement { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/engagements/v1/engagements/paged', + qs: options, + }) + } + + getRecentlyModified(options) { + return this.client._request({ + method: 'GET', + path: '/engagements/v1/engagements/recent/modified', + qs: options, + }) + } + + getAssociated(objectType, objectId, options) { + return this.client._request({ + method: 'GET', + path: + '/engagements/v1/engagements/associated/' + + objectType + + '/' + + objectId + + '/paged', + qs: options, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/engagements/v1/engagements', + body: data, + }) + } + + getCallDispositions() { + return this.client._request({ + method: 'GET', + path: '/calling/v1/dispositions', + }) + } +} + +module.exports = Engagement diff --git a/lib/file.js b/lib/file.js index 09b3e7b..6893c90 100644 --- a/lib/file.js +++ b/lib/file.js @@ -1,21 +1,21 @@ -class File { - constructor(client) { - this.client = client - } - - get() { - return this.client._request({ - method: 'GET', - path: '/filemanager/api/v2/files', - }) - } - - getOne(id) { - return this.client._request({ - method: 'GET', - path: '/filemanager/api/v2/files/' + id, - }) - } -} - -module.exports = File +class File { + constructor(client) { + this.client = client + } + + get() { + return this.client._request({ + method: 'GET', + path: '/filemanager/api/v2/files', + }) + } + + getOne(id) { + return this.client._request({ + method: 'GET', + path: '/filemanager/api/v2/files/' + id, + }) + } +} + +module.exports = File diff --git a/lib/integrations.js b/lib/integrations.js new file mode 100644 index 0000000..19b750f --- /dev/null +++ b/lib/integrations.js @@ -0,0 +1,14 @@ +class Integrations { + constructor(client) { + this.client = client + } + + getAccountDetails() { + return this.client._request({ + method: 'GET', + path: '/integrations/v1/me', + }) + } +} + +module.exports = Integrations diff --git a/lib/list.js b/lib/list.js index a872eb1..080239a 100644 --- a/lib/list.js +++ b/lib/list.js @@ -1,86 +1,86 @@ -class List { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists', - qs: options, - }) - } - - getOne(id) { - if (!id) { - return Promise.reject(new Error('id parameter must be provided.')) - } - - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/' + id, - }) - } - - create(data) { - return this.client._request({ - method: 'POST', - path: '/contacts/v1/lists', - body: data, - }) - } - - delete(listId) { - return this.client._request({ - method: 'DELETE', - path: `/contacts/v1/lists/${listId}`, - }) - } - - getContacts(id, options) { - if (!id) { - return Promise.reject(new Error('id parameter must be provided.')) - } - - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/' + id + '/contacts/all', - qs: options, - qsStringifyOptions: { indices: false }, - }) - } - - getRecentContacts(id, options) { - if (!id) { - return Promise.reject(new Error('id parameter must be provided.')) - } - - return this.client._request({ - method: 'GET', - path: '/contacts/v1/lists/' + id + '/contacts/recent', - qs: options, - qsStringifyOptions: { indices: false }, - }) - } - - addContacts(id, contactBody) { - if (!id) { - return Promise.reject(new Error('id parameter must be provided.')) - } - if (!contactBody) { - return Promise.reject( - new Error('contactBody parameter must be provided.') - ) - } - - var body = contactBody - - return this.client._request({ - method: 'POST', - path: '/contacts/v1/lists/' + id + '/add', - body, - }) - } -} - -module.exports = List +class List { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists', + qs: options, + }) + } + + getOne(id) { + if (!id) { + return Promise.reject(new Error('id parameter must be provided.')) + } + + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/' + id, + }) + } + + create(data) { + return this.client._request({ + method: 'POST', + path: '/contacts/v1/lists', + body: data, + }) + } + + delete(listId) { + return this.client._request({ + method: 'DELETE', + path: `/contacts/v1/lists/${listId}`, + }) + } + + getContacts(id, options) { + if (!id) { + return Promise.reject(new Error('id parameter must be provided.')) + } + + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/' + id + '/contacts/all', + qs: options, + qsStringifyOptions: { indices: false }, + }) + } + + getRecentContacts(id, options) { + if (!id) { + return Promise.reject(new Error('id parameter must be provided.')) + } + + return this.client._request({ + method: 'GET', + path: '/contacts/v1/lists/' + id + '/contacts/recent', + qs: options, + qsStringifyOptions: { indices: false }, + }) + } + + addContacts(id, contactBody) { + if (!id) { + return Promise.reject(new Error('id parameter must be provided.')) + } + if (!contactBody) { + return Promise.reject( + new Error('contactBody parameter must be provided.') + ) + } + + var body = contactBody + + return this.client._request({ + method: 'POST', + path: '/contacts/v1/lists/' + id + '/add', + body, + }) + } +} + +module.exports = List diff --git a/lib/oauth.js b/lib/oauth.js index 2ef9672..2cdf8b3 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -1,54 +1,54 @@ -const qs = require('querystring') - -class OAuth { - constructor(client) { - this.client = client - } - - getAuthorizationUrl(data) { - const params = { - client_id: this.client.clientId, - redirect_uri: this.client.redirectUri, - ...data, - } - return 'https://app.hubspot.com/oauth/authorize?' + qs.stringify(params) - } - - getAccessToken(data) { - const form = { - grant_type: 'authorization_code', - client_id: this.client.clientId, - client_secret: this.client.clientSecret, - redirect_uri: this.client.redirectUri, - ...data, - } - return this.client._request({ - method: 'POST', - path: '/oauth/v1/token', - form, - }) - } - - refreshAccessToken(data) { - const form = { - grant_type: 'refresh_token', - client_id: this.client.clientId, - client_secret: this.client.clientSecret, - redirect_uri: this.client.redirectUri, - refresh_token: this.client.refreshToken, - ...data, - } - return this.client - ._request({ - method: 'POST', - path: '/oauth/v1/token', - form, - }) - .then(results => { - this.client.setAccessToken(results.access_token) // refresh the new access_token on the client - return results - }) - } -} - -module.exports = OAuth +const qs = require('querystring') + +class OAuth { + constructor(client) { + this.client = client + } + + getAuthorizationUrl(data) { + const params = { + client_id: this.client.clientId, + redirect_uri: this.client.redirectUri, + ...data, + } + return 'https://app.hubspot.com/oauth/authorize?' + qs.stringify(params) + } + + getAccessToken(data) { + const form = { + grant_type: 'authorization_code', + client_id: this.client.clientId, + client_secret: this.client.clientSecret, + redirect_uri: this.client.redirectUri, + ...data, + } + return this.client._request({ + method: 'POST', + path: '/oauth/v1/token', + form, + }) + } + + refreshAccessToken(data) { + const form = { + grant_type: 'refresh_token', + client_id: this.client.clientId, + client_secret: this.client.clientSecret, + redirect_uri: this.client.redirectUri, + refresh_token: this.client.refreshToken, + ...data, + } + return this.client + ._request({ + method: 'POST', + path: '/oauth/v1/token', + form, + }) + .then(results => { + this.client.setAccessToken(results.access_token) // refresh the new access_token on the client + return results + }) + } +} + +module.exports = OAuth diff --git a/lib/owner.js b/lib/owner.js index 10d5fb9..a5873be 100644 --- a/lib/owner.js +++ b/lib/owner.js @@ -1,15 +1,15 @@ -class Owner { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/owners/v2/owners', - qs: options, - }) - } -} - -module.exports = Owner +class Owner { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/owners/v2/owners', + qs: options, + }) + } +} + +module.exports = Owner diff --git a/lib/page.js b/lib/page.js index 990690e..6b4aa2a 100644 --- a/lib/page.js +++ b/lib/page.js @@ -1,15 +1,15 @@ -class Page { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/content/api/v2/pages', - qs: options, - }) - } -} - -module.exports = Page +class Page { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/content/api/v2/pages', + qs: options, + }) + } +} + +module.exports = Page diff --git a/lib/pipeline.js b/lib/pipeline.js index b4d9291..16d0a32 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -1,15 +1,15 @@ -class Pipeline { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/deals/v1/pipelines', - qs: options, - }) - } -} - -module.exports = Pipeline +class Pipeline { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/deals/v1/pipelines', + qs: options, + }) + } +} + +module.exports = Pipeline diff --git a/lib/subscription.js b/lib/subscription.js index 8fb27f2..b9b547c 100644 --- a/lib/subscription.js +++ b/lib/subscription.js @@ -1,15 +1,15 @@ -class Subscription { - constructor(client) { - this.client = client - } - - get(options) { - return this.client._request({ - method: 'GET', - path: '/email/public/v1/subscriptions/timeline', - qs: options, - }) - } -} - -module.exports = Subscription +class Subscription { + constructor(client) { + this.client = client + } + + get(options) { + return this.client._request({ + method: 'GET', + path: '/email/public/v1/subscriptions/timeline', + qs: options, + }) + } +} + +module.exports = Subscription diff --git a/lib/timeline.js b/lib/timeline.js index 0f79af3..5a47814 100644 --- a/lib/timeline.js +++ b/lib/timeline.js @@ -1,67 +1,67 @@ -const guid = require('./utils/guid') - -class Timeline { - constructor(client) { - this.client = client - } - - createEventType(applicationId, userId, data) { - data['applicationId'] = data['applicationId'] || applicationId - const parameters = { - method: 'POST', - path: `/integrations/v1/${applicationId}/timeline/event-types?userId=${userId}`, - body: data, - } - return this.client._request(parameters) - } - - updateEventType(applicationId, eventTypeId, data) { - data['applicationId'] = data['applicationId'] || applicationId - const parameters = { - method: 'PUT', - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`, - body: data, - } - - return this.client._request(parameters) - } - - createEventTypeProperty(applicationId, eventTypeId, userId, data) { - const parameters = { - method: 'POST', - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties?userId=${userId}`, - body: data, - } - - return this.client._request(parameters) - } - - updateEventTypeProperty(applicationId, eventTypeId, propertyId, data) { - data['id'] = data['id'] || propertyId - const parameters = { - method: 'PUT', - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, - body: data, - } - - return this.client._request(parameters) - } - - createTimelineEvent(applicationId, eventTypeId, data) { - if (!data.id) { - data.id = guid() - } - - data.eventTypeId = data.eventTypeId || eventTypeId - - const parameters = { - method: 'PUT', - path: `/integrations/v1/${applicationId}/timeline/event`, - body: data, - } - - return this.client._request(parameters) - } -} - -module.exports = Timeline +const guid = require('./utils/guid') + +class Timeline { + constructor(client) { + this.client = client + } + + createEventType(applicationId, userId, data) { + data['applicationId'] = data['applicationId'] || applicationId + const parameters = { + method: 'POST', + path: `/integrations/v1/${applicationId}/timeline/event-types?userId=${userId}`, + body: data, + } + return this.client._request(parameters) + } + + updateEventType(applicationId, eventTypeId, data) { + data['applicationId'] = data['applicationId'] || applicationId + const parameters = { + method: 'PUT', + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`, + body: data, + } + + return this.client._request(parameters) + } + + createEventTypeProperty(applicationId, eventTypeId, userId, data) { + const parameters = { + method: 'POST', + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties?userId=${userId}`, + body: data, + } + + return this.client._request(parameters) + } + + updateEventTypeProperty(applicationId, eventTypeId, propertyId, data) { + data['id'] = data['id'] || propertyId + const parameters = { + method: 'PUT', + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, + body: data, + } + + return this.client._request(parameters) + } + + createTimelineEvent(applicationId, eventTypeId, data) { + if (!data.id) { + data.id = guid() + } + + data.eventTypeId = data.eventTypeId || eventTypeId + + const parameters = { + method: 'PUT', + path: `/integrations/v1/${applicationId}/timeline/event`, + body: data, + } + + return this.client._request(parameters) + } +} + +module.exports = Timeline diff --git a/lib/typescript/broadcast.ts b/lib/typescript/broadcast.ts index 1b5b264..873e00d 100644 --- a/lib/typescript/broadcast.ts +++ b/lib/typescript/broadcast.ts @@ -1,7 +1,7 @@ -import { RequestPromise } from 'request-promise' - -declare class Broadcast { - get(opts?: {}): RequestPromise -} - -export { Broadcast } +import { RequestPromise } from 'request-promise' + +declare class Broadcast { + get(opts?: {}): RequestPromise +} + +export { Broadcast } diff --git a/lib/typescript/campaign.ts b/lib/typescript/campaign.ts index 0ccca88..4ce28dc 100644 --- a/lib/typescript/campaign.ts +++ b/lib/typescript/campaign.ts @@ -1,11 +1,11 @@ -import { RequestPromise } from 'request-promise' - -declare class Campaign { - get(opts?: {}): RequestPromise - - getOne(id: number, appId: number): RequestPromise - - events(opts?: {}): RequestPromise -} - -export { Campaign } +import { RequestPromise } from 'request-promise' + +declare class Campaign { + get(opts?: {}): RequestPromise + + getOne(id: number, appId: number): RequestPromise + + events(opts?: {}): RequestPromise +} + +export { Campaign } diff --git a/lib/typescript/company.ts b/lib/typescript/company.ts index 64d6035..c113c76 100644 --- a/lib/typescript/company.ts +++ b/lib/typescript/company.ts @@ -1,36 +1,36 @@ -import { RequestPromise } from 'request-promise' - -import { Properties } from './company_property' - -declare class Company { - get(opts?: {}): RequestPromise - - getById(id: number): RequestPromise - - getRecentlyCreated(opts?: {}): RequestPromise - - getRecentlyModified(opts?: {}): RequestPromise - - getByDomain(domain: string): RequestPromise - - create(data: {}): RequestPromise - - addContactToCompany(data: { - companyId: number - contactVid: number - }): RequestPromise - - getContactIds(id: number, opts?: {}): RequestPromise - - getContacts(id: number, opts?: {}): RequestPromise - - update(id: number, data: {}): RequestPromise - - updateBatch(data: {}[]): RequestPromise - - delete(id: number): RequestPromise - - properties: Properties -} - -export { Company } +import { RequestPromise } from 'request-promise' + +import { Properties } from './company_property' + +declare class Company { + get(opts?: {}): RequestPromise + + getById(id: number): RequestPromise + + getRecentlyCreated(opts?: {}): RequestPromise + + getRecentlyModified(opts?: {}): RequestPromise + + getByDomain(domain: string): RequestPromise + + create(data: {}): RequestPromise + + addContactToCompany(data: { + companyId: number + contactVid: number + }): RequestPromise + + getContactIds(id: number, opts?: {}): RequestPromise + + getContacts(id: number, opts?: {}): RequestPromise + + update(id: number, data: {}): RequestPromise + + updateBatch(data: {}[]): RequestPromise + + delete(id: number): RequestPromise + + properties: Properties +} + +export { Company } diff --git a/lib/typescript/company_property.ts b/lib/typescript/company_property.ts index e1089a8..4961ddd 100644 --- a/lib/typescript/company_property.ts +++ b/lib/typescript/company_property.ts @@ -1,19 +1,19 @@ -import { RequestPromise } from 'request-promise' - -import { Groups } from './company_property_group' - -declare class Properties { - get(query?: {}): RequestPromise - - getByName(name: string): RequestPromise - - create(data: {}): RequestPromise - - update(name: string, data: {}): RequestPromise - - upsert(name: string, data: {}): RequestPromise - - groups: Groups -} - -export { Properties } +import { RequestPromise } from 'request-promise' + +import { Groups } from './company_property_group' + +declare class Properties { + get(query?: {}): RequestPromise + + getByName(name: string): RequestPromise + + create(data: {}): RequestPromise + + update(name: string, data: {}): RequestPromise + + upsert(name: string, data: {}): RequestPromise + + groups: Groups +} + +export { Properties } diff --git a/lib/typescript/company_property_group.ts b/lib/typescript/company_property_group.ts index 9b64a25..de329c2 100644 --- a/lib/typescript/company_property_group.ts +++ b/lib/typescript/company_property_group.ts @@ -1,13 +1,13 @@ -import { RequestPromise } from 'request-promise' - -declare class Groups { - get(query?: {}): RequestPromise - - create(data: {}): RequestPromise - - update(name: string, data: {}): RequestPromise - - upsert(name: string, data: {}): RequestPromise -} - -export { Groups } +import { RequestPromise } from 'request-promise' + +declare class Groups { + get(query?: {}): RequestPromise + + create(data: {}): RequestPromise + + update(name: string, data: {}): RequestPromise + + upsert(name: string, data: {}): RequestPromise +} + +export { Groups } diff --git a/lib/typescript/contact.ts b/lib/typescript/contact.ts index a484589..4f48154 100644 --- a/lib/typescript/contact.ts +++ b/lib/typescript/contact.ts @@ -1,36 +1,36 @@ -import { RequestPromise } from 'request-promise' -import { Properties } from './contact_property' - -declare class Contact { - get(opts?: {}): RequestPromise - - getByEmail(email: string): RequestPromise - - getByEmailBatch(email: string[]): RequestPromise - - getById(number: string): RequestPromise - - getByIdBatch(ids: number[]): RequestPromise - - getByToken(utk: string): RequestPromise - - update(id: number, data: {}): RequestPromise - - create(data: {}): RequestPromise - - createOrUpdateBatch(data: any[]): RequestPromise - - search(query: string): RequestPromise - - getRecentlyCreated(opts: {}): RequestPromise - - getRecentlyModified(opts: {}): RequestPromise - - createOrUpdate(email: string, data: any[]): RequestPromise - - delete(id: number): RequestPromise - - properties: Properties -} - -export { Contact } +import { RequestPromise } from 'request-promise' +import { Properties } from './contact_property' + +declare class Contact { + get(opts?: {}): RequestPromise + + getByEmail(email: string): RequestPromise + + getByEmailBatch(email: string[]): RequestPromise + + getById(number: string): RequestPromise + + getByIdBatch(ids: number[]): RequestPromise + + getByToken(utk: string): RequestPromise + + update(id: number, data: {}): RequestPromise + + create(data: {}): RequestPromise + + createOrUpdateBatch(data: any[]): RequestPromise + + search(query: string): RequestPromise + + getRecentlyCreated(opts: {}): RequestPromise + + getRecentlyModified(opts: {}): RequestPromise + + createOrUpdate(email: string, data: any[]): RequestPromise + + delete(id: number): RequestPromise + + properties: Properties +} + +export { Contact } diff --git a/lib/typescript/contact_property.ts b/lib/typescript/contact_property.ts index 276e8f6..95a0ac7 100644 --- a/lib/typescript/contact_property.ts +++ b/lib/typescript/contact_property.ts @@ -1,26 +1,26 @@ -import { RequestPromise } from 'request-promise' - -declare class Properties { - get(): RequestPromise - - getByName(name: string): RequestPromise - - create(data: {}): RequestPromise - - update(name: string, data: {}): RequestPromise - - upsert(name: string, data: {}): RequestPromise - - getGroups(): RequestPromise - getGroups(): RequestPromise - - createGroup(data: {}): void - - updateGroup(name: string, data: {}): void - - deleteGroup(name: string): void - - delete(name: string): void -} - -export { Properties } +import { RequestPromise } from 'request-promise' + +declare class Properties { + get(): RequestPromise + + getByName(name: string): RequestPromise + + create(data: {}): RequestPromise + + update(name: string, data: {}): RequestPromise + + upsert(name: string, data: {}): RequestPromise + + getGroups(): RequestPromise + getGroups(): RequestPromise + + createGroup(data: {}): void + + updateGroup(name: string, data: {}): void + + deleteGroup(name: string): void + + delete(name: string): void +} + +export { Properties } diff --git a/lib/typescript/deal.ts b/lib/typescript/deal.ts index c0b2081..7b0f26a 100644 --- a/lib/typescript/deal.ts +++ b/lib/typescript/deal.ts @@ -1,36 +1,36 @@ -import { RequestPromise } from 'request-promise' -import { Properties } from './deal_property' - -declare class Deal { - get(opts?: {}): RequestPromise - - getRecentlyCreated(opts?: {}): RequestPromise - - getRecentlyModified(opts?: {}): RequestPromise - - getById(id: number): RequestPromise - - getAssociated(objectType: string, objectId: number, opts?: {}): RequestPromise - - deleteById(id: number): RequestPromise - - updateById(id: number, data: {}): RequestPromise - - create(data: {}): RequestPromise - - associate( - id: number, - objectType: string, - associatedObjectId: number - ): RequestPromise - - removeAssociation( - id: number, - objectType: string, - associatedObjectId: number - ): RequestPromise - - properties: Properties -} - -export { Deal } +import { RequestPromise } from 'request-promise' +import { Properties } from './deal_property' + +declare class Deal { + get(opts?: {}): RequestPromise + + getRecentlyCreated(opts?: {}): RequestPromise + + getRecentlyModified(opts?: {}): RequestPromise + + getById(id: number): RequestPromise + + getAssociated(objectType: string, objectId: number, opts?: {}): RequestPromise + + deleteById(id: number): RequestPromise + + updateById(id: number, data: {}): RequestPromise + + create(data: {}): RequestPromise + + associate( + id: number, + objectType: string, + associatedObjectId: number + ): RequestPromise + + removeAssociation( + id: number, + objectType: string, + associatedObjectId: number + ): RequestPromise + + properties: Properties +} + +export { Deal } diff --git a/lib/typescript/deal_property.ts b/lib/typescript/deal_property.ts index 35a472a..c741454 100644 --- a/lib/typescript/deal_property.ts +++ b/lib/typescript/deal_property.ts @@ -1,18 +1,18 @@ -import { RequestPromise } from 'request-promise' -import { Groups } from './deal_property_group' - -declare class Properties { - get(query?: {}): RequestPromise - - getByName(name: string): RequestPromise - - create(data: {}): RequestPromise - - update(name: string, data: {}): RequestPromise - - upsert(name: string, data: {}): RequestPromise - - groups: Groups -} - -export { Properties } +import { RequestPromise } from 'request-promise' +import { Groups } from './deal_property_group' + +declare class Properties { + get(query?: {}): RequestPromise + + getByName(name: string): RequestPromise + + create(data: {}): RequestPromise + + update(name: string, data: {}): RequestPromise + + upsert(name: string, data: {}): RequestPromise + + groups: Groups +} + +export { Properties } diff --git a/lib/typescript/deal_property_group.ts b/lib/typescript/deal_property_group.ts index 9b64a25..de329c2 100644 --- a/lib/typescript/deal_property_group.ts +++ b/lib/typescript/deal_property_group.ts @@ -1,13 +1,13 @@ -import { RequestPromise } from 'request-promise' - -declare class Groups { - get(query?: {}): RequestPromise - - create(data: {}): RequestPromise - - update(name: string, data: {}): RequestPromise - - upsert(name: string, data: {}): RequestPromise -} - -export { Groups } +import { RequestPromise } from 'request-promise' + +declare class Groups { + get(query?: {}): RequestPromise + + create(data: {}): RequestPromise + + update(name: string, data: {}): RequestPromise + + upsert(name: string, data: {}): RequestPromise +} + +export { Groups } diff --git a/lib/typescript/engagement.ts b/lib/typescript/engagement.ts index d8aa04b..bcbb1d5 100644 --- a/lib/typescript/engagement.ts +++ b/lib/typescript/engagement.ts @@ -1,13 +1,13 @@ -import { RequestPromise } from 'request-promise' - -declare class Engagement { - create(data: {}): RequestPromise - - get(opts?: {}): RequestPromise - - getRecentlyModified(opts?: {}): RequestPromise - - getAssociated(objectType: string, objectId: number, opts?: {}): RequestPromise -} - -export { Engagement } +import { RequestPromise } from 'request-promise' + +declare class Engagement { + create(data: {}): RequestPromise + + get(opts?: {}): RequestPromise + + getRecentlyModified(opts?: {}): RequestPromise + + getAssociated(objectType: string, objectId: number, opts?: {}): RequestPromise +} + +export { Engagement } diff --git a/lib/typescript/file.ts b/lib/typescript/file.ts index 5f20e66..0a6cef4 100644 --- a/lib/typescript/file.ts +++ b/lib/typescript/file.ts @@ -1,9 +1,9 @@ -import { RequestPromise } from 'request-promise' - -declare class File { - get(opts?: {}): RequestPromise - - getOne(id: number): RequestPromise -} - -export { File } +import { RequestPromise } from 'request-promise' + +declare class File { + get(opts?: {}): RequestPromise + + getOne(id: number): RequestPromise +} + +export { File } diff --git a/lib/typescript/integrations.ts b/lib/typescript/integrations.ts new file mode 100644 index 0000000..4dc3fb4 --- /dev/null +++ b/lib/typescript/integrations.ts @@ -0,0 +1,7 @@ +import { RequestPromise } from 'request-promise' + +declare class Integrations { + getAccountDetails(): RequestPromise +} + +export { Integrations } diff --git a/lib/typescript/list.ts b/lib/typescript/list.ts index 376a233..64f6ab8 100644 --- a/lib/typescript/list.ts +++ b/lib/typescript/list.ts @@ -1,15 +1,15 @@ -import { RequestPromise } from 'request-promise' - -declare class List { - get(opts?: {}): RequestPromise - - getOne(id: number): RequestPromise - - getContacts(id: number): RequestPromise - - getRecentContacts(id: number): RequestPromise - - addContacts(id: number, contactBody: {}): RequestPromise -} - -export { List } +import { RequestPromise } from 'request-promise' + +declare class List { + get(opts?: {}): RequestPromise + + getOne(id: number): RequestPromise + + getContacts(id: number): RequestPromise + + getRecentContacts(id: number): RequestPromise + + addContacts(id: number, contactBody: {}): RequestPromise +} + +export { List } diff --git a/lib/typescript/oauth.ts b/lib/typescript/oauth.ts index a467e6e..ade6e14 100644 --- a/lib/typescript/oauth.ts +++ b/lib/typescript/oauth.ts @@ -1,9 +1,9 @@ -import { RequestPromise } from 'request-promise' - -declare class OAuth { - getAuthorizationUrl(opts?: {}): string - getAccessToken(data: { code: string }): RequestPromise - refreshAccessToken(): RequestPromise -} - -export { OAuth } +import { RequestPromise } from 'request-promise' + +declare class OAuth { + getAuthorizationUrl(opts?: {}): string + getAccessToken(data: { code: string }): RequestPromise + refreshAccessToken(): RequestPromise +} + +export { OAuth } diff --git a/lib/typescript/owner.ts b/lib/typescript/owner.ts index 7152fbf..e858624 100644 --- a/lib/typescript/owner.ts +++ b/lib/typescript/owner.ts @@ -1,7 +1,7 @@ -import { RequestPromise } from 'request-promise' - -declare class Owner { - get(opts?: {}): RequestPromise -} - -export { Owner } +import { RequestPromise } from 'request-promise' + +declare class Owner { + get(opts?: {}): RequestPromise +} + +export { Owner } diff --git a/lib/typescript/page.ts b/lib/typescript/page.ts index 5214d69..4792772 100644 --- a/lib/typescript/page.ts +++ b/lib/typescript/page.ts @@ -1,7 +1,7 @@ -import { RequestPromise } from 'request-promise' - -declare class Page { - get(opts?: {}): RequestPromise -} - -export { Page } +import { RequestPromise } from 'request-promise' + +declare class Page { + get(opts?: {}): RequestPromise +} + +export { Page } diff --git a/lib/typescript/pipeline.ts b/lib/typescript/pipeline.ts index e0e4c0b..752739d 100644 --- a/lib/typescript/pipeline.ts +++ b/lib/typescript/pipeline.ts @@ -1,7 +1,7 @@ -import { RequestPromise } from 'request-promise' - -declare class Pipeline { - get(opts?: {}): RequestPromise -} - -export { Pipeline } +import { RequestPromise } from 'request-promise' + +declare class Pipeline { + get(opts?: {}): RequestPromise +} + +export { Pipeline } diff --git a/lib/typescript/subscription.ts b/lib/typescript/subscription.ts index 5a88608..27e5dbc 100644 --- a/lib/typescript/subscription.ts +++ b/lib/typescript/subscription.ts @@ -1,7 +1,7 @@ -import { RequestPromise } from 'request-promise' - -declare class Subscription { - get(opts?: {}): RequestPromise -} - -export { Subscription } +import { RequestPromise } from 'request-promise' + +declare class Subscription { + get(opts?: {}): RequestPromise +} + +export { Subscription } diff --git a/lib/utils/guid.js b/lib/utils/guid.js index add010a..e0c4f4e 100644 --- a/lib/utils/guid.js +++ b/lib/utils/guid.js @@ -1,23 +1,23 @@ -function guid() { - function s4() { - return Math.floor((1 + Math.random()) * 0x10000) - .toString(16) - .substring(1) - } - return ( - s4() + - s4() + - '-' + - s4() + - '-' + - s4() + - '-' + - s4() + - '-' + - s4() + - s4() + - s4() - ) -} - -module.exports = guid +function guid() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1) + } + return ( + s4() + + s4() + + '-' + + s4() + + '-' + + s4() + + '-' + + s4() + + '-' + + s4() + + s4() + + s4() + ) +} + +module.exports = guid diff --git a/lib/workflow.js b/lib/workflow.js index 3bcb5e2..0f740ea 100644 --- a/lib/workflow.js +++ b/lib/workflow.js @@ -1,42 +1,42 @@ -class Workflow { - constructor(client) { - this.client = client - } - - get(workflowId) { - return this.client._request({ - method: 'GET', - path: `/automation/v3/workflows/${workflowId}`, - }) - } - - getAll() { - return this.client._request({ - method: 'GET', - path: '/automation/v3/workflows', - }) - } - - enroll(workflowId, email) { - return this.client._request({ - method: 'POST', - path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`, - }) - } - - unenroll(workflowId, email) { - return this.client._request({ - method: 'DELETE', - path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`, - }) - } - - current(contactId) { - return this.client._request({ - method: 'GET', - path: `/automation/v2/workflows/enrollments/contacts/${contactId}`, - }) - } -} - -module.exports = Workflow +class Workflow { + constructor(client) { + this.client = client + } + + get(workflowId) { + return this.client._request({ + method: 'GET', + path: `/automation/v3/workflows/${workflowId}`, + }) + } + + getAll() { + return this.client._request({ + method: 'GET', + path: '/automation/v3/workflows', + }) + } + + enroll(workflowId, email) { + return this.client._request({ + method: 'POST', + path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`, + }) + } + + unenroll(workflowId, email) { + return this.client._request({ + method: 'DELETE', + path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`, + }) + } + + current(contactId) { + return this.client._request({ + method: 'GET', + path: `/automation/v2/workflows/enrollments/contacts/${contactId}`, + }) + } +} + +module.exports = Workflow diff --git a/package-lock.json b/package-lock.json index 645e123..250e53e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,30 +14,16 @@ } }, "@babel/generator": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.2.0.tgz", - "integrity": "sha512-BA75MVfRlFQG2EZgFYIwyT1r6xSkwfP2bdkY/kLZusEYWiJs4xCowab/alaEaT0wSvmVuXGqiefeBlP+7V1yKg==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", + "integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==", "dev": true, "requires": { - "@babel/types": "^7.2.0", + "@babel/types": "^7.4.0", "jsesc": "^2.5.1", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "source-map": "^0.5.0", "trim-right": "^1.0.1" - }, - "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } } }, "@babel/helper-function-name": { @@ -61,12 +47,12 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz", - "integrity": "sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", + "integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==", "dev": true, "requires": { - "@babel/types": "^7.0.0" + "@babel/types": "^7.4.0" } }, "@babel/highlight": { @@ -81,76 +67,60 @@ } }, "@babel/parser": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.2.0.tgz", - "integrity": "sha512-M74+GvK4hn1eejD9lZ7967qAwvqTZayQa3g10ag4s9uewgR7TKjeaT0YMyoq+gVfKYABiWZ4MQD701/t5e1Jhg==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.3.tgz", + "integrity": "sha512-gxpEUhTS1sGA63EGQGuA+WESPR/6tz6ng7tSHFCmaTJK/cGK8y37cBTspX+U2xCAue2IQVvF6Z0oigmjwD8YGQ==", "dev": true }, "@babel/template": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.1.2.tgz", - "integrity": "sha512-SY1MmplssORfFiLDcOETrW7fCLl+PavlwMh92rrGcikQaRq4iWPVH0MpwPpY3etVMx6RnDjXtr6VZYr/IbP/Ag==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", + "integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.1.2", - "@babel/types": "^7.1.2" + "@babel/parser": "^7.4.0", + "@babel/types": "^7.4.0" } }, "@babel/traverse": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.1.6.tgz", - "integrity": "sha512-CXedit6GpISz3sC2k2FsGCUpOhUqKdyL0lqNrImQojagnUMXf8hex4AxYFRuMkNGcvJX5QAFGzB5WJQmSv8SiQ==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.3.tgz", + "integrity": "sha512-HmA01qrtaCwwJWpSKpA948cBvU5BrmviAief/b3AVw936DtcdsTexlbyzNuDnthwhOQ37xshn7hvQaEQk7ISYQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.1.6", + "@babel/generator": "^7.4.0", "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/parser": "^7.1.6", - "@babel/types": "^7.1.6", + "@babel/helper-split-export-declaration": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/types": "^7.4.0", "debug": "^4.1.0", "globals": "^11.1.0", - "lodash": "^4.17.10" - }, - "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true - } + "lodash": "^4.17.11" } }, "@babel/types": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.2.0.tgz", - "integrity": "sha512-b4v7dyfApuKDvmPb+O488UlGuR1WbwMXFsO/cyqMrnfvRAChZKJAYeeglWTjUO1b9UghKKgepAQM5tsvBJca6A==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", + "integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==", "dev": true, "requires": { "esutils": "^2.0.2", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "to-fast-properties": "^2.0.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true - } } }, "@types/bluebird": { - "version": "3.5.20", - "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.20.tgz", - "integrity": "sha512-Wk41MVdF+cHBfVXj/ufUHJeO3BlIQr1McbHZANErMykaCWeDSZbH5erGjNBw2/3UlRdSxZbLfSuQTzFmPOYFsA==", + "version": "3.5.26", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.26.tgz", + "integrity": "sha512-aj2mrBLn5ky0GmAg6IPXrQjnN0iB/ulozuJ+oZdrHRAzRbXjGmu4UXsNCjFvPbSaaPZmniocdOzsM392qLOlmQ==", "dev": true }, "@types/caseless": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.1.tgz", - "integrity": "sha512-FhlMa34NHp9K5MY1Uz8yb+ZvuX0pnvn3jScRSNAb75KHGB8d3rEU6hqMs3Z2vjuytcMfRg6c5CHMc3wtYyD2/A==", + "version": "0.12.2", + "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", + "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==", "dev": true }, "@types/form-data": { @@ -163,15 +133,15 @@ } }, "@types/node": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz", - "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ==", + "version": "10.14.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.5.tgz", + "integrity": "sha512-Ja7d4s0qyGFxjGeDq5S7Si25OFibSAHUi6i17UWnwNnpitADN7hah9q0Tl25gxuV5R1u2Bx+np6w4LHXfHyj/g==", "dev": true }, "@types/request": { - "version": "2.47.0", - "resolved": "https://registry.npmjs.org/@types/request/-/request-2.47.0.tgz", - "integrity": "sha512-/KXM5oev+nNCLIgBjkwbk8VqxmzI56woD4VUxn95O+YeQ8hJzcSmIZ1IN3WexiqBb6srzDo2bdMbsXxgXNkz5Q==", + "version": "2.48.1", + "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.1.tgz", + "integrity": "sha512-ZgEZ1TiD+KGA9LiAAPPJL68Id2UWfeSO62ijSXZjFJArVV+2pKcsVHmrcu+1oiE3q6eDGiFiSolRc4JHoerBBg==", "dev": true, "requires": { "@types/caseless": "*", @@ -181,9 +151,9 @@ } }, "@types/request-promise": { - "version": "4.1.41", - "resolved": "https://registry.npmjs.org/@types/request-promise/-/request-promise-4.1.41.tgz", - "integrity": "sha512-qlx6COxSTdSFHY9oX9v2zL1I05hgz5lwqYiXa2SFL2nDxAiG5KK8rnllLBH7k6OqzS3Ck0bWbxlGVdrZhS6oNw==", + "version": "4.1.43", + "resolved": "https://registry.npmjs.org/@types/request-promise/-/request-promise-4.1.43.tgz", + "integrity": "sha512-SEJaRP9jfxS7IbgjmcRfNOEbT1wcgVEgSYX0iyABO+0vkLdtB4xjvvYF6HBvYTCbSBF+KKgdtN2mfB8ua8JlXA==", "dev": true, "requires": { "@types/bluebird": "*", @@ -191,38 +161,38 @@ } }, "@types/tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha512-MDQLxNFRLasqS4UlkWMSACMKeSm1x4Q3TxzUC7KQUsh6RK1ZrQ0VEyE3yzXcBu+K8ejVj4wuX32eUG02yNp+YQ==", + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", + "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==", "dev": true }, "acorn": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.2.tgz", - "integrity": "sha512-GXmKIvbrN3TV7aVqAzVFaMW8F8wzVX7voEBRO3bDA64+EX37YSayggRJP5Xig6HYHBkWKpFg9W5gg6orklubhg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", "dev": true }, "acorn-jsx": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.0.tgz", - "integrity": "sha512-XkB50fn0MURDyww9+UYL3c1yLbOBz0ZFvrdYlGB8l+Ije1oSC75qAqrzSPjYQbdnQUzhlUGNKuesryAv0gxZOg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", + "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", "dev": true }, "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", + "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, "ansi-escapes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", - "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", "dev": true }, "ansi-regex": { @@ -249,21 +219,16 @@ "sprintf-js": "~1.0.2" } }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", "dev": true, "requires": { - "array-uniq": "^1.0.1" + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" } }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -271,9 +236,12 @@ "dev": true }, "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } }, "assert-plus": { "version": "1.0.0", @@ -281,9 +249,15 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, "assertion-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", - "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, "asynckit": { @@ -297,9 +271,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", - "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, "balanced-match": { "version": "1.0.0", @@ -308,23 +282,22 @@ "dev": true }, "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "requires": { "tweetnacl": "^0.14.3" } }, "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz", + "integrity": "sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw==" }, "bottleneck": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.3.0.tgz", - "integrity": "sha512-Zxhe8FRIiFp5/uGRxIt/s26f6bm0Z87BWzPbUUZZGLkXOldRse1I/pqASYKjcth+6D1NOpVjaqD1X6aEqH+GCw==" + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.18.0.tgz", + "integrity": "sha512-U1xiBRaokw4yEguzikOl0VrnZp6uekjpmfrh6rKtr1D+/jFjYCL6J83ZXlGtlBDwVdTmJJ+4Lg5FpB3xmLSiyA==" }, "brace-expansion": { "version": "1.1.11", @@ -337,9 +310,9 @@ } }, "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "buffer-from": { @@ -348,25 +321,10 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "^0.2.0" - } - }, "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, "caseless": { @@ -375,23 +333,23 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", "dev": true, "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" + "pathval": "^1.1.0", + "type-detect": "^4.0.5" } }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", @@ -411,12 +369,6 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -432,10 +384,6 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, - "co": { - "version": "4.6.0", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -452,17 +400,17 @@ "dev": true }, "combined-stream": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", - "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", "requires": { "delayed-stream": "~1.0.0" } }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, "concat-map": { @@ -480,7 +428,7 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cross-env": { "version": "5.2.0", @@ -514,18 +462,11 @@ } }, "debug": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", - "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "requires": { "ms": "^2.1.1" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - } } }, "deep-eql": { @@ -549,19 +490,13 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "del": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", "dev": true, "requires": { - "globby": "^5.0.0", - "is-path-cwd": "^1.0.0", - "is-path-in-cwd": "^1.0.0", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "rimraf": "^2.2.8" + "object-keys": "^1.0.12" } }, "delayed-stream": { @@ -570,15 +505,15 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "diff": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz", - "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { "esutils": "^2.0.2" @@ -591,23 +526,54 @@ "dev": true }, "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "requires": { - "jsbn": "~0.1.0" + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, "requires": { "is-arrayish": "^0.2.1" } }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -615,87 +581,53 @@ "dev": true }, "eslint": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", - "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.5.3", + "ajv": "^6.9.1", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^4.0.1", - "doctrine": "^2.1.0", - "eslint-scope": "^4.0.0", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", - "espree": "^4.0.0", + "espree": "^5.0.1", "esquery": "^1.0.1", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", + "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", "glob": "^7.1.2", "globals": "^11.7.0", "ignore": "^4.0.6", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.1.0", - "is-resolvable": "^1.1.0", - "js-yaml": "^3.12.0", + "inquirer": "^6.2.2", + "js-yaml": "^3.13.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", "progress": "^2.0.0", "regexpp": "^2.0.1", - "require-uncached": "^1.0.3", "semver": "^5.5.1", "strip-ansi": "^4.0.0", "strip-json-comments": "^2.0.1", - "table": "^5.0.2", + "table": "^5.2.3", "text-table": "^0.2.0" - }, - "dependencies": { - "ajv": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", - "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", - "dev": true, - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true - } } }, "eslint-config-prettier": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.3.0.tgz", - "integrity": "sha512-Bc3bh5bAcKNvs3HOpSi6EfGA2IIp7EzWcg2tS4vP7stnXu/J1opihHDM7jI9JCIckyIDTgZLSWn7J3HY0j2JfA==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.6.0.tgz", + "integrity": "sha512-ixJ4U3uTLXwJts4rmSVW/lMXjlGwCijhBJHk8iVqKKSifeI0qgFEfWl8L63isfc8Od7EiBALF6BX3jKLluf/jQ==", "dev": true, "requires": { "get-stdin": "^6.0.0" @@ -725,17 +657,23 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, "eslint-module-utils": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz", - "integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", + "integrity": "sha512-14tltLm38Eu3zS+mt0KvILC3q8jyIAH518MlG+HO0p+yK885Lb1UHTY/UgR91eOyGdmxAPb+OLoW4znqIT6Ndw==", "dev": true, "requires": { "debug": "^2.6.8", - "pkg-dir": "^1.0.0" + "pkg-dir": "^2.0.0" }, "dependencies": { "debug": { @@ -746,35 +684,42 @@ "requires": { "ms": "2.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, "eslint-plugin-es": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.3.1.tgz", - "integrity": "sha512-9XcVyZiQRVeFjqHw8qHNDAZcQLqaHlOGGpeYqzYh8S4JYCWTCO3yzyen8yVmA5PratfzTRWDwCOFphtDEG+w/w==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.4.0.tgz", + "integrity": "sha512-XfFmgFdIUDgvaRAlaXUkxrRg5JSADoRC8IkKLc/cISeR3yHVMefFHQZpcyXXEUUPHfy5DwviBcrfqlyqEwlQVw==", "dev": true, "requires": { "eslint-utils": "^1.3.0", - "regexpp": "^2.0.0" + "regexpp": "^2.0.1" } }, "eslint-plugin-import": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz", - "integrity": "sha1-JgAu+/ylmJtyiKwEdQi9JPIXsWk=", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.2.tgz", + "integrity": "sha512-m+cSVxM7oLsIpmwNn2WXTJoReOF9f/CtLMo7qOVmKd1KntBy0hEcuNZ3erTmWjx+DxRO0Zcrm5KwAvI9wHcV5g==", "dev": true, "requires": { - "builtin-modules": "^1.1.1", + "array-includes": "^3.0.3", "contains-path": "^0.1.0", - "debug": "^2.6.8", + "debug": "^2.6.9", "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.1", - "eslint-module-utils": "^2.1.1", - "has": "^1.0.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.3", - "read-pkg-up": "^2.0.0" + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.0", + "has": "^1.0.3", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "read-pkg-up": "^2.0.0", + "resolve": "^1.10.0" }, "dependencies": { "debug": { @@ -795,6 +740,12 @@ "esutils": "^2.0.2", "isarray": "^1.0.0" } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -810,32 +761,21 @@ "minimatch": "^3.0.4", "resolve": "^1.8.1", "semver": "^5.5.0" - }, - "dependencies": { - "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", - "dev": true, - "requires": { - "path-parse": "^1.0.5" - } - } } }, "eslint-plugin-prettier": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz", - "integrity": "sha512-4g11opzhqq/8+AMmo5Vc2Gn7z9alZ4JqrbZ+D4i8KlSyxeQhZHlmIrY8U9Akf514MoEhogPa87Jgkq87aZ2Ohw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz", + "integrity": "sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ==", "dev": true, "requires": { "prettier-linter-helpers": "^1.0.0" } }, "eslint-plugin-promise": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.0.1.tgz", - "integrity": "sha512-Si16O0+Hqz1gDHsys6RtFRrW7cCTB6P7p3OJmKp3Y3dxpQE2qwOA7d3xnV+0mBmrPoi0RBnxlCKvqu70te6wjg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.1.1.tgz", + "integrity": "sha512-faAHw7uzlNPy7b45J1guyjazw28M+7gJokKUjC5JSFoYfUEyy6Gw/i7YQvmv2Yk00sUjWcmzXQLpU1Ki/C2IZQ==", "dev": true }, "eslint-plugin-standard": { @@ -845,9 +785,9 @@ "dev": true }, "eslint-scope": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", - "integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", "dev": true, "requires": { "esrecurse": "^4.1.0", @@ -867,12 +807,12 @@ "dev": true }, "espree": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-4.1.0.tgz", - "integrity": "sha512-I5BycZW6FCVIub93TeVY1s7vjhP9CY6cXCznIRfiig7nRviKZYdRnj/sHEWC6A7WE9RDWOFq9+7OsWSYz8qv2w==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", "dev": true, "requires": { - "acorn": "^6.0.2", + "acorn": "^6.0.7", "acorn-jsx": "^5.0.0", "eslint-visitor-keys": "^1.0.0" } @@ -914,9 +854,9 @@ "dev": true }, "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, "external-editor": { "version": "3.0.3", @@ -935,9 +875,9 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, "fast-deep-equal": { - "version": "1.0.0", - "resolved": false, - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-diff": { "version": "1.2.0", @@ -966,49 +906,52 @@ } }, "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "^2.0.1" } }, "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", "dev": true, "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "locate-path": "^2.0.0" } }, "flat-cache": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", - "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", "dev": true, "requires": { - "circular-json": "^0.3.1", - "del": "^2.0.2", - "graceful-fs": "^4.1.2", - "write": "^0.2.1" + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" } }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "dev": true + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", - "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "1.0.6", + "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, @@ -1051,9 +994,9 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -1065,35 +1008,21 @@ } }, "globals": { - "version": "11.8.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", - "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", + "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==", "dev": true }, - "globby": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "arrify": "^1.0.0", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", "dev": true }, "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, "har-schema": { @@ -1102,21 +1031,21 @@ "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" }, "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "requires": { - "ajv": "^5.1.0", + "ajv": "^6.5.5", "har-schema": "^2.0.0" } }, "has": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "^1.1.1" } }, "has-flag": { @@ -1125,6 +1054,12 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", @@ -1132,9 +1067,9 @@ "dev": true }, "hosted-git-info": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", "dev": true }, "http-signature": { @@ -1162,6 +1097,16 @@ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, + "import-fresh": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", + "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -1185,31 +1130,40 @@ "dev": true }, "inquirer": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz", - "integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", + "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", "dev": true, "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", "cli-cursor": "^2.1.0", "cli-width": "^2.0.0", - "external-editor": "^3.0.0", + "external-editor": "^3.0.3", "figures": "^2.0.0", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "mute-stream": "0.0.7", "run-async": "^2.2.0", - "rxjs": "^6.1.0", + "rxjs": "^6.4.0", "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", + "strip-ansi": "^5.1.0", "through": "^2.3.6" }, "dependencies": { - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } } } }, @@ -1219,14 +1173,17 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", @@ -1234,42 +1191,30 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, - "is-path-cwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", - "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "is-path-in-cwd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", - "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", "dev": true, "requires": { - "is-path-inside": "^1.0.0" + "has": "^1.0.1" } }, - "is-path-inside": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", "dev": true, "requires": { - "path-is-inside": "^1.0.1" + "has-symbols": "^1.0.0" } }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, - "is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1299,15 +1244,15 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, "istanbul-lib-coverage": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", - "integrity": "sha512-nPvSZsVlbG9aLhZYaC3Oi1gT/tpyo3Yt5fNyf6NmcKIayz4VV/txxJFFKAK/gU4dcNn8ehsanBbVHVl0+amOLA==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-LXTBICkMARVgo579kWDm8SqfB6nvSDKNqIOBEjmJRnL04JvoMHCYGWaMddQnseJYtkEuEvO/sIcOxPLk9gERug==", "dev": true }, "istanbul-lib-instrument": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.0.0.tgz", - "integrity": "sha512-eQY9vN9elYjdgN9Iv6NS/00bptm02EBBk70lRMaVjeA6QYocQgenVrSgC28TJurdnZa80AGO3ASdFN+w/njGiQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.2.0.tgz", + "integrity": "sha512-06IM3xShbNW4NgZv5AP4QH0oHqf1/ivFo8eFys0ZjPXHGldHJQWb3riYOKXqmOqfxXBfxu4B+g/iuhOPZH0RJg==", "dev": true, "requires": { "@babel/generator": "^7.0.0", @@ -1315,8 +1260,16 @@ "@babel/template": "^7.0.0", "@babel/traverse": "^7.0.0", "@babel/types": "^7.0.0", - "istanbul-lib-coverage": "^2.0.1", - "semver": "^5.5.0" + "istanbul-lib-coverage": "^2.0.4", + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.0.0.tgz", + "integrity": "sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ==", + "dev": true + } } }, "js-tokens": { @@ -1326,9 +1279,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -1338,8 +1291,7 @@ "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, "jsesc": { "version": "2.5.2", @@ -1353,8 +1305,9 @@ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" }, "json-schema-traverse": { - "version": "0.3.1", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -1408,20 +1361,12 @@ "requires": { "p-locate": "^2.0.0", "path-exists": "^3.0.0" - }, - "dependencies": { - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - } } }, "lodash": { - "version": "4.17.5", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "make-error": { "version": "1.3.5", @@ -1430,16 +1375,16 @@ "dev": true }, "mime-db": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.33.0" + "mime-db": "1.40.0" } }, "mimic-fn": { @@ -1473,21 +1418,22 @@ } }, "mocha": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.1.tgz", - "integrity": "sha512-SpwyojlnE/WRBNGtvJSNfllfm5PqEDFxcWluSIgLeSBJtXG4DmoX2NNAeEA7rP5kK+79VgtVq8nG6HskaL1ykg==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { - "browser-stdout": "1.3.0", - "commander": "2.11.0", + "browser-stdout": "1.3.1", + "commander": "2.15.1", "debug": "3.1.0", - "diff": "3.3.1", + "diff": "3.5.0", "escape-string-regexp": "1.0.5", "glob": "7.1.2", - "growl": "1.10.3", + "growl": "1.10.5", "he": "1.1.1", + "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "4.4.0" + "supports-color": "5.4.0" }, "dependencies": { "debug": { @@ -1499,28 +1445,41 @@ "ms": "2.0.0" } }, - "has-flag": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^2.0.0" + "has-flag": "^3.0.0" } } } }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "mute-stream": { "version": "0.0.7", @@ -1541,9 +1500,9 @@ "dev": true }, "nock": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/nock/-/nock-10.0.3.tgz", - "integrity": "sha512-nR3wVeDsEygk3qBdj8D/QLOjoXqTRGUaWaxJW+RVfcQKm0ByaYDiq9crsp02g1725V3EGOPrZPXzphqfhosrlA==", + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/nock/-/nock-10.0.6.tgz", + "integrity": "sha512-b47OWj1qf/LqSQYnmokNWM8D88KvUl2y7jT0567NB3ZBAZFz2bWp2PC81Xn7u8F2/vJxzkzNZybnemeFa7AZ2w==", "dev": true, "requires": { "chai": "^4.1.2", @@ -1558,66 +1517,49 @@ } }, "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, "nyc": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/nyc/-/nyc-13.1.0.tgz", - "integrity": "sha512-3GyY6TpQ58z9Frpv4GMExE1SV2tAgYqC7HSy2omEhNiCT3mhT9NyiOvIE8zkbuJVFzmvvNTnE4h/7/wQae7xLg==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-13.3.0.tgz", + "integrity": "sha512-P+FwIuro2aFG6B0Esd9ZDWUd51uZrAEoGutqZxzrVmYl3qSfkLgcQpBPBjtDFsUQLFY1dvTQJPOyeqr8S9GF8w==", "dev": true, "requires": { "archy": "^1.0.0", "arrify": "^1.0.1", - "caching-transform": "^2.0.0", + "caching-transform": "^3.0.1", "convert-source-map": "^1.6.0", - "debug-log": "^1.0.1", "find-cache-dir": "^2.0.0", "find-up": "^3.0.0", "foreground-child": "^1.5.6", "glob": "^7.1.3", - "istanbul-lib-coverage": "^2.0.1", - "istanbul-lib-hook": "^2.0.1", - "istanbul-lib-instrument": "^3.0.0", - "istanbul-lib-report": "^2.0.2", - "istanbul-lib-source-maps": "^2.0.1", - "istanbul-reports": "^2.0.1", + "istanbul-lib-coverage": "^2.0.3", + "istanbul-lib-hook": "^2.0.3", + "istanbul-lib-instrument": "^3.1.0", + "istanbul-lib-report": "^2.0.4", + "istanbul-lib-source-maps": "^3.0.2", + "istanbul-reports": "^2.1.1", "make-dir": "^1.3.0", "merge-source-map": "^1.1.0", "resolve-from": "^4.0.0", - "rimraf": "^2.6.2", + "rimraf": "^2.6.3", "signal-exit": "^3.0.2", "spawn-wrap": "^1.4.2", - "test-exclude": "^5.0.0", + "test-exclude": "^5.1.0", "uuid": "^3.3.2", - "yargs": "11.1.0", - "yargs-parser": "^9.0.2" + "yargs": "^12.0.5", + "yargs-parser": "^11.1.1" }, "dependencies": { - "align-text": { - "version": "0.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" - } - }, - "amdefine": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, "ansi-regex": { "version": "3.0.0", "bundled": true, @@ -1642,11 +1584,14 @@ "dev": true }, "async": { - "version": "1.5.2", + "version": "2.6.2", "bundled": true, - "dev": true - }, - "balanced-match": { + "dev": true, + "requires": { + "lodash": "^4.17.11" + } + }, + "balanced-match": { "version": "1.0.0", "bundled": true, "dev": true @@ -1660,55 +1605,30 @@ "concat-map": "0.0.1" } }, - "builtin-modules": { - "version": "1.1.1", - "bundled": true, - "dev": true - }, "caching-transform": { - "version": "2.0.0", + "version": "3.0.1", "bundled": true, "dev": true, "requires": { - "make-dir": "^1.0.0", - "md5-hex": "^2.0.0", - "package-hash": "^2.0.0", - "write-file-atomic": "^2.0.0" + "hasha": "^3.0.0", + "make-dir": "^1.3.0", + "package-hash": "^3.0.0", + "write-file-atomic": "^2.3.0" } }, "camelcase": { - "version": "1.2.1", - "bundled": true, - "dev": true, - "optional": true - }, - "center-align": { - "version": "0.1.3", + "version": "5.0.0", "bundled": true, - "dev": true, - "optional": true, - "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" - } + "dev": true }, "cliui": { - "version": "2.1.0", + "version": "4.1.0", "bundled": true, "dev": true, - "optional": true, "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", - "wordwrap": "0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "bundled": true, - "dev": true, - "optional": true - } + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" } }, "code-point-at": { @@ -1716,6 +1636,12 @@ "bundled": true, "dev": true }, + "commander": { + "version": "2.17.1", + "bundled": true, + "dev": true, + "optional": true + }, "commondir": { "version": "1.0.1", "bundled": true, @@ -1744,18 +1670,13 @@ } }, "debug": { - "version": "3.1.0", + "version": "4.1.1", "bundled": true, "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, - "debug-log": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, "decamelize": { "version": "1.2.0", "bundled": true, @@ -1769,6 +1690,14 @@ "strip-bom": "^3.0.0" } }, + "end-of-stream": { + "version": "1.4.1", + "bundled": true, + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, "error-ex": { "version": "1.3.2", "bundled": true, @@ -1783,12 +1712,12 @@ "dev": true }, "execa": { - "version": "0.7.0", + "version": "1.0.0", "bundled": true, "dev": true, "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", + "cross-spawn": "^6.0.0", + "get-stream": "^4.0.0", "is-stream": "^1.1.0", "npm-run-path": "^2.0.0", "p-finally": "^1.0.0", @@ -1797,11 +1726,13 @@ }, "dependencies": { "cross-spawn": { - "version": "5.1.0", + "version": "6.0.5", "bundled": true, "dev": true, "requires": { - "lru-cache": "^4.0.1", + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" } @@ -1846,9 +1777,12 @@ "dev": true }, "get-stream": { - "version": "3.0.0", + "version": "4.1.0", "bundled": true, - "dev": true + "dev": true, + "requires": { + "pump": "^3.0.0" + } }, "glob": { "version": "7.1.3", @@ -1864,28 +1798,25 @@ } }, "graceful-fs": { - "version": "4.1.11", + "version": "4.1.15", "bundled": true, "dev": true }, "handlebars": { - "version": "4.0.11", + "version": "4.1.0", "bundled": true, "dev": true, "requires": { - "async": "^1.4.0", + "async": "^2.5.0", "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" }, "dependencies": { "source-map": { - "version": "0.4.4", + "version": "0.6.1", "bundled": true, - "dev": true, - "requires": { - "amdefine": ">=0.0.4" - } + "dev": true } } }, @@ -1894,6 +1825,14 @@ "bundled": true, "dev": true }, + "hasha": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "is-stream": "^1.0.1" + } + }, "hosted-git-info": { "version": "2.7.1", "bundled": true, @@ -1919,7 +1858,7 @@ "dev": true }, "invert-kv": { - "version": "1.0.0", + "version": "2.0.0", "bundled": true, "dev": true }, @@ -1928,20 +1867,6 @@ "bundled": true, "dev": true }, - "is-buffer": { - "version": "1.1.6", - "bundled": true, - "dev": true, - "optional": true - }, - "is-builtin-module": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, "is-fullwidth-code-point": { "version": "2.0.0", "bundled": true, @@ -1958,12 +1883,12 @@ "dev": true }, "istanbul-lib-coverage": { - "version": "2.0.1", + "version": "2.0.3", "bundled": true, "dev": true }, "istanbul-lib-hook": { - "version": "2.0.1", + "version": "2.0.3", "bundled": true, "dev": true, "requires": { @@ -1971,22 +1896,32 @@ } }, "istanbul-lib-report": { - "version": "2.0.2", + "version": "2.0.4", "bundled": true, "dev": true, "requires": { - "istanbul-lib-coverage": "^2.0.1", + "istanbul-lib-coverage": "^2.0.3", "make-dir": "^1.3.0", - "supports-color": "^5.4.0" + "supports-color": "^6.0.0" + }, + "dependencies": { + "supports-color": { + "version": "6.1.0", + "bundled": true, + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "istanbul-lib-source-maps": { - "version": "2.0.1", + "version": "3.0.2", "bundled": true, "dev": true, "requires": { - "debug": "^3.1.0", - "istanbul-lib-coverage": "^2.0.1", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^2.0.3", "make-dir": "^1.3.0", "rimraf": "^2.6.2", "source-map": "^0.6.1" @@ -2000,11 +1935,11 @@ } }, "istanbul-reports": { - "version": "2.0.1", + "version": "2.1.1", "bundled": true, "dev": true, "requires": { - "handlebars": "^4.0.11" + "handlebars": "^4.1.0" } }, "json-parse-better-errors": { @@ -2012,27 +1947,12 @@ "bundled": true, "dev": true }, - "kind-of": { - "version": "3.2.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "lazy-cache": { - "version": "1.0.4", - "bundled": true, - "dev": true, - "optional": true - }, "lcid": { - "version": "1.0.0", + "version": "2.0.0", "bundled": true, "dev": true, "requires": { - "invert-kv": "^1.0.0" + "invert-kv": "^2.0.0" } }, "load-json-file": { @@ -2055,19 +1975,18 @@ "path-exists": "^3.0.0" } }, - "lodash.flattendeep": { - "version": "4.4.0", + "lodash": { + "version": "4.17.11", "bundled": true, "dev": true }, - "longest": { - "version": "1.0.1", + "lodash.flattendeep": { + "version": "4.4.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "lru-cache": { - "version": "4.1.3", + "version": "4.1.5", "bundled": true, "dev": true, "requires": { @@ -2083,25 +2002,22 @@ "pify": "^3.0.0" } }, - "md5-hex": { - "version": "2.0.0", + "map-age-cleaner": { + "version": "0.1.3", "bundled": true, "dev": true, "requires": { - "md5-o-matic": "^0.1.1" + "p-defer": "^1.0.0" } }, - "md5-o-matic": { - "version": "0.1.1", - "bundled": true, - "dev": true - }, "mem": { - "version": "1.1.0", + "version": "4.1.0", "bundled": true, "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^1.0.0", + "p-is-promise": "^2.0.0" } }, "merge-source-map": { @@ -2153,17 +2069,22 @@ } }, "ms": { - "version": "2.0.0", + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "nice-try": { + "version": "1.0.5", "bundled": true, "dev": true }, "normalize-package-data": { - "version": "2.4.0", + "version": "2.5.0", "bundled": true, "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } @@ -2204,23 +2125,33 @@ "dev": true }, "os-locale": { - "version": "2.1.0", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "execa": "^1.0.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" } }, + "p-defer": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, "p-finally": { "version": "1.0.0", "bundled": true, "dev": true }, - "p-limit": { + "p-is-promise": { "version": "2.0.0", "bundled": true, + "dev": true + }, + "p-limit": { + "version": "2.1.0", + "bundled": true, "dev": true, "requires": { "p-try": "^2.0.0" @@ -2240,13 +2171,13 @@ "dev": true }, "package-hash": { - "version": "2.0.0", + "version": "3.0.0", "bundled": true, "dev": true, "requires": { - "graceful-fs": "^4.1.11", + "graceful-fs": "^4.1.15", + "hasha": "^3.0.0", "lodash.flattendeep": "^4.4.0", - "md5-hex": "^2.0.0", "release-zalgo": "^1.0.0" } }, @@ -2274,6 +2205,11 @@ "bundled": true, "dev": true }, + "path-parse": { + "version": "1.0.6", + "bundled": true, + "dev": true + }, "path-type": { "version": "3.0.0", "bundled": true, @@ -2300,6 +2236,15 @@ "bundled": true, "dev": true }, + "pump": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "read-pkg": { "version": "3.0.0", "bundled": true, @@ -2327,12 +2272,6 @@ "es6-error": "^4.0.1" } }, - "repeat-string": { - "version": "1.6.1", - "bundled": true, - "dev": true, - "optional": true - }, "require-directory": { "version": "2.1.1", "bundled": true, @@ -2343,26 +2282,25 @@ "bundled": true, "dev": true }, - "resolve-from": { - "version": "4.0.0", - "bundled": true, - "dev": true - }, - "right-align": { - "version": "0.1.3", + "resolve": { + "version": "1.10.0", "bundled": true, "dev": true, - "optional": true, "requires": { - "align-text": "^0.1.1" + "path-parse": "^1.0.6" } }, + "resolve-from": { + "version": "4.0.0", + "bundled": true, + "dev": true + }, "rimraf": { - "version": "2.6.2", + "version": "2.6.3", "bundled": true, "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { @@ -2371,7 +2309,7 @@ "dev": true }, "semver": { - "version": "5.5.0", + "version": "5.6.0", "bundled": true, "dev": true }, @@ -2398,12 +2336,6 @@ "bundled": true, "dev": true }, - "source-map": { - "version": "0.5.7", - "bundled": true, - "dev": true, - "optional": true - }, "spawn-wrap": { "version": "1.4.2", "bundled": true, @@ -2418,7 +2350,7 @@ } }, "spdx-correct": { - "version": "3.0.0", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { @@ -2427,7 +2359,7 @@ } }, "spdx-exceptions": { - "version": "2.1.0", + "version": "2.2.0", "bundled": true, "dev": true }, @@ -2441,7 +2373,7 @@ } }, "spdx-license-ids": { - "version": "3.0.0", + "version": "3.0.3", "bundled": true, "dev": true }, @@ -2472,16 +2404,8 @@ "bundled": true, "dev": true }, - "supports-color": { - "version": "5.4.0", - "bundled": true, - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, "test-exclude": { - "version": "5.0.0", + "version": "5.1.0", "bundled": true, "dev": true, "requires": { @@ -2492,43 +2416,30 @@ } }, "uglify-js": { - "version": "2.8.29", + "version": "3.4.9", "bundled": true, "dev": true, "optional": true, "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" + "commander": "~2.17.1", + "source-map": "~0.6.1" }, "dependencies": { - "yargs": { - "version": "3.10.0", + "source-map": { + "version": "0.6.1", "bundled": true, "dev": true, - "optional": true, - "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" - } + "optional": true } } }, - "uglify-to-browserify": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, "uuid": { "version": "3.3.2", "bundled": true, "dev": true }, "validate-npm-package-license": { - "version": "3.0.3", + "version": "3.0.4", "bundled": true, "dev": true, "requires": { @@ -2549,12 +2460,6 @@ "bundled": true, "dev": true }, - "window-size": { - "version": "0.1.0", - "bundled": true, - "dev": true, - "optional": true - }, "wordwrap": { "version": "0.0.3", "bundled": true, @@ -2608,7 +2513,7 @@ "dev": true }, "write-file-atomic": { - "version": "2.3.0", + "version": "2.4.2", "bundled": true, "dev": true, "requires": { @@ -2618,7 +2523,7 @@ } }, "y18n": { - "version": "3.2.1", + "version": "4.0.0", "bundled": true, "dev": true }, @@ -2628,100 +2533,44 @@ "dev": true }, "yargs": { - "version": "11.1.0", + "version": "12.0.5", "bundled": true, "dev": true, "requires": { "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", + "decamelize": "^1.2.0", + "find-up": "^3.0.0", "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", + "os-locale": "^3.0.0", "require-directory": "^2.1.1", "require-main-filename": "^1.0.1", "set-blocking": "^2.0.0", "string-width": "^2.0.0", "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - }, - "dependencies": { - "cliui": { - "version": "4.1.0", - "bundled": true, - "dev": true, - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, - "find-up": { - "version": "2.1.0", - "bundled": true, - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "bundled": true, - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "bundled": true, - "dev": true - } + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^11.1.1" } }, "yargs-parser": { - "version": "9.0.2", + "version": "11.1.1", "bundled": true, "dev": true, "requires": { - "camelcase": "^4.1.0" - }, - "dependencies": { - "camelcase": { - "version": "4.1.0", - "bundled": true, - "dev": true - } + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" } } } }, "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, "once": { @@ -2763,9 +2612,9 @@ "dev": true }, "p-limit": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", - "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "dev": true, "requires": { "p-try": "^1.0.0" @@ -2786,6 +2635,15 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -2796,13 +2654,10 @@ } }, "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true }, "path-is-absolute": { "version": "1.0.1", @@ -2823,9 +2678,9 @@ "dev": true }, "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "path-type": { @@ -2854,36 +2709,15 @@ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, "pkg-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", "dev": true, "requires": { - "find-up": "^1.0.0" + "find-up": "^2.1.0" } }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true - }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -2891,9 +2725,9 @@ "dev": true }, "prettier": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz", - "integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.0.tgz", + "integrity": "sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw==", "dev": true }, "prettier-linter-helpers": { @@ -2906,9 +2740,9 @@ } }, "progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.1.tgz", - "integrity": "sha512-OE+a6vzqazc+K6LxJrX5UPyKFvGnL5CYmq2jFGNIBWHpc4QyE49/YOumcrpQFJpfejmvRtbJzgO1zPmMCqlbBg==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, "propagate": { @@ -2917,10 +2751,15 @@ "integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk=", "dev": true }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==" + }, "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { "version": "6.5.2", @@ -2946,17 +2785,6 @@ "requires": { "find-up": "^2.0.0", "read-pkg": "^2.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - } } }, "regexpp": { @@ -2966,74 +2794,64 @@ "dev": true }, "request": { - "version": "2.87.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", - "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", "requires": { "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", + "aws4": "^1.8.0", "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "tough-cookie": "~2.3.3", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" + "uuid": "^3.3.2" } }, "request-promise": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.2.tgz", - "integrity": "sha1-0epG1lSm7k+O5qT+oQGMIpEZBLQ=", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.4.tgz", + "integrity": "sha512-8wgMrvE546PzbR5WbYxUQogUnUDfM0S7QIFZMID+J73vdFARkFy+HElj4T+MWYhpXwlLp0EQ8Zoj8xUA0he4Vg==", "requires": { "bluebird": "^3.5.0", - "request-promise-core": "1.1.1", - "stealthy-require": "^1.1.0", - "tough-cookie": ">=2.3.3" + "request-promise-core": "1.1.2", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" } }, "request-promise-core": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", - "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", - "requires": { - "lodash": "^4.13.1" - } - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.2.tgz", + "integrity": "sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==", "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" + "lodash": "^4.17.11" } }, "resolve": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "^1.0.6" } }, "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "restore-cursor": { @@ -3047,12 +2865,12 @@ } }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "run-async": { @@ -3065,29 +2883,28 @@ } }, "rxjs": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", - "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.1.tgz", + "integrity": "sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg==", "dev": true, "requires": { "tslib": "^1.9.0" } }, "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true }, "shebang-command": { @@ -3112,49 +2929,70 @@ "dev": true }, "slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", "is-fullwidth-code-point": "^2.0.0" } }, "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true }, "source-map-support": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", - "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "spdx-correct": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", - "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, "requires": { - "spdx-license-ids": "^1.0.2" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, - "spdx-expression-parse": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", - "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "spdx-license-ids": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", - "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", + "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "dev": true }, "sprintf-js": { @@ -3164,9 +3002,9 @@ "dev": true }, "sshpk": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", - "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", @@ -3175,6 +3013,7 @@ "ecc-jsbn": "~0.1.1", "getpass": "^0.1.1", "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" } }, @@ -3224,46 +3063,42 @@ } }, "table": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", - "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/table/-/table-5.2.3.tgz", + "integrity": "sha512-N2RsDAMvDLvYwFcwbPyF3VmVSSkuF+G1e+8inhBLtHpvwXGw4QRPEZhihQNeEN0i1up6/f6ObCJXNdlRG3YVyQ==", "dev": true, "requires": { - "ajv": "^6.5.3", - "lodash": "^4.17.10", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "ajv": "^6.9.1", + "lodash": "^4.17.11", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" }, "dependencies": { - "ajv": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", - "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" } }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", - "dev": true + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } } } }, @@ -3295,11 +3130,19 @@ "dev": true }, "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "requires": { + "psl": "^1.1.24", "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + } } }, "trim-right": { @@ -3349,8 +3192,7 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, "type-check": { "version": "0.3.2", @@ -3362,47 +3204,38 @@ } }, "type-detect": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz", - "integrity": "sha512-N9IvkQslUGYGC24RkJk1ba99foK6TkwC2FHAEBlQFBP0RxQZS8ZpJuAZcwiY/w9ZJHFQb1aOXBI60OdxhTrwEQ==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, "typescript": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.3.tgz", - "integrity": "sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==", + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", "dev": true }, "uri-js": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, "requires": { "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } } }, "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" }, "validate-npm-package-license": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", - "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { - "spdx-correct": "~1.0.0", - "spdx-expression-parse": "~1.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, "verror": { @@ -3437,9 +3270,9 @@ "dev": true }, "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", "dev": true, "requires": { "mkdirp": "^0.5.1" diff --git a/test/broadcasts.js b/test/broadcasts.js index 44dbfbb..107785a 100644 --- a/test/broadcasts.js +++ b/test/broadcasts.js @@ -1,23 +1,23 @@ -const { expect } = require('chai') -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') - -describe('broadcasts', function() { - const broadcastsGetEndpoint = { - path: '/broadcast/v1/broadcasts', - response: [], - } - fakeHubspotApi.setupServer({ getEndpoints: [broadcastsGetEndpoint] }) - - describe('get', function() { - it('Should return details on a set of broadcast messages', function() { - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'fake-token', - }) - - return hubspot.broadcasts - .get() - .then(data => expect(data).to.be.a('array')) - }) - }) -}) +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') + +describe('broadcasts', function() { + const broadcastsGetEndpoint = { + path: '/broadcast/v1/broadcasts', + response: [], + } + fakeHubspotApi.setupServer({ getEndpoints: [broadcastsGetEndpoint] }) + + describe('get', function() { + it('Should return details on a set of broadcast messages', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'fake-token', + }) + + return hubspot.broadcasts + .get() + .then(data => expect(data).to.be.a('array')) + }) + }) +}) diff --git a/test/campaigns.js b/test/campaigns.js index 85d7f9d..cc9e3f9 100644 --- a/test/campaigns.js +++ b/test/campaigns.js @@ -1,95 +1,95 @@ -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') -const { expect } = require('chai') -const hubspot = () => - new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'fake-token', - }) - -describe('campaigns', function() { - describe('get', function() { - const campaignsGetEndpoint = { - path: '/email/public/v1/campaigns', - response: { campaigns: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [campaignsGetEndpoint] }) - - it('Should return campaigns with IDs', function() { - return hubspot() - .campaigns.get() - .then(data => { - expect(data.campaigns).to.be.an('array') - }) - }) - }) - - describe('getOne', function() { - const hubspotDemo = new Hubspot({ apiKey: 'demo' }) - - describe('successfully', function() { - let campaignId = 345 - const campaignGetEndpoint = { - path: `/email/public/v1/campaigns/${campaignId}`, - response: { id: campaignId }, - } - fakeHubspotApi.setupServer({ - demo: true, - getEndpoints: [campaignGetEndpoint], - }) - - beforeEach(() => { - if (process.env.NOCK_OFF) { - return hubspotDemo.campaigns.get().then(data => { - campaignId = data.campaigns[0].id - }) - } - }) - - it('Should return a campaign', function() { - return hubspotDemo.campaigns.getOne(campaignId).then(data => { - expect(data.id).to.eq(campaignId) - }) - }) - }) - - describe('unsuccessfully', function() { - it('Should error when not passed an id', function() { - return hubspotDemo.campaigns.getOne().catch(error => { - expect(error.message).to.eq('id parameter must be provided.') - }) - }) - }) - }) - - describe('getById', function() { - const campaignsByIdEndpoint = { - path: '/email/public/v1/campaigns/by-id', - response: { campaigns: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [campaignsByIdEndpoint] }) - - it('Should return a campaign', function() { - return hubspot() - .campaigns.getById() - .then(data => { - expect(data.campaigns).to.be.an('array') - }) - }) - }) - - describe('events', function() { - const eventsGetEndpoint = { - path: '/email/public/v1/events', - response: { events: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [eventsGetEndpoint] }) - - it('Should return events', function() { - return hubspot() - .campaigns.events() - .then(data => { - expect(data.events).to.be.an('array') - }) - }) - }) -}) +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') +const { expect } = require('chai') +const hubspot = () => + new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'fake-token', + }) + +describe('campaigns', function() { + describe('get', function() { + const campaignsGetEndpoint = { + path: '/email/public/v1/campaigns', + response: { campaigns: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [campaignsGetEndpoint] }) + + it('Should return campaigns with IDs', function() { + return hubspot() + .campaigns.get() + .then(data => { + expect(data.campaigns).to.be.an('array') + }) + }) + }) + + describe('getOne', function() { + const hubspotDemo = new Hubspot({ apiKey: 'demo' }) + + describe('successfully', function() { + let campaignId = 345 + const campaignGetEndpoint = { + path: `/email/public/v1/campaigns/${campaignId}`, + response: { id: campaignId }, + } + fakeHubspotApi.setupServer({ + demo: true, + getEndpoints: [campaignGetEndpoint], + }) + + beforeEach(() => { + if (process.env.NOCK_OFF) { + return hubspotDemo.campaigns.get().then(data => { + campaignId = data.campaigns[0].id + }) + } + }) + + it('Should return a campaign', function() { + return hubspotDemo.campaigns.getOne(campaignId).then(data => { + expect(data.id).to.eq(campaignId) + }) + }) + }) + + describe('unsuccessfully', function() { + it('Should error when not passed an id', function() { + return hubspotDemo.campaigns.getOne().catch(error => { + expect(error.message).to.eq('id parameter must be provided.') + }) + }) + }) + }) + + describe('getById', function() { + const campaignsByIdEndpoint = { + path: '/email/public/v1/campaigns/by-id', + response: { campaigns: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [campaignsByIdEndpoint] }) + + it('Should return a campaign', function() { + return hubspot() + .campaigns.getById() + .then(data => { + expect(data.campaigns).to.be.an('array') + }) + }) + }) + + describe('events', function() { + const eventsGetEndpoint = { + path: '/email/public/v1/events', + response: { events: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [eventsGetEndpoint] }) + + it('Should return events', function() { + return hubspot() + .campaigns.events() + .then(data => { + expect(data.events).to.be.an('array') + }) + }) + }) +}) diff --git a/test/client.js b/test/client.js index f83f1a4..acf725c 100644 --- a/test/client.js +++ b/test/client.js @@ -1,105 +1,105 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') - -describe('client', function() { - this.timeout(10000) - let hubspot - - describe('apiKey', function() { - before(() => { - hubspot = new Hubspot({ apiKey: 'demo' }) - }) - - it('should instantiate all methods', function() { - expect(hubspot.campaigns).to.be.an('object') - expect(hubspot.subscriptions).to.be.an('object') - expect(hubspot.contacts).to.be.an('object') - expect(hubspot.companies).to.be.an('object') - expect(hubspot.deals).to.be.an('object') - expect(hubspot.pipelines).to.be.an('object') - expect(hubspot.broadcasts).to.be.an('object') - expect(hubspot.lists).to.be.an('object') - expect(hubspot.files).to.be.an('object') - expect(hubspot.engagements).to.be.an('object') - expect(hubspot.workflows).to.be.an('object') - }) - - describe('getApiLimit', function() { - it('should return the api limit', function() { - return hubspot.getApiLimit().then(data => { - expect(data).to.be.an('object') - expect(data.usageLimit).to.be.a('number') - expect(data.currentUsage).to.be.a('number') - }) - }) - - it('should return from cache the second time', function() { - return hubspot.getApiLimit().then(data => { - // console.log(data) - expect(data).to.be.an('object') - expect(data.usageLimit).to.be.a('number') - expect(data.currentUsage).to.be.a('number') - }) - }) - }) - }) - - describe('bad apiKey', function() { - it('should instantiate all methods', async () => { - const hubspot = new Hubspot({ apiKey: 'bad' }) - try { - await hubspot.getApiLimit() - } catch (e) { - expect(e instanceof Error).to.equal(true) - expect(e.name).to.equal('StatusCodeError') - expect(e.statusCode).to.equal(401) - } - }) - }) - - describe('accessToken', function() { - it('should fail if no auth at all', function(done) { - const hubspot = new Hubspot() - hubspot.contacts - .get() - .then(data => { - // access_key needs contacts scope - throw new Error('this call should have failed') - }) - .catch(() => done()) - }) - - it('should work with an accessToken', function() { - if (!process.env.accessToken) { - return - } // hard to reproduce on CI. local testing only for now - const hubspot = new Hubspot({ accessToken: process.env.accessToken }) - return hubspot.contacts.get().then(data => { - // access_key used for test needs `contacts` scope - expect(data.contacts).to.be.an('array') - }) - }) - - it('should work if we have a refreshToken and refresh the access_token', function() { - if (!process.env.refreshToken) { - return - } // hard to reproduce on CI. local testing only for now - const params = { - clientId: process.env.clientId, - clientSecret: process.env.clientSecret, - redirectUri: process.env.redirectUri, - refreshToken: process.env.refreshToken, - } - const hubspot = new Hubspot(params) - return hubspot - .refreshAccessToken() - .then(() => hubspot.contacts.get()) - .then(data => { - // access_key needs contacts scope - expect(data.contacts).to.be.an('array') - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') + +describe('client', function() { + this.timeout(10000) + let hubspot + + describe('apiKey', function() { + before(() => { + hubspot = new Hubspot({ apiKey: 'demo' }) + }) + + it('should instantiate all methods', function() { + expect(hubspot.campaigns).to.be.an('object') + expect(hubspot.subscriptions).to.be.an('object') + expect(hubspot.contacts).to.be.an('object') + expect(hubspot.companies).to.be.an('object') + expect(hubspot.deals).to.be.an('object') + expect(hubspot.pipelines).to.be.an('object') + expect(hubspot.broadcasts).to.be.an('object') + expect(hubspot.lists).to.be.an('object') + expect(hubspot.files).to.be.an('object') + expect(hubspot.engagements).to.be.an('object') + expect(hubspot.workflows).to.be.an('object') + }) + + describe('getApiLimit', function() { + it('should return the api limit', function() { + return hubspot.getApiLimit().then(data => { + expect(data).to.be.an('object') + expect(data.usageLimit).to.be.a('number') + expect(data.currentUsage).to.be.a('number') + }) + }) + + it('should return from cache the second time', function() { + return hubspot.getApiLimit().then(data => { + // console.log(data) + expect(data).to.be.an('object') + expect(data.usageLimit).to.be.a('number') + expect(data.currentUsage).to.be.a('number') + }) + }) + }) + }) + + describe('bad apiKey', function() { + it('should instantiate all methods', async () => { + const hubspot = new Hubspot({ apiKey: 'bad' }) + try { + await hubspot.getApiLimit() + } catch (e) { + expect(e instanceof Error).to.equal(true) + expect(e.name).to.equal('StatusCodeError') + expect(e.statusCode).to.equal(401) + } + }) + }) + + describe('accessToken', function() { + it('should fail if no auth at all', function(done) { + const hubspot = new Hubspot() + hubspot.contacts + .get() + .then(data => { + // access_key needs contacts scope + throw new Error('this call should have failed') + }) + .catch(() => done()) + }) + + it('should work with an accessToken', function() { + if (!process.env.accessToken) { + return + } // hard to reproduce on CI. local testing only for now + const hubspot = new Hubspot({ accessToken: process.env.accessToken }) + return hubspot.contacts.get().then(data => { + // access_key used for test needs `contacts` scope + expect(data.contacts).to.be.an('array') + }) + }) + + it('should work if we have a refreshToken and refresh the access_token', function() { + if (!process.env.refreshToken) { + return + } // hard to reproduce on CI. local testing only for now + const params = { + clientId: process.env.clientId, + clientSecret: process.env.clientSecret, + redirectUri: process.env.redirectUri, + refreshToken: process.env.refreshToken, + } + const hubspot = new Hubspot(params) + return hubspot + .refreshAccessToken() + .then(() => hubspot.contacts.get()) + .then(data => { + // access_key needs contacts scope + expect(data.contacts).to.be.an('array') + }) + }) + }) +}) diff --git a/test/companies.js b/test/companies.js index be5bdac..86f98e9 100644 --- a/test/companies.js +++ b/test/companies.js @@ -1,183 +1,183 @@ -var chai = require('chai') -var expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) -const _ = require('lodash') - -describe('companies', function() { - describe('get', function() { - it('should return all companies', function() { - return hubspot.companies.get().then(data => { - expect(data).to.be.an('object') - expect(data.companies).to.be.a('array') - }) - }) - - it('should return a limited number of companies', function() { - return hubspot.companies.get({ limit: 5 }).then(data => { - expect(data).to.be.an('object') - expect(data.companies).to.be.a('array') - expect(data.companies.length).to.eq(5) - expect(data['has-more']).to.eq(true) - }) - }) - - it('should return the requested properties', function() { - return hubspot.companies - .get({ limit: 5, properties: ['name', 'country', 'city'] }) - .then(data => { - expect(data.companies).to.be.a('array') - expect(data.companies[0].properties.name.value).to.be.a('string') - }) - }) - }) - - describe('getById', function() { - let companyId - - before(function() { - return hubspot.companies.get().then(data => { - companyId = data.companies[0].companyId - }) - }) - - it('should return a company', function() { - return hubspot.companies.getById(companyId).then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('getRecentlyCreated', function() { - it('should return recently created companies', function() { - return hubspot.companies.getRecentlyCreated().then(data => { - expect(data).to.be.an('object') - expect(data.results).to.be.a('array') - }) - }) - }) - - describe('getRecentlyModified', function() { - it('should return recently modified companies', function() { - return hubspot.companies.getRecentlyModified().then(data => { - expect(data).to.be.an('object') - expect(data.results).to.be.a('array') - }) - }) - }) - - describe('getByDomain', function() { - it('should returns a list of all companies that have a matching domain to the specified domain in the request URL', function() { - this.timeout(10000) - return hubspot.companies.getByDomain('example.com').then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0].properties.domain.value).to.equal('example.com') - }) - }) - }) - - describe('create', function() { - it('should create a company in a given portal', function() { - const payload = { - properties: [ - { name: 'name', value: 'A company name' }, - { name: 'description', value: 'A company description' }, - ], - } - return hubspot.companies.create(payload).then(data => { - expect(data).to.be.an('object') - // console.log(data) - expect(data.properties.name.value).to.equal('A company name') - }) - }) - }) - - describe('delete', function() { - it('can delete', function() { - const payload = { - properties: [ - { name: 'name', value: 'A company name' }, - { name: 'description', value: 'A company description' }, - ], - } - return hubspot.companies.create(payload).then(data => { - return hubspot.companies.delete(data.companyId) - }) - }) - }) - - describe('getContactIds', function() { - let companyId - - before(function() { - return hubspot.companies.get().then(data => { - companyId = data.companies[0].companyId - }) - }) - - it('should return a list of contact vids', function() { - const payload = { count: 10 } - return hubspot.companies.getContactIds(companyId, payload).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.property('vids') - expect(data).to.have.property('vidOffset') - expect(data).to.have.property('hasMore') - expect(data.vids).to.be.an('array') - }) - }) - }) - - describe('getContacts', function() { - let companyId - - before(function() { - return hubspot.companies.get().then(data => { - companyId = data.companies[0].companyId - }) - }) - - it('should return a list of contact objects', function() { - const payload = { count: 10 } - return hubspot.companies.getContacts(companyId, payload).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.property('contacts') - expect(data).to.have.property('vidOffset') - expect(data).to.have.property('hasMore') - expect(data.contacts).to.be.an('array') - }) - }) - }) - - describe('updateBatch', function() { - let companies - - before(function() { - return hubspot.companies.get().then(data => { - companies = data.companies - }) - }) - - it('should update a batch of company', function() { - const batch = _.map(companies, company => { - const update = { - objectId: company.companyId, - properties: [{ name: 'about_us', value: 'Thumbs up!' }], - } - return update - }) - return hubspot.companies.updateBatch(batch).then(data => { - expect(data).to.equal(undefined) - }) - }) - }) - - // describe('addContactToCompany', function () { - // it('should add contact to a specific company', function () { - // return hubspot.companies.addContactToCompany({ companyId: 322620707, contactVid: 123123 }).then(data => { - // expect(data).to.be.an('undefined') - // }) - // }) - // }) -}) +var chai = require('chai') +var expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) +const _ = require('lodash') + +describe('companies', function() { + describe('get', function() { + it('should return all companies', function() { + return hubspot.companies.get().then(data => { + expect(data).to.be.an('object') + expect(data.companies).to.be.a('array') + }) + }) + + it('should return a limited number of companies', function() { + return hubspot.companies.get({ limit: 5 }).then(data => { + expect(data).to.be.an('object') + expect(data.companies).to.be.a('array') + expect(data.companies.length).to.eq(5) + expect(data['has-more']).to.eq(true) + }) + }) + + it('should return the requested properties', function() { + return hubspot.companies + .get({ limit: 5, properties: ['name', 'country', 'city'] }) + .then(data => { + expect(data.companies).to.be.a('array') + expect(data.companies[0].properties.name.value).to.be.a('string') + }) + }) + }) + + describe('getById', function() { + let companyId + + before(function() { + return hubspot.companies.get().then(data => { + companyId = data.companies[0].companyId + }) + }) + + it('should return a company', function() { + return hubspot.companies.getById(companyId).then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('getRecentlyCreated', function() { + it('should return recently created companies', function() { + return hubspot.companies.getRecentlyCreated().then(data => { + expect(data).to.be.an('object') + expect(data.results).to.be.a('array') + }) + }) + }) + + describe('getRecentlyModified', function() { + it('should return recently modified companies', function() { + return hubspot.companies.getRecentlyModified().then(data => { + expect(data).to.be.an('object') + expect(data.results).to.be.a('array') + }) + }) + }) + + describe('getByDomain', function() { + it('should returns a list of all companies that have a matching domain to the specified domain in the request URL', function() { + this.timeout(10000) + return hubspot.companies.getByDomain('example.com').then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0].properties.domain.value).to.equal('example.com') + }) + }) + }) + + describe('create', function() { + it('should create a company in a given portal', function() { + const payload = { + properties: [ + { name: 'name', value: 'A company name' }, + { name: 'description', value: 'A company description' }, + ], + } + return hubspot.companies.create(payload).then(data => { + expect(data).to.be.an('object') + // console.log(data) + expect(data.properties.name.value).to.equal('A company name') + }) + }) + }) + + describe('delete', function() { + it('can delete', function() { + const payload = { + properties: [ + { name: 'name', value: 'A company name' }, + { name: 'description', value: 'A company description' }, + ], + } + return hubspot.companies.create(payload).then(data => { + return hubspot.companies.delete(data.companyId) + }) + }) + }) + + describe('getContactIds', function() { + let companyId + + before(function() { + return hubspot.companies.get().then(data => { + companyId = data.companies[0].companyId + }) + }) + + it('should return a list of contact vids', function() { + const payload = { count: 10 } + return hubspot.companies.getContactIds(companyId, payload).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.property('vids') + expect(data).to.have.property('vidOffset') + expect(data).to.have.property('hasMore') + expect(data.vids).to.be.an('array') + }) + }) + }) + + describe('getContacts', function() { + let companyId + + before(function() { + return hubspot.companies.get().then(data => { + companyId = data.companies[0].companyId + }) + }) + + it('should return a list of contact objects', function() { + const payload = { count: 10 } + return hubspot.companies.getContacts(companyId, payload).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.property('contacts') + expect(data).to.have.property('vidOffset') + expect(data).to.have.property('hasMore') + expect(data.contacts).to.be.an('array') + }) + }) + }) + + describe('updateBatch', function() { + let companies + + before(function() { + return hubspot.companies.get().then(data => { + companies = data.companies + }) + }) + + it('should update a batch of company', function() { + const batch = _.map(companies, company => { + const update = { + objectId: company.companyId, + properties: [{ name: 'about_us', value: 'Thumbs up!' }], + } + return update + }) + return hubspot.companies.updateBatch(batch).then(data => { + expect(data).to.equal(undefined) + }) + }) + }) + + // describe('addContactToCompany', function () { + // it('should add contact to a specific company', function () { + // return hubspot.companies.addContactToCompany({ companyId: 322620707, contactVid: 123123 }).then(data => { + // expect(data).to.be.an('undefined') + // }) + // }) + // }) +}) diff --git a/test/company_properties.js b/test/company_properties.js index ff9fa35..3144226 100644 --- a/test/company_properties.js +++ b/test/company_properties.js @@ -1,85 +1,85 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -const property = { - name: 'mk_company_fit_segment', - label: 'MadKudu Company Fit', - groupName: 'companyinformation', - description: 'MadKudu Company Fit', - type: 'string', - fieldType: 'text', - formField: false, - displayOrder: -1, - options: [], -} - -describe('companies.properties', function() { - describe('get', function() { - it('should return the list of properties for companies', function() { - return hubspot.companies.properties.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getAll', function() { - it('should return the same thing as get', function() { - return hubspot.companies.properties.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getByName', function() { - let propertyName - - before(() => { - return hubspot.companies.properties.get().then(results => { - // console.log(results) - propertyName = results[0].name - }) - }) - - it('should get a property by name', function() { - return hubspot.companies.properties - .getByName(propertyName) - .then(results => { - // console.log(results) - expect(results).to.be.an('object') - expect(results).to.have.a.property('name') - }) - }) - }) - - describe('upsert (create)', function() { - it('should create or update the property', function() { - return hubspot.companies.properties.upsert(property).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - }) - }) - }) - - describe('update', function() { - property.label = 'MadKudo Company Fit' - - it('should update the property', function() { - return hubspot.companies.properties - .update(property.name, property) - .then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - expect(data.label).to.equal(property.label) - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +const property = { + name: 'mk_company_fit_segment', + label: 'MadKudu Company Fit', + groupName: 'companyinformation', + description: 'MadKudu Company Fit', + type: 'string', + fieldType: 'text', + formField: false, + displayOrder: -1, + options: [], +} + +describe('companies.properties', function() { + describe('get', function() { + it('should return the list of properties for companies', function() { + return hubspot.companies.properties.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getAll', function() { + it('should return the same thing as get', function() { + return hubspot.companies.properties.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getByName', function() { + let propertyName + + before(() => { + return hubspot.companies.properties.get().then(results => { + // console.log(results) + propertyName = results[0].name + }) + }) + + it('should get a property by name', function() { + return hubspot.companies.properties + .getByName(propertyName) + .then(results => { + // console.log(results) + expect(results).to.be.an('object') + expect(results).to.have.a.property('name') + }) + }) + }) + + describe('upsert (create)', function() { + it('should create or update the property', function() { + return hubspot.companies.properties.upsert(property).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + }) + }) + }) + + describe('update', function() { + property.label = 'MadKudo Company Fit' + + it('should update the property', function() { + return hubspot.companies.properties + .update(property.name, property) + .then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + expect(data.label).to.equal(property.label) + }) + }) + }) +}) diff --git a/test/company_properties_groups.js b/test/company_properties_groups.js index 82606dc..2fa6e73 100644 --- a/test/company_properties_groups.js +++ b/test/company_properties_groups.js @@ -1,57 +1,57 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -const group = { - displayName: 'GROUP DIPLAY NAME', - name: 'mk_group_fit_segment', -} - -describe('companies.properties.groups', function() { - describe('get', function() { - it('should return the list of properties groups for companies', function() { - return hubspot.companies.properties.groups.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getAll', function() { - it('should return the same thing as get', function() { - return hubspot.companies.properties.groups.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('upsert (create)', function() { - it('should create or update the properties group', function() { - return hubspot.companies.properties.groups.upsert(group).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - }) - }) - }) - - describe('update', function() { - group.displayName = 'MadKudo Company Fit' - - it('should update the property', function() { - return hubspot.companies.properties.groups - .update(group.name, group) - .then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - expect(data.displayName).to.equal(group.displayName) - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +const group = { + displayName: 'GROUP DIPLAY NAME', + name: 'mk_group_fit_segment', +} + +describe('companies.properties.groups', function() { + describe('get', function() { + it('should return the list of properties groups for companies', function() { + return hubspot.companies.properties.groups.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getAll', function() { + it('should return the same thing as get', function() { + return hubspot.companies.properties.groups.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('upsert (create)', function() { + it('should create or update the properties group', function() { + return hubspot.companies.properties.groups.upsert(group).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + }) + }) + }) + + describe('update', function() { + group.displayName = 'MadKudo Company Fit' + + it('should update the property', function() { + return hubspot.companies.properties.groups + .update(group.name, group) + .then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + expect(data.displayName).to.equal(group.displayName) + }) + }) + }) +}) diff --git a/test/contact_properties.js b/test/contact_properties.js index d9cce35..ec35c02 100644 --- a/test/contact_properties.js +++ b/test/contact_properties.js @@ -1,321 +1,321 @@ -const { expect } = require('chai') -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') - -describe('contacts.properties', function() { - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'fake-token', - }) - const contactPropertyProperties = { - name: 'mk_customer_fit_segment', - label: 'MadKudu Customer Fit', - description: 'MadKudu Customer Fit', - type: 'string', - groupName: 'contactinformation', - fieldType: 'text', - options: [], - } - const deleteTestContactPropertyGroup = name => - hubspot.contacts.properties.deleteGroup(name) - const createTestContactPropertyGroup = properties => - hubspot.contacts.properties.createGroup(properties) - - const deleteTestContactProperty = name => - hubspot.contacts.properties.delete(name) - const createTestContactProperty = properties => - hubspot.contacts.properties.create(properties) - - describe('get', function() { - const getAllEndpoint = { - path: '/properties/v1/contacts/properties', - response: [{}], - } - fakeHubspotApi.setupServer({ getEndpoints: [getAllEndpoint] }) - - it('should return the list of properties for contacts', function() { - return hubspot.contacts.properties.get().then(data => { - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - }) - }) - }) - - describe('getAll', function() { - const getAllEndpoint = { - path: '/properties/v1/contacts/properties', - response: [{}], - } - fakeHubspotApi.setupServer({ getEndpoints: [getAllEndpoint] }) - - it('should return the same thing as get', function() { - return hubspot.contacts.properties.get().then(data => { - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - }) - }) - }) - - describe('getByName', function() { - const getByNameEndpoint = { - path: `/properties/v1/contacts/properties/named/${ - contactPropertyProperties.name - }`, - response: contactPropertyProperties, - } - fakeHubspotApi.setupServer({ getEndpoints: [getByNameEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactProperty(contactPropertyProperties) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactProperty(contactPropertyProperties.name) - } - }) - - it('should get a property by name', function() { - return hubspot.contacts.properties - .getByName(contactPropertyProperties.name) - .then(results => { - expect(results).to.be.an('object') - expect(results).to.have.a.property('name') - }) - }) - }) - - describe('delete', function() { - const deleteEndpoint = { - path: `/properties/v1/contacts/properties/named/${ - contactPropertyProperties.name - }`, - statusCode: 204, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [deleteEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactProperty(contactPropertyProperties) - } - }) - - it('can delete', function() { - return hubspot.contacts.properties - .delete(contactPropertyProperties.name) - .then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) - - describe('create', function() { - const createEndpoint = { - path: '/properties/v1/contacts/properties', - response: contactPropertyProperties, - } - fakeHubspotApi.setupServer({ postEndpoints: [createEndpoint] }) - - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactProperty(contactPropertyProperties.name) - } - }) - - it('should create the property', function() { - return hubspot.contacts.properties - .create(contactPropertyProperties) - .then(data => { - expect(data.description).to.eq(contactPropertyProperties.description) - }) - }) - }) - - describe('update', function() { - const description = 'Updated display name' - const updateEndpoint = { - path: `/properties/v1/contacts/properties/named/${ - contactPropertyProperties.name - }`, - response: { ...contactPropertyProperties, description }, - } - fakeHubspotApi.setupServer({ putEndpoints: [updateEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactProperty(contactPropertyProperties) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactProperty(contactPropertyProperties.name) - } - }) - - it('should update the property', function() { - return hubspot.contacts.properties - .update(contactPropertyProperties.name, { - ...contactPropertyProperties, - description, - }) - .then(data => { - expect(data.description).to.eq(description) - }) - }) - }) - - describe('upsert', function() { - describe("when the record doesn't exists", function() { - const createEndpoint = { - path: '/properties/v1/contacts/properties', - response: contactPropertyProperties, - } - fakeHubspotApi.setupServer({ postEndpoints: [createEndpoint] }) - - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactProperty(contactPropertyProperties.name) - } - }) - - it('should create the property', function() { - return hubspot.contacts.properties - .upsert(contactPropertyProperties) - .then(data => { - expect(data.description).to.eq( - contactPropertyProperties.description - ) - }) - }) - }) - - describe('when the record already exists', function() { - const description = 'Updated display name' - const createEndpoint = { - path: '/properties/v1/contacts/properties', - statusCode: 409, - } - const updateEndpoint = { - path: `/properties/v1/contacts/properties/named/${ - contactPropertyProperties.name - }`, - response: { ...contactPropertyProperties, description }, - } - fakeHubspotApi.setupServer({ - postEndpoints: [createEndpoint], - putEndpoints: [updateEndpoint], - }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactProperty(contactPropertyProperties) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactProperty(contactPropertyProperties.name) - } - }) - - it('should update the property', function() { - return hubspot.contacts.properties - .upsert({ ...contactPropertyProperties, description }) - .then(data => { - expect(data.description).to.eq(description) - }) - }) - }) - }) - - describe('groups', () => { - describe('getGroups', () => { - const getGroupsEndpoint = { - path: '/properties/v1/contacts/groups', - response: [], - } - fakeHubspotApi.setupServer({ getEndpoints: [getGroupsEndpoint] }) - - it('should return groups', function() { - return hubspot.contacts.properties.getGroups().then(data => { - expect(data).to.be.an('array') - }) - }) - }) - - describe('createGroup', function() { - const name = 'test_group' - const createGroupEndpoint = { - path: '/properties/v1/contacts/groups', - response: {}, - } - fakeHubspotApi.setupServer({ postEndpoints: [createGroupEndpoint] }) - - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactPropertyGroup(name) - } - }) - - it('returns a 200', function() { - return hubspot.contacts.properties - .createGroup({ name }) - .then(data => expect(data).to.be.a('object')) - }) - }) - - describe('updateGroup', function() { - const name = 'test_group' - const displayName = 'Updated display name' - const updateGroupEndpoint = { - path: `/properties/v1/contacts/groups/named/${name}`, - request: { displayName }, - response: { name, displayName }, - } - fakeHubspotApi.setupServer({ putEndpoints: [updateGroupEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactPropertyGroup({ - name, - displayName: 'something', - }) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContactPropertyGroup(name) - } - }) - - it('returns a 200', function() { - return hubspot.contacts.properties - .updateGroup(name, { displayName }) - .then(data => expect(data.displayName).to.eq(displayName)) - }) - }) - - describe('deleteGroup', function() { - const name = 'test_group' - const deleteGroupEndpoint = { - path: `/properties/v1/contacts/groups/named/${name}`, - statusCode: 204, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [deleteGroupEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContactPropertyGroup({ - name, - displayName: 'something', - }) - } - }) - - it('returns a 204', function() { - return hubspot.contacts.properties - .deleteGroup(name) - .then(data => expect(data).to.be.an('undefined')) - }) - }) - }) -}) +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') + +describe('contacts.properties', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'fake-token', + }) + const contactPropertyProperties = { + name: 'mk_customer_fit_segment', + label: 'MadKudu Customer Fit', + description: 'MadKudu Customer Fit', + type: 'string', + groupName: 'contactinformation', + fieldType: 'text', + options: [], + } + const deleteTestContactPropertyGroup = name => + hubspot.contacts.properties.deleteGroup(name) + const createTestContactPropertyGroup = properties => + hubspot.contacts.properties.createGroup(properties) + + const deleteTestContactProperty = name => + hubspot.contacts.properties.delete(name) + const createTestContactProperty = properties => + hubspot.contacts.properties.create(properties) + + describe('get', function() { + const getAllEndpoint = { + path: '/properties/v1/contacts/properties', + response: [{}], + } + fakeHubspotApi.setupServer({ getEndpoints: [getAllEndpoint] }) + + it('should return the list of properties for contacts', function() { + return hubspot.contacts.properties.get().then(data => { + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + }) + }) + }) + + describe('getAll', function() { + const getAllEndpoint = { + path: '/properties/v1/contacts/properties', + response: [{}], + } + fakeHubspotApi.setupServer({ getEndpoints: [getAllEndpoint] }) + + it('should return the same thing as get', function() { + return hubspot.contacts.properties.get().then(data => { + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + }) + }) + }) + + describe('getByName', function() { + const getByNameEndpoint = { + path: `/properties/v1/contacts/properties/named/${ + contactPropertyProperties.name + }`, + response: contactPropertyProperties, + } + fakeHubspotApi.setupServer({ getEndpoints: [getByNameEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactProperty(contactPropertyProperties) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactProperty(contactPropertyProperties.name) + } + }) + + it('should get a property by name', function() { + return hubspot.contacts.properties + .getByName(contactPropertyProperties.name) + .then(results => { + expect(results).to.be.an('object') + expect(results).to.have.a.property('name') + }) + }) + }) + + describe('delete', function() { + const deleteEndpoint = { + path: `/properties/v1/contacts/properties/named/${ + contactPropertyProperties.name + }`, + statusCode: 204, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [deleteEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactProperty(contactPropertyProperties) + } + }) + + it('can delete', function() { + return hubspot.contacts.properties + .delete(contactPropertyProperties.name) + .then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) + + describe('create', function() { + const createEndpoint = { + path: '/properties/v1/contacts/properties', + response: contactPropertyProperties, + } + fakeHubspotApi.setupServer({ postEndpoints: [createEndpoint] }) + + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactProperty(contactPropertyProperties.name) + } + }) + + it('should create the property', function() { + return hubspot.contacts.properties + .create(contactPropertyProperties) + .then(data => { + expect(data.description).to.eq(contactPropertyProperties.description) + }) + }) + }) + + describe('update', function() { + const description = 'Updated display name' + const updateEndpoint = { + path: `/properties/v1/contacts/properties/named/${ + contactPropertyProperties.name + }`, + response: { ...contactPropertyProperties, description }, + } + fakeHubspotApi.setupServer({ putEndpoints: [updateEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactProperty(contactPropertyProperties) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactProperty(contactPropertyProperties.name) + } + }) + + it('should update the property', function() { + return hubspot.contacts.properties + .update(contactPropertyProperties.name, { + ...contactPropertyProperties, + description, + }) + .then(data => { + expect(data.description).to.eq(description) + }) + }) + }) + + describe('upsert', function() { + describe("when the record doesn't exists", function() { + const createEndpoint = { + path: '/properties/v1/contacts/properties', + response: contactPropertyProperties, + } + fakeHubspotApi.setupServer({ postEndpoints: [createEndpoint] }) + + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactProperty(contactPropertyProperties.name) + } + }) + + it('should create the property', function() { + return hubspot.contacts.properties + .upsert(contactPropertyProperties) + .then(data => { + expect(data.description).to.eq( + contactPropertyProperties.description + ) + }) + }) + }) + + describe('when the record already exists', function() { + const description = 'Updated display name' + const createEndpoint = { + path: '/properties/v1/contacts/properties', + statusCode: 409, + } + const updateEndpoint = { + path: `/properties/v1/contacts/properties/named/${ + contactPropertyProperties.name + }`, + response: { ...contactPropertyProperties, description }, + } + fakeHubspotApi.setupServer({ + postEndpoints: [createEndpoint], + putEndpoints: [updateEndpoint], + }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactProperty(contactPropertyProperties) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactProperty(contactPropertyProperties.name) + } + }) + + it('should update the property', function() { + return hubspot.contacts.properties + .upsert({ ...contactPropertyProperties, description }) + .then(data => { + expect(data.description).to.eq(description) + }) + }) + }) + }) + + describe('groups', () => { + describe('getGroups', () => { + const getGroupsEndpoint = { + path: '/properties/v1/contacts/groups', + response: [], + } + fakeHubspotApi.setupServer({ getEndpoints: [getGroupsEndpoint] }) + + it('should return groups', function() { + return hubspot.contacts.properties.getGroups().then(data => { + expect(data).to.be.an('array') + }) + }) + }) + + describe('createGroup', function() { + const name = 'test_group' + const createGroupEndpoint = { + path: '/properties/v1/contacts/groups', + response: {}, + } + fakeHubspotApi.setupServer({ postEndpoints: [createGroupEndpoint] }) + + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactPropertyGroup(name) + } + }) + + it('returns a 200', function() { + return hubspot.contacts.properties + .createGroup({ name }) + .then(data => expect(data).to.be.a('object')) + }) + }) + + describe('updateGroup', function() { + const name = 'test_group' + const displayName = 'Updated display name' + const updateGroupEndpoint = { + path: `/properties/v1/contacts/groups/named/${name}`, + request: { displayName }, + response: { name, displayName }, + } + fakeHubspotApi.setupServer({ putEndpoints: [updateGroupEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactPropertyGroup({ + name, + displayName: 'something', + }) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContactPropertyGroup(name) + } + }) + + it('returns a 200', function() { + return hubspot.contacts.properties + .updateGroup(name, { displayName }) + .then(data => expect(data.displayName).to.eq(displayName)) + }) + }) + + describe('deleteGroup', function() { + const name = 'test_group' + const deleteGroupEndpoint = { + path: `/properties/v1/contacts/groups/named/${name}`, + statusCode: 204, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [deleteGroupEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContactPropertyGroup({ + name, + displayName: 'something', + }) + } + }) + + it('returns a 204', function() { + return hubspot.contacts.properties + .deleteGroup(name) + .then(data => expect(data).to.be.an('undefined')) + }) + }) + }) +}) diff --git a/test/contacts.js b/test/contacts.js index 8a95d68..7368274 100644 --- a/test/contacts.js +++ b/test/contacts.js @@ -1,438 +1,438 @@ -const { expect } = require('chai') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') -const { createTestContact, deleteTestContact } = require('./helpers/factories') - -const Hubspot = require('..') -const emailsFromContacts = contacts => - contacts.flatMap(contact => - contact['identity-profiles'].map( - profile => - profile.identities.find(identity => identity.type === 'EMAIL').value - ) - ) - -describe('contacts', function() { - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'fake-token', - }) - - describe('get', function() { - const count = 10 - const contactsGetEndpoint = { - path: '/contacts/v1/lists/all/contacts/all', - response: { contacts: [{}] }, - } - const tenContactsGetEndpoint = { - path: '/contacts/v1/lists/all/contacts/all', - response: { contacts: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}] }, - query: { count }, - } - fakeHubspotApi.setupServer({ - getEndpoints: [contactsGetEndpoint, tenContactsGetEndpoint], - }) - - it('should return a batch of contacts', function() { - return hubspot.contacts.get().then(data => { - expect(data).to.be.a('object') - expect(data.contacts).to.be.a('array') - expect(data.contacts[0]).to.be.an('object') - }) - }) - - it('should pass through a count', function() { - return hubspot.contacts.get({ count }).then(data => { - expect(data).to.be.a('object') - expect(data.contacts).to.be.a('array') - }) - }) - }) - - describe('getRecentlyModified', function() { - const recentlyModifiedContactsGetEndpoint = { - path: '/contacts/v1/lists/recently_updated/contacts/recent', - response: { contacts: [{}] }, - } - fakeHubspotApi.setupServer({ - getEndpoints: [recentlyModifiedContactsGetEndpoint], - }) - - it('should return a list of contacts', function() { - return hubspot.contacts.getRecentlyModified().then(data => { - expect(data.contacts).to.be.an('array') - }) - }) - }) - - describe('getRecentlyCreated', function() { - const recentlyCreatedContactsGetEndpoint = { - path: '/contacts/v1/lists/all/contacts/recent', - response: { contacts: [{}] }, - } - fakeHubspotApi.setupServer({ - getEndpoints: [recentlyCreatedContactsGetEndpoint], - }) - - it('should return a list of contacts', function() { - return hubspot.contacts.getRecentlyCreated().then(data => { - expect(data.contacts).to.be.an('array') - }) - }) - }) - - describe('getById', function() { - let contactId = 123 - const contactByIdEndpoint = { - path: `/contacts/v1/contact/vid/${contactId}/profile`, - response: { vid: contactId }, - } - fakeHubspotApi.setupServer({ getEndpoints: [contactByIdEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContact(hubspot).then(data => (contactId = data.vid)) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestContact(hubspot, contactId) - } - }) - - it('should return a contact based on its id', function() { - return hubspot.contacts.getById(contactId).then(data => { - expect(data.vid).to.equal(contactId) - }) - }) - }) - - describe('getByIdBatch', function() { - let contactIds = [123, 234, 345] - const contactsByIdsEndpoint = { - path: '/contacts/v1/contact/vids/batch', - response: { '123': {}, '234': {}, '345': {} }, - query: { vid: contactIds }, - } - fakeHubspotApi.setupServer({ getEndpoints: [contactsByIdsEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return hubspot.contacts.get({ count: 3 }).then(data => { - contactIds = data.contacts.map(contact => contact.vid) - }) - } - }) - - it('should return a contact record based on a array of ids', function() { - return hubspot.contacts.getByIdBatch(contactIds).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property(contactIds[0]) - }) - }) - }) - - describe('getByEmail', function() { - let email = 'testingapis@hubspot.com' - const contactByEmailEndpoint = { - path: `/contacts/v1/contact/email/${email}/profile`, - response: { properties: {} }, - } - fakeHubspotApi.setupServer({ getEndpoints: [contactByEmailEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return hubspot.contacts.get({ count: 1 }).then(data => { - email = emailsFromContacts(data.contacts)[0] - }) - } - }) - - it('should return a contact record based on the email', function() { - return hubspot.contacts.getByEmail(email).then(data => { - expect(data).to.be.a('object') - expect(data.properties).to.be.a('object') - }) - }) - }) - - describe('getByEmailBatch', function() { - let emails = [ - 'testingapis@hubspot.com', - 'testingapisawesomeandstuff@hubspot.com', - ] - const contactByEmailsEndpoint = { - path: '/contacts/v1/contact/emails/batch', - response: { properties: {} }, - query: { email: emails }, - } - fakeHubspotApi.setupServer({ getEndpoints: [contactByEmailsEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return hubspot.contacts.get({ count: 3 }).then(data => { - emails = emailsFromContacts(data.contacts) - }) - } - }) - - it('should return a contact record based on a array of emails', function() { - return hubspot.contacts.getByEmailBatch(emails).then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('update', function() { - let contactId = 123 - const updateData = { - properties: [ - { - property: 'email', - value: `new-email${Date.now()}@hubspot.com`, - }, - { - property: 'firstname', - value: 'Updated', - }, - { - property: 'lastname', - value: 'Lead', - }, - { - property: 'website', - value: 'http://hubspot-updated-lead.com', - }, - { - property: 'lifecyclestage', - value: 'customer', - }, - ], - } - const updateContactEndpoint = { - path: `/contacts/v1/contact/vid/${contactId}/profile`, - request: updateData, - statusCode: 204, - } - fakeHubspotApi.setupServer({ postEndpoints: [updateContactEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return hubspot.contacts.get().then(data => { - contactId = data.contacts[0].vid - }) - } - }) - - it('should update an existing contact', function() { - return hubspot.contacts.update(contactId, updateData).then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) - - describe('createOrUpdate', function() { - const email = 'test@hubspot.com' - const createOrUpdateData = { - properties: [ - { - property: 'email', - value: email, - }, - { - property: 'firstname', - value: 'Matt', - }, - { - property: 'lastname', - value: 'Schnitt', - }, - { - property: 'website', - value: 'http://hubspot.com', - }, - { - property: 'company', - value: 'HubSpot', - }, - { - property: 'phone', - value: '555-122-2323', - }, - { - property: 'address', - value: '25 First Street', - }, - { - property: 'city', - value: 'Cambridge', - }, - { - property: 'state', - value: 'MA', - }, - { - property: 'zip', - value: '02139', - }, - ], - } - const createOrUpdateContactEndpoint = { - path: `/contacts/v1/contact/createOrUpdate/email/${email}`, - request: createOrUpdateData, - response: {}, - } - fakeHubspotApi.setupServer({ - postEndpoints: [createOrUpdateContactEndpoint], - }) - - it('should Create or Update a contact', function() { - return hubspot.contacts - .createOrUpdate(email, createOrUpdateData) - .then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('create', function() { - const companyName = 'MadKudu' - const createData = { - properties: [ - { - property: 'email', - value: 'node-hubspot' + Date.now() + '@madkudu.com', - }, - { - property: 'firstname', - value: 'Try', - }, - { - property: 'lastname', - value: 'MadKudu', - }, - { - property: 'website', - value: 'http://www.madkudu.com', - }, - { - property: 'company', - value: companyName, - }, - ], - } - const createErrorData = { - properties: [ - { - property: 'email', - value: 'node-hubspot@hubspot.com', - }, - { - property: 'firstname', - value: 'Test', - }, - ], - } - const createContactEndpoint = { - path: '/contacts/v1/contact', - request: createData, - response: { properties: { company: { value: companyName } } }, - } - const createExisitingContactEndpoint = { - path: '/contacts/v1/contact', - request: createErrorData, - responseError: 'Contact already exists', - } - fakeHubspotApi.setupServer({ - postEndpoints: [createContactEndpoint, createExisitingContactEndpoint], - }) - - it('should create a new contact', function() { - return hubspot.contacts.create(createData).then(data => { - expect(data).to.be.an('object') - expect(data.properties.company.value).to.equal('MadKudu') - }) - }) - - it('should fail if the contact already exists', function() { - return hubspot.contacts - .create(createErrorData) - .then(data => { - throw new Error('This should have failed') - }) - .catch(err => { - expect(err instanceof Error).to.equal(true) - expect(err.error.message).to.equal('Contact already exists') - }) - }) - }) - - describe('delete', function() { - let contactId = 123 - const deleteContactEndpoint = { - path: `/contacts/v1/contact/vid/${contactId}`, - response: { vid: contactId }, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [deleteContactEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestContact(hubspot).then(data => (contactId = data.vid)) - } - }) - - it('can delete', function() { - return hubspot.contacts.delete(contactId).then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('createOrUpdateBatch', function() { - const contactIds = [123, 234, 345] - const properties = [{ property: 'company', value: 'MadKudu ' }] - let createOrUpdateData = contactIds.map(vid => ({ vid, properties })) - const createOrUpdateContactsEndpoint = { - path: '/contacts/v1/contact/batch', - statusCode: 204, - request: createOrUpdateData, - } - fakeHubspotApi.setupServer({ - postEndpoints: [createOrUpdateContactsEndpoint], - }) - - before(function() { - if (process.env.NOCK_OFF) { - return hubspot.contacts.get({ count: 3 }).then(data => { - createOrUpdateData = data.contacts.map(({ vid }) => ({ - vid, - properties, - })) - }) - } - }) - - it('should update a batch of company', function() { - return hubspot.contacts - .createOrUpdateBatch(createOrUpdateData) - .then(data => { - expect(data).to.equal(undefined) - }) - }) - }) - - describe('search', function() { - const query = 'example' - const searchContactsEndpoint = { - path: '/contacts/v1/search/query', - query: { q: query }, - response: { contacts: [{}], query }, - } - fakeHubspotApi.setupServer({ getEndpoints: [searchContactsEndpoint] }) - - it("should return contacts and some data associated with those contacts by the contact's email address or name.", function() { - return hubspot.contacts.search('example').then(data => { - expect(data.contacts).to.be.a('array') - expect(data.query).to.equal('example') - }) - }) - }) -}) +const { expect } = require('chai') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') +const { createTestContact, deleteTestContact } = require('./helpers/factories') + +const Hubspot = require('..') +const emailsFromContacts = contacts => + contacts.flatMap(contact => + contact['identity-profiles'].map( + profile => + profile.identities.find(identity => identity.type === 'EMAIL').value + ) + ) + +describe('contacts', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'fake-token', + }) + + describe('get', function() { + const count = 10 + const contactsGetEndpoint = { + path: '/contacts/v1/lists/all/contacts/all', + response: { contacts: [{}] }, + } + const tenContactsGetEndpoint = { + path: '/contacts/v1/lists/all/contacts/all', + response: { contacts: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}] }, + query: { count }, + } + fakeHubspotApi.setupServer({ + getEndpoints: [contactsGetEndpoint, tenContactsGetEndpoint], + }) + + it('should return a batch of contacts', function() { + return hubspot.contacts.get().then(data => { + expect(data).to.be.a('object') + expect(data.contacts).to.be.a('array') + expect(data.contacts[0]).to.be.an('object') + }) + }) + + it('should pass through a count', function() { + return hubspot.contacts.get({ count }).then(data => { + expect(data).to.be.a('object') + expect(data.contacts).to.be.a('array') + }) + }) + }) + + describe('getRecentlyModified', function() { + const recentlyModifiedContactsGetEndpoint = { + path: '/contacts/v1/lists/recently_updated/contacts/recent', + response: { contacts: [{}] }, + } + fakeHubspotApi.setupServer({ + getEndpoints: [recentlyModifiedContactsGetEndpoint], + }) + + it('should return a list of contacts', function() { + return hubspot.contacts.getRecentlyModified().then(data => { + expect(data.contacts).to.be.an('array') + }) + }) + }) + + describe('getRecentlyCreated', function() { + const recentlyCreatedContactsGetEndpoint = { + path: '/contacts/v1/lists/all/contacts/recent', + response: { contacts: [{}] }, + } + fakeHubspotApi.setupServer({ + getEndpoints: [recentlyCreatedContactsGetEndpoint], + }) + + it('should return a list of contacts', function() { + return hubspot.contacts.getRecentlyCreated().then(data => { + expect(data.contacts).to.be.an('array') + }) + }) + }) + + describe('getById', function() { + let contactId = 123 + const contactByIdEndpoint = { + path: `/contacts/v1/contact/vid/${contactId}/profile`, + response: { vid: contactId }, + } + fakeHubspotApi.setupServer({ getEndpoints: [contactByIdEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContact(hubspot).then(data => (contactId = data.vid)) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestContact(hubspot, contactId) + } + }) + + it('should return a contact based on its id', function() { + return hubspot.contacts.getById(contactId).then(data => { + expect(data.vid).to.equal(contactId) + }) + }) + }) + + describe('getByIdBatch', function() { + let contactIds = [123, 234, 345] + const contactsByIdsEndpoint = { + path: '/contacts/v1/contact/vids/batch', + response: { '123': {}, '234': {}, '345': {} }, + query: { vid: contactIds }, + } + fakeHubspotApi.setupServer({ getEndpoints: [contactsByIdsEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return hubspot.contacts.get({ count: 3 }).then(data => { + contactIds = data.contacts.map(contact => contact.vid) + }) + } + }) + + it('should return a contact record based on a array of ids', function() { + return hubspot.contacts.getByIdBatch(contactIds).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property(contactIds[0]) + }) + }) + }) + + describe('getByEmail', function() { + let email = 'testingapis@hubspot.com' + const contactByEmailEndpoint = { + path: `/contacts/v1/contact/email/${email}/profile`, + response: { properties: {} }, + } + fakeHubspotApi.setupServer({ getEndpoints: [contactByEmailEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return hubspot.contacts.get({ count: 1 }).then(data => { + email = emailsFromContacts(data.contacts)[0] + }) + } + }) + + it('should return a contact record based on the email', function() { + return hubspot.contacts.getByEmail(email).then(data => { + expect(data).to.be.a('object') + expect(data.properties).to.be.a('object') + }) + }) + }) + + describe('getByEmailBatch', function() { + let emails = [ + 'testingapis@hubspot.com', + 'testingapisawesomeandstuff@hubspot.com', + ] + const contactByEmailsEndpoint = { + path: '/contacts/v1/contact/emails/batch', + response: { properties: {} }, + query: { email: emails }, + } + fakeHubspotApi.setupServer({ getEndpoints: [contactByEmailsEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return hubspot.contacts.get({ count: 3 }).then(data => { + emails = emailsFromContacts(data.contacts) + }) + } + }) + + it('should return a contact record based on a array of emails', function() { + return hubspot.contacts.getByEmailBatch(emails).then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('update', function() { + let contactId = 123 + const updateData = { + properties: [ + { + property: 'email', + value: `new-email${Date.now()}@hubspot.com`, + }, + { + property: 'firstname', + value: 'Updated', + }, + { + property: 'lastname', + value: 'Lead', + }, + { + property: 'website', + value: 'http://hubspot-updated-lead.com', + }, + { + property: 'lifecyclestage', + value: 'customer', + }, + ], + } + const updateContactEndpoint = { + path: `/contacts/v1/contact/vid/${contactId}/profile`, + request: updateData, + statusCode: 204, + } + fakeHubspotApi.setupServer({ postEndpoints: [updateContactEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return hubspot.contacts.get().then(data => { + contactId = data.contacts[0].vid + }) + } + }) + + it('should update an existing contact', function() { + return hubspot.contacts.update(contactId, updateData).then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) + + describe('createOrUpdate', function() { + const email = 'test@hubspot.com' + const createOrUpdateData = { + properties: [ + { + property: 'email', + value: email, + }, + { + property: 'firstname', + value: 'Matt', + }, + { + property: 'lastname', + value: 'Schnitt', + }, + { + property: 'website', + value: 'http://hubspot.com', + }, + { + property: 'company', + value: 'HubSpot', + }, + { + property: 'phone', + value: '555-122-2323', + }, + { + property: 'address', + value: '25 First Street', + }, + { + property: 'city', + value: 'Cambridge', + }, + { + property: 'state', + value: 'MA', + }, + { + property: 'zip', + value: '02139', + }, + ], + } + const createOrUpdateContactEndpoint = { + path: `/contacts/v1/contact/createOrUpdate/email/${email}`, + request: createOrUpdateData, + response: {}, + } + fakeHubspotApi.setupServer({ + postEndpoints: [createOrUpdateContactEndpoint], + }) + + it('should Create or Update a contact', function() { + return hubspot.contacts + .createOrUpdate(email, createOrUpdateData) + .then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('create', function() { + const companyName = 'MadKudu' + const createData = { + properties: [ + { + property: 'email', + value: 'node-hubspot' + Date.now() + '@madkudu.com', + }, + { + property: 'firstname', + value: 'Try', + }, + { + property: 'lastname', + value: 'MadKudu', + }, + { + property: 'website', + value: 'http://www.madkudu.com', + }, + { + property: 'company', + value: companyName, + }, + ], + } + const createErrorData = { + properties: [ + { + property: 'email', + value: 'node-hubspot@hubspot.com', + }, + { + property: 'firstname', + value: 'Test', + }, + ], + } + const createContactEndpoint = { + path: '/contacts/v1/contact', + request: createData, + response: { properties: { company: { value: companyName } } }, + } + const createExisitingContactEndpoint = { + path: '/contacts/v1/contact', + request: createErrorData, + responseError: 'Contact already exists', + } + fakeHubspotApi.setupServer({ + postEndpoints: [createContactEndpoint, createExisitingContactEndpoint], + }) + + it('should create a new contact', function() { + return hubspot.contacts.create(createData).then(data => { + expect(data).to.be.an('object') + expect(data.properties.company.value).to.equal('MadKudu') + }) + }) + + it('should fail if the contact already exists', function() { + return hubspot.contacts + .create(createErrorData) + .then(data => { + throw new Error('This should have failed') + }) + .catch(err => { + expect(err instanceof Error).to.equal(true) + expect(err.error.message).to.equal('Contact already exists') + }) + }) + }) + + describe('delete', function() { + let contactId = 123 + const deleteContactEndpoint = { + path: `/contacts/v1/contact/vid/${contactId}`, + response: { vid: contactId }, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [deleteContactEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestContact(hubspot).then(data => (contactId = data.vid)) + } + }) + + it('can delete', function() { + return hubspot.contacts.delete(contactId).then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('createOrUpdateBatch', function() { + const contactIds = [123, 234, 345] + const properties = [{ property: 'company', value: 'MadKudu ' }] + let createOrUpdateData = contactIds.map(vid => ({ vid, properties })) + const createOrUpdateContactsEndpoint = { + path: '/contacts/v1/contact/batch', + statusCode: 204, + request: createOrUpdateData, + } + fakeHubspotApi.setupServer({ + postEndpoints: [createOrUpdateContactsEndpoint], + }) + + before(function() { + if (process.env.NOCK_OFF) { + return hubspot.contacts.get({ count: 3 }).then(data => { + createOrUpdateData = data.contacts.map(({ vid }) => ({ + vid, + properties, + })) + }) + } + }) + + it('should update a batch of company', function() { + return hubspot.contacts + .createOrUpdateBatch(createOrUpdateData) + .then(data => { + expect(data).to.equal(undefined) + }) + }) + }) + + describe('search', function() { + const query = 'example' + const searchContactsEndpoint = { + path: '/contacts/v1/search/query', + query: { q: query }, + response: { contacts: [{}], query }, + } + fakeHubspotApi.setupServer({ getEndpoints: [searchContactsEndpoint] }) + + it("should return contacts and some data associated with those contacts by the contact's email address or name.", function() { + return hubspot.contacts.search('example').then(data => { + expect(data.contacts).to.be.a('array') + expect(data.query).to.equal('example') + }) + }) + }) +}) diff --git a/test/deal_properties.js b/test/deal_properties.js index 0ebf875..358440a 100644 --- a/test/deal_properties.js +++ b/test/deal_properties.js @@ -1,105 +1,105 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -const property = { - name: 'mk_deal_fit_segment', - label: 'MadKudu Deal Fit', - groupName: 'dealinformation', - description: 'MadKudu Deal Fit', - type: 'string', - fieldType: 'text', - formField: false, - displayOrder: -1, - options: [], -} - -describe('deals.properties', function() { - describe('get', function() { - it('should return the list of properties for deals', function() { - return hubspot.deals.properties.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getAll', function() { - it('should return the same thing as get', function() { - return hubspot.deals.properties.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getByName', function() { - let propertyName - - before(() => { - return hubspot.deals.properties.get().then(results => { - // console.log(results) - propertyName = results[0].name - }) - }) - - it('should get a property by name', function() { - return hubspot.deals.properties.getByName(propertyName).then(results => { - // console.log(results) - expect(results).to.be.an('object') - expect(results).to.have.a.property('name') - }) - }) - }) - - describe('upsert (create)', function() { - it('should create or update the property', function() { - return hubspot.deals.properties.upsert(property).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - }) - }) - }) - - describe('delete', function() { - const testDeleteProperty = { - name: 'delete_test_property_' + Date.now(), - label: 'node-hubspot test property', - groupName: 'dealinformation', - description: 'Test property', - type: 'string', - fieldType: 'text', - formField: false, - displayOrder: -1, - options: [], - } - - it('should delete a property', function() { - return hubspot.deals.properties.upsert(testDeleteProperty).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - return hubspot.deals.properties.delete(testDeleteProperty.name) - }) - }) - }) - - describe('update', function() { - property.label = 'MadKudo Company Fit' - - it('should update the property', function() { - return hubspot.deals.properties - .update(property.name, property) - .then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - expect(data.label).to.equal(property.label) - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +const property = { + name: 'mk_deal_fit_segment', + label: 'MadKudu Deal Fit', + groupName: 'dealinformation', + description: 'MadKudu Deal Fit', + type: 'string', + fieldType: 'text', + formField: false, + displayOrder: -1, + options: [], +} + +describe('deals.properties', function() { + describe('get', function() { + it('should return the list of properties for deals', function() { + return hubspot.deals.properties.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getAll', function() { + it('should return the same thing as get', function() { + return hubspot.deals.properties.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getByName', function() { + let propertyName + + before(() => { + return hubspot.deals.properties.get().then(results => { + // console.log(results) + propertyName = results[0].name + }) + }) + + it('should get a property by name', function() { + return hubspot.deals.properties.getByName(propertyName).then(results => { + // console.log(results) + expect(results).to.be.an('object') + expect(results).to.have.a.property('name') + }) + }) + }) + + describe('upsert (create)', function() { + it('should create or update the property', function() { + return hubspot.deals.properties.upsert(property).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + }) + }) + }) + + describe('delete', function() { + const testDeleteProperty = { + name: 'delete_test_property_' + Date.now(), + label: 'node-hubspot test property', + groupName: 'dealinformation', + description: 'Test property', + type: 'string', + fieldType: 'text', + formField: false, + displayOrder: -1, + options: [], + } + + it('should delete a property', function() { + return hubspot.deals.properties.upsert(testDeleteProperty).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + return hubspot.deals.properties.delete(testDeleteProperty.name) + }) + }) + }) + + describe('update', function() { + property.label = 'MadKudo Company Fit' + + it('should update the property', function() { + return hubspot.deals.properties + .update(property.name, property) + .then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + expect(data.label).to.equal(property.label) + }) + }) + }) +}) diff --git a/test/deal_properties_group.js b/test/deal_properties_group.js index 89bc33b..574efbe 100644 --- a/test/deal_properties_group.js +++ b/test/deal_properties_group.js @@ -1,57 +1,57 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -const group = { - displayName: 'GROUP DIPLAY NAME', - name: 'mk_group_fit_segment', -} - -describe('deals.properties.groups', function() { - describe('get', function() { - it('should return the list of properties groups for deals', function() { - return hubspot.deals.properties.groups.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('getAll', function() { - it('should return the same thing as get', function() { - return hubspot.deals.properties.groups.get().then(data => { - // console.log(data) - expect(data).to.be.an('array') - expect(data[0]).to.be.an('object') - expect(data[0]).to.have.a.property('name') - }) - }) - }) - - describe('upsert (create)', function() { - it('should create or update the properties group', function() { - return hubspot.deals.properties.groups.upsert(group).then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - }) - }) - }) - - describe('update', function() { - group.displayName = 'MadKudo Company Fit' - - it('should update the property', function() { - return hubspot.deals.properties.groups - .update(group.name, group) - .then(data => { - expect(data).to.be.an('object') - expect(data).to.have.a.property('name') - expect(data.displayName).to.equal(group.displayName) - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +const group = { + displayName: 'GROUP DIPLAY NAME', + name: 'mk_group_fit_segment', +} + +describe('deals.properties.groups', function() { + describe('get', function() { + it('should return the list of properties groups for deals', function() { + return hubspot.deals.properties.groups.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('getAll', function() { + it('should return the same thing as get', function() { + return hubspot.deals.properties.groups.get().then(data => { + // console.log(data) + expect(data).to.be.an('array') + expect(data[0]).to.be.an('object') + expect(data[0]).to.have.a.property('name') + }) + }) + }) + + describe('upsert (create)', function() { + it('should create or update the properties group', function() { + return hubspot.deals.properties.groups.upsert(group).then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + }) + }) + }) + + describe('update', function() { + group.displayName = 'MadKudo Company Fit' + + it('should update the property', function() { + return hubspot.deals.properties.groups + .update(group.name, group) + .then(data => { + expect(data).to.be.an('object') + expect(data).to.have.a.property('name') + expect(data.displayName).to.equal(group.displayName) + }) + }) + }) +}) diff --git a/test/deals.js b/test/deals.js index 21e40a9..1f1f87d 100644 --- a/test/deals.js +++ b/test/deals.js @@ -1,344 +1,344 @@ -const { expect } = require('chai') -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') - -describe('deals', function() { - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'fake-token', - }) - const dealProperties = [ - { - value: 'MadKudu', - name: 'dealname', - }, - { - value: 'appointmentscheduled', - name: 'dealstage', - }, - { - value: 'default', - name: 'pipeline', - }, - { - value: Date.now(), - name: 'closedate', - }, - { - value: '60000', - name: 'amount', - }, - { - value: 'newbusiness', - name: 'dealtype', - }, - ] - const companyProperties = [ - { name: 'name', value: 'A company name' }, - { name: 'description', value: 'A company description' }, - ] - const createTestDeal = () => - hubspot.deals.create({ properties: dealProperties }) - const deleteTestDeal = dealId => hubspot.deals.deleteById(dealId) - const createTestCompany = () => - hubspot.companies.create({ properties: companyProperties }) - const createDealWithCompany = () => - hubspot.companies - .create({ properties: companyProperties }) - .then(companyData => { - return hubspot.deals - .create({ - associations: { - associatedCompanyIds: [companyData.companyId], - }, - properties: dealProperties, - }) - .then(dealData => { - return { - dataCompanyId: companyData.companyId, - dataDealId: dealData.dealId, - } - }) - }) - const deleteTestCompany = companyId => hubspot.companies.delete(companyId) - - describe('get', function() { - const dealsEndpoint = { - path: '/deals/v1/deal/paged', - response: { deals: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [dealsEndpoint] }) - - it('Should return deal properties', function() { - return hubspot.deals.get().then(data => { - expect(data).to.be.a('object') - expect(data.deals).to.be.an('array') - }) - }) - }) - - describe('getRecentlyCreated', function() { - const recentlyCreatedDealsEndpoint = { - path: '/deals/v1/deal/recent/created', - response: { results: [] }, - } - fakeHubspotApi.setupServer({ - getEndpoints: [recentlyCreatedDealsEndpoint], - }) - - it('Returns Recently Created Deals', function() { - return hubspot.deals.getRecentlyCreated().then(data => { - expect(data.results).to.be.an('array') - }) - }) - }) - - describe('getRecentlyModified', function() { - const recentlyModifiedDealsEndpoint = { - path: '/deals/v1/deal/recent/modified', - response: { results: [] }, - } - fakeHubspotApi.setupServer({ - getEndpoints: [recentlyModifiedDealsEndpoint], - }) - - it('Returns Recently Modified Deals', function() { - return hubspot.deals.getRecentlyModified().then(data => { - expect(data.results).to.be.an('array') - }) - }) - }) - - describe('getById', function() { - let dealId = 123 - const dealEndpoint = { - path: `/deals/v1/deal/${dealId}`, - response: {}, - } - fakeHubspotApi.setupServer({ getEndpoints: [dealEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestDeal().then(data => { - dealId = data.dealId - }) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestDeal(dealId) - } - }) - - it("Returns the entire deal, including all of it's properties", function() { - return hubspot.deals.getById(dealId).then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('getAssociated', function() { - let dealId = 123 - let companyId = 234 - const associationType = 'COMPANY' - const associatedDealsEndpoint = { - path: `/deals/v1/deal/associated/${associationType}/${companyId}/paged`, - response: { deals: [{}] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [associatedDealsEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createDealWithCompany().then(({ dataDealId, dataCompanyId }) => { - dealId = dataDealId - companyId = dataCompanyId - }) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestDeal(dealId).then(() => deleteTestCompany(companyId)) - } - }) - - it('Returns the deals associated to the object', function() { - return hubspot.deals - .getAssociated(associationType, companyId) - .then(data => { - expect(data).to.be.an('object') - expect(data.deals).to.have.length(1) - }) - }) - }) - - describe('deleteById', function() { - let dealId = 123 - const deleteDealEndpoint = { - path: `/deals/v1/deal/${dealId}`, - statusCode: 204, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [deleteDealEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestDeal().then(data => (dealId = data.dealId)) - } - }) - - it('should delete a deal by Id', function() { - return hubspot.deals.deleteById(dealId).then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) - - describe('updateById', function() { - let dealId = 123 - const updateDealEndpoint = { - path: `/deals/v1/deal/${dealId}`, - response: {}, - } - fakeHubspotApi.setupServer({ putEndpoints: [updateDealEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestDeal().then(data => (dealId = data.dealId)) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestDeal(dealId) - } - }) - - it('updates the deal', function() { - return hubspot.deals - .updateById(dealId, { - properties: [{ name: 'dealname', value: 'MadKudu' }], - }) - .then(data => { - expect(data).to.be.an('object') - }) - }) - }) - - describe('create', function() { - let dealId - const createDealEndpoint = { - path: '/deals/v1/deal', - response: {}, - } - fakeHubspotApi.setupServer({ postEndpoints: [createDealEndpoint] }) - - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestDeal(dealId) - } - }) - - it('Returns a 200 with the newly created Deal', function() { - return hubspot.deals - .create({ - properties: [ - { - value: 'MadKudu', - name: 'dealname', - }, - { - value: 'appointmentscheduled', - name: 'dealstage', - }, - { - value: 'default', - name: 'pipeline', - }, - { - value: '60000', - name: 'amount', - }, - { - value: 'newbusiness', - name: 'dealtype', - }, - ], - }) - .then(data => { - dealId = data.dealId - expect(data).to.be.a('object') - }) - }) - }) - - describe('associate', function() { - let dealId = 123 - let companyId = 234 - const associationType = 'COMPANY' - const associateDealEndpoint = { - path: `/deals/v1/deal/${dealId}/associations/${associationType}`, - query: { id: companyId }, - statusCode: 204, - } - fakeHubspotApi.setupServer({ putEndpoints: [associateDealEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return Promise.all([ - createTestDeal().then(data => (dealId = data.dealId)), - createTestCompany().then(data => (companyId = data.companyId)), - ]) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return Promise.all([ - deleteTestDeal(dealId), - deleteTestCompany(companyId), - ]) - } - }) - - it('Returns a 204', function() { - return hubspot.deals - .associate(dealId, associationType, companyId) - .then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) - - describe('removeAssociation', function() { - let dealId = 123 - let companyId = 234 - const associationType = 'COMPANY' - const unassociateDealEndpoint = { - path: `/deals/v1/deal/${dealId}/associations/${associationType}`, - query: { id: companyId }, - statusCode: 204, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [unassociateDealEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createDealWithCompany().then(({ dataDealId, dataCompanyId }) => { - dealId = dataDealId - companyId = dataCompanyId - }) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return Promise.all([ - deleteTestDeal(dealId), - deleteTestCompany(companyId), - ]) - } - }) - - it('Returns a 204', function() { - return hubspot.deals - .removeAssociation(dealId, associationType, companyId) - .then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) -}) +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') + +describe('deals', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'fake-token', + }) + const dealProperties = [ + { + value: 'MadKudu', + name: 'dealname', + }, + { + value: 'appointmentscheduled', + name: 'dealstage', + }, + { + value: 'default', + name: 'pipeline', + }, + { + value: Date.now(), + name: 'closedate', + }, + { + value: '60000', + name: 'amount', + }, + { + value: 'newbusiness', + name: 'dealtype', + }, + ] + const companyProperties = [ + { name: 'name', value: 'A company name' }, + { name: 'description', value: 'A company description' }, + ] + const createTestDeal = () => + hubspot.deals.create({ properties: dealProperties }) + const deleteTestDeal = dealId => hubspot.deals.deleteById(dealId) + const createTestCompany = () => + hubspot.companies.create({ properties: companyProperties }) + const createDealWithCompany = () => + hubspot.companies + .create({ properties: companyProperties }) + .then(companyData => { + return hubspot.deals + .create({ + associations: { + associatedCompanyIds: [companyData.companyId], + }, + properties: dealProperties, + }) + .then(dealData => { + return { + dataCompanyId: companyData.companyId, + dataDealId: dealData.dealId, + } + }) + }) + const deleteTestCompany = companyId => hubspot.companies.delete(companyId) + + describe('get', function() { + const dealsEndpoint = { + path: '/deals/v1/deal/paged', + response: { deals: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [dealsEndpoint] }) + + it('Should return deal properties', function() { + return hubspot.deals.get().then(data => { + expect(data).to.be.a('object') + expect(data.deals).to.be.an('array') + }) + }) + }) + + describe('getRecentlyCreated', function() { + const recentlyCreatedDealsEndpoint = { + path: '/deals/v1/deal/recent/created', + response: { results: [] }, + } + fakeHubspotApi.setupServer({ + getEndpoints: [recentlyCreatedDealsEndpoint], + }) + + it('Returns Recently Created Deals', function() { + return hubspot.deals.getRecentlyCreated().then(data => { + expect(data.results).to.be.an('array') + }) + }) + }) + + describe('getRecentlyModified', function() { + const recentlyModifiedDealsEndpoint = { + path: '/deals/v1/deal/recent/modified', + response: { results: [] }, + } + fakeHubspotApi.setupServer({ + getEndpoints: [recentlyModifiedDealsEndpoint], + }) + + it('Returns Recently Modified Deals', function() { + return hubspot.deals.getRecentlyModified().then(data => { + expect(data.results).to.be.an('array') + }) + }) + }) + + describe('getById', function() { + let dealId = 123 + const dealEndpoint = { + path: `/deals/v1/deal/${dealId}`, + response: {}, + } + fakeHubspotApi.setupServer({ getEndpoints: [dealEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestDeal().then(data => { + dealId = data.dealId + }) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestDeal(dealId) + } + }) + + it("Returns the entire deal, including all of it's properties", function() { + return hubspot.deals.getById(dealId).then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('getAssociated', function() { + let dealId = 123 + let companyId = 234 + const associationType = 'COMPANY' + const associatedDealsEndpoint = { + path: `/deals/v1/deal/associated/${associationType}/${companyId}/paged`, + response: { deals: [{}] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [associatedDealsEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createDealWithCompany().then(({ dataDealId, dataCompanyId }) => { + dealId = dataDealId + companyId = dataCompanyId + }) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestDeal(dealId).then(() => deleteTestCompany(companyId)) + } + }) + + it('Returns the deals associated to the object', function() { + return hubspot.deals + .getAssociated(associationType, companyId) + .then(data => { + expect(data).to.be.an('object') + expect(data.deals).to.have.length(1) + }) + }) + }) + + describe('deleteById', function() { + let dealId = 123 + const deleteDealEndpoint = { + path: `/deals/v1/deal/${dealId}`, + statusCode: 204, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [deleteDealEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestDeal().then(data => (dealId = data.dealId)) + } + }) + + it('should delete a deal by Id', function() { + return hubspot.deals.deleteById(dealId).then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) + + describe('updateById', function() { + let dealId = 123 + const updateDealEndpoint = { + path: `/deals/v1/deal/${dealId}`, + response: {}, + } + fakeHubspotApi.setupServer({ putEndpoints: [updateDealEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestDeal().then(data => (dealId = data.dealId)) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestDeal(dealId) + } + }) + + it('updates the deal', function() { + return hubspot.deals + .updateById(dealId, { + properties: [{ name: 'dealname', value: 'MadKudu' }], + }) + .then(data => { + expect(data).to.be.an('object') + }) + }) + }) + + describe('create', function() { + let dealId + const createDealEndpoint = { + path: '/deals/v1/deal', + response: {}, + } + fakeHubspotApi.setupServer({ postEndpoints: [createDealEndpoint] }) + + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestDeal(dealId) + } + }) + + it('Returns a 200 with the newly created Deal', function() { + return hubspot.deals + .create({ + properties: [ + { + value: 'MadKudu', + name: 'dealname', + }, + { + value: 'appointmentscheduled', + name: 'dealstage', + }, + { + value: 'default', + name: 'pipeline', + }, + { + value: '60000', + name: 'amount', + }, + { + value: 'newbusiness', + name: 'dealtype', + }, + ], + }) + .then(data => { + dealId = data.dealId + expect(data).to.be.a('object') + }) + }) + }) + + describe('associate', function() { + let dealId = 123 + let companyId = 234 + const associationType = 'COMPANY' + const associateDealEndpoint = { + path: `/deals/v1/deal/${dealId}/associations/${associationType}`, + query: { id: companyId }, + statusCode: 204, + } + fakeHubspotApi.setupServer({ putEndpoints: [associateDealEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return Promise.all([ + createTestDeal().then(data => (dealId = data.dealId)), + createTestCompany().then(data => (companyId = data.companyId)), + ]) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return Promise.all([ + deleteTestDeal(dealId), + deleteTestCompany(companyId), + ]) + } + }) + + it('Returns a 204', function() { + return hubspot.deals + .associate(dealId, associationType, companyId) + .then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) + + describe('removeAssociation', function() { + let dealId = 123 + let companyId = 234 + const associationType = 'COMPANY' + const unassociateDealEndpoint = { + path: `/deals/v1/deal/${dealId}/associations/${associationType}`, + query: { id: companyId }, + statusCode: 204, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [unassociateDealEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createDealWithCompany().then(({ dataDealId, dataCompanyId }) => { + dealId = dataDealId + companyId = dataCompanyId + }) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return Promise.all([ + deleteTestDeal(dealId), + deleteTestCompany(companyId), + ]) + } + }) + + it('Returns a 204', function() { + return hubspot.deals + .removeAssociation(dealId, associationType, companyId) + .then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) +}) diff --git a/test/engagements.js b/test/engagements.js index 0e62a4c..775b824 100644 --- a/test/engagements.js +++ b/test/engagements.js @@ -1,71 +1,71 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('Engagements', function() { - describe('Get All Engagements', function() { - it('Should return engagement properties', function() { - return hubspot.engagements.get().then(data => { - expect(data).to.be.an('object') - expect(data.results).to.be.a('array') - expect(data.results[0]).to.have.a.property('engagement') - }) - }) - }) - - describe('Get Recent Engagements', function() { - it('Should return engagement properties', function() { - return hubspot.engagements.getRecentlyModified().then(data => { - expect(data).to.be.an('object') - expect(data.results).to.be.a('array') - expect(data.results[0]).to.have.a.property('engagement') - expect(data.total).to.be.above(0) - }) - }) - }) - - describe('Get Call Dispositions', function() { - it('Should return a list of call dispositions', function() { - return hubspot.engagements.getCallDispositions().then(data => { - expect(data).to.be.an('array') - expect(data[0]).to.have.a.property('id') - expect(data[0]).to.have.a.property('label') - }) - }) - }) - - // Test too brittle. First contactId doesn't necessarily has engagement - - // describe('Get Associated Engagements', function () { - // let contactId - // - // before(function () { - // return hubspot.contacts.get().then(data => { - // contactId = data.contacts[0].vid - // }) - // }) - // - // it('should return associated engagements for a contact id', function () { - // return hubspot.engagements.getAssociated('CONTACT', contactId).then(data => { - // expect(data).to.be.an('object') - // expect(data.results).to.be.a('array') - // expect(data.results[0]).to.have.a.property('engagement') - // expect(data.results[0]).to.have.a.property('associations') - // expect(data.results[0].associations).to.have.a.property('contactIds') - // expect(data.results[0].associations.contactIds[0]).to.equal(contactId) - // }) - // }) - // }) - - // describe('create', function () { - // it('Should create an engagement', function () { - // const payload = { 'engagement': { 'active': true, 'ownerId': 1, 'type': 'NOTE', 'timestamp': 1409172644778 }, 'associations': { 'contactIds': [2], 'companyIds': [ ], 'dealIds': [ ], 'ownerIds': [ ] }, 'metadata': { 'body': 'note body' } } - // return hubspot.engagements.create(payload).then(data => { - // expect(data.status).to.equal('error') - // expect(data.message).to.equal('one or more associations were invalid') - // }) - // }) - // }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('Engagements', function() { + describe('Get All Engagements', function() { + it('Should return engagement properties', function() { + return hubspot.engagements.get().then(data => { + expect(data).to.be.an('object') + expect(data.results).to.be.a('array') + expect(data.results[0]).to.have.a.property('engagement') + }) + }) + }) + + describe('Get Recent Engagements', function() { + it('Should return engagement properties', function() { + return hubspot.engagements.getRecentlyModified().then(data => { + expect(data).to.be.an('object') + expect(data.results).to.be.a('array') + expect(data.results[0]).to.have.a.property('engagement') + expect(data.total).to.be.above(0) + }) + }) + }) + + describe('Get Call Dispositions', function() { + it('Should return a list of call dispositions', function() { + return hubspot.engagements.getCallDispositions().then(data => { + expect(data).to.be.an('array') + expect(data[0]).to.have.a.property('id') + expect(data[0]).to.have.a.property('label') + }) + }) + }) + + // Test too brittle. First contactId doesn't necessarily has engagement + + // describe('Get Associated Engagements', function () { + // let contactId + // + // before(function () { + // return hubspot.contacts.get().then(data => { + // contactId = data.contacts[0].vid + // }) + // }) + // + // it('should return associated engagements for a contact id', function () { + // return hubspot.engagements.getAssociated('CONTACT', contactId).then(data => { + // expect(data).to.be.an('object') + // expect(data.results).to.be.a('array') + // expect(data.results[0]).to.have.a.property('engagement') + // expect(data.results[0]).to.have.a.property('associations') + // expect(data.results[0].associations).to.have.a.property('contactIds') + // expect(data.results[0].associations.contactIds[0]).to.equal(contactId) + // }) + // }) + // }) + + // describe('create', function () { + // it('Should create an engagement', function () { + // const payload = { 'engagement': { 'active': true, 'ownerId': 1, 'type': 'NOTE', 'timestamp': 1409172644778 }, 'associations': { 'contactIds': [2], 'companyIds': [ ], 'dealIds': [ ], 'ownerIds': [ ] }, 'metadata': { 'body': 'note body' } } + // return hubspot.engagements.create(payload).then(data => { + // expect(data.status).to.equal('error') + // expect(data.message).to.equal('one or more associations were invalid') + // }) + // }) + // }) +}) diff --git a/test/files.js b/test/files.js index df16b8a..c7edb47 100644 --- a/test/files.js +++ b/test/files.js @@ -1,34 +1,34 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('files', function() { - describe('get', function() { - it('Should return all files', function() { - return hubspot.files.get().then(data => { - // console.log(data) - expect(data).to.be.a('object') - expect(data.total_count).to.be.above(0) - }) - }) - }) - - describe('getOne', function() { - let fileId - - before(function() { - return hubspot.files.get().then(data => { - fileId = data.objects[0].id - }) - }) - - it('Should return one file', function() { - return hubspot.files.getOne(fileId).then(data => { - // console.log(data) - expect(data).to.be.an('object') - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('files', function() { + describe('get', function() { + it('Should return all files', function() { + return hubspot.files.get().then(data => { + // console.log(data) + expect(data).to.be.a('object') + expect(data.total_count).to.be.above(0) + }) + }) + }) + + describe('getOne', function() { + let fileId + + before(function() { + return hubspot.files.get().then(data => { + fileId = data.objects[0].id + }) + }) + + it('Should return one file', function() { + return hubspot.files.getOne(fileId).then(data => { + // console.log(data) + expect(data).to.be.an('object') + }) + }) + }) +}) diff --git a/test/helpers/factories.js b/test/helpers/factories.js index b843b90..4e4d193 100644 --- a/test/helpers/factories.js +++ b/test/helpers/factories.js @@ -1,29 +1,29 @@ -const createTestContact = hubspot => - hubspot.contacts.create({ - properties: [ - { - property: 'email', - value: 'node-hubspot' + Date.now() + '@madkudu.com', - }, - { - property: 'firstname', - value: 'Try', - }, - { - property: 'lastname', - value: 'MadKudu', - }, - { - property: 'website', - value: 'http://www.madkudu.com', - }, - { - property: 'company', - value: 'MadKudu', - }, - ], - }) -const deleteTestContact = (hubspot, contactId) => - hubspot.contacts.delete(contactId) - -module.exports = { createTestContact, deleteTestContact } +const createTestContact = hubspot => + hubspot.contacts.create({ + properties: [ + { + property: 'email', + value: 'node-hubspot' + Date.now() + '@madkudu.com', + }, + { + property: 'firstname', + value: 'Try', + }, + { + property: 'lastname', + value: 'MadKudu', + }, + { + property: 'website', + value: 'http://www.madkudu.com', + }, + { + property: 'company', + value: 'MadKudu', + }, + ], + }) +const deleteTestContact = (hubspot, contactId) => + hubspot.contacts.delete(contactId) + +module.exports = { createTestContact, deleteTestContact } diff --git a/test/helpers/fake_hubspot_api.js b/test/helpers/fake_hubspot_api.js index c76f65c..da0d646 100644 --- a/test/helpers/fake_hubspot_api.js +++ b/test/helpers/fake_hubspot_api.js @@ -1,37 +1,37 @@ -const nockHelper = require('./nock_helper') - -class FakeHubSpotApi { - setupServer({ - demo = false, - getEndpoints = [], - postEndpoints = [], - putEndpoints = [], - deleteEndpoints = [], - } = {}) { - let maybeAddHapiKeyToQuery = x => x - if (demo) { - maybeAddHapiKeyToQuery = parameters => { - parameters.query = parameters.query || {} - parameters.query.hapikey = parameters.query.hapikey || 'demo' - return parameters - } - } - - beforeEach(function() { - nockHelper.disableNetConnect() - nockHelper.mockRateLimit() - getEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockGetEndpoint) - postEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockPostEndpoint) - putEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockPutEndpoint) - deleteEndpoints - .map(maybeAddHapiKeyToQuery) - .map(nockHelper.mockDeleteEndpoint) - }) - - afterEach(function() { - nockHelper.resetNock() - }) - } -} - -module.exports = new FakeHubSpotApi() +const nockHelper = require('./nock_helper') + +class FakeHubSpotApi { + setupServer({ + demo = false, + getEndpoints = [], + postEndpoints = [], + putEndpoints = [], + deleteEndpoints = [], + } = {}) { + let maybeAddHapiKeyToQuery = x => x + if (demo) { + maybeAddHapiKeyToQuery = parameters => { + parameters.query = parameters.query || {} + parameters.query.hapikey = parameters.query.hapikey || 'demo' + return parameters + } + } + + beforeEach(function() { + nockHelper.disableNetConnect() + nockHelper.mockRateLimit() + getEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockGetEndpoint) + postEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockPostEndpoint) + putEndpoints.map(maybeAddHapiKeyToQuery).map(nockHelper.mockPutEndpoint) + deleteEndpoints + .map(maybeAddHapiKeyToQuery) + .map(nockHelper.mockDeleteEndpoint) + }) + + afterEach(function() { + nockHelper.resetNock() + }) + } +} + +module.exports = new FakeHubSpotApi() diff --git a/test/helpers/nock_helper.js b/test/helpers/nock_helper.js index cb33fc4..43e75e4 100644 --- a/test/helpers/nock_helper.js +++ b/test/helpers/nock_helper.js @@ -1,74 +1,74 @@ -const nock = require('nock') - -const mockEndpoint = ({ - path, - response, - responseError, - verb, - request, - query = {}, - statusCode = 200, -}) => { - if (responseError) { - nock('http://api.hubapi.com', { encodedQueryParams: true }) - .intercept(path, verb, request) - .query(query) - .replyWithError(responseError) - } else { - nock('http://api.hubapi.com', { encodedQueryParams: true }) - .intercept(path, verb, request) - .query(query) - .reply(statusCode, response) - } -} - -class NockHelper { - disableNetConnect() { - nock.disableNetConnect() - } - - mockRateLimit() { - mockEndpoint({ - path: '/integrations/v1/limit/daily', - verb: 'GET', - response: [ - { - name: 'api-calls-daily', - usageLimit: 160000, - currentUsage: 19742, - collectedAt: Date.now(), - fetchStatus: 'CACHED', - resetsAt: Date.now() + 24 * 60 * 60 * 1000, - }, - ], - query: { hapikey: 'demo' }, - }) - } - - mockGetEndpoint(parameters) { - parameters.verb = 'GET' - mockEndpoint(parameters) - } - - mockPostEndpoint(parameters) { - parameters.verb = 'POST' - mockEndpoint(parameters) - } - - mockPutEndpoint(parameters) { - parameters.verb = 'PUT' - mockEndpoint(parameters) - } - - mockDeleteEndpoint(parameters) { - parameters.verb = 'DELETE' - mockEndpoint(parameters) - } - - resetNock() { - nock.cleanAll() - nock.enableNetConnect() - } -} - -module.exports = new NockHelper() +const nock = require('nock') + +const mockEndpoint = ({ + path, + response, + responseError, + verb, + request, + query = {}, + statusCode = 200, +}) => { + if (responseError) { + nock('http://api.hubapi.com', { encodedQueryParams: true }) + .intercept(path, verb, request) + .query(query) + .replyWithError(responseError) + } else { + nock('http://api.hubapi.com', { encodedQueryParams: true }) + .intercept(path, verb, request) + .query(query) + .reply(statusCode, response) + } +} + +class NockHelper { + disableNetConnect() { + nock.disableNetConnect() + } + + mockRateLimit() { + mockEndpoint({ + path: '/integrations/v1/limit/daily', + verb: 'GET', + response: [ + { + name: 'api-calls-daily', + usageLimit: 160000, + currentUsage: 19742, + collectedAt: Date.now(), + fetchStatus: 'CACHED', + resetsAt: Date.now() + 24 * 60 * 60 * 1000, + }, + ], + query: { hapikey: 'demo' }, + }) + } + + mockGetEndpoint(parameters) { + parameters.verb = 'GET' + mockEndpoint(parameters) + } + + mockPostEndpoint(parameters) { + parameters.verb = 'POST' + mockEndpoint(parameters) + } + + mockPutEndpoint(parameters) { + parameters.verb = 'PUT' + mockEndpoint(parameters) + } + + mockDeleteEndpoint(parameters) { + parameters.verb = 'DELETE' + mockEndpoint(parameters) + } + + resetNock() { + nock.cleanAll() + nock.enableNetConnect() + } +} + +module.exports = new NockHelper() diff --git a/test/integrations.js b/test/integrations.js new file mode 100644 index 0000000..6d31025 --- /dev/null +++ b/test/integrations.js @@ -0,0 +1,24 @@ +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') + +describe('integrations', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'some-fake-token', + }) + + describe('getAccountDetails', function() { + const integrationsEndpoint = { + path: '/integrations/v1/me', + response: { integrations: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [integrationsEndpoint] }) + + it('should return account details', function() { + return hubspot.integrations.getAccountDetails().then(data => { + expect(data).to.be.a('object') + expect(data.integrations).to.be.a('array') + }) + }) + }) +}) diff --git a/test/lists.js b/test/lists.js index d9ba964..5dbd281 100644 --- a/test/lists.js +++ b/test/lists.js @@ -1,272 +1,272 @@ -const { expect } = require('chai') -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') -const { createTestContact, deleteTestContact } = require('./helpers/factories') - -describe('lists', function() { - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'some-fake-token', - }) - const listProperties = { name: 'Test list name' } - const createTestList = () => hubspot.lists.create(listProperties) - const deleteTestList = listId => hubspot.lists.delete(listId) - - describe('get', function() { - const listsEndpoint = { - path: '/contacts/v1/lists', - response: { lists: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [listsEndpoint] }) - - it('should return contact lists', function() { - return hubspot.lists.get().then(data => { - expect(data).to.be.a('object') - expect(data.lists).to.be.a('array') - }) - }) - }) - - describe('getOne', function() { - describe('when passed a listId', function() { - let listId = 123 - const listEndpoint = { - path: `/contacts/v1/lists/${listId}`, - response: listProperties, - } - fakeHubspotApi.setupServer({ getEndpoints: [listEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestList(listProperties).then( - data => (listId = data.listId) - ) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestList(listId) - } - }) - - it('should return one contact list', function() { - return hubspot.lists.getOne(listId).then(data => { - expect(data).to.be.a('object') - expect(data.name).to.equal(listProperties.name) - }) - }) - }) - - describe('when not passed a listId', function() { - it('should return a rejected promise', function() { - return hubspot.lists - .getOne() - .then(data => { - throw new Error('I should have thrown an error') - }) - .catch(error => { - expect(error.message).to.equal('id parameter must be provided.') - }) - }) - }) - }) - - describe('create', function() { - let listId - const createListEndpoint = { - path: '/contacts/v1/lists', - request: listProperties, - response: listProperties, - } - fakeHubspotApi.setupServer({ postEndpoints: [createListEndpoint] }) - - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestList(listId) - } - }) - - it('should return the created list', function() { - return hubspot.lists.create(listProperties).then(data => { - listId = data.listId - expect(data).to.be.a('object') - }) - }) - }) - - describe('delete', function() { - let listId - const deleteListEndpoint = { - path: `/contacts/v1/lists/${listId}`, - statusCode: 204, - } - fakeHubspotApi.setupServer({ deleteEndpoints: [deleteListEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestList(listProperties).then( - data => (listId = data.listId) - ) - } - }) - - it('should return a 204', function() { - return hubspot.lists.delete(listId).then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) - - describe('getContacts', function() { - describe('when passed a listId', function() { - let listId = 123 - const listContactsEndpoint = { - path: `/contacts/v1/lists/${listId}/contacts/all`, - response: { contacts: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [listContactsEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestList(listProperties).then( - data => (listId = data.listId) - ) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestList(listId) - } - }) - - it('should return contacts', function() { - return hubspot.lists.getContacts(listId).then(data => { - expect(data).to.be.a('object') - expect(data.contacts).to.be.an('array') - }) - }) - }) - - describe('when not passed a listId', function() { - it('should return a rejected promise', function() { - return hubspot.lists - .getContacts() - .then(data => { - throw new Error('I should have thrown an error') - }) - .catch(error => { - expect(error.message).to.equal('id parameter must be provided.') - }) - }) - }) - }) - - describe('getRecentContacts', function() { - describe('when passed a listId', function() { - let listId = 123 - const listContactsEndpoint = { - path: `/contacts/v1/lists/${listId}/contacts/recent`, - response: { contacts: [] }, - } - fakeHubspotApi.setupServer({ getEndpoints: [listContactsEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return createTestList(listProperties).then( - data => (listId = data.listId) - ) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return deleteTestList(listId) - } - }) - - it('should return contacts', function() { - return hubspot.lists.getRecentContacts(listId).then(data => { - expect(data).to.be.a('object') - expect(data.contacts).to.be.an('array') - }) - }) - }) - - describe('when not passed a listId', function() { - it('should return a rejected promise', function() { - return hubspot.lists - .getRecentContacts() - .then(data => { - throw new Error('I should have thrown an error') - }) - .catch(error => { - expect(error.message).to.equal('id parameter must be provided.') - }) - }) - }) - }) - - describe('addContacts', function() { - describe('when a id and contactBody is provided', function() { - let listId = 123 - let contactId = 234 - const addContactToListEndpoint = { - path: `/contacts/v1/lists/${listId}/add`, - request: { vids: [contactId] }, - response: { contacts: [] }, - } - fakeHubspotApi.setupServer({ postEndpoints: [addContactToListEndpoint] }) - - before(function() { - if (process.env.NOCK_OFF) { - return Promise.all([ - createTestContact(hubspot).then(data => (contactId = data.vid)), - createTestList(listProperties).then(data => (listId = data.listId)), - ]) - } - }) - after(function() { - if (process.env.NOCK_OFF) { - return Promise.all([ - deleteTestContact(hubspot, contactId), - deleteTestList(listId), - ]) - } - }) - - it('should return results', function() { - return hubspot.lists - .addContacts(listId, { vids: [contactId] }) - .then(data => { - expect(data).to.be.a('object') - }) - }) - }) - - describe('when not passed a listId', function() { - it('should return a rejected promise', function() { - return hubspot.lists - .addContacts() - .then(data => { - throw new Error('I should have thrown an error') - }) - .catch(error => { - expect(error.message).to.equal('id parameter must be provided.') - }) - }) - }) - - describe('when passed a listId but not contactBody', function() { - it('should return a rejected promise', function() { - return hubspot.lists - .addContacts(123) - .then(data => { - throw new Error('I should have thrown an error') - }) - .catch(error => { - expect(error.message).to.equal( - 'contactBody parameter must be provided.' - ) - }) - }) - }) - }) -}) +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') +const { createTestContact, deleteTestContact } = require('./helpers/factories') + +describe('lists', function() { + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'some-fake-token', + }) + const listProperties = { name: 'Test list name' } + const createTestList = () => hubspot.lists.create(listProperties) + const deleteTestList = listId => hubspot.lists.delete(listId) + + describe('get', function() { + const listsEndpoint = { + path: '/contacts/v1/lists', + response: { lists: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [listsEndpoint] }) + + it('should return contact lists', function() { + return hubspot.lists.get().then(data => { + expect(data).to.be.a('object') + expect(data.lists).to.be.a('array') + }) + }) + }) + + describe('getOne', function() { + describe('when passed a listId', function() { + let listId = 123 + const listEndpoint = { + path: `/contacts/v1/lists/${listId}`, + response: listProperties, + } + fakeHubspotApi.setupServer({ getEndpoints: [listEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestList(listProperties).then( + data => (listId = data.listId) + ) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestList(listId) + } + }) + + it('should return one contact list', function() { + return hubspot.lists.getOne(listId).then(data => { + expect(data).to.be.a('object') + expect(data.name).to.equal(listProperties.name) + }) + }) + }) + + describe('when not passed a listId', function() { + it('should return a rejected promise', function() { + return hubspot.lists + .getOne() + .then(data => { + throw new Error('I should have thrown an error') + }) + .catch(error => { + expect(error.message).to.equal('id parameter must be provided.') + }) + }) + }) + }) + + describe('create', function() { + let listId + const createListEndpoint = { + path: '/contacts/v1/lists', + request: listProperties, + response: listProperties, + } + fakeHubspotApi.setupServer({ postEndpoints: [createListEndpoint] }) + + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestList(listId) + } + }) + + it('should return the created list', function() { + return hubspot.lists.create(listProperties).then(data => { + listId = data.listId + expect(data).to.be.a('object') + }) + }) + }) + + describe('delete', function() { + let listId + const deleteListEndpoint = { + path: `/contacts/v1/lists/${listId}`, + statusCode: 204, + } + fakeHubspotApi.setupServer({ deleteEndpoints: [deleteListEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestList(listProperties).then( + data => (listId = data.listId) + ) + } + }) + + it('should return a 204', function() { + return hubspot.lists.delete(listId).then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) + + describe('getContacts', function() { + describe('when passed a listId', function() { + let listId = 123 + const listContactsEndpoint = { + path: `/contacts/v1/lists/${listId}/contacts/all`, + response: { contacts: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [listContactsEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestList(listProperties).then( + data => (listId = data.listId) + ) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestList(listId) + } + }) + + it('should return contacts', function() { + return hubspot.lists.getContacts(listId).then(data => { + expect(data).to.be.a('object') + expect(data.contacts).to.be.an('array') + }) + }) + }) + + describe('when not passed a listId', function() { + it('should return a rejected promise', function() { + return hubspot.lists + .getContacts() + .then(data => { + throw new Error('I should have thrown an error') + }) + .catch(error => { + expect(error.message).to.equal('id parameter must be provided.') + }) + }) + }) + }) + + describe('getRecentContacts', function() { + describe('when passed a listId', function() { + let listId = 123 + const listContactsEndpoint = { + path: `/contacts/v1/lists/${listId}/contacts/recent`, + response: { contacts: [] }, + } + fakeHubspotApi.setupServer({ getEndpoints: [listContactsEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return createTestList(listProperties).then( + data => (listId = data.listId) + ) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return deleteTestList(listId) + } + }) + + it('should return contacts', function() { + return hubspot.lists.getRecentContacts(listId).then(data => { + expect(data).to.be.a('object') + expect(data.contacts).to.be.an('array') + }) + }) + }) + + describe('when not passed a listId', function() { + it('should return a rejected promise', function() { + return hubspot.lists + .getRecentContacts() + .then(data => { + throw new Error('I should have thrown an error') + }) + .catch(error => { + expect(error.message).to.equal('id parameter must be provided.') + }) + }) + }) + }) + + describe('addContacts', function() { + describe('when a id and contactBody is provided', function() { + let listId = 123 + let contactId = 234 + const addContactToListEndpoint = { + path: `/contacts/v1/lists/${listId}/add`, + request: { vids: [contactId] }, + response: { contacts: [] }, + } + fakeHubspotApi.setupServer({ postEndpoints: [addContactToListEndpoint] }) + + before(function() { + if (process.env.NOCK_OFF) { + return Promise.all([ + createTestContact(hubspot).then(data => (contactId = data.vid)), + createTestList(listProperties).then(data => (listId = data.listId)), + ]) + } + }) + after(function() { + if (process.env.NOCK_OFF) { + return Promise.all([ + deleteTestContact(hubspot, contactId), + deleteTestList(listId), + ]) + } + }) + + it('should return results', function() { + return hubspot.lists + .addContacts(listId, { vids: [contactId] }) + .then(data => { + expect(data).to.be.a('object') + }) + }) + }) + + describe('when not passed a listId', function() { + it('should return a rejected promise', function() { + return hubspot.lists + .addContacts() + .then(data => { + throw new Error('I should have thrown an error') + }) + .catch(error => { + expect(error.message).to.equal('id parameter must be provided.') + }) + }) + }) + + describe('when passed a listId but not contactBody', function() { + it('should return a rejected promise', function() { + return hubspot.lists + .addContacts(123) + .then(data => { + throw new Error('I should have thrown an error') + }) + .catch(error => { + expect(error.message).to.equal( + 'contactBody parameter must be provided.' + ) + }) + }) + }) + }) +}) diff --git a/test/oauth.js b/test/oauth.js index af059b9..395f317 100644 --- a/test/oauth.js +++ b/test/oauth.js @@ -1,101 +1,101 @@ -const { expect } = require('chai') -const Hubspot = require('..') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') - -describe('oauth', function() { - let hubspot - - describe('getAuthorizationUrl', function() { - beforeEach(() => { - hubspot = new Hubspot() - }) - - it('should return the correct authorizationUrl for a given app', function() { - const params = { - client_id: 'fake_client_id', - scopes: 'some scopes', - redirect_uri: 'take_me_to_the_ballpark', - } - const uri = hubspot.oauth.getAuthorizationUrl(params) - expect(uri).to.be.a('string') - expect(uri).to.contain('scopes=some%20scopes') - }) - }) - - describe('getAccessToken', function() { - const code = 'a_fake_code' - const clientProperties = { - clientId: 'fake_client_id', - clientSecret: 'fake_client_secret', - redirectUri: 'some-redirect-uri', - } - const expectedResponse = { - refresh_token: 'a_fake_refresh_token', - access_token: 'a_fake_access_token', - expires_in: 21600, - } - const oauthTokenEndpoint = { - path: '/oauth/v1/token', - request: { - grant_type: 'authorization_code', - client_id: clientProperties.clientId, - client_secret: clientProperties.clientSecret, - redirect_uri: clientProperties.redirectUri, - code, - }, - response: expectedResponse, - } - fakeHubspotApi.setupServer({ postEndpoints: [oauthTokenEndpoint] }) - - if (process.env.NOCK_OFF) { - it('will not run with NOCK_OFF set to true. See commit message.') - } else { - it('should return a token from hubspot', function() { - hubspot = new Hubspot(clientProperties) - - return hubspot.oauth.getAccessToken({ code }).then(data => { - expect(data).to.deep.equal(expectedResponse) - }) - }) - } - }) - - describe('refreshAccessToken', function() { - const clientProperties = { - clientId: 'fake_client_id', - clientSecret: 'fake_client_secret', - redirectUri: 'some-redirect-uri', - refreshToken: 'a_fake_refresh_token', - accessToken: 'a_fake_access_token', - } - const expectedResponse = { - refresh_token: 'a_new_fake_refresh_token', - access_token: 'a_new_fake_access_token', - expires_in: 21600, - } - const oauthTokenEndpoint = { - path: '/oauth/v1/token', - request: { - grant_type: 'refresh_token', - client_id: clientProperties.clientId, - client_secret: clientProperties.clientSecret, - redirect_uri: clientProperties.redirectUri, - refresh_token: clientProperties.refreshToken, - }, - response: expectedResponse, - } - fakeHubspotApi.setupServer({ postEndpoints: [oauthTokenEndpoint] }) - - if (process.env.NOCK_OFF) { - it('will not run with NOCK_OFF set to true. See commit message.') - } else { - it('should return a token from hubspot', function() { - hubspot = new Hubspot(clientProperties) - - return hubspot.oauth.refreshAccessToken().then(data => { - expect(data).to.deep.equal(expectedResponse) - }) - }) - } - }) -}) +const { expect } = require('chai') +const Hubspot = require('..') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') + +describe('oauth', function() { + let hubspot + + describe('getAuthorizationUrl', function() { + beforeEach(() => { + hubspot = new Hubspot() + }) + + it('should return the correct authorizationUrl for a given app', function() { + const params = { + client_id: 'fake_client_id', + scopes: 'some scopes', + redirect_uri: 'take_me_to_the_ballpark', + } + const uri = hubspot.oauth.getAuthorizationUrl(params) + expect(uri).to.be.a('string') + expect(uri).to.contain('scopes=some%20scopes') + }) + }) + + describe('getAccessToken', function() { + const code = 'a_fake_code' + const clientProperties = { + clientId: 'fake_client_id', + clientSecret: 'fake_client_secret', + redirectUri: 'some-redirect-uri', + } + const expectedResponse = { + refresh_token: 'a_fake_refresh_token', + access_token: 'a_fake_access_token', + expires_in: 21600, + } + const oauthTokenEndpoint = { + path: '/oauth/v1/token', + request: { + grant_type: 'authorization_code', + client_id: clientProperties.clientId, + client_secret: clientProperties.clientSecret, + redirect_uri: clientProperties.redirectUri, + code, + }, + response: expectedResponse, + } + fakeHubspotApi.setupServer({ postEndpoints: [oauthTokenEndpoint] }) + + if (process.env.NOCK_OFF) { + it('will not run with NOCK_OFF set to true. See commit message.') + } else { + it('should return a token from hubspot', function() { + hubspot = new Hubspot(clientProperties) + + return hubspot.oauth.getAccessToken({ code }).then(data => { + expect(data).to.deep.equal(expectedResponse) + }) + }) + } + }) + + describe('refreshAccessToken', function() { + const clientProperties = { + clientId: 'fake_client_id', + clientSecret: 'fake_client_secret', + redirectUri: 'some-redirect-uri', + refreshToken: 'a_fake_refresh_token', + accessToken: 'a_fake_access_token', + } + const expectedResponse = { + refresh_token: 'a_new_fake_refresh_token', + access_token: 'a_new_fake_access_token', + expires_in: 21600, + } + const oauthTokenEndpoint = { + path: '/oauth/v1/token', + request: { + grant_type: 'refresh_token', + client_id: clientProperties.clientId, + client_secret: clientProperties.clientSecret, + redirect_uri: clientProperties.redirectUri, + refresh_token: clientProperties.refreshToken, + }, + response: expectedResponse, + } + fakeHubspotApi.setupServer({ postEndpoints: [oauthTokenEndpoint] }) + + if (process.env.NOCK_OFF) { + it('will not run with NOCK_OFF set to true. See commit message.') + } else { + it('should return a token from hubspot', function() { + hubspot = new Hubspot(clientProperties) + + return hubspot.oauth.refreshAccessToken().then(data => { + expect(data).to.deep.equal(expectedResponse) + }) + }) + } + }) +}) diff --git a/test/owners.js b/test/owners.js index 5846aaa..e5733e0 100644 --- a/test/owners.js +++ b/test/owners.js @@ -1,18 +1,18 @@ -const { expect } = require('chai') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') -const Hubspot = require('..') - -describe('Owners', function() { - const ownersGetEndpoint = { path: '/owners/v2/owners', response: [] } - fakeHubspotApi.setupServer({ demo: true, getEndpoints: [ownersGetEndpoint] }) - - describe('get', function() { - it('Should return all owners', function() { - const hubspot = new Hubspot({ apiKey: 'demo' }) - - return hubspot.owners.get().then(data => { - expect(data).to.be.a('array') - }) - }) - }) -}) +const { expect } = require('chai') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') +const Hubspot = require('..') + +describe('Owners', function() { + const ownersGetEndpoint = { path: '/owners/v2/owners', response: [] } + fakeHubspotApi.setupServer({ demo: true, getEndpoints: [ownersGetEndpoint] }) + + describe('get', function() { + it('Should return all owners', function() { + const hubspot = new Hubspot({ apiKey: 'demo' }) + + return hubspot.owners.get().then(data => { + expect(data).to.be.a('array') + }) + }) + }) +}) diff --git a/test/page.js b/test/page.js index a947c04..e8bb705 100644 --- a/test/page.js +++ b/test/page.js @@ -1,23 +1,23 @@ -var chai = require('chai') -var expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('pages', function() { - describe('get', function() { - it('should return all pages', function() { - return hubspot.pages.get().then(data => { - expect(data).to.be.an('object') - expect(data.objects).to.be.a('array') - }) - }) - - it('should return only published pages', function() { - return hubspot.pages.get({ is_draft: false }).then(data => { - expect(data).to.be.an('object') - expect(data.objects).to.be.a('array') - }) - }) - }) -}) +var chai = require('chai') +var expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('pages', function() { + describe('get', function() { + it('should return all pages', function() { + return hubspot.pages.get().then(data => { + expect(data).to.be.an('object') + expect(data.objects).to.be.a('array') + }) + }) + + it('should return only published pages', function() { + return hubspot.pages.get({ is_draft: false }).then(data => { + expect(data).to.be.an('object') + expect(data.objects).to.be.a('array') + }) + }) + }) +}) diff --git a/test/pipelines.js b/test/pipelines.js index 5cc4d96..12935be 100644 --- a/test/pipelines.js +++ b/test/pipelines.js @@ -1,16 +1,16 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('Pipelines', function() { - describe('get', function() { - it('Should return all deal pipelines for a given portal', function() { - return hubspot.pipelines.get().then(data => { - expect(data).to.be.a('array') - expect(data[0]).to.have.a.property('pipelineId') - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('Pipelines', function() { + describe('get', function() { + it('Should return all deal pipelines for a given portal', function() { + return hubspot.pipelines.get().then(data => { + expect(data).to.be.a('array') + expect(data[0]).to.have.a.property('pipelineId') + }) + }) + }) +}) diff --git a/test/subscriptions.js b/test/subscriptions.js index c2086af..f8ec878 100644 --- a/test/subscriptions.js +++ b/test/subscriptions.js @@ -1,16 +1,16 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('subscriptions', function() { - describe('get', function() { - it('Should return a list of subscriptions', function() { - return hubspot.subscriptions.get().then(data => { - expect(data.timeline).to.be.a('array') - expect(data.hasMore).to.equal(true) - }) - }) - }) -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('subscriptions', function() { + describe('get', function() { + it('Should return a list of subscriptions', function() { + return hubspot.subscriptions.get().then(data => { + expect(data.timeline).to.be.a('array') + expect(data.hasMore).to.equal(true) + }) + }) + }) +}) diff --git a/test/timeline.js b/test/timeline.js index 430da25..71013f3 100644 --- a/test/timeline.js +++ b/test/timeline.js @@ -1,205 +1,205 @@ -const { expect } = require('chai') -const fakeHubspotApi = require('./helpers/fake_hubspot_api') -const Hubspot = require('..') - -const userId = process.env.USER_ID || 23456 -const applicationId = process.env.APPLICATION_ID || 12345 - -describe('timeline', function() { - const headerTemplate = - '# Title for event {{id}}\nThis is an event for {{objectType}}' - const detailTemplate = - 'This event happened on {{#formatDate timestamp}}{{/formatDate}}' - const hubspot = new Hubspot({ - accessToken: process.env.ACCESS_TOKEN || 'some-fake-token', - }) - const createEventType = () => - hubspot.timelines.createEventType(applicationId, userId, { - name: 'Test Event Type', - headerTemplate, - detailTemplate, - }) - const createEventTypeProperty = eventTypeId => - hubspot.timelines.createEventTypeProperty( - applicationId, - eventTypeId, - userId, - { - name: 'NumericProperty', - label: 'Numeric Property', - propertyType: 'Numeric', - } - ) - - describe('createEventType', () => { - const createEventTypeEndpoint = { - path: `/integrations/v1/${applicationId}/timeline/event-types`, - response: { - name: 'Test Event Type', - headerTemplate, - detailTemplate, - applicationId, - }, - query: { userId }, - } - fakeHubspotApi.setupServer({ postEndpoints: [createEventTypeEndpoint] }) - - it('should create an event type', async () => { - return hubspot.timelines - .createEventType(applicationId, userId, { - name: 'Test Event Type', - headerTemplate, - detailTemplate, - }) - .then(data => { - expect(data.headerTemplate).to.eq(headerTemplate) - expect(data.detailTemplate).to.eq(detailTemplate) - }) - }) - }) - - describe('updateEventType', () => { - let eventTypeId = 123 - const updateEventTypeEndpoint = { - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`, - response: { - name: 'Edited Event Type', - headerTemplate, - detailTemplate, - applicationId, - }, - } - fakeHubspotApi.setupServer({ putEndpoints: [updateEventTypeEndpoint] }) - - beforeEach(() => { - if (process.env.NOCK_OFF) { - return createEventType().then(data => (eventTypeId = data.id)) - } - }) - - it('should update an event type', async () => { - return hubspot.timelines - .updateEventType(applicationId, eventTypeId, { - name: 'Edited Event Type', - headerTemplate, - detailTemplate, - }) - .then(data => { - expect(data.name).to.eq('Edited Event Type') - }) - }) - }) - - describe('createEventTypeProperty', () => { - let eventTypeId = 123 - const createEventTypePropertyEndpoint = { - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, - response: { - name: 'NumericProperty', - label: 'Numeric Property', - propertyType: 'Numeric', - }, - query: { userId }, - } - fakeHubspotApi.setupServer({ - postEndpoints: [createEventTypePropertyEndpoint], - }) - - beforeEach(() => { - if (process.env.NOCK_OFF) { - return createEventType().then(data => (eventTypeId = data.id)) - } - }) - - it('should create an event type property', async () => { - return hubspot.timelines - .createEventTypeProperty(applicationId, eventTypeId, userId, { - name: 'NumericProperty', - label: 'Numeric Property', - propertyType: 'Numeric', - }) - .then(data => { - expect(data.name).to.eq('NumericProperty') - }) - }) - }) - - describe('updateEventTypeProperty', () => { - let eventTypeId = 123 - let eventTypePropertyId = 234 - const updateEventTypePropertyEndpoint = { - path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, - response: { - name: 'NumericProperty', - label: 'A new label', - propertyType: 'Numeric', - id: eventTypePropertyId, - }, - } - fakeHubspotApi.setupServer({ - putEndpoints: [updateEventTypePropertyEndpoint], - }) - - beforeEach(() => { - if (process.env.NOCK_OFF) { - return createEventType().then(data => { - eventTypeId = data.id - return createEventTypeProperty(eventTypeId).then( - data => (eventTypePropertyId = data.id) - ) - }) - } - }) - - it('should update an event type property', async () => { - return hubspot.timelines - .updateEventTypeProperty( - applicationId, - eventTypeId, - eventTypePropertyId, - { - name: 'NumericProperty', - label: 'A new label', - propertyType: 'Numeric', - } - ) - .then(data => { - expect(data.label).to.eq('A new label') - }) - }) - }) - - describe('createTimelineEvent', () => { - let eventTypeId = 123 - const createTimelineEventEndpoint = { - path: `/integrations/v1/${applicationId}/timeline/event`, - request: body => { - return ( - !!body.id && - body.email === 'test@test.com' && - body.eventTypeId === eventTypeId - ) - }, - statusCode: 204, - } - fakeHubspotApi.setupServer({ - putEndpoints: [createTimelineEventEndpoint], - }) - - beforeEach(() => { - if (process.env.NOCK_OFF) { - return createEventType().then(data => (eventTypeId = data.id)) - } - }) - - it('should create an event', async () => { - return hubspot.timelines - .createTimelineEvent(applicationId, eventTypeId, { - email: 'test@test.com', - }) - .then(data => { - expect(data).to.be.an('undefined') - }) - }) - }) -}) +const { expect } = require('chai') +const fakeHubspotApi = require('./helpers/fake_hubspot_api') +const Hubspot = require('..') + +const userId = process.env.USER_ID || 23456 +const applicationId = process.env.APPLICATION_ID || 12345 + +describe('timeline', function() { + const headerTemplate = + '# Title for event {{id}}\nThis is an event for {{objectType}}' + const detailTemplate = + 'This event happened on {{#formatDate timestamp}}{{/formatDate}}' + const hubspot = new Hubspot({ + accessToken: process.env.ACCESS_TOKEN || 'some-fake-token', + }) + const createEventType = () => + hubspot.timelines.createEventType(applicationId, userId, { + name: 'Test Event Type', + headerTemplate, + detailTemplate, + }) + const createEventTypeProperty = eventTypeId => + hubspot.timelines.createEventTypeProperty( + applicationId, + eventTypeId, + userId, + { + name: 'NumericProperty', + label: 'Numeric Property', + propertyType: 'Numeric', + } + ) + + describe('createEventType', () => { + const createEventTypeEndpoint = { + path: `/integrations/v1/${applicationId}/timeline/event-types`, + response: { + name: 'Test Event Type', + headerTemplate, + detailTemplate, + applicationId, + }, + query: { userId }, + } + fakeHubspotApi.setupServer({ postEndpoints: [createEventTypeEndpoint] }) + + it('should create an event type', async () => { + return hubspot.timelines + .createEventType(applicationId, userId, { + name: 'Test Event Type', + headerTemplate, + detailTemplate, + }) + .then(data => { + expect(data.headerTemplate).to.eq(headerTemplate) + expect(data.detailTemplate).to.eq(detailTemplate) + }) + }) + }) + + describe('updateEventType', () => { + let eventTypeId = 123 + const updateEventTypeEndpoint = { + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}`, + response: { + name: 'Edited Event Type', + headerTemplate, + detailTemplate, + applicationId, + }, + } + fakeHubspotApi.setupServer({ putEndpoints: [updateEventTypeEndpoint] }) + + beforeEach(() => { + if (process.env.NOCK_OFF) { + return createEventType().then(data => (eventTypeId = data.id)) + } + }) + + it('should update an event type', async () => { + return hubspot.timelines + .updateEventType(applicationId, eventTypeId, { + name: 'Edited Event Type', + headerTemplate, + detailTemplate, + }) + .then(data => { + expect(data.name).to.eq('Edited Event Type') + }) + }) + }) + + describe('createEventTypeProperty', () => { + let eventTypeId = 123 + const createEventTypePropertyEndpoint = { + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, + response: { + name: 'NumericProperty', + label: 'Numeric Property', + propertyType: 'Numeric', + }, + query: { userId }, + } + fakeHubspotApi.setupServer({ + postEndpoints: [createEventTypePropertyEndpoint], + }) + + beforeEach(() => { + if (process.env.NOCK_OFF) { + return createEventType().then(data => (eventTypeId = data.id)) + } + }) + + it('should create an event type property', async () => { + return hubspot.timelines + .createEventTypeProperty(applicationId, eventTypeId, userId, { + name: 'NumericProperty', + label: 'Numeric Property', + propertyType: 'Numeric', + }) + .then(data => { + expect(data.name).to.eq('NumericProperty') + }) + }) + }) + + describe('updateEventTypeProperty', () => { + let eventTypeId = 123 + let eventTypePropertyId = 234 + const updateEventTypePropertyEndpoint = { + path: `/integrations/v1/${applicationId}/timeline/event-types/${eventTypeId}/properties`, + response: { + name: 'NumericProperty', + label: 'A new label', + propertyType: 'Numeric', + id: eventTypePropertyId, + }, + } + fakeHubspotApi.setupServer({ + putEndpoints: [updateEventTypePropertyEndpoint], + }) + + beforeEach(() => { + if (process.env.NOCK_OFF) { + return createEventType().then(data => { + eventTypeId = data.id + return createEventTypeProperty(eventTypeId).then( + data => (eventTypePropertyId = data.id) + ) + }) + } + }) + + it('should update an event type property', async () => { + return hubspot.timelines + .updateEventTypeProperty( + applicationId, + eventTypeId, + eventTypePropertyId, + { + name: 'NumericProperty', + label: 'A new label', + propertyType: 'Numeric', + } + ) + .then(data => { + expect(data.label).to.eq('A new label') + }) + }) + }) + + describe('createTimelineEvent', () => { + let eventTypeId = 123 + const createTimelineEventEndpoint = { + path: `/integrations/v1/${applicationId}/timeline/event`, + request: body => { + return ( + !!body.id && + body.email === 'test@test.com' && + body.eventTypeId === eventTypeId + ) + }, + statusCode: 204, + } + fakeHubspotApi.setupServer({ + putEndpoints: [createTimelineEventEndpoint], + }) + + beforeEach(() => { + if (process.env.NOCK_OFF) { + return createEventType().then(data => (eventTypeId = data.id)) + } + }) + + it('should create an event', async () => { + return hubspot.timelines + .createTimelineEvent(applicationId, eventTypeId, { + email: 'test@test.com', + }) + .then(data => { + expect(data).to.be.an('undefined') + }) + }) + }) +}) diff --git a/test/typescript/hubspot.ts b/test/typescript/hubspot.ts index 31f41ec..93b360d 100644 --- a/test/typescript/hubspot.ts +++ b/test/typescript/hubspot.ts @@ -1,23 +1,23 @@ -import Hubspot, { ApiOptions, HubspotError } from '../..' -import { RequestError } from 'request-promise/errors' - -const apiKeyOptions: ApiOptions = { apiKey: 'demo' } - -const handleResponse = response => { - console.log(response) -} - -const handleError = (requestError: RequestError) => { - const error = requestError.error as HubspotError - console.log(error.status) - console.log(error.message) - console.log(error.correlationId) - console.log(error.requestId) -} - -const hubspot = new Hubspot(apiKeyOptions) - -hubspot.companies - .get({ limit: 1 }) - .then(handleResponse) - .catch(handleError) +import Hubspot, { ApiOptions, HubspotError } from '../..' +import { RequestError } from 'request-promise/errors' + +const apiKeyOptions: ApiOptions = { apiKey: 'demo' } + +const handleResponse = response => { + console.log(response) +} + +const handleError = (requestError: RequestError) => { + const error = requestError.error as HubspotError + console.log(error.status) + console.log(error.message) + console.log(error.correlationId) + console.log(error.requestId) +} + +const hubspot = new Hubspot(apiKeyOptions) + +hubspot.companies + .get({ limit: 1 }) + .then(handleResponse) + .catch(handleError) diff --git a/test/workflows.js b/test/workflows.js index 1713061..698b510 100644 --- a/test/workflows.js +++ b/test/workflows.js @@ -1,63 +1,63 @@ -const chai = require('chai') -const expect = chai.expect - -const Hubspot = require('..') -const hubspot = new Hubspot({ apiKey: 'demo' }) - -describe('workflows', function() { - let workflowId = 2641273 - let contactId - let contactEmail - - before(function() { - return hubspot.contacts.get().then(data => { - const firstContact = data.contacts[0] - contactId = firstContact.vid - contactEmail = firstContact['identity-profiles'][0].identities.find( - obj => obj.type === 'EMAIL' - ).value - }) - }) - - describe('get', function() { - it('Should get all workflows', function() { - return hubspot.workflows.getAll().then(data => { - expect(data.workflows).to.be.a('array') - }) - }) - - it('Should get a specific workflow', function() { - return hubspot.workflows.get(workflowId).then(data => { - expect(data).to.be.a('object') - }) - }) - }) - - describe.skip('create', function() {}) - - describe.skip('delete', function() {}) - - describe('enroll', function() { - it('Enrolls a contact into a workflow', function() { - return hubspot.workflows.enroll(workflowId, contactEmail).then(data => { - expect(true).to.equal(true) - }) - }) - - it('Unenrolls a contact into a workflow', function() { - return hubspot.workflows.unenroll(workflowId, contactEmail).then(data => { - expect(true).to.equal(true) - }) - }) - }) - - describe('current', function() { - it('Gets the workflows of a contact', function() { - return hubspot.workflows.current(contactId).then(data => { - expect(data).to.be.an('array') - }) - }) - }) - - describe.skip('events') -}) +const chai = require('chai') +const expect = chai.expect + +const Hubspot = require('..') +const hubspot = new Hubspot({ apiKey: 'demo' }) + +describe('workflows', function() { + let workflowId = 2641273 + let contactId + let contactEmail + + before(function() { + return hubspot.contacts.get().then(data => { + const firstContact = data.contacts[0] + contactId = firstContact.vid + contactEmail = firstContact['identity-profiles'][0].identities.find( + obj => obj.type === 'EMAIL' + ).value + }) + }) + + describe('get', function() { + it('Should get all workflows', function() { + return hubspot.workflows.getAll().then(data => { + expect(data.workflows).to.be.a('array') + }) + }) + + it('Should get a specific workflow', function() { + return hubspot.workflows.get(workflowId).then(data => { + expect(data).to.be.a('object') + }) + }) + }) + + describe.skip('create', function() {}) + + describe.skip('delete', function() {}) + + describe('enroll', function() { + it('Enrolls a contact into a workflow', function() { + return hubspot.workflows.enroll(workflowId, contactEmail).then(data => { + expect(true).to.equal(true) + }) + }) + + it('Unenrolls a contact into a workflow', function() { + return hubspot.workflows.unenroll(workflowId, contactEmail).then(data => { + expect(true).to.equal(true) + }) + }) + }) + + describe('current', function() { + it('Gets the workflows of a contact', function() { + return hubspot.workflows.current(contactId).then(data => { + expect(data).to.be.an('array') + }) + }) + }) + + describe.skip('events') +})