@kikiutils/mongoose 7.0.3 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +8 -8
  2. package/dist/_internals.d.ts +5 -2
  3. package/dist/_internals.d.ts.map +1 -1
  4. package/dist/_internals.js +2 -1
  5. package/dist/_internals.js.map +1 -1
  6. package/dist/assertions.d.ts +1 -2
  7. package/dist/assertions.d.ts.map +1 -1
  8. package/dist/builders.d.ts +3 -4
  9. package/dist/builders.d.ts.map +1 -1
  10. package/dist/builders.js +2 -3
  11. package/dist/builders.js.map +1 -1
  12. package/dist/connection.d.ts +5 -0
  13. package/dist/connection.d.ts.map +1 -0
  14. package/dist/connection.js +10 -0
  15. package/dist/connection.js.map +1 -0
  16. package/dist/options.d.ts +1 -2
  17. package/dist/options.d.ts.map +1 -1
  18. package/dist/options.js +2 -1
  19. package/dist/options.js.map +1 -1
  20. package/dist/plugins/assertions.d.ts +1 -2
  21. package/dist/plugins/assertions.d.ts.map +1 -1
  22. package/dist/plugins/normalize.d.ts +23 -17
  23. package/dist/plugins/normalize.d.ts.map +1 -1
  24. package/dist/plugins/normalize.js +19 -12
  25. package/dist/plugins/normalize.js.map +1 -1
  26. package/dist/schema-builders/base.d.ts +2 -3
  27. package/dist/schema-builders/base.d.ts.map +1 -1
  28. package/dist/schema-builders/base.js.map +1 -1
  29. package/dist/schema-builders/bigint.d.ts +48 -0
  30. package/dist/schema-builders/bigint.d.ts.map +1 -0
  31. package/dist/schema-builders/bigint.js +36 -0
  32. package/dist/schema-builders/bigint.js.map +1 -0
  33. package/dist/schema-builders/boolean.d.ts +2 -3
  34. package/dist/schema-builders/boolean.d.ts.map +1 -1
  35. package/dist/schema-builders/boolean.js.map +1 -1
  36. package/dist/schema-builders/date.d.ts +2 -3
  37. package/dist/schema-builders/date.d.ts.map +1 -1
  38. package/dist/schema-builders/decimal128.d.ts +33 -15
  39. package/dist/schema-builders/decimal128.d.ts.map +1 -1
  40. package/dist/schema-builders/decimal128.js +23 -0
  41. package/dist/schema-builders/decimal128.js.map +1 -1
  42. package/dist/schema-builders/double.d.ts +48 -0
  43. package/dist/schema-builders/double.d.ts.map +1 -0
  44. package/dist/schema-builders/double.js +37 -0
  45. package/dist/schema-builders/double.js.map +1 -0
  46. package/dist/schema-builders/index.d.ts +6 -1
  47. package/dist/schema-builders/index.js +6 -1
  48. package/dist/schema-builders/int32.d.ts +48 -0
  49. package/dist/schema-builders/int32.d.ts.map +1 -0
  50. package/dist/schema-builders/int32.js +36 -0
  51. package/dist/schema-builders/int32.js.map +1 -0
  52. package/dist/schema-builders/mixed.d.ts +34 -0
  53. package/dist/schema-builders/mixed.d.ts.map +1 -0
  54. package/dist/schema-builders/mixed.js +8 -0
  55. package/dist/schema-builders/mixed.js.map +1 -0
  56. package/dist/schema-builders/number.d.ts +2 -3
  57. package/dist/schema-builders/number.d.ts.map +1 -1
  58. package/dist/schema-builders/object-id.d.ts +2 -3
  59. package/dist/schema-builders/object-id.d.ts.map +1 -1
  60. package/dist/schema-builders/ref.d.ts +2 -3
  61. package/dist/schema-builders/ref.d.ts.map +1 -1
  62. package/dist/schema-builders/string.d.ts +56 -19
  63. package/dist/schema-builders/string.d.ts.map +1 -1
  64. package/dist/schema-builders/string.js +13 -1
  65. package/dist/schema-builders/string.js.map +1 -1
  66. package/dist/schema-builders/uuid.d.ts +34 -0
  67. package/dist/schema-builders/uuid.d.ts.map +1 -0
  68. package/dist/schema-builders/uuid.js +8 -0
  69. package/dist/schema-builders/uuid.js.map +1 -0
  70. package/dist/types/_internals.d.ts +1 -2
  71. package/dist/types/_internals.d.ts.map +1 -1
  72. package/dist/types/aggregate-paginate.d.ts +30 -14
  73. package/dist/types/aggregate-paginate.d.ts.map +1 -1
  74. package/dist/types/data.d.ts +2 -3
  75. package/dist/types/data.d.ts.map +1 -1
  76. package/dist/types/index.d.ts +10 -14
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/options.d.ts +4 -4
  79. package/dist/types/options.d.ts.map +1 -1
  80. package/dist/types/paginate.d.ts +15 -11
  81. package/dist/types/paginate.d.ts.map +1 -1
  82. package/package.json +23 -18
  83. package/src/_internals.ts +3 -0
  84. package/src/builders.ts +3 -10
  85. package/src/connection.ts +14 -0
  86. package/src/options.ts +8 -1
  87. package/src/plugins/normalize.ts +23 -15
  88. package/src/schema-builders/base.ts +8 -1
  89. package/src/schema-builders/bigint.ts +134 -0
  90. package/src/schema-builders/boolean.ts +1 -4
  91. package/src/schema-builders/decimal128.ts +92 -12
  92. package/src/schema-builders/double.ts +135 -0
  93. package/src/schema-builders/index.ts +15 -0
  94. package/src/schema-builders/int32.ts +135 -0
  95. package/src/schema-builders/mixed.ts +37 -0
  96. package/src/schema-builders/string.ts +90 -17
  97. package/src/schema-builders/uuid.ts +48 -0
  98. package/src/types/aggregate-paginate.ts +29 -8
  99. package/src/types/index.ts +0 -5
  100. package/src/types/options.ts +3 -0
  101. package/src/types/paginate.ts +6 -2
  102. package/dist/constants.d.ts +0 -6
  103. package/dist/constants.d.ts.map +0 -1
  104. package/dist/constants.js +0 -6
  105. package/dist/constants.js.map +0 -1
  106. package/dist/helpers.d.ts +0 -6
  107. package/dist/helpers.d.ts.map +0 -1
  108. package/dist/helpers.js +0 -9
  109. package/dist/helpers.js.map +0 -1
  110. package/src/constants.ts +0 -3
  111. package/src/helpers.ts +0 -5
@@ -3,11 +3,21 @@ import { DefaultType, IndexDirection, IndexOptions, Schema, Types } from "mongoo
3
3
  import { Decimal } from "decimal.js";
4
4
  import { Merge } from "type-fest";
5
5
  //#region src/schema-builders/decimal128.d.ts
6
+ type Decimal128Limit = Decimal.Value | Types.Decimal128 | {
7
+ toString: () => string;
8
+ };
6
9
  type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Decimal128SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
7
10
  interface BaseProps {
8
11
  type: typeof Schema.Types.Decimal128;
9
12
  }
10
- interface Decimal128SchemaBuilder<Props extends {
13
+ interface Decimal128LimitValidator {
14
+ max?: string;
15
+ message: string;
16
+ min?: string;
17
+ type: 'max' | 'min';
18
+ validator: (value: null | Types.Decimal128 | undefined) => boolean;
19
+ }
20
+ export interface Decimal128SchemaBuilder<Props extends {
11
21
  type: typeof Schema.Types.Decimal128;
12
22
  } = {
13
23
  type: typeof Schema.Types.Decimal128;
@@ -29,6 +39,8 @@ interface Decimal128SchemaBuilder<Props extends {
29
39
  index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
30
40
  index: T;
31
41
  }>, ExtraOmitFields>;
42
+ max: <T extends D | Readonlyable<[D, S]>, D extends Decimal128Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Decimal128ValidationSchema>, 'max' | ExtraOmitFields>;
43
+ min: <T extends D | Readonlyable<[D, S]>, D extends Decimal128Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Decimal128ValidationSchema>, 'min' | ExtraOmitFields>;
32
44
  nonRequired: Props;
33
45
  private: ExtendSchemaBuilder<Merge<Props, {
34
46
  private: true;
@@ -37,24 +49,28 @@ interface Decimal128SchemaBuilder<Props extends {
37
49
  required: true;
38
50
  }>;
39
51
  /**
40
- * Sets the rounding and toFixed behavior for Decimal128 fields.
41
- * This method allows specifying the number of decimal places and the rounding strategy to be used when
42
- * saving the field to the database.
52
+ * Configures a setter that rounds decimal values and formats them with a fixed number of decimal places.
53
+ *
54
+ * @remarks
55
+ * Replaces the configured setter on this builder. The setter converts non-nullish values through Decimal.js
56
+ * and returns a decimal string for Mongoose to cast to `Decimal128`. It returns `undefined` for `null` or
57
+ * `undefined`. Decimal.js validates conversion and formatting when the setter processes a value,
58
+ * not when the setter is configured.
43
59
  *
44
- * @param places - The number of decimal places to round to (default is 2).
45
- * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).
60
+ * @param places - The non-negative integer number of decimal places. Defaults to `2`.
61
+ * @param rounding - The Decimal.js rounding mode. Defaults to `Decimal.ROUND_DOWN`, which rounds toward zero.
46
62
  *
47
- * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.
63
+ * @returns This instance for chaining.
48
64
  */
49
65
  setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendSchemaBuilder<Merge<Props, ToStringSetterSchema>, 'setRoundAndToFixedSetter' | ExtraOmitFields>;
50
66
  /**
51
- * Sets the toString behavior for Decimal128 fields.
52
- * This method defines how the Decimal128 field should be converted to a string when processing or
53
- * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128
54
- * in the database.
67
+ * Configures a getter that converts decimal values to strings.
55
68
  *
56
- * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string
57
- * when accessed in the application.
69
+ * @remarks
70
+ * Replaces the configured getter on this builder. The getter returns the value's string representation,
71
+ * or `undefined` for `null` or `undefined`. It changes the read representation, not the stored BSON type.
72
+ *
73
+ * @returns This instance for chaining.
58
74
  */
59
75
  setToStringGetter: ExtendSchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;
60
76
  sparse: ExtendSchemaBuilder<Merge<Props, {
@@ -64,6 +80,9 @@ interface Decimal128SchemaBuilder<Props extends {
64
80
  unique: true;
65
81
  }>, ExtraOmitFields>;
66
82
  }
83
+ interface Decimal128ValidationSchema {
84
+ validate: Decimal128LimitValidator[];
85
+ }
67
86
  interface ToStringGetterSchema {
68
87
  get: (value?: Types.Decimal128) => string | undefined;
69
88
  }
@@ -72,7 +91,6 @@ interface ToStringSetterSchema {
72
91
  toString: () => string;
73
92
  }) => string | undefined;
74
93
  }
75
- declare function decimal128SchemaBuilder(): Decimal128SchemaBuilder;
94
+ export declare function decimal128SchemaBuilder(): Decimal128SchemaBuilder;
76
95
  //#endregion
77
- export { Decimal128SchemaBuilder, decimal128SchemaBuilder };
78
96
  //# sourceMappingURL=decimal128.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decimal128.d.ts","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"mappings":";;;;;KAcK,oBACD,cAAc,WACd,kCACA,KACA,wBAAwB,OAAO,kBAC/B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGb,wBACb;EAAgB,aAAa,OAAO,MAAM;;EAAiB,aAAa,OAAO,MAAM;GACrF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,YAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,UAAU,MAAM,YAChB,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,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;;;;;;;;;;;EAYzB,2BAA2B,iBAAiB,WAAW,QAAQ,aAAa,oBACxE,MAAM,OAAO,oDACgB;;;;;;;;;;EAYjC,mBAAmB,oBAAoB,MAAM,OAAO,6CAA6C;EACjG,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;UAGtD;EACN,MAAM,QAAQ,MAAM;;UAGd;EACN,MAAM;IAAU;;;iBAKJ,2BA4BP"}
1
+ {"version":3,"file":"decimal128.d.ts","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"mappings":";;;;;KAcK,kBAAkB,QAAQ,QAAQ,MAAM;EAAe;;KACvD,oBACD,cAAc,WACd,kCACA,KACA,wBAAwB,OAAO,kBAC/B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGpB;EACN;EACA;EACA;EACA;EACA,YAAY,cAAc,MAAM;;iBAGnB,wBACb;EAAgB,aAAa,OAAO,MAAM;;EAAiB,aAAa,OAAO,MAAM;GACrF;EAEA,UACI,YAAY,WAAW,aAAa,YAAY,MAAM,YAAY,WAClE,UAAU,MAAM,YAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,OACI,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,UAAU,MAAM,YAChB,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,IAAI,cAAc,GAAG,KAC/B,UAAU,iBACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,qCACL;EAGZ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,iBACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,qCACL;EAGZ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;;;;;;;;;;;;;;;EAgBzB,2BAA2B,iBAAiB,WAAW,QAAQ,aAAa,oBACxE,MAAM,OAAO,oDACgB;;;;;;;;;;EAYjC,mBAAmB,oBAAoB,MAAM,OAAO,6CAA6C;EACjG,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;UAGtD;EACN,UAAU;;UAGJ;EACN,MAAM,QAAQ,MAAM;;UAGd;EACN,MAAM;IAAU;;;wBAqCJ,2BAyCP"}
@@ -2,11 +2,34 @@ import { createBaseSchemaBuilderFactory } from "./base.js";
2
2
  import { Schema } from "mongoose";
3
3
  import { Decimal } from "decimal.js";
4
4
  //#region src/schema-builders/decimal128.ts
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}).";
5
7
  const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);
8
+ function createLimitValidator(type, value) {
9
+ const [limit, message] = Array.isArray(value) ? value : [value, void 0];
10
+ const decimalLimit = new Decimal(limit.toString());
11
+ if (!decimalLimit.isFinite()) throw new RangeError(`Decimal128 ${type} limit must be finite`);
12
+ return {
13
+ message: message ?? (type === "min" ? defaultMinValidateMessage : defaultMaxValidateMessage),
14
+ [type]: decimalLimit.toString(),
15
+ type,
16
+ validator: (value) => {
17
+ if (value === null || value === void 0) return true;
18
+ const decimalValue = new Decimal(value.toString());
19
+ return type === "min" ? decimalValue.gte(decimalLimit) : decimalValue.lte(decimalLimit);
20
+ }
21
+ };
22
+ }
6
23
  function decimal128SchemaBuilder() {
7
24
  const schema = {};
8
25
  const baseBuilder = baseBuilderFactory(schema);
9
26
  return new Proxy(baseBuilder, { get(target, key, receiver) {
27
+ if (key === "max" || key === "min") return (value) => {
28
+ const validator = createLimitValidator(key, value);
29
+ const validators = Array.isArray(schema.validate) ? schema.validate : [];
30
+ schema.validate = [...validators.filter(({ type }) => type !== key), validator];
31
+ return receiver;
32
+ };
10
33
  if (key === "setRoundAndToFixedSetter") return (places = 2, rounding = Decimal.ROUND_DOWN) => {
11
34
  schema.set = (value) => {
12
35
  if (value !== void 0 && value !== null) return (Decimal.isDecimal(value) ? value : new Decimal(value.toString())).toFixed(places, rounding);
@@ -1 +1 @@
1
- {"version":3,"file":"decimal128.js","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport { 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 { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n Decimal128SchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\nexport interface Decimal128SchemaBuilder<\n Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.Decimal128,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M 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 nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Sets the rounding and toFixed behavior for Decimal128 fields.\n * This method allows specifying the number of decimal places and the rounding strategy to be used when\n * saving the field to the database.\n *\n * @param places - The number of decimal places to round to (default is 2).\n * @param rounding - The rounding strategy from the Decimal.js library (default is Decimal.ROUND_DOWN).\n *\n * @returns A schema builder with the rounding and toFixed behavior applied to the `set` option in Mongoose.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendSchemaBuilder<\n Merge<Props, ToStringSetterSchema>,\n 'setRoundAndToFixedSetter' | ExtraOmitFields\n >;\n\n /**\n * Sets the toString behavior for Decimal128 fields.\n * This method defines how the Decimal128 field should be converted to a string when processing or\n * retrieving the value in the application (e.g., via getters), while still storing the value as Decimal128\n * in the database.\n *\n * @returns A schema builder with the custom `get` behavior applied to convert the Decimal128 field to a string\n * when accessed in the application.\n */\n setToStringGetter: ExtendSchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string | undefined;\n}\n\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nexport function decimal128SchemaBuilder() {\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 === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => {\n if (value !== undefined && value !== null) {\n const decimal = Decimal.isDecimal(value) ? value : new Decimal(value.toString());\n return decimal.toFixed(places, rounding);\n }\n };\n\n return receiver;\n };\n }\n\n if (key === 'setToStringGetter') {\n schema.get = (value?: Types.Decimal128) => value?.toString();\n return receiver;\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Decimal128SchemaBuilder;\n}\n"],"mappings":";;;;AAiGA,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,UAAU;AAEjF,SAAgB,0BAA0B;CACtC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,4BACR,QAAQ,SAAiB,GAAG,WAA6B,QAAQ,eAAe;GAC5E,OAAO,OAAO,UAAuC;IACjD,IAAI,UAAU,KAAA,KAAa,UAAU,MAEjC,QADgB,QAAQ,UAAU,KAAK,IAAI,QAAQ,IAAI,QAAQ,MAAM,SAAS,CAAC,EAAA,CAChE,QAAQ,QAAQ,QAAQ;GAE/C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,qBAAqB;GAC7B,OAAO,OAAO,UAA6B,OAAO,SAAS;GAC3D,OAAO;EACX;EAEA,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
1
+ {"version":3,"file":"decimal128.js","names":[],"sources":["../../src/schema-builders/decimal128.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport { 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 { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype Decimal128Limit = Decimal.Value | Types.Decimal128 | { toString: () => string };\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n Decimal128SchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Decimal128;\n}\n\ninterface Decimal128LimitValidator {\n max?: string;\n message: string;\n min?: string;\n type: 'max' | 'min';\n validator: (value: null | Types.Decimal128 | undefined) => boolean;\n}\n\nexport interface Decimal128SchemaBuilder<\n Props extends { type: typeof Schema.Types.Decimal128 } = { type: typeof Schema.Types.Decimal128 },\n ExtraOmitFields extends string = never,\n> {\n default: <\n T extends ((this: any, doc: any) => DefaultType<D>) | DefaultType<D> | null,\n D extends Types.Decimal128,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: T }>,\n ExtraOmitFields\n >;\n\n enum: <\n T extends\n | Readonlyable<Array<D | null>>\n | { [path: string]: D | null }\n | { message?: M; values: Readonlyable<Array<D | null>> },\n D extends Types.Decimal128,\n M 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 max: <\n T extends D | Readonlyable<[D, S]>,\n D extends Decimal128Limit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, Decimal128ValidationSchema>,\n 'max' | ExtraOmitFields\n >;\n\n min: <\n T extends D | Readonlyable<[D, S]>,\n D extends Decimal128Limit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, Decimal128ValidationSchema>,\n 'min' | ExtraOmitFields\n >;\n\n nonRequired: Props;\n private: ExtendSchemaBuilder<Merge<Props, { private: true }>, ExtraOmitFields>;\n required: Merge<Props, { required: true }>;\n\n /**\n * Configures a setter that rounds decimal values and formats them with a fixed number of decimal places.\n *\n * @remarks\n * Replaces the configured setter on this builder. The setter converts non-nullish values through Decimal.js\n * and returns a decimal string for Mongoose to cast to `Decimal128`. It returns `undefined` for `null` or\n * `undefined`. Decimal.js validates conversion and formatting when the setter processes a value,\n * not when the setter is configured.\n *\n * @param places - The non-negative integer number of decimal places. Defaults to `2`.\n * @param rounding - The Decimal.js rounding mode. Defaults to `Decimal.ROUND_DOWN`, which rounds toward zero.\n *\n * @returns This instance for chaining.\n */\n setRoundAndToFixedSetter: (places?: number, rounding?: Decimal.Rounding) => ExtendSchemaBuilder<\n Merge<Props, ToStringSetterSchema>,\n 'setRoundAndToFixedSetter' | ExtraOmitFields\n >;\n\n /**\n * Configures a getter that converts decimal values to strings.\n *\n * @remarks\n * Replaces the configured getter on this builder. The getter returns the value's string representation,\n * or `undefined` for `null` or `undefined`. It changes the read representation, not the stored BSON type.\n *\n * @returns This instance for chaining.\n */\n setToStringGetter: ExtendSchemaBuilder<Merge<Props, ToStringGetterSchema>, 'setToStringGetter' | ExtraOmitFields>;\n sparse: ExtendSchemaBuilder<Merge<Props, { sparse: true }>, ExtraOmitFields>;\n unique: ExtendSchemaBuilder<Merge<Props, { unique: true }>, ExtraOmitFields>;\n}\n\ninterface Decimal128ValidationSchema {\n validate: Decimal128LimitValidator[];\n}\n\ninterface ToStringGetterSchema {\n get: (value?: Types.Decimal128) => string | undefined;\n}\n\ninterface ToStringSetterSchema {\n set: (value?: { toString: () => string }) => string | undefined;\n}\n\n// Constants/Variables\nconst defaultMinValidateMessage = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';\nconst defaultMaxValidateMessage = 'Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).';\n\n// Functions\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Decimal128);\n\nfunction createLimitValidator(\n type: 'max' | 'min',\n value: Decimal128Limit | Readonlyable<[Decimal128Limit, string]>,\n): Decimal128LimitValidator {\n const [limit, message] = Array.isArray(value)\n ? value as Readonly<[Decimal128Limit, string]>\n : [\n value,\n undefined,\n ];\n\n const decimalLimit = new Decimal(limit.toString());\n if (!decimalLimit.isFinite()) throw new RangeError(`Decimal128 ${type} limit must be finite`);\n\n return {\n message: message ?? (type === 'min' ? defaultMinValidateMessage : defaultMaxValidateMessage),\n [type]: decimalLimit.toString(),\n type,\n validator: (value) => {\n if (value === null || value === undefined) return true;\n\n const decimalValue = new Decimal(value.toString());\n return type === 'min' ? decimalValue.gte(decimalLimit) : decimalValue.lte(decimalLimit);\n },\n };\n}\n\nexport function decimal128SchemaBuilder() {\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 === 'max' || key === 'min') {\n return (value: Decimal128Limit | Readonlyable<[Decimal128Limit, string]>) => {\n const validator = createLimitValidator(key, value);\n const validators = Array.isArray(schema.validate) ? schema.validate : [];\n schema.validate = [\n ...validators.filter(({ type }) => type !== key),\n validator,\n ];\n\n return receiver;\n };\n }\n\n if (key === 'setRoundAndToFixedSetter') {\n return (places: number = 2, rounding: Decimal.Rounding = Decimal.ROUND_DOWN) => {\n schema.set = (value?: { toString: () => string }) => {\n if (value !== undefined && value !== null) {\n const decimal = Decimal.isDecimal(value) ? value : new Decimal(value.toString());\n return decimal.toFixed(places, rounding);\n }\n };\n\n return receiver;\n };\n }\n\n if (key === 'setToStringGetter') {\n schema.get = (value?: Types.Decimal128) => value?.toString();\n return receiver;\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Decimal128SchemaBuilder;\n}\n"],"mappings":";;;;AAqIA,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,UAAU;AAEjF,SAAS,qBACL,MACA,OACwB;CACxB,MAAM,CAAC,OAAO,WAAW,MAAM,QAAQ,KAAK,IACtC,QACA,CACE,OACA,KAAA,CACJ;CAEJ,MAAM,eAAe,IAAI,QAAQ,MAAM,SAAS,CAAC;CACjD,IAAI,CAAC,aAAa,SAAS,GAAG,MAAM,IAAI,WAAW,cAAc,KAAK,sBAAsB;CAE5F,OAAO;EACH,SAAS,YAAY,SAAS,QAAQ,4BAA4B;GACjE,OAAO,aAAa,SAAS;EAC9B;EACA,YAAY,UAAU;GAClB,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;GAElD,MAAM,eAAe,IAAI,QAAQ,MAAM,SAAS,CAAC;GACjD,OAAO,SAAS,QAAQ,aAAa,IAAI,YAAY,IAAI,aAAa,IAAI,YAAY;EAC1F;CACJ;AACJ;AAEA,SAAgB,0BAA0B;CACtC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,SAAS,QAAQ,OACzB,QAAQ,UAAqE;GACzE,MAAM,YAAY,qBAAqB,KAAK,KAAK;GACjD,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;GACvE,OAAO,WAAW,CACd,GAAG,WAAW,QAAQ,EAAE,WAAW,SAAS,GAAG,GAC/C,SACJ;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,4BACR,QAAQ,SAAiB,GAAG,WAA6B,QAAQ,eAAe;GAC5E,OAAO,OAAO,UAAuC;IACjD,IAAI,UAAU,KAAA,KAAa,UAAU,MAEjC,QADgB,QAAQ,UAAU,KAAK,IAAI,QAAQ,IAAI,QAAQ,MAAM,SAAS,CAAC,EAAA,CAChE,QAAQ,QAAQ,QAAQ;GAE/C;GAEA,OAAO;EACX;EAGJ,IAAI,QAAQ,qBAAqB;GAC7B,OAAO,OAAO,UAA6B,OAAO,SAAS;GAC3D,OAAO;EACX;EAEA,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
@@ -0,0 +1,48 @@
1
+ import { Readonlyable } from "../types/_internals.js";
2
+ import { IndexDirection, IndexOptions, Schema, Types } from "mongoose";
3
+ import { Merge } from "type-fest";
4
+ //#region src/schema-builders/double.d.ts
5
+ type DoubleLimit = number | Types.Double;
6
+ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<DoubleSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
7
+ interface BaseProps {
8
+ type: typeof Schema.Types.Double;
9
+ }
10
+ interface DoubleLimitValidator {
11
+ max?: number;
12
+ message: string;
13
+ min?: number;
14
+ type: 'max' | 'min';
15
+ validator: (value: null | Types.Double | undefined) => boolean;
16
+ }
17
+ export interface DoubleSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {
18
+ default: <T extends ((this: any, doc: any) => D | null | undefined) | D | null | undefined, D extends Types.Double>(value: T) => ExtendSchemaBuilder<Merge<Props, {
19
+ default: T;
20
+ }>, ExtraOmitFields>;
21
+ immutable: ExtendSchemaBuilder<Merge<Props, {
22
+ immutable: true;
23
+ }>, ExtraOmitFields>;
24
+ index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
25
+ index: T;
26
+ }>, ExtraOmitFields>;
27
+ max: <T extends L | Readonlyable<[L, S]>, L extends DoubleLimit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, DoubleValidationSchema>, 'max' | ExtraOmitFields>;
28
+ min: <T extends L | Readonlyable<[L, S]>, L extends DoubleLimit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, DoubleValidationSchema>, 'min' | ExtraOmitFields>;
29
+ nonRequired: Props;
30
+ private: ExtendSchemaBuilder<Merge<Props, {
31
+ private: true;
32
+ }>, ExtraOmitFields>;
33
+ required: Merge<Props, {
34
+ required: true;
35
+ }>;
36
+ sparse: ExtendSchemaBuilder<Merge<Props, {
37
+ sparse: true;
38
+ }>, ExtraOmitFields>;
39
+ unique: ExtendSchemaBuilder<Merge<Props, {
40
+ unique: true;
41
+ }>, ExtraOmitFields>;
42
+ }
43
+ interface DoubleValidationSchema {
44
+ validate: DoubleLimitValidator[];
45
+ }
46
+ export declare function doubleSchemaBuilder(): DoubleSchemaBuilder;
47
+ //#endregion
48
+ //# sourceMappingURL=double.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"double.d.ts","names":[],"sources":["../../src/schema-builders/double.ts"],"mappings":";;;;KAYK,uBAAuB,MAAM;KAC7B,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGpB;EACN;EACA;EACA;EACA;EACA,YAAY,cAAc,MAAM;;iBAGnB,oBAAoB,cAAc,YAAY,WAAW;EACtE,UACI,YAAY,WAAW,aAAa,wBAAwB,sBAC5D,UAAU,MAAM,QAClB,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,aACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,iCACL;EAGZ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,aACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,iCACL;EAGZ,aAAa;EACb,SAAS,oBAAoB,MAAM;IAAS;MAAkB;EAC9D,UAAU,MAAM;IAAS;;EACzB,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;EAC5D,QAAQ,oBAAoB,MAAM;IAAS;MAAiB;;UAGtD;EACN,UAAU;;wBAoCE,uBAuBP"}
@@ -0,0 +1,37 @@
1
+ import { createBaseSchemaBuilderFactory } from "./base.js";
2
+ import { Schema } from "mongoose";
3
+ //#region src/schema-builders/double.ts
4
+ const defaultMinValidateMessage = "Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).";
5
+ const defaultMaxValidateMessage = "Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).";
6
+ const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Double);
7
+ function createLimitValidator(type, value) {
8
+ const [limit, message] = Array.isArray(value) ? value : [value, void 0];
9
+ const numericLimit = typeof limit === "number" ? limit : limit.valueOf();
10
+ if (!Number.isFinite(numericLimit)) throw new RangeError(`Double ${type} limit must be finite`);
11
+ return {
12
+ message: message ?? (type === "min" ? defaultMinValidateMessage : defaultMaxValidateMessage),
13
+ [type]: numericLimit,
14
+ type,
15
+ validator: (value) => {
16
+ if (value === null || value === void 0) return true;
17
+ return type === "min" ? value.valueOf() >= numericLimit : value.valueOf() <= numericLimit;
18
+ }
19
+ };
20
+ }
21
+ function doubleSchemaBuilder() {
22
+ const schema = {};
23
+ const baseBuilder = baseBuilderFactory(schema);
24
+ return new Proxy(baseBuilder, { get(target, key, receiver) {
25
+ if (key === "max" || key === "min") return (value) => {
26
+ const validator = createLimitValidator(key, value);
27
+ const validators = Array.isArray(schema.validate) ? schema.validate : [];
28
+ schema.validate = [...validators.filter(({ type }) => type !== key), validator];
29
+ return receiver;
30
+ };
31
+ return Reflect.get(target, key, receiver);
32
+ } });
33
+ }
34
+ //#endregion
35
+ export { doubleSchemaBuilder };
36
+
37
+ //# sourceMappingURL=double.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"double.js","names":[],"sources":["../../src/schema-builders/double.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n IndexDirection,\n IndexOptions,\n Types,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport type { Readonlyable } from '../types/_internals';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype DoubleLimit = number | Types.Double;\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n DoubleSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Double;\n}\n\ninterface DoubleLimitValidator {\n max?: number;\n message: string;\n min?: number;\n type: 'max' | 'min';\n validator: (value: null | Types.Double | undefined) => boolean;\n}\n\nexport interface DoubleSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {\n default: <\n T extends ((this: any, doc: any) => D | null | undefined) | D | null | undefined,\n D extends Types.Double,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, { default: 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 L | Readonlyable<[L, S]>,\n L extends DoubleLimit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, DoubleValidationSchema>,\n 'max' | ExtraOmitFields\n >;\n\n min: <\n T extends L | Readonlyable<[L, S]>,\n L extends DoubleLimit,\n S extends string,\n >(value: T) => ExtendSchemaBuilder<\n Merge<Props, DoubleValidationSchema>,\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\ninterface DoubleValidationSchema {\n validate: DoubleLimitValidator[];\n}\n\n// Constants/Variables\nconst defaultMinValidateMessage = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';\nconst defaultMaxValidateMessage = 'Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).';\n\n// Functions\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Double);\n\nfunction createLimitValidator(\n type: 'max' | 'min',\n value: DoubleLimit | Readonlyable<[DoubleLimit, string]>,\n): DoubleLimitValidator {\n const [limit, message] = Array.isArray(value)\n ? value as Readonly<[DoubleLimit, string]>\n : [\n value as DoubleLimit,\n undefined,\n ];\n\n const numericLimit = typeof limit === 'number' ? limit : limit.valueOf();\n if (!Number.isFinite(numericLimit)) throw new RangeError(`Double ${type} limit must be finite`);\n\n return {\n message: message ?? (type === 'min' ? defaultMinValidateMessage : defaultMaxValidateMessage),\n [type]: numericLimit,\n type,\n validator: (value) => {\n if (value === null || value === undefined) return true;\n\n return type === 'min' ? value.valueOf() >= numericLimit : value.valueOf() <= numericLimit;\n },\n };\n}\n\nexport function doubleSchemaBuilder() {\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 === 'max' || key === 'min') {\n return (value: DoubleLimit | Readonlyable<[DoubleLimit, string]>) => {\n const validator = createLimitValidator(key, value);\n const validators = Array.isArray(schema.validate) ? schema.validate : [];\n schema.validate = [\n ...validators.filter(({ type }) => type !== key),\n validator,\n ];\n\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as DoubleSchemaBuilder;\n}\n"],"mappings":";;;AA8EA,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,MAAM;AAE7E,SAAS,qBACL,MACA,OACoB;CACpB,MAAM,CAAC,OAAO,WAAW,MAAM,QAAQ,KAAK,IACtC,QACA,CACE,OACA,KAAA,CACJ;CAEJ,MAAM,eAAe,OAAO,UAAU,WAAW,QAAQ,MAAM,QAAQ;CACvE,IAAI,CAAC,OAAO,SAAS,YAAY,GAAG,MAAM,IAAI,WAAW,UAAU,KAAK,sBAAsB;CAE9F,OAAO;EACH,SAAS,YAAY,SAAS,QAAQ,4BAA4B;GACjE,OAAO;EACR;EACA,YAAY,UAAU;GAClB,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;GAElD,OAAO,SAAS,QAAQ,MAAM,QAAQ,KAAK,eAAe,MAAM,QAAQ,KAAK;EACjF;CACJ;AACJ;AAEA,SAAgB,sBAAsB;CAClC,MAAM,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,SAAS,QAAQ,OACzB,QAAQ,UAA6D;GACjE,MAAM,YAAY,qBAAqB,KAAK,KAAK;GACjD,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;GACvE,OAAO,WAAW,CACd,GAAG,WAAW,QAAQ,EAAE,WAAW,SAAS,GAAG,GAC/C,SACJ;GAEA,OAAO;EACX;EAGJ,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
@@ -1,8 +1,13 @@
1
+ import { BigIntSchemaBuilder, bigintSchemaBuilder } from "./bigint.js";
1
2
  import { BooleanSchemaBuilder, booleanSchemaBuilder } from "./boolean.js";
2
3
  import { DateSchemaBuilder, dateSchemaBuilder } from "./date.js";
3
4
  import { Decimal128SchemaBuilder, decimal128SchemaBuilder } from "./decimal128.js";
5
+ import { DoubleSchemaBuilder, doubleSchemaBuilder } from "./double.js";
6
+ import { Int32SchemaBuilder, int32SchemaBuilder } from "./int32.js";
7
+ import { MixedSchemaBuilder, mixedSchemaBuilder } from "./mixed.js";
4
8
  import { NumberSchemaBuilder, numberSchemaBuilder } from "./number.js";
5
9
  import { ObjectIdSchemaBuilder, objectIdSchemaBuilder } from "./object-id.js";
6
10
  import { RefSchemaBuilder, refSchemaBuilder } from "./ref.js";
7
11
  import { StringSchemaBuilder, stringSchemaBuilder } from "./string.js";
8
- export { BooleanSchemaBuilder, DateSchemaBuilder, Decimal128SchemaBuilder, NumberSchemaBuilder, ObjectIdSchemaBuilder, RefSchemaBuilder, StringSchemaBuilder, booleanSchemaBuilder as boolean, booleanSchemaBuilder, dateSchemaBuilder as date, dateSchemaBuilder, decimal128SchemaBuilder as decimal128, decimal128SchemaBuilder, numberSchemaBuilder as number, numberSchemaBuilder, objectIdSchemaBuilder as objectId, objectIdSchemaBuilder, refSchemaBuilder as ref, refSchemaBuilder, stringSchemaBuilder as string, stringSchemaBuilder };
12
+ import { UUIDSchemaBuilder, uuidSchemaBuilder } from "./uuid.js";
13
+ export { BigIntSchemaBuilder, BooleanSchemaBuilder, DateSchemaBuilder, Decimal128SchemaBuilder, DoubleSchemaBuilder, Int32SchemaBuilder, MixedSchemaBuilder, NumberSchemaBuilder, ObjectIdSchemaBuilder, RefSchemaBuilder, StringSchemaBuilder, UUIDSchemaBuilder, bigintSchemaBuilder as bigint, bigintSchemaBuilder, booleanSchemaBuilder as boolean, booleanSchemaBuilder, dateSchemaBuilder as date, dateSchemaBuilder, decimal128SchemaBuilder as decimal128, decimal128SchemaBuilder, doubleSchemaBuilder as double, doubleSchemaBuilder, int32SchemaBuilder as int32, int32SchemaBuilder, mixedSchemaBuilder as mixed, mixedSchemaBuilder, numberSchemaBuilder as number, numberSchemaBuilder, objectIdSchemaBuilder as objectId, objectIdSchemaBuilder, refSchemaBuilder as ref, refSchemaBuilder, stringSchemaBuilder as string, stringSchemaBuilder, uuidSchemaBuilder as uuid, uuidSchemaBuilder };
@@ -1,8 +1,13 @@
1
+ import { bigintSchemaBuilder } from "./bigint.js";
1
2
  import { booleanSchemaBuilder } from "./boolean.js";
2
3
  import { dateSchemaBuilder } from "./date.js";
3
4
  import { decimal128SchemaBuilder } from "./decimal128.js";
5
+ import { doubleSchemaBuilder } from "./double.js";
6
+ import { int32SchemaBuilder } from "./int32.js";
7
+ import { mixedSchemaBuilder } from "./mixed.js";
4
8
  import { numberSchemaBuilder } from "./number.js";
5
9
  import { objectIdSchemaBuilder } from "./object-id.js";
6
10
  import { refSchemaBuilder } from "./ref.js";
7
11
  import { stringSchemaBuilder } from "./string.js";
8
- export { booleanSchemaBuilder as boolean, booleanSchemaBuilder, dateSchemaBuilder as date, dateSchemaBuilder, decimal128SchemaBuilder as decimal128, decimal128SchemaBuilder, numberSchemaBuilder as number, numberSchemaBuilder, objectIdSchemaBuilder as objectId, objectIdSchemaBuilder, refSchemaBuilder as ref, refSchemaBuilder, stringSchemaBuilder as string, stringSchemaBuilder };
12
+ import { uuidSchemaBuilder } from "./uuid.js";
13
+ export { bigintSchemaBuilder as bigint, bigintSchemaBuilder, booleanSchemaBuilder as boolean, booleanSchemaBuilder, dateSchemaBuilder as date, dateSchemaBuilder, decimal128SchemaBuilder as decimal128, decimal128SchemaBuilder, doubleSchemaBuilder as double, doubleSchemaBuilder, int32SchemaBuilder as int32, int32SchemaBuilder, mixedSchemaBuilder as mixed, mixedSchemaBuilder, numberSchemaBuilder as number, numberSchemaBuilder, objectIdSchemaBuilder as objectId, objectIdSchemaBuilder, refSchemaBuilder as ref, refSchemaBuilder, stringSchemaBuilder as string, stringSchemaBuilder, uuidSchemaBuilder as uuid, uuidSchemaBuilder };
@@ -0,0 +1,48 @@
1
+ import { Readonlyable } from "../types/_internals.js";
2
+ import { DefaultType, IndexDirection, IndexOptions, Schema } from "mongoose";
3
+ import { Merge } from "type-fest";
4
+ //#region src/schema-builders/int32.d.ts
5
+ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<Int32SchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
6
+ type Int32Limit = number;
7
+ interface BaseProps {
8
+ type: typeof Schema.Types.Int32;
9
+ }
10
+ interface Int32LimitValidator {
11
+ max?: number;
12
+ message: string;
13
+ min?: number;
14
+ type: 'max' | 'min';
15
+ validator: (value: null | number | undefined) => boolean;
16
+ }
17
+ export interface Int32SchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {
18
+ default: <T extends ((this: any, doc: any) => DefaultType<D> | null | undefined) | DefaultType<D> | null | undefined, D extends number>(value: T) => ExtendSchemaBuilder<Merge<Props, {
19
+ default: T;
20
+ }>, ExtraOmitFields>;
21
+ immutable: ExtendSchemaBuilder<Merge<Props, {
22
+ immutable: true;
23
+ }>, ExtraOmitFields>;
24
+ index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
25
+ index: T;
26
+ }>, ExtraOmitFields>;
27
+ max: <T extends L | Readonlyable<[L, S]>, L extends Int32Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'max' | ExtraOmitFields>;
28
+ min: <T extends L | Readonlyable<[L, S]>, L extends Int32Limit, S extends string>(value: T) => ExtendSchemaBuilder<Merge<Props, Int32ValidationSchema>, 'min' | ExtraOmitFields>;
29
+ nonRequired: Props;
30
+ private: ExtendSchemaBuilder<Merge<Props, {
31
+ private: true;
32
+ }>, ExtraOmitFields>;
33
+ required: Merge<Props, {
34
+ required: true;
35
+ }>;
36
+ sparse: ExtendSchemaBuilder<Merge<Props, {
37
+ sparse: true;
38
+ }>, ExtraOmitFields>;
39
+ unique: ExtendSchemaBuilder<Merge<Props, {
40
+ unique: true;
41
+ }>, ExtraOmitFields>;
42
+ }
43
+ interface Int32ValidationSchema {
44
+ validate: Int32LimitValidator[];
45
+ }
46
+ export declare function int32SchemaBuilder(): Int32SchemaBuilder;
47
+ //#endregion
48
+ //# sourceMappingURL=int32.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"int32.d.ts","names":[],"sources":["../../src/schema-builders/int32.ts"],"mappings":";;;;KAYK,oBACD,cAAc,WACd,kCACA,KACA,mBAAmB,OAAO,kBAC1B,wBAAwB;KAGvB;UAEK;EACN,aAAa,OAAO,MAAM;;UAGpB;EACN;EACA;EACA;EACA;EACA,YAAY;;iBAGC,mBAAmB,cAAc,YAAY,WAAW;EACrE,UACI,YAAY,WAAW,aAAa,YAAY,yBAAyB,YAAY,uBACrF,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,SAAS;MACxB;EAGJ,WAAW,oBAAoB,MAAM;IAAS;MAAoB;EAClE,QAAQ,oBAAoB,iBAAiB,cAAc,OAAO,MAAM,oBACpE,MAAM;IAAS,OAAO;MACtB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,UAAU,YACV,kBACF,OAAO,MAAM,oBACX,MAAM,OAAO,gCACL;EAGZ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,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;;UAGtD;EACN,UAAU;;wBAmCE,sBAuBP"}
@@ -0,0 +1,36 @@
1
+ import { createBaseSchemaBuilderFactory } from "./base.js";
2
+ import { Schema } from "mongoose";
3
+ //#region src/schema-builders/int32.ts
4
+ const defaultMinValidateMessage = "Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).";
5
+ const defaultMaxValidateMessage = "Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).";
6
+ const baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Int32);
7
+ function createLimitValidator(type, value) {
8
+ const [numericLimit, message] = Array.isArray(value) ? value : [value, void 0];
9
+ if (!Number.isFinite(numericLimit)) throw new RangeError(`Int32 ${type} limit must be finite`);
10
+ return {
11
+ message: message ?? (type === "min" ? defaultMinValidateMessage : defaultMaxValidateMessage),
12
+ [type]: numericLimit,
13
+ type,
14
+ validator: (value) => {
15
+ if (value === null || value === void 0) return true;
16
+ return type === "min" ? value >= numericLimit : value <= numericLimit;
17
+ }
18
+ };
19
+ }
20
+ function int32SchemaBuilder() {
21
+ const schema = {};
22
+ const baseBuilder = baseBuilderFactory(schema);
23
+ return new Proxy(baseBuilder, { get(target, key, receiver) {
24
+ if (key === "max" || key === "min") return (value) => {
25
+ const validator = createLimitValidator(key, value);
26
+ const validators = Array.isArray(schema.validate) ? schema.validate : [];
27
+ schema.validate = [...validators.filter(({ type }) => type !== key), validator];
28
+ return receiver;
29
+ };
30
+ return Reflect.get(target, key, receiver);
31
+ } });
32
+ }
33
+ //#endregion
34
+ export { int32SchemaBuilder };
35
+
36
+ //# sourceMappingURL=int32.js.map
@@ -0,0 +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 { Readonlyable } from '../types/_internals';\n\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\ninterface BaseProps {\n type: typeof Schema.Types.Int32;\n}\n\ninterface Int32LimitValidator {\n max?: number;\n message: string;\n min?: number;\n type: 'max' | 'min';\n validator: (value: null | number | undefined) => boolean;\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 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 L | Readonlyable<[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 L | Readonlyable<[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\ninterface Int32ValidationSchema {\n validate: Int32LimitValidator[];\n}\n\n// Constants/Variables\nconst defaultMinValidateMessage = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';\nconst defaultMaxValidateMessage = 'Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).';\n\n// Functions\nconst baseBuilderFactory = createBaseSchemaBuilderFactory(Schema.Types.Int32);\n\nfunction createLimitValidator(\n type: 'max' | 'min',\n value: Int32Limit | Readonlyable<[Int32Limit, string]>,\n): Int32LimitValidator {\n const [numericLimit, message] = Array.isArray(value)\n ? value as Readonly<[Int32Limit, string]>\n : [\n value as Int32Limit,\n undefined,\n ];\n\n if (!Number.isFinite(numericLimit)) throw new RangeError(`Int32 ${type} limit must be finite`);\n\n return {\n message: message ?? (type === 'min' ? defaultMinValidateMessage : defaultMaxValidateMessage),\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: Record<string, any> = {};\n const baseBuilder = baseBuilderFactory(schema);\n return new Proxy(\n baseBuilder,\n {\n get(target, key, receiver) {\n if (key === 'max' || key === 'min') {\n return (value: Int32Limit | Readonlyable<[Int32Limit, string]>) => {\n const validator = createLimitValidator(key, value);\n const validators = Array.isArray(schema.validate) ? schema.validate : [];\n schema.validate = [\n ...validators.filter(({ type }) => type !== key),\n validator,\n ];\n\n return receiver;\n };\n }\n\n return Reflect.get(target, key, receiver);\n },\n },\n ) as Int32SchemaBuilder;\n}\n"],"mappings":";;;AA+EA,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAGlC,MAAM,qBAAqB,+BAA+B,OAAO,MAAM,KAAK;AAE5E,SAAS,qBACL,MACA,OACmB;CACnB,MAAM,CAAC,cAAc,WAAW,MAAM,QAAQ,KAAK,IAC7C,QACA,CACE,OACA,KAAA,CACJ;CAEJ,IAAI,CAAC,OAAO,SAAS,YAAY,GAAG,MAAM,IAAI,WAAW,SAAS,KAAK,sBAAsB;CAE7F,OAAO;EACH,SAAS,YAAY,SAAS,QAAQ,4BAA4B;GACjE,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,SAA8B,CAAC;CACrC,MAAM,cAAc,mBAAmB,MAAM;CAC7C,OAAO,IAAI,MACP,aACA,EACI,IAAI,QAAQ,KAAK,UAAU;EACvB,IAAI,QAAQ,SAAS,QAAQ,OACzB,QAAQ,UAA2D;GAC/D,MAAM,YAAY,qBAAqB,KAAK,KAAK;GACjD,MAAM,aAAa,MAAM,QAAQ,OAAO,QAAQ,IAAI,OAAO,WAAW,CAAC;GACvE,OAAO,WAAW,CACd,GAAG,WAAW,QAAQ,EAAE,WAAW,SAAS,GAAG,GAC/C,SACJ;GAEA,OAAO;EACX;EAGJ,OAAO,QAAQ,IAAI,QAAQ,KAAK,QAAQ;CAC5C,EACJ,CACJ;AACJ"}
@@ -0,0 +1,34 @@
1
+ import { IndexDirection, IndexOptions, Schema } from "mongoose";
2
+ import { Merge } from "type-fest";
3
+ //#region src/schema-builders/mixed.d.ts
4
+ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string> = Omit<MixedSchemaBuilder<Props, ExtraOmitFields>, ExtraOmitFields | keyof Props>;
5
+ interface BaseProps {
6
+ type: typeof Schema.Types.Mixed;
7
+ }
8
+ export interface MixedSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {
9
+ default: <T>(value: T) => ExtendSchemaBuilder<Merge<Props, {
10
+ default: T;
11
+ }>, ExtraOmitFields>;
12
+ immutable: ExtendSchemaBuilder<Merge<Props, {
13
+ immutable: true;
14
+ }>, ExtraOmitFields>;
15
+ index: <T extends boolean | IndexDirection | IndexOptions>(value: T) => ExtendSchemaBuilder<Merge<Props, {
16
+ index: T;
17
+ }>, ExtraOmitFields>;
18
+ nonRequired: Props;
19
+ private: ExtendSchemaBuilder<Merge<Props, {
20
+ private: true;
21
+ }>, ExtraOmitFields>;
22
+ required: Merge<Props, {
23
+ required: true;
24
+ }>;
25
+ sparse: ExtendSchemaBuilder<Merge<Props, {
26
+ sparse: true;
27
+ }>, ExtraOmitFields>;
28
+ unique: ExtendSchemaBuilder<Merge<Props, {
29
+ unique: true;
30
+ }>, ExtraOmitFields>;
31
+ }
32
+ export declare const mixedSchemaBuilder: (schema?: Record<string, any>) => MixedSchemaBuilder<BaseProps, never>;
33
+ //#endregion
34
+ //# sourceMappingURL=mixed.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
1
+ import { createBaseSchemaBuilderFactory } from "./base.js";
2
+ import { Schema } from "mongoose";
3
+ //#region src/schema-builders/mixed.ts
4
+ const mixedSchemaBuilder = createBaseSchemaBuilderFactory(Schema.Types.Mixed);
5
+ //#endregion
6
+ export { mixedSchemaBuilder };
7
+
8
+ //# sourceMappingURL=mixed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mixed.js","names":[],"sources":["../../src/schema-builders/mixed.ts"],"sourcesContent":["import { Schema } from 'mongoose';\nimport type {\n IndexDirection,\n IndexOptions,\n} from 'mongoose';\nimport type { Merge } from 'type-fest';\n\nimport { createBaseSchemaBuilderFactory } from './base';\n\ntype ExtendSchemaBuilder<\n Props extends BaseProps,\n ExtraOmitFields extends string,\n> = Omit<\n MixedSchemaBuilder<Props, ExtraOmitFields>,\n ExtraOmitFields | keyof Props\n>;\n\ninterface BaseProps {\n type: typeof Schema.Types.Mixed;\n}\n\nexport interface MixedSchemaBuilder<Props extends BaseProps = BaseProps, ExtraOmitFields extends string = never> {\n default: <T>(value: T) => ExtendSchemaBuilder<Merge<Props, { default: T }>, ExtraOmitFields>;\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 mixedSchemaBuilder = createBaseSchemaBuilderFactory<MixedSchemaBuilder>(Schema.Types.Mixed);\n"],"mappings":";;;AAoCA,MAAa,qBAAqB,+BAAmD,OAAO,MAAM,KAAK"}
@@ -6,7 +6,7 @@ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string
6
6
  interface BaseProps {
7
7
  type: NumberSchemaDefinition;
8
8
  }
9
- interface NumberSchemaBuilder<Props extends {
9
+ export interface NumberSchemaBuilder<Props extends {
10
10
  type: NumberSchemaDefinition;
11
11
  } = {
12
12
  type: NumberSchemaDefinition;
@@ -48,9 +48,8 @@ interface NumberSchemaBuilder<Props extends {
48
48
  unique: true;
49
49
  }>, ExtraOmitFields>;
50
50
  }
51
- declare const numberSchemaBuilder: (schema?: Record<string, any>) => NumberSchemaBuilder<{
51
+ export declare const numberSchemaBuilder: (schema?: Record<string, any>) => NumberSchemaBuilder<{
52
52
  type: NumberSchemaDefinition;
53
53
  }, never>;
54
54
  //#endregion
55
- export { NumberSchemaBuilder, numberSchemaBuilder };
56
55
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":";;;;KAYK,oBACD,cAAc,WACd,kCACA,KACA,oBAAoB,OAAO,kBAC3B,wBAAwB;UAGlB;EACN,MAAM;;UAGO,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,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,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,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,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;;cAGnD,sBAAmB,SAAA,wBAAA;EAtD6B,MAAA"}
1
+ {"version":3,"file":"number.d.ts","names":[],"sources":["../../src/schema-builders/number.ts"],"mappings":";;;;KAYK,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,UACE,aAAa,MAAM;KAChB,eAAe;;IAChB,UAAU;IAAG,QAAQ,aAAa,MAAM;KAC5C,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,IAAI,cAAc,GAAG,KAC/B,kBACA,kBACF,OAAO,MAAM,oBACX,MAAM;IAAS,KAAK;MACpB;EAGJ,MACI,UAAU,IAAI,cAAc,GAAG,KAC/B,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;EAtD6B,MAAA"}
@@ -6,7 +6,7 @@ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string
6
6
  interface BaseProps {
7
7
  type: typeof Schema.Types.ObjectId;
8
8
  }
9
- interface ObjectIdSchemaBuilder<Props extends {
9
+ export interface ObjectIdSchemaBuilder<Props extends {
10
10
  type: typeof Schema.Types.ObjectId;
11
11
  } = {
12
12
  type: typeof Schema.Types.ObjectId;
@@ -42,9 +42,8 @@ interface ObjectIdSchemaBuilder<Props extends {
42
42
  unique: true;
43
43
  }>, ExtraOmitFields>;
44
44
  }
45
- declare const objectIdSchemaBuilder: (schema?: Record<string, any>) => ObjectIdSchemaBuilder<{
45
+ export declare const objectIdSchemaBuilder: (schema?: Record<string, any>) => ObjectIdSchemaBuilder<{
46
46
  type: typeof Schema.Types.ObjectId;
47
47
  }, never>;
48
48
  //#endregion
49
- export { ObjectIdSchemaBuilder, objectIdSchemaBuilder };
50
49
  //# 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":";;;;KAaK,oBACD,cAAc,WACd,kCACA,KACA,sBAAsB,OAAO,kBAC7B,wBAAwB;UAGlB;EACN,aAAa,OAAO,MAAM;;UAGb,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,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,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;;cAGnD,wBAAqB,SAAA,wBAAA;EApCiC,aAAO,OAAO,MAAM"}
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,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,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;EApCiC,aAAO,OAAO,MAAM"}
@@ -6,7 +6,7 @@ type ExtendSchemaBuilder<Props extends BaseProps, ExtraOmitFields extends string
6
6
  interface BaseProps {
7
7
  type: typeof Schema.Types.ObjectId;
8
8
  }
9
- interface RefSchemaBuilder<Props extends {
9
+ export interface RefSchemaBuilder<Props extends {
10
10
  type: typeof Schema.Types.ObjectId;
11
11
  } = {
12
12
  type: typeof Schema.Types.ObjectId;
@@ -42,10 +42,9 @@ interface RefSchemaBuilder<Props extends {
42
42
  unique: true;
43
43
  }>, ExtraOmitFields>;
44
44
  }
45
- declare function refSchemaBuilder<T extends ((this: any, doc: any) => Model<any> | string) | Model<any> | string>(ref: T): RefSchemaBuilder<{
45
+ export declare function refSchemaBuilder<T extends ((this: any, doc: any) => Model<any> | string) | Model<any> | string>(ref: T): RefSchemaBuilder<{
46
46
  ref: T;
47
47
  type: typeof Schema.Types.ObjectId;
48
48
  }>;
49
49
  //#endregion
50
- export { RefSchemaBuilder, refSchemaBuilder };
51
50
  //# sourceMappingURL=ref.d.ts.map
@@ -1 +1 @@
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;;UAGb,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,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,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;;iBAKhD,iBAAiB,YAAY,WAAW,aAAa,uBAAuB,qBACxF,KAAK,IAEiC;EAAmB,KAAK;EAAG,aAAa,OAAO,MAAM"}
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,UACE,aAAa,aAAa;KACvB,sBAAsB;;IACvB,UAAU;IAAG,QAAQ,aAAa,aAAa;KACnD,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"}