@digipair/skill-basic 0.49.6 → 0.50.6

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 CHANGED
@@ -4,6 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var engine = require('@digipair/engine');
6
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
+
7
18
  let BasicService = class BasicService {
8
19
  async transform(params, _pinsSettingsList, context) {
9
20
  const { value, execute } = params;
@@ -57,6 +68,16 @@ let BasicService = class BasicService {
57
68
  const buffer = Buffer.from(data, 'base64');
58
69
  return buffer;
59
70
  }
71
+ async trycatch(params, _pinsSettingsList, context) {
72
+ const { executeTry, executeCatch = [] } = params;
73
+ try {
74
+ return await engine.executePinsList(executeTry, context);
75
+ } catch (error) {
76
+ return await engine.executePinsList(executeCatch, _extends({}, context, {
77
+ error
78
+ }));
79
+ }
80
+ }
60
81
  };
61
82
  const transform = (params, pinsSettingsList, context)=>new BasicService().transform(params, pinsSettingsList, context);
62
83
  const setVariable = (params, pinsSettingsList, context)=>new BasicService().setVariable(params, pinsSettingsList, context);
@@ -65,6 +86,7 @@ const interval = (params, pinsSettingsList, context)=>new BasicService().interva
65
86
  const defer = (params, pinsSettingsList, context)=>new BasicService().defer(params, pinsSettingsList, context);
66
87
  const stopInterval = (params, pinsSettingsList, context)=>new BasicService().stopInterval(params, pinsSettingsList, context);
67
88
  const stopDefer = (params, pinsSettingsList, context)=>new BasicService().stopDefer(params, pinsSettingsList, context);
89
+ const trycatch = (params, pinsSettingsList, context)=>new BasicService().trycatch(params, pinsSettingsList, context);
68
90
 
69
91
  exports.base64ToBuffer = base64ToBuffer;
70
92
  exports.defer = defer;
@@ -73,3 +95,4 @@ exports.setVariable = setVariable;
73
95
  exports.stopDefer = stopDefer;
74
96
  exports.stopInterval = stopInterval;
75
97
  exports.transform = transform;
98
+ exports.trycatch = trycatch;
package/index.esm.js CHANGED
@@ -23899,14 +23899,14 @@ function indent(str, spaces) {
23899
23899
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23900
23900
  // match is required
23901
23901
  if (!match) {
23902
- return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23902
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23903
23903
  v: nextMatch1
23904
23904
  };
23905
23905
  }
23906
23906
  var token = match.token, offset = match.offset;
23907
23907
  i1 += offset;
23908
23908
  if (token === " ") {
23909
- return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23909
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23910
23910
  }
23911
23911
  tokens1 = _to_consumable_array$1(tokens1).concat([
23912
23912
  token
@@ -23925,7 +23925,7 @@ function indent(str, spaces) {
23925
23925
  if (contextKeys.some(function(el) {
23926
23926
  return el.startsWith(name);
23927
23927
  })) {
23928
- return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23928
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23929
23929
  }
23930
23930
  if (dateTimeIdentifiers.some(function(el) {
23931
23931
  return el === name;
@@ -23944,9 +23944,9 @@ function indent(str, spaces) {
23944
23944
  if (dateTimeIdentifiers.some(function(el) {
23945
23945
  return el.startsWith(name);
23946
23946
  })) {
23947
- return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23947
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23948
23948
  }
23949
- return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23949
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23950
23950
  v: nextMatch1
23951
23951
  };
23952
23952
  };
@@ -28006,6 +28006,16 @@ let BasicService = class BasicService {
28006
28006
  const buffer = Buffer.from(data, 'base64');
28007
28007
  return buffer;
28008
28008
  }
28009
+ async trycatch(params, _pinsSettingsList, context) {
28010
+ const { executeTry, executeCatch = [] } = params;
28011
+ try {
28012
+ return await executePinsList(executeTry, context);
28013
+ } catch (error) {
28014
+ return await executePinsList(executeCatch, _extends({}, context, {
28015
+ error
28016
+ }));
28017
+ }
28018
+ }
28009
28019
  };
28010
28020
  const transform = (params, pinsSettingsList, context)=>new BasicService().transform(params, pinsSettingsList, context);
28011
28021
  const setVariable = (params, pinsSettingsList, context)=>new BasicService().setVariable(params, pinsSettingsList, context);
@@ -28014,5 +28024,6 @@ const interval = (params, pinsSettingsList, context)=>new BasicService().interva
28014
28024
  const defer = (params, pinsSettingsList, context)=>new BasicService().defer(params, pinsSettingsList, context);
28015
28025
  const stopInterval = (params, pinsSettingsList, context)=>new BasicService().stopInterval(params, pinsSettingsList, context);
28016
28026
  const stopDefer = (params, pinsSettingsList, context)=>new BasicService().stopDefer(params, pinsSettingsList, context);
28027
+ const trycatch = (params, pinsSettingsList, context)=>new BasicService().trycatch(params, pinsSettingsList, context);
28017
28028
 
28018
- export { base64ToBuffer, defer, interval, setVariable, stopDefer, stopInterval, transform };
28029
+ export { base64ToBuffer, defer, interval, setVariable, stopDefer, stopInterval, transform, trycatch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-basic",
3
- "version": "0.49.6",
3
+ "version": "0.50.6",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
package/schema.fr.json CHANGED
@@ -197,6 +197,40 @@
197
197
  ],
198
198
  "x-events": []
199
199
  }
200
+ },
201
+ "/trycatch": {
202
+ "post": {
203
+ "tags": ["web", "service", "spatial"],
204
+ "summary": "Attraper les erreurs",
205
+ "description": "Essaye une action et attrape les erreurs",
206
+ "parameters": [
207
+ {
208
+ "name": "executeTry",
209
+ "summary": "Executer",
210
+ "required": true,
211
+ "description": "Actions à exécuter",
212
+ "schema": {
213
+ "type": "array",
214
+ "items": {
215
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
216
+ }
217
+ }
218
+ },
219
+ {
220
+ "name": "executeCatch",
221
+ "summary": "Lors d'une erreur",
222
+ "required": false,
223
+ "description": "Actions à exécuter en cas d'erreur",
224
+ "schema": {
225
+ "type": "array",
226
+ "items": {
227
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
228
+ }
229
+ }
230
+ }
231
+ ],
232
+ "x-events": []
233
+ }
200
234
  }
201
235
  },
202
236
  "components": {
package/schema.json CHANGED
@@ -197,6 +197,40 @@
197
197
  ],
198
198
  "x-events": []
199
199
  }
200
+ },
201
+ "/trycatch": {
202
+ "post": {
203
+ "tags": ["web", "service", "spatial"],
204
+ "summary": "Try and Catch",
205
+ "description": "Executes a series of actions and catches any errors.",
206
+ "parameters": [
207
+ {
208
+ "name": "executeTry",
209
+ "summary": "Execute",
210
+ "required": true,
211
+ "description": "Actions to execute",
212
+ "schema": {
213
+ "type": "array",
214
+ "items": {
215
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
216
+ }
217
+ }
218
+ },
219
+ {
220
+ "name": "executeCatch",
221
+ "summary": "When an error occurs",
222
+ "required": false,
223
+ "description": "Actions to execute in case of an error",
224
+ "schema": {
225
+ "type": "array",
226
+ "items": {
227
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
228
+ }
229
+ }
230
+ }
231
+ ],
232
+ "x-events": []
233
+ }
200
234
  }
201
235
  },
202
236
  "components": {
@@ -8,3 +8,4 @@ export declare const interval: (params: any, pinsSettingsList: PinsSettings[], c
8
8
  export declare const defer: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<NodeJS.Timeout>;
9
9
  export declare const stopInterval: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
10
10
  export declare const stopDefer: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<void>;
11
+ export declare const trycatch: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;