@promptbook/fake-llm 0.77.1 → 0.78.2

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.
Files changed (23) hide show
  1. package/esm/index.es.js +209 -187
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +10 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/utils.index.d.ts +4 -8
  6. package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
  7. package/esm/typings/src/config.d.ts +14 -0
  8. package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
  9. package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
  10. package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
  11. package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
  12. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
  13. package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
  14. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  15. package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
  16. package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
  17. package/package.json +2 -2
  18. package/umd/index.umd.js +208 -186
  19. package/umd/index.umd.js.map +1 -1
  20. /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
  21. /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
  22. /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
  23. /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import _spaceTrim, { spaceTrim } from 'spacetrim';
1
+ import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
2
2
  import { LoremIpsum } from 'lorem-ipsum';
3
3
  import { format } from 'prettier';
4
4
  import parserHtml from 'prettier/parser-html';
@@ -16,7 +16,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
16
16
  *
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- var PROMPTBOOK_ENGINE_VERSION = '0.77.0';
19
+ var PROMPTBOOK_ENGINE_VERSION = '0.78.1';
20
20
  /**
21
21
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
22
22
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -234,164 +234,25 @@ function $getCurrentDate() {
234
234
  }
235
235
 
236
236
  /**
237
- * This error type indicates that the error should not happen and its last check before crashing with some other error
237
+ * Name for the Promptbook
238
+ *
239
+ * TODO: [🗽] Unite branding and make single place for it
238
240
  *
239
241
  * @public exported from `@promptbook/core`
240
242
  */
241
- var UnexpectedError = /** @class */ (function (_super) {
242
- __extends(UnexpectedError, _super);
243
- function UnexpectedError(message) {
244
- var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
245
- _this.name = 'UnexpectedError';
246
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
247
- return _this;
248
- }
249
- return UnexpectedError;
250
- }(Error));
251
-
243
+ var NAME = "Promptbook";
252
244
  /**
253
- * Checks if the value is [🚉] serializable as JSON
254
- * If not, throws an UnexpectedError with a rich error message and tracking
255
- *
256
- * - Almost all primitives are serializable BUT:
257
- * - `undefined` is not serializable
258
- * - `NaN` is not serializable
259
- * - Objects and arrays are serializable if all their properties are serializable
260
- * - Functions are not serializable
261
- * - Circular references are not serializable
262
- * - `Date` objects are not serializable
263
- * - `Map` and `Set` objects are not serializable
264
- * - `RegExp` objects are not serializable
265
- * - `Error` objects are not serializable
266
- * - `Symbol` objects are not serializable
267
- * - And much more...
245
+ * Email of the responsible person
268
246
  *
269
- * @throws UnexpectedError if the value is not serializable as JSON
270
- * @public exported from `@promptbook/utils`
271
- */
272
- function checkSerializableAsJson(name, value) {
273
- var e_1, _a;
274
- if (value === undefined) {
275
- throw new UnexpectedError("".concat(name, " is undefined"));
276
- }
277
- else if (value === null) {
278
- return;
279
- }
280
- else if (typeof value === 'boolean') {
281
- return;
282
- }
283
- else if (typeof value === 'number' && !isNaN(value)) {
284
- return;
285
- }
286
- else if (typeof value === 'string') {
287
- return;
288
- }
289
- else if (typeof value === 'symbol') {
290
- throw new UnexpectedError("".concat(name, " is symbol"));
291
- }
292
- else if (typeof value === 'function') {
293
- throw new UnexpectedError("".concat(name, " is function"));
294
- }
295
- else if (typeof value === 'object' && Array.isArray(value)) {
296
- for (var i = 0; i < value.length; i++) {
297
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
298
- }
299
- }
300
- else if (typeof value === 'object') {
301
- if (value instanceof Date) {
302
- throw new UnexpectedError(_spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
303
- }
304
- else if (value instanceof Map) {
305
- throw new UnexpectedError("".concat(name, " is Map"));
306
- }
307
- else if (value instanceof Set) {
308
- throw new UnexpectedError("".concat(name, " is Set"));
309
- }
310
- else if (value instanceof RegExp) {
311
- throw new UnexpectedError("".concat(name, " is RegExp"));
312
- }
313
- else if (value instanceof Error) {
314
- throw new UnexpectedError(_spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
315
- }
316
- else {
317
- try {
318
- for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
319
- var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
320
- if (subValue === undefined) {
321
- // Note: undefined in object is serializable - it is just omited
322
- continue;
323
- }
324
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
325
- }
326
- }
327
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
328
- finally {
329
- try {
330
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
331
- }
332
- finally { if (e_1) throw e_1.error; }
333
- }
334
- try {
335
- JSON.stringify(value); // <- TODO: [0]
336
- }
337
- catch (error) {
338
- if (!(error instanceof Error)) {
339
- throw error;
340
- }
341
- throw new UnexpectedError(_spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
342
- }
343
- /*
344
- TODO: [0] Is there some more elegant way to check circular references?
345
- const seen = new Set();
346
- const stack = [{ value }];
347
- while (stack.length > 0) {
348
- const { value } = stack.pop()!;
349
- if (typeof value === 'object' && value !== null) {
350
- if (seen.has(value)) {
351
- throw new UnexpectedError(`${name} has circular reference`);
352
- }
353
- seen.add(value);
354
- if (Array.isArray(value)) {
355
- stack.push(...value.map((value) => ({ value })));
356
- } else {
357
- stack.push(...Object.values(value).map((value) => ({ value })));
358
- }
359
- }
360
- }
361
- */
362
- return;
363
- }
364
- }
365
- else {
366
- throw new UnexpectedError("".concat(name, " is unknown"));
367
- }
368
- }
369
- /**
370
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
371
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
372
- * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
247
+ * @public exported from `@promptbook/core`
373
248
  */
374
-
249
+ var ADMIN_EMAIL = 'me@pavolhejny.com';
375
250
  /**
376
- * @@@
377
- * @@@
378
- *
379
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
251
+ * Name of the responsible person for the Promptbook on GitHub
380
252
  *
381
- * @param name - Name of the object for debugging purposes
382
- * @param objectValue - Object to be deeply frozen
383
- * @returns The same object as the input, but deeply frozen
384
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
385
- */
386
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
387
- checkSerializableAsJson(name, objectValue);
388
- return $deepFreeze(objectValue);
389
- }
390
- /**
391
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
392
- * TODO: [🧠] Is there a way how to meaningfully test this utility
253
+ * @public exported from `@promptbook/core`
393
254
  */
394
-
255
+ var ADMIN_GITHUB_NAME = 'hejny';
395
256
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
396
257
  /**
397
258
  * The maximum number of iterations for a loops
@@ -411,22 +272,6 @@ var CHARACTER_LOOP_LIMIT = 100000;
411
272
  * @private within the repository
412
273
  */
413
274
  var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
414
- /**
415
- * The names of the parameters that are reserved for special purposes
416
- *
417
- * @public exported from `@promptbook/core`
418
- */
419
- $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
420
- 'content',
421
- 'context',
422
- 'knowledge',
423
- 'examples',
424
- 'modelName',
425
- 'currentDate',
426
- // <- TODO: list here all command names
427
- // <- TODO: Add more like 'date', 'modelName',...
428
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
429
- ]);
430
275
  /**
431
276
  * @@@
432
277
  *
@@ -489,6 +334,40 @@ var PipelineExecutionError = /** @class */ (function (_super) {
489
334
  return PipelineExecutionError;
490
335
  }(Error));
491
336
 
337
+ /**
338
+ * Make error report URL for the given error
339
+ *
340
+ * @private !!!!!!
341
+ */
342
+ function getErrorReportUrl(error) {
343
+ var report = {
344
+ title: "\uD83D\uDC1C Error report from ".concat(NAME),
345
+ body: spaceTrim(function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
346
+ };
347
+ var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
348
+ reportUrl.searchParams.set('labels', 'bug');
349
+ reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
350
+ reportUrl.searchParams.set('title', report.title);
351
+ reportUrl.searchParams.set('body', report.body);
352
+ return reportUrl;
353
+ }
354
+
355
+ /**
356
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
357
+ *
358
+ * @public exported from `@promptbook/core`
359
+ */
360
+ var UnexpectedError = /** @class */ (function (_super) {
361
+ __extends(UnexpectedError, _super);
362
+ function UnexpectedError(message) {
363
+ var _this = _super.call(this, spaceTrim$1(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
364
+ _this.name = 'UnexpectedError';
365
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
366
+ return _this;
367
+ }
368
+ return UnexpectedError;
369
+ }(Error));
370
+
492
371
  /**
493
372
  * Replaces parameters in template with values from parameters object
494
373
  *
@@ -568,6 +447,149 @@ function replaceParameters(template, parameters) {
568
447
  return replacedTemplates;
569
448
  }
570
449
 
450
+ /**
451
+ * Checks if the value is [🚉] serializable as JSON
452
+ * If not, throws an UnexpectedError with a rich error message and tracking
453
+ *
454
+ * - Almost all primitives are serializable BUT:
455
+ * - `undefined` is not serializable
456
+ * - `NaN` is not serializable
457
+ * - Objects and arrays are serializable if all their properties are serializable
458
+ * - Functions are not serializable
459
+ * - Circular references are not serializable
460
+ * - `Date` objects are not serializable
461
+ * - `Map` and `Set` objects are not serializable
462
+ * - `RegExp` objects are not serializable
463
+ * - `Error` objects are not serializable
464
+ * - `Symbol` objects are not serializable
465
+ * - And much more...
466
+ *
467
+ * @throws UnexpectedError if the value is not serializable as JSON
468
+ * @public exported from `@promptbook/utils`
469
+ */
470
+ function checkSerializableAsJson(name, value) {
471
+ var e_1, _a;
472
+ if (value === undefined) {
473
+ throw new UnexpectedError("".concat(name, " is undefined"));
474
+ }
475
+ else if (value === null) {
476
+ return;
477
+ }
478
+ else if (typeof value === 'boolean') {
479
+ return;
480
+ }
481
+ else if (typeof value === 'number' && !isNaN(value)) {
482
+ return;
483
+ }
484
+ else if (typeof value === 'string') {
485
+ return;
486
+ }
487
+ else if (typeof value === 'symbol') {
488
+ throw new UnexpectedError("".concat(name, " is symbol"));
489
+ }
490
+ else if (typeof value === 'function') {
491
+ throw new UnexpectedError("".concat(name, " is function"));
492
+ }
493
+ else if (typeof value === 'object' && Array.isArray(value)) {
494
+ for (var i = 0; i < value.length; i++) {
495
+ checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
496
+ }
497
+ }
498
+ else if (typeof value === 'object') {
499
+ if (value instanceof Date) {
500
+ throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
501
+ }
502
+ else if (value instanceof Map) {
503
+ throw new UnexpectedError("".concat(name, " is Map"));
504
+ }
505
+ else if (value instanceof Set) {
506
+ throw new UnexpectedError("".concat(name, " is Set"));
507
+ }
508
+ else if (value instanceof RegExp) {
509
+ throw new UnexpectedError("".concat(name, " is RegExp"));
510
+ }
511
+ else if (value instanceof Error) {
512
+ throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
513
+ }
514
+ else {
515
+ try {
516
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
517
+ var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
518
+ if (subValue === undefined) {
519
+ // Note: undefined in object is serializable - it is just omited
520
+ continue;
521
+ }
522
+ checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
523
+ }
524
+ }
525
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
526
+ finally {
527
+ try {
528
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
529
+ }
530
+ finally { if (e_1) throw e_1.error; }
531
+ }
532
+ try {
533
+ JSON.stringify(value); // <- TODO: [0]
534
+ }
535
+ catch (error) {
536
+ if (!(error instanceof Error)) {
537
+ throw error;
538
+ }
539
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
540
+ }
541
+ /*
542
+ TODO: [0] Is there some more elegant way to check circular references?
543
+ const seen = new Set();
544
+ const stack = [{ value }];
545
+ while (stack.length > 0) {
546
+ const { value } = stack.pop()!;
547
+ if (typeof value === 'object' && value !== null) {
548
+ if (seen.has(value)) {
549
+ throw new UnexpectedError(`${name} has circular reference`);
550
+ }
551
+ seen.add(value);
552
+ if (Array.isArray(value)) {
553
+ stack.push(...value.map((value) => ({ value })));
554
+ } else {
555
+ stack.push(...Object.values(value).map((value) => ({ value })));
556
+ }
557
+ }
558
+ }
559
+ */
560
+ return;
561
+ }
562
+ }
563
+ else {
564
+ throw new UnexpectedError("".concat(name, " is unknown"));
565
+ }
566
+ }
567
+ /**
568
+ * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
569
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
570
+ * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
571
+ */
572
+
573
+ /**
574
+ * @@@
575
+ * @@@
576
+ *
577
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
578
+ *
579
+ * @param name - Name of the object for debugging purposes
580
+ * @param objectValue - Object to be deeply frozen
581
+ * @returns The same object as the input, but deeply frozen
582
+ * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
583
+ */
584
+ function $asDeeplyFrozenSerializableJson(name, objectValue) {
585
+ checkSerializableAsJson(name, objectValue);
586
+ return $deepFreeze(objectValue);
587
+ }
588
+ /**
589
+ * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
590
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
591
+ */
592
+
571
593
  /**
572
594
  * Mocked execution Tools for just echoing the requests for testing purposes.
573
595
  *
@@ -629,7 +651,7 @@ var MockedEchoLlmExecutionTools = /** @class */ (function () {
629
651
  usage = ZERO_USAGE;
630
652
  // <- TODO: [🧠] Compute here at least words, characters,... etc
631
653
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('MockedEchoLlmExecutionTools ChatPromptResult', {
632
- content: spaceTrim(function (block) { return "\n You said:\n ".concat(block(rawPromptContent), "\n "); }),
654
+ content: spaceTrim$1(function (block) { return "\n You said:\n ".concat(block(rawPromptContent), "\n "); }),
633
655
  modelName: modelName,
634
656
  timing: {
635
657
  start: $getCurrentDate(),
@@ -661,7 +683,7 @@ var MockedEchoLlmExecutionTools = /** @class */ (function () {
661
683
  usage = ZERO_USAGE;
662
684
  // <- TODO: [🧠] Compute here at least words, characters,... etc
663
685
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('MockedEchoLlmExecutionTools CompletionPromptResult', {
664
- content: spaceTrim(function (block) { return "\n ".concat(block(rawPromptContent), "\n And so on...\n "); }),
686
+ content: spaceTrim$1(function (block) { return "\n ".concat(block(rawPromptContent), "\n And so on...\n "); }),
665
687
  modelName: modelName,
666
688
  timing: {
667
689
  start: $getCurrentDate(),
@@ -1262,7 +1284,7 @@ function extractAllBlocksFromMarkdown(markdown) {
1262
1284
  function extractOneBlockFromMarkdown(markdown) {
1263
1285
  var codeBlocks = extractAllBlocksFromMarkdown(markdown);
1264
1286
  if (codeBlocks.length !== 1) {
1265
- throw new ParseError(_spaceTrim(function (block) { return "\n There should be exactly 1 code block in task section, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
1287
+ throw new ParseError(spaceTrim(function (block) { return "\n There should be exactly 1 code block in task section, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
1266
1288
  }
1267
1289
  return codeBlocks[0];
1268
1290
  }
@@ -1653,13 +1675,13 @@ function removeQuotes(text) {
1653
1675
  * @public exported from `@promptbook/utils`
1654
1676
  */
1655
1677
  function trimCodeBlock(value) {
1656
- value = spaceTrim(value);
1678
+ value = spaceTrim$1(value);
1657
1679
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
1658
1680
  return value;
1659
1681
  }
1660
1682
  value = value.replace(/^```[a-z]*/i, '');
1661
1683
  value = value.replace(/```$/i, '');
1662
- value = spaceTrim(value);
1684
+ value = spaceTrim$1(value);
1663
1685
  return value;
1664
1686
  }
1665
1687
 
@@ -1672,9 +1694,9 @@ function trimCodeBlock(value) {
1672
1694
  * @public exported from `@promptbook/utils`
1673
1695
  */
1674
1696
  function trimEndOfCodeBlock(value) {
1675
- value = spaceTrim(value);
1697
+ value = spaceTrim$1(value);
1676
1698
  value = value.replace(/```$/g, '');
1677
- value = spaceTrim(value);
1699
+ value = spaceTrim$1(value);
1678
1700
  return value;
1679
1701
  }
1680
1702
 
@@ -1696,7 +1718,7 @@ function unwrapResult(text, options) {
1696
1718
  var trimmedText = text;
1697
1719
  // Remove leading and trailing spaces and newlines
1698
1720
  if (isTrimmed) {
1699
- trimmedText = spaceTrim(trimmedText);
1721
+ trimmedText = spaceTrim$1(trimmedText);
1700
1722
  }
1701
1723
  var processedText = trimmedText;
1702
1724
  if (isIntroduceSentenceRemoved) {
@@ -1705,7 +1727,7 @@ function unwrapResult(text, options) {
1705
1727
  // Remove the introduce sentence and quotes by replacing it with an empty string
1706
1728
  processedText = processedText.replace(introduceSentenceRegex, '');
1707
1729
  }
1708
- processedText = spaceTrim(processedText);
1730
+ processedText = spaceTrim$1(processedText);
1709
1731
  }
1710
1732
  if (processedText.length < 3) {
1711
1733
  return trimmedText;
@@ -1765,10 +1787,10 @@ function preserve(func) {
1765
1787
  return __generator(this, function (_a) {
1766
1788
  switch (_a.label) {
1767
1789
  case 0:
1768
- // TODO: Change to `await forEver` or something better
1790
+ // TODO: [💩] Change to `await forEver` or something better
1769
1791
  return [4 /*yield*/, forTime(100000000)];
1770
1792
  case 1:
1771
- // TODO: Change to `await forEver` or something better
1793
+ // TODO: [💩] Change to `await forEver` or something better
1772
1794
  _a.sent();
1773
1795
  _a.label = 2;
1774
1796
  case 2:
@@ -1832,7 +1854,7 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
1832
1854
  */
1833
1855
  JavascriptEvalExecutionTools.prototype.execute = function (options) {
1834
1856
  return __awaiter(this, void 0, void 0, function () {
1835
- var scriptLanguage, parameters, script, spaceTrim, removeQuotes$1, unwrapResult$1, trimEndOfCodeBlock$1, trimCodeBlock$1, trim, reverse, removeEmojis$1, prettifyMarkdown$1, capitalize$1, decapitalize$1, nameToUriPart$1, nameToUriParts$1, removeDiacritics$1, normalizeWhitespaces$1, normalizeToKebabCase$1, normalizeTo_camelCase$1, normalizeTo_snake_case$1, normalizeTo_PascalCase$1, parseKeywords, normalizeTo_SCREAMING_CASE$1, buildinFunctions, buildinFunctionsStatement, customFunctions, customFunctionsStatement, statementToEvaluate, result, error_1, undefinedName_1;
1857
+ var scriptLanguage, parameters, script, spaceTrim$1, removeQuotes$1, unwrapResult$1, trimEndOfCodeBlock$1, trimCodeBlock$1, trim, reverse, removeEmojis$1, prettifyMarkdown$1, capitalize$1, decapitalize$1, nameToUriPart$1, nameToUriParts$1, removeDiacritics$1, normalizeWhitespaces$1, normalizeToKebabCase$1, normalizeTo_camelCase$1, normalizeTo_snake_case$1, normalizeTo_PascalCase$1, parseKeywords, normalizeTo_SCREAMING_CASE$1, buildinFunctions, buildinFunctionsStatement, customFunctions, customFunctionsStatement, statementToEvaluate, result, error_1, undefinedName_1;
1836
1858
  return __generator(this, function (_a) {
1837
1859
  switch (_a.label) {
1838
1860
  case 0:
@@ -1841,8 +1863,8 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
1841
1863
  if (scriptLanguage !== 'javascript') {
1842
1864
  throw new PipelineExecutionError("Script language ".concat(scriptLanguage, " not supported to be executed by JavascriptEvalExecutionTools"));
1843
1865
  }
1844
- spaceTrim = function (_) { return _spaceTrim(_); };
1845
- preserve(spaceTrim);
1866
+ spaceTrim$1 = function (_) { return spaceTrim(_); };
1867
+ preserve(spaceTrim$1);
1846
1868
  removeQuotes$1 = removeQuotes;
1847
1869
  preserve(removeQuotes$1);
1848
1870
  unwrapResult$1 = unwrapResult;
@@ -1892,7 +1914,7 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
1892
1914
  }
1893
1915
  buildinFunctions = {
1894
1916
  // TODO: [🍯] DRY all these functions across the file
1895
- spaceTrim: spaceTrim,
1917
+ spaceTrim: spaceTrim$1,
1896
1918
  removeQuotes: removeQuotes$1,
1897
1919
  unwrapResult: unwrapResult$1,
1898
1920
  trimEndOfCodeBlock: trimEndOfCodeBlock$1,
@@ -1928,14 +1950,14 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
1928
1950
  return "const ".concat(functionName, " = customFunctions.").concat(functionName, ";");
1929
1951
  })
1930
1952
  .join('\n');
1931
- statementToEvaluate = _spaceTrim(function (block) { return "\n\n // Build-in functions:\n ".concat(block(buildinFunctionsStatement), "\n\n // Custom functions:\n ").concat(block(customFunctionsStatement || '// -- No custom functions --'), "\n\n // The script:\n ").concat(block(Object.entries(parameters)
1953
+ statementToEvaluate = spaceTrim(function (block) { return "\n\n // Build-in functions:\n ".concat(block(buildinFunctionsStatement), "\n\n // Custom functions:\n ").concat(block(customFunctionsStatement || '// -- No custom functions --'), "\n\n // The script:\n ").concat(block(Object.entries(parameters)
1932
1954
  .map(function (_a) {
1933
1955
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
1934
1956
  return "const ".concat(key, " = ").concat(JSON.stringify(value), ";");
1935
1957
  })
1936
1958
  .join('\n')), "\n (()=>{ ").concat(script, " })()\n "); });
1937
1959
  if (this.options.isVerbose) {
1938
- console.info(_spaceTrim(function (block) { return "\n \uD83D\uDE80 Evaluating ".concat(scriptLanguage, " script:\n\n ").concat(block(statementToEvaluate)); }));
1960
+ console.info(spaceTrim(function (block) { return "\n \uD83D\uDE80 Evaluating ".concat(scriptLanguage, " script:\n\n ").concat(block(statementToEvaluate)); }));
1939
1961
  }
1940
1962
  _a.label = 1;
1941
1963
  case 1:
@@ -1960,12 +1982,12 @@ var JavascriptEvalExecutionTools = /** @class */ (function () {
1960
1982
  To: [PipelineExecutionError: Parameter `{thing}` is not defined],
1961
1983
  */
1962
1984
  if (!statementToEvaluate.includes(undefinedName_1 + '(')) {
1963
- throw new PipelineExecutionError(_spaceTrim(function (block) { return "\n\n Parameter `{".concat(undefinedName_1, "}` is not defined\n\n This happen during evaluation of the javascript, which has access to the following parameters as javascript variables:\n\n ").concat(block(Object.keys(parameters)
1985
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n\n Parameter `{".concat(undefinedName_1, "}` is not defined\n\n This happen during evaluation of the javascript, which has access to the following parameters as javascript variables:\n\n ").concat(block(Object.keys(parameters)
1964
1986
  .map(function (key) { return " - ".concat(key, "\n"); })
1965
1987
  .join('')), "\n\n The script is:\n ```javascript\n ").concat(block(script), "\n ```\n\n Original error message:\n ").concat(block(error_1.message), "\n\n\n "); }));
1966
1988
  }
1967
1989
  else {
1968
- throw new PipelineExecutionError(_spaceTrim(function (block) { return "\n Function ".concat(undefinedName_1, "() is not defined\n\n - Make sure that the function is one of built-in functions\n - Or you have to defined the function during construction of JavascriptEvalExecutionTools\n\n Original error message:\n ").concat(block(error_1.message), "\n\n "); }));
1990
+ throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Function ".concat(undefinedName_1, "() is not defined\n\n - Make sure that the function is one of built-in functions\n - Or you have to defined the function during construction of JavascriptEvalExecutionTools\n\n Original error message:\n ").concat(block(error_1.message), "\n\n "); }));
1969
1991
  }
1970
1992
  }
1971
1993
  throw error_1;
@@ -2068,7 +2090,7 @@ function $fakeTextToExpectations(expectations, postprocessingFunctionNames) {
2068
2090
  loremText = loremText.substring(1);
2069
2091
  _d.label = 10;
2070
2092
  case 10: return [3 /*break*/, 1];
2071
- case 11: throw new LimitReachedError(spaceTrim(function (block) { return "\n Can not generate fake text to met the expectations\n\n Loop limit reached\n The expectations:\n ".concat(block(JSON.stringify(expectations, null, 4)), "\n\n The draft text:\n ").concat(block(text), "\n\n "); }));
2093
+ case 11: throw new LimitReachedError(spaceTrim$1(function (block) { return "\n Can not generate fake text to met the expectations\n\n Loop limit reached\n The expectations:\n ".concat(block(JSON.stringify(expectations, null, 4)), "\n\n The draft text:\n ").concat(block(text), "\n\n "); }));
2072
2094
  }
2073
2095
  });
2074
2096
  });