mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
fix(flows): pebble autocompletion performance optimization (#11981)
closes #11881
This commit is contained in:
committed by
brian.mulier
parent
70ef82faba
commit
63f30f11ef
@@ -1,23 +1,22 @@
|
||||
const maybeText = (allowSeparators: boolean) => "(?:\"[^\"]*\")|(?:'[^']*')|(?:(?:(?!\\}\\})" + (allowSeparators ? "[\\S\\n ]" : "[^~+,:\\n ]") + ")*)";
|
||||
const maybeAnotherPebbleExpression = "(?:[\\n ]*\\{\\{[\\n ]*" + maybeText(true) + "[\\n ]*\\}\\}[\\n ]*)*";
|
||||
const pebbleStart = "\\{\\{[\\n ]*";
|
||||
const fieldWithoutDotCapture = "([^\\(\\)\\}:~+.\\n '\"]*)(?![^\\(\\)\\}\\n ])";
|
||||
const dotAccessedFieldWithParentCapture = "([^\\(\\)\\}:~+\\n '\"]*)\\." + fieldWithoutDotCapture;
|
||||
const maybeTextFollowedBySeparator = "(?:" + maybeText(false) + "[~+ ]+)*";
|
||||
const paramKey = "[^\\n \\(\\)~+\\},:=]+";
|
||||
const paramValue = "(?:(?:(?:\"[^\"]*\"?)|(?:'[^']*'?)|[^,)]))*";
|
||||
const fieldWithoutDotCapture = "([^()}:~+.\\n '\"]*)(?![^()}\\n ])";
|
||||
const dotAccessedFieldWithParentCapture = "([^()}:~+\\n '\"]*)\\." + fieldWithoutDotCapture;
|
||||
const maybeTextFollowedBySeparator = "(?:" + maybeText(true) + "[\\n ]*(?:(?:[~+]+)|(?:\\}\\}[\\n ]*" + pebbleStart + "))[\\n ]*)*";
|
||||
const paramKey = "[^\\n ()~+},:=]+";
|
||||
const paramValue = "(?:(?:(?:\"[^\"]*\"?)|(?:'[^']*'?)|[^,)}]))*";
|
||||
const maybeParams = "(" +
|
||||
"(?:[\\n ]*" + paramKey + "[\\n ]*=[\\n ]*" + paramValue + "(?:[\\n ]*,[\\n ]*)?)+)?" +
|
||||
"([^\\n \\(\\)~+\\},:=]*)?";
|
||||
const functionWithMaybeParams = "([^\\n\\(\\)\\},:~ ]+)\\(" + maybeParams
|
||||
"([^\\n ()~+},:=]*)?";
|
||||
const functionWithMaybeParams = "([^\\n()},:~ ]+)\\(" + maybeParams
|
||||
|
||||
export default {
|
||||
beforeSeparator: (additionalSeparators: string[] = []) => `([^\\}:\\n ${additionalSeparators.join("")}]*)`,
|
||||
/** [fullMatch, dotForbiddenField] */
|
||||
capturePebbleVarRoot: `${maybeAnotherPebbleExpression}${pebbleStart}${maybeTextFollowedBySeparator}${fieldWithoutDotCapture}`,
|
||||
capturePebbleVarRoot: `${pebbleStart}${maybeTextFollowedBySeparator}${fieldWithoutDotCapture}`,
|
||||
/** [fullMatch, parentFieldMaybeIncludingDots, childField] */
|
||||
capturePebbleVarParent: `${maybeAnotherPebbleExpression}${pebbleStart}${maybeTextFollowedBySeparator}${dotAccessedFieldWithParentCapture}`,
|
||||
capturePebbleVarParent: `${pebbleStart}${maybeTextFollowedBySeparator}${dotAccessedFieldWithParentCapture}`,
|
||||
/** [fullMatch, functionName, textBetweenParenthesis, maybeTypedWordStart] */
|
||||
capturePebbleFunction: `${maybeAnotherPebbleExpression}${pebbleStart}${maybeTextFollowedBySeparator}${functionWithMaybeParams}`,
|
||||
capturePebbleFunction: `${pebbleStart}${maybeTextFollowedBySeparator}${functionWithMaybeParams}`,
|
||||
captureStringValue: "^[\"']([^\"']+)[\"']$"
|
||||
}
|
||||
|
||||
@@ -109,16 +109,7 @@ tasks:
|
||||
"\\")) | (.key + \\"->\\" + .value)"
|
||||
}} {{myFunc(my-param_1='value1', my-param_2="value2", myK`
|
||||
expect([...(regex.exec(shouldMatchLastFunction) ?? [])]).toEqual([
|
||||
`id: breaking-ui
|
||||
namespace: io.kestra.blx
|
||||
description: "Upload multiple files to s3 sequentially"
|
||||
|
||||
|
||||
tasks:
|
||||
- id: placeholder
|
||||
type: io.kestra.plugin.core.log.Log
|
||||
message: |-
|
||||
{{
|
||||
`{{
|
||||
"to_entries[] | select(.key | startswith(\\"" +
|
||||
inputs.selector +
|
||||
"\\")) | (.key + \\"->\\" + .value)"
|
||||
|
||||
Reference in New Issue
Block a user