From a1f5ffe86d466b3fd33e063852f25480874cc08e Mon Sep 17 00:00:00 2001 From: Georg Schwarz Date: Mon, 4 Sep 2023 19:04:00 +0200 Subject: [PATCH] Replace lang extensions by builtin blocktype definitions --- apps/vs-code-extension/src/language-server.ts | 8 +- .../standard-library-file-system-provider.ts | 8 +- example/test.jv | 19 + libs/execution/src/lib/execution-context.ts | 5 +- libs/extensions/rdbms/lang/.babelrc | 10 - libs/extensions/rdbms/lang/.babelrc.license | 3 - libs/extensions/rdbms/lang/.eslintrc.json | 18 - .../rdbms/lang/.eslintrc.json.license | 3 - libs/extensions/rdbms/lang/README.md | 17 - libs/extensions/rdbms/lang/jest.config.ts | 18 - libs/extensions/rdbms/lang/package.json | 4 - .../rdbms/lang/package.json.license | 3 - libs/extensions/rdbms/lang/project.json | 34 -- .../rdbms/lang/project.json.license | 3 - libs/extensions/rdbms/lang/src/extension.ts | 20 - libs/extensions/rdbms/lang/src/index.ts | 5 - libs/extensions/rdbms/lang/src/lib/index.ts | 6 - .../lib/postgres-loader-meta-information.ts | 74 ---- .../src/lib/sqlite-loader-meta-information.ts | 55 --- libs/extensions/rdbms/lang/tsconfig.json | 22 - .../rdbms/lang/tsconfig.json.license | 3 - libs/extensions/rdbms/lang/tsconfig.lib.json | 10 - .../rdbms/lang/tsconfig.lib.json.license | 3 - libs/extensions/rdbms/lang/tsconfig.spec.json | 14 - .../rdbms/lang/tsconfig.spec.json.license | 3 - libs/extensions/std/lang/.babelrc | 10 - libs/extensions/std/lang/.babelrc.license | 3 - libs/extensions/std/lang/.eslintrc.json | 18 - .../std/lang/.eslintrc.json.license | 3 - libs/extensions/std/lang/README.md | 17 - libs/extensions/std/lang/jest.config.ts | 18 - libs/extensions/std/lang/package.json | 4 - libs/extensions/std/lang/package.json.license | 3 - libs/extensions/std/lang/project.json | 34 -- libs/extensions/std/lang/project.json.license | 3 - .../lang/src/archive-interpreter-meta-inf.ts | 46 -- .../std/lang/src/example-validation.spec.ts | 51 --- libs/extensions/std/lang/src/extension.ts | 39 -- .../std/lang/src/file-picker-meta-inf.ts | 46 -- .../src/gtfs-rt-interpreter-meta-inf.spec.ts | 64 --- .../lang/src/gtfs-rt-interpreter-meta-inf.ts | 124 ------ .../std/lang/src/http-extractor-meta-inf.ts | 185 -------- libs/extensions/std/lang/src/index.ts | 5 - .../src/meta-inf-example-validation.spec.ts | 135 ------ .../text-file-interpreter-meta-inf.spec.ts | 64 --- .../src/text-file-interpreter-meta-inf.ts | 64 --- .../src/text-line-deleter-meta-inf.spec.ts | 64 --- .../lang/src/text-line-deleter-meta-inf.ts | 53 --- .../src/text-range-selector-meta-inf.spec.ts | 101 ----- .../lang/src/text-range-selector-meta-inf.ts | 101 ----- .../invalid-invalid-entity-param.jv | 17 - .../valid-valid-entity-param.jv | 17 - .../invalid-invalid-encoding-param.jv | 17 - .../valid-utf8-encoding.jv | 17 - .../invalid-line-less-or-equal-zero.jv | 17 - .../valid-postive-line-number.jv | 17 - .../invalid-lineFrom-greater-lineTo.jv | 18 - .../invalid-lineFrom-less-or-equal-zero.jv | 17 - .../invalid-lineTo-less-or-equal-zero.jv | 18 - .../valid-correct-range.jv | 18 - libs/extensions/std/lang/tsconfig.json | 22 - .../extensions/std/lang/tsconfig.json.license | 3 - libs/extensions/std/lang/tsconfig.lib.json | 10 - .../std/lang/tsconfig.lib.json.license | 3 - libs/extensions/std/lang/tsconfig.spec.json | 14 - .../std/lang/tsconfig.spec.json.license | 3 - libs/extensions/tabular/lang/.babelrc | 10 - libs/extensions/tabular/lang/.babelrc.license | 3 - libs/extensions/tabular/lang/.eslintrc.json | 18 - .../tabular/lang/.eslintrc.json.license | 3 - libs/extensions/tabular/lang/README.md | 17 - libs/extensions/tabular/lang/jest.config.ts | 18 - libs/extensions/tabular/lang/package.json | 4 - .../tabular/lang/package.json.license | 3 - libs/extensions/tabular/lang/project.json | 34 -- .../tabular/lang/project.json.license | 3 - libs/extensions/tabular/lang/src/extension.ts | 35 -- libs/extensions/tabular/lang/src/index.ts | 5 - .../src/lib/cell-range-selector-meta-inf.ts | 47 -- .../lang/src/lib/cell-writer-meta-inf.spec.ts | 90 ---- .../lang/src/lib/cell-writer-meta-inf.ts | 137 ------ .../src/lib/column-deleter-meta-inf.spec.ts | 67 --- .../lang/src/lib/column-deleter-meta-inf.ts | 72 ---- .../lang/src/lib/csv-interpreter-meta-inf.ts | 69 --- .../lang/src/lib/row-deleter-meta-inf.spec.ts | 65 --- .../lang/src/lib/row-deleter-meta-inf.ts | 73 ---- .../src/lib/sheet-picker-meta-inf.spec.ts | 67 --- .../lang/src/lib/sheet-picker-meta-inf.ts | 44 -- .../lib/table-interpreter-meta-inf.spec.ts | 70 --- .../src/lib/table-interpreter-meta-inf.ts | 105 ----- .../lib/table-transformer-meta-inf.spec.ts | 67 --- .../src/lib/table-transformer-meta-inf.ts | 149 ------- .../src/lib/xlsx-interpreter-meta-inf.spec.ts | 49 --- .../lang/src/lib/xlsx-interpreter-meta-inf.ts | 33 -- ...-write-length-does-not-match-cell-range.jv | 18 - .../invalid-wrong-at-dimension.jv | 18 - .../valid-range-matches-array-length.jv | 18 - .../invalid-partial-column-delete.jv | 17 - .../valid-column-delete.jv | 17 - .../invalid-partial-row-delete.jv | 17 - .../row-deleter-meta-inf/valid-row-delete.jv | 17 - .../invalid-sheet-picker-missing-parameter.jv | 17 - .../valid-correct-sheet-picker.jv | 18 - .../invalid-non-unique-column-names.jv | 21 - .../valid-correct-table.jv | 21 - ...-input-columns-transform-port-missmatch.jv | 26 -- .../valid-correct-ports.jv | 26 -- .../valid-xlsx-interpreter.jv | 17 - libs/extensions/tabular/lang/tsconfig.json | 22 - .../tabular/lang/tsconfig.json.license | 3 - .../extensions/tabular/lang/tsconfig.lib.json | 10 - .../tabular/lang/tsconfig.lib.json.license | 3 - .../tabular/lang/tsconfig.spec.json | 14 - .../tabular/lang/tsconfig.spec.json.license | 3 - libs/interpreter-lib/src/interpreter.ts | 3 - libs/interpreter-lib/src/parsing-util.ts | 1 + .../completion/jayvee-completion-provider.ts | 42 +- libs/language-server/src/lib/extension.ts | 15 - .../lib/meta-information/block-meta-inf.ts | 18 +- .../lib/meta-information/meta-inf-registry.ts | 65 +-- libs/language-server/src/stdlib/blocktypes.jv | 406 ------------------ .../builtin-blocktypes/ArchiveInterpreter.jv | 22 + .../builtin-blocktypes/CellRangeSelector.jv | 15 + .../stdlib/builtin-blocktypes/CellWriter.jv | 25 ++ .../builtin-blocktypes/ColumnDeleter.jv | 15 + .../builtin-blocktypes/CsvInterpreter.jv | 19 + .../stdlib/builtin-blocktypes/FilePicker.jv | 15 + .../builtin-blocktypes/GtfsRtInterpreter.jv | 70 +++ .../builtin-blocktypes/HttpExtractor.jv | 45 ++ .../builtin-blocktypes/PostgresLoader.jv | 30 ++ .../stdlib/builtin-blocktypes/RowDeleter.jv | 15 + .../stdlib/builtin-blocktypes/SheetPicker.jv | 15 + .../stdlib/builtin-blocktypes/SqliteLoader.jv | 20 + .../builtin-blocktypes/TableInterpreter.jv | 32 ++ .../builtin-blocktypes/TableTransformer.jv | 45 ++ .../builtin-blocktypes/TextFileInterpreter.jv | 21 + .../builtin-blocktypes/TextLineDeleter.jv | 17 + .../builtin-blocktypes/TextRangeSelector.jv | 11 + .../builtin-blocktypes/XlsInterpreter.jv | 11 + tsconfig.base.json | 9 - 140 files changed, 512 insertions(+), 4021 deletions(-) create mode 100644 example/test.jv delete mode 100644 libs/extensions/rdbms/lang/.babelrc delete mode 100644 libs/extensions/rdbms/lang/.babelrc.license delete mode 100644 libs/extensions/rdbms/lang/.eslintrc.json delete mode 100644 libs/extensions/rdbms/lang/.eslintrc.json.license delete mode 100644 libs/extensions/rdbms/lang/README.md delete mode 100644 libs/extensions/rdbms/lang/jest.config.ts delete mode 100644 libs/extensions/rdbms/lang/package.json delete mode 100644 libs/extensions/rdbms/lang/package.json.license delete mode 100644 libs/extensions/rdbms/lang/project.json delete mode 100644 libs/extensions/rdbms/lang/project.json.license delete mode 100644 libs/extensions/rdbms/lang/src/extension.ts delete mode 100644 libs/extensions/rdbms/lang/src/index.ts delete mode 100644 libs/extensions/rdbms/lang/src/lib/index.ts delete mode 100644 libs/extensions/rdbms/lang/src/lib/postgres-loader-meta-information.ts delete mode 100644 libs/extensions/rdbms/lang/src/lib/sqlite-loader-meta-information.ts delete mode 100644 libs/extensions/rdbms/lang/tsconfig.json delete mode 100644 libs/extensions/rdbms/lang/tsconfig.json.license delete mode 100644 libs/extensions/rdbms/lang/tsconfig.lib.json delete mode 100644 libs/extensions/rdbms/lang/tsconfig.lib.json.license delete mode 100644 libs/extensions/rdbms/lang/tsconfig.spec.json delete mode 100644 libs/extensions/rdbms/lang/tsconfig.spec.json.license delete mode 100644 libs/extensions/std/lang/.babelrc delete mode 100644 libs/extensions/std/lang/.babelrc.license delete mode 100644 libs/extensions/std/lang/.eslintrc.json delete mode 100644 libs/extensions/std/lang/.eslintrc.json.license delete mode 100644 libs/extensions/std/lang/README.md delete mode 100644 libs/extensions/std/lang/jest.config.ts delete mode 100644 libs/extensions/std/lang/package.json delete mode 100644 libs/extensions/std/lang/package.json.license delete mode 100644 libs/extensions/std/lang/project.json delete mode 100644 libs/extensions/std/lang/project.json.license delete mode 100644 libs/extensions/std/lang/src/archive-interpreter-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/example-validation.spec.ts delete mode 100644 libs/extensions/std/lang/src/extension.ts delete mode 100644 libs/extensions/std/lang/src/file-picker-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.spec.ts delete mode 100644 libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/http-extractor-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/index.ts delete mode 100644 libs/extensions/std/lang/src/meta-inf-example-validation.spec.ts delete mode 100644 libs/extensions/std/lang/src/text-file-interpreter-meta-inf.spec.ts delete mode 100644 libs/extensions/std/lang/src/text-file-interpreter-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/text-line-deleter-meta-inf.spec.ts delete mode 100644 libs/extensions/std/lang/src/text-line-deleter-meta-inf.ts delete mode 100644 libs/extensions/std/lang/src/text-range-selector-meta-inf.spec.ts delete mode 100644 libs/extensions/std/lang/src/text-range-selector-meta-inf.ts delete mode 100644 libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv delete mode 100644 libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/invalid-invalid-encoding-param.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/valid-utf8-encoding.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/invalid-line-less-or-equal-zero.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/valid-postive-line-number.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-greater-lineTo.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-less-or-equal-zero.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineTo-less-or-equal-zero.jv delete mode 100644 libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/valid-correct-range.jv delete mode 100644 libs/extensions/std/lang/tsconfig.json delete mode 100644 libs/extensions/std/lang/tsconfig.json.license delete mode 100644 libs/extensions/std/lang/tsconfig.lib.json delete mode 100644 libs/extensions/std/lang/tsconfig.lib.json.license delete mode 100644 libs/extensions/std/lang/tsconfig.spec.json delete mode 100644 libs/extensions/std/lang/tsconfig.spec.json.license delete mode 100644 libs/extensions/tabular/lang/.babelrc delete mode 100644 libs/extensions/tabular/lang/.babelrc.license delete mode 100644 libs/extensions/tabular/lang/.eslintrc.json delete mode 100644 libs/extensions/tabular/lang/.eslintrc.json.license delete mode 100644 libs/extensions/tabular/lang/README.md delete mode 100644 libs/extensions/tabular/lang/jest.config.ts delete mode 100644 libs/extensions/tabular/lang/package.json delete mode 100644 libs/extensions/tabular/lang/package.json.license delete mode 100644 libs/extensions/tabular/lang/project.json delete mode 100644 libs/extensions/tabular/lang/project.json.license delete mode 100644 libs/extensions/tabular/lang/src/extension.ts delete mode 100644 libs/extensions/tabular/lang/src/index.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/cell-range-selector-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/csv-interpreter-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.spec.ts delete mode 100644 libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.ts delete mode 100644 libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-write-length-does-not-match-cell-range.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-wrong-at-dimension.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/valid-range-matches-array-length.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/invalid-partial-column-delete.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/valid-column-delete.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/invalid-partial-row-delete.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/valid-row-delete.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/invalid-sheet-picker-missing-parameter.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/valid-correct-sheet-picker.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/invalid-non-unique-column-names.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/valid-correct-table.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/invalid-input-columns-transform-port-missmatch.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/valid-correct-ports.jv delete mode 100644 libs/extensions/tabular/lang/test/assets/xlsx-interpreter-meta-inf/valid-xlsx-interpreter.jv delete mode 100644 libs/extensions/tabular/lang/tsconfig.json delete mode 100644 libs/extensions/tabular/lang/tsconfig.json.license delete mode 100644 libs/extensions/tabular/lang/tsconfig.lib.json delete mode 100644 libs/extensions/tabular/lang/tsconfig.lib.json.license delete mode 100644 libs/extensions/tabular/lang/tsconfig.spec.json delete mode 100644 libs/extensions/tabular/lang/tsconfig.spec.json.license delete mode 100644 libs/language-server/src/lib/extension.ts delete mode 100644 libs/language-server/src/stdlib/blocktypes.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/ArchiveInterpreter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/CellRangeSelector.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/CellWriter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/ColumnDeleter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/CsvInterpreter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/FilePicker.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/GtfsRtInterpreter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/HttpExtractor.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/PostgresLoader.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/RowDeleter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/SheetPicker.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/SqliteLoader.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/TableInterpreter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/TableTransformer.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/TextFileInterpreter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/TextLineDeleter.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/TextRangeSelector.jv create mode 100644 libs/language-server/src/stdlib/builtin-blocktypes/XlsInterpreter.jv diff --git a/apps/vs-code-extension/src/language-server.ts b/apps/vs-code-extension/src/language-server.ts index 21595f4c3..e03b1c248 100644 --- a/apps/vs-code-extension/src/language-server.ts +++ b/apps/vs-code-extension/src/language-server.ts @@ -2,11 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0-only -import { StdLangExtension } from '@jvalue/jayvee-extensions/std/lang'; -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; +import { createJayveeServices } from '@jvalue/jayvee-language-server'; import { startLanguageServer } from 'langium'; import { NodeFileSystem } from 'langium/node'; import { ProposedFeatures, createConnection } from 'vscode-languageserver/node'; @@ -14,8 +10,6 @@ import { ProposedFeatures, createConnection } from 'vscode-languageserver/node'; // Create a connection to the client const connection = createConnection(ProposedFeatures.all); -useExtension(new StdLangExtension()); - // Inject the shared services and language-specific services const { shared } = createJayveeServices({ connection, diff --git a/apps/vs-code-extension/src/standard-library-file-system-provider.ts b/apps/vs-code-extension/src/standard-library-file-system-provider.ts index 862ff9eaa..180c81675 100644 --- a/apps/vs-code-extension/src/standard-library-file-system-provider.ts +++ b/apps/vs-code-extension/src/standard-library-file-system-provider.ts @@ -2,12 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0-only -import { StdLangExtension } from '@jvalue/jayvee-extensions/std/lang'; -import { - getStdLib, - registerConstraints, - useExtension as useLangExtension, -} from '@jvalue/jayvee-language-server'; +import { getStdLib, registerConstraints } from '@jvalue/jayvee-language-server'; import { EventEmitter, ExtensionContext, @@ -34,7 +29,6 @@ export class StandardLibraryFileSystemProvider implements FileSystemProvider { private registerStdLib() { // The VSCode Extension needs to register the StdLangExtension, // otherwise the StdLib does not include the blocktype definitions. - useLangExtension(new StdLangExtension()); registerConstraints(); Object.entries(getStdLib()).forEach(([libName, lib]) => { diff --git a/example/test.jv b/example/test.jv new file mode 100644 index 000000000..8f2337c4e --- /dev/null +++ b/example/test.jv @@ -0,0 +1,19 @@ +/* +Interprets an input file as a csv-file containing string-values delimited by `delimiter` and outputs a `Sheet`. + +@example Interprets an input file as a csv-file containing string-values delimited by `;` and outputs `Sheet`. +block AgencyCSVInterpreter oftype CSVInterpreter { + delimiter: ";"; + } +*/ +builtin blocktype CSVInterpreter { + input default oftype TextFile; + output default oftype Sheet; + + // The delimiter for values in the CSV file. + property delimiter oftype text: ','; + // The enclosing character that may be used for values in the CSV file. + property enclosing oftype text: ''; + // The character to escape enclosing characters in values. + property enclosingEscape oftype text: ''; +} \ No newline at end of file diff --git a/libs/execution/src/lib/execution-context.ts b/libs/execution/src/lib/execution-context.ts index 05123b152..8253fcc44 100644 --- a/libs/execution/src/lib/execution-context.ts +++ b/libs/execution/src/lib/execution-context.ts @@ -6,6 +6,7 @@ import { strict as assert } from 'assert'; import { BlockDefinition, + BlockMetaInformation, ConstraintDefinition, EvaluationContext, InternalValueRepresentation, @@ -14,7 +15,6 @@ import { TransformDefinition, Valuetype, evaluatePropertyValue, - getOrFailBockMetaInf, getOrFailConstraintMetaInf, isBlockDefinition, isExpressionConstraintDefinition, @@ -150,7 +150,8 @@ export class ExecutionContext { return getOrFailConstraintMetaInf(currentNode.type); } else if (isBlockDefinition(currentNode)) { assert(isReference(currentNode.type)); - return getOrFailBockMetaInf(currentNode.type); + assert(BlockMetaInformation.canBeWrapped(currentNode.type)); + return new BlockMetaInformation(currentNode.type); } assertUnreachable(currentNode); } diff --git a/libs/extensions/rdbms/lang/.babelrc b/libs/extensions/rdbms/lang/.babelrc deleted file mode 100644 index e24a5465f..000000000 --- a/libs/extensions/rdbms/lang/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nrwl/web/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/extensions/rdbms/lang/.babelrc.license b/libs/extensions/rdbms/lang/.babelrc.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/.babelrc.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/.eslintrc.json b/libs/extensions/rdbms/lang/.eslintrc.json deleted file mode 100644 index 632e9b0e2..000000000 --- a/libs/extensions/rdbms/lang/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/extensions/rdbms/lang/.eslintrc.json.license b/libs/extensions/rdbms/lang/.eslintrc.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/.eslintrc.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/README.md b/libs/extensions/rdbms/lang/README.md deleted file mode 100644 index f29a26396..000000000 --- a/libs/extensions/rdbms/lang/README.md +++ /dev/null @@ -1,17 +0,0 @@ - - -# extensions-rdbms - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build extensions-rdbms` to build the library. - -## Running unit tests - -Run `nx test extensions-rdbms` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/extensions/rdbms/lang/jest.config.ts b/libs/extensions/rdbms/lang/jest.config.ts deleted file mode 100644 index 94553f702..000000000 --- a/libs/extensions/rdbms/lang/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export default { - displayName: 'extensions-rdbms', - preset: '../../../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../../coverage/libs/extensions/rdbms', -}; diff --git a/libs/extensions/rdbms/lang/package.json b/libs/extensions/rdbms/lang/package.json deleted file mode 100644 index d72af8ee2..000000000 --- a/libs/extensions/rdbms/lang/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@jvalue/jayvee-extensions/rdbms/lang", - "type": "commonjs" -} diff --git a/libs/extensions/rdbms/lang/package.json.license b/libs/extensions/rdbms/lang/package.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/package.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/project.json b/libs/extensions/rdbms/lang/project.json deleted file mode 100644 index b92c660f7..000000000 --- a/libs/extensions/rdbms/lang/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "extensions-rdbms-lang", - "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/extensions/rdbms/lang/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nrwl/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/extensions/rdbms/lang", - "main": "libs/extensions/rdbms/lang/src/index.ts", - "tsConfig": "libs/extensions/rdbms/lang/tsconfig.lib.json", - "assets": ["libs/extensions/rdbms/lang/*.md"] - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/extensions/rdbms/lang/**/*.ts"] - } - }, - "test": { - "executor": "@nrwl/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/extensions/rdbms/lang/jest.config.ts", - "passWithNoTests": true - } - } - }, - "tags": [] -} diff --git a/libs/extensions/rdbms/lang/project.json.license b/libs/extensions/rdbms/lang/project.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/project.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/src/extension.ts b/libs/extensions/rdbms/lang/src/extension.ts deleted file mode 100644 index 067bc8eb6..000000000 --- a/libs/extensions/rdbms/lang/src/extension.ts +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - ConstructorClass, - JayveeLangExtension, -} from '@jvalue/jayvee-language-server'; - -import { - PostgresLoaderMetaInformation, - SQLiteLoaderMetaInformation, -} from './lib'; - -export class RdbmsLangExtension implements JayveeLangExtension { - getBlockMetaInf(): Array> { - return [PostgresLoaderMetaInformation, SQLiteLoaderMetaInformation]; - } -} diff --git a/libs/extensions/rdbms/lang/src/index.ts b/libs/extensions/rdbms/lang/src/index.ts deleted file mode 100644 index 88d3a0045..000000000 --- a/libs/extensions/rdbms/lang/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export * from './extension'; diff --git a/libs/extensions/rdbms/lang/src/lib/index.ts b/libs/extensions/rdbms/lang/src/lib/index.ts deleted file mode 100644 index 4d82edcaf..000000000 --- a/libs/extensions/rdbms/lang/src/lib/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export * from './postgres-loader-meta-information'; -export * from './sqlite-loader-meta-information'; diff --git a/libs/extensions/rdbms/lang/src/lib/postgres-loader-meta-information.ts b/libs/extensions/rdbms/lang/src/lib/postgres-loader-meta-information.ts deleted file mode 100644 index d963ba778..000000000 --- a/libs/extensions/rdbms/lang/src/lib/postgres-loader-meta-information.ts +++ /dev/null @@ -1,74 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class PostgresLoaderMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'PostgresLoader', - { - host: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The hostname or IP address of the Postgres database.', - }, - }, - port: { - type: PrimitiveValuetypes.Integer, - docs: { - description: 'The port of the Postgres database.', - }, - }, - username: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The username to login to the Postgres database.', - }, - }, - password: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The password to login to the Postgres database.', - }, - }, - database: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The database to use.', - }, - }, - table: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The name of the table to write into.', - }, - }, - }, - IOType.TABLE, - IOType.NONE, - ); - this.docs.description = 'Loads a `Table` into a PostgreSQL database sink.'; - this.docs.examples = [ - { - code: blockExampleUsage, - description: - 'A local Postgres instance is filled with table data about cars.', - }, - ]; - } -} - -const blockExampleUsage = `block CarsLoader oftype PostgresLoader { - host: "localhost"; - port: 5432; - username: "postgres"; - password: "postgres"; - database: "CarsDB"; - table: "Cars"; -}`; diff --git a/libs/extensions/rdbms/lang/src/lib/sqlite-loader-meta-information.ts b/libs/extensions/rdbms/lang/src/lib/sqlite-loader-meta-information.ts deleted file mode 100644 index 531d9fe2c..000000000 --- a/libs/extensions/rdbms/lang/src/lib/sqlite-loader-meta-information.ts +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class SQLiteLoaderMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'SQLiteLoader', - { - table: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The name of the table to write into.', - }, - }, - file: { - type: PrimitiveValuetypes.Text, - docs: { - description: - 'The path to a SQLite file that will be created if it does not exist. Usual file extensions are `.sqlite` and `.db`.', - }, - }, - dropTable: { - type: PrimitiveValuetypes.Boolean, - defaultValue: true, - docs: { - description: - 'Indicates, whether to drop the table before loading data into it. If `false`, data is appended to the table instead of dropping it.', - }, - }, - }, - IOType.TABLE, - IOType.NONE, - ); - this.docs.description = 'Loads a `Table` into a SQLite database sink.'; - this.docs.examples = [ - { - code: blockExampleUsage, - description: - 'A SQLite file `cars.db` is created in the working directory. Incoming data is written to the table `cars`.', - }, - ]; - } -} - -const blockExampleUsage = `block CarsLoader oftype SQLiteLoader { - table: "cars"; - file: "./cars.db"; -}`; diff --git a/libs/extensions/rdbms/lang/tsconfig.json b/libs/extensions/rdbms/lang/tsconfig.json deleted file mode 100644 index 4022fd4d0..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/extensions/rdbms/lang/tsconfig.json.license b/libs/extensions/rdbms/lang/tsconfig.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/tsconfig.lib.json b/libs/extensions/rdbms/lang/tsconfig.lib.json deleted file mode 100644 index 18f2d37a1..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/libs/extensions/rdbms/lang/tsconfig.lib.json.license b/libs/extensions/rdbms/lang/tsconfig.lib.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.lib.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/rdbms/lang/tsconfig.spec.json b/libs/extensions/rdbms/lang/tsconfig.spec.json deleted file mode 100644 index 6668655fc..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/libs/extensions/rdbms/lang/tsconfig.spec.json.license b/libs/extensions/rdbms/lang/tsconfig.spec.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/rdbms/lang/tsconfig.spec.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/.babelrc b/libs/extensions/std/lang/.babelrc deleted file mode 100644 index e24a5465f..000000000 --- a/libs/extensions/std/lang/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nrwl/web/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/extensions/std/lang/.babelrc.license b/libs/extensions/std/lang/.babelrc.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/.babelrc.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/.eslintrc.json b/libs/extensions/std/lang/.eslintrc.json deleted file mode 100644 index 632e9b0e2..000000000 --- a/libs/extensions/std/lang/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/extensions/std/lang/.eslintrc.json.license b/libs/extensions/std/lang/.eslintrc.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/.eslintrc.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/README.md b/libs/extensions/std/lang/README.md deleted file mode 100644 index e1798ab56..000000000 --- a/libs/extensions/std/lang/README.md +++ /dev/null @@ -1,17 +0,0 @@ - - -# extensions-std-lang - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build extensions-std-lang` to build the library. - -## Running unit tests - -Run `nx test extensions-std-lang` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/extensions/std/lang/jest.config.ts b/libs/extensions/std/lang/jest.config.ts deleted file mode 100644 index 3c56c8520..000000000 --- a/libs/extensions/std/lang/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export default { - displayName: 'extensions-std-lang', - preset: '../../../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../../../coverage/libs/extensions/std/lang', -}; diff --git a/libs/extensions/std/lang/package.json b/libs/extensions/std/lang/package.json deleted file mode 100644 index 53dfb5523..000000000 --- a/libs/extensions/std/lang/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@jvalue/jayvee-extensions/std/lang", - "type": "commonjs" -} diff --git a/libs/extensions/std/lang/package.json.license b/libs/extensions/std/lang/package.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/package.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/project.json b/libs/extensions/std/lang/project.json deleted file mode 100644 index cf1faa3d6..000000000 --- a/libs/extensions/std/lang/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "extensions-std-lang", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/extensions/std/lang/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nrwl/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/extensions/std/lang", - "main": "libs/extensions/std/lang/src/index.ts", - "tsConfig": "libs/extensions/std/lang/tsconfig.lib.json", - "assets": ["libs/extensions/std/lang/*.md"] - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/extensions/std/lang/**/*.ts"] - } - }, - "test": { - "executor": "@nrwl/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/extensions/std/lang/jest.config.ts", - "passWithNoTests": false - } - } - }, - "tags": [] -} diff --git a/libs/extensions/std/lang/project.json.license b/libs/extensions/std/lang/project.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/project.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/src/archive-interpreter-meta-inf.ts b/libs/extensions/std/lang/src/archive-interpreter-meta-inf.ts deleted file mode 100644 index 7339fbd2a..000000000 --- a/libs/extensions/std/lang/src/archive-interpreter-meta-inf.ts +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class ArchiveInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'ArchiveInterpreter', - - // Property definitions: - { - archiveType: { - type: PrimitiveValuetypes.Text, - docs: { - description: - 'The archive type to be interpreted, e.g., "zip" or "gz".', - }, - }, - }, - // Input type: - IOType.FILE, - - // Output type: - IOType.FILE_SYSTEM, - ); - this.docs.description = - 'Interprets a `File` as an archive file and converts it to a `FileSystem`. The archive file root is considered the root of the `FileSystem`.'; - - this.docs.examples = [ - { - code: `block ZipArchiveInterpreter oftype ArchiveInterpreter { - archiveType: "zip"; -}`, - description: - 'Interprets a `File` as a ZIP-archive and creates a `FileSystem` of its extracted contents.', - }, - ]; - } -} diff --git a/libs/extensions/std/lang/src/example-validation.spec.ts b/libs/extensions/std/lang/src/example-validation.spec.ts deleted file mode 100644 index c98e468c4..000000000 --- a/libs/extensions/std/lang/src/example-validation.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { readdirSync } from 'fs'; -import * as path from 'path'; - -import { - JayveeServices, - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('jv example tests', () => { - let services: JayveeServices; - let validate: (input: string) => Promise>; - - const baseDirPath = path.resolve(__dirname, '../../../../../example/'); - const readJvTestAsset = readJvTestAssetHelper(baseDirPath); - - beforeAll(() => { - // Register std extension - useExtension(new StdLangExtension()); - // Create language services - services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it.each( - // Get all .jv files from example dir - readdirSync(baseDirPath).filter((file) => path.extname(file) === '.jv'), - )('valid %s', async (file: string) => { - const text = readJvTestAsset(file); - - // Validate input - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - // Expect 0 errors - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/std/lang/src/extension.ts b/libs/extensions/std/lang/src/extension.ts deleted file mode 100644 index 407dd38c9..000000000 --- a/libs/extensions/std/lang/src/extension.ts +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { RdbmsLangExtension } from '@jvalue/jayvee-extensions/rdbms/lang'; -import { TabularLangExtension } from '@jvalue/jayvee-extensions/tabular/lang'; -import { - BlockMetaInformation, - ConstructorClass, - JayveeLangExtension, -} from '@jvalue/jayvee-language-server'; - -import { ArchiveInterpreterMetaInformation } from './archive-interpreter-meta-inf'; -import { FilePickerMetaInformation } from './file-picker-meta-inf'; -import { GtfsRTInterpreterMetaInformation } from './gtfs-rt-interpreter-meta-inf'; -import { HttpExtractorMetaInformation } from './http-extractor-meta-inf'; -import { TextFileInterpreterMetaInformation } from './text-file-interpreter-meta-inf'; -import { TextLineDeleterMetaInformation } from './text-line-deleter-meta-inf'; -import { TextRangeSelectorMetaInformation } from './text-range-selector-meta-inf'; - -export class StdLangExtension implements JayveeLangExtension { - private readonly wrappedExtensions: JayveeLangExtension[] = [ - new TabularLangExtension(), - new RdbmsLangExtension(), - ]; - - getBlockMetaInf(): Array> { - return [ - ...this.wrappedExtensions.map((x) => x.getBlockMetaInf()).flat(), - HttpExtractorMetaInformation, - TextFileInterpreterMetaInformation, - TextRangeSelectorMetaInformation, - TextLineDeleterMetaInformation, - ArchiveInterpreterMetaInformation, - FilePickerMetaInformation, - GtfsRTInterpreterMetaInformation, - ]; - } -} diff --git a/libs/extensions/std/lang/src/file-picker-meta-inf.ts b/libs/extensions/std/lang/src/file-picker-meta-inf.ts deleted file mode 100644 index df53872bd..000000000 --- a/libs/extensions/std/lang/src/file-picker-meta-inf.ts +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class FilePickerMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'FilePicker', - - // Property definitions: - { - path: { - type: PrimitiveValuetypes.Text, - docs: { - description: - 'The path of the file to select, relative to the root of the provided `FileSystem`.', - }, - }, - }, - // Input type: - IOType.FILE_SYSTEM, - - // Output type: - IOType.FILE, - ); - - this.docs.description = - 'Selects one `File` from a `FileSystem` based on its relative path to the root of the `FileSystem`. If no file matches the relative path, no output is created and the execution of the pipeline is aborted.'; - this.docs.examples = [ - { - code: `block AgencyFilePicker oftype FilePicker { - path: "./agency.txt"; -}`, - description: - 'Tries to pick the file `agency.txt` from the root of the provided `FileSystem`. If `agency.txt` exists it is passed on as `File`, if it does not exist the execution of the pipeline is aborted.', - }, - ]; - } -} diff --git a/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.spec.ts b/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.spec.ts deleted file mode 100644 index 9110e1635..000000000 --- a/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('Validation of GtfsRTInterpreterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper(__dirname, '../test/assets/'); - - beforeAll(() => { - // Register std extension - useExtension(new StdLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose no error on valid entity parameter value', async () => { - const text = readJvTestAsset( - 'gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); - - it('should diagnose error on invalid entity parameter value', async () => { - const text = readJvTestAsset( - 'gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Entity must be "trip_update", "alert" or "vehicle"', - }), - ]), - ); - }); -}); diff --git a/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.ts b/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.ts deleted file mode 100644 index 39e7cf32a..000000000 --- a/libs/extensions/std/lang/src/gtfs-rt-interpreter-meta-inf.ts +++ /dev/null @@ -1,124 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - EvaluationContext, - IOType, - PrimitiveValuetypes, - PropertyAssignment, - ValidationContext, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class GtfsRTInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'GtfsRTInterpreter', - - // Attribute definitions: - { - entity: { - type: PrimitiveValuetypes.Text, - validation: isGtfsRTEntity, - docs: { - description: `Entity to process from GTFS-RT-feed (\`trip_update\`, \`alert\` or \`vehicle\`). - We currently support following Output-Sheets, each are an equivalent to the flattened Element Index defined in (just required fields are included)): - - Entity TripUpdate: - \`\`\` - [ - 'header.gtfs_realtime_version', - 'header.timestamp', - 'header.incrementality', - 'entity.id', - 'entity.trip_update.trip.trip_id', - 'entity.trip_update.trip.route_id', - 'entity.trip_update.stop_time_update.stop_sequence', - 'entity.trip_update.stop_time_update.stop_id', - 'entity.trip_update.stop_time_update.arrival.time', - 'entity.trip_update.stop_time_update.departure.time', - ]; - - \`\`\` - Entity VehiclePosition: - \`\`\` - [ - 'header.gtfs_realtime_version', - 'header.timestamp', - 'header.incrementality', - 'entity.id', - 'entity.vehicle_position.vehicle_descriptor.id', - 'entity.vehicle_position.trip.trip_id', - 'entity.vehicle_position.trip.route_id', - 'entity.vehicle_position.position.latitude', - 'entity.vehicle_position.position.longitude', - 'entity.vehicle_position.timestamp', - ]; - \`\`\` - - Entity Alert: - \`\`\` - [ - 'header.gtfs_realtime_version', - 'header.timestamp', - 'header.incrementality', - 'entity.id', - 'entity.alert.informed_entity.route_id', - 'entity.alert.header_text', - 'entity.alert.description_text', - ]; - \`\`\` - - `, - }, - }, - }, - // Input type: - IOType.FILE, - - // Output type: - IOType.SHEET, - ); - this.docs.description = - 'Interprets an protobuf file (binary) of type `File` by decoding the file according to `gtfs-realtime.proto`. Outputs the extracted entity defined by `entity` as a `Sheet`'; - this.docs.examples = [ - { - code: blockExampleUsage, - description: - 'A file is interpretet as an GTFS-RT file, which contains TripUpdate.', - }, - ]; - } -} - -const blockExampleUsage = `block GtfsRTTripUpdateInterpreter oftype GtfsRTInterpreter{ - entity: "trip_update"; -}`; - -function isGtfsRTEntity( - property: PropertyAssignment, - validationContext: ValidationContext, - evaluationContext: EvaluationContext, -) { - const entityValue = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Text, - ); - if (entityValue === undefined) { - return; - } - - if (!['trip_update', 'alert', 'vehicle'].includes(entityValue)) { - validationContext.accept( - 'error', - `Entity must be "trip_update", "alert" or "vehicle"`, - { - node: property.value, - }, - ); - } -} diff --git a/libs/extensions/std/lang/src/http-extractor-meta-inf.ts b/libs/extensions/std/lang/src/http-extractor-meta-inf.ts deleted file mode 100644 index 1ac27dc34..000000000 --- a/libs/extensions/std/lang/src/http-extractor-meta-inf.ts +++ /dev/null @@ -1,185 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class HttpExtractorMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'HttpExtractor', - - // Property definitions: - { - url: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The URL to the file in the web to extract.', - examples: [ - { - code: 'url: "tinyurl.com/4ub9spwz"', - description: 'Specifies the URL to fetch the data from.', - }, - ], - }, - }, - retries: { - type: PrimitiveValuetypes.Integer, - defaultValue: 0, - docs: { - description: - 'Configures how many retries should be executed after a failure fetching the data.', - examples: [ - { - code: 'retries: 3', - description: - 'Executes up to 3 retries if the original retry fails (so in total max. 4 requests).', - }, - ], - }, - validation: (property, validationContext, evaluationContext) => { - const encodingValue = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Integer, - ); - if (encodingValue === undefined) { - return; - } - - if (encodingValue < 0) { - validationContext.accept( - 'error', - 'Only not negative integers allowed', - { - node: property, - property: 'value', - }, - ); - } - }, - }, - retryBackoffMilliseconds: { - type: PrimitiveValuetypes.Integer, - defaultValue: 2000, - docs: { - description: - 'Configures the wait time in milliseconds before executing a retry.', - examples: [ - { - code: 'retryBackoff: 5000', - description: 'Waits 5s (5000 ms) before executing a retry.', - }, - ], - }, - validation: (property, validationContext, evaluationContext) => { - const minBockoffValue = 1000; - - const encodingValue = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Integer, - ); - if (encodingValue === undefined) { - return; - } - - if (encodingValue < minBockoffValue) { - validationContext.accept( - 'error', - `Only integers larger or equal to ${minBockoffValue} are allowed`, - { - node: property, - property: 'value', - }, - ); - } - }, - }, - retryBackoffStrategy: { - type: PrimitiveValuetypes.Text, - defaultValue: 'exponential', - docs: { - description: - 'Configures the wait strategy before executing a retry. Can have values "exponential" or "linear".', - examples: [ - { - code: 'retryBackoffStrategy: "linear"', - description: - 'Waits always the same amount of time before executing a retry.', - }, - { - code: 'retryBackoffStrategy: "exponential"', - description: - 'Exponentially increases the wait time before executing a retry.', - }, - ], - }, - validation: (property, validationContext, evaluationContext) => { - const allowedValues = ['exponential', 'linear']; - - const encodingValue = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Text, - ); - if (encodingValue === undefined) { - return; - } - - if (!allowedValues.includes(encodingValue)) { - validationContext.accept( - 'error', - `Only the following values are allowed: ${allowedValues - .map((v) => `"${v}"`) - .join(', ')}`, - { - node: property, - property: 'value', - }, - ); - } - }, - }, - followRedirects: { - type: PrimitiveValuetypes.Boolean, - defaultValue: true, - docs: { - description: - 'Indicates, whether to follow redirects on get requests. If `false`, redirects are not followed. Default `true`', - examples: [ - { - code: 'url: "tinyurl.com/4ub9spwz" \n followRedirects: true', - description: - 'Specifies the URL to fetch the data from and allows redirects.', - }, - ], - }, - }, - }, - - // Input type: - IOType.NONE, - - // Output type: - IOType.FILE, - ); - this.docs.description = 'Extracts a `File` from the web.'; - this.docs.examples = [ - { - code: blockExampleUsage, - description: 'Fetches a file from the given URL.', - }, - ]; - } -} - -const blockExampleUsage = `block CarsFileExtractor oftype HttpExtractor { - url: "tinyurl.com/4ub9spwz"; -}`; diff --git a/libs/extensions/std/lang/src/index.ts b/libs/extensions/std/lang/src/index.ts deleted file mode 100644 index 88d3a0045..000000000 --- a/libs/extensions/std/lang/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export * from './extension'; diff --git a/libs/extensions/std/lang/src/meta-inf-example-validation.spec.ts b/libs/extensions/std/lang/src/meta-inf-example-validation.spec.ts deleted file mode 100644 index 26a7cd554..000000000 --- a/libs/extensions/std/lang/src/meta-inf-example-validation.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockDefinition, - BlockMetaInformation, - IOType, - JayveeServices, - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - ParseHelperOptions, - TestLangExtension, - ValidationResult, - expectNoParserAndLexerErrors, - getTestExtensionBlockForIOType, - parseHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode, AstNodeLocator, LangiumDocument } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('Validation of builtin examples of BlockMetaInformation', () => { - let services: JayveeServices; - let parse: ( - input: string, - options?: ParseHelperOptions, - ) => Promise>; - let validate: (input: string) => Promise>; - - let locator: AstNodeLocator; - - const testExtension = new TestLangExtension(); - const stdExtension = new StdLangExtension(); - - function generateBlockWithPipeForIOType( - io: IOType, - ioType: 'input' | 'output', - blockName: string, - ): string { - const ioBlockMetaInf = getTestExtensionBlockForIOType( - testExtension, - io, - ioType, - ); - // Generate block - const ioBlockName = - ioType === 'input' ? 'TestLoaderBlock' : 'TestExtractorBlock'; - const ioBlock = `block ${ioBlockName} oftype ${ioBlockMetaInf.type} {}`; - // generate pipe - const pipe = - ioType === 'input' - ? `${blockName} -> ${ioBlockName};` - : `${ioBlockName} -> ${blockName};`; - return `\n${ioBlock}\n${pipe}`; - } - - async function getBlockNameFromExample( - blockExample: string, - ): Promise { - const parsedExample = await parse(`pipeline Test {${blockExample}}`); - expectNoParserAndLexerErrors(parsedExample); - return ( - locator.getAstNode( - parsedExample.parseResult.value, - 'pipelines@0/blocks@0', - ) as BlockDefinition - ).name; - } - - async function generateFullJvExample( - blockMetaInf: BlockMetaInformation, - blockExample: string, - ): Promise { - const blockName = await getBlockNameFromExample(blockExample); - - let pipelineContent = `${blockExample}`; - // Generate extractor block and pipe - if (blockMetaInf.hasInput()) { - pipelineContent += generateBlockWithPipeForIOType( - blockMetaInf.inputType, - 'output', - blockName, - ); - } - // Generate loader block and pipe - if (blockMetaInf.hasOutput()) { - pipelineContent += generateBlockWithPipeForIOType( - blockMetaInf.outputType, - 'input', - blockName, - ); - } - return `pipeline Test { - ${pipelineContent} - }`; - } - - beforeAll(() => { - // Register test extension - useExtension(testExtension); - // Register std extension - useExtension(stdExtension); - // Create language services - services = createJayveeServices(NodeFileSystem).Jayvee; - locator = services.workspace.AstNodeLocator; - // Create validation helper for language services - validate = validationHelper(services); - // Parse function for Jayvee (without validation) - parse = parseHelper(services); - }); - - it.each( - stdExtension.getBlockMetaInf().map((metaInfClass) => { - const metaInf = new metaInfClass(); - return [metaInf.type, metaInf]; - }), - )( - 'should have no error on %s example validation', - async (type, blockMetaInf) => { - for (const example of blockMetaInf.docs.examples ?? []) { - const text = await generateFullJvExample(blockMetaInf, example.code); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - } - }, - ); -}); diff --git a/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.spec.ts b/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.spec.ts deleted file mode 100644 index 60c7fbd4d..000000000 --- a/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('Validation of TextFileInterpreterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper(__dirname, '../test/assets/'); - - beforeAll(() => { - // Register std extension - useExtension(new StdLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on invalid encoding parameter value', async () => { - const text = readJvTestAsset( - 'text-file-interpreter-meta-inf/invalid-invalid-encoding-param.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Unknown encoding "invalid"', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'text-file-interpreter-meta-inf/valid-utf8-encoding.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.ts b/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.ts deleted file mode 100644 index c5789ba78..000000000 --- a/libs/extensions/std/lang/src/text-file-interpreter-meta-inf.ts +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { TextDecoder } from 'util'; - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class TextFileInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'TextFileInterpreter', - { - encoding: { - type: PrimitiveValuetypes.Text, - defaultValue: 'utf-8', - docs: { - description: 'The encoding used for decoding the file contents.', - }, - validation: (property, validationContext, evaluationContext) => { - const encodingValue = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Text, - ); - if (encodingValue === undefined) { - return; - } - - try { - new TextDecoder(encodingValue); - } catch (error) { - validationContext.accept( - 'error', - `Unknown encoding "${encodingValue}"`, - { - node: property.value, - }, - ); - } - }, - }, - lineBreak: { - type: PrimitiveValuetypes.Regex, - defaultValue: /\r?\n/, - docs: { - description: 'The regex for identifying line breaks.', - }, - }, - }, - // Input type: - IOType.FILE, - - // Output type: - IOType.TEXT_FILE, - ); - this.docs.description = 'Interprets a `File` as a `TextFile`.'; - } -} diff --git a/libs/extensions/std/lang/src/text-line-deleter-meta-inf.spec.ts b/libs/extensions/std/lang/src/text-line-deleter-meta-inf.spec.ts deleted file mode 100644 index eeacaf4e2..000000000 --- a/libs/extensions/std/lang/src/text-line-deleter-meta-inf.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('Validation of TextLineDeleterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper(__dirname, '../test/assets/'); - - beforeAll(() => { - // Register std extension - useExtension(new StdLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on line parameter less or equal to zero', async () => { - const text = readJvTestAsset( - 'text-line-deleter-meta-inf/invalid-line-less-or-equal-zero.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(3); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Line numbers need to be greater than zero', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'text-line-deleter-meta-inf/valid-postive-line-number.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/std/lang/src/text-line-deleter-meta-inf.ts b/libs/extensions/std/lang/src/text-line-deleter-meta-inf.ts deleted file mode 100644 index 2f36d3078..000000000 --- a/libs/extensions/std/lang/src/text-line-deleter-meta-inf.ts +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class TextLineDeleterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'TextLineDeleter', - { - lines: { - type: new CollectionValuetype(PrimitiveValuetypes.Integer), - validation: (property, validationContext, evaluationContext) => { - const lines = evaluatePropertyValue( - property, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.Integer), - ); - lines?.forEach((value, index) => { - if (value <= 0) { - validationContext.accept( - 'error', - `Line numbers need to be greater than zero`, - { - node: property.value, - property: 'values', - index: index, - }, - ); - } - }); - }, - docs: { - description: 'The line numbers to delete.', - }, - }, - }, - // Input type: - IOType.TEXT_FILE, - - // Output type: - IOType.TEXT_FILE, - ); - this.docs.description = 'Deletes individual lines from a `TextFile`.'; - } -} diff --git a/libs/extensions/std/lang/src/text-range-selector-meta-inf.spec.ts b/libs/extensions/std/lang/src/text-range-selector-meta-inf.spec.ts deleted file mode 100644 index d0fdd645d..000000000 --- a/libs/extensions/std/lang/src/text-range-selector-meta-inf.spec.ts +++ /dev/null @@ -1,101 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { StdLangExtension } from './extension'; - -describe('Validation of TextRangeSelectorMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper(__dirname, '../test/assets/'); - - beforeAll(() => { - // Register std extension - useExtension(new StdLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on lineFrom parameter less or equal to zero', async () => { - const text = readJvTestAsset( - 'text-range-selector-meta-inf/invalid-lineFrom-less-or-equal-zero.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Line numbers need to be greater than zero', - }), - ]), - ); - }); - - it('should diagnose error on lineTo parameter less or equal to zero', async () => { - const text = readJvTestAsset( - 'text-range-selector-meta-inf/invalid-lineTo-less-or-equal-zero.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(2); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Line numbers need to be greater than zero', - }), - ]), - ); - }); - - it('should diagnose error on lineFrom > lineTo', async () => { - const text = readJvTestAsset( - 'text-range-selector-meta-inf/invalid-lineFrom-greater-lineTo.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(2); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: - 'The lower line number needs to be smaller or equal to the upper line number', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'text-range-selector-meta-inf/valid-correct-range.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/std/lang/src/text-range-selector-meta-inf.ts b/libs/extensions/std/lang/src/text-range-selector-meta-inf.ts deleted file mode 100644 index 80a618cc8..000000000 --- a/libs/extensions/std/lang/src/text-range-selector-meta-inf.ts +++ /dev/null @@ -1,101 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - EvaluationContext, - IOType, - PrimitiveValuetypes, - PropertyAssignment, - ValidationContext, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class TextRangeSelectorMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'TextRangeSelector', - { - lineFrom: { - type: PrimitiveValuetypes.Integer, - defaultValue: 1, - validation: greaterThanZeroValidation, - }, - lineTo: { - type: PrimitiveValuetypes.Integer, - defaultValue: Number.POSITIVE_INFINITY, - validation: greaterThanZeroValidation, - }, - }, - // Input type: - IOType.TEXT_FILE, - - // Output type: - IOType.TEXT_FILE, - - (propertyBody, validationContext, evaluationContext) => { - const lineFromProperty = propertyBody.properties.find( - (p) => p.name === 'lineFrom', - ); - const lineToProperty = propertyBody.properties.find( - (p) => p.name === 'lineTo', - ); - - if (lineFromProperty === undefined || lineToProperty === undefined) { - return; - } - - const lineFrom = evaluatePropertyValue( - lineFromProperty, - evaluationContext, - PrimitiveValuetypes.Integer, - ); - const lineTo = evaluatePropertyValue( - lineToProperty, - evaluationContext, - PrimitiveValuetypes.Integer, - ); - if (lineFrom === undefined || lineTo === undefined) { - return; - } - - if (lineFrom > lineTo) { - [lineFromProperty, lineToProperty].forEach((property) => { - validationContext.accept( - 'error', - 'The lower line number needs to be smaller or equal to the upper line number', - { node: property.value }, - ); - }); - } - }, - ); - this.docs.description = 'Selects a range of lines from a `TextFile`.'; - } -} - -function greaterThanZeroValidation( - property: PropertyAssignment, - validationContext: ValidationContext, - evaluationContext: EvaluationContext, -) { - const value = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.Integer, - ); - if (value === undefined) { - return; - } - - if (value <= 0) { - validationContext.accept( - 'error', - `Line numbers need to be greater than zero`, - { - node: property.value, - }, - ); - } -} diff --git a/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv b/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv deleted file mode 100644 index abcdd2705..000000000 --- a/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/invalid-invalid-entity-param.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype GtfsRTInterpreter { - entity: 'invalid'; - } - - block TestExtractor oftype TestFileExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv b/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv deleted file mode 100644 index 98acd3a98..000000000 --- a/libs/extensions/std/lang/test/assets/gtfs-rt-interpreter-meta-inf/valid-valid-entity-param.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype GtfsRTInterpreter { - entity: 'alert'; - } - - block TestExtractor oftype TestFileExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/invalid-invalid-encoding-param.jv b/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/invalid-invalid-encoding-param.jv deleted file mode 100644 index 4a9dbe87b..000000000 --- a/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/invalid-invalid-encoding-param.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextFileInterpreter { - encoding: 'invalid'; - } - - block TestExtractor oftype TestFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/valid-utf8-encoding.jv b/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/valid-utf8-encoding.jv deleted file mode 100644 index 7537150f1..000000000 --- a/libs/extensions/std/lang/test/assets/text-file-interpreter-meta-inf/valid-utf8-encoding.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextFileInterpreter { - encoding: 'utf8'; - } - - block TestExtractor oftype TestFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/invalid-line-less-or-equal-zero.jv b/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/invalid-line-less-or-equal-zero.jv deleted file mode 100644 index 68f2df265..000000000 --- a/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/invalid-line-less-or-equal-zero.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextLineDeleter { - lines: [2,3,0,-1,-20]; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/valid-postive-line-number.jv b/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/valid-postive-line-number.jv deleted file mode 100644 index fc7709419..000000000 --- a/libs/extensions/std/lang/test/assets/text-line-deleter-meta-inf/valid-postive-line-number.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextLineDeleter { - lines: [2,3]; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-greater-lineTo.jv b/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-greater-lineTo.jv deleted file mode 100644 index cdd0a588c..000000000 --- a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-greater-lineTo.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextRangeSelector { - lineFrom: 10; - lineTo: 1; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-less-or-equal-zero.jv b/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-less-or-equal-zero.jv deleted file mode 100644 index 6bce31112..000000000 --- a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineFrom-less-or-equal-zero.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextRangeSelector { - lineFrom: -1; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineTo-less-or-equal-zero.jv b/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineTo-less-or-equal-zero.jv deleted file mode 100644 index bcb03507e..000000000 --- a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/invalid-lineTo-less-or-equal-zero.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextRangeSelector { - lineFrom: -2; - lineTo: -1; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/valid-correct-range.jv b/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/valid-correct-range.jv deleted file mode 100644 index 3359596c0..000000000 --- a/libs/extensions/std/lang/test/assets/text-range-selector-meta-inf/valid-correct-range.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TextRangeSelector { - lineFrom: 1; - lineTo: 2; - } - - block TestExtractor oftype TestTextFileExtractor { - } - - block TestLoader oftype TestTextFileLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/std/lang/tsconfig.json b/libs/extensions/std/lang/tsconfig.json deleted file mode 100644 index 4022fd4d0..000000000 --- a/libs/extensions/std/lang/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/extensions/std/lang/tsconfig.json.license b/libs/extensions/std/lang/tsconfig.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/tsconfig.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/tsconfig.lib.json b/libs/extensions/std/lang/tsconfig.lib.json deleted file mode 100644 index 18f2d37a1..000000000 --- a/libs/extensions/std/lang/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/libs/extensions/std/lang/tsconfig.lib.json.license b/libs/extensions/std/lang/tsconfig.lib.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/tsconfig.lib.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/std/lang/tsconfig.spec.json b/libs/extensions/std/lang/tsconfig.spec.json deleted file mode 100644 index 6668655fc..000000000 --- a/libs/extensions/std/lang/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/libs/extensions/std/lang/tsconfig.spec.json.license b/libs/extensions/std/lang/tsconfig.spec.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/std/lang/tsconfig.spec.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/.babelrc b/libs/extensions/tabular/lang/.babelrc deleted file mode 100644 index e24a5465f..000000000 --- a/libs/extensions/tabular/lang/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - [ - "@nrwl/web/babel", - { - "useBuiltIns": "usage" - } - ] - ] -} diff --git a/libs/extensions/tabular/lang/.babelrc.license b/libs/extensions/tabular/lang/.babelrc.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/.babelrc.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/.eslintrc.json b/libs/extensions/tabular/lang/.eslintrc.json deleted file mode 100644 index 632e9b0e2..000000000 --- a/libs/extensions/tabular/lang/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/extensions/tabular/lang/.eslintrc.json.license b/libs/extensions/tabular/lang/.eslintrc.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/.eslintrc.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/README.md b/libs/extensions/tabular/lang/README.md deleted file mode 100644 index da66460c6..000000000 --- a/libs/extensions/tabular/lang/README.md +++ /dev/null @@ -1,17 +0,0 @@ - - -# extensions-tabular-lang - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build extensions-tabular-lang` to build the library. - -## Running unit tests - -Run `nx test extensions-tabular-lang` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/extensions/tabular/lang/jest.config.ts b/libs/extensions/tabular/lang/jest.config.ts deleted file mode 100644 index bdeda4338..000000000 --- a/libs/extensions/tabular/lang/jest.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export default { - displayName: 'extensions-tabular-lang', - preset: '../../../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../../../coverage/libs/extensions/tabular/lang', -}; diff --git a/libs/extensions/tabular/lang/package.json b/libs/extensions/tabular/lang/package.json deleted file mode 100644 index 1c495c53a..000000000 --- a/libs/extensions/tabular/lang/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@jvalue/jayvee-extensions/tabular/lang", - "type": "commonjs" -} diff --git a/libs/extensions/tabular/lang/package.json.license b/libs/extensions/tabular/lang/package.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/package.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/project.json b/libs/extensions/tabular/lang/project.json deleted file mode 100644 index 287c6e5ce..000000000 --- a/libs/extensions/tabular/lang/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "extensions-tabular-lang", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/extensions/tabular/lang/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nrwl/js:tsc", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/extensions/tabular/lang", - "main": "libs/extensions/tabular/lang/src/index.ts", - "tsConfig": "libs/extensions/tabular/lang/tsconfig.lib.json", - "assets": ["libs/extensions/tabular/lang/*.md"] - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/extensions/tabular/lang/**/*.ts"] - } - }, - "test": { - "executor": "@nrwl/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/extensions/tabular/lang/jest.config.ts", - "passWithNoTests": false - } - } - }, - "tags": [] -} diff --git a/libs/extensions/tabular/lang/project.json.license b/libs/extensions/tabular/lang/project.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/project.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/src/extension.ts b/libs/extensions/tabular/lang/src/extension.ts deleted file mode 100644 index 959be5362..000000000 --- a/libs/extensions/tabular/lang/src/extension.ts +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - ConstructorClass, - JayveeLangExtension, -} from '@jvalue/jayvee-language-server'; - -import { CellRangeSelectorMetaInformation } from './lib/cell-range-selector-meta-inf'; -import { CellWriterMetaInformation } from './lib/cell-writer-meta-inf'; -import { ColumnDeleterMetaInformation } from './lib/column-deleter-meta-inf'; -import { CSVInterpreterMetaInformation } from './lib/csv-interpreter-meta-inf'; -import { RowDeleterMetaInformation } from './lib/row-deleter-meta-inf'; -import { SheetPickerMetaInformation } from './lib/sheet-picker-meta-inf'; -import { TableInterpreterMetaInformation } from './lib/table-interpreter-meta-inf'; -import { TableTransformerMetaInformation } from './lib/table-transformer-meta-inf'; -import { XLSXInterpreterMetaInformation } from './lib/xlsx-interpreter-meta-inf'; - -export class TabularLangExtension implements JayveeLangExtension { - getBlockMetaInf(): Array> { - return [ - ColumnDeleterMetaInformation, - RowDeleterMetaInformation, - CellRangeSelectorMetaInformation, - CellWriterMetaInformation, - TableInterpreterMetaInformation, - CSVInterpreterMetaInformation, - TableTransformerMetaInformation, - XLSXInterpreterMetaInformation, - SheetPickerMetaInformation, - ]; - } -} diff --git a/libs/extensions/tabular/lang/src/index.ts b/libs/extensions/tabular/lang/src/index.ts deleted file mode 100644 index 88d3a0045..000000000 --- a/libs/extensions/tabular/lang/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -export * from './extension'; diff --git a/libs/extensions/tabular/lang/src/lib/cell-range-selector-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/cell-range-selector-meta-inf.ts deleted file mode 100644 index fc732c994..000000000 --- a/libs/extensions/tabular/lang/src/lib/cell-range-selector-meta-inf.ts +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class CellRangeSelectorMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'CellRangeSelector', - { - select: { - type: PrimitiveValuetypes.CellRange, - docs: { - description: 'The cell range to select.', - examples: [ - { - code: 'select: range A1:E*', - description: - 'Select cells from `A1` to the last cell of column `E`.', - }, - ], - }, - }, - }, - IOType.SHEET, - IOType.SHEET, - ); - this.docs.description = - 'Selects a subset of a `Sheet` to produce a new `Sheet`.'; - this.docs.examples = [ - { - code: blockExample, - description: - 'Selects the cells in the given range and produces a new `Sheet` containing only the selected cells.', - }, - ]; - } -} - -const blockExample = `block CarsCoreDataSelector oftype CellRangeSelector { - select: range A1:E*; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.spec.ts deleted file mode 100644 index 10413f0b8..000000000 --- a/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of CellWriterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on wrong dimension for at parameter', async () => { - const text = readJvTestAsset( - 'cell-writer-meta-inf/invalid-wrong-at-dimension.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'The cell range needs to be one-dimensional', - }), - ]), - ); - }); - - it('should diagnose error on number of write values does not match cell range', async () => { - const text = readJvTestAsset( - 'cell-writer-meta-inf/invalid-write-length-does-not-match-cell-range.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(2); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: - 'The number of values to write (3) does not match the number of cells (4)', - }), - expect.objectContaining({ - message: - 'The number of values to write (3) does not match the number of cells (4)', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'cell-writer-meta-inf/valid-range-matches-array-length.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.ts deleted file mode 100644 index 04cadb699..000000000 --- a/libs/extensions/tabular/lang/src/lib/cell-writer-meta-inf.ts +++ /dev/null @@ -1,137 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class CellWriterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'CellWriter', - { - write: { - type: new CollectionValuetype(PrimitiveValuetypes.Text), - docs: { - description: 'The values to write.', - examples: [ - { - code: 'write: ["Name"]', - description: 'Write the value "Name" into the cell.', - }, - { - code: 'write: ["Name1", "Name2"]', - description: - 'Write the value "Name1" into the first cell and "Name2 into the second.', - }, - ], - }, - }, - at: { - type: PrimitiveValuetypes.CellRange, - validation: (property, validationContext, evaluationContext) => { - const cellRange = evaluatePropertyValue( - property, - evaluationContext, - PrimitiveValuetypes.CellRange, - ); - if (cellRange === undefined) { - return; - } - - if (!cellRange.isOneDimensional()) { - validationContext.accept( - 'error', - 'The cell range needs to be one-dimensional', - { - node: cellRange.astNode, - }, - ); - } - }, - docs: { - description: 'The cells to write into.', - examples: [ - { - code: 'at: cell A1', - description: 'Write into cell A1.', - }, - { - code: 'at: range A1:A3', - description: 'Write into cells A1, A2 and A3.', - }, - ], - validation: 'Needs to be a one-dimensional range of cells.', - }, - }, - }, - IOType.SHEET, - IOType.SHEET, - (propertyBody, validationContext, evaluationContext) => { - const writeProperty = propertyBody.properties.find( - (p) => p.name === 'write', - ); - const atProperty = propertyBody.properties.find((p) => p.name === 'at'); - - if (writeProperty === undefined || atProperty === undefined) { - return; - } - - const writeValues = evaluatePropertyValue( - writeProperty, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.Text), - ); - - const atValue = evaluatePropertyValue( - atProperty, - evaluationContext, - PrimitiveValuetypes.CellRange, - ); - - if (writeValues === undefined || atValue === undefined) { - return; - } - - const numberOfValuesToWrite = writeValues.length; - const numberOfCells = atValue.numberOfCells(); - - if (numberOfCells !== numberOfValuesToWrite) { - [writeProperty, atProperty].forEach((propertyNode) => { - validationContext.accept( - 'warning', - `The number of values to write (${numberOfValuesToWrite}) does not match the number of cells (${numberOfCells})`, - { node: propertyNode.value }, - ); - }); - } - }, - ); - this.docs.description = - 'Writes textual values into cells of a `Sheet`. The number of text values needs to match the number of cells to write into.'; - this.docs.examples = [ - { - code: blockExampleSingleCell, - description: 'Write the value "Name" into cell `A1`.', - }, - { - code: blockExampleCellRange, - description: 'Write the values "Name", "Age" into cells `A1` and `A2`.', - }, - ]; - } -} - -const blockExampleSingleCell = `block NameHeaderWriter oftype CellWriter { - at: cell A1; - write: ["Name"]; -}`; -const blockExampleCellRange = `block HeaderSequenceWriter oftype CellWriter { - at: range A1:A2; - write: ["Name", "Age"]; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.spec.ts deleted file mode 100644 index 0875860f4..000000000 --- a/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of ColumnDeleterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on deleting partial column', async () => { - const text = readJvTestAsset( - 'column-deleter-meta-inf/invalid-partial-column-delete.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'An entire column needs to be selected', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'column-deleter-meta-inf/valid-column-delete.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.ts deleted file mode 100644 index 45b90d152..000000000 --- a/libs/extensions/tabular/lang/src/lib/column-deleter-meta-inf.ts +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, - isColumnWrapper, -} from '@jvalue/jayvee-language-server'; - -export class ColumnDeleterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'ColumnDeleter', - { - delete: { - type: new CollectionValuetype(PrimitiveValuetypes.CellRange), - validation: (property, validationContext, evaluationContext) => { - const cellRanges = evaluatePropertyValue( - property, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.CellRange), - ); - - cellRanges?.forEach((cellRange) => { - if (!isColumnWrapper(cellRange)) { - validationContext.accept( - 'error', - 'An entire column needs to be selected', - { - node: cellRange.astNode, - }, - ); - } - }); - }, - docs: { - description: 'The columns to delete.', - examples: [ - { - code: 'delete: [column B]', - description: 'Delete column B.', - }, - { - code: 'delete: [column B, column C]', - description: 'Delete column B and column C.', - }, - ], - validation: 'You need to specify at least one column.', - }, - }, - }, - IOType.SHEET, - IOType.SHEET, - ); - this.docs.description = - 'Deletes columns from a `Sheet`. Column IDs of subsequent columns will be shifted accordingly, so there will be no gaps.'; - this.docs.examples = [ - { - code: blockExample, - description: 'Deletes column B (i.e. the second column).', - }, - ]; - } -} - -const blockExample = `block MpgColumnDeleter oftype ColumnDeleter { - delete: [column B]; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/csv-interpreter-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/csv-interpreter-meta-inf.ts deleted file mode 100644 index 34b900c1b..000000000 --- a/libs/extensions/tabular/lang/src/lib/csv-interpreter-meta-inf.ts +++ /dev/null @@ -1,69 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class CSVInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'CSVInterpreter', - // Property definitions: - { - delimiter: { - type: PrimitiveValuetypes.Text, - defaultValue: ',', - docs: { - description: 'The delimiter for values in the CSV file.', - examples: [ - { - code: 'delimiter: ","', - description: - 'Commas are used to separate values in the CSV file.', - }, - ], - }, - }, - enclosing: { - type: PrimitiveValuetypes.Text, - defaultValue: '', - docs: { - description: - 'The enclosing character that may be used for values in the CSV file.', - }, - }, - enclosingEscape: { - type: PrimitiveValuetypes.Text, - defaultValue: '', - docs: { - description: - 'The character to escape enclosing characters in values.', - }, - }, - }, - // Input type: - IOType.TEXT_FILE, - - // Output type: - IOType.SHEET, - ); - - this.docs.description = - 'Interprets an input file as a csv-file containing string-values delimited by `delimiter` and outputs a `Sheet`.'; - this.docs.examples = [ - { - code: blockExample, - description: - 'Interprets an input file as a csv-file containing string-values delimited by `;` and outputs `Sheet`.', - }, - ]; - } -} -const blockExample = `block AgencyCSVInterpreter oftype CSVInterpreter { - delimiter: ";"; - }`; diff --git a/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.spec.ts deleted file mode 100644 index 4ec568451..000000000 --- a/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of RowDeleterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on deleting partial row', async () => { - const text = readJvTestAsset( - 'row-deleter-meta-inf/invalid-partial-row-delete.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'An entire row needs to be selected', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset('row-deleter-meta-inf/valid-row-delete.jv'); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.ts deleted file mode 100644 index 43aae44c1..000000000 --- a/libs/extensions/tabular/lang/src/lib/row-deleter-meta-inf.ts +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - IOType, - PrimitiveValuetypes, - evaluatePropertyValue, - isRowWrapper, -} from '@jvalue/jayvee-language-server'; - -export class RowDeleterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'RowDeleter', - { - delete: { - type: new CollectionValuetype(PrimitiveValuetypes.CellRange), - validation: (property, validationContext, evaluationContext) => { - const cellRanges = evaluatePropertyValue( - property, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.CellRange), - ); - - cellRanges?.forEach((cellRange) => { - if (!isRowWrapper(cellRange)) { - validationContext.accept( - 'error', - 'An entire row needs to be selected', - { - node: cellRange.astNode, - }, - ); - } - }); - }, - docs: { - description: 'The rows to delete.', - examples: [ - { - code: 'delete: [row 2]', - description: 'Delete row 2.', - }, - { - code: 'delete: [row 2, row 3]', - description: 'Delete row 2 and row 3.', - }, - ], - validation: 'You need to specify at least one row.', - }, - }, - }, - IOType.SHEET, - IOType.SHEET, - ); - - this.docs.description = - 'Deletes one or more rows from a `Sheet`. Row IDs of subsequent rows will be shifted accordingly, so there will be no gaps.'; - this.docs.examples = [ - { - code: blockExample, - description: 'Deletes row 2 (i.e. the second row).', - }, - ]; - } -} - -const blockExample = `block SecondRowDeleter oftype RowDeleter { - delete: [row 2]; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.spec.ts deleted file mode 100644 index 5ef6bb7ff..000000000 --- a/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of SheetPickerMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on missing parameters', async () => { - const text = readJvTestAsset( - 'sheet-picker-meta-inf/invalid-sheet-picker-missing-parameter.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'The following required properties are missing: "sheetName"', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'sheet-picker-meta-inf/valid-correct-sheet-picker.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.ts deleted file mode 100644 index 518560040..000000000 --- a/libs/extensions/tabular/lang/src/lib/sheet-picker-meta-inf.ts +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - IOType, - PrimitiveValuetypes, -} from '@jvalue/jayvee-language-server'; - -export class SheetPickerMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'SheetPicker', - // Property definitions: - { - sheetName: { - type: PrimitiveValuetypes.Text, - docs: { - description: 'The name of the sheet to select.', - }, - }, - }, - // Input type: - IOType.WORKBOOK, - - // Output type: - IOType.SHEET, - ); - - this.docs.description = - 'Selects one `Sheet` from a `Workbook` based on its `sheetName`. If no sheet matches the name, no output is created and the execution of the pipeline is aborted.'; - this.docs.examples = [ - { - code: `block AgencySheetPicker oftype SheetPicker { - sheetName: "AgencyNames"; -}`, - description: - 'Tries to pick the sheet `AgencyNames` from the provided `Workbook`. If `AgencyNames` exists it is passed on as `Sheet`, if it does not exist the execution of the pipeline is aborted.', - }, - ]; - } -} diff --git a/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.spec.ts deleted file mode 100644 index 0ad7f640c..000000000 --- a/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.spec.ts +++ /dev/null @@ -1,70 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of TableInterpreterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on non unique column names', async () => { - const text = readJvTestAsset( - 'table-interpreter-meta-inf/invalid-non-unique-column-names.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(2); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'The column name "name" needs to be unique.', - }), - expect.objectContaining({ - message: 'The column name "name" needs to be unique.', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'table-interpreter-meta-inf/valid-correct-table.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.ts deleted file mode 100644 index 15c514131..000000000 --- a/libs/extensions/tabular/lang/src/lib/table-interpreter-meta-inf.ts +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - IOType, - PrimitiveValuetypes, - checkUniqueNames, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class TableInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'TableInterpreter', - { - header: { - type: PrimitiveValuetypes.Boolean, - docs: { - description: - 'Whether the first row should be interpreted as header row.', - examples: [ - { - code: 'header: true', - description: - 'The first row is interpreted as table header. The values in the header row will become the column names of the table.', - }, - { - code: 'header: false', - description: - 'The first row is NOT interpreted as table header and columns of the sheet are directly mapped to table columns. The column names are taken form the provided names in the `columns` property.', - }, - ], - }, - }, - columns: { - type: new CollectionValuetype( - PrimitiveValuetypes.ValuetypeAssignment, - ), - validation: (property, validationContext, evaluationContext) => { - const valuetypeAssignments = evaluatePropertyValue( - property, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.ValuetypeAssignment), - ); - if (valuetypeAssignments === undefined) { - return; - } - - checkUniqueNames(valuetypeAssignments, validationContext, 'column'); - }, - docs: { - description: - 'Collection of valuetype assignments. Uses column names (potentially matched with the header or by sequence depending on the `header` property) to assign a primitive valuetype to each column.', - examples: [ - { - code: 'columns: [ "name" oftype text ]', - description: - 'There is one column with the header "name". All values in this colum are typed as text.', - }, - ], - validation: - 'Needs to be a collection of valuetype assignments. Each column needs to have a unique name.', - }, - }, - }, - IOType.SHEET, - IOType.TABLE, - ); - this.docs.description = - 'Interprets a `Sheet` as a `Table`. In case a header row is present in the sheet, its names can be matched with the provided column names. Otherwise, the provided column names are assigned in order.'; - this.docs.examples = [ - { - code: blockExampleWithHeader, - description: - 'Interprets a `Sheet` about cars with a topmost header row and interprets it as a `Table` by assigning a primitive valuetype to each column. The column names are matched to the header, so the order of the type assignments does not matter.', - }, - { - code: blockExampleWithoutHeader, - description: - 'Interprets a `Sheet` about cars without a topmost header row and interprets it as a `Table` by sequentially assigning a name and a primitive valuetype to each column of the sheet. Note that the order of columns matters here. The first column (column `A`) will be named "name", the second column (column `B`) will be named "mpg" etc.', - }, - ]; - } -} - -const blockExampleWithHeader = `block CarsTableInterpreter oftype TableInterpreter { - header: true; - columns: [ - "name" oftype text, - "mpg" oftype decimal, - "cyl" oftype integer, - ]; -}`; - -const blockExampleWithoutHeader = `block CarsTableInterpreter oftype TableInterpreter { - header: false; - columns: [ - "name" oftype text, - "mpg" oftype decimal, - "cyl" oftype integer, - ]; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.spec.ts deleted file mode 100644 index 6f4fff372..000000000 --- a/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of TableTransformerMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose error on number of input columns do not match transform input ports', async () => { - const text = readJvTestAsset( - 'table-transformer-meta-inf/invalid-input-columns-transform-port-missmatch.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(1); - expect(diagnostics).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - message: 'Expected 1 columns but only got 2', - }), - ]), - ); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'table-transformer-meta-inf/valid-correct-ports.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.ts deleted file mode 100644 index 43b25a193..000000000 --- a/libs/extensions/tabular/lang/src/lib/table-transformer-meta-inf.ts +++ /dev/null @@ -1,149 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - BlockMetaInformation, - CollectionValuetype, - EvaluationContext, - IOType, - PrimitiveValuetypes, - PropertyBody, - ValidationContext, - evaluatePropertyValue, -} from '@jvalue/jayvee-language-server'; - -export class TableTransformerMetaInformation extends BlockMetaInformation { - constructor() { - super( - 'TableTransformer', - { - inputColumns: { - type: new CollectionValuetype(PrimitiveValuetypes.Text), - docs: { - description: - "The names of the input columns. The columns have to be present in the table and match with the transform's input port types.", - }, - }, - outputColumn: { - type: PrimitiveValuetypes.Text, - docs: { - description: - 'The name of the output column. Overwrites the column if it already exists, or otherwise creates a new one.', - }, - }, - use: { - type: PrimitiveValuetypes.Transform, - docs: { - description: - 'Reference to the transform that is applied to the column.', - }, - }, - }, - IOType.TABLE, - IOType.TABLE, - (property, validationContext, evaluationContext) => { - this.checkInputColumnsMatchTransformationPorts( - property, - validationContext, - evaluationContext, - ); - }, - ); - this.docs = { - description: - 'Applies a transform on each value of a column. The input port type of the used transform has to match the type of the input column.', - examples: [ - { - description: - 'Given a column "temperature" with temperature values in Celsius, it overwrites the column with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model.', - code: blockExampleOverwrite, - }, - { - description: - 'Given a column "temperatureCelsius" with temperature values in Celsius, it adds a new column "temperatureFahrenheit" with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model.', - code: blockExampleNewCol, - }, - ], - }; - } - - private checkInputColumnsMatchTransformationPorts( - body: PropertyBody, - validationContext: ValidationContext, - evaluationContext: EvaluationContext, - ): void { - const useProperty = body.properties.find((x) => x.name === 'use'); - const inputColumnsProperty = body.properties.find( - (x) => x.name === 'inputColumns', - ); - - if (useProperty === undefined || inputColumnsProperty === undefined) { - return; - } - - const transform = evaluatePropertyValue( - useProperty, - evaluationContext, - PrimitiveValuetypes.Transform, - ); - const inputColumns = evaluatePropertyValue( - inputColumnsProperty, - evaluationContext, - new CollectionValuetype(PrimitiveValuetypes.Text), - ); - - if (transform === undefined || inputColumns === undefined) { - return; - } - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - const transformInputPorts = transform?.body?.ports?.filter( - (x) => x.kind === 'from', - ); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (transformInputPorts === undefined) { - return; - } - - const numberTransformPorts = transformInputPorts.length; - const numberInputColumns = inputColumns.length; - - if (numberTransformPorts !== numberInputColumns) { - validationContext.accept( - 'error', - `Expected ${numberTransformPorts} columns but only got ${numberInputColumns}`, - { - node: inputColumnsProperty, - }, - ); - } - } -} - -const blockExampleOverwrite = ` -transform CelsiusToFahrenheit { - from Celsius oftype decimal; - to Fahrenheit oftype decimal; - - Fahrenheit: (Celsius * 9/5) + 32; -} - -block CelsiusToFahrenheitTransformer oftype TableTransformer { - inputColumns: ['temperature']; - outputColumn: 'temperature'; - use: CelsiusToFahrenheit; -}`; - -const blockExampleNewCol = ` -transform CelsiusToFahrenheit { - from Celsius oftype decimal; - to Fahrenheit oftype decimal; - - Fahrenheit: (Celsius * 9/5) + 32; -} - -block CelsiusToFahrenheitTransformer oftype TableTransformer { - inputColumns: ['temperatureCelsius']; - outputColumn: 'temperatureFahrenheit'; - use: CelsiusToFahrenheit; -}`; diff --git a/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.spec.ts b/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.spec.ts deleted file mode 100644 index e4a7f9f7d..000000000 --- a/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { - createJayveeServices, - useExtension, -} from '@jvalue/jayvee-language-server'; -import { - TestLangExtension, - ValidationResult, - readJvTestAssetHelper, - validationHelper, -} from '@jvalue/jayvee-language-server/test'; -import { AstNode } from 'langium'; -import { NodeFileSystem } from 'langium/node'; - -import { TabularLangExtension } from '../extension'; - -describe('Validation of XLSXInterpreterMetaInformation', () => { - let validate: (input: string) => Promise>; - - const readJvTestAsset = readJvTestAssetHelper( - __dirname, - '../../test/assets/', - ); - - beforeAll(() => { - // Register std extension - useExtension(new TabularLangExtension()); - // Register test extension - useExtension(new TestLangExtension()); - // Create language services - const services = createJayveeServices(NodeFileSystem).Jayvee; - // Create validation helper for language services - validate = validationHelper(services); - }); - - it('should diagnose no error', async () => { - const text = readJvTestAsset( - 'xlsx-interpreter-meta-inf/valid-xlsx-interpreter.jv', - ); - - const validationResult = await validate(text); - const diagnostics = validationResult.diagnostics; - - expect(diagnostics).toHaveLength(0); - }); -}); diff --git a/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.ts b/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.ts deleted file mode 100644 index 70020414d..000000000 --- a/libs/extensions/tabular/lang/src/lib/xlsx-interpreter-meta-inf.ts +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { BlockMetaInformation, IOType } from '@jvalue/jayvee-language-server'; - -export class XLSXInterpreterMetaInformation extends BlockMetaInformation { - constructor() { - super( - // How the block type should be called: - 'XLSXInterpreter', - // Property definitions: - {}, - // Input type: - IOType.FILE, - - // Output type: - IOType.WORKBOOK, - ); - - this.docs.description = - 'Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s.'; - this.docs.examples = [ - { - code: blockExample, - description: - 'Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s.', - }, - ]; - } -} -const blockExample = `block AgencyXLSXInterpreter oftype XLSXInterpreter { - }`; diff --git a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-write-length-does-not-match-cell-range.jv b/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-write-length-does-not-match-cell-range.jv deleted file mode 100644 index 9384c99aa..000000000 --- a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-write-length-does-not-match-cell-range.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype CellWriter { - at: range A1:A4; - write: ['values', 'to', 'write']; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-wrong-at-dimension.jv b/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-wrong-at-dimension.jv deleted file mode 100644 index d8154bf76..000000000 --- a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/invalid-wrong-at-dimension.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype CellWriter { - at: range A1:B2; - write: ['the', 'values', 'to', 'write']; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/valid-range-matches-array-length.jv b/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/valid-range-matches-array-length.jv deleted file mode 100644 index 2d9a51d5f..000000000 --- a/libs/extensions/tabular/lang/test/assets/cell-writer-meta-inf/valid-range-matches-array-length.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype CellWriter { - at: range A1:A3; - write: ['values', 'to', 'write']; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/invalid-partial-column-delete.jv b/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/invalid-partial-column-delete.jv deleted file mode 100644 index 981dab3ae..000000000 --- a/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/invalid-partial-column-delete.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype ColumnDeleter { - delete: [range A1:A3]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/valid-column-delete.jv b/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/valid-column-delete.jv deleted file mode 100644 index 29da54be1..000000000 --- a/libs/extensions/tabular/lang/test/assets/column-deleter-meta-inf/valid-column-delete.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype ColumnDeleter { - delete: [column A]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/invalid-partial-row-delete.jv b/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/invalid-partial-row-delete.jv deleted file mode 100644 index 80c2e8e34..000000000 --- a/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/invalid-partial-row-delete.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype RowDeleter { - delete: [range A1:C1]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/valid-row-delete.jv b/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/valid-row-delete.jv deleted file mode 100644 index 673fe5f6d..000000000 --- a/libs/extensions/tabular/lang/test/assets/row-deleter-meta-inf/valid-row-delete.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype RowDeleter { - delete: [row 1]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/invalid-sheet-picker-missing-parameter.jv b/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/invalid-sheet-picker-missing-parameter.jv deleted file mode 100644 index add4f8876..000000000 --- a/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/invalid-sheet-picker-missing-parameter.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block TestSheetPicker oftype SheetPicker { - } - - - block TestExtractor oftype TestWorkbookExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> TestSheetPicker -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/valid-correct-sheet-picker.jv b/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/valid-correct-sheet-picker.jv deleted file mode 100644 index 901d531e3..000000000 --- a/libs/extensions/tabular/lang/test/assets/sheet-picker-meta-inf/valid-correct-sheet-picker.jv +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block TestSheetPicker oftype SheetPicker { - sheetName: "TestName"; - } - - - block TestExtractor oftype TestWorkbookExtractor { - } - - block TestLoader oftype TestSheetLoader { - } - - TestExtractor -> TestSheetPicker -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/invalid-non-unique-column-names.jv b/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/invalid-non-unique-column-names.jv deleted file mode 100644 index 197e2d49a..000000000 --- a/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/invalid-non-unique-column-names.jv +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TableInterpreter { - header: false; - columns: [ - "name" oftype text, - "name" oftype integer, - ]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestTableLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/valid-correct-table.jv b/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/valid-correct-table.jv deleted file mode 100644 index 22bbbae40..000000000 --- a/libs/extensions/tabular/lang/test/assets/table-interpreter-meta-inf/valid-correct-table.jv +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype TableInterpreter { - header: false; - columns: [ - "name" oftype text, - "version" oftype integer, - ]; - } - - block TestExtractor oftype TestSheetExtractor { - } - - block TestLoader oftype TestTableLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/invalid-input-columns-transform-port-missmatch.jv b/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/invalid-input-columns-transform-port-missmatch.jv deleted file mode 100644 index 4179d0a04..000000000 --- a/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/invalid-input-columns-transform-port-missmatch.jv +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - transform TestTransform { - from inputParam oftype decimal; - to result oftype integer; - - result: ceil(inputParam); - } - - block Test oftype TableTransformer { - inputColumns: ['input1', 'input2']; - outputColumn: 'output'; - use: TestTransform; - } - - block TestExtractor oftype TestTableExtractor { - } - - block TestLoader oftype TestTableLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/valid-correct-ports.jv b/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/valid-correct-ports.jv deleted file mode 100644 index c6da883da..000000000 --- a/libs/extensions/tabular/lang/test/assets/table-transformer-meta-inf/valid-correct-ports.jv +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - transform TestTransform { - from inputParam oftype decimal; - to result oftype integer; - - result: ceil(inputParam); - } - - block Test oftype TableTransformer { - inputColumns: ['input1']; - outputColumn: 'output'; - use: TestTransform; - } - - block TestExtractor oftype TestTableExtractor { - } - - block TestLoader oftype TestTableLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/test/assets/xlsx-interpreter-meta-inf/valid-xlsx-interpreter.jv b/libs/extensions/tabular/lang/test/assets/xlsx-interpreter-meta-inf/valid-xlsx-interpreter.jv deleted file mode 100644 index 3e540c38c..000000000 --- a/libs/extensions/tabular/lang/test/assets/xlsx-interpreter-meta-inf/valid-xlsx-interpreter.jv +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -pipeline Pipeline { - block Test oftype XLSXInterpreter { - } - - - block TestExtractor oftype TestFileExtractor { - } - - block TestLoader oftype TestWorkbookLoader { - } - - TestExtractor -> Test -> TestLoader; -} diff --git a/libs/extensions/tabular/lang/tsconfig.json b/libs/extensions/tabular/lang/tsconfig.json deleted file mode 100644 index 4022fd4d0..000000000 --- a/libs/extensions/tabular/lang/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/extensions/tabular/lang/tsconfig.json.license b/libs/extensions/tabular/lang/tsconfig.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/tsconfig.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/tsconfig.lib.json b/libs/extensions/tabular/lang/tsconfig.lib.json deleted file mode 100644 index 18f2d37a1..000000000 --- a/libs/extensions/tabular/lang/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/libs/extensions/tabular/lang/tsconfig.lib.json.license b/libs/extensions/tabular/lang/tsconfig.lib.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/tsconfig.lib.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/extensions/tabular/lang/tsconfig.spec.json b/libs/extensions/tabular/lang/tsconfig.spec.json deleted file mode 100644 index 6668655fc..000000000 --- a/libs/extensions/tabular/lang/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/libs/extensions/tabular/lang/tsconfig.spec.json.license b/libs/extensions/tabular/lang/tsconfig.spec.json.license deleted file mode 100644 index 17c5d2bad..000000000 --- a/libs/extensions/tabular/lang/tsconfig.spec.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg - -SPDX-License-Identifier: AGPL-3.0-only diff --git a/libs/interpreter-lib/src/interpreter.ts b/libs/interpreter-lib/src/interpreter.ts index 75f586c5c..ecb5d22ac 100644 --- a/libs/interpreter-lib/src/interpreter.ts +++ b/libs/interpreter-lib/src/interpreter.ts @@ -17,7 +17,6 @@ import { } from '@jvalue/jayvee-execution'; import * as R from '@jvalue/jayvee-execution'; import { StdExecExtension } from '@jvalue/jayvee-extensions/std/exec'; -import { StdLangExtension } from '@jvalue/jayvee-extensions/std/lang'; import { BlockDefinition, EvaluationContext, @@ -29,7 +28,6 @@ import { collectStartingBlocks, createJayveeServices, getBlocksInTopologicalSorting, - useExtension as useLangExtension, } from '@jvalue/jayvee-language-server'; import * as chalk from 'chalk'; import { NodeFileSystem } from 'langium/node'; @@ -136,7 +134,6 @@ function setupRuntimeParameterProvider( } export function useStdExtension() { - useLangExtension(new StdLangExtension()); useExecutionExtension(new StdExecExtension()); } diff --git a/libs/interpreter-lib/src/parsing-util.ts b/libs/interpreter-lib/src/parsing-util.ts index a08029a09..1268e3d1d 100644 --- a/libs/interpreter-lib/src/parsing-util.ts +++ b/libs/interpreter-lib/src/parsing-util.ts @@ -79,6 +79,7 @@ export async function validateDocument( for (const errDiagnostic of errDiagnostics) { logger.logLanguageServerDiagnostic(errDiagnostic, document); } + throw new Error(errDiagnostics.map((r) => r.message).join('\n')); process.exit(ExitCode.FAILURE); } diff --git a/libs/language-server/src/lib/completion/jayvee-completion-provider.ts b/libs/language-server/src/lib/completion/jayvee-completion-provider.ts index a6851c17a..1d3be1893 100644 --- a/libs/language-server/src/lib/completion/jayvee-completion-provider.ts +++ b/libs/language-server/src/lib/completion/jayvee-completion-provider.ts @@ -36,7 +36,6 @@ import { BlockMetaInformation } from '../meta-information'; import { MetaInformation } from '../meta-information/meta-inf'; import { getConstraintMetaInf, - getRegisteredBlockMetaInformation, getRegisteredConstraintMetaInformation, } from '../meta-information/meta-inf-registry'; @@ -88,22 +87,33 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider { private completionForBlockType( acceptor: CompletionAcceptor, ): MaybePromise { - getRegisteredBlockMetaInformation().forEach((metaInf) => { - const lspDocBuilder = new LspDocGenerator(); - const markdownDoc = lspDocBuilder.generateBlockTypeDoc(metaInf); - acceptor({ - label: metaInf.type, - labelDetails: { - detail: ` ${metaInf.inputType} ${RIGHT_ARROW_SYMBOL} ${metaInf.outputType}`, - }, - kind: CompletionItemKind.Class, - detail: `(block type)`, - documentation: { - kind: 'markdown', - value: markdownDoc, - }, + this.langiumDocumentService.all + .map((document) => document.parseResult.value) + .forEach((parsedDocument) => { + if (!isJayveeModel(parsedDocument)) { + throw new Error('Expected parsed document to be a JayveeModel'); + } + parsedDocument.blocktypes.forEach((blocktypeDefinition) => { + if (!BlockMetaInformation.canBeWrapped(blocktypeDefinition)) { + return; + } + const blocktype = new BlockMetaInformation(blocktypeDefinition); + const lspDocBuilder = new LspDocGenerator(); + const markdownDoc = lspDocBuilder.generateBlockTypeDoc(blocktype); + acceptor({ + label: blocktype.type, + labelDetails: { + detail: ` ${blocktype.inputType} ${RIGHT_ARROW_SYMBOL} ${blocktype.outputType}`, + }, + kind: CompletionItemKind.Class, + detail: `(block type)`, + documentation: { + kind: 'markdown', + value: markdownDoc, + }, + }); + }); }); - }); } private completionForConstraintType( diff --git a/libs/language-server/src/lib/extension.ts b/libs/language-server/src/lib/extension.ts deleted file mode 100644 index e4a7d0799..000000000 --- a/libs/language-server/src/lib/extension.ts +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Friedrich-Alexander-Universitat Erlangen-Nurnberg -// -// SPDX-License-Identifier: AGPL-3.0-only - -import { BlockMetaInformation } from './meta-information'; -import { registerBlockMetaInf } from './meta-information/meta-inf-registry'; -import { ConstructorClass } from './util/constructor-class'; - -export interface JayveeLangExtension { - getBlockMetaInf(): Array>; -} - -export function useExtension(extension: JayveeLangExtension) { - extension.getBlockMetaInf().forEach(registerBlockMetaInf); -} diff --git a/libs/language-server/src/lib/meta-information/block-meta-inf.ts b/libs/language-server/src/lib/meta-information/block-meta-inf.ts index 4c8f046b6..ce5730122 100644 --- a/libs/language-server/src/lib/meta-information/block-meta-inf.ts +++ b/libs/language-server/src/lib/meta-information/block-meta-inf.ts @@ -7,11 +7,18 @@ import { strict as assert } from 'assert'; import { Reference, isReference } from 'langium'; // eslint-disable-next-line import/no-cycle -import { IOType, createValuetype, getIOType } from '../ast'; +import { + EvaluationContext, + IOType, + createValuetype, + evaluateExpression, + getIOType, +} from '../ast'; import { ReferenceableBlocktypeDefinition, isBuiltinBlocktypeDefinition, } from '../ast/generated/ast'; +import { RuntimeParameterProvider } from '../services'; import { ExampleDoc, MetaInformation, PropertySpecification } from './meta-inf'; @@ -46,6 +53,15 @@ export class BlockMetaInformation extends MetaInformation { properties[property.name] = { type: valuetype, }; + + const defaultValue = evaluateExpression( + property.defaultValue, + new EvaluationContext(new RuntimeParameterProvider()), // TODO: check if that works + ); + if (defaultValue !== undefined) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + properties[property.name]!.defaultValue = defaultValue; + } } super(blocktypeName, properties, undefined); diff --git a/libs/language-server/src/lib/meta-information/meta-inf-registry.ts b/libs/language-server/src/lib/meta-information/meta-inf-registry.ts index 262d62a0d..d1a536de3 100644 --- a/libs/language-server/src/lib/meta-information/meta-inf-registry.ts +++ b/libs/language-server/src/lib/meta-information/meta-inf-registry.ts @@ -6,30 +6,16 @@ import { strict as assert } from 'assert'; import { Reference, isReference } from 'langium'; -import { - BuiltinConstrainttypeDefinition, - ReferenceableBlocktypeDefinition, - isCompositeBlocktypeDefinition, -} from '../ast/generated/ast'; +import { BuiltinConstrainttypeDefinition } from '../ast/generated/ast'; import { ConstructorClass } from '../util/constructor-class'; import { Registry } from '../util/registry'; // eslint-disable-next-line import/no-cycle -import { BlockMetaInformation } from './block-meta-inf'; -import { CompositeBlocktypeMetaInformation } from './composite-blocktype-meta-inf'; import { ConstraintMetaInformation } from './constraint-meta-inf'; -export const blockMetaInfRegistry = new Registry(); export const constraintMetaInfRegistry = new Registry(); -export function registerBlockMetaInf( - metaInfClass: ConstructorClass, -) { - const metaInf = new metaInfClass(); - blockMetaInfRegistry.register(metaInf.type, metaInf); -} - export function registerConstraintMetaInf( metaInfClass: ConstructorClass, ) { @@ -37,36 +23,6 @@ export function registerConstraintMetaInf( constraintMetaInfRegistry.register(metaInf.type, metaInf); } -export function getBlockMetaInf( - type: - | ReferenceableBlocktypeDefinition - | Reference - | undefined, -): BlockMetaInformation | undefined { - const dereferencedType = isReference(type) ? type.ref : type; - if (dereferencedType === undefined) { - return undefined; - } - - // Register meta information about composite blocks from jv code - if ( - isCompositeBlocktypeDefinition(dereferencedType) && - !blockMetaInfRegistry.get(dereferencedType.name) - ) { - blockMetaInfRegistry.register( - dereferencedType.name, - new CompositeBlocktypeMetaInformation(dereferencedType), - ); - } - - const metaInf = blockMetaInfRegistry.get(dereferencedType.name); - if (metaInf === undefined) { - return undefined; - } - - return metaInf; -} - export function getConstraintMetaInf( type: | BuiltinConstrainttypeDefinition @@ -86,29 +42,10 @@ export function getConstraintMetaInf( return metaInf; } -export function getRegisteredBlockMetaInformation(): BlockMetaInformation[] { - return blockMetaInfRegistry.getAll(); -} - export function getRegisteredConstraintMetaInformation(): ConstraintMetaInformation[] { return constraintMetaInfRegistry.getAll(); } -export function getOrFailBockMetaInf( - type: - | ReferenceableBlocktypeDefinition - | Reference, -): BlockMetaInformation { - const result = getBlockMetaInf(type); - const typeName = - (isReference(type) ? type.ref?.name : type.name) ?? ''; - assert( - result !== undefined, - `Meta information for blocktype ${typeName} was expected to be present, got undefined instead`, - ); - return result; -} - export function getOrFailConstraintMetaInf( type: | BuiltinConstrainttypeDefinition diff --git a/libs/language-server/src/stdlib/blocktypes.jv b/libs/language-server/src/stdlib/blocktypes.jv deleted file mode 100644 index 977a2111b..000000000 --- a/libs/language-server/src/stdlib/blocktypes.jv +++ /dev/null @@ -1,406 +0,0 @@ -/* -Deletes columns from a `Sheet`. Column IDs of subsequent columns will be shifted accordingly, so there will be no gaps. - -@example Deletes column B (i.e. the second column). -block MpgColumnDeleter oftype ColumnDeleter { - delete: [column B]; -} -*/ -builtin blocktype ColumnDeleter { - input default oftype Sheet; - output default oftype Sheet; - - // The columns to delete. - property delete oftype Collection; -} - -/* -Deletes one or more rows from a `Sheet`. Row IDs of subsequent rows will be shifted accordingly, so there will be no gaps. - -@example Deletes row 2 (i.e. the second row). -block SecondRowDeleter oftype RowDeleter { - delete: [row 2]; -} -*/ -builtin blocktype RowDeleter { - input default oftype Sheet; - output default oftype Sheet; - - // The rows to delete. - property delete oftype Collection; -} - -/* -Selects a subset of a `Sheet` to produce a new `Sheet`. - -@example Selects the cells in the given range and produces a new `Sheet` containing only the selected cells. -block CarsCoreDataSelector oftype CellRangeSelector { - select: range A1:E*; -} -*/ -builtin blocktype CellRangeSelector { - input default oftype Sheet; - output default oftype Sheet; - - // The cell range to select. - property select oftype CellRange; -} - -/* -Writes textual values into cells of a `Sheet`. The number of text values needs to match the number of cells to write into. - -@example Write the value "Name" into cell `A1`. -block NameHeaderWriter oftype CellWriter { - at: cell A1; - write: ["Name"]; -} - -@example Write the values "Name", "Age" into cells `A1` and `A2`. -block HeaderSequenceWriter oftype CellWriter { - at: range A1:A2; - write: ["Name", "Age"]; -} -*/ -builtin blocktype CellWriter { - input default oftype Sheet; - output default oftype Sheet; - - // The values to write. - property write oftype Collection; - // The cells to write into. - property at oftype CellRange; -} - -/* -Interprets a `Sheet` as a `Table`. In case a header row is present in the sheet, its names can be matched with the provided column names. Otherwise, the provided column names are assigned in order. - -@example Interprets a `Sheet` about cars with a topmost header row and interprets it as a `Table` by assigning a primitive valuetype to each column. The column names are matched to the header, so the order of the type assignments does not matter. -block CarsTableInterpreter oftype TableInterpreter { - header: true; - columns: [ - "name" oftype text, - "mpg" oftype decimal, - "cyl" oftype integer, - ]; -} - -@example Interprets a `Sheet` about cars without a topmost header row and interprets it as a `Table` by sequentially assigning a name and a primitive valuetype to each column of the sheet. Note that the order of columns matters here. The first column (column `A`) will be named "name", the second column (column `B`) will be named "mpg" etc. -block CarsTableInterpreter oftype TableInterpreter { - header: false; - columns: [ - "name" oftype text, - "mpg" oftype decimal, - "cyl" oftype integer, - ]; -} -*/ -builtin blocktype TableInterpreter { - input default oftype Sheet; - output default oftype Table; - - // Whether the first row should be interpreted as header row. - property header oftype boolean; - // Collection of valuetype assignments. Uses column names (potentially matched with the header or by sequence depending on the `header` property) to assign a primitive valuetype to each column. - property columns oftype Collection; -} - -/* -Interprets an input file as a csv-file containing string-values delimited by `delimiter` and outputs a `Sheet`. - -@example Interprets an input file as a csv-file containing string-values delimited by `;` and outputs `Sheet`. -block AgencyCSVInterpreter oftype CSVInterpreter { - delimiter: ";"; - } -*/ -builtin blocktype CSVInterpreter { - input default oftype TextFile; - output default oftype Sheet; - - // The delimiter for values in the CSV file. - property delimiter oftype text; - // The enclosing character that may be used for values in the CSV file. - property enclosing oftype text; - // The character to escape enclosing characters in values. - property enclosingEscape oftype text; -} - -/* -Applies a transform on each value of a column. The input port type of the used transform has to match the type of the input column. - -@example Given a column "temperature" with temperature values in Celsius, it overwrites the column with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model. - -transform CelsiusToFahrenheit { - from Celsius oftype decimal; - to Fahrenheit oftype decimal; - - Fahrenheit: (Celsius * 9/5) + 32; -} - -block CelsiusToFahrenheitTransformer oftype TableTransformer { - inputColumns: ['temperature']; - outputColumn: 'temperature'; - use: CelsiusToFahrenheit; -} - -@example Given a column "temperatureCelsius" with temperature values in Celsius, it adds a new column "temperatureFahrenheit" with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model. - -transform CelsiusToFahrenheit { - from Celsius oftype decimal; - to Fahrenheit oftype decimal; - - Fahrenheit: (Celsius * 9/5) + 32; -} - -block CelsiusToFahrenheitTransformer oftype TableTransformer { - inputColumns: ['temperatureCelsius']; - outputColumn: 'temperatureFahrenheit'; - use: CelsiusToFahrenheit; -} -*/ -builtin blocktype TableTransformer { - input default oftype Table; - output default oftype Table; - - // The names of the input columns. The columns have to be present in the table and match with the transform's input port types. - property inputColumns oftype Collection; - // The name of the output column. Overwrites the column if it already exists, or otherwise creates a new one. - property outputColumn oftype text; - // Reference to the transform that is applied to the column. - property use oftype Transform; -} - -/* -Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s. - -@example Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s. -block AgencyXLSXInterpreter oftype XLSXInterpreter { - } -*/ -builtin blocktype XLSXInterpreter { - input default oftype File; - output default oftype Workbook; - -} - -/* -Selects one `Sheet` from a `Workbook` based on its `sheetName`. If no sheet matches the name, no output is created and the execution of the pipeline is aborted. - -@example Tries to pick the sheet `AgencyNames` from the provided `Workbook`. If `AgencyNames` exists it is passed on as `Sheet`, if it does not exist the execution of the pipeline is aborted. -block AgencySheetPicker oftype SheetPicker { - sheetName: "AgencyNames"; -} -*/ -builtin blocktype SheetPicker { - input default oftype Workbook; - output default oftype Sheet; - - // The name of the sheet to select. - property sheetName oftype text; -} - -/* -Loads a `Table` into a PostgreSQL database sink. - -@example A local Postgres instance is filled with table data about cars. -block CarsLoader oftype PostgresLoader { - host: "localhost"; - port: 5432; - username: "postgres"; - password: "postgres"; - database: "CarsDB"; - table: "Cars"; -} -*/ -builtin blocktype PostgresLoader { - input default oftype Table; - output default oftype None; - - // The hostname or IP address of the Postgres database. - property host oftype text; - // The port of the Postgres database. - property port oftype integer; - // The username to login to the Postgres database. - property username oftype text; - // The password to login to the Postgres database. - property password oftype text; - // The database to use. - property database oftype text; - // The name of the table to write into. - property table oftype text; -} - -/* -Loads a `Table` into a SQLite database sink. - -@example A SQLite file `cars.db` is created in the working directory. Incoming data is written to the table `cars`. -block CarsLoader oftype SQLiteLoader { - table: "cars"; - file: "./cars.db"; -} -*/ -builtin blocktype SQLiteLoader { - input default oftype Table; - output default oftype None; - - // The name of the table to write into. - property table oftype text; - // The path to a SQLite file that will be created if it does not exist. Usual file extensions are `.sqlite` and `.db`. - property file oftype text; - // Indicates, whether to drop the table before loading data into it. If `false`, data is appended to the table instead of dropping it. - property dropTable oftype boolean; -} - -/* -Extracts a `File` from the web. - -@example Fetches a file from the given URL. -block CarsFileExtractor oftype HttpExtractor { - url: "tinyurl.com/4ub9spwz"; -} -*/ -builtin blocktype HttpExtractor { - input default oftype None; - output default oftype File; - - // The URL to the file in the web to extract. - property url oftype text; - // Configures how many retries should be executed after a failure fetching the data. - property retries oftype integer; - // Configures the wait time in milliseconds before executing a retry. - property retryBackoffMilliseconds oftype integer; - // Configures the wait strategy before executing a retry. Can have values "exponential" or "linear". - property retryBackoffStrategy oftype text; - // Indicates, whether to follow redirects on get requests. If `false`, redirects are not followed. Default `true` - property followRedirects oftype boolean; -} - -/* -Interprets a `File` as a `TextFile`. -*/ -builtin blocktype TextFileInterpreter { - input default oftype File; - output default oftype TextFile; - - // The encoding used for decoding the file contents. - property encoding oftype text; - // The regex for identifying line breaks. - property lineBreak oftype Regex; -} - -/* -Selects a range of lines from a `TextFile`. -*/ -builtin blocktype TextRangeSelector { - input default oftype TextFile; - output default oftype TextFile; - - property lineFrom oftype integer; - property lineTo oftype integer; -} - -/* -Deletes individual lines from a `TextFile`. -*/ -builtin blocktype TextLineDeleter { - input default oftype TextFile; - output default oftype TextFile; - - // The line numbers to delete. - property lines oftype Collection; -} - -/* -Interprets a `File` as an archive file and converts it to a `FileSystem`. The archive file root is considered the root of the `FileSystem`. - -@example Interprets a `File` as a ZIP-archive and creates a `FileSystem` of its extracted contents. -block ZipArchiveInterpreter oftype ArchiveInterpreter { - archiveType: "zip"; -} -*/ -builtin blocktype ArchiveInterpreter { - input default oftype File; - output default oftype FileSystem; - - // The archive type to be interpreted, e.g., "zip" or "gz". - property archiveType oftype text; -} - -/* -Selects one `File` from a `FileSystem` based on its relative path to the root of the `FileSystem`. If no file matches the relative path, no output is created and the execution of the pipeline is aborted. - -@example Tries to pick the file `agency.txt` from the root of the provided `FileSystem`. If `agency.txt` exists it is passed on as `File`, if it does not exist the execution of the pipeline is aborted. -block AgencyFilePicker oftype FilePicker { - path: "./agency.txt"; -} -*/ -builtin blocktype FilePicker { - input default oftype FileSystem; - output default oftype File; - - // The path of the file to select, relative to the root of the provided `FileSystem`. - property path oftype text; -} - -/* -Interprets an protobuf file (binary) of type `File` by decoding the file according to `gtfs-realtime.proto`. Outputs the extracted entity defined by `entity` as a `Sheet` - -@example A file is interpretet as an GTFS-RT file, which contains TripUpdate. -block GtfsRTTripUpdateInterpreter oftype GtfsRTInterpreter{ - entity: "trip_update"; -} -*/ -builtin blocktype GtfsRTInterpreter { - input default oftype File; - output default oftype Sheet; - - // Entity to process from GTFS-RT-feed (`trip_update`, `alert` or `vehicle`). - // We currently support following Output-Sheets, each are an equivalent to the flattened Element Index defined in (just required fields are included)): - // - // Entity TripUpdate: - // ``` - // [ - // 'header.gtfs_realtime_version', - // 'header.timestamp', - // 'header.incrementality', - // 'entity.id', - // 'entity.trip_update.trip.trip_id', - // 'entity.trip_update.trip.route_id', - // 'entity.trip_update.stop_time_update.stop_sequence', - // 'entity.trip_update.stop_time_update.stop_id', - // 'entity.trip_update.stop_time_update.arrival.time', - // 'entity.trip_update.stop_time_update.departure.time', - // ]; - // - // ``` - // Entity VehiclePosition: - // ``` - // [ - // 'header.gtfs_realtime_version', - // 'header.timestamp', - // 'header.incrementality', - // 'entity.id', - // 'entity.vehicle_position.vehicle_descriptor.id', - // 'entity.vehicle_position.trip.trip_id', - // 'entity.vehicle_position.trip.route_id', - // 'entity.vehicle_position.position.latitude', - // 'entity.vehicle_position.position.longitude', - // 'entity.vehicle_position.timestamp', - // ]; - // ``` - // - // Entity Alert: - // ``` - // [ - // 'header.gtfs_realtime_version', - // 'header.timestamp', - // 'header.incrementality', - // 'entity.id', - // 'entity.alert.informed_entity.route_id', - // 'entity.alert.header_text', - // 'entity.alert.description_text', - // ]; - // ``` - // - // - property entity oftype text; -} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/ArchiveInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/ArchiveInterpreter.jv new file mode 100644 index 000000000..14c836897 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/ArchiveInterpreter.jv @@ -0,0 +1,22 @@ +/* +Interprets a `File` as an archive file and converts it to a `FileSystem`. The archive file root is considered the root of the `FileSystem`. + +@example Interprets a `File` as a ZIP-archive and creates a `FileSystem` of its extracted contents. +block ZipArchiveInterpreter oftype ArchiveInterpreter { + archiveType: "zip"; +} +*/ +builtin blocktype ArchiveInterpreter { + input default oftype File; + output default oftype FileSystem; + + // The archive type to be interpreted, e.g., "zip" or "gz". + property archiveType oftype ArchiveType; // TODO: supported archive types +} + +valuetype ArchiveType { + constraints: [ArchiveTypeHandleConstraint]; +} + +constraint ArchiveTypeHandleConstraint on text: + value in ["zip", "gz"]; \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/CellRangeSelector.jv b/libs/language-server/src/stdlib/builtin-blocktypes/CellRangeSelector.jv new file mode 100644 index 000000000..2f8ddd5eb --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/CellRangeSelector.jv @@ -0,0 +1,15 @@ +/* +Selects a subset of a `Sheet` to produce a new `Sheet`. + +@example Selects the cells in the given range and produces a new `Sheet` containing only the selected cells. +block CarsCoreDataSelector oftype CellRangeSelector { + select: range A1:E*; +} +*/ +builtin blocktype CellRangeSelector { + input default oftype Sheet; + output default oftype Sheet; + + // The cell range to select. + property select oftype CellRange; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/CellWriter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/CellWriter.jv new file mode 100644 index 000000000..aea96ccb6 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/CellWriter.jv @@ -0,0 +1,25 @@ +/* +Writes textual values into cells of a `Sheet`. The number of text values needs to match the number of cells to write into. + +@example Write the value "Name" into cell `A1`. +block NameHeaderWriter oftype CellWriter { + at: cell A1; + write: ["Name"]; +} + +@example Write the values "Name", "Age" into cells `A1` and `A2`. +block HeaderSequenceWriter oftype CellWriter { + at: range A1:A2; + write: ["Name", "Age"]; +} +*/ +builtin blocktype CellWriter { + input default oftype Sheet; + output default oftype Sheet; + + // The values to write. + property write oftype Collection; + // The cells to write into. + property at oftype CellRange; // TODO: ensure 1-dimensional + // TODO: ensure write.length === at.dim +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/ColumnDeleter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/ColumnDeleter.jv new file mode 100644 index 000000000..89bdfd4d4 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/ColumnDeleter.jv @@ -0,0 +1,15 @@ +/* +Deletes columns from a `Sheet`. Column IDs of subsequent columns will be shifted accordingly, so there will be no gaps. + +@example Deletes column B (i.e. the second column). +block MpgColumnDeleter oftype ColumnDeleter { + delete: [column B]; +} +*/ +builtin blocktype ColumnDeleter { + input default oftype Sheet; + output default oftype Sheet; + + // The columns to delete. + property delete oftype Collection; // TODO: ensure whole column is selected +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/CsvInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/CsvInterpreter.jv new file mode 100644 index 000000000..8f2337c4e --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/CsvInterpreter.jv @@ -0,0 +1,19 @@ +/* +Interprets an input file as a csv-file containing string-values delimited by `delimiter` and outputs a `Sheet`. + +@example Interprets an input file as a csv-file containing string-values delimited by `;` and outputs `Sheet`. +block AgencyCSVInterpreter oftype CSVInterpreter { + delimiter: ";"; + } +*/ +builtin blocktype CSVInterpreter { + input default oftype TextFile; + output default oftype Sheet; + + // The delimiter for values in the CSV file. + property delimiter oftype text: ','; + // The enclosing character that may be used for values in the CSV file. + property enclosing oftype text: ''; + // The character to escape enclosing characters in values. + property enclosingEscape oftype text: ''; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/FilePicker.jv b/libs/language-server/src/stdlib/builtin-blocktypes/FilePicker.jv new file mode 100644 index 000000000..4cb18c9ce --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/FilePicker.jv @@ -0,0 +1,15 @@ +/* +Selects one `File` from a `FileSystem` based on its relative path to the root of the `FileSystem`. If no file matches the relative path, no output is created and the execution of the pipeline is aborted. + +@example Tries to pick the file `agency.txt` from the root of the provided `FileSystem`. If `agency.txt` exists it is passed on as `File`, if it does not exist the execution of the pipeline is aborted. +block AgencyFilePicker oftype FilePicker { + path: "./agency.txt"; +} +*/ +builtin blocktype FilePicker { + input default oftype FileSystem; + output default oftype File; + + // The path of the file to select, relative to the root of the provided `FileSystem`. + property path oftype text; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/GtfsRtInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/GtfsRtInterpreter.jv new file mode 100644 index 000000000..61f765f0b --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/GtfsRtInterpreter.jv @@ -0,0 +1,70 @@ +/* +Interprets an protobuf file (binary) of type `File` by decoding the file according to `gtfs-realtime.proto`. Outputs the extracted entity defined by `entity` as a `Sheet` + +@example A file is interpretet as an GTFS-RT file, which contains TripUpdate. +block GtfsRTTripUpdateInterpreter oftype GtfsRTInterpreter{ + entity: "trip_update"; +} +*/ +builtin blocktype GtfsRTInterpreter { + input default oftype File; + output default oftype Sheet; + + // Entity to process from GTFS-RT-feed (`trip_update`, `alert` or `vehicle`). + // We currently support following Output-Sheets, each are an equivalent to the flattened Element Index defined in (just required fields are included)): + // + // Entity TripUpdate: + // ``` + // [ + // 'header.gtfs_realtime_version', + // 'header.timestamp', + // 'header.incrementality', + // 'entity.id', + // 'entity.trip_update.trip.trip_id', + // 'entity.trip_update.trip.route_id', + // 'entity.trip_update.stop_time_update.stop_sequence', + // 'entity.trip_update.stop_time_update.stop_id', + // 'entity.trip_update.stop_time_update.arrival.time', + // 'entity.trip_update.stop_time_update.departure.time', + // ]; + // + // ``` + // Entity VehiclePosition: + // ``` + // [ + // 'header.gtfs_realtime_version', + // 'header.timestamp', + // 'header.incrementality', + // 'entity.id', + // 'entity.vehicle_position.vehicle_descriptor.id', + // 'entity.vehicle_position.trip.trip_id', + // 'entity.vehicle_position.trip.route_id', + // 'entity.vehicle_position.position.latitude', + // 'entity.vehicle_position.position.longitude', + // 'entity.vehicle_position.timestamp', + // ]; + // ``` + // + // Entity Alert: + // ``` + // [ + // 'header.gtfs_realtime_version', + // 'header.timestamp', + // 'header.incrementality', + // 'entity.id', + // 'entity.alert.informed_entity.route_id', + // 'entity.alert.header_text', + // 'entity.alert.description_text', + // ]; + // ``` + // + // + property entity oftype GtfsRTEntity; +} + +valuetype GtfsRTEntity { + constraints: [GtfsRTEntityConstraint]; +} + +constraint GtfsRTEntityConstraint on text: + value in ['trip_update', 'alert', 'vehicle']; \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/HttpExtractor.jv b/libs/language-server/src/stdlib/builtin-blocktypes/HttpExtractor.jv new file mode 100644 index 000000000..21adc1043 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/HttpExtractor.jv @@ -0,0 +1,45 @@ +/* +Extracts a `File` from the web. + +@example Fetches a file from the given URL. +block CarsFileExtractor oftype HttpExtractor { + url: "tinyurl.com/4ub9spwz"; +} +*/ +builtin blocktype HttpExtractor { + input default oftype None; + output default oftype File; + + // The URL to the file in the web to extract. + property url oftype text; + // Configures how many retries should be executed after a failure fetching the data. + property retries oftype Count: 0; + // Configures the wait time in milliseconds before executing a retry. + property retryBackoffMilliseconds oftype RetryIntervalMilliseconds: 1000; + // Configures the wait strategy before executing a retry. Can have values "exponential" or "linear". + property retryBackoffStrategy oftype RetryBackoffStrategy: "exponential"; + // Indicates, whether to follow redirects on get requests. If `false`, redirects are not followed. Default `true` + property followRedirects oftype boolean: true; +} + +valuetype Count { + constraints: [IntNonNegative]; +} + +constraint IntNonNegative on integer: + value >= 0; + +valuetype RetryIntervalMilliseconds { + constraints: [IntOver999]; +} + +constraint IntOver999 on integer: + value > 999; + +valuetype RetryBackoffStrategy { + constraints : [RetryBackoffStrategyConstraint] +} + +constraint RetryBackoffStrategyConstraint on text: + value in ["linear", "exponential"]; + diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/PostgresLoader.jv b/libs/language-server/src/stdlib/builtin-blocktypes/PostgresLoader.jv new file mode 100644 index 000000000..ca41e29aa --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/PostgresLoader.jv @@ -0,0 +1,30 @@ +/* +Loads a `Table` into a PostgreSQL database sink. + +@example A local Postgres instance is filled with table data about cars. +block CarsLoader oftype PostgresLoader { + host: "localhost"; + port: 5432; + username: "postgres"; + password: "postgres"; + database: "CarsDB"; + table: "Cars"; +} +*/ +builtin blocktype PostgresLoader { + input default oftype Table; + output default oftype None; + + // The hostname or IP address of the Postgres database. + property host oftype text; + // The port of the Postgres database. + property port oftype integer; + // The username to login to the Postgres database. + property username oftype text; + // The password to login to the Postgres database. + property password oftype text; + // The database to use. + property database oftype text; + // The name of the table to write into. + property table oftype text; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/RowDeleter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/RowDeleter.jv new file mode 100644 index 000000000..e94e5a75a --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/RowDeleter.jv @@ -0,0 +1,15 @@ +/* +Deletes one or more rows from a `Sheet`. Row IDs of subsequent rows will be shifted accordingly, so there will be no gaps. + +@example Deletes row 2 (i.e. the second row). +block SecondRowDeleter oftype RowDeleter { + delete: [row 2]; +} +*/ +builtin blocktype RowDeleter { + input default oftype Sheet; + output default oftype Sheet; + + // The rows to delete. + property delete oftype Collection; // TODO: ensure whole row is selected +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/SheetPicker.jv b/libs/language-server/src/stdlib/builtin-blocktypes/SheetPicker.jv new file mode 100644 index 000000000..28022d5c7 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/SheetPicker.jv @@ -0,0 +1,15 @@ +/* +Selects one `Sheet` from a `Workbook` based on its `sheetName`. If no sheet matches the name, no output is created and the execution of the pipeline is aborted. + +@example Tries to pick the sheet `AgencyNames` from the provided `Workbook`. If `AgencyNames` exists it is passed on as `Sheet`, if it does not exist the execution of the pipeline is aborted. +block AgencySheetPicker oftype SheetPicker { + sheetName: "AgencyNames"; +} +*/ +builtin blocktype SheetPicker { + input default oftype Workbook; + output default oftype Sheet; + + // The name of the sheet to select. + property sheetName oftype text; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/SqliteLoader.jv b/libs/language-server/src/stdlib/builtin-blocktypes/SqliteLoader.jv new file mode 100644 index 000000000..477b3fb78 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/SqliteLoader.jv @@ -0,0 +1,20 @@ +/* +Loads a `Table` into a SQLite database sink. + +@example A SQLite file `cars.db` is created in the working directory. Incoming data is written to the table `cars`. +block CarsLoader oftype SQLiteLoader { + table: "cars"; + file: "./cars.db"; +} +*/ +builtin blocktype SQLiteLoader { + input default oftype Table; + output default oftype None; + + // The name of the table to write into. + property table oftype text; + // The path to a SQLite file that will be created if it does not exist. Usual file extensions are `.sqlite` and `.db`. + property file oftype text; + // Indicates, whether to drop the table before loading data into it. If `false`, data is appended to the table instead of dropping it. + property dropTable oftype boolean: true; +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/TableInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/TableInterpreter.jv new file mode 100644 index 000000000..4f79ac284 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/TableInterpreter.jv @@ -0,0 +1,32 @@ +/* +Interprets a `Sheet` as a `Table`. In case a header row is present in the sheet, its names can be matched with the provided column names. Otherwise, the provided column names are assigned in order. + +@example Interprets a `Sheet` about cars with a topmost header row and interprets it as a `Table` by assigning a primitive valuetype to each column. The column names are matched to the header, so the order of the type assignments does not matter. +block CarsTableInterpreter oftype TableInterpreter { + header: true; + columns: [ + "name" oftype text, + "mpg" oftype decimal, + "cyl" oftype integer, + ]; +} + +@example Interprets a `Sheet` about cars without a topmost header row and interprets it as a `Table` by sequentially assigning a name and a primitive valuetype to each column of the sheet. Note that the order of columns matters here. The first column (column `A`) will be named "name", the second column (column `B`) will be named "mpg" etc. +block CarsTableInterpreter oftype TableInterpreter { + header: false; + columns: [ + "name" oftype text, + "mpg" oftype decimal, + "cyl" oftype integer, + ]; +} +*/ +builtin blocktype TableInterpreter { + input default oftype Sheet; + output default oftype Table; + + // Whether the first row should be interpreted as header row. + property header oftype boolean: true; + // Collection of valuetype assignments. Uses column names (potentially matched with the header or by sequence depending on the `header` property) to assign a primitive valuetype to each column. + property columns oftype Collection; // TODO: ensure unique names +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/TableTransformer.jv b/libs/language-server/src/stdlib/builtin-blocktypes/TableTransformer.jv new file mode 100644 index 000000000..1676c7c59 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/TableTransformer.jv @@ -0,0 +1,45 @@ +/* +Applies a transform on each value of a column. The input port type of the used transform has to match the type of the input column. + +@example Given a column "temperature" with temperature values in Celsius, it overwrites the column with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model. + +transform CelsiusToFahrenheit { + from Celsius oftype decimal; + to Fahrenheit oftype decimal; + + Fahrenheit: (Celsius * 9/5) + 32; +} + +block CelsiusToFahrenheitTransformer oftype TableTransformer { + inputColumns: ['temperature']; + outputColumn: 'temperature'; + use: CelsiusToFahrenheit; +} + +@example Given a column "temperatureCelsius" with temperature values in Celsius, it adds a new column "temperatureFahrenheit" with computed values in Fahrenheit by using the `CelsiusToFahrenheit` transform. The transform itself is defined elsewhere in the model. + +transform CelsiusToFahrenheit { + from Celsius oftype decimal; + to Fahrenheit oftype decimal; + + Fahrenheit: (Celsius * 9/5) + 32; +} + +block CelsiusToFahrenheitTransformer oftype TableTransformer { + inputColumns: ['temperatureCelsius']; + outputColumn: 'temperatureFahrenheit'; + use: CelsiusToFahrenheit; +} +*/ +builtin blocktype TableTransformer { + input default oftype Table; + output default oftype Table; + + // The names of the input columns. The columns have to be present in the table and match with the transform's input port types. + property inputColumns oftype Collection; + // The name of the output column. Overwrites the column if it already exists, or otherwise creates a new one. + property outputColumn oftype text; + // Reference to the transform that is applied to the column. + property use oftype Transform; + // TODO: checkInputColumnsMatchTransformationPorts +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/TextFileInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/TextFileInterpreter.jv new file mode 100644 index 000000000..04cbc5401 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/TextFileInterpreter.jv @@ -0,0 +1,21 @@ +/* +Interprets a `File` as a `TextFile`. +*/ +builtin blocktype TextFileInterpreter { + input default oftype File; + output default oftype TextFile; + + // The encoding used for decoding the file contents. + property encoding oftype TextEncoding: 'utf-8'; + // The regex for identifying line breaks. + property lineBreak oftype Regex: /\r?\n/; + // TODO: check Regex valuetype +} + +valuetype TextEncoding { + constraints: [TextEncodingConstraint]; +} + +constraint TextEncodingConstraint on text: + // https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings + value in ['utf-8', 'ibm866', 'latin2', 'latin3', 'latin4', 'cyrillic', 'arabic', 'greek', 'hebrew', 'logical', 'latin6', 'utf-16']; diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/TextLineDeleter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/TextLineDeleter.jv new file mode 100644 index 000000000..2868184cd --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/TextLineDeleter.jv @@ -0,0 +1,17 @@ +/* +Deletes individual lines from a `TextFile`. +*/ +builtin blocktype TextLineDeleter { + input default oftype TextFile; + output default oftype TextFile; + + // The line numbers to delete. + property lines oftype Collection; +} + +valuetype TextLine { + constraints: [PositiveIntConstraint]; +} + +constraint PositiveIntConstraint on integer: + value > 0; \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/TextRangeSelector.jv b/libs/language-server/src/stdlib/builtin-blocktypes/TextRangeSelector.jv new file mode 100644 index 000000000..f71724f28 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/TextRangeSelector.jv @@ -0,0 +1,11 @@ +/* +Selects a range of lines from a `TextFile`. +*/ +builtin blocktype TextRangeSelector { + input default oftype TextFile; + output default oftype TextFile; + + property lineFrom oftype integer: 1; + property lineTo oftype integer: 999999; // TODO: allow sth like +Infinity + // TODO: ensure lineFrom <= lineTo +} \ No newline at end of file diff --git a/libs/language-server/src/stdlib/builtin-blocktypes/XlsInterpreter.jv b/libs/language-server/src/stdlib/builtin-blocktypes/XlsInterpreter.jv new file mode 100644 index 000000000..c74e6ade6 --- /dev/null +++ b/libs/language-server/src/stdlib/builtin-blocktypes/XlsInterpreter.jv @@ -0,0 +1,11 @@ +/* +Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s. + +@example Interprets an input file as a XLSX-file and outputs a `Workbook` containing `Sheet`s. +block AgencyXLSXInterpreter oftype XLSXInterpreter { + } +*/ +builtin blocktype XLSXInterpreter { + input default oftype File; + output default oftype Workbook; +} \ No newline at end of file diff --git a/tsconfig.base.json b/tsconfig.base.json index c164052d5..efd1f64e5 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -32,24 +32,15 @@ "@jvalue/jayvee-extensions/rdbms/test": [ "libs/extensions/rdbms/exec/test/index.ts" ], - "@jvalue/jayvee-extensions/rdbms/lang": [ - "libs/extensions/rdbms/lang/src/index.ts" - ], "@jvalue/jayvee-extensions/std/exec": [ "libs/extensions/std/exec/src/index.ts" ], "@jvalue/jayvee-extensions/std/test": [ "libs/extensions/std/exec/test/index.ts" ], - "@jvalue/jayvee-extensions/std/lang": [ - "libs/extensions/std/lang/src/index.ts" - ], "@jvalue/jayvee-extensions/tabular/exec": [ "libs/extensions/tabular/exec/src/index.ts" ], - "@jvalue/jayvee-extensions/tabular/lang": [ - "libs/extensions/tabular/lang/src/index.ts" - ], "@jvalue/jayvee-language-server": ["libs/language-server/src/index.ts"], "@jvalue/jayvee-language-server/test": [ "libs/language-server/src/test/index.ts"