mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
feat(editor): Migrate codemirror-lang-n8n-expression
into this monorepo (no-changelog) (#9087)
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
parent
aa397b9730
commit
244520547b
2
.github/workflows/units-tests-reusable.yml
vendored
2
.github/workflows/units-tests-reusable.yml
vendored
|
@ -69,4 +69,4 @@ jobs:
|
||||||
if: ${{ inputs.collectCoverage == 'true' }}
|
if: ${{ inputs.collectCoverage == 'true' }}
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
files: packages/@n8n/chat/coverage/cobertura-coverage.xml,packages/@n8n/nodes-langchain/coverage/cobertura-coverage.xml,packages/@n8n/permissions/coverage/cobertura-coverage.xml,packages/@n8n/client-oauth2/coverage/cobertura-coverage.xml,packages/cli/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/design-system/coverage/cobertura-coverage.xml,packages/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml
|
files: packages/@n8n/chat/coverage/cobertura-coverage.xml,packages/@n8n/nodes-langchain/coverage/cobertura-coverage.xml,packages/@n8n/permissions/coverage/cobertura-coverage.xml,packages/@n8n/client-oauth2/coverage/cobertura-coverage.xml,packages/cli/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/design-system/coverage/cobertura-coverage.xml,packages/@n8n/codemirror-lang/coverage/cobertura-coverage.xml,packages/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "node scripts/block-npm-install.js",
|
"preinstall": "node scripts/block-npm-install.js",
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"build:backend": "pnpm --filter=!@n8n/chat --filter=!n8n-design-system --filter=!n8n-editor-ui build",
|
"build:backend": "pnpm --filter=!@n8n/chat --filter=!@n8n/codemirror-lang --filter=!n8n-design-system --filter=!n8n-editor-ui build",
|
||||||
"build:frontend": "pnpm --filter=@n8n/chat --filter=n8n-design-system --filter=n8n-editor-ui build",
|
"build:frontend": "pnpm --filter=@n8n/chat --filter=@n8n/codemirror-lang --filter=n8n-design-system --filter=n8n-editor-ui build",
|
||||||
"typecheck": "turbo run typecheck",
|
"typecheck": "turbo run typecheck",
|
||||||
"dev": "turbo run dev --parallel --filter=!n8n-design-system --filter=!@n8n/chat",
|
"dev": "turbo run dev --parallel --filter=!n8n-design-system --filter=!@n8n/chat",
|
||||||
"dev:ai": "turbo run dev --parallel --filter=@n8n/nodes-langchain --filter=n8n --filter=n8n-core",
|
"dev:ai": "turbo run dev --parallel --filter=@n8n/nodes-langchain --filter=n8n --filter=n8n-core",
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
"start:tunnel": "./packages/cli/bin/n8n start --tunnel",
|
"start:tunnel": "./packages/cli/bin/n8n start --tunnel",
|
||||||
"start:windows": "cd packages/cli/bin && n8n",
|
"start:windows": "cd packages/cli/bin && n8n",
|
||||||
"test": "turbo run test",
|
"test": "turbo run test",
|
||||||
"test:backend": "pnpm --filter=!@n8n/chat --filter=!n8n-design-system --filter=!n8n-editor-ui --filter=!n8n-nodes-base --filter=!@n8n/n8n-nodes-langchain test",
|
"test:backend": "pnpm --filter=!@n8n/chat --filter=!@n8n/codemirror-lang --filter=!n8n-design-system --filter=!n8n-editor-ui --filter=!n8n-nodes-base test --filter=!@n8n/n8n-nodes-langchain test",
|
||||||
"test:nodes": "pnpm --filter=n8n-nodes-base --filter=@n8n/n8n-nodes-langchain test",
|
"test:nodes": "pnpm --filter=n8n-nodes-base --filter=@n8n/n8n-nodes-langchain test",
|
||||||
"test:frontend": "pnpm --filter=@n8n/chat --filter=n8n-design-system --filter=n8n-editor-ui test",
|
"test:frontend": "pnpm --filter=@n8n/chat --filter=@n8n/codemirror-lang --filter=n8n-design-system --filter=n8n-editor-ui test",
|
||||||
"watch": "turbo run watch --parallel",
|
"watch": "turbo run watch --parallel",
|
||||||
"webhook": "./packages/cli/bin/n8n webhook",
|
"webhook": "./packages/cli/bin/n8n webhook",
|
||||||
"worker": "./packages/cli/bin/n8n worker",
|
"worker": "./packages/cli/bin/n8n worker",
|
||||||
|
|
14
packages/@n8n/codemirror-lang/.eslintrc.cjs
Normal file
14
packages/@n8n/codemirror-lang/.eslintrc.cjs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
const sharedOptions = require('@n8n_io/eslint-config/shared');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('@types/eslint').ESLint.ConfigData}
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
extends: ['@n8n_io/eslint-config/base'],
|
||||||
|
|
||||||
|
...sharedOptions(__dirname),
|
||||||
|
|
||||||
|
ignorePatterns: [
|
||||||
|
'src/expressions/grammar*.ts'
|
||||||
|
]
|
||||||
|
};
|
5
packages/@n8n/codemirror-lang/README.md
Normal file
5
packages/@n8n/codemirror-lang/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# @n8n/codemirror-lang
|
||||||
|
|
||||||
|
Language support package for CodeMirror 6 in n8n
|
||||||
|
|
||||||
|
[n8n Expression Language support](./src/expressions/README.md)
|
2
packages/@n8n/codemirror-lang/jest.config.js
Normal file
2
packages/@n8n/codemirror-lang/jest.config.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/** @type {import('jest').Config} */
|
||||||
|
module.exports = require('../../../jest.config');
|
37
packages/@n8n/codemirror-lang/package.json
Normal file
37
packages/@n8n/codemirror-lang/package.json
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"name": "@n8n/codemirror-lang",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "Language support package for CodeMirror 6 in n8n",
|
||||||
|
"private": true,
|
||||||
|
"sideEffects": false,
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"module": "src/index.ts",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"require": "./dist/index.js",
|
||||||
|
"import": "./src/index.ts",
|
||||||
|
"types": "./dist/index.d.ts"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"clean": "rimraf dist .turbo",
|
||||||
|
"typecheck": "tsc --noEmit",
|
||||||
|
"generate:expressions:grammar": "lezer-generator --typeScript --output src/expressions/grammar.ts src/expressions/expressions.grammar",
|
||||||
|
"generate": "pnpm generate:expressions:grammar && pnpm format",
|
||||||
|
"build": "tsc -p tsconfig.build.json",
|
||||||
|
"test": "jest",
|
||||||
|
"lint": "eslint . --ext .ts --quiet",
|
||||||
|
"lintfix": "eslint . --ext .ts --fix",
|
||||||
|
"format": "prettier --write --ignore-path ../../.prettierignore src test"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@codemirror/language": "*",
|
||||||
|
"@lezer/highlight": "*",
|
||||||
|
"@lezer/lr": "^1.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@lezer/generator": "^1.7.0"
|
||||||
|
}
|
||||||
|
}
|
26
packages/@n8n/codemirror-lang/src/expressions/README.md
Normal file
26
packages/@n8n/codemirror-lang/src/expressions/README.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# n8n Expression language support
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { parserWithMetaData as n8nParser } from '@n8n/codemirror-lang';
|
||||||
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
||||||
|
import { parseMixed } from '@lezer/common';
|
||||||
|
import { parser as jsParser } from '@lezer/javascript';
|
||||||
|
|
||||||
|
const n8nPlusJsParser = n8nParser.configure({
|
||||||
|
wrap: parseMixed((node) => {
|
||||||
|
if (node.type.isTop) return null;
|
||||||
|
|
||||||
|
return node.name === 'Resolvable'
|
||||||
|
? { parser: jsParser, overlay: (node) => node.type.name === 'Resolvable' }
|
||||||
|
: null;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const n8nLanguage = LRLanguage.define({ parser: n8nPlusJsParser });
|
||||||
|
|
||||||
|
export function n8nExpressionLanguageSupport() {
|
||||||
|
return new LanguageSupport(n8nLanguage);
|
||||||
|
}
|
||||||
|
```
|
|
@ -0,0 +1,21 @@
|
||||||
|
@top Program { entity* }
|
||||||
|
|
||||||
|
entity { Plaintext | Resolvable }
|
||||||
|
|
||||||
|
@tokens {
|
||||||
|
Plaintext { ![{] Plaintext? | "{" (@eof | ![{] Plaintext?) }
|
||||||
|
|
||||||
|
OpenMarker[closedBy="CloseMarker"] { "{{" }
|
||||||
|
|
||||||
|
CloseMarker[openedBy="OpenMarker"] { "}}" }
|
||||||
|
|
||||||
|
Resolvable {
|
||||||
|
OpenMarker resolvableChar* CloseMarker
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvableChar { unicodeChar | "}" ![}] | "\\}}" }
|
||||||
|
|
||||||
|
unicodeChar { $[\u0000-\u007C] | $[\u007E-\u1FFF] | $[\u20A0-\u20CF] | $[\u{1F300}-\u{1F64F}] }
|
||||||
|
}
|
||||||
|
|
||||||
|
@detectDelim
|
|
@ -0,0 +1,4 @@
|
||||||
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||||||
|
export const Program = 1,
|
||||||
|
Plaintext = 2,
|
||||||
|
Resolvable = 3;
|
18
packages/@n8n/codemirror-lang/src/expressions/grammar.ts
Normal file
18
packages/@n8n/codemirror-lang/src/expressions/grammar.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||||||
|
import { LRParser } from '@lezer/lr';
|
||||||
|
|
||||||
|
export const parser = LRParser.deserialize({
|
||||||
|
version: 14,
|
||||||
|
states: "nQQOPOOOOOO'#Cb'#CbOOOO'#C`'#C`QQOPOOOOOO-E6^-E6^",
|
||||||
|
stateData: 'Y~OQPORPO~O',
|
||||||
|
goto: 'bVPPPPWP^QRORSRTQOR',
|
||||||
|
nodeNames: '⚠ Program Plaintext Resolvable',
|
||||||
|
maxTerm: 6,
|
||||||
|
skippedNodes: [0],
|
||||||
|
repeatNodeCount: 1,
|
||||||
|
tokenData:
|
||||||
|
"&U~RTO#ob#o#p!h#p;'Sb;'S;=`!]<%lOb~gTQ~O#ob#o#pv#p;'Sb;'S;=`!]<%lOb~yUO#ob#p;'Sb;'S;=`!]<%l~b~Ob~~!c~!`P;=`<%lb~!hOQ~~!kVO#ob#o#p#Q#p;'Sb;'S;=`!]<%l~b~Ob~~!c~#TWO#O#Q#O#P#m#P#q#Q#q#r%Z#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~#pWO#O#Q#O#P#m#P#q#Q#q#r$Y#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~$]TO#q#Q#q#r$l#r;'S#Q;'S;=`%r<%lO#Q~$qWR~O#O#Q#O#P#m#P#q#Q#q#r%Z#r$IS#Q$Lj$Ml#Q;(b;(c%x;(c;(d&O~%^TO#q#Q#q#r%m#r;'S#Q;'S;=`%r<%lO#Q~%rOR~~%uP;=`<%l#Q~%{P;NQ<%l#Q~&RP;=`;JY#Q",
|
||||||
|
tokenizers: [0],
|
||||||
|
topRules: { Program: [0, 1] },
|
||||||
|
tokenPrec: 0,
|
||||||
|
});
|
28
packages/@n8n/codemirror-lang/src/expressions/index.ts
Normal file
28
packages/@n8n/codemirror-lang/src/expressions/index.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { LRLanguage, LanguageSupport, foldNodeProp, foldInside } from '@codemirror/language';
|
||||||
|
import { styleTags, tags as t } from '@lezer/highlight';
|
||||||
|
import { parser } from './grammar';
|
||||||
|
|
||||||
|
export const parserWithMetaData = parser.configure({
|
||||||
|
props: [
|
||||||
|
foldNodeProp.add({
|
||||||
|
Application: foldInside,
|
||||||
|
}),
|
||||||
|
styleTags({
|
||||||
|
OpenMarker: t.brace,
|
||||||
|
CloseMarker: t.brace,
|
||||||
|
Plaintext: t.content,
|
||||||
|
Resolvable: t.string,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const n8nLanguage = LRLanguage.define({
|
||||||
|
parser: parserWithMetaData,
|
||||||
|
languageData: {
|
||||||
|
commentTokens: { line: ';' },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function n8nExpression() {
|
||||||
|
return new LanguageSupport(n8nLanguage);
|
||||||
|
}
|
1
packages/@n8n/codemirror-lang/src/index.ts
Normal file
1
packages/@n8n/codemirror-lang/src/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export { parserWithMetaData, n8nLanguage } from './expressions';
|
255
packages/@n8n/codemirror-lang/test/expressions/cases.txt
Normal file
255
packages/@n8n/codemirror-lang/test/expressions/cases.txt
Normal file
|
@ -0,0 +1,255 @@
|
||||||
|
# Resolvable
|
||||||
|
|
||||||
|
{{ 1 + 1 }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Empty Resolvable
|
||||||
|
|
||||||
|
{{}}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable of only whitespace
|
||||||
|
|
||||||
|
{{ }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# No content
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program
|
||||||
|
|
||||||
|
# Plaintext
|
||||||
|
|
||||||
|
text
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext)
|
||||||
|
|
||||||
|
# Plaintext of single-brace-wrapped text
|
||||||
|
|
||||||
|
{text}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext)
|
||||||
|
|
||||||
|
# Plaintext then Resolvable
|
||||||
|
|
||||||
|
text {{ 1 + 1 }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext, Resolvable)
|
||||||
|
|
||||||
|
# Resolvable then Plaintext
|
||||||
|
|
||||||
|
{{ 1 + 1 }} Plaintext
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable, Plaintext)
|
||||||
|
|
||||||
|
# Plaintext then Resolvable then Plaintext
|
||||||
|
|
||||||
|
text {{ 1 + 1 }} text
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext, Resolvable, Plaintext)
|
||||||
|
|
||||||
|
# Resolvable then Plaintext then Resolvable
|
||||||
|
|
||||||
|
{{ 1 + 1 }} text {{ 1 + 1 }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable,Plaintext,Resolvable)
|
||||||
|
|
||||||
|
# Plaintext then Resolvable then Plaintext then Resolvable
|
||||||
|
|
||||||
|
text {{ 1 + 1 }} text {{ 1 + 1 }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext, Resolvable, Plaintext, Resolvable)
|
||||||
|
|
||||||
|
# Resolvable then Plaintext then Resolvable then Plaintext
|
||||||
|
|
||||||
|
{{ 1 + 1 }} text {{ 1 + 1 }} text
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable,Plaintext,Resolvable,Plaintext)
|
||||||
|
|
||||||
|
# Resolvable containing all resolvable chars
|
||||||
|
|
||||||
|
{{ he ()[]{<>~`!@#$%^&*-_+=|\;:'",./?\{ llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing single left brace
|
||||||
|
|
||||||
|
{{ he { llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing double left brace
|
||||||
|
|
||||||
|
{{ he {{ llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing triple left brace
|
||||||
|
|
||||||
|
{{ he {{{ llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing single right brace
|
||||||
|
|
||||||
|
{{ he } llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing escaped double right brace
|
||||||
|
|
||||||
|
{{ he \}} llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing escaped triple right brace
|
||||||
|
|
||||||
|
{{ he \}}} llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing single-brace-wrapped text with escaping
|
||||||
|
|
||||||
|
{{ he { abc } llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing double-brace-wrapped text with escaping
|
||||||
|
|
||||||
|
{{ he {{ abc \}} llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing triple-brace-wrapped text with escaping
|
||||||
|
|
||||||
|
{{ he {{{ abc \}}} llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing single-bracket-wrapped text
|
||||||
|
|
||||||
|
{{ he [ abc ] llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing double-bracket-wrapped text
|
||||||
|
|
||||||
|
{{ he [[ abc ]] llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable containing triple-bracket-wrapped text
|
||||||
|
|
||||||
|
{{ he [[[ abc ]]] llo }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Plaintext of one opening brace
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext)
|
||||||
|
|
||||||
|
# Plaintext of one opening brace and two closing braces
|
||||||
|
|
||||||
|
{ }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext)
|
||||||
|
|
||||||
|
# Plaintext then Resolvable with non-ASCII chars then Plaintext
|
||||||
|
|
||||||
|
a {{ 'áßи' }} a
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Plaintext, Resolvable, Plaintext)
|
||||||
|
|
||||||
|
# Resolvable with currency symbol
|
||||||
|
|
||||||
|
{{ '€' }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable with cyrillic char
|
||||||
|
|
||||||
|
{{ 'л' }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable with Pictographs char
|
||||||
|
|
||||||
|
{{ '🎉' }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
||||||
|
|
||||||
|
# Resolvable with Emoticons char
|
||||||
|
|
||||||
|
{{ '😎' }}
|
||||||
|
|
||||||
|
==>
|
||||||
|
|
||||||
|
Program(Resolvable)
|
|
@ -0,0 +1,21 @@
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileTests as runTestFile } from '@lezer/generator/dist/test';
|
||||||
|
import { n8nLanguage } from '../../src/expressions/index';
|
||||||
|
|
||||||
|
describe('expressions language', () => {
|
||||||
|
const CASES_DIR = __dirname;
|
||||||
|
for (const testFile of fs.readdirSync(CASES_DIR)) {
|
||||||
|
if (!/\.txt$/.test(testFile)) continue;
|
||||||
|
|
||||||
|
const testFileName = /^[^\.]*/.exec(testFile)![0];
|
||||||
|
describe(testFileName, () => {
|
||||||
|
for (const { name, run } of runTestFile(
|
||||||
|
fs.readFileSync(path.join(CASES_DIR, testFile), 'utf8'),
|
||||||
|
testFile,
|
||||||
|
)) {
|
||||||
|
it(name, () => run(n8nLanguage.parser));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
10
packages/@n8n/codemirror-lang/tsconfig.build.json
Normal file
10
packages/@n8n/codemirror-lang/tsconfig.build.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"extends": ["./tsconfig.json", "../../../tsconfig.build.json"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "src",
|
||||||
|
"outDir": "dist",
|
||||||
|
"tsBuildInfoFile": "dist/build.tsbuildinfo"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts"],
|
||||||
|
"exclude": ["test/**"]
|
||||||
|
}
|
9
packages/@n8n/codemirror-lang/tsconfig.json
Normal file
9
packages/@n8n/codemirror-lang/tsconfig.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": ".",
|
||||||
|
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo",
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "test/**/*.ts"]
|
||||||
|
}
|
|
@ -50,7 +50,7 @@
|
||||||
"axios": "1.6.7",
|
"axios": "1.6.7",
|
||||||
"chart.js": "^4.4.0",
|
"chart.js": "^4.4.0",
|
||||||
"codemirror-lang-html-n8n": "^1.0.0",
|
"codemirror-lang-html-n8n": "^1.0.0",
|
||||||
"codemirror-lang-n8n-expression": "^0.3.0",
|
"@n8n/codemirror-lang": "workspace:*",
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"email-providers": "^2.0.1",
|
"email-providers": "^2.0.1",
|
||||||
"esprima-next": "5.8.4",
|
"esprima-next": "5.8.4",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { parserWithMetaData as n8nParser } from 'codemirror-lang-n8n-expression';
|
import { parserWithMetaData as n8nParser } from '@n8n/codemirror-lang';
|
||||||
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
||||||
import { parseMixed } from '@lezer/common';
|
import { parseMixed } from '@lezer/common';
|
||||||
import { javascriptLanguage } from '@codemirror/lang-javascript';
|
import { javascriptLanguage } from '@codemirror/lang-javascript';
|
||||||
|
|
|
@ -186,6 +186,22 @@ importers:
|
||||||
specifier: 1.6.7
|
specifier: 1.6.7
|
||||||
version: 1.6.7(debug@3.2.7)
|
version: 1.6.7(debug@3.2.7)
|
||||||
|
|
||||||
|
packages/@n8n/codemirror-lang:
|
||||||
|
dependencies:
|
||||||
|
'@codemirror/language':
|
||||||
|
specifier: '*'
|
||||||
|
version: 6.9.3
|
||||||
|
'@lezer/highlight':
|
||||||
|
specifier: '*'
|
||||||
|
version: 1.1.1
|
||||||
|
'@lezer/lr':
|
||||||
|
specifier: ^1.4.0
|
||||||
|
version: 1.4.0
|
||||||
|
devDependencies:
|
||||||
|
'@lezer/generator':
|
||||||
|
specifier: ^1.7.0
|
||||||
|
version: 1.7.0
|
||||||
|
|
||||||
packages/@n8n/imap:
|
packages/@n8n/imap:
|
||||||
dependencies:
|
dependencies:
|
||||||
iconv-lite:
|
iconv-lite:
|
||||||
|
@ -1116,6 +1132,9 @@ importers:
|
||||||
'@n8n/chat':
|
'@n8n/chat':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../@n8n/chat
|
version: link:../@n8n/chat
|
||||||
|
'@n8n/codemirror-lang':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../@n8n/codemirror-lang
|
||||||
'@n8n/codemirror-lang-sql':
|
'@n8n/codemirror-lang-sql':
|
||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.2(@codemirror/view@6.22.3)(@lezer/common@1.1.0)
|
version: 1.0.2(@codemirror/view@6.22.3)(@lezer/common@1.1.0)
|
||||||
|
@ -1137,9 +1156,6 @@ importers:
|
||||||
codemirror-lang-html-n8n:
|
codemirror-lang-html-n8n:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
codemirror-lang-n8n-expression:
|
|
||||||
specifier: ^0.3.0
|
|
||||||
version: 0.3.0(@codemirror/state@6.3.3)(@codemirror/view@6.22.3)(@lezer/common@1.1.0)
|
|
||||||
dateformat:
|
dateformat:
|
||||||
specifier: ^3.0.3
|
specifier: ^3.0.3
|
||||||
version: 3.0.3
|
version: 3.0.3
|
||||||
|
@ -4700,8 +4716,8 @@ packages:
|
||||||
'@codemirror/view': 6.22.3
|
'@codemirror/view': 6.22.3
|
||||||
'@lezer/common': 1.1.0
|
'@lezer/common': 1.1.0
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
style-mod: 4.0.0
|
style-mod: 4.1.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@codemirror/lint@6.4.2:
|
/@codemirror/lint@6.4.2:
|
||||||
|
@ -6422,15 +6438,22 @@ packages:
|
||||||
|
|
||||||
/@lezer/common@1.1.0:
|
/@lezer/common@1.1.0:
|
||||||
resolution: {integrity: sha512-XPIN3cYDXsoJI/oDWoR2tD++juVrhgIago9xyKhZ7IhGlzdDM9QgC8D8saKNCz5pindGcznFr2HBSsEQSWnSjw==}
|
resolution: {integrity: sha512-XPIN3cYDXsoJI/oDWoR2tD++juVrhgIago9xyKhZ7IhGlzdDM9QgC8D8saKNCz5pindGcznFr2HBSsEQSWnSjw==}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@lezer/css@1.1.1:
|
/@lezer/css@1.1.1:
|
||||||
resolution: {integrity: sha512-mSjx+unLLapEqdOYDejnGBokB5+AiJKZVclmud0MKQOKx3DLJ5b5VTCstgDDknR6iIV4gVrN6euzsCnj0A2gQA==}
|
resolution: {integrity: sha512-mSjx+unLLapEqdOYDejnGBokB5+AiJKZVclmud0MKQOKx3DLJ5b5VTCstgDDknR6iIV4gVrN6euzsCnj0A2gQA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@lezer/generator@1.7.0:
|
||||||
|
resolution: {integrity: sha512-IJ16tx3biLKlCXUzcK4v8S10AVa2BSM2rB12rtAL6f1hL2TS/HQQlGCoWRvanlL2J4mCYEEIv9uG7n4kVMkVDA==}
|
||||||
|
hasBin: true
|
||||||
|
dependencies:
|
||||||
|
'@lezer/common': 1.1.0
|
||||||
|
'@lezer/lr': 1.4.0
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@lezer/highlight@1.1.1:
|
/@lezer/highlight@1.1.1:
|
||||||
resolution: {integrity: sha512-duv9D23O9ghEDnnUDmxu+L8pJy4nYo4AbCOHIudUhscrLSazqeJeK1V50EU6ZufWF1zv0KJwu/frFRyZWXxHBQ==}
|
resolution: {integrity: sha512-duv9D23O9ghEDnnUDmxu+L8pJy4nYo4AbCOHIudUhscrLSazqeJeK1V50EU6ZufWF1zv0KJwu/frFRyZWXxHBQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -6442,34 +6465,33 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/common': 1.1.0
|
'@lezer/common': 1.1.0
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@lezer/javascript@1.0.2:
|
/@lezer/javascript@1.0.2:
|
||||||
resolution: {integrity: sha512-IjOVeIRhM8IuafWNnk+UzRz7p4/JSOKBNINLYLsdSGuJS9Ju7vFdc82AlTt0jgtV5D8eBZf4g0vK4d3ttBNz7A==}
|
resolution: {integrity: sha512-IjOVeIRhM8IuafWNnk+UzRz7p4/JSOKBNINLYLsdSGuJS9Ju7vFdc82AlTt0jgtV5D8eBZf4g0vK4d3ttBNz7A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@lezer/json@1.0.0:
|
/@lezer/json@1.0.0:
|
||||||
resolution: {integrity: sha512-zbAuUY09RBzCoCA3lJ1+ypKw5WSNvLqGMtasdW6HvVOqZoCpPr8eWrsGnOVWGKGn8Rh21FnrKRVlJXrGAVUqRw==}
|
resolution: {integrity: sha512-zbAuUY09RBzCoCA3lJ1+ypKw5WSNvLqGMtasdW6HvVOqZoCpPr8eWrsGnOVWGKGn8Rh21FnrKRVlJXrGAVUqRw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@lezer/lr@1.2.3:
|
/@lezer/lr@1.4.0:
|
||||||
resolution: {integrity: sha512-qpB7rBzH8f6Mzjv2AVZRahcm+2Cf7nbIH++uXbvVOL1yIRvVWQ3HAM/saeBLCyz/togB7LGo76qdJYL1uKQlqA==}
|
resolution: {integrity: sha512-Wst46p51km8gH0ZUmeNrtpRYmdlRHUpN1DQd3GFAyKANi8WVz8c2jHYTf1CVScFaCjQw1iO3ZZdqGDxQPRErTg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/common': 1.1.0
|
'@lezer/common': 1.1.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@lezer/python@1.1.5:
|
/@lezer/python@1.1.5:
|
||||||
resolution: {integrity: sha512-h0DVr6IfrmKUbTc5PeetaC87IZYoHyn5JogsVYW5mRDpVRyEsvaLBMLyEN4Ufc2BKp1c9y2Pkr8ZNLxS8dTLsQ==}
|
resolution: {integrity: sha512-h0DVr6IfrmKUbTc5PeetaC87IZYoHyn5JogsVYW5mRDpVRyEsvaLBMLyEN4Ufc2BKp1c9y2Pkr8ZNLxS8dTLsQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@mdx-js/react@3.0.1(@types/react@18.0.27)(react@18.2.0):
|
/@mdx-js/react@3.0.1(@types/react@18.0.27)(react@18.2.0):
|
||||||
|
@ -6593,7 +6615,7 @@ packages:
|
||||||
'@codemirror/language': 6.9.3
|
'@codemirror/language': 6.9.3
|
||||||
'@codemirror/state': 6.3.3
|
'@codemirror/state': 6.3.3
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@codemirror/view'
|
- '@codemirror/view'
|
||||||
- '@lezer/common'
|
- '@lezer/common'
|
||||||
|
@ -9240,7 +9262,7 @@ packages:
|
||||||
ts-dedent: 2.2.0
|
ts-dedent: 2.2.0
|
||||||
type-fest: 2.19.0
|
type-fest: 2.19.0
|
||||||
vue: 3.4.21(typescript@5.4.2)
|
vue: 3.4.21(typescript@5.4.2)
|
||||||
vue-component-type-helpers: 2.0.16
|
vue-component-type-helpers: 2.0.17
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- encoding
|
- encoding
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -12377,20 +12399,7 @@ packages:
|
||||||
'@lezer/css': 1.1.1
|
'@lezer/css': 1.1.1
|
||||||
'@lezer/highlight': 1.1.1
|
'@lezer/highlight': 1.1.1
|
||||||
'@lezer/html': 1.3.0
|
'@lezer/html': 1.3.0
|
||||||
'@lezer/lr': 1.2.3
|
'@lezer/lr': 1.4.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/codemirror-lang-n8n-expression@0.3.0(@codemirror/state@6.3.3)(@codemirror/view@6.22.3)(@lezer/common@1.1.0):
|
|
||||||
resolution: {integrity: sha512-lY3qD+FB0/JCotK9hV40YhE+jC98iyC8L667pnguq7gxgIU3Kgy2RHy+PAxz/GpLR7BYtUMyVumZU7dJnjiXbw==}
|
|
||||||
dependencies:
|
|
||||||
'@codemirror/autocomplete': 6.11.1(@codemirror/language@6.9.3)(@codemirror/state@6.3.3)(@codemirror/view@6.22.3)(@lezer/common@1.1.0)
|
|
||||||
'@codemirror/language': 6.9.3
|
|
||||||
'@lezer/highlight': 1.1.1
|
|
||||||
'@lezer/lr': 1.2.3
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@codemirror/state'
|
|
||||||
- '@codemirror/view'
|
|
||||||
- '@lezer/common'
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/cohere-ai@6.2.2:
|
/cohere-ai@6.2.2:
|
||||||
|
@ -22735,10 +22744,6 @@ packages:
|
||||||
resolution: {integrity: sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==}
|
resolution: {integrity: sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/style-mod@4.0.0:
|
|
||||||
resolution: {integrity: sha512-OPhtyEjyyN9x3nhPsu76f52yUGXiZcgvsrFVtvTkyGRQJ0XK+GPc6ov1z+lRpbeabka+MYEQxOYRnt5nF30aMw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/style-mod@4.1.0:
|
/style-mod@4.1.0:
|
||||||
resolution: {integrity: sha512-Ca5ib8HrFn+f+0n4N4ScTIA9iTOQ7MaGS1ylHcoVqW9J7w2w8PzN6g9gKmTYgGEBH8e120+RCmhpje6jC5uGWA==}
|
resolution: {integrity: sha512-Ca5ib8HrFn+f+0n4N4ScTIA9iTOQ7MaGS1ylHcoVqW9J7w2w8PzN6g9gKmTYgGEBH8e120+RCmhpje6jC5uGWA==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -24339,8 +24344,8 @@ packages:
|
||||||
resolution: {integrity: sha512-0vOfAtI67UjeO1G6UiX5Kd76CqaQ67wrRZiOe7UAb9Jm6GzlUr/fC7CV90XfwapJRjpCMaZFhv1V0ajWRmE9Dg==}
|
resolution: {integrity: sha512-0vOfAtI67UjeO1G6UiX5Kd76CqaQ67wrRZiOe7UAb9Jm6GzlUr/fC7CV90XfwapJRjpCMaZFhv1V0ajWRmE9Dg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vue-component-type-helpers@2.0.16:
|
/vue-component-type-helpers@2.0.17:
|
||||||
resolution: {integrity: sha512-qisL/iAfdO++7w+SsfYQJVPj6QKvxp4i1MMxvsNO41z/8zu3KuAw9LkhKUfP/kcOWGDxESp+pQObWppXusejCA==}
|
resolution: {integrity: sha512-2car49m8ciqg/JjgMBkx7o/Fd2A7fHESxNqL/2vJYFLXm4VwYO4yH0rexOi4a35vwNgDyvt17B07Vj126l9rAQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vue-demi@0.14.5(vue@3.4.21):
|
/vue-demi@0.14.5(vue@3.4.21):
|
||||||
|
|
Loading…
Reference in a new issue