Permalink
Browse files

Completely removed pre-es6 async/await constructs.

  • Loading branch information...
Orbifold committed Jan 15, 2019
1 parent 67e0821 commit 53f929d89212d6feaa68142dbb7d31f3336826af
Showing with 3,568 additions and 4,182 deletions.
  1. +1 −10 PackageServer/Packages/base/1.0/States/Weather/index.js
  2. +2 −1 lib/Framework/FrameworkBase.js
  3. +66 −74 lib/Interpreters/Commands/Add.js
  4. +32 −39 lib/Interpreters/Commands/Delete.js
  5. +445 −500 lib/Interpreters/Commands/Executors.js
  6. +48 −55 lib/Interpreters/Commands/Get.js
  7. +1 −4 lib/Interpreters/Commands/Help.js
  8. +32 −39 lib/Interpreters/Commands/Language.js
  9. +1 −4 lib/Interpreters/Commands/Load.js
  10. +20 −28 lib/Interpreters/Commands/Set.js
  11. +44 −50 lib/Interpreters/Commands/index.js
  12. +177 −198 lib/Interpreters/Edictor/index.js
  13. +50 −58 lib/Interpreters/Flows/index.js
  14. +14 −20 lib/Interpreters/Historization/index.js
  15. +23 −29 lib/Interpreters/Parsers/index.js
  16. +1 −5 lib/Services/Apps/AppStorage.js
  17. +92 −110 lib/Services/Apps/index.js
  18. +728 −810 lib/Services/Graph/GraphStorage.js
  19. +34 −36 lib/Services/History/HistoryStorage.js
  20. +72 −98 lib/Services/History/index.js
  21. +2 −5 lib/Services/Identity/IdentityStorage.js
  22. +11 −14 lib/Services/Log/LogStorage.js
  23. +9 −11 lib/Services/Log/index.js
  24. +2 −5 lib/Services/Oracle/OracleStorage.js
  25. +168 −185 lib/Services/Oracle/index.js
  26. +23 −24 lib/Services/Personalization/index.js
  27. +3 −6 lib/Services/Statistics/StatisticsStorage.js
  28. +57 −77 lib/Services/Topics/TopicsStorage.js
  29. +1 −5 lib/Services/Topics/index.js
  30. +19 −24 lib/Services/Workflows/States/CheckAnswer/index.js
  31. +3 −4 lib/Services/Workflows/States/Choice/index.js
  32. +19 −25 lib/Services/Workflows/States/Decision/index.js
  33. +21 −26 lib/Services/Workflows/States/QA/index.js
  34. +17 −26 lib/Services/Workflows/States/Transient/index.js
  35. +42 −55 lib/Services/Workflows/Workflow.js
  36. +1 −3 lib/Services/Workflows/WorkflowLoader.js
  37. +1 −7 lib/Services/Workflows/WorkflowSpy.js
  38. +71 −97 lib/Services/Workflows/WorkflowState.js
  39. +1 −5 lib/Services/Workflows/WorkflowStorage.js
  40. +1 −6 lib/Services/Workflows/WorkflowValidation.js
  41. +93 −107 lib/Services/Workflows/index.js
  42. +218 −236 lib/index.js
  43. +2 −7 lib/repl.js
  44. +0 −1 package.json
  45. +334 −413 test/Apps.js
  46. +4 −2 test/Graph.js
  47. +1 −1 test/Instantiator.js
  48. +347 −421 test/Oracle.js
  49. +1 −1 test/QTL.js
  50. +0 −3 test/Questions.js
  51. +200 −193 test/Qwiery.js
  52. +1 −9 test/TestUtils/index.js
  53. +12 −10 test/Workflows.js
@@ -1,18 +1,9 @@
const
// WorkflowState = require("/Users/Swa/Desktop/Qwiery/lib/Services/Workflows/WorkflowState");
// utils = require("/Users/Swa/Desktop/Qwiery/lib/utils");

Qwiery = require("qwiery"),
WorkflowState = Qwiery.WorkflowState,
utils = Qwiery.utils,
path = require("path"),
_ = require("lodash");

// _ = require('lodash'),
// utils = require("../../../../utils"),
// constants = require("../../../../constants"),
// async = require('asyncawait/async'),
// waitFor = require('asyncawait/await');
class WeatherState extends WorkflowState {
constructor(options) {
super(options);
@@ -94,4 +85,4 @@ class WeatherState extends WorkflowState {
return json;
}
}
module.exports = WeatherState;
module.exports = WeatherState;
@@ -1,5 +1,6 @@
const utils = require("../utils");
const _ = require("lodash");

/**
* Base class for all Qwiery plugins.
* @class FrameworkBase
@@ -93,4 +94,4 @@ class FrameworkBase {
}
}

module.exports = FrameworkBase;
module.exports = FrameworkBase;
@@ -1,97 +1,89 @@
const utils = require('../../utils'),
constants = require("../../constants"),
async = require('asyncawait/async'),
waitFor = require('asyncawait/await'),
_ = require("lodash"),
CommandBase = require("../../Framework/CommandBase"),
Executors = require("./Executors");
constants = require('../../constants'),
_ = require('lodash'),
CommandBase = require('../../Framework/CommandBase'),
Executors = require('./Executors');

/**
* Handles the `add>` commands.
* @class Add
*/
class Add extends CommandBase {
constructor() {
super("add");
super('add');
}

canHandle(input) {
return utils.isDefined(input.match(/^\s?add\s?>\s?/gi));
}

handle(session) {
const that = this;

function runner() {

const question = session.Input.Raw;
const cmd = utils.getCommand(question);
const ctx = session.Context;
let pods = [];
if(cmd.Commands.length > 1) {
switch(cmd.Commands[1]) {
case "space":
pods = Executors.addSpace(cmd, session, that);
break;
case "tag":
pods = waitFor(Executors.addTag(cmd, session, that));
break;
case "task":
pods = waitFor(Executors.addTask(cmd, session, that));
break;
case "person":
pods = waitFor(Executors.addPerson(cmd, session, that));
break;
case "address":
pods = waitFor(Executors.addAddress(cmd, session, that));
break;
case "personalization":
case "preference":
pods = waitFor(Executors.addPersonalization(cmd, session, that));
break;
case "agenda":
case "appointment":
if(!cmd.HasNamedArguments) {
const Entities = require("../../Understanding/Entities"),
Event = Entities.Appointment;
if(utils.isUndefined(cmd.FirstParameter)) {
return Executors.messagePods("You did not supply anything to create an appointment.");
}
const a = Event.tryMakingSense(cmd.FirstParameter.value);
if(utils.isUndefined(a)) {
pods = utils.messagePods("Sorry, I could not make sense of the date and/or time you specified there. Can you try again please?");
} else {
pods = waitFor(Executors.addAppointment(a, session, that));
}
async handle(session) {
const question = session.Input.Raw;
const cmd = utils.getCommand(question);
const ctx = session.Context;
let pods = [];
if (cmd.Commands.length > 1) {
switch (cmd.Commands[1]) {
case 'space':
pods = Executors.addSpace(cmd, session, this);
break;
case 'tag':
pods = await (Executors.addTag(cmd, session, this));
break;
case 'task':
pods = await (Executors.addTask(cmd, session, this));
break;
case 'person':
pods = await (Executors.addPerson(cmd, session, this));
break;
case 'address':
pods = await (Executors.addAddress(cmd, session, this));
break;
case 'personalization':
case 'preference':
pods = await (Executors.addPersonalization(cmd, session, this));
break;
case 'agenda':
case 'appointment':
if (!cmd.HasNamedArguments) {
const Entities = require('../../Understanding/Entities'),
Event = Entities.Appointment;
if (utils.isUndefined(cmd.FirstParameter)) {
return Executors.messagePods('You did not supply anything to create an appointment.');
}
else {
pods = waitFor(Executors.addAppointment(cmd, session, that));
}
break;
default:
if(cmd.Commands.length > 2) {
pods = Executors.messagePods("If you want to add an entity, try with e.g. '`add>thought>` my new thought'.");
const a = Event.tryMakingSense(cmd.FirstParameter.value);
if (utils.isUndefined(a)) {
pods = utils.messagePods('Sorry, I could not make sense of the date and/or time you specified there. Can you try again please?');
} else {
let node = waitFor(Executors.addEntity(cmd, session, that));
pods = Executors.singleEntityPod(node, "The new node has been added.");
pods = await (Executors.addAppointment(a, session, this));
}
break;
}
} else {
pods = await (Executors.addAppointment(cmd, session, this));
}
break;
default:
if (cmd.Commands.length > 2) {
pods = Executors.messagePods('If you want to add an entity, try with e.g. \'`add>thought>` my new thought\'.');
} else {
let node = await (Executors.addEntity(cmd, session, this));
pods = Executors.singleEntityPod(node, 'The new node has been added.');
}
break;
}

} else {
if (utils.isUndefined(cmd.FirstParameter)) {
pods = Executors.messagePods(Executors.NotOK + ' If you want to add an entity, try with e.g. \'add>thought>...\'.');
} else {
if(utils.isUndefined(cmd.FirstParameter)) {
pods = Executors.messagePods(Executors.NotOK + " If you want to add an entity, try with e.g. 'add>thought>...'.");
} else {
// if no addditional command the default is adding a thought
let node = waitFor(that.addEntity(session, cmd.Commands[1], cmd.FirstParameter));
pods = Executors.singleEntityPod(node, "The new node has been added.");
}

// if no addditional command the default is adding a thought
let node = await (this.addEntity(session, cmd.Commands[1], cmd.FirstParameter));
pods = Executors.singleEntityPod(node, 'The new node has been added.');
}
return pods;
}

return async(runner)();
}
return pods;
}

}
module.exports = Add;

module.exports = Add;
@@ -1,7 +1,4 @@
const utils = require('../../utils'),
constants = require("../../constants"),
async = require('asyncawait/async'),
waitFor = require('asyncawait/await'),
_ = require("lodash"),
CommandBase = require("../../Framework/CommandBase"),
Executors = require("./Executors");
@@ -21,46 +18,42 @@ class Delete extends CommandBase {
handle(session) {
const that = this;

function runner() {
const question = session.Input.Raw;
const cmd = utils.getCommand(question);
const ctx = session.Context;
const question = session.Input.Raw;
const cmd = utils.getCommand(question);
const ctx = session.Context;


if(cmd.Commands.length > 1) {
if(cmd.Commands.length > 1) {

// DELETE:SPACE:
// if(cmd.Commands[1] === "space") {
// if(cmd.Commands.length > 2) {
// pods = [{
// "Content": "I don't understand this command. If you want to add a workspace, try with e.g. 'add:space: my new space'.",
// "DataType": constants.podType.Text
// }];
// } else {
// var workspaceId = graph.addWorkspace({Name: cmd.FirstParameter}, ctx);
// pods = [{
// "Content": "The new space was added and is now the active one. You can change the active workspace by using the command 'set:space: <the name of the space you have given>'.",
// "DataType": constants.podType.Text
// }];
// }
// }
switch(cmd.Commands[1]) {
case "tag":
return Executors.deleteTag(cmd, session, that);
case "entity":
return Executors.deleteEntity(cmd, session, that);
case "space":
return Executors.deleteSpace(cmd, session, that);
default:
return Executors.messagePods(`Deleting a '${cmd.Commands[1]}' is not implemented yet. You can delete tags however.`);
}
} else {
return Executors.deleteEntity(cmd, session, that);
//return Executors.messagePods(Executors.NotOK + "If you want to delete a tag, try with e.g. 'delete:tag: my new tag'.");
// DELETE:SPACE:
// if(cmd.Commands[1] === "space") {
// if(cmd.Commands.length > 2) {
// pods = [{
// "Content": "I don't understand this command. If you want to add a workspace, try with e.g. 'add:space: my new space'.",
// "DataType": constants.podType.Text
// }];
// } else {
// var workspaceId = graph.addWorkspace({Name: cmd.FirstParameter}, ctx);
// pods = [{
// "Content": "The new space was added and is now the active one. You can change the active workspace by using the command 'set:space: <the name of the space you have given>'.",
// "DataType": constants.podType.Text
// }];
// }
// }
switch(cmd.Commands[1]) {
case "tag":
return Executors.deleteTag(cmd, session, that);
case "entity":
return Executors.deleteEntity(cmd, session, that);
case "space":
return Executors.deleteSpace(cmd, session, that);
default:
return Executors.messagePods(`Deleting a '${cmd.Commands[1]}' is not implemented yet. You can delete tags however.`);
}
} else {
return Executors.deleteEntity(cmd, session, that);
//return Executors.messagePods(Executors.NotOK + "If you want to delete a tag, try with e.g. 'delete:tag: my new tag'.");
}

return async(runner)();
}
}
module.exports = Delete;
module.exports = Delete;
Oops, something went wrong.

0 comments on commit 53f929d

Please sign in to comment.