@promptbook/core 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('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('moment'), require('colors')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'moment', 'colors'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.papaparse, global.hexEncoder, global.sha256, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, papaparse, 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('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('node:path'), require('crypto-js'), require('mime-types'), require('moment'), require('colors')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'rxjs', 'crypto', 'waitasecond', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'node:path', 'crypto-js', 'mime-types', 'moment', 'colors'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.rxjs, global.crypto, global.waitasecond, global.papaparse, global.hexEncoder, global.sha256, global.node_path, global.cryptoJs, global.mimeTypes, global.moment, global.colors));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, rxjs, crypto, waitasecond, papaparse, hexEncoder, sha256, node_path, cryptoJs, mimeTypes, moment, colors) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
30
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-0';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2375,9 +2375,9 @@
|
|
|
2375
2375
|
function createTask(options) {
|
|
2376
2376
|
var taskType = options.taskType, taskProcessCallback = options.taskProcessCallback;
|
|
2377
2377
|
var taskId = "".concat(taskType.toLowerCase(), "-").concat($randomToken(256 /* <- TODO: !!! To global config */));
|
|
2378
|
-
var
|
|
2378
|
+
var partialResultSubject = new rxjs.BehaviorSubject({});
|
|
2379
2379
|
var finalResultPromise = /* not await */ taskProcessCallback(function (newOngoingResult) {
|
|
2380
|
-
|
|
2380
|
+
partialResultSubject.next(newOngoingResult);
|
|
2381
2381
|
});
|
|
2382
2382
|
function asPromise(options) {
|
|
2383
2383
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2402,7 +2402,7 @@
|
|
|
2402
2402
|
taskId: taskId,
|
|
2403
2403
|
asPromise: asPromise,
|
|
2404
2404
|
asObservable: function () {
|
|
2405
|
-
return rxjs.concat(
|
|
2405
|
+
return rxjs.concat(partialResultSubject.asObservable(), rxjs.from(asPromise({
|
|
2406
2406
|
isCrashedOnError: true,
|
|
2407
2407
|
})));
|
|
2408
2408
|
},
|
|
@@ -5938,7 +5938,7 @@
|
|
|
5938
5938
|
value = value.replace(/\.html$/, '');
|
|
5939
5939
|
}
|
|
5940
5940
|
else if (isValidFilePath(value)) {
|
|
5941
|
-
value =
|
|
5941
|
+
value = node_path.basename(value);
|
|
5942
5942
|
// Note: Keeping extension in the name
|
|
5943
5943
|
}
|
|
5944
5944
|
value = value.split('/').join('-');
|
|
@@ -6044,9 +6044,9 @@
|
|
|
6044
6044
|
}
|
|
6045
6045
|
basename = url.split('/').pop() || titleToName(url);
|
|
6046
6046
|
hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
|
|
6047
|
-
rootDirname_1 =
|
|
6048
|
-
filepath =
|
|
6049
|
-
return [4 /*yield*/, tools.fs.mkdir(
|
|
6047
|
+
rootDirname_1 = node_path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
6048
|
+
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));
|
|
6049
|
+
return [4 /*yield*/, tools.fs.mkdir(node_path.dirname(node_path.join(rootDirname_1, filepath)), { recursive: true })];
|
|
6050
6050
|
case 2:
|
|
6051
6051
|
_h.sent();
|
|
6052
6052
|
_g = (_f = Buffer).from;
|
|
@@ -6056,7 +6056,7 @@
|
|
|
6056
6056
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
6057
6057
|
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."));
|
|
6058
6058
|
}
|
|
6059
|
-
return [4 /*yield*/, tools.fs.writeFile(
|
|
6059
|
+
return [4 /*yield*/, tools.fs.writeFile(node_path.join(rootDirname_1, filepath), fileContent)];
|
|
6060
6060
|
case 4:
|
|
6061
6061
|
_h.sent();
|
|
6062
6062
|
// TODO: [💵] Check the file security
|
|
@@ -6072,7 +6072,7 @@
|
|
|
6072
6072
|
throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
|
|
6073
6073
|
// <- TODO: [🧠] What is the best error type here`
|
|
6074
6074
|
}
|
|
6075
|
-
filename_1 =
|
|
6075
|
+
filename_1 = node_path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
|
|
6076
6076
|
fileExtension = getFileExtension(filename_1);
|
|
6077
6077
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
6078
6078
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|