@promptbook/remote-server 0.88.0-9 → 0.88.0
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/README.md +35 -18
- package/esm/index.es.js +52 -23
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +5 -0
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +5 -0
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +55 -26
- package/umd/index.umd.js.map +1 -1
|
@@ -162,7 +162,7 @@ export declare const DEFAULT_MAX_PARALLEL_COUNT = 5;
|
|
|
162
162
|
*
|
|
163
163
|
* @public exported from `@promptbook/core`
|
|
164
164
|
*/
|
|
165
|
-
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
165
|
+
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10;
|
|
166
166
|
/**
|
|
167
167
|
* @@@
|
|
168
168
|
* TODO: [🐝][main] !!3 Use
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { task_id } from '../types/typeAliases';
|
|
1
2
|
/**
|
|
2
3
|
* This error indicates errors during the execution of the pipeline
|
|
3
4
|
*
|
|
@@ -5,5 +6,9 @@
|
|
|
5
6
|
*/
|
|
6
7
|
export declare class PipelineExecutionError extends Error {
|
|
7
8
|
readonly name = "PipelineExecutionError";
|
|
9
|
+
readonly id?: task_id;
|
|
8
10
|
constructor(message: string);
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* TODO: !!!!!! Add id to all errors
|
|
14
|
+
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { task_id } from '../../types/typeAliases';
|
|
1
2
|
import type { ALL_ERRORS } from '../0-index';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a serialized error or custom Promptbook error
|
|
@@ -5,6 +6,10 @@ import type { ALL_ERRORS } from '../0-index';
|
|
|
5
6
|
* Note: [🚉] This is fully serializable as JSON
|
|
6
7
|
*/
|
|
7
8
|
export type ErrorJson = {
|
|
9
|
+
/**
|
|
10
|
+
* The unique identifier of the error
|
|
11
|
+
*/
|
|
12
|
+
readonly id?: task_id;
|
|
8
13
|
/**
|
|
9
14
|
* The type of the error
|
|
10
15
|
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countCharacters(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countLines(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
7
7
|
* @public exported from `@promptbook/utils`
|
|
8
8
|
*/
|
|
9
9
|
export declare function countPages(text: string): ExpectationAmount;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
12
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countParagraphs(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
|
@@ -11,3 +11,6 @@ export declare function splitIntoSentences(text: string): ReadonlyArray<string>;
|
|
|
11
11
|
* @public exported from `@promptbook/utils`
|
|
12
12
|
*/
|
|
13
13
|
export declare function countSentences(text: string): ExpectationAmount;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
16
|
+
*/
|
|
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
|
|
|
5
5
|
* @public exported from `@promptbook/utils`
|
|
6
6
|
*/
|
|
7
7
|
export declare function countWords(text: string): ExpectationAmount;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
10
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-server",
|
|
3
|
-
"version": "0.88.0
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.88.0
|
|
50
|
+
"@promptbook/core": "0.88.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
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('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('waitasecond'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'waitasecond', 'child_process', 'fs/promises', 'path', 'rxjs', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.waitasecond, global.child_process, global.promises, global.path, global.rxjs, global.
|
|
5
|
-
})(this, (function (exports, colors, express, http, socket_io, spaceTrim, waitasecond, child_process, promises, path, rxjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('http'), require('socket.io'), require('spacetrim'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'http', 'socket.io', 'spacetrim', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.http, global.socket_io, global.spaceTrim, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, colors, express, http, socket_io, spaceTrim, waitasecond, crypto, child_process, promises, path, rxjs, prettier, parserHtml, hexEncoder, sha256, 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
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
*
|
|
152
152
|
* @public exported from `@promptbook/core`
|
|
153
153
|
*/
|
|
154
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
154
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [🤹♂️]
|
|
155
155
|
// <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
156
156
|
/**
|
|
157
157
|
* Where to store the temporary downloads
|
|
@@ -207,6 +207,21 @@
|
|
|
207
207
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
208
208
|
*/
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Generates random token
|
|
212
|
+
*
|
|
213
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
214
|
+
*
|
|
215
|
+
* @private internal helper function
|
|
216
|
+
* @returns secure random token
|
|
217
|
+
*/
|
|
218
|
+
function $randomToken(randomness) {
|
|
219
|
+
return crypto.randomBytes(randomness).toString('hex');
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
223
|
+
*/
|
|
224
|
+
|
|
210
225
|
/**
|
|
211
226
|
* This error indicates errors during the execution of the pipeline
|
|
212
227
|
*
|
|
@@ -214,11 +229,17 @@
|
|
|
214
229
|
*/
|
|
215
230
|
class PipelineExecutionError extends Error {
|
|
216
231
|
constructor(message) {
|
|
232
|
+
// Added id parameter
|
|
217
233
|
super(message);
|
|
218
234
|
this.name = 'PipelineExecutionError';
|
|
235
|
+
// TODO: [🐙] DRY - Maybe $randomId
|
|
236
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
219
237
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
220
238
|
}
|
|
221
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* TODO: !!!!!! Add id to all errors
|
|
242
|
+
*/
|
|
222
243
|
|
|
223
244
|
/**
|
|
224
245
|
* This error indicates problems parsing the format value
|
|
@@ -548,19 +569,21 @@
|
|
|
548
569
|
*/
|
|
549
570
|
function serializeError(error) {
|
|
550
571
|
const { name, message, stack } = error;
|
|
572
|
+
const { id } = error;
|
|
551
573
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
552
574
|
console.error(spaceTrim__default["default"]((block) => `
|
|
553
|
-
|
|
575
|
+
|
|
554
576
|
Cannot serialize error with name "${name}"
|
|
555
577
|
|
|
556
578
|
${block(stack || message)}
|
|
557
|
-
|
|
579
|
+
|
|
558
580
|
`));
|
|
559
581
|
}
|
|
560
582
|
return {
|
|
561
583
|
name: name,
|
|
562
584
|
message,
|
|
563
585
|
stack,
|
|
586
|
+
id, // Include id in the serialized object
|
|
564
587
|
};
|
|
565
588
|
}
|
|
566
589
|
|
|
@@ -1703,21 +1726,6 @@
|
|
|
1703
1726
|
* - [♨] Are tasks prepared
|
|
1704
1727
|
*/
|
|
1705
1728
|
|
|
1706
|
-
/**
|
|
1707
|
-
* Generates random token
|
|
1708
|
-
*
|
|
1709
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1710
|
-
*
|
|
1711
|
-
* @private internal helper function
|
|
1712
|
-
* @returns secure random token
|
|
1713
|
-
*/
|
|
1714
|
-
function $randomToken(randomness) {
|
|
1715
|
-
return crypto.randomBytes(randomness).toString('hex');
|
|
1716
|
-
}
|
|
1717
|
-
/**
|
|
1718
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1719
|
-
*/
|
|
1720
|
-
|
|
1721
1729
|
/**
|
|
1722
1730
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1723
1731
|
*
|
|
@@ -1775,7 +1783,7 @@
|
|
|
1775
1783
|
* @public exported from `@promptbook/utils`
|
|
1776
1784
|
*/
|
|
1777
1785
|
function deserializeError(error) {
|
|
1778
|
-
const { name, stack } = error;
|
|
1786
|
+
const { name, stack, id } = error; // Added id
|
|
1779
1787
|
let { message } = error;
|
|
1780
1788
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
1781
1789
|
if (ErrorClass === undefined) {
|
|
@@ -1790,7 +1798,9 @@
|
|
|
1790
1798
|
${block(stack || '')}
|
|
1791
1799
|
`);
|
|
1792
1800
|
}
|
|
1793
|
-
|
|
1801
|
+
const deserializedError = new ErrorClass(message);
|
|
1802
|
+
deserializedError.id = id; // Assign id to the error object
|
|
1803
|
+
return deserializedError;
|
|
1794
1804
|
}
|
|
1795
1805
|
|
|
1796
1806
|
/**
|
|
@@ -1840,6 +1850,7 @@
|
|
|
1840
1850
|
*/
|
|
1841
1851
|
function createTask(options) {
|
|
1842
1852
|
const { taskType, taskProcessCallback } = options;
|
|
1853
|
+
// TODO: [🐙] DRY
|
|
1843
1854
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1844
1855
|
let status = 'RUNNING';
|
|
1845
1856
|
const createdAt = new Date();
|
|
@@ -1872,7 +1883,7 @@
|
|
|
1872
1883
|
assertsTaskSuccessful(executionResult);
|
|
1873
1884
|
status = 'FINISHED';
|
|
1874
1885
|
currentValue = jsonStringsToJsons(executionResult);
|
|
1875
|
-
// <- TODO:
|
|
1886
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
1876
1887
|
partialResultSubject.next(executionResult);
|
|
1877
1888
|
}
|
|
1878
1889
|
catch (error) {
|
|
@@ -4688,6 +4699,9 @@
|
|
|
4688
4699
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
4689
4700
|
return text.length;
|
|
4690
4701
|
}
|
|
4702
|
+
/**
|
|
4703
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4704
|
+
*/
|
|
4691
4705
|
|
|
4692
4706
|
/**
|
|
4693
4707
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -4719,6 +4733,9 @@
|
|
|
4719
4733
|
const lines = text.split('\n');
|
|
4720
4734
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
4721
4735
|
}
|
|
4736
|
+
/**
|
|
4737
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4738
|
+
*/
|
|
4722
4739
|
|
|
4723
4740
|
/**
|
|
4724
4741
|
* Counts number of pages in the text
|
|
@@ -4730,6 +4747,9 @@
|
|
|
4730
4747
|
function countPages(text) {
|
|
4731
4748
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4732
4749
|
}
|
|
4750
|
+
/**
|
|
4751
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4752
|
+
*/
|
|
4733
4753
|
|
|
4734
4754
|
/**
|
|
4735
4755
|
* Counts number of paragraphs in the text
|
|
@@ -4739,6 +4759,9 @@
|
|
|
4739
4759
|
function countParagraphs(text) {
|
|
4740
4760
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
4741
4761
|
}
|
|
4762
|
+
/**
|
|
4763
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4764
|
+
*/
|
|
4742
4765
|
|
|
4743
4766
|
/**
|
|
4744
4767
|
* Split text into sentences
|
|
@@ -4756,6 +4779,9 @@
|
|
|
4756
4779
|
function countSentences(text) {
|
|
4757
4780
|
return splitIntoSentences(text).length;
|
|
4758
4781
|
}
|
|
4782
|
+
/**
|
|
4783
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4784
|
+
*/
|
|
4759
4785
|
|
|
4760
4786
|
/**
|
|
4761
4787
|
* Counts number of words in the text
|
|
@@ -4769,6 +4795,9 @@
|
|
|
4769
4795
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
4770
4796
|
return text.split(/[^a-zа-я0-9]+/i).filter((word) => word.length > 0).length;
|
|
4771
4797
|
}
|
|
4798
|
+
/**
|
|
4799
|
+
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4800
|
+
*/
|
|
4772
4801
|
|
|
4773
4802
|
/**
|
|
4774
4803
|
* Index of all counter functions
|