@kikiutils/mongoose 7.1.0 → 9.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 (113) hide show
  1. package/README.md +8 -8
  2. package/dist/_internals.d.ts +4 -0
  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/builders.d.ts +1 -3
  7. package/dist/builders.d.ts.map +1 -1
  8. package/dist/builders.js +8 -9
  9. package/dist/builders.js.map +1 -1
  10. package/dist/connection.d.ts +5 -0
  11. package/dist/connection.d.ts.map +1 -0
  12. package/dist/connection.js +10 -0
  13. package/dist/connection.js.map +1 -0
  14. package/dist/options.d.ts.map +1 -1
  15. package/dist/options.js +2 -1
  16. package/dist/options.js.map +1 -1
  17. package/dist/plugins/lean-decimal128-to-string.d.ts +26 -0
  18. package/dist/plugins/lean-decimal128-to-string.d.ts.map +1 -0
  19. package/dist/plugins/lean-decimal128-to-string.js +85 -0
  20. package/dist/plugins/lean-decimal128-to-string.js.map +1 -0
  21. package/dist/plugins/normalize.d.ts +24 -14
  22. package/dist/plugins/normalize.d.ts.map +1 -1
  23. package/dist/plugins/normalize.js +20 -10
  24. package/dist/plugins/normalize.js.map +1 -1
  25. package/dist/schema-builders/base.d.ts +1 -1
  26. package/dist/schema-builders/base.d.ts.map +1 -1
  27. package/dist/schema-builders/base.js.map +1 -1
  28. package/dist/schema-builders/bigint.d.ts +60 -0
  29. package/dist/schema-builders/bigint.d.ts.map +1 -0
  30. package/dist/schema-builders/bigint.js +58 -0
  31. package/dist/schema-builders/bigint.js.map +1 -0
  32. package/dist/schema-builders/boolean.d.ts.map +1 -1
  33. package/dist/schema-builders/boolean.js.map +1 -1
  34. package/dist/schema-builders/date.d.ts +2 -2
  35. package/dist/schema-builders/date.d.ts.map +1 -1
  36. package/dist/schema-builders/date.js.map +1 -1
  37. package/dist/schema-builders/decimal128.d.ts +20 -14
  38. package/dist/schema-builders/decimal128.d.ts.map +1 -1
  39. package/dist/schema-builders/decimal128.js +1 -0
  40. package/dist/schema-builders/decimal128.js.map +1 -1
  41. package/dist/schema-builders/double.d.ts +60 -0
  42. package/dist/schema-builders/double.d.ts.map +1 -0
  43. package/dist/schema-builders/double.js +62 -0
  44. package/dist/schema-builders/double.js.map +1 -0
  45. package/dist/schema-builders/index.d.ts +6 -1
  46. package/dist/schema-builders/index.js +6 -1
  47. package/dist/schema-builders/int32.d.ts +60 -0
  48. package/dist/schema-builders/int32.d.ts.map +1 -0
  49. package/dist/schema-builders/int32.js +58 -0
  50. package/dist/schema-builders/int32.js.map +1 -0
  51. package/dist/schema-builders/mixed.d.ts +34 -0
  52. package/dist/schema-builders/mixed.d.ts.map +1 -0
  53. package/dist/schema-builders/mixed.js +8 -0
  54. package/dist/schema-builders/mixed.js.map +1 -0
  55. package/dist/schema-builders/number.d.ts +2 -2
  56. package/dist/schema-builders/number.d.ts.map +1 -1
  57. package/dist/schema-builders/number.js.map +1 -1
  58. package/dist/schema-builders/object-id.d.ts +2 -2
  59. package/dist/schema-builders/object-id.d.ts.map +1 -1
  60. package/dist/schema-builders/object-id.js.map +1 -1
  61. package/dist/schema-builders/ref.d.ts +2 -2
  62. package/dist/schema-builders/ref.d.ts.map +1 -1
  63. package/dist/schema-builders/ref.js.map +1 -1
  64. package/dist/schema-builders/string.d.ts +35 -25
  65. package/dist/schema-builders/string.d.ts.map +1 -1
  66. package/dist/schema-builders/string.js.map +1 -1
  67. package/dist/schema-builders/uuid.d.ts +34 -0
  68. package/dist/schema-builders/uuid.d.ts.map +1 -0
  69. package/dist/schema-builders/uuid.js +8 -0
  70. package/dist/schema-builders/uuid.js.map +1 -0
  71. package/dist/types/aggregate-paginate.d.ts +24 -8
  72. package/dist/types/aggregate-paginate.d.ts.map +1 -1
  73. package/dist/types/index.d.ts +1 -4
  74. package/dist/types/index.d.ts.map +1 -1
  75. package/dist/types/options.d.ts +9 -4
  76. package/dist/types/options.d.ts.map +1 -1
  77. package/dist/types/paginate.d.ts +6 -2
  78. package/dist/types/paginate.d.ts.map +1 -1
  79. package/package.json +17 -12
  80. package/src/_internals.ts +3 -0
  81. package/src/builders.ts +18 -32
  82. package/src/connection.ts +14 -0
  83. package/src/options.ts +8 -1
  84. package/src/plugins/lean-decimal128-to-string.ts +149 -0
  85. package/src/plugins/normalize.ts +39 -15
  86. package/src/schema-builders/base.ts +6 -1
  87. package/src/schema-builders/bigint.ts +190 -0
  88. package/src/schema-builders/boolean.ts +1 -4
  89. package/src/schema-builders/date.ts +2 -2
  90. package/src/schema-builders/decimal128.ts +21 -14
  91. package/src/schema-builders/double.ts +198 -0
  92. package/src/schema-builders/index.ts +15 -0
  93. package/src/schema-builders/int32.ts +191 -0
  94. package/src/schema-builders/mixed.ts +37 -0
  95. package/src/schema-builders/number.ts +2 -2
  96. package/src/schema-builders/object-id.ts +2 -2
  97. package/src/schema-builders/ref.ts +2 -2
  98. package/src/schema-builders/string.ts +35 -25
  99. package/src/schema-builders/uuid.ts +48 -0
  100. package/src/types/aggregate-paginate.ts +29 -8
  101. package/src/types/index.ts +0 -5
  102. package/src/types/options.ts +12 -3
  103. package/src/types/paginate.ts +6 -2
  104. package/dist/constants.d.ts +0 -5
  105. package/dist/constants.d.ts.map +0 -1
  106. package/dist/constants.js +0 -6
  107. package/dist/constants.js.map +0 -1
  108. package/dist/helpers.d.ts +0 -5
  109. package/dist/helpers.d.ts.map +0 -1
  110. package/dist/helpers.js +0 -9
  111. package/dist/helpers.js.map +0 -1
  112. package/src/constants.ts +0 -3
  113. package/src/helpers.ts +0 -5
@@ -49,9 +49,13 @@ export interface AggregatePaginateOptions {
49
49
  page?: number;
50
50
 
51
51
  /**
52
- * If pagination is set to `false`, it will return all docs without adding limit condition.
52
+ * Whether to apply pagination to the aggregation results.
53
53
  *
54
- * @default true
54
+ * @remarks
55
+ * If `false`, the pagination plugin adds no pagination `$skip` or `$limit` stages. Existing pipeline stages
56
+ * still apply.
57
+ *
58
+ * @defaultValue `true`, unless overridden by plugin-wide defaults.
55
59
  */
56
60
  pagination?: boolean;
57
61
  sort?: object | string;
@@ -59,17 +63,34 @@ export interface AggregatePaginateOptions {
59
63
  }
60
64
 
61
65
  export interface AggregatePaginateQueryPopulateOptions {
62
- /** optional query conditions to match */
66
+ /**
67
+ * The query conditions used to filter populated documents.
68
+ */
63
69
  match?: any;
64
- /** optional model to use for population */
70
+
71
+ /**
72
+ * The model or model name used to populate the referenced documents.
73
+ */
65
74
  model?: Model<any> | string;
66
- /** optional query options like sort, limit, etc */
75
+
76
+ /**
77
+ * The query options applied when retrieving populated documents, such as sorting and limits.
78
+ */
67
79
  options?: any;
68
- /** space delimited path(s) to populate */
80
+
81
+ /**
82
+ * The path or space-delimited paths to populate.
83
+ */
69
84
  path: string;
70
- /** deep populate */
85
+
86
+ /**
87
+ * The nested population options applied to the populated documents.
88
+ */
71
89
  populate?: AggregatePaginateQueryPopulateOptions | AggregatePaginateQueryPopulateOptions[];
72
- /** optional fields to select */
90
+
91
+ /**
92
+ * The field projection used when retrieving populated documents.
93
+ */
73
94
  select?: any;
74
95
  }
75
96
 
@@ -1,5 +1,4 @@
1
1
  import type {
2
- Connection,
3
2
  HydratedDocument,
4
3
  QueryWithHelpers,
5
4
  Types,
@@ -55,7 +54,3 @@ export type SetFieldsToObjectId<T, K extends keyof T> = SetFieldType<T, K, Types
55
54
  // @ts-expect-error Ignore this error.
56
55
  // eslint-disable-next-line unused-imports/no-unused-vars
57
56
  export interface BaseMongooseModelStatics<RawDocType, InstanceMethodsAndOverrides = object, QueryHelpers = object> {}
58
-
59
- export interface MongooseConnections {
60
- default?: Connection;
61
- }
@@ -1,18 +1,25 @@
1
1
  import type {
2
2
  Connection,
3
+ ConnectOptions,
3
4
  Schema,
4
5
  SchemaTimestampsConfig,
5
6
  } from 'mongoose';
6
7
 
8
+ import type { MongooseLeanDecimal128ToStringPluginOptions } from '../plugins/lean-decimal128-to-string';
7
9
  import type { MongooseNormalizePluginOptions } from '../plugins/normalize';
8
10
 
9
11
  import type { BaseMongoosePaginateModel } from './';
10
12
 
11
13
  export interface BuildMongooseModelOptions {
12
14
  connection?: Connection;
13
- enableNormalizePlugin?: boolean;
14
- normalizePluginOptions?: MongooseNormalizePluginOptions;
15
- normalizePluginRecursive?: boolean;
15
+ plugins?: {
16
+ /** Register lean conversion for marked Decimal128 fields. Defaults to true. */
17
+ leanDecimal128ToString?: boolean | MongooseLeanDecimal128ToStringPluginOptions;
18
+
19
+ /** Register JSON normalization. Defaults to true; an object enables it with custom options. */
20
+ normalize?: boolean | MongooseNormalizePluginOptions;
21
+ };
22
+
16
23
  timestamps?: boolean | SchemaTimestampsConfig;
17
24
  }
18
25
 
@@ -30,4 +37,6 @@ export interface CustomMongooseOptions {
30
37
  QueryHelpers
31
38
  >,
32
39
  ) => void;
40
+
41
+ defaultConnectionOptions?: ConnectOptions;
33
42
  }
@@ -91,9 +91,13 @@ export interface PaginateOptions {
91
91
  page?: number;
92
92
 
93
93
  /**
94
- * If pagination is set to `false`, it will return all docs without adding limit condition.
94
+ * Whether to apply pagination to the query results.
95
95
  *
96
- * @default true
96
+ * @remarks
97
+ * If `false`, the pagination plugin does not apply its page-based `skip` or `limit`. Explicit query options
98
+ * and other query conditions still apply.
99
+ *
100
+ * @defaultValue `true`, unless overridden by plugin-wide defaults.
97
101
  */
98
102
  pagination?: boolean;
99
103
  populate?: PopulateOptions | PopulateOptions[] | string | string[];
@@ -1,5 +0,0 @@
1
- import { MongooseConnections } from "./types/index.js";
2
- //#region src/constants.d.ts
3
- export declare const mongooseConnections: MongooseConnections;
4
- //#endregion
5
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;qBAEa,qBAAqB"}
package/dist/constants.js DELETED
@@ -1,6 +0,0 @@
1
- //#region src/constants.ts
2
- const mongooseConnections = {};
3
- //#endregion
4
- export { mongooseConnections };
5
-
6
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { MongooseConnections } from './types';\n\nexport const mongooseConnections: MongooseConnections = {};\n"],"mappings":";AAEA,MAAa,sBAA2C,CAAC"}
package/dist/helpers.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Types } from "mongoose";
2
- //#region src/helpers.d.ts
3
- export declare function toObjectIdHexString(id: string | Types.ObjectId): string;
4
- //#endregion
5
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","names":[],"sources":["../src/helpers.ts"],"mappings":";;wBAEgB,oBAAoB,aAAa,MAAM"}
package/dist/helpers.js DELETED
@@ -1,9 +0,0 @@
1
- import { Types } from "mongoose";
2
- //#region src/helpers.ts
3
- function toObjectIdHexString(id) {
4
- return id instanceof Types.ObjectId ? id.toHexString() : id;
5
- }
6
- //#endregion
7
- export { toObjectIdHexString };
8
-
9
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { Types } from 'mongoose';\n\nexport function toObjectIdHexString(id: string | Types.ObjectId) {\n return id instanceof Types.ObjectId ? id.toHexString() : id;\n}\n"],"mappings":";;AAEA,SAAgB,oBAAoB,IAA6B;CAC7D,OAAO,cAAc,MAAM,WAAW,GAAG,YAAY,IAAI;AAC7D"}
package/src/constants.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { MongooseConnections } from './types';
2
-
3
- export const mongooseConnections: MongooseConnections = {};
package/src/helpers.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Types } from 'mongoose';
2
-
3
- export function toObjectIdHexString(id: string | Types.ObjectId) {
4
- return id instanceof Types.ObjectId ? id.toHexString() : id;
5
- }