@pgomes13/drift-guard 2.6.4 → 3.0.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.
Files changed (2) hide show
  1. package/README.md +133 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # @pgomes13/drift-guard
2
+
3
+ API schema diff engine — detect breaking changes in **OpenAPI**, **GraphQL**, and **gRPC** schemas.
4
+
5
+ Thin npm wrapper around the [`drift-guard`](https://github.com/pgomes13/drift-guard-engine) Go binary. On install, the correct pre-built binary for your platform is downloaded automatically.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @pgomes13/drift-guard
11
+ ```
12
+
13
+ Requires Node.js ≥ 16. The binary is downloaded for your platform (macOS arm64/amd64, Linux arm64/amd64, Windows amd64) during `npm install`.
14
+
15
+ ## CLI
16
+
17
+ After installing, the `drift-guard` binary is available as an npm bin:
18
+
19
+ ```sh
20
+ npx drift-guard --help
21
+ ```
22
+
23
+ ### OpenAPI
24
+
25
+ ```sh
26
+ drift-guard openapi --base old.yaml --head new.yaml
27
+ drift-guard openapi --base old.yaml --head new.yaml --format json
28
+ drift-guard openapi --base old.yaml --head new.yaml --fail-on-breaking
29
+ ```
30
+
31
+ ### GraphQL
32
+
33
+ ```sh
34
+ drift-guard graphql --base old.graphql --head new.graphql
35
+ drift-guard graphql --base old.graphql --head new.graphql --format markdown
36
+ ```
37
+
38
+ ### gRPC / Protobuf
39
+
40
+ ```sh
41
+ drift-guard grpc --base old.proto --head new.proto
42
+ drift-guard grpc --base old.proto --head new.proto --format json
43
+ ```
44
+
45
+ ### Impact analysis
46
+
47
+ Scan source code for references to each breaking change:
48
+
49
+ ```sh
50
+ # From a saved diff JSON
51
+ drift-guard openapi --base old.yaml --head new.yaml --format json > diff.json
52
+ drift-guard impact --diff diff.json --scan ./src
53
+
54
+ # Pipe mode
55
+ drift-guard openapi --base old.yaml --head new.yaml --format json \
56
+ | drift-guard impact --scan ./src
57
+
58
+ # Output as markdown
59
+ drift-guard impact --diff diff.json --scan ./src --format markdown
60
+ ```
61
+
62
+ ## Node.js / TypeScript API
63
+
64
+ ```ts
65
+ import { compareOpenAPI, compareGraphQL, compareGRPC, impact } from "@pgomes13/drift-guard";
66
+
67
+ // Diff two OpenAPI schemas
68
+ const result = compareOpenAPI("old.yaml", "new.yaml");
69
+ console.log(result.summary);
70
+ // { total: 3, breaking: 1, non_breaking: 2, info: 0 }
71
+
72
+ // Diff two GraphQL schemas
73
+ const gqlResult = compareGraphQL("old.graphql", "new.graphql");
74
+
75
+ // Diff two Protobuf schemas
76
+ const grpcResult = compareGRPC("old.proto", "new.proto");
77
+
78
+ // Scan source for references to breaking changes
79
+ const hits = impact(result, "./src");
80
+ // Returns Hit[] — file paths and line numbers that reference each breaking change
81
+
82
+ // Text or markdown report
83
+ const report = impact(result, "./src", { format: "markdown" });
84
+ ```
85
+
86
+ ### CommonJS
87
+
88
+ ```js
89
+ const { compareOpenAPI, impact } = require("@pgomes13/drift-guard");
90
+ ```
91
+
92
+ ## TypeScript types
93
+
94
+ ```ts
95
+ type Severity = "breaking" | "non-breaking" | "info";
96
+
97
+ interface Change {
98
+ type: string; // e.g. "endpoint_removed", "field_type_changed"
99
+ severity: Severity;
100
+ path: string; // e.g. "/users/{id}"
101
+ method: string; // e.g. "DELETE"
102
+ location: string;
103
+ description: string;
104
+ before?: string;
105
+ after?: string;
106
+ }
107
+
108
+ interface Summary {
109
+ total: number;
110
+ breaking: number;
111
+ non_breaking: number;
112
+ info: number;
113
+ }
114
+
115
+ interface DiffResult {
116
+ base_file: string;
117
+ head_file: string;
118
+ changes: Change[];
119
+ summary: Summary;
120
+ }
121
+
122
+ interface Hit {
123
+ file: string;
124
+ line_num: number;
125
+ line: string;
126
+ change_type: string; // e.g. "endpoint_removed"
127
+ change_path: string; // e.g. "DELETE /users/{id}"
128
+ }
129
+ ```
130
+
131
+ ## License
132
+
133
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgomes13/drift-guard",
3
- "version": "2.6.4",
3
+ "version": "3.0.0",
4
4
  "description": "API schema diff engine — detect breaking changes in OpenAPI, GraphQL, and gRPC schemas",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "index.d.ts",
16
16
  "run.js",
17
17
  "install.js",
18
- "bin/"
18
+ "bin/",
19
+ "README.md"
19
20
  ],
20
21
  "keywords": [
21
22
  "api",