<commit_before>import serverlessLog from '../../../../serverlessLog.js'
import { createUniqueId } from '../../../../utils/index.js'

export default class InvokeController {
  constructor(lambda) {
    this._lambda = lambda
  }

  async invoke(functionName, invocationType, event, clientContext) {
    const lambdaFunction = this._lambda.getByFunctionName(functionName)
    const requestId = createUniqueId()

    lambdaFunction.setClientContext(clientContext)
    lambdaFunction.setEvent(event)
    lambdaFunction.setRequestId(requestId)

    if (invocationType === 'Event') {
      // don't await result!
      /* result =  await */
      lambdaFunction
        .runHandler()
        .then(() => {
          const {
            billedExecutionTimeInMillis,
            executionTimeInMillis,
          } = lambdaFunction

          serverlessLog(
            `(λ: ${functionName}) RequestId: ${requestId}  Duration: ${executionTimeInMillis.toFixed(
              2,
            )} ms  Billed Duration: ${billedExecutionTimeInMillis} ms`,
          )
        })
        .catch((err) => {
          // TODO handle error
          console.log(err)
          throw err
        })

      return {
        Payload: '',
        StatusCode: 202,
      }
    }

    if (invocationType === 'RequestResponse') {
      let result

      try {
        result = await lambdaFunction.runHandler()

        const {
          billedExecutionTimeInMillis,
          executionTimeInMillis,
        } = lambdaFunction

        serverlessLog(
          `(λ: ${functionName}) RequestId: ${requestId}  Duration: ${executionTimeInMillis.toFixed(
            2,
          )} ms  Billed Duration: ${billedExecutionTimeInMillis} ms`,
        )
      } catch (err) {
        // TODO handle error
        console.log(err)
        throw err
      }

      return result
    }

    return undefined
  }
}<commit_msg>Add temporary support message<commit_after>import serverlessLog from '../../../../serverlessLog.js'
import { createUniqueId } from '../../../../utils/index.js'

export default class InvokeController {
  constructor(lambda) {
    this._lambda = lambda
  }

  async invoke(functionName, invocationType, event, clientContext) {
    const lambdaFunction = this._lambda.getByFunctionName(functionName)
    const requestId = createUniqueId()

    lambdaFunction.setClientContext(clientContext)
    lambdaFunction.setEvent(event)
    lambdaFunction.setRequestId(requestId)

    if (invocationType === 'Event') {
      // don't await result!
      /* result =  await */
      lambdaFunction
        .runHandler()
        .then(() => {
          const {
            billedExecutionTimeInMillis,
            executionTimeInMillis,
          } = lambdaFunction

          serverlessLog(
            `(λ: ${functionName}) RequestId: ${requestId}  Duration: ${executionTimeInMillis.toFixed(
              2,
            )} ms  Billed Duration: ${billedExecutionTimeInMillis} ms`,
          )
        })
        .catch((err) => {
          // TODO handle error
          console.log(err)
          throw err
        })

      return {
        Payload: '',
        StatusCode: 202,
      }
    }

    if (invocationType === 'RequestResponse') {
      let result

      try {
        result = await lambdaFunction.runHandler()

        const {
          billedExecutionTimeInMillis,
          executionTimeInMillis,
        } = lambdaFunction

        serverlessLog(
          `(λ: ${functionName}) RequestId: ${requestId}  Duration: ${executionTimeInMillis.toFixed(
            2,
          )} ms  Billed Duration: ${billedExecutionTimeInMillis} ms`,
        )
      } catch (err) {
        // TODO handle error
        console.log(err)
        throw err
      }

      return result
    }

    // TODO FIXME
    console.log(
      `invocationType: '${invocationType}' not supported by serverless-offline`,
    )

    return undefined
  }
}
{'fraction_non_alphanumeric': 0.1102019943748402, 'fraction_numerical': 0.0025568908207619537, 'mean_word_length': 1.995405819295559, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5996493', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1047, 'n_words': 224}