@lbdudc/linea-core 0.1.1 → 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.
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 +1 @@
1
- {"version":3,"file":"derive.js","sourceRoot":"","sources":["../../src/derivation/derive.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,YAAY,GAAG,CAAC,IAAiB,EAAqB,EAAE,CAC5D,eAAe,CAAC,EAAE,IAAI,EAAE,CAAiC,CAAA;AAE3D,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAU,EAAE;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,IAAa,EAAe,EAAE;IAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,oBAAoB,CAAC,2BAA2B,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,IAAmB,CAAA;AAC5B,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,IAAI,EACJ,SAAS,EAKV,EAAkC,EAAE;IACnC,aAAa,CAAC,OAAO,CAAC,CA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AA","sourcesContent":["/**\n * Product derivation with spl-js-engine.\n *\n * Migrated from:\n * - `linea/server/src/model/services/generatePipeline.js:runEngine` (~132-147)\n * - `linea/server/src/model/services/ProductService.js:generateZip` (~352-394)\n *\n * Everything those two do around the engine belongs to linea-server (ADR-003):\n * downloading the line archive from GitLab, permission checks, the temp\n * directory dance and the Mongo transaction.\n */\nimport type { ProductSpec as EngineProductSpec } from 'spl-js-engine'\nimport { InvalidArgumentError } from '../errors.js'\nimport { ensureDir } from '../fs/workspace.js'\nimport { buildEngineSpec } from '../product/engine-spec.js'\nimport type { ProductSpec } from '../product/spec.js'\nimport { createEngine, rethrowDerivationError } from './engine.js'\n\n/**\n * Hands the spec to the engine unchanged, as `runEngine` does.\n *\n * The cast is needed because linea-core's `ProductSpec.features` also admits the\n * legacy object-map form `{ Feature: true }`, while the engine's\n * `completeFeatureSelection` requires a string array.\n *\n * NOT normalised here, on purpose: the monolith passes `buildEngineSpec(spec)`\n * straight through, so an object-map spec fails there too. Normalising silently\n * would be a behaviour change hidden inside derivation. Callers holding a legacy\n * spec should run it through `normalizeFeatureSelection` first.\n */\nconst toEngineSpec = (spec: ProductSpec): EngineProductSpec =>\n buildEngineSpec({ spec }) as unknown as EngineProductSpec\n\nconst assertLineDir = (lineDir: unknown): string => {\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\n }\n return lineDir\n}\n\nconst assertSpec = (spec: unknown): ProductSpec => {\n if (typeof spec !== 'object' || spec === null || Array.isArray(spec)) {\n throw new InvalidArgumentError('\"spec\" must be an object.')\n }\n return spec as ProductSpec\n}\n\n/**\n * Derives a product into a directory.\n *\n * The spec goes through `buildEngineSpec` first, exactly as `runEngine` does, so\n * a product carrying a parsed sensor DSL takes the engine's shortcut path.\n *\n * DELIBERATE DIVERGENCE 1: `runEngine` finishes with\n * `fs.rmSync(lineOutput, { recursive: true, force: true })`, deleting the line\n * directory it just consumed. linea-core deletes NOTHING. Those directories\n * belong to the caller — in the monolith they happen to be throwaway temp dirs,\n * but here `lineDir` may well be a user's working copy. Cleaning up is the\n * caller's decision (ADR-009/ADR-014). A test pins this.\n *\n * DELIBERATE DIVERGENCE 2, and the one that matters most for whoever ports\n * linea-server: `runEngine` writes\n * `(await engine(lineOutput)).generateProduct(...)`. It awaits the CONSTRUCTOR\n * — which does return a promise — but NOT the generation, which returns one\n * too. So in the monolith the surrounding `try/catch` cannot catch anything\n * thrown during generation: the `FeatureSelectionError` its very next line\n * means to turn into a 400 becomes an unhandled rejection instead, and the\n * `rmSync` above runs while generation may still be reading the directory.\n *\n * linea-core awaits (below), which fixes both. The consequence is that the\n * error classification here does NOT merely replicate `runEngine`'s — it is\n * strictly more effective, because in the monolith most of those errors never\n * reach the `catch` at all.\n *\n * @param params.lineDir Line working directory (holding `src/platform/...`).\n * @param params.spec Product spec.\n * @param params.outputDir Directory to generate into. Created if missing.\n * @returns The directory that was generated into.\n * @throws {FeatureSelectionInvalidError} when the spec's feature selection is\n * not valid for the line's feature model.\n * @throws {LinePlatformNotFoundError} when the line has no usable platform, or\n * for any other engine failure — including a template calling a helper that\n * `extra.js` does not define, reported with the\n * `error_messages.missing_function_error` key.\n * @throws {InvalidArgumentError} when the arguments are malformed.\n */\nexport const deriveProduct = async ({\n lineDir,\n spec,\n outputDir\n}: {\n lineDir: string\n spec: ProductSpec\n outputDir: string\n}): Promise<{ outputDir: string }> => {\n assertLineDir(lineDir)\n const checkedSpec = assertSpec(spec)\n if (typeof outputDir !== 'string' || outputDir.trim() === '') {\n throw new InvalidArgumentError('\"outputDir\" must be a non-empty path.')\n }\n\n const target = ensureDir({ dirPath: outputDir })\n\n try {\n const engine = await createEngine(lineDir)\n await engine.generateProduct(target, toEngineSpec(checkedSpec))\n } catch (error) {\n rethrowDerivationError(error)\n }\n\n return { outputDir: target }\n}\n\n/**\n * Derives a product into a zip archive, without writing the generated tree.\n *\n * Same classification of failures as `deriveProduct`, matching `generateZip`.\n *\n * RETURN TYPE: the engine hands back a JSZip instance\n * (`spl-js-engine/src/output.js:ZipOutput`), which the monolith's controller\n * turns into base64 at the HTTP edge (`ProductController.js:117`). linea-core\n * materialises it into a `Buffer` instead, so the result is a real artifact a\n * caller can write, hash or feed to `extractArchive` without knowing anything\n * about JSZip. linea-server gets its base64 with `buffer.toString('base64')`.\n *\n * @param params.lineDir Line working directory.\n * @param params.spec Product spec.\n * @returns The zip archive bytes.\n * @throws The same errors as `deriveProduct`.\n */\nexport const deriveProductToZip = async ({\n lineDir,\n spec\n}: {\n lineDir: string\n spec: ProductSpec\n}): Promise<Buffer> => {\n assertLineDir(lineDir)\n const checkedSpec = assertSpec(spec)\n\n try {\n const engine = await createEngine(lineDir)\n const zip = await engine.generateZip(toEngineSpec(checkedSpec))\n const archive = zip as { generateAsync: (options: { type: 'nodebuffer' }) => Promise<Buffer> }\n return await archive.generateAsync({ type: 'nodebuffer' })\n } catch (error) {\n return rethrowDerivationError(error)\n }\n}\n"]}
1
+ {"version":3,"file":"derive.js","sourceRoot":"","sources":["../../src/derivation/derive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAwB,MAAM,aAAa,CAAA;AAExF,MAAM,YAAY,GAAG,CAAC,IAAiB,EAAqB,EAAE,CAC5D,eAAe,CAAC,EAAE,IAAI,EAAE,CAAiC,CAAA;AAE3D,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAU,EAAE;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,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type { ProductSpec as EngineProductSpec } from 'spl-js-engine'\nimport { InvalidArgumentError } from '../errors.js'\nimport { ensureDir } from '../fs/workspace.js'\nimport { buildEngineSpec } from '../product/engine-spec.js'\nimport type { ProductSpec } from '../product/spec.js'\nimport { createEngine, rethrowDerivationError, type DerivationStage } from './engine.js'\n\nconst toEngineSpec = (spec: ProductSpec): EngineProductSpec =>\n buildEngineSpec({ spec }) as unknown as EngineProductSpec\n\nconst assertLineDir = (lineDir: unknown): string => {\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\n }\n return lineDir\n}\n\nconst assertSpec = (spec: unknown): ProductSpec => {\n if (typeof spec !== 'object' || spec === null || Array.isArray(spec)) {\n throw new InvalidArgumentError('\"spec\" must be an object.')\n }\n return spec as ProductSpec\n}\n\nexport const deriveProduct = async ({\n lineDir,\n spec,\n outputDir\n}: {\n lineDir: string\n spec: ProductSpec\n outputDir: string\n}): Promise<{ outputDir: string }> => {\n assertLineDir(lineDir)\n const checkedSpec = assertSpec(spec)\n if (typeof outputDir !== 'string' || outputDir.trim() === '') {\n throw new InvalidArgumentError('\"outputDir\" must be a non-empty path.')\n }\n\n const target = ensureDir({ dirPath: outputDir })\n\n let stage: DerivationStage = 'setup'\n try {\n const engine = await createEngine(lineDir)\n stage = 'generate'\n await engine.generateProduct(target, toEngineSpec(checkedSpec))\n } catch (error) {\n rethrowDerivationError(error, stage)\n }\n\n return { outputDir: target }\n}\n\ninterface EngineZip {\n files: Record<string, { name: string, dir: boolean }>\n generateAsync: (options: { type: 'nodebuffer' }) => Promise<Buffer>\n}\n\nconst withPortableNames = (archive: EngineZip): EngineZip => {\n for (const name of Object.keys(archive.files)) {\n if (!name.includes('\\\\')) continue\n const portable = name.replace(/\\\\/g, '/')\n const entry = archive.files[name]\n delete archive.files[name]\n if (entry === undefined || (entry.dir && portable in archive.files)) continue\n entry.name = portable\n archive.files[portable] = entry\n }\n return archive\n}\n\nexport const deriveProductToZip = async ({\n lineDir,\n spec\n}: {\n lineDir: string\n spec: ProductSpec\n}): Promise<Buffer> => {\n assertLineDir(lineDir)\n const checkedSpec = assertSpec(spec)\n\n let stage: DerivationStage = 'setup'\n try {\n const engine = await createEngine(lineDir)\n stage = 'generate'\n const zip = await engine.generateZip(toEngineSpec(checkedSpec))\n return await withPortableNames(zip as EngineZip).generateAsync({ type: 'nodebuffer' })\n } catch (error) {\n return rethrowDerivationError(error, stage)\n }\n}\n"]}
@@ -1,48 +1,16 @@
1
- /**
2
- * The slice of the engine this module actually drives.
3
- *
4
- * Declared locally rather than importing `DerivationEngineInstance`, for the
5
- * same reason as `SolvingType` in `analysis/runtime.ts`: `spl-js-engine` ships
6
- * no declarations of its own, and our ambient ones under `src/types/` are never
7
- * published. A third-party type on an exported signature therefore ends up as a
8
- * dangling reference in `dist/**\/*.d.ts` and breaks any consumer building with
9
- * `skipLibCheck: false`. This one was NOT yet reachable from `index.d.ts`, so it
10
- * did not fail anything — it was a latent version of the bug that did.
11
- * `npm run check:consumer` now compiles every emitted declaration, so a
12
- * regression here fails immediately instead of waiting for the day something
13
- * public happens to expose it.
14
- */
15
1
  interface DerivationEngineHandle {
16
2
  generateProduct: (outputDir: string, spec: unknown) => Promise<unknown>;
17
3
  generateZip: (spec: unknown) => Promise<unknown>;
18
4
  }
19
- /**
20
- * Builds a `DerivationEngine` for a line working directory.
21
- *
22
- * Remember the engine's constructor RETURNS A PROMISE — `new DerivationEngine()`
23
- * evaluates to a promise and must be awaited. The positional argument order
24
- * mirrors `utils.js:engine()`.
25
- */
26
5
  export declare const createEngine: (lineDir: string) => Promise<DerivationEngineHandle>;
27
- /**
28
- * Turns whatever the engine threw into linea-core's taxonomy.
29
- *
30
- * Replicates the classification of `generatePipeline.js:runEngine` (~132-147)
31
- * and `ProductService.js:generateZip` (~375-382):
32
- *
33
- * - `FeatureSelectionError` propagates as such — it is the caller's fault, and
34
- * the monolith maps it to a 400.
35
- * - a `ReferenceError` means an annotation called a helper that `extra.js` does
36
- * not define; the monolith logs `error_messages.missing_function_error` and
37
- * then throws `LinePlatformNotFoundError` anyway.
38
- * - anything else becomes `LinePlatformNotFoundError`.
39
- *
40
- * PARITY NOTE: in the monolith BOTH the ReferenceError branch and the catch-all
41
- * throw `LinePlatformNotFoundError`; only the LOG MESSAGE differs. linea-core
42
- * takes no log callback (generation logs are out of scope), so the distinction
43
- * is preserved where it survives: the i18n key travels in the error MESSAGE
44
- * instead of a log line, and the original error is attached as `cause`. The
45
- * thrown TYPE is identical to the monolith's in every branch.
46
- */
47
- export declare const rethrowDerivationError: (error: unknown) => never;
6
+ type CodeFileCallback = (filePath: string, ...rest: unknown[]) => unknown;
7
+ export interface EngineWithInput {
8
+ input?: {
9
+ forEachCodeFile?: (cb: CodeFileCallback) => unknown;
10
+ };
11
+ }
12
+ export declare const namingFailedTemplates: (engine: EngineWithInput) => void;
13
+ /** `setup`: building the engine from the platform files; `generate`: running the templates for a product. */
14
+ export type DerivationStage = 'setup' | 'generate';
15
+ export declare const rethrowDerivationError: (error: unknown, stage?: DerivationStage) => never;
48
16
  export {};
@@ -1,52 +1,17 @@
1
- /**
2
- * INTERNAL adapter that builds a configured `DerivationEngine` from a line
3
- * working directory, and classifies whatever the engine throws.
4
- *
5
- * Migrated from `linea/server/src/model/services/utils.js:engine` and
6
- * `getEngineModel` (~18-36). Not exported from `src/index.ts`.
7
- */
8
1
  import fs from 'node:fs';
9
2
  import { DerivationEngine } from 'spl-js-engine';
10
3
  import { PLATFORM_PATHS } from '../constants.js';
11
- import { FeatureSelectionInvalidError, LinePlatformNotFoundError } from '../errors.js';
12
- import { describeSelectionFailure, isFeatureSelectionError } from '../feature-model/engine.js';
4
+ import { FeatureModelEmptyError, FeatureSelectionInvalidError, LinePlatformNotFoundError, TemplateError } from '../errors.js';
5
+ import { describeSelectionFailure, isFeatureSelectionError } from './selection-error.js';
13
6
  import { fileExists, readTextFile, resolveLinePaths } from '../fs/workspace.js';
14
- /**
15
- * The `featureModel` argument for `DerivationEngine`.
16
- *
17
- * PARITY QUIRK, forced by the engine rather than chosen. `setFeatureModel`
18
- * sniffs the notation with `featureModel.endsWith('uvl')` over the ARGUMENT, so:
19
- *
20
- * - for UVL it must be handed the FILE PATH — the path ends in `.uvl`, the
21
- * check passes and `FeatureModel.fromUVL` reads the file. Passing UVL *text*
22
- * would fail the `endsWith` test and the engine would try `fromXml` on it.
23
- * - for XML it must be handed the CONTENT — a path not ending in `uvl` would go
24
- * to `fromXml`, which would then try to parse the path itself as a document.
25
- *
26
- * That is exactly what `getEngineModel` does, and why it looks inconsistent.
27
- *
28
- * Note this bypasses `parseFeatureModel`, so the `asUvlContent` guard (which
29
- * appends a newline to stop `fromUVL` reading a file) is NOT in play here: for
30
- * UVL we deliberately WANT the file to be read, and the argument is a path we
31
- * built ourselves from `lineDir`, never caller-supplied content.
32
- */
7
+ /** The feature model the derivation engine reads: the one composed from the SPL's feature model and its modules' (UVL). */
33
8
  const resolveEngineModel = (lineDir) => {
34
9
  const paths = resolveLinePaths({ lineDir });
35
- if (fileExists({ filePath: paths.model }))
36
- return paths.model;
37
- const xmlPath = paths.model.replace(/\.uvl$/, '.xml');
38
- if (!fileExists({ filePath: xmlPath })) {
39
- throw new LinePlatformNotFoundError(`No feature model in "${lineDir}": expected "${PLATFORM_PATHS.model}" or "${PLATFORM_PATHS.modelXml}".`);
10
+ if (!fileExists({ filePath: paths.model })) {
11
+ throw new LinePlatformNotFoundError(`No feature model in "${lineDir}": expected "${PLATFORM_PATHS.model}".`);
40
12
  }
41
- return readTextFile({ filePath: xmlPath });
13
+ return paths.model;
42
14
  };
43
- /**
44
- * Builds a `DerivationEngine` for a line working directory.
45
- *
46
- * Remember the engine's constructor RETURNS A PROMISE — `new DerivationEngine()`
47
- * evaluates to a promise and must be awaited. The positional argument order
48
- * mirrors `utils.js:engine()`.
49
- */
50
15
  export const createEngine = async (lineDir) => {
51
16
  const paths = resolveLinePaths({ lineDir });
52
17
  const featureModel = resolveEngineModel(lineDir);
@@ -56,35 +21,34 @@ export const createEngine = async (lineDir) => {
56
21
  const config = JSON.parse(readTextFile({ filePath: paths.config }));
57
22
  const extraJs = readTextFile({ filePath: paths.extraJs });
58
23
  const transformation = readTextFile({ filePath: paths.transformation });
59
- // The cast is the price of not leaking `DerivationEngineInstance` into the
60
- // published declarations: the engine's own parameter types are narrower than
61
- // the structural handle, and function parameters are contravariant. Widening
62
- // is safe here because this module is the only caller and it always passes the
63
- // output of `buildEngineSpec`.
64
24
  const engine = await new DerivationEngine(paths.code, featureModel, config, extraJs, transformation);
25
+ namingFailedTemplates(engine);
65
26
  return engine;
66
27
  };
67
- /**
68
- * Turns whatever the engine threw into linea-core's taxonomy.
69
- *
70
- * Replicates the classification of `generatePipeline.js:runEngine` (~132-147)
71
- * and `ProductService.js:generateZip` (~375-382):
72
- *
73
- * - `FeatureSelectionError` propagates as such — it is the caller's fault, and
74
- * the monolith maps it to a 400.
75
- * - a `ReferenceError` means an annotation called a helper that `extra.js` does
76
- * not define; the monolith logs `error_messages.missing_function_error` and
77
- * then throws `LinePlatformNotFoundError` anyway.
78
- * - anything else becomes `LinePlatformNotFoundError`.
79
- *
80
- * PARITY NOTE: in the monolith BOTH the ReferenceError branch and the catch-all
81
- * throw `LinePlatformNotFoundError`; only the LOG MESSAGE differs. linea-core
82
- * takes no log callback (generation logs are out of scope), so the distinction
83
- * is preserved where it survives: the i18n key travels in the error MESSAGE
84
- * instead of a log line, and the original error is attached as `cause`. The
85
- * thrown TYPE is identical to the monolith's in every branch.
86
- */
87
- export const rethrowDerivationError = (error) => {
28
+ const named = new WeakSet();
29
+ export const namingFailedTemplates = (engine) => {
30
+ const input = engine.input;
31
+ const forEach = input?.forEachCodeFile;
32
+ if (!input || typeof forEach !== 'function')
33
+ return;
34
+ input.forEachCodeFile = (cb) => forEach.call(input, (filePath, ...rest) => {
35
+ try {
36
+ return cb(filePath, ...rest);
37
+ }
38
+ catch (error) {
39
+ if (error instanceof Error && !named.has(error)) {
40
+ named.add(error);
41
+ error.message = `${error.message} (${String(filePath).split('\\').join('/')})`;
42
+ }
43
+ throw error;
44
+ }
45
+ });
46
+ };
47
+ const ROOT_WITHOUT_FEATURES = 'abstract feature cannot be leaf';
48
+ export const rethrowDerivationError = (error, stage = 'setup') => {
49
+ if (error === ROOT_WITHOUT_FEATURES) {
50
+ throw new FeatureModelEmptyError('error_messages.feature_model_empty', { cause: error });
51
+ }
88
52
  if (isFeatureSelectionError(error)) {
89
53
  throw new FeatureSelectionInvalidError(describeSelectionFailure(error).message, { cause: error });
90
54
  }
@@ -93,6 +57,11 @@ export const rethrowDerivationError = (error) => {
93
57
  if (error instanceof ReferenceError) {
94
58
  throw new LinePlatformNotFoundError('error_messages.missing_function_error', { cause: error });
95
59
  }
96
- throw new LinePlatformNotFoundError(error instanceof Error ? error.message : String(error), { cause: error });
60
+ const message = error instanceof Error ? error.message : String(error);
61
+ // anything else that came out of the templates while generating (a TypeError on a missing section, a bad
62
+ // expression...): the platform exists, so it is not "platform not found" -- report the template failure it is
63
+ if (stage === 'generate')
64
+ throw new TemplateError(message, { cause: error });
65
+ throw new LinePlatformNotFoundError(message, { cause: error });
97
66
  };
98
67
  //# sourceMappingURL=engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/derivation/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAA+B,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACtF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAC9F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE/E;;;;;;;;;;;;;;;;;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ACzD,MAAM,cAAc,GAAG,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAEvE,2EAA2E;IAC3E,6EAA6E;IAC7E,6EAA6E;IAC7E,+EAA+E;IAC/E,+BAA+B;IAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,gBAAgB,CACvC,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAC1D,CAAA;IACD,OAAO,MAA2C,CAAA;AACpD,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAS,EAAE;IAC9D,IAAI,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,4BAA4B,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACnG,CAAC;IACD,IAAI,KAAK,YAAY,yBAAyB;QAAE,MAAM,KAAK,CAAA;IAC3D,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,yBAAyB,CAAC,uCAAuC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IAChG,CAAC;IACD,MAAM,IAAI,yBAAyB,CACjC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\n * INTERNAL adapter that builds a configured `DerivationEngine` from a line\n * working directory, and classifies whatever the engine throws.\n *\n * Migrated from `linea/server/src/model/services/utils.js:engine` and\n * `getEngineModel` (~18-36). Not exported from `src/index.ts`.\n */\nimport fs from 'node:fs'\nimport { DerivationEngine, type DerivationEngineConfig } from 'spl-js-engine'\nimport { PLATFORM_PATHS } from '../constants.js'\nimport { FeatureSelectionInvalidError, LinePlatformNotFoundError } from '../errors.js'\nimport { describeSelectionFailure, isFeatureSelectionError } from '../feature-model/engine.js'\nimport { fileExists, readTextFile, resolveLinePaths } from '../fs/workspace.js'\n\n/**\n * The `featureModel` argument for `DerivationEngine`.\n *\n * PARITY QUIRK, forced by the engine rather than chosen. `setFeatureModel`\n * sniffs the notation with `featureModel.endsWith('uvl')` over the ARGUMENT, so:\n *\n * - for UVL it must be handed the FILE PATH — the path ends in `.uvl`, the\n * check passes and `FeatureModel.fromUVL` reads the file. Passing UVL *text*\n * would fail the `endsWith` test and the engine would try `fromXml` on it.\n * - for XML it must be handed the CONTENT — a path not ending in `uvl` would go\n * to `fromXml`, which would then try to parse the path itself as a document.\n *\n * That is exactly what `getEngineModel` does, and why it looks inconsistent.\n *\n * Note this bypasses `parseFeatureModel`, so the `asUvlContent` guard (which\n * appends a newline to stop `fromUVL` reading a file) is NOT in play here: for\n * UVL we deliberately WANT the file to be read, and the argument is a path we\n * built ourselves from `lineDir`, never caller-supplied content.\n */\nconst resolveEngineModel = (lineDir: string): string => {\n const paths = resolveLinePaths({ lineDir })\n if (fileExists({ filePath: paths.model })) return paths.model\n\n const xmlPath = paths.model.replace(/\\.uvl$/, '.xml')\n if (!fileExists({ filePath: xmlPath })) {\n throw new LinePlatformNotFoundError(\n `No feature model in \"${lineDir}\": expected \"${PLATFORM_PATHS.model}\" or \"${PLATFORM_PATHS.modelXml}\".`\n )\n }\n return readTextFile({ filePath: xmlPath })\n}\n\n/**\n * The slice of the engine this module actually drives.\n *\n * Declared locally rather than importing `DerivationEngineInstance`, for the\n * same reason as `SolvingType` in `analysis/runtime.ts`: `spl-js-engine` ships\n * no declarations of its own, and our ambient ones under `src/types/` are never\n * published. A third-party type on an exported signature therefore ends up as a\n * dangling reference in `dist/**\\/*.d.ts` and breaks any consumer building with\n * `skipLibCheck: false`. This one was NOT yet reachable from `index.d.ts`, so it\n * did not fail anything — it was a latent version of the bug that did.\n * `npm run check:consumer` now compiles every emitted declaration, so a\n * regression here fails immediately instead of waiting for the day something\n * public happens to expose it.\n */\ninterface DerivationEngineHandle {\n generateProduct: (outputDir: string, spec: unknown) => Promise<unknown>\n generateZip: (spec: unknown) => Promise<unknown>\n}\n\n/**\n * Builds a `DerivationEngine` for a line working directory.\n *\n * Remember the engine's constructor RETURNS A PROMISE — `new DerivationEngine()`\n * evaluates to a promise and must be awaited. The positional argument order\n * mirrors `utils.js:engine()`.\n */\nexport const createEngine = async (lineDir: string): Promise<DerivationEngineHandle> => {\n const paths = resolveLinePaths({ lineDir })\n const featureModel = resolveEngineModel(lineDir)\n\n if (!fs.existsSync(paths.code)) {\n throw new LinePlatformNotFoundError(\n `No annotated code in \"${lineDir}\": expected \"${PLATFORM_PATHS.code}\".`\n )\n }\n\n const config = JSON.parse(readTextFile({ filePath: paths.config })) as DerivationEngineConfig\n const extraJs = readTextFile({ filePath: paths.extraJs })\n const transformation = readTextFile({ filePath: paths.transformation })\n\n // The cast is the price of not leaking `DerivationEngineInstance` into the\n // published declarations: the engine's own parameter types are narrower than\n // the structural handle, and function parameters are contravariant. Widening\n // is safe here because this module is the only caller and it always passes the\n // output of `buildEngineSpec`.\n const engine = await new DerivationEngine(\n paths.code, featureModel, config, extraJs, transformation\n )\n return engine as unknown as DerivationEngineHandle\n}\n\n/**\n * Turns whatever the engine threw into linea-core's taxonomy.\n *\n * Replicates the classification of `generatePipeline.js:runEngine` (~132-147)\n * and `ProductService.js:generateZip` (~375-382):\n *\n * - `FeatureSelectionError` propagates as such — it is the caller's fault, and\n * the monolith maps it to a 400.\n * - a `ReferenceError` means an annotation called a helper that `extra.js` does\n * not define; the monolith logs `error_messages.missing_function_error` and\n * then throws `LinePlatformNotFoundError` anyway.\n * - anything else becomes `LinePlatformNotFoundError`.\n *\n * PARITY NOTE: in the monolith BOTH the ReferenceError branch and the catch-all\n * throw `LinePlatformNotFoundError`; only the LOG MESSAGE differs. linea-core\n * takes no log callback (generation logs are out of scope), so the distinction\n * is preserved where it survives: the i18n key travels in the error MESSAGE\n * instead of a log line, and the original error is attached as `cause`. The\n * thrown TYPE is identical to the monolith's in every branch.\n */\nexport const rethrowDerivationError = (error: unknown): never => {\n if (isFeatureSelectionError(error)) {\n throw new FeatureSelectionInvalidError(describeSelectionFailure(error).message, { cause: error })\n }\n if (error instanceof LinePlatformNotFoundError) throw error\n if (error instanceof ReferenceError) {\n throw new LinePlatformNotFoundError('error_messages.missing_function_error', { cause: error })\n }\n throw new LinePlatformNotFoundError(\n error instanceof Error ? error.message : String(error),\n { cause: error }\n )\n}\n"]}
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/derivation/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAA+B,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC7H,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACxF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,2HAA2H;AAC3H,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAU,EAAE;IACrD,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;IAC3C,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,yBAAyB,CAAC,wBAAwB,OAAO,gBAAgB,cAAc,CAAC,KAAK,IAAI,CAAC,CAAA;IAC9G,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAA;AACpB,CAAC,CAAA;AAOD,MAAM,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AM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,yGAAyG;IACzG,8GAA8G;IAC9G,IAAI,KAAK,KAAK,UAAU;QAAE,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5E,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AAChE,CAAC,CAAA","sourcesContent":["import fs from 'node:fs'\nimport { DerivationEngine, type DerivationEngineConfig } from 'spl-js-engine'\nimport { PLATFORM_PATHS } from '../constants.js'\nimport { FeatureModelEmptyError, FeatureSelectionInvalidError, LinePlatformNotFoundError, TemplateError } from '../errors.js'\nimport { describeSelectionFailure, isFeatureSelectionError } from './selection-error.js'\nimport { fileExists, readTextFile, resolveLinePaths } from '../fs/workspace.js'\n\n/** The feature model the derivation engine reads: the one composed from the SPL's feature model and its modules' (UVL). */\nconst resolveEngineModel = (lineDir: string): string => {\n const paths = resolveLinePaths({ lineDir })\n if (!fileExists({ filePath: paths.model })) {\n throw new LinePlatformNotFoundError(`No feature model in \"${lineDir}\": expected \"${PLATFORM_PATHS.model}\".`)\n }\n return paths.model\n}\n\ninterface DerivationEngineHandle {\n generateProduct: (outputDir: string, spec: unknown) => Promise<unknown>\n generateZip: (spec: unknown) => Promise<unknown>\n}\n\nexport const createEngine = async (lineDir: string): Promise<DerivationEngineHandle> => {\n const paths = resolveLinePaths({ lineDir })\n const featureModel = resolveEngineModel(lineDir)\n\n if (!fs.existsSync(paths.code)) {\n throw new LinePlatformNotFoundError(\n `No annotated code in \"${lineDir}\": expected \"${PLATFORM_PATHS.code}\".`\n )\n }\n\n const config = JSON.parse(readTextFile({ filePath: paths.config })) as DerivationEngineConfig\n const extraJs = readTextFile({ filePath: paths.extraJs })\n const transformation = readTextFile({ filePath: paths.transformation })\n\n const engine = await new DerivationEngine(\n paths.code, featureModel, config, extraJs, transformation\n )\n namingFailedTemplates(engine as unknown as EngineWithInput)\n return engine as unknown as DerivationEngineHandle\n}\n\ntype CodeFileCallback = (filePath: string, ...rest: unknown[]) => unknown\nexport interface EngineWithInput { input?: { forEachCodeFile?: (cb: CodeFileCallback) => unknown } }\n\nconst named = new WeakSet<Error>()\n\nexport const namingFailedTemplates = (engine: EngineWithInput): void => {\n const input = engine.input\n const forEach = input?.forEachCodeFile\n if (!input || typeof forEach !== 'function') return\n input.forEachCodeFile = (cb) => forEach.call(input, (filePath: string, ...rest: unknown[]) => {\n try {\n return cb(filePath, ...rest)\n } catch (error) {\n if (error instanceof Error && !named.has(error)) {\n named.add(error)\n error.message = `${error.message} (${String(filePath).split('\\\\').join('/')})`\n }\n throw error\n }\n })\n}\n\nconst ROOT_WITHOUT_FEATURES = 'abstract feature cannot be leaf'\n\n/** `setup`: building the engine from the platform files; `generate`: running the templates for a product. */\nexport type DerivationStage = 'setup' | 'generate'\n\nexport const rethrowDerivationError = (error: unknown, stage: DerivationStage = 'setup'): never => {\n if (error === ROOT_WITHOUT_FEATURES) {\n throw new FeatureModelEmptyError('error_messages.feature_model_empty', { cause: error })\n }\n if (isFeatureSelectionError(error)) {\n throw new FeatureSelectionInvalidError(describeSelectionFailure(error).message, { cause: error })\n }\n if (error instanceof LinePlatformNotFoundError) throw error\n if (error instanceof ReferenceError) {\n throw new LinePlatformNotFoundError('error_messages.missing_function_error', { cause: error })\n }\n const message = error instanceof Error ? error.message : String(error)\n // anything else that came out of the templates while generating (a TypeError on a missing section, a bad\n // expression...): the platform exists, so it is not \"platform not found\" -- report the template failure it is\n if (stage === 'generate') throw new TemplateError(message, { cause: error })\n throw new LinePlatformNotFoundError(message, { cause: error })\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export interface SelectionFailure {
2
+ readonly message: string;
3
+ readonly errorType: string | null;
4
+ }
5
+ /** Whether the derivation engine refused a product because its feature selection does not fit the feature model. */
6
+ export declare const isFeatureSelectionError: (error: unknown) => boolean;
7
+ export declare const describeSelectionFailure: (error: unknown) => SelectionFailure;
@@ -0,0 +1,13 @@
1
+ import FeatureSelectionError from 'spl-js-engine/src/feature-model/feature-selection-error.js';
2
+ /** Whether the derivation engine refused a product because its feature selection does not fit the feature model. */
3
+ export const isFeatureSelectionError = (error) => error instanceof FeatureSelectionError;
4
+ export const describeSelectionFailure = (error) => {
5
+ if (error instanceof FeatureSelectionError) {
6
+ return { message: error.message, errorType: error.errorType ?? null };
7
+ }
8
+ if (error instanceof Error) {
9
+ return { message: error.message, errorType: null };
10
+ }
11
+ return { message: String(error), errorType: null };
12
+ };
13
+ //# sourceMappingURL=selection-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection-error.js","sourceRoot":"","sources":["../../src/derivation/selection-error.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,4DAA4D,CAAA;AAO9F,oHAAoH;AACpH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAW,EAAE,CACjE,KAAK,YAAY,qBAAqB,CAAA;AAExC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAc,EAAoB,EAAE;IAC3E,IAAI,KAAK,YAAY,qBAAqB,EAAE,CAAC;QAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,EAAE,CAAA;IACvE,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IACpD,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;AACpD,CAAC,CAAA","sourcesContent":["import FeatureSelectionError from 'spl-js-engine/src/feature-model/feature-selection-error.js'\n\nexport interface SelectionFailure {\n readonly message: string\n readonly errorType: string | null\n}\n\n/** Whether the derivation engine refused a product because its feature selection does not fit the feature model. */\nexport const isFeatureSelectionError = (error: unknown): boolean =>\n error instanceof FeatureSelectionError\n\nexport const describeSelectionFailure = (error: unknown): SelectionFailure => {\n if (error instanceof FeatureSelectionError) {\n return { message: error.message, errorType: error.errorType ?? null }\n }\n if (error instanceof Error) {\n return { message: error.message, errorType: null }\n }\n return { message: String(error), errorType: null }\n}\n"]}
package/dist/errors.d.ts CHANGED
@@ -1,72 +1,44 @@
1
- /**
2
- * Error taxonomy of linea-core.
3
- *
4
- * Migrated from `linea/server/src/model/errors/errors.js`, keeping only the
5
- * subset that belongs to the offline engine. User-facing and GitLab-facing
6
- * errors (`IncorrectCredentialsError`, `UserNotFoundError`, `PermissionError`,
7
- * `AlreadyExistent*Error`, `LineNotFoundError`) stay in linea-server: linea-core
8
- * knows nothing about users, sessions or repositories (ADR-002, ADR-003).
9
- *
10
- * Every error carries a stable `.code` so callers can branch on it without
11
- * string-matching messages or relying on `instanceof` across module instances.
12
- */
13
- /** Stable, machine-readable discriminator of a `LineaCoreError`. */
14
- export type LineaCoreErrorCode = 'INVALID_ARGUMENT' | 'UVL_PARSE_ERROR' | 'UNSUPPORTED_CONVERSION' | 'FEATURE_SELECTION_INVALID' | 'LINE_PLATFORM_NOT_FOUND' | 'INVALID_PRODUCT_SPEC' | 'PRODUCTS_INDEX_ERROR' | 'ANALYSIS_RUNTIME_ERROR';
15
- /** Base class of every error thrown by linea-core. */
1
+ import type { Diagnostic } from './modules/types.js';
2
+ export type LineaCoreErrorCode = 'INVALID_ARGUMENT' | 'UVL_PARSE_ERROR' | 'FEATURE_SELECTION_INVALID' | 'LINE_PLATFORM_NOT_FOUND' | 'FEATURE_MODEL_EMPTY' | 'INVALID_PRODUCT_SPEC' | 'PRODUCTS_INDEX_ERROR' | 'ANALYSIS_RUNTIME_ERROR' | 'MODULE_MANIFEST_INVALID' | 'MODULE_RESOLUTION_FAILED' | 'MODULE_CHECK_FAILED' | 'TEMPLATE_ERROR';
16
3
  export declare class LineaCoreError extends Error {
17
- /** Stable discriminator; never changes for a given subclass. */
18
4
  readonly code: LineaCoreErrorCode;
19
5
  constructor(code: LineaCoreErrorCode, message: string, options?: ErrorOptions);
20
6
  }
21
- /** A parameter is missing, malformed or outside its allowed domain. */
22
7
  export declare class InvalidArgumentError extends LineaCoreError {
23
8
  constructor(message: string, options?: ErrorOptions);
24
9
  }
25
- /**
26
- * A UVL document could not be parsed.
27
- * Equivalent of `UVLValidationError` in the monolith.
28
- */
29
10
  export declare class UvlParseError extends LineaCoreError {
30
11
  constructor(message: string, options?: ErrorOptions);
31
12
  }
32
- /**
33
- * The requested feature model conversion is not supported (e.g. UVL to UVL).
34
- * Migrated from `UnsupportedConversionError`.
35
- */
36
- export declare class UnsupportedConversionError extends LineaCoreError {
37
- constructor(message: string, options?: ErrorOptions);
38
- }
39
- /**
40
- * A feature selection is not valid against its feature model.
41
- * Wraps `FeatureSelectionError` from spl-js-engine, which the monolith surfaces
42
- * directly (e.g. `ProductService.js:14`, `agents/tools/evolution.js`).
43
- */
44
13
  export declare class FeatureSelectionInvalidError extends LineaCoreError {
45
14
  constructor(message: string, options?: ErrorOptions);
46
15
  }
47
- /**
48
- * A line working directory has no platform feature model.
49
- * Migrated from `LinePlatformNotFoundError` (used in `generatePipeline.js:27`).
50
- */
51
16
  export declare class LinePlatformNotFoundError extends LineaCoreError {
52
17
  constructor(message: string, options?: ErrorOptions);
53
18
  }
54
- /** A product spec fails the domain rules (name, version, features, SRID...). */
19
+ /** A template of the annotated code threw while the product was derived: the platform is there, one of its files is broken for this product. */
20
+ export declare class TemplateError extends LineaCoreError {
21
+ constructor(message: string, options?: ErrorOptions);
22
+ }
23
+ export declare class FeatureModelEmptyError extends LineaCoreError {
24
+ constructor(message: string, options?: ErrorOptions);
25
+ }
55
26
  export declare class InvalidProductSpecError extends LineaCoreError {
56
27
  constructor(message: string, options?: ErrorOptions);
57
28
  }
58
- /** The `products.json` index (ADR-011) is missing, unreadable or malformed. */
59
29
  export declare class ProductsIndexError extends LineaCoreError {
60
30
  constructor(message: string, options?: ErrorOptions);
61
31
  }
62
- /**
63
- * The feature model analysis runtime could not start, failed its canary, or has
64
- * already been disposed (ADR-021).
65
- *
66
- * Exists so a broken Pyodide bootstrap surfaces as an explicit failure. flamapy
67
- * swallows those errors and then returns `undefined` from every operation, which
68
- * would make an offline core report empty metrics without telling anyone.
69
- */
70
32
  export declare class AnalysisRuntimeError extends LineaCoreError {
71
33
  constructor(message: string, options?: ErrorOptions);
72
34
  }
35
+ export declare class ModuleManifestError extends LineaCoreError {
36
+ constructor(message: string, options?: ErrorOptions);
37
+ }
38
+ export declare class ModuleResolutionError extends LineaCoreError {
39
+ constructor(message: string, options?: ErrorOptions);
40
+ }
41
+ export declare class ModuleCheckError extends LineaCoreError {
42
+ readonly diagnostics: readonly Diagnostic[];
43
+ constructor(message: string, diagnostics: readonly Diagnostic[], options?: ErrorOptions);
44
+ }
package/dist/errors.js CHANGED
@@ -1,18 +1,4 @@
1
- /**
2
- * Error taxonomy of linea-core.
3
- *
4
- * Migrated from `linea/server/src/model/errors/errors.js`, keeping only the
5
- * subset that belongs to the offline engine. User-facing and GitLab-facing
6
- * errors (`IncorrectCredentialsError`, `UserNotFoundError`, `PermissionError`,
7
- * `AlreadyExistent*Error`, `LineNotFoundError`) stay in linea-server: linea-core
8
- * knows nothing about users, sessions or repositories (ADR-002, ADR-003).
9
- *
10
- * Every error carries a stable `.code` so callers can branch on it without
11
- * string-matching messages or relying on `instanceof` across module instances.
12
- */
13
- /** Base class of every error thrown by linea-core. */
14
1
  export class LineaCoreError extends Error {
15
- /** Stable discriminator; never changes for a given subclass. */
16
2
  code;
17
3
  constructor(code, message, options) {
18
4
  super(message, options);
@@ -20,72 +6,67 @@ export class LineaCoreError extends Error {
20
6
  this.code = code;
21
7
  }
22
8
  }
23
- /** A parameter is missing, malformed or outside its allowed domain. */
24
9
  export class InvalidArgumentError extends LineaCoreError {
25
10
  constructor(message, options) {
26
11
  super('INVALID_ARGUMENT', message, options);
27
12
  }
28
13
  }
29
- /**
30
- * A UVL document could not be parsed.
31
- * Equivalent of `UVLValidationError` in the monolith.
32
- */
33
14
  export class UvlParseError extends LineaCoreError {
34
15
  constructor(message, options) {
35
16
  super('UVL_PARSE_ERROR', message, options);
36
17
  }
37
18
  }
38
- /**
39
- * The requested feature model conversion is not supported (e.g. UVL to UVL).
40
- * Migrated from `UnsupportedConversionError`.
41
- */
42
- export class UnsupportedConversionError extends LineaCoreError {
43
- constructor(message, options) {
44
- super('UNSUPPORTED_CONVERSION', message, options);
45
- }
46
- }
47
- /**
48
- * A feature selection is not valid against its feature model.
49
- * Wraps `FeatureSelectionError` from spl-js-engine, which the monolith surfaces
50
- * directly (e.g. `ProductService.js:14`, `agents/tools/evolution.js`).
51
- */
52
19
  export class FeatureSelectionInvalidError extends LineaCoreError {
53
20
  constructor(message, options) {
54
21
  super('FEATURE_SELECTION_INVALID', message, options);
55
22
  }
56
23
  }
57
- /**
58
- * A line working directory has no platform feature model.
59
- * Migrated from `LinePlatformNotFoundError` (used in `generatePipeline.js:27`).
60
- */
61
24
  export class LinePlatformNotFoundError extends LineaCoreError {
62
25
  constructor(message, options) {
63
26
  super('LINE_PLATFORM_NOT_FOUND', message, options);
64
27
  }
65
28
  }
66
- /** A product spec fails the domain rules (name, version, features, SRID...). */
29
+ /** A template of the annotated code threw while the product was derived: the platform is there, one of its files is broken for this product. */
30
+ export class TemplateError extends LineaCoreError {
31
+ constructor(message, options) {
32
+ super('TEMPLATE_ERROR', message, options);
33
+ }
34
+ }
35
+ export class FeatureModelEmptyError extends LineaCoreError {
36
+ constructor(message, options) {
37
+ super('FEATURE_MODEL_EMPTY', message, options);
38
+ }
39
+ }
67
40
  export class InvalidProductSpecError extends LineaCoreError {
68
41
  constructor(message, options) {
69
42
  super('INVALID_PRODUCT_SPEC', message, options);
70
43
  }
71
44
  }
72
- /** The `products.json` index (ADR-011) is missing, unreadable or malformed. */
73
45
  export class ProductsIndexError extends LineaCoreError {
74
46
  constructor(message, options) {
75
47
  super('PRODUCTS_INDEX_ERROR', message, options);
76
48
  }
77
49
  }
78
- /**
79
- * The feature model analysis runtime could not start, failed its canary, or has
80
- * already been disposed (ADR-021).
81
- *
82
- * Exists so a broken Pyodide bootstrap surfaces as an explicit failure. flamapy
83
- * swallows those errors and then returns `undefined` from every operation, which
84
- * would make an offline core report empty metrics without telling anyone.
85
- */
86
50
  export class AnalysisRuntimeError extends LineaCoreError {
87
51
  constructor(message, options) {
88
52
  super('ANALYSIS_RUNTIME_ERROR', message, options);
89
53
  }
90
54
  }
55
+ export class ModuleManifestError extends LineaCoreError {
56
+ constructor(message, options) {
57
+ super('MODULE_MANIFEST_INVALID', message, options);
58
+ }
59
+ }
60
+ export class ModuleResolutionError extends LineaCoreError {
61
+ constructor(message, options) {
62
+ super('MODULE_RESOLUTION_FAILED', message, options);
63
+ }
64
+ }
65
+ export class ModuleCheckError extends LineaCoreError {
66
+ diagnostics;
67
+ constructor(message, diagnostics, options) {
68
+ super('MODULE_CHECK_FAILED', message, options);
69
+ this.diagnostics = diagnostics;
70
+ }
71
+ }
91
72
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,sDAAsD;AACtD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,gEAAgE;IACvD,IAAI,CAAoB;IAEjC,YAAa,IAAwB,EAAE,OAAe,EAAE,OAAsB;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,uEAAuE;AACvE,MAAM,OAAO,oBAAqB,SAAQ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AE,OAAO,CAAC,CAAA;IACnD,CAAC;CACF","sourcesContent":["/**\n * Error taxonomy of linea-core.\n *\n * Migrated from `linea/server/src/model/errors/errors.js`, keeping only the\n * subset that belongs to the offline engine. User-facing and GitLab-facing\n * errors (`IncorrectCredentialsError`, `UserNotFoundError`, `PermissionError`,\n * `AlreadyExistent*Error`, `LineNotFoundError`) stay in linea-server: linea-core\n * knows nothing about users, sessions or repositories (ADR-002, ADR-003).\n *\n * Every error carries a stable `.code` so callers can branch on it without\n * string-matching messages or relying on `instanceof` across module instances.\n */\n\n/** Stable, machine-readable discriminator of a `LineaCoreError`. */\nexport type LineaCoreErrorCode =\n | 'INVALID_ARGUMENT'\n | 'UVL_PARSE_ERROR'\n | 'UNSUPPORTED_CONVERSION'\n | 'FEATURE_SELECTION_INVALID'\n | 'LINE_PLATFORM_NOT_FOUND'\n | 'INVALID_PRODUCT_SPEC'\n | 'PRODUCTS_INDEX_ERROR'\n | 'ANALYSIS_RUNTIME_ERROR'\n\n/** Base class of every error thrown by linea-core. */\nexport class LineaCoreError extends Error {\n /** Stable discriminator; never changes for a given subclass. */\n readonly code: LineaCoreErrorCode\n\n constructor (code: LineaCoreErrorCode, message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = new.target.name\n this.code = code\n }\n}\n\n/** A parameter is missing, malformed or outside its allowed domain. */\nexport class InvalidArgumentError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('INVALID_ARGUMENT', message, options)\n }\n}\n\n/**\n * A UVL document could not be parsed.\n * Equivalent of `UVLValidationError` in the monolith.\n */\nexport class UvlParseError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('UVL_PARSE_ERROR', message, options)\n }\n}\n\n/**\n * The requested feature model conversion is not supported (e.g. UVL to UVL).\n * Migrated from `UnsupportedConversionError`.\n */\nexport class UnsupportedConversionError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('UNSUPPORTED_CONVERSION', message, options)\n }\n}\n\n/**\n * A feature selection is not valid against its feature model.\n * Wraps `FeatureSelectionError` from spl-js-engine, which the monolith surfaces\n * directly (e.g. `ProductService.js:14`, `agents/tools/evolution.js`).\n */\nexport class FeatureSelectionInvalidError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('FEATURE_SELECTION_INVALID', message, options)\n }\n}\n\n/**\n * A line working directory has no platform feature model.\n * Migrated from `LinePlatformNotFoundError` (used in `generatePipeline.js:27`).\n */\nexport class LinePlatformNotFoundError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('LINE_PLATFORM_NOT_FOUND', message, options)\n }\n}\n\n/** A product spec fails the domain rules (name, version, features, SRID...). */\nexport class InvalidProductSpecError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('INVALID_PRODUCT_SPEC', message, options)\n }\n}\n\n/** The `products.json` index (ADR-011) is missing, unreadable or malformed. */\nexport class ProductsIndexError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('PRODUCTS_INDEX_ERROR', message, options)\n }\n}\n\n/**\n * The feature model analysis runtime could not start, failed its canary, or has\n * already been disposed (ADR-021).\n *\n * Exists so a broken Pyodide bootstrap surfaces as an explicit failure. flamapy\n * swallows those errors and then returns `undefined` from every operation, which\n * would make an offline core report empty metrics without telling anyone.\n */\nexport class AnalysisRuntimeError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('ANALYSIS_RUNTIME_ERROR', message, options)\n }\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,CAAoB;IAEjC,YAAa,IAAwB,EAAE,OAAe,EAAE,OAAsB;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAA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C;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IACtD,YAAa,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,YAAa,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,yBAAyB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IACvD,YAAa,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IACzC,WAAW,CAAuB;IAE3C,YACE,OAAe,EACf,WAAkC,EAClC,OAAsB;QAEtB,KAAK,CAAC,qBAAqB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAC9C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CACF","sourcesContent":["import type { Diagnostic } from './modules/types.js'\n\nexport type LineaCoreErrorCode =\n | 'INVALID_ARGUMENT'\n | 'UVL_PARSE_ERROR'\n | 'FEATURE_SELECTION_INVALID'\n | 'LINE_PLATFORM_NOT_FOUND'\n | 'FEATURE_MODEL_EMPTY'\n | 'INVALID_PRODUCT_SPEC'\n | 'PRODUCTS_INDEX_ERROR'\n | 'ANALYSIS_RUNTIME_ERROR'\n | 'MODULE_MANIFEST_INVALID'\n | 'MODULE_RESOLUTION_FAILED'\n | 'MODULE_CHECK_FAILED'\n | 'TEMPLATE_ERROR'\n\nexport class LineaCoreError extends Error {\n readonly code: LineaCoreErrorCode\n\n constructor (code: LineaCoreErrorCode, message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = new.target.name\n this.code = code\n }\n}\n\nexport class InvalidArgumentError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('INVALID_ARGUMENT', message, options)\n }\n}\n\nexport class UvlParseError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('UVL_PARSE_ERROR', message, options)\n }\n}\n\nexport class FeatureSelectionInvalidError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('FEATURE_SELECTION_INVALID', message, options)\n }\n}\n\nexport class LinePlatformNotFoundError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('LINE_PLATFORM_NOT_FOUND', message, options)\n }\n}\n\n/** A template of the annotated code threw while the product was derived: the platform is there, one of its files is broken for this product. */\nexport class TemplateError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('TEMPLATE_ERROR', message, options)\n }\n}\n\nexport class FeatureModelEmptyError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('FEATURE_MODEL_EMPTY', message, options)\n }\n}\n\nexport class InvalidProductSpecError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('INVALID_PRODUCT_SPEC', message, options)\n }\n}\n\nexport class ProductsIndexError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('PRODUCTS_INDEX_ERROR', message, options)\n }\n}\n\nexport class AnalysisRuntimeError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('ANALYSIS_RUNTIME_ERROR', message, options)\n }\n}\n\nexport class ModuleManifestError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('MODULE_MANIFEST_INVALID', message, options)\n }\n}\n\nexport class ModuleResolutionError extends LineaCoreError {\n constructor (message: string, options?: ErrorOptions) {\n super('MODULE_RESOLUTION_FAILED', message, options)\n }\n}\n\nexport class ModuleCheckError extends LineaCoreError {\n readonly diagnostics: readonly Diagnostic[]\n\n constructor (\n message: string,\n diagnostics: readonly Diagnostic[],\n options?: ErrorOptions\n ) {\n super('MODULE_CHECK_FAILED', message, options)\n this.diagnostics = diagnostics\n }\n}\n"]}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The feature model as bango's feature metamodel (`featuremodel`) gives it as JSON (its JSON mapping, `featureModel`), and UVL (the
3
+ * Universal Variability Language, Boolean level) as text. The platform's tools speak UVL (flamapy, the derivation engine); the models are
4
+ * bango's. This is the one place where one becomes the other.
5
+ */
6
+ export type GroupKind = 'mandatory' | 'optional' | 'alternative' | 'or' | 'cardinality';
7
+ export interface FeatureNode {
8
+ readonly name: string;
9
+ readonly abstract?: boolean;
10
+ readonly groups: readonly FeatureGroup[];
11
+ }
12
+ export interface FeatureGroup {
13
+ readonly kind: GroupKind;
14
+ /** Only for a `cardinality` group: `[min..max]`; `max` is missing when there is none (`[min..*]`). */
15
+ readonly min?: number;
16
+ readonly max?: number;
17
+ readonly features: readonly FeatureNode[];
18
+ }
19
+ export type Formula = {
20
+ readonly feature: string;
21
+ } | {
22
+ readonly not: Formula;
23
+ } | {
24
+ readonly operator: '&' | '|' | '=>' | '<=>';
25
+ readonly left: Formula;
26
+ readonly right: Formula;
27
+ };
28
+ export interface FeatureModelTree {
29
+ readonly name: string;
30
+ readonly root: FeatureNode;
31
+ readonly constraints: readonly Formula[];
32
+ }
33
+ /** A name as UVL writes it: plain when it can be, else between double quotes (which cannot hold a dot, a quote or a line break). */
34
+ export declare const uvlName: ({ name }: {
35
+ name: string;
36
+ }) => string;
37
+ /** The tree as UVL: tabs, one feature or group to a line, empty groups left out (UVL has none), constraints one to a line. */
38
+ export declare const printUvl: ({ tree }: {
39
+ tree: FeatureModelTree;
40
+ }) => string;
41
+ /**
42
+ * UVL (Boolean level: features with mandatory, optional, alternative, or and cardinality groups, and `! & | => <=>` constraints) as a tree.
43
+ * `namespace`, `include` and `imports` are skipped. What is not supported (typed features, feature cardinalities, arithmetic) is said, with its line.
44
+ * Throws `UvlParseError`.
45
+ */
46
+ export declare const parseUvl: ({ content }: {
47
+ content: string;
48
+ }) => FeatureModelTree;
49
+ /** Every feature of the tree, parents first. */
50
+ export declare const featuresOf: ({ tree }: {
51
+ tree: FeatureModelTree;
52
+ }) => FeatureNode[];