How to use the @serverless/utils.pick 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 / registry / AwsApiGateway / src / index.js View on Github external
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'
      }
    }
github serverless / components / registry / Component / src / utils / pickComponentProps.js View on Github external
const pickComponentProps = (component) => {
  const props = walkReduceTypeChain(
    (accum, Type) => union(accum, keys(or(Type.props, {}))),
    ['inputs'],
    component.getType()
  )

  return omit(['components', 'inputTypes'], pick(props, component))
}
github serverless / components / registry / TwilioApplication / src / index.js View on Github external
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)
github serverless / components / registry / AwsDynamoDb / src / index.js View on Github external
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'
      }
    }
github serverless / components / registry / TwilioPhoneNumber / src / index.js View on Github external
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
        })
github serverless / components / registry / Component / src / index.js View on Github external
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
      }
    }
github serverless / components / registry / AwsIamRole / src / index.js View on Github external
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'
      }
    }
github serverless / components / registry / TwilioApplication / src / index.js View on Github external
hydrate(prevInstance) {
      super.hydrate(prevInstance)
      Object.assign(this, pick(applicationProps, prevInstance))
    }
github serverless / components / registry / TwilioPhoneNumber / src / index.js View on Github external
hydrate(prevInstance = {}) {
      super.hydrate(prevInstance)
      Object.assign(this, pick(phoneNumberProps, prevInstance))
    }
github serverless / components / registry / TwilioPhoneNumber / src / index.js View on Github external
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
    }