@promptbook/pdf 0.89.0-31 → 0.89.0-33
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/types.index.d.ts +2 -0
- 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/esm/typings/src/remote-server/socket-types/_subtypes/Identification.d.ts +7 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +7 -0
- package/package.json +2 -2
- package/umd/index.umd.js +52 -3
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-33';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -944,6 +944,9 @@ function assertsError(whatWasThrown) {
|
|
|
944
944
|
/**
|
|
945
945
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
946
946
|
*
|
|
947
|
+
* @param value The string to check
|
|
948
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
949
|
+
*
|
|
947
950
|
* @public exported from `@promptbook/utils`
|
|
948
951
|
*/
|
|
949
952
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -4024,6 +4027,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
4024
4027
|
// encoding: 'utf-8',
|
|
4025
4028
|
});
|
|
4026
4029
|
|
|
4030
|
+
/**
|
|
4031
|
+
* Function to check if a string is valid CSV
|
|
4032
|
+
*
|
|
4033
|
+
* @param value The string to check
|
|
4034
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
4035
|
+
*
|
|
4036
|
+
* @public exported from `@promptbook/utils`
|
|
4037
|
+
*/
|
|
4038
|
+
function isValidCsvString(value) {
|
|
4039
|
+
try {
|
|
4040
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
4041
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
4042
|
+
return true;
|
|
4043
|
+
}
|
|
4044
|
+
return false;
|
|
4045
|
+
}
|
|
4046
|
+
catch (error) {
|
|
4047
|
+
assertsError(error);
|
|
4048
|
+
return false;
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
|
|
4027
4052
|
/**
|
|
4028
4053
|
* Definition for CSV spreadsheet
|
|
4029
4054
|
*
|
|
@@ -4034,7 +4059,7 @@ const CsvFormatDefinition = {
|
|
|
4034
4059
|
formatName: 'CSV',
|
|
4035
4060
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
4036
4061
|
isValid(value, settings, schema) {
|
|
4037
|
-
return
|
|
4062
|
+
return isValidCsvString(value);
|
|
4038
4063
|
},
|
|
4039
4064
|
canBeValid(partialValue, settings, schema) {
|
|
4040
4065
|
return true;
|
|
@@ -4188,6 +4213,30 @@ const TextFormatDefinition = {
|
|
|
4188
4213
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
4189
4214
|
*/
|
|
4190
4215
|
|
|
4216
|
+
/**
|
|
4217
|
+
* Function to check if a string is valid XML
|
|
4218
|
+
*
|
|
4219
|
+
* @param value
|
|
4220
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
4221
|
+
*
|
|
4222
|
+
* @public exported from `@promptbook/utils`
|
|
4223
|
+
*/
|
|
4224
|
+
function isValidXmlString(value) {
|
|
4225
|
+
try {
|
|
4226
|
+
const parser = new DOMParser();
|
|
4227
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
4228
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
4229
|
+
if (parserError.length > 0) {
|
|
4230
|
+
return false;
|
|
4231
|
+
}
|
|
4232
|
+
return true;
|
|
4233
|
+
}
|
|
4234
|
+
catch (error) {
|
|
4235
|
+
assertsError(error);
|
|
4236
|
+
return false;
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4191
4240
|
/**
|
|
4192
4241
|
* Definition for XML format
|
|
4193
4242
|
*
|
|
@@ -4197,7 +4246,7 @@ const XmlFormatDefinition = {
|
|
|
4197
4246
|
formatName: 'XML',
|
|
4198
4247
|
mimeType: 'application/xml',
|
|
4199
4248
|
isValid(value, settings, schema) {
|
|
4200
|
-
return
|
|
4249
|
+
return isValidXmlString(value);
|
|
4201
4250
|
},
|
|
4202
4251
|
canBeValid(partialValue, settings, schema) {
|
|
4203
4252
|
return true;
|