@e22m4u/js-repository 0.7.0 → 0.8.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.
- package/.mocharc.json +2 -3
- package/README.md +123 -164
- package/dist/cjs/index.cjs +8 -114
- package/eslint.config.js +29 -58
- package/jsconfig.json +7 -0
- package/package.json +11 -19
- package/src/adapter/adapter-loader.js +3 -4
- package/src/adapter/adapter.js +8 -5
- package/src/adapter/adapter.spec.js +10 -9
- package/src/adapter/builtin/memory-adapter.js +8 -7
- package/src/adapter/builtin/memory-adapter.spec.js +5 -2
- package/src/adapter/decorator/default-values-decorator.spec.js +1 -2
- package/src/database-schema.js +1 -2
- package/src/{database-schema.spec.ts → database-schema.spec.js} +5 -17
- package/src/definition/model/index.js +0 -1
- package/src/definition/model/model-definition-utils.js +1 -2
- package/src/definition/model/model-definition-utils.spec.js +5 -2
- package/src/definition/model/properties/index.js +0 -1
- package/src/definition/model/relations/index.js +0 -1
- package/src/definition/model/relations/relations-definition-validator.js +4 -5
- package/src/filter/include-clause-tool.js +8 -6
- package/src/index.js +0 -1
- package/src/relations/belongs-to-resolver.js +1 -2
- package/src/relations/belongs-to-resolver.spec.js +6 -3
- package/src/relations/has-many-resolver.js +1 -2
- package/src/relations/has-many-resolver.spec.js +6 -3
- package/src/relations/has-one-resolver.js +1 -2
- package/src/relations/has-one-resolver.spec.js +6 -3
- package/src/relations/references-many-resolver.js +1 -2
- package/src/relations/references-many-resolver.spec.js +6 -3
- package/src/repository/repository.js +1 -2
- package/src/utils/is-plain-object.js +4 -4
- package/src/adapter/adapter-loader.d.ts +0 -16
- package/src/adapter/adapter-registry.d.ts +0 -14
- package/src/adapter/adapter.d.ts +0 -153
- package/src/adapter/builtin/memory-adapter.d.ts +0 -148
- package/src/adapter/decorator/data-sanitizing-decorator.d.ts +0 -14
- package/src/adapter/decorator/default-values-decorator.d.ts +0 -14
- package/src/adapter/decorator/fields-filtering-decorator.d.ts +0 -14
- package/src/adapter/decorator/inclusion-decorator.d.ts +0 -14
- package/src/adapter/decorator/index.d.ts +0 -5
- package/src/adapter/decorator/property-uniqueness-decorator.d.ts +0 -14
- package/src/adapter/index.d.ts +0 -3
- package/src/database-schema.d.ts +0 -37
- package/src/definition/datasource/datasource-definition-validator.d.ts +0 -14
- package/src/definition/datasource/datasource-definition.d.ts +0 -8
- package/src/definition/datasource/index.d.ts +0 -2
- package/src/definition/definition-registry.d.ts +0 -50
- package/src/definition/index.d.ts +0 -3
- package/src/definition/model/index.d.ts +0 -6
- package/src/definition/model/model-data-sanitizer.d.ts +0 -15
- package/src/definition/model/model-definition-utils.d.ts +0 -180
- package/src/definition/model/model-definition-validator.d.ts +0 -14
- package/src/definition/model/model-definition.d.ts +0 -28
- package/src/definition/model/model-definition.js +0 -1
- package/src/definition/model/properties/data-type.d.ts +0 -16
- package/src/definition/model/properties/index.d.ts +0 -6
- package/src/definition/model/properties/primary-keys-definition-validator.d.ts +0 -15
- package/src/definition/model/properties/properties-definition-validator.d.ts +0 -15
- package/src/definition/model/properties/property-definition.d.ts +0 -23
- package/src/definition/model/properties/property-definition.js +0 -1
- package/src/definition/model/properties/property-uniqueness-validator.d.ts +0 -31
- package/src/definition/model/properties/property-uniqueness.d.ts +0 -14
- package/src/definition/model/relations/index.d.ts +0 -3
- package/src/definition/model/relations/relation-definition.d.ts +0 -236
- package/src/definition/model/relations/relation-definition.js +0 -1
- package/src/definition/model/relations/relation-type.d.ts +0 -14
- package/src/definition/model/relations/relations-definition-validator.d.ts +0 -15
- package/src/errors/index.d.ts +0 -3
- package/src/errors/invalid-argument-error.d.ts +0 -6
- package/src/errors/invalid-operator-value-error.d.ts +0 -13
- package/src/errors/not-implemented-error.d.ts +0 -6
- package/src/filter/fields-clause-tool.d.ts +0 -38
- package/src/filter/filter-clause.d.ts +0 -348
- package/src/filter/include-clause-tool.d.ts +0 -55
- package/src/filter/index.d.ts +0 -7
- package/src/filter/operator-clause-tool.d.ts +0 -224
- package/src/filter/order-clause-tool.d.ts +0 -32
- package/src/filter/slice-clause-tool.d.ts +0 -30
- package/src/filter/where-clause-tool.d.ts +0 -23
- package/src/index.d.ts +0 -9
- package/src/relations/belongs-to-resolver.d.ts +0 -46
- package/src/relations/has-many-resolver.d.ts +0 -67
- package/src/relations/has-one-resolver.d.ts +0 -67
- package/src/relations/index.d.ts +0 -4
- package/src/relations/references-many-resolver.d.ts +0 -27
- package/src/repository/index.d.ts +0 -2
- package/src/repository/repository-registry.d.ts +0 -29
- package/src/repository/repository.d.ts +0 -183
- package/src/types.d.ts +0 -43
- package/src/types.js +0 -1
- package/src/utils/capitalize.d.ts +0 -6
- package/src/utils/clone-deep.d.ts +0 -6
- package/src/utils/exclude-object-keys.d.ts +0 -10
- package/src/utils/get-value-by-path.d.ts +0 -12
- package/src/utils/index.d.ts +0 -12
- package/src/utils/is-deep-equal.d.ts +0 -10
- package/src/utils/is-plain-object.d.ts +0 -6
- package/src/utils/is-promise.d.ts +0 -10
- package/src/utils/like-to-regexp.d.ts +0 -14
- package/src/utils/model-name-to-model-key.d.ts +0 -6
- package/src/utils/select-object-keys.d.ts +0 -10
- package/src/utils/singularize.d.ts +0 -6
- package/src/utils/string-to-regexp.d.ts +0 -10
- package/tsconfig.json +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/js-repository",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Реализация репозитория для работы с базами данных",
|
|
5
5
|
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,17 +12,15 @@
|
|
|
12
12
|
"Datasource",
|
|
13
13
|
"Relations"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://
|
|
15
|
+
"homepage": "https://gitrepos.ru/e22m4u/js-repository",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://
|
|
18
|
+
"url": "git+https://gitrepos.ru/e22m4u/js-repository.git"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
21
|
-
"types": "./src/index.d.ts",
|
|
22
21
|
"module": "./src/index.js",
|
|
23
22
|
"main": "./dist/cjs/index.cjs",
|
|
24
23
|
"exports": {
|
|
25
|
-
"types": "./src/index.d.ts",
|
|
26
24
|
"import": "./src/index.js",
|
|
27
25
|
"require": "./dist/cjs/index.cjs"
|
|
28
26
|
},
|
|
@@ -30,26 +28,22 @@
|
|
|
30
28
|
"node": ">=12"
|
|
31
29
|
},
|
|
32
30
|
"scripts": {
|
|
33
|
-
"lint": "
|
|
34
|
-
"lint:fix": "
|
|
31
|
+
"lint": "eslint ./src",
|
|
32
|
+
"lint:fix": "eslint ./src --fix",
|
|
35
33
|
"format": "prettier --write \"./src/**/*.js\"",
|
|
36
34
|
"test": "npm run lint && c8 --reporter=text-summary mocha --bail",
|
|
37
35
|
"test:coverage": "npm run lint && c8 --reporter=text mocha --bail",
|
|
38
|
-
"build:cjs": "rimraf ./dist/cjs && node
|
|
36
|
+
"build:cjs": "rimraf ./dist/cjs && node build-cjs.js",
|
|
39
37
|
"prepare": "husky"
|
|
40
38
|
},
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@e22m4u/js-empty-values": "~0.
|
|
43
|
-
"@e22m4u/js-format": "~0.
|
|
40
|
+
"@e22m4u/js-empty-values": "~0.2.0",
|
|
41
|
+
"@e22m4u/js-format": "~0.3.0",
|
|
44
42
|
"@e22m4u/js-service": "~0.4.6"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"@commitlint/cli": "~20.1.0",
|
|
48
46
|
"@commitlint/config-conventional": "~20.0.0",
|
|
49
|
-
"@types/chai": "~5.2.3",
|
|
50
|
-
"@types/chai-as-promised": "~8.0.2",
|
|
51
|
-
"@types/chai-spies": "~1.0.6",
|
|
52
|
-
"@types/mocha": "~10.0.10",
|
|
53
47
|
"c8": "~10.1.3",
|
|
54
48
|
"chai": "~6.2.1",
|
|
55
49
|
"chai-as-promised": "~8.0.2",
|
|
@@ -58,14 +52,12 @@
|
|
|
58
52
|
"eslint": "~9.39.1",
|
|
59
53
|
"eslint-config-prettier": "~10.1.8",
|
|
60
54
|
"eslint-plugin-chai-expect": "~3.1.0",
|
|
55
|
+
"eslint-plugin-import": "~2.32.0",
|
|
61
56
|
"eslint-plugin-jsdoc": "~61.4.1",
|
|
62
57
|
"eslint-plugin-mocha": "~11.2.0",
|
|
63
58
|
"husky": "~9.1.7",
|
|
64
59
|
"mocha": "~11.7.5",
|
|
65
|
-
"prettier": "~3.
|
|
66
|
-
"rimraf": "~6.1.2"
|
|
67
|
-
"ts-node": "~10.9.2",
|
|
68
|
-
"typescript": "~5.9.3",
|
|
69
|
-
"typescript-eslint": "~8.48.0"
|
|
60
|
+
"prettier": "~3.7.3",
|
|
61
|
+
"rimraf": "~6.1.2"
|
|
70
62
|
}
|
|
71
63
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {Adapter} from './adapter.js';
|
|
2
1
|
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {ADAPTER_CLASS_NAME} from './adapter.js';
|
|
4
2
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
3
|
+
import {Adapter, ADAPTER_CLASS_NAME} from './adapter.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Adapter loader.
|
|
@@ -24,7 +23,7 @@ export class AdapterLoader extends Service {
|
|
|
24
23
|
try {
|
|
25
24
|
const module = await import(`./builtin/${adapterName}-adapter.js`);
|
|
26
25
|
adapterCtor = findAdapterCtorInModule(module);
|
|
27
|
-
} catch
|
|
26
|
+
} catch {
|
|
28
27
|
/**/
|
|
29
28
|
}
|
|
30
29
|
if (!adapterCtor)
|
|
@@ -33,7 +32,7 @@ export class AdapterLoader extends Service {
|
|
|
33
32
|
`@e22m4u/js-repository-${adapterName}-adapter`
|
|
34
33
|
);
|
|
35
34
|
adapterCtor = findAdapterCtorInModule(module);
|
|
36
|
-
} catch
|
|
35
|
+
} catch {
|
|
37
36
|
/**/
|
|
38
37
|
}
|
|
39
38
|
if (!adapterCtor)
|
package/src/adapter/adapter.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
/* eslint jsdoc/require-returns-check: 0 */
|
|
3
3
|
import {Service} from '@e22m4u/js-service';
|
|
4
4
|
import {NotImplementedError} from '../errors/index.js';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
InclusionDecorator,
|
|
8
|
+
DefaultValuesDecorator,
|
|
9
|
+
DataSanitizingDecorator,
|
|
10
|
+
FieldsFilteringDecorator,
|
|
11
|
+
PropertyUniquenessDecorator,
|
|
12
|
+
} from './decorator/index.js';
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Adapter class name.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {chai} from '../chai.js';
|
|
3
|
-
import {Adapter} from './adapter.js';
|
|
4
|
-
import {Service} from '@e22m4u/js-service';
|
|
5
|
-
import {ADAPTER_CLASS_NAME} from './adapter.js';
|
|
6
|
-
import {ServiceContainer} from '@e22m4u/js-service';
|
|
7
3
|
import {DatabaseSchema} from '../database-schema.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
4
|
+
import {Adapter, ADAPTER_CLASS_NAME} from './adapter.js';
|
|
5
|
+
import {Service, ServiceContainer} from '@e22m4u/js-service';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
InclusionDecorator,
|
|
9
|
+
DefaultValuesDecorator,
|
|
10
|
+
DataSanitizingDecorator,
|
|
11
|
+
FieldsFilteringDecorator,
|
|
12
|
+
PropertyUniquenessDecorator,
|
|
13
|
+
} from './decorator/index.js';
|
|
13
14
|
|
|
14
15
|
const sandbox = chai.spy.sandbox();
|
|
15
16
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {Adapter} from '../adapter.js';
|
|
2
|
-
import {cloneDeep} from '../../utils/index.js';
|
|
3
|
-
import {capitalize} from '../../utils/index.js';
|
|
4
|
-
import {DataType} from '../../definition/index.js';
|
|
5
|
-
import {SliceClauseTool} from '../../filter/index.js';
|
|
6
|
-
import {WhereClauseTool} from '../../filter/index.js';
|
|
7
|
-
import {OrderClauseTool} from '../../filter/index.js';
|
|
2
|
+
import {cloneDeep, capitalize} from '../../utils/index.js';
|
|
8
3
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
9
|
-
import {ModelDefinitionUtils} from '../../definition/index.js';
|
|
4
|
+
import {DataType, ModelDefinitionUtils} from '../../definition/index.js';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SliceClauseTool,
|
|
8
|
+
WhereClauseTool,
|
|
9
|
+
OrderClauseTool,
|
|
10
|
+
} from '../../filter/index.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Memory adapter.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {format} from '@e22m4u/js-format';
|
|
3
3
|
import {MemoryAdapter} from './memory-adapter.js';
|
|
4
|
-
import {DataType} from '../../definition/index.js';
|
|
5
4
|
import {DatabaseSchema} from '../../database-schema.js';
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataType,
|
|
8
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
9
|
+
} from '../../definition/index.js';
|
|
7
10
|
|
|
8
11
|
describe('MemoryAdapter', function () {
|
|
9
12
|
describe('_getTableOrCreate', function () {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {chai} from '../../chai.js';
|
|
3
3
|
import {Adapter} from '../adapter.js';
|
|
4
|
-
import {DataType} from '../../definition/index.js';
|
|
5
4
|
import {DatabaseSchema} from '../../database-schema.js';
|
|
6
|
-
import {ModelDefinitionUtils} from '../../definition/index.js';
|
|
5
|
+
import {DataType, ModelDefinitionUtils} from '../../definition/index.js';
|
|
7
6
|
|
|
8
7
|
const dbs = new DatabaseSchema();
|
|
9
8
|
dbs.defineModel({
|
package/src/database-schema.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {Repository} from './repository/index.js';
|
|
3
2
|
import {DefinitionRegistry} from './definition/index.js';
|
|
4
|
-
import {RepositoryRegistry} from './repository/index.js';
|
|
3
|
+
import {Repository, RepositoryRegistry} from './repository/index.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Database schema.
|
|
@@ -17,16 +17,17 @@ describe('DatabaseSchema', function () {
|
|
|
17
17
|
it('sets the datasource definition', function () {
|
|
18
18
|
const dbs = new DatabaseSchema();
|
|
19
19
|
dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
|
|
20
|
-
const res =
|
|
21
|
-
|
|
20
|
+
const res = dbs
|
|
21
|
+
.getService(DefinitionRegistry)
|
|
22
|
+
.getDatasource('datasource');
|
|
22
23
|
expect(res).to.be.eql({name: 'datasource', adapter: 'memory'});
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
it('throws an error if the datasource name already defined', function () {
|
|
26
27
|
const dbs = new DatabaseSchema();
|
|
27
28
|
dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
|
|
28
|
-
const throwable =
|
|
29
|
-
|
|
29
|
+
const throwable = () =>
|
|
30
|
+
dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
|
|
30
31
|
expect(throwable).to.throw(
|
|
31
32
|
'The datasource "datasource" is already defined.',
|
|
32
33
|
);
|
|
@@ -69,18 +70,5 @@ describe('DatabaseSchema', function () {
|
|
|
69
70
|
const throwable = () => dbs.getRepository('model');
|
|
70
71
|
expect(throwable).to.throw('The model "model" is not defined.');
|
|
71
72
|
});
|
|
72
|
-
|
|
73
|
-
it('uses generic types to define the repository type', function () {
|
|
74
|
-
const dbs = new DatabaseSchema();
|
|
75
|
-
dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
|
|
76
|
-
dbs.defineModel({name: 'model', datasource: 'datasource'});
|
|
77
|
-
interface MyModel {
|
|
78
|
-
myId: number;
|
|
79
|
-
}
|
|
80
|
-
const res1: Repository = dbs.getRepository('model');
|
|
81
|
-
const res2: Repository<MyModel, number, 'myId'> =
|
|
82
|
-
dbs.getRepository<MyModel, number, 'myId'>('model');
|
|
83
|
-
expect(res1).to.be.eq(res2);
|
|
84
|
-
});
|
|
85
73
|
});
|
|
86
74
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
2
|
import {DataType} from './properties/index.js';
|
|
3
|
-
import {cloneDeep} from '../../utils/index.js';
|
|
4
|
-
import {excludeObjectKeys} from '../../utils/index.js';
|
|
5
3
|
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
6
4
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
7
5
|
import {DefinitionRegistry} from '../definition-registry.js';
|
|
6
|
+
import {cloneDeep, excludeObjectKeys} from '../../utils/index.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Default primary key property name.
|
|
@@ -6,8 +6,11 @@ import {RelationType} from './relations/index.js';
|
|
|
6
6
|
import {DatabaseSchema} from '../../database-schema.js';
|
|
7
7
|
import {EmptyValuesService} from '@e22m4u/js-empty-values';
|
|
8
8
|
import {InvalidArgumentError} from '../../errors/index.js';
|
|
9
|
-
|
|
10
|
-
import {
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ModelDefinitionUtils,
|
|
12
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
13
|
+
} from './model-definition-utils.js';
|
|
11
14
|
|
|
12
15
|
const sandbox = chai.spy.sandbox();
|
|
13
16
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
2
|
import {RelationType} from './relation-type.js';
|
|
3
|
-
import {RelationType as Type} from './relation-type.js';
|
|
4
3
|
import {InvalidArgumentError} from '../../../errors/index.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -62,13 +61,13 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
62
61
|
modelName,
|
|
63
62
|
relDef,
|
|
64
63
|
);
|
|
65
|
-
if (!relDef.type || !Object.values(
|
|
64
|
+
if (!relDef.type || !Object.values(RelationType).includes(relDef.type))
|
|
66
65
|
throw new InvalidArgumentError(
|
|
67
66
|
'The relation %v of the model %v requires the option "type" ' +
|
|
68
67
|
'to have one of relation types: %l, but %v was given.',
|
|
69
68
|
relName,
|
|
70
69
|
modelName,
|
|
71
|
-
Object.values(
|
|
70
|
+
Object.values(RelationType),
|
|
72
71
|
relDef.type,
|
|
73
72
|
);
|
|
74
73
|
this._validateBelongsTo(modelName, relName, relDef);
|
|
@@ -105,7 +104,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
105
104
|
* @private
|
|
106
105
|
*/
|
|
107
106
|
_validateBelongsTo(modelName, relName, relDef) {
|
|
108
|
-
if (relDef.type !==
|
|
107
|
+
if (relDef.type !== RelationType.BELONGS_TO) return;
|
|
109
108
|
if (relDef.polymorphic) {
|
|
110
109
|
// A polymorphic "belongsTo" relation.
|
|
111
110
|
if (typeof relDef.polymorphic !== 'boolean')
|
|
@@ -419,7 +418,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
419
418
|
* @private
|
|
420
419
|
*/
|
|
421
420
|
_validateReferencesMany(modelName, relName, relDef) {
|
|
422
|
-
if (relDef.type !==
|
|
421
|
+
if (relDef.type !== RelationType.REFERENCES_MANY) return;
|
|
423
422
|
if (!relDef.model || typeof relDef.model !== 'string')
|
|
424
423
|
throw new InvalidArgumentError(
|
|
425
424
|
'The relation %v of the model %v has the type "referencesMany", ' +
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {RelationType} from '../definition/index.js';
|
|
3
|
-
import {HasOneResolver} from '../relations/index.js';
|
|
4
|
-
import {HasManyResolver} from '../relations/index.js';
|
|
5
2
|
import {WhereClauseTool} from './where-clause-tool.js';
|
|
6
3
|
import {OrderClauseTool} from './order-clause-tool.js';
|
|
7
4
|
import {SliceClauseTool} from './slice-clause-tool.js';
|
|
8
5
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
9
|
-
import {BelongsToResolver} from '../relations/index.js';
|
|
10
6
|
import {FieldsClauseTool} from './fields-clause-tool.js';
|
|
11
|
-
import {ModelDefinitionUtils} from '../definition/index.js';
|
|
12
|
-
|
|
7
|
+
import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
HasOneResolver,
|
|
11
|
+
HasManyResolver,
|
|
12
|
+
BelongsToResolver,
|
|
13
|
+
ReferencesManyResolver,
|
|
14
|
+
} from '../relations/index.js';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Include clause tool.
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {cloneDeep} from '../utils/index.js';
|
|
3
|
-
import {singularize} from '../utils/index.js';
|
|
4
2
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
3
|
+
import {cloneDeep, singularize} from '../utils/index.js';
|
|
5
4
|
import {RepositoryRegistry} from '../repository/index.js';
|
|
6
5
|
import {ModelDefinitionUtils} from '../definition/index.js';
|
|
7
6
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {format} from '@e22m4u/js-format';
|
|
3
|
-
import {DataType} from '../definition/index.js';
|
|
4
|
-
import {RelationType} from '../definition/index.js';
|
|
5
3
|
import {DatabaseSchema} from '../database-schema.js';
|
|
6
4
|
import {BelongsToResolver} from './belongs-to-resolver.js';
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataType,
|
|
8
|
+
RelationType,
|
|
9
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
10
|
+
} from '../definition/index.js';
|
|
8
11
|
|
|
9
12
|
describe('BelongsToResolver', function () {
|
|
10
13
|
describe('includeTo', function () {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
2
|
import {cloneDeep} from '../utils/index.js';
|
|
3
|
-
import {RelationType} from '../definition/index.js';
|
|
4
3
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
5
4
|
import {RepositoryRegistry} from '../repository/index.js';
|
|
6
|
-
import {ModelDefinitionUtils} from '../definition/index.js';
|
|
5
|
+
import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Has many resolver.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {format} from '@e22m4u/js-format';
|
|
3
|
-
import {DataType} from '../definition/index.js';
|
|
4
|
-
import {RelationType} from '../definition/index.js';
|
|
5
3
|
import {DatabaseSchema} from '../database-schema.js';
|
|
6
4
|
import {HasManyResolver} from './has-many-resolver.js';
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataType,
|
|
8
|
+
RelationType,
|
|
9
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
10
|
+
} from '../definition/index.js';
|
|
8
11
|
|
|
9
12
|
describe('HasManyResolver', function () {
|
|
10
13
|
describe('includeTo', function () {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
2
|
import {cloneDeep} from '../utils/index.js';
|
|
3
|
-
import {RelationType} from '../definition/index.js';
|
|
4
3
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
5
4
|
import {RepositoryRegistry} from '../repository/index.js';
|
|
6
|
-
import {ModelDefinitionUtils} from '../definition/index.js';
|
|
5
|
+
import {RelationType, ModelDefinitionUtils} from '../definition/index.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Has one resolver.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {format} from '@e22m4u/js-format';
|
|
3
|
-
import {DataType} from '../definition/index.js';
|
|
4
|
-
import {RelationType} from '../definition/index.js';
|
|
5
3
|
import {HasOneResolver} from './has-one-resolver.js';
|
|
6
4
|
import {DatabaseSchema} from '../database-schema.js';
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataType,
|
|
8
|
+
RelationType,
|
|
9
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
10
|
+
} from '../definition/index.js';
|
|
8
11
|
|
|
9
12
|
describe('HasOneResolver', function () {
|
|
10
13
|
describe('includeTo', function () {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {cloneDeep} from '../utils/index.js';
|
|
3
|
-
import {singularize} from '../utils/index.js';
|
|
4
2
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
3
|
+
import {cloneDeep, singularize} from '../utils/index.js';
|
|
5
4
|
import {RepositoryRegistry} from '../repository/index.js';
|
|
6
5
|
import {ModelDefinitionUtils} from '../definition/index.js';
|
|
7
6
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {format} from '@e22m4u/js-format';
|
|
3
|
-
import {DataType} from '../definition/index.js';
|
|
4
|
-
import {RelationType} from '../definition/index.js';
|
|
5
3
|
import {DatabaseSchema} from '../database-schema.js';
|
|
6
4
|
import {ReferencesManyResolver} from './references-many-resolver.js';
|
|
7
|
-
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DataType,
|
|
8
|
+
RelationType,
|
|
9
|
+
DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK,
|
|
10
|
+
} from '../definition/index.js';
|
|
8
11
|
|
|
9
12
|
describe('ReferencesManyResolver', function () {
|
|
10
13
|
describe('includeTo', function () {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {Adapter} from '../adapter/index.js';
|
|
3
|
-
import {AdapterRegistry} from '../adapter/index.js';
|
|
4
2
|
import {InvalidArgumentError} from '../errors/index.js';
|
|
5
3
|
import {DefinitionRegistry} from '../definition/index.js';
|
|
4
|
+
import {Adapter, AdapterRegistry} from '../adapter/index.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Repository.
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
export function isPlainObject(value) {
|
|
8
8
|
return Boolean(
|
|
9
9
|
typeof value === 'object' &&
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
value &&
|
|
11
|
+
!Array.isArray(value) &&
|
|
12
|
+
(!value.constructor ||
|
|
13
|
+
(value.constructor && value.constructor.name === 'Object')),
|
|
14
14
|
);
|
|
15
15
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {Adapter} from './adapter.js';
|
|
2
|
-
import {AnyObject} from '../types.js';
|
|
3
|
-
import {Service} from '@e22m4u/js-service';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Adapter loader.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AdapterLoader extends Service {
|
|
9
|
-
/**
|
|
10
|
-
* Load by name.
|
|
11
|
-
*
|
|
12
|
-
* @param adapterName
|
|
13
|
-
* @param settings
|
|
14
|
-
*/
|
|
15
|
-
loadByName(adapterName: string, settings?: AnyObject): Promise<Adapter>;
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {Adapter} from './adapter.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Adapter registry.
|
|
6
|
-
*/
|
|
7
|
-
export declare class AdapterRegistry extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Get adapter.
|
|
10
|
-
*
|
|
11
|
-
* @param datasourceName
|
|
12
|
-
*/
|
|
13
|
-
getAdapter(datasourceName: string): Promise<Adapter>;
|
|
14
|
-
}
|