@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/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('path'), require('moment')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'path', 'moment'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.path, global.moment));
5
- })(this, (function (exports, spaceTrim, prettier, parserHtml, path, moment) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('moment')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'moment'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.moment));
5
+ })(this, (function (exports, spaceTrim, prettier, parserHtml, moment) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -454,7 +454,7 @@
454
454
  /**
455
455
  * The version of the Promptbook library
456
456
  */
457
- var PROMPTBOOK_VERSION = '0.52.0-14';
457
+ var PROMPTBOOK_VERSION = '0.52.0-16';
458
458
 
459
459
  /**
460
460
  * Parses the template and returns the list of all parameter names
@@ -3175,23 +3175,6 @@
3175
3175
  */
3176
3176
  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");
3177
3177
 
3178
- /**
3179
- * Returns the same value that is passed as argument.
3180
- * No side effects.
3181
- *
3182
- * Note: It can be usefull for leveling indentation
3183
- *
3184
- * @param value any values
3185
- * @returns the same values
3186
- */
3187
- function just(value) {
3188
- if (value === undefined) {
3189
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3190
- return undefined;
3191
- }
3192
- return value;
3193
- }
3194
-
3195
3178
  /**
3196
3179
  * This error indicates that promptbook not found in the library
3197
3180
  */
@@ -3430,32 +3413,34 @@
3430
3413
  * @param options - Misc options for the library
3431
3414
  * @returns PromptbookLibrary
3432
3415
  */
3433
- function createPromptbookLibraryFromDirectory(path$1, options) {
3416
+ function createPromptbookLibraryFromDirectory(path, options) {
3434
3417
  var _this = this;
3435
3418
  if (!isRunningInNode()) {
3436
3419
  throw new Error('Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3437
3420
  }
3438
3421
  var _a = (options || {}).isRecursive, isRecursive = _a === void 0 ? true : _a;
3439
3422
  return createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3440
- var justR_equire, readdir, dirents, fileNames;
3441
3423
  return __generator(this, function (_a) {
3442
- switch (_a.label) {
3443
- case 0:
3444
- justR_equire = require;
3445
- readdir = justR_equire(just('fs/promises') /* <- Note: [2] */).readdir;
3446
- return [4 /*yield*/, readdir(path$1, {
3447
- withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
3448
- })];
3449
- case 1:
3450
- dirents = _a.sent();
3451
- fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
3452
- var name = _a.name;
3453
- return path.join(name, path$1);
3454
- });
3455
- // TODO: !!! Implement
3456
- console.info('createPromptbookLibraryFromDirectory', { path: path$1, isRecursive: isRecursive, fileNames: fileNames });
3457
- throw new Error('Not implemented yet');
3458
- }
3424
+ /*
3425
+ const justR_equire = require; /* <- Note: [1] * /
3426
+ const readdir = justR_equire(just('fs/promises') /* <- Note: [2] * /).readdir as typeof readdirType;
3427
+
3428
+ // TODO: !!!! Implement recursive reading
3429
+ // TODO: !!!!! readAllFiles util
3430
+
3431
+ const dirents = await readdir(path, {
3432
+ withFileTypes: true /* Note: This is not working: recursive: isRecursive * /,
3433
+ });
3434
+ const fileNames = dirents.filter((dirent) => dirent.isFile()).map(({ name }) => join(name, path));
3435
+
3436
+ // TODO: !!! Implement
3437
+
3438
+ console.info('createPromptbookLibraryFromDirectory', { path, isRecursive, fileNames });
3439
+ throw new Error('Not implemented yet');
3440
+
3441
+ */
3442
+ console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive });
3443
+ return [2 /*return*/, []];
3459
3444
  });
3460
3445
  }); });
3461
3446
  }
@@ -3567,6 +3552,45 @@
3567
3552
  * TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
3568
3553
  */
3569
3554
 
3555
+ /**
3556
+ * Returns the same value that is passed as argument.
3557
+ * No side effects.
3558
+ *
3559
+ * Note: It can be usefull for leveling indentation
3560
+ *
3561
+ * @param value any values
3562
+ * @returns the same values
3563
+ */
3564
+ function just(value) {
3565
+ if (value === undefined) {
3566
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3567
+ return undefined;
3568
+ }
3569
+ return value;
3570
+ }
3571
+
3572
+ /**
3573
+ * Just testing imports and compatibility
3574
+ */
3575
+ function justTestFsImport() {
3576
+ return __awaiter(this, void 0, void 0, function () {
3577
+ var files;
3578
+ return __generator(this, function (_a) {
3579
+ switch (_a.label) {
3580
+ case 0:
3581
+ if (!isRunningInNode()) {
3582
+ throw new Error('Function `testFiles` can only be run in Node.js environment because it reads the file system.');
3583
+ }
3584
+ return [4 /*yield*/, require(just('glob-promise'))('/**/*')];
3585
+ case 1:
3586
+ files = _a.sent();
3587
+ console.info('testFiles', { files: files });
3588
+ return [2 /*return*/];
3589
+ }
3590
+ });
3591
+ });
3592
+ }
3593
+
3570
3594
  /**
3571
3595
  * Format either small or big number
3572
3596
  *
@@ -3884,6 +3908,7 @@
3884
3908
  exports.createPromptbookSublibrary = createPromptbookSublibrary;
3885
3909
  exports.executionReportJsonToString = executionReportJsonToString;
3886
3910
  exports.isPassingExpectations = isPassingExpectations;
3911
+ exports.justTestFsImport = justTestFsImport;
3887
3912
  exports.prettifyPromptbookString = prettifyPromptbookString;
3888
3913
  exports.promptbookJsonToString = promptbookJsonToString;
3889
3914
  exports.promptbookStringToJson = promptbookStringToJson;