Socket
Socket
Sign inDemoInstall

recime-message-responder

Package Overview
Dependencies
251
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.6 to 1.3.7

6

dist/request.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const code_block_1 = require("./code-block");
const recime_keyvalue_store_1 = require("recime-keyvalue-store");
class Request {

@@ -60,6 +59,7 @@ send(__, id, options) {

msgId = message.id;
return recime_keyvalue_store_1.default.set(`${id}-${message.type}`, {
options.vars[message.type] = {
index: index,
response: options.res
}).then(() => options.break());
};
return Promise.resolve(options.break());
}

@@ -66,0 +66,0 @@ default: {

@@ -10,3 +10,2 @@ import { Vars } from './vars';

processResponse(res: any, __: any, v: Vars): any;
clearUserInput(): any;
}

@@ -21,25 +21,24 @@ "use strict";

const vars = new vars_1.Vars(vals || {});
return recime_keyvalue_store_1.default.get(`${this.id}-user-input`).then((data) => {
this.mapEventToUserInput(this.args);
if (data && data.response && this.args.text) {
const message = data.response[data.index];
const content = message.content;
vars.set('system_message_id', message.id);
let validator;
switch (content.dataType) {
case 'string':
validator = new string_validator_1.StringValidator(this);
break;
case 'number':
validator = new number_validator_1.NumberValidator(this);
break;
case 'date':
validator = new date_validator_1.DateValidator(this);
}
return validator.validate(__, vars, this.args, data);
const data = vars['user-input'];
this.mapEventToUserInput(this.args);
if (data && data.response && this.args.text) {
const message = data.response[data.index];
const content = message.content;
vars.set('system_message_id', message.id);
let validator;
switch (content.dataType) {
case 'string':
validator = new string_validator_1.StringValidator(this);
break;
case 'number':
validator = new number_validator_1.NumberValidator(this);
break;
case 'date':
validator = new date_validator_1.DateValidator(this);
}
else {
return this.processRequest(__, vars);
}
});
return validator.validate(__, vars, this.args, data);
}
else {
return this.processRequest(__, vars);
}
});

@@ -78,3 +77,2 @@ }

execute: (intentName) => {
this.clearUserInput();
return new Responder({

@@ -103,4 +101,4 @@ meta: this.args.meta,

const template = handlebars_1.default.compile(JSON.stringify(result));
delete v.vals[this.id];
return recime_keyvalue_store_1.default.set(`${this.args.sender}-${process.env.UID}`, v.vals).then(() => JSON.parse(template(user)));
delete v.vals['system_message_id'];
return recime_keyvalue_store_1.default.set(this.id, v.vals).then(() => JSON.parse(template(user)));
}).catch(error => {

@@ -111,6 +109,3 @@ return __.text(error.message);

}
clearUserInput() {
return recime_keyvalue_store_1.default.set(`${this.id}-user-input`, "-");
}
}
exports.Responder = Responder;

@@ -31,5 +31,4 @@ "use strict";

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);
}

@@ -36,0 +35,0 @@ catch (ex) {

@@ -36,5 +36,4 @@ "use strict";

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);
}

@@ -41,0 +40,0 @@ catch (ex) {

@@ -30,5 +30,4 @@ "use strict";

catch (ex) {
return this.responder.clearUserInput()
.then(() => __.text(ex.message))
.then(resolve);
delete vars['user-input'];
return resolve(__.text(ex.message));
}

@@ -51,5 +50,4 @@ break;

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);
});

@@ -56,0 +54,0 @@ }

{
"name": "recime-message-responder",
"version": "1.3.6",
"version": "1.3.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -71,7 +71,7 @@ import { CodeBlock } from './code-block';

msgId = message.id;
return db.set(`${id}-${message.type}`, {
options.vars[message.type] = {
index: index,
response: options.res
}).then(() => options.break());
};
return Promise.resolve(options.break());
}

@@ -78,0 +78,0 @@ default: {

@@ -27,4 +27,5 @@ import HandleBars from 'handlebars';

return db.get(this.id).then((vals) => {
const vars = new Vars(vals || {});
return db.get(`${this.id}-user-input`).then((data) => {
const vars = new Vars(vals || {});
const data = vars['user-input'];
this.mapEventToUserInput(this.args);

@@ -56,3 +57,2 @@

}
});
});

@@ -99,3 +99,2 @@ }

, execute : (intentName)=>{
this.clearUserInput();
return new Responder({

@@ -126,5 +125,5 @@ meta: this.args.meta

delete v.vals[this.id];
delete v.vals['system_message_id'];
return db.set(`${this.args.sender}-${process.env.UID}`, v.vals).then(() => JSON.parse(template(user)));
return db.set(this.id, v.vals).then(() => JSON.parse(template(user)));
}).catch(error => {

@@ -135,6 +134,2 @@ return __.text(error.message);

}
clearUserInput(){
return db.set(`${this.id}-user-input`, "-");
}
}

@@ -32,5 +32,5 @@ import {Validator} from './validator';

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);
} catch (ex) {

@@ -37,0 +37,0 @@ resolve(__.text(ex.message))

@@ -38,5 +38,5 @@ import {Validator} from './validator';

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);

@@ -43,0 +43,0 @@ } catch (ex) {

@@ -30,5 +30,4 @@ import {Validator} from './validator';

} catch (ex) {
return this.responder.clearUserInput()
.then(() => __.text(ex.message))
.then(resolve)
delete vars['user-input'];
return resolve(__.text(ex.message));
}

@@ -52,8 +51,7 @@ break;

vars.set(content.variable.replace(/[{}]+/ig, ""), input);
return this.responder.clearUserInput()
.then(() => this.responder.processResponse(data.response, __, vars))
.then(resolve);
delete vars['user-input'];
return this.responder.processResponse(data.response, __, vars).then(resolve);
});
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc