@open-norantec/herbal 1.0.2-alpha.27 → 1.0.2-alpha.29

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.
@@ -95,7 +95,7 @@ var TypeScriptClient = (function (_super) {
95
95
  return [4, this.schemaToTypeScriptLiteral(responseSchema)];
96
96
  case 3:
97
97
  responseTypeLiteral = _o.sent();
98
- methodTypeMapCodeLines.push(["'".concat(pathname, "': {"), " request: ".concat(requestTypeLiteral, ";"), " response: ".concat(responseTypeLiteral, ";"), ' };'].join(''));
98
+ methodTypeMapCodeLines.push([" '".concat(pathname, "': {"), " request: ".concat(requestTypeLiteral, ";"), " response: ".concat(responseTypeLiteral, ";"), ' };'].join(''));
99
99
  _o.label = 4;
100
100
  case 4:
101
101
  _i++;
@@ -215,6 +215,7 @@ var TypeScriptClient = (function (_super) {
215
215
  format: true,
216
216
  bannerComment: '',
217
217
  additionalProperties: false,
218
+ unknownAny: false,
218
219
  style: {
219
220
  singleQuote: true,
220
221
  semi: true,
package/dist/core.d.ts CHANGED
@@ -3,17 +3,11 @@ import { HeaderUtil } from '@open-norantec/utilities/dist/header-util.class';
3
3
  import { z } from 'zod';
4
4
  import { Request } from './types/request.type';
5
5
  export * from '@nestjs/core';
6
- interface LegacyMethodContext<IS extends z.Schema<any>> {
7
- headers: ReturnType<typeof HeaderUtil.parse>;
8
- input: z.infer<IS>;
9
- request: Request;
10
- }
11
6
  export type MethodHandler<IS extends z.Schema<any>, OS extends z.Schema<any>> = (request: Request, input: unknown, headers: ReturnType<typeof HeaderUtil.parse>) => Promise<{
12
7
  request: z.infer<IS>;
13
8
  response: z.infer<OS>;
14
9
  }>;
15
10
  export declare class HerbalController {
16
- protected registerMethod: <IS extends z.ZodType<any, z.ZodTypeDef, any>, OS extends z.ZodType<any, z.ZodTypeDef, any>>(inputSchema: IS, outputSchema: OS, callback: (context: LegacyMethodContext<IS>) => Promise<z.TypeOf<OS>>) => MethodHandler<IS, OS>;
17
11
  private $handleRequest;
18
12
  private $call;
19
13
  }
package/dist/core.js CHANGED
@@ -66,42 +66,12 @@ exports.HerbalController = void 0;
66
66
  require("reflect-metadata");
67
67
  var common_1 = require("@nestjs/common");
68
68
  var header_util_class_1 = require("@open-norantec/utilities/dist/header-util.class");
69
- var zod_1 = require("zod");
70
- var _ = require("lodash");
71
69
  var string_util_class_1 = require("@open-norantec/utilities/dist/string-util.class");
72
70
  var utilities_1 = require("@open-norantec/utilities");
73
71
  var controller_util_class_1 = require("./utilities/controller-util.class");
74
72
  __exportStar(require("@nestjs/core"), exports);
75
73
  var HerbalController = exports.HerbalController = (function () {
76
74
  function HerbalController() {
77
- var _this = this;
78
- this.registerMethod = function (inputSchema, outputSchema, callback) {
79
- return function (request, rawInput, headers) { return __awaiter(_this, void 0, void 0, function () {
80
- var input, responseData;
81
- var _a, _b, _c;
82
- return __generator(this, function (_d) {
83
- switch (_d.label) {
84
- case 0:
85
- input = inputSchema instanceof zod_1.ZodAny ? rawInput : _.attempt(function () { return inputSchema.parse(rawInput); });
86
- if (input instanceof Error) {
87
- if (input instanceof zod_1.ZodError) {
88
- throw new common_1.BadRequestException({
89
- invalidParams: (_c = (_b = (_a = input === null || input === void 0 ? void 0 : input.issues) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.path) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '.'); })) !== null && _c !== void 0 ? _c : [],
90
- });
91
- }
92
- throw input;
93
- }
94
- return [4, callback({ input: input, headers: headers, request: request })];
95
- case 1:
96
- responseData = _d.sent();
97
- return [2, {
98
- request: input,
99
- response: outputSchema instanceof zod_1.ZodAny ? responseData : outputSchema.parse(responseData),
100
- }];
101
- }
102
- });
103
- }); };
104
- };
105
75
  }
106
76
  HerbalController.prototype.$handleRequest = function (request) {
107
77
  var _a, _b, _c, _d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/herbal",
3
- "version": "1.0.2-alpha.27",
3
+ "version": "1.0.2-alpha.29",
4
4
  "description": "Herbal is a builder and toolchain for Nest.js applications",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {