How to use the @serverless/utils.get function in @serverless/utils

To help you get started, we’ve selected a few @serverless/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serverless / components / src / utils / dag / deployGraph.js View on Github external
// 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)
  }
}
github serverless / components / src / utils / type / validateInputs.js View on Github external
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',
github serverless / components / registry / AwsDynamoDb / src / index.js View on Github external
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)`
          )
        }
github serverless / components / registry / AwsSnsTopic / src / index.js View on Github external
hydrate(prevInstance = {}) {
      super.hydrate(prevInstance)
      this.topicArn = get('topicArn', prevInstance)
    }
github serverless / components / src / utils / component / defineComponent.js View on Github external
      async (child, key) => defineComponent(child, get(['children', key], state), context),
      children
github serverless / components / src / utils / dag / removeGraph.js View on Github external
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)
      }
github serverless / components / registry / AwsLambdaLayerVersion / src / index.js View on Github external
hydrate(prevInstance) {
      super.hydrate(prevInstance)
      this.arn = get('arn', prevInstance)
      this.layerVersion = get('layerVersion', prevInstance)
      this.versions = get('versions', prevInstance)
    }
github serverless / components / registry / AwsLambdaLayerVersion / src / index.js View on Github external
hydrate(prevInstance) {
      super.hydrate(prevInstance)
      this.arn = get('arn', prevInstance)
      this.layerVersion = get('layerVersion', prevInstance)
      this.versions = get('versions', prevInstance)
    }
github serverless / components / src / utils / component / getParentIds.js View on Github external
const getParentIds = (component) => {
  const parent = get('parent', component)
  if (parent) {
    return concat([get('instanceId', parent)], getParentIds(parent))
  }
  return []
}