@openmrs/esm-expression-evaluator 8.0.1-pre.3439 → 8.0.1-pre.3457

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 5 files with swc (268.62ms)
1
+ [0] Successfully compiled: 5 files with swc (215.08ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
package/dist/evaluator.js CHANGED
@@ -211,6 +211,12 @@ export { jsep };
211
211
  if (typeof expression !== 'string' && (typeof expression !== 'object' || !expression || !('type' in expression))) {
212
212
  throw `Unknown expression type ${expression}. Expressions must either be a string or pre-compiled string.`;
213
213
  }
214
+ if (typeof expression === 'string' && expression.trim().length === 0) {
215
+ throw {
216
+ type: 'Empty expression',
217
+ message: 'Expression cannot be an empty string'
218
+ };
219
+ }
214
220
  if (typeof variables === 'undefined' || variables === null) {
215
221
  variables = {};
216
222
  }
@@ -241,6 +247,12 @@ export { jsep };
241
247
  if (typeof expression !== 'string' && (typeof expression !== 'object' || !expression || !('type' in expression))) {
242
248
  return Promise.reject(`Unknown expression type ${expression}. Expressions must either be a string or pre-compiled string.`);
243
249
  }
250
+ if (typeof expression === 'string' && expression.trim().length === 0) {
251
+ throw {
252
+ type: 'Empty expression',
253
+ message: 'Expression cannot be an empty string'
254
+ };
255
+ }
244
256
  if (typeof variables === 'undefined' || variables === null) {
245
257
  variables = {};
246
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-expression-evaluator",
3
- "version": "8.0.1-pre.3439",
3
+ "version": "8.0.1-pre.3457",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Utilities for evaluating user-defined expressions",
6
6
  "type": "module",
package/src/evaluator.ts CHANGED
@@ -242,6 +242,13 @@ export function evaluateAsType<T>(
242
242
  throw `Unknown expression type ${expression}. Expressions must either be a string or pre-compiled string.`;
243
243
  }
244
244
 
245
+ if (typeof expression === 'string' && expression.trim().length === 0) {
246
+ throw {
247
+ type: 'Empty expression',
248
+ message: 'Expression cannot be an empty string',
249
+ };
250
+ }
251
+
245
252
  if (typeof variables === 'undefined' || variables === null) {
246
253
  variables = {};
247
254
  }
@@ -286,6 +293,13 @@ export async function evaluateAsTypeAsync<T>(
286
293
  );
287
294
  }
288
295
 
296
+ if (typeof expression === 'string' && expression.trim().length === 0) {
297
+ throw {
298
+ type: 'Empty expression',
299
+ message: 'Expression cannot be an empty string',
300
+ };
301
+ }
302
+
289
303
  if (typeof variables === 'undefined' || variables === null) {
290
304
  variables = {};
291
305
  }