@baijimu/cmodel 1.1.2 → 1.1.3
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/README.md +3 -1
- package/dist/parser.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Strict TypeScript types and parser for Baijimu CModel Error Contract `1.0.0`.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm install @baijimu/cmodel@1.1.
|
|
6
|
+
npm install @baijimu/cmodel@1.1.3
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```ts
|
|
@@ -12,4 +12,6 @@ import { parseCModelResponse } from "@baijimu/cmodel";
|
|
|
12
12
|
const response = parseCModelResponse(httpStatus, body, (value) => value);
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
An absent `contractVersion` is interpreted as CModel Error Contract `1.0.0`. Explicit versions are validated strictly and unsupported versions are rejected.
|
|
16
|
+
|
|
15
17
|
The public package contains only the protocol types and validation logic. It does not include Baijimu's internal service catalog or internal data models. See <https://docs.baijimu.com/integration/cmodel-error-model/>.
|
package/dist/parser.js
CHANGED
|
@@ -11,9 +11,9 @@ export class CModelContractError extends Error {
|
|
|
11
11
|
export function parseCModelResponse(httpStatus, input, parseData) {
|
|
12
12
|
const envelope = envelopeAt(input, "$");
|
|
13
13
|
requiredKeys(envelope, "$", ["errorCode", "data"]);
|
|
14
|
-
const contractVersion =
|
|
15
|
-
?
|
|
16
|
-
:
|
|
14
|
+
const contractVersion = "contractVersion" in envelope
|
|
15
|
+
? stringAt(envelope.contractVersion, "$.contractVersion", 1, 64)
|
|
16
|
+
: CONTRACT_VERSION;
|
|
17
17
|
if (contractVersion !== CONTRACT_VERSION) {
|
|
18
18
|
fail("$.contractVersion", `unsupported contract version ${contractVersion}`);
|
|
19
19
|
}
|