@promptbook/remote-server 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 CHANGED
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-31';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1814,6 +1814,9 @@ function isPipelinePrepared(pipeline) {
1814
1814
  /**
1815
1815
  * Function isValidJsonString will tell you if the string is valid JSON or not
1816
1816
  *
1817
+ * @param value The string to check
1818
+ * @returns True if the string is a valid JSON string, false otherwise
1819
+ *
1817
1820
  * @public exported from `@promptbook/utils`
1818
1821
  */
1819
1822
  function isValidJsonString(value /* <- [👨‍⚖️] */) {
@@ -4342,6 +4345,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
4342
4345
  // encoding: 'utf-8',
4343
4346
  });
4344
4347
 
4348
+ /**
4349
+ * Function to check if a string is valid CSV
4350
+ *
4351
+ * @param value The string to check
4352
+ * @returns True if the string is a valid CSV string, false otherwise
4353
+ *
4354
+ * @public exported from `@promptbook/utils`
4355
+ */
4356
+ function isValidCsvString(value) {
4357
+ try {
4358
+ // A simple check for CSV format: at least one comma and no invalid characters
4359
+ if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
4360
+ return true;
4361
+ }
4362
+ return false;
4363
+ }
4364
+ catch (error) {
4365
+ assertsError(error);
4366
+ return false;
4367
+ }
4368
+ }
4369
+
4345
4370
  /**
4346
4371
  * Definition for CSV spreadsheet
4347
4372
  *
@@ -4352,7 +4377,7 @@ const CsvFormatDefinition = {
4352
4377
  formatName: 'CSV',
4353
4378
  aliases: ['SPREADSHEET', 'TABLE'],
4354
4379
  isValid(value, settings, schema) {
4355
- return true;
4380
+ return isValidCsvString(value);
4356
4381
  },
4357
4382
  canBeValid(partialValue, settings, schema) {
4358
4383
  return true;
@@ -4506,6 +4531,30 @@ const TextFormatDefinition = {
4506
4531
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
4507
4532
  */
4508
4533
 
4534
+ /**
4535
+ * Function to check if a string is valid XML
4536
+ *
4537
+ * @param value
4538
+ * @returns True if the string is a valid XML string, false otherwise
4539
+ *
4540
+ * @public exported from `@promptbook/utils`
4541
+ */
4542
+ function isValidXmlString(value) {
4543
+ try {
4544
+ const parser = new DOMParser();
4545
+ const parsedDocument = parser.parseFromString(value, 'application/xml');
4546
+ const parserError = parsedDocument.getElementsByTagName('parsererror');
4547
+ if (parserError.length > 0) {
4548
+ return false;
4549
+ }
4550
+ return true;
4551
+ }
4552
+ catch (error) {
4553
+ assertsError(error);
4554
+ return false;
4555
+ }
4556
+ }
4557
+
4509
4558
  /**
4510
4559
  * Definition for XML format
4511
4560
  *
@@ -4515,7 +4564,7 @@ const XmlFormatDefinition = {
4515
4564
  formatName: 'XML',
4516
4565
  mimeType: 'application/xml',
4517
4566
  isValid(value, settings, schema) {
4518
- return true;
4567
+ return isValidXmlString(value);
4519
4568
  },
4520
4569
  canBeValid(partialValue, settings, schema) {
4521
4570
  return true;