@promptbook/editable 0.86.10 → 0.86.30

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/umd/index.umd.js CHANGED
@@ -16,138 +16,19 @@
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/book
18
18
  */
19
- var BOOK_LANGUAGE_VERSION = '1.0.0';
19
+ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  /**
21
21
  * The version of the Promptbook engine
22
22
  *
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.86.10';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.86.30';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
30
30
  */
31
31
 
32
- /*! *****************************************************************************
33
- Copyright (c) Microsoft Corporation.
34
-
35
- Permission to use, copy, modify, and/or distribute this software for any
36
- purpose with or without fee is hereby granted.
37
-
38
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
39
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
41
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
42
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
43
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44
- PERFORMANCE OF THIS SOFTWARE.
45
- ***************************************************************************** */
46
- /* global Reflect, Promise */
47
-
48
- var extendStatics = function(d, b) {
49
- extendStatics = Object.setPrototypeOf ||
50
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
51
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
52
- return extendStatics(d, b);
53
- };
54
-
55
- function __extends(d, b) {
56
- if (typeof b !== "function" && b !== null)
57
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
58
- extendStatics(d, b);
59
- function __() { this.constructor = d; }
60
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
61
- }
62
-
63
- var __assign = function() {
64
- __assign = Object.assign || function __assign(t) {
65
- for (var s, i = 1, n = arguments.length; i < n; i++) {
66
- s = arguments[i];
67
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
68
- }
69
- return t;
70
- };
71
- return __assign.apply(this, arguments);
72
- };
73
-
74
- function __awaiter(thisArg, _arguments, P, generator) {
75
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
76
- return new (P || (P = Promise))(function (resolve, reject) {
77
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
78
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
79
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
80
- step((generator = generator.apply(thisArg, _arguments || [])).next());
81
- });
82
- }
83
-
84
- function __generator(thisArg, body) {
85
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
86
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
87
- function verb(n) { return function (v) { return step([n, v]); }; }
88
- function step(op) {
89
- if (f) throw new TypeError("Generator is already executing.");
90
- while (_) try {
91
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
92
- if (y = 0, t) op = [op[0] & 2, t.value];
93
- switch (op[0]) {
94
- case 0: case 1: t = op; break;
95
- case 4: _.label++; return { value: op[1], done: false };
96
- case 5: _.label++; y = op[1]; op = [0]; continue;
97
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
98
- default:
99
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
100
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
101
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
102
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
103
- if (t[2]) _.ops.pop();
104
- _.trys.pop(); continue;
105
- }
106
- op = body.call(thisArg, _);
107
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
108
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
109
- }
110
- }
111
-
112
- function __values(o) {
113
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
114
- if (m) return m.call(o);
115
- if (o && typeof o.length === "number") return {
116
- next: function () {
117
- if (o && i >= o.length) o = void 0;
118
- return { value: o && o[i++], done: !o };
119
- }
120
- };
121
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
122
- }
123
-
124
- function __read(o, n) {
125
- var m = typeof Symbol === "function" && o[Symbol.iterator];
126
- if (!m) return o;
127
- var i = m.call(o), r, ar = [], e;
128
- try {
129
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
130
- }
131
- catch (error) { e = { error: error }; }
132
- finally {
133
- try {
134
- if (r && !r.done && (m = i["return"])) m.call(i);
135
- }
136
- finally { if (e) throw e.error; }
137
- }
138
- return ar;
139
- }
140
-
141
- function __spreadArray(to, from, pack) {
142
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
143
- if (ar || !(i in from)) {
144
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
145
- ar[i] = from[i];
146
- }
147
- }
148
- return to.concat(ar || Array.prototype.slice.call(from));
149
- }
150
-
151
32
  /**
152
33
  * Returns the same value that is passed as argument.
153
34
  * No side effects.
@@ -175,38 +56,38 @@
175
56
  *
176
57
  * @public exported from `@promptbook/core`
177
58
  */
178
- var NAME = "Promptbook";
59
+ const NAME = `Promptbook`;
179
60
  /**
180
61
  * Email of the responsible person
181
62
  *
182
63
  * @public exported from `@promptbook/core`
183
64
  */
184
- var ADMIN_EMAIL = 'pavol@ptbk.io';
65
+ const ADMIN_EMAIL = 'pavol@ptbk.io';
185
66
  /**
186
67
  * Name of the responsible person for the Promptbook on GitHub
187
68
  *
188
69
  * @public exported from `@promptbook/core`
189
70
  */
190
- var ADMIN_GITHUB_NAME = 'hejny';
71
+ const ADMIN_GITHUB_NAME = 'hejny';
191
72
  /**
192
73
  * When the title is not provided, the default title is used
193
74
  *
194
75
  * @public exported from `@promptbook/core`
195
76
  */
196
- var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
77
+ const DEFAULT_BOOK_TITLE = `✨ Untitled Book`;
197
78
  /**
198
79
  * When the pipeline is flat and no name of return parameter is provided, this name is used
199
80
  *
200
81
  * @public exported from `@promptbook/core`
201
82
  */
202
- var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
83
+ const DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
203
84
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
204
85
  /**
205
86
  * The maximum number of iterations for a loops
206
87
  *
207
88
  * @private within the repository - too low-level in comparison with other `MAX_...`
208
89
  */
209
- var LOOP_LIMIT = 1000;
90
+ const LOOP_LIMIT = 1000;
210
91
  // <- TODO: [🧜‍♂️]
211
92
  /**
212
93
  * @@@
@@ -230,11 +111,37 @@
230
111
  * @private private within the repository
231
112
  */
232
113
  function getErrorReportUrl(error) {
233
- var report = {
234
- title: "\uD83D\uDC1C Error report from ".concat(NAME),
235
- body: spaceTrim__default["default"](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 "); }),
114
+ const report = {
115
+ title: `🐜 Error report from ${NAME}`,
116
+ body: spaceTrim__default["default"]((block) => `
117
+
118
+
119
+ \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
120
+
121
+ \`\`\`
122
+ ${block(error.message || '(no error message)')}
123
+ \`\`\`
124
+
125
+
126
+ ## More info:
127
+
128
+ - **Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
129
+ - **Book language version:** ${BOOK_LANGUAGE_VERSION}
130
+ - **Time:** ${new Date().toISOString()}
131
+
132
+ <details>
133
+ <summary>Stack trace:</summary>
134
+
135
+ ## Stack trace:
136
+
137
+ \`\`\`stacktrace
138
+ ${block(error.stack || '(empty)')}
139
+ \`\`\`
140
+ </details>
141
+
142
+ `),
236
143
  };
237
- var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
144
+ const reportUrl = new URL(`https://github.com/webgptorg/promptbook/issues/new`);
238
145
  reportUrl.searchParams.set('labels', 'bug');
239
146
  reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
240
147
  reportUrl.searchParams.set('title', report.title);
@@ -247,32 +154,37 @@
247
154
  *
248
155
  * @public exported from `@promptbook/core`
249
156
  */
250
- var UnexpectedError = /** @class */ (function (_super) {
251
- __extends(UnexpectedError, _super);
252
- function UnexpectedError(message) {
253
- var _this = _super.call(this, spaceTrim.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 ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
254
- _this.name = 'UnexpectedError';
255
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
256
- return _this;
157
+ class UnexpectedError extends Error {
158
+ constructor(message) {
159
+ super(spaceTrim.spaceTrim((block) => `
160
+ ${block(message)}
161
+
162
+ Note: This error should not happen.
163
+ It's probbably a bug in the pipeline collection
164
+
165
+ Please report issue:
166
+ ${block(getErrorReportUrl(new Error(message)).href)}
167
+
168
+ Or contact us on ${ADMIN_EMAIL}
169
+
170
+ `));
171
+ this.name = 'UnexpectedError';
172
+ Object.setPrototypeOf(this, UnexpectedError.prototype);
257
173
  }
258
- return UnexpectedError;
259
- }(Error));
174
+ }
260
175
 
261
176
  /**
262
177
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
263
178
  *
264
179
  * @public exported from `@promptbook/core`
265
180
  */
266
- var ParseError = /** @class */ (function (_super) {
267
- __extends(ParseError, _super);
268
- function ParseError(message) {
269
- var _this = _super.call(this, message) || this;
270
- _this.name = 'ParseError';
271
- Object.setPrototypeOf(_this, ParseError.prototype);
272
- return _this;
181
+ class ParseError extends Error {
182
+ constructor(message) {
183
+ super(message);
184
+ this.name = 'ParseError';
185
+ Object.setPrototypeOf(this, ParseError.prototype);
273
186
  }
274
- return ParseError;
275
- }(Error));
187
+ }
276
188
  /**
277
189
  * TODO: Maybe split `ParseError` and `ApplyError`
278
190
  */
@@ -285,7 +197,7 @@
285
197
  * @see `documentationUrl` for more details
286
198
  * @private within the commands folder
287
199
  */
288
- var boilerplateCommandParser = {
200
+ const boilerplateCommandParser = {
289
201
  /**
290
202
  * Name of the command
291
203
  */
@@ -302,7 +214,7 @@
302
214
  /**
303
215
  * Description of the BOILERPLATE command
304
216
  */
305
- description: "@@",
217
+ description: `@@`,
306
218
  /**
307
219
  * Link to documentation
308
220
  */
@@ -314,18 +226,18 @@
314
226
  /**
315
227
  * Parses the BOILERPLATE command
316
228
  */
317
- parse: function (input) {
318
- var args = input.args;
229
+ parse(input) {
230
+ const { args } = input;
319
231
  if (args.length !== 1) {
320
- throw new ParseError("BOILERPLATE command requires exactly one argument");
232
+ throw new ParseError(`BOILERPLATE command requires exactly one argument`);
321
233
  }
322
- var value = args[0].toLowerCase();
234
+ const value = args[0].toLowerCase();
323
235
  if (value.includes('brr')) {
324
- throw new ParseError("BOILERPLATE value can not contain brr");
236
+ throw new ParseError(`BOILERPLATE value can not contain brr`);
325
237
  }
326
238
  return {
327
239
  type: 'BOILERPLATE',
328
- value: value,
240
+ value,
329
241
  };
330
242
  },
331
243
  /**
@@ -333,40 +245,40 @@
333
245
  *
334
246
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
335
247
  */
336
- $applyToPipelineJson: function (command, $pipelineJson) {
337
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
248
+ $applyToPipelineJson(command, $pipelineJson) {
249
+ throw new ParseError(`BOILERPLATE command is only for testing purposes and should not be used in the .book.md file`);
338
250
  },
339
251
  /**
340
252
  * Apply the BOILERPLATE command to the `pipelineJson`
341
253
  *
342
254
  * Note: `$` is used to indicate that this function mutates given `taskJson`
343
255
  */
344
- $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
345
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
256
+ $applyToTaskJson(command, $taskJson, $pipelineJson) {
257
+ throw new ParseError(`BOILERPLATE command is only for testing purposes and should not be used in the .book.md file`);
346
258
  },
347
259
  /**
348
260
  * Converts the BOILERPLATE command back to string
349
261
  *
350
262
  * Note: This is used in `pipelineJsonToString` utility
351
263
  */
352
- stringify: function (command) {
353
- return "---"; // <- TODO: [🛋] Implement
264
+ stringify(command) {
265
+ return `---`; // <- TODO: [🛋] Implement
354
266
  },
355
267
  /**
356
268
  * Reads the BOILERPLATE command from the `PipelineJson`
357
269
  *
358
270
  * Note: This is used in `pipelineJsonToString` utility
359
271
  */
360
- takeFromPipelineJson: function (pipelineJson) {
361
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
272
+ takeFromPipelineJson(pipelineJson) {
273
+ throw new ParseError(`BOILERPLATE command is only for testing purposes and should not be used in the .book.md file`);
362
274
  },
363
275
  /**
364
276
  * Reads the BOILERPLATE command from the `TaskJson`
365
277
  *
366
278
  * Note: This is used in `pipelineJsonToString` utility
367
279
  */
368
- takeFromTaskJson: function ($taskJson) {
369
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
280
+ takeFromTaskJson($taskJson) {
281
+ throw new ParseError(`BOILERPLATE command is only for testing purposes and should not be used in the .book.md file`);
370
282
  },
371
283
  };
372
284
 
@@ -375,16 +287,23 @@
375
287
  *
376
288
  * @public exported from `@promptbook/core`
377
289
  */
378
- var NotYetImplementedError = /** @class */ (function (_super) {
379
- __extends(NotYetImplementedError, _super);
380
- function NotYetImplementedError(message) {
381
- var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on pavol@ptbk.io\n\n "); })) || this;
382
- _this.name = 'NotYetImplementedError';
383
- Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
384
- return _this;
290
+ class NotYetImplementedError extends Error {
291
+ constructor(message) {
292
+ super(spaceTrim.spaceTrim((block) => `
293
+ ${block(message)}
294
+
295
+ Note: This feature is not implemented yet but it will be soon.
296
+
297
+ If you want speed up the implementation or just read more, look here:
298
+ https://github.com/webgptorg/promptbook
299
+
300
+ Or contact us on pavol@ptbk.io
301
+
302
+ `));
303
+ this.name = 'NotYetImplementedError';
304
+ Object.setPrototypeOf(this, NotYetImplementedError.prototype);
385
305
  }
386
- return NotYetImplementedError;
387
- }(Error));
306
+ }
388
307
 
389
308
  /**
390
309
  * Tests if given string is valid semantic version
@@ -434,7 +353,7 @@
434
353
  * @see `documentationUrl` for more details
435
354
  * @public exported from `@promptbook/editable`
436
355
  */
437
- var bookVersionCommandParser = {
356
+ const bookVersionCommandParser = {
438
357
  /**
439
358
  * Name of the command
440
359
  */
@@ -448,7 +367,7 @@
448
367
  /**
449
368
  * Description of the BOOK_VERSION command
450
369
  */
451
- description: "Which version of the Book language is the .book.md using",
370
+ description: `Which version of the Book language is the .book.md using`,
452
371
  /**
453
372
  * Link to documentation
454
373
  */
@@ -456,21 +375,21 @@
456
375
  /**
457
376
  * Example usages of the BOOK_VERSION command
458
377
  */
459
- examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
378
+ examples: [`BOOK VERSION ${BOOK_LANGUAGE_VERSION}`, `BOOK ${BOOK_LANGUAGE_VERSION}`],
460
379
  /**
461
380
  * Parses the BOOK_VERSION command
462
381
  */
463
- parse: function (input) {
464
- var args = input.args;
465
- var bookVersion = args.pop();
382
+ parse(input) {
383
+ const { args } = input;
384
+ const bookVersion = args.pop();
466
385
  if (bookVersion === undefined) {
467
- throw new ParseError("Version is required");
386
+ throw new ParseError(`Version is required`);
468
387
  }
469
388
  if (!isValidPromptbookVersion(bookVersion)) {
470
- throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
389
+ throw new ParseError(`Invalid Promptbook version "${bookVersion}"`);
471
390
  }
472
391
  if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
473
- throw new ParseError("Can not have more than one Promptbook version");
392
+ throw new ParseError(`Can not have more than one Promptbook version`);
474
393
  }
475
394
  return {
476
395
  type: 'BOOK_VERSION',
@@ -482,7 +401,7 @@
482
401
  *
483
402
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
484
403
  */
485
- $applyToPipelineJson: function (command, $pipelineJson) {
404
+ $applyToPipelineJson(command, $pipelineJson) {
486
405
  // TODO: Warn if the version is overridden
487
406
  $pipelineJson.bookVersion = command.bookVersion;
488
407
  },
@@ -491,16 +410,16 @@
491
410
  *
492
411
  * Note: This is used in `pipelineJsonToString` utility
493
412
  */
494
- stringify: function (command) {
495
- return "---"; // <- TODO: [🛋] Implement
413
+ stringify(command) {
414
+ return `---`; // <- TODO: [🛋] Implement
496
415
  },
497
416
  /**
498
417
  * Reads the BOOK_VERSION command from the `PipelineJson`
499
418
  *
500
419
  * Note: This is used in `pipelineJsonToString` utility
501
420
  */
502
- takeFromPipelineJson: function (pipelineJson) {
503
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
421
+ takeFromPipelineJson(pipelineJson) {
422
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
504
423
  },
505
424
  };
506
425
 
@@ -510,7 +429,7 @@
510
429
  * @see https://github.com/webgptorg/promptbook/discussions/30
511
430
  * @public exported from `@promptbook/core`
512
431
  */
513
- var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
432
+ const EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
514
433
  /**
515
434
  * TODO: [💝] Unite object for expecting amount and format - remove format
516
435
  */
@@ -527,7 +446,7 @@
527
446
  * @public exported from `@promptbook/utils`
528
447
  */
529
448
  function parseNumber(value) {
530
- var originalValue = value;
449
+ const originalValue = value;
531
450
  if (typeof value === 'number') {
532
451
  value = value.toString(); // <- TODO: Maybe more efficient way to do this
533
452
  }
@@ -539,7 +458,7 @@
539
458
  return parseNumber(value.substring(1));
540
459
  }
541
460
  if (value.startsWith('-')) {
542
- var number = parseNumber(value.substring(1));
461
+ const number = parseNumber(value.substring(1));
543
462
  if (number === 0) {
544
463
  return 0; // <- Note: To prevent -0
545
464
  }
@@ -554,11 +473,11 @@
554
473
  return Infinity;
555
474
  }
556
475
  if (value.includes('/')) {
557
- var _a = __read(value.split('/'), 2), numerator_ = _a[0], denominator_ = _a[1];
558
- var numerator = parseNumber(numerator_);
559
- var denominator = parseNumber(denominator_);
476
+ const [numerator_, denominator_] = value.split('/');
477
+ const numerator = parseNumber(numerator_);
478
+ const denominator = parseNumber(denominator_);
560
479
  if (denominator === 0) {
561
- throw new ParseError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
480
+ throw new ParseError(`Unable to parse number from "${originalValue}" because denominator is zero`);
562
481
  }
563
482
  return numerator / denominator;
564
483
  }
@@ -566,15 +485,15 @@
566
485
  return 0;
567
486
  }
568
487
  if (value.includes('E')) {
569
- var _b = __read(value.split('E'), 2), significand = _b[0], exponent = _b[1];
570
- return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
488
+ const [significand, exponent] = value.split('E');
489
+ return parseNumber(significand) * 10 ** parseNumber(exponent);
571
490
  }
572
491
  if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
573
- throw new ParseError("Unable to parse number from \"".concat(originalValue, "\""));
492
+ throw new ParseError(`Unable to parse number from "${originalValue}"`);
574
493
  }
575
- var num = parseFloat(value);
494
+ const num = parseFloat(value);
576
495
  if (isNaN(num)) {
577
- throw new ParseError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
496
+ throw new ParseError(`Unexpected NaN when parsing number from "${originalValue}"`);
578
497
  }
579
498
  return num;
580
499
  }
@@ -589,7 +508,7 @@
589
508
  * @see `documentationUrl` for more details
590
509
  * @public exported from `@promptbook/editable`
591
510
  */
592
- var expectCommandParser = {
511
+ const expectCommandParser = {
593
512
  /**
594
513
  * Name of the command
595
514
  */
@@ -602,7 +521,10 @@
602
521
  /**
603
522
  * Description of the FORMAT command
604
523
  */
605
- description: spaceTrim__default["default"]("\n Expect command describes the desired output of the task *(after post-processing)*\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
524
+ description: spaceTrim__default["default"](`
525
+ Expect command describes the desired output of the task *(after post-processing)*
526
+ It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
527
+ `),
606
528
  /**
607
529
  * Link to documentation
608
530
  */
@@ -620,12 +542,11 @@
620
542
  /**
621
543
  * Parses the FORMAT command
622
544
  */
623
- parse: function (input) {
624
- var e_1, _a;
625
- var args = input.args;
545
+ parse(input) {
546
+ const { args } = input;
626
547
  try {
627
- var sign = void 0;
628
- var signRaw = args.shift();
548
+ let sign;
549
+ const signRaw = args.shift();
629
550
  if (/^exact/i.test(signRaw)) {
630
551
  sign = 'EXACTLY';
631
552
  }
@@ -636,59 +557,50 @@
636
557
  sign = 'MAXIMUM';
637
558
  }
638
559
  else {
639
- throw new ParseError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
560
+ throw new ParseError(`Invalid sign "${signRaw}", expected EXACTLY, MIN or MAX`);
640
561
  }
641
- var amountRaw = args.shift();
642
- var amount = parseNumber(amountRaw);
562
+ const amountRaw = args.shift();
563
+ const amount = parseNumber(amountRaw);
643
564
  if (amount < 0) {
644
565
  throw new ParseError('Amount must be positive number or zero');
645
566
  }
646
567
  if (amount !== Math.floor(amount)) {
647
568
  throw new ParseError('Amount must be whole number');
648
569
  }
649
- var unitRaw = args.shift();
650
- var unit = undefined;
651
- try {
652
- for (var EXPECTATION_UNITS_1 = __values(EXPECTATION_UNITS), EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next(); !EXPECTATION_UNITS_1_1.done; EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next()) {
653
- var existingUnit = EXPECTATION_UNITS_1_1.value;
654
- var existingUnitText = existingUnit;
655
- existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
656
- if (existingUnitText === 'CHARACTER') {
657
- existingUnitText = 'CHAR';
658
- }
659
- if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
660
- new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
661
- if (unit !== undefined) {
662
- throw new ParseError("Ambiguous unit \"".concat(unitRaw, "\""));
663
- }
664
- unit = existingUnit;
665
- }
570
+ const unitRaw = args.shift();
571
+ let unit = undefined;
572
+ for (const existingUnit of EXPECTATION_UNITS) {
573
+ let existingUnitText = existingUnit;
574
+ existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
575
+ if (existingUnitText === 'CHARACTER') {
576
+ existingUnitText = 'CHAR';
666
577
  }
667
- }
668
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
669
- finally {
670
- try {
671
- if (EXPECTATION_UNITS_1_1 && !EXPECTATION_UNITS_1_1.done && (_a = EXPECTATION_UNITS_1.return)) _a.call(EXPECTATION_UNITS_1);
578
+ if (new RegExp(`^${existingUnitText.toLowerCase()}`).test(unitRaw.toLowerCase()) ||
579
+ new RegExp(`^${unitRaw.toLowerCase()}`).test(existingUnitText.toLowerCase())) {
580
+ if (unit !== undefined) {
581
+ throw new ParseError(`Ambiguous unit "${unitRaw}"`);
582
+ }
583
+ unit = existingUnit;
672
584
  }
673
- finally { if (e_1) throw e_1.error; }
674
585
  }
675
586
  if (unit === undefined) {
676
- throw new ParseError("Invalid unit \"".concat(unitRaw, "\""));
587
+ throw new ParseError(`Invalid unit "${unitRaw}"`);
677
588
  }
678
589
  return {
679
590
  type: 'EXPECT',
680
- sign: sign,
681
- unit: unit,
682
- amount: amount,
591
+ sign,
592
+ unit,
593
+ amount,
683
594
  };
684
595
  }
685
596
  catch (error) {
686
597
  if (!(error instanceof Error)) {
687
598
  throw error;
688
599
  }
689
- throw new ParseError(spaceTrim__default["default"](function (block) {
690
- return "\n Invalid FORMAT command\n ".concat(block(error.message), ":\n ");
691
- }));
600
+ throw new ParseError(spaceTrim__default["default"]((block) => `
601
+ Invalid FORMAT command
602
+ ${block(error.message)}:
603
+ `));
692
604
  }
693
605
  },
694
606
  /**
@@ -696,20 +608,20 @@
696
608
  *
697
609
  * Note: `$` is used to indicate that this function mutates given `taskJson`
698
610
  */
699
- $applyToTaskJson: function (command, $taskJson) {
611
+ $applyToTaskJson(command, $taskJson) {
700
612
  // eslint-disable-next-line no-case-declarations
701
- var unit = command.unit.toLowerCase();
613
+ const unit = command.unit.toLowerCase();
702
614
  $taskJson.expectations = $taskJson.expectations || {};
703
615
  $taskJson.expectations[unit] = $taskJson.expectations[unit] || {};
704
616
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
705
617
  if ($taskJson.expectations[unit].min !== undefined) {
706
- throw new ParseError("Already defined minumum ".concat($taskJson.expectations[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
618
+ throw new ParseError(`Already defined minumum ${$taskJson.expectations[unit].min} ${command.unit.toLowerCase()}, now trying to redefine it to ${command.amount}`);
707
619
  }
708
620
  $taskJson.expectations[unit].min = command.amount;
709
621
  } /* not else */
710
622
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
711
623
  if ($taskJson.expectations[unit].max !== undefined) {
712
- throw new ParseError("Already defined maximum ".concat($taskJson.expectations[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
624
+ throw new ParseError(`Already defined maximum ${$taskJson.expectations[unit].max} ${command.unit.toLowerCase()}, now trying to redefine it to ${command.amount}`);
713
625
  }
714
626
  $taskJson.expectations[unit].max = command.amount;
715
627
  }
@@ -719,16 +631,16 @@
719
631
  *
720
632
  * Note: This is used in `pipelineJsonToString` utility
721
633
  */
722
- stringify: function (command) {
723
- return "---"; // <- TODO: [🛋] Implement
634
+ stringify(command) {
635
+ return `---`; // <- TODO: [🛋] Implement
724
636
  },
725
637
  /**
726
638
  * Reads the FORMAT command from the `TaskJson`
727
639
  *
728
640
  * Note: This is used in `pipelineJsonToString` utility
729
641
  */
730
- takeFromTaskJson: function ($taskJson) {
731
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
642
+ takeFromTaskJson($taskJson) {
643
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
732
644
  },
733
645
  };
734
646
 
@@ -740,40 +652,34 @@
740
652
  *
741
653
  * @public exported from `@promptbook/core`
742
654
  */
743
- var AbstractFormatError = /** @class */ (function (_super) {
744
- __extends(AbstractFormatError, _super);
655
+ class AbstractFormatError extends Error {
745
656
  // Note: To allow instanceof do not put here error `name`
746
657
  // public readonly name = 'AbstractFormatError';
747
- function AbstractFormatError(message) {
748
- var _this = _super.call(this, message) || this;
749
- Object.setPrototypeOf(_this, AbstractFormatError.prototype);
750
- return _this;
658
+ constructor(message) {
659
+ super(message);
660
+ Object.setPrototypeOf(this, AbstractFormatError.prototype);
751
661
  }
752
- return AbstractFormatError;
753
- }(Error));
662
+ }
754
663
 
755
664
  /**
756
665
  * This error indicates problem with parsing of CSV
757
666
  *
758
667
  * @public exported from `@promptbook/core`
759
668
  */
760
- var CsvFormatError = /** @class */ (function (_super) {
761
- __extends(CsvFormatError, _super);
762
- function CsvFormatError(message) {
763
- var _this = _super.call(this, message) || this;
764
- _this.name = 'CsvFormatError';
765
- Object.setPrototypeOf(_this, CsvFormatError.prototype);
766
- return _this;
669
+ class CsvFormatError extends AbstractFormatError {
670
+ constructor(message) {
671
+ super(message);
672
+ this.name = 'CsvFormatError';
673
+ Object.setPrototypeOf(this, CsvFormatError.prototype);
767
674
  }
768
- return CsvFormatError;
769
- }(AbstractFormatError));
675
+ }
770
676
 
771
677
  /**
772
678
  * @@@
773
679
  *
774
680
  * @public exported from `@promptbook/core`
775
681
  */
776
- var MANDATORY_CSV_SETTINGS = Object.freeze({
682
+ const MANDATORY_CSV_SETTINGS = Object.freeze({
777
683
  header: true,
778
684
  // encoding: 'utf-8',
779
685
  });
@@ -784,92 +690,76 @@
784
690
  * @public exported from `@promptbook/core`
785
691
  * <- TODO: [🏢] Export from package `@promptbook/csv`
786
692
  */
787
- var CsvFormatDefinition = {
693
+ const CsvFormatDefinition = {
788
694
  formatName: 'CSV',
789
695
  aliases: ['SPREADSHEET', 'TABLE'],
790
- isValid: function (value, settings, schema) {
696
+ isValid(value, settings, schema) {
791
697
  return true;
792
698
  },
793
- canBeValid: function (partialValue, settings, schema) {
699
+ canBeValid(partialValue, settings, schema) {
794
700
  return true;
795
701
  },
796
- heal: function (value, settings, schema) {
702
+ heal(value, settings, schema) {
797
703
  throw new Error('Not implemented');
798
704
  },
799
705
  subvalueDefinitions: [
800
706
  {
801
707
  subvalueName: 'ROW',
802
- mapValues: function (value, outputParameterName, settings, mapCallback) {
803
- return __awaiter(this, void 0, void 0, function () {
804
- var csv, mappedData;
805
- var _this = this;
806
- return __generator(this, function (_a) {
807
- switch (_a.label) {
808
- case 0:
809
- csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
810
- if (csv.errors.length !== 0) {
811
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
812
- }
813
- return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
814
- var _a, _b;
815
- var _c;
816
- return __generator(this, function (_d) {
817
- switch (_d.label) {
818
- case 0:
819
- if (row[outputParameterName]) {
820
- throw new CsvFormatError("Can not overwrite existing column \"".concat(outputParameterName, "\" in CSV row"));
821
- }
822
- _a = [__assign({}, row)];
823
- _c = {};
824
- _b = outputParameterName;
825
- return [4 /*yield*/, mapCallback(row, index)];
826
- case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c[_b] = _d.sent(), _c)]))];
827
- }
828
- });
829
- }); }))];
830
- case 1:
831
- mappedData = _a.sent();
832
- return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
833
- }
834
- });
835
- });
708
+ async mapValues(value, outputParameterName, settings, mapCallback) {
709
+ // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
710
+ const csv = papaparse.parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
711
+ if (csv.errors.length !== 0) {
712
+ throw new CsvFormatError(spaceTrim__default["default"]((block) => `
713
+ CSV parsing error
714
+
715
+ Error(s) from CSV parsing:
716
+ ${block(csv.errors.map((error) => error.message).join('\n\n'))}
717
+
718
+ The CSV setings:
719
+ ${block(JSON.stringify({ ...settings, ...MANDATORY_CSV_SETTINGS }, null, 2))}
720
+
721
+ The CSV data:
722
+ ${block(value)}
723
+ `));
724
+ }
725
+ const mappedData = await Promise.all(csv.data.map(async (row, index) => {
726
+ if (row[outputParameterName]) {
727
+ throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
728
+ }
729
+ return {
730
+ ...row,
731
+ [outputParameterName]: await mapCallback(row, index),
732
+ };
733
+ }));
734
+ return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
836
735
  },
837
736
  },
838
737
  {
839
738
  subvalueName: 'CELL',
840
- mapValues: function (value, outputParameterName, settings, mapCallback) {
841
- return __awaiter(this, void 0, void 0, function () {
842
- var csv, mappedData;
843
- var _this = this;
844
- return __generator(this, function (_a) {
845
- switch (_a.label) {
846
- case 0:
847
- csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
848
- if (csv.errors.length !== 0) {
849
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
850
- }
851
- return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
852
- var _this = this;
853
- return __generator(this, function (_a) {
854
- return [2 /*return*/, /* not await */ Promise.all(Object.entries(row).map(function (_a, columnIndex) {
855
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
856
- return __awaiter(_this, void 0, void 0, function () {
857
- var index;
858
- var _c;
859
- return __generator(this, function (_d) {
860
- index = rowIndex * Object.keys(row).length + columnIndex;
861
- return [2 /*return*/, /* not await */ mapCallback((_c = {}, _c[key] = value, _c), index)];
862
- });
863
- });
864
- }))];
865
- });
866
- }); }))];
867
- case 1:
868
- mappedData = _a.sent();
869
- return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
870
- }
871
- });
872
- });
739
+ async mapValues(value, outputParameterName, settings, mapCallback) {
740
+ // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
741
+ const csv = papaparse.parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
742
+ if (csv.errors.length !== 0) {
743
+ throw new CsvFormatError(spaceTrim__default["default"]((block) => `
744
+ CSV parsing error
745
+
746
+ Error(s) from CSV parsing:
747
+ ${block(csv.errors.map((error) => error.message).join('\n\n'))}
748
+
749
+ The CSV setings:
750
+ ${block(JSON.stringify({ ...settings, ...MANDATORY_CSV_SETTINGS }, null, 2))}
751
+
752
+ The CSV data:
753
+ ${block(value)}
754
+ `));
755
+ }
756
+ const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
757
+ return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
758
+ const index = rowIndex * Object.keys(row).length + columnIndex;
759
+ return /* not await */ mapCallback({ [key]: value }, index);
760
+ }));
761
+ }));
762
+ return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
873
763
  },
874
764
  },
875
765
  ],
@@ -908,16 +798,16 @@
908
798
  *
909
799
  * @private still in development [🏢]
910
800
  */
911
- var JsonFormatDefinition = {
801
+ const JsonFormatDefinition = {
912
802
  formatName: 'JSON',
913
803
  mimeType: 'application/json',
914
- isValid: function (value, settings, schema) {
804
+ isValid(value, settings, schema) {
915
805
  return isValidJsonString(value);
916
806
  },
917
- canBeValid: function (partialValue, settings, schema) {
807
+ canBeValid(partialValue, settings, schema) {
918
808
  return true;
919
809
  },
920
- heal: function (value, settings, schema) {
810
+ heal(value, settings, schema) {
921
811
  throw new Error('Not implemented');
922
812
  },
923
813
  subvalueDefinitions: [],
@@ -941,48 +831,37 @@
941
831
  *
942
832
  * @public exported from `@promptbook/core`
943
833
  */
944
- var TextFormatDefinition = {
834
+ const TextFormatDefinition = {
945
835
  formatName: 'TEXT',
946
- isValid: function (value) {
836
+ isValid(value) {
947
837
  return typeof value === 'string';
948
838
  },
949
- canBeValid: function (partialValue) {
839
+ canBeValid(partialValue) {
950
840
  return typeof partialValue === 'string';
951
841
  },
952
- heal: function () {
842
+ heal() {
953
843
  throw new UnexpectedError('It does not make sense to call `TextFormatDefinition.heal`');
954
844
  },
955
845
  subvalueDefinitions: [
956
846
  {
957
847
  subvalueName: 'LINE',
958
- mapValues: function (value, outputParameterName, settings, mapCallback) {
959
- return __awaiter(this, void 0, void 0, function () {
960
- var lines, mappedLines;
961
- return __generator(this, function (_a) {
962
- switch (_a.label) {
963
- case 0:
964
- lines = value.split('\n');
965
- return [4 /*yield*/, Promise.all(lines.map(function (lineContent, lineNumber) {
966
- // TODO: [🧠] Maybe option to skip empty line
967
- /* not await */ return mapCallback({
968
- lineContent: lineContent,
969
- // TODO: [🧠] Maybe also put here `lineNumber`
970
- }, lineNumber);
971
- }))];
972
- case 1:
973
- mappedLines = _a.sent();
974
- return [2 /*return*/, mappedLines.join('\n')];
975
- }
976
- });
977
- });
848
+ async mapValues(value, outputParameterName, settings, mapCallback) {
849
+ const lines = value.split('\n');
850
+ const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
851
+ // TODO: [🧠] Maybe option to skip empty line
852
+ /* not await */ mapCallback({
853
+ lineContent,
854
+ // TODO: [🧠] Maybe also put here `lineNumber`
855
+ }, lineNumber)));
856
+ return mappedLines.join('\n');
978
857
  },
979
858
  },
980
- // <- TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
859
+ // <- TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
981
860
  ],
982
861
  };
983
862
  /**
984
863
  * TODO: [1] Make type for XML Text and Schema
985
- * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
864
+ * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
986
865
  * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
987
866
  * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
988
867
  * TODO: [🍓] In `TextFormatDefinition` implement `heal
@@ -995,16 +874,16 @@
995
874
  *
996
875
  * @private still in development [🏢]
997
876
  */
998
- var XmlFormatDefinition = {
877
+ const XmlFormatDefinition = {
999
878
  formatName: 'XML',
1000
879
  mimeType: 'application/xml',
1001
- isValid: function (value, settings, schema) {
880
+ isValid(value, settings, schema) {
1002
881
  return true;
1003
882
  },
1004
- canBeValid: function (partialValue, settings, schema) {
883
+ canBeValid(partialValue, settings, schema) {
1005
884
  return true;
1006
885
  },
1007
- heal: function (value, settings, schema) {
886
+ heal(value, settings, schema) {
1008
887
  throw new Error('Not implemented');
1009
888
  },
1010
889
  subvalueDefinitions: [],
@@ -1026,7 +905,7 @@
1026
905
  *
1027
906
  * @private internal index of `...` <- TODO [🏢]
1028
907
  */
1029
- var FORMAT_DEFINITIONS = [
908
+ const FORMAT_DEFINITIONS = [
1030
909
  JsonFormatDefinition,
1031
910
  XmlFormatDefinition,
1032
911
  TextFormatDefinition,
@@ -1046,46 +925,35 @@
1046
925
  * @public exported from `@promptbook/utils`
1047
926
  */
1048
927
  function normalizeTo_SCREAMING_CASE(text) {
1049
- var e_1, _a;
1050
- var charType;
1051
- var lastCharType = 'OTHER';
1052
- var normalizedName = '';
1053
- try {
1054
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
1055
- var char = text_1_1.value;
1056
- var normalizedChar = void 0;
1057
- if (/^[a-z]$/.test(char)) {
1058
- charType = 'LOWERCASE';
1059
- normalizedChar = char.toUpperCase();
1060
- }
1061
- else if (/^[A-Z]$/.test(char)) {
1062
- charType = 'UPPERCASE';
1063
- normalizedChar = char;
1064
- }
1065
- else if (/^[0-9]$/.test(char)) {
1066
- charType = 'NUMBER';
1067
- normalizedChar = char;
1068
- }
1069
- else {
1070
- charType = 'OTHER';
1071
- normalizedChar = '_';
1072
- }
1073
- if (charType !== lastCharType &&
1074
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
1075
- !(lastCharType === 'NUMBER') &&
1076
- !(charType === 'NUMBER')) {
1077
- normalizedName += '_';
1078
- }
1079
- normalizedName += normalizedChar;
1080
- lastCharType = charType;
928
+ let charType;
929
+ let lastCharType = 'OTHER';
930
+ let normalizedName = '';
931
+ for (const char of text) {
932
+ let normalizedChar;
933
+ if (/^[a-z]$/.test(char)) {
934
+ charType = 'LOWERCASE';
935
+ normalizedChar = char.toUpperCase();
1081
936
  }
1082
- }
1083
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1084
- finally {
1085
- try {
1086
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
937
+ else if (/^[A-Z]$/.test(char)) {
938
+ charType = 'UPPERCASE';
939
+ normalizedChar = char;
1087
940
  }
1088
- finally { if (e_1) throw e_1.error; }
941
+ else if (/^[0-9]$/.test(char)) {
942
+ charType = 'NUMBER';
943
+ normalizedChar = char;
944
+ }
945
+ else {
946
+ charType = 'OTHER';
947
+ normalizedChar = '_';
948
+ }
949
+ if (charType !== lastCharType &&
950
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
951
+ !(lastCharType === 'NUMBER') &&
952
+ !(charType === 'NUMBER')) {
953
+ normalizedName += '_';
954
+ }
955
+ normalizedName += normalizedChar;
956
+ lastCharType = charType;
1089
957
  }
1090
958
  normalizedName = normalizedName.replace(/_+/g, '_');
1091
959
  normalizedName = normalizedName.replace(/_?\/_?/g, '/');
@@ -1109,8 +977,11 @@
1109
977
  * @public exported from `@promptbook/utils`
1110
978
  */
1111
979
  function orderJson(options) {
1112
- var value = options.value, order = options.order;
1113
- var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
980
+ const { value, order } = options;
981
+ const orderedValue = {
982
+ ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
983
+ ...value,
984
+ };
1114
985
  return orderedValue;
1115
986
  }
1116
987
 
@@ -1124,26 +995,15 @@
1124
995
  * @public exported from `@promptbook/utils`
1125
996
  */
1126
997
  function $deepFreeze(objectValue) {
1127
- var e_1, _a;
1128
998
  if (Array.isArray(objectValue)) {
1129
- return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
999
+ return Object.freeze(objectValue.map((item) => $deepFreeze(item)));
1130
1000
  }
1131
- var propertyNames = Object.getOwnPropertyNames(objectValue);
1132
- try {
1133
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
1134
- var propertyName = propertyNames_1_1.value;
1135
- var value = objectValue[propertyName];
1136
- if (value && typeof value === 'object') {
1137
- $deepFreeze(value);
1138
- }
1139
- }
1140
- }
1141
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1142
- finally {
1143
- try {
1144
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
1001
+ const propertyNames = Object.getOwnPropertyNames(objectValue);
1002
+ for (const propertyName of propertyNames) {
1003
+ const value = objectValue[propertyName];
1004
+ if (value && typeof value === 'object') {
1005
+ $deepFreeze(value);
1145
1006
  }
1146
- finally { if (e_1) throw e_1.error; }
1147
1007
  }
1148
1008
  Object.freeze(objectValue);
1149
1009
  return objectValue;
@@ -1173,10 +1033,9 @@
1173
1033
  * @public exported from `@promptbook/utils`
1174
1034
  */
1175
1035
  function checkSerializableAsJson(options) {
1176
- var e_1, _a;
1177
- var value = options.value, name = options.name, message = options.message;
1036
+ const { value, name, message } = options;
1178
1037
  if (value === undefined) {
1179
- throw new UnexpectedError("".concat(name, " is undefined"));
1038
+ throw new UnexpectedError(`${name} is undefined`);
1180
1039
  }
1181
1040
  else if (value === null) {
1182
1041
  return;
@@ -1191,49 +1050,54 @@
1191
1050
  return;
1192
1051
  }
1193
1052
  else if (typeof value === 'symbol') {
1194
- throw new UnexpectedError("".concat(name, " is symbol"));
1053
+ throw new UnexpectedError(`${name} is symbol`);
1195
1054
  }
1196
1055
  else if (typeof value === 'function') {
1197
- throw new UnexpectedError("".concat(name, " is function"));
1056
+ throw new UnexpectedError(`${name} is function`);
1198
1057
  }
1199
1058
  else if (typeof value === 'object' && Array.isArray(value)) {
1200
- for (var i = 0; i < value.length; i++) {
1201
- checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
1059
+ for (let i = 0; i < value.length; i++) {
1060
+ checkSerializableAsJson({ name: `${name}[${i}]`, value: value[i], message });
1202
1061
  }
1203
1062
  }
1204
1063
  else if (typeof value === 'object') {
1205
1064
  if (value instanceof Date) {
1206
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
1065
+ throw new UnexpectedError(spaceTrim__default["default"]((block) => `
1066
+ \`${name}\` is Date
1067
+
1068
+ Use \`string_date_iso8601\` instead
1069
+
1070
+ Additional message for \`${name}\`:
1071
+ ${block(message || '(nothing)')}
1072
+ `));
1207
1073
  }
1208
1074
  else if (value instanceof Map) {
1209
- throw new UnexpectedError("".concat(name, " is Map"));
1075
+ throw new UnexpectedError(`${name} is Map`);
1210
1076
  }
1211
1077
  else if (value instanceof Set) {
1212
- throw new UnexpectedError("".concat(name, " is Set"));
1078
+ throw new UnexpectedError(`${name} is Set`);
1213
1079
  }
1214
1080
  else if (value instanceof RegExp) {
1215
- throw new UnexpectedError("".concat(name, " is RegExp"));
1081
+ throw new UnexpectedError(`${name} is RegExp`);
1216
1082
  }
1217
1083
  else if (value instanceof Error) {
1218
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
1084
+ throw new UnexpectedError(spaceTrim__default["default"]((block) => `
1085
+ \`${name}\` is unserialized Error
1086
+
1087
+ Use function \`serializeError\`
1088
+
1089
+ Additional message for \`${name}\`:
1090
+ ${block(message || '(nothing)')}
1091
+
1092
+ `));
1219
1093
  }
1220
1094
  else {
1221
- try {
1222
- for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
1223
- var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
1224
- if (subValue === undefined) {
1225
- // Note: undefined in object is serializable - it is just omited
1226
- continue;
1227
- }
1228
- checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
1095
+ for (const [subName, subValue] of Object.entries(value)) {
1096
+ if (subValue === undefined) {
1097
+ // Note: undefined in object is serializable - it is just omited
1098
+ continue;
1229
1099
  }
1230
- }
1231
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1232
- finally {
1233
- try {
1234
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1235
- }
1236
- finally { if (e_1) throw e_1.error; }
1100
+ checkSerializableAsJson({ name: `${name}.${subName}`, value: subValue, message });
1237
1101
  }
1238
1102
  try {
1239
1103
  JSON.stringify(value); // <- TODO: [0]
@@ -1242,7 +1106,14 @@
1242
1106
  if (!(error instanceof Error)) {
1243
1107
  throw error;
1244
1108
  }
1245
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
1109
+ throw new UnexpectedError(spaceTrim__default["default"]((block) => `
1110
+ \`${name}\` is not serializable
1111
+
1112
+ ${block(error.stack || error.message)}
1113
+
1114
+ Additional message for \`${name}\`:
1115
+ ${block(message || '(nothing)')}
1116
+ `));
1246
1117
  }
1247
1118
  /*
1248
1119
  TODO: [0] Is there some more elegant way to check circular references?
@@ -1267,7 +1138,12 @@
1267
1138
  }
1268
1139
  }
1269
1140
  else {
1270
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
1141
+ throw new UnexpectedError(spaceTrim__default["default"]((block) => `
1142
+ \`${name}\` is unknown type
1143
+
1144
+ Additional message for \`${name}\`:
1145
+ ${block(message || '(nothing)')}
1146
+ `));
1271
1147
  }
1272
1148
  }
1273
1149
  /**
@@ -1313,9 +1189,9 @@
1313
1189
  * @public exported from `@promptbook/utils`
1314
1190
  */
1315
1191
  function exportJson(options) {
1316
- var name = options.name, value = options.value, order = options.order, message = options.message;
1317
- checkSerializableAsJson({ name: name, value: value, message: message });
1318
- var orderedValue =
1192
+ const { name, value, order, message } = options;
1193
+ checkSerializableAsJson({ name, value, message });
1194
+ const orderedValue =
1319
1195
  // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
1320
1196
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1321
1197
  // @ts-ignore
@@ -1338,15 +1214,15 @@
1338
1214
  *
1339
1215
  * @private within the repository
1340
1216
  */
1341
- var REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
1217
+ const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
1342
1218
  /**
1343
1219
  * The names of the parameters that are reserved for special purposes
1344
1220
  *
1345
1221
  * @public exported from `@promptbook/core`
1346
1222
  */
1347
- var RESERVED_PARAMETER_NAMES = exportJson({
1223
+ const RESERVED_PARAMETER_NAMES = exportJson({
1348
1224
  name: 'RESERVED_PARAMETER_NAMES',
1349
- message: "The names of the parameters that are reserved for special purposes",
1225
+ message: `The names of the parameters that are reserved for special purposes`,
1350
1226
  value: [
1351
1227
  'content',
1352
1228
  'context',
@@ -1373,53 +1249,41 @@
1373
1249
  * @example 'iLovePromptbook'
1374
1250
  * @public exported from `@promptbook/utils`
1375
1251
  */
1376
- function normalizeTo_camelCase(text, _isFirstLetterCapital) {
1377
- var e_1, _a;
1378
- if (_isFirstLetterCapital === void 0) { _isFirstLetterCapital = false; }
1379
- var charType;
1380
- var lastCharType = null;
1381
- var normalizedName = '';
1382
- try {
1383
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
1384
- var char = text_1_1.value;
1385
- var normalizedChar = void 0;
1386
- if (/^[a-z]$/.test(char)) {
1387
- charType = 'LOWERCASE';
1388
- normalizedChar = char;
1389
- }
1390
- else if (/^[A-Z]$/.test(char)) {
1391
- charType = 'UPPERCASE';
1392
- normalizedChar = char.toLowerCase();
1393
- }
1394
- else if (/^[0-9]$/.test(char)) {
1395
- charType = 'NUMBER';
1396
- normalizedChar = char;
1397
- }
1398
- else {
1399
- charType = 'OTHER';
1400
- normalizedChar = '';
1401
- }
1402
- if (!lastCharType) {
1403
- if (_isFirstLetterCapital) {
1404
- normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
1405
- }
1406
- }
1407
- else if (charType !== lastCharType &&
1408
- !(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
1409
- !(lastCharType === 'NUMBER') &&
1410
- !(charType === 'NUMBER')) {
1411
- normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
1252
+ function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
1253
+ let charType;
1254
+ let lastCharType = null;
1255
+ let normalizedName = '';
1256
+ for (const char of text) {
1257
+ let normalizedChar;
1258
+ if (/^[a-z]$/.test(char)) {
1259
+ charType = 'LOWERCASE';
1260
+ normalizedChar = char;
1261
+ }
1262
+ else if (/^[A-Z]$/.test(char)) {
1263
+ charType = 'UPPERCASE';
1264
+ normalizedChar = char.toLowerCase();
1265
+ }
1266
+ else if (/^[0-9]$/.test(char)) {
1267
+ charType = 'NUMBER';
1268
+ normalizedChar = char;
1269
+ }
1270
+ else {
1271
+ charType = 'OTHER';
1272
+ normalizedChar = '';
1273
+ }
1274
+ if (!lastCharType) {
1275
+ if (_isFirstLetterCapital) {
1276
+ normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
1412
1277
  }
1413
- normalizedName += normalizedChar;
1414
- lastCharType = charType;
1415
1278
  }
1416
- }
1417
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1418
- finally {
1419
- try {
1420
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
1279
+ else if (charType !== lastCharType &&
1280
+ !(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
1281
+ !(lastCharType === 'NUMBER') &&
1282
+ !(charType === 'NUMBER')) {
1283
+ normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
1421
1284
  }
1422
- finally { if (e_1) throw e_1.error; }
1285
+ normalizedName += normalizedChar;
1286
+ lastCharType = charType;
1423
1287
  }
1424
1288
  return normalizedName;
1425
1289
  }
@@ -1427,7 +1291,7 @@
1427
1291
  * TODO: [🌺] Use some intermediate util splitWords
1428
1292
  */
1429
1293
 
1430
- var defaultDiacriticsRemovalMap = [
1294
+ const defaultDiacriticsRemovalMap = [
1431
1295
  {
1432
1296
  base: 'A',
1433
1297
  letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
@@ -1646,12 +1510,12 @@
1646
1510
  *
1647
1511
  * @public exported from `@promptbook/utils`
1648
1512
  */
1649
- var DIACRITIC_VARIANTS_LETTERS = {};
1513
+ const DIACRITIC_VARIANTS_LETTERS = {};
1650
1514
  // tslint:disable-next-line: prefer-for-of
1651
- for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
1652
- var letters = defaultDiacriticsRemovalMap[i].letters;
1515
+ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
1516
+ const letters = defaultDiacriticsRemovalMap[i].letters;
1653
1517
  // tslint:disable-next-line: prefer-for-of
1654
- for (var j = 0; j < letters.length; j++) {
1518
+ for (let j = 0; j < letters.length; j++) {
1655
1519
  DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
1656
1520
  }
1657
1521
  }
@@ -1680,7 +1544,7 @@
1680
1544
  */
1681
1545
  function removeDiacritics(input) {
1682
1546
  /*eslint no-control-regex: "off"*/
1683
- return input.replace(/[^\u0000-\u007E]/g, function (a) {
1547
+ return input.replace(/[^\u0000-\u007E]/g, (a) => {
1684
1548
  return DIACRITIC_VARIANTS_LETTERS[a] || a;
1685
1549
  });
1686
1550
  }
@@ -1736,33 +1600,22 @@
1736
1600
  * @private within the repository
1737
1601
  */
1738
1602
  function validateParameterName(parameterName) {
1739
- var e_1, _a;
1740
- var rawParameterName = parameterName;
1741
- try {
1742
- for (var _b = __values([
1743
- ['`', '`'],
1744
- ['{', '}'],
1745
- ['[', ']'],
1746
- ['(', ')'],
1747
- ['<', '>'],
1748
- ]), _c = _b.next(); !_c.done; _c = _b.next()) {
1749
- var _d = __read(_c.value, 2), start = _d[0], end = _d[1];
1750
- if (parameterName.substring(0, 1) === start &&
1751
- parameterName.substring(parameterName.length - 1, parameterName.length) === end
1603
+ const rawParameterName = parameterName;
1604
+ for (const [start, end] of [
1605
+ ['`', '`'],
1606
+ ['{', '}'],
1607
+ ['[', ']'],
1608
+ ['(', ')'],
1609
+ ['<', '>'],
1610
+ ]) {
1611
+ if (parameterName.substring(0, 1) === start &&
1612
+ parameterName.substring(parameterName.length - 1, parameterName.length) === end
1613
+ // <- TODO: More universal that 1 character
1614
+ ) {
1615
+ parameterName = parameterName.substring(1, parameterName.length - 1);
1752
1616
  // <- TODO: More universal that 1 character
1753
- ) {
1754
- parameterName = parameterName.substring(1, parameterName.length - 1);
1755
- // <- TODO: More universal that 1 character
1756
- }
1757
1617
  }
1758
1618
  }
1759
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1760
- finally {
1761
- try {
1762
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1763
- }
1764
- finally { if (e_1) throw e_1.error; }
1765
- }
1766
1619
  // TODO: [🐠] Following try-catch block should be part of common validators logic
1767
1620
  try {
1768
1621
  /*
@@ -1772,10 +1625,10 @@
1772
1625
  }
1773
1626
  */
1774
1627
  if (parameterName.includes('.')) {
1775
- throw new ParseError("Parameter name cannot contain dots");
1628
+ throw new ParseError(`Parameter name cannot contain dots`);
1776
1629
  }
1777
1630
  if (parameterName.includes('/') || parameterName.includes('\\')) {
1778
- throw new ParseError("Parameter name cannot contain slashes");
1631
+ throw new ParseError(`Parameter name cannot contain slashes`);
1779
1632
  }
1780
1633
  if (parameterName.includes('(') ||
1781
1634
  parameterName.includes(')') ||
@@ -1783,24 +1636,29 @@
1783
1636
  parameterName.includes('}') ||
1784
1637
  parameterName.includes('[') ||
1785
1638
  parameterName.includes(']')) {
1786
- throw new ParseError("Parameter name cannot contain braces");
1639
+ throw new ParseError(`Parameter name cannot contain braces`);
1787
1640
  }
1788
1641
  parameterName = removeDiacritics(parameterName);
1789
1642
  parameterName = removeEmojis(parameterName);
1790
1643
  parameterName = removeQuotes(parameterName);
1791
1644
  parameterName = normalizeTo_camelCase(parameterName);
1792
1645
  if (parameterName === '') {
1793
- throw new ParseError("Parameter name cannot be empty");
1646
+ throw new ParseError(`Parameter name cannot be empty`);
1794
1647
  }
1795
1648
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
1796
- throw new ParseError("{".concat(parameterName, "} is a reserved parameter name"));
1649
+ throw new ParseError(`{${parameterName}} is a reserved parameter name`);
1797
1650
  }
1798
1651
  }
1799
1652
  catch (error) {
1800
1653
  if (!(error instanceof ParseError)) {
1801
1654
  throw error;
1802
1655
  }
1803
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n ".concat(block(error.message), "\n\n Tried to validate parameter name:\n ").concat(block(rawParameterName), "\n "); }));
1656
+ throw new ParseError(spaceTrim__default["default"]((block) => `
1657
+ ${block(error.message)}
1658
+
1659
+ Tried to validate parameter name:
1660
+ ${block(rawParameterName)}
1661
+ `));
1804
1662
  }
1805
1663
  return parameterName;
1806
1664
  }
@@ -1813,7 +1671,7 @@
1813
1671
  * @see `documentationUrl` for more details
1814
1672
  * @public exported from `@promptbook/editable`
1815
1673
  */
1816
- var foreachCommandParser = {
1674
+ const foreachCommandParser = {
1817
1675
  /**
1818
1676
  * Name of the command
1819
1677
  */
@@ -1830,7 +1688,7 @@
1830
1688
  /**
1831
1689
  * Description of the FOREACH command
1832
1690
  */
1833
- description: "@@",
1691
+ description: `@@`,
1834
1692
  /**
1835
1693
  * Link to documentation
1836
1694
  */
@@ -1848,58 +1706,64 @@
1848
1706
  /**
1849
1707
  * Parses the FOREACH command
1850
1708
  */
1851
- parse: function (input) {
1852
- var args = input.args;
1853
- var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
1854
- var subformatName = normalizeTo_SCREAMING_CASE(args[1] || '');
1855
- var parameterNameArg = args[2] || '';
1856
- var assignSign = args[3];
1857
- var formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
1858
- return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(formatName);
1859
- });
1709
+ parse(input) {
1710
+ const { args } = input;
1711
+ const formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
1712
+ const subformatName = normalizeTo_SCREAMING_CASE(args[1] || '');
1713
+ const parameterNameArg = args[2] || '';
1714
+ const assignSign = args[3];
1715
+ const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
1860
1716
  if (formatDefinition === undefined) {
1861
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unsupported format \"".concat(formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
1862
- .map(function (formatName) { return "- ".concat(formatName); })
1863
- .join('\n')), "\n "); }));
1717
+ throw new ParseError(spaceTrim__default["default"]((block) => `
1718
+ Unsupported format "${formatName}"
1719
+
1720
+ Available formats:
1721
+ ${block(FORMAT_DEFINITIONS.map((formatDefinition) => formatDefinition.formatName)
1722
+ .map((formatName) => `- ${formatName}`)
1723
+ .join('\n'))}
1724
+ `));
1864
1725
  // <- TODO: [🏢] List all supported format names
1865
1726
  }
1866
- var subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
1867
- return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(subformatName);
1868
- });
1727
+ const subvalueDefinition = formatDefinition.subvalueDefinitions.find((subvalueDefinition) => [subvalueDefinition.subvalueName, ...(subvalueDefinition.aliases || [])].includes(subformatName));
1869
1728
  if (subvalueDefinition === undefined) {
1870
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unsupported subformat name \"".concat(subformatName, "\" for format \"").concat(formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
1871
- .map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
1872
- .map(function (subvalueName) { return "- ".concat(subvalueName); })
1873
- .join('\n')), "\n "); }));
1729
+ throw new ParseError(spaceTrim__default["default"]((block) => `
1730
+ Unsupported subformat name "${subformatName}" for format "${formatName}"
1731
+
1732
+ Available subformat names for format "${formatDefinition.formatName}":
1733
+ ${block(formatDefinition.subvalueDefinitions
1734
+ .map((subvalueDefinition) => subvalueDefinition.subvalueName)
1735
+ .map((subvalueName) => `- ${subvalueName}`)
1736
+ .join('\n'))}
1737
+ `));
1874
1738
  // <- TODO: [🏢] List all supported subformat names for the format
1875
1739
  }
1876
1740
  if (assignSign !== '->') {
1877
- throw new ParseError("FOREACH command must have '->' to assign the value to the parameter");
1741
+ throw new ParseError(`FOREACH command must have '->' to assign the value to the parameter`);
1878
1742
  }
1879
- var parameterName = validateParameterName(parameterNameArg);
1880
- var outputSubparameterName = null;
1743
+ const parameterName = validateParameterName(parameterNameArg);
1744
+ let outputSubparameterName = null;
1881
1745
  // TODO: [4] DRY
1882
- var inputSubparameterNames = args
1746
+ const inputSubparameterNames = args
1883
1747
  .slice(4)
1884
- .map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
1885
- .filter(function (parameterName) { return !parameterName.includes('+'); })
1886
- .filter(function (parameterName) { return parameterName !== ''; })
1748
+ .map((parameterName) => parameterName.split(',').join(' ').trim())
1749
+ .filter((parameterName) => !parameterName.includes('+'))
1750
+ .filter((parameterName) => parameterName !== '')
1887
1751
  .map(validateParameterName);
1888
1752
  // TODO: [4] DRY
1889
- var outputSubparameterNames = args
1753
+ const outputSubparameterNames = args
1890
1754
  .slice(4)
1891
- .map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
1892
- .filter(function (parameterName) { return parameterName.includes('+'); })
1893
- .map(function (parameterName) { return parameterName.split('+').join(''); })
1755
+ .map((parameterName) => parameterName.split(',').join(' ').trim())
1756
+ .filter((parameterName) => parameterName.includes('+'))
1757
+ .map((parameterName) => parameterName.split('+').join(''))
1894
1758
  .map(validateParameterName);
1895
1759
  if (outputSubparameterNames.length === 1) {
1896
1760
  outputSubparameterName = outputSubparameterNames[0];
1897
1761
  }
1898
1762
  else if (outputSubparameterNames.length > 1) {
1899
- throw new ParseError("FOREACH command can not have more than one output subparameter");
1763
+ throw new ParseError(`FOREACH command can not have more than one output subparameter`);
1900
1764
  }
1901
1765
  if (inputSubparameterNames.length === 0) {
1902
- throw new ParseError("FOREACH command must have at least one input subparameter");
1766
+ throw new ParseError(`FOREACH command must have at least one input subparameter`);
1903
1767
  }
1904
1768
  if (outputSubparameterName === null) {
1905
1769
  // TODO: Following code should be unhardcoded from here and moved to the format definition
@@ -1910,16 +1774,22 @@
1910
1774
  outputSubparameterName = 'newLine';
1911
1775
  }
1912
1776
  else {
1913
- throw new ParseError(spaceTrim__default["default"]("\n FOREACH ".concat(formatName, " ").concat(subformatName, " must specify output subparameter\n\n Correct example:\n - FOREACH ").concat(formatName, " ").concat(subformatName, " {").concat(parameterName, "} -> {inputSubparameterName1}, {inputSubparameterName2}, +{outputSubparameterName}\n\n ")));
1777
+ throw new ParseError(spaceTrim__default["default"](`
1778
+ FOREACH ${formatName} ${subformatName} must specify output subparameter
1779
+
1780
+ Correct example:
1781
+ - FOREACH ${formatName} ${subformatName} {${parameterName}} -> {inputSubparameterName1}, {inputSubparameterName2}, +{outputSubparameterName}
1782
+
1783
+ `));
1914
1784
  }
1915
1785
  }
1916
1786
  return {
1917
1787
  type: 'FOREACH',
1918
- formatName: formatName,
1919
- subformatName: subformatName,
1920
- parameterName: parameterName,
1921
- inputSubparameterNames: inputSubparameterNames,
1922
- outputSubparameterName: outputSubparameterName,
1788
+ formatName,
1789
+ subformatName,
1790
+ parameterName,
1791
+ inputSubparameterNames,
1792
+ outputSubparameterName,
1923
1793
  };
1924
1794
  },
1925
1795
  /**
@@ -1927,16 +1797,16 @@
1927
1797
  *
1928
1798
  * Note: `$` is used to indicate that this function mutates given `taskJson`
1929
1799
  */
1930
- $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
1931
- var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
1800
+ $applyToTaskJson(command, $taskJson, $pipelineJson) {
1801
+ const { formatName, subformatName, parameterName, inputSubparameterNames, outputSubparameterName } = command;
1932
1802
  // TODO: [🍭] Detect double use
1933
1803
  // TODO: [🍭] Detect usage with JOKER and don't allow it
1934
1804
  $taskJson.foreach = {
1935
- formatName: formatName,
1936
- subformatName: subformatName,
1937
- parameterName: parameterName,
1938
- inputSubparameterNames: inputSubparameterNames,
1939
- outputSubparameterName: outputSubparameterName,
1805
+ formatName,
1806
+ subformatName,
1807
+ parameterName,
1808
+ inputSubparameterNames,
1809
+ outputSubparameterName,
1940
1810
  };
1941
1811
  // Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
1942
1812
  },
@@ -1945,16 +1815,16 @@
1945
1815
  *
1946
1816
  * Note: This is used in `pipelineJsonToString` utility
1947
1817
  */
1948
- stringify: function (command) {
1949
- return "---"; // <- TODO: [🛋] Implement
1818
+ stringify(command) {
1819
+ return `---`; // <- TODO: [🛋] Implement
1950
1820
  },
1951
1821
  /**
1952
1822
  * Reads the FOREACH command from the `TaskJson`
1953
1823
  *
1954
1824
  * Note: This is used in `pipelineJsonToString` utility
1955
1825
  */
1956
- takeFromTaskJson: function ($taskJson) {
1957
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
1826
+ takeFromTaskJson($taskJson) {
1827
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
1958
1828
  },
1959
1829
  };
1960
1830
  /**
@@ -1967,7 +1837,7 @@
1967
1837
  * @see `documentationUrl` for more details
1968
1838
  * @public exported from `@promptbook/editable`
1969
1839
  */
1970
- var formatCommandParser = {
1840
+ const formatCommandParser = {
1971
1841
  /**
1972
1842
  * Name of the command
1973
1843
  */
@@ -1980,7 +1850,10 @@
1980
1850
  /**
1981
1851
  * Description of the FORMAT command
1982
1852
  */
1983
- description: spaceTrim__default["default"]("\n Format command describes the desired output of the task (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
1853
+ description: spaceTrim__default["default"](`
1854
+ Format command describes the desired output of the task (after post-processing)
1855
+ It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
1856
+ `),
1984
1857
  /**
1985
1858
  * Link to documentation
1986
1859
  */
@@ -1992,10 +1865,10 @@
1992
1865
  /**
1993
1866
  * Parses the FORMAT command
1994
1867
  */
1995
- parse: function (input) {
1996
- var normalized = input.normalized;
1868
+ parse(input) {
1869
+ const { normalized } = input;
1997
1870
  if (!normalized.startsWith('FORMAT_JSON')) {
1998
- throw new ParseError("For now only JSON format is supported, in future we will support more formats");
1871
+ throw new ParseError(`For now only JSON format is supported, in future we will support more formats`);
1999
1872
  }
2000
1873
  return {
2001
1874
  type: 'FORMAT',
@@ -2009,9 +1882,10 @@
2009
1882
  *
2010
1883
  * Note: `$` is used to indicate that this function mutates given `taskJson`
2011
1884
  */
2012
- $applyToTaskJson: function (command, $taskJson) {
1885
+ $applyToTaskJson(command, $taskJson) {
2013
1886
  if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
2014
- throw new ParseError("Format format is already defined to \"".concat($taskJson.format, "\".\n Now you try to redefine it by \"").concat(command.format, "\""));
1887
+ throw new ParseError(`Format format is already defined to "${$taskJson.format}".
1888
+ Now you try to redefine it by "${command.format}"`);
2015
1889
  }
2016
1890
  $taskJson.format = command.format;
2017
1891
  },
@@ -2020,16 +1894,16 @@
2020
1894
  *
2021
1895
  * Note: This is used in `pipelineJsonToString` utility
2022
1896
  */
2023
- stringify: function (command) {
2024
- return "---"; // <- TODO: [🛋] Implement
1897
+ stringify(command) {
1898
+ return `---`; // <- TODO: [🛋] Implement
2025
1899
  },
2026
1900
  /**
2027
1901
  * Reads the FORMAT command from the `TaskJson`
2028
1902
  *
2029
1903
  * Note: This is used in `pipelineJsonToString` utility
2030
1904
  */
2031
- takeFromTaskJson: function ($taskJson) {
2032
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
1905
+ takeFromTaskJson($taskJson) {
1906
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2033
1907
  },
2034
1908
  };
2035
1909
 
@@ -2038,31 +1912,31 @@
2038
1912
  *
2039
1913
  * @public exported from `@promptbook/core`
2040
1914
  */
2041
- var ChatbotFormfactorDefinition = {
1915
+ const ChatbotFormfactorDefinition = {
2042
1916
  name: 'CHATBOT',
2043
1917
  aliasNames: ['CHAT'],
2044
- description: "@@@",
2045
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
1918
+ description: `@@@`,
1919
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/174`,
2046
1920
  pipelineInterface: {
2047
1921
  inputParameters: [
2048
1922
  {
2049
1923
  name: 'previousTitle',
2050
- description: "Previous title of the conversation",
1924
+ description: `Previous title of the conversation`,
2051
1925
  isInput: true,
2052
1926
  isOutput: false,
2053
1927
  },
2054
1928
  {
2055
1929
  name: 'previousConversationSummary',
2056
- description: "Previous conversation summary",
1930
+ description: `Previous conversation summary`,
2057
1931
  isInput: true,
2058
1932
  isOutput: false,
2059
1933
  },
2060
- { name: 'userMessage', description: "User message", isInput: true, isOutput: false },
1934
+ { name: 'userMessage', description: `User message`, isInput: true, isOutput: false },
2061
1935
  ],
2062
1936
  outputParameters: [
2063
- { name: 'title', description: "Title of the conversation", isInput: false, isOutput: true },
2064
- { name: 'conversationSummary', description: "Summary of the conversation", isInput: false, isOutput: true },
2065
- { name: 'chatbotResponse', description: "Chatbot response", isInput: false, isOutput: true },
1937
+ { name: 'title', description: `Title of the conversation`, isInput: false, isOutput: true },
1938
+ { name: 'conversationSummary', description: `Summary of the conversation`, isInput: false, isOutput: true },
1939
+ { name: 'chatbotResponse', description: `Chatbot response`, isInput: false, isOutput: true },
2066
1940
  ],
2067
1941
  },
2068
1942
  };
@@ -2072,15 +1946,15 @@
2072
1946
  *
2073
1947
  * @public exported from `@promptbook/core`
2074
1948
  */
2075
- var GeneratorFormfactorDefinition = {
1949
+ const GeneratorFormfactorDefinition = {
2076
1950
  name: 'GENERATOR',
2077
- description: "Generates any kind (in HTML with possible scripts and css format) of content from input message",
2078
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
1951
+ description: `Generates any kind (in HTML with possible scripts and css format) of content from input message`,
1952
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/184`,
2079
1953
  pipelineInterface: {
2080
1954
  inputParameters: [
2081
1955
  {
2082
1956
  name: 'inputMessage',
2083
- description: "Input message to be image made from",
1957
+ description: `Input message to be image made from`,
2084
1958
  isInput: true,
2085
1959
  isOutput: false,
2086
1960
  },
@@ -2088,7 +1962,7 @@
2088
1962
  outputParameters: [
2089
1963
  {
2090
1964
  name: 'result',
2091
- description: "Result in HTML to be shown to user",
1965
+ description: `Result in HTML to be shown to user`,
2092
1966
  isInput: false,
2093
1967
  isOutput: true,
2094
1968
  },
@@ -2103,7 +1977,7 @@
2103
1977
  *
2104
1978
  * @public exported from `@promptbook/core`
2105
1979
  */
2106
- var GENERIC_PIPELINE_INTERFACE = {
1980
+ const GENERIC_PIPELINE_INTERFACE = {
2107
1981
  inputParameters: [],
2108
1982
  outputParameters: [],
2109
1983
  };
@@ -2116,10 +1990,10 @@
2116
1990
  *
2117
1991
  * @public exported from `@promptbook/core`
2118
1992
  */
2119
- var GenericFormfactorDefinition = {
1993
+ const GenericFormfactorDefinition = {
2120
1994
  name: 'GENERIC',
2121
- description: "@@@",
2122
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/173",
1995
+ description: `@@@`,
1996
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/173`,
2123
1997
  pipelineInterface: GENERIC_PIPELINE_INTERFACE,
2124
1998
  };
2125
1999
 
@@ -2128,15 +2002,15 @@
2128
2002
  *
2129
2003
  * @public exported from `@promptbook/core`
2130
2004
  */
2131
- var ImageGeneratorFormfactorDefinition = {
2005
+ const ImageGeneratorFormfactorDefinition = {
2132
2006
  name: 'IMAGE_GENERATOR',
2133
- description: "Generates prompt for image generation from input message",
2134
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
2007
+ description: `Generates prompt for image generation from input message`,
2008
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/184`,
2135
2009
  pipelineInterface: {
2136
2010
  inputParameters: [
2137
2011
  {
2138
2012
  name: 'inputMessage',
2139
- description: "Input message to be image made from",
2013
+ description: `Input message to be image made from`,
2140
2014
  isInput: true,
2141
2015
  isOutput: false,
2142
2016
  },
@@ -2144,7 +2018,7 @@
2144
2018
  outputParameters: [
2145
2019
  {
2146
2020
  name: 'prompt',
2147
- description: "Prompt to be used for image generation",
2021
+ description: `Prompt to be used for image generation`,
2148
2022
  isInput: false,
2149
2023
  isOutput: true,
2150
2024
  },
@@ -2157,10 +2031,10 @@
2157
2031
  *
2158
2032
  * @public exported from `@promptbook/core`
2159
2033
  */
2160
- var MatcherFormfactorDefinition = {
2034
+ const MatcherFormfactorDefinition = {
2161
2035
  name: 'EXPERIMENTAL_MATCHER',
2162
- description: "@@@",
2163
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
2036
+ description: `@@@`,
2037
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
2164
2038
  pipelineInterface: {
2165
2039
  inputParameters: [
2166
2040
  /* @@@ */
@@ -2182,16 +2056,16 @@
2182
2056
  *
2183
2057
  * @public exported from `@promptbook/core`
2184
2058
  */
2185
- var SheetsFormfactorDefinition = {
2059
+ const SheetsFormfactorDefinition = {
2186
2060
  name: 'SHEETS',
2187
2061
  aliasNames: ['SHEETS', 'SHEET'],
2188
- description: "@@@",
2189
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
2062
+ description: `@@@`,
2063
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
2190
2064
  pipelineInterface: {
2191
2065
  inputParameters: [
2192
2066
  {
2193
2067
  name: 'inputSheet',
2194
- description: "Input sheet to be processed as csv",
2068
+ description: `Input sheet to be processed as csv`,
2195
2069
  isInput: true,
2196
2070
  isOutput: false,
2197
2071
  },
@@ -2199,7 +2073,7 @@
2199
2073
  outputParameters: [
2200
2074
  {
2201
2075
  name: 'outputSheet',
2202
- description: "Output sheet as csv",
2076
+ description: `Output sheet as csv`,
2203
2077
  isInput: false,
2204
2078
  isOutput: true,
2205
2079
  },
@@ -2212,15 +2086,15 @@
2212
2086
  *
2213
2087
  * @public exported from `@promptbook/core`
2214
2088
  */
2215
- var TranslatorFormfactorDefinition = {
2089
+ const TranslatorFormfactorDefinition = {
2216
2090
  name: 'TRANSLATOR',
2217
- description: "@@@",
2218
- documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
2091
+ description: `@@@`,
2092
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
2219
2093
  pipelineInterface: {
2220
2094
  inputParameters: [
2221
2095
  {
2222
2096
  name: 'inputMessage',
2223
- description: "Input message to be translated",
2097
+ description: `Input message to be translated`,
2224
2098
  isInput: true,
2225
2099
  isOutput: false,
2226
2100
  },
@@ -2228,7 +2102,7 @@
2228
2102
  outputParameters: [
2229
2103
  {
2230
2104
  name: 'outputMessage',
2231
- description: "Translated output message",
2105
+ description: `Translated output message`,
2232
2106
  isInput: false,
2233
2107
  isOutput: true,
2234
2108
  },
@@ -2243,7 +2117,7 @@
2243
2117
  *
2244
2118
  * @public exported from `@promptbook/core`
2245
2119
  */
2246
- var FORMFACTOR_DEFINITIONS = [
2120
+ const FORMFACTOR_DEFINITIONS = [
2247
2121
  GenericFormfactorDefinition,
2248
2122
  ChatbotFormfactorDefinition,
2249
2123
  TranslatorFormfactorDefinition,
@@ -2264,7 +2138,7 @@
2264
2138
  * @see `documentationUrl` for more details
2265
2139
  * @public exported from `@promptbook/editable`
2266
2140
  */
2267
- var formfactorCommandParser = {
2141
+ const formfactorCommandParser = {
2268
2142
  /**
2269
2143
  * Name of the command
2270
2144
  */
@@ -2281,7 +2155,7 @@
2281
2155
  /**
2282
2156
  * Description of the FORMFACTOR command
2283
2157
  */
2284
- description: "@@",
2158
+ description: `@@`,
2285
2159
  /**
2286
2160
  * Link to documentation
2287
2161
  */
@@ -2293,20 +2167,20 @@
2293
2167
  /**
2294
2168
  * Parses the FORMFACTOR command
2295
2169
  */
2296
- parse: function (input) {
2297
- var args = input.args;
2170
+ parse(input) {
2171
+ const { args } = input;
2298
2172
  if (args.length !== 1) {
2299
- throw new ParseError("FORMFACTOR command requires exactly one argument");
2173
+ throw new ParseError(`FORMFACTOR command requires exactly one argument`);
2300
2174
  }
2301
- var formfactorNameCandidate = args[0].toUpperCase();
2302
- var formfactor = FORMFACTOR_DEFINITIONS.find(function (definition) {
2303
- return __spreadArray([definition.name], __read(__assign({ aliasNames: [] }, definition).aliasNames), false).includes(formfactorNameCandidate);
2304
- });
2175
+ const formfactorNameCandidate = args[0].toUpperCase();
2176
+ const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
2305
2177
  if (formfactor === undefined) {
2306
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown formfactor name \"".concat(formfactorNameCandidate, "\"\n\n Available formfactors:\n ").concat(block(FORMFACTOR_DEFINITIONS.map(function (_a) {
2307
- var name = _a.name;
2308
- return "- ".concat(name);
2309
- }).join('\n')), "\n "); }));
2178
+ throw new ParseError(spaceTrim__default["default"]((block) => `
2179
+ Unknown formfactor name "${formfactorNameCandidate}"
2180
+
2181
+ Available formfactors:
2182
+ ${block(FORMFACTOR_DEFINITIONS.map(({ name }) => `- ${name}`).join('\n'))}
2183
+ `));
2310
2184
  }
2311
2185
  return {
2312
2186
  type: 'FORMFACTOR',
@@ -2318,9 +2192,15 @@
2318
2192
  *
2319
2193
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
2320
2194
  */
2321
- $applyToPipelineJson: function (command, $pipelineJson) {
2195
+ $applyToPipelineJson(command, $pipelineJson) {
2322
2196
  if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
2323
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
2197
+ throw new ParseError(spaceTrim__default["default"](`
2198
+ Redefinition of \`FORMFACTOR\` in the pipeline head
2199
+
2200
+ You have used:
2201
+ 1) FORMFACTOR \`${$pipelineJson.formfactorName}\`
2202
+ 2) FORMFACTOR \`${command.formfactorName}\`
2203
+ `));
2324
2204
  }
2325
2205
  $pipelineJson.formfactorName = command.formfactorName;
2326
2206
  },
@@ -2329,15 +2209,15 @@
2329
2209
  *
2330
2210
  * Note: This is used in `pipelineJsonToString` utility
2331
2211
  */
2332
- stringify: function (command) {
2333
- return "FORMFACTOR ".concat(command.formfactorName);
2212
+ stringify(command) {
2213
+ return `FORMFACTOR ${command.formfactorName}`;
2334
2214
  },
2335
2215
  /**
2336
2216
  * Reads the FORMFACTOR command from the `PipelineJson`
2337
2217
  *
2338
2218
  * Note: This is used in `pipelineJsonToString` utility
2339
2219
  */
2340
- takeFromPipelineJson: function (pipelineJson) {
2220
+ takeFromPipelineJson(pipelineJson) {
2341
2221
  return [
2342
2222
  {
2343
2223
  type: 'FORMFACTOR',
@@ -2353,7 +2233,7 @@
2353
2233
  * @see `documentationUrl` for more details
2354
2234
  * @public exported from `@promptbook/editable`
2355
2235
  */
2356
- var jokerCommandParser = {
2236
+ const jokerCommandParser = {
2357
2237
  /**
2358
2238
  * Name of the command
2359
2239
  */
@@ -2366,7 +2246,7 @@
2366
2246
  /**
2367
2247
  * Description of the JOKER command
2368
2248
  */
2369
- description: "Joker parameter is used instead of executing the task result if jokers value meets the expectations requirements",
2249
+ description: `Joker parameter is used instead of executing the task result if jokers value meets the expectations requirements`,
2370
2250
  /**
2371
2251
  * Link to documentation
2372
2252
  */
@@ -2378,16 +2258,16 @@
2378
2258
  /**
2379
2259
  * Parses the JOKER command
2380
2260
  */
2381
- parse: function (input) {
2382
- var args = input.args;
2261
+ parse(input) {
2262
+ const { args } = input;
2383
2263
  if (args.length !== 1) {
2384
- throw new ParseError("JOKE command expects exactly one parameter name");
2264
+ throw new ParseError(`JOKE command expects exactly one parameter name`);
2385
2265
  }
2386
- var parameterNameArg = args[0] || '';
2387
- var parameterName = validateParameterName(parameterNameArg);
2266
+ const parameterNameArg = args[0] || '';
2267
+ const parameterName = validateParameterName(parameterNameArg);
2388
2268
  return {
2389
2269
  type: 'JOKER',
2390
- parameterName: parameterName,
2270
+ parameterName,
2391
2271
  };
2392
2272
  },
2393
2273
  /**
@@ -2395,7 +2275,7 @@
2395
2275
  *
2396
2276
  * Note: `$` is used to indicate that this function mutates given `taskJson`
2397
2277
  */
2398
- $applyToTaskJson: function (command, $taskJson) {
2278
+ $applyToTaskJson(command, $taskJson) {
2399
2279
  $taskJson.jokerParameterNames = $taskJson.jokerParameterNames || [];
2400
2280
  $taskJson.jokerParameterNames.push(command.parameterName);
2401
2281
  },
@@ -2404,16 +2284,16 @@
2404
2284
  *
2405
2285
  * Note: This is used in `pipelineJsonToString` utility
2406
2286
  */
2407
- stringify: function (command) {
2408
- return "---"; // <- TODO: [🛋] Implement
2287
+ stringify(command) {
2288
+ return `---`; // <- TODO: [🛋] Implement
2409
2289
  },
2410
2290
  /**
2411
2291
  * Reads the JOKER command from the `TaskJson`
2412
2292
  *
2413
2293
  * Note: This is used in `pipelineJsonToString` utility
2414
2294
  */
2415
- takeFromTaskJson: function ($taskJson) {
2416
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2295
+ takeFromTaskJson($taskJson) {
2296
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2417
2297
  },
2418
2298
  };
2419
2299
 
@@ -2434,7 +2314,7 @@
2434
2314
  5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
2435
2315
  return false;
2436
2316
  }
2437
- var filenameSlashes = filename.split('\\').join('/');
2317
+ const filenameSlashes = filename.split('\\').join('/');
2438
2318
  // Absolute Unix path: /hello.txt
2439
2319
  if (/^(\/)/i.test(filenameSlashes)) {
2440
2320
  // console.log(filename, 'Absolute Unix path: /hello.txt');
@@ -2484,7 +2364,7 @@
2484
2364
  if (url.startsWith('blob:')) {
2485
2365
  url = url.replace(/^blob:/, '');
2486
2366
  }
2487
- var urlObject = new URL(url /* because fail is handled */);
2367
+ const urlObject = new URL(url /* because fail is handled */);
2488
2368
  if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
2489
2369
  return false;
2490
2370
  }
@@ -2505,47 +2385,36 @@
2505
2385
  * @public exported from `@promptbook/utils`
2506
2386
  */
2507
2387
  function normalizeToKebabCase(text) {
2508
- var e_1, _a;
2509
2388
  text = removeDiacritics(text);
2510
- var charType;
2511
- var lastCharType = 'OTHER';
2512
- var normalizedName = '';
2513
- try {
2514
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
2515
- var char = text_1_1.value;
2516
- var normalizedChar = void 0;
2517
- if (/^[a-z]$/.test(char)) {
2518
- charType = 'LOWERCASE';
2519
- normalizedChar = char;
2520
- }
2521
- else if (/^[A-Z]$/.test(char)) {
2522
- charType = 'UPPERCASE';
2523
- normalizedChar = char.toLowerCase();
2524
- }
2525
- else if (/^[0-9]$/.test(char)) {
2526
- charType = 'NUMBER';
2527
- normalizedChar = char;
2528
- }
2529
- else {
2530
- charType = 'OTHER';
2531
- normalizedChar = '-';
2532
- }
2533
- if (charType !== lastCharType &&
2534
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
2535
- !(lastCharType === 'NUMBER') &&
2536
- !(charType === 'NUMBER')) {
2537
- normalizedName += '-';
2538
- }
2539
- normalizedName += normalizedChar;
2540
- lastCharType = charType;
2389
+ let charType;
2390
+ let lastCharType = 'OTHER';
2391
+ let normalizedName = '';
2392
+ for (const char of text) {
2393
+ let normalizedChar;
2394
+ if (/^[a-z]$/.test(char)) {
2395
+ charType = 'LOWERCASE';
2396
+ normalizedChar = char;
2541
2397
  }
2542
- }
2543
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2544
- finally {
2545
- try {
2546
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
2398
+ else if (/^[A-Z]$/.test(char)) {
2399
+ charType = 'UPPERCASE';
2400
+ normalizedChar = char.toLowerCase();
2401
+ }
2402
+ else if (/^[0-9]$/.test(char)) {
2403
+ charType = 'NUMBER';
2404
+ normalizedChar = char;
2547
2405
  }
2548
- finally { if (e_1) throw e_1.error; }
2406
+ else {
2407
+ charType = 'OTHER';
2408
+ normalizedChar = '-';
2409
+ }
2410
+ if (charType !== lastCharType &&
2411
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
2412
+ !(lastCharType === 'NUMBER') &&
2413
+ !(charType === 'NUMBER')) {
2414
+ normalizedName += '-';
2415
+ }
2416
+ normalizedName += normalizedChar;
2417
+ lastCharType = charType;
2549
2418
  }
2550
2419
  normalizedName = normalizedName.split(/-+/g).join('-');
2551
2420
  normalizedName = normalizedName.split(/-?\/-?/g).join('/');
@@ -2563,14 +2432,14 @@
2563
2432
  * @public exported from `@promptbook/editable`
2564
2433
  */
2565
2434
  function knowledgeSourceContentToName(knowledgeSourceContent) {
2566
- var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
2435
+ const hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
2567
2436
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
2568
2437
  .toString( /* hex */)
2569
2438
  .substring(0, 20);
2570
2439
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
2571
- var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
2572
- var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
2573
- var name = pieces.join('-').split('--').join('-');
2440
+ const semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
2441
+ const pieces = ['source', semanticName, hash].filter((piece) => piece !== '');
2442
+ const name = pieces.join('-').split('--').join('-');
2574
2443
  // <- TODO: Use MAX_FILENAME_LENGTH
2575
2444
  return name;
2576
2445
  }
@@ -2584,7 +2453,7 @@
2584
2453
  * @see `documentationUrl` for more details
2585
2454
  * @public exported from `@promptbook/editable`
2586
2455
  */
2587
- var knowledgeCommandParser = {
2456
+ const knowledgeCommandParser = {
2588
2457
  /**
2589
2458
  * Name of the command
2590
2459
  */
@@ -2597,7 +2466,7 @@
2597
2466
  /**
2598
2467
  * Description of the KNOWLEDGE command
2599
2468
  */
2600
- description: "Tells promptbook which external knowledge to use",
2469
+ description: `Tells promptbook which external knowledge to use`,
2601
2470
  /**
2602
2471
  * Link to documentation
2603
2472
  */
@@ -2616,27 +2485,27 @@
2616
2485
  /**
2617
2486
  * Parses the KNOWLEDGE command
2618
2487
  */
2619
- parse: function (input) {
2620
- var args = input.args;
2621
- var knowledgeSourceContent = spaceTrim__default["default"](args[0] || '');
2488
+ parse(input) {
2489
+ const { args } = input;
2490
+ const knowledgeSourceContent = spaceTrim__default["default"](args[0] || '');
2622
2491
  if (knowledgeSourceContent === '') {
2623
- throw new ParseError("Source is not defined");
2492
+ throw new ParseError(`Source is not defined`);
2624
2493
  }
2625
2494
  // TODO: [main] !!4 Following checks should be applied every link in the `sourceContent`
2626
2495
  if (knowledgeSourceContent.startsWith('http://')) {
2627
- throw new ParseError("Source is not secure");
2496
+ throw new ParseError(`Source is not secure`);
2628
2497
  }
2629
2498
  if (!(isValidFilePath(knowledgeSourceContent) || isValidUrl(knowledgeSourceContent))) {
2630
- throw new ParseError("Source not valid");
2499
+ throw new ParseError(`Source not valid`);
2631
2500
  }
2632
2501
  if (knowledgeSourceContent.startsWith('../') ||
2633
2502
  knowledgeSourceContent.startsWith('/') ||
2634
2503
  /^[A-Z]:[\\/]+/i.test(knowledgeSourceContent)) {
2635
- throw new ParseError("Source cannot be outside of the .book.md folder");
2504
+ throw new ParseError(`Source cannot be outside of the .book.md folder`);
2636
2505
  }
2637
2506
  return {
2638
2507
  type: 'KNOWLEDGE',
2639
- knowledgeSourceContent: knowledgeSourceContent,
2508
+ knowledgeSourceContent,
2640
2509
  };
2641
2510
  },
2642
2511
  /**
@@ -2644,11 +2513,11 @@
2644
2513
  *
2645
2514
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
2646
2515
  */
2647
- $applyToPipelineJson: function (command, $pipelineJson) {
2648
- var knowledgeSourceContent = command.knowledgeSourceContent;
2516
+ $applyToPipelineJson(command, $pipelineJson) {
2517
+ const { knowledgeSourceContent } = command;
2649
2518
  $pipelineJson.knowledgeSources.push({
2650
2519
  name: knowledgeSourceContentToName(knowledgeSourceContent),
2651
- knowledgeSourceContent: knowledgeSourceContent,
2520
+ knowledgeSourceContent,
2652
2521
  });
2653
2522
  },
2654
2523
  /**
@@ -2656,16 +2525,16 @@
2656
2525
  *
2657
2526
  * Note: This is used in `pipelineJsonToString` utility
2658
2527
  */
2659
- stringify: function (command) {
2660
- return "---"; // <- TODO: [🛋] Implement
2528
+ stringify(command) {
2529
+ return `---`; // <- TODO: [🛋] Implement
2661
2530
  },
2662
2531
  /**
2663
2532
  * Reads the KNOWLEDGE command from the `PipelineJson`
2664
2533
  *
2665
2534
  * Note: This is used in `pipelineJsonToString` utility
2666
2535
  */
2667
- takeFromPipelineJson: function (pipelineJson) {
2668
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2536
+ takeFromPipelineJson(pipelineJson) {
2537
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2669
2538
  },
2670
2539
  };
2671
2540
  /**
@@ -2677,7 +2546,7 @@
2677
2546
  *
2678
2547
  * @public exported from `@promptbook/core`
2679
2548
  */
2680
- var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
2549
+ const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
2681
2550
 
2682
2551
  /**
2683
2552
  * Parses the model command
@@ -2686,7 +2555,7 @@
2686
2555
  * @deprecated Option to manually set the model requirements is not recommended to use, use `PERSONA` instead
2687
2556
  * @public exported from `@promptbook/editable`
2688
2557
  */
2689
- var modelCommandParser = {
2558
+ const modelCommandParser = {
2690
2559
  /**
2691
2560
  * Name of the command
2692
2561
  */
@@ -2699,7 +2568,7 @@
2699
2568
  /**
2700
2569
  * Description of the MODEL command
2701
2570
  */
2702
- description: "Tells which `modelRequirements` (for example which model) to use for the prompt task execution",
2571
+ description: `Tells which \`modelRequirements\` (for example which model) to use for the prompt task execution`,
2703
2572
  /**
2704
2573
  * Link to documentation
2705
2574
  */
@@ -2711,11 +2580,12 @@
2711
2580
  /**
2712
2581
  * Parses the MODEL command
2713
2582
  */
2714
- parse: function (input) {
2715
- var args = input.args, normalized = input.normalized;
2716
- var availableVariantsMessage = spaceTrim__default["default"](function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
2717
- return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
2718
- }).join('\n')), "\n "); });
2583
+ parse(input) {
2584
+ const { args, normalized } = input;
2585
+ const availableVariantsMessage = spaceTrim__default["default"]((block) => `
2586
+ Available variants are:
2587
+ ${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
2588
+ `);
2719
2589
  // TODO: Make this more elegant and dynamically
2720
2590
  if (normalized.startsWith('MODEL_VARIANT')) {
2721
2591
  if (normalized === 'MODEL_VARIANT_CHAT') {
@@ -2734,10 +2604,18 @@
2734
2604
  // <- Note: [🤖]
2735
2605
  }
2736
2606
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
2737
- spaceTrim__default["default"](function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
2607
+ spaceTrim__default["default"]((block) => `
2608
+ Embedding model can not be used in pipeline
2609
+
2610
+ ${block(availableVariantsMessage)}
2611
+ `);
2738
2612
  }
2739
2613
  else {
2740
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
2614
+ throw new ParseError(spaceTrim__default["default"]((block) => `
2615
+ Unknown model variant in command:
2616
+
2617
+ ${block(availableVariantsMessage)}
2618
+ `));
2741
2619
  }
2742
2620
  }
2743
2621
  if (normalized.startsWith('MODEL_NAME')) {
@@ -2748,7 +2626,16 @@
2748
2626
  };
2749
2627
  }
2750
2628
  else {
2751
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model key in command.\n\n Supported model keys are:\n ".concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
2629
+ throw new ParseError(spaceTrim__default["default"]((block) => `
2630
+ Unknown model key in command.
2631
+
2632
+ Supported model keys are:
2633
+ ${block(['variant', 'name'].join(', '))}
2634
+
2635
+ Example:
2636
+ - MODEL VARIANT Chat
2637
+ - MODEL NAME gpt-4
2638
+ `));
2752
2639
  }
2753
2640
  },
2754
2641
  /**
@@ -2756,16 +2643,22 @@
2756
2643
  *
2757
2644
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
2758
2645
  */
2759
- $applyToPipelineJson: function (command, $pipelineJson) {
2646
+ $applyToPipelineJson(command, $pipelineJson) {
2760
2647
  $pipelineJson.defaultModelRequirements = $pipelineJson.defaultModelRequirements || {};
2761
2648
  // TODO: [🚜] DRY
2762
2649
  if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
2763
2650
  if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
2764
- console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
2651
+ console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the pipeline head`);
2765
2652
  // <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
2766
2653
  }
2767
2654
  else {
2768
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
2655
+ throw new ParseError(spaceTrim__default["default"](`
2656
+ Redefinition of \`MODEL ${command.key}\` in the pipeline head
2657
+
2658
+ You have used:
2659
+ 1) \`MODEL ${command.key} ${$pipelineJson.defaultModelRequirements[command.key]}\`
2660
+ 2) \`MODEL ${command.key} ${command.value}\`
2661
+ `));
2769
2662
  }
2770
2663
  }
2771
2664
  $pipelineJson.defaultModelRequirements[command.key] = command.value;
@@ -2775,26 +2668,40 @@
2775
2668
  *
2776
2669
  * Note: `$` is used to indicate that this function mutates given `taskJson`
2777
2670
  */
2778
- $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
2671
+ $applyToTaskJson(command, $taskJson, $pipelineJson) {
2779
2672
  if ($taskJson.taskType !== 'PROMPT_TASK') {
2780
- throw new ParseError("MODEL command can only be used in PROMPT_TASK block");
2673
+ throw new ParseError(`MODEL command can only be used in PROMPT_TASK block`);
2781
2674
  }
2782
2675
  $taskJson.modelRequirements = $taskJson.modelRequirements || {};
2783
2676
  // TODO: [🚜] DRY
2784
2677
  if ($taskJson.modelRequirements[command.key] !== undefined) {
2785
2678
  if ($taskJson.modelRequirements[command.key] === command.value) {
2786
- console.warn("Multiple commands `MODEL ".concat({
2787
- modelName: 'NAME',
2788
- modelVariant: 'VARIANT',
2789
- maxTokens: '???',
2790
- }[command.key], " ").concat(command.value, "` in the task \"").concat($taskJson.title || $taskJson.name, "\""));
2679
+ console.warn(`Multiple commands \`MODEL ${{
2680
+ modelName: 'NAME',
2681
+ modelVariant: 'VARIANT',
2682
+ maxTokens: '???',
2683
+ }[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
2791
2684
  }
2792
2685
  else {
2793
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\"\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($taskJson.modelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
2686
+ throw new ParseError(spaceTrim__default["default"](`
2687
+ Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
2688
+
2689
+ You have used:
2690
+ - MODEL ${command.key} ${$taskJson.modelRequirements[command.key]}
2691
+ - MODEL ${command.key} ${command.value}
2692
+ `));
2794
2693
  }
2795
2694
  }
2796
2695
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
2797
- console.log(spaceTrim__default["default"]("\n Setting MODEL `".concat(command.key, "` in the task \"").concat($taskJson.title || $taskJson.name, "\" to the same value as in the pipeline head\n\n In pipeline head:\n - MODEL ").concat(command.key, " ").concat(($pipelineJson.defaultModelRequirements || {})[command.key], "\n\n But same value is used in the task:\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
2696
+ console.log(spaceTrim__default["default"](`
2697
+ Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
2698
+
2699
+ In pipeline head:
2700
+ - MODEL ${command.key} ${($pipelineJson.defaultModelRequirements || {})[command.key]}
2701
+
2702
+ But same value is used in the task:
2703
+ - MODEL ${command.key} ${command.value}
2704
+ `));
2798
2705
  }
2799
2706
  $taskJson.modelRequirements[command.key] = command.value;
2800
2707
  },
@@ -2803,24 +2710,24 @@
2803
2710
  *
2804
2711
  * Note: This is used in `pipelineJsonToString` utility
2805
2712
  */
2806
- stringify: function (command) {
2807
- return "---"; // <- TODO: [🛋] Implement
2713
+ stringify(command) {
2714
+ return `---`; // <- TODO: [🛋] Implement
2808
2715
  },
2809
2716
  /**
2810
2717
  * Reads the MODEL command from the `PipelineJson`
2811
2718
  *
2812
2719
  * Note: This is used in `pipelineJsonToString` utility
2813
2720
  */
2814
- takeFromPipelineJson: function (pipelineJson) {
2815
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2721
+ takeFromPipelineJson(pipelineJson) {
2722
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2816
2723
  },
2817
2724
  /**
2818
2725
  * Reads the MODEL command from the `TaskJson`
2819
2726
  *
2820
2727
  * Note: This is used in `pipelineJsonToString` utility
2821
2728
  */
2822
- takeFromTaskJson: function ($taskJson) {
2823
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2729
+ takeFromTaskJson($taskJson) {
2730
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2824
2731
  },
2825
2732
  };
2826
2733
 
@@ -2830,7 +2737,7 @@
2830
2737
  * @see `documentationUrl` for more details
2831
2738
  * @public exported from `@promptbook/editable`
2832
2739
  */
2833
- var parameterCommandParser = {
2740
+ const parameterCommandParser = {
2834
2741
  /**
2835
2742
  * Name of the command
2836
2743
  */
@@ -2850,7 +2757,7 @@
2850
2757
  /**
2851
2758
  * Description of the PARAMETER command
2852
2759
  */
2853
- description: "Describes one parameter of the task",
2760
+ description: `Describes one parameter of the task`,
2854
2761
  /**
2855
2762
  * Link to documentation
2856
2763
  */
@@ -2862,29 +2769,34 @@
2862
2769
  /**
2863
2770
  * Parses the PARAMETER command
2864
2771
  */
2865
- parse: function (input) {
2866
- var normalized = input.normalized, args = input.args, raw = input.raw;
2867
- var parameterNameRaw = args.shift() || '';
2868
- var parameterDescriptionRaw = args.join(' ');
2772
+ parse(input) {
2773
+ const { normalized, args, raw } = input;
2774
+ const parameterNameRaw = args.shift() || '';
2775
+ const parameterDescriptionRaw = args.join(' ');
2869
2776
  // <- TODO: When [🥶] fixed, change to:
2870
2777
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
2871
2778
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
2872
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Parameter `{".concat(parameterNameRaw, "}` can not contain another parameter in description\n\n The description:\n ").concat(block(parameterDescriptionRaw), "\n "); }));
2779
+ throw new ParseError(spaceTrim__default["default"]((block) => `
2780
+ Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
2781
+
2782
+ The description:
2783
+ ${block(parameterDescriptionRaw)}
2784
+ `));
2873
2785
  }
2874
- var isInput = normalized.startsWith('INPUT');
2875
- var isOutput = normalized.startsWith('OUTPUT');
2786
+ let isInput = normalized.startsWith('INPUT');
2787
+ let isOutput = normalized.startsWith('OUTPUT');
2876
2788
  if (raw.startsWith('> {')) {
2877
2789
  isInput = false;
2878
2790
  isOutput = false;
2879
2791
  }
2880
- var parameterName = validateParameterName(parameterNameRaw);
2881
- var parameterDescription = parameterDescriptionRaw.trim() || null;
2792
+ const parameterName = validateParameterName(parameterNameRaw);
2793
+ const parameterDescription = parameterDescriptionRaw.trim() || null;
2882
2794
  return {
2883
2795
  type: 'PARAMETER',
2884
- parameterName: parameterName,
2885
- parameterDescription: parameterDescription,
2886
- isInput: isInput,
2887
- isOutput: isOutput,
2796
+ parameterName,
2797
+ parameterDescription,
2798
+ isInput,
2799
+ isOutput,
2888
2800
  };
2889
2801
  },
2890
2802
  /**
@@ -2892,7 +2804,7 @@
2892
2804
  *
2893
2805
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
2894
2806
  */
2895
- $applyToPipelineJson: function (command, $pipelineJson) {
2807
+ $applyToPipelineJson(command, $pipelineJson) {
2896
2808
  // Note: [🍣] Do nothing, its application is implemented separately in `parsePipeline`
2897
2809
  },
2898
2810
  /**
@@ -2900,7 +2812,7 @@
2900
2812
  *
2901
2813
  * Note: `$` is used to indicate that this function mutates given `taskJson`
2902
2814
  */
2903
- $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
2815
+ $applyToTaskJson(command, $taskJson, $pipelineJson) {
2904
2816
  // Note: [🍣] Do nothing, its application is implemented separately in `parsePipeline`
2905
2817
  },
2906
2818
  /**
@@ -2908,24 +2820,24 @@
2908
2820
  *
2909
2821
  * Note: This is used in `pipelineJsonToString` utility
2910
2822
  */
2911
- stringify: function (command) {
2912
- return "---"; // <- TODO: [🛋] Implement
2823
+ stringify(command) {
2824
+ return `---`; // <- TODO: [🛋] Implement
2913
2825
  },
2914
2826
  /**
2915
2827
  * Reads the PARAMETER command from the `PipelineJson`
2916
2828
  *
2917
2829
  * Note: This is used in `pipelineJsonToString` utility
2918
2830
  */
2919
- takeFromPipelineJson: function (pipelineJson) {
2920
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2831
+ takeFromPipelineJson(pipelineJson) {
2832
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2921
2833
  },
2922
2834
  /**
2923
2835
  * Reads the PARAMETER command from the `TaskJson`
2924
2836
  *
2925
2837
  * Note: This is used in `pipelineJsonToString` utility
2926
2838
  */
2927
- takeFromTaskJson: function ($taskJson) {
2928
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2839
+ takeFromTaskJson($taskJson) {
2840
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
2929
2841
  },
2930
2842
  };
2931
2843
 
@@ -2935,7 +2847,7 @@
2935
2847
  * @see `documentationUrl` for more details
2936
2848
  * @public exported from `@promptbook/editable`
2937
2849
  */
2938
- var personaCommandParser = {
2850
+ const personaCommandParser = {
2939
2851
  /**
2940
2852
  * Name of the command
2941
2853
  */
@@ -2952,7 +2864,7 @@
2952
2864
  /**
2953
2865
  * Description of the PERSONA command
2954
2866
  */
2955
- description: "Persona command is used to specify who the system is, it will be transformed into system message, top_t,...",
2867
+ description: `Persona command is used to specify who the system is, it will be transformed into system message, top_t,...`,
2956
2868
  /**
2957
2869
  * Link to documentation
2958
2870
  */
@@ -2964,21 +2876,21 @@
2964
2876
  /**
2965
2877
  * Parses the PERSONA command
2966
2878
  */
2967
- parse: function (input) {
2968
- var rawArgs = input.rawArgs;
2969
- var _a = __read(rawArgs.split(/[,;:]/, 2), 2), personaNameRaw = _a[0], personaDescriptionRaw = _a[1];
2970
- var personaName = (personaNameRaw || '').trim();
2879
+ parse(input) {
2880
+ const { rawArgs } = input;
2881
+ const [personaNameRaw, personaDescriptionRaw] = rawArgs.split(/[,;:]/, 2);
2882
+ const personaName = (personaNameRaw || '').trim();
2971
2883
  if (personaName === '') {
2972
- throw new ParseError("You must set name for the persona");
2884
+ throw new ParseError(`You must set name for the persona`);
2973
2885
  }
2974
- var personaDescription = (personaDescriptionRaw || '').trim();
2886
+ let personaDescription = (personaDescriptionRaw || '').trim();
2975
2887
  if (personaDescription === '') {
2976
2888
  personaDescription = null;
2977
2889
  }
2978
2890
  return {
2979
2891
  type: 'PERSONA',
2980
- personaName: personaName,
2981
- personaDescription: personaDescription,
2892
+ personaName,
2893
+ personaDescription,
2982
2894
  };
2983
2895
  },
2984
2896
  /**
@@ -2986,33 +2898,33 @@
2986
2898
  *
2987
2899
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
2988
2900
  */
2989
- $applyToPipelineJson: function (command, $pipelineJson) {
2901
+ $applyToPipelineJson(command, $pipelineJson) {
2990
2902
  $applyToTaskJson(command, null, $pipelineJson);
2991
2903
  },
2992
- $applyToTaskJson: $applyToTaskJson,
2904
+ $applyToTaskJson,
2993
2905
  /**
2994
2906
  * Converts the PERSONA command back to string
2995
2907
  *
2996
2908
  * Note: This is used in `pipelineJsonToString` utility
2997
2909
  */
2998
- stringify: function (command) {
2999
- return "---"; // <- TODO: [🛋] Implement
2910
+ stringify(command) {
2911
+ return `---`; // <- TODO: [🛋] Implement
3000
2912
  },
3001
2913
  /**
3002
2914
  * Reads the PERSONA command from the `PipelineJson`
3003
2915
  *
3004
2916
  * Note: This is used in `pipelineJsonToString` utility
3005
2917
  */
3006
- takeFromPipelineJson: function (pipelineJson) {
3007
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2918
+ takeFromPipelineJson(pipelineJson) {
2919
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
3008
2920
  },
3009
2921
  /**
3010
2922
  * Reads the PERSONA command from the `TaskJson`
3011
2923
  *
3012
2924
  * Note: This is used in `pipelineJsonToString` utility
3013
2925
  */
3014
- takeFromTaskJson: function ($taskJson) {
3015
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
2926
+ takeFromTaskJson($taskJson) {
2927
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
3016
2928
  },
3017
2929
  };
3018
2930
  /**
@@ -3021,14 +2933,14 @@
3021
2933
  * Note: `$` is used to indicate that this function mutates given `taskJson`
3022
2934
  */
3023
2935
  function $applyToTaskJson(command, $taskJson, $pipelineJson) {
3024
- var personaName = command.personaName, personaDescription = command.personaDescription;
2936
+ const { personaName, personaDescription } = command;
3025
2937
  if ($taskJson !== null) {
3026
2938
  if ($taskJson.taskType !== 'PROMPT_TASK') {
3027
- throw new ParseError("PERSONA command can be used only in PROMPT_TASK block");
2939
+ throw new ParseError(`PERSONA command can be used only in PROMPT_TASK block`);
3028
2940
  }
3029
2941
  $taskJson.personaName = personaName;
3030
2942
  }
3031
- var persona = $pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
2943
+ const persona = $pipelineJson.personas.find((persona) => persona.name === personaName);
3032
2944
  if (persona === undefined) {
3033
2945
  $pipelineJson.personas.push({
3034
2946
  name: personaName,
@@ -3046,7 +2958,17 @@
3046
2958
  persona.description = personaDescription;
3047
2959
  return;
3048
2960
  }
3049
- console.warn(spaceTrim__default["default"]("\n\n Persona \"".concat(personaName, "\" is defined multiple times with different description:\n\n First definition:\n ").concat(persona.description, "\n\n Second definition:\n ").concat(personaDescription, "\n\n ")));
2961
+ console.warn(spaceTrim__default["default"](`
2962
+
2963
+ Persona "${personaName}" is defined multiple times with different description:
2964
+
2965
+ First definition:
2966
+ ${persona.description}
2967
+
2968
+ Second definition:
2969
+ ${personaDescription}
2970
+
2971
+ `));
3050
2972
  persona.description += spaceTrim__default["default"]('\n\n' + personaDescription);
3051
2973
  }
3052
2974
 
@@ -3070,7 +2992,7 @@
3070
2992
  * @see `documentationUrl` for more details
3071
2993
  * @public exported from `@promptbook/editable`
3072
2994
  */
3073
- var postprocessCommandParser = {
2995
+ const postprocessCommandParser = {
3074
2996
  /**
3075
2997
  * Name of the command
3076
2998
  */
@@ -3084,7 +3006,7 @@
3084
3006
  /**
3085
3007
  * Description of the POSTPROCESS command
3086
3008
  */
3087
- description: "Defines the postprocess function to be used on the result from LLM and before the result is validated",
3009
+ description: `Defines the postprocess function to be used on the result from LLM and before the result is validated`,
3088
3010
  /**
3089
3011
  * Link to documentation
3090
3012
  */
@@ -3098,21 +3020,21 @@
3098
3020
  /**
3099
3021
  * Parses the POSTPROCESS command
3100
3022
  */
3101
- parse: function (input) {
3102
- var args = input.args;
3103
- var functionName = args.pop();
3023
+ parse(input) {
3024
+ const { args } = input;
3025
+ const functionName = args.pop();
3104
3026
  if (functionName === undefined) {
3105
- throw new ParseError("Postprocess function name is required");
3027
+ throw new ParseError(`Postprocess function name is required`);
3106
3028
  }
3107
3029
  if (!isValidJavascriptName(functionName)) {
3108
- throw new ParseError("Invalid postprocess function name \"".concat(functionName, "\""));
3030
+ throw new ParseError(`Invalid postprocess function name "${functionName}"`);
3109
3031
  }
3110
3032
  if (args.length > 0) {
3111
- throw new ParseError("Can not have more than one postprocess function");
3033
+ throw new ParseError(`Can not have more than one postprocess function`);
3112
3034
  }
3113
3035
  return {
3114
3036
  type: 'POSTPROCESS',
3115
- functionName: functionName,
3037
+ functionName,
3116
3038
  };
3117
3039
  },
3118
3040
  /**
@@ -3120,7 +3042,7 @@
3120
3042
  *
3121
3043
  * Note: `$` is used to indicate that this function mutates given `taskJson`
3122
3044
  */
3123
- $applyToTaskJson: function (command, $taskJson) {
3045
+ $applyToTaskJson(command, $taskJson) {
3124
3046
  $taskJson.postprocessingFunctionNames = $taskJson.postprocessingFunctionNames || [];
3125
3047
  $taskJson.postprocessingFunctionNames.push(command.functionName);
3126
3048
  },
@@ -3129,16 +3051,16 @@
3129
3051
  *
3130
3052
  * Note: This is used in `pipelineJsonToString` utility
3131
3053
  */
3132
- stringify: function (command) {
3133
- return "---"; // <- TODO: [🛋] Implement
3054
+ stringify(command) {
3055
+ return `---`; // <- TODO: [🛋] Implement
3134
3056
  },
3135
3057
  /**
3136
3058
  * Reads the POSTPROCESS command from the `TaskJson`
3137
3059
  *
3138
3060
  * Note: This is used in `pipelineJsonToString` utility
3139
3061
  */
3140
- takeFromTaskJson: function ($taskJson) {
3141
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
3062
+ takeFromTaskJson($taskJson) {
3063
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
3142
3064
  },
3143
3065
  };
3144
3066
 
@@ -3151,7 +3073,7 @@
3151
3073
  *
3152
3074
  * @public exported from `@promptbook/core`
3153
3075
  */
3154
- var TaskTypes = [
3076
+ const TaskTypes = [
3155
3077
  'PROMPT',
3156
3078
  'SIMPLE',
3157
3079
  'SCRIPT',
@@ -3164,7 +3086,7 @@
3164
3086
  *
3165
3087
  * @public exported from `@promptbook/core`
3166
3088
  */
3167
- var NonTaskSectionTypes = ['EXAMPLE', 'KNOWLEDGE', 'INSTRUMENT', 'ACTION'];
3089
+ const NonTaskSectionTypes = ['EXAMPLE', 'KNOWLEDGE', 'INSTRUMENT', 'ACTION'];
3168
3090
  /**
3169
3091
  * All available section types
3170
3092
  *
@@ -3174,7 +3096,10 @@
3174
3096
  *
3175
3097
  * @public exported from `@promptbook/core`
3176
3098
  */
3177
- var SectionTypes = __spreadArray(__spreadArray([], __read(TaskTypes.map(function (TaskType) { return "".concat(TaskType, "_TASK"); })), false), __read(NonTaskSectionTypes), false);
3099
+ const SectionTypes = [
3100
+ ...TaskTypes.map((TaskType) => `${TaskType}_TASK`),
3101
+ ...NonTaskSectionTypes,
3102
+ ];
3178
3103
 
3179
3104
  /**
3180
3105
  * Parses the section command
@@ -3182,7 +3107,7 @@
3182
3107
  * @see `documentationUrl` for more details
3183
3108
  * @public exported from `@promptbook/editable`
3184
3109
  */
3185
- var sectionCommandParser = {
3110
+ const sectionCommandParser = {
3186
3111
  /**
3187
3112
  * Name of the command
3188
3113
  */
@@ -3213,7 +3138,7 @@
3213
3138
  /**
3214
3139
  * Description of the SECTION command
3215
3140
  */
3216
- description: "Defines the purpose of the markdown section - if its a task and which type or something else",
3141
+ description: `Defines the purpose of the markdown section - if its a task and which type or something else`,
3217
3142
  /**
3218
3143
  * Link to documentation
3219
3144
  */
@@ -3259,21 +3184,24 @@
3259
3184
  /**
3260
3185
  * Parses the SECTION command
3261
3186
  */
3262
- parse: function (input) {
3263
- var normalized = input.normalized;
3187
+ parse(input) {
3188
+ let { normalized } = input;
3264
3189
  normalized = normalized.split('SAMPLE').join('EXAMPLE');
3265
3190
  normalized = normalized.split('EXECUTE_').join('');
3266
3191
  normalized = normalized.split('DIALOGUE').join('DIALOG');
3267
- var taskTypes = SectionTypes.filter(function (sectionType) {
3268
- return normalized.includes(sectionType.split('_TASK').join(''));
3269
- });
3192
+ const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
3270
3193
  if (taskTypes.length !== 1) {
3271
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
3194
+ throw new ParseError(spaceTrim__default["default"]((block) => `
3195
+ Unknown section type "${normalized}"
3196
+
3197
+ Supported section types are:
3198
+ ${block(SectionTypes.join(', '))}
3199
+ `));
3272
3200
  }
3273
- var taskType = taskTypes[0];
3201
+ const taskType = taskTypes[0];
3274
3202
  return {
3275
3203
  type: 'SECTION',
3276
- taskType: taskType,
3204
+ taskType,
3277
3205
  };
3278
3206
  },
3279
3207
  /**
@@ -3281,27 +3209,30 @@
3281
3209
  *
3282
3210
  * Note: `$` is used to indicate that this function mutates given `taskJson`
3283
3211
  */
3284
- $applyToTaskJson: function (command, $taskJson, $pipelineJson) {
3212
+ $applyToTaskJson(command, $taskJson, $pipelineJson) {
3285
3213
  if ($taskJson.isSectionTypeSet === true) {
3286
- throw new ParseError(spaceTrim__default["default"]("\n Section type is already defined in the section.\n It can be defined only once.\n "));
3214
+ throw new ParseError(spaceTrim__default["default"](`
3215
+ Section type is already defined in the section.
3216
+ It can be defined only once.
3217
+ `));
3287
3218
  }
3288
3219
  $taskJson.isSectionTypeSet = true;
3289
3220
  // TODO: [🍧][💩] Rearrange better - but at bottom and unwrap from function
3290
- var expectResultingParameterName = function () {
3221
+ const expectResultingParameterName = () => {
3291
3222
  if ($taskJson.resultingParameterName) {
3292
3223
  return;
3293
3224
  }
3294
- throw new ParseError("Task section and example section must end with return statement -> {parameterName}");
3225
+ throw new ParseError(`Task section and example section must end with return statement -> {parameterName}`);
3295
3226
  };
3296
3227
  if ($taskJson.content === undefined) {
3297
- throw new UnexpectedError("Content is missing in the taskJson - probbably commands are applied in wrong order");
3228
+ throw new UnexpectedError(`Content is missing in the taskJson - probbably commands are applied in wrong order`);
3298
3229
  }
3299
3230
  if (command.taskType === 'EXAMPLE') {
3300
3231
  expectResultingParameterName();
3301
- var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
3232
+ const parameter = $pipelineJson.parameters.find((param) => param.name === $taskJson.resultingParameterName);
3302
3233
  if (parameter === undefined) {
3303
3234
  // TODO: !!6 Change to logic error for higher level abstraction of chatbot to work
3304
- throw new ParseError("Parameter `{".concat($taskJson.resultingParameterName, "}` is not defined so can not define example value of it"));
3235
+ throw new ParseError(`Parameter \`{${$taskJson.resultingParameterName}}\` is not defined so can not define example value of it`);
3305
3236
  }
3306
3237
  parameter.exampleValues = parameter.exampleValues || [];
3307
3238
  parameter.exampleValues.push($taskJson.content);
@@ -3335,16 +3266,16 @@
3335
3266
  *
3336
3267
  * Note: This is used in `pipelineJsonToString` utility
3337
3268
  */
3338
- stringify: function (command) {
3339
- return "---"; // <- TODO: [🛋] Implement
3269
+ stringify(command) {
3270
+ return `---`; // <- TODO: [🛋] Implement
3340
3271
  },
3341
3272
  /**
3342
3273
  * Reads the SECTION command from the `TaskJson`
3343
3274
  *
3344
3275
  * Note: This is used in `pipelineJsonToString` utility
3345
3276
  */
3346
- takeFromTaskJson: function ($taskJson) {
3347
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
3277
+ takeFromTaskJson($taskJson) {
3278
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
3348
3279
  },
3349
3280
  };
3350
3281
  /**
@@ -3397,7 +3328,7 @@
3397
3328
  * @see `documentationUrl` for more details
3398
3329
  * @public exported from `@promptbook/editable`
3399
3330
  */
3400
- var urlCommandParser = {
3331
+ const urlCommandParser = {
3401
3332
  /**
3402
3333
  * Name of the command
3403
3334
  */
@@ -3415,7 +3346,7 @@
3415
3346
  /**
3416
3347
  * Description of the URL command
3417
3348
  */
3418
- description: "Declares unique URL for the pipeline",
3349
+ description: `Declares unique URL for the pipeline`,
3419
3350
  /**
3420
3351
  * Link to documentation
3421
3352
  */
@@ -3431,18 +3362,18 @@
3431
3362
  /**
3432
3363
  * Parses the URL command
3433
3364
  */
3434
- parse: function (input) {
3435
- var args = input.args;
3436
- var pipelineUrl = args.pop();
3365
+ parse(input) {
3366
+ const { args } = input;
3367
+ const pipelineUrl = args.pop();
3437
3368
  if (pipelineUrl === undefined) {
3438
- throw new ParseError("URL is required");
3369
+ throw new ParseError(`URL is required`);
3439
3370
  }
3440
3371
  // TODO: [🧠][🚲] This should be maybe tested as logic not parse
3441
3372
  if (!isValidPipelineUrl(pipelineUrl)) {
3442
- throw new ParseError("Invalid pipeline URL \"".concat(pipelineUrl, "\""));
3373
+ throw new ParseError(`Invalid pipeline URL "${pipelineUrl}"`);
3443
3374
  }
3444
3375
  if (args.length > 0) {
3445
- throw new ParseError("Can not have more than one pipeline URL");
3376
+ throw new ParseError(`Can not have more than one pipeline URL`);
3446
3377
  }
3447
3378
  /*
3448
3379
  TODO: [🐠 Maybe more info from `isValidPipelineUrl`:
@@ -3471,7 +3402,7 @@
3471
3402
  *
3472
3403
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
3473
3404
  */
3474
- $applyToPipelineJson: function (command, $pipelineJson) {
3405
+ $applyToPipelineJson(command, $pipelineJson) {
3475
3406
  $pipelineJson.pipelineUrl = command.pipelineUrl.href;
3476
3407
  },
3477
3408
  /**
@@ -3479,16 +3410,16 @@
3479
3410
  *
3480
3411
  * Note: This is used in `pipelineJsonToString` utility
3481
3412
  */
3482
- stringify: function (command) {
3483
- return "---"; // <- TODO: [🛋] Implement
3413
+ stringify(command) {
3414
+ return `---`; // <- TODO: [🛋] Implement
3484
3415
  },
3485
3416
  /**
3486
3417
  * Reads the URL command from the `PipelineJson`
3487
3418
  *
3488
3419
  * Note: This is used in `pipelineJsonToString` utility
3489
3420
  */
3490
- takeFromPipelineJson: function (pipelineJson) {
3491
- throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
3421
+ takeFromPipelineJson(pipelineJson) {
3422
+ throw new NotYetImplementedError(`[🛋] Not implemented yet`); // <- TODO: [🛋] Implement
3492
3423
  },
3493
3424
  };
3494
3425
 
@@ -3498,7 +3429,7 @@
3498
3429
  * @see `documentationUrl` for more details
3499
3430
  * @public exported from `@promptbook/editable`
3500
3431
  */
3501
- var actionCommandParser = {
3432
+ const actionCommandParser = {
3502
3433
  /**
3503
3434
  * Name of the command
3504
3435
  */
@@ -3511,7 +3442,7 @@
3511
3442
  /**
3512
3443
  * Description of the ACTION command
3513
3444
  */
3514
- description: "Actions influences from the pipeline or task into external world. Like turning on a light, sending an email, etc.",
3445
+ description: `Actions influences from the pipeline or task into external world. Like turning on a light, sending an email, etc.`,
3515
3446
  /**
3516
3447
  * Link to documentation
3517
3448
  */
@@ -3523,8 +3454,7 @@
3523
3454
  /**
3524
3455
  * Parses the ACTION command
3525
3456
  */
3526
- parse: function (input) {
3527
- input.args;
3457
+ parse(input) {
3528
3458
  return {
3529
3459
  type: 'ACTION',
3530
3460
  };
@@ -3534,7 +3464,7 @@
3534
3464
  *
3535
3465
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
3536
3466
  */
3537
- $applyToPipelineJson: function (command, $pipelineJson) {
3467
+ $applyToPipelineJson(command, $pipelineJson) {
3538
3468
  console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
3539
3469
  },
3540
3470
  /**
@@ -3542,7 +3472,7 @@
3542
3472
  *
3543
3473
  * Note: This is used in `pipelineJsonToString` utility
3544
3474
  */
3545
- stringify: function (command) {
3475
+ stringify(command) {
3546
3476
  throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
3547
3477
  },
3548
3478
  /**
@@ -3550,7 +3480,7 @@
3550
3480
  *
3551
3481
  * Note: This is used in `pipelineJsonToString` utility
3552
3482
  */
3553
- takeFromPipelineJson: function (pipelineJson) {
3483
+ takeFromPipelineJson(pipelineJson) {
3554
3484
  throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
3555
3485
  },
3556
3486
  };
@@ -3564,7 +3494,7 @@
3564
3494
  * @see `documentationUrl` for more details
3565
3495
  * @public exported from `@promptbook/editable`
3566
3496
  */
3567
- var instrumentCommandParser = {
3497
+ const instrumentCommandParser = {
3568
3498
  /**
3569
3499
  * Name of the command
3570
3500
  */
@@ -3577,7 +3507,7 @@
3577
3507
  /**
3578
3508
  * Description of the INSTRUMENT command
3579
3509
  */
3580
- description: "Instrument command is used to specify the instrument to be used in the pipeline or task like search, calculate, etc.",
3510
+ description: `Instrument command is used to specify the instrument to be used in the pipeline or task like search, calculate, etc.`,
3581
3511
  /**
3582
3512
  * Link to documentation
3583
3513
  */
@@ -3589,8 +3519,7 @@
3589
3519
  /**
3590
3520
  * Parses the INSTRUMENT command
3591
3521
  */
3592
- parse: function (input) {
3593
- input.args;
3522
+ parse(input) {
3594
3523
  return {
3595
3524
  type: 'INSTRUMENT',
3596
3525
  };
@@ -3600,7 +3529,7 @@
3600
3529
  *
3601
3530
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
3602
3531
  */
3603
- $applyToPipelineJson: function (command, $pipelineJson) {
3532
+ $applyToPipelineJson(command, $pipelineJson) {
3604
3533
  console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
3605
3534
  },
3606
3535
  /**
@@ -3608,7 +3537,7 @@
3608
3537
  *
3609
3538
  * Note: This is used in `pipelineJsonToString` utility
3610
3539
  */
3611
- stringify: function (command) {
3540
+ stringify(command) {
3612
3541
  throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
3613
3542
  },
3614
3543
  /**
@@ -3616,7 +3545,7 @@
3616
3545
  *
3617
3546
  * Note: This is used in `pipelineJsonToString` utility
3618
3547
  */
3619
- takeFromPipelineJson: function (pipelineJson) {
3548
+ takeFromPipelineJson(pipelineJson) {
3620
3549
  throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
3621
3550
  },
3622
3551
  };
@@ -3629,7 +3558,7 @@
3629
3558
  *
3630
3559
  * @public exported from `@promptbook/editable`
3631
3560
  */
3632
- var COMMANDS = [
3561
+ const COMMANDS = [
3633
3562
  sectionCommandParser,
3634
3563
  expectCommandParser,
3635
3564
  formatCommandParser,
@@ -3661,12 +3590,16 @@
3661
3590
  * @public exported from `@promptbook/editable`
3662
3591
  */
3663
3592
  function getParserForCommand(command) {
3664
- var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
3593
+ const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
3665
3594
  if (commandParser === undefined) {
3666
- throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " parser is not found\n\n ").concat(block(JSON.stringify(command, null, 4)
3667
- .split('\n')
3668
- .map(function (line) { return "> ".concat(line); })
3669
- .join('\n')), "\n "); }));
3595
+ throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
3596
+ Command ${command.type} parser is not found
3597
+
3598
+ ${block(JSON.stringify(command, null, 4)
3599
+ .split('\n')
3600
+ .map((line) => `> ${line}`)
3601
+ .join('\n'))}
3602
+ `));
3670
3603
  }
3671
3604
  return commandParser;
3672
3605
  }
@@ -3701,7 +3634,7 @@
3701
3634
  throw new ParseError('Command can not contain new line characters' /* <- TODO: [🚞] */);
3702
3635
  }
3703
3636
  // TODO: Unit test all this processing and parsing
3704
- var normalized = raw.trim();
3637
+ let normalized = raw.trim();
3705
3638
  normalized = normalized.split('`').join('');
3706
3639
  normalized = normalized.split('"').join('');
3707
3640
  normalized = normalized.split("'").join('');
@@ -3711,7 +3644,7 @@
3711
3644
  normalized = normalized.split('(').join('');
3712
3645
  normalized = normalized.split(')').join('');
3713
3646
  normalized = normalizeTo_SCREAMING_CASE(normalized);
3714
- var items = raw
3647
+ const items = raw
3715
3648
  .trim()
3716
3649
  // Note: [🐡]
3717
3650
  .split(/^>/)
@@ -3730,25 +3663,30 @@
3730
3663
  .join('PARAMETER {')
3731
3664
  // ---
3732
3665
  .split(' ')
3733
- .map(function (part) { return part.trim(); })
3734
- .filter(function (item) { return item !== ''; })
3666
+ .map((part) => part.trim())
3667
+ .filter((item) => item !== '')
3735
3668
  .map(removeMarkdownFormatting)
3736
- .map(function (item) { return item.trim(); });
3669
+ .map((item) => item.trim());
3737
3670
  if (items.length === 0 || items[0] === '') {
3738
- throw new ParseError(spaceTrim.spaceTrim(function (block) {
3739
- return "\n Malformed command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
3740
- }));
3671
+ throw new ParseError(spaceTrim.spaceTrim((block) => `
3672
+ Malformed command:
3673
+ - ${raw}
3674
+
3675
+ Supported commands are:
3676
+ ${block(getSupportedCommandsMessage())}
3677
+
3678
+ `));
3741
3679
  }
3742
3680
  // Note: Taking command name from beginning of the line
3743
3681
  // FOO | BAR Arg1 Arg2 Arg3
3744
3682
  // FOO BAR | Arg1 Arg2 Arg3
3745
- for (var commandNameSegmentsCount = 0; commandNameSegmentsCount < Math.min(items.length, 3); commandNameSegmentsCount++) {
3746
- var commandNameRaw = items.slice(0, commandNameSegmentsCount + 1).join('_');
3747
- var args = items.slice(commandNameSegmentsCount + 1);
3748
- var rawArgs = raw
3683
+ for (let commandNameSegmentsCount = 0; commandNameSegmentsCount < Math.min(items.length, 3); commandNameSegmentsCount++) {
3684
+ const commandNameRaw = items.slice(0, commandNameSegmentsCount + 1).join('_');
3685
+ const args = items.slice(commandNameSegmentsCount + 1);
3686
+ const rawArgs = raw
3749
3687
  .substring(commandNameRaw.length)
3750
3688
  .trim();
3751
- var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
3689
+ const command = parseCommandVariant({ usagePlace, raw, rawArgs, normalized, args, commandNameRaw });
3752
3690
  if (command !== null) {
3753
3691
  return command;
3754
3692
  }
@@ -3756,78 +3694,79 @@
3756
3694
  // Note: Taking command name from end of the line
3757
3695
  // Arg1 Arg2 Arg3 | FOO
3758
3696
  {
3759
- var commandNameRaw = items.slice(-1).join('_');
3760
- var args = items.slice(0, -1); // <- Note: This is probbably not correct
3761
- var rawArgs = raw
3697
+ const commandNameRaw = items.slice(-1).join('_');
3698
+ const args = items.slice(0, -1); // <- Note: This is probbably not correct
3699
+ const rawArgs = raw
3762
3700
  .substring(0, raw.length - commandNameRaw.length)
3763
3701
  .trim();
3764
- var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
3702
+ const command = parseCommandVariant({ usagePlace, raw, rawArgs, normalized, args, commandNameRaw });
3765
3703
  if (command !== null) {
3766
3704
  return command;
3767
3705
  }
3768
3706
  }
3769
- throw new ParseError(spaceTrim.spaceTrim(function (block) {
3770
- return "\n Malformed or unknown command:\n - ".concat(raw, "\n\n Supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
3771
- }));
3707
+ throw new ParseError(spaceTrim.spaceTrim((block) => `
3708
+ Malformed or unknown command:
3709
+ - ${raw}
3710
+
3711
+ Supported commands are:
3712
+ ${block(getSupportedCommandsMessage())}
3713
+
3714
+ `));
3772
3715
  }
3773
3716
  /**
3774
3717
  * @@@
3775
3718
  */
3776
3719
  function getSupportedCommandsMessage() {
3777
- return COMMANDS.flatMap(function (_a) {
3778
- var name = _a.name, aliasNames = _a.aliasNames, description = _a.description, documentationUrl = _a.documentationUrl;
3779
- // <- Note: [🦦] Its strange that this type assertion is needed
3780
- return __spreadArray([
3781
- "- **".concat(name, "** ").concat(description, ", see [discussion](").concat(documentationUrl, ")")
3782
- ], __read((aliasNames || []).map(function (aliasName) { return " - **".concat(aliasName, "** Alias for **").concat(name, "**"); })), false);
3783
- }).join('\n');
3720
+ return COMMANDS.flatMap(({ name, aliasNames, description, documentationUrl }) =>
3721
+ // <- Note: [🦦] Its strange that this type assertion is needed
3722
+ [
3723
+ `- **${name}** ${description}, see [discussion](${documentationUrl})`,
3724
+ ...(aliasNames || []).map((aliasName) => ` - **${aliasName}** Alias for **${name}**`),
3725
+ ]).join('\n');
3784
3726
  }
3785
3727
  /**
3786
3728
  * @@@
3787
3729
  */
3788
3730
  function parseCommandVariant(input) {
3789
- var e_1, _a;
3790
- var commandNameRaw = input.commandNameRaw, usagePlace = input.usagePlace, normalized = input.normalized, args = input.args, raw = input.raw, rawArgs = input.rawArgs;
3791
- var commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
3792
- var _loop_1 = function (commandParser) {
3731
+ const { commandNameRaw, usagePlace, normalized, args, raw, rawArgs } = input;
3732
+ const commandName = normalizeTo_SCREAMING_CASE(commandNameRaw);
3733
+ for (const commandParser of COMMANDS) {
3793
3734
  // <- Note: [🦦] Its strange that this type assertion is needed
3794
- var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTask = commandParser.isUsedInPipelineTask, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
3735
+ const { name, isUsedInPipelineHead, isUsedInPipelineTask, aliasNames, deprecatedNames, parse } = commandParser;
3795
3736
  if (just(false)) ;
3796
3737
  else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
3797
- return "continue";
3738
+ continue;
3798
3739
  }
3799
3740
  else if (usagePlace === 'PIPELINE_TASK' && !isUsedInPipelineTask) {
3800
- return "continue";
3741
+ continue;
3801
3742
  }
3802
- var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
3743
+ const names = [name, ...(aliasNames || []), ...(deprecatedNames || [])];
3803
3744
  if (names.includes(commandName)) {
3804
3745
  try {
3805
- return { value: parse({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args }) };
3746
+ return parse({ usagePlace, raw, rawArgs, normalized, args }); // <- Note: [🦦]
3806
3747
  }
3807
3748
  catch (error) {
3808
3749
  if (!(error instanceof ParseError)) {
3809
3750
  throw error;
3810
3751
  }
3811
- throw new ParseError(spaceTrim.spaceTrim(function (block) {
3812
- return "\n Invalid ".concat(commandName, " command:\n\n Your command:\n - ").concat(raw, "\n\n The detailed error:\n ").concat(block(error.message), "\n\n Usage of ").concat(commandName, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n All supported commands are:\n ").concat(block(getSupportedCommandsMessage()), "\n\n ");
3813
- }));
3752
+ throw new ParseError(spaceTrim.spaceTrim((block) => `
3753
+ Invalid ${commandName} command:
3754
+
3755
+ Your command:
3756
+ - ${raw}
3757
+
3758
+ The detailed error:
3759
+ ${block(error.message)}
3760
+
3761
+ Usage of ${commandName}:
3762
+ ${block(commandParser.examples.map((example) => `- ${example}`).join('\n'))}
3763
+
3764
+ All supported commands are:
3765
+ ${block(getSupportedCommandsMessage())}
3766
+
3767
+ `));
3814
3768
  }
3815
3769
  }
3816
- };
3817
- try {
3818
- for (var _b = __values(COMMANDS), _c = _b.next(); !_c.done; _c = _b.next()) {
3819
- var commandParser = _c.value;
3820
- var state_1 = _loop_1(commandParser);
3821
- if (typeof state_1 === "object")
3822
- return state_1.value;
3823
- }
3824
- }
3825
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3826
- finally {
3827
- try {
3828
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3829
- }
3830
- finally { if (e_1) throw e_1.error; }
3831
3770
  }
3832
3771
  return null;
3833
3772
  }
@@ -3861,13 +3800,13 @@
3861
3800
  throw new ParseError('Expected a book, but got a JSON string');
3862
3801
  }
3863
3802
  else if (isValidUrl(pipelineString)) {
3864
- throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
3803
+ throw new ParseError(`Expected a book, but got just the URL "${pipelineString}"`);
3865
3804
  }
3866
3805
  else if (isValidFilePath(pipelineString)) {
3867
- throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
3806
+ throw new ParseError(`Expected a book, but got just the file path "${pipelineString}"`);
3868
3807
  }
3869
3808
  else if (isValidEmail(pipelineString)) {
3870
- throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
3809
+ throw new ParseError(`Expected a book, but got just the email "${pipelineString}"`);
3871
3810
  }
3872
3811
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
3873
3812
  return pipelineString;
@@ -3895,16 +3834,16 @@
3895
3834
  function isFlatPipeline(pipelineString) {
3896
3835
  pipelineString = removeMarkdownComments(pipelineString);
3897
3836
  pipelineString = spaceTrim__default["default"](pipelineString);
3898
- var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
3837
+ const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
3899
3838
  //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
3900
- var isBacktickBlockUsed = pipelineString.includes('```');
3901
- var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
3902
- var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
3839
+ const isBacktickBlockUsed = pipelineString.includes('```');
3840
+ const isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
3841
+ const isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
3903
3842
  // TODO: [🧉] Also (double)check
3904
3843
  // > const usedCommands
3905
3844
  // > const isBlocksUsed
3906
3845
  // > const returnStatementCount
3907
- var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
3846
+ const isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
3908
3847
  return isFlat;
3909
3848
  }
3910
3849
 
@@ -3917,27 +3856,39 @@
3917
3856
  if (!isFlatPipeline(pipelineString)) {
3918
3857
  return pipelineString;
3919
3858
  }
3920
- var pipelineStringLines = pipelineString.split('\n');
3921
- var potentialReturnStatement = pipelineStringLines.pop();
3922
- var returnStatement;
3859
+ const pipelineStringLines = pipelineString.split('\n');
3860
+ const potentialReturnStatement = pipelineStringLines.pop();
3861
+ let returnStatement;
3923
3862
  if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
3924
3863
  // Note: Last line is return statement
3925
3864
  returnStatement = potentialReturnStatement;
3926
3865
  }
3927
3866
  else {
3928
3867
  // Note: Last line is not a return statement
3929
- returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
3868
+ returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
3930
3869
  pipelineStringLines.push(potentialReturnStatement);
3931
3870
  }
3932
- var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
3933
- var quotedPrompt;
3871
+ const prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
3872
+ let quotedPrompt;
3934
3873
  if (prompt.split('\n').length <= 1) {
3935
- quotedPrompt = "> ".concat(prompt);
3874
+ quotedPrompt = `> ${prompt}`;
3936
3875
  }
3937
3876
  else {
3938
- quotedPrompt = spaceTrim__default["default"](function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
3877
+ quotedPrompt = spaceTrim__default["default"]((block) => `
3878
+ \`\`\`
3879
+ ${block(prompt.split('`').join('\\`'))}
3880
+ \`\`\`
3881
+ `);
3939
3882
  }
3940
- pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
3883
+ pipelineString = validatePipelineString(spaceTrim__default["default"]((block) => `
3884
+ # ${DEFAULT_BOOK_TITLE}
3885
+
3886
+ ## Prompt
3887
+
3888
+ ${block(quotedPrompt)}
3889
+
3890
+ ${returnStatement}
3891
+ `));
3941
3892
  // <- TODO: Maybe use book` notation
3942
3893
  return pipelineString;
3943
3894
  }
@@ -3951,37 +3902,26 @@
3951
3902
  * @public exported from `@promptbook/editable`
3952
3903
  */
3953
3904
  function addPipelineCommand(options) {
3954
- var e_1, _a;
3955
- var commandString = options.commandString, pipelineString = options.pipelineString;
3956
- var deflatedPipelineString = deflatePipeline(pipelineString);
3957
- var lines = deflatedPipelineString.split('\n');
3958
- var newLines = [];
3959
- var isCommandAdded = false;
3960
- try {
3961
- for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
3962
- var line = lines_1_1.value;
3963
- // Add command before second (or more) heading
3964
- if (!isCommandAdded && line.startsWith('##')) {
3965
- newLines.push("- ".concat(commandString));
3966
- newLines.push('');
3967
- isCommandAdded = true;
3968
- }
3969
- newLines.push(line);
3970
- }
3971
- }
3972
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3973
- finally {
3974
- try {
3975
- if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
3905
+ const { commandString, pipelineString } = options;
3906
+ const deflatedPipelineString = deflatePipeline(pipelineString);
3907
+ const lines = deflatedPipelineString.split('\n');
3908
+ const newLines = [];
3909
+ let isCommandAdded = false;
3910
+ for (const line of lines) {
3911
+ // Add command before second (or more) heading
3912
+ if (!isCommandAdded && line.startsWith('##')) {
3913
+ newLines.push(`- ${commandString}`);
3914
+ newLines.push('');
3915
+ isCommandAdded = true;
3976
3916
  }
3977
- finally { if (e_1) throw e_1.error; }
3917
+ newLines.push(line);
3978
3918
  }
3979
3919
  if (!isCommandAdded) {
3980
3920
  // Note: Only situation when this should happen is when pipeline has no tasks
3981
3921
  if ((newLines[newLines.length - 1] || '').startsWith('#')) {
3982
3922
  newLines.push('');
3983
3923
  }
3984
- newLines.push("- ".concat(commandString));
3924
+ newLines.push(`- ${commandString}`);
3985
3925
  /*
3986
3926
  TODO: [🧠] Is this error relevant:
3987
3927
  throw new UnexpectedError(
@@ -4021,47 +3961,36 @@
4021
3961
  * @public exported from `@promptbook/editable`
4022
3962
  */
4023
3963
  function removePipelineCommand(options) {
4024
- var e_1, _a;
4025
- var command = options.command, pipelineString = options.pipelineString;
4026
- var lines = pipelineString.split('\n');
3964
+ const { command, pipelineString } = options;
3965
+ const lines = pipelineString.split('\n');
4027
3966
  // TODO: [🧽] DRY
4028
- var currentType = 'MARKDOWN';
4029
- var newLines = [];
4030
- try {
4031
- for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
4032
- var line = lines_1_1.value;
4033
- if (currentType === 'MARKDOWN') {
4034
- if (line.startsWith('```')) {
4035
- currentType = 'CODE_BLOCK';
4036
- }
4037
- else if (line.includes('<!--')) {
4038
- currentType = 'COMMENT';
4039
- }
3967
+ let currentType = 'MARKDOWN';
3968
+ const newLines = [];
3969
+ for (const line of lines) {
3970
+ if (currentType === 'MARKDOWN') {
3971
+ if (line.startsWith('```')) {
3972
+ currentType = 'CODE_BLOCK';
4040
3973
  }
4041
- else if (currentType === 'CODE_BLOCK') {
4042
- if (line.startsWith('```')) {
4043
- currentType = 'MARKDOWN';
4044
- }
3974
+ else if (line.includes('<!--')) {
3975
+ currentType = 'COMMENT';
4045
3976
  }
4046
- else if (currentType === 'COMMENT') {
4047
- if (line.includes('-->')) {
4048
- currentType = 'MARKDOWN';
4049
- }
3977
+ }
3978
+ else if (currentType === 'CODE_BLOCK') {
3979
+ if (line.startsWith('```')) {
3980
+ currentType = 'MARKDOWN';
4050
3981
  }
4051
- if (currentType === 'MARKDOWN' && /^(-|\d\))/m.test(line) && line.toUpperCase().includes(command)) {
4052
- continue;
3982
+ }
3983
+ else if (currentType === 'COMMENT') {
3984
+ if (line.includes('-->')) {
3985
+ currentType = 'MARKDOWN';
4053
3986
  }
4054
- newLines.push(line);
4055
3987
  }
4056
- }
4057
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4058
- finally {
4059
- try {
4060
- if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
3988
+ if (currentType === 'MARKDOWN' && /^(-|\d\))/m.test(line) && line.toUpperCase().includes(command)) {
3989
+ continue;
4061
3990
  }
4062
- finally { if (e_1) throw e_1.error; }
3991
+ newLines.push(line);
4063
3992
  }
4064
- var newPipeline = spaceTrim__default["default"](newLines.join('\n'));
3993
+ const newPipeline = spaceTrim__default["default"](newLines.join('\n'));
4065
3994
  return newPipeline;
4066
3995
  }
4067
3996
 
@@ -4070,16 +3999,13 @@
4070
3999
  *
4071
4000
  * @public exported from `@promptbook/core`
4072
4001
  */
4073
- var PipelineLogicError = /** @class */ (function (_super) {
4074
- __extends(PipelineLogicError, _super);
4075
- function PipelineLogicError(message) {
4076
- var _this = _super.call(this, message) || this;
4077
- _this.name = 'PipelineLogicError';
4078
- Object.setPrototypeOf(_this, PipelineLogicError.prototype);
4079
- return _this;
4002
+ class PipelineLogicError extends Error {
4003
+ constructor(message) {
4004
+ super(message);
4005
+ this.name = 'PipelineLogicError';
4006
+ Object.setPrototypeOf(this, PipelineLogicError.prototype);
4080
4007
  }
4081
- return PipelineLogicError;
4082
- }(Error));
4008
+ }
4083
4009
 
4084
4010
  /**
4085
4011
  * Function `renamePipelineParameter` will find all usable parameters for given task
@@ -4089,53 +4015,33 @@
4089
4015
  * @public exported from `@promptbook/editable`
4090
4016
  */
4091
4017
  function renamePipelineParameter(options) {
4092
- var e_1, _a, e_2, _b;
4093
- var pipeline = options.pipeline, oldParameterName = options.oldParameterName, newParameterName = options.newParameterName;
4094
- if (pipeline.parameters.some(function (parameter) { return parameter.name === newParameterName; })) {
4095
- throw new PipelineLogicError("Can not replace {".concat(oldParameterName, "} to {").concat(newParameterName, "} because {").concat(newParameterName, "} is already used in the pipeline"));
4018
+ const { pipeline: pipeline, oldParameterName, newParameterName } = options;
4019
+ if (pipeline.parameters.some((parameter) => parameter.name === newParameterName)) {
4020
+ throw new PipelineLogicError(`Can not replace {${oldParameterName}} to {${newParameterName}} because {${newParameterName}} is already used in the pipeline`);
4096
4021
  }
4097
- var renamedPipeline = __assign(__assign({}, pipeline), {
4022
+ const renamedPipeline = {
4023
+ ...pipeline,
4098
4024
  // <- TODO: [🪓] This should be without `as $PipelineJson`
4099
- parameters: __spreadArray([], __read(pipeline.parameters), false), tasks: __spreadArray([], __read(pipeline.tasks), false) });
4100
- try {
4101
- for (var _c = __values(renamedPipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
4102
- var parameter = _d.value;
4103
- if (parameter.name !== oldParameterName) {
4104
- continue;
4105
- }
4106
- parameter.name = newParameterName;
4107
- }
4108
- }
4109
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4110
- finally {
4111
- try {
4112
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
4113
- }
4114
- finally { if (e_1) throw e_1.error; }
4115
- }
4116
- try {
4117
- for (var _e = __values(renamedPipeline.tasks), _f = _e.next(); !_f.done; _f = _e.next()) {
4118
- var task = _f.value;
4119
- if (task.resultingParameterName === oldParameterName) {
4120
- task.resultingParameterName = newParameterName;
4121
- }
4122
- task.dependentParameterNames = task.dependentParameterNames.map(function (dependentParameterName) {
4123
- return dependentParameterName === oldParameterName ? newParameterName : dependentParameterName;
4124
- });
4125
- task.content = task.content.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
4126
- task.title = task.title.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
4127
- task.description =
4128
- task.description === undefined
4129
- ? undefined
4130
- : task.description.replace(new RegExp("{".concat(oldParameterName, "}"), 'g'), "{".concat(newParameterName, "}"));
4025
+ parameters: [...pipeline.parameters],
4026
+ tasks: [...pipeline.tasks],
4027
+ };
4028
+ for (const parameter of renamedPipeline.parameters) {
4029
+ if (parameter.name !== oldParameterName) {
4030
+ continue;
4131
4031
  }
4032
+ parameter.name = newParameterName;
4132
4033
  }
4133
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
4134
- finally {
4135
- try {
4136
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
4034
+ for (const task of renamedPipeline.tasks) {
4035
+ if (task.resultingParameterName === oldParameterName) {
4036
+ task.resultingParameterName = newParameterName;
4137
4037
  }
4138
- finally { if (e_2) throw e_2.error; }
4038
+ task.dependentParameterNames = task.dependentParameterNames.map((dependentParameterName) => dependentParameterName === oldParameterName ? newParameterName : dependentParameterName);
4039
+ task.content = task.content.replace(new RegExp(`{${oldParameterName}}`, 'g'), `{${newParameterName}}`);
4040
+ task.title = task.title.replace(new RegExp(`{${oldParameterName}}`, 'g'), `{${newParameterName}}`);
4041
+ task.description =
4042
+ task.description === undefined
4043
+ ? undefined
4044
+ : task.description.replace(new RegExp(`{${oldParameterName}}`, 'g'), `{${newParameterName}}`);
4139
4045
  }
4140
4046
  return renamedPipeline;
4141
4047
  }
@@ -4165,7 +4071,7 @@
4165
4071
  */
4166
4072
  function isSerializableAsJson(value) {
4167
4073
  try {
4168
- checkSerializableAsJson({ value: value });
4074
+ checkSerializableAsJson({ value });
4169
4075
  return true;
4170
4076
  }
4171
4077
  catch (error) {
@@ -4187,11 +4093,17 @@
4187
4093
  */
4188
4094
  function stringifyPipelineJson(pipeline) {
4189
4095
  if (!isSerializableAsJson(pipeline)) {
4190
- throw new UnexpectedError(spaceTrim__default["default"]("\n Cannot stringify the pipeline, because it is not serializable as JSON\n\n There can be multiple reasons:\n 1) The pipeline contains circular references\n 2) It is not a valid PipelineJson\n "));
4096
+ throw new UnexpectedError(spaceTrim__default["default"](`
4097
+ Cannot stringify the pipeline, because it is not serializable as JSON
4098
+
4099
+ There can be multiple reasons:
4100
+ 1) The pipeline contains circular references
4101
+ 2) It is not a valid PipelineJson
4102
+ `));
4191
4103
  }
4192
- var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
4193
- for (var i = 0; i < LOOP_LIMIT; i++) {
4194
- pipelineJsonStringified = pipelineJsonStringified.replace(/(-?0\.\d+),[\n\s]+(-?0\.\d+)/gms, "$1".concat(REPLACING_NONCE, "$2"));
4104
+ let pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
4105
+ for (let i = 0; i < LOOP_LIMIT; i++) {
4106
+ pipelineJsonStringified = pipelineJsonStringified.replace(/(-?0\.\d+),[\n\s]+(-?0\.\d+)/gms, `$1${REPLACING_NONCE}$2`);
4195
4107
  }
4196
4108
  pipelineJsonStringified = pipelineJsonStringified.split(REPLACING_NONCE).join(', ');
4197
4109
  pipelineJsonStringified += '\n';