@cmflow/atlas 3.4.0-alpha.1

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 ADDED
@@ -0,0 +1,132 @@
1
+ <div style="text-align: center" align="center">
2
+ <img src="https://ns.clubmed.com/fbs/RWD/branding2023/Logo/MicrosoftTeams-image%20(9).png" width="200" alt="Club Med"/>
3
+ </div>
4
+
5
+ <div align="center">
6
+ <h1>@cmflow/atlas</h1>
7
+ <hr />
8
+
9
+ [![npm version](https://badge.fury.io/js/%40cmflow%2Fatlas.svg)](https://badge.fury.io/js/%40cmflow%2Fatlas)
10
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
11
+ [![code style: oxfmt](https://img.shields.io/badge/code_style-oxfmt-ef4444.svg?style=flat-square)](https://oxc.rs/docs/guide/usage/formatter)
12
+
13
+ </div>
14
+
15
+ Atlas builds an API-to-backend mapping catalogue from an OpenAPI contract and static TypeScript analysis. It generates a reviewable YAML document per route, can optionally infer unresolved mappings, and synchronizes confirmed mappings with Directus.
16
+
17
+ ## What Atlas produces
18
+
19
+ For each API route, Atlas writes a route-centric YAML document and a companion `.graph.yaml` file. The graph records the resolved path from the API handler to its backends; the YAML records inputs, outputs, mapping evidence and fields that require review.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install --save-dev @cmflow/atlas
25
+ ```
26
+
27
+ ```bash
28
+ yarn add -D @cmflow/atlas
29
+ ```
30
+
31
+ ```bash
32
+ pnpm add -D @cmflow/atlas
33
+ ```
34
+
35
+ ## Initialize a target API project
36
+
37
+ Create `atlas.config.ts` at the root of the API project; it does not belong in the Atlas package.
38
+
39
+ ```bash
40
+ atlas init
41
+ # or create it at an explicit location
42
+ atlas --config /path/to/api/atlas.config.ts init
43
+ ```
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 `--project-root` only to override the API project directory to analyze.
46
+
47
+ The configuration imports `defineConfig` from Atlas:
48
+
49
+ ```ts
50
+ import { defineConfig } from "@cmflow/atlas";
51
+
52
+ export default defineConfig({
53
+ backendTypesFile: "app/_infra/back/BackendTypes.ts",
54
+ openapiUrl: "https://api.example.com/openapi.json",
55
+ openapiTimeoutMs: 60_000,
56
+ directusUrl: "https://cms.api.clubmed"
57
+ });
58
+ ```
59
+
60
+ Create a `.env.local` in the target API project when pushing to Directus:
61
+
62
+ ```dotenv
63
+ DIRECTUS_URL=https://****
64
+ DIRECTUS_TOKEN=replace-with-a-static-token
65
+ ```
66
+
67
+ ## Workflow
68
+
69
+ Generate the topology first, then the route catalogue:
70
+
71
+ ```bash
72
+ atlas --project-root /path/to/api generate:graph
73
+ atlas --project-root /path/to/api generate:catalogue --output .tmp/datasource-catalogue
74
+ ```
75
+
76
+ 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`.
77
+
78
+ Check configured coverage baselines:
79
+
80
+ ```bash
81
+ atlas --project-root /path/to/api generate:test
82
+ ```
83
+
84
+ Review unresolved mappings or run optional AI inference:
85
+
86
+ ```bash
87
+ atlas --project-root /path/to/api needs-review --sort percentage --limit 25
88
+ atlas --project-root /path/to/api infer .tmp/datasource-catalogue
89
+ ```
90
+
91
+ 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.
92
+
93
+ Push route artifacts to Directus with an explicit write flag:
94
+
95
+ ```bash
96
+ atlas --project-root /path/to/api push .tmp/datasource-catalogue --write
97
+ ```
98
+
99
+ Without `--write`, the command performs a dry run. Use `clean-orphans` to inspect Directus links that no longer reference an API or backend property.
100
+
101
+ ## Command reference
102
+
103
+ ```text
104
+ atlas init Create atlas.config.ts
105
+ atlas generate:graph Trace API routes to backends
106
+ atlas generate:catalogue [route] Generate route review documents
107
+ atlas generate:test Check configured coverage baselines
108
+ atlas needs-review Rank unresolved routes
109
+ atlas infer [route|directory] Optionally enrich unresolved mappings
110
+ atlas push [directory|route] Preview or push mappings to Directus
111
+ atlas clean-orphans Inspect or delete orphaned Directus links
112
+ atlas report:changed Report coverage for changed routes
113
+ ```
114
+
115
+ ## CI
116
+
117
+ The recommended static CI flow is `generate:graph`, `generate:catalogue`, then `push`. Do not run optional inference in CI. Supply `DIRECTUS_URL` and `DIRECTUS_TOKEN` through the CI secret context; skip the push if either value is absent.
118
+
119
+ ## Development
120
+
121
+ From the monorepo root:
122
+
123
+ ```bash
124
+ yarn workspace @cmflow/atlas build
125
+ yarn workspace @cmflow/atlas test
126
+ ```
127
+
128
+ ## License
129
+
130
+ LicenseThe MIT License (MIT)Copyright (c) 2016 - Today ClubMed
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.