@e22m4u/js-repository 0.1.16 → 0.1.18
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/.husky/pre-commit +1 -0
- package/.mocharc.json +5 -0
- package/README.md +38 -14
- package/build-cjs.js +10 -0
- package/dist/cjs/index.cjs +6716 -0
- package/eslint.config.js +66 -0
- package/package.json +34 -29
- package/src/adapter/adapter.spec.js +1 -1
- package/src/adapter/builtin/memory-adapter.js +1 -0
- package/src/adapter/decorator/data-sanitizing-decorator.spec.js +1 -1
- package/src/adapter/decorator/data-transformation-decorator.spec.js +1 -1
- package/src/adapter/decorator/data-validation-decorator.spec.js +1 -1
- package/src/adapter/decorator/default-values-decorator.spec.js +1 -1
- package/src/adapter/decorator/fields-filtering-decorator.spec.js +1 -1
- package/src/adapter/decorator/inclusion-decorator.spec.js +1 -1
- package/src/adapter/decorator/property-uniqueness-decorator.spec.js +1 -1
- package/src/chai.js +11 -0
- package/src/definition/definition-registry.spec.js +1 -1
- package/src/definition/model/model-definition-utils.spec.js +1 -1
- package/src/definition/model/model-definition-validator.spec.js +1 -1
- package/src/definition/model/properties/properties-definition-validator.spec.js +1 -1
- package/src/utils/get-decorator-target-type.spec.js +3 -0
- package/src/utils/is-deep-equal.js +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -51
- package/.mocharc.cjs +0 -7
- package/mocha.setup.js +0 -15
package/eslint.config.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import eslintJs from '@eslint/js';
|
|
3
|
+
import eslintTypescript from 'typescript-eslint';
|
|
4
|
+
import eslintJsdocPlugin from 'eslint-plugin-jsdoc';
|
|
5
|
+
import eslintMochaPlugin from 'eslint-plugin-mocha';
|
|
6
|
+
import eslintPrettierConfig from 'eslint-config-prettier';
|
|
7
|
+
import eslintChaiExpectPlugin from 'eslint-plugin-chai-expect';
|
|
8
|
+
|
|
9
|
+
export default [
|
|
10
|
+
{
|
|
11
|
+
files: ['src/**/*.js'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
globals: {
|
|
14
|
+
...globals.node,
|
|
15
|
+
...globals.es2021,
|
|
16
|
+
...globals.mocha,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: {
|
|
20
|
+
'jsdoc': eslintJsdocPlugin,
|
|
21
|
+
'mocha': eslintMochaPlugin,
|
|
22
|
+
'chai-expect': eslintChaiExpectPlugin,
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
...eslintJs.configs.recommended.rules,
|
|
26
|
+
...eslintPrettierConfig.rules,
|
|
27
|
+
...eslintMochaPlugin.configs.flat.recommended.rules,
|
|
28
|
+
...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
|
|
29
|
+
...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
|
|
30
|
+
'no-unused-vars': ['error', {'caughtErrors': 'none'}],
|
|
31
|
+
'jsdoc/require-param-description': 0,
|
|
32
|
+
'jsdoc/require-returns-description': 0,
|
|
33
|
+
'jsdoc/require-property-description': 0,
|
|
34
|
+
'jsdoc/tag-lines': ['error', 'any', {startLines: 1}],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
files: ['src/**/*.ts'],
|
|
39
|
+
ignores: ['src/**/*.d.ts'],
|
|
40
|
+
languageOptions: {
|
|
41
|
+
globals: {
|
|
42
|
+
...globals.node,
|
|
43
|
+
...globals.es2021,
|
|
44
|
+
...globals.mocha,
|
|
45
|
+
},
|
|
46
|
+
parser: eslintTypescript.parser,
|
|
47
|
+
parserOptions: {
|
|
48
|
+
projectService: true,
|
|
49
|
+
tsconfigRootDir: import.meta.dirname,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
plugins: {
|
|
53
|
+
'@typescript-eslint': eslintTypescript.plugin,
|
|
54
|
+
'mocha': eslintMochaPlugin,
|
|
55
|
+
'chai-expect': eslintChaiExpectPlugin,
|
|
56
|
+
},
|
|
57
|
+
rules: {
|
|
58
|
+
...eslintJs.configs.recommended.rules,
|
|
59
|
+
...eslintPrettierConfig.rules,
|
|
60
|
+
...eslintTypescript.configs.recommended.rules,
|
|
61
|
+
'@typescript-eslint/no-namespace': 0,
|
|
62
|
+
'@typescript-eslint/no-var-requires': 0,
|
|
63
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 0,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
package/package.json
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/js-repository",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Модуль для работы с базами данных для Node.js",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
6
|
+
"module": "./src/index.js",
|
|
7
|
+
"main": "./dist/cjs/index.cjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"import": "./src/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.cjs"
|
|
12
|
+
},
|
|
7
13
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
14
|
+
"node": ">=12"
|
|
9
15
|
},
|
|
10
16
|
"scripts": {
|
|
11
|
-
"lint": "tsc && eslint
|
|
12
|
-
"lint:fix": "tsc && eslint
|
|
17
|
+
"lint": "tsc && eslint ./src",
|
|
18
|
+
"lint:fix": "tsc && eslint ./src --fix",
|
|
13
19
|
"format": "prettier --write \"./src/**/*.js\"",
|
|
14
20
|
"test": "npm run lint && c8 --reporter=text-summary mocha",
|
|
15
21
|
"test:coverage": "npm run lint && c8 --reporter=text mocha",
|
|
22
|
+
"build:cjs": "node build-cjs.js",
|
|
16
23
|
"prepare": "husky"
|
|
17
24
|
},
|
|
18
25
|
"repository": {
|
|
19
26
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/e22m4u/js-repository.git"
|
|
27
|
+
"url": "git+https://github.com/e22m4u/js-repository.git"
|
|
21
28
|
},
|
|
22
29
|
"keywords": [
|
|
23
30
|
"Repository",
|
|
@@ -30,35 +37,33 @@
|
|
|
30
37
|
"author": "e22m4u <e22m4u@yandex.ru>",
|
|
31
38
|
"license": "MIT",
|
|
32
39
|
"homepage": "https://github.com/e22m4u/js-repository",
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@e22m4u/js-service": "0.0.12"
|
|
35
|
-
},
|
|
36
40
|
"peerDependencies": {
|
|
37
|
-
"@e22m4u/js-
|
|
41
|
+
"@e22m4u/js-format": "0.1.x",
|
|
42
|
+
"@e22m4u/js-service": "0.1.x"
|
|
38
43
|
},
|
|
39
44
|
"devDependencies": {
|
|
40
|
-
"@commitlint/cli": "~19.
|
|
41
|
-
"@commitlint/config-conventional": "~19.
|
|
42
|
-
"@types/chai": "~
|
|
43
|
-
"@types/chai-as-promised": "~
|
|
45
|
+
"@commitlint/cli": "~19.5.0",
|
|
46
|
+
"@commitlint/config-conventional": "~19.5.0",
|
|
47
|
+
"@types/chai": "~5.0.0",
|
|
48
|
+
"@types/chai-as-promised": "~8.0.1",
|
|
44
49
|
"@types/chai-spies": "~1.0.6",
|
|
45
|
-
"@types/mocha": "~10.0.
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"chai": "~4.4.1",
|
|
50
|
-
"chai-as-promised": "~7.1.1",
|
|
50
|
+
"@types/mocha": "~10.0.9",
|
|
51
|
+
"c8": "~10.1.2",
|
|
52
|
+
"chai": "~5.1.1",
|
|
53
|
+
"chai-as-promised": "~8.0.0",
|
|
51
54
|
"chai-spies": "~1.1.0",
|
|
52
55
|
"chai-subset": "~1.6.0",
|
|
53
|
-
"
|
|
56
|
+
"esbuild": "~0.24.0",
|
|
57
|
+
"eslint": "~9.12.0",
|
|
54
58
|
"eslint-config-prettier": "~9.1.0",
|
|
55
|
-
"eslint-plugin-chai-expect": "~3.
|
|
56
|
-
"eslint-plugin-jsdoc": "~
|
|
57
|
-
"eslint-plugin-mocha": "~10.
|
|
58
|
-
"husky": "~9.
|
|
59
|
-
"mocha": "~10.
|
|
60
|
-
"prettier": "~3.
|
|
61
|
-
"
|
|
62
|
-
"typescript": "~5.4
|
|
59
|
+
"eslint-plugin-chai-expect": "~3.1.0",
|
|
60
|
+
"eslint-plugin-jsdoc": "~50.3.1",
|
|
61
|
+
"eslint-plugin-mocha": "~10.5.0",
|
|
62
|
+
"husky": "~9.1.6",
|
|
63
|
+
"mocha": "~10.7.3",
|
|
64
|
+
"prettier": "~3.3.3",
|
|
65
|
+
"tsx": "~4.19.1",
|
|
66
|
+
"typescript": "~5.5.4",
|
|
67
|
+
"typescript-eslint": "~8.8.1"
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -164,6 +164,7 @@ export class MemoryAdapter extends Adapter {
|
|
|
164
164
|
* @param {object|undefined} filter
|
|
165
165
|
* @returns {Promise<object>}
|
|
166
166
|
*/
|
|
167
|
+
// eslint-disable-next-line no-unused-vars
|
|
167
168
|
async replaceOrCreate(modelName, modelData, filter = undefined) {
|
|
168
169
|
const pkPropName =
|
|
169
170
|
this.getService(ModelDefinitionUtils).getPrimaryKeyAsPropertyName(
|
package/src/chai.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as chaiTools from 'chai';
|
|
2
|
+
import chaiSpies from 'chai-spies';
|
|
3
|
+
import chaiSubset from 'chai-subset';
|
|
4
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
5
|
+
const chai = {...chaiTools};
|
|
6
|
+
|
|
7
|
+
chaiSpies(chai, chai.util);
|
|
8
|
+
chaiSubset(chai, chai.util);
|
|
9
|
+
chaiAsPromised(chai, chai.util);
|
|
10
|
+
|
|
11
|
+
export {chai};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
1
|
import {expect} from 'chai';
|
|
2
|
+
import {chai} from '../chai.js';
|
|
3
3
|
import {ModelDefinitionValidator} from './model/index.js';
|
|
4
4
|
import {DefinitionRegistry} from './definition-registry.js';
|
|
5
5
|
import {DatasourceDefinitionValidator} from '../definition/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
1
|
import {expect} from 'chai';
|
|
2
|
+
import {chai} from '../../chai.js';
|
|
3
3
|
import {format} from '@e22m4u/js-format';
|
|
4
4
|
import {RelationsDefinitionValidator} from './relations/index.js';
|
|
5
5
|
import {PropertiesDefinitionValidator} from './properties/index.js';
|
|
@@ -56,6 +56,7 @@ describe('getDecoratorTargetType', function () {
|
|
|
56
56
|
|
|
57
57
|
it('returns CONSTRUCTOR_PARAMETER', function () {
|
|
58
58
|
class Target {
|
|
59
|
+
// eslint-disable-next-line no-unused-vars
|
|
59
60
|
constructor(param) {}
|
|
60
61
|
}
|
|
61
62
|
validate(DTT.CONSTRUCTOR_PARAMETER)(Target, undefined, 0);
|
|
@@ -63,6 +64,7 @@ describe('getDecoratorTargetType', function () {
|
|
|
63
64
|
|
|
64
65
|
it('returns STATIC_METHOD_PARAMETER', function () {
|
|
65
66
|
class Target {
|
|
67
|
+
// eslint-disable-next-line no-unused-vars
|
|
66
68
|
static method(param) {}
|
|
67
69
|
}
|
|
68
70
|
validate(DTT.STATIC_METHOD_PARAMETER)(Target, 'method', 0);
|
|
@@ -70,6 +72,7 @@ describe('getDecoratorTargetType', function () {
|
|
|
70
72
|
|
|
71
73
|
it('returns INSTANCE_METHOD_PARAMETER', function () {
|
|
72
74
|
class Target {
|
|
75
|
+
// eslint-disable-next-line no-unused-vars
|
|
73
76
|
method(param) {}
|
|
74
77
|
}
|
|
75
78
|
validate(DTT.INSTANCE_METHOD_PARAMETER)(Target.prototype, 'method', 0);
|
|
@@ -58,7 +58,7 @@ export function isDeepEqual(firstValue, secondValue) {
|
|
|
58
58
|
// the property value.
|
|
59
59
|
const propertyNamesA = [...keysA, ...symbolsA];
|
|
60
60
|
for (const propertyNameA of propertyNamesA) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!Object.prototype.hasOwnProperty.call(b, propertyNameA)) return false;
|
|
62
62
|
const propertyValueA = a[propertyNameA];
|
|
63
63
|
const propertyValueB = b[propertyNameA];
|
|
64
64
|
if (!compare(propertyValueA, propertyValueB)) return false;
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.d.ts
|
package/.eslintrc.cjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
es2021: true,
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
parserOptions: {
|
|
7
|
-
sourceType: 'module',
|
|
8
|
-
ecmaVersion: 13,
|
|
9
|
-
},
|
|
10
|
-
overrides: [
|
|
11
|
-
{
|
|
12
|
-
files: ['**/*.js'],
|
|
13
|
-
plugins: [
|
|
14
|
-
'mocha',
|
|
15
|
-
'jsdoc',
|
|
16
|
-
'chai-expect',
|
|
17
|
-
],
|
|
18
|
-
extends: [
|
|
19
|
-
'prettier',
|
|
20
|
-
'plugin:jsdoc/recommended',
|
|
21
|
-
'plugin:mocha/recommended',
|
|
22
|
-
'plugin:chai-expect/recommended',
|
|
23
|
-
'plugin:jsdoc/recommended-error',
|
|
24
|
-
],
|
|
25
|
-
rules: {
|
|
26
|
-
'jsdoc/require-param-description': 0,
|
|
27
|
-
'jsdoc/require-returns-description': 0,
|
|
28
|
-
'jsdoc/require-property-description': 0,
|
|
29
|
-
'jsdoc/tag-lines': ['error', 'any', {startLines: 1}],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
files: ['**/*.ts'],
|
|
34
|
-
plugins: [
|
|
35
|
-
'mocha',
|
|
36
|
-
'chai-expect',
|
|
37
|
-
'@typescript-eslint',
|
|
38
|
-
],
|
|
39
|
-
extends: [
|
|
40
|
-
'prettier',
|
|
41
|
-
'eslint:recommended',
|
|
42
|
-
'plugin:@typescript-eslint/recommended',
|
|
43
|
-
],
|
|
44
|
-
rules: {
|
|
45
|
-
'@typescript-eslint/no-namespace': 0,
|
|
46
|
-
'@typescript-eslint/no-var-requires': 0,
|
|
47
|
-
'@typescript-eslint/no-unnecessary-type-constraint': 0,
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
}
|
package/.mocharc.cjs
DELETED
package/mocha.setup.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
process.env['NODE_ENV'] = 'test';
|
|
2
|
-
|
|
3
|
-
// ts loader
|
|
4
|
-
import {register} from 'node:module';
|
|
5
|
-
import {pathToFileURL} from 'node:url';
|
|
6
|
-
register('ts-node/esm', pathToFileURL('./'));
|
|
7
|
-
|
|
8
|
-
// chai
|
|
9
|
-
import chai from 'chai';
|
|
10
|
-
import chaiSpies from 'chai-spies';
|
|
11
|
-
import chaiSubset from 'chai-subset';
|
|
12
|
-
import chaiAsPromised from 'chai-as-promised';
|
|
13
|
-
chai.use(chaiSpies);
|
|
14
|
-
chai.use(chaiSubset);
|
|
15
|
-
chai.use(chaiAsPromised);
|