@promptbook/markdown-utils 0.85.0-0 → 0.85.0-1
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 +5 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +2 -0
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +6 -4
- package/package.json +1 -1
- package/umd/index.umd.js +14 -14
- package/umd/index.umd.js.map +1 -1
|
@@ -11,6 +11,8 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
|
|
13
13
|
/**
|
|
14
|
+
* TODO: !!!!!!! CORS and security
|
|
15
|
+
* TODO: !!!!!!! Allow to pass tokem here
|
|
14
16
|
* TODO: [👩🏾🤝🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
|
|
15
17
|
* TODO: Split this file into multiple functions - handler for each request
|
|
16
18
|
* TODO: Maybe use `$exportJson`
|
|
@@ -25,12 +25,14 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
|
|
|
25
25
|
*/
|
|
26
26
|
readonly port: number;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Root path of the server
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* Note: This is useful when you reverse proxy the server without changing the path
|
|
31
|
+
*
|
|
32
|
+
* @default '/'
|
|
33
|
+
* @example '/api/promptbook/'
|
|
32
34
|
*/
|
|
33
|
-
readonly
|
|
35
|
+
readonly rootPath: string_uri;
|
|
34
36
|
} & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
|
|
35
37
|
export type AnonymousRemoteServerOptions = {
|
|
36
38
|
/**
|
package/package.json
CHANGED
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('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.hexEncoder, global.sha256, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, hexEncoder, sha256,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('rxjs'), require('crypto'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('node:path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'node:path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.hexEncoder, global.sha256, global.node_path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, hexEncoder, sha256, node_path, cryptoJs, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-0';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2191,9 +2191,9 @@
|
|
|
2191
2191
|
function createTask(options) {
|
|
2192
2192
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2193
2193
|
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
|
|
2194
|
-
var
|
|
2194
|
+
var partialResultSubject = new rxjs.BehaviorSubject({});
|
|
2195
2195
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2196
|
-
|
|
2196
|
+
partialResultSubject.next(newOngoingResult);
|
|
2197
2197
|
});
|
|
2198
2198
|
function asPromise(options) {
|
|
2199
2199
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2218,7 +2218,7 @@
|
|
|
2218
2218
|
taskId: taskId,
|
|
2219
2219
|
asPromise: asPromise,
|
|
2220
2220
|
asObservable: function () {
|
|
2221
|
-
return rxjs.concat(
|
|
2221
|
+
return rxjs.concat(partialResultSubject.asObservable(), rxjs.from(asPromise({
|
|
2222
2222
|
isCrashedOnError: true,
|
|
2223
2223
|
})));
|
|
2224
2224
|
},
|
|
@@ -3650,7 +3650,7 @@
|
|
|
3650
3650
|
value = value.replace(/\.html$/, '');
|
|
3651
3651
|
}
|
|
3652
3652
|
else if (isValidFilePath(value)) {
|
|
3653
|
-
value =
|
|
3653
|
+
value = node_path.basename(value);
|
|
3654
3654
|
// Note: Keeping extension in the name
|
|
3655
3655
|
}
|
|
3656
3656
|
value = value.split('/').join('-');
|
|
@@ -3756,9 +3756,9 @@
|
|
|
3756
3756
|
}
|
|
3757
3757
|
basename = url.split('/').pop() || titleToName(url);
|
|
3758
3758
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
3759
|
-
rootDirname_1 =
|
|
3760
|
-
filepath =
|
|
3761
|
-
return [4 /*yield*/, tools.fs.mkdir(
|
|
3759
|
+
rootDirname_1 = node_path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3760
|
+
filepath = node_path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
|
|
3761
|
+
return [4 /*yield*/, tools.fs.mkdir(node_path.dirname(node_path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
3762
3762
|
case 2:
|
|
3763
3763
|
_h.sent();
|
|
3764
3764
|
_g = (_f = Buffer).from;
|
|
@@ -3768,7 +3768,7 @@
|
|
|
3768
3768
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3769
3769
|
throw new LimitReachedError("File is too large (".concat(Math.round(fileContent.length / 1024 / 1024), "MB). Maximum allowed size is ").concat(Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024), "MB."));
|
|
3770
3770
|
}
|
|
3771
|
-
return [4 /*yield*/, tools.fs.writeFile(
|
|
3771
|
+
return [4 /*yield*/, tools.fs.writeFile(node_path.join(rootDirname_1, filepath), fileContent)];
|
|
3772
3772
|
case 4:
|
|
3773
3773
|
_h.sent();
|
|
3774
3774
|
// TODO: [💵] Check the file security
|
|
@@ -3784,7 +3784,7 @@
|
|
|
3784
3784
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
3785
3785
|
// <- TODO: [🧠] What is the best error type here`
|
|
3786
3786
|
}
|
|
3787
|
-
filename_1 =
|
|
3787
|
+
filename_1 = node_path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
3788
3788
|
fileExtension = getFileExtension(filename_1);
|
|
3789
3789
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3790
3790
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|