@digipair/skill-chatbot 0.94.0-8 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js ADDED
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var engine = require('@digipair/engine');
6
+
7
+ function _extends() {
8
+ _extends = Object.assign || function assign(target) {
9
+ for(var i = 1; i < arguments.length; i++){
10
+ var source = arguments[i];
11
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
12
+ }
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
17
+
18
+ let ChatbotService = class ChatbotService {
19
+ async answer(params, _pinsSettingsList, context) {
20
+ const { command = [], boosts = [], sources = [], assistant, logs, boost, parent_conversation, parent_history, session, uuid } = params;
21
+ return {
22
+ assistant,
23
+ command: await Promise.all(command.map((settings)=>engine.preparePinsSettings(settings, context))),
24
+ boosts,
25
+ sources,
26
+ logs,
27
+ boost: boost ? _extends({}, boost, {
28
+ inputs: await Promise.all((boost.inputs || []).map((settings)=>engine.preparePinsSettings(settings, context)))
29
+ }) : boost,
30
+ parent_conversation,
31
+ parent_history,
32
+ session,
33
+ uuid
34
+ };
35
+ }
36
+ async execute(params, _pinsSettingsList, context) {
37
+ const { step } = params;
38
+ const { steps } = context.boost;
39
+ const execute = steps.findIndex(({ name })=>name === step);
40
+ const result = await engine.executePinsList(execute, context, `${context.__PATH__}.execute`);
41
+ return result;
42
+ }
43
+ // SCENES
44
+ async boost(params, _pinsSettingsList, context) {
45
+ var _steps_step;
46
+ if (context.request.method && context.request.method !== 'POST') {
47
+ return {
48
+ error: 'Method not allowed'
49
+ };
50
+ }
51
+ const { steps } = params;
52
+ const step = context.request.body.step ? steps.findIndex(({ name })=>name === context.request.body.step) : 0;
53
+ const execute = ((_steps_step = steps[step]) == null ? void 0 : _steps_step.execute) || [];
54
+ const result = await engine.executePinsList(execute, _extends({}, context, {
55
+ boost: {
56
+ steps
57
+ }
58
+ }), `${context.__PATH__}.steps[${step}].execute`);
59
+ return result;
60
+ }
61
+ };
62
+ // PIN'S
63
+ const answer = (params, pinsSettingsList, context)=>new ChatbotService().answer(params, pinsSettingsList, context);
64
+ const execute = (params, pinsSettingsList, context)=>new ChatbotService().execute(params, pinsSettingsList, context);
65
+ // SCENES
66
+ const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
67
+
68
+ exports.answer = answer;
69
+ exports.boost = boost;
70
+ exports.execute = execute;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './libs/skill-chatbot/src/index';
package/index.esm.js ADDED
@@ -0,0 +1,64 @@
1
+ import { preparePinsSettings, executePinsList } from '@digipair/engine';
2
+
3
+ function _extends() {
4
+ _extends = Object.assign || function assign(target) {
5
+ for(var i = 1; i < arguments.length; i++){
6
+ var source = arguments[i];
7
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
8
+ }
9
+ return target;
10
+ };
11
+ return _extends.apply(this, arguments);
12
+ }
13
+
14
+ let ChatbotService = class ChatbotService {
15
+ async answer(params, _pinsSettingsList, context) {
16
+ const { command = [], boosts = [], sources = [], assistant, logs, boost, parent_conversation, parent_history, session, uuid } = params;
17
+ return {
18
+ assistant,
19
+ command: await Promise.all(command.map((settings)=>preparePinsSettings(settings, context))),
20
+ boosts,
21
+ sources,
22
+ logs,
23
+ boost: boost ? _extends({}, boost, {
24
+ inputs: await Promise.all((boost.inputs || []).map((settings)=>preparePinsSettings(settings, context)))
25
+ }) : boost,
26
+ parent_conversation,
27
+ parent_history,
28
+ session,
29
+ uuid
30
+ };
31
+ }
32
+ async execute(params, _pinsSettingsList, context) {
33
+ const { step } = params;
34
+ const { steps } = context.boost;
35
+ const execute = steps.findIndex(({ name })=>name === step);
36
+ const result = await executePinsList(execute, context, `${context.__PATH__}.execute`);
37
+ return result;
38
+ }
39
+ // SCENES
40
+ async boost(params, _pinsSettingsList, context) {
41
+ var _steps_step;
42
+ if (context.request.method && context.request.method !== 'POST') {
43
+ return {
44
+ error: 'Method not allowed'
45
+ };
46
+ }
47
+ const { steps } = params;
48
+ const step = context.request.body.step ? steps.findIndex(({ name })=>name === context.request.body.step) : 0;
49
+ const execute = ((_steps_step = steps[step]) == null ? void 0 : _steps_step.execute) || [];
50
+ const result = await executePinsList(execute, _extends({}, context, {
51
+ boost: {
52
+ steps
53
+ }
54
+ }), `${context.__PATH__}.steps[${step}].execute`);
55
+ return result;
56
+ }
57
+ };
58
+ // PIN'S
59
+ const answer = (params, pinsSettingsList, context)=>new ChatbotService().answer(params, pinsSettingsList, context);
60
+ const execute = (params, pinsSettingsList, context)=>new ChatbotService().execute(params, pinsSettingsList, context);
61
+ // SCENES
62
+ const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
63
+
64
+ export { answer, boost, execute };
@@ -1,2 +1 @@
1
1
  export * from './lib/skill-chatbot';
2
- //# sourceMappingURL=index.d.ts.map
@@ -13,4 +13,3 @@ export declare const answer: (params: any, pinsSettingsList: PinsSettings[], con
13
13
  }>;
14
14
  export declare const execute: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
15
15
  export declare const boost: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
16
- //# sourceMappingURL=skill-chatbot.d.ts.map
package/package.json CHANGED
@@ -1,28 +1,13 @@
1
1
  {
2
2
  "name": "@digipair/skill-chatbot",
3
- "version": "0.94.0-8",
4
- "main": "./dist/index.cjs.js",
5
- "module": "./dist/index.esm.js",
6
- "types": "./dist/index.d.ts",
3
+ "version": "0.95.1",
7
4
  "keywords": [
8
5
  "digipair",
9
6
  "service",
10
7
  "util"
11
8
  ],
12
- "exports": {
13
- "./package.json": "./package.json",
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.esm.js",
17
- "default": "./dist/index.cjs.js"
18
- }
19
- },
20
- "files": [
21
- "dist",
22
- "!**/*.tsbuildinfo"
23
- ],
24
- "nx": {
25
- "name": "skill-chatbot"
26
- },
27
- "dependencies": {}
28
- }
9
+ "dependencies": {},
10
+ "typings": "./index.d.ts",
11
+ "main": "./index.cjs.js",
12
+ "module": "./index.esm.js"
13
+ }
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # skill-test
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build skill-chatbot` to build the library.