@promptbook/pdf 0.86.22 → 0.86.30

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.
@@ -2,7 +2,6 @@ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { VALUE_STRINGS } from '../config';
3
3
  import { SMALL_NUMBER } from '../config';
4
4
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
5
- import { extractVariablesFromScript } from '../conversion/utils/extractVariablesFromScript';
6
5
  import { deserializeError } from '../errors/utils/deserializeError';
7
6
  import { serializeError } from '../errors/utils/serializeError';
8
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
@@ -84,7 +83,6 @@ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
84
83
  export { VALUE_STRINGS };
85
84
  export { SMALL_NUMBER };
86
85
  export { renderPromptbookMermaid };
87
- export { extractVariablesFromScript };
88
86
  export { deserializeError };
89
87
  export { serializeError };
90
88
  export { forEachAsync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/pdf",
3
- "version": "0.86.22",
3
+ "version": "0.86.30",
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,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/pdf.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.86.22"
50
+ "@promptbook/core": "0.86.30"
51
51
  },
52
52
  "dependencies": {
53
53
  "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.86.22';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.86.30';
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
@@ -3647,142 +3647,6 @@
3647
3647
  }
3648
3648
  }
3649
3649
 
3650
- /**
3651
- * Extract all used variable names from ginen JavaScript/TypeScript script
3652
- *
3653
- * @param script JavaScript/TypeScript script
3654
- * @returns Set of variable names
3655
- * @throws {ParseError} if the script is invalid
3656
- * @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
3657
- */
3658
- function extractVariablesFromScript(script) {
3659
- if (script.trim() === '') {
3660
- return new Set();
3661
- }
3662
- const variables = new Set();
3663
- // JS keywords and builtins to exclude
3664
- const exclude = new Set([
3665
- // Keywords
3666
- 'break',
3667
- 'case',
3668
- 'catch',
3669
- 'class',
3670
- 'const',
3671
- 'continue',
3672
- 'debugger',
3673
- 'default',
3674
- 'delete',
3675
- 'do',
3676
- 'else',
3677
- 'export',
3678
- 'extends',
3679
- 'false',
3680
- 'finally',
3681
- 'for',
3682
- 'function',
3683
- 'if',
3684
- 'import',
3685
- 'in',
3686
- 'instanceof',
3687
- 'let',
3688
- 'new',
3689
- 'null',
3690
- 'return',
3691
- 'super',
3692
- 'switch',
3693
- 'this',
3694
- 'throw',
3695
- 'true',
3696
- 'try',
3697
- 'typeof',
3698
- 'var',
3699
- 'void',
3700
- 'while',
3701
- 'with',
3702
- 'yield',
3703
- // Common globals
3704
- 'console',
3705
- 'JSON',
3706
- 'Error',
3707
- // Typescript types
3708
- 'string',
3709
- 'number',
3710
- 'boolean',
3711
- 'object',
3712
- 'symbol',
3713
- // Common methods on built-in objects
3714
- 'test',
3715
- 'match',
3716
- 'exec',
3717
- 'replace',
3718
- 'search',
3719
- 'split',
3720
- ]);
3721
- try {
3722
- // Note: Extract variables from template literals like ${variable}
3723
- const templateRegex = /\$\{([a-zA-Z_$][a-zA-Z0-9_$]*)\}/g;
3724
- let match;
3725
- while ((match = templateRegex.exec(script)) !== null) {
3726
- const varName = match[1];
3727
- if (!exclude.has(varName)) {
3728
- variables.add(varName);
3729
- }
3730
- }
3731
- // Note: Process the script to handle normal variable usage
3732
- const processedScript = script
3733
- .replace(/'(?:\\.|[^'\\])*'/g, "''") // <- Note: Remove string literals
3734
- .replace(/"(?:\\.|[^"\\])*"/g, '""')
3735
- .replace(/`(?:\\.|[^`\\])*`/g, '``')
3736
- .replace(/\/(?:\\.|[^/\\])*\/[gimsuy]*/g, '{}'); // <- Note: Remove regex literals
3737
- // Note: Find identifiers in function arguments
3738
- const funcArgRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g;
3739
- const funcNames = new Set();
3740
- while ((match = funcArgRegex.exec(processedScript)) !== null) {
3741
- funcNames.add(match[1]);
3742
- }
3743
- // Find variable declarations to exclude them
3744
- const declaredVars = new Set();
3745
- const declRegex = /\b(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
3746
- while ((match = declRegex.exec(processedScript)) !== null) {
3747
- declaredVars.add(match[2]);
3748
- }
3749
- // Note: Find identifiers in the script
3750
- const identifierRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
3751
- while ((match = identifierRegex.exec(processedScript)) !== null) {
3752
- const name = match[1];
3753
- // Add if not excluded, not a function name, and not a declared variable
3754
- if (!exclude.has(name) && !funcNames.has(name) && !declaredVars.has(name)) {
3755
- variables.add(name);
3756
- }
3757
- }
3758
- }
3759
- catch (error) {
3760
- if (!(error instanceof Error)) {
3761
- throw error;
3762
- }
3763
- throw new ParseError(spaceTrim__default["default"]((block) => `
3764
- Can not extract variables from the script
3765
- ${block(error.stack || error.message)}
3766
-
3767
- Found variables:
3768
- ${Array.from(variables)
3769
- .map((variableName, i) => `${i + 1}) ${variableName}`)
3770
- .join('\n')}
3771
-
3772
-
3773
- The script:
3774
-
3775
- \`\`\`javascript
3776
- ${block(script)}
3777
- \`\`\`
3778
- `));
3779
- }
3780
- return variables;
3781
- }
3782
- /**
3783
- * TODO: [🔣] Support for multiple languages - python, java,...
3784
- */
3785
-
3786
3650
  /**
3787
3651
  * Parses the task and returns the set of all used parameters
3788
3652
  *
@@ -3792,7 +3656,7 @@
3792
3656
  * @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
3793
3657
  */
3794
3658
  function extractParameterNamesFromTask(task) {
3795
- const { title, description, taskType, content, preparedContent, jokerParameterNames, foreach } = task;
3659
+ const { title, description, /* [🙊] taskType,*/ content, preparedContent, jokerParameterNames, foreach } = task;
3796
3660
  const parameterNames = new Set();
3797
3661
  for (const parameterName of [
3798
3662
  ...extractParameterNames(title),
@@ -3802,11 +3666,14 @@
3802
3666
  ]) {
3803
3667
  parameterNames.add(parameterName);
3804
3668
  }
3669
+ /*/
3670
+ // TODO: [🙊] Fix `extractVariablesFromScript` or delete
3805
3671
  if (taskType === 'SCRIPT_TASK') {
3806
3672
  for (const parameterName of extractVariablesFromScript(content)) {
3807
3673
  parameterNames.add(parameterName);
3808
3674
  }
3809
3675
  }
3676
+ /**/
3810
3677
  for (const jokerName of jokerParameterNames || []) {
3811
3678
  parameterNames.add(jokerName);
3812
3679
  }