@tstdl/base 0.78.1 → 0.78.3
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/notification/api.d.ts +1 -3
- package/package.json +1 -1
- package/schema/coercers/index.d.ts +0 -1
- package/schema/coercers/index.js +0 -1
- package/schema/coercers/index.js.map +1 -1
- package/schema/constraints/maximum-length.js +1 -1
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/minimum-length.js +1 -1
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/schema.d.ts +10 -10
- package/schema/schema.js +16 -19
- package/schema/schema.js.map +1 -1
- package/schema/schemas/any.d.ts +4 -3
- package/schema/schemas/any.js +4 -4
- package/schema/schemas/any.js.map +1 -1
- package/schema/schemas/array.d.ts +5 -5
- package/schema/schemas/array.js +3 -2
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/assign.d.ts +5 -5
- package/schema/schemas/boolean.d.ts +2 -2
- package/schema/schemas/boolean.js +1 -3
- package/schema/schemas/boolean.js.map +1 -1
- package/schema/schemas/constraint.d.ts +1 -1
- package/schema/schemas/constraint.js.map +1 -1
- package/schema/schemas/date.d.ts +2 -2
- package/schema/schemas/date.js +3 -2
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/defaulted.d.ts +1 -1
- package/schema/schemas/defaulted.js +2 -4
- package/schema/schemas/defaulted.js.map +1 -1
- package/schema/schemas/enumeration.d.ts +2 -2
- package/schema/schemas/enumeration.js +7 -4
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/instance.d.ts +3 -2
- package/schema/schemas/instance.js +2 -2
- package/schema/schemas/instance.js.map +1 -1
- package/schema/schemas/literal.d.ts +3 -2
- package/schema/schemas/literal.js +7 -3
- package/schema/schemas/literal.js.map +1 -1
- package/schema/schemas/nullable.d.ts +3 -2
- package/schema/schemas/nullable.js +2 -2
- package/schema/schemas/nullable.js.map +1 -1
- package/schema/schemas/number.d.ts +2 -2
- package/schema/schemas/number.js +7 -6
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/object.d.ts +1 -1
- package/schema/schemas/object.js.map +1 -1
- package/schema/schemas/one-or-many.d.ts +4 -8
- package/schema/schemas/one-or-many.js +5 -2
- package/schema/schemas/one-or-many.js.map +1 -1
- package/schema/schemas/optional.d.ts +3 -2
- package/schema/schemas/optional.js +2 -2
- package/schema/schemas/optional.js.map +1 -1
- package/schema/schemas/readable-stream.d.ts +4 -2
- package/schema/schemas/readable-stream.js +2 -2
- package/schema/schemas/readable-stream.js.map +1 -1
- package/schema/schemas/record.d.ts +1 -1
- package/schema/schemas/record.js.map +1 -1
- package/schema/schemas/regexp.d.ts +2 -2
- package/schema/schemas/regexp.js +2 -4
- package/schema/schemas/regexp.js.map +1 -1
- package/schema/schemas/string.d.ts +2 -2
- package/schema/schemas/string.js +8 -7
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/transform.d.ts +3 -3
- package/schema/schemas/transform.js +2 -2
- package/schema/schemas/transform.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +4 -2
- package/schema/schemas/uint8-array.js +11 -5
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/schemas/union.d.ts +4 -2
- package/schema/schemas/union.js +5 -3
- package/schema/schemas/union.js.map +1 -1
- package/schema/schemas/unknown.d.ts +4 -3
- package/schema/schemas/unknown.js +6 -6
- package/schema/schemas/unknown.js.map +1 -1
- package/schema/transformers/generic.d.ts +8 -9
- package/schema/transformers/generic.js +4 -10
- package/schema/transformers/generic.js.map +1 -1
- package/schema/transformers/lowercase.d.ts +1 -2
- package/schema/transformers/lowercase.js +1 -2
- package/schema/transformers/lowercase.js.map +1 -1
- package/schema/transformers/trim.d.ts +1 -2
- package/schema/transformers/trim.js +1 -2
- package/schema/transformers/trim.js.map +1 -1
- package/schema/transformers/uppercase.d.ts +1 -2
- package/schema/transformers/uppercase.js +1 -2
- package/schema/transformers/uppercase.js.map +1 -1
- package/schema/types.d.ts +41 -44
- package/schema/types.js +11 -2
- package/schema/types.js.map +1 -1
- package/schema/utils/schema.d.ts +5 -5
- package/schema/utils/schema.js +2 -2
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +1 -0
- package/schema/utils/value-type.js +10 -1
- package/schema/utils/value-type.js.map +1 -1
- package/schema/coercers/default-value.coercer.d.ts +0 -9
- package/schema/coercers/default-value.coercer.js +0 -16
- package/schema/coercers/default-value.coercer.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare type NumberOptions =
|
|
2
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
3
|
+
export declare type NumberOptions = ValueSchemaOptions & {
|
|
4
4
|
minimum?: number;
|
|
5
5
|
maximum?: number;
|
|
6
6
|
integer?: boolean;
|
package/schema/schemas/number.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Number = exports.number = void 0;
|
|
5
|
+
const array_1 = require("../../utils/array/array");
|
|
5
6
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
7
|
const integer_1 = require("../constraints/integer");
|
|
7
8
|
const maximum_1 = require("../constraints/maximum");
|
|
@@ -9,19 +10,19 @@ const minimum_1 = require("../constraints/minimum");
|
|
|
9
10
|
const decorators_1 = require("../decorators");
|
|
10
11
|
const types_1 = require("../types");
|
|
11
12
|
function number(options = {}) {
|
|
12
|
-
const
|
|
13
|
+
const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
|
|
13
14
|
if ((0, type_guards_1.isDefined)(options.minimum)) {
|
|
14
|
-
|
|
15
|
+
valueConstraints.push(new minimum_1.MinimumConstraint(options.minimum));
|
|
15
16
|
}
|
|
16
17
|
if ((0, type_guards_1.isDefined)(options.maximum)) {
|
|
17
|
-
|
|
18
|
+
valueConstraints.push(new maximum_1.MaximumConstraint(options.maximum));
|
|
18
19
|
}
|
|
19
20
|
if (options.integer == true) {
|
|
20
|
-
|
|
21
|
+
valueConstraints.push(integer_1.integerConstraint);
|
|
21
22
|
}
|
|
22
23
|
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Number), {
|
|
23
|
-
|
|
24
|
-
valueConstraints
|
|
24
|
+
...options,
|
|
25
|
+
valueConstraints
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
exports.number = number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;AAExE,oCAAmD;AAQnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../source/schema/schemas/number.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,mDAA8C;AAC9C,yDAAgD;AAChD,oDAA2D;AAC3D,oDAA2D;AAC3D,oDAA2D;AAC3D,8CAAwE;AAExE,oCAAmD;AAQnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,gBAAgB,GAA4B,IAAA,eAAO,EAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAE1F,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,gBAAgB,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,gBAAgB,CAAC,IAAI,CAAC,IAAI,2BAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/D;IAED,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE;QAC3B,gBAAgB,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;KAC1C;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,GAAG,OAAO;QACV,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AAnBD,wBAmBC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -2,4 +2,4 @@ import type { Record, SimplifiedOptionalize, TypedOmit } from "../../types";
|
|
|
2
2
|
import type { ObjectSchema, ObjectSchemaProperties } from '../types';
|
|
3
3
|
export declare type ObjectOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties'>;
|
|
4
4
|
export declare function explicitObject<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<T>;
|
|
5
|
-
export declare function object<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<SimplifiedOptionalize<T
|
|
5
|
+
export declare function object<T extends Record>(properties: ObjectSchemaProperties<T>, options?: ObjectOptions<T>): ObjectSchema<SimplifiedOptionalize<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,cAAc,CAAmB,UAAqC,EAAE,OAA0B;IAChH,OAAO,MAAM,CAAC,UAAU,EAAE,OAAO,CAA2B,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED,SAAgB,MAAM,CAAmB,UAAqC,EAAE,OAA0B;IACxG,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU;QACV,GAAG,OAAO;KACX,
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/schema/schemas/object.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,oCAAwC;AAIxC,SAAgB,cAAc,CAAmB,UAAqC,EAAE,OAA0B;IAChH,OAAO,MAAM,CAAC,UAAU,EAAE,OAAO,CAA2B,CAAC;AAC/D,CAAC;AAFD,wCAEC;AAED,SAAgB,MAAM,CAAmB,UAAqC,EAAE,OAA0B;IACxG,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU;QACV,GAAG,OAAO;KACX,CAAsD,CAAC;AAC1D,CAAC;AALD,wBAKC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { OneOrMany } from "../../types";
|
|
2
2
|
import type { SchemaTestable } from '../schema';
|
|
3
|
-
import type { ValueSchema } from '../types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** maximum array length */
|
|
8
|
-
maximumLength?: number;
|
|
9
|
-
};
|
|
10
|
-
export declare function oneOrMany<T, O = T>(innerValues: OneOrMany<SchemaTestable<T, O>>, options?: OneOrManyOptions): ValueSchema<T, O | O[]>;
|
|
3
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
4
|
+
import { ArrayOptions } from './array';
|
|
5
|
+
export declare type OneOrManyOptions = ValueSchemaOptions & Pick<ArrayOptions, 'minimumLength' | 'maximumLength'>;
|
|
6
|
+
export declare function oneOrMany<T>(innerValues: OneOrMany<SchemaTestable<T>>, options?: OneOrManyOptions): ValueSchema<T | T[]>;
|
|
@@ -5,8 +5,11 @@ exports.oneOrMany = void 0;
|
|
|
5
5
|
const array_1 = require("../../utils/array");
|
|
6
6
|
const array_2 = require("./array");
|
|
7
7
|
const union_1 = require("./union");
|
|
8
|
-
function oneOrMany(innerValues, options
|
|
9
|
-
return (0, union_1.union)(
|
|
8
|
+
function oneOrMany(innerValues, options) {
|
|
9
|
+
return (0, union_1.union)([
|
|
10
|
+
(0, array_2.array)(innerValues, { minimumLength: options?.minimumLength, maximumLength: options?.maximumLength }),
|
|
11
|
+
...(0, array_1.toArray)(innerValues)
|
|
12
|
+
], options);
|
|
10
13
|
}
|
|
11
14
|
exports.oneOrMany = oneOrMany;
|
|
12
15
|
//# sourceMappingURL=one-or-many.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-or-many.js","sourceRoot":"","sources":["../../../source/schema/schemas/one-or-many.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,6CAAwC;AAGxC,
|
|
1
|
+
{"version":3,"file":"one-or-many.js","sourceRoot":"","sources":["../../../source/schema/schemas/one-or-many.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,6CAAwC;AAGxC,mCAA8C;AAC9C,mCAAgC;AAIhC,SAAgB,SAAS,CAAI,WAAyC,EAAE,OAA0B;IAChG,OAAO,IAAA,aAAK,EACV;QACE,IAAA,aAAK,EAAC,WAAW,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;QACpG,GAAG,IAAA,eAAO,EAAC,WAAW,CAAC;KACxB,EACD,OAAO,CACgB,CAAC;AAC5B,CAAC;AARD,8BAQC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OneOrMany } from "../../types";
|
|
2
2
|
import type { SchemaTestable } from '../schema';
|
|
3
|
-
import type { ValueSchema } from '../types';
|
|
4
|
-
export declare
|
|
3
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
4
|
+
export declare type OptionalOptions = ValueSchemaOptions;
|
|
5
|
+
export declare function optional<T>(schema: OneOrMany<SchemaTestable<T>>, options?: OptionalOptions): ValueSchema<T | undefined>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.optional = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
function optional(schema) {
|
|
6
|
-
return (0, types_1.valueSchema)(schema, { optional: true });
|
|
5
|
+
function optional(schema, options) {
|
|
6
|
+
return (0, types_1.valueSchema)(schema, { ...options, optional: true });
|
|
7
7
|
}
|
|
8
8
|
exports.optional = optional;
|
|
9
9
|
//# sourceMappingURL=optional.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;AAGA,oCAAuC;
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../source/schema/schemas/optional.ts"],"names":[],"mappings":";;;AAGA,oCAAuC;AAIvC,SAAgB,QAAQ,CAAI,MAAoC,EAAE,OAAyB;IACzF,OAAO,IAAA,mBAAW,EAAC,MAAuC,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9F,CAAC;AAFD,4BAEC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Schema } from '../schema';
|
|
3
|
+
import type { ValueSchemaOptions } from '../types';
|
|
4
|
+
export declare type ReadableStreamOptions = ValueSchemaOptions;
|
|
5
|
+
export declare function readableStream(options?: ReadableStreamOptions): Schema<globalThis.ReadableStream>;
|
|
4
6
|
export declare function ReadableStream(): Decorator<'property' | 'accessor'>;
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.ReadableStream = exports.readableStream = void 0;
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
function readableStream() {
|
|
8
|
-
return (0, types_1.
|
|
7
|
+
function readableStream(options) {
|
|
8
|
+
return (0, types_1.valueSchema)(globalThis.ReadableStream, options);
|
|
9
9
|
}
|
|
10
10
|
exports.readableStream = readableStream;
|
|
11
11
|
function ReadableStream() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;
|
|
1
|
+
{"version":3,"file":"readable-stream.js","sourceRoot":"","sources":["../../../source/schema/schemas/readable-stream.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAuC;AAIvC,SAAgB,cAAc,CAAC,OAA+B;IAC5D,OAAO,IAAA,mBAAW,EAAC,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc;IAC5B,OAAO,IAAA,oDAAuC,EAAC,cAAc,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wCAEC"}
|
|
@@ -2,4 +2,4 @@ import type { OneOrMany, Record, TypedOmit } from "../../types";
|
|
|
2
2
|
import type { SchemaTestable } from '../schema';
|
|
3
3
|
import type { ObjectSchema } from '../types';
|
|
4
4
|
export declare type RecordOptions<T extends Record = Record> = TypedOmit<ObjectSchema<T>, 'properties' | 'allowUnknownProperties' | 'mask'>;
|
|
5
|
-
export declare function record<T
|
|
5
|
+
export declare function record<T>(valueType: OneOrMany<SchemaTestable<T>>, options?: RecordOptions): ObjectSchema<Record<any, T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../source/schema/schemas/record.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAKzD,oCAAwC;AAIxC,SAAgB,MAAM,CAAI,SAAuC,EAAE,OAAuB;IACxF,OAAO,IAAA,oBAAY,EAAC;QAClB,UAAU,EAAE,EAAE;QACd,sBAAsB,EAAE,SAAS;QACjC,GAAG,OAAO;KACX,CAAiB,CAAC;AACrB,CAAC;AAND,wBAMC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
2
|
import type { Schema } from '../schema';
|
|
3
|
-
import type {
|
|
4
|
-
export declare type RegExpSchemaOptions =
|
|
3
|
+
import type { ValueSchemaOptions } from '../types';
|
|
4
|
+
export declare type RegExpSchemaOptions = ValueSchemaOptions;
|
|
5
5
|
export declare function regexp(options?: RegExpSchemaOptions): Schema<globalThis.RegExp>;
|
|
6
6
|
export declare function RegExp(options?: RegExpSchemaOptions): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/regexp.js
CHANGED
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.RegExp = exports.regexp = void 0;
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
function regexp(options
|
|
8
|
-
return (0, types_1.valueSchema)(
|
|
9
|
-
coerce: options.coerce
|
|
10
|
-
});
|
|
7
|
+
function regexp(options) {
|
|
8
|
+
return (0, types_1.valueSchema)(globalThis.RegExp, options);
|
|
11
9
|
}
|
|
12
10
|
exports.regexp = regexp;
|
|
13
11
|
function RegExp(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,
|
|
1
|
+
{"version":3,"file":"regexp.js","sourceRoot":"","sources":["../../../source/schema/schemas/regexp.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAGxE,oCAAuC;AAIvC,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,mBAAW,EAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAC,OAA6B;IAClD,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare type StringOptions =
|
|
2
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
3
|
+
export declare type StringOptions = ValueSchemaOptions & {
|
|
4
4
|
/** trim */
|
|
5
5
|
trim?: boolean;
|
|
6
6
|
/** lowercase */
|
package/schema/schemas/string.js
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.String = exports.string = void 0;
|
|
5
|
+
const array_1 = require("../../utils/array/array");
|
|
5
6
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
7
|
const constraints_1 = require("../constraints");
|
|
7
8
|
const decorators_1 = require("../decorators");
|
|
8
9
|
const transformers_1 = require("../transformers");
|
|
9
10
|
const types_1 = require("../types");
|
|
10
11
|
function string(options = {}) {
|
|
11
|
-
const
|
|
12
|
-
const transformers = [];
|
|
12
|
+
const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
|
|
13
|
+
const transformers = (0, array_1.toArray)(options.transformers ?? []);
|
|
13
14
|
if ((0, type_guards_1.isDefined)(options.minimumLength)) {
|
|
14
|
-
|
|
15
|
+
valueConstraints.push(new constraints_1.MinimumLengthConstraint(options.minimumLength));
|
|
15
16
|
}
|
|
16
17
|
if ((0, type_guards_1.isDefined)(options.maximumLength)) {
|
|
17
|
-
|
|
18
|
+
valueConstraints.push(new constraints_1.MaximumLengthConstraint(options.maximumLength));
|
|
18
19
|
}
|
|
19
20
|
if ((0, type_guards_1.isDefined)(options.pattern)) {
|
|
20
21
|
const pattern = RegExp(options.pattern, options.patternFlags);
|
|
21
|
-
|
|
22
|
+
valueConstraints.push(new constraints_1.PatternConstraint(pattern, options.patternName));
|
|
22
23
|
}
|
|
23
24
|
if ((0, type_guards_1.isDefined)(options.trim)) {
|
|
24
25
|
transformers.push(new transformers_1.TrimTransformer());
|
|
@@ -30,8 +31,8 @@ function string(options = {}) {
|
|
|
30
31
|
transformers.push(new transformers_1.UppercaseTransformer());
|
|
31
32
|
}
|
|
32
33
|
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.String), {
|
|
33
|
-
|
|
34
|
-
valueConstraints
|
|
34
|
+
...options,
|
|
35
|
+
valueConstraints,
|
|
35
36
|
transformers
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,gDAAqG;AACrG,8CAAwE;AACxE,kDAA8F;AAE9F,oCAAmD;AA4BnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../source/schema/schemas/string.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,mDAA8C;AAC9C,yDAAgD;AAChD,gDAAqG;AACrG,8CAAwE;AACxE,kDAA8F;AAE9F,oCAAmD;AA4BnD,SAAgB,MAAM,CAAC,UAAyB,EAAE;IAChD,MAAM,gBAAgB,GAA4B,IAAA,eAAO,EAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAC1F,MAAM,YAAY,GAA6B,IAAA,eAAO,EAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAEnF,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,qCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,qCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAC9D,gBAAgB,CAAC,IAAI,CAAC,IAAI,+BAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;KAC5E;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,8BAAe,EAAE,CAAC,CAAC;KAC1C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAChC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAoB,EAAE,CAAC,CAAC;KAC/C;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAChD,GAAG,OAAO;QACV,gBAAgB;QAChB,YAAY;KACb,CAAC,CAAC;AACL,CAAC;AAlCD,wBAkCC;AAED,SAAgB,MAAM,CAAC,OAAuB;IAC5C,OAAO,IAAA,oDAAuC,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAFD,wBAEC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { OneOrMany } from "../../types";
|
|
2
|
+
import type { SchemaTestable } from '../schema';
|
|
3
3
|
import type { GenericTransformFunction } from '../transformers/generic';
|
|
4
4
|
import type { ValueSchema, ValueType } from '../types';
|
|
5
|
-
export declare function transform<T, O
|
|
5
|
+
export declare function transform<T, O>(schema: OneOrMany<SchemaTestable<T>>, transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<ValueType<T>>): ValueSchema<O>;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transform = void 0;
|
|
4
4
|
const generic_1 = require("../transformers/generic");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
function transform(schema,
|
|
6
|
+
function transform(schema, transformFunction, sourceType) {
|
|
7
7
|
return (0, types_1.valueSchema)(schema, {
|
|
8
|
-
transformers: new generic_1.GenericTransformer(
|
|
8
|
+
transformers: new generic_1.GenericTransformer(transformFunction, sourceType)
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
exports.transform = transform;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AAGA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../source/schema/schemas/transform.ts"],"names":[],"mappings":";;;AAGA,qDAA6D;AAE7D,oCAAuC;AAEvC,SAAgB,SAAS,CAAO,MAAoC,EAAE,iBAAiD,EAAE,UAAoC;IAC3J,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE;QACzB,YAAY,EAAE,IAAI,4BAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC;KACpE,CAAqB,CAAC;AACzB,CAAC;AAJD,8BAIC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare type Uint8ArraySchemaOptions =
|
|
2
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
3
|
+
export declare type Uint8ArraySchemaOptions = ValueSchemaOptions & {
|
|
4
|
+
/** Minimum byte length */
|
|
4
5
|
minimumLength?: number;
|
|
6
|
+
/** Maximum byte length */
|
|
5
7
|
maximumLength?: number;
|
|
6
8
|
};
|
|
7
9
|
export declare function uint8Array(options?: Uint8ArraySchemaOptions): ValueSchema<globalThis.Uint8Array>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Uint8Array = exports.uint8Array = void 0;
|
|
5
|
+
const array_1 = require("../../utils/array/array");
|
|
5
6
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
7
|
const uint8_array_coercer_1 = require("../coercers/uint8-array.coercer");
|
|
7
8
|
const maximum_length_1 = require("../constraints/maximum-length");
|
|
@@ -9,16 +10,21 @@ const minimum_length_1 = require("../constraints/minimum-length");
|
|
|
9
10
|
const utils_1 = require("../decorators/utils");
|
|
10
11
|
const types_1 = require("../types");
|
|
11
12
|
function uint8Array(options = {}) {
|
|
12
|
-
const
|
|
13
|
+
const coercers = (0, array_1.toArray)(options.coercers ?? []);
|
|
14
|
+
const valueConstraints = (0, array_1.toArray)(options.valueConstraints ?? []);
|
|
15
|
+
if (options.coerce == true) {
|
|
16
|
+
coercers.push(uint8_array_coercer_1.uint8ArrayCoercer);
|
|
17
|
+
}
|
|
13
18
|
if ((0, type_guards_1.isDefined)(options.minimumLength)) {
|
|
14
|
-
|
|
19
|
+
valueConstraints.push(new minimum_length_1.MinimumLengthConstraint(options.minimumLength));
|
|
15
20
|
}
|
|
16
21
|
if ((0, type_guards_1.isDefined)(options.maximumLength)) {
|
|
17
|
-
|
|
22
|
+
valueConstraints.push(new maximum_length_1.MaximumLengthConstraint(options.maximumLength));
|
|
18
23
|
}
|
|
19
24
|
return (0, types_1.valueSchema)((0, types_1.typeSchema)(globalThis.Uint8Array), {
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
...options,
|
|
26
|
+
coercers,
|
|
27
|
+
valueConstraints
|
|
22
28
|
});
|
|
23
29
|
}
|
|
24
30
|
exports.uint8Array = uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE,+CAA8E;AAE9E,oCAAmD;
|
|
1
|
+
{"version":3,"file":"uint8-array.js","sourceRoot":"","sources":["../../../source/schema/schemas/uint8-array.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,mDAA8C;AAC9C,yDAAgD;AAChD,yEAAoE;AACpE,kEAAwE;AACxE,kEAAwE;AACxE,+CAA8E;AAE9E,oCAAmD;AAUnD,SAAgB,UAAU,CAAC,UAAmC,EAAE;IAC9D,MAAM,QAAQ,GAAyB,IAAA,eAAO,EAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IACvE,MAAM,gBAAgB,GAA4B,IAAA,eAAO,EAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAE1F,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE;QAC1B,QAAQ,CAAC,IAAI,CAAC,uCAAiB,CAAC,CAAC;KAClC;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,IAAI,IAAA,uBAAS,EAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,wCAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;KAC3E;IAED,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACpD,GAAG,OAAO;QACV,QAAQ;QACR,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC;AArBD,gCAqBC;AAED,SAAgB,UAAU,CAAC,OAAiC;IAC1D,OAAO,IAAA,+CAAuC,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AACtE,CAAC;AAFD,gCAEC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
2
|
import type { SchemaTestable } from '../schema';
|
|
3
|
-
import type {
|
|
4
|
-
export declare
|
|
3
|
+
import type { SchemaOutput, ValueSchema, ValueSchemaOptions } from '../types';
|
|
4
|
+
export declare type UnionOptions = ValueSchemaOptions;
|
|
5
|
+
export declare function union<T extends SchemaTestable[]>(...schemas: [...T]): ValueSchema<SchemaOutput<T[number]>>;
|
|
6
|
+
export declare function union<T extends SchemaTestable[]>(schemas: [...T], options?: UnionOptions): ValueSchema<SchemaOutput<T[number]>>;
|
|
5
7
|
export declare function Union(...schemas: SchemaTestable[]): Decorator<'property' | 'accessor'>;
|
package/schema/schemas/union.js
CHANGED
|
@@ -5,9 +5,11 @@ exports.Union = exports.union = void 0;
|
|
|
5
5
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
6
|
const decorators_1 = require("../decorators");
|
|
7
7
|
const types_1 = require("../types");
|
|
8
|
-
function union(...
|
|
9
|
-
(0, type_guards_1.
|
|
10
|
-
|
|
8
|
+
function union(...args) {
|
|
9
|
+
const schemas = (0, type_guards_1.isArray)(args[0]) ? args[0] : args;
|
|
10
|
+
const options = (0, type_guards_1.isArray)(args[0]) ? args[1] : undefined;
|
|
11
|
+
(0, type_guards_1.assert)(schemas.length >= 2, 'Union requires at least 2 schemas.');
|
|
12
|
+
return (0, types_1.valueSchema)(schemas, options);
|
|
11
13
|
}
|
|
12
14
|
exports.union = union;
|
|
13
15
|
function Union(...schemas) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,
|
|
1
|
+
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../source/schema/schemas/union.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,yDAAsD;AACtD,8CAAwE;AAGxE,oCAAuC;AAMvC,SAAgB,KAAK,CAA6B,GAAG,IAA8C;IACjG,MAAM,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAS,CAAC;IACvD,MAAM,OAAO,GAAG,IAAA,qBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvE,IAAA,oBAAM,EAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,oCAAoC,CAAC,CAAC;IAClE,OAAO,IAAA,mBAAW,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAND,sBAMC;AAED,SAAgB,KAAK,CAAC,GAAG,OAAyB;IAChD,OAAO,IAAA,oDAAuC,EAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,sBAEC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type {
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
2
|
+
import type { ValueSchema, ValueSchemaOptions } from '../types';
|
|
3
|
+
export declare type UnknownOptions = ValueSchemaOptions;
|
|
4
|
+
export declare function unknown(options?: UnknownOptions): ValueSchema<unknown>;
|
|
5
|
+
export declare function Unknown(options?: UnknownOptions): Decorator<'property' | 'accessor'>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.Unknown = exports.unknown = void 0;
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
|
-
function unknown() {
|
|
8
|
-
return (0, types_1.typeSchema)('any');
|
|
7
|
+
function unknown(options) {
|
|
8
|
+
return (0, types_1.valueSchema)((0, types_1.typeSchema)('any'), options);
|
|
9
9
|
}
|
|
10
10
|
exports.unknown = unknown;
|
|
11
|
-
function
|
|
12
|
-
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(unknown());
|
|
11
|
+
function Unknown(options) {
|
|
12
|
+
return (0, decorators_1.createSchemaPropertyDecoratorFromSchema)(unknown(options));
|
|
13
13
|
}
|
|
14
|
-
exports.
|
|
14
|
+
exports.Unknown = Unknown;
|
|
15
15
|
//# sourceMappingURL=unknown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAExE,
|
|
1
|
+
{"version":3,"file":"unknown.js","sourceRoot":"","sources":["../../../source/schema/schemas/unknown.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAwE;AAExE,oCAAmD;AAInD,SAAgB,OAAO,CAAC,OAAwB;IAC9C,OAAO,IAAA,mBAAW,EAAC,IAAA,kBAAU,EAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO,CAAC,OAAwB;IAC9C,OAAO,IAAA,oDAAuC,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC;AAFD,0BAEC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
|
-
import type { AbstractConstructor, OneOrMany
|
|
2
|
+
import type { AbstractConstructor, OneOrMany } from "../../types";
|
|
3
3
|
import type { TransformResult, ValueType } from '../types';
|
|
4
4
|
import { SchemaValueTransformer } from '../types';
|
|
5
|
-
export declare type GenericTransformFunction<T, O> = (value: T) =>
|
|
6
|
-
export declare class GenericTransformer<T, O
|
|
7
|
-
readonly sourceType
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
transform(value: O): TransformResult<TransformOutput>;
|
|
5
|
+
export declare type GenericTransformFunction<T, O> = (value: T) => TransformResult<O>;
|
|
6
|
+
export declare class GenericTransformer<T, O> extends SchemaValueTransformer<T, O> {
|
|
7
|
+
readonly sourceType?: OneOrMany<ValueType<T>>;
|
|
8
|
+
readonly transformFunction: GenericTransformFunction<T, O>;
|
|
9
|
+
constructor(transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<ValueType<T>>);
|
|
10
|
+
transform(value: T): TransformResult<O>;
|
|
12
11
|
}
|
|
13
|
-
export declare function Transform<T, O
|
|
12
|
+
export declare function Transform<T, O>(transformFunction: GenericTransformFunction<T, O>, sourceType?: OneOrMany<AbstractConstructor<T>>): Decorator<'property' | 'accessor'>;
|
|
@@ -2,27 +2,21 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Transform = exports.GenericTransformer = void 0;
|
|
5
|
-
const type_guards_1 = require("../../utils/type-guards");
|
|
6
5
|
const decorators_1 = require("../decorators");
|
|
7
6
|
const types_1 = require("../types");
|
|
8
7
|
class GenericTransformer extends types_1.SchemaValueTransformer {
|
|
9
|
-
constructor(
|
|
8
|
+
constructor(transformFunction, sourceType) {
|
|
10
9
|
super();
|
|
11
10
|
this.sourceType = sourceType;
|
|
12
|
-
this.targetType = targetType;
|
|
13
11
|
this.transformFunction = transformFunction;
|
|
14
12
|
}
|
|
15
13
|
transform(value) {
|
|
16
|
-
|
|
17
|
-
if ((0, type_guards_1.isDefined)(result.error)) {
|
|
18
|
-
return { success: false, error: result.error };
|
|
19
|
-
}
|
|
20
|
-
return { success: true, value: result.value };
|
|
14
|
+
return this.transformFunction(value);
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
17
|
exports.GenericTransformer = GenericTransformer;
|
|
24
|
-
function Transform(
|
|
25
|
-
return (0, decorators_1.createSchemaValueTransformerDecorator)(new GenericTransformer(
|
|
18
|
+
function Transform(transformFunction, sourceType) {
|
|
19
|
+
return (0, decorators_1.createSchemaValueTransformerDecorator)(new GenericTransformer(transformFunction, sourceType));
|
|
26
20
|
}
|
|
27
21
|
exports.Transform = Transform;
|
|
28
22
|
//# sourceMappingURL=generic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/transformers/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../source/schema/transformers/generic.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAIzD,8CAAsE;AAEtE,oCAAkD;AAIlD,MAAa,kBAAyB,SAAQ,8BAA4B;IAIxE,YAAY,iBAAiD,EAAE,UAAoC;QACjG,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,SAAS,CAAC,KAAQ;QAChB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF;AAdD,gDAcC;AAED,SAAgB,SAAS,CAAO,iBAAiD,EAAE,UAA8C;IAC/H,OAAO,IAAA,kDAAqC,EAAC,IAAI,kBAAkB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;AACtG,CAAC;AAFD,8BAEC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
2
|
import type { TransformResult } from '../types';
|
|
3
3
|
import { SchemaValueTransformer } from '../types';
|
|
4
|
-
export declare class LowercaseTransformer extends SchemaValueTransformer<string, string
|
|
4
|
+
export declare class LowercaseTransformer extends SchemaValueTransformer<string, string> {
|
|
5
5
|
readonly sourceType: StringConstructor;
|
|
6
|
-
readonly targetType: StringConstructor;
|
|
7
6
|
transform(value: string): TransformResult<string>;
|
|
8
7
|
}
|
|
9
8
|
export declare function Lowercase(): Decorator<'property' | 'accessor'>;
|
|
@@ -8,10 +8,9 @@ class LowercaseTransformer extends types_1.SchemaValueTransformer {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.sourceType = String;
|
|
11
|
-
this.targetType = String;
|
|
12
11
|
}
|
|
13
12
|
transform(value) {
|
|
14
|
-
return
|
|
13
|
+
return value.toLowerCase();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
exports.LowercaseTransformer = LowercaseTransformer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/lowercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,
|
|
1
|
+
{"version":3,"file":"lowercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/lowercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,8BAAsC;IAAhF;;QACW,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;CACF;AAND,oDAMC;AAED,SAAgB,SAAS;IACvB,OAAO,IAAA,kDAAqC,EAAC,IAAI,oBAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAFD,8BAEC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
2
|
import type { TransformResult } from '../types';
|
|
3
3
|
import { SchemaValueTransformer } from '../types';
|
|
4
|
-
export declare class TrimTransformer extends SchemaValueTransformer<string, string
|
|
4
|
+
export declare class TrimTransformer extends SchemaValueTransformer<string, string> {
|
|
5
5
|
readonly sourceType: StringConstructor;
|
|
6
|
-
readonly targetType: StringConstructor;
|
|
7
6
|
transform(value: string): TransformResult<string>;
|
|
8
7
|
}
|
|
9
8
|
export declare function Trim(): Decorator<'property' | 'accessor'>;
|
|
@@ -8,10 +8,9 @@ class TrimTransformer extends types_1.SchemaValueTransformer {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.sourceType = String;
|
|
11
|
-
this.targetType = String;
|
|
12
11
|
}
|
|
13
12
|
transform(value) {
|
|
14
|
-
return
|
|
13
|
+
return value.trim();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
exports.TrimTransformer = TrimTransformer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../source/schema/transformers/trim.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,eAAgB,SAAQ,
|
|
1
|
+
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../source/schema/transformers/trim.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,eAAgB,SAAQ,8BAAsC;IAA3E;;QACW,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACF;AAND,0CAMC;AAED,SAAgB,IAAI;IAClB,OAAO,IAAA,kDAAqC,EAAC,IAAI,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACtG,CAAC;AAFD,oBAEC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Decorator } from "../../reflection";
|
|
2
2
|
import type { TransformResult } from '../types';
|
|
3
3
|
import { SchemaValueTransformer } from '../types';
|
|
4
|
-
export declare class UppercaseTransformer extends SchemaValueTransformer<string, string
|
|
4
|
+
export declare class UppercaseTransformer extends SchemaValueTransformer<string, string> {
|
|
5
5
|
readonly sourceType: StringConstructor;
|
|
6
|
-
readonly targetType: StringConstructor;
|
|
7
6
|
transform(value: string): TransformResult<string>;
|
|
8
7
|
}
|
|
9
8
|
export declare function Uppercase(): Decorator<'property' | 'accessor'>;
|
|
@@ -8,10 +8,9 @@ class UppercaseTransformer extends types_1.SchemaValueTransformer {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.sourceType = String;
|
|
11
|
-
this.targetType = String;
|
|
12
11
|
}
|
|
13
12
|
transform(value) {
|
|
14
|
-
return
|
|
13
|
+
return value.toUpperCase();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
exports.UppercaseTransformer = UppercaseTransformer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/uppercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,
|
|
1
|
+
{"version":3,"file":"uppercase.js","sourceRoot":"","sources":["../../../source/schema/transformers/uppercase.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAGzD,8CAAsE;AAEtE,oCAA8D;AAE9D,MAAa,oBAAqB,SAAQ,8BAAsC;IAAhF;;QACW,eAAU,GAAG,MAAM,CAAC;IAK/B,CAAC;IAHC,SAAS,CAAC,KAAa;QACrB,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;CACF;AAND,oDAMC;AAED,SAAgB,SAAS;IACvB,OAAO,IAAA,kDAAqC,EAAC,IAAI,oBAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAA,kBAAU,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC;AAFD,8BAEC"}
|