@promptbook/markdown-utils 0.77.0 → 0.77.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 +47 -17
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- 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/package.json +1 -1
- package/umd/index.umd.js +47 -17
- package/umd/index.umd.js.map +1 -1
|
@@ -35,7 +35,7 @@ import { validatePipeline } from '../conversion/validation/validatePipeline';
|
|
|
35
35
|
import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
|
|
36
36
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
37
37
|
import { BoilerplateError } from '../errors/0-BoilerplateError';
|
|
38
|
-
import {
|
|
38
|
+
import { PROMPTBOOK_ERRORS } from '../errors/0-index';
|
|
39
39
|
import { AbstractFormatError } from '../errors/AbstractFormatError';
|
|
40
40
|
import { CollectionError } from '../errors/CollectionError';
|
|
41
41
|
import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
|
|
@@ -150,7 +150,7 @@ export { validatePipeline };
|
|
|
150
150
|
export { CallbackInterfaceTools };
|
|
151
151
|
export type { CallbackInterfaceToolsOptions };
|
|
152
152
|
export { BoilerplateError };
|
|
153
|
-
export {
|
|
153
|
+
export { PROMPTBOOK_ERRORS };
|
|
154
154
|
export { AbstractFormatError };
|
|
155
155
|
export { CollectionError };
|
|
156
156
|
export { EnvironmentMismatchError };
|
|
@@ -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 {};
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.0
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.0';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2125,7 +2125,7 @@
|
|
|
2125
2125
|
*
|
|
2126
2126
|
* @public exported from `@promptbook/core`
|
|
2127
2127
|
*/
|
|
2128
|
-
var
|
|
2128
|
+
var PROMPTBOOK_ERRORS = {
|
|
2129
2129
|
AbstractFormatError: AbstractFormatError,
|
|
2130
2130
|
CsvFormatError: CsvFormatError,
|
|
2131
2131
|
CollectionError: CollectionError,
|
|
@@ -2143,6 +2143,35 @@
|
|
|
2143
2143
|
UnexpectedError: UnexpectedError,
|
|
2144
2144
|
// TODO: [🪑]> VersionMismatchError,
|
|
2145
2145
|
};
|
|
2146
|
+
/**
|
|
2147
|
+
* Index of all javascript errors
|
|
2148
|
+
*
|
|
2149
|
+
* @private for internal usage
|
|
2150
|
+
*/
|
|
2151
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
2152
|
+
Error: Error,
|
|
2153
|
+
EvalError: EvalError,
|
|
2154
|
+
RangeError: RangeError,
|
|
2155
|
+
ReferenceError: ReferenceError,
|
|
2156
|
+
SyntaxError: SyntaxError,
|
|
2157
|
+
TypeError: TypeError,
|
|
2158
|
+
URIError: URIError,
|
|
2159
|
+
AggregateError: AggregateError,
|
|
2160
|
+
/*
|
|
2161
|
+
Note: Not widely supported
|
|
2162
|
+
> InternalError,
|
|
2163
|
+
> ModuleError,
|
|
2164
|
+
> HeapError,
|
|
2165
|
+
> WebAssemblyCompileError,
|
|
2166
|
+
> WebAssemblyRuntimeError,
|
|
2167
|
+
*/
|
|
2168
|
+
};
|
|
2169
|
+
/**
|
|
2170
|
+
* Index of all errors
|
|
2171
|
+
*
|
|
2172
|
+
* @private for internal usage
|
|
2173
|
+
*/
|
|
2174
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2146
2175
|
/**
|
|
2147
2176
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2148
2177
|
*/
|
|
@@ -2153,11 +2182,11 @@
|
|
|
2153
2182
|
* @public exported from `@promptbook/utils`
|
|
2154
2183
|
*/
|
|
2155
2184
|
function deserializeError(error) {
|
|
2156
|
-
|
|
2157
|
-
|
|
2185
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
2186
|
+
if (ErrorClass === undefined) {
|
|
2187
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2158
2188
|
}
|
|
2159
|
-
|
|
2160
|
-
return new CustomError(error.message);
|
|
2189
|
+
return new ErrorClass(error.message);
|
|
2161
2190
|
}
|
|
2162
2191
|
|
|
2163
2192
|
/**
|
|
@@ -2231,8 +2260,8 @@
|
|
|
2231
2260
|
*/
|
|
2232
2261
|
function serializeError(error) {
|
|
2233
2262
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2234
|
-
if (!
|
|
2235
|
-
|
|
2263
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2264
|
+
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 "); }));
|
|
2236
2265
|
}
|
|
2237
2266
|
return {
|
|
2238
2267
|
name: name,
|
|
@@ -5840,18 +5869,19 @@
|
|
|
5840
5869
|
var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
|
|
5841
5870
|
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
5842
5871
|
var sectionMatch = content.match(sectionRegex);
|
|
5872
|
+
var contentToInsert = spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); });
|
|
5843
5873
|
if (sectionMatch) {
|
|
5844
|
-
return content.replace(sectionRegex,
|
|
5874
|
+
return content.replace(sectionRegex, contentToInsert);
|
|
5845
5875
|
}
|
|
5876
|
+
// Note: Following is the case when the section is not found in the file so we add it there
|
|
5846
5877
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
5847
|
-
if (
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
5878
|
+
if (placeForSection !== null) {
|
|
5879
|
+
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
5880
|
+
return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n \n ").concat(block(heading_1), "\n "); }));
|
|
5881
|
+
}
|
|
5882
|
+
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
5883
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
5884
|
+
return spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(content), "\n \n ").concat(block(contentToInsert), "\n "); });
|
|
5855
5885
|
}
|
|
5856
5886
|
/**
|
|
5857
5887
|
* TODO: [🏛] This can be part of markdown builder
|