@crouter/api 0.3.390 → 0.3.392
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/dist/api/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { ErrorBody } from './errors.js';
|
|
|
5
5
|
export { errorCodes } from './error-codes.js';
|
|
6
6
|
export type { ErrorCode, ErrorEnvelope, ErrorOrigin, ErrorType } from './error-codes.js';
|
|
7
7
|
export { API_VERSION, routes } from './routes.js';
|
|
8
|
+
export { RUNTIME_VERSION_HEADER, compareReleaseVersions } from './runtime-version.js';
|
|
8
9
|
export * from '../shared/generated-context.js';
|
|
9
10
|
export * from './dto/common.js';
|
|
10
11
|
export * from './dto/health.js';
|
package/dist/api/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { CrtrClient, waitForDaemonAvailability } from './client.js';
|
|
|
5
5
|
export { APIError, ApiError, isErrorBody } from './errors.js';
|
|
6
6
|
export { errorCodes } from './error-codes.js';
|
|
7
7
|
export { API_VERSION, routes } from './routes.js';
|
|
8
|
+
export { RUNTIME_VERSION_HEADER, compareReleaseVersions } from './runtime-version.js';
|
|
8
9
|
export * from '../shared/generated-context.js';
|
|
9
10
|
export * from './dto/common.js';
|
|
10
11
|
export * from './dto/health.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Response header carrying the runtime's release version, e.g. `0.3.389`. */
|
|
2
|
+
export declare const RUNTIME_VERSION_HEADER = "Crouter-Runtime-Version";
|
|
3
|
+
/** Compares two `major.minor.patch` versions numerically (a prerelease or build
|
|
4
|
+
* suffix is ignored). Negative when `a` is older, zero when equal, positive when
|
|
5
|
+
* newer. A version that does not parse sorts below every version that does. */
|
|
6
|
+
export declare function compareReleaseVersions(a: string, b: string): number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The runtime's release version on every response (P2: latest only).
|
|
2
|
+
//
|
|
3
|
+
// The runtime sends its package version (`crouter` `package.json`) in this
|
|
4
|
+
// header on every `/v1` answer of the owner API and the app listener. A client
|
|
5
|
+
// built from the same release set compares it with its own version and refuses
|
|
6
|
+
// an older runtime: there is no capability negotiation, so a client's types are
|
|
7
|
+
// true only for a runtime at or above its own release.
|
|
8
|
+
//
|
|
9
|
+
// PURITY (spec §3.1): Node built-ins + `src/api/*` only.
|
|
10
|
+
/** Response header carrying the runtime's release version, e.g. `0.3.389`. */
|
|
11
|
+
export const RUNTIME_VERSION_HEADER = 'Crouter-Runtime-Version';
|
|
12
|
+
/** Compares two `major.minor.patch` versions numerically (a prerelease or build
|
|
13
|
+
* suffix is ignored). Negative when `a` is older, zero when equal, positive when
|
|
14
|
+
* newer. A version that does not parse sorts below every version that does. */
|
|
15
|
+
export function compareReleaseVersions(a, b) {
|
|
16
|
+
const left = parseRelease(a);
|
|
17
|
+
const right = parseRelease(b);
|
|
18
|
+
if (left === null || right === null)
|
|
19
|
+
return left === right ? 0 : left === null ? -1 : 1;
|
|
20
|
+
for (let i = 0; i < 3; i++)
|
|
21
|
+
if (left[i] !== right[i])
|
|
22
|
+
return left[i] - right[i];
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
function parseRelease(version) {
|
|
26
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version.trim());
|
|
27
|
+
return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crouter/api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.392",
|
|
4
4
|
"description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/api/index.js",
|