@e22m4u/js-repository 0.6.5 → 0.7.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/README.md +6 -532
- package/dist/cjs/index.cjs +125 -1140
- package/package.json +4 -4
- package/src/adapter/adapter.d.ts +2 -4
- package/src/adapter/adapter.js +2 -6
- package/src/adapter/adapter.spec.js +3 -15
- package/src/adapter/builtin/memory-adapter.js +41 -12
- package/src/adapter/builtin/memory-adapter.spec.js +47 -0
- package/src/adapter/decorator/index.d.ts +0 -2
- package/src/adapter/decorator/index.js +0 -2
- package/src/definition/model/index.d.ts +0 -2
- package/src/definition/model/index.js +0 -2
- package/src/definition/model/properties/index.d.ts +0 -2
- package/src/definition/model/properties/index.js +0 -2
- 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/properties/property-definition.d.ts +1 -5
- package/src/utils/index.d.ts +0 -4
- package/src/utils/index.js +0 -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/tsconfig.json +2 -2
- 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/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/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-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/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/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/transform-promise.d.ts +0 -13
- package/src/utils/transform-promise.js +0 -15
- package/src/utils/transform-promise.spec.js +0 -19
|
@@ -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/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,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
|
-
});
|