@promptbook/cli 0.84.0-12 → 0.84.0-13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.84.0-12",
3
+ "version": "0.84.0-13",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
package/umd/index.umd.js CHANGED
@@ -51,7 +51,7 @@
51
51
  * @generated
52
52
  * @see https://github.com/webgptorg/promptbook
53
53
  */
54
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-11';
54
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-12';
55
55
  /**
56
56
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
57
57
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6523,7 +6523,7 @@
6523
6523
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6524
6524
  var _a;
6525
6525
  return __awaiter(this, void 0, void 0, function () {
6526
- var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response, mimeType, filename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
6526
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, basename, hash, rootDirname_1, filepath, _f, _g, _h, _j, _k, filename_1, fileExtension, mimeType;
6527
6527
  return __generator(this, function (_l) {
6528
6528
  switch (_l.label) {
6529
6529
  case 0:
@@ -6539,19 +6539,61 @@
6539
6539
  url = knowledgeSourceContent;
6540
6540
  return [4 /*yield*/, fetch(url)];
6541
6541
  case 1:
6542
- response = _l.sent();
6543
- mimeType = ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6544
- filename = url.split('/').pop() || titleToName(url);
6542
+ response_1 = _l.sent();
6543
+ mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
6544
+ if (tools.fs === undefined || !url.endsWith('.pdf')) {
6545
+ return [2 /*return*/, {
6546
+ source: name,
6547
+ filename: null,
6548
+ url: url,
6549
+ mimeType: mimeType,
6550
+ /*
6551
+ TODO: [🥽]
6552
+ > async asBlob() {
6553
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
6554
+ > const content = await response.blob();
6555
+ > return content;
6556
+ > },
6557
+ */
6558
+ asJson: function () {
6559
+ return __awaiter(this, void 0, void 0, function () {
6560
+ var content;
6561
+ return __generator(this, function (_a) {
6562
+ switch (_a.label) {
6563
+ case 0: return [4 /*yield*/, response_1.json()];
6564
+ case 1:
6565
+ content = _a.sent();
6566
+ return [2 /*return*/, content];
6567
+ }
6568
+ });
6569
+ });
6570
+ },
6571
+ asText: function () {
6572
+ return __awaiter(this, void 0, void 0, function () {
6573
+ var content;
6574
+ return __generator(this, function (_a) {
6575
+ switch (_a.label) {
6576
+ case 0: return [4 /*yield*/, response_1.text()];
6577
+ case 1:
6578
+ content = _a.sent();
6579
+ return [2 /*return*/, content];
6580
+ }
6581
+ });
6582
+ });
6583
+ },
6584
+ }];
6585
+ }
6586
+ basename = url.split('/').pop() || titleToName(url);
6545
6587
  hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
6546
6588
  rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
6547
- filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(filename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
6589
+ filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
6548
6590
  return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
6549
6591
  case 2:
6550
6592
  _l.sent();
6551
6593
  _g = (_f = tools.fs).writeFile;
6552
6594
  _h = [path.join(rootDirname_1, filepath)];
6553
6595
  _k = (_j = Buffer).from;
6554
- return [4 /*yield*/, response.arrayBuffer()];
6596
+ return [4 /*yield*/, response_1.arrayBuffer()];
6555
6597
  case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
6556
6598
  case 4:
6557
6599
  _l.sent();