@kikiutils/mongoose 1.4.0 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiutils/mongoose",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A Mongoose plugin for enhanced JSON normalization and common schema creation, with built-in support for pagination and automatic Decimal128 conversion.",
5
5
  "license": "MIT",
6
6
  "author": "kiki-kanri",
@@ -10,23 +10,23 @@
10
10
  },
11
11
  "scripts": {
12
12
  "build": "ts-project-builder ./src/constants.ts ./src/utils.ts --clean --preserve-modules",
13
- "bumplog": "changelogen --bump"
13
+ "bumplog": "changelogen --bump",
14
+ "release": "pnpm run build && changelogen --release && sh ./build-and-publish.sh"
14
15
  },
15
16
  "dependencies": {
16
17
  "decimal.js": "^10.4.3",
17
18
  "lodash": "^4.17.21",
18
- "mongoose": "^8.7.0",
19
+ "mongoose": "^8.7.2",
19
20
  "mongoose-aggregate-paginate-v2": "^1.1.2",
20
21
  "mongoose-paginate-v2": "^1.8.5"
21
22
  },
22
23
  "devDependencies": {
24
+ "@kikiutils/changelogen": "^0.6.0",
23
25
  "@kikiutils/prettierrc": "^1.3.2",
24
26
  "@kikiutils/tsconfigs": "^3.0.1",
25
- "@types/lodash": "^4.17.9",
26
- "@types/node": "^22.7.4",
27
- "changelogen": "^0.5.7",
28
- "ts-project-builder": "^3.0.1",
29
- "tslib": "^2.7.0"
27
+ "@types/lodash": "^4.17.10",
28
+ "@types/node": "^22.7.6",
29
+ "ts-project-builder": "^3.2.4"
30
30
  },
31
31
  "keywords": [
32
32
  "Decimal128",
@@ -32,7 +32,7 @@ declare module 'mongoose' {
32
32
  /** optional query conditions to match */
33
33
  match?: any;
34
34
  /** optional model to use for population */
35
- model?: string | Model<any> | undefined;
35
+ model?: string | Model<any>;
36
36
  /** optional query options like sort, limit, etc */
37
37
  options?: any;
38
38
  /** deep populate */
package/types/data.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Interface for the base data of a Mongoose model, optionally including timestamp fields.
3
3
  *
4
- * This interface extends `_WithTimestampFieldsData` to optionally include `createdAt`
4
+ * This interface extends `LocalWithTimestampFieldsData` to optionally include `createdAt`
5
5
  * and `updatedAt` fields based on the `CreatedAtField` and `UpdatedAtField` flags.
6
6
  * It also includes a mandatory `id` field.
7
7
  *
8
8
  * @template CreatedAtField - A boolean flag indicating whether the `createdAt` field should be included.
9
9
  * @template UpdatedAtField - A boolean flag indicating whether the `updatedAt` field should be included.
10
10
  */
11
- interface _BaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> extends _WithTimestampFieldsData<CreatedAtField, UpdatedAtField> {
11
+ interface LocalBaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> extends LocalWithTimestampFieldsData<CreatedAtField, UpdatedAtField> {
12
12
  id: string;
13
13
  }
14
14
  /**
@@ -21,7 +21,7 @@ interface _BaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedA
21
21
  * @template CreatedAt - A boolean flag indicating whether the `createdAt` field should be included.
22
22
  * @template UpdatedAt - A boolean flag indicating whether the `updatedAt` field should be included.
23
23
  */
24
- interface _WithTimestampFieldsData<CreatedAt extends boolean = true, UpdatedAt extends boolean = true> {
24
+ interface LocalWithTimestampFieldsData<CreatedAt extends boolean = true, UpdatedAt extends boolean = true> {
25
25
  createdAt: CreatedAt extends true ? string : never;
26
26
  updatedAt: UpdatedAt extends true ? string : never;
27
27
  }
@@ -40,13 +40,13 @@ declare global {
40
40
  /**
41
41
  * Type definition for the base data of a Mongoose model, optionally including timestamp fields.
42
42
  *
43
- * This type alias uses `OmitNever` to remove any `never` properties from `_BaseMongooseModelData`
43
+ * This type alias uses `OmitNever` to remove any `never` properties from `LocalBaseMongooseModelData`
44
44
  * based on the presence of the `CreatedAtField` and `UpdatedAtField` flags.
45
45
  *
46
46
  * @template CreatedAtField - A boolean flag indicating whether the `createdAt` field should be included.
47
47
  * @template UpdatedAtField - A boolean flag indicating whether the `updatedAt` field should be included.
48
48
  */
49
- type BaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> = OmitNever<_BaseMongooseModelData<CreatedAtField, UpdatedAtField>>;
49
+ type BaseMongooseModelData<CreatedAtField extends boolean = true, UpdatedAtField extends boolean = true> = OmitNever<LocalBaseMongooseModelData<CreatedAtField, UpdatedAtField>>;
50
50
  /**
51
51
  * Type definition to omit timestamp fields and other specified fields from a given type.
52
52
  *
@@ -60,12 +60,12 @@ declare global {
60
60
  /**
61
61
  * Type definition for including timestamp fields conditionally based on the provided flags.
62
62
  *
63
- * This type alias uses `OmitNever` to remove any `never` properties from `_WithTimestampFieldsData`
63
+ * This type alias uses `OmitNever` to remove any `never` properties from `LocalWithTimestampFieldsData`
64
64
  * based on the presence of the `CreatedAt` and `UpdatedAt` flags.
65
65
  *
66
66
  * @template CreatedAt - A boolean flag indicating whether the `createdAt` field should be included.
67
67
  * @template UpdatedAt - A boolean flag indicating whether the `updatedAt` field should be included.
68
68
  */
69
- type WithMongooseTimestampFieldsData<CreatedAt extends boolean = true, UpdatedAt extends boolean = true> = OmitNever<_WithTimestampFieldsData<CreatedAt, UpdatedAt>>;
69
+ type WithMongooseTimestampFieldsData<CreatedAt extends boolean = true, UpdatedAt extends boolean = true> = OmitNever<LocalWithTimestampFieldsData<CreatedAt, UpdatedAt>>;
70
70
  }
71
71
  export {};
@@ -39,13 +39,13 @@ declare module 'mongoose' {
39
39
  }
40
40
  interface SubPaginateOptions {
41
41
  select?: object | string;
42
- populate?: PopulateOptions[] | string[] | PopulateOptions | string | PopulateOptions;
42
+ populate?: PopulateOptions[] | string[] | PopulateOptions | string;
43
43
  pagination?: boolean;
44
44
  read?: PaginateReadOptions;
45
45
  pagingOptions: SubDocumentPagingOptions | undefined;
46
46
  }
47
47
  interface SubDocumentPagingOptions {
48
- populate?: PopulateOptions[] | string[] | PopulateOptions | string | PopulateOptions;
48
+ populate?: PopulateOptions[] | string[] | PopulateOptions | string;
49
49
  page?: number;
50
50
  limit?: number;
51
51
  }
package/utils.cjs CHANGED
@@ -297,8 +297,9 @@ function createMongooseStringSchema(...attributes) {
297
297
  const schema = { type: String };
298
298
  new Set(attributes).forEach((attribute) => {
299
299
  if (attribute === 'short')
300
- return (schema.maxlength = 16);
301
- schema[attribute] = true;
300
+ schema.maxlength = 16;
301
+ else
302
+ schema[attribute] = true;
302
303
  });
303
304
  return schema;
304
305
  }
package/utils.mjs CHANGED
@@ -286,8 +286,9 @@ function createMongooseStringSchema(...attributes) {
286
286
  const schema = { type: String };
287
287
  new Set(attributes).forEach((attribute) => {
288
288
  if (attribute === 'short')
289
- return (schema.maxlength = 16);
290
- schema[attribute] = true;
289
+ schema.maxlength = 16;
290
+ else
291
+ schema[attribute] = true;
291
292
  });
292
293
  return schema;
293
294
  }