@promptbook/legacy-documents 0.77.0 → 0.78.0-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 +4 -0
- package/esm/index.es.js +74 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -2
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -8
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +17 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +1 -1
- package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/removePipelineCommand.d.ts +22 -0
- package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts} +3 -3
- package/esm/typings/src/errors/0-index.d.ts +46 -1
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/titleToName.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +74 -45
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/utils/{extractVariables.test.d.ts → extractVariablesFromScript.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{renameParameter.test.d.ts → removePipelineCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{titleToName.test.d.ts → renamePipelineParameter.test.d.ts} +0 -0
- /package/esm/typings/src/{conversion/utils → utils/normalization}/titleToName.d.ts +0 -0
|
@@ -30,12 +30,15 @@ import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
|
|
|
30
30
|
import { pipelineStringToJson } from '../conversion/pipelineStringToJson';
|
|
31
31
|
import { pipelineStringToJsonSync } from '../conversion/pipelineStringToJsonSync';
|
|
32
32
|
import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
|
|
33
|
+
import { extractParameterNamesFromTask } from '../conversion/utils/extractParameterNamesFromTask';
|
|
34
|
+
import { removePipelineCommand } from '../conversion/utils/removePipelineCommand';
|
|
35
|
+
import { renamePipelineParameter } from '../conversion/utils/renamePipelineParameter';
|
|
33
36
|
import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson';
|
|
34
37
|
import { validatePipeline } from '../conversion/validation/validatePipeline';
|
|
35
38
|
import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
|
|
36
39
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
37
40
|
import { BoilerplateError } from '../errors/0-BoilerplateError';
|
|
38
|
-
import {
|
|
41
|
+
import { PROMPTBOOK_ERRORS } from '../errors/0-index';
|
|
39
42
|
import { AbstractFormatError } from '../errors/AbstractFormatError';
|
|
40
43
|
import { CollectionError } from '../errors/CollectionError';
|
|
41
44
|
import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
|
|
@@ -145,12 +148,15 @@ export { pipelineJsonToString };
|
|
|
145
148
|
export { pipelineStringToJson };
|
|
146
149
|
export { pipelineStringToJsonSync };
|
|
147
150
|
export { prettifyPipelineString };
|
|
151
|
+
export { extractParameterNamesFromTask };
|
|
152
|
+
export { removePipelineCommand };
|
|
153
|
+
export { renamePipelineParameter };
|
|
148
154
|
export { stringifyPipelineJson };
|
|
149
155
|
export { validatePipeline };
|
|
150
156
|
export { CallbackInterfaceTools };
|
|
151
157
|
export type { CallbackInterfaceToolsOptions };
|
|
152
158
|
export { BoilerplateError };
|
|
153
|
-
export {
|
|
159
|
+
export { PROMPTBOOK_ERRORS };
|
|
154
160
|
export { AbstractFormatError };
|
|
155
161
|
export { CollectionError };
|
|
156
162
|
export { EnvironmentMismatchError };
|
|
@@ -5,6 +5,8 @@ import type { PipelineBothCommandParser } from '../commands/_common/types/Comman
|
|
|
5
5
|
import type { PipelineHeadCommandParser } from '../commands/_common/types/CommandParser';
|
|
6
6
|
import type { PipelineTaskCommandParser } from '../commands/_common/types/CommandParser';
|
|
7
7
|
import type { CommandParserInput } from '../commands/_common/types/CommandParser';
|
|
8
|
+
import type { CommandType } from '../commands/_common/types/CommandType';
|
|
9
|
+
import type { CommandTypeOrAlias } from '../commands/_common/types/CommandType';
|
|
8
10
|
import type { CommandUsagePlace } from '../commands/_common/types/CommandUsagePlaces';
|
|
9
11
|
import type { ExpectCommand } from '../commands/EXPECT/ExpectCommand';
|
|
10
12
|
import type { ForeachJson } from '../commands/FOREACH/ForeachJson';
|
|
@@ -263,6 +265,8 @@ export type { PipelineBothCommandParser };
|
|
|
263
265
|
export type { PipelineHeadCommandParser };
|
|
264
266
|
export type { PipelineTaskCommandParser };
|
|
265
267
|
export type { CommandParserInput };
|
|
268
|
+
export type { CommandType };
|
|
269
|
+
export type { CommandTypeOrAlias };
|
|
266
270
|
export type { CommandUsagePlace };
|
|
267
271
|
export type { ExpectCommand };
|
|
268
272
|
export type { ForeachJson };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
2
|
import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
3
|
-
import {
|
|
4
|
-
import { extractVariables } from '../conversion/utils/extractVariables';
|
|
5
|
-
import { renameParameter } from '../conversion/utils/renameParameter';
|
|
6
|
-
import { titleToName } from '../conversion/utils/titleToName';
|
|
3
|
+
import { extractVariablesFromScript } from '../conversion/utils/extractVariablesFromScript';
|
|
7
4
|
import { deserializeError } from '../errors/utils/deserializeError';
|
|
8
5
|
import { serializeError } from '../errors/utils/serializeError';
|
|
9
6
|
import { forEachAsync } from '../execution/utils/forEachAsync';
|
|
@@ -45,6 +42,7 @@ import { parseKeywords } from '../utils/normalization/parseKeywords';
|
|
|
45
42
|
import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
|
|
46
43
|
import { removeDiacritics } from '../utils/normalization/removeDiacritics';
|
|
47
44
|
import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
45
|
+
import { titleToName } from '../utils/normalization/titleToName';
|
|
48
46
|
import { spaceTrim } from '../utils/organization/spaceTrim';
|
|
49
47
|
import { extractParameterNames } from '../utils/parameters/extractParameterNames';
|
|
50
48
|
import { replaceParameters } from '../utils/parameters/replaceParameters';
|
|
@@ -75,10 +73,7 @@ import { isValidUrl } from '../utils/validators/url/isValidUrl';
|
|
|
75
73
|
import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
|
|
76
74
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
77
75
|
export { renderPromptbookMermaid };
|
|
78
|
-
export {
|
|
79
|
-
export { extractVariables };
|
|
80
|
-
export { renameParameter };
|
|
81
|
-
export { titleToName };
|
|
76
|
+
export { extractVariablesFromScript };
|
|
82
77
|
export { deserializeError };
|
|
83
78
|
export { serializeError };
|
|
84
79
|
export { forEachAsync };
|
|
@@ -120,6 +115,7 @@ export { parseKeywords };
|
|
|
120
115
|
export { parseKeywordsFromString };
|
|
121
116
|
export { removeDiacritics };
|
|
122
117
|
export { searchKeywords };
|
|
118
|
+
export { titleToName };
|
|
123
119
|
export { spaceTrim };
|
|
124
120
|
export { extractParameterNames };
|
|
125
121
|
export { replaceParameters };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from './Command';
|
|
2
|
+
/**
|
|
3
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
4
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
5
|
+
*
|
|
6
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
7
|
+
*/
|
|
8
|
+
export type CommandType = Command['type'];
|
|
9
|
+
/**
|
|
10
|
+
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
11
|
+
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
12
|
+
*
|
|
13
|
+
* This is a type of the command like "KNOWLEDGE" or "PERSONA"
|
|
14
|
+
*
|
|
15
|
+
export type CommandTypeOrAlias = Command['type'] | Command['aliasNames'] | Command['deprecatedNames'];
|
|
16
|
+
// <- TODO: [🧘] Implement
|
|
17
|
+
*/
|
|
@@ -7,7 +7,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
|
|
|
7
7
|
* @param task the task with used parameters
|
|
8
8
|
* @returns the set of parameter names
|
|
9
9
|
* @throws {ParseError} if the script is invalid
|
|
10
|
-
* @public exported from `@promptbook/
|
|
10
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
11
11
|
*/
|
|
12
12
|
export declare function extractParameterNamesFromTask(task: ReadonlyDeep<Pick<TaskJson, 'title' | 'description' | 'taskType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>>): Set<string_parameter_name>;
|
|
13
13
|
/**
|
package/esm/typings/src/conversion/utils/{extractVariables.d.ts → extractVariablesFromScript.d.ts}
RENAMED
|
@@ -6,9 +6,9 @@ import type { string_javascript_name } from '../../types/typeAliases';
|
|
|
6
6
|
* @param script from which to extract the variables
|
|
7
7
|
* @returns the list of variable names
|
|
8
8
|
* @throws {ParseError} if the script is invalid
|
|
9
|
-
* @public exported from `@promptbook/utils`
|
|
9
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function extractVariablesFromScript(script: string_javascript): Set<string_javascript_name>;
|
|
12
12
|
/**
|
|
13
13
|
* TODO: [🔣] Support for multiple languages - python, java,...
|
|
14
14
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandType } from '../../commands/_common/types/CommandType';
|
|
2
|
+
import type { PipelineString } from '../../pipeline/PipelineString';
|
|
3
|
+
/**
|
|
4
|
+
* Options for `removePipelineCommand`
|
|
5
|
+
*/
|
|
6
|
+
type RemovePipelineCommandOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The command you want to remove
|
|
9
|
+
*/
|
|
10
|
+
command: CommandType;
|
|
11
|
+
/**
|
|
12
|
+
* Pipeline you want to remove command from
|
|
13
|
+
*/
|
|
14
|
+
pipeline: PipelineString;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
18
|
+
*
|
|
19
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
20
|
+
*/
|
|
21
|
+
export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
|
|
22
|
+
export {};
|
package/esm/typings/src/conversion/utils/{renameParameter.d.ts → renamePipelineParameter.d.ts}
RENAMED
|
@@ -16,11 +16,11 @@ type RenameParameterOptions = {
|
|
|
16
16
|
readonly newParameterName: string_name;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
* Function `
|
|
19
|
+
* Function `renamePipelineParameter` will find all usable parameters for given task
|
|
20
20
|
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
21
21
|
*
|
|
22
22
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
23
|
-
* @public exported from `@promptbook/
|
|
23
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
|
|
26
26
|
export {};
|
|
@@ -18,7 +18,52 @@ import { UnexpectedError } from './UnexpectedError';
|
|
|
18
18
|
*
|
|
19
19
|
* @public exported from `@promptbook/core`
|
|
20
20
|
*/
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const PROMPTBOOK_ERRORS: {
|
|
22
|
+
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
23
|
+
readonly CsvFormatError: typeof CsvFormatError;
|
|
24
|
+
readonly CollectionError: typeof CollectionError;
|
|
25
|
+
readonly EnvironmentMismatchError: typeof EnvironmentMismatchError;
|
|
26
|
+
readonly ExpectError: typeof ExpectError;
|
|
27
|
+
readonly KnowledgeScrapeError: typeof KnowledgeScrapeError;
|
|
28
|
+
readonly LimitReachedError: typeof LimitReachedError;
|
|
29
|
+
readonly MissingToolsError: typeof MissingToolsError;
|
|
30
|
+
readonly NotFoundError: typeof NotFoundError;
|
|
31
|
+
readonly NotYetImplementedError: typeof NotYetImplementedError;
|
|
32
|
+
readonly ParseError: typeof ParseError;
|
|
33
|
+
readonly PipelineExecutionError: typeof PipelineExecutionError;
|
|
34
|
+
readonly PipelineLogicError: typeof PipelineLogicError;
|
|
35
|
+
readonly PipelineUrlError: typeof PipelineUrlError;
|
|
36
|
+
readonly UnexpectedError: typeof UnexpectedError;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Index of all javascript errors
|
|
40
|
+
*
|
|
41
|
+
* @private for internal usage
|
|
42
|
+
*/
|
|
43
|
+
export declare const COMMON_JAVASCRIPT_ERRORS: {
|
|
44
|
+
readonly Error: ErrorConstructor;
|
|
45
|
+
readonly EvalError: EvalErrorConstructor;
|
|
46
|
+
readonly RangeError: RangeErrorConstructor;
|
|
47
|
+
readonly ReferenceError: ReferenceErrorConstructor;
|
|
48
|
+
readonly SyntaxError: SyntaxErrorConstructor;
|
|
49
|
+
readonly TypeError: TypeErrorConstructor;
|
|
50
|
+
readonly URIError: URIErrorConstructor;
|
|
51
|
+
readonly AggregateError: AggregateErrorConstructor;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Index of all errors
|
|
55
|
+
*
|
|
56
|
+
* @private for internal usage
|
|
57
|
+
*/
|
|
58
|
+
export declare const ALL_ERRORS: {
|
|
59
|
+
readonly Error: ErrorConstructor;
|
|
60
|
+
readonly EvalError: EvalErrorConstructor;
|
|
61
|
+
readonly RangeError: RangeErrorConstructor;
|
|
62
|
+
readonly ReferenceError: ReferenceErrorConstructor;
|
|
63
|
+
readonly SyntaxError: SyntaxErrorConstructor;
|
|
64
|
+
readonly TypeError: TypeErrorConstructor;
|
|
65
|
+
readonly URIError: URIErrorConstructor;
|
|
66
|
+
readonly AggregateError: AggregateErrorConstructor;
|
|
22
67
|
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
23
68
|
readonly CsvFormatError: typeof CsvFormatError;
|
|
24
69
|
readonly CollectionError: typeof CollectionError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ALL_ERRORS } from '../0-index';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a serialized error or custom Promptbook error
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ export type ErrorJson = {
|
|
|
8
8
|
/**
|
|
9
9
|
* The type of the error
|
|
10
10
|
*/
|
|
11
|
-
readonly name: keyof typeof
|
|
11
|
+
readonly name: keyof typeof ALL_ERRORS;
|
|
12
12
|
/**
|
|
13
13
|
* The message of the error
|
|
14
14
|
*/
|
package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/legacy-documents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0-0",
|
|
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,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.
|
|
57
|
+
"@promptbook/core": "0.78.0-0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.
|
|
26
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.1';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -740,32 +740,12 @@
|
|
|
740
740
|
*/
|
|
741
741
|
|
|
742
742
|
/**
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
* Note: Dataurl are considered perfectly valid.
|
|
746
|
-
* Note: There are two simmilar functions:
|
|
747
|
-
* - `isValidUrl` which tests any URL
|
|
748
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
743
|
+
* @@@
|
|
749
744
|
*
|
|
750
|
-
* @
|
|
745
|
+
* @private for `FileCacheStorage`
|
|
751
746
|
*/
|
|
752
|
-
function
|
|
753
|
-
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
try {
|
|
757
|
-
if (url.startsWith('blob:')) {
|
|
758
|
-
url = url.replace(/^blob:/, '');
|
|
759
|
-
}
|
|
760
|
-
var urlObject = new URL(url /* because fail is handled */);
|
|
761
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
762
|
-
return false;
|
|
763
|
-
}
|
|
764
|
-
return true;
|
|
765
|
-
}
|
|
766
|
-
catch (error) {
|
|
767
|
-
return false;
|
|
768
|
-
}
|
|
747
|
+
function nameToSubfolderPath(name) {
|
|
748
|
+
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
769
749
|
}
|
|
770
750
|
|
|
771
751
|
var defaultDiacriticsRemovalMap = [
|
|
@@ -1133,6 +1113,35 @@
|
|
|
1133
1113
|
return false;
|
|
1134
1114
|
}
|
|
1135
1115
|
|
|
1116
|
+
/**
|
|
1117
|
+
* Tests if given string is valid URL.
|
|
1118
|
+
*
|
|
1119
|
+
* Note: Dataurl are considered perfectly valid.
|
|
1120
|
+
* Note: There are two simmilar functions:
|
|
1121
|
+
* - `isValidUrl` which tests any URL
|
|
1122
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
1123
|
+
*
|
|
1124
|
+
* @public exported from `@promptbook/utils`
|
|
1125
|
+
*/
|
|
1126
|
+
function isValidUrl(url) {
|
|
1127
|
+
if (typeof url !== 'string') {
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
try {
|
|
1131
|
+
if (url.startsWith('blob:')) {
|
|
1132
|
+
url = url.replace(/^blob:/, '');
|
|
1133
|
+
}
|
|
1134
|
+
var urlObject = new URL(url /* because fail is handled */);
|
|
1135
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
catch (error) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1136
1145
|
/**
|
|
1137
1146
|
* @@@
|
|
1138
1147
|
*
|
|
@@ -1157,15 +1166,6 @@
|
|
|
1157
1166
|
return value;
|
|
1158
1167
|
}
|
|
1159
1168
|
|
|
1160
|
-
/**
|
|
1161
|
-
* @@@
|
|
1162
|
-
*
|
|
1163
|
-
* @private for `FileCacheStorage`
|
|
1164
|
-
*/
|
|
1165
|
-
function nameToSubfolderPath(name) {
|
|
1166
|
-
return [name.substr(0, 1).toLowerCase(), name.substr(1, 1).toLowerCase()];
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Create a filename for intermediate cache for scrapers
|
|
1171
1171
|
*
|
|
@@ -2228,7 +2228,7 @@
|
|
|
2228
2228
|
*
|
|
2229
2229
|
* @public exported from `@promptbook/core`
|
|
2230
2230
|
*/
|
|
2231
|
-
var
|
|
2231
|
+
var PROMPTBOOK_ERRORS = {
|
|
2232
2232
|
AbstractFormatError: AbstractFormatError,
|
|
2233
2233
|
CsvFormatError: CsvFormatError,
|
|
2234
2234
|
CollectionError: CollectionError,
|
|
@@ -2246,6 +2246,35 @@
|
|
|
2246
2246
|
UnexpectedError: UnexpectedError,
|
|
2247
2247
|
// TODO: [🪑]> VersionMismatchError,
|
|
2248
2248
|
};
|
|
2249
|
+
/**
|
|
2250
|
+
* Index of all javascript errors
|
|
2251
|
+
*
|
|
2252
|
+
* @private for internal usage
|
|
2253
|
+
*/
|
|
2254
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
2255
|
+
Error: Error,
|
|
2256
|
+
EvalError: EvalError,
|
|
2257
|
+
RangeError: RangeError,
|
|
2258
|
+
ReferenceError: ReferenceError,
|
|
2259
|
+
SyntaxError: SyntaxError,
|
|
2260
|
+
TypeError: TypeError,
|
|
2261
|
+
URIError: URIError,
|
|
2262
|
+
AggregateError: AggregateError,
|
|
2263
|
+
/*
|
|
2264
|
+
Note: Not widely supported
|
|
2265
|
+
> InternalError,
|
|
2266
|
+
> ModuleError,
|
|
2267
|
+
> HeapError,
|
|
2268
|
+
> WebAssemblyCompileError,
|
|
2269
|
+
> WebAssemblyRuntimeError,
|
|
2270
|
+
*/
|
|
2271
|
+
};
|
|
2272
|
+
/**
|
|
2273
|
+
* Index of all errors
|
|
2274
|
+
*
|
|
2275
|
+
* @private for internal usage
|
|
2276
|
+
*/
|
|
2277
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2249
2278
|
/**
|
|
2250
2279
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2251
2280
|
*/
|
|
@@ -2256,11 +2285,11 @@
|
|
|
2256
2285
|
* @public exported from `@promptbook/utils`
|
|
2257
2286
|
*/
|
|
2258
2287
|
function deserializeError(error) {
|
|
2259
|
-
|
|
2260
|
-
|
|
2288
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
2289
|
+
if (ErrorClass === undefined) {
|
|
2290
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2261
2291
|
}
|
|
2262
|
-
|
|
2263
|
-
return new CustomError(error.message);
|
|
2292
|
+
return new ErrorClass(error.message);
|
|
2264
2293
|
}
|
|
2265
2294
|
|
|
2266
2295
|
/**
|
|
@@ -2334,8 +2363,8 @@
|
|
|
2334
2363
|
*/
|
|
2335
2364
|
function serializeError(error) {
|
|
2336
2365
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2337
|
-
if (!
|
|
2338
|
-
|
|
2366
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2367
|
+
console.error(spaceTrim__default["default"](function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2339
2368
|
}
|
|
2340
2369
|
return {
|
|
2341
2370
|
name: name,
|
|
@@ -3811,9 +3840,9 @@
|
|
|
3811
3840
|
* @param script from which to extract the variables
|
|
3812
3841
|
* @returns the list of variable names
|
|
3813
3842
|
* @throws {ParseError} if the script is invalid
|
|
3814
|
-
* @public exported from `@promptbook/utils`
|
|
3843
|
+
* @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
|
|
3815
3844
|
*/
|
|
3816
|
-
function
|
|
3845
|
+
function extractVariablesFromScript(script) {
|
|
3817
3846
|
var variables = new Set();
|
|
3818
3847
|
script = "(()=>{".concat(script, "})()");
|
|
3819
3848
|
try {
|
|
@@ -3860,7 +3889,7 @@
|
|
|
3860
3889
|
* @param task the task with used parameters
|
|
3861
3890
|
* @returns the set of parameter names
|
|
3862
3891
|
* @throws {ParseError} if the script is invalid
|
|
3863
|
-
* @public exported from `@promptbook/
|
|
3892
|
+
* @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
|
|
3864
3893
|
*/
|
|
3865
3894
|
function extractParameterNamesFromTask(task) {
|
|
3866
3895
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
@@ -3881,7 +3910,7 @@
|
|
|
3881
3910
|
}
|
|
3882
3911
|
if (taskType === 'SCRIPT_TASK') {
|
|
3883
3912
|
try {
|
|
3884
|
-
for (var _g = __values(
|
|
3913
|
+
for (var _g = __values(extractVariablesFromScript(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3885
3914
|
var parameterName = _h.value;
|
|
3886
3915
|
parameterNames.add(parameterName);
|
|
3887
3916
|
}
|