@baijimu/cmodel 1.0.2 → 1.0.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/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +6 -8
- package/package.json +1 -1
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAQpB,MAAM,YAAY,CAAC;AAqBpB,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC;AAEhE,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,cAAc,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EAQpB,MAAM,YAAY,CAAC;AAqBpB,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC;AAEhE,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GACvB,cAAc,CAAC,CAAC,CAAC,CAiEnB"}
|
package/dist/parser.js
CHANGED
|
@@ -26,14 +26,7 @@ export class CModelContractError extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
export function parseCModelResponse(httpStatus, input, parseData) {
|
|
29
|
-
const envelope =
|
|
30
|
-
"contractVersion",
|
|
31
|
-
"errorCode",
|
|
32
|
-
"value",
|
|
33
|
-
"data",
|
|
34
|
-
"systemCurrentTime",
|
|
35
|
-
"error",
|
|
36
|
-
]);
|
|
29
|
+
const envelope = envelopeAt(input, "$");
|
|
37
30
|
requiredKeys(envelope, "$", [
|
|
38
31
|
"contractVersion",
|
|
39
32
|
"errorCode",
|
|
@@ -223,6 +216,11 @@ function objectAt(input, path, allowedKeys) {
|
|
|
223
216
|
fail(`${path}.${key}`, "unknown field");
|
|
224
217
|
return value;
|
|
225
218
|
}
|
|
219
|
+
function envelopeAt(input, path) {
|
|
220
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
221
|
+
fail(path, "must be an object");
|
|
222
|
+
return input;
|
|
223
|
+
}
|
|
226
224
|
function requiredKeys(value, path, keys) {
|
|
227
225
|
for (const key of keys)
|
|
228
226
|
if (!(key in value))
|