@promptbook/cli 0.71.0-21 → 0.71.0-24

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.
@@ -51,12 +51,9 @@ export type ScraperSourceHandler = {
51
51
  * Get the content as a utf-8 string
52
52
  */
53
53
  asText(): Promisable<string>;
54
- /**
55
- * Get the content as a blob
56
- */
57
- asBlob(): Promisable<Blob>;
58
54
  };
59
55
  /**
56
+ * TODO: [🥽] Add ` asBlob(): Promisable<Blob>;` or asFile
60
57
  * TODO: [🐝] @@@ Annotate all
61
58
  * TODO: [🔼] Export via types
62
59
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.71.0-21",
3
+ "version": "0.71.0-24",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -39,7 +39,7 @@
39
39
  /**
40
40
  * The version of the Promptbook library
41
41
  */
42
- var PROMPTBOOK_VERSION = '0.71.0-20';
42
+ var PROMPTBOOK_VERSION = '0.71.0-23';
43
43
  // TODO: [main] !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -5185,7 +5185,7 @@
5185
5185
  return __awaiter(this, void 0, void 0, function () {
5186
5186
  var sourceContent, name, _b, _c, rootDirname, _d,
5187
5187
  // <- TODO: process.cwd() if running in Node.js
5188
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
5188
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5189
5189
  return __generator(this, function (_e) {
5190
5190
  switch (_e.label) {
5191
5191
  case 0:
@@ -5207,19 +5207,14 @@
5207
5207
  filename: null,
5208
5208
  url: url,
5209
5209
  mimeType: mimeType,
5210
- asBlob: function () {
5211
- return __awaiter(this, void 0, void 0, function () {
5212
- var content;
5213
- return __generator(this, function (_a) {
5214
- switch (_a.label) {
5215
- case 0: return [4 /*yield*/, response_1.blob()];
5216
- case 1:
5217
- content = _a.sent();
5218
- return [2 /*return*/, content];
5219
- }
5220
- });
5221
- });
5222
- },
5210
+ /*
5211
+ TODO: [🥽]
5212
+ > async asBlob() {
5213
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
5214
+ > const content = await response.blob();
5215
+ > return content;
5216
+ > },
5217
+ */
5223
5218
  asJson: function () {
5224
5219
  return __awaiter(this, void 0, void 0, function () {
5225
5220
  var content;
@@ -5259,34 +5254,31 @@
5259
5254
  }
5260
5255
  filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
5261
5256
  fileExtension = getFileExtension(filename_1);
5262
- mimeType_1 = extensionToMimeType(fileExtension || '');
5257
+ mimeType = extensionToMimeType(fileExtension || '');
5263
5258
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5264
5259
  case 3:
5265
5260
  if (!(_e.sent())) {
5266
5261
  throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
5267
5262
  }
5268
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
5263
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5269
5264
  return [2 /*return*/, {
5270
5265
  source: name,
5271
5266
  filename: filename_1,
5272
5267
  url: null,
5273
- mimeType: mimeType_1,
5274
- asBlob: function () {
5275
- return __awaiter(this, void 0, void 0, function () {
5276
- var content;
5277
- return __generator(this, function (_a) {
5278
- switch (_a.label) {
5279
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5280
- case 1:
5281
- content = _a.sent();
5282
- return [2 /*return*/, new Blob([
5283
- content,
5284
- // <- TODO: !!!!!! Test that this is working
5285
- ], { type: mimeType_1 })];
5286
- }
5287
- });
5288
- });
5289
- },
5268
+ mimeType: mimeType,
5269
+ /*
5270
+ TODO: [🥽]
5271
+ > async asBlob() {
5272
+ > const content = await tools.fs!.readFile(filename);
5273
+ > return new Blob(
5274
+ > [
5275
+ > content,
5276
+ > // <- TODO: [🥽] This is NOT tested, test it
5277
+ > ],
5278
+ > { type: mimeType },
5279
+ > );
5280
+ > },
5281
+ */
5290
5282
  asJson: function () {
5291
5283
  return __awaiter(this, void 0, void 0, function () {
5292
5284
  var _a, _b;
@@ -5322,9 +5314,14 @@
5322
5314
  asJson: function () {
5323
5315
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
5324
5316
  },
5325
- asBlob: function () {
5326
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
5327
- },
5317
+ /*
5318
+ TODO: [🥽]
5319
+ > asBlob() {
5320
+ > throw new UnexpectedError(
5321
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
5322
+ > );
5323
+ > },
5324
+ */
5328
5325
  }];
5329
5326
  }
5330
5327
  });
@@ -5649,6 +5646,7 @@
5649
5646
  'KNOWLEDGE ./hejny-cv.md',
5650
5647
  'KNOWLEDGE ./hejny-cv.pdf',
5651
5648
  'KNOWLEDGE ./hejny-cv.docx',
5649
+ // <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
5652
5650
  ],
5653
5651
  /**
5654
5652
  * Parses the KNOWLEDGE command
@@ -13401,9 +13399,14 @@
13401
13399
  asJson: function () {
13402
13400
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
13403
13401
  },
13404
- asBlob: function () {
13405
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
13406
- },
13402
+ /*
13403
+ TODO: [🥽]
13404
+ > asBlob() {
13405
+ > throw new UnexpectedError(
13406
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
13407
+ > );
13408
+ > },
13409
+ */
13407
13410
  };
13408
13411
  knowledge = this.markdownScraper.scrape(markdownSource);
13409
13412
  return [4 /*yield*/, cacheFilehandler.destroy()];
@@ -13569,9 +13572,14 @@
13569
13572
  asJson: function () {
13570
13573
  throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asJson`');
13571
13574
  },
13572
- asBlob: function () {
13573
- throw new UnexpectedError('Did not expect that `documentScraper` would need to get the content `asBlob`');
13574
- },
13575
+ /*
13576
+ TODO: [🥽]
13577
+ > asBlob() {
13578
+ > throw new UnexpectedError(
13579
+ > 'Did not expect that `documentScraper` would need to get the content `asBlob`',
13580
+ > );
13581
+ > },
13582
+ */
13575
13583
  };
13576
13584
  knowledge = this.documentScraper.scrape(markdownSource);
13577
13585
  return [4 /*yield*/, cacheFilehandler.destroy()];
@@ -13859,7 +13867,6 @@
13859
13867
  switch (_g.label) {
13860
13868
  case 0:
13861
13869
  _a = this.options, _b = _a.rootDirname, rootDirname = _b === void 0 ? process.cwd() : _b, _c = _a.cacheDirname, cacheDirname = _c === void 0 ? DEFAULT_SCRAPE_CACHE_DIRNAME : _c, _d = _a.intermediateFilesStrategy, intermediateFilesStrategy = _d === void 0 ? DEFAULT_INTERMEDIATE_FILES_STRATEGY : _d, _e = _a.isVerbose, isVerbose = _e === void 0 ? DEFAULT_IS_VERBOSE : _e;
13862
- // TODO: !!!!!! Does this work in browser? Make it work.
13863
13870
  if (source.url === null) {
13864
13871
  throw new KnowledgeScrapeError('Website scraper requires URL');
13865
13872
  }
@@ -13919,9 +13926,14 @@
13919
13926
  asJson: function () {
13920
13927
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
13921
13928
  },
13922
- asBlob: function () {
13923
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
13924
- },
13929
+ /*
13930
+ TODO: [🥽]
13931
+ > asBlob() {
13932
+ > throw new UnexpectedError(
13933
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
13934
+ > );
13935
+ > },
13936
+ */
13925
13937
  };
13926
13938
  knowledge = this.markdownScraper.scrape(markdownSource);
13927
13939
  return [4 /*yield*/, cacheFilehandler.destroy()];