@e22m4u/js-repository 0.5.2 → 0.5.4

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.
@@ -403,6 +403,8 @@ function modelNameToModelKey(modelName) {
403
403
  "The model name should be a non-empty String without spaces, but %v was given.",
404
404
  modelName
405
405
  );
406
+ if (modelName.toLowerCase() !== "model")
407
+ modelName = modelName.replace(/[-_]?Model$/, "").replace(/[-_](MODEL|model)$/, "");
406
408
  return modelName.toLowerCase().replace(/[-_]/g, "");
407
409
  }
408
410
  var init_model_name_to_model_key = __esm({
package/eslint.config.js CHANGED
@@ -28,6 +28,8 @@ export default [
28
28
  ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
29
29
  ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
30
30
  'no-unused-vars': ['error', {'caughtErrors': 'none'}],
31
+ 'jsdoc/reject-any-type': 0,
32
+ 'jsdoc/reject-function-type': 0,
31
33
  'jsdoc/require-param-description': 0,
32
34
  'jsdoc/require-returns-description': 0,
33
35
  'jsdoc/require-property-description': 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/js-repository",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Реализация репозитория для работы с базами данных в Node.js",
5
5
  "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -39,9 +39,9 @@
39
39
  "prepare": "husky"
40
40
  },
41
41
  "dependencies": {
42
- "@e22m4u/js-empty-values": "~0.0.2",
43
- "@e22m4u/js-format": "~0.1.8",
44
- "@e22m4u/js-service": "~0.3.6"
42
+ "@e22m4u/js-empty-values": "~0.0.3",
43
+ "@e22m4u/js-format": "~0.2.0",
44
+ "@e22m4u/js-service": "~0.3.8"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@commitlint/cli": "~19.8.1",
@@ -54,18 +54,18 @@
54
54
  "chai": "~6.0.1",
55
55
  "chai-as-promised": "~8.0.2",
56
56
  "chai-spies": "~1.1.0",
57
- "esbuild": "~0.25.9",
58
- "eslint": "~9.34.0",
57
+ "esbuild": "~0.25.10",
58
+ "eslint": "~9.36.0",
59
59
  "eslint-config-prettier": "~10.1.8",
60
60
  "eslint-plugin-chai-expect": "~3.1.0",
61
- "eslint-plugin-jsdoc": "~54.1.1",
61
+ "eslint-plugin-jsdoc": "~60.3.0",
62
62
  "eslint-plugin-mocha": "~11.1.0",
63
63
  "husky": "~9.1.7",
64
- "mocha": "~11.7.1",
64
+ "mocha": "~11.7.2",
65
65
  "prettier": "~3.6.2",
66
66
  "rimraf": "~6.0.1",
67
67
  "ts-node": "~10.9.2",
68
68
  "typescript": "~5.9.2",
69
- "typescript-eslint": "~8.41.0"
69
+ "typescript-eslint": "~8.44.1"
70
70
  }
71
71
  }
@@ -13,5 +13,9 @@ export function modelNameToModelKey(modelName) {
13
13
  'without spaces, but %v was given.',
14
14
  modelName,
15
15
  );
16
+ if (modelName.toLowerCase() !== 'model')
17
+ modelName = modelName
18
+ .replace(/[-_]?Model$/, '')
19
+ .replace(/[-_](MODEL|model)$/, '');
16
20
  return modelName.toLowerCase().replace(/[-_]/g, '');
17
21
  }
@@ -12,6 +12,8 @@ describe('modelNameToModelKey', function () {
12
12
  'UserProfileDetails',
13
13
  'user-profile-details',
14
14
  'user_profile_details',
15
+ 'User-Profile-Details',
16
+ 'User_Profile_Details',
15
17
  'USER-PROFILE-DETAILS',
16
18
  'USER_PROFILE_DETAILS',
17
19
  'USERPROFILEDETAILS',
@@ -34,6 +36,29 @@ describe('modelNameToModelKey', function () {
34
36
  expect(modelNameToModelKey(modelName)).to.be.eq(expected);
35
37
  });
36
38
 
39
+ it('should remove the "model" word from a model name', function () {
40
+ const modelNames = [
41
+ 'userProfileDetailsModel',
42
+ 'UserProfileDetailsModel',
43
+ 'user-profile-details-model',
44
+ 'user_profile_details_model',
45
+ 'User-Profile-Details-Model',
46
+ 'User_Profile_Details_Model',
47
+ 'USER-PROFILE-DETAILS-MODEL',
48
+ 'USER_PROFILE_DETAILS_MODEL',
49
+ ];
50
+ modelNames.forEach(v =>
51
+ expect(modelNameToModelKey(v)).to.be.eq('userprofiledetails'),
52
+ );
53
+ });
54
+
55
+ it('should not remove the "model" suffix as a part of last word in a model name', function () {
56
+ const exceptions = ['SUPERMODEL', 'supermodel'];
57
+ exceptions.forEach(v =>
58
+ expect(modelNameToModelKey(v)).to.be.eq('supermodel'),
59
+ );
60
+ });
61
+
37
62
  it('should throw an error for an empty string', function () {
38
63
  const throwable = () => modelNameToModelKey('');
39
64
  expect(throwable).to.throw(