@promptbook/node 0.68.0 β 0.69.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.
- package/esm/index.es.js +126 -81
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +6 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +16 -1
- package/package.json +2 -2
- package/umd/index.umd.js +126 -81
- package/umd/index.umd.js.map +1 -1
|
@@ -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:
|
|
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
|
|
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/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0-0",
|
|
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.
|
|
50
|
+
"@promptbook/core": "0.69.0-0"
|
|
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.68.0
|
|
38
|
+
var PROMPTBOOK_VERSION = '0.68.0';
|
|
39
39
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
40
40
|
|
|
41
41
|
/*! *****************************************************************************
|
|
@@ -895,7 +895,7 @@
|
|
|
895
895
|
});
|
|
896
896
|
}
|
|
897
897
|
|
|
898
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.0
|
|
898
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.68.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.68.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.68.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.68.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"}];
|
|
899
899
|
|
|
900
900
|
/**
|
|
901
901
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -4912,6 +4912,76 @@
|
|
|
4912
4912
|
},
|
|
4913
4913
|
};
|
|
4914
4914
|
|
|
4915
|
+
/**
|
|
4916
|
+
* @@@
|
|
4917
|
+
*
|
|
4918
|
+
* @param text @@@
|
|
4919
|
+
* @returns @@@
|
|
4920
|
+
* @example 'HELLO_WORLD'
|
|
4921
|
+
* @example 'I_LOVE_PROMPTBOOK'
|
|
4922
|
+
* @public exported from `@promptbook/utils`
|
|
4923
|
+
*/
|
|
4924
|
+
function normalizeTo_SCREAMING_CASE(text) {
|
|
4925
|
+
var e_1, _a;
|
|
4926
|
+
var charType;
|
|
4927
|
+
var lastCharType = 'OTHER';
|
|
4928
|
+
var normalizedName = '';
|
|
4929
|
+
try {
|
|
4930
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
4931
|
+
var char = text_1_1.value;
|
|
4932
|
+
var normalizedChar = void 0;
|
|
4933
|
+
if (/^[a-z]$/.test(char)) {
|
|
4934
|
+
charType = 'LOWERCASE';
|
|
4935
|
+
normalizedChar = char.toUpperCase();
|
|
4936
|
+
}
|
|
4937
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
4938
|
+
charType = 'UPPERCASE';
|
|
4939
|
+
normalizedChar = char;
|
|
4940
|
+
}
|
|
4941
|
+
else if (/^[0-9]$/.test(char)) {
|
|
4942
|
+
charType = 'NUMBER';
|
|
4943
|
+
normalizedChar = char;
|
|
4944
|
+
}
|
|
4945
|
+
else if (/^\/$/.test(char)) {
|
|
4946
|
+
charType = 'SLASH';
|
|
4947
|
+
normalizedChar = char;
|
|
4948
|
+
}
|
|
4949
|
+
else {
|
|
4950
|
+
charType = 'OTHER';
|
|
4951
|
+
normalizedChar = '_';
|
|
4952
|
+
}
|
|
4953
|
+
if (charType !== lastCharType &&
|
|
4954
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
4955
|
+
!(lastCharType === 'NUMBER') &&
|
|
4956
|
+
!(charType === 'NUMBER')) {
|
|
4957
|
+
normalizedName += '_';
|
|
4958
|
+
}
|
|
4959
|
+
normalizedName += normalizedChar;
|
|
4960
|
+
lastCharType = charType;
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4964
|
+
finally {
|
|
4965
|
+
try {
|
|
4966
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
4967
|
+
}
|
|
4968
|
+
finally { if (e_1) throw e_1.error; }
|
|
4969
|
+
}
|
|
4970
|
+
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
4971
|
+
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
4972
|
+
normalizedName = normalizedName.replace(/^_/, '');
|
|
4973
|
+
normalizedName = normalizedName.replace(/_$/, '');
|
|
4974
|
+
return normalizedName;
|
|
4975
|
+
}
|
|
4976
|
+
/**
|
|
4977
|
+
* TODO: Tests
|
|
4978
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
4979
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ΔΕ‘ΔΕΕΎΕΎΓ½Γ‘ΓΓΊΕ―' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
4980
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
4981
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
4982
|
+
* TODO: [πΊ] Use some intermediate util splitWords
|
|
4983
|
+
*/
|
|
4984
|
+
|
|
4915
4985
|
/**
|
|
4916
4986
|
* Parses the foreach command
|
|
4917
4987
|
*
|
|
@@ -4949,17 +5019,59 @@
|
|
|
4949
5019
|
'FOREACH List Line -> `{customer}`',
|
|
4950
5020
|
'FOR List Line -> `{customer}`',
|
|
4951
5021
|
'EACH List Line -> `{customer}`',
|
|
4952
|
-
// <- TODO: [π] More
|
|
5022
|
+
// <- TODO: [π] !!!!!! More
|
|
4953
5023
|
],
|
|
4954
5024
|
/**
|
|
4955
5025
|
* Parses the FOREACH command
|
|
4956
5026
|
*/
|
|
4957
5027
|
parse: function (input) {
|
|
4958
|
-
var args = input.args;
|
|
4959
|
-
|
|
4960
|
-
|
|
5028
|
+
var args = input.args, rawArgs = input.rawArgs;
|
|
5029
|
+
var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
|
|
5030
|
+
var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
|
|
5031
|
+
var assignSign = args[2];
|
|
5032
|
+
var parameter = args[3];
|
|
5033
|
+
if (![
|
|
5034
|
+
'LIST',
|
|
5035
|
+
'CSV',
|
|
5036
|
+
// <- TODO: [π’] Unhardcode formats
|
|
5037
|
+
].includes(formatName)) {
|
|
5038
|
+
console.info({ args: args, formatName: formatName });
|
|
5039
|
+
throw new Error("Unsupported format \"".concat(formatName, "\""));
|
|
5040
|
+
// <- TODO: [π’] List all supported format names
|
|
5041
|
+
}
|
|
5042
|
+
if (![
|
|
5043
|
+
'LINE',
|
|
5044
|
+
'ROW',
|
|
5045
|
+
'COLUMN',
|
|
5046
|
+
'CELL',
|
|
5047
|
+
// <- TODO: [π’] Unhardcode format cekks
|
|
5048
|
+
].includes(cellName)) {
|
|
5049
|
+
console.info({ args: args, cellName: cellName });
|
|
5050
|
+
throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
|
|
5051
|
+
// <- TODO: [π’] List all supported cell names for the format
|
|
5052
|
+
}
|
|
5053
|
+
if (assignSign !== '->') {
|
|
5054
|
+
console.info({ args: args, assignSign: assignSign });
|
|
5055
|
+
throw new Error("FOREACH command must have '->' to assign the value to the parameter");
|
|
5056
|
+
}
|
|
5057
|
+
var parameterNames = extractParameterNames(parameter || rawArgs);
|
|
5058
|
+
if (parameterNames.size !== 1) {
|
|
5059
|
+
console.info({ args: args, parameter: parameter, rawArgs: rawArgs });
|
|
5060
|
+
throw new Error("FOREACH command contain exactly one parameter, but found ".concat(parameterNames.size));
|
|
5061
|
+
}
|
|
5062
|
+
var parameterName = parameterNames.values().next().value;
|
|
5063
|
+
if (typeof parameterName !== 'string'
|
|
5064
|
+
// <- TODO: !!!!!! Replace with propper parameter name validation
|
|
5065
|
+
) {
|
|
5066
|
+
console.info({ args: args, parameterName: parameterName });
|
|
5067
|
+
throw new Error("Invalid parameter name");
|
|
5068
|
+
// <- TODO: !!!!!! Better error (with rules and precise error) from validateParameterName
|
|
5069
|
+
}
|
|
4961
5070
|
return {
|
|
4962
5071
|
type: 'FOREACH',
|
|
5072
|
+
formatName: formatName,
|
|
5073
|
+
cellName: cellName,
|
|
5074
|
+
parameterName: parameterName,
|
|
4963
5075
|
};
|
|
4964
5076
|
},
|
|
4965
5077
|
/**
|
|
@@ -4969,7 +5081,7 @@
|
|
|
4969
5081
|
*/
|
|
4970
5082
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
4971
5083
|
keepUnused(command, $templateJson, $pipelineJson);
|
|
4972
|
-
// <- TODO: [π] Implement
|
|
5084
|
+
// <- TODO: [π] !!!!!! Implement
|
|
4973
5085
|
},
|
|
4974
5086
|
/**
|
|
4975
5087
|
* Converts the FOREACH command back to string
|
|
@@ -4979,7 +5091,7 @@
|
|
|
4979
5091
|
stringify: function (command) {
|
|
4980
5092
|
keepUnused(command);
|
|
4981
5093
|
return "";
|
|
4982
|
-
// <- TODO: [π] Implement
|
|
5094
|
+
// <- TODO: [π] !!!!!! Implement
|
|
4983
5095
|
},
|
|
4984
5096
|
/**
|
|
4985
5097
|
* Reads the FOREACH command from the `TemplateJson`
|
|
@@ -4989,11 +5101,12 @@
|
|
|
4989
5101
|
takeFromTemplateJson: function ($templateJson) {
|
|
4990
5102
|
keepUnused($templateJson);
|
|
4991
5103
|
return [];
|
|
4992
|
-
// <- TODO: [π] Implement
|
|
5104
|
+
// <- TODO: [π] !!!!!! Implement
|
|
4993
5105
|
},
|
|
4994
5106
|
};
|
|
4995
5107
|
/**
|
|
4996
|
-
* TODO:
|
|
5108
|
+
* TODO: !!!!!! Comment console logs
|
|
5109
|
+
* TODO: [π] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
|
|
4997
5110
|
*/
|
|
4998
5111
|
|
|
4999
5112
|
/**
|
|
@@ -5346,6 +5459,7 @@
|
|
|
5346
5459
|
isInput = false;
|
|
5347
5460
|
isOutput = false;
|
|
5348
5461
|
}
|
|
5462
|
+
// TODO: !!!!!! Add parameter name validation
|
|
5349
5463
|
return {
|
|
5350
5464
|
type: 'PARAMETER',
|
|
5351
5465
|
parameterName: parameterName,
|
|
@@ -6098,76 +6212,6 @@
|
|
|
6098
6212
|
return str;
|
|
6099
6213
|
}
|
|
6100
6214
|
|
|
6101
|
-
/**
|
|
6102
|
-
* @@@
|
|
6103
|
-
*
|
|
6104
|
-
* @param text @@@
|
|
6105
|
-
* @returns @@@
|
|
6106
|
-
* @example 'HELLO_WORLD'
|
|
6107
|
-
* @example 'I_LOVE_PROMPTBOOK'
|
|
6108
|
-
* @public exported from `@promptbook/utils`
|
|
6109
|
-
*/
|
|
6110
|
-
function normalizeTo_SCREAMING_CASE(text) {
|
|
6111
|
-
var e_1, _a;
|
|
6112
|
-
var charType;
|
|
6113
|
-
var lastCharType = 'OTHER';
|
|
6114
|
-
var normalizedName = '';
|
|
6115
|
-
try {
|
|
6116
|
-
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
6117
|
-
var char = text_1_1.value;
|
|
6118
|
-
var normalizedChar = void 0;
|
|
6119
|
-
if (/^[a-z]$/.test(char)) {
|
|
6120
|
-
charType = 'LOWERCASE';
|
|
6121
|
-
normalizedChar = char.toUpperCase();
|
|
6122
|
-
}
|
|
6123
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
6124
|
-
charType = 'UPPERCASE';
|
|
6125
|
-
normalizedChar = char;
|
|
6126
|
-
}
|
|
6127
|
-
else if (/^[0-9]$/.test(char)) {
|
|
6128
|
-
charType = 'NUMBER';
|
|
6129
|
-
normalizedChar = char;
|
|
6130
|
-
}
|
|
6131
|
-
else if (/^\/$/.test(char)) {
|
|
6132
|
-
charType = 'SLASH';
|
|
6133
|
-
normalizedChar = char;
|
|
6134
|
-
}
|
|
6135
|
-
else {
|
|
6136
|
-
charType = 'OTHER';
|
|
6137
|
-
normalizedChar = '_';
|
|
6138
|
-
}
|
|
6139
|
-
if (charType !== lastCharType &&
|
|
6140
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
6141
|
-
!(lastCharType === 'NUMBER') &&
|
|
6142
|
-
!(charType === 'NUMBER')) {
|
|
6143
|
-
normalizedName += '_';
|
|
6144
|
-
}
|
|
6145
|
-
normalizedName += normalizedChar;
|
|
6146
|
-
lastCharType = charType;
|
|
6147
|
-
}
|
|
6148
|
-
}
|
|
6149
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6150
|
-
finally {
|
|
6151
|
-
try {
|
|
6152
|
-
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
6153
|
-
}
|
|
6154
|
-
finally { if (e_1) throw e_1.error; }
|
|
6155
|
-
}
|
|
6156
|
-
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
6157
|
-
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
6158
|
-
normalizedName = normalizedName.replace(/^_/, '');
|
|
6159
|
-
normalizedName = normalizedName.replace(/_$/, '');
|
|
6160
|
-
return normalizedName;
|
|
6161
|
-
}
|
|
6162
|
-
/**
|
|
6163
|
-
* TODO: Tests
|
|
6164
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
6165
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ΔΕ‘ΔΕΕΎΕΎΓ½Γ‘ΓΓΊΕ―' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
6166
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
6167
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
6168
|
-
* TODO: [πΊ] Use some intermediate util splitWords
|
|
6169
|
-
*/
|
|
6170
|
-
|
|
6171
6215
|
/**
|
|
6172
6216
|
* Parses one line of ul/ol to command
|
|
6173
6217
|
*
|
|
@@ -6180,6 +6224,7 @@
|
|
|
6180
6224
|
if (raw.includes('\n') || raw.includes('\r')) {
|
|
6181
6225
|
throw new ParseError('Command can not contain new line characters' /* <- TODO: [π] */);
|
|
6182
6226
|
}
|
|
6227
|
+
// TODO: Unit test all this processing and parsing
|
|
6183
6228
|
var normalized = raw.trim();
|
|
6184
6229
|
normalized = normalized.split('`').join('');
|
|
6185
6230
|
normalized = normalized.split('"').join('');
|
|
@@ -6235,7 +6280,7 @@
|
|
|
6235
6280
|
// Arg1 Arg2 Arg3 | FOO
|
|
6236
6281
|
{
|
|
6237
6282
|
var commandNameRaw = items.slice(-1).join('_');
|
|
6238
|
-
var args = items.slice(0, -1);
|
|
6283
|
+
var args = items.slice(0, -1); // <- Note: This is probbably not correct
|
|
6239
6284
|
var rawArgs = raw.substring(0, raw.length - commandNameRaw.length).trim();
|
|
6240
6285
|
var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
|
|
6241
6286
|
if (command !== null) {
|