@promptbook/documents 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/documents",
|
|
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/documents.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
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-32';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1121,6 +1121,9 @@
|
|
|
1121
1121
|
/**
|
|
1122
1122
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1123
1123
|
*
|
|
1124
|
+
* @param value The string to check
|
|
1125
|
+
* @returns True if the string is a valid JSON string, false otherwise
|
|
1126
|
+
*
|
|
1124
1127
|
* @public exported from `@promptbook/utils`
|
|
1125
1128
|
*/
|
|
1126
1129
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
@@ -4173,6 +4176,28 @@
|
|
|
4173
4176
|
// encoding: 'utf-8',
|
|
4174
4177
|
});
|
|
4175
4178
|
|
|
4179
|
+
/**
|
|
4180
|
+
* Function to check if a string is valid CSV
|
|
4181
|
+
*
|
|
4182
|
+
* @param value The string to check
|
|
4183
|
+
* @returns True if the string is a valid CSV string, false otherwise
|
|
4184
|
+
*
|
|
4185
|
+
* @public exported from `@promptbook/utils`
|
|
4186
|
+
*/
|
|
4187
|
+
function isValidCsvString(value) {
|
|
4188
|
+
try {
|
|
4189
|
+
// A simple check for CSV format: at least one comma and no invalid characters
|
|
4190
|
+
if (value.includes(',') && /^[\w\s,"']+$/.test(value)) {
|
|
4191
|
+
return true;
|
|
4192
|
+
}
|
|
4193
|
+
return false;
|
|
4194
|
+
}
|
|
4195
|
+
catch (error) {
|
|
4196
|
+
assertsError(error);
|
|
4197
|
+
return false;
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4176
4201
|
/**
|
|
4177
4202
|
* Definition for CSV spreadsheet
|
|
4178
4203
|
*
|
|
@@ -4183,7 +4208,7 @@
|
|
|
4183
4208
|
formatName: 'CSV',
|
|
4184
4209
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
4185
4210
|
isValid(value, settings, schema) {
|
|
4186
|
-
return
|
|
4211
|
+
return isValidCsvString(value);
|
|
4187
4212
|
},
|
|
4188
4213
|
canBeValid(partialValue, settings, schema) {
|
|
4189
4214
|
return true;
|
|
@@ -4337,6 +4362,30 @@
|
|
|
4337
4362
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
4338
4363
|
*/
|
|
4339
4364
|
|
|
4365
|
+
/**
|
|
4366
|
+
* Function to check if a string is valid XML
|
|
4367
|
+
*
|
|
4368
|
+
* @param value
|
|
4369
|
+
* @returns True if the string is a valid XML string, false otherwise
|
|
4370
|
+
*
|
|
4371
|
+
* @public exported from `@promptbook/utils`
|
|
4372
|
+
*/
|
|
4373
|
+
function isValidXmlString(value) {
|
|
4374
|
+
try {
|
|
4375
|
+
const parser = new DOMParser();
|
|
4376
|
+
const parsedDocument = parser.parseFromString(value, 'application/xml');
|
|
4377
|
+
const parserError = parsedDocument.getElementsByTagName('parsererror');
|
|
4378
|
+
if (parserError.length > 0) {
|
|
4379
|
+
return false;
|
|
4380
|
+
}
|
|
4381
|
+
return true;
|
|
4382
|
+
}
|
|
4383
|
+
catch (error) {
|
|
4384
|
+
assertsError(error);
|
|
4385
|
+
return false;
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
|
|
4340
4389
|
/**
|
|
4341
4390
|
* Definition for XML format
|
|
4342
4391
|
*
|
|
@@ -4346,7 +4395,7 @@
|
|
|
4346
4395
|
formatName: 'XML',
|
|
4347
4396
|
mimeType: 'application/xml',
|
|
4348
4397
|
isValid(value, settings, schema) {
|
|
4349
|
-
return
|
|
4398
|
+
return isValidXmlString(value);
|
|
4350
4399
|
},
|
|
4351
4400
|
canBeValid(partialValue, settings, schema) {
|
|
4352
4401
|
return true;
|