@promptbook/remote-client 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 CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-31';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-33';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1834,6 +1834,28 @@ const MANDATORY_CSV_SETTINGS = Object.freeze({
1834
1834
  // encoding: 'utf-8',
1835
1835
  });
1836
1836
 
1837
+ /**
1838
+ * Function to check if a string is valid CSV
1839
+ *
1840
+ * @param value The string to check
1841
+ * @returns True if the string is a valid CSV string, false otherwise
1842
+ *
1843
+ * @public exported from `@promptbook/utils`
1844
+ */
1845
+ function isValidCsvString(value) {
1846
+ try {
1847
+ // A simple check for CSV format: at least one comma and no invalid characters
1848
+ if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
1849
+ return true;
1850
+ }
1851
+ return false;
1852
+ }
1853
+ catch (error) {
1854
+ assertsError(error);
1855
+ return false;
1856
+ }
1857
+ }
1858
+
1837
1859
  /**
1838
1860
  * Definition for CSV spreadsheet
1839
1861
  *
@@ -1844,7 +1866,7 @@ const CsvFormatDefinition = {
1844
1866
  formatName: 'CSV',
1845
1867
  aliases: ['SPREADSHEET', 'TABLE'],
1846
1868
  isValid(value, settings, schema) {
1847
- return true;
1869
+ return isValidCsvString(value);
1848
1870
  },
1849
1871
  canBeValid(partialValue, settings, schema) {
1850
1872
  return true;
@@ -1925,6 +1947,9 @@ const CsvFormatDefinition = {
1925
1947
  /**
1926
1948
  * Function isValidJsonString will tell you if the string is valid JSON or not
1927
1949
  *
1950
+ * @param value The string to check
1951
+ * @returns True if the string is a valid JSON string, false otherwise
1952
+ *
1928
1953
  * @public exported from `@promptbook/utils`
1929
1954
  */
1930
1955
  function isValidJsonString(value /* <- [👨‍⚖️] */) {
@@ -2017,6 +2042,30 @@ const TextFormatDefinition = {
2017
2042
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
2018
2043
  */
2019
2044
 
2045
+ /**
2046
+ * Function to check if a string is valid XML
2047
+ *
2048
+ * @param value
2049
+ * @returns True if the string is a valid XML string, false otherwise
2050
+ *
2051
+ * @public exported from `@promptbook/utils`
2052
+ */
2053
+ function isValidXmlString(value) {
2054
+ try {
2055
+ const parser = new DOMParser();
2056
+ const parsedDocument = parser.parseFromString(value, 'application/xml');
2057
+ const parserError = parsedDocument.getElementsByTagName('parsererror');
2058
+ if (parserError.length > 0) {
2059
+ return false;
2060
+ }
2061
+ return true;
2062
+ }
2063
+ catch (error) {
2064
+ assertsError(error);
2065
+ return false;
2066
+ }
2067
+ }
2068
+
2020
2069
  /**
2021
2070
  * Definition for XML format
2022
2071
  *
@@ -2026,7 +2075,7 @@ const XmlFormatDefinition = {
2026
2075
  formatName: 'XML',
2027
2076
  mimeType: 'application/xml',
2028
2077
  isValid(value, settings, schema) {
2029
- return true;
2078
+ return isValidXmlString(value);
2030
2079
  },
2031
2080
  canBeValid(partialValue, settings, schema) {
2032
2081
  return true;