@lbdudc/linea-core 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +230 -358
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/extra.js +54 -54
- package/dist/line/templates/core/transformation.js +208 -196
- package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
- package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
- package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +82 -67
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,67 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lbdudc/linea-core",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Motor autocontenido de Líneas de Producto Software (SPL): feature models, validación de specs y derivación de productos. Funciona 100% offline.",
|
|
5
|
-
"license": "
|
|
6
|
-
"author": "Laboratorio de Bases de Datos (LBD) - Universidade da Coruña",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@lbdudc/linea-core",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Motor autocontenido de Líneas de Producto Software (SPL): feature models, validación de specs y derivación de productos. Funciona 100% offline.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Laboratorio de Bases de Datos (LBD) - Universidade da Coruña",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./workspace": {
|
|
16
|
+
"types": "./dist/workspace/index.d.ts",
|
|
17
|
+
"import": "./dist/workspace/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.11"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/lbdudc/linea.git",
|
|
30
|
+
"directory": "packages/core"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/lbdudc/linea/tree/main/packages/core",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"spl",
|
|
35
|
+
"software-product-line",
|
|
36
|
+
"feature-model",
|
|
37
|
+
"uvl",
|
|
38
|
+
"derivation",
|
|
39
|
+
"linea",
|
|
40
|
+
"splalm"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc && node scripts/copy-assets.mjs",
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"lint:fix": "eslint . --fix",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:watch": "vitest",
|
|
50
|
+
"test:coverage": "vitest run --coverage",
|
|
51
|
+
"check:consumer": "npm run build && node scripts/check-consumer.mjs",
|
|
52
|
+
"check:install": "node scripts/check-install.mjs"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@lbdudc/flamapy.js": "^1.1.0",
|
|
56
|
+
"extract-zip": "^2.0.1",
|
|
57
|
+
"prettier": "^3.9.6",
|
|
58
|
+
"pyodide": "0.26.2",
|
|
59
|
+
"semver": "^7.8.5",
|
|
60
|
+
"spl-js-engine": "git+https://github.com/lbdudc/spl-js-engine.git#3b64b69b74495e3993fb08bee7daa9cf166d49fb"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@lbdudc/bango": "^0.2.0",
|
|
64
|
+
"@eslint/js": "^9.17.0",
|
|
65
|
+
"@types/node": "^20.17.0",
|
|
66
|
+
"@types/semver": "^7.8.0",
|
|
67
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
68
|
+
"eslint": "^9.17.0",
|
|
69
|
+
"globals": "^15.14.0",
|
|
70
|
+
"langium": "^4.4.0",
|
|
71
|
+
"typescript": "^5.7.2",
|
|
72
|
+
"typescript-eslint": "^8.18.0",
|
|
73
|
+
"vitest": "^2.1.8"
|
|
74
|
+
},
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/lbdudc/linea/issues"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public",
|
|
80
|
+
"provenance": true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Feature model notation conversion.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from `linea/server/src/model/services/LineService.js:convertFeatureModel`
|
|
5
|
-
* (~421-461), keeping ONLY the domain logic. Everything around it belongs to
|
|
6
|
-
* linea-server (ADR-003): permission checks, the GitLab commit that creates the
|
|
7
|
-
* new file and deletes the old one, the line version bump (`incrementVersion`)
|
|
8
|
-
* and the Mongo transaction.
|
|
9
|
-
*
|
|
10
|
-
* Note that the monolith derives the target notation from the line's current
|
|
11
|
-
* `featureModelType`; here both ends are explicit parameters, so the caller can
|
|
12
|
-
* convert a document it holds in memory without owning a line.
|
|
13
|
-
*/
|
|
14
|
-
import { type FeatureModelType } from '../constants.js';
|
|
15
|
-
/**
|
|
16
|
-
* Converts a feature model between UVL and XML.
|
|
17
|
-
*
|
|
18
|
-
* @param params.content Model document as plain text.
|
|
19
|
-
* @param params.from Notation of `content`.
|
|
20
|
-
* @param params.to Target notation.
|
|
21
|
-
* @returns The converted document and its notation.
|
|
22
|
-
* @throws {UnsupportedConversionError} when `from` equals `to` — there is no
|
|
23
|
-
* such thing as a UVL-to-UVL conversion, and silently returning the input
|
|
24
|
-
* would hide a caller bug.
|
|
25
|
-
* @throws {InvalidArgumentError} when a notation is unknown.
|
|
26
|
-
* @throws {UvlParseError} when `content` is not parseable UVL.
|
|
27
|
-
*/
|
|
28
|
-
export declare const convertFeatureModel: ({ content, from, to }: {
|
|
29
|
-
content: string;
|
|
30
|
-
from: FeatureModelType;
|
|
31
|
-
to: FeatureModelType;
|
|
32
|
-
}) => {
|
|
33
|
-
content: string;
|
|
34
|
-
type: FeatureModelType;
|
|
35
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Feature model notation conversion.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from `linea/server/src/model/services/LineService.js:convertFeatureModel`
|
|
5
|
-
* (~421-461), keeping ONLY the domain logic. Everything around it belongs to
|
|
6
|
-
* linea-server (ADR-003): permission checks, the GitLab commit that creates the
|
|
7
|
-
* new file and deletes the old one, the line version bump (`incrementVersion`)
|
|
8
|
-
* and the Mongo transaction.
|
|
9
|
-
*
|
|
10
|
-
* Note that the monolith derives the target notation from the line's current
|
|
11
|
-
* `featureModelType`; here both ends are explicit parameters, so the caller can
|
|
12
|
-
* convert a document it holds in memory without owning a line.
|
|
13
|
-
*/
|
|
14
|
-
import { isFeatureModelType } from '../constants.js';
|
|
15
|
-
import { InvalidArgumentError, UnsupportedConversionError } from '../errors.js';
|
|
16
|
-
import { modelToUvl, modelToXml } from './engine.js';
|
|
17
|
-
import { parseFeatureModel } from './parse.js';
|
|
18
|
-
/**
|
|
19
|
-
* Converts a feature model between UVL and XML.
|
|
20
|
-
*
|
|
21
|
-
* @param params.content Model document as plain text.
|
|
22
|
-
* @param params.from Notation of `content`.
|
|
23
|
-
* @param params.to Target notation.
|
|
24
|
-
* @returns The converted document and its notation.
|
|
25
|
-
* @throws {UnsupportedConversionError} when `from` equals `to` — there is no
|
|
26
|
-
* such thing as a UVL-to-UVL conversion, and silently returning the input
|
|
27
|
-
* would hide a caller bug.
|
|
28
|
-
* @throws {InvalidArgumentError} when a notation is unknown.
|
|
29
|
-
* @throws {UvlParseError} when `content` is not parseable UVL.
|
|
30
|
-
*/
|
|
31
|
-
export const convertFeatureModel = ({ content, from, to }) => {
|
|
32
|
-
if (!isFeatureModelType(from)) {
|
|
33
|
-
throw new InvalidArgumentError(`Unknown source feature model type "${String(from)}". Use "UVL" or "XML".`);
|
|
34
|
-
}
|
|
35
|
-
if (!isFeatureModelType(to)) {
|
|
36
|
-
throw new InvalidArgumentError(`Unknown target feature model type "${String(to)}". Use "UVL" or "XML".`);
|
|
37
|
-
}
|
|
38
|
-
if (from === to) {
|
|
39
|
-
throw new UnsupportedConversionError(`Cannot convert a feature model from "${from}" to itself.`);
|
|
40
|
-
}
|
|
41
|
-
const model = parseFeatureModel({ content, type: from });
|
|
42
|
-
return {
|
|
43
|
-
content: to === 'UVL' ? modelToUvl(model) : modelToXml(model),
|
|
44
|
-
type: to
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/feature-model/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAC/E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,OAAO,EACP,IAAI,EACJ,EAAE,EAKH,EAA+C,EAAE;IAChD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,oBAAoB,CAAC,sCAAsC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IAC5G,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAAC,sCAAsC,MAAM,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAA;IAC1G,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,0BAA0B,CAAC,wCAAwC,IAAI,cAAc,CAAC,CAAA;IAClG,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACxD,OAAO;QACL,OAAO,EAAE,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;QAC7D,IAAI,EAAE,EAAE;KACT,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\r\n * Feature model notation conversion.\r\n *\r\n * Migrated from `linea/server/src/model/services/LineService.js:convertFeatureModel`\r\n * (~421-461), keeping ONLY the domain logic. Everything around it belongs to\r\n * linea-server (ADR-003): permission checks, the GitLab commit that creates the\r\n * new file and deletes the old one, the line version bump (`incrementVersion`)\r\n * and the Mongo transaction.\r\n *\r\n * Note that the monolith derives the target notation from the line's current\r\n * `featureModelType`; here both ends are explicit parameters, so the caller can\r\n * convert a document it holds in memory without owning a line.\r\n */\r\nimport { isFeatureModelType, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError, UnsupportedConversionError } from '../errors.js'\r\nimport { modelToUvl, modelToXml } from './engine.js'\r\nimport { parseFeatureModel } from './parse.js'\r\n\r\n/**\r\n * Converts a feature model between UVL and XML.\r\n *\r\n * @param params.content Model document as plain text.\r\n * @param params.from Notation of `content`.\r\n * @param params.to Target notation.\r\n * @returns The converted document and its notation.\r\n * @throws {UnsupportedConversionError} when `from` equals `to` — there is no\r\n * such thing as a UVL-to-UVL conversion, and silently returning the input\r\n * would hide a caller bug.\r\n * @throws {InvalidArgumentError} when a notation is unknown.\r\n * @throws {UvlParseError} when `content` is not parseable UVL.\r\n */\r\nexport const convertFeatureModel = ({\r\n content,\r\n from,\r\n to\r\n}: {\r\n content: string\r\n from: FeatureModelType\r\n to: FeatureModelType\r\n}): { content: string, type: FeatureModelType } => {\r\n if (!isFeatureModelType(from)) {\r\n throw new InvalidArgumentError(`Unknown source feature model type \"${String(from)}\". Use \"UVL\" or \"XML\".`)\r\n }\r\n if (!isFeatureModelType(to)) {\r\n throw new InvalidArgumentError(`Unknown target feature model type \"${String(to)}\". Use \"UVL\" or \"XML\".`)\r\n }\r\n if (from === to) {\r\n throw new UnsupportedConversionError(`Cannot convert a feature model from \"${from}\" to itself.`)\r\n }\r\n\r\n const model = parseFeatureModel({ content, type: from })\r\n return {\r\n content: to === 'UVL' ? modelToUvl(model) : modelToXml(model),\r\n type: to\r\n }\r\n}\r\n"]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { FeatureModelType } from '../constants.js';
|
|
2
|
-
declare const featureModelBrand: unique symbol;
|
|
3
|
-
/**
|
|
4
|
-
* A parsed feature model.
|
|
5
|
-
*
|
|
6
|
-
* Opaque on purpose: it is really a `FeatureModel` from `spl-js-engine`, but
|
|
7
|
-
* that type is not part of linea-core's contract. Pass the value back into
|
|
8
|
-
* linea-core functions; do not introspect it.
|
|
9
|
-
*/
|
|
10
|
-
export interface FeatureModelValue {
|
|
11
|
-
readonly [featureModelBrand]: 'linea-core/FeatureModel';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Parses UVL or XML text into an opaque model value.
|
|
15
|
-
*
|
|
16
|
-
* Guards three engine quirks:
|
|
17
|
-
* - `FeatureModel.fromUVL` accepts a *path or* text. Neutralised by
|
|
18
|
-
* `asUvlContent`: whatever the caller passes is parsed as a document, and no
|
|
19
|
-
* file is ever opened.
|
|
20
|
-
* - The same path probe writes the entire document to stderr; see
|
|
21
|
-
* `withoutPathProbeNoise`.
|
|
22
|
-
* - `DerivationEngine.setFeatureModel` sniffs the notation with
|
|
23
|
-
* `featureModel.endsWith('uvl')` over the *content*. linea-core never relies
|
|
24
|
-
* on that: the notation is always an explicit parameter.
|
|
25
|
-
*/
|
|
26
|
-
export declare const parseModel: (content: string, type: FeatureModelType) => FeatureModelValue;
|
|
27
|
-
/** Serialises a model to UVL. */
|
|
28
|
-
export declare const modelToUvl: (value: FeatureModelValue) => string;
|
|
29
|
-
/** Serialises a model to XML. */
|
|
30
|
-
export declare const modelToXml: (value: FeatureModelValue) => string;
|
|
31
|
-
/** How a feature selection failed, normalised away from the engine's own shape. */
|
|
32
|
-
export interface SelectionFailure {
|
|
33
|
-
/** Human-readable reason. Never empty. */
|
|
34
|
-
readonly message: string;
|
|
35
|
-
/** Engine discriminator: `'TOO_MANY_CHILDS'`, `'MISSING_CHILD'`, or `null`. */
|
|
36
|
-
readonly errorType: string | null;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Whether `error` is the engine's `FeatureSelectionError`.
|
|
40
|
-
*
|
|
41
|
-
* Needed because it does not extend `Error`, so no generic guard identifies it.
|
|
42
|
-
* `runEngine` and `generateZip` in the monolith branch on exactly this check.
|
|
43
|
-
*/
|
|
44
|
-
export declare const isFeatureSelectionError: (error: unknown) => boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Classifies whatever `completeSelection` threw.
|
|
47
|
-
*
|
|
48
|
-
* `FeatureSelectionError` does NOT extend `Error`, so an `instanceof Error`
|
|
49
|
-
* branch falls through to `String(err)` for the very error it cares about. The
|
|
50
|
-
* message survives that (the class defines `toString()`), but **`errorType` does
|
|
51
|
-
* not**: the `TOO_MANY_CHILDS` / `MISSING_CHILD` discriminator is silently lost.
|
|
52
|
-
* Checked explicitly here so callers can branch on it.
|
|
53
|
-
*/
|
|
54
|
-
export declare const describeSelectionFailure: (error: unknown) => SelectionFailure;
|
|
55
|
-
/**
|
|
56
|
-
* Expands a partial selection into the full set of implied features.
|
|
57
|
-
* @throws the engine's `FeatureSelectionError` when the selection is invalid.
|
|
58
|
-
*/
|
|
59
|
-
export declare const completeSelection: (value: FeatureModelValue, features: string[]) => string[];
|
|
60
|
-
export {};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* INTERNAL adapter over `spl-js-engine`. This is the ONLY module in linea-core
|
|
3
|
-
* that imports the engine.
|
|
4
|
-
*
|
|
5
|
-
* Two reasons for the isolation:
|
|
6
|
-
*
|
|
7
|
-
* 1. The engine ships no types, so its declarations are hand-written
|
|
8
|
-
* (`src/types/spl-js-engine.d.ts`). Keeping every engine type out of the
|
|
9
|
-
* exported signatures below guarantees that no emitted `.d.ts` in `dist/`
|
|
10
|
-
* ever references `spl-js-engine` — consumers do not need our ambient
|
|
11
|
-
* declarations, and `skipLibCheck: false` on their side still works.
|
|
12
|
-
*
|
|
13
|
-
* 2. The engine API has sharp edges that must not reach linea-core's public
|
|
14
|
-
* surface (see `parseFeatureModel`).
|
|
15
|
-
*
|
|
16
|
-
* Not exported from `src/index.ts`.
|
|
17
|
-
*/
|
|
18
|
-
import { FeatureModel } from 'spl-js-engine';
|
|
19
|
-
import FeatureSelectionError from 'spl-js-engine/src/feature-model/feature-selection-error.js';
|
|
20
|
-
import { InvalidArgumentError, UvlParseError } from '../errors.js';
|
|
21
|
-
const toEngineModel = (value) => value;
|
|
22
|
-
const toValue = (model) => model;
|
|
23
|
-
const describe = (error) => error instanceof Error ? error.message : String(error);
|
|
24
|
-
/**
|
|
25
|
-
* Upstream noise filter for UVL parsing.
|
|
26
|
-
*
|
|
27
|
-
* `uvl-parser/src/FeatureModel.js:22-28` decides whether its argument is a path
|
|
28
|
-
* by calling `fs.statSync(str)` inside a try/catch that does
|
|
29
|
-
* `console.error('Error: ' + e)` before returning false. A UVL document is never
|
|
30
|
-
* a valid path, so EVERY successful parse dumps the whole model to stderr. For a
|
|
31
|
-
* library embedded in a TUI (linea-cli) that is corrupting output, not logging.
|
|
32
|
-
*
|
|
33
|
-
* This wrapper swallows exactly that message and forwards anything else. It is
|
|
34
|
-
* safe despite touching a global: `FeatureModel.fromUVL` is fully synchronous,
|
|
35
|
-
* so no other task can interleave, and the original `console.error` is restored
|
|
36
|
-
* in `finally`.
|
|
37
|
-
*/
|
|
38
|
-
const PARSER_PATH_PROBE_NOISE = /^Error: Error: (ENOENT|ENAMETOOLONG|ERR_INVALID_ARG_VALUE)/;
|
|
39
|
-
const withoutPathProbeNoise = (run) => {
|
|
40
|
-
const original = console.error;
|
|
41
|
-
console.error = (...args) => {
|
|
42
|
-
const first = args[0];
|
|
43
|
-
if (typeof first === 'string' && PARSER_PATH_PROBE_NOISE.test(first))
|
|
44
|
-
return;
|
|
45
|
-
original(...args);
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
return run();
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
51
|
-
console.error = original;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Forces `FeatureModel.fromUVL` to treat its argument as CONTENT, never as a path.
|
|
56
|
-
*
|
|
57
|
-
* `uvl-parser` decides with `fs.statSync(str)`: when the string happens to name
|
|
58
|
-
* an existing file it reads that file through `antlr4.FileStream` instead of
|
|
59
|
-
* parsing what it was given. Since linea-server hands user-controlled bodies to
|
|
60
|
-
* `PUT /api/lines/:id/model` and `POST /api/lines/:id/model/convert` straight
|
|
61
|
-
* into these functions, that is an arbitrary-file-read primitive — and relative
|
|
62
|
-
* paths would resolve against `process.cwd()`, breaking the "no ambient state"
|
|
63
|
-
* invariant of ADR-009/ADR-014.
|
|
64
|
-
*
|
|
65
|
-
* A trailing newline makes `statSync` fail with ENOENT on both Windows and
|
|
66
|
-
* Linux, and is semantically inert in UVL. The monolith carries the same defect;
|
|
67
|
-
* linea-core is the layer that closes it.
|
|
68
|
-
*
|
|
69
|
-
* Appended UNCONDITIONALLY. A "only if it does not already end in \n" guard
|
|
70
|
-
* would leave a gap on Linux, where a file name may legally contain a newline,
|
|
71
|
-
* so `"/tmp/evil\n"` would reach `statSync` untouched. A doubled trailing
|
|
72
|
-
* newline is inert in UVL, so there is nothing to trade off.
|
|
73
|
-
*/
|
|
74
|
-
const asUvlContent = (content) => `${content}\n`;
|
|
75
|
-
/**
|
|
76
|
-
* Parses UVL or XML text into an opaque model value.
|
|
77
|
-
*
|
|
78
|
-
* Guards three engine quirks:
|
|
79
|
-
* - `FeatureModel.fromUVL` accepts a *path or* text. Neutralised by
|
|
80
|
-
* `asUvlContent`: whatever the caller passes is parsed as a document, and no
|
|
81
|
-
* file is ever opened.
|
|
82
|
-
* - The same path probe writes the entire document to stderr; see
|
|
83
|
-
* `withoutPathProbeNoise`.
|
|
84
|
-
* - `DerivationEngine.setFeatureModel` sniffs the notation with
|
|
85
|
-
* `featureModel.endsWith('uvl')` over the *content*. linea-core never relies
|
|
86
|
-
* on that: the notation is always an explicit parameter.
|
|
87
|
-
*/
|
|
88
|
-
export const parseModel = (content, type) => {
|
|
89
|
-
try {
|
|
90
|
-
return toValue(type === 'XML'
|
|
91
|
-
? FeatureModel.fromXml(content)
|
|
92
|
-
: withoutPathProbeNoise(() => FeatureModel.fromUVL(asUvlContent(content))));
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
if (type === 'XML') {
|
|
96
|
-
throw new InvalidArgumentError(`Could not parse the XML feature model: ${describe(error)}`, {
|
|
97
|
-
cause: error
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
throw new UvlParseError(`Could not parse the UVL feature model: ${describe(error)}`, {
|
|
101
|
-
cause: error
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
/** Serialises a model to UVL. */
|
|
106
|
-
export const modelToUvl = (value) => toEngineModel(value).toUVL();
|
|
107
|
-
/** Serialises a model to XML. */
|
|
108
|
-
export const modelToXml = (value) => toEngineModel(value).toXml();
|
|
109
|
-
/**
|
|
110
|
-
* Whether `error` is the engine's `FeatureSelectionError`.
|
|
111
|
-
*
|
|
112
|
-
* Needed because it does not extend `Error`, so no generic guard identifies it.
|
|
113
|
-
* `runEngine` and `generateZip` in the monolith branch on exactly this check.
|
|
114
|
-
*/
|
|
115
|
-
export const isFeatureSelectionError = (error) => error instanceof FeatureSelectionError;
|
|
116
|
-
/**
|
|
117
|
-
* Classifies whatever `completeSelection` threw.
|
|
118
|
-
*
|
|
119
|
-
* `FeatureSelectionError` does NOT extend `Error`, so an `instanceof Error`
|
|
120
|
-
* branch falls through to `String(err)` for the very error it cares about. The
|
|
121
|
-
* message survives that (the class defines `toString()`), but **`errorType` does
|
|
122
|
-
* not**: the `TOO_MANY_CHILDS` / `MISSING_CHILD` discriminator is silently lost.
|
|
123
|
-
* Checked explicitly here so callers can branch on it.
|
|
124
|
-
*/
|
|
125
|
-
export const describeSelectionFailure = (error) => {
|
|
126
|
-
if (error instanceof FeatureSelectionError) {
|
|
127
|
-
return { message: error.message, errorType: error.errorType ?? null };
|
|
128
|
-
}
|
|
129
|
-
if (error instanceof Error) {
|
|
130
|
-
return { message: error.message, errorType: null };
|
|
131
|
-
}
|
|
132
|
-
return { message: String(error), errorType: null };
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Expands a partial selection into the full set of implied features.
|
|
136
|
-
* @throws the engine's `FeatureSelectionError` when the selection is invalid.
|
|
137
|
-
*/
|
|
138
|
-
export const completeSelection = (value, features) => toEngineModel(value).completeFeatureSelection(features);
|
|
139
|
-
//# sourceMappingURL=engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/feature-model/engine.ts"],"names":[],"mappings":"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","sourcesContent":["/**\r\n * INTERNAL adapter over `spl-js-engine`. This is the ONLY module in linea-core\r\n * that imports the engine.\r\n *\r\n * Two reasons for the isolation:\r\n *\r\n * 1. The engine ships no types, so its declarations are hand-written\r\n * (`src/types/spl-js-engine.d.ts`). Keeping every engine type out of the\r\n * exported signatures below guarantees that no emitted `.d.ts` in `dist/`\r\n * ever references `spl-js-engine` — consumers do not need our ambient\r\n * declarations, and `skipLibCheck: false` on their side still works.\r\n *\r\n * 2. The engine API has sharp edges that must not reach linea-core's public\r\n * surface (see `parseFeatureModel`).\r\n *\r\n * Not exported from `src/index.ts`.\r\n */\r\nimport { FeatureModel } from 'spl-js-engine'\r\nimport FeatureSelectionError from 'spl-js-engine/src/feature-model/feature-selection-error.js'\r\nimport type { FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError, UvlParseError } from '../errors.js'\r\n\r\ndeclare const featureModelBrand: unique symbol\r\n\r\n/**\r\n * A parsed feature model.\r\n *\r\n * Opaque on purpose: it is really a `FeatureModel` from `spl-js-engine`, but\r\n * that type is not part of linea-core's contract. Pass the value back into\r\n * linea-core functions; do not introspect it.\r\n */\r\nexport interface FeatureModelValue {\r\n readonly [featureModelBrand]: 'linea-core/FeatureModel'\r\n}\r\n\r\nconst toEngineModel = (value: FeatureModelValue): FeatureModel =>\r\n value as unknown as FeatureModel\r\n\r\nconst toValue = (model: FeatureModel): FeatureModelValue =>\r\n model as unknown as FeatureModelValue\r\n\r\nconst describe = (error: unknown): string =>\r\n error instanceof Error ? error.message : String(error)\r\n\r\n/**\r\n * Upstream noise filter for UVL parsing.\r\n *\r\n * `uvl-parser/src/FeatureModel.js:22-28` decides whether its argument is a path\r\n * by calling `fs.statSync(str)` inside a try/catch that does\r\n * `console.error('Error: ' + e)` before returning false. A UVL document is never\r\n * a valid path, so EVERY successful parse dumps the whole model to stderr. For a\r\n * library embedded in a TUI (linea-cli) that is corrupting output, not logging.\r\n *\r\n * This wrapper swallows exactly that message and forwards anything else. It is\r\n * safe despite touching a global: `FeatureModel.fromUVL` is fully synchronous,\r\n * so no other task can interleave, and the original `console.error` is restored\r\n * in `finally`.\r\n */\r\nconst PARSER_PATH_PROBE_NOISE = /^Error: Error: (ENOENT|ENAMETOOLONG|ERR_INVALID_ARG_VALUE)/\r\n\r\nconst withoutPathProbeNoise = <T>(run: () => T): T => {\r\n const original = console.error\r\n console.error = (...args: unknown[]): void => {\r\n const first = args[0]\r\n if (typeof first === 'string' && PARSER_PATH_PROBE_NOISE.test(first)) return\r\n original(...args)\r\n }\r\n try {\r\n return run()\r\n } finally {\r\n console.error = original\r\n }\r\n}\r\n\r\n/**\r\n * Forces `FeatureModel.fromUVL` to treat its argument as CONTENT, never as a path.\r\n *\r\n * `uvl-parser` decides with `fs.statSync(str)`: when the string happens to name\r\n * an existing file it reads that file through `antlr4.FileStream` instead of\r\n * parsing what it was given. Since linea-server hands user-controlled bodies to\r\n * `PUT /api/lines/:id/model` and `POST /api/lines/:id/model/convert` straight\r\n * into these functions, that is an arbitrary-file-read primitive — and relative\r\n * paths would resolve against `process.cwd()`, breaking the \"no ambient state\"\r\n * invariant of ADR-009/ADR-014.\r\n *\r\n * A trailing newline makes `statSync` fail with ENOENT on both Windows and\r\n * Linux, and is semantically inert in UVL. The monolith carries the same defect;\r\n * linea-core is the layer that closes it.\r\n *\r\n * Appended UNCONDITIONALLY. A \"only if it does not already end in \\n\" guard\r\n * would leave a gap on Linux, where a file name may legally contain a newline,\r\n * so `\"/tmp/evil\\n\"` would reach `statSync` untouched. A doubled trailing\r\n * newline is inert in UVL, so there is nothing to trade off.\r\n */\r\nconst asUvlContent = (content: string): string => `${content}\\n`\r\n\r\n/**\r\n * Parses UVL or XML text into an opaque model value.\r\n *\r\n * Guards three engine quirks:\r\n * - `FeatureModel.fromUVL` accepts a *path or* text. Neutralised by\r\n * `asUvlContent`: whatever the caller passes is parsed as a document, and no\r\n * file is ever opened.\r\n * - The same path probe writes the entire document to stderr; see\r\n * `withoutPathProbeNoise`.\r\n * - `DerivationEngine.setFeatureModel` sniffs the notation with\r\n * `featureModel.endsWith('uvl')` over the *content*. linea-core never relies\r\n * on that: the notation is always an explicit parameter.\r\n */\r\nexport const parseModel = (content: string, type: FeatureModelType): FeatureModelValue => {\r\n try {\r\n return toValue(\r\n type === 'XML'\r\n ? FeatureModel.fromXml(content)\r\n : withoutPathProbeNoise(() => FeatureModel.fromUVL(asUvlContent(content)))\r\n )\r\n } catch (error) {\r\n if (type === 'XML') {\r\n throw new InvalidArgumentError(`Could not parse the XML feature model: ${describe(error)}`, {\r\n cause: error\r\n })\r\n }\r\n throw new UvlParseError(`Could not parse the UVL feature model: ${describe(error)}`, {\r\n cause: error\r\n })\r\n }\r\n}\r\n\r\n/** Serialises a model to UVL. */\r\nexport const modelToUvl = (value: FeatureModelValue): string => toEngineModel(value).toUVL()\r\n\r\n/** Serialises a model to XML. */\r\nexport const modelToXml = (value: FeatureModelValue): string => toEngineModel(value).toXml()\r\n\r\n/** How a feature selection failed, normalised away from the engine's own shape. */\r\nexport interface SelectionFailure {\r\n /** Human-readable reason. Never empty. */\r\n readonly message: string\r\n /** Engine discriminator: `'TOO_MANY_CHILDS'`, `'MISSING_CHILD'`, or `null`. */\r\n readonly errorType: string | null\r\n}\r\n\r\n/**\r\n * Whether `error` is the engine's `FeatureSelectionError`.\r\n *\r\n * Needed because it does not extend `Error`, so no generic guard identifies it.\r\n * `runEngine` and `generateZip` in the monolith branch on exactly this check.\r\n */\r\nexport const isFeatureSelectionError = (error: unknown): boolean =>\r\n error instanceof FeatureSelectionError\r\n\r\n/**\r\n * Classifies whatever `completeSelection` threw.\r\n *\r\n * `FeatureSelectionError` does NOT extend `Error`, so an `instanceof Error`\r\n * branch falls through to `String(err)` for the very error it cares about. The\r\n * message survives that (the class defines `toString()`), but **`errorType` does\r\n * not**: the `TOO_MANY_CHILDS` / `MISSING_CHILD` discriminator is silently lost.\r\n * Checked explicitly here so callers can branch on it.\r\n */\r\nexport const describeSelectionFailure = (error: unknown): SelectionFailure => {\r\n if (error instanceof FeatureSelectionError) {\r\n return { message: error.message, errorType: error.errorType ?? null }\r\n }\r\n if (error instanceof Error) {\r\n return { message: error.message, errorType: null }\r\n }\r\n return { message: String(error), errorType: null }\r\n}\r\n\r\n/**\r\n * Expands a partial selection into the full set of implied features.\r\n * @throws the engine's `FeatureSelectionError` when the selection is invalid.\r\n */\r\nexport const completeSelection = (value: FeatureModelValue, features: string[]): string[] =>\r\n toEngineModel(value).completeFeatureSelection(features)\r\n"]}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-only inspection of feature models.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from `linea/server/src/agents/tools/fmAnalysis.js`
|
|
5
|
-
* (`extractFeaturesFromModel`, `computeMandatoryFeatures`). The aggregate
|
|
6
|
-
* portfolio helpers of that file (`computePortfolioAnomalies`,
|
|
7
|
-
* `computePairCoverage`, `findCouplingSmells`) work over product verdicts, not
|
|
8
|
-
* over the model, and belong with the product operations.
|
|
9
|
-
*/
|
|
10
|
-
import { type FeatureModelType } from '../constants.js';
|
|
11
|
-
import { type FeatureModelValue } from './engine.js';
|
|
12
|
-
/**
|
|
13
|
-
* Extracts feature names from a model document without parsing it.
|
|
14
|
-
*
|
|
15
|
-
* Conservative by design, exactly as the monolith documents it: it prefers false
|
|
16
|
-
* positives over false negatives, so a few extra identifiers (type names, for
|
|
17
|
-
* instance) may show up. Callers that need exact names should parse the model
|
|
18
|
-
* and use the engine instead.
|
|
19
|
-
*
|
|
20
|
-
* HARDENED PORT, not a verbatim one. `fmAnalysis.js:extractFeaturesFromModel`
|
|
21
|
-
* coerces the notation with `(type ?? 'UVL').toUpperCase()`, defaulting a
|
|
22
|
-
* missing or lowercase value to UVL. This function requires an exact `'UVL'` or
|
|
23
|
-
* `'XML'` and throws otherwise.
|
|
24
|
-
*
|
|
25
|
-
* That matters when migrating callers: `line.featureModelType` can be
|
|
26
|
-
* `undefined` for lines created before the field existed, which is why
|
|
27
|
-
* `LineService.js:284,401,432` all write `(line.featureModelType ?? 'UVL')`.
|
|
28
|
-
* Applying that same default is now the CALLER's responsibility — whoever ports
|
|
29
|
-
* `lineHealthAgent.js:89` must pass `line.featureModelType ?? 'UVL'` explicitly
|
|
30
|
-
* or they will get an `InvalidArgumentError` on legacy lines.
|
|
31
|
-
*
|
|
32
|
-
* @param params.content Model document as plain text.
|
|
33
|
-
* @param params.type Notation of `content`. Exact, never coerced.
|
|
34
|
-
* @returns Feature names, de-duplicated, in order of first appearance.
|
|
35
|
-
* @throws {InvalidArgumentError} when `content` is not a string or `type` is unknown.
|
|
36
|
-
*/
|
|
37
|
-
export declare const extractFeatureNames: ({ content, type }: {
|
|
38
|
-
content: string;
|
|
39
|
-
type: FeatureModelType;
|
|
40
|
-
}) => string[];
|
|
41
|
-
/** Outcome of probing a model with an empty selection. */
|
|
42
|
-
export interface MandatoryFeaturesResult {
|
|
43
|
-
/** `true` when the model admits no valid configuration at all. */
|
|
44
|
-
readonly voidModel: boolean;
|
|
45
|
-
/** Features implied even by an empty selection. */
|
|
46
|
-
readonly mandatory: string[];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Probes a model with an empty selection to detect the void-model case and the
|
|
50
|
-
* features that are always present.
|
|
51
|
-
*
|
|
52
|
-
* Port of `fmAnalysis.js:computeMandatoryFeatures`, keeping its
|
|
53
|
-
* degrade-gracefully contract intact: any failure from the ENGINE is reported as
|
|
54
|
-
* `voidModel: true` with an empty `mandatory`, never as a thrown error.
|
|
55
|
-
*
|
|
56
|
-
* HARDENED on one point: the monolith would happily accept a non-model and
|
|
57
|
-
* return `{ voidModel: true }` because its `try` swallows the `TypeError` too.
|
|
58
|
-
* Here an argument that is not a parsed model is a caller bug and throws, so it
|
|
59
|
-
* cannot masquerade as an unsatisfiable model.
|
|
60
|
-
*
|
|
61
|
-
* @param params.model A model returned by `parseFeatureModel`.
|
|
62
|
-
* @returns Whether the model is void, and its mandatory features.
|
|
63
|
-
* @throws {InvalidArgumentError} when `model` did not come from `parseFeatureModel`.
|
|
64
|
-
*/
|
|
65
|
-
export declare const computeMandatoryFeatures: ({ model }: {
|
|
66
|
-
model: FeatureModelValue;
|
|
67
|
-
}) => MandatoryFeaturesResult;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-only inspection of feature models.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from `linea/server/src/agents/tools/fmAnalysis.js`
|
|
5
|
-
* (`extractFeaturesFromModel`, `computeMandatoryFeatures`). The aggregate
|
|
6
|
-
* portfolio helpers of that file (`computePortfolioAnomalies`,
|
|
7
|
-
* `computePairCoverage`, `findCouplingSmells`) work over product verdicts, not
|
|
8
|
-
* over the model, and belong with the product operations.
|
|
9
|
-
*/
|
|
10
|
-
import { isFeatureModelType } from '../constants.js';
|
|
11
|
-
import { InvalidArgumentError } from '../errors.js';
|
|
12
|
-
import { completeSelection } from './engine.js';
|
|
13
|
-
/**
|
|
14
|
-
* UVL tokens that are never feature names.
|
|
15
|
-
* Verbatim from `fmAnalysis.js:UVL_KEYWORDS`.
|
|
16
|
-
*/
|
|
17
|
-
const UVL_KEYWORDS = new Set([
|
|
18
|
-
'features', 'constraints', 'mandatory', 'optional', 'alternative', 'or', 'and',
|
|
19
|
-
'as', 'type', 'String', 'Integer', 'Real', 'Boolean', 'include', 'namespace',
|
|
20
|
-
'cardinality', 'abstract', 'true', 'false', 'null'
|
|
21
|
-
]);
|
|
22
|
-
/** Port of `fmAnalysis.js:parseUvlFeatureNames`; same tokens, same output. */
|
|
23
|
-
const parseUvlFeatureNames = (uvl) => {
|
|
24
|
-
const names = new Set();
|
|
25
|
-
for (const line of uvl.split('\n')) {
|
|
26
|
-
const trimmed = line.trim();
|
|
27
|
-
if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#'))
|
|
28
|
-
continue;
|
|
29
|
-
// Namespace declarations are not feature lines.
|
|
30
|
-
if (trimmed.startsWith('namespace'))
|
|
31
|
-
continue;
|
|
32
|
-
for (const match of trimmed.matchAll(/\b([A-Za-z_][A-Za-z0-9_]*)\b/g)) {
|
|
33
|
-
const name = match[1];
|
|
34
|
-
if (name !== undefined && !UVL_KEYWORDS.has(name))
|
|
35
|
-
names.add(name);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return [...names];
|
|
39
|
-
};
|
|
40
|
-
/** Port of `fmAnalysis.js:parseXmlFeatureNames`; same regex, same output. */
|
|
41
|
-
const parseXmlFeatureNames = (xml) => {
|
|
42
|
-
const names = new Set();
|
|
43
|
-
for (const match of xml.matchAll(/\bname="([^"]+)"/g)) {
|
|
44
|
-
const name = match[1];
|
|
45
|
-
if (name !== undefined)
|
|
46
|
-
names.add(name);
|
|
47
|
-
}
|
|
48
|
-
return [...names];
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Extracts feature names from a model document without parsing it.
|
|
52
|
-
*
|
|
53
|
-
* Conservative by design, exactly as the monolith documents it: it prefers false
|
|
54
|
-
* positives over false negatives, so a few extra identifiers (type names, for
|
|
55
|
-
* instance) may show up. Callers that need exact names should parse the model
|
|
56
|
-
* and use the engine instead.
|
|
57
|
-
*
|
|
58
|
-
* HARDENED PORT, not a verbatim one. `fmAnalysis.js:extractFeaturesFromModel`
|
|
59
|
-
* coerces the notation with `(type ?? 'UVL').toUpperCase()`, defaulting a
|
|
60
|
-
* missing or lowercase value to UVL. This function requires an exact `'UVL'` or
|
|
61
|
-
* `'XML'` and throws otherwise.
|
|
62
|
-
*
|
|
63
|
-
* That matters when migrating callers: `line.featureModelType` can be
|
|
64
|
-
* `undefined` for lines created before the field existed, which is why
|
|
65
|
-
* `LineService.js:284,401,432` all write `(line.featureModelType ?? 'UVL')`.
|
|
66
|
-
* Applying that same default is now the CALLER's responsibility — whoever ports
|
|
67
|
-
* `lineHealthAgent.js:89` must pass `line.featureModelType ?? 'UVL'` explicitly
|
|
68
|
-
* or they will get an `InvalidArgumentError` on legacy lines.
|
|
69
|
-
*
|
|
70
|
-
* @param params.content Model document as plain text.
|
|
71
|
-
* @param params.type Notation of `content`. Exact, never coerced.
|
|
72
|
-
* @returns Feature names, de-duplicated, in order of first appearance.
|
|
73
|
-
* @throws {InvalidArgumentError} when `content` is not a string or `type` is unknown.
|
|
74
|
-
*/
|
|
75
|
-
export const extractFeatureNames = ({ content, type }) => {
|
|
76
|
-
if (typeof content !== 'string') {
|
|
77
|
-
throw new InvalidArgumentError('"content" must be a string.');
|
|
78
|
-
}
|
|
79
|
-
if (!isFeatureModelType(type)) {
|
|
80
|
-
throw new InvalidArgumentError(`Unknown feature model type "${String(type)}". Use "UVL" or "XML".`);
|
|
81
|
-
}
|
|
82
|
-
return type === 'XML' ? parseXmlFeatureNames(content) : parseUvlFeatureNames(content);
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Probes a model with an empty selection to detect the void-model case and the
|
|
86
|
-
* features that are always present.
|
|
87
|
-
*
|
|
88
|
-
* Port of `fmAnalysis.js:computeMandatoryFeatures`, keeping its
|
|
89
|
-
* degrade-gracefully contract intact: any failure from the ENGINE is reported as
|
|
90
|
-
* `voidModel: true` with an empty `mandatory`, never as a thrown error.
|
|
91
|
-
*
|
|
92
|
-
* HARDENED on one point: the monolith would happily accept a non-model and
|
|
93
|
-
* return `{ voidModel: true }` because its `try` swallows the `TypeError` too.
|
|
94
|
-
* Here an argument that is not a parsed model is a caller bug and throws, so it
|
|
95
|
-
* cannot masquerade as an unsatisfiable model.
|
|
96
|
-
*
|
|
97
|
-
* @param params.model A model returned by `parseFeatureModel`.
|
|
98
|
-
* @returns Whether the model is void, and its mandatory features.
|
|
99
|
-
* @throws {InvalidArgumentError} when `model` did not come from `parseFeatureModel`.
|
|
100
|
-
*/
|
|
101
|
-
export const computeMandatoryFeatures = ({ model }) => {
|
|
102
|
-
if (model === null || typeof model !== 'object') {
|
|
103
|
-
throw new InvalidArgumentError('"model" must be a value returned by parseFeatureModel().');
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
const result = completeSelection(model, []);
|
|
107
|
-
return { voidModel: false, mandatory: Array.isArray(result) ? result : [] };
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
return { voidModel: true, mandatory: [] };
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
//# sourceMappingURL=inspect.js.map
|