@promptbook/pdf 0.89.0-31 → 0.89.0-32
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 +52 -3
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +9 -0
- package/esm/typings/src/formats/csv/utils/isValidCsvString.test.d.ts +1 -0
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +3 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +9 -0
- package/esm/typings/src/formats/xml/utils/isValidXmlString.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +52 -3
- package/umd/index.umd.js.map +1 -1
|
@@ -5,7 +5,9 @@ import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMe
|
|
|
5
5
|
import { deserializeError } from '../errors/utils/deserializeError';
|
|
6
6
|
import { serializeError } from '../errors/utils/serializeError';
|
|
7
7
|
import { forEachAsync } from '../execution/utils/forEachAsync';
|
|
8
|
+
import { isValidCsvString } from '../formats/csv/utils/isValidCsvString';
|
|
8
9
|
import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
|
|
10
|
+
import { isValidXmlString } from '../formats/xml/utils/isValidXmlString';
|
|
9
11
|
import { prompt } from '../pipeline/prompt-notation';
|
|
10
12
|
import { promptTemplate } from '../pipeline/prompt-notation';
|
|
11
13
|
import { $getCurrentDate } from '../utils/$getCurrentDate';
|
|
@@ -87,7 +89,9 @@ export { renderPromptbookMermaid };
|
|
|
87
89
|
export { deserializeError };
|
|
88
90
|
export { serializeError };
|
|
89
91
|
export { forEachAsync };
|
|
92
|
+
export { isValidCsvString };
|
|
90
93
|
export { isValidJsonString };
|
|
94
|
+
export { isValidXmlString };
|
|
91
95
|
export { prompt };
|
|
92
96
|
export { promptTemplate };
|
|
93
97
|
export { $getCurrentDate };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to check if a string is valid CSV
|
|
3
|
+
*
|
|
4
|
+
* @param value The string to check
|
|
5
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/utils`
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidCsvString(value: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
3
3
|
*
|
|
4
|
+
* @param value The string to check
|
|
5
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
6
|
+
*
|
|
4
7
|
* @public exported from `@promptbook/utils`
|
|
5
8
|
*/
|
|
6
9
|
export declare function isValidJsonString(value: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to check if a string is valid XML
|
|
3
|
+
*
|
|
4
|
+
* @param value
|
|
5
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
6
|
+
*
|
|
7
|
+
* @public exported from `@promptbook/utils`
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidXmlString(value: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.89.0-
|
|
3
|
+
"version": "0.89.0-32",
|
|
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,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"module": "./esm/index.es.js",
|
|
52
52
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.89.0-
|
|
54
|
+
"@promptbook/core": "0.89.0-32"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
|
|
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
|
|
@@ -943,6 +943,9 @@
|
|
|
943
943
|
/**
|
|
944
944
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
945
945
|
*
|
|
946
|
+
* @param value The string to check
|
|
947
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
948
|
+
*
|
|
946
949
|
* @public exported from `@promptbook/utils`
|
|
947
950
|
*/
|
|
948
951
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -4023,6 +4026,28 @@
|
|
|
4023
4026
|
// encoding: 'utf-8',
|
|
4024
4027
|
});
|
|
4025
4028
|
|
|
4029
|
+
/**
|
|
4030
|
+
* Function to check if a string is valid CSV
|
|
4031
|
+
*
|
|
4032
|
+
* @param value The string to check
|
|
4033
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
4034
|
+
*
|
|
4035
|
+
* @public exported from `@promptbook/utils`
|
|
4036
|
+
*/
|
|
4037
|
+
function isValidCsvString(value) {
|
|
4038
|
+
try {
|
|
4039
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
4040
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
4041
|
+
return true;
|
|
4042
|
+
}
|
|
4043
|
+
return false;
|
|
4044
|
+
}
|
|
4045
|
+
catch (error) {
|
|
4046
|
+
assertsError(error);
|
|
4047
|
+
return false;
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4026
4051
|
/**
|
|
4027
4052
|
* Definition for CSV spreadsheet
|
|
4028
4053
|
*
|
|
@@ -4033,7 +4058,7 @@
|
|
|
4033
4058
|
formatName: 'CSV',
|
|
4034
4059
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
4035
4060
|
isValid(value, settings, schema) {
|
|
4036
|
-
return
|
|
4061
|
+
return isValidCsvString(value);
|
|
4037
4062
|
},
|
|
4038
4063
|
canBeValid(partialValue, settings, schema) {
|
|
4039
4064
|
return true;
|
|
@@ -4187,6 +4212,30 @@
|
|
|
4187
4212
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
4188
4213
|
*/
|
|
4189
4214
|
|
|
4215
|
+
/**
|
|
4216
|
+
* Function to check if a string is valid XML
|
|
4217
|
+
*
|
|
4218
|
+
* @param value
|
|
4219
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
4220
|
+
*
|
|
4221
|
+
* @public exported from `@promptbook/utils`
|
|
4222
|
+
*/
|
|
4223
|
+
function isValidXmlString(value) {
|
|
4224
|
+
try {
|
|
4225
|
+
const parser = new DOMParser();
|
|
4226
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
4227
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
4228
|
+
if (parserError.length > 0) {
|
|
4229
|
+
return false;
|
|
4230
|
+
}
|
|
4231
|
+
return true;
|
|
4232
|
+
}
|
|
4233
|
+
catch (error) {
|
|
4234
|
+
assertsError(error);
|
|
4235
|
+
return false;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
|
|
4190
4239
|
/**
|
|
4191
4240
|
* Definition for XML format
|
|
4192
4241
|
*
|
|
@@ -4196,7 +4245,7 @@
|
|
|
4196
4245
|
formatName: 'XML',
|
|
4197
4246
|
mimeType: 'application/xml',
|
|
4198
4247
|
isValid(value, settings, schema) {
|
|
4199
|
-
return
|
|
4248
|
+
return isValidXmlString(value);
|
|
4200
4249
|
},
|
|
4201
4250
|
canBeValid(partialValue, settings, schema) {
|
|
4202
4251
|
return true;
|