@promptbook/core 0.52.0-15 → 0.52.0-17

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/esm/index.es.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import spaceTrim$1, { spaceTrim } from 'spacetrim';
2
2
  import { format } from 'prettier';
3
3
  import parserHtml from 'prettier/parser-html';
4
- import { join } from 'path';
5
4
  import moment from 'moment';
6
5
 
7
6
  /*! *****************************************************************************
@@ -448,7 +447,7 @@ function union() {
448
447
  /**
449
448
  * The version of the Promptbook library
450
449
  */
451
- var PROMPTBOOK_VERSION = '0.52.0-14';
450
+ var PROMPTBOOK_VERSION = '0.52.0-16';
452
451
 
453
452
  /**
454
453
  * Parses the template and returns the list of all parameter names
@@ -3169,23 +3168,6 @@ var isRunningInNode = new Function("\n try {\n return this === global;
3169
3168
  */
3170
3169
  new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
3171
3170
 
3172
- /**
3173
- * Returns the same value that is passed as argument.
3174
- * No side effects.
3175
- *
3176
- * Note: It can be usefull for leveling indentation
3177
- *
3178
- * @param value any values
3179
- * @returns the same values
3180
- */
3181
- function just(value) {
3182
- if (value === undefined) {
3183
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3184
- return undefined;
3185
- }
3186
- return value;
3187
- }
3188
-
3189
3171
  /**
3190
3172
  * This error indicates that promptbook not found in the library
3191
3173
  */
@@ -3431,25 +3413,27 @@ function createPromptbookLibraryFromDirectory(path, options) {
3431
3413
  }
3432
3414
  var _a = (options || {}).isRecursive, isRecursive = _a === void 0 ? true : _a;
3433
3415
  return createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3434
- var justR_equire, readdir, dirents, fileNames;
3435
3416
  return __generator(this, function (_a) {
3436
- switch (_a.label) {
3437
- case 0:
3438
- justR_equire = require;
3439
- readdir = justR_equire(just('fs/promises') /* <- Note: [2] */).readdir;
3440
- return [4 /*yield*/, readdir(path, {
3441
- withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
3442
- })];
3443
- case 1:
3444
- dirents = _a.sent();
3445
- fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
3446
- var name = _a.name;
3447
- return join(name, path);
3448
- });
3449
- // TODO: !!! Implement
3450
- console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
3451
- throw new Error('Not implemented yet');
3452
- }
3417
+ /*
3418
+ const justR_equire = require; /* <- Note: [1] * /
3419
+ const readdir = justR_equire(just('fs/promises') /* <- Note: [2] * /).readdir as typeof readdirType;
3420
+
3421
+ // TODO: !!!! Implement recursive reading
3422
+ // TODO: !!!!! readAllFiles util
3423
+
3424
+ const dirents = await readdir(path, {
3425
+ withFileTypes: true /* Note: This is not working: recursive: isRecursive * /,
3426
+ });
3427
+ const fileNames = dirents.filter((dirent) => dirent.isFile()).map(({ name }) => join(name, path));
3428
+
3429
+ // TODO: !!! Implement
3430
+
3431
+ console.info('createPromptbookLibraryFromDirectory', { path, isRecursive, fileNames });
3432
+ throw new Error('Not implemented yet');
3433
+
3434
+ */
3435
+ console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive });
3436
+ return [2 /*return*/, []];
3453
3437
  });
3454
3438
  }); });
3455
3439
  }
@@ -3561,6 +3545,45 @@ function createPromptbookSublibrary(library, predicate) {
3561
3545
  * TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
3562
3546
  */
3563
3547
 
3548
+ /**
3549
+ * Returns the same value that is passed as argument.
3550
+ * No side effects.
3551
+ *
3552
+ * Note: It can be usefull for leveling indentation
3553
+ *
3554
+ * @param value any values
3555
+ * @returns the same values
3556
+ */
3557
+ function just(value) {
3558
+ if (value === undefined) {
3559
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3560
+ return undefined;
3561
+ }
3562
+ return value;
3563
+ }
3564
+
3565
+ /**
3566
+ * Just testing imports and compatibility
3567
+ */
3568
+ function justTestFsImport() {
3569
+ return __awaiter(this, void 0, void 0, function () {
3570
+ var files;
3571
+ return __generator(this, function (_a) {
3572
+ switch (_a.label) {
3573
+ case 0:
3574
+ if (!isRunningInNode()) {
3575
+ throw new Error('Function `testFiles` can only be run in Node.js environment because it reads the file system.');
3576
+ }
3577
+ return [4 /*yield*/, require(just('glob-promise'))('/**/*')];
3578
+ case 1:
3579
+ files = _a.sent();
3580
+ console.info('testFiles', { files: files });
3581
+ return [2 /*return*/];
3582
+ }
3583
+ });
3584
+ });
3585
+ }
3586
+
3564
3587
  /**
3565
3588
  * Format either small or big number
3566
3589
  *
@@ -3861,5 +3884,5 @@ function executionReportJsonToString(executionReportJson, options) {
3861
3884
  * TODO: [🧠] Allow to filter out some parts of the report by options
3862
3885
  */
3863
3886
 
3864
- export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, SimplePromptInterfaceTools, SimplePromptbookLibrary, assertsExecutionSuccessful, checkExpectations, createPromptbookExecutor, createPromptbookLibraryFromDirectory, createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, executionReportJsonToString, isPassingExpectations, prettifyPromptbookString, promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
3887
+ export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, SimplePromptInterfaceTools, SimplePromptbookLibrary, assertsExecutionSuccessful, checkExpectations, createPromptbookExecutor, createPromptbookLibraryFromDirectory, createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, executionReportJsonToString, isPassingExpectations, justTestFsImport, prettifyPromptbookString, promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
3865
3888
  //# sourceMappingURL=index.es.js.map