@promptbook/documents 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
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-33';
|
|
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
|
|
@@ -1123,6 +1123,9 @@ function assertsError(whatWasThrown) {
|
|
|
1123
1123
|
/**
|
|
1124
1124
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1125
1125
|
*
|
|
1126
|
+
* @param value The string to check
|
|
1127
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
1128
|
+
*
|
|
1126
1129
|
* @public exported from `@promptbook/utils`
|
|
1127
1130
|
*/
|
|
1128
1131
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -4175,6 +4178,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
|
4175
4178
|
// encoding: 'utf-8',
|
|
4176
4179
|
});
|
|
4177
4180
|
|
|
4181
|
+
/**
|
|
4182
|
+
* Function to check if a string is valid CSV
|
|
4183
|
+
*
|
|
4184
|
+
* @param value The string to check
|
|
4185
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
4186
|
+
*
|
|
4187
|
+
* @public exported from `@promptbook/utils`
|
|
4188
|
+
*/
|
|
4189
|
+
function isValidCsvString(value) {
|
|
4190
|
+
try {
|
|
4191
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
4192
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
4193
|
+
return true;
|
|
4194
|
+
}
|
|
4195
|
+
return false;
|
|
4196
|
+
}
|
|
4197
|
+
catch (error) {
|
|
4198
|
+
assertsError(error);
|
|
4199
|
+
return false;
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4178
4203
|
/**
|
|
4179
4204
|
* Definition for CSV spreadsheet
|
|
4180
4205
|
*
|
|
@@ -4185,7 +4210,7 @@ const CsvFormatDefinition = {
|
|
|
4185
4210
|
formatName: 'CSV',
|
|
4186
4211
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
4187
4212
|
isValid(value, settings, schema) {
|
|
4188
|
-
return
|
|
4213
|
+
return isValidCsvString(value);
|
|
4189
4214
|
},
|
|
4190
4215
|
canBeValid(partialValue, settings, schema) {
|
|
4191
4216
|
return true;
|
|
@@ -4339,6 +4364,30 @@ const TextFormatDefinition = {
|
|
|
4339
4364
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
4340
4365
|
*/
|
|
4341
4366
|
|
|
4367
|
+
/**
|
|
4368
|
+
* Function to check if a string is valid XML
|
|
4369
|
+
*
|
|
4370
|
+
* @param value
|
|
4371
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
4372
|
+
*
|
|
4373
|
+
* @public exported from `@promptbook/utils`
|
|
4374
|
+
*/
|
|
4375
|
+
function isValidXmlString(value) {
|
|
4376
|
+
try {
|
|
4377
|
+
const parser = new DOMParser();
|
|
4378
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
4379
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
4380
|
+
if (parserError.length > 0) {
|
|
4381
|
+
return false;
|
|
4382
|
+
}
|
|
4383
|
+
return true;
|
|
4384
|
+
}
|
|
4385
|
+
catch (error) {
|
|
4386
|
+
assertsError(error);
|
|
4387
|
+
return false;
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4342
4391
|
/**
|
|
4343
4392
|
* Definition for XML format
|
|
4344
4393
|
*
|
|
@@ -4348,7 +4397,7 @@ const XmlFormatDefinition = {
|
|
|
4348
4397
|
formatName: 'XML',
|
|
4349
4398
|
mimeType: 'application/xml',
|
|
4350
4399
|
isValid(value, settings, schema) {
|
|
4351
|
-
return
|
|
4400
|
+
return isValidXmlString(value);
|
|
4352
4401
|
},
|
|
4353
4402
|
canBeValid(partialValue, settings, schema) {
|
|
4354
4403
|
return true;
|