@lbdudc/linea-core 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -260
- 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/transformation.js +17 -5
- 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 +22 -7
- 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":"engine-spec.js","sourceRoot":"","sources":["../../src/product/engine-spec.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"engine-spec.js","sourceRoot":"","sources":["../../src/product/engine-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AASrD,wEAAwE;AACxE,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAE,QAAiB,EAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AAE3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAyB,EAA4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E,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC/F,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { InvalidArgumentError } from '../errors.js'\nimport { isPlainObject } from '../internal/guards.js'\nimport type { ProductSpec } from './spec.js'\n\nexport interface EngineSpec {\n features: string[]\n data: Record<string, unknown>\n [key: string]: unknown\n}\n\n// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\nconst truthyOr = (value: unknown, fallback: unknown): unknown => (value ? value : fallback)\n\nexport const buildEngineSpec = ({ spec }: { spec: ProductSpec }): ProductSpec | EngineSpec => {\n if (!isPlainObject(spec)) {\n throw new InvalidArgumentError('\"spec\" must be an object.')\n }\n\n const parsed = isPlainObject(spec.sensor) ? spec.sensor.parsed : undefined\n if (!isPlainObject(parsed)) return spec\n\n const parsedData = isPlainObject(parsed.data) ? parsed.data : undefined\n if (!Array.isArray(parsed.features) || !isPlainObject(parsedData?.basicData)) return spec\n\n const specBasicData = isPlainObject(spec.basicData) ? spec.basicData : undefined\n\n return {\n features: parsed.features as string[],\n data: {\n ...parsedData,\n basicData: {\n ...parsedData.basicData,\n database: truthyOr(specBasicData?.database, {}),\n version: specBasicData?.version\n }\n },\n // what the modules of a modular SPL read (`input.models`); absent for a plain line\n ...(spec.models === undefined ? {} : { models: spec.models }),\n ...(spec.modelsByMetamodel === undefined ? {} : { modelsByMetamodel: spec.modelsByMetamodel })\n }\n}\n"]}
|
package/dist/product/spec.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** `spec.basicData` — product identity and generation-wide settings. */
|
|
2
1
|
export interface ProductBasicData {
|
|
3
2
|
name?: string;
|
|
4
3
|
version?: string;
|
|
@@ -13,7 +12,6 @@ export interface ProductBasicData {
|
|
|
13
12
|
createdAt?: unknown;
|
|
14
13
|
[key: string]: unknown;
|
|
15
14
|
}
|
|
16
|
-
/** A product spec as stored by the monolith and consumed by the engine. */
|
|
17
15
|
export interface ProductSpec {
|
|
18
16
|
basicData?: ProductBasicData;
|
|
19
17
|
dataModel?: {
|
|
@@ -26,105 +24,25 @@ export interface ProductSpec {
|
|
|
26
24
|
dsl?: string;
|
|
27
25
|
parsed?: unknown;
|
|
28
26
|
};
|
|
29
|
-
/** Legacy feature-selection field. */
|
|
30
27
|
selection?: string[];
|
|
31
28
|
[key: string]: unknown;
|
|
32
29
|
}
|
|
33
|
-
/** A single spec problem. */
|
|
34
30
|
export interface ProductSpecError {
|
|
35
|
-
/** Dotted path of the offending field, e.g. `spec.basicData.name`. */
|
|
36
31
|
readonly path: string;
|
|
37
|
-
/** Stable machine-readable discriminator. */
|
|
38
32
|
readonly code: ProductSpecErrorCode;
|
|
39
|
-
/**
|
|
40
|
-
* An i18n KEY, never a human-readable sentence. Always pass it through the
|
|
41
|
-
* consumer's translation function; there is nothing sensible to render raw.
|
|
42
|
-
*
|
|
43
|
-
* Five keys are INHERITED verbatim from the monolith and already have
|
|
44
|
-
* translations in `linea/client/src/i18n/{en,es,gl}`:
|
|
45
|
-
* `spec_object_validation`, `basicData_object_validation`,
|
|
46
|
-
* `basicData_name_validation`, `invalid_name_characters`,
|
|
47
|
-
* `basicData_version_format`.
|
|
48
|
-
*
|
|
49
|
-
* Four keys are NEW and have NO translation yet, because the monolith enforced
|
|
50
|
-
* these constraints through the Mongoose schema rather than express-validator,
|
|
51
|
-
* so there was no key to copy: `basicData_languages_validation`,
|
|
52
|
-
* `basicData_SRID_validation`, `spec_features_validation`,
|
|
53
|
-
* `spec_statics_validation`. Until webui and linea-cli add them, vue-i18n will
|
|
54
|
-
* render the key itself. Tracked in CHANGELOG.md.
|
|
55
|
-
*/
|
|
56
33
|
readonly messageKey: string;
|
|
57
34
|
}
|
|
58
|
-
/** Stable discriminators for spec problems. */
|
|
59
35
|
export type ProductSpecErrorCode = 'SPEC_NOT_OBJECT' | 'BASIC_DATA_NOT_OBJECT' | 'NAME_REQUIRED' | 'NAME_INVALID_CHARACTERS' | 'VERSION_FORMAT' | 'LANGUAGES_NOT_STRING_ARRAY' | 'SRID_NOT_STRING' | 'FEATURES_INVALID_SHAPE' | 'STATICS_NOT_ARRAY';
|
|
60
|
-
/** Result of validating a spec. */
|
|
61
36
|
export interface ProductSpecValidation {
|
|
62
37
|
readonly valid: boolean;
|
|
63
38
|
readonly errors: ProductSpecError[];
|
|
64
39
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Validates a product spec **without throwing**.
|
|
67
|
-
*
|
|
68
|
-
* Reproduces `createProductValidator` / `updateProductValidator` with their exact
|
|
69
|
-
* i18n keys, and ADDS shape checks for the fields whose type the Mongoose schema
|
|
70
|
-
* used to enforce (`languages`, `SRID`, `features`, `statics`). Those four carry
|
|
71
|
-
* new keys with no translation yet — see `ProductSpecError.messageKey`.
|
|
72
|
-
*
|
|
73
|
-
* `lineId` is NOT validated here: it is a GitLab/persistence concern that lives
|
|
74
|
-
* in linea-server (ADR-003), even though `createProductValidator` checks it.
|
|
75
|
-
*
|
|
76
|
-
* @param params.spec The spec to validate. Anything, including nullish.
|
|
77
|
-
* @returns `valid` plus one entry per problem, in a stable order.
|
|
78
|
-
*/
|
|
79
40
|
export declare const validateProductSpec: ({ spec }: {
|
|
80
41
|
spec: unknown;
|
|
81
42
|
}) => ProductSpecValidation;
|
|
82
|
-
/**
|
|
83
|
-
* Validates a product spec and throws when it is not acceptable.
|
|
84
|
-
*
|
|
85
|
-
* The throwing counterpart of `validateProductSpec`, mirroring the
|
|
86
|
-
* `validateFeatureSelection` / `assertFeatureSelection` pair. It is what makes
|
|
87
|
-
* `InvalidProductSpecError` reachable: the monolith's equivalent is
|
|
88
|
-
* express-validator short-circuiting the request with a 400 before
|
|
89
|
-
* `ProductService.createProduct` ever runs, which has no direct analogue in a
|
|
90
|
-
* library.
|
|
91
|
-
*
|
|
92
|
-
* The message lists every problem with its i18n key. Callers that need the
|
|
93
|
-
* problems as DATA (to build an HTTP response body, say) should call
|
|
94
|
-
* `validateProductSpec` instead — that is precisely what it is for, and it keeps
|
|
95
|
-
* this error free of ad-hoc payload properties.
|
|
96
|
-
*
|
|
97
|
-
* @param params.spec The spec to validate.
|
|
98
|
-
* @returns The spec, unchanged, when it is valid.
|
|
99
|
-
* @throws {InvalidProductSpecError} listing every problem found.
|
|
100
|
-
*/
|
|
101
43
|
export declare const assertProductSpec: ({ spec }: {
|
|
102
44
|
spec: ProductSpec;
|
|
103
45
|
}) => ProductSpec;
|
|
104
|
-
/**
|
|
105
|
-
* Fills a product spec with the domain defaults.
|
|
106
|
-
*
|
|
107
|
-
* Union of the two places the monolith applies defaults:
|
|
108
|
-
* - `entities/product.js` (Mongoose schema): `version` `'0.0.0'`, `database` `{}`,
|
|
109
|
-
* `extra` `{}`, `testEnvironment` `{ image: '', command: '' }`, `languages`
|
|
110
|
-
* `['en','es','gl']`, `SRID` `'4326'`, `dataModel.cells` `[]`, `features` `[]`,
|
|
111
|
-
* `statics` `[]`, `sensor` `{ dsl: '', parsed: null }`.
|
|
112
|
-
* - `generatePipeline.js:saveProductVersion` (~212-222), which re-applies
|
|
113
|
-
* `database`, `extra`, `languages` and `SRID` with `||` right before returning.
|
|
114
|
-
*
|
|
115
|
-
* `||` semantics are preserved for those four, which is subtler than it looks:
|
|
116
|
-
* an empty-string `SRID` falls back to `'4326'` because `''` is falsy, but an
|
|
117
|
-
* EMPTY `languages` array is kept because `[]` is truthy. Both match the monolith.
|
|
118
|
-
*
|
|
119
|
-
* PURE: returns a new object and never mutates the input. `basicData.createdAt`
|
|
120
|
-
* is deliberately NOT filled — the schema defaults it to `Date.now`, which would
|
|
121
|
-
* make this function non-deterministic. Timestamping is persistence metadata and
|
|
122
|
-
* belongs to linea-server.
|
|
123
|
-
*
|
|
124
|
-
* @param params.spec The spec to complete.
|
|
125
|
-
* @returns A new spec with defaults applied.
|
|
126
|
-
* @throws {InvalidArgumentError} when `spec` is not an object.
|
|
127
|
-
*/
|
|
128
46
|
export declare const normalizeProductSpec: ({ spec }: {
|
|
129
47
|
spec: ProductSpec;
|
|
130
48
|
}) => ProductSpec;
|
package/dist/product/spec.js
CHANGED
|
@@ -1,38 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Product spec validation and default filling.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from:
|
|
5
|
-
* - `linea/server/src/rest/validators/productValidators.js` (createProductValidator,
|
|
6
|
-
* updateProductValidator) and `commonValidators.js` (`nameRule`, `versionRule`)
|
|
7
|
-
* - `linea/server/src/model/entities/product.js` — the Mongoose schema defaults
|
|
8
|
-
* - `linea/server/src/model/services/generatePipeline.js:saveProductVersion`
|
|
9
|
-
* (~212-222) — the defaults applied right before returning a generated product
|
|
10
|
-
*
|
|
11
|
-
* The monolith validates at the HTTP edge with express-validator and fills
|
|
12
|
-
* defaults twice: once through the Mongoose schema and once again in
|
|
13
|
-
* `saveProductVersion`. Neither mechanism exists in linea-core, so both collapse
|
|
14
|
-
* into these two functions.
|
|
15
|
-
*
|
|
16
|
-
* `linea-cli/src/core/specSchema.ts` duplicates the same rules with Zod today and
|
|
17
|
-
* is meant to call this instead.
|
|
18
|
-
*/
|
|
19
1
|
import { DEFAULT_LANGUAGES, DEFAULT_SRID, NAME_PATTERN, VERSION_PATTERN } from '../constants.js';
|
|
20
2
|
import { InvalidArgumentError, InvalidProductSpecError } from '../errors.js';
|
|
21
3
|
import { isPlainObject } from '../internal/guards.js';
|
|
22
|
-
/**
|
|
23
|
-
* Validates a product spec **without throwing**.
|
|
24
|
-
*
|
|
25
|
-
* Reproduces `createProductValidator` / `updateProductValidator` with their exact
|
|
26
|
-
* i18n keys, and ADDS shape checks for the fields whose type the Mongoose schema
|
|
27
|
-
* used to enforce (`languages`, `SRID`, `features`, `statics`). Those four carry
|
|
28
|
-
* new keys with no translation yet — see `ProductSpecError.messageKey`.
|
|
29
|
-
*
|
|
30
|
-
* `lineId` is NOT validated here: it is a GitLab/persistence concern that lives
|
|
31
|
-
* in linea-server (ADR-003), even though `createProductValidator` checks it.
|
|
32
|
-
*
|
|
33
|
-
* @param params.spec The spec to validate. Anything, including nullish.
|
|
34
|
-
* @returns `valid` plus one entry per problem, in a stable order.
|
|
35
|
-
*/
|
|
36
4
|
export const validateProductSpec = ({ spec }) => {
|
|
37
5
|
const errors = [];
|
|
38
6
|
if (!isPlainObject(spec)) {
|
|
@@ -114,25 +82,6 @@ export const validateProductSpec = ({ spec }) => {
|
|
|
114
82
|
}
|
|
115
83
|
return { valid: errors.length === 0, errors };
|
|
116
84
|
};
|
|
117
|
-
/**
|
|
118
|
-
* Validates a product spec and throws when it is not acceptable.
|
|
119
|
-
*
|
|
120
|
-
* The throwing counterpart of `validateProductSpec`, mirroring the
|
|
121
|
-
* `validateFeatureSelection` / `assertFeatureSelection` pair. It is what makes
|
|
122
|
-
* `InvalidProductSpecError` reachable: the monolith's equivalent is
|
|
123
|
-
* express-validator short-circuiting the request with a 400 before
|
|
124
|
-
* `ProductService.createProduct` ever runs, which has no direct analogue in a
|
|
125
|
-
* library.
|
|
126
|
-
*
|
|
127
|
-
* The message lists every problem with its i18n key. Callers that need the
|
|
128
|
-
* problems as DATA (to build an HTTP response body, say) should call
|
|
129
|
-
* `validateProductSpec` instead — that is precisely what it is for, and it keeps
|
|
130
|
-
* this error free of ad-hoc payload properties.
|
|
131
|
-
*
|
|
132
|
-
* @param params.spec The spec to validate.
|
|
133
|
-
* @returns The spec, unchanged, when it is valid.
|
|
134
|
-
* @throws {InvalidProductSpecError} listing every problem found.
|
|
135
|
-
*/
|
|
136
85
|
export const assertProductSpec = ({ spec }) => {
|
|
137
86
|
const { valid, errors } = validateProductSpec({ spec });
|
|
138
87
|
if (!valid) {
|
|
@@ -141,30 +90,6 @@ export const assertProductSpec = ({ spec }) => {
|
|
|
141
90
|
}
|
|
142
91
|
return spec;
|
|
143
92
|
};
|
|
144
|
-
/**
|
|
145
|
-
* Fills a product spec with the domain defaults.
|
|
146
|
-
*
|
|
147
|
-
* Union of the two places the monolith applies defaults:
|
|
148
|
-
* - `entities/product.js` (Mongoose schema): `version` `'0.0.0'`, `database` `{}`,
|
|
149
|
-
* `extra` `{}`, `testEnvironment` `{ image: '', command: '' }`, `languages`
|
|
150
|
-
* `['en','es','gl']`, `SRID` `'4326'`, `dataModel.cells` `[]`, `features` `[]`,
|
|
151
|
-
* `statics` `[]`, `sensor` `{ dsl: '', parsed: null }`.
|
|
152
|
-
* - `generatePipeline.js:saveProductVersion` (~212-222), which re-applies
|
|
153
|
-
* `database`, `extra`, `languages` and `SRID` with `||` right before returning.
|
|
154
|
-
*
|
|
155
|
-
* `||` semantics are preserved for those four, which is subtler than it looks:
|
|
156
|
-
* an empty-string `SRID` falls back to `'4326'` because `''` is falsy, but an
|
|
157
|
-
* EMPTY `languages` array is kept because `[]` is truthy. Both match the monolith.
|
|
158
|
-
*
|
|
159
|
-
* PURE: returns a new object and never mutates the input. `basicData.createdAt`
|
|
160
|
-
* is deliberately NOT filled — the schema defaults it to `Date.now`, which would
|
|
161
|
-
* make this function non-deterministic. Timestamping is persistence metadata and
|
|
162
|
-
* belongs to linea-server.
|
|
163
|
-
*
|
|
164
|
-
* @param params.spec The spec to complete.
|
|
165
|
-
* @returns A new spec with defaults applied.
|
|
166
|
-
* @throws {InvalidArgumentError} when `spec` is not an object.
|
|
167
|
-
*/
|
|
168
93
|
export const normalizeProductSpec = ({ spec }) => {
|
|
169
94
|
if (!isPlainObject(spec)) {
|
|
170
95
|
throw new InvalidArgumentError('"spec" must be an object.');
|
|
@@ -190,10 +115,6 @@ export const normalizeProductSpec = ({ spec }) => {
|
|
|
190
115
|
image: typeof testEnvironment.image === 'string' ? testEnvironment.image : '',
|
|
191
116
|
command: typeof testEnvironment.command === 'string' ? testEnvironment.command : ''
|
|
192
117
|
},
|
|
193
|
-
// An EMPTY array is kept. `saveProductVersion` uses `languages || [...]`
|
|
194
|
-
// and `[]` is truthy in JavaScript, so the monolith preserves it; the
|
|
195
|
-
// Mongoose default only fires when the path is `undefined`. A user who
|
|
196
|
-
// deselected every language must generate the same product here.
|
|
197
118
|
languages: Array.isArray(languages) ? [...languages] : [...DEFAULT_LANGUAGES],
|
|
198
119
|
SRID: typeof basicData.SRID === 'string' && basicData.SRID !== ''
|
|
199
120
|
? basicData.SRID
|
package/dist/product/spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/product/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAuErD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAqB,EAAyB,EAAE;IACxF,MAAM,MAAM,GAAuB,EAAE,CAAA;IAErC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAiB;oBACvB,UAAU,EAAE,uCAAuC;iBACpD,CAAC;SACH,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;IAChC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC;oBACP,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,uBAAuB;oBAC7B,UAAU,EAAE,4CAA4C;iBACzD,CAAC;SACH,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;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,QAAQ,EAAE;gBACtB,CAAC,CAAC,EAAE;QACR,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;QAC7D,MAAM,EAAE;YACN,GAAG,MAAM;YACT,GAAG,EAAE,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACrD,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,IAAI;SAC9B;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\n * Product spec validation and default filling.\n *\n * Migrated from:\n * - `linea/server/src/rest/validators/productValidators.js` (createProductValidator,\n * updateProductValidator) and `commonValidators.js` (`nameRule`, `versionRule`)\n * - `linea/server/src/model/entities/product.js` — the Mongoose schema defaults\n * - `linea/server/src/model/services/generatePipeline.js:saveProductVersion`\n * (~212-222) — the defaults applied right before returning a generated product\n *\n * The monolith validates at the HTTP edge with express-validator and fills\n * defaults twice: once through the Mongoose schema and once again in\n * `saveProductVersion`. Neither mechanism exists in linea-core, so both collapse\n * into these two functions.\n *\n * `linea-cli/src/core/specSchema.ts` duplicates the same rules with Zod today and\n * is meant to call this instead.\n */\nimport {\n DEFAULT_LANGUAGES,\n DEFAULT_SRID,\n NAME_PATTERN,\n VERSION_PATTERN\n} from '../constants.js'\nimport { InvalidArgumentError, InvalidProductSpecError } from '../errors.js'\nimport { isPlainObject } from '../internal/guards.js'\n\n/** `spec.basicData` — product identity and generation-wide settings. */\nexport interface ProductBasicData {\n name?: string\n version?: string\n languages?: string[]\n SRID?: string\n database?: Record<string, unknown>\n extra?: Record<string, unknown>\n testEnvironment?: { image?: string, command?: string }\n createdAt?: unknown\n [key: string]: unknown\n}\n\n/** A product spec as stored by the monolith and consumed by the engine. */\nexport interface ProductSpec {\n basicData?: ProductBasicData\n dataModel?: { cells?: unknown[], [key: string]: unknown }\n features?: string[] | Record<string, boolean>\n statics?: unknown[]\n sensor?: { dsl?: string, parsed?: unknown }\n /** Legacy feature-selection field. */\n selection?: string[]\n [key: string]: unknown\n}\n\n/** A single spec problem. */\nexport interface ProductSpecError {\n /** Dotted path of the offending field, e.g. `spec.basicData.name`. */\n readonly path: string\n /** Stable machine-readable discriminator. */\n readonly code: ProductSpecErrorCode\n /**\n * An i18n KEY, never a human-readable sentence. Always pass it through the\n * consumer's translation function; there is nothing sensible to render raw.\n *\n * Five keys are INHERITED verbatim from the monolith and already have\n * translations in `linea/client/src/i18n/{en,es,gl}`:\n * `spec_object_validation`, `basicData_object_validation`,\n * `basicData_name_validation`, `invalid_name_characters`,\n * `basicData_version_format`.\n *\n * Four keys are NEW and have NO translation yet, because the monolith enforced\n * these constraints through the Mongoose schema rather than express-validator,\n * so there was no key to copy: `basicData_languages_validation`,\n * `basicData_SRID_validation`, `spec_features_validation`,\n * `spec_statics_validation`. Until webui and linea-cli add them, vue-i18n will\n * render the key itself. Tracked in CHANGELOG.md.\n */\n readonly messageKey: string\n}\n\n/** Stable discriminators for spec problems. */\nexport type ProductSpecErrorCode =\n | 'SPEC_NOT_OBJECT'\n | 'BASIC_DATA_NOT_OBJECT'\n | 'NAME_REQUIRED'\n | 'NAME_INVALID_CHARACTERS'\n | 'VERSION_FORMAT'\n | 'LANGUAGES_NOT_STRING_ARRAY'\n | 'SRID_NOT_STRING'\n | 'FEATURES_INVALID_SHAPE'\n | 'STATICS_NOT_ARRAY'\n\n/** Result of validating a spec. */\nexport interface ProductSpecValidation {\n readonly valid: boolean\n readonly errors: ProductSpecError[]\n}\n\n/**\n * Validates a product spec **without throwing**.\n *\n * Reproduces `createProductValidator` / `updateProductValidator` with their exact\n * i18n keys, and ADDS shape checks for the fields whose type the Mongoose schema\n * used to enforce (`languages`, `SRID`, `features`, `statics`). Those four carry\n * new keys with no translation yet — see `ProductSpecError.messageKey`.\n *\n * `lineId` is NOT validated here: it is a GitLab/persistence concern that lives\n * in linea-server (ADR-003), even though `createProductValidator` checks it.\n *\n * @param params.spec The spec to validate. Anything, including nullish.\n * @returns `valid` plus one entry per problem, in a stable order.\n */\nexport const validateProductSpec = ({ spec }: { spec: unknown }): ProductSpecValidation => {\n const errors: ProductSpecError[] = []\n\n if (!isPlainObject(spec)) {\n return {\n valid: false,\n errors: [{\n path: 'spec',\n code: 'SPEC_NOT_OBJECT',\n messageKey: 'error_messages.spec_object_validation'\n }]\n }\n }\n\n const basicData = spec.basicData\n if (!isPlainObject(basicData)) {\n return {\n valid: false,\n errors: [{\n path: 'spec.basicData',\n code: 'BASIC_DATA_NOT_OBJECT',\n messageKey: 'error_messages.basicData_object_validation'\n }]\n }\n }\n\n const name = basicData.name\n if (typeof name !== 'string' || name === '') {\n errors.push({\n path: 'spec.basicData.name',\n code: 'NAME_REQUIRED',\n messageKey: 'error_messages.basicData_name_validation'\n })\n } else if (!NAME_PATTERN.test(name)) {\n errors.push({\n path: 'spec.basicData.name',\n code: 'NAME_INVALID_CHARACTERS',\n messageKey: 'error_messages.invalid_name_characters'\n })\n }\n\n if (typeof basicData.version !== 'string' || !VERSION_PATTERN.test(basicData.version)) {\n errors.push({\n path: 'spec.basicData.version',\n code: 'VERSION_FORMAT',\n messageKey: 'error_messages.basicData_version_format'\n })\n }\n\n const { languages } = basicData\n if (\n languages !== undefined &&\n (!Array.isArray(languages) || languages.some((l) => typeof l !== 'string'))\n ) {\n errors.push({\n path: 'spec.basicData.languages',\n code: 'LANGUAGES_NOT_STRING_ARRAY',\n messageKey: 'error_messages.basicData_languages_validation'\n })\n }\n\n if (basicData.SRID !== undefined && typeof basicData.SRID !== 'string') {\n errors.push({\n path: 'spec.basicData.SRID',\n code: 'SRID_NOT_STRING',\n messageKey: 'error_messages.basicData_SRID_validation'\n })\n }\n\n const { features } = spec\n const featuresValid =\n features === undefined ||\n (Array.isArray(features) && features.every((f) => typeof f === 'string')) ||\n isPlainObject(features)\n if (!featuresValid) {\n errors.push({\n path: 'spec.features',\n code: 'FEATURES_INVALID_SHAPE',\n messageKey: 'error_messages.spec_features_validation'\n })\n }\n\n if (spec.statics !== undefined && !Array.isArray(spec.statics)) {\n errors.push({\n path: 'spec.statics',\n code: 'STATICS_NOT_ARRAY',\n messageKey: 'error_messages.spec_statics_validation'\n })\n }\n\n return { valid: errors.length === 0, errors }\n}\n\n/**\n * Validates a product spec and throws when it is not acceptable.\n *\n * The throwing counterpart of `validateProductSpec`, mirroring the\n * `validateFeatureSelection` / `assertFeatureSelection` pair. It is what makes\n * `InvalidProductSpecError` reachable: the monolith's equivalent is\n * express-validator short-circuiting the request with a 400 before\n * `ProductService.createProduct` ever runs, which has no direct analogue in a\n * library.\n *\n * The message lists every problem with its i18n key. Callers that need the\n * problems as DATA (to build an HTTP response body, say) should call\n * `validateProductSpec` instead — that is precisely what it is for, and it keeps\n * this error free of ad-hoc payload properties.\n *\n * @param params.spec The spec to validate.\n * @returns The spec, unchanged, when it is valid.\n * @throws {InvalidProductSpecError} listing every problem found.\n */\nexport const assertProductSpec = ({ spec }: { spec: ProductSpec }): ProductSpec => {\n const { valid, errors } = validateProductSpec({ spec })\n if (!valid) {\n const summary = errors.map((error) => `${error.path}: ${error.messageKey}`).join('; ')\n throw new InvalidProductSpecError(`Invalid product spec: ${summary}`)\n }\n return spec\n}\n\n/**\n * Fills a product spec with the domain defaults.\n *\n * Union of the two places the monolith applies defaults:\n * - `entities/product.js` (Mongoose schema): `version` `'0.0.0'`, `database` `{}`,\n * `extra` `{}`, `testEnvironment` `{ image: '', command: '' }`, `languages`\n * `['en','es','gl']`, `SRID` `'4326'`, `dataModel.cells` `[]`, `features` `[]`,\n * `statics` `[]`, `sensor` `{ dsl: '', parsed: null }`.\n * - `generatePipeline.js:saveProductVersion` (~212-222), which re-applies\n * `database`, `extra`, `languages` and `SRID` with `||` right before returning.\n *\n * `||` semantics are preserved for those four, which is subtler than it looks:\n * an empty-string `SRID` falls back to `'4326'` because `''` is falsy, but an\n * EMPTY `languages` array is kept because `[]` is truthy. Both match the monolith.\n *\n * PURE: returns a new object and never mutates the input. `basicData.createdAt`\n * is deliberately NOT filled — the schema defaults it to `Date.now`, which would\n * make this function non-deterministic. Timestamping is persistence metadata and\n * belongs to linea-server.\n *\n * @param params.spec The spec to complete.\n * @returns A new spec with defaults applied.\n * @throws {InvalidArgumentError} when `spec` is not an object.\n */\nexport const normalizeProductSpec = ({ spec }: { spec: ProductSpec }): ProductSpec => {\n if (!isPlainObject(spec)) {\n throw new InvalidArgumentError('\"spec\" must be an object.')\n }\n const basicData = isPlainObject(spec.basicData) ? spec.basicData : {}\n const dataModel = isPlainObject(spec.dataModel) ? spec.dataModel : {}\n const sensor = isPlainObject(spec.sensor) ? spec.sensor : {}\n const testEnvironment = isPlainObject(basicData.testEnvironment)\n ? basicData.testEnvironment\n : {}\n\n const { languages } = basicData\n\n return {\n ...spec,\n basicData: {\n ...basicData,\n name: typeof basicData.name === 'string' ? basicData.name : '',\n version: typeof basicData.version === 'string' && basicData.version !== ''\n ? basicData.version\n : '0.0.0',\n database: isPlainObject(basicData.database) ? basicData.database : {},\n extra: isPlainObject(basicData.extra) ? basicData.extra : {},\n testEnvironment: {\n image: typeof testEnvironment.image === 'string' ? testEnvironment.image : '',\n command: typeof testEnvironment.command === 'string' ? testEnvironment.command : ''\n },\n // An EMPTY array is kept. `saveProductVersion` uses `languages || [...]`\n // and `[]` is truthy in JavaScript, so the monolith preserves it; the\n // Mongoose default only fires when the path is `undefined`. A user who\n // deselected every language must generate the same product here.\n languages: Array.isArray(languages) ? [...languages] : [...DEFAULT_LANGUAGES],\n SRID: typeof basicData.SRID === 'string' && basicData.SRID !== ''\n ? basicData.SRID\n : DEFAULT_SRID\n },\n dataModel: {\n ...dataModel,\n cells: Array.isArray(dataModel.cells) ? [...dataModel.cells] : []\n },\n features: Array.isArray(spec.features)\n ? [...spec.features]\n : isPlainObject(spec.features)\n ? { ...spec.features }\n : [],\n statics: Array.isArray(spec.statics) ? [...spec.statics] : [],\n sensor: {\n ...sensor,\n dsl: typeof sensor.dsl === 'string' ? sensor.dsl : '',\n parsed: sensor.parsed ?? null\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/product/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AA8CrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,IAAI,EAAqB,EAAyB,EAAE;IACxF,MAAM,MAAM,GAAuB,EAAE,CAAA;IAErC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAiB;oBACvB,UAAU,EAAE,uCAAuC;iBACpD,CAAC;SACH,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;IAChC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,CAAC;oBACP,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,uBAAuB;oBAC7B,UAAU,EAAE,4CAA4C;iBACzD,CAAC;SACH,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,eAAe;YACrB,UAAU,EAAE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G,EAAE,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACrD,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,IAAI;SAC9B;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n DEFAULT_LANGUAGES,\n DEFAULT_SRID,\n NAME_PATTERN,\n VERSION_PATTERN\n} from '../constants.js'\nimport { InvalidArgumentError, InvalidProductSpecError } from '../errors.js'\nimport { isPlainObject } from '../internal/guards.js'\n\nexport interface ProductBasicData {\n name?: string\n version?: string\n languages?: string[]\n SRID?: string\n database?: Record<string, unknown>\n extra?: Record<string, unknown>\n testEnvironment?: { image?: string, command?: string }\n createdAt?: unknown\n [key: string]: unknown\n}\n\nexport interface ProductSpec {\n basicData?: ProductBasicData\n dataModel?: { cells?: unknown[], [key: string]: unknown }\n features?: string[] | Record<string, boolean>\n statics?: unknown[]\n sensor?: { dsl?: string, parsed?: unknown }\n selection?: string[]\n [key: string]: unknown\n}\n\nexport interface ProductSpecError {\n readonly path: string\n readonly code: ProductSpecErrorCode\n readonly messageKey: string\n}\n\nexport type ProductSpecErrorCode =\n | 'SPEC_NOT_OBJECT'\n | 'BASIC_DATA_NOT_OBJECT'\n | 'NAME_REQUIRED'\n | 'NAME_INVALID_CHARACTERS'\n | 'VERSION_FORMAT'\n | 'LANGUAGES_NOT_STRING_ARRAY'\n | 'SRID_NOT_STRING'\n | 'FEATURES_INVALID_SHAPE'\n | 'STATICS_NOT_ARRAY'\n\nexport interface ProductSpecValidation {\n readonly valid: boolean\n readonly errors: ProductSpecError[]\n}\n\nexport const validateProductSpec = ({ spec }: { spec: unknown }): ProductSpecValidation => {\n const errors: ProductSpecError[] = []\n\n if (!isPlainObject(spec)) {\n return {\n valid: false,\n errors: [{\n path: 'spec',\n code: 'SPEC_NOT_OBJECT',\n messageKey: 'error_messages.spec_object_validation'\n }]\n }\n }\n\n const basicData = spec.basicData\n if (!isPlainObject(basicData)) {\n return {\n valid: false,\n errors: [{\n path: 'spec.basicData',\n code: 'BASIC_DATA_NOT_OBJECT',\n messageKey: 'error_messages.basicData_object_validation'\n }]\n }\n }\n\n const name = basicData.name\n if (typeof name !== 'string' || name === '') {\n errors.push({\n path: 'spec.basicData.name',\n code: 'NAME_REQUIRED',\n messageKey: 'error_messages.basicData_name_validation'\n })\n } else if (!NAME_PATTERN.test(name)) {\n errors.push({\n path: 'spec.basicData.name',\n code: 'NAME_INVALID_CHARACTERS',\n messageKey: 'error_messages.invalid_name_characters'\n })\n }\n\n if (typeof basicData.version !== 'string' || !VERSION_PATTERN.test(basicData.version)) {\n errors.push({\n path: 'spec.basicData.version',\n code: 'VERSION_FORMAT',\n messageKey: 'error_messages.basicData_version_format'\n })\n }\n\n const { languages } = basicData\n if (\n languages !== undefined &&\n (!Array.isArray(languages) || languages.some((l) => typeof l !== 'string'))\n ) {\n errors.push({\n path: 'spec.basicData.languages',\n code: 'LANGUAGES_NOT_STRING_ARRAY',\n messageKey: 'error_messages.basicData_languages_validation'\n })\n }\n\n if (basicData.SRID !== undefined && typeof basicData.SRID !== 'string') {\n errors.push({\n path: 'spec.basicData.SRID',\n code: 'SRID_NOT_STRING',\n messageKey: 'error_messages.basicData_SRID_validation'\n })\n }\n\n const { features } = spec\n const featuresValid =\n features === undefined ||\n (Array.isArray(features) && features.every((f) => typeof f === 'string')) ||\n isPlainObject(features)\n if (!featuresValid) {\n errors.push({\n path: 'spec.features',\n code: 'FEATURES_INVALID_SHAPE',\n messageKey: 'error_messages.spec_features_validation'\n })\n }\n\n if (spec.statics !== undefined && !Array.isArray(spec.statics)) {\n errors.push({\n path: 'spec.statics',\n code: 'STATICS_NOT_ARRAY',\n messageKey: 'error_messages.spec_statics_validation'\n })\n }\n\n return { valid: errors.length === 0, errors }\n}\n\nexport const assertProductSpec = ({ spec }: { spec: ProductSpec }): ProductSpec => {\n const { valid, errors } = validateProductSpec({ spec })\n if (!valid) {\n const summary = errors.map((error) => `${error.path}: ${error.messageKey}`).join('; ')\n throw new InvalidProductSpecError(`Invalid product spec: ${summary}`)\n }\n return spec\n}\n\nexport const normalizeProductSpec = ({ spec }: { spec: ProductSpec }): ProductSpec => {\n if (!isPlainObject(spec)) {\n throw new InvalidArgumentError('\"spec\" must be an object.')\n }\n const basicData = isPlainObject(spec.basicData) ? spec.basicData : {}\n const dataModel = isPlainObject(spec.dataModel) ? spec.dataModel : {}\n const sensor = isPlainObject(spec.sensor) ? spec.sensor : {}\n const testEnvironment = isPlainObject(basicData.testEnvironment)\n ? basicData.testEnvironment\n : {}\n\n const { languages } = basicData\n\n return {\n ...spec,\n basicData: {\n ...basicData,\n name: typeof basicData.name === 'string' ? basicData.name : '',\n version: typeof basicData.version === 'string' && basicData.version !== ''\n ? basicData.version\n : '0.0.0',\n database: isPlainObject(basicData.database) ? basicData.database : {},\n extra: isPlainObject(basicData.extra) ? basicData.extra : {},\n testEnvironment: {\n image: typeof testEnvironment.image === 'string' ? testEnvironment.image : '',\n command: typeof testEnvironment.command === 'string' ? testEnvironment.command : ''\n },\n languages: Array.isArray(languages) ? [...languages] : [...DEFAULT_LANGUAGES],\n SRID: typeof basicData.SRID === 'string' && basicData.SRID !== ''\n ? basicData.SRID\n : DEFAULT_SRID\n },\n dataModel: {\n ...dataModel,\n cells: Array.isArray(dataModel.cells) ? [...dataModel.cells] : []\n },\n features: Array.isArray(spec.features)\n ? [...spec.features]\n : isPlainObject(spec.features)\n ? { ...spec.features }\n : [],\n statics: Array.isArray(spec.statics) ? [...spec.statics] : [],\n sensor: {\n ...sensor,\n dsl: typeof sensor.dsl === 'string' ? sensor.dsl : '',\n parsed: sensor.parsed ?? null\n }\n }\n}\n"]}
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bumps one component of an `x.y.z` version, zeroing everything to its right.
|
|
3
|
-
*
|
|
4
|
-
* Verbatim algorithm of the monolith: the component at `index` is incremented
|
|
5
|
-
* and every component after it is reset to 0.
|
|
6
|
-
*
|
|
7
|
-
* incrementVersion({ version: '1.2.3', index: 0 }) === '2.0.0'
|
|
8
|
-
* incrementVersion({ version: '1.2.3', index: 1 }) === '1.3.0'
|
|
9
|
-
* incrementVersion({ version: '1.2.3', index: 2 }) === '1.2.4'
|
|
10
|
-
*
|
|
11
|
-
* The monolith bumps index 1 on a feature-model save (`LineService.js:406`) and
|
|
12
|
-
* on a conversion, and index 2 on a product generation.
|
|
13
|
-
*
|
|
14
|
-
* HARDENED (ADR-019): the original does `version.split('.').map(Number)` with no
|
|
15
|
-
* validation, so `'abc'` silently yields `'NaN.NaN.NaN'` and would be persisted.
|
|
16
|
-
* Here a version that does not match `VERSION_PATTERN` is rejected.
|
|
17
|
-
*
|
|
18
|
-
* @param params.version Current version, `x.y.z`.
|
|
19
|
-
* @param params.index Zero-based component to bump: 0 major, 1 minor, 2 patch.
|
|
20
|
-
* @returns The bumped version.
|
|
21
|
-
* @throws {InvalidArgumentError} when `version` is not `x.y.z` or `index` is not
|
|
22
|
-
* an integer in `[0, 2]`.
|
|
23
|
-
*/
|
|
24
1
|
export declare const incrementVersion: ({ version, index }: {
|
|
25
2
|
version: string;
|
|
26
3
|
index: number;
|
package/dist/product/version.js
CHANGED
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Product version arithmetic.
|
|
3
|
-
*
|
|
4
|
-
* Migrated from `linea/server/src/model/services/utils.js:incrementVersion` (~152-163).
|
|
5
|
-
*/
|
|
6
1
|
import { VERSION_PATTERN } from '../constants.js';
|
|
7
2
|
import { InvalidArgumentError } from '../errors.js';
|
|
8
|
-
/**
|
|
9
|
-
* Bumps one component of an `x.y.z` version, zeroing everything to its right.
|
|
10
|
-
*
|
|
11
|
-
* Verbatim algorithm of the monolith: the component at `index` is incremented
|
|
12
|
-
* and every component after it is reset to 0.
|
|
13
|
-
*
|
|
14
|
-
* incrementVersion({ version: '1.2.3', index: 0 }) === '2.0.0'
|
|
15
|
-
* incrementVersion({ version: '1.2.3', index: 1 }) === '1.3.0'
|
|
16
|
-
* incrementVersion({ version: '1.2.3', index: 2 }) === '1.2.4'
|
|
17
|
-
*
|
|
18
|
-
* The monolith bumps index 1 on a feature-model save (`LineService.js:406`) and
|
|
19
|
-
* on a conversion, and index 2 on a product generation.
|
|
20
|
-
*
|
|
21
|
-
* HARDENED (ADR-019): the original does `version.split('.').map(Number)` with no
|
|
22
|
-
* validation, so `'abc'` silently yields `'NaN.NaN.NaN'` and would be persisted.
|
|
23
|
-
* Here a version that does not match `VERSION_PATTERN` is rejected.
|
|
24
|
-
*
|
|
25
|
-
* @param params.version Current version, `x.y.z`.
|
|
26
|
-
* @param params.index Zero-based component to bump: 0 major, 1 minor, 2 patch.
|
|
27
|
-
* @returns The bumped version.
|
|
28
|
-
* @throws {InvalidArgumentError} when `version` is not `x.y.z` or `index` is not
|
|
29
|
-
* an integer in `[0, 2]`.
|
|
30
|
-
*/
|
|
31
3
|
export const incrementVersion = ({ version, index }) => {
|
|
32
4
|
if (typeof version !== 'string' || !VERSION_PATTERN.test(version)) {
|
|
33
5
|
throw new InvalidArgumentError(`"version" must match x.y.z, got ${JSON.stringify(version)}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/product/version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/product/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,KAAK,EAIN,EAAU,EAAE;IACX,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,oBAAoB,CAC5B,mCAAmC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAC9D,CAAA;IACH,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,oBAAoB,CAAC,6CAA6C,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/F,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC5C,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACf,IAAI,CAAC,KAAK,KAAK;YAAE,OAAO,IAAI,GAAG,CAAC,CAAA;QAChC,IAAI,CAAC,GAAG,KAAK;YAAE,OAAO,CAAC,CAAA;QACvB,OAAO,IAAI,CAAA;IACb,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { VERSION_PATTERN } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\n\nexport const incrementVersion = ({\n version,\n index\n}: {\n version: string\n index: number\n}): string => {\n if (typeof version !== 'string' || !VERSION_PATTERN.test(version)) {\n throw new InvalidArgumentError(\n `\"version\" must match x.y.z, got ${JSON.stringify(version)}.`\n )\n }\n if (!Number.isInteger(index) || index < 0 || index > 2) {\n throw new InvalidArgumentError(`\"index\" must be an integer in [0, 2], got ${String(index)}.`)\n }\n\n const parts = version.split('.').map(Number)\n return parts\n .map((part, i) => {\n if (i === index) return part + 1\n if (i > index) return 0\n return part\n })\n .join('.')\n}\n"]}
|
|
@@ -1,223 +1,58 @@
|
|
|
1
|
-
/** One product of a line, as recorded in `products.json`. */
|
|
2
1
|
export interface ProductsIndexEntry {
|
|
3
|
-
/** Product name; same rules as any other name (`NAME_PATTERN`). */
|
|
4
2
|
readonly name: string;
|
|
5
|
-
/** Path of the product repository in the laboratory's GitLab. */
|
|
6
3
|
readonly repositorio: string;
|
|
7
|
-
/**
|
|
8
|
-
* Current product version (`VERSION_PATTERN`, i.e. `x.y.z`). **Optional**:
|
|
9
|
-
* every index written before this field existed is still valid, and an entry
|
|
10
|
-
* without it is never given one implicitly.
|
|
11
|
-
*
|
|
12
|
-
* It duplicates `spec.basicData.version`, which lives in the product's own
|
|
13
|
-
* repository. That is the point: the enrolled-products listing needs every
|
|
14
|
-
* version at once, and reading one file per product would be one GitLab
|
|
15
|
-
* request per row. The product repository stays the source of truth; this is
|
|
16
|
-
* the copy the line keeps to be able to list without fanning out.
|
|
17
|
-
*/
|
|
18
4
|
readonly version?: string;
|
|
19
5
|
}
|
|
20
|
-
/** The whole index. */
|
|
21
6
|
export interface ProductsIndex {
|
|
22
7
|
readonly productos: ProductsIndexEntry[];
|
|
23
8
|
}
|
|
24
|
-
/** A problem found in an index. */
|
|
25
9
|
export interface ProductsIndexProblem {
|
|
26
|
-
/** Dotted path of the offending field, e.g. `productos[2].repositorio`. */
|
|
27
10
|
readonly path: string;
|
|
28
|
-
/** Stable machine-readable discriminator. */
|
|
29
11
|
readonly code: ProductsIndexProblemCode;
|
|
30
|
-
/**
|
|
31
|
-
* An i18n KEY, never a human-readable sentence — same policy as
|
|
32
|
-
* `ProductSpecError.messageKey`, so a consumer never has to guess whether to
|
|
33
|
-
* translate a value or render it raw.
|
|
34
|
-
*
|
|
35
|
-
* Two keys are inherited from the monolith and already translated:
|
|
36
|
-
* `invalid_name_characters` and `basicData_version_format` (the latter reads
|
|
37
|
-
* "Version must follow the format X.Y.Z", which is exactly the fact being
|
|
38
|
-
* reported, so it is reused instead of minting an untranslated twin). The
|
|
39
|
-
* rest are NEW (there was no products index to validate before ADR-011) and
|
|
40
|
-
* have no translation yet; they are listed in CHANGELOG.md for whoever
|
|
41
|
-
* migrates webui and linea-cli.
|
|
42
|
-
*/
|
|
43
12
|
readonly messageKey: string;
|
|
44
13
|
}
|
|
45
|
-
/** Stable discriminators for index problems. */
|
|
46
14
|
export type ProductsIndexProblemCode = 'INDEX_NOT_OBJECT' | 'PRODUCTOS_NOT_ARRAY' | 'ENTRY_NOT_OBJECT' | 'NAME_REQUIRED' | 'NAME_INVALID_CHARACTERS' | 'NAME_DUPLICATED' | 'REPOSITORIO_REQUIRED' | 'VERSION_INVALID_FORMAT';
|
|
47
|
-
/** Result of validating an index. */
|
|
48
15
|
export interface ProductsIndexValidation {
|
|
49
16
|
readonly valid: boolean;
|
|
50
17
|
readonly errors: ProductsIndexProblem[];
|
|
51
18
|
}
|
|
52
|
-
/**
|
|
53
|
-
* An empty index.
|
|
54
|
-
*
|
|
55
|
-
* @returns A fresh `{ productos: [] }`. A new object every call, so callers can
|
|
56
|
-
* safely treat it as their own.
|
|
57
|
-
*/
|
|
58
19
|
export declare const emptyProductsIndex: () => ProductsIndex;
|
|
59
|
-
/**
|
|
60
|
-
* Validates an index **without throwing**.
|
|
61
|
-
*
|
|
62
|
-
* Checks the ADR-011 shape plus the domain rules that make the index usable:
|
|
63
|
-
* names must be valid (`NAME_PATTERN`) and unique, and every entry needs a
|
|
64
|
-
* `repositorio`.
|
|
65
|
-
*
|
|
66
|
-
* @param params.index The index to validate. Anything, including nullish.
|
|
67
|
-
* @returns `valid` plus one entry per problem, in document order.
|
|
68
|
-
*/
|
|
69
20
|
export declare const validateProductsIndex: ({ index }: {
|
|
70
21
|
index: unknown;
|
|
71
22
|
}) => ProductsIndexValidation;
|
|
72
|
-
/**
|
|
73
|
-
* Parses the JSON contents of a `products.json`.
|
|
74
|
-
*
|
|
75
|
-
* @param params.content Raw file contents.
|
|
76
|
-
* @returns The index, with only the normative fields kept per entry: `name`,
|
|
77
|
-
* `repositorio` and, when the file has it, `version`. An index written before
|
|
78
|
-
* `version` existed parses exactly as it always did.
|
|
79
|
-
* @throws {ProductsIndexError} when the JSON is malformed or does not satisfy
|
|
80
|
-
* the ADR-011 shape — which includes a `version` present but not `x.y.z`.
|
|
81
|
-
*/
|
|
82
23
|
export declare const parseProductsIndex: ({ content }: {
|
|
83
24
|
content: string;
|
|
84
25
|
}) => ProductsIndex;
|
|
85
|
-
/**
|
|
86
|
-
* Serialises an index deterministically.
|
|
87
|
-
*
|
|
88
|
-
* Stability is a feature, not a detail: linea-server commits this file to the
|
|
89
|
-
* line repository on every product create/rename/delete, so an unstable
|
|
90
|
-
* serialisation would produce noisy diffs and spurious merge conflicts.
|
|
91
|
-
* Guarantees: entries sorted alphabetically by `name`, only the normative fields
|
|
92
|
-
* emitted and always in the same order (`name`, `repositorio`, `version`),
|
|
93
|
-
* two-space indentation, single trailing newline.
|
|
94
|
-
*
|
|
95
|
-
* An entry with no version emits **no `version` key** — not `null`, not `''`.
|
|
96
|
-
* That is what keeps an index written before this field byte-identical after a
|
|
97
|
-
* read/write round trip.
|
|
98
|
-
*
|
|
99
|
-
* @param params.index The index to serialise.
|
|
100
|
-
* @returns The JSON text to write.
|
|
101
|
-
* @throws {InvalidArgumentError} when `index` is not index-shaped.
|
|
102
|
-
*/
|
|
103
26
|
export declare const serializeProductsIndex: ({ index }: {
|
|
104
27
|
index: ProductsIndex;
|
|
105
28
|
}) => string;
|
|
106
|
-
/**
|
|
107
|
-
* Adds a product to the index.
|
|
108
|
-
*
|
|
109
|
-
* @param params.index Current index. Not mutated.
|
|
110
|
-
* @param params.product Entry to add. `version` is optional; when given it must
|
|
111
|
-
* be `x.y.z`, and when omitted the entry simply has no version.
|
|
112
|
-
* @returns A new, sorted index.
|
|
113
|
-
* @throws {ProductsIndexError} when a product with that name is already there.
|
|
114
|
-
* @throws {InvalidArgumentError} when the arguments are malformed.
|
|
115
|
-
*/
|
|
116
29
|
export declare const addProductToIndex: ({ index, product }: {
|
|
117
30
|
index: ProductsIndex;
|
|
118
31
|
product: ProductsIndexEntry;
|
|
119
32
|
}) => ProductsIndex;
|
|
120
|
-
/**
|
|
121
|
-
* Renames a product in the index, keeping its `repositorio` and its `version`.
|
|
122
|
-
*
|
|
123
|
-
* Note the repository path is intentionally left untouched: renaming a GitLab
|
|
124
|
-
* project does not necessarily move it, and linea-server is the only component
|
|
125
|
-
* that knows the new path. It should follow up with the real value if it changed.
|
|
126
|
-
*
|
|
127
|
-
* @param params.index Current index. Not mutated.
|
|
128
|
-
* @param params.from Current product name.
|
|
129
|
-
* @param params.to New product name.
|
|
130
|
-
* @returns A new, sorted index.
|
|
131
|
-
* @throws {ProductsIndexError} when `from` is missing or `to` already exists.
|
|
132
|
-
* @throws {InvalidArgumentError} when the arguments are malformed.
|
|
133
|
-
*/
|
|
134
33
|
export declare const renameProductInIndex: ({ index, from, to }: {
|
|
135
34
|
index: ProductsIndex;
|
|
136
35
|
from: string;
|
|
137
36
|
to: string;
|
|
138
37
|
}) => ProductsIndex;
|
|
139
|
-
/**
|
|
140
|
-
* Removes a product from the index.
|
|
141
|
-
*
|
|
142
|
-
* IDEMPOTENT: removing a product that is not there returns an equivalent index
|
|
143
|
-
* instead of throwing, so a retried or replayed delete cannot fail half-way.
|
|
144
|
-
*
|
|
145
|
-
* @param params.index Current index. Not mutated.
|
|
146
|
-
* @param params.name Product to remove.
|
|
147
|
-
* @returns A new, sorted index.
|
|
148
|
-
* @throws {InvalidArgumentError} when the arguments are malformed.
|
|
149
|
-
*/
|
|
150
38
|
export declare const removeProductFromIndex: ({ index, name }: {
|
|
151
39
|
index: ProductsIndex;
|
|
152
40
|
name: string;
|
|
153
41
|
}) => ProductsIndex;
|
|
154
|
-
/**
|
|
155
|
-
* Reads the index of a line working directory.
|
|
156
|
-
*
|
|
157
|
-
* A line with no `products.json` is a line with no products, not an error: the
|
|
158
|
-
* file only appears once the first product is created, and every line predating
|
|
159
|
-
* ADR-011 lacks it. A file that EXISTS but is corrupt is a different story and
|
|
160
|
-
* does throw — silently treating it as empty would let linea-server commit a
|
|
161
|
-
* fresh index over a real one and lose the product list.
|
|
162
|
-
*
|
|
163
|
-
* @param params.lineDir Root of the line working directory.
|
|
164
|
-
* @returns The index, or an empty one when the file is absent.
|
|
165
|
-
* @throws {ProductsIndexError} when the file exists but is malformed.
|
|
166
|
-
*/
|
|
167
42
|
export declare const readProductsIndex: ({ lineDir }: {
|
|
168
43
|
lineDir: string;
|
|
169
44
|
}) => ProductsIndex;
|
|
170
|
-
/**
|
|
171
|
-
* Writes the index of a line working directory, creating it if needed.
|
|
172
|
-
*
|
|
173
|
-
* @param params.lineDir Root of the line working directory.
|
|
174
|
-
* @param params.index The index to write.
|
|
175
|
-
* @returns The absolute path written.
|
|
176
|
-
* @throws {InvalidArgumentError} when the arguments are malformed.
|
|
177
|
-
*/
|
|
178
45
|
export declare const writeProductsIndex: ({ lineDir, index }: {
|
|
179
46
|
lineDir: string;
|
|
180
47
|
index: ProductsIndex;
|
|
181
48
|
}) => {
|
|
182
49
|
path: string;
|
|
183
50
|
};
|
|
184
|
-
/** Outcome of reconciling an index against the repositories actually observed. */
|
|
185
51
|
export interface ProductsIndexReconciliation {
|
|
186
|
-
/** The index with the newly discovered repositories added. */
|
|
187
52
|
readonly index: ProductsIndex;
|
|
188
|
-
/**
|
|
189
|
-
* Entries added because a repository existed but was not indexed. They carry
|
|
190
|
-
* a `version` only if the caller observed one.
|
|
191
|
-
*/
|
|
192
53
|
readonly added: ProductsIndexEntry[];
|
|
193
|
-
/**
|
|
194
|
-
* Entries indexed but with no observed repository.
|
|
195
|
-
*
|
|
196
|
-
* REPORTED ONLY — they stay in `index`. The monolith's `prune` archived such
|
|
197
|
-
* rows in Mongo; without a database, dropping them here would silently destroy
|
|
198
|
-
* the record of a product whose repository the caller merely could not see
|
|
199
|
-
* (a permissions hiccup, a partial listing). linea-server decides.
|
|
200
|
-
*/
|
|
201
54
|
readonly removed: ProductsIndexEntry[];
|
|
202
55
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Reconciles an index against the repositories a caller actually observed.
|
|
205
|
-
*
|
|
206
|
-
* Adapted from the `reconcile*` pair of the monolith, which discovers GitLab
|
|
207
|
-
* projects by topic and creates the rows that are missing.
|
|
208
|
-
*
|
|
209
|
-
* Versions already recorded in the index are preserved verbatim, exactly like
|
|
210
|
-
* `repositorio`: the observation the caller makes is "this repository exists",
|
|
211
|
-
* not "this is the product's version", so it never overwrites what is indexed.
|
|
212
|
-
* A newly added entry keeps the `version` the caller supplied, if any.
|
|
213
|
-
*
|
|
214
|
-
* @param params.index Current index. Not mutated.
|
|
215
|
-
* @param params.repositories Repositories observed, as `{ name, repositorio }`
|
|
216
|
-
* plus an optional `version`. linea-server builds this from GitLab; linea-core
|
|
217
|
-
* never looks.
|
|
218
|
-
* @returns The reconciled index plus what was added and what is missing.
|
|
219
|
-
* @throws {InvalidArgumentError} when the arguments are malformed.
|
|
220
|
-
*/
|
|
221
56
|
export declare const reconcileProductsIndex: ({ index, repositories }: {
|
|
222
57
|
index: ProductsIndex;
|
|
223
58
|
repositories: readonly ProductsIndexEntry[];
|