@lbdudc/linea-core 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +230 -358
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/extra.js +54 -54
- package/dist/line/templates/core/transformation.js +208 -196
- package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
- package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
- package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +82 -67
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,i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;QAC3F,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE;QACtF;YACE,IAAI,EAAE,gCAAgC;YACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;YAC1C,QAAQ,EAAE,MAAM;SACjB;QACD,GAAG,gBAAgB,EAAE;KACtB,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,GAAG,EACH,IAAI,EACJ,MAAM,GAAG,EAAE,EACX,gBAAgB,GAAG,KAAK,EACY,EAAsC,EAAE;IAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,oBAAoB,CAAC,iCAAiC,CAAC,CAAA;IACnE,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;IAExC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,2EAA2E;QAC3E,kCAAkC;QAClC,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["/**\r\n * The initial file tree of a brand new line.\r\n *\r\n * Migrated from `linea/server/src/model/services/LineService.js:createLine`\r\n * (~43-68), keeping ONLY the file construction. Everything around it belongs to\r\n * linea-server (ADR-003): creating the GitLab group and project, the\r\n * `createFile` calls, the Mongo transaction and the rollback.\r\n *\r\n * The API is split into a PURE half and an IMPURE half on purpose:\r\n *\r\n * - `buildLineScaffold` computes the files and touches nothing. linea-server\r\n * feeds the result straight to `gitlabSession.createFile`, in order, for\r\n * exact parity with `createLine` — without linea-core ever reaching the\r\n * network or the disk (ADR-002).\r\n * - `writeLineScaffold` materialises the same description on disk, which is\r\n * what linea-cli needs in local mode (ADR-004).\r\n *\r\n * They must stay separate: collapsing them would force the GitLab path to write\r\n * a temporary tree it does not want.\r\n */\r\nimport path from 'node:path'\r\nimport { FEATURE_MODEL_TYPES, isFeatureModelType, NAME_PATTERN, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\nimport { modelToXml } from '../feature-model/engine.js'\r\nimport { parseFeatureModel } from '../feature-model/parse.js'\r\nimport { emptyFeatureModelUvl } from '../feature-model/text.js'\r\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\r\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type FileSpec } from './platform-files.js'\r\n\r\n/**\r\n * Engine configuration seeded into every new line (`src/platform/config.json`).\r\n *\r\n * Verbatim from `LineService.js:48-56`, which is what actually runs when a line\r\n * is created.\r\n *\r\n * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture\r\n * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER\r\n * list — it also declares `dockerfile` and `sh` extensions. The two have drifted\r\n * apart. `LineService.js` is the source of truth here because it is the code\r\n * path that creates real lines; the fixture only feeds derivation tests. A line\r\n * seeded by linea-core therefore will not process `Dockerfile` or `.sh`\r\n * annotations until someone edits its `config.json`, exactly as today.\r\n */\r\nexport const DEFAULT_PLATFORM_CONFIG = {\r\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\r\n delimiters: [\r\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\r\n {\r\n extension: [\r\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\r\n 'gitignore', 'properties', 'sql', 'env', 'production'\r\n ],\r\n start: '/*%',\r\n end: '%*/'\r\n },\r\n { extension: ['py'], start: '#%', end: '%#' },\r\n { extension: ['json'], start: '###<', end: '>###' }\r\n ]\r\n} as const\r\n\r\n/** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */\r\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\r\n\r\n/** What a line scaffold needs to know. */\r\nexport interface LineScaffoldInput {\r\n /** Line name; becomes the root feature of the seed model. */\r\n name: string\r\n /** Metamodels chosen for the line, e.g. `['UML']`. Unknown names are ignored. */\r\n models?: readonly string[]\r\n /** Notation of the seed feature model. Defaults to `'UVL'`. */\r\n featureModelType?: FeatureModelType\r\n}\r\n\r\n/**\r\n * Computes the files of a brand new line. PURE: reads no working directory and\r\n * writes nothing.\r\n *\r\n * The returned order is the order `createLine` creates them in, and callers\r\n * should preserve it: model, config, code/.gitignore, extra.js,\r\n * transformation.js, then the pipeline files.\r\n *\r\n * Note the template files themselves ARE read from the package's own asset\r\n * directory — that is reading linea-core's own installed data, not the caller's\r\n * working directory, and is what makes the function usable with no filesystem\r\n * target at all.\r\n *\r\n * @param params.name Line name.\r\n * @param params.models Metamodels chosen for the line.\r\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\r\n * @returns The files to create, in order.\r\n * @throws {InvalidArgumentError} when `name` is empty or has characters outside\r\n * `NAME_PATTERN`, or when `featureModelType` is unknown.\r\n */\r\nexport const buildLineScaffold = ({\r\n name,\r\n models = [],\r\n featureModelType = 'UVL'\r\n}: LineScaffoldInput): FileSpec[] => {\r\n if (typeof name !== 'string' || name === '') {\r\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\r\n }\r\n if (!NAME_PATTERN.test(name)) {\r\n throw new InvalidArgumentError(\r\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\r\n )\r\n }\r\n if (!isFeatureModelType(featureModelType)) {\r\n throw new InvalidArgumentError(\r\n `Unknown feature model type ${JSON.stringify(featureModelType)}. Use one of ${FEATURE_MODEL_TYPES.join(', ')}.`\r\n )\r\n }\r\n\r\n const uvlContent = emptyFeatureModelUvl({ name })\r\n const modelFile: FileSpec = featureModelType === 'XML'\r\n ? {\r\n path: 'src/platform/model.xml',\r\n content: modelToXml(parseFeatureModel({ content: uvlContent, type: 'UVL' })),\r\n encoding: 'text'\r\n }\r\n : { path: 'src/platform/model.uvl', content: uvlContent, encoding: 'text' }\r\n\r\n return [\r\n modelFile,\r\n {\r\n path: 'src/platform/config.json',\r\n // JSON.stringify(config, null, 2) — same two-space indentation as the\r\n // monolith, and no trailing newline, so the committed file matches.\r\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\r\n encoding: 'text'\r\n },\r\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\r\n { path: 'src/platform/extra.js', content: buildExtraJs({ models }), encoding: 'text' },\r\n {\r\n path: 'src/platform/transformation.js',\r\n content: buildTransformationJs({ models }),\r\n encoding: 'text'\r\n },\r\n ...getPipelineFiles()\r\n ]\r\n}\r\n\r\n/**\r\n * Materialises a line scaffold in a directory.\r\n *\r\n * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.\r\n * Creates `dir` and every parent directory the files need.\r\n *\r\n * @param params.dir Target directory (the line's working directory root).\r\n * @param params.name Line name.\r\n * @param params.models Metamodels chosen for the line.\r\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\r\n * @returns The resolved directory and the files written.\r\n * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or\r\n * when `dir` is not a non-empty path.\r\n */\r\nexport const writeLineScaffold = ({\r\n dir,\r\n name,\r\n models = [],\r\n featureModelType = 'UVL'\r\n}: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\r\n if (typeof dir !== 'string' || dir.trim() === '') {\r\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\r\n }\r\n const files = buildLineScaffold({ name, models, featureModelType })\r\n const root = ensureDir({ dirPath: dir })\r\n\r\n for (const file of files) {\r\n // FileSpec paths are POSIX and repository-relative; join with the platform\r\n // separator to land them on disk.\r\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\r\n }\r\n\r\n return { dir: root, files }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AACtH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAEvE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAA8B,MAAM,qBAAqB,CAAA;AAEvH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,MAAM,EAAE,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;IACxG,UAAU,EAAE;QACV,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE;QAClE;YACE,SAAS,EAAE;gBACT,KAAK,EAAE,I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,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA","sourcesContent":["import path from 'node:path'\nimport { NAME_PATTERN } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\nimport { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, withFeatureMetamodel } from '../modules/configuration/constants.js'\nimport { bangoName, rootFeatureName } from '../modules/configuration/names.js'\nimport { serializeSplManifest } from '../modules/packages/manifests.js'\nimport type { SplKind, SplManifest } from '../modules/types.js'\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type CiHost, type FileSpec } from './platform-files.js'\n\nexport const DEFAULT_PLATFORM_CONFIG = {\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\n delimiters: [\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\n {\n extension: [\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\n 'gitignore', 'properties', 'sql', 'env', 'production'\n ],\n start: '/*%',\n end: '%*/'\n },\n { extension: ['py'], start: '#%', end: '%#' },\n { extension: ['json'], start: '###<', end: '>###' }\n ]\n} as const\n\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\n\n/** The first feature model of an SPL, as a model of the feature metamodel: just the root, named after the SPL. */\nexport const emptyFeatureModel = ({ name }: { name: string }): string => {\n const root = bangoName({ name: rootFeatureName({ name }) })\n return `featuremodel ${root}\\nfeature ${root}\\n`\n}\n\n/** Where an SPL keeps its feature model. */\nexport const FEATURE_MODEL_PATH = `models/${FEATURE_MODEL_GRAMMAR}.${FEATURE_MODEL_GRAMMAR}`\n\nexport interface LineScaffoldInput {\n name: string\n /** `plain` (the default): the feature metamodel only. `project`: also the `metamodels` the user chose. `modular`: made of `modules`. */\n kind?: SplKind\n /** The metamodels of a `project` (location -> range), besides the feature metamodel. */\n metamodels?: Record<string, string>\n /** The modules of a `modular` SPL (location -> range). */\n modules?: Record<string, string>\n /** Where the feature metamodel is, when not in the default registry (a workspace on disk has it as `file:metamodels/featuremodel`). */\n featureMetamodel?: string\n /** The git host the SPL will live on: which CI file the generated products get (default `gitlab`). */\n ci?: CiHost\n}\n\n/** The `spl.json` of a new SPL. */\nexport const buildSplManifest = ({ name, kind = 'plain', metamodels = {}, modules = {}, featureMetamodel }: LineScaffoldInput): SplManifest =>\n withFeatureMetamodel({\n spl: { name, version: '1.0.0', kind, metamodels: kind === 'project' ? metamodels : {}, modules: kind === 'modular' ? modules : {} },\n ...(featureMetamodel === undefined ? {} : { location: featureMetamodel })\n })\n\n/**\n * The files of a new SPL: its manifest, its feature model (a model of the feature metamodel), and, for a plain or project SPL, the platform\n * its products are derived with (a modular one gets it from its modules).\n */\nexport const buildLineScaffold = ({ name, kind = 'plain', metamodels, modules, featureMetamodel, ci = 'gitlab' }: LineScaffoldInput): FileSpec[] => {\n if (typeof name !== 'string' || name === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n if (!NAME_PATTERN.test(name)) {\n throw new InvalidArgumentError(\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\n )\n }\n\n const own: FileSpec[] = [\n { path: 'spl.json', content: serializeSplManifest({ spl: buildSplManifest({ name, kind, ...(metamodels === undefined ? {} : { metamodels }), ...(modules === undefined ? {} : { modules }), ...(featureMetamodel === undefined ? {} : { featureMetamodel }) }) }), encoding: 'text' },\n { path: FEATURE_MODEL_PATH, content: emptyFeatureModel({ name }), encoding: 'text' }\n ]\n if (kind === 'modular') return own\n\n return [\n ...own,\n {\n path: 'src/platform/config.json',\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\n encoding: 'text'\n },\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\n { path: 'src/platform/extra.js', content: buildExtraJs(), encoding: 'text' },\n {\n path: 'src/platform/transformation.js',\n content: buildTransformationJs(),\n encoding: 'text'\n },\n ...getPipelineFiles({ ci })\n ]\n}\n\nexport const writeLineScaffold = ({ dir, ...rest }: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const files = buildLineScaffold(rest)\n const root = ensureDir({ dirPath: dir })\n\n for (const file of files) {\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\n }\n\n return { dir: root, files }\n}\n\nexport { FEATURE_METAMODEL }\n"]}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
function pluralize(name) {
|
|
2
|
-
return name + "s";
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function capitalizeOneWord(word) {
|
|
6
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function camelToSnakeCase(str) {
|
|
10
|
-
return str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => '_' + letter.toLowerCase());
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function normalizeKebabCase(str) {
|
|
14
|
-
return str
|
|
15
|
-
.replace(/[\s-]+/g, '-')
|
|
16
|
-
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
17
|
-
.toLowerCase();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function normalizeSnakeCase(str) {
|
|
21
|
-
return str
|
|
22
|
-
.replace(/[\s-]+/g, '_')
|
|
23
|
-
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
24
|
-
.toLowerCase();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function normalizeUrl(str) {
|
|
28
|
-
return str
|
|
29
|
-
.normalize("NFKD")
|
|
30
|
-
.replace(/[\u0300-\u036F]/g, "")
|
|
31
|
-
.trim()
|
|
32
|
-
.replace(/[\s]/g, "-")
|
|
33
|
-
.toLowerCase();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getDatabaseConfigFromSpec(data, name, defaultValue) {
|
|
37
|
-
var dataBase = data.basicData.database;
|
|
38
|
-
if (dataBase) {
|
|
39
|
-
if (dataBase[name] && dataBase[name] != "") {
|
|
40
|
-
return dataBase[name];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return defaultValue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getExtraConfigFromSpec(data, name, defaultValue) {
|
|
47
|
-
var extra = data.basicData.extra;
|
|
48
|
-
if (extra) {
|
|
49
|
-
if (extra[name] && extra[name] != "") {
|
|
50
|
-
return extra[name];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return defaultValue;
|
|
54
|
-
}
|
|
1
|
+
function pluralize(name) {
|
|
2
|
+
return name + "s";
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function capitalizeOneWord(word) {
|
|
6
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function camelToSnakeCase(str) {
|
|
10
|
+
return str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => '_' + letter.toLowerCase());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function normalizeKebabCase(str) {
|
|
14
|
+
return str
|
|
15
|
+
.replace(/[\s-]+/g, '-')
|
|
16
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
17
|
+
.toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function normalizeSnakeCase(str) {
|
|
21
|
+
return str
|
|
22
|
+
.replace(/[\s-]+/g, '_')
|
|
23
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
24
|
+
.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeUrl(str) {
|
|
28
|
+
return str
|
|
29
|
+
.normalize("NFKD")
|
|
30
|
+
.replace(/[\u0300-\u036F]/g, "")
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/[\s]/g, "-")
|
|
33
|
+
.toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getDatabaseConfigFromSpec(data, name, defaultValue) {
|
|
37
|
+
var dataBase = data.basicData.database;
|
|
38
|
+
if (dataBase) {
|
|
39
|
+
if (dataBase[name] && dataBase[name] != "") {
|
|
40
|
+
return dataBase[name];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return defaultValue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getExtraConfigFromSpec(data, name, defaultValue) {
|
|
47
|
+
var extra = data.basicData.extra;
|
|
48
|
+
if (extra) {
|
|
49
|
+
if (extra[name] && extra[name] != "") {
|
|
50
|
+
return extra[name];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return defaultValue;
|
|
54
|
+
}
|
|
@@ -1,196 +1,208 @@
|
|
|
1
|
-
module.exports = modelTransformation;
|
|
2
|
-
|
|
3
|
-
var _metamodelProcessors = [];
|
|
4
|
-
|
|
5
|
-
function registerMetamodelProcessor(fn) {
|
|
6
|
-
_metamodelProcessors.push(fn);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function modelTransformation(input) {
|
|
10
|
-
if (input.data && input.data.basicData) return input;
|
|
11
|
-
|
|
12
|
-
let ret = {};
|
|
13
|
-
ret.features = input.features;
|
|
14
|
-
ret.data = {};
|
|
15
|
-
ret.data.basicData =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ret.data.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (features.indexOf("GUI_M_Top") !== -1
|
|
83
|
-
ret.design = "
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
ret[
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
1
|
+
module.exports = modelTransformation;
|
|
2
|
+
|
|
3
|
+
var _metamodelProcessors = [];
|
|
4
|
+
|
|
5
|
+
function registerMetamodelProcessor(fn) {
|
|
6
|
+
_metamodelProcessors.push(fn);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function modelTransformation(input) {
|
|
10
|
+
if (input.data && input.data.basicData) return input;
|
|
11
|
+
|
|
12
|
+
let ret = {};
|
|
13
|
+
ret.features = input.features;
|
|
14
|
+
ret.data = Object.assign({}, modelData(input));
|
|
15
|
+
ret.data.basicData = ret.data.basicData
|
|
16
|
+
? withVersion(ret.data.basicData, input.basicData)
|
|
17
|
+
: basicData(input.basicData);
|
|
18
|
+
|
|
19
|
+
_metamodelProcessors.forEach(function(processor) {
|
|
20
|
+
processor(ret, input);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
ret.data.gui = Object.assign(gui(ret.features, ret.data.basicData.name), ret.data.gui);
|
|
24
|
+
ret.data.menus = Array.isArray(ret.data.menus) && ret.data.menus.length ? ret.data.menus : menus(ret);
|
|
25
|
+
ret.data.statics = ret.data.statics !== undefined ? ret.data.statics : statics(input.statics);
|
|
26
|
+
return ret;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function modelData(input) {
|
|
30
|
+
return input.models && input.models.data ? input.models.data : {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function withVersion(fromModels, given) {
|
|
34
|
+
const ret = Object.assign({}, fromModels);
|
|
35
|
+
if (ret.version === undefined && given && given.version !== undefined) ret.version = given.version;
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function normalize(str, upper) {
|
|
40
|
+
return str
|
|
41
|
+
.normalize("NFKD")
|
|
42
|
+
.replace(/[\u0300-\u036F]/g, "")
|
|
43
|
+
.replace(/[-_]+/g, " ")
|
|
44
|
+
.replace(/[^\w\s]/gi, "")
|
|
45
|
+
.replace(/\s(.)/g, function ($1) {
|
|
46
|
+
return $1.toUpperCase();
|
|
47
|
+
})
|
|
48
|
+
.replace(/\s/g, "")
|
|
49
|
+
.replace(/^(.)/, function ($1) {
|
|
50
|
+
return upper ? $1.toUpperCase() : $1.toLowerCase();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function basicData(input) {
|
|
55
|
+
return {
|
|
56
|
+
index: {
|
|
57
|
+
component: "STATIC",
|
|
58
|
+
view: "welcome",
|
|
59
|
+
},
|
|
60
|
+
languages: input.languages || [],
|
|
61
|
+
name: input.name,
|
|
62
|
+
packageInfo: {
|
|
63
|
+
artifact: normalize(input.name).toLowerCase(),
|
|
64
|
+
group: input.packageGroup || "com.example",
|
|
65
|
+
},
|
|
66
|
+
database: input.database,
|
|
67
|
+
extra: input.extra,
|
|
68
|
+
SRID: input.SRID,
|
|
69
|
+
version: input.version,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function gui(features, name) {
|
|
74
|
+
const ret = {
|
|
75
|
+
settings: {
|
|
76
|
+
font: { family: "Arial", size: "14px" },
|
|
77
|
+
colorset: ["#fff", "#eee", "#777", "#555", "#577492", "#333", "#222"],
|
|
78
|
+
header: { type: "Text", text: name },
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (features.indexOf("GUI_M_Top") !== -1) {
|
|
83
|
+
ret.design = "1";
|
|
84
|
+
} else if (features.indexOf("GUI_M_Left") !== -1) {
|
|
85
|
+
ret.design = "5";
|
|
86
|
+
} else if (features.indexOf("GUI_M_Right") !== -1) {
|
|
87
|
+
ret.design = "6";
|
|
88
|
+
} else {
|
|
89
|
+
ret.design = "4";
|
|
90
|
+
}
|
|
91
|
+
if (features.indexOf("GUI_M_Top") !== -1 && features.indexOf("GUI_M_Left") !== -1) {
|
|
92
|
+
ret.design = "2";
|
|
93
|
+
}
|
|
94
|
+
if (features.indexOf("GUI_M_Top") !== -1 && features.indexOf("GUI_M_Right") !== -1) {
|
|
95
|
+
ret.design = "3";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function statics(input) {
|
|
102
|
+
return input;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function menus(product) {
|
|
106
|
+
const ret = [];
|
|
107
|
+
|
|
108
|
+
switch (product.data.gui.design) {
|
|
109
|
+
case "1": ret.push({ id: "top", elements: [] }); break;
|
|
110
|
+
case "2": ret.push({ id: "top", elements: [] }); ret.push({ id: "left", elements: [] }); break;
|
|
111
|
+
case "3": ret.push({ id: "top", elements: [] }); ret.push({ id: "right", elements: [] }); break;
|
|
112
|
+
case "4": return [];
|
|
113
|
+
case "5": ret.push({ id: "left", elements: [] }); break;
|
|
114
|
+
case "6": ret.push({ id: "right", elements: [] }); break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (product.data.lists && product.features.indexOf("GUI_Lists") !== -1) {
|
|
118
|
+
ret[0].elements.push(listMenu(product.data.lists));
|
|
119
|
+
}
|
|
120
|
+
ret[0].elements.push(listComponents(product.features));
|
|
121
|
+
|
|
122
|
+
if (product.features.indexOf("UserManagement") !== -1) {
|
|
123
|
+
ret[0].elements.push(listUserManagement(product.features));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return ret;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function listMenu(lists) {
|
|
130
|
+
return {
|
|
131
|
+
id: "Lists",
|
|
132
|
+
type: "MENU",
|
|
133
|
+
elements: lists.map((l) => ({
|
|
134
|
+
id: l.id,
|
|
135
|
+
type: "VIEW",
|
|
136
|
+
view: { component: "LIST", view: l.id },
|
|
137
|
+
})),
|
|
138
|
+
access: { admin: true, logged: true },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function listComponents(features) {
|
|
143
|
+
return {
|
|
144
|
+
id: "Components",
|
|
145
|
+
type: "MENU",
|
|
146
|
+
elements: features
|
|
147
|
+
.filter((f) => featureMenu(f, features))
|
|
148
|
+
.map((f) => featureMenu(f, features)),
|
|
149
|
+
access: { admin: true, logged: true },
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function featureMenu(feature, features) {
|
|
154
|
+
// Add cases for your platform's features here
|
|
155
|
+
// Example: case "MY_FEATURE": return view("MY_COMPONENT", "My View");
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function listUserManagement(features) {
|
|
160
|
+
const list = [];
|
|
161
|
+
let aux;
|
|
162
|
+
|
|
163
|
+
if (features.indexOf("UM_Authentication") !== -1) {
|
|
164
|
+
aux = view("USER_MANAGEMENT", "Sign in");
|
|
165
|
+
aux.access = { anonymous: true };
|
|
166
|
+
list.push(aux);
|
|
167
|
+
}
|
|
168
|
+
if (features.indexOf("UM_R_Anonymous") !== -1) {
|
|
169
|
+
aux = view("USER_MANAGEMENT", "Registration");
|
|
170
|
+
aux.access = { anonymous: true };
|
|
171
|
+
list.push(aux);
|
|
172
|
+
}
|
|
173
|
+
if (features.indexOf("UM_UP_ByUser") !== -1) {
|
|
174
|
+
aux = view("USER_MANAGEMENT", "Change password");
|
|
175
|
+
aux.access = { admin: true, logged: true };
|
|
176
|
+
list.push(aux);
|
|
177
|
+
}
|
|
178
|
+
if (features.indexOf("UM_UserProfile") !== -1) {
|
|
179
|
+
aux = view("USER_MANAGEMENT", "Profile details");
|
|
180
|
+
aux.access = { admin: true, logged: true };
|
|
181
|
+
list.push(aux);
|
|
182
|
+
}
|
|
183
|
+
if (features.indexOf("UM_UserSessions") !== -1) {
|
|
184
|
+
aux = view("USER_MANAGEMENT", "Sessions");
|
|
185
|
+
aux.access = { admin: true, logged: true };
|
|
186
|
+
list.push(aux);
|
|
187
|
+
}
|
|
188
|
+
if (features.indexOf("UM_UserCRUD") !== -1) {
|
|
189
|
+
aux = view("USER_MANAGEMENT", "User Management");
|
|
190
|
+
aux.access = { admin: true };
|
|
191
|
+
list.push(aux);
|
|
192
|
+
}
|
|
193
|
+
if (features.indexOf("UM_Authentication") !== -1) {
|
|
194
|
+
aux = view("USER_MANAGEMENT", "Exit");
|
|
195
|
+
aux.access = { admin: true, logged: true };
|
|
196
|
+
list.push(aux);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return { id: "Account", type: "MENU", elements: list };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function view(comp, view) {
|
|
203
|
+
return {
|
|
204
|
+
id: view,
|
|
205
|
+
type: "VIEW",
|
|
206
|
+
view: { component: comp, view: view },
|
|
207
|
+
};
|
|
208
|
+
}
|