Компоненты отладчика - Node.js - PullRequest
0 голосов
/ 27 марта 2019

Я пишу компонент для чат-бота Oracle, но я не могу и не знаю, отлаживаю ли мой код в моем узле Project.js.

Мой компонент успешно импортируется для DigitalПомощник Oracle, но у меня много работы для тестирования.

Мой компонент:

"use strict"
module.exports = {

    metadata: () => ({
        "name": "DocumentNumber",
        "properties": {
            "numberDocument": { "type": "string", "required": true }
        },
        "supportedActions": [
            "allow",
            "block"
        ]
    }),

    invoke: (conversation, done) => {
        // Parse a number out of the incoming message
        const text = conversation.text();

        var document = "";
        if (text) {
            const textSize = text.length;
            if (textSize < 10) {
                conversation.invalidUserInput("xxxxxx");

                done();
                return;
            } else {
                document = text;
            }
        } else {
            var errText = "xxxx";
            conversation.logger().error(errText);
            done(new Error(errText));
            return;
        }

        conversation.logger().info('DocumentNumber: using numberDocumento=' + document);


        var express = require('express');


        var linkReturn = "";
        axios.put('http://xxxxx', {
            numeroDocumento: document,
            filial: 0001
          })
          .then(function (response) {
            linkReturn = response;
            console.log(response);

          })
          .catch(function (error) {
            linkReturn = "";
            console.log(error);
          });

        // Set action based on age check
        //conversation.invalidUserInput(linkReturn);

        if (linkReturn !== ""){
            conversation.invalidUserInput(linkReturn);
            conversation.transition('allow');
        } else {
            conversation.invalidUserInput(response.data);
            conversation.transition('block');
        }

        done();
    }
};

Мой package.json:

{
  "name": "cooper-component-service",
  "version": "1.0.0",
  "description": "Bots Custom Components Samples Service in form of npm package",
  "main": "main.js",
  "author": "josivan",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.18.0",
    "moment": "^2.16.0"
  },
  "devDependencies": {
    "@oracle/bots-node-sdk": "2.0.6"
  }
}

Я хотел бы знатьКак можно отладить мой компонент, установив значение для свойства numberDocument.

Я использую визуальный код, пытаюсь нажать F5, но безуспешно.

...