@promptbook/remote-client 0.92.0-21 → 0.92.0-22
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 +17 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +8 -1
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +11 -1
- package/package.json +2 -2
- package/umd/index.umd.js +17 -7
- package/umd/index.umd.js.map +1 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import type { PartialDeep, Promisable } from 'type-fest';
|
|
1
2
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
3
|
+
import type { PipelineExecutorResult } from '../PipelineExecutorResult';
|
|
2
4
|
import type { ExecuteAttemptsOptions } from './40-executeAttempts';
|
|
3
5
|
/**
|
|
4
6
|
* @@@
|
|
5
7
|
*
|
|
6
8
|
* @private internal type of `executeFormatSubvalues`
|
|
7
9
|
*/
|
|
8
|
-
type ExecuteFormatCellsOptions = ExecuteAttemptsOptions
|
|
10
|
+
type ExecuteFormatCellsOptions = ExecuteAttemptsOptions & {
|
|
11
|
+
/**
|
|
12
|
+
* @@@
|
|
13
|
+
*/
|
|
14
|
+
readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
|
|
15
|
+
};
|
|
9
16
|
/**
|
|
10
17
|
* @@@
|
|
11
18
|
*
|
|
@@ -24,7 +24,17 @@ export type FormatSubvalueParser<TValue extends string, TSettings extends empty_
|
|
|
24
24
|
* For example, if you have a JSON object and you want to map all values to uppercase
|
|
25
25
|
* Or iterate over all CSV cells @@@
|
|
26
26
|
*/
|
|
27
|
-
mapValues(
|
|
27
|
+
mapValues(options: FormatSubvalueParserMapValuesOptions<TValue, TSettings>): Promise<string>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @@@
|
|
31
|
+
*/
|
|
32
|
+
export type FormatSubvalueParserMapValuesOptions<TValue extends string, TSettings extends empty_object> = {
|
|
33
|
+
readonly value: TValue;
|
|
34
|
+
readonly outputParameterName: string_parameter_name;
|
|
35
|
+
readonly settings: TSettings;
|
|
36
|
+
mapCallback: (subvalues: Parameters, index: number) => Promisable<TValue>;
|
|
37
|
+
onProgress(partialResultString: TValue): Promisable<void>;
|
|
28
38
|
};
|
|
29
39
|
/**
|
|
30
40
|
* Note: [👩🏾🤝🧑🏽]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-client",
|
|
3
|
-
"version": "0.92.0-
|
|
3
|
+
"version": "0.92.0-22",
|
|
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.92.0-
|
|
54
|
+
"@promptbook/core": "0.92.0-22"
|
|
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.92.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
|
|
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
|
|
@@ -1898,7 +1898,8 @@
|
|
|
1898
1898
|
subvalueParsers: [
|
|
1899
1899
|
{
|
|
1900
1900
|
subvalueName: 'ROW',
|
|
1901
|
-
async mapValues(
|
|
1901
|
+
async mapValues(options) {
|
|
1902
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
1902
1903
|
const csv = csvParse(value, settings);
|
|
1903
1904
|
if (csv.errors.length !== 0) {
|
|
1904
1905
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
@@ -1914,21 +1915,29 @@
|
|
|
1914
1915
|
${block(value)}
|
|
1915
1916
|
`));
|
|
1916
1917
|
}
|
|
1917
|
-
const mappedData =
|
|
1918
|
+
const mappedData = [];
|
|
1919
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
1920
|
+
const row = csv.data[index];
|
|
1918
1921
|
if (row[outputParameterName]) {
|
|
1919
1922
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
1920
1923
|
}
|
|
1921
|
-
|
|
1924
|
+
const mappedRow = {
|
|
1922
1925
|
...row,
|
|
1923
1926
|
[outputParameterName]: await mapCallback(row, index),
|
|
1924
1927
|
};
|
|
1925
|
-
|
|
1928
|
+
mappedData.push(mappedRow);
|
|
1929
|
+
if (onProgress) {
|
|
1930
|
+
// Note: Report the CSV with all rows mapped so far
|
|
1931
|
+
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1926
1934
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
1927
1935
|
},
|
|
1928
1936
|
},
|
|
1929
1937
|
{
|
|
1930
1938
|
subvalueName: 'CELL',
|
|
1931
|
-
async mapValues(
|
|
1939
|
+
async mapValues(options) {
|
|
1940
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
1932
1941
|
const csv = csvParse(value, settings);
|
|
1933
1942
|
if (csv.errors.length !== 0) {
|
|
1934
1943
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
@@ -2037,7 +2046,8 @@
|
|
|
2037
2046
|
subvalueParsers: [
|
|
2038
2047
|
{
|
|
2039
2048
|
subvalueName: 'LINE',
|
|
2040
|
-
async mapValues(
|
|
2049
|
+
async mapValues(options) {
|
|
2050
|
+
const { value, mapCallback, onProgress } = options;
|
|
2041
2051
|
const lines = value.split('\n');
|
|
2042
2052
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
2043
2053
|
// TODO: [🧠] Maybe option to skip empty line
|