jovotech/jovo-framework

Return serialized concrete request/response instances in `$history?.prev?.request` and `$history?.prev?.response` to be able to use class methods.

jrglg opened this issue · 1 comments

jrglg commented

I'm submitting a...

  • Bug report
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Expected Behavior

You expect this @If((jovo: Jovo) => jovo.$history.prev?.request?.isNewSession()! to return true if the last request started a new session and DB plugin config is correct.

Current Behavior

When using this

@If((jovo: Jovo) => jovo.$history.prev?.request?.isNewSession()!)

An error is thrown because request is not deserialized (isNewSession is not a function)

I'm not an expert in TS and I don't know if I'm missing something. What should and what shouldn't be serialized in $history?

I feel like this is weird:

  @Intents('TestIntent')
  @If((jovo: Jovo) =>
    jovo.$alexa
      ? new AlexaRequestBuilder().intent(jovo.$alexa.$history?.prev?.request).isNewSession()!
      : new GoogleAssistantRequestBuilder()
          .intent(jovo.$googleAssistant?.$history?.prev?.request)
          .isNewSession()!,
  )
  TestHandler(): Promise<void> {
    // ...
  }

It works for Alexa without the GA part.

If you include the GA parte in the else, it throws an error:
Error: Cannot find module '@jovotech/platform-googleassistant/dist/types/GoogleAssistantRequestBuilder'

Error Log

When using `jovo.$history.prev?.request?.isNewSession()!`
Error: isNewSession is not a function.

When adding the workaround for GA:
Error: Cannot find module '@jovotech/platform-googleassistant/dist/types/GoogleAssistantRequestBuilder'

Your Environment

@jovotech/cli: 4.1.6

Jovo packages of the current project :
  - @jovotech/analytics-dashbot: 4.2.28
  - @jovotech/client-web: 4.2.28
  - @jovotech/db-dynamodb: 4.2.28
  - @jovotech/db-filedb: 4.2.28
  - @jovotech/db-mongodb: 4.2.26
  - @jovotech/framework: 4.2.28
  - @jovotech/model: 4.0.2
  - @jovotech/model-lexv2: 4.0.2
  - @jovotech/nlu-nlpjs: 4.2.28
  - @jovotech/output: 4.2.24
  - @jovotech/platform-alexa: 4.2.28
  - @jovotech/platform-core: 4.2.28
  - @jovotech/platform-facebookmessenger: 4.2.28
  - @jovotech/platform-googleassistant: 4.2.28
  - @jovotech/platform-web: 4.2.28
  - @jovotech/plugin-debugger: 4.2.29
  - @jovotech/server-express: 4.2.28
  - @jovotech/server-lambda: 4.2.28
  - @jovotech/slu-lex: 4.2.28
  - @jovotech/target-serverless: 4.1.6
  - @jovotech/cli-command-build: 4.1.6 [dev]
  - @jovotech/cli-command-deploy: 4.1.6 [dev]
  - @jovotech/cli-command-get: 4.1.6 [dev]
  - @jovotech/cli-command-new: 4.1.6 [dev]
  - @jovotech/cli-command-run: 4.1.7 [dev]
  - @jovotech/cli-core: 4.1.7 [dev]
  - @jovotech/common: 4.2.22 [dev]
  - @jovotech/filebuilder: 0.0.1 [dev]

Environment:
  System:
    OS: Windows 10
  Binaries:
    Node: 14.19.0
    npm: 6.14.16