How to use the @serverless/utils.append 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 / type / validateInputs.js View on Github external
'datetime-only',
        'file'
      ]),
    inputTypes
  )

  const coreInputs = mapObjIndexed((value) => resolve(value), pick(keys(coreInputTypes), inputs))

  const schema = validate({ ...coreInputTypes }, 'RAML10')
  const validation = schema({ ...coreInputs })

  if (!validation.valid) {
    let errorMessages = []
    const typeName = chalk.white(`"${Type.props.name}"`)
    const header = chalk.redBright.bold(`\ninputType error(s) in Type ${typeName}:\n`)
    errorMessages = append(header, errorMessages)

    forEach((error) => {
      const value = chalk.cyanBright(`"${error.value}"`)
      const key = `${chalk.yellowBright(error.key)}`
      const suppliedInputType = typeof error.value
      const msg = `  - inputType ${key} has invalid \`${suppliedInputType}\` value of ${value} according to the rule: ${chalk.yellowBright(
        error.rule
      )} ${chalk.yellowBright(error.attr)}.\n`
      errorMessages = append(msg, errorMessages)
    }, prop('errors', validation))

    const message = errorMessages.join('')
    throw Error(message)
  }
  // set defaults if any...
  forEachObjIndexed((coreInputType, key) => {
github serverless / components / src / utils / component / appendKey.js View on Github external
const appendKey = (key, keyPart) => join('.', append(keyPart, split('.', key)))
github serverless / components / src / utils / component / getComponentReferenceIds.js View on Github external
(accum, componentReference) => {
      const { instanceId } = componentReference
      if (isNil(instanceId)) {
        throw new Error(
          `Found a Component reference without an instanceId while getting reference ids. This should not happen. The reference was ${componentReference} and belongs to component ${component}`
        )
      }
      return append(instanceId, accum)
    },
    [],
github serverless / components / registry / Service / src / index.js View on Github external
        async (accum, func) => append(await func.info(), accum),
        [],
github serverless / components / src / utils / dag / execGraph.js View on Github external
(accum, nodeId) => {
        const node = graph.node(nodeId)
        if (!node) {
          throw new Error(`could not find node for nodeId:${nodeId}`)
        }
        graph.removeNode(nodeId)
        return append(execNode(iteratee, node, context), accum)
      },
      [],
github serverless / components / registry / App / src / index.js View on Github external
      async (accum, component) => append(await component.info(), accum),
      [],
github serverless / components / src / utils / component / getChildrenIds.js View on Github external
(accum, childKey) => {
        const instanceId = resolve(get('instanceId', children[childKey]))
        if (isNil(instanceId)) {
          throw new Error(
            `Found a child without an instanceId while getting children ids. This should not happen. The child was ${
              children[childKey]
            } and belongs to parent ${component}`
          )
        }
        return append(instanceId, accum)
      },
      [],
github serverless / components / src / utils / type / validateInputs.js View on Github external
forEach((error) => {
      const value = chalk.cyanBright(`"${error.value}"`)
      const key = `${chalk.yellowBright(error.key)}`
      const suppliedInputType = typeof error.value
      const msg = `  - inputType ${key} has invalid \`${suppliedInputType}\` value of ${value} according to the rule: ${chalk.yellowBright(
        error.rule
      )} ${chalk.yellowBright(error.attr)}.\n`
      errorMessages = append(msg, errorMessages)
    }, prop('errors', validation))
github serverless / components / registry / Component / src / index.js View on Github external
        async (accum, component) => append(await component.info(), accum),
        [],