@ebenos/framework
Advanced tools
Comparing version 4.0.0-alpha.11 to 4.0.0-alpha.12
@@ -8,3 +8,10 @@ import User from '../models/User'; | ||
}; | ||
export declare function addTextRule<U extends User<any>>(module: Module<U>, action: (user: U, payload: any) => Promise<any>, rule: RegExp): void; | ||
export declare function addTextRule<U extends User<any>>(module: Module<U>, action: (user: U, payload: any) => Promise<any>, rule: RegExp | RegExp[]): void; | ||
export declare function createPayload<U extends User<any>>(module: Module<U>, action: (user: U, payload: any) => Promise<any>, type: 'string'): string; | ||
export declare function createPayload<U extends User<any>>(module: Module<U>, action: (user: U, payload: any) => Promise<any>, type: 'object'): { | ||
type: string; | ||
}; | ||
export declare function createPayload<T extends Record<string, any>, U extends User<any>>(module: Module<U>, action: (user: U, payload: any) => Promise<any>, type: 'object', payloadData: T): { | ||
type: string; | ||
} & T; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addTextRule = exports.addPostbackRule = exports.addAction = exports.createModule = void 0; | ||
exports.createPayload = exports.addTextRule = exports.addPostbackRule = exports.addAction = exports.createModule = void 0; | ||
function createModule(name = 'global') { | ||
@@ -65,5 +65,24 @@ const module = { | ||
} | ||
module.text.push({ regex: rule, action: actionName }); | ||
if (Array.isArray(rule)) { | ||
module.text.concat(rule.map((r) => ({ regex: r, action: actionName }))); | ||
} | ||
else { | ||
module.text.push({ regex: rule, action: actionName }); | ||
} | ||
} | ||
exports.addTextRule = addTextRule; | ||
function createPayload(module, action, type = 'string', payloadData) { | ||
const actionName = module.name + '/' + action.name; | ||
if (module.actions === undefined || !(actionName in module.actions)) { | ||
throw new Error(`Action with name: '${actionName}', doesn't exist!`); | ||
} | ||
if (type === 'string') { | ||
return actionName; | ||
} | ||
if (payloadData !== undefined) { | ||
return Object.assign({ type: actionName }, payloadData); | ||
} | ||
return { type: actionName }; | ||
} | ||
exports.createPayload = createPayload; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ebenos/framework", | ||
"version": "4.0.0-alpha.11", | ||
"version": "4.0.0-alpha.12", | ||
"description": "A module-based NodeJS chatbot framework.", | ||
@@ -32,7 +32,7 @@ "main": "./build/index.js", | ||
"dependencies": { | ||
"@types/lodash": "^4.14.165", | ||
"@types/mongodb": "^3.6.3", | ||
"lodash": "^4.17.20", | ||
"mongodb": "^3.6.3", | ||
"mongoose": "^5.11.8" | ||
"@types/lodash": "^4.14.168", | ||
"@types/mongodb": "^3.6.8", | ||
"lodash": "^4.17.21", | ||
"mongodb": "^3.6.4", | ||
"mongoose": "^5.11.18" | ||
}, | ||
@@ -47,3 +47,3 @@ "engines": { | ||
], | ||
"gitHead": "d476dd1b80f9d8ad91d87625d673beca57258805" | ||
"gitHead": "d97359cfeb8ba21c7d1d50b9aa260953c737d2a3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
104670
1649
Updated@types/lodash@^4.14.168
Updated@types/mongodb@^3.6.8
Updatedlodash@^4.17.21
Updatedmongodb@^3.6.4
Updatedmongoose@^5.11.18