@promptbook/editable 0.92.0-11 → 0.92.0-13
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 +50 -55
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/core.index.d.ts +6 -4
- package/esm/typings/src/_packages/types.index.d.ts +2 -2
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +3 -1
- package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
- package/esm/typings/src/formats/_common/{FormatDefinition.d.ts → FormatParser.d.ts} +3 -3
- package/esm/typings/src/formats/_common/{FormatSubvalueDefinition.d.ts → FormatSubvalueParser.d.ts} +1 -1
- package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
- package/esm/typings/src/formats/index.d.ts +2 -2
- package/esm/typings/src/formats/json/{JsonFormatDefinition.d.ts → JsonFormatParser.d.ts} +6 -6
- package/esm/typings/src/formats/text/{TextFormatDefinition.d.ts → TextFormatParser.d.ts} +7 -7
- package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
- package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +1 -1
- package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +10 -0
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +7 -0
- package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +50 -55
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +0 -17
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +0 -19
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FormatParser } from '../_common/FormatParser';
|
|
3
3
|
/**
|
|
4
4
|
* Definition for JSON format
|
|
5
5
|
*
|
|
6
6
|
* @private still in development [🏢]
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const JsonFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🧠] Maybe propper instance of object
|
|
11
11
|
* TODO: [0] Make string_serialized_json
|
|
12
12
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
13
13
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
14
|
-
* TODO: [🍓] In `
|
|
15
|
-
* TODO: [🍓] In `
|
|
16
|
-
* TODO: [🍓] In `
|
|
17
|
-
* TODO: [🍓] In `
|
|
14
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
15
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
16
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
17
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
18
18
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
19
19
|
*/
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FormatParser } from '../_common/FormatParser';
|
|
3
3
|
/**
|
|
4
4
|
* Definition for any text - this will be always valid
|
|
5
5
|
*
|
|
6
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
6
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
7
7
|
*
|
|
8
8
|
* @public exported from `@promptbook/core`
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const TextFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
|
|
11
11
|
/**
|
|
12
12
|
* TODO: [1] Make type for XML Text and Schema
|
|
13
13
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
14
|
-
* TODO: [🍓] In `
|
|
15
|
-
* TODO: [🍓] In `
|
|
16
|
-
* TODO: [🍓] In `
|
|
17
|
-
* TODO: [🍓] In `
|
|
14
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
15
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
16
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
17
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
18
18
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
19
19
|
*/
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
2
|
+
import type { FormatParser } from '../_common/FormatParser';
|
|
3
|
+
/**
|
|
4
|
+
* Definition for XML format
|
|
5
|
+
*
|
|
6
|
+
* @private still in development [🏢]
|
|
7
|
+
*/
|
|
8
|
+
export declare const XmlFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠] Maybe propper instance of object
|
|
11
|
+
* TODO: [0] Make string_serialized_xml
|
|
12
|
+
* TODO: [1] Make type for XML Settings and Schema
|
|
13
|
+
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
14
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
15
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
16
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
17
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
18
|
+
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
19
|
+
*/
|
|
@@ -21,5 +21,5 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
|
|
|
21
21
|
export declare function extractJsonBlock(markdown: string_markdown): string_json<really_unknown>;
|
|
22
22
|
/**
|
|
23
23
|
* TODO: Add some auto-healing logic + extract YAML, JSON5, TOML, etc.
|
|
24
|
-
* TODO: [🏢] Make this logic part of `
|
|
24
|
+
* TODO: [🏢] Make this logic part of `JsonFormatParser` or `isValidJsonString`
|
|
25
25
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* Gets wrapper around IndexedDB which can be used as PromptbookStorage
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/browser`
|
|
6
|
+
*/
|
|
7
|
+
export declare function getIndexedDbStorage<TItem>(): PromptbookStorage<TItem>;
|
|
8
|
+
/**
|
|
9
|
+
* Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
|
|
10
|
+
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PromptbookStorage } from '../../_common/PromptbookStorage';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a PromptbookStorage backed by IndexedDB.
|
|
4
|
+
* Uses a single object store named 'promptbook'.
|
|
5
|
+
* @private for `getIndexedDbStorage`
|
|
6
|
+
*/
|
|
7
|
+
export declare function makePromptbookStorageFromIndexedDb<TValue>(dbName?: string, storeName?: string): PromptbookStorage<TValue>;
|
|
@@ -7,6 +7,6 @@ import type { ExpectationUnit } from '../../pipeline/PipelineJson/Expectations';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const CountUtils: Record<ExpectationUnit, (text: string) => ExpectationAmount>;
|
|
9
9
|
/**
|
|
10
|
-
* TODO: [🧠][🤠] This should be probbably as part of `
|
|
10
|
+
* TODO: [🧠][🤠] This should be probbably as part of `TextFormatParser`
|
|
11
11
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
12
12
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/editable",
|
|
3
|
-
"version": "0.92.0-
|
|
3
|
+
"version": "0.92.0-13",
|
|
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/editable.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.92.0-
|
|
54
|
+
"@promptbook/core": "0.92.0-13"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"crypto-js": "4.2.0",
|
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.92.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-13';
|
|
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
|
|
@@ -733,6 +733,24 @@
|
|
|
733
733
|
// encoding: 'utf-8',
|
|
734
734
|
});
|
|
735
735
|
|
|
736
|
+
/**
|
|
737
|
+
* Converts a CSV string into an object
|
|
738
|
+
*
|
|
739
|
+
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
740
|
+
*
|
|
741
|
+
* @private - for now until `@promptbook/csv` is released
|
|
742
|
+
*/
|
|
743
|
+
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
744
|
+
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
745
|
+
// Note: Autoheal invalid '\n' characters
|
|
746
|
+
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
747
|
+
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
748
|
+
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
749
|
+
}
|
|
750
|
+
const csv = papaparse.parse(value, settings);
|
|
751
|
+
return csv;
|
|
752
|
+
}
|
|
753
|
+
|
|
736
754
|
/**
|
|
737
755
|
* Function to check if a string is valid CSV
|
|
738
756
|
*
|
|
@@ -755,31 +773,13 @@
|
|
|
755
773
|
}
|
|
756
774
|
}
|
|
757
775
|
|
|
758
|
-
/**
|
|
759
|
-
* Converts a CSV string into an object
|
|
760
|
-
*
|
|
761
|
-
* Note: This is wrapper around `papaparse.parse()` with better autohealing
|
|
762
|
-
*
|
|
763
|
-
* @private - for now until `@promptbook/csv` is released
|
|
764
|
-
*/
|
|
765
|
-
function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
|
|
766
|
-
settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
|
|
767
|
-
// Note: Autoheal invalid '\n' characters
|
|
768
|
-
if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
|
|
769
|
-
console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
|
|
770
|
-
value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
771
|
-
}
|
|
772
|
-
const csv = papaparse.parse(value, settings);
|
|
773
|
-
return csv;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
776
|
/**
|
|
777
777
|
* Definition for CSV spreadsheet
|
|
778
778
|
*
|
|
779
779
|
* @public exported from `@promptbook/core`
|
|
780
780
|
* <- TODO: [🏢] Export from package `@promptbook/csv`
|
|
781
781
|
*/
|
|
782
|
-
const
|
|
782
|
+
const CsvFormatParser = {
|
|
783
783
|
formatName: 'CSV',
|
|
784
784
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
785
785
|
isValid(value, settings, schema) {
|
|
@@ -791,7 +791,7 @@
|
|
|
791
791
|
heal(value, settings, schema) {
|
|
792
792
|
throw new Error('Not implemented');
|
|
793
793
|
},
|
|
794
|
-
|
|
794
|
+
subvalueParsers: [
|
|
795
795
|
{
|
|
796
796
|
subvalueName: 'ROW',
|
|
797
797
|
async mapValues(value, outputParameterName, settings, mapCallback) {
|
|
@@ -852,10 +852,10 @@
|
|
|
852
852
|
],
|
|
853
853
|
};
|
|
854
854
|
/**
|
|
855
|
-
* TODO: [🍓] In `
|
|
856
|
-
* TODO: [🍓] In `
|
|
857
|
-
* TODO: [🍓] In `
|
|
858
|
-
* TODO: [🍓] In `
|
|
855
|
+
* TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
|
|
856
|
+
* TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
|
|
857
|
+
* TODO: [🍓] In `CsvFormatParser` implement `heal
|
|
858
|
+
* TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
|
|
859
859
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
860
860
|
*/
|
|
861
861
|
|
|
@@ -886,7 +886,7 @@
|
|
|
886
886
|
*
|
|
887
887
|
* @private still in development [🏢]
|
|
888
888
|
*/
|
|
889
|
-
const
|
|
889
|
+
const JsonFormatParser = {
|
|
890
890
|
formatName: 'JSON',
|
|
891
891
|
mimeType: 'application/json',
|
|
892
892
|
isValid(value, settings, schema) {
|
|
@@ -898,28 +898,28 @@
|
|
|
898
898
|
heal(value, settings, schema) {
|
|
899
899
|
throw new Error('Not implemented');
|
|
900
900
|
},
|
|
901
|
-
|
|
901
|
+
subvalueParsers: [],
|
|
902
902
|
};
|
|
903
903
|
/**
|
|
904
904
|
* TODO: [🧠] Maybe propper instance of object
|
|
905
905
|
* TODO: [0] Make string_serialized_json
|
|
906
906
|
* TODO: [1] Make type for JSON Settings and Schema
|
|
907
907
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
908
|
-
* TODO: [🍓] In `
|
|
909
|
-
* TODO: [🍓] In `
|
|
910
|
-
* TODO: [🍓] In `
|
|
911
|
-
* TODO: [🍓] In `
|
|
908
|
+
* TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
|
|
909
|
+
* TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
|
|
910
|
+
* TODO: [🍓] In `JsonFormatParser` implement `heal
|
|
911
|
+
* TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
|
|
912
912
|
* TODO: [🏢] Allow to expect something inside JSON objects and other formats
|
|
913
913
|
*/
|
|
914
914
|
|
|
915
915
|
/**
|
|
916
916
|
* Definition for any text - this will be always valid
|
|
917
917
|
*
|
|
918
|
-
* Note: This is not useful for validation, but for splitting and mapping with `
|
|
918
|
+
* Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
|
|
919
919
|
*
|
|
920
920
|
* @public exported from `@promptbook/core`
|
|
921
921
|
*/
|
|
922
|
-
const
|
|
922
|
+
const TextFormatParser = {
|
|
923
923
|
formatName: 'TEXT',
|
|
924
924
|
isValid(value) {
|
|
925
925
|
return typeof value === 'string';
|
|
@@ -928,9 +928,9 @@
|
|
|
928
928
|
return typeof partialValue === 'string';
|
|
929
929
|
},
|
|
930
930
|
heal() {
|
|
931
|
-
throw new UnexpectedError('It does not make sense to call `
|
|
931
|
+
throw new UnexpectedError('It does not make sense to call `TextFormatParser.heal`');
|
|
932
932
|
},
|
|
933
|
-
|
|
933
|
+
subvalueParsers: [
|
|
934
934
|
{
|
|
935
935
|
subvalueName: 'LINE',
|
|
936
936
|
async mapValues(value, outputParameterName, settings, mapCallback) {
|
|
@@ -950,10 +950,10 @@
|
|
|
950
950
|
/**
|
|
951
951
|
* TODO: [1] Make type for XML Text and Schema
|
|
952
952
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
|
|
953
|
-
* TODO: [🍓] In `
|
|
954
|
-
* TODO: [🍓] In `
|
|
955
|
-
* TODO: [🍓] In `
|
|
956
|
-
* TODO: [🍓] In `
|
|
953
|
+
* TODO: [🍓] In `TextFormatParser` implement simple `isValid`
|
|
954
|
+
* TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
|
|
955
|
+
* TODO: [🍓] In `TextFormatParser` implement `heal
|
|
956
|
+
* TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
|
|
957
957
|
* TODO: [🏢] Allow to expect something inside each item of list and other formats
|
|
958
958
|
*/
|
|
959
959
|
|
|
@@ -986,7 +986,7 @@
|
|
|
986
986
|
*
|
|
987
987
|
* @private still in development [🏢]
|
|
988
988
|
*/
|
|
989
|
-
const
|
|
989
|
+
const XmlFormatParser = {
|
|
990
990
|
formatName: 'XML',
|
|
991
991
|
mimeType: 'application/xml',
|
|
992
992
|
isValid(value, settings, schema) {
|
|
@@ -998,17 +998,17 @@
|
|
|
998
998
|
heal(value, settings, schema) {
|
|
999
999
|
throw new Error('Not implemented');
|
|
1000
1000
|
},
|
|
1001
|
-
|
|
1001
|
+
subvalueParsers: [],
|
|
1002
1002
|
};
|
|
1003
1003
|
/**
|
|
1004
1004
|
* TODO: [🧠] Maybe propper instance of object
|
|
1005
1005
|
* TODO: [0] Make string_serialized_xml
|
|
1006
1006
|
* TODO: [1] Make type for XML Settings and Schema
|
|
1007
1007
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
1008
|
-
* TODO: [🍓] In `
|
|
1009
|
-
* TODO: [🍓] In `
|
|
1010
|
-
* TODO: [🍓] In `
|
|
1011
|
-
* TODO: [🍓] In `
|
|
1008
|
+
* TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
|
|
1009
|
+
* TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
|
|
1010
|
+
* TODO: [🍓] In `XmlFormatParser` implement `heal
|
|
1011
|
+
* TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
|
|
1012
1012
|
* TODO: [🏢] Allow to expect something inside XML and other formats
|
|
1013
1013
|
*/
|
|
1014
1014
|
|
|
@@ -1017,12 +1017,7 @@
|
|
|
1017
1017
|
*
|
|
1018
1018
|
* @private internal index of `...` <- TODO [🏢]
|
|
1019
1019
|
*/
|
|
1020
|
-
const FORMAT_DEFINITIONS = [
|
|
1021
|
-
JsonFormatDefinition,
|
|
1022
|
-
XmlFormatDefinition,
|
|
1023
|
-
TextFormatDefinition,
|
|
1024
|
-
CsvFormatDefinition,
|
|
1025
|
-
];
|
|
1020
|
+
const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser, CsvFormatParser];
|
|
1026
1021
|
/**
|
|
1027
1022
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1028
1023
|
*/
|
|
@@ -1834,14 +1829,14 @@
|
|
|
1834
1829
|
`));
|
|
1835
1830
|
// <- TODO: [🏢] List all supported format names
|
|
1836
1831
|
}
|
|
1837
|
-
const
|
|
1838
|
-
if (
|
|
1832
|
+
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
1833
|
+
if (subvalueParser === undefined) {
|
|
1839
1834
|
throw new ParseError(spaceTrim__default["default"]((block) => `
|
|
1840
1835
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
1841
1836
|
|
|
1842
1837
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
1843
|
-
${block(formatDefinition.
|
|
1844
|
-
.map((
|
|
1838
|
+
${block(formatDefinition.subvalueParsers
|
|
1839
|
+
.map((subvalueParser) => subvalueParser.subvalueName)
|
|
1845
1840
|
.map((subvalueName) => `- ${subvalueName}`)
|
|
1846
1841
|
.join('\n'))}
|
|
1847
1842
|
`));
|