Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async shouldDeploy(prevInstance) {
const inputs = {
stage: this.stage,
swaggerTemplate: this.swaggerTemplate
}
const prevInputs = prevInstance ? pick(keys(inputs), prevInstance) : {}
const configChanged = not(equals(inputs, prevInputs))
// Eslam:
// interestingly, there's no replace for APIG!
// because the user cannot change the rest api id
// he can only change the name, in which case AWS would do the "replace"
if (!prevInstance || configChanged) {
return 'deploy'
}
}
const pickComponentProps = (component) => {
const props = walkReduceTypeChain(
(accum, Type) => union(accum, keys(or(Type.props, {}))),
['inputs'],
component.getType()
)
return omit(['components', 'inputTypes'], pick(props, component))
}
async deploy(prevInstance = {}, context) {
const inputs = pick(inputsProps, this)
const prevInputs = pick(inputsProps, prevInstance)
const noChanges = equals(inputs, prevInputs)
if (noChanges) {
return
} else if (!prevInstance.sid) {
context.log(`Creating Twilio Application: "${this.friendlyName}"`)
const props = await createTwilioApplication(this.provider.getSdk(), inputs)
Object.assign(this, props)
} else {
context.log(`Updating Twilio Application: "${this.friendlyName}"`)
const props = await updateTwilioApplication(this.provider.getSdk(), {
...inputs,
sid: prevInstance.sid
})
Object.assign(this, props)
shouldDeploy(prevInstance) {
const inputs = {
attributeDefinitions: this.attributeDefinitions,
provisionedThroughput: this.provisionedThroughput,
globalSecondaryIndexes: this.globalSecondaryIndexes,
sseSpecification: this.sseSpecification,
streamSpecification: this.streamSpecification,
timeToLiveSpecification: this.timeToLiveSpecification
}
const prevInputs = prevInstance ? pick(keys(inputs), prevInstance) : {}
const configChanged = not(equals(inputs, prevInputs))
if (!prevInstance || configChanged) {
return 'deploy'
} else if (
prevInstance.tableName !== this.tableName ||
not(equals(prevInstance.keySchema, this.keySchema))
) {
return 'replace'
}
}
async deploy(prevInstance, context) {
const inputs = pick(inputsProps, this)
if (!prevInstance) {
context.log(`Creating Twilio Phone Number: "${inputs.friendlyName || inputs.phoneNumber}"`)
const props = await createPhoneNumber(this.provider.getSdk(), inputs)
Object.assign(this, props)
} else {
const prevInputs = pick(inputsProps, prevInstance)
const noChanges = equals(prevInputs, inputs)
if (noChanges) {
return
}
context.log(`Updating Twilio Phone Number: "${inputs.friendlyName || inputs.phoneNumber}"`)
const props = await updatePhoneNumber(this.provider.getSdk(), {
...inputs,
sid: prevInstance.sid
})
async info() {
const children = await reduce(
async (accum, component) => append(await component.info(), accum),
[],
or(this.components, {})
)
return {
title: this.name,
type: this.name,
data: pick(['name', 'license', 'version'], this),
children
}
}
shouldDeploy(prevInstance) {
const inputs = {
roleName: this.roleName,
service: this.service,
policy: this.policy
}
const prevInputs = prevInstance ? pick(keys(inputs), prevInstance) : {}
const configChanged = not(equals(inputs, prevInputs))
if (prevInstance && prevInstance.roleName !== inputs.roleName) {
return 'replace'
} else if (!prevInstance || configChanged) {
return 'deploy'
}
}
hydrate(prevInstance) {
super.hydrate(prevInstance)
Object.assign(this, pick(applicationProps, prevInstance))
}
hydrate(prevInstance = {}) {
super.hydrate(prevInstance)
Object.assign(this, pick(phoneNumberProps, prevInstance))
}
shouldDeploy(prevInstance) {
if (!prevInstance) {
return 'deploy'
}
const inputs = pick(inputsProps, this)
const prevInputs = prevInstance ? pick(inputsProps, prevInstance) : {}
const configChanged = not(equals(inputs, prevInputs))
if (not(equals(prevInputs.phoneNumber, inputs.phoneNumber))) {
return 'replace'
} else if (configChanged) {
return 'deploy'
}
return undefined
}