@promptbook/remote-client 0.92.0-21 → 0.92.0-23

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.
Files changed (27) hide show
  1. package/esm/index.es.js +40 -24
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  5. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
  6. package/esm/typings/src/config.d.ts +29 -11
  7. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +12 -9
  8. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +11 -8
  9. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -3
  10. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +10 -8
  11. package/esm/typings/src/formats/_common/FormatParser.d.ts +5 -3
  12. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +40 -5
  13. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
  14. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
  15. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
  16. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +4 -1
  17. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
  18. package/esm/typings/src/types/typeAliases.d.ts +9 -7
  19. package/esm/typings/src/utils/$Register.d.ts +8 -7
  20. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
  21. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
  22. package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
  23. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
  24. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
  25. package/package.json +2 -2
  26. package/umd/index.umd.js +40 -24
  27. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-21';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-23';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -361,7 +361,7 @@ const CONNECTION_TIMEOUT_MS = 7 * 1000;
361
361
  const CONNECTION_RETRIES_LIMIT = 5;
362
362
  // <- TODO: [🧜‍♂️]
363
363
  /**
364
- * @@@
364
+ * Default settings for parsing and generating CSV files in Promptbook.
365
365
  *
366
366
  * @public exported from `@promptbook/core`
367
367
  */
@@ -1856,7 +1856,7 @@ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO:
1856
1856
  * Function to check if a string is valid CSV
1857
1857
  *
1858
1858
  * @param value The string to check
1859
- * @returns True if the string is a valid CSV string, false otherwise
1859
+ * @returns `true` if the string is a valid CSV string, false otherwise
1860
1860
  *
1861
1861
  * @public exported from `@promptbook/utils`
1862
1862
  */
@@ -1895,7 +1895,8 @@ const CsvFormatParser = {
1895
1895
  subvalueParsers: [
1896
1896
  {
1897
1897
  subvalueName: 'ROW',
1898
- async mapValues(value, outputParameterName, settings, mapCallback) {
1898
+ async mapValues(options) {
1899
+ const { value, outputParameterName, settings, mapCallback, onProgress } = options;
1899
1900
  const csv = csvParse(value, settings);
1900
1901
  if (csv.errors.length !== 0) {
1901
1902
  throw new CsvFormatError(spaceTrim$1((block) => `
@@ -1911,21 +1912,30 @@ const CsvFormatParser = {
1911
1912
  ${block(value)}
1912
1913
  `));
1913
1914
  }
1914
- const mappedData = await Promise.all(csv.data.map(async (row, index) => {
1915
+ const mappedData = [];
1916
+ const length = csv.data.length;
1917
+ for (let index = 0; index < length; index++) {
1918
+ const row = csv.data[index];
1915
1919
  if (row[outputParameterName]) {
1916
1920
  throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
1917
1921
  }
1918
- return {
1922
+ const mappedRow = {
1919
1923
  ...row,
1920
- [outputParameterName]: await mapCallback(row, index),
1924
+ [outputParameterName]: await mapCallback(row, index, length),
1921
1925
  };
1922
- }));
1926
+ mappedData.push(mappedRow);
1927
+ if (onProgress) {
1928
+ // Note: Report the CSV with all rows mapped so far
1929
+ await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
1930
+ }
1931
+ }
1923
1932
  return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
1924
1933
  },
1925
1934
  },
1926
1935
  {
1927
1936
  subvalueName: 'CELL',
1928
- async mapValues(value, outputParameterName, settings, mapCallback) {
1937
+ async mapValues(options) {
1938
+ const { value, settings, mapCallback, onProgress } = options;
1929
1939
  const csv = csvParse(value, settings);
1930
1940
  if (csv.errors.length !== 0) {
1931
1941
  throw new CsvFormatError(spaceTrim$1((block) => `
@@ -1942,9 +1952,9 @@ const CsvFormatParser = {
1942
1952
  `));
1943
1953
  }
1944
1954
  const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
1945
- return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
1955
+ return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
1946
1956
  const index = rowIndex * Object.keys(row).length + columnIndex;
1947
- return /* not await */ mapCallback({ [key]: value }, index);
1957
+ return /* not await */ mapCallback({ [key]: value }, index, array.length);
1948
1958
  }));
1949
1959
  }));
1950
1960
  return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
@@ -1964,7 +1974,7 @@ const CsvFormatParser = {
1964
1974
  * Function isValidJsonString will tell you if the string is valid JSON or not
1965
1975
  *
1966
1976
  * @param value The string to check
1967
- * @returns True if the string is a valid JSON string, false otherwise
1977
+ * @returns `true` if the string is a valid JSON string, false otherwise
1968
1978
  *
1969
1979
  * @public exported from `@promptbook/utils`
1970
1980
  */
@@ -2034,14 +2044,15 @@ const TextFormatParser = {
2034
2044
  subvalueParsers: [
2035
2045
  {
2036
2046
  subvalueName: 'LINE',
2037
- async mapValues(value, outputParameterName, settings, mapCallback) {
2047
+ async mapValues(options) {
2048
+ const { value, mapCallback, onProgress } = options;
2038
2049
  const lines = value.split('\n');
2039
- const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
2050
+ const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
2040
2051
  // TODO: [🧠] Maybe option to skip empty line
2041
2052
  /* not await */ mapCallback({
2042
2053
  lineContent,
2043
2054
  // TODO: [🧠] Maybe also put here `lineNumber`
2044
- }, lineNumber)));
2055
+ }, lineNumber, array.length)));
2045
2056
  return mappedLines.join('\n');
2046
2057
  },
2047
2058
  },
@@ -2062,7 +2073,7 @@ const TextFormatParser = {
2062
2073
  * Function to check if a string is valid XML
2063
2074
  *
2064
2075
  * @param value
2065
- * @returns True if the string is a valid XML string, false otherwise
2076
+ * @returns `true` if the string is a valid XML string, false otherwise
2066
2077
  *
2067
2078
  * @public exported from `@promptbook/utils`
2068
2079
  */
@@ -2359,8 +2370,12 @@ function checkSerializableAsJson(options) {
2359
2370
  */
2360
2371
 
2361
2372
  /**
2362
- * @@@
2373
+ * Creates a deep clone of the given object
2363
2374
  *
2375
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
2376
+ *
2377
+ * @param objectValue The object to clone.
2378
+ * @returns A deep, writable clone of the input object.
2364
2379
  * @public exported from `@promptbook/utils`
2365
2380
  */
2366
2381
  function deepClone(objectValue) {
@@ -2551,11 +2566,12 @@ function removeQuotes(text) {
2551
2566
  }
2552
2567
 
2553
2568
  /**
2554
- * Function `validateParameterName` will @@@
2569
+ * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
2570
+ * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
2555
2571
  *
2556
- * @param parameterName @@@
2557
- * @returns @@@
2558
- * @throws {ParseError} @@@
2572
+ * @param parameterName The parameter name to validate and normalize.
2573
+ * @returns The validated and normalized parameter name.
2574
+ * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
2559
2575
  * @private within the repository
2560
2576
  */
2561
2577
  function validateParameterName(parameterName) {
@@ -3729,10 +3745,10 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
3729
3745
  }
3730
3746
 
3731
3747
  /**
3732
- * @@@
3748
+ * Checks if the given value is a valid JavaScript identifier name.
3733
3749
  *
3734
- * @param javascriptName @@@
3735
- * @returns @@@
3750
+ * @param javascriptName The value to check for JavaScript identifier validity.
3751
+ * @returns `true` if the value is a valid JavaScript name, false otherwise.
3736
3752
  * @public exported from `@promptbook/utils`
3737
3753
  */
3738
3754
  function isValidJavascriptName(javascriptName) {