@open-norantec/herbal 2.0.0-alpha.2 → 2.0.0-alpha.4

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/core.d.ts CHANGED
@@ -4,7 +4,9 @@ import { Request, RequestContext } from './types/request.type';
4
4
  import { z } from '@open-norantec/utilities';
5
5
  import 'reflect-metadata';
6
6
  import { Request as ExpressRequest } from 'express';
7
+ import { ModuleRef } from '@nestjs/core';
7
8
  import { Constructor } from 'type-fest';
9
+ import { Sequelize } from 'sequelize-typescript';
8
10
  import { AuthAdapter } from './abstracts/auth-adapter.abstract.class';
9
11
  import { PathsObject } from 'openapi3-ts/oas31';
10
12
  export * from '@nestjs/core';
@@ -39,9 +41,9 @@ declare class MethodConfig<IS extends z.ZodType<any>, OS extends z.ZodType<any>,
39
41
  declare class MethodPool {
40
42
  protected readonly methods: Map<string, MethodConfig<any, any, any>>;
41
43
  registerMethod<IS extends z.ZodType<any>, OS extends z.ZodType<any>, C>(name: string, options: MethodRegisterOptions<IS, OS>, callback: MethodCallback<IS, OS, C>): void;
42
- transactionDisabled(name: string): boolean | undefined;
44
+ transactionDisabled(name?: string): boolean;
43
45
  getCallFn(name: string): ((controller: any, callContext: MethodCallContext<any>) => Promise<any>) | null;
44
- getAuthAdapters(name: string): Constructor<AuthAdapter>[] | null | undefined;
46
+ getAuthAdapters(name?: string): Constructor<AuthAdapter>[] | null | undefined;
45
47
  getOpenAPIPathsObject(group?: string): PathsObject;
46
48
  }
47
49
  export declare function isHerbalController(target: Function): boolean;
@@ -58,6 +60,15 @@ export interface ControllerUtilCreateOptions {
58
60
  useGuards?: Constructor<any>[];
59
61
  getTraceId?: (request: ExpressRequest) => string;
60
62
  }
63
+ export declare function parseRequest({ request, traceId: inputTraceId, sequelize: sequelizeInstance, moduleRef, handlerName, handlerPrototype, onLog, }: {
64
+ handlerPrototype: object;
65
+ moduleRef: ModuleRef;
66
+ request: Request;
67
+ handlerName?: string;
68
+ sequelize?: Sequelize;
69
+ traceId?: string;
70
+ onLog?: (methodName: string, message: string) => void;
71
+ }): Promise<void>;
61
72
  export declare function getMethodPool(targetPrototype: object): MethodPool | null;
62
73
  export declare class ControllerUtil {
63
74
  static create(createOptions?: ControllerUtilCreateOptions): {
@@ -66,3 +77,4 @@ export declare class ControllerUtil {
66
77
  getControllerName: typeof getControllerName;
67
78
  };
68
79
  }
80
+ export declare function getRequestHandler(controller: object): ((request: Request) => Promise<any>) | null;
package/dist/core.js CHANGED
@@ -86,7 +86,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
86
86
  return to.concat(ar || Array.prototype.slice.call(from));
87
87
  };
88
88
  Object.defineProperty(exports, "__esModule", { value: true });
89
- exports.ControllerUtil = exports.getMethodPool = exports.getControllerName = exports.isHerbalController = void 0;
89
+ exports.getRequestHandler = exports.ControllerUtil = exports.getMethodPool = exports.parseRequest = exports.getControllerName = exports.isHerbalController = void 0;
90
90
  require("reflect-metadata");
91
91
  var common_1 = require("@nestjs/common");
92
92
  var header_util_class_1 = require("@open-norantec/utilities/dist/header-util.class");
@@ -173,7 +173,7 @@ var MethodPool = (function () {
173
173
  MethodPool.prototype.transactionDisabled = function (name) {
174
174
  var _a, _b;
175
175
  if (string_util_class_1.StringUtil.isFalsyString(name))
176
- return;
176
+ return false;
177
177
  if (name.includes('/'))
178
178
  throw new Error("Method name cannot contain slashes: ".concat(name));
179
179
  return !!((_b = (_a = this.methods.get(name)) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.disableTransaction);
@@ -185,6 +185,8 @@ var MethodPool = (function () {
185
185
  return config.call.bind(config);
186
186
  };
187
187
  MethodPool.prototype.getAuthAdapters = function (name) {
188
+ if (string_util_class_1.StringUtil.isFalsyString(name))
189
+ return null;
188
190
  var config = this.methods.get(name);
189
191
  if (!(config instanceof MethodConfig))
190
192
  return null;
@@ -303,22 +305,176 @@ var ControllerInterceptor = (function () {
303
305
  ], ControllerInterceptor);
304
306
  return ControllerInterceptor;
305
307
  }());
308
+ function parseRequest(_a) {
309
+ var _b, request_1, request_1_1;
310
+ var _c, e_1, _d, _e;
311
+ var _f, _g, _h, _j, _k;
312
+ var request = _a.request, inputTraceId = _a.traceId, sequelizeInstance = _a.sequelize, moduleRef = _a.moduleRef, handlerName = _a.handlerName, handlerPrototype = _a.handlerPrototype, onLog = _a.onLog;
313
+ return __awaiter(this, void 0, void 0, function () {
314
+ var transaction, chunks_1, chunk, e_1_1, _l, parsedBody, methodPool, authAdapters, shouldHaveTransaction, error_2, authSucceeded, error_3, _m;
315
+ var _this = this;
316
+ return __generator(this, function (_o) {
317
+ switch (_o.label) {
318
+ case 0:
319
+ transaction = undefined;
320
+ request.traceId = string_util_class_1.StringUtil.isFalsyString(inputTraceId) ? uuid_util_class_1.UUIDUtil.generateV4() : inputTraceId;
321
+ request.methodName = request.url.split('/').pop();
322
+ if (!(typeof request.rawBody === 'undefined')) return [3, 16];
323
+ chunks_1 = [];
324
+ _o.label = 1;
325
+ case 1:
326
+ _o.trys.push([1, 14, , 15]);
327
+ _o.label = 2;
328
+ case 2:
329
+ _o.trys.push([2, 7, 8, 13]);
330
+ _b = true, request_1 = __asyncValues(request);
331
+ _o.label = 3;
332
+ case 3: return [4, request_1.next()];
333
+ case 4:
334
+ if (!(request_1_1 = _o.sent(), _c = request_1_1.done, !_c)) return [3, 6];
335
+ _e = request_1_1.value;
336
+ _b = false;
337
+ chunk = _e;
338
+ chunks_1.push(chunk);
339
+ _o.label = 5;
340
+ case 5:
341
+ _b = true;
342
+ return [3, 3];
343
+ case 6: return [3, 13];
344
+ case 7:
345
+ e_1_1 = _o.sent();
346
+ e_1 = { error: e_1_1 };
347
+ return [3, 13];
348
+ case 8:
349
+ _o.trys.push([8, , 11, 12]);
350
+ if (!(!_b && !_c && (_d = request_1.return))) return [3, 10];
351
+ return [4, _d.call(request_1)];
352
+ case 9:
353
+ _o.sent();
354
+ _o.label = 10;
355
+ case 10: return [3, 12];
356
+ case 11:
357
+ if (e_1) throw e_1.error;
358
+ return [7];
359
+ case 12: return [7];
360
+ case 13: return [3, 15];
361
+ case 14:
362
+ _l = _o.sent();
363
+ return [3, 15];
364
+ case 15:
365
+ parsedBody = _.attempt(function () { return Buffer.concat(chunks_1).toString('utf8'); });
366
+ if (!(parsedBody instanceof Error)) {
367
+ request.rawBody = parsedBody;
368
+ }
369
+ else {
370
+ request.rawBody = null;
371
+ }
372
+ _o.label = 16;
373
+ case 16:
374
+ _.attempt(function () { return onLog === null || onLog === void 0 ? void 0 : onLog('log', "[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":request:body] ").concat(request.rawBody)); });
375
+ methodPool = getMethodPool(handlerPrototype);
376
+ authAdapters = (_f = methodPool === null || methodPool === void 0 ? void 0 : methodPool.getAuthAdapters) === null || _f === void 0 ? void 0 : _f.call(methodPool, request.methodName);
377
+ if (authAdapters === null)
378
+ authAdapters = auth_adapter_decorator_1.AuthAdapters.getAdapters(handlerPrototype, handlerName);
379
+ shouldHaveTransaction = !decorators_1.NoTransaction.isDisabled(handlerPrototype, handlerName) && !((_g = methodPool === null || methodPool === void 0 ? void 0 : methodPool.transactionDisabled) === null || _g === void 0 ? void 0 : _g.call(methodPool, request.methodName));
380
+ if (!(sequelizeInstance instanceof sequelize_typescript_1.Sequelize && shouldHaveTransaction)) return [3, 21];
381
+ _o.label = 17;
382
+ case 17:
383
+ _o.trys.push([17, 19, , 20]);
384
+ return [4, ((_j = (_h = sequelizeInstance === null || sequelizeInstance === void 0 ? void 0 : sequelizeInstance.transaction) === null || _h === void 0 ? void 0 : _h.call(sequelizeInstance)) === null || _j === void 0 ? void 0 : _j.catch(function () { return Promise.resolve(undefined); }))];
385
+ case 18:
386
+ transaction = _o.sent();
387
+ request.transaction = transaction;
388
+ onLog === null || onLog === void 0 ? void 0 : onLog('log', "[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Started transaction for route: ").concat(request.url));
389
+ return [3, 20];
390
+ case 19:
391
+ error_2 = _o.sent();
392
+ if (error_2 instanceof Error) {
393
+ onLog === null || onLog === void 0 ? void 0 : onLog('error', "[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Failed to start transaction: ").concat(error_2 === null || error_2 === void 0 ? void 0 : error_2.message, "\n").concat(error_2 === null || error_2 === void 0 ? void 0 : error_2.stack));
394
+ }
395
+ return [3, 20];
396
+ case 20: return [3, 22];
397
+ case 21:
398
+ if (!shouldHaveTransaction) {
399
+ onLog === null || onLog === void 0 ? void 0 : onLog('log', "[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Transaction is disabled for this route: ").concat(request.url));
400
+ }
401
+ else {
402
+ throw new Error('Sequelize instance not found, cannot start transaction');
403
+ }
404
+ _o.label = 22;
405
+ case 22:
406
+ _o.trys.push([22, 25, , 30]);
407
+ if (!(Array.isArray(authAdapters) && authAdapters.length > 0 && typeof request.authenticateResult === 'undefined')) return [3, 24];
408
+ return [4, (function () { return __awaiter(_this, void 0, void 0, function () {
409
+ var _i, authAdapters_1, AuthAdapterClass, adapter, authenticateResult;
410
+ return __generator(this, function (_a) {
411
+ switch (_a.label) {
412
+ case 0:
413
+ _i = 0, authAdapters_1 = authAdapters;
414
+ _a.label = 1;
415
+ case 1:
416
+ if (!(_i < authAdapters_1.length)) return [3, 4];
417
+ AuthAdapterClass = authAdapters_1[_i];
418
+ adapter = new AuthAdapterClass(request, moduleRef);
419
+ if (!adapter.match())
420
+ return [3, 3];
421
+ return [4, adapter.authenticate(transaction)];
422
+ case 2:
423
+ authenticateResult = _a.sent();
424
+ if (!authenticateResult)
425
+ return [3, 4];
426
+ request.authenticateResult = __assign({ AuthenticatorClass: AuthAdapterClass }, authenticateResult);
427
+ return [2, true];
428
+ case 3:
429
+ _i++;
430
+ return [3, 1];
431
+ case 4: return [2, false];
432
+ }
433
+ });
434
+ }); })()];
435
+ case 23:
436
+ authSucceeded = _o.sent();
437
+ if (!authSucceeded)
438
+ throw new common_3.UnauthorizedException();
439
+ _o.label = 24;
440
+ case 24: return [3, 30];
441
+ case 25:
442
+ error_3 = _o.sent();
443
+ _o.label = 26;
444
+ case 26:
445
+ _o.trys.push([26, 28, , 29]);
446
+ if (error_3 instanceof Error) {
447
+ onLog === null || onLog === void 0 ? void 0 : onLog('error', "[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":error] Got error when handling route: ").concat(error_3 === null || error_3 === void 0 ? void 0 : error_3.message, " ").concat(error_3 === null || error_3 === void 0 ? void 0 : error_3.stack));
448
+ }
449
+ return [4, ((_k = transaction === null || transaction === void 0 ? void 0 : transaction.rollback) === null || _k === void 0 ? void 0 : _k.call(transaction))];
450
+ case 27:
451
+ _o.sent();
452
+ return [3, 29];
453
+ case 28:
454
+ _m = _o.sent();
455
+ return [3, 29];
456
+ case 29: throw error_3;
457
+ case 30: return [2];
458
+ }
459
+ });
460
+ });
461
+ }
462
+ exports.parseRequest = parseRequest;
306
463
  function HerbalGuard(options) {
307
464
  var HerbalGuardMixin = (function () {
308
465
  function HerbalGuardMixin(ref) {
309
466
  this.ref = ref;
310
467
  }
311
468
  HerbalGuardMixin.prototype.canActivate = function (context) {
312
- var _a, e_1, _b, _c;
313
- var _d, _e, _f, _g, _h, _j, _k, _l, _m;
469
+ var _a, _b, _c, _d, _e;
314
470
  return __awaiter(this, void 0, void 0, function () {
315
- var sequelizeInstance, transaction, request, response, traceId, chunks, _o, request_1, request_1_1, chunk, e_1_1, _p, parsedBody, rawHandlerName, handlerPropertype, handlerName, methodPool, authAdapters, error_2, _i, authAdapters_1, AuthAdapterClass, adapter, authenticateResult, error_3, _q;
471
+ var logger, sequelizeInstance, request, response, traceId;
316
472
  var _this = this;
317
- return __generator(this, function (_r) {
318
- switch (_r.label) {
473
+ return __generator(this, function (_f) {
474
+ switch (_f.label) {
319
475
  case 0:
476
+ logger = this.getLogger();
320
477
  sequelizeInstance = _.attempt(function () { return _this.ref.get(sequelize_typescript_1.Sequelize, { strict: false }); });
321
- transaction = undefined;
322
478
  request = context.switchToHttp().getRequest();
323
479
  response = context.switchToHttp().getResponse();
324
480
  traceId = typeof (options === null || options === void 0 ? void 0 : options.getTraceId) === 'function'
@@ -326,130 +482,25 @@ function HerbalGuard(options) {
326
482
  : uuid_util_class_1.UUIDUtil.generateV4();
327
483
  if (traceId instanceof Error || string_util_class_1.StringUtil.isFalsyString(traceId))
328
484
  traceId = uuid_util_class_1.UUIDUtil.generateV4();
329
- request.traceId = traceId;
330
- request.methodName = request.url.split('/').pop();
331
- response.setHeader(headers_constant_1.HEADERS.TRACE_ID, traceId);
332
- chunks = [];
333
- _r.label = 1;
485
+ return [4, parseRequest({
486
+ request: request,
487
+ moduleRef: this.ref,
488
+ sequelize: sequelizeInstance instanceof Error ? undefined : sequelizeInstance,
489
+ handlerPrototype: (_c = (_b = (_a = context === null || context === void 0 ? void 0 : context.getClass) === null || _a === void 0 ? void 0 : _a.call(context)) === null || _b === void 0 ? void 0 : _b.prototype) !== null && _c !== void 0 ? _c : {},
490
+ handlerName: (_e = (_d = context === null || context === void 0 ? void 0 : context.getHandler) === null || _d === void 0 ? void 0 : _d.call(context)) === null || _e === void 0 ? void 0 : _e.name,
491
+ traceId: traceId,
492
+ onLog: function (method, message) {
493
+ var _a;
494
+ try {
495
+ (_a = logger[method]) === null || _a === void 0 ? void 0 : _a.call(logger, message);
496
+ }
497
+ catch (_b) { }
498
+ },
499
+ })];
334
500
  case 1:
335
- _r.trys.push([1, 14, , 15]);
336
- _r.label = 2;
337
- case 2:
338
- _r.trys.push([2, 7, 8, 13]);
339
- _o = true, request_1 = __asyncValues(request);
340
- _r.label = 3;
341
- case 3: return [4, request_1.next()];
342
- case 4:
343
- if (!(request_1_1 = _r.sent(), _a = request_1_1.done, !_a)) return [3, 6];
344
- _c = request_1_1.value;
345
- _o = false;
346
- chunk = _c;
347
- chunks.push(chunk);
348
- _r.label = 5;
349
- case 5:
350
- _o = true;
351
- return [3, 3];
352
- case 6: return [3, 13];
353
- case 7:
354
- e_1_1 = _r.sent();
355
- e_1 = { error: e_1_1 };
356
- return [3, 13];
357
- case 8:
358
- _r.trys.push([8, , 11, 12]);
359
- if (!(!_o && !_a && (_b = request_1.return))) return [3, 10];
360
- return [4, _b.call(request_1)];
361
- case 9:
362
- _r.sent();
363
- _r.label = 10;
364
- case 10: return [3, 12];
365
- case 11:
366
- if (e_1) throw e_1.error;
367
- return [7];
368
- case 12: return [7];
369
- case 13: return [3, 15];
370
- case 14:
371
- _p = _r.sent();
372
- return [3, 15];
373
- case 15:
374
- parsedBody = _.attempt(function () { return Buffer.concat(chunks).toString('utf8'); });
375
- if (!(parsedBody instanceof Error)) {
376
- request.rawBody = parsedBody;
377
- }
378
- else {
379
- request.rawBody = null;
380
- }
381
- _.attempt(function () { return _this.getLogger().log("[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":request:body] ").concat(request.rawBody)); });
382
- rawHandlerName = (_e = (_d = context === null || context === void 0 ? void 0 : context.getHandler) === null || _d === void 0 ? void 0 : _d.call(context)) === null || _e === void 0 ? void 0 : _e.name;
383
- handlerPropertype = (_g = (_f = context === null || context === void 0 ? void 0 : context.getClass) === null || _f === void 0 ? void 0 : _f.call(context)) === null || _g === void 0 ? void 0 : _g.prototype;
384
- handlerName = string_util_class_1.StringUtil.isFalsyString(request.methodName) ? rawHandlerName : request.methodName;
385
- methodPool = getMethodPool(handlerPropertype);
386
- authAdapters = (_h = methodPool === null || methodPool === void 0 ? void 0 : methodPool.getAuthAdapters) === null || _h === void 0 ? void 0 : _h.call(methodPool, handlerName);
387
- if (authAdapters === null)
388
- authAdapters = auth_adapter_decorator_1.AuthAdapters.getAdapters(handlerPropertype, handlerName);
389
- if (!(!(sequelizeInstance instanceof Error) &&
390
- !decorators_1.NoTransaction.isDisabled(handlerPropertype, rawHandlerName) &&
391
- !((_j = methodPool === null || methodPool === void 0 ? void 0 : methodPool.transactionDisabled) === null || _j === void 0 ? void 0 : _j.call(methodPool, handlerName)))) return [3, 20];
392
- _r.label = 16;
393
- case 16:
394
- _r.trys.push([16, 18, , 19]);
395
- return [4, ((_l = (_k = sequelizeInstance === null || sequelizeInstance === void 0 ? void 0 : sequelizeInstance.transaction) === null || _k === void 0 ? void 0 : _k.call(sequelizeInstance)) === null || _l === void 0 ? void 0 : _l.catch(function () { return Promise.resolve(undefined); }))];
396
- case 17:
397
- transaction = _r.sent();
398
- request.transaction = transaction;
399
- this.getLogger().log("[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Started transaction for route: ").concat(handlerName));
400
- return [3, 19];
401
- case 18:
402
- error_2 = _r.sent();
403
- if (error_2 instanceof Error) {
404
- this.getLogger().error("[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Failed to start transaction: ").concat(error_2 === null || error_2 === void 0 ? void 0 : error_2.message, "\n").concat(error_2 === null || error_2 === void 0 ? void 0 : error_2.stack));
405
- }
406
- return [3, 19];
407
- case 19: return [3, 21];
408
- case 20:
409
- if (decorators_1.NoTransaction.isDisabled(handlerPropertype, handlerName)) {
410
- this.getLogger().log("[trace:".concat(request === null || request === void 0 ? void 0 : request.traceId, ":transaction] Transaction is disabled for this route: ").concat(handlerName));
411
- }
412
- _r.label = 21;
413
- case 21:
414
- _r.trys.push([21, 27, , 32]);
415
- if (!(Array.isArray(authAdapters) && authAdapters.length > 0)) return [3, 26];
416
- _i = 0, authAdapters_1 = authAdapters;
417
- _r.label = 22;
418
- case 22:
419
- if (!(_i < authAdapters_1.length)) return [3, 25];
420
- AuthAdapterClass = authAdapters_1[_i];
421
- adapter = new AuthAdapterClass(request, this.ref);
422
- if (!adapter.match())
423
- return [3, 24];
424
- return [4, adapter.authenticate(transaction)];
425
- case 23:
426
- authenticateResult = _r.sent();
427
- if (!authenticateResult)
428
- return [3, 25];
429
- request.authenticateResult = __assign({ AuthenticatorClass: AuthAdapterClass }, authenticateResult);
501
+ _f.sent();
502
+ response.setHeader(headers_constant_1.HEADERS.TRACE_ID, traceId);
430
503
  return [2, true];
431
- case 24:
432
- _i++;
433
- return [3, 22];
434
- case 25: throw new common_3.UnauthorizedException();
435
- case 26: return [3, 32];
436
- case 27:
437
- error_3 = _r.sent();
438
- _r.label = 28;
439
- case 28:
440
- _r.trys.push([28, 30, , 31]);
441
- if (error_3 instanceof Error) {
442
- this.getLogger().error("Got error when handling route: ".concat(error_3 === null || error_3 === void 0 ? void 0 : error_3.message, " ").concat(error_3 === null || error_3 === void 0 ? void 0 : error_3.stack));
443
- }
444
- return [4, ((_m = transaction === null || transaction === void 0 ? void 0 : transaction.rollback) === null || _m === void 0 ? void 0 : _m.call(transaction))];
445
- case 29:
446
- _r.sent();
447
- return [3, 31];
448
- case 30:
449
- _q = _r.sent();
450
- return [3, 31];
451
- case 31: throw error_3;
452
- case 32: return [2, true];
453
504
  }
454
505
  });
455
506
  });
@@ -570,7 +621,7 @@ var ControllerUtil = (function () {
570
621
  Object.defineProperty(target.prototype, HANDLE_REQUEST_INSTANCE_SYMBOL, {
571
622
  enumerable: false,
572
623
  writable: false,
573
- value: function (request) {
624
+ value: function $herbalInternal(request) {
574
625
  return handleRequest.call(this, request);
575
626
  },
576
627
  });
@@ -593,3 +644,16 @@ var ControllerUtil = (function () {
593
644
  return ControllerUtil;
594
645
  }());
595
646
  exports.ControllerUtil = ControllerUtil;
647
+ function getRequestHandler(controller) {
648
+ var _a;
649
+ try {
650
+ var requestHandler = (_a = Object.getOwnPropertyDescriptor(controller, HANDLE_REQUEST_INSTANCE_SYMBOL)) === null || _a === void 0 ? void 0 : _a.value;
651
+ if (typeof requestHandler !== 'function')
652
+ return null;
653
+ return requestHandler;
654
+ }
655
+ catch (_b) {
656
+ return null;
657
+ }
658
+ }
659
+ exports.getRequestHandler = getRequestHandler;
@@ -3,5 +3,5 @@ import { Constructor } from 'type-fest';
3
3
  import { AuthAdapter } from '../abstracts/auth-adapter.abstract.class';
4
4
  export declare function AuthAdapters(adapters?: Constructor<AuthAdapter>[]): PropertyDecorator;
5
5
  export declare namespace AuthAdapters {
6
- var getAdapters: (target: object, propertyKey: string) => Constructor<AuthAdapter>[];
6
+ var getAdapters: (target: object, propertyKey?: string | undefined) => Constructor<AuthAdapter>[];
7
7
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthAdapters = void 0;
4
4
  require("reflect-metadata");
5
5
  var _ = require("lodash");
6
+ var utilities_1 = require("@open-norantec/utilities");
6
7
  var AUTH_ADAPTERS = Symbol();
7
8
  function AuthAdapters(adapters) {
8
9
  return function (target, propertyKey) {
@@ -11,6 +12,8 @@ function AuthAdapters(adapters) {
11
12
  }
12
13
  exports.AuthAdapters = AuthAdapters;
13
14
  AuthAdapters.getAdapters = function (target, propertyKey) {
15
+ if (utilities_1.StringUtil.isFalsyString(propertyKey))
16
+ return [];
14
17
  var result = _.attempt(function () { return Reflect.getMetadata(AUTH_ADAPTERS, target, propertyKey); });
15
18
  if (Array.isArray(result))
16
19
  return result;
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
2
  export declare function NoTransaction(): PropertyDecorator;
3
3
  export declare namespace NoTransaction {
4
- var isDisabled: (target: object, propertyKey: string) => boolean;
4
+ var isDisabled: (target: object, propertyKey?: string | undefined) => boolean;
5
5
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NoTransaction = void 0;
4
4
  require("reflect-metadata");
5
5
  var _ = require("lodash");
6
+ var string_util_class_1 = require("@open-norantec/utilities/dist/string-util.class");
6
7
  var TRANSACTION_DISABLED = Symbol();
7
8
  function NoTransaction() {
8
9
  return function (target, propertyKey) {
@@ -11,6 +12,8 @@ function NoTransaction() {
11
12
  }
12
13
  exports.NoTransaction = NoTransaction;
13
14
  NoTransaction.isDisabled = function (target, propertyKey) {
15
+ if (string_util_class_1.StringUtil.isFalsyString(propertyKey))
16
+ return false;
14
17
  var result = _.attempt(function () { return Reflect.getMetadata(TRANSACTION_DISABLED, target, propertyKey); });
15
18
  return result === true;
16
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/herbal",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "Herbal is a builder and toolchain for Nest.js applications",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {