@contractspec/lib.contracts-transformers 3.7.6 → 3.7.10
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 +41 -73
- package/dist/browser/index.js +900 -896
- package/dist/browser/openapi/index.js +965 -961
- package/dist/index.d.ts +1 -1
- package/dist/index.js +900 -896
- package/dist/node/index.js +900 -896
- package/dist/node/openapi/index.js +965 -961
- package/dist/openapi/differ.d.ts +1 -1
- package/dist/openapi/exporter/index.d.ts +7 -7
- package/dist/openapi/exporter/presentations.d.ts +1 -1
- package/dist/openapi/exporter.d.ts +2 -2
- package/dist/openapi/importer/events.d.ts +1 -1
- package/dist/openapi/importer/generator.d.ts +2 -2
- package/dist/openapi/importer/index.d.ts +5 -5
- package/dist/openapi/importer/models.d.ts +1 -1
- package/dist/openapi/index.d.ts +5 -5
- package/dist/openapi/index.js +965 -961
- package/dist/openapi/parser/index.d.ts +4 -4
- package/dist/openapi/parser/operation.d.ts +1 -1
- package/dist/openapi/parser/resolvers.d.ts +1 -1
- package/dist/openapi/parser/utils.d.ts +1 -1
- package/dist/openapi/schema-converter.d.ts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,95 +1,63 @@
|
|
|
1
1
|
# @contractspec/lib.contracts-transformers
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**Contract format transformations: import/export between ContractSpec and external formats (OpenAPI, AsyncAPI, etc.).**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What It Provides
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
9
|
+
- **Layer**: lib.
|
|
10
|
+
- **Consumers**: `lib.contracts-spec`, bundles, CLI.
|
|
11
|
+
- Related ContractSpec packages include `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
12
|
+
- Related ContractSpec packages include `@contractspec/lib.contracts-spec`, `@contractspec/lib.schema`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
bun add @contractspec/lib.contracts-transformers
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
### Export ContractSpec to OpenAPI
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { openApiForRegistry } from '@contractspec/lib.contracts-transformers/openapi';
|
|
24
|
-
import { OperationSpecRegistry } from '@contractspec/lib.contracts-spec';
|
|
25
|
-
|
|
26
|
-
const registry = new OperationSpecRegistry();
|
|
27
|
-
// ... register your specs ...
|
|
16
|
+
`npm install @contractspec/lib.contracts-transformers`
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
title: 'My API',
|
|
31
|
-
version: '1.0.0',
|
|
32
|
-
description: 'API generated from ContractSpec',
|
|
33
|
-
servers: [{ url: 'https://api.example.com' }],
|
|
34
|
-
});
|
|
35
|
-
```
|
|
18
|
+
or
|
|
36
19
|
|
|
37
|
-
|
|
20
|
+
`bun add @contractspec/lib.contracts-transformers`
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
import { parseOpenApi, importFromOpenApi } from '@contractspec/lib.contracts-transformers/openapi';
|
|
41
|
-
|
|
42
|
-
// Parse OpenAPI from file or URL
|
|
43
|
-
const openApiDoc = await parseOpenApi('./api.yaml');
|
|
44
|
-
// Or from URL
|
|
45
|
-
const openApiDoc = await parseOpenApi('https://api.example.com/openapi.json');
|
|
46
|
-
|
|
47
|
-
// Convert to ContractSpec specs
|
|
48
|
-
const importResult = importFromOpenApi(openApiDoc, {
|
|
49
|
-
prefix: 'myApi',
|
|
50
|
-
tags: ['users', 'orders'], // Optional: filter by tags
|
|
51
|
-
exclude: ['deprecated_endpoint'], // Optional: exclude by operationId
|
|
52
|
-
schemaFormat: 'contractspec', // Optional: 'contractspec' | 'zod' | 'json-schema' | 'graphql'
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// importResult contains generated spec code as strings
|
|
56
|
-
for (const spec of importResult.specs) {
|
|
57
|
-
console.log(spec.name, spec.code);
|
|
58
|
-
}
|
|
59
|
-
```
|
|
22
|
+
## Usage
|
|
60
23
|
|
|
61
|
-
|
|
24
|
+
Import the root entrypoint from `@contractspec/lib.contracts-transformers`, or choose a documented subpath when you only need one part of the package surface.
|
|
62
25
|
|
|
63
|
-
|
|
64
|
-
import { diffSpecs } from '@contractspec/lib.contracts-transformers/openapi';
|
|
26
|
+
## Architecture
|
|
65
27
|
|
|
66
|
-
|
|
28
|
+
- `src/common` is part of the package's public or composition surface.
|
|
29
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
30
|
+
- `src/openapi` is part of the package's public or composition surface.
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
console.log(`${diff.operationId}: ${diff.changes.length} changes`);
|
|
70
|
-
for (const change of diff.changes) {
|
|
71
|
-
console.log(` - ${change.path}: ${change.type}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
32
|
+
## Public Entry Points
|
|
75
33
|
|
|
76
|
-
|
|
34
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
35
|
+
- Export `./common` resolves through `./src/common/index.ts`.
|
|
36
|
+
- Export `./openapi` resolves through `./src/openapi/index.ts`.
|
|
77
37
|
|
|
78
|
-
|
|
38
|
+
## Local Commands
|
|
79
39
|
|
|
80
|
-
- `
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
- `
|
|
40
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
41
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
42
|
+
- `bun run test` — bun test
|
|
43
|
+
- `bun run lint` — bun lint:fix
|
|
44
|
+
- `bun run lint:check` — biome check .
|
|
45
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
46
|
+
- `bun run typecheck` — tsc --noEmit
|
|
47
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
48
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
49
|
+
- `bun run clean` — rimraf dist .turbo
|
|
50
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
51
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
52
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
87
53
|
|
|
88
|
-
##
|
|
54
|
+
## Recent Updates
|
|
89
55
|
|
|
90
|
-
|
|
56
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
91
57
|
|
|
92
|
-
|
|
93
|
-
- gRPC/Protobuf
|
|
94
|
-
- GraphQL Schema
|
|
58
|
+
## Notes
|
|
95
59
|
|
|
60
|
+
- Core logic must be pure functions with no I/O.
|
|
61
|
+
- Preserve original transport metadata (path/query/header params) for accurate round-trips.
|
|
62
|
+
- Track provenance — where specs came from — for sync operations.
|
|
63
|
+
- `@contractspec/lib.contracts-spec` re-exports this library for existing consumers; avoid breaking that contract.
|