@e22m4u/js-repository 0.6.5 → 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 +128 -695
- package/dist/cjs/index.cjs +141 -1262
- package/eslint.config.js +29 -58
- package/jsconfig.json +7 -0
- package/package.json +12 -20
- package/src/adapter/adapter-loader.js +3 -4
- package/src/adapter/adapter.js +10 -11
- package/src/adapter/adapter.spec.js +13 -24
- package/src/adapter/builtin/memory-adapter.js +49 -19
- package/src/adapter/builtin/memory-adapter.spec.js +52 -2
- package/src/adapter/decorator/default-values-decorator.spec.js +1 -2
- package/src/adapter/decorator/index.js +0 -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 -3
- 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 -3
- package/src/definition/model/properties/properties-definition-validator.js +0 -169
- package/src/definition/model/properties/properties-definition-validator.spec.js +0 -162
- 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/index.js +0 -4
- package/src/utils/is-plain-object.js +4 -4
- package/src/utils/model-name-to-model-key.js +0 -4
- package/src/utils/model-name-to-model-key.spec.js +0 -23
- 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 -155
- 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/data-transformation-decorator.d.ts +0 -14
- package/src/adapter/decorator/data-transformation-decorator.js +0 -54
- package/src/adapter/decorator/data-transformation-decorator.spec.js +0 -193
- package/src/adapter/decorator/data-validation-decorator.d.ts +0 -14
- package/src/adapter/decorator/data-validation-decorator.js +0 -54
- package/src/adapter/decorator/data-validation-decorator.spec.js +0 -105
- 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 -7
- 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 -8
- package/src/definition/model/model-data-sanitizer.d.ts +0 -15
- package/src/definition/model/model-data-transformer.d.ts +0 -16
- package/src/definition/model/model-data-transformer.js +0 -170
- package/src/definition/model/model-data-transformer.spec.js +0 -2312
- package/src/definition/model/model-data-validator.d.ts +0 -16
- package/src/definition/model/model-data-validator.js +0 -318
- package/src/definition/model/model-data-validator.spec.js +0 -4528
- 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 -8
- 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 -27
- package/src/definition/model/properties/property-definition.js +0 -1
- package/src/definition/model/properties/property-transformer/builtin/index.d.ts +0 -3
- package/src/definition/model/properties/property-transformer/builtin/index.js +0 -3
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.d.ts +0 -6
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js +0 -19
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.spec.js +0 -39
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.d.ts +0 -6
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js +0 -19
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.spec.js +0 -39
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.d.ts +0 -6
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.js +0 -19
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.spec.js +0 -39
- package/src/definition/model/properties/property-transformer/index.d.ts +0 -2
- package/src/definition/model/properties/property-transformer/index.js +0 -2
- package/src/definition/model/properties/property-transformer/property-transformer-registry.d.ts +0 -29
- package/src/definition/model/properties/property-transformer/property-transformer-registry.js +0 -76
- package/src/definition/model/properties/property-transformer/property-transformer-registry.spec.js +0 -133
- package/src/definition/model/properties/property-transformer/property-transformer.d.ts +0 -27
- package/src/definition/model/properties/property-transformer/property-transformer.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/properties/property-validator/builtin/index.d.ts +0 -3
- package/src/definition/model/properties/property-validator/builtin/index.js +0 -3
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +0 -6
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +0 -28
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +0 -100
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +0 -6
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +0 -28
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +0 -100
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +0 -6
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +0 -30
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +0 -102
- package/src/definition/model/properties/property-validator/index.d.ts +0 -2
- package/src/definition/model/properties/property-validator/index.js +0 -2
- package/src/definition/model/properties/property-validator/property-validator-registry.d.ts +0 -29
- package/src/definition/model/properties/property-validator/property-validator-registry.js +0 -76
- package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +0 -132
- package/src/definition/model/properties/property-validator/property-validator.d.ts +0 -25
- package/src/definition/model/properties/property-validator/property-validator.js +0 -1
- 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-ctor-name.d.ts +0 -6
- package/src/utils/get-ctor-name.js +0 -11
- package/src/utils/get-ctor-name.spec.js +0 -17
- package/src/utils/get-decorator-target-type.d.ts +0 -27
- package/src/utils/get-decorator-target-type.js +0 -63
- package/src/utils/get-decorator-target-type.spec.js +0 -80
- package/src/utils/get-value-by-path.d.ts +0 -12
- package/src/utils/index.d.ts +0 -16
- package/src/utils/is-ctor.d.ts +0 -8
- package/src/utils/is-ctor.js +0 -11
- package/src/utils/is-ctor.spec.js +0 -26
- 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/src/utils/transform-promise.d.ts +0 -13
- package/src/utils/transform-promise.js +0 -15
- package/src/utils/transform-promise.spec.js +0 -19
- package/tsconfig.json +0 -11
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {getDecoratorTargetType} from './get-decorator-target-type.js';
|
|
3
|
-
import {DecoratorTargetType as DTT} from './get-decorator-target-type.js';
|
|
4
|
-
|
|
5
|
-
describe('getDecoratorTargetType', function () {
|
|
6
|
-
const validate = function (value) {
|
|
7
|
-
return function (target, propertyKey, descriptorOrIndex) {
|
|
8
|
-
const type = getDecoratorTargetType(
|
|
9
|
-
target,
|
|
10
|
-
propertyKey,
|
|
11
|
-
descriptorOrIndex,
|
|
12
|
-
);
|
|
13
|
-
expect(value).to.be.eq(type);
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
it('returns CONSTRUCTOR', function () {
|
|
18
|
-
class Target {}
|
|
19
|
-
validate(DTT.CONSTRUCTOR)(Target);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('returns INSTANCE', function () {
|
|
23
|
-
class Target {}
|
|
24
|
-
validate(DTT.INSTANCE)(Target.prototype);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('returns STATIC_METHOD', function () {
|
|
28
|
-
class Target {
|
|
29
|
-
static method() {}
|
|
30
|
-
}
|
|
31
|
-
const desc = Object.getOwnPropertyDescriptor(Target, 'method');
|
|
32
|
-
validate(DTT.STATIC_METHOD)(Target, 'method', desc);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('returns INSTANCE_METHOD', function () {
|
|
36
|
-
class Target {
|
|
37
|
-
method() {}
|
|
38
|
-
}
|
|
39
|
-
const desc = Object.getOwnPropertyDescriptor(Target.prototype, 'method');
|
|
40
|
-
validate(DTT.INSTANCE_METHOD)(Target.prototype, 'method', desc);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('returns STATIC_PROPERTY', function () {
|
|
44
|
-
class Target {
|
|
45
|
-
static prop;
|
|
46
|
-
}
|
|
47
|
-
validate(DTT.STATIC_PROPERTY)(Target, 'prop');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('returns INSTANCE_PROPERTY', function () {
|
|
51
|
-
class Target {
|
|
52
|
-
prop;
|
|
53
|
-
}
|
|
54
|
-
validate(DTT.INSTANCE_PROPERTY)(Target.prototype, 'prop');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('returns CONSTRUCTOR_PARAMETER', function () {
|
|
58
|
-
class Target {
|
|
59
|
-
// eslint-disable-next-line no-unused-vars
|
|
60
|
-
constructor(param) {}
|
|
61
|
-
}
|
|
62
|
-
validate(DTT.CONSTRUCTOR_PARAMETER)(Target, undefined, 0);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('returns STATIC_METHOD_PARAMETER', function () {
|
|
66
|
-
class Target {
|
|
67
|
-
// eslint-disable-next-line no-unused-vars
|
|
68
|
-
static method(param) {}
|
|
69
|
-
}
|
|
70
|
-
validate(DTT.STATIC_METHOD_PARAMETER)(Target, 'method', 0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('returns INSTANCE_METHOD_PARAMETER', function () {
|
|
74
|
-
class Target {
|
|
75
|
-
// eslint-disable-next-line no-unused-vars
|
|
76
|
-
method(param) {}
|
|
77
|
-
}
|
|
78
|
-
validate(DTT.INSTANCE_METHOD_PARAMETER)(Target.prototype, 'method', 0);
|
|
79
|
-
});
|
|
80
|
-
});
|
package/src/utils/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from './is-ctor.js';
|
|
2
|
-
export * from './is-promise.js';
|
|
3
|
-
export * from './capitalize.js';
|
|
4
|
-
export * from './clone-deep.js';
|
|
5
|
-
export * from './singularize.js';
|
|
6
|
-
export * from './is-deep-equal.js';
|
|
7
|
-
export * from './get-ctor-name.js';
|
|
8
|
-
export * from './like-to-regexp.js';
|
|
9
|
-
export * from './is-plain-object.js';
|
|
10
|
-
export * from './string-to-regexp.js';
|
|
11
|
-
export * from './get-value-by-path.js';
|
|
12
|
-
export * from './transform-promise.js';
|
|
13
|
-
export * from './select-object-keys.js';
|
|
14
|
-
export * from './exclude-object-keys.js';
|
|
15
|
-
export * from './model-name-to-model-key.js';
|
|
16
|
-
export * from './get-decorator-target-type.js';
|
package/src/utils/is-ctor.d.ts
DELETED
package/src/utils/is-ctor.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true if the given value
|
|
3
|
-
* is a constructor function or a class.
|
|
4
|
-
*
|
|
5
|
-
* @param {*} value
|
|
6
|
-
* @returns {boolean}
|
|
7
|
-
*/
|
|
8
|
-
export function isCtor(value) {
|
|
9
|
-
if (!value) return false;
|
|
10
|
-
return typeof value === 'function' && 'prototype' in value;
|
|
11
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {isCtor} from './is-ctor.js';
|
|
3
|
-
|
|
4
|
-
describe('isCtor', function () {
|
|
5
|
-
it('returns true if a given value is a constructor', function () {
|
|
6
|
-
expect(isCtor(Date)).to.be.true;
|
|
7
|
-
expect(isCtor(Number)).to.be.true;
|
|
8
|
-
expect(isCtor(String)).to.be.true;
|
|
9
|
-
class MyClass {}
|
|
10
|
-
expect(isCtor(MyClass)).to.be.true;
|
|
11
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
12
|
-
function FunctionCtor() {}
|
|
13
|
-
expect(isCtor(FunctionCtor)).to.be.true;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('returns false if a given value is not a constructor', function () {
|
|
17
|
-
expect(isCtor(() => undefined)).to.be.false;
|
|
18
|
-
expect(isCtor('string')).to.be.false;
|
|
19
|
-
expect(isCtor(10)).to.be.false;
|
|
20
|
-
expect(isCtor(true)).to.be.false;
|
|
21
|
-
expect(isCtor({})).to.be.false;
|
|
22
|
-
expect(isCtor([])).to.be.false;
|
|
23
|
-
expect(isCtor(undefined)).to.be.false;
|
|
24
|
-
expect(isCtor(null)).to.be.false;
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check whether a value is a Promise-like
|
|
3
|
-
* instance. Recognizes both native promises
|
|
4
|
-
* and third-party promise libraries.
|
|
5
|
-
*
|
|
6
|
-
* @param value
|
|
7
|
-
*/
|
|
8
|
-
export declare function isPromise<T>(
|
|
9
|
-
value: T | PromiseLike<T> | undefined
|
|
10
|
-
): value is PromiseLike<T>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Преобразует SQL LIKE-шаблон в объект RegExp.
|
|
3
|
-
*
|
|
4
|
-
* Экранирует специальные символы регулярных выражений,
|
|
5
|
-
* чтобы они обрабатывались как обычные символы, и преобразует
|
|
6
|
-
* SQL wildcards (% и _) в их эквиваленты в регулярных выражениях.
|
|
7
|
-
*
|
|
8
|
-
* @param pattern
|
|
9
|
-
* @param isCaseInsensitive
|
|
10
|
-
*/
|
|
11
|
-
export function likeToRegexp(
|
|
12
|
-
pattern: string,
|
|
13
|
-
isCaseInsensitive?: boolean,
|
|
14
|
-
): RegExp;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {ValueOrPromise} from '../types.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a value or promise with a function that
|
|
5
|
-
* produces a new value or promise.
|
|
6
|
-
*
|
|
7
|
-
* @param valueOrPromise
|
|
8
|
-
* @param transformer
|
|
9
|
-
*/
|
|
10
|
-
export declare function transformPromise<T, V>(
|
|
11
|
-
valueOrPromise: ValueOrPromise<T>,
|
|
12
|
-
transformer: (val: T) => ValueOrPromise<V>,
|
|
13
|
-
): ValueOrPromise<V>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {isPromise} from './is-promise.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transform a value or promise with a function that
|
|
5
|
-
* produces a new value or promise.
|
|
6
|
-
*
|
|
7
|
-
* @param {*} valueOrPromise
|
|
8
|
-
* @param {Function} transformer
|
|
9
|
-
* @returns {*}
|
|
10
|
-
*/
|
|
11
|
-
export function transformPromise(valueOrPromise, transformer) {
|
|
12
|
-
return isPromise(valueOrPromise)
|
|
13
|
-
? valueOrPromise.then(transformer)
|
|
14
|
-
: transformer(valueOrPromise);
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {transformPromise} from './transform-promise.js';
|
|
3
|
-
|
|
4
|
-
describe('transformPromise', function () {
|
|
5
|
-
it('transforms the given value', function () {
|
|
6
|
-
const value = 'my-value';
|
|
7
|
-
const transformer = v => v.toUpperCase();
|
|
8
|
-
const result = transformPromise(value, transformer);
|
|
9
|
-
expect(result).to.be.eq('MY-VALUE');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('transforms the given promise', async function () {
|
|
13
|
-
const promise = Promise.resolve('my-value');
|
|
14
|
-
const transformer = v => v.toUpperCase();
|
|
15
|
-
const result = await transformPromise(promise, transformer);
|
|
16
|
-
await promise;
|
|
17
|
-
expect(result).to.be.eq('MY-VALUE');
|
|
18
|
-
});
|
|
19
|
-
});
|