@digipair/skill-chatbot 0.90.0 → 0.91.0-0

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/.swcrc ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2017",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true
12
+ },
13
+ "keepClassNames": true,
14
+ "externalHelpers": true,
15
+ "loose": true
16
+ },
17
+ "module": {
18
+ "type": "es6"
19
+ },
20
+ "sourceMaps": true,
21
+ "exclude": [
22
+ "jest.config.ts",
23
+ ".*\\.spec.tsx?$",
24
+ ".*\\.test.tsx?$",
25
+ "./src/jest-setup.ts$",
26
+ "./**/jest-setup.ts$"
27
+ ]
28
+ }
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # mylib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build mylib` to build the library.
@@ -0,0 +1,22 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: [
12
+ '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
+ '{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
14
+ ],
15
+ },
16
+ ],
17
+ },
18
+ languageOptions: {
19
+ parser: await import('jsonc-eslint-parser'),
20
+ },
21
+ },
22
+ ];
package/package.json CHANGED
@@ -1,13 +1,28 @@
1
1
  {
2
2
  "name": "@digipair/skill-chatbot",
3
- "version": "0.90.0",
3
+ "version": "0.91.0-0",
4
+ "type": "module",
5
+ "main": "dist/libs/skill-chatbot/index.cjs.js",
6
+ "module": "dist/libs/skill-chatbot/index.esm.js",
7
+ "types": "dist/libs/skill-chatbot/index.esm.d.ts",
8
+ "exports": {
9
+ "./package.json": "./libs/skill-chatbot/package.json",
10
+ ".": {
11
+ "development": "./dist/libs/skill-chatbot/src/index.ts",
12
+ "types": "./dist/libs/skill-chatbot/index.esm.d.ts",
13
+ "import": "./dist/libs/skill-chatbot/index.esm.js",
14
+ "default": "./dist/libs/skill-chatbot/index.cjs.js"
15
+ }
16
+ },
4
17
  "keywords": [
5
18
  "digipair",
6
- "service",
7
- "util"
19
+ "web",
20
+ "service"
8
21
  ],
9
- "dependencies": {},
10
- "typings": "./index.d.ts",
11
- "main": "./index.cjs.js",
12
- "module": "./index.esm.js"
13
- }
22
+ "nx": {
23
+ "name": "skill-chatbot"
24
+ },
25
+ "dependencies": {
26
+ "@digipair/engine": "0.91.0-0"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ const { withNx } = require('@nx/rollup/with-nx');
2
+
3
+ module.exports = withNx(
4
+ {
5
+ main: 'libs/skill-chatbot/src/index.ts',
6
+ outputPath: 'dist/libs/skill-chatbot',
7
+ tsConfig: 'libs/skill-chatbot/tsconfig.lib.json',
8
+ compiler: 'swc',
9
+ format: ['esm', "cjs"],
10
+ assets: [
11
+ {
12
+ input: 'libs/skill-chatbot/',
13
+ glob: 'package.json',
14
+ output: '.'
15
+ },
16
+ {
17
+ input: 'libs/skill-chatbot/src/',
18
+ glob: '*.json',
19
+ output: '.'
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
25
+ // e.g.
26
+ // output: { sourcemap: true },
27
+ }
28
+ );
@@ -0,0 +1 @@
1
+ declare module 'handlebars/dist/handlebars.min.js';
@@ -0,0 +1,7 @@
1
+ import { skillChatbot } from './skill-chatbot';
2
+
3
+ describe('skillChatbot', () => {
4
+ it('should work', () => {
5
+ expect(skillChatbot()).toEqual('skill-chatbot');
6
+ });
7
+ });
@@ -0,0 +1,78 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { PinsSettings, executePinsList, preparePinsSettings } from '@digipair/engine';
3
+
4
+ class ChatbotService {
5
+ async answer(params: any, _pinsSettingsList: PinsSettings[], context: any) {
6
+ const {
7
+ command = [],
8
+ boosts = [],
9
+ sources = [],
10
+ assistant,
11
+ logs,
12
+ boost,
13
+ parent_conversation,
14
+ parent_history,
15
+ session,
16
+ uuid,
17
+ } = params;
18
+ return {
19
+ assistant,
20
+ command: await Promise.all(
21
+ command.map((settings: PinsSettings) => preparePinsSettings(settings, context)),
22
+ ),
23
+ boosts,
24
+ sources,
25
+ logs,
26
+ boost: boost
27
+ ? {
28
+ ...boost,
29
+ inputs: await Promise.all(
30
+ (boost.inputs || []).map((settings: PinsSettings) => preparePinsSettings(settings, context)),
31
+ ),
32
+ }
33
+ : boost,
34
+ parent_conversation,
35
+ parent_history,
36
+ session,
37
+ uuid,
38
+ };
39
+ }
40
+
41
+ async execute(params: any, _pinsSettingsList: PinsSettings[], context: any) {
42
+ const { step } = params;
43
+ const { steps } = context.boost;
44
+ const execute = steps.findIndex(({ name }: any) => name === step);
45
+
46
+ const result = await executePinsList(execute, context, `${context.__PATH__}.execute`);
47
+ return result;
48
+ }
49
+
50
+ // SCENES
51
+ async boost(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
52
+ if (context.request.method && context.request.method !== 'POST') {
53
+ return { error: 'Method not allowed' };
54
+ }
55
+
56
+ const { steps } = params;
57
+ const step = context.request.body.step
58
+ ? steps.findIndex(({ name }: any) => name === context.request.body.step)
59
+ : 0;
60
+ const execute = steps[step]?.execute || [];
61
+
62
+ const result = await executePinsList(execute, { ...context, boost: { steps } }, `${context.__PATH__}.steps[${step}].execute`);
63
+ return result;
64
+ }
65
+ }
66
+
67
+ // PIN'S
68
+
69
+ export const answer = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
70
+ new ChatbotService().answer(params, pinsSettingsList, context);
71
+
72
+ export const execute = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
73
+ new ChatbotService().execute(params, pinsSettingsList, context);
74
+
75
+ // SCENES
76
+
77
+ export const boost = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
78
+ new ChatbotService().boost(params, pinsSettingsList, context);
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "module": "esnext",
9
+ "moduleResolution": "node",
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "references": [
15
+ {
16
+ "path": "../engine/tsconfig.lib.json"
17
+ }
18
+ ]
19
+ }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.cjs.js DELETED
@@ -1,70 +0,0 @@
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.esm.js DELETED
@@ -1,64 +0,0 @@
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,15 +0,0 @@
1
- import { PinsSettings } from '@digipair/engine';
2
- export declare const answer: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{
3
- assistant: any;
4
- command: any[];
5
- boosts: any;
6
- sources: any;
7
- logs: any;
8
- boost: any;
9
- parent_conversation: any;
10
- parent_history: any;
11
- session: any;
12
- uuid: any;
13
- }>;
14
- export declare const execute: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
15
- export declare const boost: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
File without changes
File without changes
File without changes