@cmflow/atlas 3.4.0-beta.23 → 3.4.0-beta.25
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 +55 -10
- package/dist/{types-D5fngFrb.d.mts → UserConfig-BlRknCRh.d.mts} +32 -14
- package/dist/bin/atlas.mjs +102 -6776
- package/dist/bin/atlas.mjs.map +1 -1
- package/dist/defineExpressionRule-GhkeHHT8.mjs.map +1 -1
- package/dist/dist-uTuN89Bv.mjs +6950 -0
- package/dist/dist-uTuN89Bv.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +25 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{routeBackendTopologyService-CQyRyoSN.mjs → routeBackendTopologyService-NPO-ZHyY.mjs} +27 -18
- package/dist/{routeBackendTopologyService-CQyRyoSN.mjs.map → routeBackendTopologyService-NPO-ZHyY.mjs.map} +1 -1
- package/dist/rules/lodashGetRule.d.mts +1 -1
- package/dist/rules/mappingUtilityRule.d.mts +1 -1
- package/dist/rules/memberGetFieldRule.d.mts +1 -1
- package/dist/{taskProgressService-CAC_RIoa.mjs → taskProgressService-BRoIJQbK.mjs} +8 -5
- package/dist/taskProgressService-BRoIJQbK.mjs.map +1 -0
- package/dist/workers/routeBackendTopologyWorker.mjs +23 -18
- package/dist/workers/routeBackendTopologyWorker.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/propertyExtractionService-BLat-Hsf.mjs +0 -184
- package/dist/propertyExtractionService-BLat-Hsf.mjs.map +0 -1
- package/dist/taskProgressService-CAC_RIoa.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ atlas init
|
|
|
42
42
|
atlas --config /path/to/api/atlas.config.ts init
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
By default, Atlas loads `atlas.config.ts` from the directory where the command is launched. Use `--config` (or `-c`) to reference another configuration file. Use `--
|
|
45
|
+
By default, Atlas loads `atlas.config.ts` from the directory where the command is launched. Use `--config` (or `-c`) to reference another configuration file. Use `--analysis-dir` only to override the API source directory to analyze.
|
|
46
46
|
|
|
47
47
|
The configuration imports `defineConfig` from Atlas:
|
|
48
48
|
|
|
@@ -50,6 +50,7 @@ The configuration imports `defineConfig` from Atlas:
|
|
|
50
50
|
import { defineConfig } from "@cmflow/atlas";
|
|
51
51
|
|
|
52
52
|
export default defineConfig({
|
|
53
|
+
outputDir: "./tmp/atlas",
|
|
53
54
|
envs: {
|
|
54
55
|
XM_API_URL: "https://xm.example/openapi.json"
|
|
55
56
|
},
|
|
@@ -57,22 +58,47 @@ export default defineConfig({
|
|
|
57
58
|
openapiTimeoutMs: 60_000,
|
|
58
59
|
directusUrl: "https://cms.api.clubmed",
|
|
59
60
|
analysis: {
|
|
61
|
+
rootDir: "./app",
|
|
60
62
|
backends: ["ICC", "CMS", "CMS_B2C"]
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
```
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
`process.cwd()` is always the project root: `outputDir`, `tsconfig.json`, Git paths and serialized source paths are resolved from it. `analysis.rootDir` only defines the source tree to analyze and may therefore point to a subdirectory such as `./app`. Atlas reads `compilerOptions.paths` from the root `tsconfig.json` and uses them as module aliases. Add `resolver.alias` only to override or complement those aliases.
|
|
68
|
+
|
|
69
|
+
`outputDir` is resolved from the project root, not from `analysis.rootDir`. With the configuration above, artifacts are written to `<project-root>/tmp/atlas`, never to `<project-root>/app/tmp/atlas`.
|
|
70
|
+
|
|
71
|
+
Use `analysis.excluded` for project-root-relative technical files that must not enter dependency traversal or `analysis_files`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
analysis: {
|
|
75
|
+
rootDir: "./app",
|
|
76
|
+
excluded: ["tools/build/*-reference.json"],
|
|
77
|
+
backends: [/* ... */]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
66
80
|
|
|
67
81
|
## Backend sources
|
|
68
82
|
|
|
69
|
-
Atlas
|
|
83
|
+
Atlas starts from accesses actually detected in code on a backend reached by the route graph. It then consolidates those code candidates against the canonical properties returned by the matching `BackendSource`. Atlas never creates a confirmed mapping from API field-name similarity alone.
|
|
84
|
+
|
|
85
|
+
For a backend with no configured source, Atlas preserves code candidates for optional AI inference. A configured source is authoritative: only its resolved properties can validate the code access.
|
|
70
86
|
|
|
71
87
|
A backend can be either a string or a `BackendSource` created with `defineBackendSource`:
|
|
72
88
|
|
|
73
89
|
- a string (for example `"ICC"`) has no field reference; Atlas keeps the current code-analysis and optional inference flow;
|
|
74
90
|
- a `BackendSource` provides a `resolve` function that returns the backend's known properties. Atlas assigns its `name` as `backend` on every resolved property.
|
|
75
91
|
|
|
92
|
+
Any backend source can persist its resolved properties in a YAML cache. When the cache exists, Atlas uses it and does not call the remote source. Refresh it explicitly with `atlas backend-source --refresh` (or the compatible `atlas backend-sources --refresh`). Use `atlas backend-sources --refresh --all` to refresh every configured source without an interactive prompt.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
export const xm = defineBackendSource({
|
|
96
|
+
name: "XM",
|
|
97
|
+
cache: `${__dirname}/cache.yaml`,
|
|
98
|
+
resolve: () => openapiSource({ url: "https://xm.example/openapi.json" })
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
76
102
|
When a string and a source share the same name, the last declaration wins. This lets a source enrich a list of backend names, for example `[..., Object.values(BackendTypes), quableBackendSource]`.
|
|
77
103
|
|
|
78
104
|
The resolver returns one of the following shapes. Document-oriented backends have no route; REST backends have no document.
|
|
@@ -94,6 +120,16 @@ type BackendProperty =
|
|
|
94
120
|
|
|
95
121
|
The generated mapping preserves this shape. In particular, `document` is a separate property: Atlas does not turn a Quable field into an artificial path such as `products.product_geographical_area`.
|
|
96
122
|
|
|
123
|
+
## Resolved backend metadata artifacts
|
|
124
|
+
|
|
125
|
+
At the start of `generate:graph` and `generate:catalog`, Atlas resolves every configured backend source and writes its metadata for inspection:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
<outputDir>/backends/<backend>.yaml
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
For example, `<outputDir>/backends/quable_rest.yaml` contains the source name, generation date and canonical properties returned by Quable. Backends declared as strings still receive an artifact with `resolved: false`; this makes missing metadata sources visible during analysis.
|
|
132
|
+
|
|
97
133
|
### Quable
|
|
98
134
|
|
|
99
135
|
Attach rules that are specific to Quable directly to its source. They inherit the source backend automatically and their candidates are validated by the Quable property list.
|
|
@@ -171,6 +207,7 @@ import { constant, defineBackendSource, openapiSource } from "@cmflow/atlas";
|
|
|
171
207
|
|
|
172
208
|
export const xm = defineBackendSource({
|
|
173
209
|
name: "XM",
|
|
210
|
+
cache: `${__dirname}/xm-openapi.yaml`,
|
|
174
211
|
resolve: () =>
|
|
175
212
|
openapiSource({
|
|
176
213
|
url: constant<string>("XM_API_URL", "https://xm.example/openapi.json")
|
|
@@ -294,23 +331,30 @@ DIRECTUS_TOKEN=replace-with-a-static-token
|
|
|
294
331
|
Generate the topology first, then the route catalogue:
|
|
295
332
|
|
|
296
333
|
```bash
|
|
297
|
-
atlas --
|
|
298
|
-
atlas --
|
|
334
|
+
atlas --analysis-dir /path/to/api generate:graph
|
|
335
|
+
atlas --analysis-dir /path/to/api generate:catalog --output .tmp/datasource-catalogue
|
|
299
336
|
```
|
|
300
337
|
|
|
301
338
|
Each route produces a YAML document and a `.graph.yaml` topology artifact. The catalogue requires a valid graph and leaves ambiguous fields marked `needs_review`.
|
|
302
339
|
|
|
340
|
+
When changing `analysis.rootDir`, backend sources or exclusions, regenerate the graph before the catalogue so the route graph and metadata artifacts use the same configuration:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
atlas generate:graph "GET /v2/products"
|
|
344
|
+
atlas generate:catalog "GET /v2/products"
|
|
345
|
+
```
|
|
346
|
+
|
|
303
347
|
Check configured coverage baselines:
|
|
304
348
|
|
|
305
349
|
```bash
|
|
306
|
-
atlas --
|
|
350
|
+
atlas --analysis-dir /path/to/api generate:test
|
|
307
351
|
```
|
|
308
352
|
|
|
309
353
|
Review unresolved mappings or run optional AI inference:
|
|
310
354
|
|
|
311
355
|
```bash
|
|
312
|
-
atlas --
|
|
313
|
-
atlas --
|
|
356
|
+
atlas --analysis-dir /path/to/api needs-review --sort percentage --limit 25
|
|
357
|
+
atlas --analysis-dir /path/to/api infer .tmp/datasource-catalogue
|
|
314
358
|
```
|
|
315
359
|
|
|
316
360
|
The inference pass only reads analysis files referenced by each route graph. Accepted suggestions remain marked `inferred`; suggestions below the configured confidence threshold are retained for manual review.
|
|
@@ -318,7 +362,7 @@ The inference pass only reads analysis files referenced by each route graph. Acc
|
|
|
318
362
|
Push route artifacts to Directus with an explicit write flag:
|
|
319
363
|
|
|
320
364
|
```bash
|
|
321
|
-
atlas --
|
|
365
|
+
atlas --analysis-dir /path/to/api push .tmp/datasource-catalogue --write
|
|
322
366
|
```
|
|
323
367
|
|
|
324
368
|
Without `--write`, the command performs a dry run. Use `clean-orphans` to inspect Directus links that no longer reference an API or backend property.
|
|
@@ -327,7 +371,8 @@ Without `--write`, the command performs a dry run. Use `clean-orphans` to inspec
|
|
|
327
371
|
|
|
328
372
|
```text
|
|
329
373
|
atlas init Create atlas.config.ts
|
|
330
|
-
atlas backend-
|
|
374
|
+
atlas backend-source [--refresh] Display backend metadata; refresh configured source caches when requested
|
|
375
|
+
atlas backend-sources [--refresh] [--all] Compatible plural alias; --all skips the source picker
|
|
331
376
|
atlas generate:graph Trace API routes to backends
|
|
332
377
|
atlas generate:catalog [route] Generate route review documents
|
|
333
378
|
atlas generate:test Check configured coverage baselines
|
|
@@ -16,12 +16,21 @@ type FieldExtractionRule = {
|
|
|
16
16
|
};
|
|
17
17
|
declare function defineExpressionRule(rule: FieldExtractionRule): FieldExtractionRule;
|
|
18
18
|
//#endregion
|
|
19
|
-
//#region src/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
//#region src/interfaces/Direction.d.ts
|
|
20
|
+
type Direction = "input" | "output";
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/interfaces/PropertyLocation.d.ts
|
|
23
|
+
type PropertyLocation = "query" | "path" | "header" | "body";
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/interfaces/PropertyMetadata.d.ts
|
|
26
|
+
interface PropertyMetadata {
|
|
27
|
+
direction?: Direction;
|
|
28
|
+
location?: PropertyLocation;
|
|
29
|
+
type?: string;
|
|
23
30
|
}
|
|
24
|
-
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/interfaces/BackendProperty.d.ts
|
|
33
|
+
type BackendProperty = PropertyMetadata & ({
|
|
25
34
|
document: string;
|
|
26
35
|
field: string;
|
|
27
36
|
description?: string;
|
|
@@ -30,20 +39,27 @@ type BackendProperty = {
|
|
|
30
39
|
method: string;
|
|
31
40
|
field: string;
|
|
32
41
|
description?: string;
|
|
33
|
-
};
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/interfaces/BackendSource.d.ts
|
|
34
45
|
interface BackendSource {
|
|
35
46
|
name: string;
|
|
47
|
+
/** YAML file containing resolved properties. Existing caches are read before calling `resolve`. */
|
|
48
|
+
cache?: string;
|
|
36
49
|
resolve?: () => Promise<BackendProperty[]>;
|
|
37
50
|
rules?: FieldExtractionRule[];
|
|
38
51
|
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/config/interfaces/UserConfig.d.ts
|
|
54
|
+
interface NeutralExpressionMatcher {
|
|
55
|
+
prefix: string;
|
|
56
|
+
apiMapping?: boolean;
|
|
57
|
+
}
|
|
39
58
|
interface UserConfig {
|
|
40
59
|
/** Values injectable into backend source resolvers through `constant`. */
|
|
41
60
|
envs?: Record<string, unknown>;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
* Can be set via the ATLAS_CWD environment variable.
|
|
45
|
-
*/
|
|
46
|
-
repoRoot?: string;
|
|
61
|
+
/** Directory where Atlas writes generated graph and catalogue artifacts, resolved from `process.cwd()`. */
|
|
62
|
+
outputDir: string;
|
|
47
63
|
/**
|
|
48
64
|
* Default OpenAPI document URL used to extract the public contract exposed by the API.
|
|
49
65
|
* The CLI can still override this value with `--openapi-url`.
|
|
@@ -80,10 +96,12 @@ interface UserConfig {
|
|
|
80
96
|
* Static analysis options used to keep generated artifacts focused on business-relevant files and fields.
|
|
81
97
|
*/
|
|
82
98
|
analysis: {
|
|
99
|
+
/** Directory containing the application source tree to analyze, resolved from `process.cwd()`. */
|
|
100
|
+
rootDir: string;
|
|
83
101
|
/** Backend identifiers used by the API project. */
|
|
84
102
|
backends: Array<string | BackendSource>;
|
|
85
103
|
/**
|
|
86
|
-
* Glob patterns excluded from `analysis_files`.
|
|
104
|
+
* Glob patterns, relative to the project working directory, excluded from `analysis_files`.
|
|
87
105
|
* Use this to hide technical plumbing files that add noise to route review documents.
|
|
88
106
|
*/
|
|
89
107
|
excluded: string[];
|
|
@@ -120,5 +138,5 @@ interface UserConfig {
|
|
|
120
138
|
};
|
|
121
139
|
}
|
|
122
140
|
//#endregion
|
|
123
|
-
export { defineExpressionRule as a, FieldExtractionRule as i, BackendSource as n,
|
|
124
|
-
//# sourceMappingURL=
|
|
141
|
+
export { defineExpressionRule as a, FieldExtractionRule as i, BackendSource as n, BackendProperty as r, UserConfig as t };
|
|
142
|
+
//# sourceMappingURL=UserConfig-BlRknCRh.d.mts.map
|