@company-semantics/contracts 0.13.0 → 0.15.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.
- package/package.json +5 -1
- package/src/compatibility.ts +35 -0
- package/src/guards/config.ts +77 -0
- package/src/guards/index.ts +3 -0
- package/src/index.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./src/guards/index.ts",
|
|
17
17
|
"default": "./src/guards/index.ts"
|
|
18
18
|
},
|
|
19
|
+
"./compatibility": {
|
|
20
|
+
"types": "./src/compatibility.ts",
|
|
21
|
+
"default": "./src/compatibility.ts"
|
|
22
|
+
},
|
|
19
23
|
"./schemas/guard-result.schema.json": "./schemas/guard-result.schema.json"
|
|
20
24
|
},
|
|
21
25
|
"types": "./src/index.ts",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts Compatibility Manifest
|
|
3
|
+
*
|
|
4
|
+
* Machine-readable version policy for CI guards.
|
|
5
|
+
* Enables consumer repos to programmatically validate their installed version.
|
|
6
|
+
*
|
|
7
|
+
* @see ADR-2025-12-011 in DECISIONS.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Deprecation entry for a semver range.
|
|
12
|
+
* Consumers matching this range will receive advisory warnings.
|
|
13
|
+
*/
|
|
14
|
+
export interface Deprecation {
|
|
15
|
+
/** Semver range (e.g., "0.12.x") */
|
|
16
|
+
range: string
|
|
17
|
+
/** Human-readable reason for deprecation */
|
|
18
|
+
reason: string
|
|
19
|
+
/** Version in which support will be removed */
|
|
20
|
+
removeIn: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compatibility manifest exported as data.
|
|
25
|
+
* CI guards read this to determine freshness warnings/errors.
|
|
26
|
+
*/
|
|
27
|
+
export const COMPATIBILITY = {
|
|
28
|
+
/** Minimum version that all consumers should use */
|
|
29
|
+
minSupported: '0.14.0',
|
|
30
|
+
|
|
31
|
+
/** Versions that still work but should upgrade (with reasons) */
|
|
32
|
+
deprecations: [] as Deprecation[],
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
export type Compatibility = typeof COMPATIBILITY
|
package/src/guards/config.ts
CHANGED
|
@@ -136,6 +136,68 @@ export type GuardCheckFactory = (
|
|
|
136
136
|
*/
|
|
137
137
|
export type BoundGuardCheck = () => Promise<CheckResult> | CheckResult;
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Contracts freshness baseline configuration.
|
|
141
|
+
* Consumer repos import COMPATIBILITY from contracts and pass it here.
|
|
142
|
+
*
|
|
143
|
+
* @see ADR-2025-12-014 for design rationale
|
|
144
|
+
*/
|
|
145
|
+
export interface ContractsFreshnessBaseline {
|
|
146
|
+
/** Path to lockfile relative to repo root (e.g., 'pnpm-lock.yaml') */
|
|
147
|
+
lockfilePath: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Compatibility manifest from @company-semantics/contracts.
|
|
151
|
+
* Import and pass directly: `import { COMPATIBILITY } from '@company-semantics/contracts'`
|
|
152
|
+
*/
|
|
153
|
+
compatibility: {
|
|
154
|
+
minSupported: string;
|
|
155
|
+
deprecations: readonly { range: string; reason: string; removeIn: string }[];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Skip this guard. Use for repos with workspace:* dependency (always current).
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
skip?: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Scripts-devDependencies guard configuration.
|
|
167
|
+
* Checks that tools used in package.json scripts are declared in devDependencies.
|
|
168
|
+
*/
|
|
169
|
+
export interface ScriptsDepsBaseline {
|
|
170
|
+
/** Path to package.json relative to repo root */
|
|
171
|
+
packageJsonPath: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Additional tools to exempt from checking.
|
|
175
|
+
* Runtime-provided tools (node, pnpm, npm, npx) are always exempt.
|
|
176
|
+
*/
|
|
177
|
+
exempt?: string[];
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* If true, violations are errors. If false, violations are warnings.
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
strict?: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Structural guard baselines.
|
|
188
|
+
* Product repos provide DATA only; CI orchestrator owns guard implementations.
|
|
189
|
+
*
|
|
190
|
+
* Design invariant: Product repos must NEVER import CI guard code.
|
|
191
|
+
* They export baselines; CI injects guards at runtime.
|
|
192
|
+
*/
|
|
193
|
+
export interface StructuralBaselines {
|
|
194
|
+
/**
|
|
195
|
+
* Scripts-devDependencies check configuration.
|
|
196
|
+
* CI injects checkScriptsDeps based on this config.
|
|
197
|
+
*/
|
|
198
|
+
scriptsDeps?: ScriptsDepsBaseline;
|
|
199
|
+
}
|
|
200
|
+
|
|
139
201
|
/**
|
|
140
202
|
* Evolution guard baselines.
|
|
141
203
|
* Product repos provide DATA only; CI orchestrator owns guard implementations.
|
|
@@ -165,6 +227,14 @@ export interface EvolutionBaselines {
|
|
|
165
227
|
/** Max allowed domain file count drift before warning */
|
|
166
228
|
domainDrift?: number;
|
|
167
229
|
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Contracts freshness check configuration.
|
|
233
|
+
* CI injects checkContractsFreshness based on this config.
|
|
234
|
+
*
|
|
235
|
+
* @see ADR-2025-12-014
|
|
236
|
+
*/
|
|
237
|
+
contractsFreshness?: ContractsFreshnessBaseline;
|
|
168
238
|
}
|
|
169
239
|
|
|
170
240
|
/**
|
|
@@ -192,6 +262,13 @@ export interface GuardCheckRegistry {
|
|
|
192
262
|
meta?: BoundGuardCheck[];
|
|
193
263
|
};
|
|
194
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Structural guard baselines.
|
|
267
|
+
* CI orchestrator injects structural guards based on these baselines.
|
|
268
|
+
* Product repos provide data only, never guard implementations.
|
|
269
|
+
*/
|
|
270
|
+
structuralBaselines?: StructuralBaselines;
|
|
271
|
+
|
|
195
272
|
/**
|
|
196
273
|
* Evolution guard baselines.
|
|
197
274
|
* CI orchestrator injects evolution guards based on these baselines.
|
package/src/guards/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -56,6 +56,7 @@ export type {
|
|
|
56
56
|
BoundGuardCheck,
|
|
57
57
|
GuardCheckRegistry,
|
|
58
58
|
EvolutionBaselines,
|
|
59
|
+
ContractsFreshnessBaseline,
|
|
59
60
|
} from './guards/index.js'
|
|
60
61
|
|
|
61
62
|
export {
|
|
@@ -65,3 +66,8 @@ export {
|
|
|
65
66
|
DEFAULT_DOMAIN_SECTIONS,
|
|
66
67
|
DEFAULT_INFRA_SECTIONS,
|
|
67
68
|
} from './guards/index.js'
|
|
69
|
+
|
|
70
|
+
// Compatibility manifest (CI guard vocabulary)
|
|
71
|
+
// @see ADR-2025-12-011 for design rationale
|
|
72
|
+
export { COMPATIBILITY } from './compatibility.js'
|
|
73
|
+
export type { Compatibility, Deprecation } from './compatibility.js'
|