bigal 13.0.0-beta3 → 13.0.0-beta5

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.
@@ -1,315 +0,0 @@
1
- /**
2
- * Removes all entity collection properties. To be used as a re-map key function
3
- */
4
- type ExcludeEntityCollections<T, K extends PropertyKey> = T extends NotEntityBrand[] | undefined ? K : T extends Entity[] | undefined ? never : K;
5
-
6
- /**
7
- * Removes all functions and entity collection properties. To be used as a re-map key function
8
- */
9
- type ExcludeFunctions<T, K extends PropertyKey> = T extends Function ? never : K;
10
-
11
- /**
12
- * Changes all Entity value properties to Primitive (string|number) | Pick<Entity, 'id'>
13
- */
14
- type CreateUpdateParams<T extends Entity> = {
15
- [K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, ExcludeFunctions<T[K], K>>]?: T[K] extends NotEntityBrand | undefined ? T[K] : Extract<T[K], Entity> extends undefined ? T[K] : Exclude<T[K], Entity> | Pick<Extract<T[K], Entity>, 'id'>;
16
- };
17
-
18
- type EntityFieldValue = boolean[] | Date | number[] | Record<string, unknown> | string[] | boolean | number | string | unknown | null;
19
- declare abstract class Entity {
20
- abstract id: unknown;
21
- static beforeCreate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
22
- static beforeUpdate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
23
- }
24
- interface NotEntityBrand {
25
- _notEntityBrand: void;
26
- }
27
- type NotEntity<T> = NotEntityBrand & T;
28
- interface EntityStatic<T extends Entity> {
29
- beforeCreate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
30
- beforeUpdate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
31
- new (): T;
32
- }
33
-
34
- interface ColumnBaseMetadataOptions {
35
- /**
36
- * Name of class with @table decorator
37
- */
38
- target: string;
39
- /**
40
- * Column name in the database
41
- */
42
- name: string;
43
- /**
44
- * Class property to which the column is applied
45
- */
46
- propertyName: string;
47
- /**
48
- * Indicates if a value is required for creates.
49
- */
50
- required?: boolean;
51
- /**
52
- * Indicates if column is inserted by default. Default is true
53
- */
54
- insert?: boolean;
55
- /**
56
- * Indicates if column value is updated by "save" operation. Default is true
57
- */
58
- update?: boolean;
59
- /**
60
- * Indicates if this column is a primary key.
61
- * Same can be achieved when @primaryColumn decorator is used
62
- */
63
- primary?: boolean;
64
- /**
65
- * Value will be equal to `new Date()` when the row is inserted into the table
66
- * Same can be achieved when @createDateColumn decorator is used
67
- */
68
- createDate?: boolean;
69
- /**
70
- * Value will be equal to `new Date()` when the row is updated
71
- * Same can be achieved when @updateDateColumn decorator is used
72
- */
73
- updateDate?: boolean;
74
- /**
75
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
76
- * Same can be achieved when @versionColumn decorator is used
77
- */
78
- version?: boolean;
79
- }
80
- declare abstract class ColumnBaseMetadata {
81
- /**
82
- * Name of class with @table decorator
83
- */
84
- target: string;
85
- /**
86
- * Column name in the database
87
- */
88
- name: string;
89
- /**
90
- * Class property to which the column is applied
91
- */
92
- propertyName: string;
93
- /**
94
- * Indicates if a value is required for creates.
95
- */
96
- required: boolean;
97
- /**
98
- * Indicates if column is inserted by default. Default is true
99
- */
100
- insert: boolean;
101
- /**
102
- * Indicates if column value is updated by "save" operation. Default is true
103
- */
104
- update: boolean;
105
- /**
106
- * Indicates if this column is a primary key.
107
- * Same can be achieved when @primaryColumn decorator is used
108
- */
109
- primary: boolean;
110
- /**
111
- * Value will be equal to `new Date()` when the row is inserted into the table
112
- * Same can be achieved when @createDateColumn decorator is used
113
- */
114
- createDate: boolean;
115
- /**
116
- * Value will be equal to `new Date()` when the row is updated
117
- * Same can be achieved when @updateDateColumn decorator is used
118
- */
119
- updateDate: boolean;
120
- /**
121
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
122
- * Same can be achieved when @versionColumn decorator is used
123
- */
124
- version: boolean;
125
- protected constructor({ target, name, propertyName, required, insert, update, primary, createDate, updateDate, version, }: ColumnBaseMetadataOptions);
126
- }
127
-
128
- interface ColumnCollectionMetadataOptions extends ColumnBaseMetadataOptions {
129
- /**
130
- * Type of the items in the collection
131
- */
132
- collection: string | (() => string);
133
- /**
134
- * Property name of the on the collection item type
135
- */
136
- via: string;
137
- /**
138
- * Name of the junction table for multi-multi associations
139
- */
140
- through?: string | (() => string);
141
- }
142
- declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
143
- private _collectionString?;
144
- private _collectionFn?;
145
- private _throughString?;
146
- private _throughFn?;
147
- /**
148
- * Type of the items in the collection
149
- */
150
- get collection(): string;
151
- /**
152
- * Property name of the on the collection item type
153
- */
154
- via: string;
155
- /**
156
- * Name of the junction table for multi-multi associations
157
- */
158
- get through(): string | undefined;
159
- constructor({ target, //
160
- name, propertyName, required, insert, update, primary, createDate, updateDate, version, collection, via, through, }: ColumnCollectionMetadataOptions);
161
- }
162
-
163
- interface ColumnModelMetadataOptions extends ColumnBaseMetadataOptions {
164
- /**
165
- * Name of the model represented by this column id
166
- */
167
- model: string | (() => string);
168
- }
169
- declare class ColumnModelMetadata extends ColumnBaseMetadata {
170
- private _modelString?;
171
- private _modelFn?;
172
- /**
173
- * Name of the model represented by this column id
174
- */
175
- get model(): string;
176
- constructor({ target, //
177
- name, propertyName, required, insert, update, primary, createDate, updateDate, version, model, }: ColumnModelMetadataOptions);
178
- }
179
-
180
- interface ColumnTypeMetadataOptions extends ColumnBaseMetadataOptions {
181
- /**
182
- * Type of sql column
183
- */
184
- type: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
185
- /**
186
- * Default database value
187
- */
188
- defaultsTo?: boolean[] | number[] | string[] | boolean | number | string | (() => Date | Record<string, unknown> | boolean | number | string) | [];
189
- /**
190
- * Array of possible enumerated values
191
- */
192
- enum?: string[];
193
- /**
194
- * If set, enforces a maximum length check on the column
195
- *
196
- * Applies to types: string | string[]
197
- */
198
- maxLength?: number;
199
- }
200
- declare class ColumnTypeMetadata extends ColumnBaseMetadata {
201
- /**
202
- * Type of the column
203
- */
204
- type: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
205
- /**
206
- * Default database value
207
- */
208
- defaultsTo?: boolean[] | number[] | string[] | boolean | number | string | (() => Date | Record<string, unknown> | boolean | number | string) | [];
209
- /**
210
- * Array of possible enumerated values
211
- */
212
- enum?: string[];
213
- /**
214
- * If set, enforces a maximum length check on the column
215
- *
216
- * Applies to types: string | string[]
217
- */
218
- maxLength?: number;
219
- constructor(options: ColumnTypeMetadataOptions);
220
- }
221
-
222
- type ColumnMetadata = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
223
-
224
- interface ColumnModifierMetadata {
225
- /**
226
- * Name of class with @table decorator
227
- */
228
- target: string;
229
- /**
230
- * Column name in the database
231
- */
232
- name?: string;
233
- /**
234
- * Class property to which the column is applied
235
- */
236
- propertyName: string;
237
- /**
238
- * Indicates if a value is required for creates.
239
- */
240
- required?: boolean;
241
- /**
242
- * Indicates if this column is a primary key.
243
- * Same can be achieved when @primaryColumn decorator is used
244
- */
245
- primary?: boolean;
246
- /**
247
- * Value will be equal to `new Date()` when the row is inserted into the table
248
- * Same can be achieved when @createDateColumn decorator is used
249
- */
250
- createDate?: boolean;
251
- /**
252
- * Value will be equal to `new Date()` when the row is updated
253
- * Same can be achieved when @updateDateColumn decorator is used
254
- */
255
- updateDate?: boolean;
256
- /**
257
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
258
- * Same can be achieved when @versionColumn decorator is used
259
- */
260
- version?: boolean;
261
- /**
262
- * Type of sql column
263
- */
264
- type?: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
265
- /**
266
- * Name of the model represented by this column id
267
- */
268
- model?: string | (() => string);
269
- }
270
-
271
- type Column = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
272
- type ColumnByStringId = Record<string, Column>;
273
- interface ModelMetadataOptions<T extends Entity> {
274
- name: string;
275
- type: EntityStatic<T>;
276
- connection?: string;
277
- tableName?: string;
278
- readonly?: boolean;
279
- }
280
- declare class ModelMetadata<T extends Entity> {
281
- private _columns;
282
- private _primaryKeyColumn;
283
- private _createDateColumns;
284
- private _updateDateColumns;
285
- private _versionDateColumns;
286
- set columns(columns: readonly Column[]);
287
- get columns(): readonly Column[];
288
- get primaryKeyColumn(): Column | undefined;
289
- get createDateColumns(): readonly Column[];
290
- get updateDateColumns(): readonly Column[];
291
- get versionColumns(): readonly Column[];
292
- name: string;
293
- type: EntityStatic<T>;
294
- connection?: string;
295
- tableName: string;
296
- readonly: boolean;
297
- columnsByColumnName: ColumnByStringId;
298
- columnsByPropertyName: ColumnByStringId;
299
- constructor({ name, //
300
- type, connection, tableName, readonly, }: ModelMetadataOptions<T>);
301
- }
302
-
303
- /**
304
- * This represents an object to store all of the decorator data. Since there can be multiple decorators per
305
- * class/property, things will be reconciled when entities are initialized
306
- */
307
- declare class MetadataStorage<T extends Entity> {
308
- readonly models: ModelMetadata<T>[];
309
- readonly columns: ColumnMetadata[];
310
- readonly columnModifiers: ColumnModifierMetadata[];
311
- }
312
-
313
- declare function getMetadataStorage<T extends Entity>(): MetadataStorage<T>;
314
-
315
- export { type CreateUpdateParams as C, Entity as E, ModelMetadata as M, type NotEntityBrand as N, type ExcludeEntityCollections as a, type ExcludeFunctions as b, type EntityStatic as c, type EntityFieldValue as d, type NotEntity as e, type ColumnBaseMetadataOptions as f, getMetadataStorage as g, ColumnBaseMetadata as h, type ColumnCollectionMetadataOptions as i, ColumnCollectionMetadata as j, type ColumnMetadata as k, type ColumnModelMetadataOptions as l, ColumnModelMetadata as m, type ColumnModifierMetadata as n, type ColumnTypeMetadataOptions as o, ColumnTypeMetadata as p, type ModelMetadataOptions as q };