@manya-os/contracts 1.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.
- package/CHANGELOG.md +19 -0
- package/LICENSE +20 -0
- package/README.md +223 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +6 -0
- package/dist/esm/package.json +1 -0
- package/dist/types/api/api.d.ts +43 -0
- package/dist/types/api/api.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/index.d.ts.map +1 -0
- package/dist/types/boundaries/boundaries.d.ts +62 -0
- package/dist/types/boundaries/boundaries.d.ts.map +1 -0
- package/dist/types/boundaries/index.d.ts +3 -0
- package/dist/types/boundaries/index.d.ts.map +1 -0
- package/dist/types/compatibility/compatibility.d.ts +58 -0
- package/dist/types/compatibility/compatibility.d.ts.map +1 -0
- package/dist/types/compatibility/index.d.ts +2 -0
- package/dist/types/compatibility/index.d.ts.map +1 -0
- package/dist/types/errors.d.ts +65 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logging.d.ts +38 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/manifest/index.d.ts +2 -0
- package/dist/types/manifest/index.d.ts.map +1 -0
- package/dist/types/manifest/manifest.d.ts +24 -0
- package/dist/types/manifest/manifest.d.ts.map +1 -0
- package/dist/types/reporting/index.d.ts +2 -0
- package/dist/types/reporting/index.d.ts.map +1 -0
- package/dist/types/reporting/reporting.d.ts +37 -0
- package/dist/types/reporting/reporting.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +3 -0
- package/dist/types/schema/index.d.ts.map +1 -0
- package/dist/types/schema/schema.d.ts +77 -0
- package/dist/types/schema/schema.d.ts.map +1 -0
- package/dist/types/sync/index.d.ts +2 -0
- package/dist/types/sync/index.d.ts.map +1 -0
- package/dist/types/sync/sync.d.ts +36 -0
- package/dist/types/sync/sync.d.ts.map +1 -0
- package/dist/types/types.d.ts +215 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +47 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@manya/contracts` are documented here.
|
|
4
|
+
Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Adheres to [SemVer](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [1.0.0] — 2024-01-15
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release.
|
|
9
|
+
- Schema definition language: `compileSchema` (record or array field syntax) and `validateValue` for all 10 type kinds (string, number, boolean, null, object, array, enum, ref, union, intersection).
|
|
10
|
+
- Manifest validation (`validateManifest`, `assertManifest`, `isValidManifest`) with one stable code per failure mode.
|
|
11
|
+
- Semver parsing (`parseSemver`, `isSemver`), comparison (`compareSemver`, `compareParsedSemver`) with full prerelease handling per semver.org §11, range satisfaction (`satisfies`) supporting `*`, `^`, `~`, exact, and comparison operators.
|
|
12
|
+
- Backward-compatibility analysis (`checkBackwardCompat`) detecting field removal, type change, required addition, and enum value removal.
|
|
13
|
+
- API contract validation: `findEndpoint`, `validateRequest`, `validateResponse`, `assertValidContract`.
|
|
14
|
+
- Schema synchronization: `diffSchemas` (added/removed/changed), `mergeSchemas` with conflict detection and `fieldsEqual` deep equality.
|
|
15
|
+
- Boundary enforcement: `enforceBoundary` (with `*` wildcards), `detectViolations` over a call graph, `matchRule`, `isPolicySatisfied`.
|
|
16
|
+
- Validation reports: `buildReport`, `aggregateReports`, `serializeReport` (JSON), `summarizeReport` (one-line).
|
|
17
|
+
- Typed error hierarchy: `ContractsError`, `SchemaError`, `ManifestError` (with `MANIFEST_ERROR_CODES`), `CompatibilityError`, `ApiValidationError`, `SyncError`, `BoundaryError`, `ReportingError`.
|
|
18
|
+
- Structured logging: `Logger`, `ConsoleLogger` with secret scrubbing, `SilentLogger`, `scrubMetadata`, `shouldScrubField`, `SCRUBBED_FIELD_NAMES`.
|
|
19
|
+
- Comprehensive unit test suite (99 tests).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
6
|
+
|
|
7
|
+
Conceived, directed, and owned by Uviwe Menyiwe (Azura Daemon),
|
|
8
|
+
founder of the Manya Hael Foundation.
|
|
9
|
+
|
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
you may not use this file except in compliance with the License.
|
|
12
|
+
You may obtain a copy of the License at
|
|
13
|
+
|
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
|
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
See the License for the specific language governing permissions and
|
|
20
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# @manya/contracts
|
|
2
|
+
|
|
3
|
+
> Universal contract and schema validation for the MANYA Intelligence OS — interface schemas, manifests, semver compatibility, API contracts, schema sync, boundary enforcement, and validation reports.
|
|
4
|
+
|
|
5
|
+
`@manya/contracts` is the contract substrate of the **MANYA Intelligence OS** — a sovereign, modular, local-first intelligence operating system conceived, directed, and owned by **Uviwe Menyiwe (Azura Daemon)**, founder of the **Manya Hael Foundation**.
|
|
6
|
+
|
|
7
|
+
The package provides a JSON-ish schema definition language with a typed compiler, manifest validation, full semver parsing and range satisfaction, backward-compatibility analysis between two schema versions, HTTP API contract validation, schema diffing and merging with conflict detection, module boundary enforcement via policies, and aggregated validation reports.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Vision
|
|
12
|
+
|
|
13
|
+
The Manya Hael Foundation stewards the MANYA Intelligence OS as a long-horizon, mission-driven project. `@manya/contracts` extends that sovereignty into the contract domain: **your interfaces, your versioning rules, your boundary policy — yours alone.**
|
|
14
|
+
|
|
15
|
+
- **Sovereign.** No network calls. Every schema, manifest, and policy is local.
|
|
16
|
+
- **Typed.** Every public symbol is typed; every error carries a stable `code` string.
|
|
17
|
+
- **Composable.** Validation results are first-class values that aggregate into reports.
|
|
18
|
+
- **Reproducible.** Identical inputs produce identical validation results and reports.
|
|
19
|
+
- **Honest.** Breaking changes are listed explicitly; conflicts surface a `resolution` hint.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
| Area | What you get |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| **Schema** | `compileSchema` (record or array field syntax, defaults `required: true`), `validateValue` against 10 type kinds (string/number/boolean/null/object/array/enum/ref/union/intersection). |
|
|
28
|
+
| **Manifest** | `validateManifest` for name, version (semver), dependencies, exports, imports, capabilities — with one stable code per failure mode. |
|
|
29
|
+
| **Compatibility** | `parseSemver`, `compareSemver` (with prerelease per semver.org §11), `satisfies` (`*`, `^`, `~`, exact, `>`, `>=`, `<`, `<=`), `checkBackwardCompat` detecting field removal, type change, required addition, enum value removal. |
|
|
30
|
+
| **API** | `ApiContract` + `ApiEndpoint`, `findEndpoint`, `validateRequest`, `validateResponse`, `assertValidContract`. |
|
|
31
|
+
| **Sync** | `diffSchemas` (added/removed/changed), `mergeSchemas` with conflict detection, `fieldsEqual` deep equality. |
|
|
32
|
+
| **Boundaries** | `BoundaryPolicy` + `BoundaryRule`, `enforceBoundary` (with `*` wildcards), `detectViolations` over a call graph, `isPolicySatisfied`. |
|
|
33
|
+
| **Reporting** | `buildReport`, `aggregateReports`, `serializeReport` (JSON), `summarizeReport` (one-line). |
|
|
34
|
+
| **Logging** | `Logger` interface, `ConsoleLogger` with secret-scrubbing, `SilentLogger`. |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @manya/contracts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Requires Node.js 18+.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
### 1. Define a schema and validate a value
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { compileSchema, validateValue } from '@manya/contracts';
|
|
54
|
+
|
|
55
|
+
const User = compileSchema({
|
|
56
|
+
name: 'User', version: '1.0.0',
|
|
57
|
+
fields: {
|
|
58
|
+
id: { type: 'string', description: 'User id.' },
|
|
59
|
+
age: { type: 'number', required: false },
|
|
60
|
+
active: { type: 'boolean' },
|
|
61
|
+
role: { type: 'enum', enum: ['admin', 'user'] },
|
|
62
|
+
tags: { type: 'array', of: { type: 'string' }, required: false },
|
|
63
|
+
profile: {
|
|
64
|
+
type: 'object', required: false,
|
|
65
|
+
fields: { bio: { type: 'string', required: false } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const result = validateValue(User, {
|
|
71
|
+
id: 'u1', age: 30, active: true, role: 'admin', tags: ['x'],
|
|
72
|
+
});
|
|
73
|
+
console.log(result.valid); // true
|
|
74
|
+
console.log(result.errors); // []
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Validate a manifest and check version compatibility
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { validateManifest, satisfies, checkBackwardCompat } from '@manya/contracts';
|
|
81
|
+
|
|
82
|
+
const m = validateManifest({
|
|
83
|
+
name: '@manya/example', version: '1.2.3',
|
|
84
|
+
dependencies: { '@manya/contracts': '^1.0.0' },
|
|
85
|
+
exports: ['./src/index.js'],
|
|
86
|
+
capabilities: ['crypto'],
|
|
87
|
+
});
|
|
88
|
+
console.log(m.valid, m.errors);
|
|
89
|
+
|
|
90
|
+
console.log(satisfies('1.4.0', '^1.2.3')); // true
|
|
91
|
+
console.log(satisfies('2.0.0', '^1.2.3')); // false
|
|
92
|
+
|
|
93
|
+
const compat = checkBackwardCompat(v1, v2);
|
|
94
|
+
console.log(compat.compatible, compat.breakingChanges);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Validate an HTTP request/response against an API contract
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { compileSchema, validateRequest, validateResponse } from '@manya/contracts';
|
|
101
|
+
|
|
102
|
+
const contract = {
|
|
103
|
+
name: 'users-api', version: '1.0.0',
|
|
104
|
+
endpoints: [
|
|
105
|
+
{
|
|
106
|
+
method: 'POST', path: '/users',
|
|
107
|
+
requestSchema: compileSchema({
|
|
108
|
+
name: 'CreateUserReq', version: '1.0.0',
|
|
109
|
+
fields: { name: { type: 'string' }, email: { type: 'string' } },
|
|
110
|
+
}),
|
|
111
|
+
responseSchema: compileSchema({
|
|
112
|
+
name: 'CreateUserRes', version: '1.0.0',
|
|
113
|
+
fields: { id: { type: 'string' } },
|
|
114
|
+
}),
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const req = validateRequest(contract, 'POST', '/users', { name: 'A', email: 'a@b.c' });
|
|
120
|
+
const res = validateResponse(contract, 'POST', '/users', { id: 'u1' });
|
|
121
|
+
console.log(req.valid, res.valid);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 4. Enforce module boundaries and aggregate a report
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import {
|
|
128
|
+
enforceBoundary, detectViolations, buildReport, aggregateReports, summarizeReport,
|
|
129
|
+
} from '@manya/contracts';
|
|
130
|
+
|
|
131
|
+
const policy = {
|
|
132
|
+
name: 'p', defaultAllow: false,
|
|
133
|
+
rules: [
|
|
134
|
+
{ from: 'api', to: 'db', allowed: true, reason: 'api owns db access' },
|
|
135
|
+
{ from: 'ui', to: 'db', allowed: false, reason: 'ui must not bypass api' },
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
console.log(enforceBoundary(policy, 'ui', 'db'));
|
|
139
|
+
console.log(detectViolations(policy, [
|
|
140
|
+
{ from: 'api', to: 'db' },
|
|
141
|
+
{ from: 'ui', to: 'db' }, // violation
|
|
142
|
+
]));
|
|
143
|
+
|
|
144
|
+
const report = buildReport('deploy-gate', [
|
|
145
|
+
{ name: 'manifest', passed: true, errors: [] },
|
|
146
|
+
{ name: 'compat', passed: false, errors: [{ path: 'id', message: 'type_changed', code: 'type_changed' }] },
|
|
147
|
+
]);
|
|
148
|
+
console.log(summarizeReport(aggregateReports([report])));
|
|
149
|
+
// → aggregate: FAIL (1/2 sections, 1 error) at 2024-...
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Configuration
|
|
155
|
+
|
|
156
|
+
`@manya/contracts` has no runtime configuration object — every function is pure and explicit. The only configurable surface is the optional `Logger` you can pass to higher-level orchestration code; the package ships `ConsoleLogger` (with secret scrubbing) and `SilentLogger`.
|
|
157
|
+
|
|
158
|
+
### Supported schema type kinds
|
|
159
|
+
|
|
160
|
+
| `type` | Required extra fields | Description |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
| `string` / `number` / `boolean` / `null` | none | JSON primitives. |
|
|
163
|
+
| `object` | `fields?` | Nested record; if `fields` is given, each is validated. |
|
|
164
|
+
| `array` | `of` | Homogeneous list; `of` is the element field definition. |
|
|
165
|
+
| `enum` | `enum` | One of the literal values in `enum`. |
|
|
166
|
+
| `ref` | `ref` | Reference to another `InterfaceSchema` by name (passed via `refs`). |
|
|
167
|
+
| `union` | `oneOf` | One of several member field definitions. |
|
|
168
|
+
| `intersection` | `allOf` | All of several member field definitions. |
|
|
169
|
+
|
|
170
|
+
### Semver range forms supported by `satisfies`
|
|
171
|
+
|
|
172
|
+
| Form | Meaning |
|
|
173
|
+
| --- | --- |
|
|
174
|
+
| `*` | Any version. |
|
|
175
|
+
| `1.2.3` | Exact match. |
|
|
176
|
+
| `^1.2.3` | Compatible-with (same major; for `0.x` and `0.0.x` tighter). |
|
|
177
|
+
| `~1.2.3` | Patch-level (same major and minor). |
|
|
178
|
+
| `>=1.2.3`, `>1.2.3`, `<=1.2.3`, `<1.2.3` | Comparison. |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Extending
|
|
183
|
+
|
|
184
|
+
### Add a custom schema type
|
|
185
|
+
|
|
186
|
+
1. Add the type name to the `SchemaType` union in `src/types.ts`.
|
|
187
|
+
2. Extend `SCHEMA_TYPES` and the `compileField` validation in `src/schema/schema.ts`.
|
|
188
|
+
3. Add a `case` to the `validateField` switch.
|
|
189
|
+
4. Add unit tests covering at least one positive and one negative case.
|
|
190
|
+
5. Update `docs/API.md` and `README.md`.
|
|
191
|
+
|
|
192
|
+
### Add a new compatibility rule
|
|
193
|
+
|
|
194
|
+
`checkBackwardCompat` already detects field removal, type change, required addition, and enum value removal. To add a new rule (e.g. "field became required"), push a new `BreakingChange` to the `breakingChanges` array in `src/compatibility/compatibility.ts`, document the new `type` literal in `src/types.ts`, and add a test.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Security notes
|
|
199
|
+
|
|
200
|
+
- **Local-only.** No schema, manifest, or policy data leaves the host process.
|
|
201
|
+
- **No PII in logs.** `secret`, `token`, `apiKey`, `password`, `authorization`, `privateKey`, `accessToken`, `refreshToken` are scrubbed.
|
|
202
|
+
- **Defense in depth.** Validation never throws on a bad value — it returns `{ valid, errors }`; structural problems (e.g. unparseable schema) raise typed errors.
|
|
203
|
+
- **Reproducibility.** Identical inputs → identical validation results and reports.
|
|
204
|
+
|
|
205
|
+
For threat models, see [SECURITY.md](./SECURITY.md) and the root [SECURITY.md](../../SECURITY.md).
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Documentation
|
|
210
|
+
|
|
211
|
+
- [docs/API.md](./docs/API.md) — full TypeScript API reference.
|
|
212
|
+
- [CHANGELOG.md](./CHANGELOG.md) — release history.
|
|
213
|
+
- [CONTRIBUTING.md](./CONTRIBUTING.md) — package-specific contributor notes.
|
|
214
|
+
- [SECURITY.md](./SECURITY.md) — package-specific security surface.
|
|
215
|
+
- [LICENSE](./LICENSE) — Apache-2.0.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
Apache-2.0. Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
222
|
+
|
|
223
|
+
Conceived, directed, and owned by **Uviwe Menyiwe (Azura Daemon)**, founder of the Manya Hael Foundation.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};__export(src_exports,{ApiValidationError:()=>ApiValidationError,BoundaryError:()=>BoundaryError,CompatibilityError:()=>CompatibilityError,ConsoleLogger:()=>ConsoleLogger,ContractsError:()=>ContractsError,MANIFEST_ERROR_CODES:()=>MANIFEST_ERROR_CODES,ManifestError:()=>ManifestError,ReportingError:()=>ReportingError,SCHEMA_TYPES:()=>SCHEMA_TYPES,SCRUBBED_FIELD_NAMES:()=>SCRUBBED_FIELD_NAMES,SchemaError:()=>SchemaError,SilentLogger:()=>SilentLogger,SyncError:()=>SyncError,aggregateReports:()=>aggregateReports,assertManifest:()=>assertManifest,assertValidContract:()=>assertValidContract,buildReport:()=>buildReport,checkBackwardCompat:()=>checkBackwardCompat,compareParsedSemver:()=>compareParsedSemver,compareSemver:()=>compareSemver,compileSchema:()=>compileSchema,describeType:()=>describeType,detectViolations:()=>detectViolations,diffSchemas:()=>diffSchemas,enforceBoundary:()=>enforceBoundary,fieldsEqual:()=>fieldsEqual,findEndpoint:()=>findEndpoint,isPolicySatisfied:()=>isPolicySatisfied,isSemver:()=>isSemver,isValidManifest:()=>isValidManifest,matchRule:()=>matchRule,mergeSchemas:()=>mergeSchemas,parseSemver:()=>parseSemver,satisfies:()=>satisfies,scrubMetadata:()=>scrubMetadata,serializeReport:()=>serializeReport,shouldScrubField:()=>shouldScrubField,summarizeReport:()=>summarizeReport,validateManifest:()=>validateManifest,validateRequest:()=>validateRequest,validateResponse:()=>validateResponse,validateValue:()=>validateValue});module.exports=__toCommonJS(src_exports);var ContractsError=class extends Error{code;cause;constructor(message,code,cause){super(message),this.name=new.target.name,this.code=code??"CONTRACTS_ERROR",cause!==void 0&&(this.cause=cause),Object.setPrototypeOf(this,new.target.prototype)}},SchemaError=class extends ContractsError{constructor(message,cause){super(message,"SCHEMA_ERROR",cause)}},ManifestError=class extends ContractsError{constructor(message,code,cause){super(message,code??"MANIFEST_ERROR",cause)}},MANIFEST_ERROR_CODES={INVALID_NAME:"MANIFEST_INVALID_NAME",INVALID_VERSION:"MANIFEST_INVALID_VERSION",INVALID_DEPENDENCY:"MANIFEST_INVALID_DEPENDENCY",MISSING_FIELD:"MANIFEST_MISSING_FIELD",INVALID_EXPORTS:"MANIFEST_INVALID_EXPORTS",INVALID_IMPORTS:"MANIFEST_INVALID_IMPORTS",INVALID_CAPABILITIES:"MANIFEST_INVALID_CAPABILITIES",INVALID_DEPENDENCIES:"MANIFEST_INVALID_DEPENDENCIES"},CompatibilityError=class extends ContractsError{constructor(message,cause){super(message,"COMPATIBILITY_ERROR",cause)}},ApiValidationError=class extends ContractsError{constructor(message,cause){super(message,"API_VALIDATION_ERROR",cause)}},SyncError=class extends ContractsError{constructor(message,cause){super(message,"SYNC_ERROR",cause)}},BoundaryError=class extends ContractsError{constructor(message,cause){super(message,"BOUNDARY_ERROR",cause)}},ReportingError=class extends ContractsError{constructor(message,cause){super(message,"REPORTING_ERROR",cause)}};var LEVEL_RANK={debug:10,info:20,warn:30,error:40,silent:100},SCRUBBED_FIELD_NAMES=["secret","token","apiKey","password","authorization","privateKey","accessToken","refreshToken"];function shouldScrubField(name){let lower=name.toLowerCase();for(let needle of SCRUBBED_FIELD_NAMES){let nl=needle.toLowerCase();if(lower===nl||lower.endsWith("_"+nl))return!0}return!1}function scrubMetadata(meta){if(meta==null||typeof meta!="object")return meta;if(Buffer.isBuffer(meta))return`[buffer:${meta.length}]`;if(meta instanceof Date)return meta.toISOString();if(Array.isArray(meta))return meta.map(scrubMetadata);let out={};for(let[k,v]of Object.entries(meta))out[k]=shouldScrubField(k)?"[redacted]":scrubMetadata(v);return out}var ConsoleLogger=class{constructor(level="info"){this.level=level;this.levelRank=LEVEL_RANK[level]??LEVEL_RANK.info}level;levelRank;debug(msg,meta){this.emit("debug",msg,meta)}info(msg,meta){this.emit("info",msg,meta)}warn(msg,meta){this.emit("warn",msg,meta)}error(msg,meta){this.emit("error",msg,meta)}emit(level,msg,meta){try{if(LEVEL_RANK[level]<this.levelRank)return;let entry={level,msg,ts:new Date().toISOString(),...meta?{meta:scrubMetadata(meta)}:{}},line=JSON.stringify(entry);level==="error"||level==="warn"?process.stderr.write(line+`
|
|
2
|
+
`):process.stdout.write(line+`
|
|
3
|
+
`)}catch{}}},SilentLogger=class{debug(){}info(){}warn(){}error(){}};var SCHEMA_TYPES=new Set(["string","number","boolean","null","object","array","enum","ref","union","intersection"]);function compileSchema(definition){if(!definition||typeof definition!="object")throw new SchemaError("schema definition must be an object");let def=definition;if(typeof def.name!="string"||def.name.length===0)throw new SchemaError("schema definition must have a non-empty name");if(typeof def.version!="string"||def.version.length===0)throw new SchemaError(`schema "${def.name}" must have a non-empty version`);let fields=compileFields(def.name,def.fields);return{name:def.name,version:def.version,fields,...def.description?{description:def.description}:{}}}function compileFields(schemaName,raw){if(raw==null)return[];if(Array.isArray(raw))return raw.map((f,i)=>compileField(`${schemaName}.fields[${i}]`,f));if(typeof raw=="object"){let out=[];for(let[name,def]of Object.entries(raw)){let compiled=compileField(`${schemaName}.fields.${name}`,def);compiled.name=name,out.push(compiled)}return out}throw new SchemaError(`schema "${schemaName}" has invalid fields (expected array or record)`)}function compileField(path,def){if(!def||typeof def!="object")throw new SchemaError(`field at ${path} must be an object`);let d=def,type=d.type??"string";if(!SCHEMA_TYPES.has(type))throw new SchemaError(`field at ${path} has invalid type "${type}"; expected one of ${[...SCHEMA_TYPES].join(", ")}`);if(type==="enum"&&(!Array.isArray(d.enum)||d.enum.length===0))throw new SchemaError(`enum field at ${path} must declare a non-empty "enum" array`);if(type==="ref"&&(typeof d.ref!="string"||d.ref.length===0))throw new SchemaError(`ref field at ${path} must declare a non-empty "ref" string`);if(type==="array"&&(!d.of||typeof d.of!="object"))throw new SchemaError(`array field at ${path} must declare an "of" element type`);if(type==="union"&&(!Array.isArray(d.oneOf)||d.oneOf.length===0))throw new SchemaError(`union field at ${path} must declare a non-empty "oneOf" array`);if(type==="intersection"&&(!Array.isArray(d.allOf)||d.allOf.length===0))throw new SchemaError(`intersection field at ${path} must declare a non-empty "allOf" array`);let field={name:d.name??path.split(".").pop()??"",type,required:d.required??!0};return d.description!==void 0&&(field.description=d.description),d.default!==void 0&&(field.default=d.default),Array.isArray(d.enum)&&(field.enum=d.enum),d.ref!==void 0&&(field.ref=d.ref),d.of!==void 0&&(field.of=compileField(`${path}.of`,d.of)),Array.isArray(d.oneOf)&&(field.oneOf=d.oneOf.map((m,i)=>compileField(`${path}.oneOf[${i}]`,m))),Array.isArray(d.allOf)&&(field.allOf=d.allOf.map((m,i)=>compileField(`${path}.allOf[${i}]`,m))),d.fields!==void 0&&(field.fields=compileFields(path,d.fields)),field}function validateValue(schema,value,refs){let errors=[];return validateObject(schema.fields,value,schema.name,errors,refs??{}),{valid:errors.length===0,errors}}function validateObject(fields,value,path,errors,refs){if(value===null||typeof value!="object"||Array.isArray(value)){errors.push({path,message:`expected object, got ${describeType(value)}`,code:"SCHEMA_ERROR",expected:"object",actual:describeType(value)});return}let record=value;for(let field of fields){let fieldPath=path?`${path}.${field.name}`:field.name;if(!Object.prototype.hasOwnProperty.call(record,field.name)){field.required&&errors.push({path:fieldPath,message:`required field "${field.name}" is missing`,code:"SCHEMA_ERROR",expected:"present",actual:"missing"});continue}let v=record[field.name];validateField(field,v,fieldPath,errors,refs)}}function validateField(field,value,path,errors,refs){switch(field.type){case"string":typeof value!="string"&&errors.push(typeError(path,"string",value));break;case"number":(typeof value!="number"||Number.isNaN(value))&&errors.push(typeError(path,"number",value));break;case"boolean":typeof value!="boolean"&&errors.push(typeError(path,"boolean",value));break;case"null":value!==null&&errors.push(typeError(path,"null",value));break;case"enum":(!Array.isArray(field.enum)||!field.enum.includes(value))&&errors.push({path,message:`value ${JSON.stringify(value)} is not in enum [${(field.enum??[]).map(v=>JSON.stringify(v)).join(", ")}]`,code:"SCHEMA_ERROR",expected:`enum[${(field.enum??[]).length}]`,actual:describeType(value)});break;case"object":value===null||typeof value!="object"||Array.isArray(value)?errors.push(typeError(path,"object",value)):field.fields&&field.fields.length>0&&validateObject(field.fields,value,path,errors,refs);break;case"array":if(!Array.isArray(value))errors.push(typeError(path,"array",value));else if(field.of)for(let i=0;i<value.length;i++)validateField(field.of,value[i],`${path}[${i}]`,errors,refs);break;case"ref":{let refName=field.ref??"",refSchema=refs[refName];if(!refSchema){value==null&&errors.push(typeError(path,`ref(${refName})`,value));break}validateObject(refSchema.fields,value,path,errors,refs);break}case"union":{let members=field.oneOf??[],memberErrors=[],matched=!1;for(let member of members){let sub=[];if(validateField(member,value,path,sub,refs),sub.length===0){matched=!0;break}memberErrors.push(sub)}matched||errors.push({path,message:`value did not match any union member at ${path}`,code:"SCHEMA_ERROR",expected:`union[${members.length}]`,actual:describeType(value)});break}case"intersection":{let members=field.allOf??[];for(let member of members)validateField(member,value,path,errors,refs);break}default:errors.push({path,message:`unknown schema type "${field.type}" at ${path}`,code:"SCHEMA_ERROR",expected:"known type",actual:field.type})}}function typeError(path,expected,value){return{path,message:`expected ${expected} at ${path}, got ${describeType(value)}`,code:"SCHEMA_ERROR",expected,actual:describeType(value)}}function describeType(value){return value===null?"null":Array.isArray(value)?"array":value instanceof Date?"date":typeof value}var NAME_PATTERN=/^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/,SEMVER_PATTERN=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*))*))?(?:\+([\w.-]+))?$/;function validateManifest(manifest){let errors=[];if(!manifest||typeof manifest!="object"||Array.isArray(manifest))return errors.push({path:"",message:"manifest must be a non-array object",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"object",actual:manifest===null?"null":typeof manifest}),{valid:!1,errors};let m=manifest;if(typeof m.name!="string"||m.name.length===0?errors.push({path:"name",message:"manifest.name must be a non-empty string",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"string",actual:typeof m.name}):NAME_PATTERN.test(m.name)||errors.push({path:"name",message:`manifest.name "${m.name}" is not a valid package name`,code:MANIFEST_ERROR_CODES.INVALID_NAME,expected:"lowercase scoped or unscoped package name",actual:m.name}),typeof m.version!="string"||m.version.length===0?errors.push({path:"version",message:"manifest.version must be a non-empty semver string",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"semver string",actual:typeof m.version}):SEMVER_PATTERN.test(m.version)||errors.push({path:"version",message:`manifest.version "${m.version}" is not a valid semver`,code:MANIFEST_ERROR_CODES.INVALID_VERSION,expected:"MAJOR.MINOR.PATCH[-prerelease][+build]",actual:m.version}),m.dependencies!==void 0)if(!m.dependencies||typeof m.dependencies!="object"||Array.isArray(m.dependencies))errors.push({path:"dependencies",message:"manifest.dependencies must be a record of name \u2192 range",code:MANIFEST_ERROR_CODES.INVALID_DEPENDENCIES,expected:"Record<string, string>",actual:describeType2(m.dependencies)});else for(let[dep,range]of Object.entries(m.dependencies))(typeof range!="string"||range.length===0)&&errors.push({path:`dependencies.${dep}`,message:`dependency "${dep}" must map to a non-empty version range string`,code:MANIFEST_ERROR_CODES.INVALID_DEPENDENCY,expected:"string",actual:typeof range});return m.exports!==void 0&&validateStringArray(m.exports,"exports",errors),m.imports!==void 0&&validateStringArray(m.imports,"imports",errors),m.capabilities!==void 0&&validateStringArray(m.capabilities,"capabilities",errors),{valid:errors.length===0,errors}}function validateStringArray(value,field,errors){let code=field==="exports"?MANIFEST_ERROR_CODES.INVALID_EXPORTS:field==="imports"?MANIFEST_ERROR_CODES.INVALID_IMPORTS:MANIFEST_ERROR_CODES.INVALID_CAPABILITIES;if(!Array.isArray(value)){errors.push({path:field,message:`manifest.${field} must be an array of strings`,code,expected:"string[]",actual:describeType2(value)});return}for(let i=0;i<value.length;i++)(typeof value[i]!="string"||value[i].length===0)&&errors.push({path:`${field}[${i}]`,message:`manifest.${field}[${i}] must be a non-empty string`,code,expected:"string",actual:describeType2(value[i])})}function assertManifest(manifest){let result=validateManifest(manifest);if(!result.valid){let first=result.errors[0];throw new ManifestError(first?`${first.path?first.path+": ":""}${first.message}`:"invalid manifest",first?.code)}}function isValidManifest(manifest){return validateManifest(manifest).valid}function describeType2(value){return value===null?"null":Array.isArray(value)?"array":typeof value}var SEMVER_PATTERN2=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*))*))?(?:\+([\w.-]+))?$/;function isSemver(v){return typeof v=="string"&&SEMVER_PATTERN2.test(v)}function parseSemver(v){if(typeof v!="string")throw new CompatibilityError(`expected semver string, got ${typeof v}`);let m=v.match(SEMVER_PATTERN2);if(!m)throw new CompatibilityError(`"${v}" is not a valid semver`);let[,major,minor,patch,prerelease]=m,out={major:Number(major),minor:Number(minor),patch:Number(patch)};return prerelease!==void 0&&prerelease.length>0&&(out.prerelease=prerelease),out}function compareSemver(a,b){let pa=parseSemver(a),pb=parseSemver(b);return compareParsedSemver(pa,pb)}function compareParsedSemver(a,b){if(a.major!==b.major)return a.major<b.major?-1:1;if(a.minor!==b.minor)return a.minor<b.minor?-1:1;if(a.patch!==b.patch)return a.patch<b.patch?-1:1;let ap=a.prerelease,bp=b.prerelease;return ap===void 0&&bp===void 0?0:ap===void 0?1:bp===void 0?-1:comparePrerelease(ap,bp)}function comparePrerelease(a,b){let aa=a.split("."),bb=b.split("."),n=Math.min(aa.length,bb.length);for(let i=0;i<n;i++){let x=aa[i],y=bb[i],xn=/^[0-9]+$/.test(x),yn=/^[0-9]+$/.test(y);if(xn&&yn){let xi=Number(x),yi=Number(y);if(xi!==yi)return xi<yi?-1:1}else{if(xn!==yn)return xn?-1:1;if(x!==y)return x<y?-1:1}}return aa.length===bb.length?0:aa.length<bb.length?-1:1}function satisfies(version,range){let v=parseSemver(version),r=range.trim();if(r===""||r==="*")return!0;if(r.startsWith(">="))return compareSemver(version,r.slice(2).trim())>=0;if(r.startsWith("<="))return compareSemver(version,r.slice(2).trim())<=0;if(r.startsWith(">"))return compareSemver(version,r.slice(1).trim())>0;if(r.startsWith("<"))return compareSemver(version,r.slice(1).trim())<0;if(r.startsWith("^")){let target=parseSemver(r.slice(1).trim());return compareParsedSemver(v,target)<0?!1:target.major>0?v.major===target.major:target.minor>0?v.major===0&&v.minor===target.minor:v.major===0&&v.minor===0&&v.patch===target.patch}if(r.startsWith("~")){let target=parseSemver(r.slice(1).trim());return compareParsedSemver(v,target)<0||target.major!==v.major?!1:v.minor===target.minor}return compareSemver(version,r)===0}function checkBackwardCompat(oldSchema,newSchema){let breakingChanges=[],oldByName=new Map;for(let f of oldSchema.fields)oldByName.set(f.name,f);let newByName=new Map;for(let f of newSchema.fields)newByName.set(f.name,f);for(let[name,oldField]of oldByName){let newField=newByName.get(name);if(!newField){breakingChanges.push({type:"field_removed",field:name,from:oldField.type});continue}if(oldField.type!==newField.type&&breakingChanges.push({type:"type_changed",field:name,from:oldField.type,to:newField.type}),oldField.type==="enum"&&newField.type==="enum"){let oldSet=new Set(oldField.enum?.map(v=>JSON.stringify(v))??[]),newSet=new Set(newField.enum?.map(v=>JSON.stringify(v))??[]);for(let v of oldSet)newSet.has(v)||breakingChanges.push({type:"enum_value_removed",field:name,from:v,to:void 0})}}for(let[name,newField]of newByName)!oldByName.has(name)&&newField.required&&breakingChanges.push({type:"required_added",field:name,to:newField.type});return{compatible:breakingChanges.length===0,breakingChanges}}function findEndpoint(contract,method,path){let m=method.toUpperCase();return contract.endpoints.find(e=>e.method===m&&e.path===path)}function validateRequest(contract,method,path,request){let errors=[],endpoint=findEndpoint(contract,method,path);return endpoint?endpoint.requestSchema?validateValue(endpoint.requestSchema,request):{valid:!0,errors:[]}:(errors.push({path,message:`no endpoint matches ${method.toUpperCase()} ${path} in contract "${contract.name}"`,code:"API_VALIDATION_ERROR",expected:"known endpoint",actual:`${method.toUpperCase()} ${path}`}),{valid:!1,errors})}function validateResponse(contract,method,path,response){let errors=[],endpoint=findEndpoint(contract,method,path);return endpoint?validateValue(endpoint.responseSchema,response):(errors.push({path,message:`no endpoint matches ${method.toUpperCase()} ${path} in contract "${contract.name}"`,code:"API_VALIDATION_ERROR",expected:"known endpoint",actual:`${method.toUpperCase()} ${path}`}),{valid:!1,errors})}function assertValidContract(contract){if(!contract||typeof contract!="object"||Array.isArray(contract))throw new ApiValidationError("API contract must be a non-array object");let c=contract;if(typeof c.name!="string"||c.name.length===0)throw new ApiValidationError("API contract.name must be a non-empty string");if(typeof c.version!="string"||c.version.length===0)throw new ApiValidationError(`contract "${c.name}".version must be a non-empty string`);if(!Array.isArray(c.endpoints)||c.endpoints.length===0)throw new ApiValidationError(`contract "${c.name}" must declare a non-empty endpoints array`);for(let i=0;i<c.endpoints.length;i++){let e=c.endpoints[i];if(!e||typeof e!="object")throw new ApiValidationError(`endpoint[${i}] in contract "${c.name}" must be an object`);if(!["GET","POST","PUT","DELETE","PATCH"].includes(e.method??""))throw new ApiValidationError(`endpoint[${i}].method must be one of GET|POST|PUT|DELETE|PATCH`);if(typeof e.path!="string"||e.path.length===0)throw new ApiValidationError(`endpoint[${i}].path must be a non-empty string`);if(!e.responseSchema||typeof e.responseSchema!="object")throw new ApiValidationError(`endpoint[${i}] (${e.method} ${e.path}) must declare a responseSchema`)}}function diffSchemas(oldSchema,newSchema){let oldByName=new Map;for(let f of oldSchema.fields)oldByName.set(f.name,f);let newByName=new Map;for(let f of newSchema.fields)newByName.set(f.name,f);let added=[],removed=[],changed=[];for(let[name,newField]of newByName){let oldField=oldByName.get(name);oldField?fieldsEqual(oldField,newField)||changed.push({field:name,from:oldField,to:newField}):added.push(newField)}for(let[name]of oldByName)newByName.has(name)||removed.push(name);return{added,removed,changed}}function mergeSchemas(local,remote){if(local.name!==remote.name)throw new SyncError(`cannot merge schemas with different names: "${local.name}" vs "${remote.name}"`);let mergedVersion=compareSemver(local.version,remote.version)>=0?local.version:remote.version,localByName=new Map;for(let f of local.fields)localByName.set(f.name,f);let remoteByName=new Map;for(let f of remote.fields)remoteByName.set(f.name,f);let conflicts=[],mergedFields=[];for(let[name,localField]of localByName){let remoteField=remoteByName.get(name);if(!remoteField){mergedFields.push(localField);continue}localField.type===remoteField.type||conflicts.push({field:name,localType:localField.type,remoteType:remoteField.type,resolution:"local"}),mergedFields.push(localField)}for(let[name,remoteField]of remoteByName)localByName.has(name)||mergedFields.push(remoteField);return{schema:{name:local.name,version:mergedVersion,fields:mergedFields,...local.description??remote.description?{description:local.description??remote.description}:{}},conflicts}}function fieldsEqual(a,b){return a===b?!0:!(a.type!==b.type||a.required!==b.required||(a.description??"")!==(b.description??"")||!enumEquals(a.enum,b.enum)||(a.ref??"")!==(b.ref??"")||((a.of??void 0)!==void 0||(b.of??void 0)!==void 0)&&(!a.of||!b.of||!fieldsEqual(a.of,b.of))||!arrayEqual(a.oneOf,b.oneOf,fieldsEqual)||!arrayEqual(a.allOf,b.allOf,fieldsEqual)||!arrayEqual(a.fields,b.fields,fieldsEqual)||JSON.stringify(a.default)!==JSON.stringify(b.default))}function enumEquals(a,b){if(a===void 0&&b===void 0)return!0;if(!Array.isArray(a)||!Array.isArray(b)||a.length!==b.length)return!1;let aa=a.map(v=>JSON.stringify(v)).sort(),bb=b.map(v=>JSON.stringify(v)).sort();return aa.every((v,i)=>v===bb[i])}function arrayEqual(a,b,eq){return a===void 0&&b===void 0?!0:!Array.isArray(a)||!Array.isArray(b)||a.length!==b.length?!1:a.every((v,i)=>eq(v,b[i]))}function matchRule(policy,caller,callee){let exact,fromWild,toWild,anyWild;for(let r of policy.rules){if(r.from===caller&&r.to===callee){exact=r;break}r.from==="*"&&r.to===callee?fromWild=fromWild??r:r.from===caller&&r.to==="*"?toWild=toWild??r:r.from==="*"&&r.to==="*"&&(anyWild=anyWild??r)}return exact??fromWild??toWild??anyWild}function enforceBoundary(policy,caller,callee){if(typeof caller!="string"||caller.length===0)throw new BoundaryError("caller must be a non-empty string");if(typeof callee!="string"||callee.length===0)throw new BoundaryError("callee must be a non-empty string");let rule=matchRule(policy,caller,callee);return rule?{allowed:rule.allowed,reason:rule.reason??(rule.allowed?"allowed by rule":"denied by rule"),matchedRule:rule}:{allowed:policy.defaultAllow,reason:policy.defaultAllow?"allowed by default":"denied by default"}}function detectViolations(policy,callGraph){if(!Array.isArray(callGraph))throw new BoundaryError("callGraph must be an array of { from, to } edges");let violations=[];for(let edge of callGraph){if(!edge||typeof edge!="object")throw new BoundaryError("each call-graph edge must be an object");let result=enforceBoundary(policy,edge.from,edge.to);result.allowed||violations.push({from:edge.from,to:edge.to,reason:result.reason??"denied"})}return violations}function isPolicySatisfied(policy,callGraph){return detectViolations(policy,callGraph).length===0}function buildReport(name,sections,generatedAt){if(typeof name!="string"||name.length===0)throw new ReportingError("report name must be a non-empty string");if(!Array.isArray(sections))throw new ReportingError("sections must be an array");let passed=sections.length>0&§ions.every(s=>s.passed);return{name,passed,sections:sections.map(s=>({...s,errors:[...s.errors]})),generatedAt:generatedAt??new Date().toISOString()}}function aggregateReports(reports,name="aggregate"){if(!Array.isArray(reports))throw new ReportingError("reports must be an array");let sections=[];for(let r of reports)for(let s of r.sections)sections.push({name:reports.length>1?`${r.name}:${s.name}`:s.name,passed:s.passed,errors:[...s.errors]});let passed=reports.length===0||reports.every(r=>r.passed);return{name,passed,sections,generatedAt:new Date().toISOString()}}function serializeReport(report){try{return JSON.stringify(report,null,2)}catch(e){throw new ReportingError("failed to serialize validation report",e)}}function summarizeReport(report){if(!report||typeof report!="object")throw new ReportingError("report must be a ValidationReport object");let total=report.sections.length,passedCount=report.sections.filter(s=>s.passed).length,totalErrors=report.sections.reduce((n,s)=>n+s.errors.length,0),verdict=report.passed?"PASS":"FAIL",errorsPart=totalErrors>0?`, ${totalErrors} error${totalErrors===1?"":"s"}`:"";return`${report.name}: ${verdict} (${passedCount}/${total} sections${errorsPart}) at ${report.generatedAt}`}0&&(module.exports={ApiValidationError,BoundaryError,CompatibilityError,ConsoleLogger,ContractsError,MANIFEST_ERROR_CODES,ManifestError,ReportingError,SCHEMA_TYPES,SCRUBBED_FIELD_NAMES,SchemaError,SilentLogger,SyncError,aggregateReports,assertManifest,assertValidContract,buildReport,checkBackwardCompat,compareParsedSemver,compareSemver,compileSchema,describeType,detectViolations,diffSchemas,enforceBoundary,fieldsEqual,findEndpoint,isPolicySatisfied,isSemver,isValidManifest,matchRule,mergeSchemas,parseSemver,satisfies,scrubMetadata,serializeReport,shouldScrubField,summarizeReport,validateManifest,validateRequest,validateResponse,validateValue});
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../src/errors.ts", "../../src/logging.ts", "../../src/schema/schema.ts", "../../src/manifest/manifest.ts", "../../src/compatibility/compatibility.ts", "../../src/api/api.ts", "../../src/sync/sync.ts", "../../src/boundaries/boundaries.ts", "../../src/reporting/reporting.ts"],
|
|
4
|
+
"mappings": "wpBAAA,w+CCcO,IAAM,eAAN,cAA6B,KAAM,CACxB,KACS,MACzB,YAAY,QAAiB,KAAe,MAAiB,CAC3D,MAAM,OAAO,EACb,KAAK,KAAO,WAAW,KACvB,KAAK,KAAO,MAAQ,kBAChB,QAAU,SAAW,KAAK,MAAQ,OACtC,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,YAAN,cAA0B,cAAe,CAC9C,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,eAAgB,KAAK,CAAG,CACzF,EAUa,cAAN,cAA4B,cAAe,CAChD,YAAY,QAAiB,KAAe,MAAiB,CAC3D,MAAM,QAAS,MAAQ,iBAAkB,KAAK,CAChD,CACF,EAGa,qBAAuB,CAClC,aAAc,wBACd,gBAAiB,2BACjB,mBAAoB,8BACpB,cAAe,yBACf,gBAAiB,2BACjB,gBAAiB,2BACjB,qBAAsB,gCACtB,qBAAsB,+BACxB,EAGa,mBAAN,cAAiC,cAAe,CACrD,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,sBAAuB,KAAK,CAAG,CAChG,EAGa,mBAAN,cAAiC,cAAe,CACrD,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,uBAAwB,KAAK,CAAG,CACjG,EAGa,UAAN,cAAwB,cAAe,CAC5C,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,aAAc,KAAK,CAAG,CACvF,EAGa,cAAN,cAA4B,cAAe,CAChD,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,iBAAkB,KAAK,CAAG,CAC3F,EAGa,eAAN,cAA6B,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,IAAI,KAAK,EAAE,YAAY,CACtC,CACF,CAMO,SAAS,gBAAgB,OAAkC,CAChE,GAAI,CACF,OAAO,KAAK,UAAU,OAAQ,KAAM,CAAC,CACvC,OAAS,EAAG,CACV,MAAM,IAAI,eAAe,wCAAyC,CAAC,CACrE,CACF,CAOO,SAAS,gBAAgB,OAAkC,CAChE,GAAI,CAAC,QAAU,OAAO,QAAW,SAC/B,MAAM,IAAI,eAAe,0CAA0C,EAErE,IAAM,MAAQ,OAAO,SAAS,OACxB,YAAc,OAAO,SAAS,OAAO,GAAK,EAAE,MAAM,EAAE,OACpD,YAAc,OAAO,SAAS,OAAO,CAAC,EAAG,IAAM,EAAI,EAAE,OAAO,OAAQ,CAAC,EACrE,QAAU,OAAO,OAAS,OAAS,OACnC,WAAa,YAAc,EAAI,KAAK,WAAW,SAAS,cAAgB,EAAI,GAAK,GAAG,GAAK,GAC/F,MAAO,GAAG,OAAO,IAAI,KAAK,OAAO,KAAK,WAAW,IAAI,KAAK,YAAY,UAAU,QAAQ,OAAO,WAAW,EAC5G",
|
|
5
|
+
"names": ["describeType", "SEMVER_PATTERN"]
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var ContractsError=class extends Error{code;cause;constructor(message,code,cause){super(message),this.name=new.target.name,this.code=code??"CONTRACTS_ERROR",cause!==void 0&&(this.cause=cause),Object.setPrototypeOf(this,new.target.prototype)}},SchemaError=class extends ContractsError{constructor(message,cause){super(message,"SCHEMA_ERROR",cause)}},ManifestError=class extends ContractsError{constructor(message,code,cause){super(message,code??"MANIFEST_ERROR",cause)}},MANIFEST_ERROR_CODES={INVALID_NAME:"MANIFEST_INVALID_NAME",INVALID_VERSION:"MANIFEST_INVALID_VERSION",INVALID_DEPENDENCY:"MANIFEST_INVALID_DEPENDENCY",MISSING_FIELD:"MANIFEST_MISSING_FIELD",INVALID_EXPORTS:"MANIFEST_INVALID_EXPORTS",INVALID_IMPORTS:"MANIFEST_INVALID_IMPORTS",INVALID_CAPABILITIES:"MANIFEST_INVALID_CAPABILITIES",INVALID_DEPENDENCIES:"MANIFEST_INVALID_DEPENDENCIES"},CompatibilityError=class extends ContractsError{constructor(message,cause){super(message,"COMPATIBILITY_ERROR",cause)}},ApiValidationError=class extends ContractsError{constructor(message,cause){super(message,"API_VALIDATION_ERROR",cause)}},SyncError=class extends ContractsError{constructor(message,cause){super(message,"SYNC_ERROR",cause)}},BoundaryError=class extends ContractsError{constructor(message,cause){super(message,"BOUNDARY_ERROR",cause)}},ReportingError=class extends ContractsError{constructor(message,cause){super(message,"REPORTING_ERROR",cause)}};var LEVEL_RANK={debug:10,info:20,warn:30,error:40,silent:100},SCRUBBED_FIELD_NAMES=["secret","token","apiKey","password","authorization","privateKey","accessToken","refreshToken"];function shouldScrubField(name){let lower=name.toLowerCase();for(let needle of SCRUBBED_FIELD_NAMES){let nl=needle.toLowerCase();if(lower===nl||lower.endsWith("_"+nl))return!0}return!1}function scrubMetadata(meta){if(meta==null||typeof meta!="object")return meta;if(Buffer.isBuffer(meta))return`[buffer:${meta.length}]`;if(meta instanceof Date)return meta.toISOString();if(Array.isArray(meta))return meta.map(scrubMetadata);let out={};for(let[k,v]of Object.entries(meta))out[k]=shouldScrubField(k)?"[redacted]":scrubMetadata(v);return out}var ConsoleLogger=class{constructor(level="info"){this.level=level;this.levelRank=LEVEL_RANK[level]??LEVEL_RANK.info}level;levelRank;debug(msg,meta){this.emit("debug",msg,meta)}info(msg,meta){this.emit("info",msg,meta)}warn(msg,meta){this.emit("warn",msg,meta)}error(msg,meta){this.emit("error",msg,meta)}emit(level,msg,meta){try{if(LEVEL_RANK[level]<this.levelRank)return;let entry={level,msg,ts:new Date().toISOString(),...meta?{meta:scrubMetadata(meta)}:{}},line=JSON.stringify(entry);level==="error"||level==="warn"?process.stderr.write(line+`
|
|
2
|
+
`):process.stdout.write(line+`
|
|
3
|
+
`)}catch{}}},SilentLogger=class{debug(){}info(){}warn(){}error(){}};var SCHEMA_TYPES=new Set(["string","number","boolean","null","object","array","enum","ref","union","intersection"]);function compileSchema(definition){if(!definition||typeof definition!="object")throw new SchemaError("schema definition must be an object");let def=definition;if(typeof def.name!="string"||def.name.length===0)throw new SchemaError("schema definition must have a non-empty name");if(typeof def.version!="string"||def.version.length===0)throw new SchemaError(`schema "${def.name}" must have a non-empty version`);let fields=compileFields(def.name,def.fields);return{name:def.name,version:def.version,fields,...def.description?{description:def.description}:{}}}function compileFields(schemaName,raw){if(raw==null)return[];if(Array.isArray(raw))return raw.map((f,i)=>compileField(`${schemaName}.fields[${i}]`,f));if(typeof raw=="object"){let out=[];for(let[name,def]of Object.entries(raw)){let compiled=compileField(`${schemaName}.fields.${name}`,def);compiled.name=name,out.push(compiled)}return out}throw new SchemaError(`schema "${schemaName}" has invalid fields (expected array or record)`)}function compileField(path,def){if(!def||typeof def!="object")throw new SchemaError(`field at ${path} must be an object`);let d=def,type=d.type??"string";if(!SCHEMA_TYPES.has(type))throw new SchemaError(`field at ${path} has invalid type "${type}"; expected one of ${[...SCHEMA_TYPES].join(", ")}`);if(type==="enum"&&(!Array.isArray(d.enum)||d.enum.length===0))throw new SchemaError(`enum field at ${path} must declare a non-empty "enum" array`);if(type==="ref"&&(typeof d.ref!="string"||d.ref.length===0))throw new SchemaError(`ref field at ${path} must declare a non-empty "ref" string`);if(type==="array"&&(!d.of||typeof d.of!="object"))throw new SchemaError(`array field at ${path} must declare an "of" element type`);if(type==="union"&&(!Array.isArray(d.oneOf)||d.oneOf.length===0))throw new SchemaError(`union field at ${path} must declare a non-empty "oneOf" array`);if(type==="intersection"&&(!Array.isArray(d.allOf)||d.allOf.length===0))throw new SchemaError(`intersection field at ${path} must declare a non-empty "allOf" array`);let field={name:d.name??path.split(".").pop()??"",type,required:d.required??!0};return d.description!==void 0&&(field.description=d.description),d.default!==void 0&&(field.default=d.default),Array.isArray(d.enum)&&(field.enum=d.enum),d.ref!==void 0&&(field.ref=d.ref),d.of!==void 0&&(field.of=compileField(`${path}.of`,d.of)),Array.isArray(d.oneOf)&&(field.oneOf=d.oneOf.map((m,i)=>compileField(`${path}.oneOf[${i}]`,m))),Array.isArray(d.allOf)&&(field.allOf=d.allOf.map((m,i)=>compileField(`${path}.allOf[${i}]`,m))),d.fields!==void 0&&(field.fields=compileFields(path,d.fields)),field}function validateValue(schema,value,refs){let errors=[];return validateObject(schema.fields,value,schema.name,errors,refs??{}),{valid:errors.length===0,errors}}function validateObject(fields,value,path,errors,refs){if(value===null||typeof value!="object"||Array.isArray(value)){errors.push({path,message:`expected object, got ${describeType(value)}`,code:"SCHEMA_ERROR",expected:"object",actual:describeType(value)});return}let record=value;for(let field of fields){let fieldPath=path?`${path}.${field.name}`:field.name;if(!Object.prototype.hasOwnProperty.call(record,field.name)){field.required&&errors.push({path:fieldPath,message:`required field "${field.name}" is missing`,code:"SCHEMA_ERROR",expected:"present",actual:"missing"});continue}let v=record[field.name];validateField(field,v,fieldPath,errors,refs)}}function validateField(field,value,path,errors,refs){switch(field.type){case"string":typeof value!="string"&&errors.push(typeError(path,"string",value));break;case"number":(typeof value!="number"||Number.isNaN(value))&&errors.push(typeError(path,"number",value));break;case"boolean":typeof value!="boolean"&&errors.push(typeError(path,"boolean",value));break;case"null":value!==null&&errors.push(typeError(path,"null",value));break;case"enum":(!Array.isArray(field.enum)||!field.enum.includes(value))&&errors.push({path,message:`value ${JSON.stringify(value)} is not in enum [${(field.enum??[]).map(v=>JSON.stringify(v)).join(", ")}]`,code:"SCHEMA_ERROR",expected:`enum[${(field.enum??[]).length}]`,actual:describeType(value)});break;case"object":value===null||typeof value!="object"||Array.isArray(value)?errors.push(typeError(path,"object",value)):field.fields&&field.fields.length>0&&validateObject(field.fields,value,path,errors,refs);break;case"array":if(!Array.isArray(value))errors.push(typeError(path,"array",value));else if(field.of)for(let i=0;i<value.length;i++)validateField(field.of,value[i],`${path}[${i}]`,errors,refs);break;case"ref":{let refName=field.ref??"",refSchema=refs[refName];if(!refSchema){value==null&&errors.push(typeError(path,`ref(${refName})`,value));break}validateObject(refSchema.fields,value,path,errors,refs);break}case"union":{let members=field.oneOf??[],memberErrors=[],matched=!1;for(let member of members){let sub=[];if(validateField(member,value,path,sub,refs),sub.length===0){matched=!0;break}memberErrors.push(sub)}matched||errors.push({path,message:`value did not match any union member at ${path}`,code:"SCHEMA_ERROR",expected:`union[${members.length}]`,actual:describeType(value)});break}case"intersection":{let members=field.allOf??[];for(let member of members)validateField(member,value,path,errors,refs);break}default:errors.push({path,message:`unknown schema type "${field.type}" at ${path}`,code:"SCHEMA_ERROR",expected:"known type",actual:field.type})}}function typeError(path,expected,value){return{path,message:`expected ${expected} at ${path}, got ${describeType(value)}`,code:"SCHEMA_ERROR",expected,actual:describeType(value)}}function describeType(value){return value===null?"null":Array.isArray(value)?"array":value instanceof Date?"date":typeof value}var NAME_PATTERN=/^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*$/,SEMVER_PATTERN=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*))*))?(?:\+([\w.-]+))?$/;function validateManifest(manifest){let errors=[];if(!manifest||typeof manifest!="object"||Array.isArray(manifest))return errors.push({path:"",message:"manifest must be a non-array object",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"object",actual:manifest===null?"null":typeof manifest}),{valid:!1,errors};let m=manifest;if(typeof m.name!="string"||m.name.length===0?errors.push({path:"name",message:"manifest.name must be a non-empty string",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"string",actual:typeof m.name}):NAME_PATTERN.test(m.name)||errors.push({path:"name",message:`manifest.name "${m.name}" is not a valid package name`,code:MANIFEST_ERROR_CODES.INVALID_NAME,expected:"lowercase scoped or unscoped package name",actual:m.name}),typeof m.version!="string"||m.version.length===0?errors.push({path:"version",message:"manifest.version must be a non-empty semver string",code:MANIFEST_ERROR_CODES.MISSING_FIELD,expected:"semver string",actual:typeof m.version}):SEMVER_PATTERN.test(m.version)||errors.push({path:"version",message:`manifest.version "${m.version}" is not a valid semver`,code:MANIFEST_ERROR_CODES.INVALID_VERSION,expected:"MAJOR.MINOR.PATCH[-prerelease][+build]",actual:m.version}),m.dependencies!==void 0)if(!m.dependencies||typeof m.dependencies!="object"||Array.isArray(m.dependencies))errors.push({path:"dependencies",message:"manifest.dependencies must be a record of name \u2192 range",code:MANIFEST_ERROR_CODES.INVALID_DEPENDENCIES,expected:"Record<string, string>",actual:describeType2(m.dependencies)});else for(let[dep,range]of Object.entries(m.dependencies))(typeof range!="string"||range.length===0)&&errors.push({path:`dependencies.${dep}`,message:`dependency "${dep}" must map to a non-empty version range string`,code:MANIFEST_ERROR_CODES.INVALID_DEPENDENCY,expected:"string",actual:typeof range});return m.exports!==void 0&&validateStringArray(m.exports,"exports",errors),m.imports!==void 0&&validateStringArray(m.imports,"imports",errors),m.capabilities!==void 0&&validateStringArray(m.capabilities,"capabilities",errors),{valid:errors.length===0,errors}}function validateStringArray(value,field,errors){let code=field==="exports"?MANIFEST_ERROR_CODES.INVALID_EXPORTS:field==="imports"?MANIFEST_ERROR_CODES.INVALID_IMPORTS:MANIFEST_ERROR_CODES.INVALID_CAPABILITIES;if(!Array.isArray(value)){errors.push({path:field,message:`manifest.${field} must be an array of strings`,code,expected:"string[]",actual:describeType2(value)});return}for(let i=0;i<value.length;i++)(typeof value[i]!="string"||value[i].length===0)&&errors.push({path:`${field}[${i}]`,message:`manifest.${field}[${i}] must be a non-empty string`,code,expected:"string",actual:describeType2(value[i])})}function assertManifest(manifest){let result=validateManifest(manifest);if(!result.valid){let first=result.errors[0];throw new ManifestError(first?`${first.path?first.path+": ":""}${first.message}`:"invalid manifest",first?.code)}}function isValidManifest(manifest){return validateManifest(manifest).valid}function describeType2(value){return value===null?"null":Array.isArray(value)?"array":typeof value}var SEMVER_PATTERN2=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\w-]*))*))?(?:\+([\w.-]+))?$/;function isSemver(v){return typeof v=="string"&&SEMVER_PATTERN2.test(v)}function parseSemver(v){if(typeof v!="string")throw new CompatibilityError(`expected semver string, got ${typeof v}`);let m=v.match(SEMVER_PATTERN2);if(!m)throw new CompatibilityError(`"${v}" is not a valid semver`);let[,major,minor,patch,prerelease]=m,out={major:Number(major),minor:Number(minor),patch:Number(patch)};return prerelease!==void 0&&prerelease.length>0&&(out.prerelease=prerelease),out}function compareSemver(a,b){let pa=parseSemver(a),pb=parseSemver(b);return compareParsedSemver(pa,pb)}function compareParsedSemver(a,b){if(a.major!==b.major)return a.major<b.major?-1:1;if(a.minor!==b.minor)return a.minor<b.minor?-1:1;if(a.patch!==b.patch)return a.patch<b.patch?-1:1;let ap=a.prerelease,bp=b.prerelease;return ap===void 0&&bp===void 0?0:ap===void 0?1:bp===void 0?-1:comparePrerelease(ap,bp)}function comparePrerelease(a,b){let aa=a.split("."),bb=b.split("."),n=Math.min(aa.length,bb.length);for(let i=0;i<n;i++){let x=aa[i],y=bb[i],xn=/^[0-9]+$/.test(x),yn=/^[0-9]+$/.test(y);if(xn&&yn){let xi=Number(x),yi=Number(y);if(xi!==yi)return xi<yi?-1:1}else{if(xn!==yn)return xn?-1:1;if(x!==y)return x<y?-1:1}}return aa.length===bb.length?0:aa.length<bb.length?-1:1}function satisfies(version,range){let v=parseSemver(version),r=range.trim();if(r===""||r==="*")return!0;if(r.startsWith(">="))return compareSemver(version,r.slice(2).trim())>=0;if(r.startsWith("<="))return compareSemver(version,r.slice(2).trim())<=0;if(r.startsWith(">"))return compareSemver(version,r.slice(1).trim())>0;if(r.startsWith("<"))return compareSemver(version,r.slice(1).trim())<0;if(r.startsWith("^")){let target=parseSemver(r.slice(1).trim());return compareParsedSemver(v,target)<0?!1:target.major>0?v.major===target.major:target.minor>0?v.major===0&&v.minor===target.minor:v.major===0&&v.minor===0&&v.patch===target.patch}if(r.startsWith("~")){let target=parseSemver(r.slice(1).trim());return compareParsedSemver(v,target)<0||target.major!==v.major?!1:v.minor===target.minor}return compareSemver(version,r)===0}function checkBackwardCompat(oldSchema,newSchema){let breakingChanges=[],oldByName=new Map;for(let f of oldSchema.fields)oldByName.set(f.name,f);let newByName=new Map;for(let f of newSchema.fields)newByName.set(f.name,f);for(let[name,oldField]of oldByName){let newField=newByName.get(name);if(!newField){breakingChanges.push({type:"field_removed",field:name,from:oldField.type});continue}if(oldField.type!==newField.type&&breakingChanges.push({type:"type_changed",field:name,from:oldField.type,to:newField.type}),oldField.type==="enum"&&newField.type==="enum"){let oldSet=new Set(oldField.enum?.map(v=>JSON.stringify(v))??[]),newSet=new Set(newField.enum?.map(v=>JSON.stringify(v))??[]);for(let v of oldSet)newSet.has(v)||breakingChanges.push({type:"enum_value_removed",field:name,from:v,to:void 0})}}for(let[name,newField]of newByName)!oldByName.has(name)&&newField.required&&breakingChanges.push({type:"required_added",field:name,to:newField.type});return{compatible:breakingChanges.length===0,breakingChanges}}function findEndpoint(contract,method,path){let m=method.toUpperCase();return contract.endpoints.find(e=>e.method===m&&e.path===path)}function validateRequest(contract,method,path,request){let errors=[],endpoint=findEndpoint(contract,method,path);return endpoint?endpoint.requestSchema?validateValue(endpoint.requestSchema,request):{valid:!0,errors:[]}:(errors.push({path,message:`no endpoint matches ${method.toUpperCase()} ${path} in contract "${contract.name}"`,code:"API_VALIDATION_ERROR",expected:"known endpoint",actual:`${method.toUpperCase()} ${path}`}),{valid:!1,errors})}function validateResponse(contract,method,path,response){let errors=[],endpoint=findEndpoint(contract,method,path);return endpoint?validateValue(endpoint.responseSchema,response):(errors.push({path,message:`no endpoint matches ${method.toUpperCase()} ${path} in contract "${contract.name}"`,code:"API_VALIDATION_ERROR",expected:"known endpoint",actual:`${method.toUpperCase()} ${path}`}),{valid:!1,errors})}function assertValidContract(contract){if(!contract||typeof contract!="object"||Array.isArray(contract))throw new ApiValidationError("API contract must be a non-array object");let c=contract;if(typeof c.name!="string"||c.name.length===0)throw new ApiValidationError("API contract.name must be a non-empty string");if(typeof c.version!="string"||c.version.length===0)throw new ApiValidationError(`contract "${c.name}".version must be a non-empty string`);if(!Array.isArray(c.endpoints)||c.endpoints.length===0)throw new ApiValidationError(`contract "${c.name}" must declare a non-empty endpoints array`);for(let i=0;i<c.endpoints.length;i++){let e=c.endpoints[i];if(!e||typeof e!="object")throw new ApiValidationError(`endpoint[${i}] in contract "${c.name}" must be an object`);if(!["GET","POST","PUT","DELETE","PATCH"].includes(e.method??""))throw new ApiValidationError(`endpoint[${i}].method must be one of GET|POST|PUT|DELETE|PATCH`);if(typeof e.path!="string"||e.path.length===0)throw new ApiValidationError(`endpoint[${i}].path must be a non-empty string`);if(!e.responseSchema||typeof e.responseSchema!="object")throw new ApiValidationError(`endpoint[${i}] (${e.method} ${e.path}) must declare a responseSchema`)}}function diffSchemas(oldSchema,newSchema){let oldByName=new Map;for(let f of oldSchema.fields)oldByName.set(f.name,f);let newByName=new Map;for(let f of newSchema.fields)newByName.set(f.name,f);let added=[],removed=[],changed=[];for(let[name,newField]of newByName){let oldField=oldByName.get(name);oldField?fieldsEqual(oldField,newField)||changed.push({field:name,from:oldField,to:newField}):added.push(newField)}for(let[name]of oldByName)newByName.has(name)||removed.push(name);return{added,removed,changed}}function mergeSchemas(local,remote){if(local.name!==remote.name)throw new SyncError(`cannot merge schemas with different names: "${local.name}" vs "${remote.name}"`);let mergedVersion=compareSemver(local.version,remote.version)>=0?local.version:remote.version,localByName=new Map;for(let f of local.fields)localByName.set(f.name,f);let remoteByName=new Map;for(let f of remote.fields)remoteByName.set(f.name,f);let conflicts=[],mergedFields=[];for(let[name,localField]of localByName){let remoteField=remoteByName.get(name);if(!remoteField){mergedFields.push(localField);continue}localField.type===remoteField.type||conflicts.push({field:name,localType:localField.type,remoteType:remoteField.type,resolution:"local"}),mergedFields.push(localField)}for(let[name,remoteField]of remoteByName)localByName.has(name)||mergedFields.push(remoteField);return{schema:{name:local.name,version:mergedVersion,fields:mergedFields,...local.description??remote.description?{description:local.description??remote.description}:{}},conflicts}}function fieldsEqual(a,b){return a===b?!0:!(a.type!==b.type||a.required!==b.required||(a.description??"")!==(b.description??"")||!enumEquals(a.enum,b.enum)||(a.ref??"")!==(b.ref??"")||((a.of??void 0)!==void 0||(b.of??void 0)!==void 0)&&(!a.of||!b.of||!fieldsEqual(a.of,b.of))||!arrayEqual(a.oneOf,b.oneOf,fieldsEqual)||!arrayEqual(a.allOf,b.allOf,fieldsEqual)||!arrayEqual(a.fields,b.fields,fieldsEqual)||JSON.stringify(a.default)!==JSON.stringify(b.default))}function enumEquals(a,b){if(a===void 0&&b===void 0)return!0;if(!Array.isArray(a)||!Array.isArray(b)||a.length!==b.length)return!1;let aa=a.map(v=>JSON.stringify(v)).sort(),bb=b.map(v=>JSON.stringify(v)).sort();return aa.every((v,i)=>v===bb[i])}function arrayEqual(a,b,eq){return a===void 0&&b===void 0?!0:!Array.isArray(a)||!Array.isArray(b)||a.length!==b.length?!1:a.every((v,i)=>eq(v,b[i]))}function matchRule(policy,caller,callee){let exact,fromWild,toWild,anyWild;for(let r of policy.rules){if(r.from===caller&&r.to===callee){exact=r;break}r.from==="*"&&r.to===callee?fromWild=fromWild??r:r.from===caller&&r.to==="*"?toWild=toWild??r:r.from==="*"&&r.to==="*"&&(anyWild=anyWild??r)}return exact??fromWild??toWild??anyWild}function enforceBoundary(policy,caller,callee){if(typeof caller!="string"||caller.length===0)throw new BoundaryError("caller must be a non-empty string");if(typeof callee!="string"||callee.length===0)throw new BoundaryError("callee must be a non-empty string");let rule=matchRule(policy,caller,callee);return rule?{allowed:rule.allowed,reason:rule.reason??(rule.allowed?"allowed by rule":"denied by rule"),matchedRule:rule}:{allowed:policy.defaultAllow,reason:policy.defaultAllow?"allowed by default":"denied by default"}}function detectViolations(policy,callGraph){if(!Array.isArray(callGraph))throw new BoundaryError("callGraph must be an array of { from, to } edges");let violations=[];for(let edge of callGraph){if(!edge||typeof edge!="object")throw new BoundaryError("each call-graph edge must be an object");let result=enforceBoundary(policy,edge.from,edge.to);result.allowed||violations.push({from:edge.from,to:edge.to,reason:result.reason??"denied"})}return violations}function isPolicySatisfied(policy,callGraph){return detectViolations(policy,callGraph).length===0}function buildReport(name,sections,generatedAt){if(typeof name!="string"||name.length===0)throw new ReportingError("report name must be a non-empty string");if(!Array.isArray(sections))throw new ReportingError("sections must be an array");let passed=sections.length>0&§ions.every(s=>s.passed);return{name,passed,sections:sections.map(s=>({...s,errors:[...s.errors]})),generatedAt:generatedAt??new Date().toISOString()}}function aggregateReports(reports,name="aggregate"){if(!Array.isArray(reports))throw new ReportingError("reports must be an array");let sections=[];for(let r of reports)for(let s of r.sections)sections.push({name:reports.length>1?`${r.name}:${s.name}`:s.name,passed:s.passed,errors:[...s.errors]});let passed=reports.length===0||reports.every(r=>r.passed);return{name,passed,sections,generatedAt:new Date().toISOString()}}function serializeReport(report){try{return JSON.stringify(report,null,2)}catch(e){throw new ReportingError("failed to serialize validation report",e)}}function summarizeReport(report){if(!report||typeof report!="object")throw new ReportingError("report must be a ValidationReport object");let total=report.sections.length,passedCount=report.sections.filter(s=>s.passed).length,totalErrors=report.sections.reduce((n,s)=>n+s.errors.length,0),verdict=report.passed?"PASS":"FAIL",errorsPart=totalErrors>0?`, ${totalErrors} error${totalErrors===1?"":"s"}`:"";return`${report.name}: ${verdict} (${passedCount}/${total} sections${errorsPart}) at ${report.generatedAt}`}export{ApiValidationError,BoundaryError,CompatibilityError,ConsoleLogger,ContractsError,MANIFEST_ERROR_CODES,ManifestError,ReportingError,SCHEMA_TYPES,SCRUBBED_FIELD_NAMES,SchemaError,SilentLogger,SyncError,aggregateReports,assertManifest,assertValidContract,buildReport,checkBackwardCompat,compareParsedSemver,compareSemver,compileSchema,describeType,detectViolations,diffSchemas,enforceBoundary,fieldsEqual,findEndpoint,isPolicySatisfied,isSemver,isValidManifest,matchRule,mergeSchemas,parseSemver,satisfies,scrubMetadata,serializeReport,shouldScrubField,summarizeReport,validateManifest,validateRequest,validateResponse,validateValue};
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/errors.ts", "../../src/logging.ts", "../../src/schema/schema.ts", "../../src/manifest/manifest.ts", "../../src/compatibility/compatibility.ts", "../../src/api/api.ts", "../../src/sync/sync.ts", "../../src/boundaries/boundaries.ts", "../../src/reporting/reporting.ts"],
|
|
4
|
+
"mappings": "AAcO,IAAM,eAAN,cAA6B,KAAM,CACxB,KACS,MACzB,YAAY,QAAiB,KAAe,MAAiB,CAC3D,MAAM,OAAO,EACb,KAAK,KAAO,WAAW,KACvB,KAAK,KAAO,MAAQ,kBAChB,QAAU,SAAW,KAAK,MAAQ,OACtC,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,YAAN,cAA0B,cAAe,CAC9C,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,eAAgB,KAAK,CAAG,CACzF,EAUa,cAAN,cAA4B,cAAe,CAChD,YAAY,QAAiB,KAAe,MAAiB,CAC3D,MAAM,QAAS,MAAQ,iBAAkB,KAAK,CAChD,CACF,EAGa,qBAAuB,CAClC,aAAc,wBACd,gBAAiB,2BACjB,mBAAoB,8BACpB,cAAe,yBACf,gBAAiB,2BACjB,gBAAiB,2BACjB,qBAAsB,gCACtB,qBAAsB,+BACxB,EAGa,mBAAN,cAAiC,cAAe,CACrD,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,sBAAuB,KAAK,CAAG,CAChG,EAGa,mBAAN,cAAiC,cAAe,CACrD,YAAY,QAAiB,MAAiB,CAAE,MAAM,QAAS,uBAAwB,KAAK,CAAG,CACjG,EAGa,UAAN,cAAwB,cAAe,CAC5C,YAAY,QAAiB,MAAiB,CAAE,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OACV,OAAQ,CAAC,GAAG,EAAE,MAAM,CACtB,CAAC,EAGL,IAAM,OAAS,QAAQ,SAAW,GAAK,QAAQ,MAAM,GAAK,EAAE,MAAM,EAClE,MAAO,CACL,KACA,OACA,SACA,YAAa,IAAI,KAAK,EAAE,YAAY,CACtC,CACF,CAMO,SAAS,gBAAgB,OAAkC,CAChE,GAAI,CACF,OAAO,KAAK,UAAU,OAAQ,KAAM,CAAC,CACvC,OAAS,EAAG,CACV,MAAM,IAAI,eAAe,wCAAyC,CAAC,CACrE,CACF,CAOO,SAAS,gBAAgB,OAAkC,CAChE,GAAI,CAAC,QAAU,OAAO,QAAW,SAC/B,MAAM,IAAI,eAAe,0CAA0C,EAErE,IAAM,MAAQ,OAAO,SAAS,OACxB,YAAc,OAAO,SAAS,OAAO,GAAK,EAAE,MAAM,EAAE,OACpD,YAAc,OAAO,SAAS,OAAO,CAAC,EAAG,IAAM,EAAI,EAAE,OAAO,OAAQ,CAAC,EACrE,QAAU,OAAO,OAAS,OAAS,OACnC,WAAa,YAAc,EAAI,KAAK,WAAW,SAAS,cAAgB,EAAI,GAAK,GAAG,GAAK,GAC/F,MAAO,GAAG,OAAO,IAAI,KAAK,OAAO,KAAK,WAAW,IAAI,KAAK,YAAY,UAAU,QAAQ,OAAO,WAAW,EAC5G",
|
|
5
|
+
"names": ["describeType", "SEMVER_PATTERN"]
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/contracts — API contract validation.
|
|
3
|
+
*
|
|
4
|
+
* Validates HTTP requests and responses against a named `ApiContract`. Each
|
|
5
|
+
* endpoint is matched by `method` + `path`; the corresponding request and
|
|
6
|
+
* response bodies are validated against their declared `InterfaceSchema`s
|
|
7
|
+
* using the schema validator from `src/schema`.
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
10
|
+
* Licensed under the Apache License, Version 2.0.
|
|
11
|
+
*/
|
|
12
|
+
import type { ApiContract, ApiEndpoint, ValidationResult } from '../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Looks up an endpoint in a contract by HTTP method and path. Returns
|
|
15
|
+
* `undefined` if no endpoint matches. Path matching is exact (case-sensitive)
|
|
16
|
+
* — path parameters (`:id`) are treated as literal matches unless the caller
|
|
17
|
+
* normalizes them first.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findEndpoint(contract: ApiContract, method: string, path: string): ApiEndpoint | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Validates a request body against the contract's endpoint for the given
|
|
22
|
+
* method + path. Returns `{ valid: true }` when:
|
|
23
|
+
* - the endpoint exists and has no `requestSchema` (any body is allowed), or
|
|
24
|
+
* - the endpoint exists and `request` satisfies its `requestSchema`.
|
|
25
|
+
*
|
|
26
|
+
* Returns `{ valid: false, errors }` when the endpoint is missing, or when
|
|
27
|
+
* the request body fails schema validation. Never throws.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateRequest(contract: ApiContract, method: string, path: string, request: unknown): ValidationResult;
|
|
30
|
+
/**
|
|
31
|
+
* Validates a response body against the contract's endpoint for the given
|
|
32
|
+
* method + path. Every endpoint must declare a `responseSchema`; a missing
|
|
33
|
+
* endpoint or a response that fails schema validation produces errors.
|
|
34
|
+
* Never throws.
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateResponse(contract: ApiContract, method: string, path: string, response: unknown): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Validates a full API contract's structure: ensures name, version, and a
|
|
39
|
+
* non-empty endpoints array, and that every endpoint has method, path, and a
|
|
40
|
+
* responseSchema. Throws `ApiValidationError` on the first structural defect.
|
|
41
|
+
*/
|
|
42
|
+
export declare function assertValidContract(contract: unknown): asserts contract is ApiContract;
|
|
43
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAmB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/F;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,WAAW,GAAG,SAAS,CAGzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,gBAAgB,CAkBlB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAChB,gBAAgB,CAclB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,WAAW,CA6BtF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,GACrE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/contracts — boundary enforcement.
|
|
3
|
+
*
|
|
4
|
+
* Enforces module-level call boundaries declared via a `BoundaryPolicy` — a
|
|
5
|
+
* named collection of `BoundaryRule`s plus a `defaultAllow` flag. Rules map
|
|
6
|
+
* a `(from, to)` module pair to an allow/deny decision; when no rule matches,
|
|
7
|
+
* `defaultAllow` decides.
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
10
|
+
* Licensed under the Apache License, Version 2.0.
|
|
11
|
+
*/
|
|
12
|
+
import type { BoundaryPolicy, BoundaryRule } from '../types.js';
|
|
13
|
+
/** Result of a single boundary check. */
|
|
14
|
+
export interface BoundaryResult {
|
|
15
|
+
/** Whether the call is allowed. */
|
|
16
|
+
allowed: boolean;
|
|
17
|
+
/** Human-readable reason (the matched rule's reason, or `default`). */
|
|
18
|
+
reason?: string;
|
|
19
|
+
/** The rule that decided the result, if any. */
|
|
20
|
+
matchedRule?: BoundaryRule;
|
|
21
|
+
}
|
|
22
|
+
/** A single edge in a call graph — `from` calls `to`. */
|
|
23
|
+
export interface CallEdge {
|
|
24
|
+
from: string;
|
|
25
|
+
to: string;
|
|
26
|
+
}
|
|
27
|
+
/** A detected violation in a call graph. */
|
|
28
|
+
export interface BoundaryViolation {
|
|
29
|
+
/** Caller module. */
|
|
30
|
+
from: string;
|
|
31
|
+
/** Callee module. */
|
|
32
|
+
to: string;
|
|
33
|
+
/** Why the call is disallowed. */
|
|
34
|
+
reason: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the most specific rule matching `(caller, callee)`. Specificity:
|
|
38
|
+
* 1. An exact `(from, to)` rule wins.
|
|
39
|
+
* 2. A wildcard `('*', to)` rule matches next.
|
|
40
|
+
* 3. A wildcard `(from, '*')` rule matches next.
|
|
41
|
+
* 4. A `('*', '*')` rule matches last.
|
|
42
|
+
* Returns `undefined` when no rule matches.
|
|
43
|
+
*/
|
|
44
|
+
export declare function matchRule(policy: BoundaryPolicy, caller: string, callee: string): BoundaryRule | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Enforces the boundary policy for a single `(caller, callee)` call. When a
|
|
47
|
+
* rule matches, its `allowed` flag and `reason` are returned; otherwise the
|
|
48
|
+
* policy's `defaultAllow` flag decides.
|
|
49
|
+
*/
|
|
50
|
+
export declare function enforceBoundary(policy: BoundaryPolicy, caller: string, callee: string): BoundaryResult;
|
|
51
|
+
/**
|
|
52
|
+
* Detects every violation in a call graph: every edge whose
|
|
53
|
+
* `enforceBoundary` result has `allowed === false`. Returns an array of
|
|
54
|
+
* `BoundaryViolation`s (empty when the policy is satisfied).
|
|
55
|
+
*/
|
|
56
|
+
export declare function detectViolations(policy: BoundaryPolicy, callGraph: ReadonlyArray<CallEdge>): BoundaryViolation[];
|
|
57
|
+
/**
|
|
58
|
+
* Convenience: returns `true` iff every edge in `callGraph` is permitted by
|
|
59
|
+
* `policy`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isPolicySatisfied(policy: BoundaryPolicy, callGraph: ReadonlyArray<CallEdge>): boolean;
|
|
62
|
+
//# sourceMappingURL=boundaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../../../src/boundaries/boundaries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhE,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,yDAAyD;AACzD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,SAAS,CAY1B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,cAAc,CAmBhB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,GACjC,iBAAiB,EAAE,CAmBrB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,GACjC,OAAO,CAET"}
|