@promptbook/node 0.69.0-1 → 0.69.0-2
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 +86 -30
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +2 -6
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +26 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -4
- package/esm/typings/src/config.d.ts +7 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTemplate.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +5 -0
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +86 -30
- package/umd/index.umd.js.map +1 -1
|
@@ -7,6 +7,7 @@ import type { PipelineTemplateCommandParser } from '../commands/_common/types/Co
|
|
|
7
7
|
import type { CommandParserInput } from '../commands/_common/types/CommandParser';
|
|
8
8
|
import type { CommandUsagePlace } from '../commands/_common/types/CommandUsagePlaces';
|
|
9
9
|
import type { ExpectCommand } from '../commands/EXPECT/ExpectCommand';
|
|
10
|
+
import type { ForeachJson } from '../commands/FOREACH/ForeachJson';
|
|
10
11
|
import type { FormatCommand } from '../commands/FORMAT/FormatCommand';
|
|
11
12
|
import type { TemplateType } from '../commands/TEMPLATE/TemplateTypes';
|
|
12
13
|
import type { PipelineStringToJsonOptions } from '../conversion/pipelineStringToJson';
|
|
@@ -232,6 +233,7 @@ export type { PipelineTemplateCommandParser };
|
|
|
232
233
|
export type { CommandParserInput };
|
|
233
234
|
export type { CommandUsagePlace };
|
|
234
235
|
export type { ExpectCommand };
|
|
236
|
+
export type { ForeachJson };
|
|
235
237
|
export type { FormatCommand };
|
|
236
238
|
export type { TemplateType };
|
|
237
239
|
export type { PipelineStringToJsonOptions };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
1
|
+
import type { ForeachJson } from './ForeachJson';
|
|
3
2
|
/**
|
|
4
3
|
* Parsed FOREACH command <- Write [🍭] !!!!!!
|
|
5
4
|
*
|
|
@@ -8,7 +7,4 @@ import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
|
8
7
|
*/
|
|
9
8
|
export type ForeachCommand = {
|
|
10
9
|
readonly type: 'FOREACH';
|
|
11
|
-
|
|
12
|
-
cellName: TODO_string;
|
|
13
|
-
parameterName: string_parameter_name;
|
|
14
|
-
};
|
|
10
|
+
} & ForeachJson;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
|
+
import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
3
|
+
/**
|
|
4
|
+
* @@@
|
|
5
|
+
*/
|
|
6
|
+
export type ForeachJson = {
|
|
7
|
+
/**
|
|
8
|
+
* @@@
|
|
9
|
+
*/
|
|
10
|
+
readonly formatName: TODO_string;
|
|
11
|
+
/**
|
|
12
|
+
* @@@
|
|
13
|
+
*/
|
|
14
|
+
readonly cellName: TODO_string;
|
|
15
|
+
/**
|
|
16
|
+
* @@@
|
|
17
|
+
*/
|
|
18
|
+
readonly parameterName: string_parameter_name;
|
|
19
|
+
/**
|
|
20
|
+
* @@@
|
|
21
|
+
*/
|
|
22
|
+
readonly subparameterName: string_parameter_name;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* TODO: [🧠] Betetr name for `parameterName` and `subparameterName`
|
|
26
|
+
*/
|
|
@@ -156,28 +156,28 @@ export type CommandParserInput = {
|
|
|
156
156
|
* @@@
|
|
157
157
|
*
|
|
158
158
|
* @example 'promptbook version 0.62.0'
|
|
159
|
-
* @example 'FOREACH List Line -> `{customer}`'
|
|
159
|
+
* @example 'FOREACH List Line `{customers}` -> `{customer}`'
|
|
160
160
|
*/
|
|
161
161
|
readonly raw: string_markdown_text;
|
|
162
162
|
/**
|
|
163
163
|
* @@@
|
|
164
164
|
*
|
|
165
165
|
* @example '0.62.0'
|
|
166
|
-
* @example 'List Line -> `{customer}`'
|
|
166
|
+
* @example 'List Line `{customers}` -> `{customer}`'
|
|
167
167
|
*/
|
|
168
168
|
readonly rawArgs: string_markdown_text;
|
|
169
169
|
/**
|
|
170
170
|
* @@@
|
|
171
171
|
*
|
|
172
172
|
* @example 'PROMPTBOOK_VERSION_0_62_0'
|
|
173
|
-
* @example '
|
|
173
|
+
* @example 'FOREACH_LIST_LINE_CUSTOMERS_CUSTOMER'
|
|
174
174
|
*/
|
|
175
175
|
readonly normalized: string_name & string_SCREAMING_CASE;
|
|
176
176
|
/**
|
|
177
177
|
* @@@
|
|
178
178
|
*
|
|
179
179
|
* @example [ '0.62.0' ]
|
|
180
|
-
* @example [ 'List', 'Line', '', '{customer}' ]
|
|
180
|
+
* @example [ 'List', 'Line', '{customers}', '', '{customer}' ]
|
|
181
181
|
*/
|
|
182
182
|
readonly args: Array<string_name>;
|
|
183
183
|
};
|
|
@@ -148,7 +148,13 @@ export declare const IS_VERBOSE = false;
|
|
|
148
148
|
*
|
|
149
149
|
* @private within the repository
|
|
150
150
|
*/
|
|
151
|
-
export declare const
|
|
151
|
+
export declare const IS_COST_PREVENTED: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* @@@
|
|
154
|
+
*
|
|
155
|
+
* @private within the repository
|
|
156
|
+
*/
|
|
157
|
+
export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
|
|
152
158
|
/**
|
|
153
159
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
154
160
|
*/
|
|
@@ -22,6 +22,9 @@ export type renderPipelineMermaidOptions = {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function renderPromptbookMermaid(pipelineJson: PipelineJson, options?: renderPipelineMermaidOptions): string;
|
|
24
24
|
/**
|
|
25
|
+
* TODO: !!!!!! FOREACH in mermaid graph
|
|
26
|
+
* TODO: !!!!!! Knowledge in mermaid graph
|
|
27
|
+
* TODO: !!!!!! Personas in mermaid graph
|
|
25
28
|
* TODO: Maybe use some Mermaid package instead of string templating
|
|
26
29
|
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
27
30
|
*/
|
|
@@ -8,7 +8,7 @@ import type { string_parameter_name } from '../../types/typeAliases';
|
|
|
8
8
|
* @throws {ParseError} if the script is invalid
|
|
9
9
|
* @public exported from `@promptbook/utils`
|
|
10
10
|
*/
|
|
11
|
-
export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames'>): Set<string_parameter_name>;
|
|
11
|
+
export declare function extractParameterNamesFromTemplate(template: Pick<TemplateJson, 'title' | 'description' | 'templateType' | 'content' | 'preparedContent' | 'jokerParameterNames' | 'foreach'>): Set<string_parameter_name>;
|
|
12
12
|
/**
|
|
13
13
|
* TODO: [🔣] If script require contentLanguage
|
|
14
14
|
*/
|
|
@@ -15,6 +15,10 @@ import type { PipelineJson } from '../../types/PipelineJson/PipelineJson';
|
|
|
15
15
|
* @public exported from `@promptbook/core`
|
|
16
16
|
*/
|
|
17
17
|
export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
|
|
18
|
+
/**
|
|
19
|
+
* @private internal function for `validatePipeline`
|
|
20
|
+
*/
|
|
21
|
+
export declare function validatePipelineCore(pipeline: PipelineJson): void;
|
|
18
22
|
/**
|
|
19
23
|
* TODO: [🧠] Work with promptbookVersion
|
|
20
24
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
@@ -33,6 +33,7 @@ export type ParameterJson = {
|
|
|
33
33
|
readonly sampleValues?: Array<string_parameter_value>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
+
* TODO: [🧠] !!!!!! Should be here registered subparameter from foreach or not?
|
|
36
37
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
37
38
|
* TODO: [🍙] Make some standard order of json properties
|
|
38
39
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ForeachJson } from '../../commands/FOREACH/ForeachJson';
|
|
1
2
|
import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
|
|
2
3
|
import type { TemplateType } from '../../commands/TEMPLATE/TemplateTypes';
|
|
3
4
|
import type { string_javascript } from '../typeAliases';
|
|
@@ -42,6 +43,10 @@ export interface TemplateJsonCommon {
|
|
|
42
43
|
* @see https://github.com/webgptorg/promptbook/discussions/66
|
|
43
44
|
*/
|
|
44
45
|
readonly jokerParameterNames?: Array<string_parameter_name>;
|
|
46
|
+
/**
|
|
47
|
+
* @@@
|
|
48
|
+
*/
|
|
49
|
+
readonly foreach?: ForeachJson;
|
|
45
50
|
/**
|
|
46
51
|
* Type of the execution
|
|
47
52
|
* This determines if the template is send to LLM, user or some scripting evaluation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.69.0-
|
|
3
|
+
"version": "0.69.0-2",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
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/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.69.0-
|
|
50
|
+
"@promptbook/core": "0.69.0-2"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* The version of the Promptbook library
|
|
37
37
|
*/
|
|
38
|
-
var PROMPTBOOK_VERSION = '0.69.0-
|
|
38
|
+
var PROMPTBOOK_VERSION = '0.69.0-1';
|
|
39
39
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
40
40
|
|
|
41
41
|
/*! *****************************************************************************
|
|
@@ -447,6 +447,15 @@
|
|
|
447
447
|
* @public exported from `@promptbook/core`
|
|
448
448
|
*/
|
|
449
449
|
var IS_VERBOSE = false;
|
|
450
|
+
/**
|
|
451
|
+
* @@@
|
|
452
|
+
*
|
|
453
|
+
* @private within the repository
|
|
454
|
+
*/
|
|
455
|
+
var IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
456
|
+
/**/
|
|
457
|
+
// Note: In normal situations, we check the pipeline logic:
|
|
458
|
+
true);
|
|
450
459
|
/**
|
|
451
460
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
452
461
|
*/
|
|
@@ -895,7 +904,7 @@
|
|
|
895
904
|
});
|
|
896
905
|
}
|
|
897
906
|
|
|
898
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-
|
|
907
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-1",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-1",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-1",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-1",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
899
908
|
|
|
900
909
|
/**
|
|
901
910
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1102,6 +1111,26 @@
|
|
|
1102
1111
|
* @public exported from `@promptbook/core`
|
|
1103
1112
|
*/
|
|
1104
1113
|
function validatePipeline(pipeline) {
|
|
1114
|
+
if (IS_PIPELINE_LOGIC_VALIDATED) {
|
|
1115
|
+
validatePipelineCore(pipeline);
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
try {
|
|
1119
|
+
validatePipelineCore(pipeline);
|
|
1120
|
+
}
|
|
1121
|
+
catch (error) {
|
|
1122
|
+
if (!(error instanceof PipelineLogicError)) {
|
|
1123
|
+
throw error;
|
|
1124
|
+
}
|
|
1125
|
+
console.error(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is not valid but logic errors are temporarily disabled via `IS_PIPELINE_LOGIC_VALIDATED`\n\n ".concat(block(error.message), "\n "); }));
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return pipeline;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* @private internal function for `validatePipeline`
|
|
1132
|
+
*/
|
|
1133
|
+
function validatePipelineCore(pipeline) {
|
|
1105
1134
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
1106
1135
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1107
1136
|
var pipelineIdentification = (function () {
|
|
@@ -1300,7 +1329,6 @@
|
|
|
1300
1329
|
while (unresovedTemplates.length > 0) {
|
|
1301
1330
|
_loop_3();
|
|
1302
1331
|
}
|
|
1303
|
-
return pipeline;
|
|
1304
1332
|
}
|
|
1305
1333
|
/**
|
|
1306
1334
|
* TODO: [🧠] Work with promptbookVersion
|
|
@@ -2098,7 +2126,7 @@
|
|
|
2098
2126
|
*/
|
|
2099
2127
|
function extractParameterNamesFromTemplate(template) {
|
|
2100
2128
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
2101
|
-
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames;
|
|
2129
|
+
var title = template.title, description = template.description, templateType = template.templateType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
|
|
2102
2130
|
var parameterNames = new Set();
|
|
2103
2131
|
try {
|
|
2104
2132
|
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
@@ -2143,6 +2171,14 @@
|
|
|
2143
2171
|
}
|
|
2144
2172
|
parameterNames.delete('content');
|
|
2145
2173
|
// <- Note {websiteContent} is used in `preparedContent`
|
|
2174
|
+
// Note: [🍭] Fixing dependent subparameterName from FOREACH command
|
|
2175
|
+
if (foreach !== undefined) {
|
|
2176
|
+
if (parameterNames.has(foreach.subparameterName)) {
|
|
2177
|
+
parameterNames.delete(foreach.subparameterName);
|
|
2178
|
+
parameterNames.add(foreach.parameterName);
|
|
2179
|
+
// <- TODO: [🚎] Warn/logic error when `subparameterName` not used
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2146
2182
|
return parameterNames;
|
|
2147
2183
|
}
|
|
2148
2184
|
/**
|
|
@@ -3171,6 +3207,7 @@
|
|
|
3171
3207
|
case 0:
|
|
3172
3208
|
isJokerAttempt = attempt < 0;
|
|
3173
3209
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
3210
|
+
// TODO: [🧠] !!!!!! JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
3174
3211
|
if (isJokerAttempt && !jokerParameterName) {
|
|
3175
3212
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3176
3213
|
}
|
|
@@ -3489,6 +3526,19 @@
|
|
|
3489
3526
|
attempt++;
|
|
3490
3527
|
return [3 /*break*/, 4];
|
|
3491
3528
|
case 7:
|
|
3529
|
+
//------------------------------------
|
|
3530
|
+
/*
|
|
3531
|
+
|
|
3532
|
+
|
|
3533
|
+
|
|
3534
|
+
|
|
3535
|
+
|
|
3536
|
+
|
|
3537
|
+
|
|
3538
|
+
|
|
3539
|
+
|
|
3540
|
+
*/
|
|
3541
|
+
//------------------------------------
|
|
3492
3542
|
if (resultString === null) {
|
|
3493
3543
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3494
3544
|
}
|
|
@@ -5016,20 +5066,21 @@
|
|
|
5016
5066
|
* Example usages of the FOREACH command
|
|
5017
5067
|
*/
|
|
5018
5068
|
examples: [
|
|
5019
|
-
'FOREACH List Line -> `{customer}`',
|
|
5020
|
-
'FOR List Line -> `{customer}`',
|
|
5021
|
-
'EACH List Line -> `{customer}`',
|
|
5069
|
+
'FOREACH List Line `{customers}` -> `{customer}`',
|
|
5070
|
+
'FOR List Line `{customers}` -> `{customer}`',
|
|
5071
|
+
'EACH List Line `{customers}` -> `{customer}`',
|
|
5022
5072
|
// <- TODO: [🍭] !!!!!! More
|
|
5023
5073
|
],
|
|
5024
5074
|
/**
|
|
5025
5075
|
* Parses the FOREACH command
|
|
5026
5076
|
*/
|
|
5027
5077
|
parse: function (input) {
|
|
5028
|
-
var args = input.args
|
|
5078
|
+
var args = input.args;
|
|
5029
5079
|
var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
|
|
5030
5080
|
var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
|
|
5031
|
-
var
|
|
5032
|
-
var
|
|
5081
|
+
var parameterNameWrapped = args[2];
|
|
5082
|
+
var assignSign = args[3];
|
|
5083
|
+
var subparameterNameWrapped = args[4];
|
|
5033
5084
|
if (![
|
|
5034
5085
|
'LIST',
|
|
5035
5086
|
'CSV',
|
|
@@ -5044,7 +5095,7 @@
|
|
|
5044
5095
|
'ROW',
|
|
5045
5096
|
'COLUMN',
|
|
5046
5097
|
'CELL',
|
|
5047
|
-
// <- TODO: [🏢] Unhardcode format
|
|
5098
|
+
// <- TODO: [🏢] Unhardcode format cells
|
|
5048
5099
|
].includes(cellName)) {
|
|
5049
5100
|
console.info({ args: args, cellName: cellName });
|
|
5050
5101
|
throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
|
|
@@ -5054,24 +5105,27 @@
|
|
|
5054
5105
|
console.info({ args: args, assignSign: assignSign });
|
|
5055
5106
|
throw new Error("FOREACH command must have '->' to assign the value to the parameter");
|
|
5056
5107
|
}
|
|
5057
|
-
|
|
5058
|
-
if (
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
//
|
|
5065
|
-
) {
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5108
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5109
|
+
if ((parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(0, 1)) !== '{' ||
|
|
5110
|
+
(parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(parameterNameWrapped.length - 1, parameterNameWrapped.length)) !== '}') {
|
|
5111
|
+
console.info({ args: args, parameterNameWrapped: parameterNameWrapped }, parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(0, 1), parameterNameWrapped === null || parameterNameWrapped === void 0 ? void 0 : parameterNameWrapped.substring(parameterNameWrapped.length - 1, parameterNameWrapped.length));
|
|
5112
|
+
throw new Error("!!!!!! 1 Here will be error (with rules and precise error) from validateParameterName");
|
|
5113
|
+
}
|
|
5114
|
+
var parameterName = parameterNameWrapped.substring(1, parameterNameWrapped.length - 1);
|
|
5115
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5116
|
+
if ((subparameterNameWrapped === null || subparameterNameWrapped === void 0 ? void 0 : subparameterNameWrapped.substring(0, 1)) !== '{' ||
|
|
5117
|
+
(subparameterNameWrapped === null || subparameterNameWrapped === void 0 ? void 0 : subparameterNameWrapped.substring(subparameterNameWrapped.length - 1, subparameterNameWrapped.length)) !==
|
|
5118
|
+
'}') {
|
|
5119
|
+
console.info({ args: args, subparameterNameWrapped: subparameterNameWrapped });
|
|
5120
|
+
throw new Error("!!!!!! 2 Here will be error (with rules and precise error) from validateParameterName");
|
|
5121
|
+
}
|
|
5122
|
+
var subparameterName = subparameterNameWrapped.substring(1, subparameterNameWrapped.length - 1);
|
|
5070
5123
|
return {
|
|
5071
5124
|
type: 'FOREACH',
|
|
5072
5125
|
formatName: formatName,
|
|
5073
5126
|
cellName: cellName,
|
|
5074
5127
|
parameterName: parameterName,
|
|
5128
|
+
subparameterName: subparameterName,
|
|
5075
5129
|
};
|
|
5076
5130
|
},
|
|
5077
5131
|
/**
|
|
@@ -5080,8 +5134,10 @@
|
|
|
5080
5134
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
5081
5135
|
*/
|
|
5082
5136
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5083
|
-
|
|
5084
|
-
|
|
5137
|
+
var formatName = command.formatName, cellName = command.cellName, parameterName = command.parameterName, subparameterName = command.subparameterName;
|
|
5138
|
+
$templateJson.foreach = { formatName: formatName, cellName: cellName, parameterName: parameterName, subparameterName: subparameterName };
|
|
5139
|
+
keepUnused($pipelineJson); // <- TODO: !!!!!! BUT Maybe register subparameter from foreach into parameters of the pipeline
|
|
5140
|
+
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
5085
5141
|
},
|
|
5086
5142
|
/**
|
|
5087
5143
|
* Converts the FOREACH command back to string
|
|
@@ -5090,8 +5146,7 @@
|
|
|
5090
5146
|
*/
|
|
5091
5147
|
stringify: function (command) {
|
|
5092
5148
|
keepUnused(command);
|
|
5093
|
-
return "";
|
|
5094
|
-
// <- TODO: [🍭] !!!!!! Implement
|
|
5149
|
+
return "---"; // <- TODO: [🛋] Implement
|
|
5095
5150
|
},
|
|
5096
5151
|
/**
|
|
5097
5152
|
* Reads the FOREACH command from the `TemplateJson`
|
|
@@ -5100,8 +5155,7 @@
|
|
|
5100
5155
|
*/
|
|
5101
5156
|
takeFromTemplateJson: function ($templateJson) {
|
|
5102
5157
|
keepUnused($templateJson);
|
|
5103
|
-
|
|
5104
|
-
// <- TODO: [🍭] !!!!!! Implement
|
|
5158
|
+
throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
|
|
5105
5159
|
},
|
|
5106
5160
|
};
|
|
5107
5161
|
/**
|
|
@@ -5216,6 +5270,7 @@
|
|
|
5216
5270
|
*/
|
|
5217
5271
|
parse: function (input) {
|
|
5218
5272
|
var args = input.args;
|
|
5273
|
+
// TODO: !!!!!! Replace with propper parameter name validation
|
|
5219
5274
|
var parametersMatch = (args.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
5220
5275
|
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
5221
5276
|
throw new ParseError("Invalid joker");
|
|
@@ -5345,6 +5400,7 @@
|
|
|
5345
5400
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
5346
5401
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
5347
5402
|
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
5403
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
5348
5404
|
}
|
|
5349
5405
|
else {
|
|
5350
5406
|
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|