@e22m4u/js-repository 0.7.0 → 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 +123 -164
- package/dist/cjs/index.cjs +8 -114
- package/eslint.config.js +29 -58
- package/jsconfig.json +7 -0
- package/package.json +11 -19
- package/src/adapter/adapter-loader.js +3 -4
- package/src/adapter/adapter.js +8 -5
- package/src/adapter/adapter.spec.js +10 -9
- package/src/adapter/builtin/memory-adapter.js +8 -7
- package/src/adapter/builtin/memory-adapter.spec.js +5 -2
- package/src/adapter/decorator/default-values-decorator.spec.js +1 -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 -1
- 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 -1
- 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/is-plain-object.js +4 -4
- 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 -153
- 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/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 -5
- 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 -6
- package/src/definition/model/model-data-sanitizer.d.ts +0 -15
- 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 -6
- 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 -23
- package/src/definition/model/properties/property-definition.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/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-value-by-path.d.ts +0 -12
- package/src/utils/index.d.ts +0 -12
- 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/tsconfig.json +0 -11
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import {ModelData} from '../../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {DataType} from './properties/index.js';
|
|
4
|
-
import {RelationDefinition} from './relations/index.js';
|
|
5
|
-
import {PropertyDefinition} from './properties/index.js';
|
|
6
|
-
import {PropertyDefinitionMap} from './model-definition.js';
|
|
7
|
-
import {RelationDefinitionMap} from './model-definition.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Default primary key property name.
|
|
11
|
-
*/
|
|
12
|
-
export const DEFAULT_PRIMARY_KEY_PROPERTY_NAME: 'id';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Model definition utils.
|
|
16
|
-
*/
|
|
17
|
-
export declare class ModelDefinitionUtils extends Service {
|
|
18
|
-
/**
|
|
19
|
-
* Get primary key as property name.
|
|
20
|
-
*
|
|
21
|
-
* @param modelName
|
|
22
|
-
*/
|
|
23
|
-
getPrimaryKeyAsPropertyName(modelName: string): string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get primary key as column name.
|
|
27
|
-
*
|
|
28
|
-
* @param modelName
|
|
29
|
-
*/
|
|
30
|
-
getPrimaryKeyAsColumnName(modelName: string): string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get table name by model name.
|
|
34
|
-
*
|
|
35
|
-
* @param modelName
|
|
36
|
-
*/
|
|
37
|
-
getTableNameByModelName(modelName: string): string;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get column name by property name.
|
|
41
|
-
*
|
|
42
|
-
* @param modelName
|
|
43
|
-
* @param propertyName
|
|
44
|
-
*/
|
|
45
|
-
getColumnNameByPropertyName(modelName: string, propertyName: string): string;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get default property value.
|
|
49
|
-
*
|
|
50
|
-
* @param modelName
|
|
51
|
-
* @param propertyName
|
|
52
|
-
*/
|
|
53
|
-
getDefaultPropertyValue(modelName: string, propertyName: string): unknown;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Set default values to empty properties.
|
|
57
|
-
*
|
|
58
|
-
* @param modelName
|
|
59
|
-
* @param modelData
|
|
60
|
-
* @param onlyProvidedProperties
|
|
61
|
-
*/
|
|
62
|
-
setDefaultValuesToEmptyProperties<T extends ModelData>(
|
|
63
|
-
modelName: string,
|
|
64
|
-
modelData: T,
|
|
65
|
-
onlyProvidedProperties?: boolean,
|
|
66
|
-
): T;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Convert property names to column names.
|
|
70
|
-
*
|
|
71
|
-
* @param modelName
|
|
72
|
-
* @param modelData
|
|
73
|
-
*/
|
|
74
|
-
convertPropertyNamesToColumnNames(
|
|
75
|
-
modelName: string,
|
|
76
|
-
modelData: ModelData,
|
|
77
|
-
): ModelData;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Convert column names to property names.
|
|
81
|
-
*
|
|
82
|
-
* @param modelName
|
|
83
|
-
* @param tableData
|
|
84
|
-
*/
|
|
85
|
-
convertColumnNamesToPropertyNames(
|
|
86
|
-
modelName: string,
|
|
87
|
-
tableData: ModelData,
|
|
88
|
-
): ModelData;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get data type by property name.
|
|
92
|
-
*
|
|
93
|
-
* @param modelName
|
|
94
|
-
* @param propertyName
|
|
95
|
-
*/
|
|
96
|
-
getDataTypeByPropertyName(modelName: string, propertyName: string): DataType;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get data type from property definition.
|
|
100
|
-
*
|
|
101
|
-
* @param propDef
|
|
102
|
-
*/
|
|
103
|
-
getDataTypeFromPropertyDefinition(propDef: PropertyDefinition): DataType;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get own properties definition of primary keys.
|
|
107
|
-
*
|
|
108
|
-
* @param modelName
|
|
109
|
-
*/
|
|
110
|
-
getOwnPropertiesDefinitionOfPrimaryKeys(
|
|
111
|
-
modelName: string,
|
|
112
|
-
): PropertyDefinitionMap;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get own properties definition without primary keys.
|
|
116
|
-
*
|
|
117
|
-
* @param modelName
|
|
118
|
-
*/
|
|
119
|
-
getOwnPropertiesDefinitionWithoutPrimaryKeys(
|
|
120
|
-
modelName: string,
|
|
121
|
-
): PropertyDefinitionMap;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Get properties definition in base model hierarchy.
|
|
125
|
-
*
|
|
126
|
-
* @param modelName
|
|
127
|
-
*/
|
|
128
|
-
getPropertiesDefinitionInBaseModelHierarchy(
|
|
129
|
-
modelName: string,
|
|
130
|
-
): PropertyDefinitionMap;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get own relations definition.
|
|
134
|
-
*
|
|
135
|
-
* @param modelName
|
|
136
|
-
*/
|
|
137
|
-
getOwnRelationsDefinition(modelName: string): RelationDefinitionMap;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Get relations definition in base model hierarchy.
|
|
141
|
-
*
|
|
142
|
-
* @param modelName
|
|
143
|
-
*/
|
|
144
|
-
getRelationsDefinitionInBaseModelHierarchy(
|
|
145
|
-
modelName: string,
|
|
146
|
-
): RelationDefinitionMap;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Get relation definition by name.
|
|
150
|
-
*
|
|
151
|
-
* @param modelName
|
|
152
|
-
* @param relationName
|
|
153
|
-
*/
|
|
154
|
-
getRelationDefinitionByName(
|
|
155
|
-
modelName: string,
|
|
156
|
-
relationName: string,
|
|
157
|
-
): RelationDefinition;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Exclude object keys by relation names.
|
|
161
|
-
*
|
|
162
|
-
* @param modelName
|
|
163
|
-
* @param modelData
|
|
164
|
-
*/
|
|
165
|
-
excludeObjectKeysByRelationNames<T extends ModelData>(
|
|
166
|
-
modelName: string,
|
|
167
|
-
modelData: T,
|
|
168
|
-
): Partial<T>;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Get model name of property value if defined.
|
|
172
|
-
*
|
|
173
|
-
* @param modelName
|
|
174
|
-
* @param propertyName
|
|
175
|
-
*/
|
|
176
|
-
getModelNameOfPropertyValueIfDefined(
|
|
177
|
-
modelName: string,
|
|
178
|
-
propertyName: string,
|
|
179
|
-
): string | undefined;
|
|
180
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {ModelDefinition} from './model-definition.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Model definition validator.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ModelDefinitionValidator extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Validate.
|
|
10
|
-
*
|
|
11
|
-
* @param modelDef
|
|
12
|
-
*/
|
|
13
|
-
validate(modelDef: ModelDefinition): void;
|
|
14
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {RelationDefinition} from './relations/index.js';
|
|
2
|
-
import {PropertyDefinition} from './properties/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Property definition map.
|
|
6
|
-
*/
|
|
7
|
-
export declare type PropertyDefinitionMap = {
|
|
8
|
-
[name: string]: PropertyDefinition;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Relation definition map.
|
|
13
|
-
*/
|
|
14
|
-
export declare type RelationDefinitionMap = {
|
|
15
|
-
[name: string]: RelationDefinition;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Model definition.
|
|
20
|
-
*/
|
|
21
|
-
export declare type ModelDefinition = {
|
|
22
|
-
name: string;
|
|
23
|
-
datasource?: string;
|
|
24
|
-
base?: string;
|
|
25
|
-
tableName?: string;
|
|
26
|
-
properties?: PropertyDefinitionMap;
|
|
27
|
-
relations?: RelationDefinitionMap;
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Data type.
|
|
3
|
-
*/
|
|
4
|
-
export declare const DataType: {
|
|
5
|
-
ANY: 'any';
|
|
6
|
-
STRING: 'string';
|
|
7
|
-
NUMBER: 'number';
|
|
8
|
-
BOOLEAN: 'boolean';
|
|
9
|
-
ARRAY: 'array';
|
|
10
|
-
OBJECT: 'object';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Type of DataType.
|
|
15
|
-
*/
|
|
16
|
-
export type DataType = (typeof DataType)[keyof typeof DataType];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './data-type.js';
|
|
2
|
-
export * from './property-definition.js';
|
|
3
|
-
export * from './property-uniqueness.js';
|
|
4
|
-
export * from './property-uniqueness-validator.js';
|
|
5
|
-
export * from './properties-definition-validator.js';
|
|
6
|
-
export * from './primary-keys-definition-validator.js';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {PropertyDefinitionMap} from '../model-definition.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Primary keys definition validator.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PrimaryKeysDefinitionValidator extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Validate.
|
|
10
|
-
*
|
|
11
|
-
* @param modelName
|
|
12
|
-
* @param propDefs
|
|
13
|
-
*/
|
|
14
|
-
validate(modelName: string, propDefs: PropertyDefinitionMap): void;
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {PropertyDefinitionMap} from '../model-definition.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Properties definition validator.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PropertiesDefinitionValidator extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Validate.
|
|
10
|
-
*
|
|
11
|
-
* @param modelName
|
|
12
|
-
* @param propDefs
|
|
13
|
-
*/
|
|
14
|
-
validate(modelName: string, propDefs: PropertyDefinitionMap): void;
|
|
15
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {DataType} from './data-type.js';
|
|
2
|
-
import {PropertyUniqueness} from './property-uniqueness.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Full property definition.
|
|
6
|
-
*/
|
|
7
|
-
export declare type FullPropertyDefinition = {
|
|
8
|
-
type: DataType;
|
|
9
|
-
itemType?: DataType;
|
|
10
|
-
itemModel?: string;
|
|
11
|
-
model?: string;
|
|
12
|
-
primaryKey?: boolean;
|
|
13
|
-
columnName?: string;
|
|
14
|
-
columnType?: string;
|
|
15
|
-
required?: boolean;
|
|
16
|
-
default?: unknown;
|
|
17
|
-
unique?: boolean | PropertyUniqueness;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Property definition.
|
|
22
|
-
*/
|
|
23
|
-
export declare type PropertyDefinition = DataType | FullPropertyDefinition;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {ModelId} from '../../../types.js';
|
|
2
|
-
import {Service} from '@e22m4u/js-service';
|
|
3
|
-
import {ModelData} from '../../../types.js';
|
|
4
|
-
import {WhereClause} from '../../../filter/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Count method.
|
|
8
|
-
*/
|
|
9
|
-
type CountMethod = (where: WhereClause) => Promise<number>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Property uniqueness validator.
|
|
13
|
-
*/
|
|
14
|
-
export declare class PropertyUniquenessValidator extends Service {
|
|
15
|
-
/**
|
|
16
|
-
* Validate.
|
|
17
|
-
*
|
|
18
|
-
* @param countMethod
|
|
19
|
-
* @param methodName
|
|
20
|
-
* @param modelName
|
|
21
|
-
* @param modelData
|
|
22
|
-
* @param modelId
|
|
23
|
-
*/
|
|
24
|
-
validate(
|
|
25
|
-
countMethod: CountMethod,
|
|
26
|
-
methodName: string,
|
|
27
|
-
modelName: string,
|
|
28
|
-
modelData: ModelData,
|
|
29
|
-
modelId?: ModelId,
|
|
30
|
-
): Promise<void>;
|
|
31
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Property uniqueness.
|
|
3
|
-
*/
|
|
4
|
-
export declare const PropertyUniqueness: {
|
|
5
|
-
STRICT: 'strict';
|
|
6
|
-
SPARSE: 'sparse';
|
|
7
|
-
NON_UNIQUE: 'nonUnique';
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Type of PropertyUniqueness.
|
|
12
|
-
*/
|
|
13
|
-
export type PropertyUniqueness =
|
|
14
|
-
(typeof PropertyUniqueness)[keyof typeof PropertyUniqueness];
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import {RelationType} from './relation-type.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Relation definition.
|
|
5
|
-
*
|
|
6
|
-
* @example Available options.
|
|
7
|
-
* ```ts
|
|
8
|
-
* {
|
|
9
|
-
* type: RelationType;
|
|
10
|
-
* model?: string;
|
|
11
|
-
* foreignKey?: string;
|
|
12
|
-
* polymorphic?: boolean | string;
|
|
13
|
-
* discriminator?: string;
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare type RelationDefinition =
|
|
18
|
-
// belongsTo
|
|
19
|
-
| BelongsToDefinition
|
|
20
|
-
| PolyBelongsToDefinition
|
|
21
|
-
// hasOne
|
|
22
|
-
| HasOneDefinition
|
|
23
|
-
| PolyHasOneDefinitionWithTargetRelationName
|
|
24
|
-
| PolyHasOneDefinitionWithTargetKeys
|
|
25
|
-
// hasMany
|
|
26
|
-
| HasManyDefinition
|
|
27
|
-
| PolyHasManyDefinitionWithTargetRelationName
|
|
28
|
-
| PolyHasManyDefinitionWithTargetKeys
|
|
29
|
-
// referencesMany
|
|
30
|
-
| ReferencesManyDefinition;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The regular "belongsTo" relation.
|
|
34
|
-
*
|
|
35
|
-
* @example Required options only.
|
|
36
|
-
* ```
|
|
37
|
-
* {
|
|
38
|
-
* type: 'belongsTo',
|
|
39
|
-
* model: 'model',
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @example Verbose definition.
|
|
44
|
-
* ```
|
|
45
|
-
* {
|
|
46
|
-
* type: 'belongsTo',
|
|
47
|
-
* model: 'model',
|
|
48
|
-
* foreignKey: 'modelId',
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare type BelongsToDefinition = {
|
|
53
|
-
type: typeof RelationType.BELONGS_TO;
|
|
54
|
-
polymorphic?: false;
|
|
55
|
-
model: string;
|
|
56
|
-
foreignKey?: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* The polymorphic "belongsTo" relation.
|
|
61
|
-
*
|
|
62
|
-
* @example Required fields only.
|
|
63
|
-
* ```
|
|
64
|
-
* {
|
|
65
|
-
* type: 'belongsTo',
|
|
66
|
-
* polymorphic: true,
|
|
67
|
-
* }
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @example Verbose definition.
|
|
71
|
-
* ```
|
|
72
|
-
* {
|
|
73
|
-
* type: 'belongsTo',
|
|
74
|
-
* polymorphic: true,
|
|
75
|
-
* foreignKey: 'referenceId',
|
|
76
|
-
* discriminator: 'referenceType',
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare type PolyBelongsToDefinition = {
|
|
81
|
-
type: typeof RelationType.BELONGS_TO;
|
|
82
|
-
polymorphic: true;
|
|
83
|
-
foreignKey?: string;
|
|
84
|
-
discriminator?: string;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The regular "hasOne" relation.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* {
|
|
93
|
-
* type: 'hasOne',
|
|
94
|
-
* model: 'model',
|
|
95
|
-
* foreignKey: 'modelId',
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export declare type HasOneDefinition = {
|
|
100
|
-
type: typeof RelationType.HAS_ONE;
|
|
101
|
-
model: string;
|
|
102
|
-
foreignKey: string;
|
|
103
|
-
polymorphic?: false;
|
|
104
|
-
discriminator?: undefined;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* The polymorphic "hasOne" relation with a target relation name.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```ts
|
|
112
|
-
* {
|
|
113
|
-
* type: 'hasOne',
|
|
114
|
-
* model: 'model',
|
|
115
|
-
* polymorphic: 'reference',
|
|
116
|
-
* }
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export declare type PolyHasOneDefinitionWithTargetRelationName = {
|
|
120
|
-
type: typeof RelationType.HAS_ONE;
|
|
121
|
-
model: string;
|
|
122
|
-
polymorphic: string;
|
|
123
|
-
foreignKey?: undefined;
|
|
124
|
-
discriminator?: undefined;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* The polymorphic "hasOne" relation with target relation keys.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```
|
|
132
|
-
* {
|
|
133
|
-
* type: 'hasOne',
|
|
134
|
-
* model: 'model',
|
|
135
|
-
* polymorphic: true,
|
|
136
|
-
* foreignKey: 'referenceId',
|
|
137
|
-
* discriminator: 'referenceType',
|
|
138
|
-
* }
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export declare type PolyHasOneDefinitionWithTargetKeys = {
|
|
142
|
-
type: typeof RelationType.HAS_ONE;
|
|
143
|
-
model: string;
|
|
144
|
-
polymorphic: true;
|
|
145
|
-
foreignKey: string;
|
|
146
|
-
discriminator: string;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The regular "hasMany" relation.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* {
|
|
155
|
-
* type: 'hasMany',
|
|
156
|
-
* model: 'model',
|
|
157
|
-
* foreignKey: 'modelId',
|
|
158
|
-
* }
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
export declare type HasManyDefinition = {
|
|
162
|
-
type: typeof RelationType.HAS_MANY;
|
|
163
|
-
model: string;
|
|
164
|
-
foreignKey: string;
|
|
165
|
-
polymorphic?: false;
|
|
166
|
-
discriminator?: undefined;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* The polymorphic "hasMany" relation with a target relation name.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* {
|
|
175
|
-
* type: 'hasMany',
|
|
176
|
-
* model: 'model',
|
|
177
|
-
* polymorphic: 'reference',
|
|
178
|
-
* }
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
export declare type PolyHasManyDefinitionWithTargetRelationName = {
|
|
182
|
-
type: typeof RelationType.HAS_MANY;
|
|
183
|
-
model: string;
|
|
184
|
-
polymorphic: string;
|
|
185
|
-
foreignKey?: undefined;
|
|
186
|
-
discriminator?: undefined;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* The polymorphic "hasMany" relation with target relation keys.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```
|
|
194
|
-
* {
|
|
195
|
-
* type: 'hasMany',
|
|
196
|
-
* model: 'model',
|
|
197
|
-
* polymorphic: true,
|
|
198
|
-
* foreignKey: 'referenceId',
|
|
199
|
-
* discriminator: 'referenceType',
|
|
200
|
-
* }
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
export declare type PolyHasManyDefinitionWithTargetKeys = {
|
|
204
|
-
type: typeof RelationType.HAS_MANY;
|
|
205
|
-
model: string;
|
|
206
|
-
polymorphic: true;
|
|
207
|
-
foreignKey: string;
|
|
208
|
-
discriminator: string;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* The regular "referencesMany" relation.
|
|
213
|
-
*
|
|
214
|
-
* @example Required options only.
|
|
215
|
-
* ```
|
|
216
|
-
* {
|
|
217
|
-
* type: 'referencesMany',
|
|
218
|
-
* model: 'model',
|
|
219
|
-
* }
|
|
220
|
-
* ```
|
|
221
|
-
*
|
|
222
|
-
* @example Verbose definition.
|
|
223
|
-
* ```
|
|
224
|
-
* {
|
|
225
|
-
* type: 'referencesMany',
|
|
226
|
-
* model: 'model',
|
|
227
|
-
* foreignKey: 'modelIds',
|
|
228
|
-
* }
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
export declare type ReferencesManyDefinition = {
|
|
232
|
-
type: typeof RelationType.REFERENCES_MANY;
|
|
233
|
-
model: string;
|
|
234
|
-
foreignKey?: string;
|
|
235
|
-
discriminator?: undefined;
|
|
236
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Relation type.
|
|
3
|
-
*/
|
|
4
|
-
export declare const RelationType: {
|
|
5
|
-
BELONGS_TO: 'belongsTo';
|
|
6
|
-
HAS_ONE: 'hasOne';
|
|
7
|
-
HAS_MANY: 'hasMany';
|
|
8
|
-
REFERENCES_MANY: 'referencesMany';
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Type of RelationType.
|
|
13
|
-
*/
|
|
14
|
-
export type RelationType = (typeof RelationType)[keyof typeof RelationType];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Service} from '@e22m4u/js-service';
|
|
2
|
-
import {RelationDefinitionMap} from '../model-definition.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Relations definition validator.
|
|
6
|
-
*/
|
|
7
|
-
export declare class RelationsDefinitionValidator extends Service {
|
|
8
|
-
/**
|
|
9
|
-
* Validate.
|
|
10
|
-
*
|
|
11
|
-
* @param modelName
|
|
12
|
-
* @param relDefs
|
|
13
|
-
*/
|
|
14
|
-
validate(modelName: string, relDefs: RelationDefinitionMap): void;
|
|
15
|
-
}
|
package/src/errors/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Invalid operator value error.
|
|
3
|
-
*/
|
|
4
|
-
export declare class InvalidOperatorValueError extends Error {
|
|
5
|
-
/**
|
|
6
|
-
* Constructor.
|
|
7
|
-
*
|
|
8
|
-
* @param operator
|
|
9
|
-
* @param expects
|
|
10
|
-
* @param value
|
|
11
|
-
*/
|
|
12
|
-
constructor(operator: string, expects: string, value: unknown);
|
|
13
|
-
}
|