@promptbook/cli 0.68.0 β†’ 0.70.0-0

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.
@@ -1,9 +1,14 @@
1
+ import type { string_parameter_name } from '../../types/typeAliases';
2
+ import type { TODO_string } from '../../utils/organization/TODO_string';
1
3
  /**
2
- * Parsed FOREACH command <- Write [🍭]
4
+ * Parsed FOREACH command <- Write [🍭] !!!!!!
3
5
  *
4
6
  * @see ./foreachCommandParser.ts for more details
5
7
  * @private within the commands folder
6
8
  */
7
9
  export type ForeachCommand = {
8
10
  readonly type: 'FOREACH';
11
+ formatName: TODO_string;
12
+ cellName: TODO_string;
13
+ parameterName: string_parameter_name;
9
14
  };
@@ -10,5 +10,6 @@ import type { ForeachCommand } from './ForeachCommand';
10
10
  */
11
11
  export declare const foreachCommandParser: PipelineTemplateCommandParser<ForeachCommand>;
12
12
  /**
13
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
13
+ * TODO: !!!!!! Comment console logs
14
+ * TODO: [🍭] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
14
15
  */
@@ -147,24 +147,39 @@ export type $PipelineJson = WritableDeep<PipelineJson>;
147
147
  export type CommandParserInput = {
148
148
  /**
149
149
  * @@@
150
+ *
151
+ * @example 'PIPELINE_HEAD'
152
+ * @example 'PIPELINE_TEMPLATE'
150
153
  */
151
154
  readonly usagePlace: CommandUsagePlace;
152
155
  /**
153
156
  * @@@
157
+ *
158
+ * @example 'promptbook version 0.62.0'
159
+ * @example 'FOREACH List Line -> `{customer}`'
154
160
  */
155
161
  readonly raw: string_markdown_text;
156
162
  /**
157
163
  * @@@
164
+ *
165
+ * @example '0.62.0'
166
+ * @example 'List Line -> `{customer}`'
158
167
  */
159
168
  readonly rawArgs: string_markdown_text;
160
169
  /**
161
170
  * @@@
171
+ *
172
+ * @example 'PROMPTBOOK_VERSION_0_62_0'
173
+ * @example 'FOREACH_LIST_LINE_CUSTOMER'
162
174
  */
163
175
  readonly normalized: string_name & string_SCREAMING_CASE;
164
176
  /**
165
177
  * @@@
178
+ *
179
+ * @example [ '0.62.0' ]
180
+ * @example [ 'List', 'Line', '', '{customer}' ]
166
181
  */
167
- readonly args: Array<string_name & string_SCREAMING_CASE>;
182
+ readonly args: Array<string_name>;
168
183
  };
169
184
  /**
170
185
  * TODO: [♓️] Add order here
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.68.0",
3
+ "version": "0.70.0-0",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -39,7 +39,7 @@
39
39
  /**
40
40
  * The version of the Promptbook library
41
41
  */
42
- var PROMPTBOOK_VERSION = '0.68.0-5';
42
+ var PROMPTBOOK_VERSION = '0.69.0-0';
43
43
  // TODO: !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -1059,7 +1059,7 @@
1059
1059
  });
1060
1060
  }
1061
1061
 
1062
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0-5",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.68.0-5",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.68.0-5",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.68.0-5",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"}];
1062
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-0",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-0",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-0",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-0",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"}];
1063
1063
 
1064
1064
  /**
1065
1065
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -5060,6 +5060,76 @@
5060
5060
  },
5061
5061
  };
5062
5062
 
5063
+ /**
5064
+ * @@@
5065
+ *
5066
+ * @param text @@@
5067
+ * @returns @@@
5068
+ * @example 'HELLO_WORLD'
5069
+ * @example 'I_LOVE_PROMPTBOOK'
5070
+ * @public exported from `@promptbook/utils`
5071
+ */
5072
+ function normalizeTo_SCREAMING_CASE(text) {
5073
+ var e_1, _a;
5074
+ var charType;
5075
+ var lastCharType = 'OTHER';
5076
+ var normalizedName = '';
5077
+ try {
5078
+ for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
5079
+ var char = text_1_1.value;
5080
+ var normalizedChar = void 0;
5081
+ if (/^[a-z]$/.test(char)) {
5082
+ charType = 'LOWERCASE';
5083
+ normalizedChar = char.toUpperCase();
5084
+ }
5085
+ else if (/^[A-Z]$/.test(char)) {
5086
+ charType = 'UPPERCASE';
5087
+ normalizedChar = char;
5088
+ }
5089
+ else if (/^[0-9]$/.test(char)) {
5090
+ charType = 'NUMBER';
5091
+ normalizedChar = char;
5092
+ }
5093
+ else if (/^\/$/.test(char)) {
5094
+ charType = 'SLASH';
5095
+ normalizedChar = char;
5096
+ }
5097
+ else {
5098
+ charType = 'OTHER';
5099
+ normalizedChar = '_';
5100
+ }
5101
+ if (charType !== lastCharType &&
5102
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
5103
+ !(lastCharType === 'NUMBER') &&
5104
+ !(charType === 'NUMBER')) {
5105
+ normalizedName += '_';
5106
+ }
5107
+ normalizedName += normalizedChar;
5108
+ lastCharType = charType;
5109
+ }
5110
+ }
5111
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
5112
+ finally {
5113
+ try {
5114
+ if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
5115
+ }
5116
+ finally { if (e_1) throw e_1.error; }
5117
+ }
5118
+ normalizedName = normalizedName.replace(/_+/g, '_');
5119
+ normalizedName = normalizedName.replace(/_?\/_?/g, '/');
5120
+ normalizedName = normalizedName.replace(/^_/, '');
5121
+ normalizedName = normalizedName.replace(/_$/, '');
5122
+ return normalizedName;
5123
+ }
5124
+ /**
5125
+ * TODO: Tests
5126
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
5127
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
5128
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
5129
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
5130
+ * TODO: [🌺] Use some intermediate util splitWords
5131
+ */
5132
+
5063
5133
  /**
5064
5134
  * Parses the foreach command
5065
5135
  *
@@ -5097,17 +5167,59 @@
5097
5167
  'FOREACH List Line -> `{customer}`',
5098
5168
  'FOR List Line -> `{customer}`',
5099
5169
  'EACH List Line -> `{customer}`',
5100
- // <- TODO: [🍭] More
5170
+ // <- TODO: [🍭] !!!!!! More
5101
5171
  ],
5102
5172
  /**
5103
5173
  * Parses the FOREACH command
5104
5174
  */
5105
5175
  parse: function (input) {
5106
- var args = input.args;
5107
- keepUnused(args);
5108
- // <- TODO: [🍭] Implement
5176
+ var args = input.args, rawArgs = input.rawArgs;
5177
+ var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
5178
+ var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
5179
+ var assignSign = args[2];
5180
+ var parameter = args[3];
5181
+ if (![
5182
+ 'LIST',
5183
+ 'CSV',
5184
+ // <- TODO: [🏒] Unhardcode formats
5185
+ ].includes(formatName)) {
5186
+ console.info({ args: args, formatName: formatName });
5187
+ throw new Error("Unsupported format \"".concat(formatName, "\""));
5188
+ // <- TODO: [🏒] List all supported format names
5189
+ }
5190
+ if (![
5191
+ 'LINE',
5192
+ 'ROW',
5193
+ 'COLUMN',
5194
+ 'CELL',
5195
+ // <- TODO: [🏒] Unhardcode format cekks
5196
+ ].includes(cellName)) {
5197
+ console.info({ args: args, cellName: cellName });
5198
+ throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
5199
+ // <- TODO: [🏒] List all supported cell names for the format
5200
+ }
5201
+ if (assignSign !== '->') {
5202
+ console.info({ args: args, assignSign: assignSign });
5203
+ throw new Error("FOREACH command must have '->' to assign the value to the parameter");
5204
+ }
5205
+ var parameterNames = extractParameterNames(parameter || rawArgs);
5206
+ if (parameterNames.size !== 1) {
5207
+ console.info({ args: args, parameter: parameter, rawArgs: rawArgs });
5208
+ throw new Error("FOREACH command contain exactly one parameter, but found ".concat(parameterNames.size));
5209
+ }
5210
+ var parameterName = parameterNames.values().next().value;
5211
+ if (typeof parameterName !== 'string'
5212
+ // <- TODO: !!!!!! Replace with propper parameter name validation
5213
+ ) {
5214
+ console.info({ args: args, parameterName: parameterName });
5215
+ throw new Error("Invalid parameter name");
5216
+ // <- TODO: !!!!!! Better error (with rules and precise error) from validateParameterName
5217
+ }
5109
5218
  return {
5110
5219
  type: 'FOREACH',
5220
+ formatName: formatName,
5221
+ cellName: cellName,
5222
+ parameterName: parameterName,
5111
5223
  };
5112
5224
  },
5113
5225
  /**
@@ -5117,7 +5229,7 @@
5117
5229
  */
5118
5230
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5119
5231
  keepUnused(command, $templateJson, $pipelineJson);
5120
- // <- TODO: [🍭] Implement
5232
+ // <- TODO: [🍭] !!!!!! Implement
5121
5233
  },
5122
5234
  /**
5123
5235
  * Converts the FOREACH command back to string
@@ -5127,7 +5239,7 @@
5127
5239
  stringify: function (command) {
5128
5240
  keepUnused(command);
5129
5241
  return "";
5130
- // <- TODO: [🍭] Implement
5242
+ // <- TODO: [🍭] !!!!!! Implement
5131
5243
  },
5132
5244
  /**
5133
5245
  * Reads the FOREACH command from the `TemplateJson`
@@ -5137,11 +5249,12 @@
5137
5249
  takeFromTemplateJson: function ($templateJson) {
5138
5250
  keepUnused($templateJson);
5139
5251
  return [];
5140
- // <- TODO: [🍭] Implement
5252
+ // <- TODO: [🍭] !!!!!! Implement
5141
5253
  },
5142
5254
  };
5143
5255
  /**
5144
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5256
+ * TODO: !!!!!! Comment console logs
5257
+ * TODO: [🍭] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5145
5258
  */
5146
5259
 
5147
5260
  /**
@@ -5494,6 +5607,7 @@
5494
5607
  isInput = false;
5495
5608
  isOutput = false;
5496
5609
  }
5610
+ // TODO: !!!!!! Add parameter name validation
5497
5611
  return {
5498
5612
  type: 'PARAMETER',
5499
5613
  parameterName: parameterName,
@@ -6246,76 +6360,6 @@
6246
6360
  return str;
6247
6361
  }
6248
6362
 
6249
- /**
6250
- * @@@
6251
- *
6252
- * @param text @@@
6253
- * @returns @@@
6254
- * @example 'HELLO_WORLD'
6255
- * @example 'I_LOVE_PROMPTBOOK'
6256
- * @public exported from `@promptbook/utils`
6257
- */
6258
- function normalizeTo_SCREAMING_CASE(text) {
6259
- var e_1, _a;
6260
- var charType;
6261
- var lastCharType = 'OTHER';
6262
- var normalizedName = '';
6263
- try {
6264
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
6265
- var char = text_1_1.value;
6266
- var normalizedChar = void 0;
6267
- if (/^[a-z]$/.test(char)) {
6268
- charType = 'LOWERCASE';
6269
- normalizedChar = char.toUpperCase();
6270
- }
6271
- else if (/^[A-Z]$/.test(char)) {
6272
- charType = 'UPPERCASE';
6273
- normalizedChar = char;
6274
- }
6275
- else if (/^[0-9]$/.test(char)) {
6276
- charType = 'NUMBER';
6277
- normalizedChar = char;
6278
- }
6279
- else if (/^\/$/.test(char)) {
6280
- charType = 'SLASH';
6281
- normalizedChar = char;
6282
- }
6283
- else {
6284
- charType = 'OTHER';
6285
- normalizedChar = '_';
6286
- }
6287
- if (charType !== lastCharType &&
6288
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
6289
- !(lastCharType === 'NUMBER') &&
6290
- !(charType === 'NUMBER')) {
6291
- normalizedName += '_';
6292
- }
6293
- normalizedName += normalizedChar;
6294
- lastCharType = charType;
6295
- }
6296
- }
6297
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6298
- finally {
6299
- try {
6300
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
6301
- }
6302
- finally { if (e_1) throw e_1.error; }
6303
- }
6304
- normalizedName = normalizedName.replace(/_+/g, '_');
6305
- normalizedName = normalizedName.replace(/_?\/_?/g, '/');
6306
- normalizedName = normalizedName.replace(/^_/, '');
6307
- normalizedName = normalizedName.replace(/_$/, '');
6308
- return normalizedName;
6309
- }
6310
- /**
6311
- * TODO: Tests
6312
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
6313
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
6314
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
6315
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
6316
- * TODO: [🌺] Use some intermediate util splitWords
6317
- */
6318
-
6319
6363
  /**
6320
6364
  * Parses one line of ul/ol to command
6321
6365
  *
@@ -6328,6 +6372,7 @@
6328
6372
  if (raw.includes('\n') || raw.includes('\r')) {
6329
6373
  throw new ParseError('Command can not contain new line characters' /* <- TODO: [🚞] */);
6330
6374
  }
6375
+ // TODO: Unit test all this processing and parsing
6331
6376
  var normalized = raw.trim();
6332
6377
  normalized = normalized.split('`').join('');
6333
6378
  normalized = normalized.split('"').join('');
@@ -6383,7 +6428,7 @@
6383
6428
  // Arg1 Arg2 Arg3 | FOO
6384
6429
  {
6385
6430
  var commandNameRaw = items.slice(-1).join('_');
6386
- var args = items.slice(0, -1);
6431
+ var args = items.slice(0, -1); // <- Note: This is probbably not correct
6387
6432
  var rawArgs = raw.substring(0, raw.length - commandNameRaw.length).trim();
6388
6433
  var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
6389
6434
  if (command !== null) {