@thisisagile/easy 8.6.1 → 8.9.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.
- package/dist/services/AxiosProvider.js +1 -1
- package/dist/services/AxiosProvider.js.map +1 -1
- package/dist/validation/Contraints.d.ts +2 -0
- package/dist/validation/Contraints.js +11 -1
- package/dist/validation/Contraints.js.map +1 -1
- package/package.json +2 -2
- package/src/services/AxiosProvider.ts +2 -2
- package/src/validation/Contraints.ts +21 -1
|
@@ -18,7 +18,7 @@ class AxiosProvider {
|
|
|
18
18
|
.request({
|
|
19
19
|
url: uri.toString(),
|
|
20
20
|
method: verb.toString(),
|
|
21
|
-
headers: uri.isInternal ? options.bearer(types_1.ctx.request.jwt).headers : options.headers,
|
|
21
|
+
headers: uri.isInternal && (0, types_1.isEmpty)(options.headers.Authorization) ? options.bearer(types_1.ctx.request.jwt).headers : options.headers,
|
|
22
22
|
data: options.type.encode(body),
|
|
23
23
|
})
|
|
24
24
|
.then(r => (0, http_1.toResponse)(r.status, transform(r.data), r.headers))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosProvider.js","sourceRoot":"","sources":["../../src/services/AxiosProvider.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkD;AAClD,kCAA6H;AAC7H,
|
|
1
|
+
{"version":3,"file":"AxiosProvider.js","sourceRoot":"","sources":["../../src/services/AxiosProvider.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAkD;AAClD,kCAA6H;AAC7H,oCAAkE;AAClE,oCAAkC;AAElC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,KAAiB,EAAY,EAAE,CAC3E,IAAA,cAAM,EAAuB,KAAK,CAAC;KAChC,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,EAC1B,CAAC,CAAM,EAAE,EAAE,CACT,IAAA,iBAAU,EAAC,CAAC,C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AAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;YAC7H,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;SAChC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,iBAAU,EAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;aAC7D,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;CAAA;AAXD,sCAWC"}
|
|
@@ -14,4 +14,6 @@ export declare const lt: (limit: number, message?: Text | undefined) => Property
|
|
|
14
14
|
export declare const lte: (limit: number, message?: Text | undefined) => PropertyDecorator;
|
|
15
15
|
export declare const past: (message?: Text | undefined) => PropertyDecorator;
|
|
16
16
|
export declare const future: (message?: Text | undefined) => PropertyDecorator;
|
|
17
|
+
export declare const minLength: (length: number, message?: Text | undefined) => PropertyDecorator;
|
|
18
|
+
export declare const maxLength: (length: number, message?: Text | undefined) => PropertyDecorator;
|
|
17
19
|
export declare const rule: (message?: Text | undefined) => PropertyDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rule = exports.future = exports.past = exports.lte = exports.lt = exports.gte = exports.gt = exports.inList = exports.includes = exports.optional = exports.valid = exports.notEmpty = exports.required = exports.defined = exports.constraint = void 0;
|
|
3
|
+
exports.rule = exports.maxLength = exports.minLength = exports.future = exports.past = exports.lte = exports.lt = exports.gte = exports.gt = exports.inList = exports.includes = exports.optional = exports.valid = exports.notEmpty = exports.required = exports.defined = exports.constraint = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const Validate_1 = require("./Validate");
|
|
6
6
|
const constraint = (c, message) => (subject, property) => {
|
|
@@ -36,6 +36,16 @@ const past = (message) => (0, exports.constraint)(v => (0, types_1.inPast)(v), m
|
|
|
36
36
|
exports.past = past;
|
|
37
37
|
const future = (message) => (0, exports.constraint)(v => (0, types_1.inFuture)(v), message ?? 'Value {actual} must lay in the future.');
|
|
38
38
|
exports.future = future;
|
|
39
|
+
const minLength = (length, message) => (0, exports.constraint)(v => (0, types_1.tryTo)(() => v)
|
|
40
|
+
.is.defined()
|
|
41
|
+
.map(v => (0, types_1.text)(v).toString().length >= length)
|
|
42
|
+
.orElse(true), message ?? `Value {actual} must be at least '${length}' characters long.`);
|
|
43
|
+
exports.minLength = minLength;
|
|
44
|
+
const maxLength = (length, message) => (0, exports.constraint)(v => (0, types_1.tryTo)(() => v)
|
|
45
|
+
.is.defined()
|
|
46
|
+
.map(v => (0, types_1.text)(v).toString().length <= length)
|
|
47
|
+
.orElse(true), message ?? `Value {actual} cannot be longer than '${length}' characters.`);
|
|
48
|
+
exports.maxLength = maxLength;
|
|
39
49
|
const rule = (message) => (0, exports.constraint)(v => ((0, types_1.isFunction)(v) ? v() : false), message ?? `Value {actual} must be true`);
|
|
40
50
|
exports.rule = rule;
|
|
41
51
|
//# sourceMappingURL=Contraints.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contraints.js","sourceRoot":"","sources":["../../src/validation/Contraints.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Contraints.js","sourceRoot":"","sources":["../../src/validation/Contraints.ts"],"names":[],"mappings":";;;AAAA,oCAAqJ;AACrJ,yCAAiD;AAI1C,MAAM,UAAU,GACrB,CAAI,CAAa,EAAE,OAAa,EAAqB,EAAE,CACvD,CAAC,OAAgB,EAAE,QAAyB,EAAQ,EAAE;IACpD,MAAM,EAAE,GAAG,IAAA,YAAI,EAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,G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EAAE,CAAC,IAAA,YAAI,EAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,MAAM,CAAC;KAC7C,MAAM,CAAC,IAAI,CAAY,EAC5B,OAAO,IAAI,yCAAyC,MAAM,eAAe,CAC1E,CAAC;AARS,QAAA,SAAS,aAQlB;AAEG,MAAM,IAAI,GAAG,CAAC,OAAc,EAAqB,EAAE,CACxD,IAAA,kBAAU,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,kBAAU,EAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,EAAwB,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,OAAO,IAAI,6BAA6B,CAAC,CAAC;AADrG,QAAA,IAAI,QACiG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "8.
|
|
34
|
+
"@thisisagile/easy-test": "8.9.0",
|
|
35
35
|
"@types/form-urlencoded": "^4.4.0",
|
|
36
36
|
"@types/jsonwebtoken": "^8.5.6",
|
|
37
37
|
"@types/validator": "^13.7.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosError, Method } from 'axios';
|
|
2
2
|
import { HttpStatus, HttpVerb, isRestResult, Request, RequestOptions, RequestProvider, Response, toResponse } from '../http';
|
|
3
|
-
import { ctx, isDefined, toResult, Uri } from '../types';
|
|
3
|
+
import { ctx, isDefined, isEmpty, toResult, Uri } from '../types';
|
|
4
4
|
import { choose } from '../utils';
|
|
5
5
|
|
|
6
6
|
const asResponse = (uri: Uri, verb: HttpVerb, error: AxiosError): Response =>
|
|
@@ -22,7 +22,7 @@ export class AxiosProvider implements RequestProvider {
|
|
|
22
22
|
.request({
|
|
23
23
|
url: uri.toString(),
|
|
24
24
|
method: verb.toString() as Method,
|
|
25
|
-
headers: uri.isInternal ? options.bearer(ctx.request.jwt).headers : options.headers,
|
|
25
|
+
headers: uri.isInternal && isEmpty(options.headers.Authorization) ? options.bearer(ctx.request.jwt).headers : options.headers,
|
|
26
26
|
data: options.type.encode(body),
|
|
27
27
|
})
|
|
28
28
|
.then(r => toResponse(r.status, transform(r.data), r.headers))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Func, inFuture, inPast, isDefined, isFunction, isIn, isNotEmpty, isString, List, meta, Results, Text, toList } from '../types';
|
|
1
|
+
import { Func, inFuture, inPast, isDefined, isFunction, isIn, isNotEmpty, isString, List, meta, Results, text, Text, toList, tryTo } from '../types';
|
|
2
2
|
import { validate, Validator } from './Validate';
|
|
3
3
|
|
|
4
4
|
export type Constraint = Func<boolean | Results, any>;
|
|
@@ -43,5 +43,25 @@ export const past = (message?: Text): PropertyDecorator => constraint(v => inPas
|
|
|
43
43
|
|
|
44
44
|
export const future = (message?: Text): PropertyDecorator => constraint(v => inFuture(v), message ?? 'Value {actual} must lay in the future.');
|
|
45
45
|
|
|
46
|
+
export const minLength = (length: number, message?: Text): PropertyDecorator =>
|
|
47
|
+
constraint(
|
|
48
|
+
v =>
|
|
49
|
+
tryTo(() => v)
|
|
50
|
+
.is.defined()
|
|
51
|
+
.map(v => text(v).toString().length >= length)
|
|
52
|
+
.orElse(true) as boolean,
|
|
53
|
+
message ?? `Value {actual} must be at least '${length}' characters long.`
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const maxLength = (length: number, message?: Text): PropertyDecorator =>
|
|
57
|
+
constraint(
|
|
58
|
+
v =>
|
|
59
|
+
tryTo(() => v)
|
|
60
|
+
.is.defined()
|
|
61
|
+
.map(v => text(v).toString().length <= length)
|
|
62
|
+
.orElse(true) as boolean,
|
|
63
|
+
message ?? `Value {actual} cannot be longer than '${length}' characters.`
|
|
64
|
+
);
|
|
65
|
+
|
|
46
66
|
export const rule = (message?: Text): PropertyDecorator =>
|
|
47
67
|
constraint(v => (isFunction(v) ? (v() as boolean | Results) : false), message ?? `Value {actual} must be true`);
|