@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,46 +0,0 @@
|
|
|
1
|
-
import {ModelData} from '../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {FilterClause} from '../filter/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Belongs to resolver.
|
|
7
|
-
*/
|
|
8
|
-
export declare class BelongsToResolver extends Service {
|
|
9
|
-
/**
|
|
10
|
-
* Include to.
|
|
11
|
-
*
|
|
12
|
-
* @param entities
|
|
13
|
-
* @param sourceName
|
|
14
|
-
* @param targetName
|
|
15
|
-
* @param relationName
|
|
16
|
-
* @param foreignKey
|
|
17
|
-
* @param scope
|
|
18
|
-
*/
|
|
19
|
-
includeTo(
|
|
20
|
-
entities: ModelData[],
|
|
21
|
-
sourceName: string,
|
|
22
|
-
targetName: string,
|
|
23
|
-
relationName: string,
|
|
24
|
-
foreignKey?: string,
|
|
25
|
-
scope?: FilterClause,
|
|
26
|
-
): Promise<void>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Include polymorphic to.
|
|
30
|
-
*
|
|
31
|
-
* @param entities
|
|
32
|
-
* @param sourceName
|
|
33
|
-
* @param relationName
|
|
34
|
-
* @param foreignKey
|
|
35
|
-
* @param discriminator
|
|
36
|
-
* @param scope
|
|
37
|
-
*/
|
|
38
|
-
includePolymorphicTo(
|
|
39
|
-
entities: ModelData[],
|
|
40
|
-
sourceName: string,
|
|
41
|
-
relationName: string,
|
|
42
|
-
foreignKey?: string,
|
|
43
|
-
discriminator?: string,
|
|
44
|
-
scope?: FilterClause,
|
|
45
|
-
): Promise<void>;
|
|
46
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {ModelData} from '../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {FilterClause} from '../filter/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Has many resolver.
|
|
7
|
-
*/
|
|
8
|
-
export declare class HasManyResolver extends Service {
|
|
9
|
-
/**
|
|
10
|
-
* Include to.
|
|
11
|
-
*
|
|
12
|
-
* @param entities
|
|
13
|
-
* @param sourceName
|
|
14
|
-
* @param targetName
|
|
15
|
-
* @param relationName
|
|
16
|
-
* @param foreignKey
|
|
17
|
-
* @param scope
|
|
18
|
-
*/
|
|
19
|
-
includeTo(
|
|
20
|
-
entities: ModelData[],
|
|
21
|
-
sourceName: string,
|
|
22
|
-
targetName: string,
|
|
23
|
-
relationName: string,
|
|
24
|
-
foreignKey: string,
|
|
25
|
-
scope?: FilterClause,
|
|
26
|
-
): Promise<void>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Include polymorphic to.
|
|
30
|
-
*
|
|
31
|
-
* @param entities
|
|
32
|
-
* @param sourceName
|
|
33
|
-
* @param targetName
|
|
34
|
-
* @param relationName
|
|
35
|
-
* @param foreignKey
|
|
36
|
-
* @param discriminator
|
|
37
|
-
* @param scope
|
|
38
|
-
*/
|
|
39
|
-
includePolymorphicTo(
|
|
40
|
-
entities: ModelData[],
|
|
41
|
-
sourceName: string,
|
|
42
|
-
targetName: string,
|
|
43
|
-
relationName: string,
|
|
44
|
-
foreignKey: string,
|
|
45
|
-
discriminator: string,
|
|
46
|
-
scope?: FilterClause,
|
|
47
|
-
): Promise<void>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Include polymorphic by relation name.
|
|
51
|
-
*
|
|
52
|
-
* @param entities
|
|
53
|
-
* @param sourceName
|
|
54
|
-
* @param targetName
|
|
55
|
-
* @param relationName
|
|
56
|
-
* @param targetRelationName
|
|
57
|
-
* @param scope
|
|
58
|
-
*/
|
|
59
|
-
includePolymorphicByRelationName(
|
|
60
|
-
entities: ModelData[],
|
|
61
|
-
sourceName: string,
|
|
62
|
-
targetName: string,
|
|
63
|
-
relationName: string,
|
|
64
|
-
targetRelationName: string,
|
|
65
|
-
scope?: FilterClause,
|
|
66
|
-
): Promise<void>;
|
|
67
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {ModelData} from '../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {FilterClause} from '../filter/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Has one resolver.
|
|
7
|
-
*/
|
|
8
|
-
export declare class HasOneResolver extends Service {
|
|
9
|
-
/**
|
|
10
|
-
* Include to.
|
|
11
|
-
*
|
|
12
|
-
* @param entities
|
|
13
|
-
* @param sourceName
|
|
14
|
-
* @param targetName
|
|
15
|
-
* @param relationName
|
|
16
|
-
* @param foreignKey
|
|
17
|
-
* @param scope
|
|
18
|
-
*/
|
|
19
|
-
includeTo(
|
|
20
|
-
entities: ModelData[],
|
|
21
|
-
sourceName: string,
|
|
22
|
-
targetName: string,
|
|
23
|
-
relationName: string,
|
|
24
|
-
foreignKey: string,
|
|
25
|
-
scope?: FilterClause,
|
|
26
|
-
): Promise<void>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Include polymorphic to.
|
|
30
|
-
*
|
|
31
|
-
* @param entities
|
|
32
|
-
* @param sourceName
|
|
33
|
-
* @param targetName
|
|
34
|
-
* @param relationName
|
|
35
|
-
* @param foreignKey
|
|
36
|
-
* @param discriminator
|
|
37
|
-
* @param scope
|
|
38
|
-
*/
|
|
39
|
-
includePolymorphicTo(
|
|
40
|
-
entities: ModelData[],
|
|
41
|
-
sourceName: string,
|
|
42
|
-
targetName: string,
|
|
43
|
-
relationName: string,
|
|
44
|
-
foreignKey: string,
|
|
45
|
-
discriminator: string,
|
|
46
|
-
scope?: FilterClause,
|
|
47
|
-
): Promise<void>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Include polymorphic by relation name.
|
|
51
|
-
*
|
|
52
|
-
* @param entities
|
|
53
|
-
* @param sourceName
|
|
54
|
-
* @param targetName
|
|
55
|
-
* @param relationName
|
|
56
|
-
* @param targetRelationName
|
|
57
|
-
* @param scope
|
|
58
|
-
*/
|
|
59
|
-
includePolymorphicByRelationName(
|
|
60
|
-
entities: ModelData[],
|
|
61
|
-
sourceName: string,
|
|
62
|
-
targetName: string,
|
|
63
|
-
relationName: string,
|
|
64
|
-
targetRelationName: string,
|
|
65
|
-
scope?: FilterClause,
|
|
66
|
-
): Promise<void>;
|
|
67
|
-
}
|
package/src/relations/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {ModelData} from '../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {FilterClause} from '../filter/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* References many resolver.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ReferencesManyResolver extends Service {
|
|
9
|
-
/**
|
|
10
|
-
* Include to.
|
|
11
|
-
*
|
|
12
|
-
* @param entities
|
|
13
|
-
* @param sourceName
|
|
14
|
-
* @param targetName
|
|
15
|
-
* @param relationName
|
|
16
|
-
* @param foreignKey
|
|
17
|
-
* @param scope
|
|
18
|
-
*/
|
|
19
|
-
includeTo(
|
|
20
|
-
entities: ModelData[],
|
|
21
|
-
sourceName: string,
|
|
22
|
-
targetName: string,
|
|
23
|
-
relationName: string,
|
|
24
|
-
foreignKey?: string,
|
|
25
|
-
scope?: FilterClause,
|
|
26
|
-
): Promise<void>;
|
|
27
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {ModelId} from '../types.js';
|
|
2
|
-
import {ModelData} from '../types.js';
|
|
3
|
-
import {Service} from '@e22m4u/js-service';
|
|
4
|
-
import {Repository} from './repository.js';
|
|
5
|
-
import {Constructor} from '@e22m4u/js-service';
|
|
6
|
-
import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from '../definition/index.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Repository registry.
|
|
10
|
-
*/
|
|
11
|
-
export declare class RepositoryRegistry extends Service {
|
|
12
|
-
/**
|
|
13
|
-
* Set repository registry.
|
|
14
|
-
*
|
|
15
|
-
* @param ctor
|
|
16
|
-
*/
|
|
17
|
-
setRepositoryCtor(ctor: Constructor<Repository<any, any, any>>): void;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get repository.
|
|
21
|
-
*
|
|
22
|
-
* @param modelName
|
|
23
|
-
*/
|
|
24
|
-
getRepository<
|
|
25
|
-
Data extends ModelData = ModelData,
|
|
26
|
-
IdType extends ModelId = ModelId,
|
|
27
|
-
IdName extends string = typeof DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
28
|
-
>(modelName: string): Repository<Data, IdType, IdName>;
|
|
29
|
-
}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import {ModelId} from '../types.js';
|
|
2
|
-
import {Flatten} from '../types.js';
|
|
3
|
-
import {ModelData} from '../types.js';
|
|
4
|
-
import {PartialBy} from '../types.js';
|
|
5
|
-
import {Service} from '@e22m4u/js-service';
|
|
6
|
-
import {Adapter} from '../adapter/index.js';
|
|
7
|
-
import {WhereClause} from '../filter/index.js';
|
|
8
|
-
import {FilterClause} from '../filter/index.js';
|
|
9
|
-
import {ItemFilterClause} from '../filter/index.js';
|
|
10
|
-
import {ServiceContainer} from '@e22m4u/js-service';
|
|
11
|
-
import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from '../definition/index.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Repository.
|
|
15
|
-
*/
|
|
16
|
-
export declare class Repository<
|
|
17
|
-
Data extends object = ModelData,
|
|
18
|
-
IdType extends ModelId = ModelId,
|
|
19
|
-
IdName extends string = typeof DEFAULT_PRIMARY_KEY_PROPERTY_NAME,
|
|
20
|
-
FlatData extends object = Flatten<Data>,
|
|
21
|
-
> extends Service {
|
|
22
|
-
// it fixes unused generic bug
|
|
23
|
-
private _Data?: Data;
|
|
24
|
-
private _IdType?: IdType;
|
|
25
|
-
private _IdName?: IdName;
|
|
26
|
-
private _FlatData?: FlatData;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Model name.
|
|
30
|
-
*/
|
|
31
|
-
get modelName(): string;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Datasource name.
|
|
35
|
-
*/
|
|
36
|
-
get datasourceName(): string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Constructor.
|
|
40
|
-
*
|
|
41
|
-
* @param container
|
|
42
|
-
* @param modelName
|
|
43
|
-
*/
|
|
44
|
-
constructor(container: ServiceContainer, modelName: string);
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get adapter.
|
|
48
|
-
*/
|
|
49
|
-
getAdapter(): Promise<Adapter>;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Create.
|
|
53
|
-
*
|
|
54
|
-
* @param data
|
|
55
|
-
* @param filter
|
|
56
|
-
*/
|
|
57
|
-
create(
|
|
58
|
-
data: WithOptionalId<FlatData, IdName>,
|
|
59
|
-
filter?: ItemFilterClause<FlatData>,
|
|
60
|
-
): Promise<FlatData>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Replace by id.
|
|
64
|
-
*
|
|
65
|
-
* @param id
|
|
66
|
-
* @param data
|
|
67
|
-
* @param filter
|
|
68
|
-
*/
|
|
69
|
-
replaceById(
|
|
70
|
-
id: IdType,
|
|
71
|
-
data: WithoutId<FlatData, IdName>,
|
|
72
|
-
filter?: ItemFilterClause<FlatData>,
|
|
73
|
-
): Promise<FlatData>;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Replace or create.
|
|
77
|
-
*
|
|
78
|
-
* @param data
|
|
79
|
-
* @param filter
|
|
80
|
-
*/
|
|
81
|
-
replaceOrCreate(
|
|
82
|
-
data: WithOptionalId<FlatData, IdName>,
|
|
83
|
-
filter?: ItemFilterClause<FlatData>,
|
|
84
|
-
): Promise<FlatData>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Patch.
|
|
88
|
-
*
|
|
89
|
-
* @param data
|
|
90
|
-
* @param where
|
|
91
|
-
*/
|
|
92
|
-
patch(
|
|
93
|
-
data: PartialWithoutId<FlatData, IdName>,
|
|
94
|
-
where?: WhereClause<FlatData>,
|
|
95
|
-
): Promise<number>;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Patch by id.
|
|
99
|
-
*
|
|
100
|
-
* @param id
|
|
101
|
-
* @param data
|
|
102
|
-
* @param filter
|
|
103
|
-
*/
|
|
104
|
-
patchById(
|
|
105
|
-
id: IdType,
|
|
106
|
-
data: PartialWithoutId<FlatData, IdName>,
|
|
107
|
-
filter?: ItemFilterClause<FlatData>,
|
|
108
|
-
): Promise<FlatData>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Find.
|
|
112
|
-
*
|
|
113
|
-
* @param filter
|
|
114
|
-
*/
|
|
115
|
-
find(filter?: FilterClause<FlatData>): Promise<FlatData[]>;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Find one.
|
|
119
|
-
*
|
|
120
|
-
* @param filter
|
|
121
|
-
*/
|
|
122
|
-
findOne(filter?: FilterClause<FlatData>): Promise<FlatData | undefined>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Find by id.
|
|
126
|
-
*
|
|
127
|
-
* @param id
|
|
128
|
-
* @param filter
|
|
129
|
-
*/
|
|
130
|
-
findById(id: IdType, filter?: ItemFilterClause<FlatData>): Promise<FlatData>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Delete.
|
|
134
|
-
*
|
|
135
|
-
* @param where
|
|
136
|
-
*/
|
|
137
|
-
delete(where?: WhereClause<FlatData>): Promise<number>;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Delete by id.
|
|
141
|
-
*
|
|
142
|
-
* @param id
|
|
143
|
-
*/
|
|
144
|
-
deleteById(id: IdType): Promise<boolean>;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Exists.
|
|
148
|
-
*
|
|
149
|
-
* @param id
|
|
150
|
-
*/
|
|
151
|
-
exists(id: IdType): Promise<boolean>;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Count.
|
|
155
|
-
*
|
|
156
|
-
* @param where
|
|
157
|
-
*/
|
|
158
|
-
count(where?: WhereClause<FlatData>): Promise<number>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Removes id field.
|
|
163
|
-
*/
|
|
164
|
-
export declare type WithoutId<
|
|
165
|
-
Data extends object,
|
|
166
|
-
IdName extends string = 'id',
|
|
167
|
-
> = Flatten<Omit<Data, IdName>>;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Makes fields as optional and remove id field.
|
|
171
|
-
*/
|
|
172
|
-
export declare type PartialWithoutId<
|
|
173
|
-
Data extends object,
|
|
174
|
-
IdName extends string = 'id',
|
|
175
|
-
> = Flatten<Partial<Omit<Data, IdName>>>;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Makes the required id field as optional.
|
|
179
|
-
*/
|
|
180
|
-
export declare type WithOptionalId<
|
|
181
|
-
Data extends object,
|
|
182
|
-
IdName extends string = 'id',
|
|
183
|
-
> = Flatten<Data extends {[K in IdName]: any} ? PartialBy<Data, IdName> : Data>;
|
package/src/types.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Free-form object with open properties.
|
|
3
|
-
*/
|
|
4
|
-
export declare type AnyObject = {
|
|
5
|
-
[property: string]: unknown;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Makes specific field as optional.
|
|
10
|
-
*/
|
|
11
|
-
export declare type PartialBy<T, K extends keyof T> = Omit<T, K> &
|
|
12
|
-
Partial<Pick<T, K>>;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Model data.
|
|
16
|
-
*/
|
|
17
|
-
export declare type ModelData = Record<string, unknown>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Model id.
|
|
21
|
-
*/
|
|
22
|
-
export declare type ModelId = unknown;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Flatten.
|
|
26
|
-
*/
|
|
27
|
-
type Identity<T> = T;
|
|
28
|
-
export declare type Flatten<T> = Identity<{[k in keyof T]: T[k]}>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A callable type with the "new" operator
|
|
32
|
-
* allows class and constructor.
|
|
33
|
-
*/
|
|
34
|
-
export interface Constructor<T = unknown> {
|
|
35
|
-
new (...args: any[]): T;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Representing a value or promise. This type is used
|
|
40
|
-
* to represent results of synchronous/asynchronous
|
|
41
|
-
* resolution of values.
|
|
42
|
-
*/
|
|
43
|
-
export type ValueOrPromise<T> = T | PromiseLike<T>;
|
package/src/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get ctor name.
|
|
3
|
-
*
|
|
4
|
-
* @param {*} value
|
|
5
|
-
* @returns {string|undefined}
|
|
6
|
-
*/
|
|
7
|
-
export function getCtorName(value) {
|
|
8
|
-
if (value === null) return 'Null';
|
|
9
|
-
if (value === undefined) return 'Undefined';
|
|
10
|
-
return (value.constructor && value.constructor.name) || undefined;
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {getCtorName} from './get-ctor-name.js';
|
|
3
|
-
|
|
4
|
-
describe('getCtorName', function () {
|
|
5
|
-
it('returns a constructor name of a given value', function () {
|
|
6
|
-
expect(getCtorName({})).to.be.eq('Object');
|
|
7
|
-
expect(getCtorName(new Date())).to.be.eq('Date');
|
|
8
|
-
expect(getCtorName([])).to.be.eq('Array');
|
|
9
|
-
expect(getCtorName(() => undefined)).to.be.eq('Function');
|
|
10
|
-
expect(getCtorName('string')).to.be.eq('String');
|
|
11
|
-
expect(getCtorName(10)).to.be.eq('Number');
|
|
12
|
-
expect(getCtorName(true)).to.be.eq('Boolean');
|
|
13
|
-
expect(getCtorName(false)).to.be.eq('Boolean');
|
|
14
|
-
expect(getCtorName(null)).to.be.eq('Null');
|
|
15
|
-
expect(getCtorName(undefined)).to.be.eq('Undefined');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decorator target type.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum DecoratorTargetType {
|
|
5
|
-
CONSTRUCTOR = 'constructor',
|
|
6
|
-
INSTANCE = 'instance',
|
|
7
|
-
STATIC_METHOD = 'staticMethod',
|
|
8
|
-
INSTANCE_METHOD = 'instanceMethod',
|
|
9
|
-
STATIC_PROPERTY = 'staticProperty',
|
|
10
|
-
INSTANCE_PROPERTY = 'instanceProperty',
|
|
11
|
-
CONSTRUCTOR_PARAMETER = 'constructorParameter',
|
|
12
|
-
STATIC_METHOD_PARAMETER = 'staticMethodParameter',
|
|
13
|
-
INSTANCE_METHOD_PARAMETER = 'instanceMethodParameter',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get decorator target type.
|
|
18
|
-
*
|
|
19
|
-
* @param target
|
|
20
|
-
* @param propertyKey
|
|
21
|
-
* @param descriptorOrIndex
|
|
22
|
-
*/
|
|
23
|
-
export declare function getDecoratorTargetType(
|
|
24
|
-
target: object,
|
|
25
|
-
propertyKey?: string,
|
|
26
|
-
descriptorOrIndex?: PropertyDescriptor | number,
|
|
27
|
-
): DecoratorTargetType;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} PropertyDescriptor
|
|
3
|
-
* @property {boolean|undefined} configurable
|
|
4
|
-
* @property {boolean|undefined} enumerable
|
|
5
|
-
* @property {*} value
|
|
6
|
-
* @property {boolean|undefined} writable
|
|
7
|
-
* @property {Function} get
|
|
8
|
-
* @property {Function} set
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Decorator target type.
|
|
13
|
-
*
|
|
14
|
-
* @enum {string}
|
|
15
|
-
* @property {string} CONSTRUCTOR
|
|
16
|
-
* @property {string} INSTANCE
|
|
17
|
-
* @property {string} STATIC_METHOD
|
|
18
|
-
* @property {string} INSTANCE_METHOD
|
|
19
|
-
* @property {string} STATIC_PROPERTY
|
|
20
|
-
* @property {string} INSTANCE_PROPERTY
|
|
21
|
-
* @property {string} CONSTRUCTOR_PARAMETER
|
|
22
|
-
* @property {string} STATIC_METHOD_PARAMETER
|
|
23
|
-
* @property {string} INSTANCE_METHOD_PARAMETER
|
|
24
|
-
*/
|
|
25
|
-
export const DecoratorTargetType = {
|
|
26
|
-
CONSTRUCTOR: 'constructor',
|
|
27
|
-
INSTANCE: 'instance',
|
|
28
|
-
STATIC_METHOD: 'staticMethod',
|
|
29
|
-
INSTANCE_METHOD: 'instanceMethod',
|
|
30
|
-
STATIC_PROPERTY: 'staticProperty',
|
|
31
|
-
INSTANCE_PROPERTY: 'instanceProperty',
|
|
32
|
-
CONSTRUCTOR_PARAMETER: 'constructorParameter',
|
|
33
|
-
STATIC_METHOD_PARAMETER: 'staticMethodParameter',
|
|
34
|
-
INSTANCE_METHOD_PARAMETER: 'instanceMethodParameter',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get decorator target type.
|
|
39
|
-
*
|
|
40
|
-
* @param {object} target
|
|
41
|
-
* @param {string|undefined} propertyKey
|
|
42
|
-
* @param {PropertyDescriptor|number|undefined} descriptorOrIndex
|
|
43
|
-
* @returns {DecoratorTargetType}
|
|
44
|
-
*/
|
|
45
|
-
export function getDecoratorTargetType(target, propertyKey, descriptorOrIndex) {
|
|
46
|
-
const isCtor = typeof target === 'function';
|
|
47
|
-
const isParameter = typeof descriptorOrIndex === 'number';
|
|
48
|
-
const isProperty = propertyKey != null && descriptorOrIndex == null;
|
|
49
|
-
const isMethod = propertyKey != null && descriptorOrIndex != null;
|
|
50
|
-
const D = DecoratorTargetType;
|
|
51
|
-
if (isCtor) {
|
|
52
|
-
if (isParameter)
|
|
53
|
-
return propertyKey ? D.STATIC_METHOD_PARAMETER : D.CONSTRUCTOR_PARAMETER;
|
|
54
|
-
if (isProperty) return D.STATIC_PROPERTY;
|
|
55
|
-
if (isMethod) return D.STATIC_METHOD;
|
|
56
|
-
return D.CONSTRUCTOR;
|
|
57
|
-
} else {
|
|
58
|
-
if (isParameter) return D.INSTANCE_METHOD_PARAMETER;
|
|
59
|
-
if (isProperty) return D.INSTANCE_PROPERTY;
|
|
60
|
-
if (isMethod) return D.INSTANCE_METHOD;
|
|
61
|
-
return D.INSTANCE;
|
|
62
|
-
}
|
|
63
|
-
}
|