@promptbook/pdf 0.92.0-22 โ 0.92.0-24
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 +115 -55
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +33 -11
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +11 -8
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +8 -3
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +10 -8
- package/esm/typings/src/formats/_common/FormatParser.d.ts +5 -3
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +31 -6
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
- package/esm/typings/src/formfactors/index.d.ts +1 -1
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
- package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
- package/esm/typings/src/types/typeAliases.d.ts +9 -7
- package/esm/typings/src/utils/$Register.d.ts +8 -7
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
- package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
- package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
- package/package.json +2 -2
- package/umd/index.umd.js +115 -55
- package/umd/index.umd.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { really_any } from '../organization/really_any';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
4
|
+
* regardless of the JavaScript environment in which the code is running
|
|
4
5
|
*
|
|
5
6
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
6
7
|
*
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
2
|
import type { string_parameter_value } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Options for mapping available parameters to expected parameters in a pipeline task.
|
|
5
5
|
*/
|
|
6
6
|
type MakeapAvailableToExpectedParametersOptions = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The set of expected parameter names (keys) for the task, all values are null.
|
|
9
9
|
*/
|
|
10
10
|
readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* The set of available parameters (name-value pairs) to map to the expected parameters.
|
|
13
13
|
*/
|
|
14
14
|
readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Maps available parameters to expected parameters
|
|
17
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
18
18
|
*
|
|
19
19
|
* The strategy is:
|
|
20
|
-
* 1)
|
|
21
|
-
* 2)
|
|
20
|
+
* 1) First, match parameters by name where both available and expected.
|
|
21
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
22
22
|
*
|
|
23
|
-
* @throws {PipelineExecutionError}
|
|
23
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
24
24
|
* @private within the repository used in `createPipelineExecutor`
|
|
25
25
|
*/
|
|
26
26
|
export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a deep clone of a PipelineJson object, copying all properties explicitly.
|
|
4
4
|
*
|
|
5
|
-
* Note: It is
|
|
5
|
+
* Note: It is useful for ensuring that modifications to the returned pipeline do not affect the original.
|
|
6
6
|
*
|
|
7
|
-
* @param pipeline
|
|
7
|
+
* @param pipeline The pipeline to clone.
|
|
8
|
+
* @returns A new PipelineJson object with the same properties as the input.
|
|
8
9
|
* @public exported from `@promptbook/utils`
|
|
9
10
|
*/
|
|
10
11
|
export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { WritableDeep } from 'type-fest';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a deep clone of the given object
|
|
4
4
|
*
|
|
5
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
6
|
+
*
|
|
7
|
+
* @param objectValue The object to clone.
|
|
8
|
+
* @returns A deep, writable clone of the input object.
|
|
5
9
|
* @public exported from `@promptbook/utils`
|
|
6
10
|
*/
|
|
7
11
|
export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { string_javascript_name } from '../../../types/typeAliases';
|
|
2
2
|
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
5
5
|
*
|
|
6
|
-
* @param javascriptName
|
|
7
|
-
* @returns
|
|
6
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
7
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
8
8
|
* @public exported from `@promptbook/utils`
|
|
9
9
|
*/
|
|
10
10
|
export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { string_parameter_name } from '../../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
|
-
* Function `validateParameterName` will
|
|
3
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
4
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
4
5
|
*
|
|
5
|
-
* @param parameterName
|
|
6
|
-
* @returns
|
|
7
|
-
* @throws {ParseError}
|
|
6
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
7
|
+
* @returns The validated and normalized parameter name.
|
|
8
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
8
9
|
* @private within the repository
|
|
9
10
|
*/
|
|
10
11
|
export declare function validateParameterName(parameterName: string): string_parameter_name;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.92.0-
|
|
3
|
+
"version": "0.92.0-24",
|
|
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/pdf.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.92.0-
|
|
54
|
+
"@promptbook/core": "0.92.0-24"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-24';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -101,6 +101,21 @@
|
|
|
101
101
|
* @public exported from `@promptbook/core`
|
|
102
102
|
*/
|
|
103
103
|
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
104
|
+
/**
|
|
105
|
+
* Threshold value that determines when a dataset is considered "big"
|
|
106
|
+
* and may require special handling or optimizations
|
|
107
|
+
*
|
|
108
|
+
* For example, when error occurs in one item of the big dataset, it will not fail the whole pipeline
|
|
109
|
+
*
|
|
110
|
+
* @public exported from `@promptbook/core`
|
|
111
|
+
*/
|
|
112
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
113
|
+
/**
|
|
114
|
+
* Placeholder text used to represent a placeholder value of failed operation
|
|
115
|
+
*
|
|
116
|
+
* @public exported from `@promptbook/core`
|
|
117
|
+
*/
|
|
118
|
+
const FAILED_VALUE_PLACEHOLDER = '!?';
|
|
104
119
|
// <- TODO: [๐ง ] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
105
120
|
/**
|
|
106
121
|
* The maximum number of iterations for a loops
|
|
@@ -180,7 +195,7 @@
|
|
|
180
195
|
const DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
|
|
181
196
|
// <- TODO: [๐งโโ๏ธ]
|
|
182
197
|
/**
|
|
183
|
-
*
|
|
198
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
184
199
|
*
|
|
185
200
|
* @public exported from `@promptbook/core`
|
|
186
201
|
*/
|
|
@@ -191,19 +206,19 @@
|
|
|
191
206
|
skipEmptyLines: true,
|
|
192
207
|
});
|
|
193
208
|
/**
|
|
194
|
-
*
|
|
209
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
195
210
|
*
|
|
196
211
|
* @public exported from `@promptbook/core`
|
|
197
212
|
*/
|
|
198
213
|
let DEFAULT_IS_VERBOSE = false;
|
|
199
214
|
/**
|
|
200
|
-
*
|
|
215
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
201
216
|
*
|
|
202
217
|
* @public exported from `@promptbook/core`
|
|
203
218
|
*/
|
|
204
219
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
205
220
|
/**
|
|
206
|
-
*
|
|
221
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
207
222
|
*
|
|
208
223
|
* @private within the repository
|
|
209
224
|
*/
|
|
@@ -944,7 +959,7 @@
|
|
|
944
959
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
945
960
|
*
|
|
946
961
|
* @param value The string to check
|
|
947
|
-
* @returns
|
|
962
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
948
963
|
*
|
|
949
964
|
* @public exported from `@promptbook/utils`
|
|
950
965
|
*/
|
|
@@ -1355,8 +1370,12 @@
|
|
|
1355
1370
|
*/
|
|
1356
1371
|
|
|
1357
1372
|
/**
|
|
1358
|
-
*
|
|
1373
|
+
* Creates a deep clone of the given object
|
|
1374
|
+
*
|
|
1375
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1359
1376
|
*
|
|
1377
|
+
* @param objectValue The object to clone.
|
|
1378
|
+
* @returns A deep, writable clone of the input object.
|
|
1360
1379
|
* @public exported from `@promptbook/utils`
|
|
1361
1380
|
*/
|
|
1362
1381
|
function deepClone(objectValue) {
|
|
@@ -1943,7 +1962,7 @@
|
|
|
1943
1962
|
/**
|
|
1944
1963
|
* Constructs a pipeline collection from pipelines
|
|
1945
1964
|
*
|
|
1946
|
-
* @param pipelines
|
|
1965
|
+
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
1947
1966
|
*
|
|
1948
1967
|
* Note: During the construction logic of all pipelines are validated
|
|
1949
1968
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
@@ -3080,7 +3099,8 @@
|
|
|
3080
3099
|
*/
|
|
3081
3100
|
|
|
3082
3101
|
/**
|
|
3083
|
-
*
|
|
3102
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
3103
|
+
* regardless of the JavaScript environment in which the code is running
|
|
3084
3104
|
*
|
|
3085
3105
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
3086
3106
|
*
|
|
@@ -3159,11 +3179,11 @@
|
|
|
3159
3179
|
}
|
|
3160
3180
|
|
|
3161
3181
|
/**
|
|
3162
|
-
*
|
|
3182
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
3163
3183
|
*
|
|
3164
3184
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
3165
3185
|
*
|
|
3166
|
-
* @private internal utility, exported are only
|
|
3186
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
3167
3187
|
*/
|
|
3168
3188
|
class $Register {
|
|
3169
3189
|
constructor(registerName) {
|
|
@@ -3207,10 +3227,10 @@
|
|
|
3207
3227
|
}
|
|
3208
3228
|
|
|
3209
3229
|
/**
|
|
3210
|
-
*
|
|
3230
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
3211
3231
|
*
|
|
3212
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3213
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3232
|
+
* Note: `$` is used to indicate that this interacts with the global scope.
|
|
3233
|
+
* @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
|
|
3214
3234
|
* @public exported from `@promptbook/core`
|
|
3215
3235
|
*/
|
|
3216
3236
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -4111,7 +4131,7 @@
|
|
|
4111
4131
|
* Function to check if a string is valid CSV
|
|
4112
4132
|
*
|
|
4113
4133
|
* @param value The string to check
|
|
4114
|
-
* @returns
|
|
4134
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
4115
4135
|
*
|
|
4116
4136
|
* @public exported from `@promptbook/utils`
|
|
4117
4137
|
*/
|
|
@@ -4168,18 +4188,28 @@
|
|
|
4168
4188
|
`));
|
|
4169
4189
|
}
|
|
4170
4190
|
const mappedData = [];
|
|
4171
|
-
|
|
4191
|
+
const length = csv.data.length;
|
|
4192
|
+
for (let index = 0; index < length; index++) {
|
|
4172
4193
|
const row = csv.data[index];
|
|
4173
4194
|
if (row[outputParameterName]) {
|
|
4174
4195
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4175
4196
|
}
|
|
4176
4197
|
const mappedRow = {
|
|
4177
4198
|
...row,
|
|
4178
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
4199
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
4179
4200
|
};
|
|
4180
4201
|
mappedData.push(mappedRow);
|
|
4181
4202
|
if (onProgress) {
|
|
4182
4203
|
// Note: Report the CSV with all rows mapped so far
|
|
4204
|
+
/*
|
|
4205
|
+
!!!!
|
|
4206
|
+
// Report progress with updated value
|
|
4207
|
+
const progressData = mappedData.map((row, i) =>
|
|
4208
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
4209
|
+
);
|
|
4210
|
+
|
|
4211
|
+
|
|
4212
|
+
*/
|
|
4183
4213
|
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4184
4214
|
}
|
|
4185
4215
|
}
|
|
@@ -4206,9 +4236,9 @@
|
|
|
4206
4236
|
`));
|
|
4207
4237
|
}
|
|
4208
4238
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
4209
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
4239
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
4210
4240
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
4211
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
4241
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
4212
4242
|
}));
|
|
4213
4243
|
}));
|
|
4214
4244
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -4279,12 +4309,12 @@
|
|
|
4279
4309
|
async mapValues(options) {
|
|
4280
4310
|
const { value, mapCallback, onProgress } = options;
|
|
4281
4311
|
const lines = value.split('\n');
|
|
4282
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4312
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
4283
4313
|
// TODO: [๐ง ] Maybe option to skip empty line
|
|
4284
4314
|
/* not await */ mapCallback({
|
|
4285
4315
|
lineContent,
|
|
4286
4316
|
// TODO: [๐ง ] Maybe also put here `lineNumber`
|
|
4287
|
-
}, lineNumber)));
|
|
4317
|
+
}, lineNumber, array.length)));
|
|
4288
4318
|
return mappedLines.join('\n');
|
|
4289
4319
|
},
|
|
4290
4320
|
},
|
|
@@ -4305,7 +4335,7 @@
|
|
|
4305
4335
|
* Function to check if a string is valid XML
|
|
4306
4336
|
*
|
|
4307
4337
|
* @param value
|
|
4308
|
-
* @returns
|
|
4338
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
4309
4339
|
*
|
|
4310
4340
|
* @public exported from `@promptbook/utils`
|
|
4311
4341
|
*/
|
|
@@ -4367,13 +4397,13 @@
|
|
|
4367
4397
|
*/
|
|
4368
4398
|
|
|
4369
4399
|
/**
|
|
4370
|
-
* Maps available parameters to expected parameters
|
|
4400
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
4371
4401
|
*
|
|
4372
4402
|
* The strategy is:
|
|
4373
|
-
* 1)
|
|
4374
|
-
* 2)
|
|
4403
|
+
* 1) First, match parameters by name where both available and expected.
|
|
4404
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
4375
4405
|
*
|
|
4376
|
-
* @throws {PipelineExecutionError}
|
|
4406
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
4377
4407
|
* @private within the repository used in `createPipelineExecutor`
|
|
4378
4408
|
*/
|
|
4379
4409
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -5093,7 +5123,11 @@
|
|
|
5093
5123
|
*/
|
|
5094
5124
|
|
|
5095
5125
|
/**
|
|
5096
|
-
*
|
|
5126
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
5127
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
5128
|
+
*
|
|
5129
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
5130
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
5097
5131
|
*
|
|
5098
5132
|
* @private internal utility of `createPipelineExecutor`
|
|
5099
5133
|
*/
|
|
@@ -5158,15 +5192,11 @@
|
|
|
5158
5192
|
settings: formatSettings,
|
|
5159
5193
|
onProgress(partialResultString) {
|
|
5160
5194
|
return onProgress(Object.freeze({
|
|
5161
|
-
[task.resultingParameterName]:
|
|
5162
|
-
// <- Note: [๐ฉโ๐ฉโ๐ง] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5163
|
-
partialResultString,
|
|
5195
|
+
[task.resultingParameterName]: partialResultString,
|
|
5164
5196
|
}));
|
|
5165
5197
|
},
|
|
5166
|
-
async mapCallback(subparameters, index) {
|
|
5198
|
+
async mapCallback(subparameters, index, length) {
|
|
5167
5199
|
let mappedParameters;
|
|
5168
|
-
// TODO: [๐คนโโ๏ธ][๐ช] Limit to N concurrent executions
|
|
5169
|
-
// TODO: When done [๐] Report progress also for each subvalue here
|
|
5170
5200
|
try {
|
|
5171
5201
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
5172
5202
|
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
@@ -5177,32 +5207,52 @@
|
|
|
5177
5207
|
if (!(error instanceof PipelineExecutionError)) {
|
|
5178
5208
|
throw error;
|
|
5179
5209
|
}
|
|
5180
|
-
|
|
5181
|
-
|
|
5210
|
+
const highLevelError = new PipelineExecutionError(spaceTrim__default["default"]((block) => `
|
|
5211
|
+
${error.message}
|
|
5182
5212
|
|
|
5183
|
-
|
|
5184
|
-
|
|
5213
|
+
This is error in FOREACH command when mapping data
|
|
5214
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
5185
5215
|
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5216
|
+
${block(pipelineIdentification)}
|
|
5217
|
+
Subparameter index: ${index}
|
|
5218
|
+
`));
|
|
5219
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
5220
|
+
console.error(highLevelError);
|
|
5221
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
5222
|
+
}
|
|
5223
|
+
throw highLevelError;
|
|
5189
5224
|
}
|
|
5190
5225
|
const allSubparameters = {
|
|
5191
5226
|
...parameters,
|
|
5192
5227
|
...mappedParameters,
|
|
5193
5228
|
};
|
|
5194
|
-
// Note: [๐จโ๐จโ๐ง] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
5195
5229
|
Object.freeze(allSubparameters);
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5230
|
+
try {
|
|
5231
|
+
const subresultString = await executeAttempts({
|
|
5232
|
+
...options,
|
|
5233
|
+
priority: priority + index,
|
|
5234
|
+
parameters: allSubparameters,
|
|
5235
|
+
pipelineIdentification: spaceTrim__default["default"]((block) => `
|
|
5236
|
+
${block(pipelineIdentification)}
|
|
5237
|
+
Subparameter index: ${index}
|
|
5238
|
+
`),
|
|
5239
|
+
});
|
|
5240
|
+
return subresultString;
|
|
5241
|
+
}
|
|
5242
|
+
catch (error) {
|
|
5243
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
5244
|
+
console.error(spaceTrim__default["default"]((block) => `
|
|
5245
|
+
Error in FOREACH command:
|
|
5246
|
+
|
|
5247
|
+
${block(pipelineIdentification)}
|
|
5248
|
+
|
|
5249
|
+
${block(pipelineIdentification)}
|
|
5250
|
+
Subparameter index: ${index}
|
|
5251
|
+
`));
|
|
5252
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
5253
|
+
}
|
|
5254
|
+
throw error;
|
|
5255
|
+
}
|
|
5206
5256
|
},
|
|
5207
5257
|
});
|
|
5208
5258
|
return resultString;
|
|
@@ -5337,7 +5387,11 @@
|
|
|
5337
5387
|
*/
|
|
5338
5388
|
|
|
5339
5389
|
/**
|
|
5340
|
-
*
|
|
5390
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
5391
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
5392
|
+
*
|
|
5393
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
5394
|
+
* @returns An object containing all reserved parameters for the task.
|
|
5341
5395
|
*
|
|
5342
5396
|
* @private internal utility of `createPipelineExecutor`
|
|
5343
5397
|
*/
|
|
@@ -5370,7 +5424,10 @@
|
|
|
5370
5424
|
}
|
|
5371
5425
|
|
|
5372
5426
|
/**
|
|
5373
|
-
*
|
|
5427
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
5428
|
+
*
|
|
5429
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
5430
|
+
* @returns The output parameters produced by the task.
|
|
5374
5431
|
*
|
|
5375
5432
|
* @private internal utility of `createPipelineExecutor`
|
|
5376
5433
|
*/
|
|
@@ -5504,9 +5561,12 @@
|
|
|
5504
5561
|
}
|
|
5505
5562
|
|
|
5506
5563
|
/**
|
|
5507
|
-
*
|
|
5564
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
5565
|
+
*
|
|
5566
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
5508
5567
|
*
|
|
5509
|
-
*
|
|
5568
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
5569
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
5510
5570
|
*
|
|
5511
5571
|
* @private internal utility of `createPipelineExecutor`
|
|
5512
5572
|
*/
|