@digipair/skill-factory 0.93.0-0 → 0.93.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/index.cjs.js ADDED
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var engine = require('@digipair/engine');
6
+
7
+ let FactoryService = class FactoryService {
8
+ async initialize(startTask) {
9
+ this.startTask = startTask;
10
+ }
11
+ async start(params, _pinsSettingsList, context) {
12
+ const { reasoning, digipair = context.request.digipair, body = {}, factory = null } = params;
13
+ let result;
14
+ if (factory) {
15
+ const response = await fetch(`${factory}/${digipair}/${reasoning}`, body);
16
+ result = await response.json();
17
+ } else {
18
+ result = await this.startTask(context, digipair, reasoning, body);
19
+ }
20
+ return result;
21
+ }
22
+ async execute(params, _pinsSettingsList, _context) {
23
+ const { execute, context = _context } = params;
24
+ const result = await engine.executePinsList(execute, context, `${context.__PATH__}.execute`);
25
+ return result;
26
+ }
27
+ async keepAlive(_params, _pinsSettingsList, _context) {
28
+ throw {
29
+ type: 'DIGIPAIR_KEEPALIVE'
30
+ };
31
+ }
32
+ async stop(params, _pinsSettingsList, _context) {
33
+ const { value = {} } = params;
34
+ throw {
35
+ type: 'DIGIPAIR_STOP',
36
+ value
37
+ };
38
+ }
39
+ async task(params, _pinsSettingsList, context) {
40
+ const { execute } = params;
41
+ return await engine.executePinsList(execute, context, `${context.__PATH__}.execute`);
42
+ }
43
+ async action(params, _pinsSettingsList, context) {
44
+ const { execute } = params;
45
+ return await engine.executePinsList(execute, context, `${context.__PATH__}.execute`);
46
+ }
47
+ async trigger(params, _pinsSettingsList, context) {
48
+ const { execute } = params;
49
+ return await engine.executePinsList(execute, context, `${context.__PATH__}.execute`);
50
+ }
51
+ };
52
+ let instance;
53
+ const initialize = (launcher)=>(instance = new FactoryService()).initialize(launcher);
54
+ const start = (params, pinsSettingsList, context)=>instance.start(params, pinsSettingsList, context);
55
+ const execute = (params, pinsSettingsList, context)=>new FactoryService().execute(params, pinsSettingsList, context);
56
+ const keepAlive = (params, pinsSettingsList, context)=>new FactoryService().keepAlive(params, pinsSettingsList, context);
57
+ const stop = (params, pinsSettingsList, context)=>new FactoryService().stop(params, pinsSettingsList, context);
58
+ const task = (params, pinsSettingsList, context)=>new FactoryService().task(params, pinsSettingsList, context);
59
+ const action = (params, pinsSettingsList, context)=>new FactoryService().action(params, pinsSettingsList, context);
60
+ const trigger = (params, pinsSettingsList, context)=>new FactoryService().trigger(params, pinsSettingsList, context);
61
+
62
+ exports.action = action;
63
+ exports.execute = execute;
64
+ exports.initialize = initialize;
65
+ exports.keepAlive = keepAlive;
66
+ exports.start = start;
67
+ exports.stop = stop;
68
+ exports.task = task;
69
+ exports.trigger = trigger;
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './libs/skill-factory/src/index';