@kikiutils/mongoose 9.0.1 → 9.0.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/dist/_internals.d.ts +0 -2
- package/dist/_internals.d.ts.map +1 -1
- package/dist/_internals.js +1 -2
- package/dist/assertions.d.ts +0 -2
- package/dist/assertions.d.ts.map +1 -1
- package/dist/assertions.js +1 -2
- package/dist/assertions.js.map +1 -1
- package/dist/builders.d.ts +1 -3
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +1 -2
- package/dist/connection.d.ts +0 -2
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1 -2
- package/dist/options.d.ts +0 -2
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +1 -2
- package/dist/plugins/assertions.d.ts +0 -2
- package/dist/plugins/assertions.d.ts.map +1 -1
- package/dist/plugins/assertions.js +5 -6
- package/dist/plugins/assertions.js.map +1 -1
- package/dist/plugins/lean-decimal128-to-string.d.ts +6 -4
- package/dist/plugins/lean-decimal128-to-string.d.ts.map +1 -1
- package/dist/plugins/lean-decimal128-to-string.js +6 -6
- package/dist/plugins/lean-decimal128-to-string.js.map +1 -1
- package/dist/plugins/normalize.d.ts +3 -3
- package/dist/plugins/normalize.d.ts.map +1 -1
- package/dist/plugins/normalize.js +3 -3
- package/dist/plugins/normalize.js.map +1 -1
- package/dist/schema-builders/_internals.d.ts +18 -0
- package/dist/schema-builders/_internals.d.ts.map +1 -0
- package/dist/schema-builders/_internals.js +36 -0
- package/dist/schema-builders/_internals.js.map +1 -0
- package/dist/schema-builders/base.d.ts +1 -2
- package/dist/schema-builders/base.d.ts.map +1 -1
- package/dist/schema-builders/base.js +2 -3
- package/dist/schema-builders/base.js.map +1 -1
- package/dist/schema-builders/bigint.d.ts +6 -27
- package/dist/schema-builders/bigint.d.ts.map +1 -1
- package/dist/schema-builders/bigint.js +10 -21
- package/dist/schema-builders/bigint.js.map +1 -1
- package/dist/schema-builders/boolean.d.ts +1 -2
- package/dist/schema-builders/boolean.d.ts.map +1 -1
- package/dist/schema-builders/boolean.js +1 -2
- package/dist/schema-builders/date.d.ts +5 -11
- package/dist/schema-builders/date.d.ts.map +1 -1
- package/dist/schema-builders/date.js +1 -2
- package/dist/schema-builders/date.js.map +1 -1
- package/dist/schema-builders/decimal128.d.ts +7 -26
- package/dist/schema-builders/decimal128.d.ts.map +1 -1
- package/dist/schema-builders/decimal128.js +5 -8
- package/dist/schema-builders/decimal128.js.map +1 -1
- package/dist/schema-builders/double.d.ts +6 -27
- package/dist/schema-builders/double.d.ts.map +1 -1
- package/dist/schema-builders/double.js +10 -21
- package/dist/schema-builders/double.js.map +1 -1
- package/dist/schema-builders/int32.d.ts +6 -27
- package/dist/schema-builders/int32.d.ts.map +1 -1
- package/dist/schema-builders/int32.js +10 -21
- package/dist/schema-builders/int32.js.map +1 -1
- package/dist/schema-builders/mixed.d.ts +1 -2
- package/dist/schema-builders/mixed.d.ts.map +1 -1
- package/dist/schema-builders/mixed.js +1 -2
- package/dist/schema-builders/number.d.ts +5 -11
- package/dist/schema-builders/number.d.ts.map +1 -1
- package/dist/schema-builders/number.js +1 -2
- package/dist/schema-builders/number.js.map +1 -1
- package/dist/schema-builders/object-id.d.ts +3 -9
- package/dist/schema-builders/object-id.d.ts.map +1 -1
- package/dist/schema-builders/object-id.js +1 -2
- package/dist/schema-builders/object-id.js.map +1 -1
- package/dist/schema-builders/ref.d.ts +3 -9
- package/dist/schema-builders/ref.d.ts.map +1 -1
- package/dist/schema-builders/ref.js +1 -2
- package/dist/schema-builders/ref.js.map +1 -1
- package/dist/schema-builders/string.d.ts +6 -12
- package/dist/schema-builders/string.d.ts.map +1 -1
- package/dist/schema-builders/string.js +1 -2
- package/dist/schema-builders/string.js.map +1 -1
- package/dist/schema-builders/uuid.d.ts +1 -2
- package/dist/schema-builders/uuid.d.ts.map +1 -1
- package/dist/schema-builders/uuid.js +1 -2
- package/dist/types/_internals.d.ts +22 -2
- package/dist/types/_internals.d.ts.map +1 -1
- package/dist/types/_internals.js +1 -0
- package/dist/types/aggregate-paginate.d.ts +2 -3
- package/dist/types/aggregate-paginate.d.ts.map +1 -1
- package/dist/types/aggregate-paginate.js +1 -0
- package/dist/types/data.d.ts +3 -3
- package/dist/types/data.d.ts.map +1 -1
- package/dist/types/data.js +1 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/options.d.ts +6 -4
- package/dist/types/options.d.ts.map +1 -1
- package/dist/types/options.js +1 -0
- package/dist/types/paginate.d.ts +0 -2
- package/dist/types/paginate.d.ts.map +1 -1
- package/dist/types/paginate.js +1 -0
- package/package.json +40 -43
- package/src/assertions.ts +0 -1
- package/src/plugins/assertions.ts +4 -4
- package/src/plugins/lean-decimal128-to-string.ts +18 -7
- package/src/plugins/normalize.ts +5 -2
- package/src/schema-builders/_internals.ts +64 -0
- package/src/schema-builders/base.ts +1 -1
- package/src/schema-builders/bigint.ts +33 -67
- package/src/schema-builders/date.ts +7 -7
- package/src/schema-builders/decimal128.ts +25 -41
- package/src/schema-builders/double.ts +35 -67
- package/src/schema-builders/int32.ts +33 -67
- package/src/schema-builders/number.ts +7 -7
- package/src/schema-builders/object-id.ts +2 -5
- package/src/schema-builders/ref.ts +2 -5
- package/src/schema-builders/string.ts +8 -8
- package/src/types/_internals.ts +26 -0
- package/src/types/aggregate-paginate.ts +2 -1
- package/src/types/data.ts +3 -1
- package/src/types/options.ts +6 -2
|
@@ -1,43 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumInput, EnumValidator, LimitValidator, ValidationSchema, ValueWithMessage } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Schema } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
//#region src/schema-builders/int32.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Int32SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
type Int32Limit = number;
|
|
6
|
+
type Int32ValidationSchema = ValidationSchema<EnumValidator<number> | LimitValidator<number>>;
|
|
7
7
|
interface BaseProps {
|
|
8
8
|
type: typeof Schema.Types.Int32;
|
|
9
9
|
}
|
|
10
|
-
interface Int32EnumValidator {
|
|
11
|
-
enumValues: (null | number)[];
|
|
12
|
-
message: string;
|
|
13
|
-
type: 'enum';
|
|
14
|
-
validator: (value: null | number | undefined) => boolean;
|
|
15
|
-
}
|
|
16
|
-
interface Int32LimitValidator {
|
|
17
|
-
max?: number;
|
|
18
|
-
message: string;
|
|
19
|
-
min?: number;
|
|
20
|
-
type: 'max' | 'min';
|
|
21
|
-
validator: (value: null | number | undefined) => boolean;
|
|
22
|
-
}
|
|
23
10
|
export interface Int32SchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {
|
|
24
11
|
default: <T extends ((this: any, doc: any) => DefaultType<D> | null | undefined) | DefaultType<D> | null | undefined, D extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
25
12
|
default: T;
|
|
26
13
|
}>, ExtraOmitFields>;
|
|
27
|
-
enum: <T extends
|
|
28
|
-
[path: string]: N | null;
|
|
29
|
-
} | {
|
|
30
|
-
message?: M;
|
|
31
|
-
values: Readonlyable<(N | null)[]>;
|
|
32
|
-
}, M extends string, N extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'enum' | ExtraOmitFields>;
|
|
14
|
+
enum: <T extends EnumInput<N | null, M>, M extends string, N extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'enum' | ExtraOmitFields>;
|
|
33
15
|
immutable: ExtendSchemaBuilder<Merge<Props, {
|
|
34
16
|
immutable: true;
|
|
35
17
|
}>, ExtraOmitFields>;
|
|
36
18
|
index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
37
19
|
index: T;
|
|
38
20
|
}>, ExtraOmitFields>;
|
|
39
|
-
max: <T extends
|
|
40
|
-
min: <T extends
|
|
21
|
+
max: <T extends ValueWithMessage<L, S>, L extends Int32Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'max' | ExtraOmitFields>;
|
|
22
|
+
min: <T extends ValueWithMessage<L, S>, L extends Int32Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'min' | ExtraOmitFields>;
|
|
41
23
|
nonRequired: Props;
|
|
42
24
|
private: ExtendSchemaBuilder<Merge<Props, {
|
|
43
25
|
private: true;
|
|
@@ -52,9 +34,6 @@ export interface Int32SchemaBuilder<Props extends BaseProps = BaseProps, ExtraOm
|
|
|
52
34
|
unique: true;
|
|
53
35
|
}>, ExtraOmitFields>;
|
|
54
36
|
}
|
|
55
|
-
interface Int32ValidationSchema {
|
|
56
|
-
validate: (Int32EnumValidator | Int32LimitValidator)[];
|
|
57
|
-
}
|
|
58
37
|
export declare function int32SchemaBuilder(): Int32SchemaBuilder;
|
|
59
|
-
|
|
38
|
+
export {};
|
|
60
39
|
//# sourceMappingURL=int32.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int32.d.ts","names":[],"sources":["../../src/schema-builders/int32.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"int32.d.ts","names":[],"sources":["../../src/schema-builders/int32.ts"],"mappings":";;;KA0BK,oBACD,cAAc,WACd,kCACA,KACA,mBAAmB,OAAO,kBAC1B,wBAAwB;KAGvB;KAEA,wBAAwB,iBAAiB,wBAAwB;UAE5D;EACN,aAAa,OAAO,MAAM;;iBAGb,mBAAmB,cAAc,YAAY,WAAW;EACrE,UACI,YAAY,WAAW,aAAa,YAAY,yBAAyB,YAAY,uBACrF,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UAAU,UAAU,UAAU,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,iCACJ;EAGb,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,iBAAiB,GAAG,IAC9B,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,gCACL;EAGZ,MACI,UAAU,iBAAiB,GAAG,IAC9B,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,gCACL;EAGZ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;wBA0BhD,sBAyCP"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
import { defaultLimitValidateMessages, hasSchemaValidator, normalizeEnumValues, normalizeValueWithMessage, setSchemaValidator } from "./_internals.js";
|
|
1
2
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
3
|
import { Schema } from "mongoose";
|
|
3
|
-
|
|
4
|
-
const defaultEnumValidateMessage = "Path `{PATH}` ({VALUE}) is not a valid enum value.";
|
|
5
|
-
const defaultMinValidateMessage = "Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).";
|
|
6
|
-
const defaultMaxValidateMessage = "Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).";
|
|
4
|
+
// src/schema-builders/int32.ts
|
|
7
5
|
const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Int32);
|
|
8
6
|
function createLimitValidator(type, value) {
|
|
9
|
-
const [numericLimit, message] =
|
|
7
|
+
const [numericLimit, message] = normalizeValueWithMessage(value);
|
|
10
8
|
if (!Number.isFinite(numericLimit)) throw new RangeError(`Int32 ${type} limit must be finite`);
|
|
11
9
|
return {
|
|
12
|
-
message: message ??
|
|
10
|
+
message: message ?? defaultLimitValidateMessages[type],
|
|
13
11
|
[type]: numericLimit,
|
|
14
12
|
type,
|
|
15
13
|
validator: (value) => {
|
|
@@ -23,36 +21,27 @@ function int32SchemaBuilder() {
|
|
|
23
21
|
const baseBuilder = baseBuilderFactory(schema);
|
|
24
22
|
return new Proxy(baseBuilder, { get(target, key, receiver) {
|
|
25
23
|
if (key === "enum") {
|
|
26
|
-
if (schema
|
|
24
|
+
if (hasSchemaValidator(schema, "enum")) throw new Error("Duplicate schema attribute: enum");
|
|
27
25
|
return (value) => {
|
|
28
|
-
|
|
29
|
-
let message;
|
|
30
|
-
if (Array.isArray(value)) enumValues = [...value];
|
|
31
|
-
else if ("values" in value && Array.isArray(value.values)) {
|
|
32
|
-
enumValues = [...value.values];
|
|
33
|
-
if ("message" in value && typeof value.message === "string") message = value.message;
|
|
34
|
-
} else enumValues = Object.values(value);
|
|
26
|
+
const { enumValues, message } = normalizeEnumValues(value);
|
|
35
27
|
const allowedValues = new Set(enumValues);
|
|
36
|
-
|
|
28
|
+
setSchemaValidator(schema, {
|
|
37
29
|
enumValues,
|
|
38
|
-
message: message ??
|
|
30
|
+
message: message ?? "Path `{PATH}` ({VALUE}) is not a valid enum value.",
|
|
39
31
|
type: "enum",
|
|
40
32
|
validator: (value) => value === null || value === void 0 || allowedValues.has(value)
|
|
41
|
-
};
|
|
42
|
-
schema.validate = [...schema.validate ?? [], validator];
|
|
33
|
+
});
|
|
43
34
|
return receiver;
|
|
44
35
|
};
|
|
45
36
|
}
|
|
46
37
|
if (key === "max" || key === "min") return (value) => {
|
|
47
38
|
const validator = createLimitValidator(key, value);
|
|
48
|
-
|
|
49
|
-
schema.validate = [...validators.filter(({ type }) => type !== key), validator];
|
|
39
|
+
setSchemaValidator(schema, validator);
|
|
50
40
|
return receiver;
|
|
51
41
|
};
|
|
52
42
|
return Reflect.get(target, key, receiver);
|
|
53
43
|
} });
|
|
54
44
|
}
|
|
55
|
-
//#endregion
|
|
56
45
|
export { int32SchemaBuilder };
|
|
57
46
|
|
|
58
47
|
//# sourceMappingURL=int32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int32.js","names":[],"sources":["../../src/schema-builders/int32.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"int32.js","names":[],"sources":["../../src/schema-builders/int32.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {\n EnumInput,\n EnumValidator,\n LimitValidator,\n ValidationSchema,\n ValueWithMessage,\n} from '../types/_internals';\n\nimport {\n defaultEnumValidateMessage,\n defaultLimitValidateMessages,\n hasSchemaValidator,\n normalizeEnumValues,\n normalizeValueWithMessage,\n setSchemaValidator,\n} from './_internals';\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n Int32SchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ntype Int32Limit = number;\n\ntype Int32ValidationSchema = ValidationSchema<EnumValidator<number> | LimitValidator<number>>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Int32;\n}\n\nexport interface Int32SchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D> | null | undefined) | DefaultType<D> | null | undefined,\n D extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends EnumInput<N | null, M>,\n M extends string,\n N extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, Int32ValidationSchema>,\n 'enum' | ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends ValueWithMessage<L, S>,\n L extends Int32Limit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, Int32ValidationSchema>,\n 'max' | ExtraOmitFields\n >;\n\n min: <\n T extends ValueWithMessage<L, S>,\n L extends Int32Limit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, Int32ValidationSchema>,\n 'min' | ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\n// Functions\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Int32);\n\nfunction createLimitValidator(\n type: 'max' | 'min',\n value: ValueWithMessage<Int32Limit>,\n): LimitValidator<number> {\n const [numericLimit, message] = normalizeValueWithMessage(value);\n\n if (!Number.isFinite(numericLimit)) throw new RangeError(`Int32 ${type} limit must be finite`);\n\n return {\n message: message ?? defaultLimitValidateMessages[type],\n [type]: numericLimit,\n type,\n validator: (value) => {\n if (value === null || value === undefined) return true;\n\n return type === 'min' ? value >= numericLimit : value <= numericLimit;\n },\n };\n}\n\nexport function int32SchemaBuilder() {\n const schema: Partial<Int32ValidationSchema> & Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'enum') {\n if (hasSchemaValidator(schema, 'enum')) {\n throw new Error('Duplicate schema attribute: enum');\n }\n\n return (value: EnumInput<null | number>) => {\n const { enumValues, message } = normalizeEnumValues(value);\n\n const allowedValues = new Set(enumValues);\n const validator: EnumValidator<number> = {\n enumValues,\n message: message ?? defaultEnumValidateMessage,\n type: 'enum',\n validator: (value) => value === null || value === undefined || allowedValues.has(value),\n };\n\n setSchemaValidator(schema, validator);\n\n return receiver;\n };\n }\n\n if (key === 'max' || key === 'min') {\n return (value: ValueWithMessage<Int32Limit>) => {\n const validator = createLimitValidator(key, value);\n setSchemaValidator(schema, validator);\n\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Int32SchemaBuilder;\n}\n"],"mappings":";;;;AA4FA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,KAAK;AAE5E,SAAS,qBACL,MACA,OACsB;CACtB,MAAM,CAAC,cAAc,WAAW,0BAA0B,KAAK;CAE/D,IAAI,CAAC,OAAO,SAAS,YAAY,GAAG,MAAM,IAAI,WAAW,SAAS,KAAK,sBAAsB;CAE7F,OAAO;EACH,SAAS,WAAW,6BAA6B;GAChD,OAAO;EACR;EACA,YAAY,UAAU;GAClB,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;GAElD,OAAO,SAAS,QAAQ,SAAS,eAAe,SAAS;EAC7D;CACJ;AACJ;AAEA,SAAgB,qBAAqB;CACjC,MAAM,SAA+D,CAAC;CACtE,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,QAAQ;GAChB,IAAI,mBAAmB,QAAQ,MAAM,GACjC,MAAM,IAAI,MAAM,kCAAkC;GAGtD,QAAQ,UAAoC;IACxC,MAAM,EAAE,YAAY,YAAY,oBAAoB,KAAK;IAEzD,MAAM,gBAAgB,IAAI,IAAI,UAAU;IAQxC,mBAAmB,QAAQ;KANvB;KACA,SAAS,WAAA;KACT,MAAM;KACN,YAAY,UAAU,UAAU,QAAQ,UAAU,KAAA,KAAa,cAAc,IAAI,KAAK;IAGvD,CAAC;IAEpC,OAAO;GACX;EACJ;EAEA,IAAI,QAAQ,SAAS,QAAQ,OACzB,QAAQ,UAAwC;GAC5C,MAAM,YAAY,qBAAqB,KAAK,KAAK;GACjD,mBAAmB,QAAQ,SAAS;GAEpC,OAAO;EACX;EAGJ,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IndexDirection, IndexOptions, Schema } from "mongoose";
|
|
2
2
|
import { Merge } from "type-fest";
|
|
3
|
-
//#region src/schema-builders/mixed.d.ts
|
|
4
3
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<MixedSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
5
4
|
interface BaseProps {
|
|
6
5
|
type: typeof Schema.Types.Mixed;
|
|
@@ -30,5 +29,5 @@ export interface MixedSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOm
|
|
|
30
29
|
}>, ExtraOmitFields>;
|
|
31
30
|
}
|
|
32
31
|
export declare const mixedSchemaBuilder: (schema?: Record<string, any>) => MixedSchemaBuilder<BaseProps, never>;
|
|
33
|
-
|
|
32
|
+
export {};
|
|
34
33
|
//# sourceMappingURL=mixed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixed.d.ts","names":[],"sources":["../../src/schema-builders/mixed.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mixed.d.ts","names":[],"sources":["../../src/schema-builders/mixed.ts"],"mappings":";;KASK,oBACD,cAAc,WACd,kCACA,KACA,mBAAmB,OAAO,kBAC1B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;iBAGb,mBAAmB,cAAc,YAAY,WAAW;EACrE,UAAU,GAAG,OAAO,MAAM,oBAAoB,MAAM;IAAS,SAAS;MAAM;EAC5E,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;qBAGnD,qBAAkB,SAAA,wBAAA,mBAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
2
|
import { Schema } from "mongoose";
|
|
3
|
-
|
|
3
|
+
// src/schema-builders/mixed.ts
|
|
4
4
|
const mixedSchemaBuilder = createBaseSchemaBuilderFactory(Schema.Types.Mixed);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { mixedSchemaBuilder };
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=mixed.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumInput, ValueWithMessage } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, NumberSchemaDefinition } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
//#region src/schema-builders/number.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<NumberSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
interface BaseProps {
|
|
7
6
|
type: NumberSchemaDefinition;
|
|
@@ -14,12 +13,7 @@ export interface NumberSchemaBuilder<Props extends {
|
|
|
14
13
|
default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
15
14
|
default: T;
|
|
16
15
|
}>, ExtraOmitFields>;
|
|
17
|
-
enum: <T extends
|
|
18
|
-
[path: string]: N | null;
|
|
19
|
-
} | {
|
|
20
|
-
message?: M;
|
|
21
|
-
values: Readonlyable<(N | null)[]>;
|
|
22
|
-
}, M extends string, N extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
16
|
+
enum: <T extends EnumInput<N | null, M>, M extends string, N extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
23
17
|
enum: T;
|
|
24
18
|
}>, ExtraOmitFields>;
|
|
25
19
|
immutable: ExtendSchemaBuilder<Merge<Props, {
|
|
@@ -28,10 +22,10 @@ export interface NumberSchemaBuilder<Props extends {
|
|
|
28
22
|
index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
29
23
|
index: T;
|
|
30
24
|
}>, ExtraOmitFields>;
|
|
31
|
-
max: <T extends
|
|
25
|
+
max: <T extends ValueWithMessage<N, S>, N extends number, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
32
26
|
max: T;
|
|
33
27
|
}>, ExtraOmitFields>;
|
|
34
|
-
min: <T extends
|
|
28
|
+
min: <T extends ValueWithMessage<N, S>, N extends number, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
35
29
|
min: T;
|
|
36
30
|
}>, ExtraOmitFields>;
|
|
37
31
|
nonRequired: Props;
|
|
@@ -51,5 +45,5 @@ export interface NumberSchemaBuilder<Props extends {
|
|
|
51
45
|
export declare const numberSchemaBuilder: (schema?: Record<string, any>) => NumberSchemaBuilder<{
|
|
52
46
|
type: NumberSchemaDefinition;
|
|
53
47
|
}, never>;
|
|
54
|
-
|
|
48
|
+
export {};
|
|
55
49
|
//# sourceMappingURL=number.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":";;;KAeK,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,MAAM;;iBAGO,oBACb;EAAgB,MAAM;;EAA6B,MAAM;GACzD;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UAAU,UAAU,UAAU,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,MACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;qBAGnD,sBAAmB,SAAA,wBAAA;EAnD6B,MAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
|
-
|
|
2
|
+
// src/schema-builders/number.ts
|
|
3
3
|
const numberSchemaBuilder = createBaseSchemaBuilderFactory(Number);
|
|
4
|
-
//#endregion
|
|
5
4
|
export { numberSchemaBuilder };
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","names":[],"sources":["../../src/schema-builders/number.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n NumberSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"number.js","names":[],"sources":["../../src/schema-builders/number.ts"],"sourcesContent":["import type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n NumberSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {\n EnumInput,\n ValueWithMessage,\n} from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n NumberSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: NumberSchemaDefinition;\n}\n\nexport interface NumberSchemaBuilder<\n Props extends { type: NumberSchemaDefinition } = { type: NumberSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends EnumInput<N | null, M>,\n M extends string,\n N extends number,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n max: <\n T extends ValueWithMessage<N, S>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { max: T }>,\n ExtraOmitFields\n >;\n\n min: <\n T extends ValueWithMessage<N, S>,\n N extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { min: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const numberSchemaBuilder = createBaseSchemaBuilderFactory<NumberSchemaBuilder>(Number);\n"],"mappings":";;AA+EA,MAAa,sBAAsB,+BAAoD,MAAM"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumInput } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Schema, Types } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
//#region src/schema-builders/object-id.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<ObjectIdSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
interface BaseProps {
|
|
7
6
|
type: typeof Schema.Types.ObjectId;
|
|
@@ -14,12 +13,7 @@ export interface ObjectIdSchemaBuilder<Props extends {
|
|
|
14
13
|
default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
15
14
|
default: T;
|
|
16
15
|
}>, ExtraOmitFields>;
|
|
17
|
-
enum: <T extends
|
|
18
|
-
[path: string]: null | O;
|
|
19
|
-
} | {
|
|
20
|
-
message?: M;
|
|
21
|
-
values: Readonlyable<(null | O)[]>;
|
|
22
|
-
}, M extends string, O extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
16
|
+
enum: <T extends EnumInput<null | O, M>, M extends string, O extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
23
17
|
enum: T;
|
|
24
18
|
}>, ExtraOmitFields>;
|
|
25
19
|
immutable: ExtendSchemaBuilder<Merge<Props, {
|
|
@@ -45,5 +39,5 @@ export interface ObjectIdSchemaBuilder<Props extends {
|
|
|
45
39
|
export declare const objectIdSchemaBuilder: (schema?: Record<string, any>) => ObjectIdSchemaBuilder<{
|
|
46
40
|
type: typeof Schema.Types.ObjectId;
|
|
47
41
|
}, never>;
|
|
48
|
-
|
|
42
|
+
export {};
|
|
49
43
|
//# sourceMappingURL=object-id.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-id.d.ts","names":[],"sources":["../../src/schema-builders/object-id.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-id.d.ts","names":[],"sources":["../../src/schema-builders/object-id.ts"],"mappings":";;;KAaK,oBACD,cAAc,WACd,kCACA,KACA,sBAAsB,OAAO,kBAC7B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;iBAGb,sBACb;EAAgB,aAAa,OAAO,MAAM;;EAAe,aAAa,OAAO,MAAM;GACnF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;qBAGnD,wBAAqB,SAAA,wBAAA;EAjCiC,aAAO,OAAO,MAAM"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
2
|
import { Schema } from "mongoose";
|
|
3
|
-
|
|
3
|
+
// src/schema-builders/object-id.ts
|
|
4
4
|
const objectIdSchemaBuilder = createBaseSchemaBuilderFactory(Schema.Types.ObjectId);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { objectIdSchemaBuilder };
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=object-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-id.js","names":[],"sources":["../../src/schema-builders/object-id.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"object-id.js","names":[],"sources":["../../src/schema-builders/object-id.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { EnumInput } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n ObjectIdSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface ObjectIdSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends EnumInput<null | O, M>,\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nexport const objectIdSchemaBuilder = createBaseSchemaBuilderFactory<ObjectIdSchemaBuilder>(Schema.Types.ObjectId);\n"],"mappings":";;;AA2DA,MAAa,wBAAwB,+BAAsD,OAAO,MAAM,QAAQ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumInput } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, Model, Schema, Types } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
//#region src/schema-builders/ref.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<RefSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
interface BaseProps {
|
|
7
6
|
type: typeof Schema.Types.ObjectId;
|
|
@@ -14,12 +13,7 @@ export interface RefSchemaBuilder<Props extends {
|
|
|
14
13
|
default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
15
14
|
default: T;
|
|
16
15
|
}>, ExtraOmitFields>;
|
|
17
|
-
enum: <T extends
|
|
18
|
-
[path: string]: null | O;
|
|
19
|
-
} | {
|
|
20
|
-
message?: M;
|
|
21
|
-
values: Readonlyable<(null | O)[]>;
|
|
22
|
-
}, M extends string, O extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
16
|
+
enum: <T extends EnumInput<null | O, M>, M extends string, O extends Types.ObjectId>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
23
17
|
enum: T;
|
|
24
18
|
}>, ExtraOmitFields>;
|
|
25
19
|
immutable: ExtendSchemaBuilder<Merge<Props, {
|
|
@@ -46,5 +40,5 @@ export declare function refSchemaBuilder<T extends ((this: any, doc: any) => Mod
|
|
|
46
40
|
ref: T;
|
|
47
41
|
type: typeof Schema.Types.ObjectId;
|
|
48
42
|
}>;
|
|
49
|
-
|
|
43
|
+
export {};
|
|
50
44
|
//# sourceMappingURL=ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","names":[],"sources":["../../src/schema-builders/ref.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ref.d.ts","names":[],"sources":["../../src/schema-builders/ref.ts"],"mappings":";;;KAcK,oBACD,cAAc,WACd,kCACA,KACA,iBAAiB,OAAO,kBACxB,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;iBAGb,iBACb;EAAgB,aAAa,OAAO,MAAM;;EAAe,aAAa,OAAO,MAAM;GACnF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,UAAU,MAAM,UAClB,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;wBAKhD,iBAAiB,YAAY,WAAW,aAAa,uBAAuB,qBACxF,KAAK,IAEiC;EAAmB,KAAK;EAAG,aAAa,OAAO,MAAM"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
2
|
import { Schema } from "mongoose";
|
|
3
|
-
|
|
3
|
+
// src/schema-builders/ref.ts
|
|
4
4
|
const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.ObjectId);
|
|
5
5
|
function refSchemaBuilder(ref) {
|
|
6
6
|
return baseBuilderFactory({ ref });
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { refSchemaBuilder };
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","names":[],"sources":["../../src/schema-builders/ref.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Model,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"ref.js","names":[],"sources":["../../src/schema-builders/ref.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n Model,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { EnumInput } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n RefSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.ObjectId;\n}\n\nexport interface RefSchemaBuilder<\n Props extends { type: typeof Schema.Types.ObjectId } = { type: typeof Schema.Types.ObjectId },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends EnumInput<null | O, M>,\n M extends string,\n O extends Types.ObjectId,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.ObjectId);\n\nexport function refSchemaBuilder<T extends ((this: any, doc: any) => Model<any> | string) | Model<any> | string>(\n ref: T,\n) {\n return baseBuilderFactory({ ref }) as RefSchemaBuilder<{ ref: T; type: typeof Schema.Types.ObjectId }>;\n}\n"],"mappings":";;;AA4DA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,QAAQ;AAE/E,SAAgB,iBACZ,KACF;CACE,OAAO,mBAAmB,EAAE,IAAI,CAAC;AACrC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnumInput, ValueWithMessage } from "../types/_internals.js";
|
|
2
2
|
import { DefaultType, IndexDirection, IndexOptions, StringSchemaDefinition } from "mongoose";
|
|
3
3
|
import { Merge } from "type-fest";
|
|
4
|
-
//#region src/schema-builders/string.d.ts
|
|
5
4
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<StringSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
6
5
|
interface BaseProps {
|
|
7
6
|
type: StringSchemaDefinition;
|
|
@@ -21,12 +20,7 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
21
20
|
default: <T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null, D extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
22
21
|
default: T;
|
|
23
22
|
}>, ExtraOmitFields>;
|
|
24
|
-
enum: <T extends
|
|
25
|
-
[path: string]: null | S;
|
|
26
|
-
} | {
|
|
27
|
-
message?: M;
|
|
28
|
-
values: Readonlyable<(null | S)[]>;
|
|
29
|
-
}, M extends string, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
23
|
+
enum: <T extends EnumInput<null | S, M>, M extends string, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
30
24
|
enum: T;
|
|
31
25
|
}>, ExtraOmitFields>;
|
|
32
26
|
immutable: ExtendSchemaBuilder<Merge<Props, {
|
|
@@ -68,7 +62,7 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
68
62
|
*
|
|
69
63
|
* @returns This instance for chaining.
|
|
70
64
|
*/
|
|
71
|
-
length: <T extends
|
|
65
|
+
length: <T extends ValueWithMessage<L, S>, L extends number, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
72
66
|
maxlength: T;
|
|
73
67
|
minlength: T;
|
|
74
68
|
}>, ExtraOmitFields>;
|
|
@@ -89,10 +83,10 @@ export interface StringSchemaBuilder<Props extends {
|
|
|
89
83
|
match: <T extends RegExp, M extends string | undefined = undefined>(regex: T, message?: M) => ExtendSchemaBuilder<Merge<Props, {
|
|
90
84
|
match: M extends string ? Readonly<[T, M]> : T;
|
|
91
85
|
}>, ExtraOmitFields>;
|
|
92
|
-
maxlength: <T extends
|
|
86
|
+
maxlength: <T extends ValueWithMessage<L, S>, L extends number, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
93
87
|
maxlength: T;
|
|
94
88
|
}>, ExtraOmitFields>;
|
|
95
|
-
minlength: <T extends
|
|
89
|
+
minlength: <T extends ValueWithMessage<L, S>, L extends number, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, {
|
|
96
90
|
minlength: T;
|
|
97
91
|
}>, ExtraOmitFields>;
|
|
98
92
|
nonRequired: Props;
|
|
@@ -140,5 +134,5 @@ declare const defaultIpv4ValidateMessage = "`{VALUE}` is not a valid IPv4 addres
|
|
|
140
134
|
declare const defaultIpv6ValidateMessage = "`{VALUE}` is not a valid IPv6 address for path `{PATH}`";
|
|
141
135
|
declare const defaultUrlValidateMessage = "`{VALUE}` is not a valid URL for path `{PATH}`";
|
|
142
136
|
export declare function stringSchemaBuilder(): StringSchemaBuilder;
|
|
143
|
-
|
|
137
|
+
export {};
|
|
144
138
|
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","names":[],"sources":["../../src/schema-builders/string.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"string.d.ts","names":[],"sources":["../../src/schema-builders/string.ts"],"mappings":";;;KAoBK,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,MAAM;;UAGA,SAAS;EACf;EACA;IAAY,SAAS;IAAG,YAAY;;;iBAGvB,oBACb;EAAgB,MAAM;;EAA6B,MAAM;GACzD;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,MAAM;MACrB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;;;;;;;;;;;EAaJ,OAAO,0BAA0B,4BAA4B,UAAU,MAAM,oBACzE,MAAM,OAAO,SAAS,+BACI;;;;;;;;;;;EAa9B,OAAO,0BAA0B,4BAA4B,UAAU,MAAM,oBACzE,MAAM,OAAO,SAAS,+BACI;;;;;;;;;;;;EAc9B,SACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;IAAG,WAAW;MACxC;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;;;;;;;;;;;;EAalE,QACI,UAAU,QACV,0CACF,OAAO,GACL,UAAU,MAAM,oBAChB,MAAM;IAAS,OAAO,mBAAmB,UAAU,GAAG,MAAM;MAC5D;EAEJ,YACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;MAC1B;EAGJ,YACI,UAAU,iBAAiB,GAAG,IAC9B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,WAAW;MAC1B;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,MAAM,oBAAoB,MAAM;IAAS;MAAe;EACxD,MAAM,oBAAoB,MAAM;IAAS;MAAe;EACxD,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,WAAW,oBAAoB,MAAM;IAAS;MAAoB;;;;;;;;;;;;EAalE,MAAM,0BAA0B,2BAA2B,UAAU,MAAM,oBACvE,MAAM,OAAO,UAAU,+BACG;;UAIxB,UAAU;EAChB;IAAY,SAAS;IAAG,YAAY;;;cAIlC;cACA;cACA;wBAKU,uBAiEP"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
2
|
import { isIPv4, isIPv6 } from "node:net";
|
|
3
|
-
|
|
3
|
+
// src/schema-builders/string.ts
|
|
4
4
|
const defaultIpv4ValidateMessage = "`{VALUE}` is not a valid IPv4 address for path `{PATH}`";
|
|
5
5
|
const defaultIpv6ValidateMessage = "`{VALUE}` is not a valid IPv6 address for path `{PATH}`";
|
|
6
6
|
const defaultUrlValidateMessage = "`{VALUE}` is not a valid URL for path `{PATH}`";
|
|
@@ -43,7 +43,6 @@ function stringSchemaBuilder() {
|
|
|
43
43
|
return Reflect.get(target, key, receiver);
|
|
44
44
|
} });
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { stringSchemaBuilder };
|
|
48
47
|
|
|
49
48
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","names":[],"sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import {\n isIPv4,\n isIPv6,\n} from 'node:net';\n\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"string.js","names":[],"sources":["../../src/schema-builders/string.ts"],"sourcesContent":["import {\n isIPv4,\n isIPv6,\n} from 'node:net';\n\nimport type {\n DefaultType,\n IndexDirection,\n IndexOptions,\n StringSchemaDefinition,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type {\n EnumInput,\n ValueWithMessage,\n} from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n StringSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: StringSchemaDefinition;\n}\n\ninterface IpSchema<T extends string> {\n trim: true;\n validate: { message: T; validator: (value: string) => boolean };\n}\n\nexport interface StringSchemaBuilder<\n Props extends { type: StringSchemaDefinition } = { type: StringSchemaDefinition },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends EnumInput<null | S, M>,\n M extends string,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { enum: T }>,\n ExtraOmitFields\n >;\n\n immutable: ExtendSchemaBuilder<Merge<Props, { immutable: true }>, ExtraOmitFields>;\n index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<\n Merge<Props, { index: T }>,\n ExtraOmitFields\n >;\n\n /**\n * Adds IPv4 address validation and enables input trimming.\n *\n * @remarks\n * Replaces the configured custom validator and sets `trim` to `true` on this builder.\n *\n * @param message - The validation error message. Defaults to the built-in IPv4 validation message.\n *\n * @returns This instance for chaining.\n */\n ipv4: <T extends string = typeof defaultIpv4ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | 'url' | ExtraOmitFields\n >;\n\n /**\n * Adds IPv6 address validation and enables input trimming.\n *\n * @remarks\n * Replaces the configured custom validator and sets `trim` to `true` on this builder.\n *\n * @param message - The validation error message. Defaults to the built-in IPv6 validation message.\n *\n * @returns This instance for chaining.\n */\n ipv6: <T extends string = typeof defaultIpv6ValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, IpSchema<T>>,\n 'ipv4' | 'ipv6' | 'url' | ExtraOmitFields\n >;\n\n /**\n * Sets equal minimum and maximum string lengths.\n *\n * @remarks\n * Assigns the same value to `minlength` and `maxlength`, replacing any previously configured limits.\n *\n * @param value - The exact length in UTF-16 code units, or a tuple containing the length and a validation\n * error message.\n *\n * @returns This instance for chaining.\n */\n length: <\n T extends ValueWithMessage<L, S>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T; minlength: T }>,\n ExtraOmitFields\n >;\n\n lowercase: ExtendSchemaBuilder<Merge<Props, { lowercase: true }>, ExtraOmitFields>;\n\n /**\n * Configures regular expression validation for the string field.\n *\n * @remarks\n * Replaces any previously configured `match` option.\n *\n * @param regex - The regular expression used by Mongoose to validate the string.\n * @param message - The validation error message. If omitted, Mongoose uses its default message.\n *\n * @returns This instance for chaining.\n */\n match: <\n T extends RegExp,\n M extends string | undefined = undefined,\n >(regex: T,\n message?: M) => ExtendSchemaBuilder<\n Merge<Props, { match: M extends string ? Readonly<[T, M]> : T }>,\n ExtraOmitFields\n >;\n maxlength: <\n T extends ValueWithMessage<L, S>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { maxlength: T }>,\n ExtraOmitFields\n >;\n\n minlength: <\n T extends ValueWithMessage<L, S>,\n L extends number,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { minlength: T }>,\n ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n text: ExtendSchemaBuilder<Merge<Props, { text: true }>, ExtraOmitFields>;\n trim: ExtendSchemaBuilder<Merge<Props, { trim: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n uppercase: ExtendSchemaBuilder<Merge<Props, { uppercase: true }>, ExtraOmitFields>;\n\n /**\n * Adds WHATWG URL parseability validation.\n *\n * @remarks\n * Accepts URLs with credentials and non-HTTP schemes. Performs no DNS lookup or stored-value normalization,\n * and does not enable trimming. Replaces the configured custom validator on this builder.\n *\n * @param message - The validation error message. Defaults to the built-in URL validation message.\n *\n * @returns This instance for chaining.\n */\n url: <T extends string = typeof defaultUrlValidateMessage>(message?: T) => ExtendSchemaBuilder<\n Merge<Props, UrlSchema<T>>,\n 'ipv4' | 'ipv6' | 'url' | ExtraOmitFields\n >;\n}\n\ninterface UrlSchema<T extends string> {\n validate: { message: T; validator: (value: string) => boolean };\n}\n\n// Constants/Variables\nconst defaultIpv4ValidateMessage = '`{VALUE}` is not a valid IPv4 address for path `{PATH}`';\nconst defaultIpv6ValidateMessage = '`{VALUE}` is not a valid IPv6 address for path `{PATH}`';\nconst defaultUrlValidateMessage = '`{VALUE}` is not a valid URL for path `{PATH}`';\n\n// Functions\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(String);\n\nexport function stringSchemaBuilder() {\n const schema: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'ipv4') {\n return (message: string = defaultIpv4ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv4(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'ipv6') {\n return (message: string = defaultIpv6ValidateMessage) => {\n schema.trim = true;\n schema.validate = {\n message,\n validator: (value: string) => isIPv6(value),\n };\n\n return receiver;\n };\n }\n\n if (key === 'length') {\n return (value: any) => {\n schema.maxlength = schema.minlength = value;\n return receiver;\n };\n }\n\n if (key === 'match') {\n return (regex: RegExp, message?: string) => {\n schema.match = message === undefined\n ? regex\n : [\n regex,\n message,\n ];\n\n return receiver;\n };\n }\n\n if (key === 'url') {\n return (message: string = defaultUrlValidateMessage) => {\n schema.validate = {\n message,\n validator: (value: string) => URL.canParse(value),\n };\n\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as StringSchemaBuilder;\n}\n"],"mappings":";;;AAwLA,MAAM,6BAA6B;AACnC,MAAM,6BAA6B;AACnC,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB,+BAA+B,MAAM;AAEhE,SAAgB,sBAAsB;CAClC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,QACR,QAAQ,UAAkB,+BAA+B;GACrD,OAAO,OAAO;GACd,OAAO,WAAW;IACd;IACA,YAAY,UAAkB,OAAO,KAAK;GAC9C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,QACR,QAAQ,UAAkB,+BAA+B;GACrD,OAAO,OAAO;GACd,OAAO,WAAW;IACd;IACA,YAAY,UAAkB,OAAO,KAAK;GAC9C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,UACR,QAAQ,UAAe;GACnB,OAAO,YAAY,OAAO,YAAY;GACtC,OAAO;EACX;EAGJ,IAAI,QAAQ,SACR,QAAQ,OAAe,YAAqB;GACxC,OAAO,QAAQ,YAAY,KAAA,IACrB,QACA,CACE,OACA,OACJ;GAEJ,OAAO;EACX;EAGJ,IAAI,QAAQ,OACR,QAAQ,UAAkB,8BAA8B;GACpD,OAAO,WAAW;IACd;IACA,YAAY,UAAkB,IAAI,SAAS,KAAK;GACpD;GAEA,OAAO;EACX;EAGJ,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IndexDirection, IndexOptions, Schema, Types } from "mongoose";
|
|
2
2
|
import { Merge } from "type-fest";
|
|
3
|
-
//#region src/schema-builders/uuid.d.ts
|
|
4
3
|
type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<UUIDSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
|
|
5
4
|
interface BaseProps {
|
|
6
5
|
type: typeof Schema.Types.UUID;
|
|
@@ -30,5 +29,5 @@ export interface UUIDSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmi
|
|
|
30
29
|
}>, ExtraOmitFields>;
|
|
31
30
|
}
|
|
32
31
|
export declare const uuidSchemaBuilder: (schema?: Record<string, any>) => UUIDSchemaBuilder<BaseProps, never>;
|
|
33
|
-
|
|
32
|
+
export {};
|
|
34
33
|
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","names":[],"sources":["../../src/schema-builders/uuid.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","names":[],"sources":["../../src/schema-builders/uuid.ts"],"mappings":";;KAUK,oBACD,cAAc,WACd,kCACA,KACA,kBAAkB,OAAO,kBACzB,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;iBAGb,kBAAkB,cAAc,YAAY,WAAW;EACpE,UACI,YACI,WAAW,6BAA6B,MAAM,oCAGhD,MAAM,kBAGR,OAAO,MACN,oBAAoB,MAAM;IAAS,SAAS;MAAM;EAEvD,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;qBAGnD,oBAAiB,SAAA,wBAAA,kBAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createBaseSchemaBuilderFactory } from "./base.js";
|
|
2
2
|
import { Schema } from "mongoose";
|
|
3
|
-
|
|
3
|
+
// src/schema-builders/uuid.ts
|
|
4
4
|
const uuidSchemaBuilder = createBaseSchemaBuilderFactory(Schema.Types.UUID);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { uuidSchemaBuilder };
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=uuid.js.map
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
export type EnumInput<T, M extends string = string> = EnumOptions<T, M> | Readonlyable<T[]> | Record<string, T>;
|
|
2
2
|
export type Readonlyable<T> = Readonly<T> | T;
|
|
3
|
-
|
|
3
|
+
export type ValueWithMessage<T, M extends string = string> = Readonlyable<[T, M]> | T;
|
|
4
|
+
export interface EnumOptions<T, M extends string = string> {
|
|
5
|
+
message?: M;
|
|
6
|
+
values: Readonlyable<T[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface EnumValidator<T, V = T> {
|
|
9
|
+
enumValues: Array<null | T>;
|
|
10
|
+
message: string;
|
|
11
|
+
type: 'enum';
|
|
12
|
+
validator: (value: null | undefined | V) => boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface LimitValidator<L, V = L> {
|
|
15
|
+
max?: L;
|
|
16
|
+
message: string;
|
|
17
|
+
min?: L;
|
|
18
|
+
type: 'max' | 'min';
|
|
19
|
+
validator: (value: null | undefined | V) => boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ValidationSchema<T> {
|
|
22
|
+
validate: T[];
|
|
23
|
+
}
|
|
4
24
|
//# sourceMappingURL=_internals.d.ts.map
|