@lbdudc/linea-core 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/README.md +132 -260
  2. package/dist/analysis/analyze.d.ts +0 -54
  3. package/dist/analysis/analyze.js +1 -70
  4. package/dist/analysis/analyze.js.map +1 -1
  5. package/dist/analysis/runtime.d.ts +4 -73
  6. package/dist/analysis/runtime.js +7 -100
  7. package/dist/analysis/runtime.js.map +1 -1
  8. package/dist/analysis/uvl-text.d.ts +8 -0
  9. package/dist/analysis/uvl-text.js +70 -0
  10. package/dist/analysis/uvl-text.js.map +1 -0
  11. package/dist/assets.d.ts +0 -12
  12. package/dist/assets.js +0 -25
  13. package/dist/assets.js.map +1 -1
  14. package/dist/ci/annotations.d.ts +6 -0
  15. package/dist/ci/annotations.js +12 -0
  16. package/dist/ci/annotations.js.map +1 -0
  17. package/dist/ci/leftovers.d.ts +25 -0
  18. package/dist/ci/leftovers.js +50 -0
  19. package/dist/ci/leftovers.js.map +1 -0
  20. package/dist/ci/pairwise.d.ts +11 -0
  21. package/dist/ci/pairwise.js +35 -0
  22. package/dist/ci/pairwise.js.map +1 -0
  23. package/dist/ci/pipeline.d.ts +18 -0
  24. package/dist/ci/pipeline.js +26 -0
  25. package/dist/ci/pipeline.js.map +1 -0
  26. package/dist/ci/select.d.ts +28 -0
  27. package/dist/ci/select.js +43 -0
  28. package/dist/ci/select.js.map +1 -0
  29. package/dist/ci/validate-specs.d.ts +52 -0
  30. package/dist/ci/validate-specs.js +212 -0
  31. package/dist/ci/validate-specs.js.map +1 -0
  32. package/dist/constants.d.ts +1 -60
  33. package/dist/constants.js +1 -58
  34. package/dist/constants.js.map +1 -1
  35. package/dist/derivation/derive.d.ts +0 -56
  36. package/dist/derivation/derive.js +21 -72
  37. package/dist/derivation/derive.js.map +1 -1
  38. package/dist/derivation/engine.d.ts +10 -42
  39. package/dist/derivation/engine.js +37 -68
  40. package/dist/derivation/engine.js.map +1 -1
  41. package/dist/derivation/selection-error.d.ts +7 -0
  42. package/dist/derivation/selection-error.js +13 -0
  43. package/dist/derivation/selection-error.js.map +1 -0
  44. package/dist/errors.d.ts +19 -47
  45. package/dist/errors.js +28 -47
  46. package/dist/errors.js.map +1 -1
  47. package/dist/feature-model/uvl.d.ts +52 -0
  48. package/dist/feature-model/uvl.js +191 -0
  49. package/dist/feature-model/uvl.js.map +1 -0
  50. package/dist/fs/archive.d.ts +0 -16
  51. package/dist/fs/archive.js +0 -36
  52. package/dist/fs/archive.js.map +1 -1
  53. package/dist/fs/diff.d.ts +0 -30
  54. package/dist/fs/diff.js +4 -65
  55. package/dist/fs/diff.js.map +1 -1
  56. package/dist/fs/format.d.ts +0 -16
  57. package/dist/fs/format.js +0 -52
  58. package/dist/fs/format.js.map +1 -1
  59. package/dist/fs/workspace.d.ts +0 -52
  60. package/dist/fs/workspace.js +0 -56
  61. package/dist/fs/workspace.js.map +1 -1
  62. package/dist/index.d.ts +23 -29
  63. package/dist/index.js +15 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/guards.d.ts +0 -13
  66. package/dist/internal/guards.js +0 -13
  67. package/dist/internal/guards.js.map +1 -1
  68. package/dist/line/deletion.d.ts +33 -0
  69. package/dist/line/deletion.js +23 -0
  70. package/dist/line/deletion.js.map +1 -0
  71. package/dist/line/platform-files.d.ts +15 -64
  72. package/dist/line/platform-files.js +18 -94
  73. package/dist/line/platform-files.js.map +1 -1
  74. package/dist/line/restoration.d.ts +27 -0
  75. package/dist/line/restoration.js +27 -0
  76. package/dist/line/restoration.js.map +1 -0
  77. package/dist/line/scaffold.d.ts +26 -57
  78. package/dist/line/scaffold.js +32 -93
  79. package/dist/line/scaffold.js.map +1 -1
  80. package/dist/line/templates/core/transformation.js +17 -5
  81. package/dist/line/templates/pipeline/github-ci.yml +50 -0
  82. package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
  83. package/dist/modules/configuration/configure.d.ts +52 -0
  84. package/dist/modules/configuration/configure.js +101 -0
  85. package/dist/modules/configuration/configure.js.map +1 -0
  86. package/dist/modules/configuration/constants.d.ts +17 -0
  87. package/dist/modules/configuration/constants.js +14 -0
  88. package/dist/modules/configuration/constants.js.map +1 -0
  89. package/dist/modules/configuration/index.d.ts +6 -0
  90. package/dist/modules/configuration/index.js +5 -0
  91. package/dist/modules/configuration/index.js.map +1 -0
  92. package/dist/modules/configuration/names.d.ts +9 -0
  93. package/dist/modules/configuration/names.js +7 -0
  94. package/dist/modules/configuration/names.js.map +1 -0
  95. package/dist/modules/configuration/selection.d.ts +32 -0
  96. package/dist/modules/configuration/selection.js +49 -0
  97. package/dist/modules/configuration/selection.js.map +1 -0
  98. package/dist/modules/diagnostics.d.ts +2 -0
  99. package/dist/modules/diagnostics.js +2 -0
  100. package/dist/modules/diagnostics.js.map +1 -0
  101. package/dist/modules/index.d.ts +18 -0
  102. package/dist/modules/index.js +18 -0
  103. package/dist/modules/index.js.map +1 -0
  104. package/dist/modules/metamodels/engine.d.ts +93 -0
  105. package/dist/modules/metamodels/engine.js +10 -0
  106. package/dist/modules/metamodels/engine.js.map +1 -0
  107. package/dist/modules/metamodels/files.d.ts +40 -0
  108. package/dist/modules/metamodels/files.js +58 -0
  109. package/dist/modules/metamodels/files.js.map +1 -0
  110. package/dist/modules/metamodels/index.d.ts +8 -0
  111. package/dist/modules/metamodels/index.js +5 -0
  112. package/dist/modules/metamodels/index.js.map +1 -0
  113. package/dist/modules/metamodels/layout.d.ts +23 -0
  114. package/dist/modules/metamodels/layout.js +29 -0
  115. package/dist/modules/metamodels/layout.js.map +1 -0
  116. package/dist/modules/metamodels/offered.d.ts +15 -0
  117. package/dist/modules/metamodels/offered.js +14 -0
  118. package/dist/modules/metamodels/offered.js.map +1 -0
  119. package/dist/modules/metamodels/prepare.d.ts +20 -0
  120. package/dist/modules/metamodels/prepare.js +155 -0
  121. package/dist/modules/metamodels/prepare.js.map +1 -0
  122. package/dist/modules/packages/index.d.ts +4 -0
  123. package/dist/modules/packages/index.js +4 -0
  124. package/dist/modules/packages/index.js.map +1 -0
  125. package/dist/modules/packages/location.d.ts +21 -0
  126. package/dist/modules/packages/location.js +34 -0
  127. package/dist/modules/packages/location.js.map +1 -0
  128. package/dist/modules/packages/manifests.d.ts +33 -0
  129. package/dist/modules/packages/manifests.js +231 -0
  130. package/dist/modules/packages/manifests.js.map +1 -0
  131. package/dist/modules/packages/source.d.ts +34 -0
  132. package/dist/modules/packages/source.js +128 -0
  133. package/dist/modules/packages/source.js.map +1 -0
  134. package/dist/modules/products/check.d.ts +28 -0
  135. package/dist/modules/products/check.js +61 -0
  136. package/dist/modules/products/check.js.map +1 -0
  137. package/dist/modules/products/derive.d.ts +30 -0
  138. package/dist/modules/products/derive.js +56 -0
  139. package/dist/modules/products/derive.js.map +1 -0
  140. package/dist/modules/products/index.d.ts +5 -0
  141. package/dist/modules/products/index.js +4 -0
  142. package/dist/modules/products/index.js.map +1 -0
  143. package/dist/modules/products/seed.d.ts +18 -0
  144. package/dist/modules/products/seed.js +23 -0
  145. package/dist/modules/products/seed.js.map +1 -0
  146. package/dist/modules/registry/catalog.d.ts +64 -0
  147. package/dist/modules/registry/catalog.js +91 -0
  148. package/dist/modules/registry/catalog.js.map +1 -0
  149. package/dist/modules/registry/index.d.ts +5 -0
  150. package/dist/modules/registry/index.js +4 -0
  151. package/dist/modules/registry/index.js.map +1 -0
  152. package/dist/modules/registry/registry.d.ts +34 -0
  153. package/dist/modules/registry/registry.js +37 -0
  154. package/dist/modules/registry/registry.js.map +1 -0
  155. package/dist/modules/registry/routing.d.ts +8 -0
  156. package/dist/modules/registry/routing.js +23 -0
  157. package/dist/modules/registry/routing.js.map +1 -0
  158. package/dist/modules/resolution/closure.d.ts +28 -0
  159. package/dist/modules/resolution/closure.js +105 -0
  160. package/dist/modules/resolution/closure.js.map +1 -0
  161. package/dist/modules/resolution/index.d.ts +4 -0
  162. package/dist/modules/resolution/index.js +3 -0
  163. package/dist/modules/resolution/index.js.map +1 -0
  164. package/dist/modules/resolution/resolve.d.ts +33 -0
  165. package/dist/modules/resolution/resolve.js +59 -0
  166. package/dist/modules/resolution/resolve.js.map +1 -0
  167. package/dist/modules/resolution/resolvers.d.ts +23 -0
  168. package/dist/modules/resolution/resolvers.js +34 -0
  169. package/dist/modules/resolution/resolvers.js.map +1 -0
  170. package/dist/modules/spl/check.d.ts +25 -0
  171. package/dist/modules/spl/check.js +21 -0
  172. package/dist/modules/spl/check.js.map +1 -0
  173. package/dist/modules/spl/cip.d.ts +67 -0
  174. package/dist/modules/spl/cip.js +98 -0
  175. package/dist/modules/spl/cip.js.map +1 -0
  176. package/dist/modules/spl/feature-model.d.ts +39 -0
  177. package/dist/modules/spl/feature-model.js +106 -0
  178. package/dist/modules/spl/feature-model.js.map +1 -0
  179. package/dist/modules/spl/index.d.ts +6 -0
  180. package/dist/modules/spl/index.js +4 -0
  181. package/dist/modules/spl/index.js.map +1 -0
  182. package/dist/modules/spl/platform.d.ts +49 -0
  183. package/dist/modules/spl/platform.js +316 -0
  184. package/dist/modules/spl/platform.js.map +1 -0
  185. package/dist/modules/types.d.ts +132 -0
  186. package/dist/modules/types.js +2 -0
  187. package/dist/modules/types.js.map +1 -0
  188. package/dist/product/engine-spec.d.ts +0 -16
  189. package/dist/product/engine-spec.js +4 -50
  190. package/dist/product/engine-spec.js.map +1 -1
  191. package/dist/product/spec.d.ts +0 -82
  192. package/dist/product/spec.js +0 -79
  193. package/dist/product/spec.js.map +1 -1
  194. package/dist/product/version.d.ts +0 -23
  195. package/dist/product/version.js +0 -28
  196. package/dist/product/version.js.map +1 -1
  197. package/dist/products-index/products-index.d.ts +0 -165
  198. package/dist/products-index/products-index.js +0 -176
  199. package/dist/products-index/products-index.js.map +1 -1
  200. package/dist/workspace/context.d.ts +25 -0
  201. package/dist/workspace/context.js +43 -0
  202. package/dist/workspace/context.js.map +1 -0
  203. package/dist/workspace/gitExclude.d.ts +2 -0
  204. package/dist/workspace/gitExclude.js +19 -0
  205. package/dist/workspace/gitExclude.js.map +1 -0
  206. package/dist/workspace/host.d.ts +14 -0
  207. package/dist/workspace/host.js +13 -0
  208. package/dist/workspace/host.js.map +1 -0
  209. package/dist/workspace/index.d.ts +12 -0
  210. package/dist/workspace/index.js +12 -0
  211. package/dist/workspace/index.js.map +1 -0
  212. package/dist/workspace/local.d.ts +81 -0
  213. package/dist/workspace/local.js +287 -0
  214. package/dist/workspace/local.js.map +1 -0
  215. package/dist/workspace/modular.d.ts +95 -0
  216. package/dist/workspace/modular.js +301 -0
  217. package/dist/workspace/modular.js.map +1 -0
  218. package/dist/workspace/operations.d.ts +35 -0
  219. package/dist/workspace/operations.js +57 -0
  220. package/dist/workspace/operations.js.map +1 -0
  221. package/dist/workspace/origin.d.ts +20 -0
  222. package/dist/workspace/origin.js +19 -0
  223. package/dist/workspace/origin.js.map +1 -0
  224. package/package.json +22 -7
  225. package/dist/feature-model/convert.d.ts +0 -35
  226. package/dist/feature-model/convert.js +0 -47
  227. package/dist/feature-model/convert.js.map +0 -1
  228. package/dist/feature-model/engine.d.ts +0 -60
  229. package/dist/feature-model/engine.js +0 -139
  230. package/dist/feature-model/engine.js.map +0 -1
  231. package/dist/feature-model/inspect.d.ts +0 -67
  232. package/dist/feature-model/inspect.js +0 -113
  233. package/dist/feature-model/inspect.js.map +0 -1
  234. package/dist/feature-model/io.d.ts +0 -66
  235. package/dist/feature-model/io.js +0 -92
  236. package/dist/feature-model/io.js.map +0 -1
  237. package/dist/feature-model/parse.d.ts +0 -30
  238. package/dist/feature-model/parse.js +0 -36
  239. package/dist/feature-model/parse.js.map +0 -1
  240. package/dist/feature-model/text.d.ts +0 -54
  241. package/dist/feature-model/text.js +0 -126
  242. package/dist/feature-model/text.js.map +0 -1
  243. package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
  244. package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
  245. package/dist/line/templates/metamodels/sensor/extra.js +0 -36
  246. package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
  247. package/dist/selection/selection.d.ts +0 -126
  248. package/dist/selection/selection.js +0 -152
  249. package/dist/selection/selection.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"io.js","sourceRoot":"","sources":["../../src/feature-model/io.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Reading and writing the platform feature model of a line working directory.\n *\n * Migrated from:\n * - `linea/server/src/model/services/LineService.js:getFeatureModel` (~277-293)\n * and `saveFeatureModel` (~391-419) — domain logic only; permissions, the\n * GitLab round-trip, the version bump and the Mongo transaction stay in\n * linea-server (ADR-003).\n * - `linea/server/src/agents/tools/harvest.js:readLineModel` (~97-107), which\n * is where the \"UVL preferred, XML fallback\" rule comes from.\n * - `linea/server/src/model/services/LineService.js:reconcileLines` (~152-156),\n * which resolves the same ambiguity for repositories that are not in the DB:\n * XML only when the XML file is there and the UVL one is not.\n *\n * The monolith decodes base64 (`atob(file.content)`) because files arrive from\n * the GitLab API. Here everything is plain text on disk.\n */\nimport path from 'node:path'\nimport { PLATFORM_PATHS, isFeatureModelType, type FeatureModelType } from '../constants.js'\nimport { InvalidArgumentError, LinePlatformNotFoundError } from '../errors.js'\nimport { fileExists, readTextFile, writeTextFile } from '../fs/workspace.js'\n\n/**\n * Where a line's feature model lives and in which notation.\n *\n * There is no `exists` flag: the function throws `LinePlatformNotFoundError`\n * when no model is there, so a flag could only ever be `true`. Widening a public\n * type later is cheap; narrowing it is a breaking change.\n */\nexport interface FeatureModelLocation {\n /** Notation of the model found. */\n readonly type: FeatureModelType\n /** Absolute path of the model file. */\n readonly path: string\n}\n\n/** Absolute path of the model file of `lineDir` for a given notation. */\nconst modelPathFor = (lineDir: string, type: FeatureModelType): string =>\n path.join(path.resolve(lineDir), type === 'XML' ? PLATFORM_PATHS.modelXml : PLATFORM_PATHS.model)\n\nconst assertLineDir = (lineDir: string): void => {\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\n }\n}\n\n/**\n * Detects which feature model a line working directory holds.\n *\n * UVL wins when both files are present, matching the monolith: `readLineModel`\n * tries `model.uvl` first, and `reconcileLines` only settles on XML when the\n * UVL lookup fails.\n *\n * @param params.lineDir Root of the line working directory.\n * @returns Notation and absolute path of the model found.\n * @throws {LinePlatformNotFoundError} when neither `src/platform/model.uvl` nor\n * `src/platform/model.xml` exists.\n */\nexport const detectFeatureModelType = ({ lineDir }: { lineDir: string }): FeatureModelLocation => {\n assertLineDir(lineDir)\n\n const uvlPath = modelPathFor(lineDir, 'UVL')\n if (fileExists({ filePath: uvlPath })) return { type: 'UVL', path: uvlPath }\n\n const xmlPath = modelPathFor(lineDir, 'XML')\n if (fileExists({ filePath: xmlPath })) return { type: 'XML', path: xmlPath }\n\n throw new LinePlatformNotFoundError(\n `No feature model found in \"${path.resolve(lineDir)}\": expected \"${PLATFORM_PATHS.model}\" or \"${PLATFORM_PATHS.modelXml}\".`\n )\n}\n\n/**\n * Reads the platform feature model of a line working directory.\n *\n * @param params.lineDir Root of the line working directory.\n * @returns Notation, absolute path and contents of the model.\n * @throws {LinePlatformNotFoundError} when the line has no platform model.\n */\nexport const readFeatureModel = ({\n lineDir\n}: {\n lineDir: string\n}): { type: FeatureModelType, path: string, content: string } => {\n const location = detectFeatureModelType({ lineDir })\n return {\n type: location.type,\n path: location.path,\n content: readTextFile({ filePath: location.path })\n }\n}\n\n/**\n * Writes the platform feature model of a line working directory, creating\n * `src/platform` if needed.\n *\n * Mirrors the model half of `saveFeatureModel`: it overwrites the file for the\n * given notation and nothing else. It deliberately does NOT delete the model of\n * the other notation — that only happens in the convert flow, where the monolith\n * issues a single GitLab commit with a `create` plus a `delete`\n * (`LineService.js:convertFeatureModel`). That flow is a line-level operation\n * and belongs to a later batch.\n *\n * @param params.lineDir Root of the line working directory.\n * @param params.content Model document as plain text.\n * @param params.type Notation of `content`.\n * @returns The absolute path written.\n */\nexport const writeFeatureModel = ({\n lineDir,\n content,\n type\n}: {\n lineDir: string\n content: string\n type: FeatureModelType\n}): { path: string } => {\n assertLineDir(lineDir)\n if (typeof content !== 'string') {\n throw new InvalidArgumentError('\"content\" must be a string.')\n }\n if (!isFeatureModelType(type)) {\n throw new InvalidArgumentError(`Unknown feature model type \"${String(type)}\". Use \"UVL\" or \"XML\".`)\n }\n return { path: writeTextFile({ filePath: modelPathFor(lineDir, type), content }) }\n}\n"]}
@@ -1,30 +0,0 @@
1
- /**
2
- * Feature model parsing.
3
- *
4
- * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`
5
- * (~42-46), minus two things:
6
- *
7
- * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the
8
- * monolith models arrive from the GitLab API, in linea-core everything is
9
- * plain text on disk. Decoding is linea-server's problem (ADR-003).
10
- * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:
11
- * linea-core keeps no state between calls. Callers that want caching own it.
12
- */
13
- import { type FeatureModelType } from '../constants.js';
14
- import { type FeatureModelValue } from './engine.js';
15
- export type { FeatureModelValue } from './engine.js';
16
- /**
17
- * Parses a feature model document.
18
- *
19
- * @param params.content Model document as plain text (UVL or XML).
20
- * @param params.type Notation of `content`. Always explicit — linea-core never
21
- * sniffs the notation from the content itself.
22
- * @returns An opaque model value, to be handed back to other linea-core functions.
23
- * @throws {InvalidArgumentError} if `content` is not a non-empty string, if
24
- * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.
25
- * @throws {UvlParseError} if a UVL document cannot be parsed.
26
- */
27
- export declare const parseFeatureModel: ({ content, type }: {
28
- content: string;
29
- type: FeatureModelType;
30
- }) => FeatureModelValue;
@@ -1,36 +0,0 @@
1
- /**
2
- * Feature model parsing.
3
- *
4
- * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`
5
- * (~42-46), minus two things:
6
- *
7
- * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the
8
- * monolith models arrive from the GitLab API, in linea-core everything is
9
- * plain text on disk. Decoding is linea-server's problem (ADR-003).
10
- * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:
11
- * linea-core keeps no state between calls. Callers that want caching own it.
12
- */
13
- import { isFeatureModelType } from '../constants.js';
14
- import { InvalidArgumentError } from '../errors.js';
15
- import { parseModel } from './engine.js';
16
- /**
17
- * Parses a feature model document.
18
- *
19
- * @param params.content Model document as plain text (UVL or XML).
20
- * @param params.type Notation of `content`. Always explicit — linea-core never
21
- * sniffs the notation from the content itself.
22
- * @returns An opaque model value, to be handed back to other linea-core functions.
23
- * @throws {InvalidArgumentError} if `content` is not a non-empty string, if
24
- * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.
25
- * @throws {UvlParseError} if a UVL document cannot be parsed.
26
- */
27
- export const parseFeatureModel = ({ content, type }) => {
28
- if (typeof content !== 'string' || content.trim() === '') {
29
- throw new InvalidArgumentError('A feature model needs non-empty "content".');
30
- }
31
- if (!isFeatureModelType(type)) {
32
- throw new InvalidArgumentError(`Unknown feature model type "${String(type)}". Use "UVL" or "XML".`);
33
- }
34
- return parseModel(content, type);
35
- };
36
- //# sourceMappingURL=parse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/feature-model/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAA;AAIhE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,OAAO,EACP,IAAI,EAIL,EAAqB,EAAE;IACtB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,4CAA4C,CAAC,CAAA;IAC9E,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,oBAAoB,CAAC,+BAA+B,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;IACrG,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA","sourcesContent":["/**\n * Feature model parsing.\n *\n * Migrated from `linea/server/src/agents/tools/splContext.js:buildFeatureModel`\n * (~42-46), minus two things:\n *\n * - the base64 handling (`file.encoding === 'base64' ? atob(...) : ...`): in the\n * monolith models arrive from the GitLab API, in linea-core everything is\n * plain text on disk. Decoding is linea-server's problem (ADR-003).\n * - the module-level `fmCache` (splContext.js ~30-40). ADR-014 forbids it:\n * linea-core keeps no state between calls. Callers that want caching own it.\n */\nimport { isFeatureModelType, type FeatureModelType } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { parseModel, type FeatureModelValue } from './engine.js'\n\nexport type { FeatureModelValue } from './engine.js'\n\n/**\n * Parses a feature model document.\n *\n * @param params.content Model document as plain text (UVL or XML).\n * @param params.type Notation of `content`. Always explicit — linea-core never\n * sniffs the notation from the content itself.\n * @returns An opaque model value, to be handed back to other linea-core functions.\n * @throws {InvalidArgumentError} if `content` is not a non-empty string, if\n * `type` is not `'UVL'`/`'XML'`, or if an XML document cannot be parsed.\n * @throws {UvlParseError} if a UVL document cannot be parsed.\n */\nexport const parseFeatureModel = ({\n content,\n type\n}: {\n content: string\n type: FeatureModelType\n}): FeatureModelValue => {\n if (typeof content !== 'string' || content.trim() === '') {\n throw new InvalidArgumentError('A feature model needs non-empty \"content\".')\n }\n if (!isFeatureModelType(type)) {\n throw new InvalidArgumentError(`Unknown feature model type \"${String(type)}\". Use \"UVL\" or \"XML\".`)\n }\n return parseModel(content, type)\n}\n"]}
@@ -1,54 +0,0 @@
1
- /**
2
- * Normalises line endings and expands tabs so the UVL parser always gets clean
3
- * input.
4
- *
5
- * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its
6
- * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave
7
- * mixed tabs and spaces that the UVL language server tolerates but the parser
8
- * does not.
9
- *
10
- * @param params.uvl Raw UVL document.
11
- * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).
12
- * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a
13
- * non-string would let a caller bug flow into `estimateFeatureCount` and
14
- * silently flip an `ANALYSIS_THRESHOLDS` decision.
15
- */
16
- export declare const normalizeUvl: ({ uvl }: {
17
- uvl: string;
18
- }) => string;
19
- /**
20
- * Counts features in a UVL document without parsing it.
21
- *
22
- * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`
23
- * (~11-28), which is itself the twin of
24
- * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting
25
- * loop is byte-compatible with both: everything after the `constraints` keyword
26
- * is ignored, and a line counts as a feature when it is indented at least 2
27
- * columns and its first token is not a group keyword.
28
- *
29
- * Normalise first: with tab indentation the root feature sits at indent 1 and is
30
- * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before
31
- * counting.
32
- *
33
- * @param params.uvl Raw UVL document.
34
- * @returns Estimated number of features.
35
- * @throws {InvalidArgumentError} if `uvl` is not a string.
36
- */
37
- export declare const estimateFeatureCount: ({ uvl }: {
38
- uvl: string;
39
- }) => number;
40
- /**
41
- * Builds the seed UVL model of a brand new line.
42
- *
43
- * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:
44
- * `` `features\n\t${line.name}\n\t\tmandatory\n\t\t\tvoid` ``.
45
- * Tabs and the absence of a trailing newline are part of the contract — a test
46
- * asserts the exact string.
47
- *
48
- * @param params.name Line name; used as the root feature.
49
- * @returns The seed UVL document.
50
- * @throws {InvalidArgumentError} if `name` is not a non-empty string.
51
- */
52
- export declare const emptyFeatureModelUvl: ({ name }: {
53
- name: string;
54
- }) => string;
@@ -1,126 +0,0 @@
1
- /**
2
- * Pure text helpers over UVL documents. No parsing, no I/O.
3
- */
4
- import { InvalidArgumentError } from '../errors.js';
5
- /** UVL keywords that introduce a group instead of naming a feature. */
6
- const UVL_GROUP_KEYWORDS = new Set([
7
- 'mandatory',
8
- 'optional',
9
- 'alternative',
10
- 'or',
11
- 'features',
12
- 'constraints'
13
- ]);
14
- const assertUvlString = (uvl, parameter) => {
15
- if (typeof uvl !== 'string') {
16
- throw new InvalidArgumentError(`"${parameter}" must be a string.`);
17
- }
18
- return uvl;
19
- };
20
- /**
21
- * Faithful port of Python's `str.expandtabs(tabsize)`.
22
- *
23
- * NOT the same as replacing each tab with N spaces: a tab advances to the next
24
- * multiple of `tabSize`. Getting this wrong would silently change the indentation
25
- * of every UVL model, which is significant in UVL.
26
- */
27
- const expandTabs = (line, tabSize = 4) => {
28
- let out = '';
29
- let column = 0;
30
- for (const char of line) {
31
- if (char === '\t') {
32
- const width = tabSize - (column % tabSize);
33
- out += ' '.repeat(width);
34
- column += width;
35
- }
36
- else {
37
- out += char;
38
- column += 1;
39
- }
40
- }
41
- return out;
42
- };
43
- /**
44
- * Normalises line endings and expands tabs so the UVL parser always gets clean
45
- * input.
46
- *
47
- * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its
48
- * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave
49
- * mixed tabs and spaces that the UVL language server tolerates but the parser
50
- * does not.
51
- *
52
- * @param params.uvl Raw UVL document.
53
- * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).
54
- * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a
55
- * non-string would let a caller bug flow into `estimateFeatureCount` and
56
- * silently flip an `ANALYSIS_THRESHOLDS` decision.
57
- */
58
- export const normalizeUvl = ({ uvl }) => {
59
- const unified = assertUvlString(uvl, 'uvl').trim().replace(/\r\n/g, '\n').replace(/\r/g, '\n');
60
- return unified
61
- .split('\n')
62
- .map((line) => expandTabs(line, 4))
63
- .join('\n');
64
- };
65
- /**
66
- * Counts features in a UVL document without parsing it.
67
- *
68
- * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`
69
- * (~11-28), which is itself the twin of
70
- * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting
71
- * loop is byte-compatible with both: everything after the `constraints` keyword
72
- * is ignored, and a line counts as a feature when it is indented at least 2
73
- * columns and its first token is not a group keyword.
74
- *
75
- * Normalise first: with tab indentation the root feature sits at indent 1 and is
76
- * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before
77
- * counting.
78
- *
79
- * @param params.uvl Raw UVL document.
80
- * @returns Estimated number of features.
81
- * @throws {InvalidArgumentError} if `uvl` is not a string.
82
- */
83
- export const estimateFeatureCount = ({ uvl }) => {
84
- const document = assertUvlString(uvl, 'uvl');
85
- let inConstraints = false;
86
- let count = 0;
87
- for (const line of document.split('\n')) {
88
- const trimmed = line.trim();
89
- if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#'))
90
- continue;
91
- if (trimmed === 'constraints') {
92
- inConstraints = true;
93
- continue;
94
- }
95
- if (inConstraints)
96
- continue;
97
- if (trimmed === 'features')
98
- continue;
99
- const indent = line.length - line.trimStart().length;
100
- if (indent >= 2) {
101
- const name = trimmed.split(/[\s{[]/)[0];
102
- if (name && !UVL_GROUP_KEYWORDS.has(name))
103
- count += 1;
104
- }
105
- }
106
- return count;
107
- };
108
- /**
109
- * Builds the seed UVL model of a brand new line.
110
- *
111
- * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:
112
- * `` `features\n\t${line.name}\n\t\tmandatory\n\t\t\tvoid` ``.
113
- * Tabs and the absence of a trailing newline are part of the contract — a test
114
- * asserts the exact string.
115
- *
116
- * @param params.name Line name; used as the root feature.
117
- * @returns The seed UVL document.
118
- * @throws {InvalidArgumentError} if `name` is not a non-empty string.
119
- */
120
- export const emptyFeatureModelUvl = ({ name }) => {
121
- if (typeof name !== 'string' || name.trim() === '') {
122
- throw new InvalidArgumentError('"name" must be a non-empty string.');
123
- }
124
- return `features\n\t${name}\n\t\tmandatory\n\t\t\tvoid`;
125
- };
126
- //# sourceMappingURL=text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/feature-model/text.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Pure text helpers over UVL documents. No parsing, no I/O.\n */\nimport { InvalidArgumentError } from '../errors.js'\n\n/** UVL keywords that introduce a group instead of naming a feature. */\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\n 'mandatory',\n 'optional',\n 'alternative',\n 'or',\n 'features',\n 'constraints'\n])\n\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\n if (typeof uvl !== 'string') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\n }\n return uvl\n}\n\n/**\n * Faithful port of Python's `str.expandtabs(tabsize)`.\n *\n * NOT the same as replacing each tab with N spaces: a tab advances to the next\n * multiple of `tabSize`. Getting this wrong would silently change the indentation\n * of every UVL model, which is significant in UVL.\n */\nconst expandTabs = (line: string, tabSize = 4): string => {\n let out = ''\n let column = 0\n for (const char of line) {\n if (char === '\\t') {\n const width = tabSize - (column % tabSize)\n out += ' '.repeat(width)\n column += width\n } else {\n out += char\n column += 1\n }\n }\n return out\n}\n\n/**\n * Normalises line endings and expands tabs so the UVL parser always gets clean\n * input.\n *\n * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its\n * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave\n * mixed tabs and spaces that the UVL language server tolerates but the parser\n * does not.\n *\n * @param params.uvl Raw UVL document.\n * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).\n * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a\n * non-string would let a caller bug flow into `estimateFeatureCount` and\n * silently flip an `ANALYSIS_THRESHOLDS` decision.\n */\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n return unified\n .split('\\n')\n .map((line) => expandTabs(line, 4))\n .join('\\n')\n}\n\n/**\n * Counts features in a UVL document without parsing it.\n *\n * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`\n * (~11-28), which is itself the twin of\n * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting\n * loop is byte-compatible with both: everything after the `constraints` keyword\n * is ignored, and a line counts as a feature when it is indented at least 2\n * columns and its first token is not a group keyword.\n *\n * Normalise first: with tab indentation the root feature sits at indent 1 and is\n * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before\n * counting.\n *\n * @param params.uvl Raw UVL document.\n * @returns Estimated number of features.\n * @throws {InvalidArgumentError} if `uvl` is not a string.\n */\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\n const document = assertUvlString(uvl, 'uvl')\n let inConstraints = false\n let count = 0\n for (const line of document.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\n if (trimmed === 'constraints') {\n inConstraints = true\n continue\n }\n if (inConstraints) continue\n if (trimmed === 'features') continue\n const indent = line.length - line.trimStart().length\n if (indent >= 2) {\n const name = trimmed.split(/[\\s{[]/)[0]\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\n }\n }\n return count\n}\n\n/**\n * Builds the seed UVL model of a brand new line.\n *\n * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:\n * `` `features\\n\\t${line.name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid` ``.\n * Tabs and the absence of a trailing newline are part of the contract — a test\n * asserts the exact string.\n *\n * @param params.name Line name; used as the root feature.\n * @returns The seed UVL document.\n * @throws {InvalidArgumentError} if `name` is not a non-empty string.\n */\nexport const emptyFeatureModelUvl = ({ name }: { name: string }): string => {\n if (typeof name !== 'string' || name.trim() === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n return `features\\n\\t${name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid`\n}\n"]}
@@ -1,328 +0,0 @@
1
- function getFilterName(entity, propertyName) {
2
- if (!entity) {
3
- return propertyName;
4
- } else if (entity.displayString == "") {
5
- return "";
6
- } else {
7
- var regExFilter = /^\$[_a-zA-Z0-9-]+$/;
8
- if (regExFilter.test(entity.displayString)) {
9
- var propertyInDisplaString = getProperty(
10
- entity,
11
- entity.displayString.replace(/\$/g, "")
12
- );
13
- if (!propertyInDisplaString || propertyInDisplaString.multiple) {
14
- return "";
15
- } else {
16
- return propertyName + "_" + propertyInDisplaString.name;
17
- }
18
- } else {
19
- return "";
20
- }
21
- }
22
- }
23
-
24
- function getDisplayString(entity, suffix) {
25
- if (!suffix) {
26
- suffix = normalize(entity.name);
27
- }
28
-
29
- if (entity.displayString == "") {
30
- return (
31
- "'" +
32
- entity.name +
33
- "'" +
34
- " + ' ' + " +
35
- suffix +
36
- "." +
37
- getIdProperty(entity).name
38
- );
39
- }
40
-
41
- return (
42
- "'" +
43
- entity.displayString.replace(/\$\w+/g, function myFunction(x) {
44
- return "' + " + x.replace(/\$/g, suffix + ".") + " + '";
45
- }) +
46
- "'"
47
- );
48
- }
49
-
50
- function getDisplayStringName(entity) {
51
- if (entity.displayString == null) {
52
- return null;
53
- }
54
- return entity.displayString.replace("$", "");
55
- }
56
-
57
- function getDisplayStringJava(entity, entityVariableName) {
58
- if (entity.displayString == "") {
59
- return (
60
- '"' +
61
- entity.name +
62
- ' " + ' +
63
- entityVariableName +
64
- ".get" +
65
- normalize(getIdProperty(entity).name, true) +
66
- "()"
67
- );
68
- }
69
-
70
- return (
71
- '"' +
72
- entity.displayString.replace(/\$\w+/g, function myFunction(x) {
73
- return (
74
- '" + ' +
75
- entityVariableName +
76
- ".get" +
77
- normalize(x.split("$")[1], true) +
78
- "()" +
79
- " + " +
80
- '"'
81
- );
82
- }) +
83
- '"'
84
- );
85
- }
86
-
87
- function getEntity(data, entityName) {
88
- return data.dataModel.entities.find(function(en) {
89
- return en.name == entityName;
90
- });
91
- }
92
-
93
- function getForm(data, className) {
94
- return data.forms.find(function(en) {
95
- return en.entity == className;
96
- });
97
- }
98
-
99
- function getProperty(entity, propertyName) {
100
- return entity.properties.find(function(p) {
101
- return p.name == propertyName;
102
- });
103
- }
104
-
105
- function getEnum(data, enumName) {
106
- return data.dataModel.enums.find(function(en) {
107
- return en.name == enumName;
108
- });
109
- }
110
-
111
- function getIdProperty(entity) {
112
- if (!entity) return null;
113
- return entity.properties.find(function(p) {
114
- return p.pk;
115
- });
116
- }
117
-
118
- function getProperties(entity, data) {
119
- const properties = entity.properties;
120
- const superclass = entity.superclass ? getEntity(data, entity.superclass) : null;
121
- if (superclass) {
122
- return properties.concat(getProperties(superclass, data));
123
- } else {
124
- return properties;
125
- }
126
- }
127
-
128
- function getEntityProperty(entity, propertyName) {
129
- if (!entity) return null;
130
-
131
- let foundProp = null;
132
- entity.properties.every((property) => {
133
- if (property.name === propertyName) {
134
- foundProp = property;
135
- return false;
136
- }
137
- return true;
138
- });
139
-
140
- if (!foundProp && entity.superclass) {
141
- const superClasses = getEntitySuperClasses(entity);
142
- superClasses.every((superclass) => {
143
- superclass.properties.every((property) => {
144
- if (property.name === propertyName) {
145
- foundProp = property;
146
- return false;
147
- }
148
- return true;
149
- });
150
- return foundProp == null;
151
- });
152
- }
153
- return foundProp;
154
- }
155
-
156
- function getRelationships(data, entity, propertiesFilter) {
157
- var r = [];
158
-
159
- var properties = entity.properties;
160
-
161
- if (propertiesFilter) {
162
- if (typeof propertiesFilter == "function") {
163
- properties = properties.filter(propertiesFilter);
164
- } else {
165
- properties = properties.filter(function(p) {
166
- return propertiesFilter.indexOf(p.name) != -1;
167
- });
168
- }
169
- }
170
-
171
- properties.forEach(function(property) {
172
- var propertyEntity = getEntity(data, property.class);
173
-
174
- if (propertyEntity != null) {
175
- r.push({
176
- property: property,
177
- class: propertyEntity,
178
- inverseProperty: propertyEntity.properties.find(function(p) {
179
- return p.name == property.bidirectional;
180
- })
181
- });
182
- }
183
- });
184
-
185
- return r;
186
- }
187
-
188
- var inputTypes = [
189
- "Boolean",
190
- "BigDecimal",
191
- "Integer",
192
- "Long",
193
- "Float",
194
- "Double",
195
- "String",
196
- "Text",
197
- "Date",
198
- "DateTime"
199
- ];
200
-
201
- function isInput(data, property) {
202
- return inputTypes.indexOf(property.class) != -1
203
- || property.class.indexOf('autoinc') != -1
204
- || getEntity(data, property.class)
205
- || getEnum(data, property.class);
206
- }
207
-
208
- function getEntityPropertyNamesOfTypes(entity, types) {
209
- const propertyNames = [];
210
- let entities = [];
211
- if (!entity.abstract) {
212
- entities.push(entity);
213
- if (entity.superclass) {
214
- const superClasses = getEntitySuperClasses(entity);
215
- entities = entities.concat(superClasses);
216
- }
217
- }
218
- entities.forEach((_entity) => {
219
- _entity.properties.forEach((property) => {
220
- types.forEach((type) => {
221
- if (property.class == type || property.class == type + " (autoinc)") {
222
- propertyNames.push(property.name);
223
- }
224
- });
225
- });
226
- });
227
- return propertyNames;
228
- }
229
-
230
- function checkEntityContainsPropertiesOfTypes(entity, types) {
231
- return getEntityPropertyNamesOfTypes(entity, types).length !== 0;
232
- }
233
-
234
- function getEntitySuperClasses(entity, superclasses = []) {
235
- let entitySuperClasses = superclasses;
236
- if (!entity.superclass) {
237
- return superclasses;
238
- } else {
239
- let _superclass = data.dataModel.entities.find(e => e.name === entity.superclass);
240
- if (!_superclass) {
241
- return superclasses;
242
- } else {
243
- entitySuperClasses = entitySuperClasses.concat(_superclass);
244
- return getEntitySuperClasses(_superclass, entitySuperClasses);
245
- }
246
- }
247
- }
248
-
249
- function checkAnyEntityContainsPropertiesOfTypes(data, types) {
250
- var propertyTypeFound = false;
251
- data.dataModel.entities.forEach(function(entity) {
252
- var found = checkEntityContainsPropertiesOfTypes(entity, types);
253
- propertyTypeFound = propertyTypeFound || found;
254
- });
255
- return propertyTypeFound;
256
- }
257
-
258
- function checkEntityContainsPatternOfType(entity, patternType) {
259
- var patternFound = false;
260
- entity.properties.forEach(function(property) {
261
- if (property.patternType === patternType) {
262
- patternFound = true;
263
- }
264
- });
265
- return patternFound;
266
- }
267
-
268
- function checkEntityContainsPatternOfTypes(entity, patternTypes) {
269
- var patternsFound = false;
270
- patternTypes.forEach(function(patternType) {
271
- var patternFound = checkEntityContainsPatternOfType(entity, patternType);
272
- patternsFound = patternsFound || patternFound;
273
- });
274
- return patternsFound;
275
- }
276
-
277
- function checkAnyEntityContainsPatternOfType(data, patternType) {
278
- var patternFound = false;
279
- data.dataModel.entities.forEach(function(entity) {
280
- patternFound =
281
- patternFound || checkEntityContainsPatternOfType(entity, patternType);
282
- });
283
- return patternFound;
284
- }
285
-
286
- function checkAnyEntityContainsPatternOfTypes(data, patternTypes) {
287
- var patternsFound = false;
288
- patternTypes.forEach(function(patternType) {
289
- var patternFound = checkAnyEntityContainsPatternOfType(data, patternType);
290
- patternsFound = patternsFound || patternFound;
291
- });
292
- return patternsFound;
293
- }
294
-
295
- function entityIsSuperclass(entity) {
296
- return data.dataModel.entities.find(e => e.superclass === entity.name) != null;
297
- }
298
-
299
- function getTableDataTitleTranslate(entityName, propertyName) {
300
- return (
301
- "'entity." +
302
- normalize(entityName) +
303
- ".prop." +
304
- normalize(propertyName) +
305
- "' | translate"
306
- );
307
- }
308
-
309
- function getOtherRelationshipsNotMultipleAndOwning(data, context) {
310
- var rels = [];
311
-
312
- data.dataModel.entities.forEach(function(entity) {
313
- entity.properties.forEach(function(property) {
314
- if (property.class == context.name && property.owner) {
315
- if (property.bidirectional && !property.multiple) {
316
- var thisProperty = context.properties.find(function(p) {
317
- return p.name == property.bidirectional;
318
- });
319
- if (!thisProperty.multiple) {
320
- rels.push({ entity: entity, property: property });
321
- }
322
- }
323
- }
324
- });
325
- });
326
-
327
- return rels;
328
- }