micro-contracts 0.17.13 → 0.17.15
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 +25 -0
- package/cli-contract.yaml +1 -1
- package/dist/external/insight-provider.js +2 -4
- package/dist/micro-contracts.bundle.mjs +344 -342
- package/dist/micro-contracts.bundle.mjs.map +4 -4
- package/docs/cli-reference.md +30 -30
- package/docs/development-guardrails.md +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -288,6 +288,17 @@ Create `micro-contracts.config.yaml`. All paths support `{module}` placeholder.
|
|
|
288
288
|
| `docs.enabled` | boolean | no | Enable documentation generation (default: `true`) |
|
|
289
289
|
| `docs.template` | string | no | Documentation template |
|
|
290
290
|
| `sharedModuleName` | string | no | Shared module name for overlays |
|
|
291
|
+
| `server.output` | string | no | Output **file** path for generated routes (default: `server/src/{module}/routes.generated.ts`) |
|
|
292
|
+
| `server.template` | string | yes if `server` is declared | Handlebars template for the routes file |
|
|
293
|
+
| `server.servicesPath` | string | no | Path to the services object in Fastify (default: `fastify.services.{module}`) |
|
|
294
|
+
| `frontend.output` | string | no | Output **directory** for the client files (default: `frontend/src/{module}`) |
|
|
295
|
+
| `frontend.template` | string | yes if `frontend` is declared | Handlebars template for the client file |
|
|
296
|
+
| `frontend.client` | string | no | Client file name (default: `api.generated.ts`) |
|
|
297
|
+
| `frontend.service` | string | no | Service re-exports file name (default: `service.generated.ts`) |
|
|
298
|
+
|
|
299
|
+
`server` and `frontend` are the built-in equivalents of an `outputs` entry, kept for
|
|
300
|
+
existing configs. They generate only when declared, and only when no `outputs` entry
|
|
301
|
+
is configured — `outputs` supersedes them for a module. Prefer `outputs`.
|
|
291
302
|
|
|
292
303
|
### modules.\<name\>
|
|
293
304
|
|
|
@@ -304,6 +315,12 @@ Create `micro-contracts.config.yaml`. All paths support `{module}` placeholder.
|
|
|
304
315
|
| `dependsOn` | string[] | no | Dependencies (`{module}.{service}.{method}`) |
|
|
305
316
|
| `spectral` | string | no | Module-specific Spectral config path |
|
|
306
317
|
| `docs.enabled` | boolean | no | Override documentation generation |
|
|
318
|
+
| `server.*` | — | no | Override any `defaults.server` field |
|
|
319
|
+
| `server.enabled` | boolean | no | Disable built-in server generation for this module |
|
|
320
|
+
| `frontend.*` | — | no | Override any `defaults.frontend` field |
|
|
321
|
+
| `frontend.enabled` | boolean | no | Disable built-in frontend generation for this module |
|
|
322
|
+
|
|
323
|
+
Unknown keys are rejected: a mistyped key fails the run instead of being ignored.
|
|
307
324
|
|
|
308
325
|
### Example
|
|
309
326
|
|
|
@@ -380,6 +397,14 @@ Lint OpenAPI specification.
|
|
|
380
397
|
|--------|-------------|
|
|
381
398
|
| `--strict` | Treat warnings as errors |
|
|
382
399
|
|
|
400
|
+
Every operation requires `x-micro-contracts-service` and `x-micro-contracts-method`,
|
|
401
|
+
and both must be valid TypeScript identifiers: they key route collection and service
|
|
402
|
+
grouping, and are emitted verbatim into generated type names. Operations missing them
|
|
403
|
+
would be dropped from every artifact, so they are errors (`MISSING_X_SERVICE`,
|
|
404
|
+
`MISSING_X_METHOD`, `INVALID_X_SERVICE`, `INVALID_X_METHOD`). In screen spec mode
|
|
405
|
+
(`screen: true`) operations are consumed via `TemplateContext.screens` and these rules
|
|
406
|
+
do not apply.
|
|
407
|
+
|
|
383
408
|
### check
|
|
384
409
|
|
|
385
410
|
Run guardrail checks.
|
package/cli-contract.yaml
CHANGED
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
|
-
import { createRequire } from "module";
|
|
8
7
|
import { loadConfig, loadOpenAPISpec } from "../generator/index.js";
|
|
9
8
|
import { extractDependencies } from "../types.js";
|
|
10
9
|
import { isMultiModuleConfig, resolveModuleConfig } from "../types.js";
|
|
11
|
-
|
|
12
|
-
const pkg = require("../../package.json");
|
|
10
|
+
import { VERSION } from "../version.js";
|
|
13
11
|
export const MICRO_CONTRACTS_INSIGHT_SOURCE = "micro-contracts";
|
|
14
12
|
const EVIDENCE_KIND = "api_contract_declaration";
|
|
15
13
|
const EDGE_WEIGHT = 0.9;
|
|
@@ -225,7 +223,7 @@ export function buildExternalInsight(projectRoot, options = {}) {
|
|
|
225
223
|
}
|
|
226
224
|
return {
|
|
227
225
|
source: MICRO_CONTRACTS_INSIGHT_SOURCE,
|
|
228
|
-
sourceVersion:
|
|
226
|
+
sourceVersion: VERSION,
|
|
229
227
|
generatedAt: new Date().toISOString(),
|
|
230
228
|
edges,
|
|
231
229
|
anchorMapping: [...anchorByDomain.values()],
|