@apipass/common 0.0.17-alpha.0 → 0.0.19-alpha.0

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.
@@ -0,0 +1,4 @@
1
+ import { ValidationPipe } from '@nestjs/common';
2
+ export declare class ClassValidatorPipe {
3
+ static getValidationPipe(): ValidationPipe;
4
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassValidatorPipe = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const _ = require("lodash");
6
+ class ClassValidatorPipe {
7
+ static getValidationPipe() {
8
+ return new common_1.ValidationPipe({ transform: true, exceptionFactory: (errors) => {
9
+ const exceptions = [];
10
+ errors.forEach(error => {
11
+ for (const key of Object.keys(error.constraints)) {
12
+ exceptions.push({
13
+ code: _.snakeCase(key).toUpperCase(),
14
+ message: error.constraints[key],
15
+ });
16
+ }
17
+ });
18
+ return new common_1.BadRequestException(exceptions);
19
+ } });
20
+ }
21
+ }
22
+ exports.ClassValidatorPipe = ClassValidatorPipe;
23
+ //# sourceMappingURL=class-validator.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-validator.pipe.js","sourceRoot":"","sources":["../../src/class-validator/class-validator.pipe.ts"],"names":[],"mappings":";;;AAAA,2CAAqE;AACrE,4BAA2B;AAE3B,MAAa,kBAAkB;IAEpB,MAAM,CAAC,iBAAiB;QAC3B,OAAO,IAAI,uBAAc,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,MAAa,EAAE,EAAE;gBAC7E,MAAM,UAAU,GAAQ,EAAE,CAAC;gBAC3B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;wBAChD,UAAU,CAAC,IAAI,CAAC;4BACd,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;4BACpC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC;yBAChC,CAAC,CAAA;qBACH;gBACH,CAAC,CAAC,CAAC;gBACH,OAAO,IAAI,4BAAmB,CAAC,UAAU,CAAC,CAAC;YAC7C,CAAC,EAAC,CACH,CAAA;IACL,CAAC;CAEJ;AAlBD,gDAkBC"}
@@ -0,0 +1,16 @@
1
+ declare type Either<S, F> = Success<S, F> | Failure<S, F>;
2
+ export declare class Success<S, F> {
3
+ readonly value: S;
4
+ constructor(value: S);
5
+ isSuccess(): this is Success<S, F>;
6
+ isFailure(): this is Failure<S, F>;
7
+ }
8
+ declare class Failure<S, F> {
9
+ readonly value: F;
10
+ constructor(value: F);
11
+ isSuccess(): this is Success<S, F>;
12
+ isFailure(): this is Failure<S, F>;
13
+ }
14
+ export declare const success: <S, F>(l: S) => Either<S, F>;
15
+ export declare const failure: <S, F>(a: F) => Either<S, F>;
16
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.failure = exports.success = exports.Success = void 0;
4
+ class Success {
5
+ constructor(value) {
6
+ this.value = value;
7
+ }
8
+ isSuccess() {
9
+ return true;
10
+ }
11
+ isFailure() {
12
+ return false;
13
+ }
14
+ }
15
+ exports.Success = Success;
16
+ class Failure {
17
+ constructor(value) {
18
+ this.value = value;
19
+ }
20
+ isSuccess() {
21
+ return false;
22
+ }
23
+ isFailure() {
24
+ return true;
25
+ }
26
+ }
27
+ const success = (l) => {
28
+ return new Success(l);
29
+ };
30
+ exports.success = success;
31
+ const failure = (a) => {
32
+ return new Failure(a);
33
+ };
34
+ exports.failure = failure;
35
+ //# sourceMappingURL=either.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"either.js","sourceRoot":"","sources":["../../src/either/either.ts"],"names":[],"mappings":";;;AAEA,MAAa,OAAO;IAGlB,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAdD,0BAcC;AAED,MAAM,OAAO;IAGX,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAEM,MAAM,OAAO,GAAG,CAAO,CAAI,EAAgB,EAAE;IAClD,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AAEK,MAAM,OAAO,GAAG,CAAO,CAAI,EAAgB,EAAE;IAClD,OAAO,IAAI,OAAO,CAAO,CAAC,CAAC,CAAC;AAC9B,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB"}
package/lib/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './environment/environment';
2
+ export * from './either/either';
3
+ export * from './class-validator/class-validator.pipe';
package/lib/index.js CHANGED
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./environment/environment"), exports);
18
+ __exportStar(require("./either/either"), exports);
19
+ __exportStar(require("./class-validator/class-validator.pipe"), exports);
18
20
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,kDAAgC;AAChC,yEAAuD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apipass/common",
3
- "version": "0.0.17-alpha.0",
3
+ "version": "0.0.19-alpha.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "Nathan Lemos <nathan@apipass.com.br>",
6
6
  "license": "ISC",
@@ -9,9 +9,6 @@
9
9
  "directories": {
10
10
  "lib": "lib"
11
11
  },
12
- "devDependencies": {
13
- "tunnel-ssh": "4.1.6"
14
- },
15
12
  "files": [
16
13
  "lib"
17
14
  ],
@@ -21,5 +18,13 @@
21
18
  "scripts": {
22
19
  "tsc": "tsc"
23
20
  },
24
- "gitHead": "446d18c608debba4f280d53f6cabf7e594b378a3"
21
+ "dependencies": {
22
+ "@nestjs/common": "9.2.1",
23
+ "lodash": "^4.17.21"
24
+ },
25
+ "devDependencies": {
26
+ "@types/lodash": "^4.14.191",
27
+ "tunnel-ssh": "4.1.6"
28
+ },
29
+ "gitHead": "6b082522817ff069718ec6855608b152b051d398"
25
30
  }