@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.
Files changed (46) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +20 -0
  3. package/README.md +223 -0
  4. package/dist/cjs/index.js +4 -0
  5. package/dist/cjs/index.js.map +6 -0
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/esm/index.mjs +4 -0
  8. package/dist/esm/index.mjs.map +6 -0
  9. package/dist/esm/package.json +1 -0
  10. package/dist/types/api/api.d.ts +43 -0
  11. package/dist/types/api/api.d.ts.map +1 -0
  12. package/dist/types/api/index.d.ts +2 -0
  13. package/dist/types/api/index.d.ts.map +1 -0
  14. package/dist/types/boundaries/boundaries.d.ts +62 -0
  15. package/dist/types/boundaries/boundaries.d.ts.map +1 -0
  16. package/dist/types/boundaries/index.d.ts +3 -0
  17. package/dist/types/boundaries/index.d.ts.map +1 -0
  18. package/dist/types/compatibility/compatibility.d.ts +58 -0
  19. package/dist/types/compatibility/compatibility.d.ts.map +1 -0
  20. package/dist/types/compatibility/index.d.ts +2 -0
  21. package/dist/types/compatibility/index.d.ts.map +1 -0
  22. package/dist/types/errors.d.ts +65 -0
  23. package/dist/types/errors.d.ts.map +1 -0
  24. package/dist/types/index.d.ts +34 -0
  25. package/dist/types/index.d.ts.map +1 -0
  26. package/dist/types/logging.d.ts +38 -0
  27. package/dist/types/logging.d.ts.map +1 -0
  28. package/dist/types/manifest/index.d.ts +2 -0
  29. package/dist/types/manifest/index.d.ts.map +1 -0
  30. package/dist/types/manifest/manifest.d.ts +24 -0
  31. package/dist/types/manifest/manifest.d.ts.map +1 -0
  32. package/dist/types/reporting/index.d.ts +2 -0
  33. package/dist/types/reporting/index.d.ts.map +1 -0
  34. package/dist/types/reporting/reporting.d.ts +37 -0
  35. package/dist/types/reporting/reporting.d.ts.map +1 -0
  36. package/dist/types/schema/index.d.ts +3 -0
  37. package/dist/types/schema/index.d.ts.map +1 -0
  38. package/dist/types/schema/schema.d.ts +77 -0
  39. package/dist/types/schema/schema.d.ts.map +1 -0
  40. package/dist/types/sync/index.d.ts +2 -0
  41. package/dist/types/sync/index.d.ts.map +1 -0
  42. package/dist/types/sync/sync.d.ts +36 -0
  43. package/dist/types/sync/sync.d.ts.map +1 -0
  44. package/dist/types/types.d.ts +215 -0
  45. package/dist/types/types.d.ts.map +1 -0
  46. package/package.json +47 -0
@@ -0,0 +1,3 @@
1
+ export { enforceBoundary, detectViolations, matchRule, isPolicySatisfied, } from './boundaries.js';
2
+ export type { BoundaryResult, CallEdge, BoundaryViolation } from './boundaries.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/boundaries/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,GAChE,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @manya-os/contracts — version compatibility.
3
+ *
4
+ * Provides semver parsing (`parseSemver`), ordering (`compareSemver`), range
5
+ * satisfaction (`satisfies`), and structural backward-compatibility checking
6
+ * (`checkBackwardCompat`) between two versions of an `InterfaceSchema`.
7
+ *
8
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
9
+ * Licensed under the Apache License, Version 2.0.
10
+ */
11
+ import type { BreakingChange, InterfaceSchema, SemverVersion } from '../types.js';
12
+ /** Returns `true` iff `v` is a valid semver string. */
13
+ export declare function isSemver(v: string): boolean;
14
+ /**
15
+ * Parses a semver string into a `SemverVersion`. Throws `CompatibilityError`
16
+ * on invalid input.
17
+ */
18
+ export declare function parseSemver(v: string): SemverVersion;
19
+ /**
20
+ * Compares two semver strings. Returns -1 if `a < b`, 0 if `a === b`, 1 if
21
+ * `a > b`. Throws `CompatibilityError` if either is invalid.
22
+ *
23
+ * Prerelease handling follows semver.org §11: a version with a prerelease is
24
+ * lower than the same version without one; prerelease identifiers compare
25
+ * numerically when both are numeric, lexically otherwise, and numeric
26
+ * identifiers are lower than alphanumeric ones.
27
+ */
28
+ export declare function compareSemver(a: string, b: string): -1 | 0 | 1;
29
+ /** Compares two parsed `SemverVersion` values. */
30
+ export declare function compareParsedSemver(a: SemverVersion, b: SemverVersion): -1 | 0 | 1;
31
+ /**
32
+ * Returns `true` iff `version` satisfies `range`. Supported range forms:
33
+ * - `*` — any version.
34
+ * - `^1.2.3` — compatible-with: `>=1.2.3 <2.0.0` (or `<1.3.0` if major is 0).
35
+ * - `~1.2.3` — patch-level: `>=1.2.3 <1.3.0`.
36
+ * - `1.2.3` — exact match.
37
+ * - `>=1.2.3`, `>1.2.3`, `<=1.2.3`, `<1.2.3` — comparison.
38
+ *
39
+ * Throws `CompatibilityError` on malformed input.
40
+ */
41
+ export declare function satisfies(version: string, range: string): boolean;
42
+ /**
43
+ * Checks whether `newSchema` is backward-compatible with `oldSchema`.
44
+ *
45
+ * A breaking change is any of:
46
+ * - `field_removed` — a field present in `oldSchema` is missing in `newSchema`.
47
+ * - `type_changed` — a field's `type` changed between versions.
48
+ * - `required_added` — a new field is marked `required: true`.
49
+ * - `enum_value_removed` — an `enum` field lost one or more allowed values.
50
+ *
51
+ * Returns `{ compatible, breakingChanges }` where `compatible === true` iff
52
+ * `breakingChanges.length === 0`.
53
+ */
54
+ export declare function checkBackwardCompat(oldSchema: InterfaceSchema, newSchema: InterfaceSchema): {
55
+ compatible: boolean;
56
+ breakingChanges: BreakingChange[];
57
+ };
58
+ //# sourceMappingURL=compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../../src/compatibility/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOlF,uDAAuD;AACvD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAgBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAI9D;AAED,kDAAkD;AAClD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAYlF;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAqCjE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,eAAe,GACzB;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,cAAc,EAAE,CAAA;CAAE,CAuD5D"}
@@ -0,0 +1,2 @@
1
+ export { isSemver, parseSemver, compareSemver, compareParsedSemver, satisfies, checkBackwardCompat, } from './compatibility.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/compatibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EACzD,SAAS,EAAE,mBAAmB,GAC/B,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @manya-os/contracts — typed error hierarchy.
3
+ *
4
+ * Every public @manya-os/contracts API throws a subclass of `ContractsError`.
5
+ * Errors carry a stable `code` string for programmatic discrimination; for
6
+ * `ManifestError`, the constructor accepts an explicit `code` so that each
7
+ * failure mode (invalid name, invalid version, invalid dependency, ...) has
8
+ * its own stable code while still being an instance of `ManifestError`.
9
+ *
10
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
11
+ * Licensed under the Apache License, Version 2.0.
12
+ */
13
+ /** Base class for all @manya-os/contracts errors. */
14
+ export declare class ContractsError extends Error {
15
+ readonly code: string;
16
+ readonly cause?: unknown;
17
+ constructor(message: string, code?: string, cause?: unknown);
18
+ }
19
+ /** Raised when a schema definition cannot be compiled or is structurally invalid. */
20
+ export declare class SchemaError extends ContractsError {
21
+ constructor(message: string, cause?: unknown);
22
+ }
23
+ /**
24
+ * Raised when a manifest is structurally invalid. Accepts an explicit `code`
25
+ * so each failure mode (`MANIFEST_INVALID_NAME`, `MANIFEST_INVALID_VERSION`,
26
+ * `MANIFEST_INVALID_DEPENDENCY`, `MANIFEST_MISSING_FIELD`,
27
+ * `MANIFEST_INVALID_EXPORTS`, `MANIFEST_INVALID_IMPORTS`,
28
+ * `MANIFEST_INVALID_CAPABILITIES`) is distinguishable while still being an
29
+ * instance of `ManifestError`.
30
+ */
31
+ export declare class ManifestError extends ContractsError {
32
+ constructor(message: string, code?: string, cause?: unknown);
33
+ }
34
+ /** Stable `ManifestError` codes — one per failure mode. */
35
+ export declare const MANIFEST_ERROR_CODES: {
36
+ readonly INVALID_NAME: "MANIFEST_INVALID_NAME";
37
+ readonly INVALID_VERSION: "MANIFEST_INVALID_VERSION";
38
+ readonly INVALID_DEPENDENCY: "MANIFEST_INVALID_DEPENDENCY";
39
+ readonly MISSING_FIELD: "MANIFEST_MISSING_FIELD";
40
+ readonly INVALID_EXPORTS: "MANIFEST_INVALID_EXPORTS";
41
+ readonly INVALID_IMPORTS: "MANIFEST_INVALID_IMPORTS";
42
+ readonly INVALID_CAPABILITIES: "MANIFEST_INVALID_CAPABILITIES";
43
+ readonly INVALID_DEPENDENCIES: "MANIFEST_INVALID_DEPENDENCIES";
44
+ };
45
+ /** Raised when version compatibility checks fail. */
46
+ export declare class CompatibilityError extends ContractsError {
47
+ constructor(message: string, cause?: unknown);
48
+ }
49
+ /** Raised when an API request or response fails validation. */
50
+ export declare class ApiValidationError extends ContractsError {
51
+ constructor(message: string, cause?: unknown);
52
+ }
53
+ /** Raised when schema synchronization cannot proceed (e.g. unresolvable conflict). */
54
+ export declare class SyncError extends ContractsError {
55
+ constructor(message: string, cause?: unknown);
56
+ }
57
+ /** Raised when a boundary policy is violated or structurally invalid. */
58
+ export declare class BoundaryError extends ContractsError {
59
+ constructor(message: string, cause?: unknown);
60
+ }
61
+ /** Raised when a validation report cannot be built, aggregated, or serialized. */
62
+ export declare class ReportingError extends ContractsError {
63
+ constructor(message: string, cause?: unknown);
64
+ }
65
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qDAAqD;AACrD,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAyB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAO5D;AAED,qFAAqF;AACrF,qBAAa,WAAY,SAAQ,cAAc;gBACjC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C;AAED;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG5D;AAED,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB;;;;;;;;;CASvB,CAAC;AAEX,qDAAqD;AACrD,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C;AAED,+DAA+D;AAC/D,qBAAa,kBAAmB,SAAQ,cAAc;gBACxC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C;AAED,sFAAsF;AACtF,qBAAa,SAAU,SAAQ,cAAc;gBAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C;AAED,yEAAyE;AACzE,qBAAa,aAAc,SAAQ,cAAc;gBACnC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C;AAED,kFAAkF;AAClF,qBAAa,cAAe,SAAQ,cAAc;gBACpC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAC7C"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @manya-os/contracts — universal contract and schema validation.
3
+ *
4
+ * Public API surface for @manya-os/contracts. Everything exported here is part
5
+ * of the stable, semver-bound public API.
6
+ *
7
+ * Capabilities:
8
+ * - Schema definition language (`compileSchema`, `validateValue`).
9
+ * - Manifest validation (`validateManifest`).
10
+ * - Semver parsing/comparison/range checks and backward-compat analysis.
11
+ * - API request/response contract validation.
12
+ * - Schema diffing and merging with conflict detection.
13
+ * - Module boundary enforcement.
14
+ * - Validation report aggregation and serialization.
15
+ *
16
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
17
+ * Conceived, directed, and owned by Uviwe Menyiwe (Azura Daemon), founder
18
+ * of the Manya Hael Foundation.
19
+ *
20
+ * Licensed under the Apache License, Version 2.0.
21
+ */
22
+ export * from './types.js';
23
+ export * from './errors.js';
24
+ export { Logger, LogLevel, ConsoleLogger, SilentLogger, scrubMetadata, shouldScrubField, SCRUBBED_FIELD_NAMES, } from './logging.js';
25
+ export { compileSchema, validateValue, describeType, SCHEMA_TYPES, } from './schema/schema.js';
26
+ export type { SchemaDefinition, SchemaFieldDefinition } from './schema/schema.js';
27
+ export { validateManifest, assertManifest, isValidManifest, } from './manifest/manifest.js';
28
+ export { isSemver, parseSemver, compareSemver, compareParsedSemver, satisfies, checkBackwardCompat, } from './compatibility/compatibility.js';
29
+ export { findEndpoint, validateRequest, validateResponse, assertValidContract, } from './api/api.js';
30
+ export { diffSchemas, mergeSchemas, fieldsEqual, } from './sync/sync.js';
31
+ export { enforceBoundary, detectViolations, matchRule, isPolicySatisfied, } from './boundaries/boundaries.js';
32
+ export type { BoundaryResult, CallEdge, BoundaryViolation } from './boundaries/boundaries.js';
33
+ export { buildReport, aggregateReports, serializeReport, summarizeReport, } from './reporting/reporting.js';
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAG5B,OAAO,EACL,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAC7C,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,GACtD,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GACzD,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGlF,OAAO,EACL,gBAAgB,EAAE,cAAc,EAAE,eAAe,GAClD,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EACzD,SAAS,EAAE,mBAAmB,GAC/B,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EACL,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,GACrE,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,WAAW,EAAE,YAAY,EAAE,WAAW,GACvC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,GAChE,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG9F,OAAO,EACL,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,GAChE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @manya-os/contracts — structured logging (mirrors @manya-os/keyring pattern).
3
+ *
4
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
5
+ * Licensed under the Apache License, Version 2.0.
6
+ */
7
+ export interface Logger {
8
+ debug(msg: string, meta?: Record<string, unknown>): void;
9
+ info(msg: string, meta?: Record<string, unknown>): void;
10
+ warn(msg: string, meta?: Record<string, unknown>): void;
11
+ error(msg: string, meta?: Record<string, unknown>): void;
12
+ }
13
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
14
+ /** Field names that are scrubbed from log metadata before emission. */
15
+ export declare const SCRUBBED_FIELD_NAMES: readonly ["secret", "token", "apiKey", "password", "authorization", "privateKey", "accessToken", "refreshToken"];
16
+ /** Returns `true` if a field name should be scrubbed from logs. */
17
+ export declare function shouldScrubField(name: string): boolean;
18
+ /** Deeply scrubs sensitive fields from log metadata. */
19
+ export declare function scrubMetadata(meta: unknown): unknown;
20
+ /** Logger that emits JSON lines to stdout/stderr with secret scrubbing. */
21
+ export declare class ConsoleLogger implements Logger {
22
+ private readonly level;
23
+ private readonly levelRank;
24
+ constructor(level?: LogLevel);
25
+ debug(msg: string, meta?: Record<string, unknown>): void;
26
+ info(msg: string, meta?: Record<string, unknown>): void;
27
+ warn(msg: string, meta?: Record<string, unknown>): void;
28
+ error(msg: string, meta?: Record<string, unknown>): void;
29
+ private emit;
30
+ }
31
+ /** Logger that discards everything. */
32
+ export declare class SilentLogger implements Logger {
33
+ debug(): void;
34
+ info(): void;
35
+ warn(): void;
36
+ error(): void;
37
+ }
38
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,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AE,OAAO,CAAC,GAAG,IAAI;IACvD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IACvD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IACxD,OAAO,CAAC,IAAI;CASb;AAED,uCAAuC;AACvC,qBAAa,YAAa,YAAW,MAAM;IACzC,KAAK,IAAI,IAAI;IACb,IAAI,IAAI,IAAI;IACZ,IAAI,IAAI,IAAI;IACZ,KAAK,IAAI,IAAI;CACd"}
@@ -0,0 +1,2 @@
1
+ export { validateManifest, assertManifest, isValidManifest, } from './manifest.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAAE,cAAc,EAAE,eAAe,GAClD,MAAM,eAAe,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @manya-os/contracts — manifest validation.
3
+ *
4
+ * Validates a `Manifest` describing a package's name, version, dependencies,
5
+ * exports, imports, and capabilities. Each failure mode carries a stable code
6
+ * (see `MANIFEST_ERROR_CODES`) so callers can react programmatically.
7
+ *
8
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
9
+ * Licensed under the Apache License, Version 2.0.
10
+ */
11
+ import type { Manifest, ValidationResult } from '../types.js';
12
+ /**
13
+ * Validates a manifest structurally. Returns `{ valid, errors }` where each
14
+ * error's `code` is one of `MANIFEST_ERROR_CODES.*`.
15
+ */
16
+ export declare function validateManifest(manifest: unknown): ValidationResult;
17
+ /**
18
+ * Throws a `ManifestError` (with the first error's code) if the manifest is
19
+ * invalid. Convenience for callers that prefer exception-based control flow.
20
+ */
21
+ export declare function assertManifest(manifest: unknown): asserts manifest is Manifest;
22
+ /** Returns `true` iff `v` is a structurally valid manifest. */
23
+ export declare function isValidManifest(manifest: unknown): manifest is Manifest;
24
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/manifest/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAmB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU/E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAqFpE;AA+BD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAS9E;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAEvE"}
@@ -0,0 +1,2 @@
1
+ export { buildReport, aggregateReports, serializeReport, summarizeReport, } from './reporting.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reporting/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,GAChE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @manya-os/contracts — validation reports.
3
+ *
4
+ * Aggregates per-section validation results into a single `ValidationReport`,
5
+ * serializes reports to JSON, and produces one-line summaries for log lines
6
+ * and dashboards.
7
+ *
8
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
9
+ * Licensed under the Apache License, Version 2.0.
10
+ */
11
+ import type { ValidationReport, ValidationReportSection } from '../types.js';
12
+ /**
13
+ * Builds a `ValidationReport` from a name and a list of section results.
14
+ * `passed` is computed as the AND of every section's `passed`. `generatedAt`
15
+ * is set to the current ISO timestamp unless provided.
16
+ */
17
+ export declare function buildReport(name: string, sections: ValidationReportSection[], generatedAt?: string): ValidationReport;
18
+ /**
19
+ * Aggregates multiple `ValidationReport`s into a single report. The merged
20
+ * report is named `aggregate` (or the provided `name`), its `passed` flag is
21
+ * the AND of all input reports' `passed` flags, and its `sections` array is
22
+ * the concatenation of every input's sections (prefixed with the source
23
+ * report name to keep section names unique). `generatedAt` is set to now.
24
+ */
25
+ export declare function aggregateReports(reports: ReadonlyArray<ValidationReport>, name?: string): ValidationReport;
26
+ /**
27
+ * Serializes a `ValidationReport` to a stable, indented JSON string. Throws
28
+ * `ReportingError` if the report contains a value that JSON cannot encode.
29
+ */
30
+ export declare function serializeReport(report: ValidationReport): string;
31
+ /**
32
+ * Returns a single-line summary of a `ValidationReport`, e.g.
33
+ * `my-contract: PASS (3/3 sections) at 2024-01-15T12:34:56.000Z`
34
+ * `my-contract: FAIL (1/3 sections, 4 errors) at 2024-01-15T12:34:56.000Z`
35
+ */
36
+ export declare function summarizeReport(report: ValidationReport): string;
37
+ //# sourceMappingURL=reporting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporting.d.ts","sourceRoot":"","sources":["../../../src/reporting/reporting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG7E;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,uBAAuB,EAAE,EACnC,WAAW,CAAC,EAAE,MAAM,GACnB,gBAAgB,CAclB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACxC,IAAI,SAAc,GACjB,gBAAgB,CAqBlB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAMhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAUhE"}
@@ -0,0 +1,3 @@
1
+ export { compileSchema, validateValue, describeType, SCHEMA_TYPES, } from './schema.js';
2
+ export type { SchemaDefinition, SchemaFieldDefinition } from './schema.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GACzD,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @manya-os/contracts — schema definition language.
3
+ *
4
+ * Provides a JSON-ish schema definition language centered on the
5
+ * `InterfaceSchema` type. `compileSchema` normalizes a definition (either an
6
+ * already-compiled `InterfaceSchema` or a raw definition object) into a
7
+ * canonical `InterfaceSchema`; `validateValue` validates any JavaScript value
8
+ * against a compiled schema, returning a `ValidationResult`.
9
+ *
10
+ * Supported field types:
11
+ * - `string` / `number` / `boolean` / `null` — JSON primitives.
12
+ * - `object` — nested record (use `fields`).
13
+ * - `array` — homogeneous list (use `of`).
14
+ * - `enum` — one of a fixed set (use `enum`).
15
+ * - `ref` — reference to another schema by name (use `ref`).
16
+ * - `union` — one of several (use `oneOf`).
17
+ * - `intersection` — all of several (use `allOf`).
18
+ *
19
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
20
+ * Licensed under the Apache License, Version 2.0.
21
+ */
22
+ import type { InterfaceSchema, SchemaField, SchemaType, ValidationResult } from '../types.js';
23
+ /** Set of all valid `SchemaType` literal names. */
24
+ export declare const SCHEMA_TYPES: ReadonlySet<string>;
25
+ /**
26
+ * A raw schema definition accepted by `compileSchema`. Either an
27
+ * already-compiled `InterfaceSchema` or a JSON-ish object whose `fields` may
28
+ * be a record mapping field name → field definition (with `required` defaulted
29
+ * to `true` when absent).
30
+ */
31
+ export type SchemaDefinition = InterfaceSchema | {
32
+ name: string;
33
+ version: string;
34
+ description?: string;
35
+ fields?: SchemaField[] | Record<string, SchemaFieldDefinition>;
36
+ };
37
+ /** A raw field definition (a partial `SchemaField` minus the name). */
38
+ export interface SchemaFieldDefinition {
39
+ type?: SchemaType | string;
40
+ required?: boolean;
41
+ description?: string;
42
+ default?: unknown;
43
+ enum?: unknown[];
44
+ of?: SchemaFieldDefinition | SchemaField;
45
+ ref?: string;
46
+ oneOf?: Array<SchemaFieldDefinition | SchemaField>;
47
+ allOf?: Array<SchemaFieldDefinition | SchemaField>;
48
+ fields?: SchemaField[] | Record<string, SchemaFieldDefinition>;
49
+ }
50
+ /**
51
+ * Compiles a raw schema definition into a normalized `InterfaceSchema`.
52
+ *
53
+ * Accepted inputs:
54
+ * - an already-compiled `InterfaceSchema` (returned as a defensive copy).
55
+ * - a definition object whose `fields` may be a record (in which case
56
+ * `required` defaults to `true`).
57
+ *
58
+ * Throws `SchemaError` on malformed input.
59
+ */
60
+ export declare function compileSchema(definition: SchemaDefinition): InterfaceSchema;
61
+ /**
62
+ * Validates a JavaScript value against a compiled `InterfaceSchema`.
63
+ *
64
+ * Returns a `ValidationResult` with `valid: true` iff the value satisfies
65
+ * every field's type, `required`, and `enum` constraints. Composite types
66
+ * (`object`, `array`, `union`, `intersection`, `ref`) are recursively
67
+ * validated; `ref` fields are matched purely by name and treated as opaque
68
+ * (a referenced schema is considered satisfied when present in `refs`).
69
+ *
70
+ * @param schema Compiled interface schema.
71
+ * @param value Value to validate.
72
+ * @param refs Optional map of referenced interface schemas (for `ref` fields).
73
+ */
74
+ export declare function validateValue(schema: InterfaceSchema, value: unknown, refs?: Record<string, InterfaceSchema>): ValidationResult;
75
+ /** Returns a short, human-readable description of a value's type. */
76
+ export declare function describeType(value: unknown): string;
77
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/sch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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GACrC,gBAAgB,CAIlB;AAoKD,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnD"}
@@ -0,0 +1,2 @@
1
+ export { diffSchemas, mergeSchemas, fieldsEqual, } from './sync.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAAE,YAAY,EAAE,WAAW,GACvC,MAAM,WAAW,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @manya-os/contracts — schema synchronization.
3
+ *
4
+ * Diffs two `InterfaceSchema`s (`diffSchemas`) and merges two schemas with
5
+ * conflict detection (`mergeSchemas`). Conflicting fields carry a
6
+ * `SchemaConflict` descriptor with a `resolution` hint.
7
+ *
8
+ * Copyright 2024 Manya Hael Foundation. All rights reserved.
9
+ * Licensed under the Apache License, Version 2.0.
10
+ */
11
+ import type { InterfaceSchema, SchemaConflict, SchemaDiff, SchemaField } from '../types.js';
12
+ /**
13
+ * Computes the diff between two schemas. `removed` is a list of field names
14
+ * that existed in `oldSchema` but not `newSchema`; `added` and `changed`
15
+ * carry full field descriptors.
16
+ */
17
+ export declare function diffSchemas(oldSchema: InterfaceSchema, newSchema: InterfaceSchema): SchemaDiff;
18
+ /**
19
+ * Merges `local` and `remote` schemas into a single schema. Fields present in
20
+ * only one schema are included verbatim. Fields present in both with the same
21
+ * type are kept from `local`; fields present in both with different types
22
+ * produce a `SchemaConflict` and are resolved in favour of `local`.
23
+ *
24
+ * The merged schema inherits `local.name` and the higher of the two versions
25
+ * (per `compareSemver`); if `local` and `remote` have different names, a
26
+ * `SyncError` is thrown — schema sync is name-scoped.
27
+ *
28
+ * @returns `{ schema, conflicts }` — the merged schema and any conflicts.
29
+ */
30
+ export declare function mergeSchemas(local: InterfaceSchema, remote: InterfaceSchema): {
31
+ schema: InterfaceSchema;
32
+ conflicts: SchemaConflict[];
33
+ };
34
+ /** Returns `true` iff two fields are structurally equivalent. */
35
+ export declare function fieldsEqual(a: SchemaField, b: SchemaField): boolean;
36
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/sync/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5F;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,eAAe,GACzB,UAAU,CAuBZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,eAAe,GACtB;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,cAAc,EAAE,CAAA;CAAE,CAsD1D;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAgBnE"}