@adviser/cement 0.2.36 → 0.2.37

Sign up to get free protection for your applications and to get access to all the features.
package/index.cjs CHANGED
@@ -1278,7 +1278,7 @@ function getParamsResult(keys, getParam) {
1278
1278
  if (typeof i === "string") {
1279
1279
  acc.push({ key: i });
1280
1280
  } else if (typeof i === "object") {
1281
- acc.push(...Object.keys(i).map((k) => ({ key: k, def: i[k] })));
1281
+ acc.push(...Object.keys(i).map((k) => ({ key: k, def: typeof i[k] === "string" ? i[k] : void 0 })));
1282
1282
  }
1283
1283
  return acc;
1284
1284
  },
@@ -1293,7 +1293,7 @@ function getParamsResult(keys, getParam) {
1293
1293
  for (const kd of keyDef) {
1294
1294
  const val = getParam.getParam(kd.key);
1295
1295
  if (val === void 0) {
1296
- if (kd.def) {
1296
+ if (typeof kd.def === "string") {
1297
1297
  result[kd.key] = kd.def;
1298
1298
  } else {
1299
1299
  errors.push(kd.key);
@@ -1957,19 +1957,29 @@ var LoggerImpl = class _LoggerImpl {
1957
1957
  this.coerceKey(key, !!value);
1958
1958
  return this;
1959
1959
  }
1960
- Http(res, req, key) {
1961
- if (Result.Is(res)) {
1962
- if (res.isErr()) {
1963
- this.Err(res.Err());
1964
- return this;
1965
- }
1966
- res = res.Ok();
1967
- }
1968
- let reqRes = res;
1969
- if (req) {
1970
- reqRes = { res, req };
1960
+ Http(...mix) {
1961
+ const key = mix.find((x) => typeof x === "string");
1962
+ mix = mix.filter((x) => typeof x !== "string");
1963
+ const resErrors = mix.filter((x) => Result.Is(x) && x.isErr());
1964
+ if (resErrors.length) {
1965
+ this.Err(resErrors.map((x) => x.Err().message).join("\n"));
1966
+ return this;
1967
+ }
1968
+ const req = mix.map((reqOrResult) => Result.Is(reqOrResult) ? reqOrResult.Ok() : reqOrResult).find((req2) => typeof req2.status !== "number");
1969
+ const res = mix.map((resOrResult) => Result.Is(resOrResult) ? resOrResult.Ok() : resOrResult).find((res2) => typeof res2.status === "number");
1970
+ let reqAndOrres;
1971
+ if (res && req) {
1972
+ reqAndOrres = { res, req };
1973
+ } else if (!res && !req) {
1974
+ reqAndOrres = void 0;
1975
+ } else if (res) {
1976
+ reqAndOrres = res;
1977
+ } else if (req) {
1978
+ reqAndOrres = req;
1979
+ }
1980
+ if (reqAndOrres) {
1981
+ this.Any(key || "Http", reqAndOrres);
1971
1982
  }
1972
- this.Any(key || "Http", reqRes);
1973
1983
  return this;
1974
1984
  }
1975
1985
  Pair(x) {
@@ -2124,8 +2134,8 @@ var WithLoggerBuilder = class {
2124
2134
  this._li.SetDebug(...modules);
2125
2135
  return this;
2126
2136
  }
2127
- Http(res, req, key) {
2128
- this._li.Http(res, req, key);
2137
+ Http(...mix) {
2138
+ this._li.Http(...mix);
2129
2139
  return this;
2130
2140
  }
2131
2141
  Pair(x) {