@promptbook/remote-server 0.89.0-30 → 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.
@@ -5,7 +5,9 @@ import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMe
5
5
  import { deserializeError } from '../errors/utils/deserializeError';
6
6
  import { serializeError } from '../errors/utils/serializeError';
7
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
8
+ import { isValidCsvString } from '../formats/csv/utils/isValidCsvString';
8
9
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
+ import { isValidXmlString } from '../formats/xml/utils/isValidXmlString';
9
11
  import { prompt } from '../pipeline/prompt-notation';
10
12
  import { promptTemplate } from '../pipeline/prompt-notation';
11
13
  import { $getCurrentDate } from '../utils/$getCurrentDate';
@@ -87,7 +89,9 @@ export { renderPromptbookMermaid };
87
89
  export { deserializeError };
88
90
  export { serializeError };
89
91
  export { forEachAsync };
92
+ export { isValidCsvString };
90
93
  export { isValidJsonString };
94
+ export { isValidXmlString };
91
95
  export { prompt };
92
96
  export { promptTemplate };
93
97
  export { $getCurrentDate };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Function to check if a string is valid CSV
3
+ *
4
+ * @param value The string to check
5
+ * @returns True if the string is a valid CSV string, false otherwise
6
+ *
7
+ * @public exported from `@promptbook/utils`
8
+ */
9
+ export declare function isValidCsvString(value: string): boolean;
@@ -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-server",
3
- "version": "0.89.0-30",
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-server.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.89.0-30"
54
+ "@promptbook/core": "0.89.0-32"
55
55
  },
56
56
  "dependencies": {
57
57
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-30';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1829,6 +1829,9 @@
1829
1829
  /**
1830
1830
  * Function isValidJsonString will tell you if the string is valid JSON or not
1831
1831
  *
1832
+ * @param value The string to check
1833
+ * @returns True if the string is a valid JSON string, false otherwise
1834
+ *
1832
1835
  * @public exported from `@promptbook/utils`
1833
1836
  */
1834
1837
  function isValidJsonString(value /* <- [👨‍⚖️] */) {
@@ -4357,6 +4360,28 @@
4357
4360
  // encoding: 'utf-8',
4358
4361
  });
4359
4362
 
4363
+ /**
4364
+ * Function to check if a string is valid CSV
4365
+ *
4366
+ * @param value The string to check
4367
+ * @returns True if the string is a valid CSV string, false otherwise
4368
+ *
4369
+ * @public exported from `@promptbook/utils`
4370
+ */
4371
+ function isValidCsvString(value) {
4372
+ try {
4373
+ // A simple check for CSV format: at least one comma and no invalid characters
4374
+ if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
4375
+ return true;
4376
+ }
4377
+ return false;
4378
+ }
4379
+ catch (error) {
4380
+ assertsError(error);
4381
+ return false;
4382
+ }
4383
+ }
4384
+
4360
4385
  /**
4361
4386
  * Definition for CSV spreadsheet
4362
4387
  *
@@ -4367,7 +4392,7 @@
4367
4392
  formatName: 'CSV',
4368
4393
  aliases: ['SPREADSHEET', 'TABLE'],
4369
4394
  isValid(value, settings, schema) {
4370
- return true;
4395
+ return isValidCsvString(value);
4371
4396
  },
4372
4397
  canBeValid(partialValue, settings, schema) {
4373
4398
  return true;
@@ -4521,6 +4546,30 @@
4521
4546
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
4522
4547
  */
4523
4548
 
4549
+ /**
4550
+ * Function to check if a string is valid XML
4551
+ *
4552
+ * @param value
4553
+ * @returns True if the string is a valid XML string, false otherwise
4554
+ *
4555
+ * @public exported from `@promptbook/utils`
4556
+ */
4557
+ function isValidXmlString(value) {
4558
+ try {
4559
+ const parser = new DOMParser();
4560
+ const parsedDocument = parser.parseFromString(value, 'application/xml');
4561
+ const parserError = parsedDocument.getElementsByTagName('parsererror');
4562
+ if (parserError.length > 0) {
4563
+ return false;
4564
+ }
4565
+ return true;
4566
+ }
4567
+ catch (error) {
4568
+ assertsError(error);
4569
+ return false;
4570
+ }
4571
+ }
4572
+
4524
4573
  /**
4525
4574
  * Definition for XML format
4526
4575
  *
@@ -4530,7 +4579,7 @@
4530
4579
  formatName: 'XML',
4531
4580
  mimeType: 'application/xml',
4532
4581
  isValid(value, settings, schema) {
4533
- return true;
4582
+ return isValidXmlString(value);
4534
4583
  },
4535
4584
  canBeValid(partialValue, settings, schema) {
4536
4585
  return true;