@promptbook/node 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.
- package/esm/index.es.js +52 -3
- package/esm/index.es.js.map +1 -1
- 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/package.json +2 -2
- package/umd/index.umd.js +52 -3
- package/umd/index.umd.js.map +1 -1
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.89.0-
|
|
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/node.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.89.0-
|
|
54
|
+
"@promptbook/core": "0.89.0-32"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1183,6 +1183,9 @@
|
|
|
1183
1183
|
/**
|
|
1184
1184
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1185
1185
|
*
|
|
1186
|
+
* @param value The string to check
|
|
1187
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
1188
|
+
*
|
|
1186
1189
|
* @public exported from `@promptbook/utils`
|
|
1187
1190
|
*/
|
|
1188
1191
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -2495,6 +2498,28 @@
|
|
|
2495
2498
|
// encoding: 'utf-8',
|
|
2496
2499
|
});
|
|
2497
2500
|
|
|
2501
|
+
/**
|
|
2502
|
+
* Function to check if a string is valid CSV
|
|
2503
|
+
*
|
|
2504
|
+
* @param value The string to check
|
|
2505
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
2506
|
+
*
|
|
2507
|
+
* @public exported from `@promptbook/utils`
|
|
2508
|
+
*/
|
|
2509
|
+
function isValidCsvString(value) {
|
|
2510
|
+
try {
|
|
2511
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
2512
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
2513
|
+
return true;
|
|
2514
|
+
}
|
|
2515
|
+
return false;
|
|
2516
|
+
}
|
|
2517
|
+
catch (error) {
|
|
2518
|
+
assertsError(error);
|
|
2519
|
+
return false;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2498
2523
|
/**
|
|
2499
2524
|
* Definition for CSV spreadsheet
|
|
2500
2525
|
*
|
|
@@ -2505,7 +2530,7 @@
|
|
|
2505
2530
|
formatName: 'CSV',
|
|
2506
2531
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2507
2532
|
isValid(value, settings, schema) {
|
|
2508
|
-
return
|
|
2533
|
+
return isValidCsvString(value);
|
|
2509
2534
|
},
|
|
2510
2535
|
canBeValid(partialValue, settings, schema) {
|
|
2511
2536
|
return true;
|
|
@@ -2659,6 +2684,30 @@
|
|
|
2659
2684
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
2660
2685
|
*/
|
|
2661
2686
|
|
|
2687
|
+
/**
|
|
2688
|
+
* Function to check if a string is valid XML
|
|
2689
|
+
*
|
|
2690
|
+
* @param value
|
|
2691
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
2692
|
+
*
|
|
2693
|
+
* @public exported from `@promptbook/utils`
|
|
2694
|
+
*/
|
|
2695
|
+
function isValidXmlString(value) {
|
|
2696
|
+
try {
|
|
2697
|
+
const parser = new DOMParser();
|
|
2698
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
2699
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
2700
|
+
if (parserError.length > 0) {
|
|
2701
|
+
return false;
|
|
2702
|
+
}
|
|
2703
|
+
return true;
|
|
2704
|
+
}
|
|
2705
|
+
catch (error) {
|
|
2706
|
+
assertsError(error);
|
|
2707
|
+
return false;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2662
2711
|
/**
|
|
2663
2712
|
* Definition for XML format
|
|
2664
2713
|
*
|
|
@@ -2668,7 +2717,7 @@
|
|
|
2668
2717
|
formatName: 'XML',
|
|
2669
2718
|
mimeType: 'application/xml',
|
|
2670
2719
|
isValid(value, settings, schema) {
|
|
2671
|
-
return
|
|
2720
|
+
return isValidXmlString(value);
|
|
2672
2721
|
},
|
|
2673
2722
|
canBeValid(partialValue, settings, schema) {
|
|
2674
2723
|
return true;
|