@lbdudc/linea-core 0.1.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.
- package/README.md +358 -0
- package/dist/analysis/analyze.d.ts +105 -0
- package/dist/analysis/analyze.js +220 -0
- package/dist/analysis/analyze.js.map +1 -0
- package/dist/analysis/runtime.d.ts +97 -0
- package/dist/analysis/runtime.js +198 -0
- package/dist/analysis/runtime.js.map +1 -0
- package/dist/analysis/wheels/micropip-0.6.0-py3-none-any.whl +0 -0
- package/dist/analysis/wheels/packaging-23.2-py3-none-any.whl +0 -0
- package/dist/assets.d.ts +16 -0
- package/dist/assets.js +36 -0
- package/dist/assets.js.map +1 -0
- package/dist/constants.d.ts +77 -0
- package/dist/constants.js +76 -0
- package/dist/constants.js.map +1 -0
- package/dist/derivation/derive.d.ts +68 -0
- package/dist/derivation/derive.js +115 -0
- package/dist/derivation/derive.js.map +1 -0
- package/dist/derivation/engine.d.ts +48 -0
- package/dist/derivation/engine.js +98 -0
- package/dist/derivation/engine.js.map +1 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.js +91 -0
- package/dist/errors.js.map +1 -0
- package/dist/feature-model/convert.d.ts +35 -0
- package/dist/feature-model/convert.js +47 -0
- package/dist/feature-model/convert.js.map +1 -0
- package/dist/feature-model/engine.d.ts +60 -0
- package/dist/feature-model/engine.js +139 -0
- package/dist/feature-model/engine.js.map +1 -0
- package/dist/feature-model/inspect.d.ts +67 -0
- package/dist/feature-model/inspect.js +113 -0
- package/dist/feature-model/inspect.js.map +1 -0
- package/dist/feature-model/io.d.ts +66 -0
- package/dist/feature-model/io.js +92 -0
- package/dist/feature-model/io.js.map +1 -0
- package/dist/feature-model/parse.d.ts +30 -0
- package/dist/feature-model/parse.js +36 -0
- package/dist/feature-model/parse.js.map +1 -0
- package/dist/feature-model/text.d.ts +54 -0
- package/dist/feature-model/text.js +126 -0
- package/dist/feature-model/text.js.map +1 -0
- package/dist/fs/archive.d.ts +23 -0
- package/dist/fs/archive.js +87 -0
- package/dist/fs/archive.js.map +1 -0
- package/dist/fs/diff.d.ts +40 -0
- package/dist/fs/diff.js +155 -0
- package/dist/fs/diff.js.map +1 -0
- package/dist/fs/format.d.ts +21 -0
- package/dist/fs/format.js +111 -0
- package/dist/fs/format.js.map +1 -0
- package/dist/fs/workspace.d.ts +77 -0
- package/dist/fs/workspace.js +103 -0
- package/dist/fs/workspace.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/guards.d.ts +15 -0
- package/dist/internal/guards.js +16 -0
- package/dist/internal/guards.js.map +1 -0
- package/dist/line/platform-files.d.ts +73 -0
- package/dist/line/platform-files.js +112 -0
- package/dist/line/platform-files.js.map +1 -0
- package/dist/line/scaffold.d.ts +88 -0
- package/dist/line/scaffold.js +145 -0
- package/dist/line/scaffold.js.map +1 -0
- package/dist/line/templates/core/extra.js +54 -0
- package/dist/line/templates/core/transformation.js +196 -0
- package/dist/line/templates/metamodels/dataModel/extra.js +328 -0
- package/dist/line/templates/metamodels/dataModel/transformation.js +211 -0
- package/dist/line/templates/metamodels/sensor/extra.js +36 -0
- package/dist/line/templates/metamodels/sensor/transformation.js +47 -0
- package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -0
- package/dist/line/templates/pipeline/ci/test-client.sh +16 -0
- package/dist/line/templates/pipeline/ci/test-server.sh +16 -0
- package/dist/product/engine-spec.d.ts +25 -0
- package/dist/product/engine-spec.js +77 -0
- package/dist/product/engine-spec.js.map +1 -0
- package/dist/product/spec.d.ts +130 -0
- package/dist/product/spec.js +219 -0
- package/dist/product/spec.js.map +1 -0
- package/dist/product/version.d.ts +27 -0
- package/dist/product/version.js +49 -0
- package/dist/product/version.js.map +1 -0
- package/dist/products-index/products-index.d.ts +224 -0
- package/dist/products-index/products-index.js +395 -0
- package/dist/products-index/products-index.js.map +1 -0
- package/dist/selection/selection.d.ts +126 -0
- package/dist/selection/selection.js +152 -0
- package/dist/selection/selection.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products-index.js","sourceRoot":"","sources":["../../src/products-index/products-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAkE9D,yEAAyE;AACzE,MAAM,MAAM,GAAG,CAAC,CAAqB,EAAE,CAAqB,EAAU,EAAE,CACtE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG,CAAC,EACtB,IAAI,EACJ,WAAW,EACX,OAAO,EACY,EAAsB,EAAE,CAC3C,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,EAAE;IAC3C,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE;IAChC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;AAE3B;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG,CAAC,EAC7B,OAAO,EACP,KAAK,EAIN,EAAQ,EAAE;IACT,IAAI,OAAO,KAAK,SAAS;QAAE,OAAM;IACjC,IAAI,OAAO,OAAO,KAAK,Q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,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACrD,GAAG,CAAC,cAAc,CAAC,CAAA;IAEtB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS;SAC9B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC5C,GAAG,CAAC,cAAc,CAAC,CAAA;IAEtB,OAAO;QACL,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACnE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9B,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;KACnC,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\r\n * The `products.json` index that lives at the root of every line repository.\r\n *\r\n * ADR-011 fixes the normative format:\r\n *\r\n * { \"productos\": [ { \"name\": \"...\", \"repositorio\": \"/ruta/en/gitlab\" } ] }\r\n *\r\n * The Spanish key `productos` is part of the decision and is NOT anglicised.\r\n *\r\n * ADR-011 foresaw its own extension (\"el esquema es versionable: si se amplía\r\n * (p. ej. versión del producto, estado), se hace de forma retrocompatible\").\r\n * That extension is now here: an entry MAY carry a `version` (`x.y.z`).\r\n *\r\n * { \"productos\": [ { \"name\": \"...\", \"repositorio\": \"...\", \"version\": \"1.2.3\" } ] }\r\n *\r\n * It is OPTIONAL and the compatibility rule is strict in both directions:\r\n * - an index written before this change parses, validates and serialises\r\n * exactly as before — no key appears out of nowhere;\r\n * - an entry with no version does NOT emit `\"version\": null` or `\"\"`, so\r\n * reading and rewriting an old index is a byte-for-byte no-op.\r\n * The reason it lives in the line's index at all — instead of in each product\r\n * repository, where the rest of the spec lives — is that listing the products of\r\n * a line has to show every version at once: one read per line instead of one\r\n * GitLab request per product.\r\n *\r\n * This index replaces the `products` Mongo collection of the monolith, so there\r\n * is no single function to migrate: the reconciliation semantics are adapted\r\n * from `linea/server/src/model/services/LineService.js:reconcileLines` (~134-193)\r\n * and `ProductService.js:reconcileProducts` (~232-295).\r\n *\r\n * Two deliberate departures from those (ADR-014, ADR-009):\r\n * - No database and no `archived` flag, so there is **no `prune`**. Entries that\r\n * no longer have a repository are REPORTED in `removed`, never dropped.\r\n * Deciding what to do about them is linea-server's call.\r\n * - Every mutation is pure: `add`/`rename`/`remove`/`reconcile` return a NEW\r\n * index and never touch the input, so a caller can diff before committing.\r\n */\r\nimport path from 'node:path'\r\nimport { NAME_PATTERN, PRODUCTS_INDEX_PATH, VERSION_PATTERN } from '../constants.js'\r\nimport { InvalidArgumentError, ProductsIndexError } from '../errors.js'\r\nimport { fileExists, readTextFile, writeTextFile } from '../fs/workspace.js'\r\nimport { isArray, isPlainObject } from '../internal/guards.js'\r\n\r\n/** One product of a line, as recorded in `products.json`. */\r\nexport interface ProductsIndexEntry {\r\n /** Product name; same rules as any other name (`NAME_PATTERN`). */\r\n readonly name: string\r\n /** Path of the product repository in the laboratory's GitLab. */\r\n readonly repositorio: string\r\n /**\r\n * Current product version (`VERSION_PATTERN`, i.e. `x.y.z`). **Optional**:\r\n * every index written before this field existed is still valid, and an entry\r\n * without it is never given one implicitly.\r\n *\r\n * It duplicates `spec.basicData.version`, which lives in the product's own\r\n * repository. That is the point: the enrolled-products listing needs every\r\n * version at once, and reading one file per product would be one GitLab\r\n * request per row. The product repository stays the source of truth; this is\r\n * the copy the line keeps to be able to list without fanning out.\r\n */\r\n readonly version?: string\r\n}\r\n\r\n/** The whole index. */\r\nexport interface ProductsIndex {\r\n readonly productos: ProductsIndexEntry[]\r\n}\r\n\r\n/** A problem found in an index. */\r\nexport interface ProductsIndexProblem {\r\n /** Dotted path of the offending field, e.g. `productos[2].repositorio`. */\r\n readonly path: string\r\n /** Stable machine-readable discriminator. */\r\n readonly code: ProductsIndexProblemCode\r\n /**\r\n * An i18n KEY, never a human-readable sentence — same policy as\r\n * `ProductSpecError.messageKey`, so a consumer never has to guess whether to\r\n * translate a value or render it raw.\r\n *\r\n * Two keys are inherited from the monolith and already translated:\r\n * `invalid_name_characters` and `basicData_version_format` (the latter reads\r\n * \"Version must follow the format X.Y.Z\", which is exactly the fact being\r\n * reported, so it is reused instead of minting an untranslated twin). The\r\n * rest are NEW (there was no products index to validate before ADR-011) and\r\n * have no translation yet; they are listed in CHANGELOG.md for whoever\r\n * migrates webui and linea-cli.\r\n */\r\n readonly messageKey: string\r\n}\r\n\r\n/** Stable discriminators for index problems. */\r\nexport type ProductsIndexProblemCode =\r\n | 'INDEX_NOT_OBJECT'\r\n | 'PRODUCTOS_NOT_ARRAY'\r\n | 'ENTRY_NOT_OBJECT'\r\n | 'NAME_REQUIRED'\r\n | 'NAME_INVALID_CHARACTERS'\r\n | 'NAME_DUPLICATED'\r\n | 'REPOSITORIO_REQUIRED'\r\n | 'VERSION_INVALID_FORMAT'\r\n\r\n/** Result of validating an index. */\r\nexport interface ProductsIndexValidation {\r\n readonly valid: boolean\r\n readonly errors: ProductsIndexProblem[]\r\n}\r\n\r\n/** Alphabetical by `name`, so serialisation is stable across callers. */\r\nconst byName = (a: ProductsIndexEntry, b: ProductsIndexEntry): number =>\r\n a.name < b.name ? -1 : a.name > b.name ? 1 : 0\r\n\r\n/**\r\n * Builds a normalised entry, keeping ONLY the normative fields.\r\n *\r\n * The `version` key is omitted altogether when there is no usable version, and\r\n * that omission is the whole retro-compatibility guarantee: emitting `null` or\r\n * `''` would change the bytes of every pre-existing `products.json` the moment\r\n * linea-server read it and wrote it back.\r\n */\r\nconst normalizeEntry = ({\r\n name,\r\n repositorio,\r\n version\r\n}: ProductsIndexEntry): ProductsIndexEntry =>\r\n typeof version === 'string' && version !== ''\r\n ? { name, repositorio, version }\r\n : { name, repositorio }\r\n\r\n/**\r\n * Guards an incoming optional version. Absent (`undefined`) is fine; anything\r\n * else has to be a `x.y.z` string.\r\n *\r\n * The mutating functions THROW here rather than reporting, unlike\r\n * `validateProductsIndex`: they take their input from a caller's arguments, not\r\n * from a file on disk, so a bad value is a programming error (ADR-018).\r\n */\r\nconst assertOptionalVersion = ({\r\n version,\r\n label\r\n}: {\r\n version: unknown\r\n label: string\r\n}): void => {\r\n if (version === undefined) return\r\n if (typeof version !== 'string' || !VERSION_PATTERN.test(version)) {\r\n throw new InvalidArgumentError(\r\n `${label} must be a version like \"1.2.3\"; got ${JSON.stringify(version)}.`\r\n )\r\n }\r\n}\r\n\r\nconst assertIndex = (index: unknown): ProductsIndex => {\r\n if (!isPlainObject(index) || !Array.isArray(index.productos)) {\r\n throw new InvalidArgumentError('\"index\" must be a { productos: [...] } object.')\r\n }\r\n return index as unknown as ProductsIndex\r\n}\r\n\r\n/**\r\n * An empty index.\r\n *\r\n * @returns A fresh `{ productos: [] }`. A new object every call, so callers can\r\n * safely treat it as their own.\r\n */\r\nexport const emptyProductsIndex = (): ProductsIndex => ({ productos: [] })\r\n\r\n/**\r\n * Validates an index **without throwing**.\r\n *\r\n * Checks the ADR-011 shape plus the domain rules that make the index usable:\r\n * names must be valid (`NAME_PATTERN`) and unique, and every entry needs a\r\n * `repositorio`.\r\n *\r\n * @param params.index The index to validate. Anything, including nullish.\r\n * @returns `valid` plus one entry per problem, in document order.\r\n */\r\nexport const validateProductsIndex = ({ index }: { index: unknown }): ProductsIndexValidation => {\r\n if (!isPlainObject(index)) {\r\n return {\r\n valid: false,\r\n errors: [{\r\n path: '(root)',\r\n code: 'INDEX_NOT_OBJECT',\r\n messageKey: 'error_messages.products_index_not_object'\r\n }]\r\n }\r\n }\r\n if (!Array.isArray(index.productos)) {\r\n return {\r\n valid: false,\r\n errors: [{\r\n path: 'productos',\r\n code: 'PRODUCTOS_NOT_ARRAY',\r\n messageKey: 'error_messages.products_index_productos_not_array'\r\n }]\r\n }\r\n }\r\n\r\n const errors: ProductsIndexProblem[] = []\r\n const seen = new Set<string>()\r\n\r\n index.productos.forEach((entry: unknown, position: number) => {\r\n const at = `productos[${position}]`\r\n if (!isPlainObject(entry)) {\r\n errors.push({\r\n path: at,\r\n code: 'ENTRY_NOT_OBJECT',\r\n messageKey: 'error_messages.products_index_entry_not_object'\r\n })\r\n return\r\n }\r\n\r\n const { name, repositorio, version } = entry\r\n if (typeof name !== 'string' || name === '') {\r\n errors.push({\r\n path: `${at}.name`,\r\n code: 'NAME_REQUIRED',\r\n messageKey: 'error_messages.products_index_name_required'\r\n })\r\n } else if (!NAME_PATTERN.test(name)) {\r\n errors.push({\r\n path: `${at}.name`,\r\n code: 'NAME_INVALID_CHARACTERS',\r\n messageKey: 'error_messages.invalid_name_characters'\r\n })\r\n } else if (seen.has(name)) {\r\n errors.push({\r\n path: `${at}.name`,\r\n code: 'NAME_DUPLICATED',\r\n messageKey: 'error_messages.products_index_name_duplicated'\r\n })\r\n } else {\r\n seen.add(name)\r\n }\r\n\r\n if (typeof repositorio !== 'string' || repositorio === '') {\r\n errors.push({\r\n path: `${at}.repositorio`,\r\n code: 'REPOSITORIO_REQUIRED',\r\n messageKey: 'error_messages.products_index_repositorio_required'\r\n })\r\n }\r\n\r\n // OPTIONAL: absent is valid, and only `undefined` counts as absent. `''`,\r\n // `null` and numbers are attempts at a version, and a wrong one is worth\r\n // reporting: silently accepting them would put junk in the field the\r\n // enrolled-products listing renders.\r\n if (version !== undefined && (typeof version !== 'string' || !VERSION_PATTERN.test(version))) {\r\n errors.push({\r\n path: `${at}.version`,\r\n code: 'VERSION_INVALID_FORMAT',\r\n messageKey: 'error_messages.basicData_version_format'\r\n })\r\n }\r\n })\r\n\r\n return { valid: errors.length === 0, errors }\r\n}\r\n\r\n/**\r\n * Parses the JSON contents of a `products.json`.\r\n *\r\n * @param params.content Raw file contents.\r\n * @returns The index, with only the normative fields kept per entry: `name`,\r\n * `repositorio` and, when the file has it, `version`. An index written before\r\n * `version` existed parses exactly as it always did.\r\n * @throws {ProductsIndexError} when the JSON is malformed or does not satisfy\r\n * the ADR-011 shape — which includes a `version` present but not `x.y.z`.\r\n */\r\nexport const parseProductsIndex = ({ content }: { content: string }): ProductsIndex => {\r\n if (typeof content !== 'string') {\r\n throw new InvalidArgumentError('\"content\" must be a string.')\r\n }\r\n if (content.trim() === '') return emptyProductsIndex()\r\n\r\n let parsed: unknown\r\n try {\r\n parsed = JSON.parse(content)\r\n } catch (error) {\r\n throw new ProductsIndexError(\r\n `products.json is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\r\n { cause: error }\r\n )\r\n }\r\n\r\n const validation = validateProductsIndex({ index: parsed })\r\n if (!validation.valid) {\r\n const summary = validation.errors.map((e) => `${e.path}: ${e.messageKey}`).join('; ')\r\n throw new ProductsIndexError(`products.json does not satisfy the ADR-011 format: ${summary}`)\r\n }\r\n\r\n const index = parsed as ProductsIndex\r\n return { productos: index.productos.map(normalizeEntry) }\r\n}\r\n\r\n/**\r\n * Serialises an index deterministically.\r\n *\r\n * Stability is a feature, not a detail: linea-server commits this file to the\r\n * line repository on every product create/rename/delete, so an unstable\r\n * serialisation would produce noisy diffs and spurious merge conflicts.\r\n * Guarantees: entries sorted alphabetically by `name`, only the normative fields\r\n * emitted and always in the same order (`name`, `repositorio`, `version`),\r\n * two-space indentation, single trailing newline.\r\n *\r\n * An entry with no version emits **no `version` key** — not `null`, not `''`.\r\n * That is what keeps an index written before this field byte-identical after a\r\n * read/write round trip.\r\n *\r\n * @param params.index The index to serialise.\r\n * @returns The JSON text to write.\r\n * @throws {InvalidArgumentError} when `index` is not index-shaped.\r\n */\r\nexport const serializeProductsIndex = ({ index }: { index: ProductsIndex }): string => {\r\n const checked = assertIndex(index)\r\n const productos = [...checked.productos].sort(byName).map(normalizeEntry)\r\n return `${JSON.stringify({ productos }, null, 2)}\\n`\r\n}\r\n\r\n/**\r\n * Adds a product to the index.\r\n *\r\n * @param params.index Current index. Not mutated.\r\n * @param params.product Entry to add. `version` is optional; when given it must\r\n * be `x.y.z`, and when omitted the entry simply has no version.\r\n * @returns A new, sorted index.\r\n * @throws {ProductsIndexError} when a product with that name is already there.\r\n * @throws {InvalidArgumentError} when the arguments are malformed.\r\n */\r\nexport const addProductToIndex = ({\r\n index,\r\n product\r\n}: {\r\n index: ProductsIndex\r\n product: ProductsIndexEntry\r\n}): ProductsIndex => {\r\n const checked = assertIndex(index)\r\n if (!isPlainObject(product)) {\r\n throw new InvalidArgumentError('\"product\" must be a { name, repositorio } object.')\r\n }\r\n const { name, repositorio, version } = product\r\n if (typeof name !== 'string' || !NAME_PATTERN.test(name)) {\r\n throw new InvalidArgumentError(`Invalid product name ${JSON.stringify(name)}.`)\r\n }\r\n if (typeof repositorio !== 'string' || repositorio === '') {\r\n throw new InvalidArgumentError('\"product.repositorio\" must be a non-empty string.')\r\n }\r\n assertOptionalVersion({ version, label: '\"product.version\"' })\r\n if (checked.productos.some((entry) => entry.name === name)) {\r\n throw new ProductsIndexError(`Product \"${name}\" is already in the index.`)\r\n }\r\n\r\n return {\r\n productos: [...checked.productos, normalizeEntry({ name, repositorio, version })].sort(byName)\r\n }\r\n}\r\n\r\n/**\r\n * Renames a product in the index, keeping its `repositorio` and its `version`.\r\n *\r\n * Note the repository path is intentionally left untouched: renaming a GitLab\r\n * project does not necessarily move it, and linea-server is the only component\r\n * that knows the new path. It should follow up with the real value if it changed.\r\n *\r\n * @param params.index Current index. Not mutated.\r\n * @param params.from Current product name.\r\n * @param params.to New product name.\r\n * @returns A new, sorted index.\r\n * @throws {ProductsIndexError} when `from` is missing or `to` already exists.\r\n * @throws {InvalidArgumentError} when the arguments are malformed.\r\n */\r\nexport const renameProductInIndex = ({\r\n index,\r\n from,\r\n to\r\n}: {\r\n index: ProductsIndex\r\n from: string\r\n to: string\r\n}): ProductsIndex => {\r\n const checked = assertIndex(index)\r\n if (typeof from !== 'string' || from === '') {\r\n throw new InvalidArgumentError('\"from\" must be a non-empty string.')\r\n }\r\n if (typeof to !== 'string' || !NAME_PATTERN.test(to)) {\r\n throw new InvalidArgumentError(`Invalid product name ${JSON.stringify(to)}.`)\r\n }\r\n if (!checked.productos.some((entry) => entry.name === from)) {\r\n throw new ProductsIndexError(`Product \"${from}\" is not in the index.`)\r\n }\r\n if (from !== to && checked.productos.some((entry) => entry.name === to)) {\r\n throw new ProductsIndexError(`Product \"${to}\" is already in the index.`)\r\n }\r\n\r\n return {\r\n productos: checked.productos\r\n .map((entry) => (entry.name === from ? normalizeEntry({ ...entry, name: to }) : entry))\r\n .sort(byName)\r\n }\r\n}\r\n\r\n/**\r\n * Removes a product from the index.\r\n *\r\n * IDEMPOTENT: removing a product that is not there returns an equivalent index\r\n * instead of throwing, so a retried or replayed delete cannot fail half-way.\r\n *\r\n * @param params.index Current index. Not mutated.\r\n * @param params.name Product to remove.\r\n * @returns A new, sorted index.\r\n * @throws {InvalidArgumentError} when the arguments are malformed.\r\n */\r\nexport const removeProductFromIndex = ({\r\n index,\r\n name\r\n}: {\r\n index: ProductsIndex\r\n name: string\r\n}): ProductsIndex => {\r\n const checked = assertIndex(index)\r\n if (typeof name !== 'string' || name === '') {\r\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\r\n }\r\n return { productos: checked.productos.filter((entry) => entry.name !== name).sort(byName) }\r\n}\r\n\r\n/**\r\n * Reads the index of a line working directory.\r\n *\r\n * A line with no `products.json` is a line with no products, not an error: the\r\n * file only appears once the first product is created, and every line predating\r\n * ADR-011 lacks it. A file that EXISTS but is corrupt is a different story and\r\n * does throw — silently treating it as empty would let linea-server commit a\r\n * fresh index over a real one and lose the product list.\r\n *\r\n * @param params.lineDir Root of the line working directory.\r\n * @returns The index, or an empty one when the file is absent.\r\n * @throws {ProductsIndexError} when the file exists but is malformed.\r\n */\r\nexport const readProductsIndex = ({ lineDir }: { lineDir: string }): ProductsIndex => {\r\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\r\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\r\n }\r\n const filePath = path.join(path.resolve(lineDir), PRODUCTS_INDEX_PATH)\r\n if (!fileExists({ filePath })) return emptyProductsIndex()\r\n return parseProductsIndex({ content: readTextFile({ filePath }) })\r\n}\r\n\r\n/**\r\n * Writes the index of a line working directory, creating it if needed.\r\n *\r\n * @param params.lineDir Root of the line working directory.\r\n * @param params.index The index to write.\r\n * @returns The absolute path written.\r\n * @throws {InvalidArgumentError} when the arguments are malformed.\r\n */\r\nexport const writeProductsIndex = ({\r\n lineDir,\r\n index\r\n}: {\r\n lineDir: string\r\n index: ProductsIndex\r\n}): { path: string } => {\r\n if (typeof lineDir !== 'string' || lineDir.trim() === '') {\r\n throw new InvalidArgumentError('\"lineDir\" must be a non-empty path.')\r\n }\r\n const content = serializeProductsIndex({ index })\r\n const filePath = path.join(path.resolve(lineDir), PRODUCTS_INDEX_PATH)\r\n return { path: writeTextFile({ filePath, content }) }\r\n}\r\n\r\n/** Outcome of reconciling an index against the repositories actually observed. */\r\nexport interface ProductsIndexReconciliation {\r\n /** The index with the newly discovered repositories added. */\r\n readonly index: ProductsIndex\r\n /**\r\n * Entries added because a repository existed but was not indexed. They carry\r\n * a `version` only if the caller observed one.\r\n */\r\n readonly added: ProductsIndexEntry[]\r\n /**\r\n * Entries indexed but with no observed repository.\r\n *\r\n * REPORTED ONLY — they stay in `index`. The monolith's `prune` archived such\r\n * rows in Mongo; without a database, dropping them here would silently destroy\r\n * the record of a product whose repository the caller merely could not see\r\n * (a permissions hiccup, a partial listing). linea-server decides.\r\n */\r\n readonly removed: ProductsIndexEntry[]\r\n}\r\n\r\n/**\r\n * Reconciles an index against the repositories a caller actually observed.\r\n *\r\n * Adapted from the `reconcile*` pair of the monolith, which discovers GitLab\r\n * projects by topic and creates the rows that are missing.\r\n *\r\n * Versions already recorded in the index are preserved verbatim, exactly like\r\n * `repositorio`: the observation the caller makes is \"this repository exists\",\r\n * not \"this is the product's version\", so it never overwrites what is indexed.\r\n * A newly added entry keeps the `version` the caller supplied, if any.\r\n *\r\n * @param params.index Current index. Not mutated.\r\n * @param params.repositories Repositories observed, as `{ name, repositorio }`\r\n * plus an optional `version`. linea-server builds this from GitLab; linea-core\r\n * never looks.\r\n * @returns The reconciled index plus what was added and what is missing.\r\n * @throws {InvalidArgumentError} when the arguments are malformed.\r\n */\r\nexport const reconcileProductsIndex = ({\r\n index,\r\n repositories\r\n}: {\r\n index: ProductsIndex\r\n repositories: readonly ProductsIndexEntry[]\r\n}): ProductsIndexReconciliation => {\r\n const checked = assertIndex(index)\r\n if (!isArray(repositories)) {\r\n throw new InvalidArgumentError('\"repositories\" must be an array of { name, repositorio }.')\r\n }\r\n for (const repository of repositories) {\r\n if (!isPlainObject(repository) ||\r\n typeof repository.name !== 'string' || repository.name === '' ||\r\n typeof repository.repositorio !== 'string' || repository.repositorio === '') {\r\n throw new InvalidArgumentError(\r\n 'Every entry of \"repositories\" must be a { name, repositorio } object with non-empty strings.'\r\n )\r\n }\r\n assertOptionalVersion({\r\n version: repository.version,\r\n label: `\"repositories[${repository.name}].version\"`\r\n })\r\n }\r\n\r\n const indexed = new Set(checked.productos.map((entry) => entry.name))\r\n const observed = new Set(repositories.map((repository) => repository.name))\r\n\r\n const added = repositories\r\n .filter((repository) => !indexed.has(repository.name))\r\n .map(normalizeEntry)\r\n\r\n const removed = checked.productos\r\n .filter((entry) => !observed.has(entry.name))\r\n .map(normalizeEntry)\r\n\r\n return {\r\n index: { productos: [...checked.productos, ...added].sort(byName) },\r\n added: [...added].sort(byName),\r\n removed: [...removed].sort(byName)\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type FeatureModelValue } from '../feature-model/engine.js';
|
|
2
|
+
/** The three historical shapes of `spec.features` accepted by the monolith. */
|
|
3
|
+
export type FeatureSelectionInput = string[] | Record<string, boolean> | undefined;
|
|
4
|
+
/** Minimal view of a product spec needed to read its feature selection. */
|
|
5
|
+
export interface SelectionBearingSpec {
|
|
6
|
+
features?: FeatureSelectionInput;
|
|
7
|
+
/** Deprecated field name, still present in old specs. */
|
|
8
|
+
selection?: string[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Normalises a spec's feature selection into a plain string array.
|
|
13
|
+
*
|
|
14
|
+
* Verbatim behaviour of `utils.js:normalizeFeatureSelection`, covering all three
|
|
15
|
+
* historical shapes:
|
|
16
|
+
* - `string[]` — canonical form.
|
|
17
|
+
* - `{ FeatureName: true | false }` — object map used by early client builds;
|
|
18
|
+
* only truthy keys are kept.
|
|
19
|
+
* - `spec.selection` — legacy field name, used as a fallback when `features` is
|
|
20
|
+
* absent **or an empty array**. That second condition is easy to miss and is
|
|
21
|
+
* load-bearing: a spec with `features: []` and a populated `selection` must
|
|
22
|
+
* resolve to `selection`.
|
|
23
|
+
*
|
|
24
|
+
* @param params.spec Product spec (or anything spec-shaped). May be nullish.
|
|
25
|
+
* @returns The selected feature names. Always an array, never `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
export declare const normalizeFeatureSelection: ({ spec }: {
|
|
28
|
+
spec: SelectionBearingSpec | null | undefined;
|
|
29
|
+
}) => string[];
|
|
30
|
+
/** Outcome of checking a selection against a feature model. */
|
|
31
|
+
export interface FeatureSelectionVerdict {
|
|
32
|
+
/** Whether the selection is satisfiable under the model. */
|
|
33
|
+
readonly valid: boolean;
|
|
34
|
+
/** The expanded selection when valid, `null` otherwise. */
|
|
35
|
+
readonly completed: string[] | null;
|
|
36
|
+
/** Failure reason when invalid, `null` otherwise. */
|
|
37
|
+
readonly error: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Engine discriminator when invalid: `'TOO_MANY_CHILDS'`, `'MISSING_CHILD'`,
|
|
40
|
+
* or `null` when the engine did not supply one.
|
|
41
|
+
*/
|
|
42
|
+
readonly errorType: string | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Checks a feature selection against a model **without throwing**.
|
|
46
|
+
*
|
|
47
|
+
* Same contract as `ProductService.js:getProductHealth`, which reports
|
|
48
|
+
* `{ valid, error, errorType }` so the UI can show why a product no longer fits
|
|
49
|
+
* its line. `completed` is the expansion that `completeFeatureSelection` returns,
|
|
50
|
+
* exposed so callers do not have to validate twice.
|
|
51
|
+
*
|
|
52
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
53
|
+
* @param params.features Selected feature names.
|
|
54
|
+
* @returns The verdict. Never throws for an invalid selection.
|
|
55
|
+
* @throws {InvalidArgumentError} only when the arguments themselves are wrong.
|
|
56
|
+
*/
|
|
57
|
+
export declare const validateFeatureSelection: ({ model, features }: {
|
|
58
|
+
model: FeatureModelValue;
|
|
59
|
+
features: string[];
|
|
60
|
+
}) => FeatureSelectionVerdict;
|
|
61
|
+
/**
|
|
62
|
+
* Checks a feature selection and throws when it is invalid.
|
|
63
|
+
*
|
|
64
|
+
* This is the guard `ProductService.js:#validateSpecFeatures` puts on
|
|
65
|
+
* create/update so a bad selection surfaces at the door instead of blowing up
|
|
66
|
+
* during generation. The monolith lets the engine's raw `FeatureSelectionError`
|
|
67
|
+
* escape (its `onError` maps it to a 400); linea-core wraps it in
|
|
68
|
+
* `FeatureSelectionInvalidError` so callers get the `LineaCoreError` taxonomy
|
|
69
|
+
* with a stable `.code` (ADR-018) — and, unlike the engine's class, a real
|
|
70
|
+
* `Error` with a stack.
|
|
71
|
+
*
|
|
72
|
+
* Note the monolith's guard is best-effort in a different sense: it *skips*
|
|
73
|
+
* validation when the selection is empty or the model cannot be read. That
|
|
74
|
+
* skipping is a caller policy (it depends on GitLab availability), so it stays
|
|
75
|
+
* in linea-server; here an empty selection is validated like any other.
|
|
76
|
+
*
|
|
77
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
78
|
+
* @param params.features Selected feature names.
|
|
79
|
+
* @returns The expanded selection.
|
|
80
|
+
* @throws {FeatureSelectionInvalidError} when the selection is not satisfiable.
|
|
81
|
+
* @throws {InvalidArgumentError} when the arguments themselves are wrong.
|
|
82
|
+
*/
|
|
83
|
+
export declare const assertFeatureSelection: ({ model, features }: {
|
|
84
|
+
model: FeatureModelValue;
|
|
85
|
+
features: string[];
|
|
86
|
+
}) => string[];
|
|
87
|
+
/** A named feature selection, e.g. one product's. */
|
|
88
|
+
export interface NamedSelection {
|
|
89
|
+
/** Identifier reported back in `broken`. */
|
|
90
|
+
readonly name: string;
|
|
91
|
+
/** Selected feature names. */
|
|
92
|
+
readonly features: string[];
|
|
93
|
+
}
|
|
94
|
+
/** Why a particular named selection no longer fits the model. */
|
|
95
|
+
export interface BrokenSelection {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly reason: string;
|
|
98
|
+
}
|
|
99
|
+
/** Result of checking a whole portfolio of selections against one model. */
|
|
100
|
+
export interface ModelAgainstSelectionsVerdict {
|
|
101
|
+
readonly valid: boolean;
|
|
102
|
+
readonly broken: BrokenSelection[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Answers "does this model still admit every one of these selections?".
|
|
106
|
+
*
|
|
107
|
+
* Migrated from `harvest.js:validateModelAgainstProducts` (~113-133), used to
|
|
108
|
+
* decide whether a proposed feature-model edit would break existing products.
|
|
109
|
+
*
|
|
110
|
+
* DELIBERATE SIGNATURE CHANGE (ADR-014): the monolith takes Mongo product
|
|
111
|
+
* documents and digs out `product.spec` and `product.spec.basicData.name`
|
|
112
|
+
* itself. linea-core knows nothing about persisted products, so it takes
|
|
113
|
+
* `[{ name, features }]`. Whoever reads them — from `products.json` (ADR-011) or
|
|
114
|
+
* from GitLab — is linea-server; pair this with `normalizeFeatureSelection` to
|
|
115
|
+
* go from a spec to `features`.
|
|
116
|
+
*
|
|
117
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
118
|
+
* @param params.selections The named selections to check.
|
|
119
|
+
* @returns `valid` plus one entry per broken selection. Never throws for a
|
|
120
|
+
* broken selection.
|
|
121
|
+
* @throws {InvalidArgumentError} when the arguments themselves are wrong.
|
|
122
|
+
*/
|
|
123
|
+
export declare const validateModelAgainstSelections: ({ model, selections }: {
|
|
124
|
+
model: FeatureModelValue;
|
|
125
|
+
selections: readonly NamedSelection[];
|
|
126
|
+
}) => ModelAgainstSelectionsVerdict;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature selection normalisation and validation.
|
|
3
|
+
*
|
|
4
|
+
* Migrated from:
|
|
5
|
+
* - `linea/server/src/model/services/utils.js:normalizeFeatureSelection` (~172-186)
|
|
6
|
+
* - `linea/server/src/model/services/ProductService.js:#validateSpecFeatures` (~37-58)
|
|
7
|
+
* - `linea/server/src/model/services/ProductService.js:getProductHealth` (~481-519),
|
|
8
|
+
* which is where the `{ valid, features, error, errorType }` shape comes from
|
|
9
|
+
* - `linea/server/src/agents/tools/harvest.js:validateModelAgainstProducts` (~113-133)
|
|
10
|
+
*
|
|
11
|
+
* The monolith spreads this logic across a service that also reads GitLab and a
|
|
12
|
+
* Mongo-backed agent tool. Here it is pure: the caller supplies the parsed model
|
|
13
|
+
* and the selections, and nothing reaches the network or a database.
|
|
14
|
+
*/
|
|
15
|
+
import { InvalidArgumentError, FeatureSelectionInvalidError } from '../errors.js';
|
|
16
|
+
import { completeSelection, describeSelectionFailure } from '../feature-model/engine.js';
|
|
17
|
+
import { isArray } from '../internal/guards.js';
|
|
18
|
+
const assertModel = (model) => {
|
|
19
|
+
if (model === null || typeof model !== 'object') {
|
|
20
|
+
throw new InvalidArgumentError('"model" must be a value returned by parseFeatureModel().');
|
|
21
|
+
}
|
|
22
|
+
return model;
|
|
23
|
+
};
|
|
24
|
+
const assertFeatureArray = (features) => {
|
|
25
|
+
if (!Array.isArray(features) || features.some((f) => typeof f !== 'string')) {
|
|
26
|
+
throw new InvalidArgumentError('"features" must be an array of strings.');
|
|
27
|
+
}
|
|
28
|
+
return features;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Normalises a spec's feature selection into a plain string array.
|
|
32
|
+
*
|
|
33
|
+
* Verbatim behaviour of `utils.js:normalizeFeatureSelection`, covering all three
|
|
34
|
+
* historical shapes:
|
|
35
|
+
* - `string[]` — canonical form.
|
|
36
|
+
* - `{ FeatureName: true | false }` — object map used by early client builds;
|
|
37
|
+
* only truthy keys are kept.
|
|
38
|
+
* - `spec.selection` — legacy field name, used as a fallback when `features` is
|
|
39
|
+
* absent **or an empty array**. That second condition is easy to miss and is
|
|
40
|
+
* load-bearing: a spec with `features: []` and a populated `selection` must
|
|
41
|
+
* resolve to `selection`.
|
|
42
|
+
*
|
|
43
|
+
* @param params.spec Product spec (or anything spec-shaped). May be nullish.
|
|
44
|
+
* @returns The selected feature names. Always an array, never `undefined`.
|
|
45
|
+
*/
|
|
46
|
+
export const normalizeFeatureSelection = ({ spec }) => {
|
|
47
|
+
let features = spec?.features;
|
|
48
|
+
// Object-map shape: { FeatureName: true/false }
|
|
49
|
+
if (features !== null && typeof features === 'object' && !Array.isArray(features)) {
|
|
50
|
+
const map = features;
|
|
51
|
+
features = Object.keys(map).filter((key) => map[key]);
|
|
52
|
+
}
|
|
53
|
+
// Fall back to spec.selection when features is absent OR empty.
|
|
54
|
+
if (!Array.isArray(features) || features.length === 0) {
|
|
55
|
+
features = spec?.selection ?? [];
|
|
56
|
+
}
|
|
57
|
+
return Array.isArray(features) ? features : [];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Checks a feature selection against a model **without throwing**.
|
|
61
|
+
*
|
|
62
|
+
* Same contract as `ProductService.js:getProductHealth`, which reports
|
|
63
|
+
* `{ valid, error, errorType }` so the UI can show why a product no longer fits
|
|
64
|
+
* its line. `completed` is the expansion that `completeFeatureSelection` returns,
|
|
65
|
+
* exposed so callers do not have to validate twice.
|
|
66
|
+
*
|
|
67
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
68
|
+
* @param params.features Selected feature names.
|
|
69
|
+
* @returns The verdict. Never throws for an invalid selection.
|
|
70
|
+
* @throws {InvalidArgumentError} only when the arguments themselves are wrong.
|
|
71
|
+
*/
|
|
72
|
+
export const validateFeatureSelection = ({ model, features }) => {
|
|
73
|
+
const checked = assertModel(model);
|
|
74
|
+
const selection = assertFeatureArray(features);
|
|
75
|
+
try {
|
|
76
|
+
const completed = completeSelection(checked, selection);
|
|
77
|
+
return { valid: true, completed, error: null, errorType: null };
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const { message, errorType } = describeSelectionFailure(error);
|
|
81
|
+
return { valid: false, completed: null, error: message, errorType };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Checks a feature selection and throws when it is invalid.
|
|
86
|
+
*
|
|
87
|
+
* This is the guard `ProductService.js:#validateSpecFeatures` puts on
|
|
88
|
+
* create/update so a bad selection surfaces at the door instead of blowing up
|
|
89
|
+
* during generation. The monolith lets the engine's raw `FeatureSelectionError`
|
|
90
|
+
* escape (its `onError` maps it to a 400); linea-core wraps it in
|
|
91
|
+
* `FeatureSelectionInvalidError` so callers get the `LineaCoreError` taxonomy
|
|
92
|
+
* with a stable `.code` (ADR-018) — and, unlike the engine's class, a real
|
|
93
|
+
* `Error` with a stack.
|
|
94
|
+
*
|
|
95
|
+
* Note the monolith's guard is best-effort in a different sense: it *skips*
|
|
96
|
+
* validation when the selection is empty or the model cannot be read. That
|
|
97
|
+
* skipping is a caller policy (it depends on GitLab availability), so it stays
|
|
98
|
+
* in linea-server; here an empty selection is validated like any other.
|
|
99
|
+
*
|
|
100
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
101
|
+
* @param params.features Selected feature names.
|
|
102
|
+
* @returns The expanded selection.
|
|
103
|
+
* @throws {FeatureSelectionInvalidError} when the selection is not satisfiable.
|
|
104
|
+
* @throws {InvalidArgumentError} when the arguments themselves are wrong.
|
|
105
|
+
*/
|
|
106
|
+
export const assertFeatureSelection = ({ model, features }) => {
|
|
107
|
+
const verdict = validateFeatureSelection({ model, features });
|
|
108
|
+
if (!verdict.valid || verdict.completed === null) {
|
|
109
|
+
throw new FeatureSelectionInvalidError(verdict.error ?? 'The feature selection is not valid for this feature model.');
|
|
110
|
+
}
|
|
111
|
+
return verdict.completed;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Answers "does this model still admit every one of these selections?".
|
|
115
|
+
*
|
|
116
|
+
* Migrated from `harvest.js:validateModelAgainstProducts` (~113-133), used to
|
|
117
|
+
* decide whether a proposed feature-model edit would break existing products.
|
|
118
|
+
*
|
|
119
|
+
* DELIBERATE SIGNATURE CHANGE (ADR-014): the monolith takes Mongo product
|
|
120
|
+
* documents and digs out `product.spec` and `product.spec.basicData.name`
|
|
121
|
+
* itself. linea-core knows nothing about persisted products, so it takes
|
|
122
|
+
* `[{ name, features }]`. Whoever reads them — from `products.json` (ADR-011) or
|
|
123
|
+
* from GitLab — is linea-server; pair this with `normalizeFeatureSelection` to
|
|
124
|
+
* go from a spec to `features`.
|
|
125
|
+
*
|
|
126
|
+
* @param params.model A model returned by `parseFeatureModel`.
|
|
127
|
+
* @param params.selections The named selections to check.
|
|
128
|
+
* @returns `valid` plus one entry per broken selection. Never throws for a
|
|
129
|
+
* broken selection.
|
|
130
|
+
* @throws {InvalidArgumentError} when the arguments themselves are wrong.
|
|
131
|
+
*/
|
|
132
|
+
export const validateModelAgainstSelections = ({ model, selections }) => {
|
|
133
|
+
const checked = assertModel(model);
|
|
134
|
+
if (!isArray(selections)) {
|
|
135
|
+
throw new InvalidArgumentError('"selections" must be an array of { name, features }.');
|
|
136
|
+
}
|
|
137
|
+
const broken = [];
|
|
138
|
+
for (const selection of selections) {
|
|
139
|
+
if (selection === null || typeof selection !== 'object') {
|
|
140
|
+
throw new InvalidArgumentError('Every entry of "selections" must be an object.');
|
|
141
|
+
}
|
|
142
|
+
if (typeof selection.name !== 'string' || selection.name === '') {
|
|
143
|
+
throw new InvalidArgumentError('Every entry of "selections" needs a non-empty "name".');
|
|
144
|
+
}
|
|
145
|
+
const verdict = validateFeatureSelection({ model: checked, features: selection.features });
|
|
146
|
+
if (!verdict.valid) {
|
|
147
|
+
broken.push({ name: selection.name, reason: verdict.error ?? 'unknown reason' });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { valid: broken.length === 0, broken };
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/selection/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AACjF,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAa/C,MAAM,WAAW,GAAG,CAAC,KAAc,EAAqB,EAAE;IACxD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,oBAAoB,CAAC,0DAA0D,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,KAA0B,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,CAAC,QAAiB,EAAY,EAAE;IACzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,oBAAoB,CAAC,yCAAyC,CAAC,CAAA;IAC3E,CAAC;IACD,OAAO,QAAoB,CAAA;AAC7B,CAAC,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,IAAI,EAGL,EAAY,EAAE;IACb,IAAI,QAAQ,GAAY,IAAI,EAAE,QAAQ,CAAA;IAEtC,gDAAgD;IAChD,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,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AAC,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,gBAAgB,EAAE,CAAC,CAAA;QAClF,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["/**\r\n * Feature selection normalisation and validation.\r\n *\r\n * Migrated from:\r\n * - `linea/server/src/model/services/utils.js:normalizeFeatureSelection` (~172-186)\r\n * - `linea/server/src/model/services/ProductService.js:#validateSpecFeatures` (~37-58)\r\n * - `linea/server/src/model/services/ProductService.js:getProductHealth` (~481-519),\r\n * which is where the `{ valid, features, error, errorType }` shape comes from\r\n * - `linea/server/src/agents/tools/harvest.js:validateModelAgainstProducts` (~113-133)\r\n *\r\n * The monolith spreads this logic across a service that also reads GitLab and a\r\n * Mongo-backed agent tool. Here it is pure: the caller supplies the parsed model\r\n * and the selections, and nothing reaches the network or a database.\r\n */\r\nimport { InvalidArgumentError, FeatureSelectionInvalidError } from '../errors.js'\r\nimport {\r\n completeSelection,\r\n describeSelectionFailure,\r\n type FeatureModelValue\r\n} from '../feature-model/engine.js'\r\nimport { isArray } from '../internal/guards.js'\r\n\r\n/** The three historical shapes of `spec.features` accepted by the monolith. */\r\nexport type FeatureSelectionInput = string[] | Record<string, boolean> | undefined\r\n\r\n/** Minimal view of a product spec needed to read its feature selection. */\r\nexport interface SelectionBearingSpec {\r\n features?: FeatureSelectionInput\r\n /** Deprecated field name, still present in old specs. */\r\n selection?: string[]\r\n [key: string]: unknown\r\n}\r\n\r\nconst assertModel = (model: unknown): FeatureModelValue => {\r\n if (model === null || typeof model !== 'object') {\r\n throw new InvalidArgumentError('\"model\" must be a value returned by parseFeatureModel().')\r\n }\r\n return model as FeatureModelValue\r\n}\r\n\r\nconst assertFeatureArray = (features: unknown): string[] => {\r\n if (!Array.isArray(features) || features.some((f) => typeof f !== 'string')) {\r\n throw new InvalidArgumentError('\"features\" must be an array of strings.')\r\n }\r\n return features as string[]\r\n}\r\n\r\n/**\r\n * Normalises a spec's feature selection into a plain string array.\r\n *\r\n * Verbatim behaviour of `utils.js:normalizeFeatureSelection`, covering all three\r\n * historical shapes:\r\n * - `string[]` — canonical form.\r\n * - `{ FeatureName: true | false }` — object map used by early client builds;\r\n * only truthy keys are kept.\r\n * - `spec.selection` — legacy field name, used as a fallback when `features` is\r\n * absent **or an empty array**. That second condition is easy to miss and is\r\n * load-bearing: a spec with `features: []` and a populated `selection` must\r\n * resolve to `selection`.\r\n *\r\n * @param params.spec Product spec (or anything spec-shaped). May be nullish.\r\n * @returns The selected feature names. Always an array, never `undefined`.\r\n */\r\nexport const normalizeFeatureSelection = ({\r\n spec\r\n}: {\r\n spec: SelectionBearingSpec | null | undefined\r\n}): string[] => {\r\n let features: unknown = spec?.features\r\n\r\n // Object-map shape: { FeatureName: true/false }\r\n if (features !== null && typeof features === 'object' && !Array.isArray(features)) {\r\n const map = features as Record<string, boolean>\r\n features = Object.keys(map).filter((key) => map[key])\r\n }\r\n\r\n // Fall back to spec.selection when features is absent OR empty.\r\n if (!Array.isArray(features) || features.length === 0) {\r\n features = spec?.selection ?? []\r\n }\r\n\r\n return Array.isArray(features) ? (features as string[]) : []\r\n}\r\n\r\n/** Outcome of checking a selection against a feature model. */\r\nexport interface FeatureSelectionVerdict {\r\n /** Whether the selection is satisfiable under the model. */\r\n readonly valid: boolean\r\n /** The expanded selection when valid, `null` otherwise. */\r\n readonly completed: string[] | null\r\n /** Failure reason when invalid, `null` otherwise. */\r\n readonly error: string | null\r\n /**\r\n * Engine discriminator when invalid: `'TOO_MANY_CHILDS'`, `'MISSING_CHILD'`,\r\n * or `null` when the engine did not supply one.\r\n */\r\n readonly errorType: string | null\r\n}\r\n\r\n/**\r\n * Checks a feature selection against a model **without throwing**.\r\n *\r\n * Same contract as `ProductService.js:getProductHealth`, which reports\r\n * `{ valid, error, errorType }` so the UI can show why a product no longer fits\r\n * its line. `completed` is the expansion that `completeFeatureSelection` returns,\r\n * exposed so callers do not have to validate twice.\r\n *\r\n * @param params.model A model returned by `parseFeatureModel`.\r\n * @param params.features Selected feature names.\r\n * @returns The verdict. Never throws for an invalid selection.\r\n * @throws {InvalidArgumentError} only when the arguments themselves are wrong.\r\n */\r\nexport const validateFeatureSelection = ({\r\n model,\r\n features\r\n}: {\r\n model: FeatureModelValue\r\n features: string[]\r\n}): FeatureSelectionVerdict => {\r\n const checked = assertModel(model)\r\n const selection = assertFeatureArray(features)\r\n try {\r\n const completed = completeSelection(checked, selection)\r\n return { valid: true, completed, error: null, errorType: null }\r\n } catch (error) {\r\n const { message, errorType } = describeSelectionFailure(error)\r\n return { valid: false, completed: null, error: message, errorType }\r\n }\r\n}\r\n\r\n/**\r\n * Checks a feature selection and throws when it is invalid.\r\n *\r\n * This is the guard `ProductService.js:#validateSpecFeatures` puts on\r\n * create/update so a bad selection surfaces at the door instead of blowing up\r\n * during generation. The monolith lets the engine's raw `FeatureSelectionError`\r\n * escape (its `onError` maps it to a 400); linea-core wraps it in\r\n * `FeatureSelectionInvalidError` so callers get the `LineaCoreError` taxonomy\r\n * with a stable `.code` (ADR-018) — and, unlike the engine's class, a real\r\n * `Error` with a stack.\r\n *\r\n * Note the monolith's guard is best-effort in a different sense: it *skips*\r\n * validation when the selection is empty or the model cannot be read. That\r\n * skipping is a caller policy (it depends on GitLab availability), so it stays\r\n * in linea-server; here an empty selection is validated like any other.\r\n *\r\n * @param params.model A model returned by `parseFeatureModel`.\r\n * @param params.features Selected feature names.\r\n * @returns The expanded selection.\r\n * @throws {FeatureSelectionInvalidError} when the selection is not satisfiable.\r\n * @throws {InvalidArgumentError} when the arguments themselves are wrong.\r\n */\r\nexport const assertFeatureSelection = ({\r\n model,\r\n features\r\n}: {\r\n model: FeatureModelValue\r\n features: string[]\r\n}): string[] => {\r\n const verdict = validateFeatureSelection({ model, features })\r\n if (!verdict.valid || verdict.completed === null) {\r\n throw new FeatureSelectionInvalidError(\r\n verdict.error ?? 'The feature selection is not valid for this feature model.'\r\n )\r\n }\r\n return verdict.completed\r\n}\r\n\r\n/** A named feature selection, e.g. one product's. */\r\nexport interface NamedSelection {\r\n /** Identifier reported back in `broken`. */\r\n readonly name: string\r\n /** Selected feature names. */\r\n readonly features: string[]\r\n}\r\n\r\n/** Why a particular named selection no longer fits the model. */\r\nexport interface BrokenSelection {\r\n readonly name: string\r\n readonly reason: string\r\n}\r\n\r\n/** Result of checking a whole portfolio of selections against one model. */\r\nexport interface ModelAgainstSelectionsVerdict {\r\n readonly valid: boolean\r\n readonly broken: BrokenSelection[]\r\n}\r\n\r\n/**\r\n * Answers \"does this model still admit every one of these selections?\".\r\n *\r\n * Migrated from `harvest.js:validateModelAgainstProducts` (~113-133), used to\r\n * decide whether a proposed feature-model edit would break existing products.\r\n *\r\n * DELIBERATE SIGNATURE CHANGE (ADR-014): the monolith takes Mongo product\r\n * documents and digs out `product.spec` and `product.spec.basicData.name`\r\n * itself. linea-core knows nothing about persisted products, so it takes\r\n * `[{ name, features }]`. Whoever reads them — from `products.json` (ADR-011) or\r\n * from GitLab — is linea-server; pair this with `normalizeFeatureSelection` to\r\n * go from a spec to `features`.\r\n *\r\n * @param params.model A model returned by `parseFeatureModel`.\r\n * @param params.selections The named selections to check.\r\n * @returns `valid` plus one entry per broken selection. Never throws for a\r\n * broken selection.\r\n * @throws {InvalidArgumentError} when the arguments themselves are wrong.\r\n */\r\nexport const validateModelAgainstSelections = ({\r\n model,\r\n selections\r\n}: {\r\n model: FeatureModelValue\r\n selections: readonly NamedSelection[]\r\n}): ModelAgainstSelectionsVerdict => {\r\n const checked = assertModel(model)\r\n if (!isArray(selections)) {\r\n throw new InvalidArgumentError('\"selections\" must be an array of { name, features }.')\r\n }\r\n\r\n const broken: BrokenSelection[] = []\r\n for (const selection of selections) {\r\n if (selection === null || typeof selection !== 'object') {\r\n throw new InvalidArgumentError('Every entry of \"selections\" must be an object.')\r\n }\r\n if (typeof selection.name !== 'string' || selection.name === '') {\r\n throw new InvalidArgumentError('Every entry of \"selections\" needs a non-empty \"name\".')\r\n }\r\n const verdict = validateFeatureSelection({ model: checked, features: selection.features })\r\n if (!verdict.valid) {\r\n broken.push({ name: selection.name, reason: verdict.error ?? 'unknown reason' })\r\n }\r\n }\r\n\r\n return { valid: broken.length === 0, broken }\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lbdudc/linea-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Motor autocontenido de Líneas de Producto Software (SPL): feature models, validación de specs y derivación de productos. Funciona 100% offline.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"author": "Laboratorio de Bases de Datos (LBD) - Universidade da Coruña",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20.11"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://gitlab.lbd.udc.es/linea/linea-core.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://gitlab.lbd.udc.es/linea/linea-core",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"spl",
|
|
31
|
+
"software-product-line",
|
|
32
|
+
"feature-model",
|
|
33
|
+
"uvl",
|
|
34
|
+
"derivation",
|
|
35
|
+
"linea",
|
|
36
|
+
"splalm"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc && node scripts/copy-assets.mjs",
|
|
40
|
+
"prepare": "npm run build",
|
|
41
|
+
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"lint:fix": "eslint . --fix",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"test:coverage": "vitest run --coverage",
|
|
47
|
+
"check:consumer": "npm run build && node scripts/check-consumer.mjs",
|
|
48
|
+
"check:install": "node scripts/check-install.mjs"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@lbdudc/flamapy.js": "^1.1.0",
|
|
52
|
+
"extract-zip": "^2.0.1",
|
|
53
|
+
"prettier": "^3.9.6",
|
|
54
|
+
"pyodide": "0.26.2",
|
|
55
|
+
"spl-js-engine": "git+https://github.com/lbdudc/spl-js-engine.git#cd67af2fd2f4019e99cbeb5ac4a8622f5549e68e"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@eslint/js": "^9.17.0",
|
|
59
|
+
"@types/node": "^20.17.0",
|
|
60
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
61
|
+
"eslint": "^9.17.0",
|
|
62
|
+
"globals": "^15.14.0",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"typescript-eslint": "^8.18.0",
|
|
65
|
+
"vitest": "^2.1.8"
|
|
66
|
+
}
|
|
67
|
+
}
|