@promptbook/remote-client 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.
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.89.0-31",
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/remote-client.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.89.0-31"
54
+ "@promptbook/core": "0.89.0-32"
55
55
  },
56
56
  "dependencies": {
57
57
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-31';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1837,6 +1837,28 @@
1837
1837
  // encoding: 'utf-8',
1838
1838
  });
1839
1839
 
1840
+ /**
1841
+ * Function to check if a string is valid CSV
1842
+ *
1843
+ * @param value The string to check
1844
+ * @returns True if the string is a valid CSV string, false otherwise
1845
+ *
1846
+ * @public exported from `@promptbook/utils`
1847
+ */
1848
+ function isValidCsvString(value) {
1849
+ try {
1850
+ // A simple check for CSV format: at least one comma and no invalid characters
1851
+ if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
1852
+ return true;
1853
+ }
1854
+ return false;
1855
+ }
1856
+ catch (error) {
1857
+ assertsError(error);
1858
+ return false;
1859
+ }
1860
+ }
1861
+
1840
1862
  /**
1841
1863
  * Definition for CSV spreadsheet
1842
1864
  *
@@ -1847,7 +1869,7 @@
1847
1869
  formatName: 'CSV',
1848
1870
  aliases: ['SPREADSHEET', 'TABLE'],
1849
1871
  isValid(value, settings, schema) {
1850
- return true;
1872
+ return isValidCsvString(value);
1851
1873
  },
1852
1874
  canBeValid(partialValue, settings, schema) {
1853
1875
  return true;
@@ -1928,6 +1950,9 @@
1928
1950
  /**
1929
1951
  * Function isValidJsonString will tell you if the string is valid JSON or not
1930
1952
  *
1953
+ * @param value The string to check
1954
+ * @returns True if the string is a valid JSON string, false otherwise
1955
+ *
1931
1956
  * @public exported from `@promptbook/utils`
1932
1957
  */
1933
1958
  function isValidJsonString(value /* <- [👨‍⚖️] */) {
@@ -2020,6 +2045,30 @@
2020
2045
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
2021
2046
  */
2022
2047
 
2048
+ /**
2049
+ * Function to check if a string is valid XML
2050
+ *
2051
+ * @param value
2052
+ * @returns True if the string is a valid XML string, false otherwise
2053
+ *
2054
+ * @public exported from `@promptbook/utils`
2055
+ */
2056
+ function isValidXmlString(value) {
2057
+ try {
2058
+ const parser = new DOMParser();
2059
+ const parsedDocument = parser.parseFromString(value, 'application/xml');
2060
+ const parserError = parsedDocument.getElementsByTagName('parsererror');
2061
+ if (parserError.length > 0) {
2062
+ return false;
2063
+ }
2064
+ return true;
2065
+ }
2066
+ catch (error) {
2067
+ assertsError(error);
2068
+ return false;
2069
+ }
2070
+ }
2071
+
2023
2072
  /**
2024
2073
  * Definition for XML format
2025
2074
  *
@@ -2029,7 +2078,7 @@
2029
2078
  formatName: 'XML',
2030
2079
  mimeType: 'application/xml',
2031
2080
  isValid(value, settings, schema) {
2032
- return true;
2081
+ return isValidXmlString(value);
2033
2082
  },
2034
2083
  canBeValid(partialValue, settings, schema) {
2035
2084
  return true;