@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,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
- }
@@ -1,4 +0,0 @@
1
- export * from './has-one-resolver.js';
2
- export * from './has-many-resolver.js';
3
- export * from './belongs-to-resolver.js';
4
- export * from './references-many-resolver.js';
@@ -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,2 +0,0 @@
1
- export * from './repository.js';
2
- export * from './repository-registry.js';
@@ -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,6 +0,0 @@
1
- /**
2
- * Capitalize.
3
- *
4
- * @param string
5
- */
6
- export declare function capitalize(string: string): string;
@@ -1,6 +0,0 @@
1
- /**
2
- * Clone deep.
3
- *
4
- * @param value
5
- */
6
- export declare function cloneDeep<T>(value: T): T;
@@ -1,10 +0,0 @@
1
- /**
2
- * Exclude object keys.
3
- *
4
- * @param obj
5
- * @param keys
6
- */
7
- export declare function excludeObjectKeys<T extends object>(
8
- obj: T,
9
- keys: string | string[],
10
- ): Partial<T>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Get ctor name.
3
- *
4
- * @param value
5
- */
6
- export declare function getCtorName(value: unknown): string | undefined;
@@ -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
- }