@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.
Files changed (82) hide show
  1. package/README.md +6 -532
  2. package/dist/cjs/index.cjs +125 -1140
  3. package/package.json +4 -4
  4. package/src/adapter/adapter.d.ts +2 -4
  5. package/src/adapter/adapter.js +2 -6
  6. package/src/adapter/adapter.spec.js +3 -15
  7. package/src/adapter/builtin/memory-adapter.js +41 -12
  8. package/src/adapter/builtin/memory-adapter.spec.js +47 -0
  9. package/src/adapter/decorator/index.d.ts +0 -2
  10. package/src/adapter/decorator/index.js +0 -2
  11. package/src/definition/model/index.d.ts +0 -2
  12. package/src/definition/model/index.js +0 -2
  13. package/src/definition/model/properties/index.d.ts +0 -2
  14. package/src/definition/model/properties/index.js +0 -2
  15. package/src/definition/model/properties/properties-definition-validator.js +0 -169
  16. package/src/definition/model/properties/properties-definition-validator.spec.js +0 -162
  17. package/src/definition/model/properties/property-definition.d.ts +1 -5
  18. package/src/utils/index.d.ts +0 -4
  19. package/src/utils/index.js +0 -4
  20. package/src/utils/model-name-to-model-key.js +0 -4
  21. package/src/utils/model-name-to-model-key.spec.js +0 -23
  22. package/tsconfig.json +2 -2
  23. package/src/adapter/decorator/data-transformation-decorator.d.ts +0 -14
  24. package/src/adapter/decorator/data-transformation-decorator.js +0 -54
  25. package/src/adapter/decorator/data-transformation-decorator.spec.js +0 -193
  26. package/src/adapter/decorator/data-validation-decorator.d.ts +0 -14
  27. package/src/adapter/decorator/data-validation-decorator.js +0 -54
  28. package/src/adapter/decorator/data-validation-decorator.spec.js +0 -105
  29. package/src/definition/model/model-data-transformer.d.ts +0 -16
  30. package/src/definition/model/model-data-transformer.js +0 -170
  31. package/src/definition/model/model-data-transformer.spec.js +0 -2312
  32. package/src/definition/model/model-data-validator.d.ts +0 -16
  33. package/src/definition/model/model-data-validator.js +0 -318
  34. package/src/definition/model/model-data-validator.spec.js +0 -4528
  35. package/src/definition/model/properties/property-transformer/builtin/index.d.ts +0 -3
  36. package/src/definition/model/properties/property-transformer/builtin/index.js +0 -3
  37. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.d.ts +0 -6
  38. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js +0 -19
  39. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.spec.js +0 -39
  40. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.d.ts +0 -6
  41. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js +0 -19
  42. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.spec.js +0 -39
  43. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.d.ts +0 -6
  44. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.js +0 -19
  45. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.spec.js +0 -39
  46. package/src/definition/model/properties/property-transformer/index.d.ts +0 -2
  47. package/src/definition/model/properties/property-transformer/index.js +0 -2
  48. package/src/definition/model/properties/property-transformer/property-transformer-registry.d.ts +0 -29
  49. package/src/definition/model/properties/property-transformer/property-transformer-registry.js +0 -76
  50. package/src/definition/model/properties/property-transformer/property-transformer-registry.spec.js +0 -133
  51. package/src/definition/model/properties/property-transformer/property-transformer.d.ts +0 -27
  52. package/src/definition/model/properties/property-transformer/property-transformer.js +0 -1
  53. package/src/definition/model/properties/property-validator/builtin/index.d.ts +0 -3
  54. package/src/definition/model/properties/property-validator/builtin/index.js +0 -3
  55. package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +0 -6
  56. package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +0 -28
  57. package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +0 -100
  58. package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +0 -6
  59. package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +0 -28
  60. package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +0 -100
  61. package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +0 -6
  62. package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +0 -30
  63. package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +0 -102
  64. package/src/definition/model/properties/property-validator/index.d.ts +0 -2
  65. package/src/definition/model/properties/property-validator/index.js +0 -2
  66. package/src/definition/model/properties/property-validator/property-validator-registry.d.ts +0 -29
  67. package/src/definition/model/properties/property-validator/property-validator-registry.js +0 -76
  68. package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +0 -132
  69. package/src/definition/model/properties/property-validator/property-validator.d.ts +0 -25
  70. package/src/definition/model/properties/property-validator/property-validator.js +0 -1
  71. package/src/utils/get-ctor-name.d.ts +0 -6
  72. package/src/utils/get-ctor-name.js +0 -11
  73. package/src/utils/get-ctor-name.spec.js +0 -17
  74. package/src/utils/get-decorator-target-type.d.ts +0 -27
  75. package/src/utils/get-decorator-target-type.js +0 -63
  76. package/src/utils/get-decorator-target-type.spec.js +0 -80
  77. package/src/utils/is-ctor.d.ts +0 -8
  78. package/src/utils/is-ctor.js +0 -11
  79. package/src/utils/is-ctor.spec.js +0 -26
  80. package/src/utils/transform-promise.d.ts +0 -13
  81. package/src/utils/transform-promise.js +0 -15
  82. 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
- });
@@ -1,8 +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 declare function isCtor(value: unknown): boolean;
@@ -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
- });