@promptbook/core 0.68.0 β†’ 0.69.0-1

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/core",
3
- "version": "0.68.0",
3
+ "version": "0.69.0-1",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -16,7 +16,7 @@
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.68.0-5';
19
+ var PROMPTBOOK_VERSION = '0.69.0-0';
20
20
  // TODO: !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
@@ -1794,7 +1794,7 @@
1794
1794
  });
1795
1795
  }
1796
1796
 
1797
- 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"}];
1797
+ 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"}];
1798
1798
 
1799
1799
  var defaultDiacriticsRemovalMap = [
1800
1800
  {
@@ -5199,6 +5199,76 @@
5199
5199
  },
5200
5200
  };
5201
5201
 
5202
+ /**
5203
+ * @@@
5204
+ *
5205
+ * @param text @@@
5206
+ * @returns @@@
5207
+ * @example 'HELLO_WORLD'
5208
+ * @example 'I_LOVE_PROMPTBOOK'
5209
+ * @public exported from `@promptbook/utils`
5210
+ */
5211
+ function normalizeTo_SCREAMING_CASE(text) {
5212
+ var e_1, _a;
5213
+ var charType;
5214
+ var lastCharType = 'OTHER';
5215
+ var normalizedName = '';
5216
+ try {
5217
+ for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
5218
+ var char = text_1_1.value;
5219
+ var normalizedChar = void 0;
5220
+ if (/^[a-z]$/.test(char)) {
5221
+ charType = 'LOWERCASE';
5222
+ normalizedChar = char.toUpperCase();
5223
+ }
5224
+ else if (/^[A-Z]$/.test(char)) {
5225
+ charType = 'UPPERCASE';
5226
+ normalizedChar = char;
5227
+ }
5228
+ else if (/^[0-9]$/.test(char)) {
5229
+ charType = 'NUMBER';
5230
+ normalizedChar = char;
5231
+ }
5232
+ else if (/^\/$/.test(char)) {
5233
+ charType = 'SLASH';
5234
+ normalizedChar = char;
5235
+ }
5236
+ else {
5237
+ charType = 'OTHER';
5238
+ normalizedChar = '_';
5239
+ }
5240
+ if (charType !== lastCharType &&
5241
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
5242
+ !(lastCharType === 'NUMBER') &&
5243
+ !(charType === 'NUMBER')) {
5244
+ normalizedName += '_';
5245
+ }
5246
+ normalizedName += normalizedChar;
5247
+ lastCharType = charType;
5248
+ }
5249
+ }
5250
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
5251
+ finally {
5252
+ try {
5253
+ if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
5254
+ }
5255
+ finally { if (e_1) throw e_1.error; }
5256
+ }
5257
+ normalizedName = normalizedName.replace(/_+/g, '_');
5258
+ normalizedName = normalizedName.replace(/_?\/_?/g, '/');
5259
+ normalizedName = normalizedName.replace(/^_/, '');
5260
+ normalizedName = normalizedName.replace(/_$/, '');
5261
+ return normalizedName;
5262
+ }
5263
+ /**
5264
+ * TODO: Tests
5265
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
5266
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
5267
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
5268
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
5269
+ * TODO: [🌺] Use some intermediate util splitWords
5270
+ */
5271
+
5202
5272
  /**
5203
5273
  * Parses the foreach command
5204
5274
  *
@@ -5236,17 +5306,59 @@
5236
5306
  'FOREACH List Line -> `{customer}`',
5237
5307
  'FOR List Line -> `{customer}`',
5238
5308
  'EACH List Line -> `{customer}`',
5239
- // <- TODO: [🍭] More
5309
+ // <- TODO: [🍭] !!!!!! More
5240
5310
  ],
5241
5311
  /**
5242
5312
  * Parses the FOREACH command
5243
5313
  */
5244
5314
  parse: function (input) {
5245
- var args = input.args;
5246
- keepUnused(args);
5247
- // <- TODO: [🍭] Implement
5315
+ var args = input.args, rawArgs = input.rawArgs;
5316
+ var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
5317
+ var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
5318
+ var assignSign = args[2];
5319
+ var parameter = args[3];
5320
+ if (![
5321
+ 'LIST',
5322
+ 'CSV',
5323
+ // <- TODO: [🏒] Unhardcode formats
5324
+ ].includes(formatName)) {
5325
+ console.info({ args: args, formatName: formatName });
5326
+ throw new Error("Unsupported format \"".concat(formatName, "\""));
5327
+ // <- TODO: [🏒] List all supported format names
5328
+ }
5329
+ if (![
5330
+ 'LINE',
5331
+ 'ROW',
5332
+ 'COLUMN',
5333
+ 'CELL',
5334
+ // <- TODO: [🏒] Unhardcode format cekks
5335
+ ].includes(cellName)) {
5336
+ console.info({ args: args, cellName: cellName });
5337
+ throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
5338
+ // <- TODO: [🏒] List all supported cell names for the format
5339
+ }
5340
+ if (assignSign !== '->') {
5341
+ console.info({ args: args, assignSign: assignSign });
5342
+ throw new Error("FOREACH command must have '->' to assign the value to the parameter");
5343
+ }
5344
+ var parameterNames = extractParameterNames(parameter || rawArgs);
5345
+ if (parameterNames.size !== 1) {
5346
+ console.info({ args: args, parameter: parameter, rawArgs: rawArgs });
5347
+ throw new Error("FOREACH command contain exactly one parameter, but found ".concat(parameterNames.size));
5348
+ }
5349
+ var parameterName = parameterNames.values().next().value;
5350
+ if (typeof parameterName !== 'string'
5351
+ // <- TODO: !!!!!! Replace with propper parameter name validation
5352
+ ) {
5353
+ console.info({ args: args, parameterName: parameterName });
5354
+ throw new Error("Invalid parameter name");
5355
+ // <- TODO: !!!!!! Better error (with rules and precise error) from validateParameterName
5356
+ }
5248
5357
  return {
5249
5358
  type: 'FOREACH',
5359
+ formatName: formatName,
5360
+ cellName: cellName,
5361
+ parameterName: parameterName,
5250
5362
  };
5251
5363
  },
5252
5364
  /**
@@ -5256,7 +5368,7 @@
5256
5368
  */
5257
5369
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5258
5370
  keepUnused(command, $templateJson, $pipelineJson);
5259
- // <- TODO: [🍭] Implement
5371
+ // <- TODO: [🍭] !!!!!! Implement
5260
5372
  },
5261
5373
  /**
5262
5374
  * Converts the FOREACH command back to string
@@ -5266,7 +5378,7 @@
5266
5378
  stringify: function (command) {
5267
5379
  keepUnused(command);
5268
5380
  return "";
5269
- // <- TODO: [🍭] Implement
5381
+ // <- TODO: [🍭] !!!!!! Implement
5270
5382
  },
5271
5383
  /**
5272
5384
  * Reads the FOREACH command from the `TemplateJson`
@@ -5276,11 +5388,12 @@
5276
5388
  takeFromTemplateJson: function ($templateJson) {
5277
5389
  keepUnused($templateJson);
5278
5390
  return [];
5279
- // <- TODO: [🍭] Implement
5391
+ // <- TODO: [🍭] !!!!!! Implement
5280
5392
  },
5281
5393
  };
5282
5394
  /**
5283
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5395
+ * TODO: !!!!!! Comment console logs
5396
+ * TODO: [🍭] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5284
5397
  */
5285
5398
 
5286
5399
  /**
@@ -5633,6 +5746,7 @@
5633
5746
  isInput = false;
5634
5747
  isOutput = false;
5635
5748
  }
5749
+ // TODO: !!!!!! Add parameter name validation
5636
5750
  return {
5637
5751
  type: 'PARAMETER',
5638
5752
  parameterName: parameterName,
@@ -6385,76 +6499,6 @@
6385
6499
  return str;
6386
6500
  }
6387
6501
 
6388
- /**
6389
- * @@@
6390
- *
6391
- * @param text @@@
6392
- * @returns @@@
6393
- * @example 'HELLO_WORLD'
6394
- * @example 'I_LOVE_PROMPTBOOK'
6395
- * @public exported from `@promptbook/utils`
6396
- */
6397
- function normalizeTo_SCREAMING_CASE(text) {
6398
- var e_1, _a;
6399
- var charType;
6400
- var lastCharType = 'OTHER';
6401
- var normalizedName = '';
6402
- try {
6403
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
6404
- var char = text_1_1.value;
6405
- var normalizedChar = void 0;
6406
- if (/^[a-z]$/.test(char)) {
6407
- charType = 'LOWERCASE';
6408
- normalizedChar = char.toUpperCase();
6409
- }
6410
- else if (/^[A-Z]$/.test(char)) {
6411
- charType = 'UPPERCASE';
6412
- normalizedChar = char;
6413
- }
6414
- else if (/^[0-9]$/.test(char)) {
6415
- charType = 'NUMBER';
6416
- normalizedChar = char;
6417
- }
6418
- else if (/^\/$/.test(char)) {
6419
- charType = 'SLASH';
6420
- normalizedChar = char;
6421
- }
6422
- else {
6423
- charType = 'OTHER';
6424
- normalizedChar = '_';
6425
- }
6426
- if (charType !== lastCharType &&
6427
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
6428
- !(lastCharType === 'NUMBER') &&
6429
- !(charType === 'NUMBER')) {
6430
- normalizedName += '_';
6431
- }
6432
- normalizedName += normalizedChar;
6433
- lastCharType = charType;
6434
- }
6435
- }
6436
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6437
- finally {
6438
- try {
6439
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
6440
- }
6441
- finally { if (e_1) throw e_1.error; }
6442
- }
6443
- normalizedName = normalizedName.replace(/_+/g, '_');
6444
- normalizedName = normalizedName.replace(/_?\/_?/g, '/');
6445
- normalizedName = normalizedName.replace(/^_/, '');
6446
- normalizedName = normalizedName.replace(/_$/, '');
6447
- return normalizedName;
6448
- }
6449
- /**
6450
- * TODO: Tests
6451
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
6452
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
6453
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
6454
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
6455
- * TODO: [🌺] Use some intermediate util splitWords
6456
- */
6457
-
6458
6502
  /**
6459
6503
  * Parses one line of ul/ol to command
6460
6504
  *
@@ -6467,6 +6511,7 @@
6467
6511
  if (raw.includes('\n') || raw.includes('\r')) {
6468
6512
  throw new ParseError('Command can not contain new line characters' /* <- TODO: [🚞] */);
6469
6513
  }
6514
+ // TODO: Unit test all this processing and parsing
6470
6515
  var normalized = raw.trim();
6471
6516
  normalized = normalized.split('`').join('');
6472
6517
  normalized = normalized.split('"').join('');
@@ -6522,7 +6567,7 @@
6522
6567
  // Arg1 Arg2 Arg3 | FOO
6523
6568
  {
6524
6569
  var commandNameRaw = items.slice(-1).join('_');
6525
- var args = items.slice(0, -1);
6570
+ var args = items.slice(0, -1); // <- Note: This is probbably not correct
6526
6571
  var rawArgs = raw.substring(0, raw.length - commandNameRaw.length).trim();
6527
6572
  var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
6528
6573
  if (command !== null) {