@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.
Files changed (171) hide show
  1. package/.mocharc.json +2 -3
  2. package/README.md +128 -695
  3. package/dist/cjs/index.cjs +141 -1262
  4. package/eslint.config.js +29 -58
  5. package/jsconfig.json +7 -0
  6. package/package.json +12 -20
  7. package/src/adapter/adapter-loader.js +3 -4
  8. package/src/adapter/adapter.js +10 -11
  9. package/src/adapter/adapter.spec.js +13 -24
  10. package/src/adapter/builtin/memory-adapter.js +49 -19
  11. package/src/adapter/builtin/memory-adapter.spec.js +52 -2
  12. package/src/adapter/decorator/default-values-decorator.spec.js +1 -2
  13. package/src/adapter/decorator/index.js +0 -2
  14. package/src/database-schema.js +1 -2
  15. package/src/{database-schema.spec.ts → database-schema.spec.js} +5 -17
  16. package/src/definition/model/index.js +0 -3
  17. package/src/definition/model/model-definition-utils.js +1 -2
  18. package/src/definition/model/model-definition-utils.spec.js +5 -2
  19. package/src/definition/model/properties/index.js +0 -3
  20. package/src/definition/model/properties/properties-definition-validator.js +0 -169
  21. package/src/definition/model/properties/properties-definition-validator.spec.js +0 -162
  22. package/src/definition/model/relations/index.js +0 -1
  23. package/src/definition/model/relations/relations-definition-validator.js +4 -5
  24. package/src/filter/include-clause-tool.js +8 -6
  25. package/src/index.js +0 -1
  26. package/src/relations/belongs-to-resolver.js +1 -2
  27. package/src/relations/belongs-to-resolver.spec.js +6 -3
  28. package/src/relations/has-many-resolver.js +1 -2
  29. package/src/relations/has-many-resolver.spec.js +6 -3
  30. package/src/relations/has-one-resolver.js +1 -2
  31. package/src/relations/has-one-resolver.spec.js +6 -3
  32. package/src/relations/references-many-resolver.js +1 -2
  33. package/src/relations/references-many-resolver.spec.js +6 -3
  34. package/src/repository/repository.js +1 -2
  35. package/src/utils/index.js +0 -4
  36. package/src/utils/is-plain-object.js +4 -4
  37. package/src/utils/model-name-to-model-key.js +0 -4
  38. package/src/utils/model-name-to-model-key.spec.js +0 -23
  39. package/src/adapter/adapter-loader.d.ts +0 -16
  40. package/src/adapter/adapter-registry.d.ts +0 -14
  41. package/src/adapter/adapter.d.ts +0 -155
  42. package/src/adapter/builtin/memory-adapter.d.ts +0 -148
  43. package/src/adapter/decorator/data-sanitizing-decorator.d.ts +0 -14
  44. package/src/adapter/decorator/data-transformation-decorator.d.ts +0 -14
  45. package/src/adapter/decorator/data-transformation-decorator.js +0 -54
  46. package/src/adapter/decorator/data-transformation-decorator.spec.js +0 -193
  47. package/src/adapter/decorator/data-validation-decorator.d.ts +0 -14
  48. package/src/adapter/decorator/data-validation-decorator.js +0 -54
  49. package/src/adapter/decorator/data-validation-decorator.spec.js +0 -105
  50. package/src/adapter/decorator/default-values-decorator.d.ts +0 -14
  51. package/src/adapter/decorator/fields-filtering-decorator.d.ts +0 -14
  52. package/src/adapter/decorator/inclusion-decorator.d.ts +0 -14
  53. package/src/adapter/decorator/index.d.ts +0 -7
  54. package/src/adapter/decorator/property-uniqueness-decorator.d.ts +0 -14
  55. package/src/adapter/index.d.ts +0 -3
  56. package/src/database-schema.d.ts +0 -37
  57. package/src/definition/datasource/datasource-definition-validator.d.ts +0 -14
  58. package/src/definition/datasource/datasource-definition.d.ts +0 -8
  59. package/src/definition/datasource/index.d.ts +0 -2
  60. package/src/definition/definition-registry.d.ts +0 -50
  61. package/src/definition/index.d.ts +0 -3
  62. package/src/definition/model/index.d.ts +0 -8
  63. package/src/definition/model/model-data-sanitizer.d.ts +0 -15
  64. package/src/definition/model/model-data-transformer.d.ts +0 -16
  65. package/src/definition/model/model-data-transformer.js +0 -170
  66. package/src/definition/model/model-data-transformer.spec.js +0 -2312
  67. package/src/definition/model/model-data-validator.d.ts +0 -16
  68. package/src/definition/model/model-data-validator.js +0 -318
  69. package/src/definition/model/model-data-validator.spec.js +0 -4528
  70. package/src/definition/model/model-definition-utils.d.ts +0 -180
  71. package/src/definition/model/model-definition-validator.d.ts +0 -14
  72. package/src/definition/model/model-definition.d.ts +0 -28
  73. package/src/definition/model/model-definition.js +0 -1
  74. package/src/definition/model/properties/data-type.d.ts +0 -16
  75. package/src/definition/model/properties/index.d.ts +0 -8
  76. package/src/definition/model/properties/primary-keys-definition-validator.d.ts +0 -15
  77. package/src/definition/model/properties/properties-definition-validator.d.ts +0 -15
  78. package/src/definition/model/properties/property-definition.d.ts +0 -27
  79. package/src/definition/model/properties/property-definition.js +0 -1
  80. package/src/definition/model/properties/property-transformer/builtin/index.d.ts +0 -3
  81. package/src/definition/model/properties/property-transformer/builtin/index.js +0 -3
  82. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.d.ts +0 -6
  83. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js +0 -19
  84. package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.spec.js +0 -39
  85. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.d.ts +0 -6
  86. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js +0 -19
  87. package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.spec.js +0 -39
  88. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.d.ts +0 -6
  89. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.js +0 -19
  90. package/src/definition/model/properties/property-transformer/builtin/trim-transformer.spec.js +0 -39
  91. package/src/definition/model/properties/property-transformer/index.d.ts +0 -2
  92. package/src/definition/model/properties/property-transformer/index.js +0 -2
  93. package/src/definition/model/properties/property-transformer/property-transformer-registry.d.ts +0 -29
  94. package/src/definition/model/properties/property-transformer/property-transformer-registry.js +0 -76
  95. package/src/definition/model/properties/property-transformer/property-transformer-registry.spec.js +0 -133
  96. package/src/definition/model/properties/property-transformer/property-transformer.d.ts +0 -27
  97. package/src/definition/model/properties/property-transformer/property-transformer.js +0 -1
  98. package/src/definition/model/properties/property-uniqueness-validator.d.ts +0 -31
  99. package/src/definition/model/properties/property-uniqueness.d.ts +0 -14
  100. package/src/definition/model/properties/property-validator/builtin/index.d.ts +0 -3
  101. package/src/definition/model/properties/property-validator/builtin/index.js +0 -3
  102. package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +0 -6
  103. package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +0 -28
  104. package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +0 -100
  105. package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +0 -6
  106. package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +0 -28
  107. package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +0 -100
  108. package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +0 -6
  109. package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +0 -30
  110. package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +0 -102
  111. package/src/definition/model/properties/property-validator/index.d.ts +0 -2
  112. package/src/definition/model/properties/property-validator/index.js +0 -2
  113. package/src/definition/model/properties/property-validator/property-validator-registry.d.ts +0 -29
  114. package/src/definition/model/properties/property-validator/property-validator-registry.js +0 -76
  115. package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +0 -132
  116. package/src/definition/model/properties/property-validator/property-validator.d.ts +0 -25
  117. package/src/definition/model/properties/property-validator/property-validator.js +0 -1
  118. package/src/definition/model/relations/index.d.ts +0 -3
  119. package/src/definition/model/relations/relation-definition.d.ts +0 -236
  120. package/src/definition/model/relations/relation-definition.js +0 -1
  121. package/src/definition/model/relations/relation-type.d.ts +0 -14
  122. package/src/definition/model/relations/relations-definition-validator.d.ts +0 -15
  123. package/src/errors/index.d.ts +0 -3
  124. package/src/errors/invalid-argument-error.d.ts +0 -6
  125. package/src/errors/invalid-operator-value-error.d.ts +0 -13
  126. package/src/errors/not-implemented-error.d.ts +0 -6
  127. package/src/filter/fields-clause-tool.d.ts +0 -38
  128. package/src/filter/filter-clause.d.ts +0 -348
  129. package/src/filter/include-clause-tool.d.ts +0 -55
  130. package/src/filter/index.d.ts +0 -7
  131. package/src/filter/operator-clause-tool.d.ts +0 -224
  132. package/src/filter/order-clause-tool.d.ts +0 -32
  133. package/src/filter/slice-clause-tool.d.ts +0 -30
  134. package/src/filter/where-clause-tool.d.ts +0 -23
  135. package/src/index.d.ts +0 -9
  136. package/src/relations/belongs-to-resolver.d.ts +0 -46
  137. package/src/relations/has-many-resolver.d.ts +0 -67
  138. package/src/relations/has-one-resolver.d.ts +0 -67
  139. package/src/relations/index.d.ts +0 -4
  140. package/src/relations/references-many-resolver.d.ts +0 -27
  141. package/src/repository/index.d.ts +0 -2
  142. package/src/repository/repository-registry.d.ts +0 -29
  143. package/src/repository/repository.d.ts +0 -183
  144. package/src/types.d.ts +0 -43
  145. package/src/types.js +0 -1
  146. package/src/utils/capitalize.d.ts +0 -6
  147. package/src/utils/clone-deep.d.ts +0 -6
  148. package/src/utils/exclude-object-keys.d.ts +0 -10
  149. package/src/utils/get-ctor-name.d.ts +0 -6
  150. package/src/utils/get-ctor-name.js +0 -11
  151. package/src/utils/get-ctor-name.spec.js +0 -17
  152. package/src/utils/get-decorator-target-type.d.ts +0 -27
  153. package/src/utils/get-decorator-target-type.js +0 -63
  154. package/src/utils/get-decorator-target-type.spec.js +0 -80
  155. package/src/utils/get-value-by-path.d.ts +0 -12
  156. package/src/utils/index.d.ts +0 -16
  157. package/src/utils/is-ctor.d.ts +0 -8
  158. package/src/utils/is-ctor.js +0 -11
  159. package/src/utils/is-ctor.spec.js +0 -26
  160. package/src/utils/is-deep-equal.d.ts +0 -10
  161. package/src/utils/is-plain-object.d.ts +0 -6
  162. package/src/utils/is-promise.d.ts +0 -10
  163. package/src/utils/like-to-regexp.d.ts +0 -14
  164. package/src/utils/model-name-to-model-key.d.ts +0 -6
  165. package/src/utils/select-object-keys.d.ts +0 -10
  166. package/src/utils/singularize.d.ts +0 -6
  167. package/src/utils/string-to-regexp.d.ts +0 -10
  168. package/src/utils/transform-promise.d.ts +0 -13
  169. package/src/utils/transform-promise.js +0 -15
  170. package/src/utils/transform-promise.spec.js +0 -19
  171. 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
- });
@@ -1,12 +0,0 @@
1
- /**
2
- * Get value by path.
3
- *
4
- * @param obj
5
- * @param path
6
- * @param orElse
7
- */
8
- export declare function getValueByPath(
9
- obj: object,
10
- path: string,
11
- orElse?: unknown,
12
- ): unknown;
@@ -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';
@@ -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,10 +0,0 @@
1
- /**
2
- * Is deep equal.
3
- *
4
- * @param firstValue
5
- * @param secondValue
6
- */
7
- export declare function isDeepEqual(
8
- firstValue: unknown,
9
- secondValue: unknown,
10
- ): boolean;
@@ -1,6 +0,0 @@
1
- /**
2
- * Is plain object.
3
- *
4
- * @param value
5
- */
6
- export declare function isPlainObject(value: unknown): boolean;
@@ -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,6 +0,0 @@
1
- /**
2
- * Model name to model key.
3
- *
4
- * @param modelName
5
- */
6
- export function modelNameToModelKey(modelName: string): string;
@@ -1,10 +0,0 @@
1
- /**
2
- * Select object keys.
3
- *
4
- * @param obj
5
- * @param keys
6
- */
7
- export declare function selectObjectKeys<T extends object>(
8
- obj: T,
9
- keys: string[],
10
- ): Partial<T>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Singularize.
3
- *
4
- * @param noun
5
- */
6
- export declare function singularize(noun: string): string;
@@ -1,10 +0,0 @@
1
- /**
2
- * String to regexp.
3
- *
4
- * @param pattern
5
- * @param flags
6
- */
7
- export declare function stringToRegexp(
8
- pattern: string | RegExp,
9
- flags?: string,
10
- ): 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
- });
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "rootDir": "src",
5
- "noEmit": true,
6
- "target": "es2022",
7
- "module": "NodeNext",
8
- "moduleResolution": "NodeNext",
9
- "strictNullChecks": true
10
- }
11
- }