Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// NOTE BRN: This only makes sense if we end up persisting variables into state
// if (!isEmpty(prevInstance)) {
// resolveComponentEvaluables(prevInstance)
// }
// NOTE BRN: We wait till the last minute to run should deploy so that
// 1. evaluables are resolved
// 2. all values within evaluables that this node depends on have had a chance to update during their deploy step.
if (!node.operation) {
node.operation = await nextInstance.shouldDeploy(prevInstance, context)
}
context.debug(
`checked if component should be deployed - result operation: ${node.operation} instanceId: ${
node.instanceId
} nextInstance: ${get('nextInstance.name', node)} prevInstance: ${get(
'prevInstance.name',
node
)}`
)
validateNode(node, context)
if (node.operation === 'deploy') {
await deployInstance(nextInstance, prevInstance, context)
} else if (node.operation === 'replace') {
await deployInstance(nextInstance, null, context)
}
}
const validateInputs = (Type, inputs) => {
const inputTypes = get('props.inputTypes', Type)
if (!inputTypes) {
return inputs
}
// we currently only support validating core types, not registry types
const coreInputTypes = pickBy(
(value) =>
contains(value.type, [
'boolean',
'string',
'number',
'integer',
'object',
'nil',
'datetime',
'date-only',
async deploy(prevInstance, context) {
const tableName = get('tableName', this)
if (
prevInstance &&
(not(equals(prevInstance.attributeDefinitions, this.attributeDefinitions)) ||
not(equals(prevInstance.provisionedThroughput, this.provisionedThroughput)) ||
not(equals(prevInstance.globalSecondaryIndexes, this.globalSecondaryIndexes)) ||
not(equals(prevInstance.sseSpecification, this.sseSpecification)) ||
not(equals(prevInstance.streamSpecification, this.streamSpecification)))
) {
context.log(`Updating table: '${tableName}'`)
if (not(equals(prevInstance.globalSecondaryIndexes, this.globalSecondaryIndexes))) {
context.log(
`Skipping GlobalSecondaryIndex updates for table '${tableName}' (currently not supported)`
)
}
hydrate(prevInstance = {}) {
super.hydrate(prevInstance)
this.topicArn = get('topicArn', prevInstance)
}
async (child, key) => defineComponent(child, get(['children', key], state), context),
children
const removeNode = async (node, context) => {
const { instanceId, operation } = node
let { nextInstance, prevInstance } = node
if (!isEmpty(nextInstance)) {
nextInstance = resolveComponentEvaluables(nextInstance)
}
if (!isEmpty(prevInstance)) {
prevInstance = resolveComponentEvaluables(prevInstance)
}
context.debug(
`checking if component should be removed - operation: ${operation} instanceId: ${instanceId} nextInstance: ${get(
'name',
nextInstance
)} prevInstance: ${get('name', prevInstance)}`
)
validateNode(node, context)
if (contains(operation, ['remove', 'replace'])) {
if (operation === 'replace') {
if (prevInstance) {
await removeInstance(prevInstance, context)
}
} else if (operation === 'remove') {
if (prevInstance) {
await removeInstance(prevInstance, context)
} else if (nextInstance) {
await removeInstance(nextInstance, context)
}
hydrate(prevInstance) {
super.hydrate(prevInstance)
this.arn = get('arn', prevInstance)
this.layerVersion = get('layerVersion', prevInstance)
this.versions = get('versions', prevInstance)
}
hydrate(prevInstance) {
super.hydrate(prevInstance)
this.arn = get('arn', prevInstance)
this.layerVersion = get('layerVersion', prevInstance)
this.versions = get('versions', prevInstance)
}
const getParentIds = (component) => {
const parent = get('parent', component)
if (parent) {
return concat([get('instanceId', parent)], getParentIds(parent))
}
return []
}