bigal 13.0.0-beta2 → 13.0.0-beta4

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/dist/index.d.ts CHANGED
@@ -1,30 +1,7 @@
1
1
  import { Pool } from 'postgres-pool';
2
-
3
- interface ClassLike {
4
- /**
5
- * Returns the name of the function. Function names are read-only and can not be changed.
6
- */
7
- readonly constructor: {
8
- readonly name: string;
9
- };
10
- }
11
-
12
- /**
13
- * Removes all entity collection properties. To be used as a re-map key function
14
- */
15
- type ExcludeEntityCollections<T, K extends PropertyKey> = T extends NotEntityBrand[] | undefined ? K : T extends Entity[] | undefined ? never : K;
16
-
17
- /**
18
- * Removes all functions and entity collection properties. To be used as a re-map key function
19
- */
20
- type ExcludeFunctions<T, K extends PropertyKey> = T extends Function ? never : K;
21
-
22
- /**
23
- * Changes all Entity value properties to Primitive (string|number) | Pick<Entity, 'id'>
24
- */
25
- type CreateUpdateParams<T extends Entity> = {
26
- [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'>;
27
- };
2
+ import { E as Entity, a as ExcludeEntityCollections, b as ExcludeFunctions, N as NotEntityBrand, M as ModelMetadata, C as CreateUpdateParams, c as EntityStatic } from './shared/bigal.06e3c45d.js';
3
+ export { h as ColumnBaseMetadata, f as ColumnBaseMetadataOptions, j as ColumnCollectionMetadata, i as ColumnCollectionMetadataOptions, k as ColumnMetadata, m as ColumnModelMetadata, l as ColumnModelMetadataOptions, n as ColumnModifierMetadata, p as ColumnTypeMetadata, o as ColumnTypeMetadataOptions, d as EntityFieldValue, q as ModelMetadataOptions, e as NotEntity, g as getMetadataStorage } from './shared/bigal.06e3c45d.js';
4
+ export { C as ClassLike, c as column, a as createDateColumn, p as primaryColumn, t as table, u as updateDateColumn, v as versionColumn } from './shared/bigal.03669aef.js';
28
5
 
29
6
  type EntityPrimitiveOrId<T> = T extends [] ? T extends (infer U)[] ? EntityPrimitiveOrId<U>[] : T : Extract<NonNullable<T>, Entity> extends undefined ? T : Exclude<NonNullable<T>, Entity> | Pick<Extract<NonNullable<T>, Entity>, 'id'>;
30
7
 
@@ -92,303 +69,6 @@ type QueryResultOptionalPopulated<T extends Entity, K extends keyof T> = Omit<Qu
92
69
  [P in K]-?: T[P] extends [] ? undefined extends T[P] ? EntityPrimitiveOrId<T[P]> | null : EntityPrimitiveOrId<T[P]> : EntityPrimitiveOrId<T[P]>;
93
70
  };
94
71
 
95
- type EntityFieldValue = boolean[] | Date | number[] | Record<string, unknown> | string[] | boolean | number | string | unknown | null;
96
- declare abstract class Entity {
97
- abstract id: unknown;
98
- static beforeCreate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
99
- static beforeUpdate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
100
- }
101
- interface NotEntityBrand {
102
- _notEntityBrand: void;
103
- }
104
- type NotEntity<T> = NotEntityBrand & T;
105
- interface EntityStatic<T extends Entity> {
106
- beforeCreate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
107
- beforeUpdate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
108
- new (): T;
109
- }
110
-
111
- interface ColumnBaseMetadataOptions {
112
- /**
113
- * Name of class with @table decorator
114
- */
115
- target: string;
116
- /**
117
- * Column name in the database
118
- */
119
- name: string;
120
- /**
121
- * Class property to which the column is applied
122
- */
123
- propertyName: string;
124
- /**
125
- * Indicates if a value is required for creates.
126
- */
127
- required?: boolean;
128
- /**
129
- * Indicates if column is inserted by default. Default is true
130
- */
131
- insert?: boolean;
132
- /**
133
- * Indicates if column value is updated by "save" operation. Default is true
134
- */
135
- update?: boolean;
136
- /**
137
- * Indicates if this column is a primary key.
138
- * Same can be achieved when @primaryColumn decorator is used
139
- */
140
- primary?: boolean;
141
- /**
142
- * Value will be equal to `new Date()` when the row is inserted into the table
143
- * Same can be achieved when @createDateColumn decorator is used
144
- */
145
- createDate?: boolean;
146
- /**
147
- * Value will be equal to `new Date()` when the row is updated
148
- * Same can be achieved when @updateDateColumn decorator is used
149
- */
150
- updateDate?: boolean;
151
- /**
152
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
153
- * Same can be achieved when @versionColumn decorator is used
154
- */
155
- version?: boolean;
156
- }
157
- declare abstract class ColumnBaseMetadata {
158
- /**
159
- * Name of class with @table decorator
160
- */
161
- target: string;
162
- /**
163
- * Column name in the database
164
- */
165
- name: string;
166
- /**
167
- * Class property to which the column is applied
168
- */
169
- propertyName: string;
170
- /**
171
- * Indicates if a value is required for creates.
172
- */
173
- required: boolean;
174
- /**
175
- * Indicates if column is inserted by default. Default is true
176
- */
177
- insert: boolean;
178
- /**
179
- * Indicates if column value is updated by "save" operation. Default is true
180
- */
181
- update: boolean;
182
- /**
183
- * Indicates if this column is a primary key.
184
- * Same can be achieved when @primaryColumn decorator is used
185
- */
186
- primary: boolean;
187
- /**
188
- * Value will be equal to `new Date()` when the row is inserted into the table
189
- * Same can be achieved when @createDateColumn decorator is used
190
- */
191
- createDate: boolean;
192
- /**
193
- * Value will be equal to `new Date()` when the row is updated
194
- * Same can be achieved when @updateDateColumn decorator is used
195
- */
196
- updateDate: boolean;
197
- /**
198
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
199
- * Same can be achieved when @versionColumn decorator is used
200
- */
201
- version: boolean;
202
- protected constructor({ target, name, propertyName, required, insert, update, primary, createDate, updateDate, version, }: ColumnBaseMetadataOptions);
203
- }
204
-
205
- interface ColumnCollectionMetadataOptions extends ColumnBaseMetadataOptions {
206
- /**
207
- * Type of the items in the collection
208
- */
209
- collection: string | (() => string);
210
- /**
211
- * Property name of the on the collection item type
212
- */
213
- via: string;
214
- /**
215
- * Name of the junction table for multi-multi associations
216
- */
217
- through?: string | (() => string);
218
- }
219
- declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
220
- private _collectionString?;
221
- private _collectionFn?;
222
- private _throughString?;
223
- private _throughFn?;
224
- /**
225
- * Type of the items in the collection
226
- */
227
- get collection(): string;
228
- /**
229
- * Property name of the on the collection item type
230
- */
231
- via: string;
232
- /**
233
- * Name of the junction table for multi-multi associations
234
- */
235
- get through(): string | undefined;
236
- constructor({ target, //
237
- name, propertyName, required, insert, update, primary, createDate, updateDate, version, collection, via, through, }: ColumnCollectionMetadataOptions);
238
- }
239
-
240
- interface ColumnModelMetadataOptions extends ColumnBaseMetadataOptions {
241
- /**
242
- * Name of the model represented by this column id
243
- */
244
- model: string | (() => string);
245
- }
246
- declare class ColumnModelMetadata extends ColumnBaseMetadata {
247
- private _modelString?;
248
- private _modelFn?;
249
- /**
250
- * Name of the model represented by this column id
251
- */
252
- get model(): string;
253
- constructor({ target, //
254
- name, propertyName, required, insert, update, primary, createDate, updateDate, version, model, }: ColumnModelMetadataOptions);
255
- }
256
-
257
- interface ColumnTypeMetadataOptions extends ColumnBaseMetadataOptions {
258
- /**
259
- * Type of sql column
260
- */
261
- type: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
262
- /**
263
- * Default database value
264
- */
265
- defaultsTo?: boolean[] | number[] | string[] | boolean | number | string | (() => Date | Record<string, unknown> | boolean | number | string) | [];
266
- /**
267
- * Array of possible enumerated values
268
- */
269
- enum?: string[];
270
- /**
271
- * If set, enforces a maximum length check on the column
272
- *
273
- * Applies to types: string | string[]
274
- */
275
- maxLength?: number;
276
- }
277
- declare class ColumnTypeMetadata extends ColumnBaseMetadata {
278
- /**
279
- * Type of the column
280
- */
281
- type: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
282
- /**
283
- * Default database value
284
- */
285
- defaultsTo?: boolean[] | number[] | string[] | boolean | number | string | (() => Date | Record<string, unknown> | boolean | number | string) | [];
286
- /**
287
- * Array of possible enumerated values
288
- */
289
- enum?: string[];
290
- /**
291
- * If set, enforces a maximum length check on the column
292
- *
293
- * Applies to types: string | string[]
294
- */
295
- maxLength?: number;
296
- constructor(options: ColumnTypeMetadataOptions);
297
- }
298
-
299
- type ColumnMetadata = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
300
-
301
- interface ColumnModifierMetadata {
302
- /**
303
- * Name of class with @table decorator
304
- */
305
- target: string;
306
- /**
307
- * Column name in the database
308
- */
309
- name?: string;
310
- /**
311
- * Class property to which the column is applied
312
- */
313
- propertyName: string;
314
- /**
315
- * Indicates if a value is required for creates.
316
- */
317
- required?: boolean;
318
- /**
319
- * Indicates if this column is a primary key.
320
- * Same can be achieved when @primaryColumn decorator is used
321
- */
322
- primary?: boolean;
323
- /**
324
- * Value will be equal to `new Date()` when the row is inserted into the table
325
- * Same can be achieved when @createDateColumn decorator is used
326
- */
327
- createDate?: boolean;
328
- /**
329
- * Value will be equal to `new Date()` when the row is updated
330
- * Same can be achieved when @updateDateColumn decorator is used
331
- */
332
- updateDate?: boolean;
333
- /**
334
- * Value will be set to 1 when the row is inserted. Value will be incremented by one when the row is updated
335
- * Same can be achieved when @versionColumn decorator is used
336
- */
337
- version?: boolean;
338
- /**
339
- * Type of sql column
340
- */
341
- type?: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
342
- /**
343
- * Name of the model represented by this column id
344
- */
345
- model?: string | (() => string);
346
- }
347
-
348
- type Column = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
349
- type ColumnByStringId = Record<string, Column>;
350
- interface ModelMetadataOptions<T extends Entity> {
351
- name: string;
352
- type: EntityStatic<T>;
353
- connection?: string;
354
- tableName?: string;
355
- readonly?: boolean;
356
- }
357
- declare class ModelMetadata<T extends Entity> {
358
- private _columns;
359
- private _primaryKeyColumn;
360
- private _createDateColumns;
361
- private _updateDateColumns;
362
- private _versionDateColumns;
363
- set columns(columns: readonly Column[]);
364
- get columns(): readonly Column[];
365
- get primaryKeyColumn(): Column | undefined;
366
- get createDateColumns(): readonly Column[];
367
- get updateDateColumns(): readonly Column[];
368
- get versionColumns(): readonly Column[];
369
- name: string;
370
- type: EntityStatic<T>;
371
- connection?: string;
372
- tableName: string;
373
- readonly: boolean;
374
- columnsByColumnName: ColumnByStringId;
375
- columnsByPropertyName: ColumnByStringId;
376
- constructor({ name, //
377
- type, connection, tableName, readonly, }: ModelMetadataOptions<T>);
378
- }
379
-
380
- /**
381
- * This represents an object to store all of the decorator data. Since there can be multiple decorators per
382
- * class/property, things will be reconciled when entities are initialized
383
- */
384
- declare class MetadataStorage<T extends Entity> {
385
- readonly models: ModelMetadata<T>[];
386
- readonly columns: ColumnMetadata[];
387
- readonly columnModifiers: ColumnModifierMetadata[];
388
- }
389
-
390
- declare function getMetadataStorage<T extends Entity>(): MetadataStorage<T>;
391
-
392
72
  type ExcludeUndefined<T> = Exclude<T, undefined>;
393
73
  type LiteralValues<TValue> = (TValue | null)[] | TValue | null;
394
74
  type WhereClauseValue<TValue> = TValue extends NotEntityBrand | undefined ? Exclude<TValue, NotEntityBrand | undefined> : Extract<TValue, Entity> extends undefined ? LiteralValues<ExcludeUndefined<TValue>> : (ExcludeUndefined<Exclude<TValue, Entity>> | null)[] | (Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null)[] | ExcludeUndefined<Exclude<TValue, Entity>> | Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null;
@@ -773,101 +453,6 @@ declare class Repository<T extends Entity> extends ReadonlyRepository<T> impleme
773
453
  destroy(where: WhereQuery<T>, options: DeleteOptions<T>): DestroyResult<T, QueryResult<T>[]>;
774
454
  }
775
455
 
776
- interface ColumnBaseOptions {
777
- /**
778
- * Column name in the database
779
- */
780
- name?: string;
781
- /**
782
- * Indicates if a value is required for creates.
783
- */
784
- required?: boolean;
785
- }
786
-
787
- interface ColumnCollectionOptions extends ColumnBaseOptions {
788
- /**
789
- * Type of the items in the collection
790
- */
791
- collection: string | (() => string);
792
- /**
793
- * Property name of the on the collection item type
794
- */
795
- via: string;
796
- /**
797
- * Name of the junction table for multi-multi associations
798
- */
799
- through?: string | (() => string);
800
- }
801
-
802
- interface ColumnModelOptions extends ColumnBaseOptions {
803
- /**
804
- * Type of the entity represented by this column id
805
- */
806
- model: string | (() => string);
807
- }
808
-
809
- interface ColumnTypeOptions extends ColumnBaseOptions {
810
- /**
811
- * Type of the column
812
- */
813
- type: 'array' | 'binary' | 'boolean' | 'boolean[]' | 'date' | 'datetime' | 'float' | 'float[]' | 'integer' | 'integer[]' | 'json' | 'string' | 'string[]';
814
- /**
815
- * Default database value
816
- */
817
- defaultsTo?: boolean[] | number[] | string[] | boolean | number | string | (() => Date | Record<string, unknown> | boolean | number | string) | [];
818
- /**
819
- * Array of possible enumerated values
820
- */
821
- enum?: string[];
822
- /**
823
- * If set, enforces a maximum length check on the column
824
- *
825
- * Applies to types: string | string[]
826
- */
827
- maxLength?: number;
828
- }
829
-
830
- type ColumnOptions$1 = ColumnCollectionOptions | ColumnModelOptions | ColumnTypeOptions;
831
- type ReturnFunctionType$5 = (object: ClassLike, propertyName: string) => void;
832
- declare function column(options?: ColumnOptions$1): ReturnFunctionType$5;
833
- declare function column(dbColumnName: string, options?: ColumnOptions$1): ReturnFunctionType$5;
834
-
835
- type ReturnFunctionType$4 = (object: ClassLike, propertyName: string) => void;
836
- declare function createDateColumn(options?: ColumnTypeOptions): ReturnFunctionType$4;
837
- declare function createDateColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType$4;
838
-
839
- type ColumnOptions = ColumnModelOptions | ColumnTypeOptions;
840
- type ReturnFunctionType$3 = (object: ClassLike, propertyName: string) => void;
841
- declare function primaryColumn(options?: ColumnOptions): ReturnFunctionType$3;
842
- declare function primaryColumn(dbColumnName: string, options?: ColumnOptions): ReturnFunctionType$3;
843
-
844
- interface TableOptions {
845
- /**
846
- * Table name in the database
847
- */
848
- name?: string;
849
- /**
850
- * Connection name to use for queries
851
- */
852
- connection?: string;
853
- /**
854
- * Indicates if create, update, delete statements should be available
855
- */
856
- readonly?: boolean;
857
- }
858
-
859
- type ReturnFunctionType$2 = (object: any) => void;
860
- declare function table(options?: TableOptions): ReturnFunctionType$2;
861
- declare function table(dbName: string, options: TableOptions): ReturnFunctionType$2;
862
-
863
- type ReturnFunctionType$1 = (object: ClassLike, propertyName: string) => void;
864
- declare function updateDateColumn(options?: ColumnTypeOptions): ReturnFunctionType$1;
865
- declare function updateDateColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType$1;
866
-
867
- type ReturnFunctionType = (object: ClassLike, propertyName: string) => void;
868
- declare function versionColumn(options?: ColumnTypeOptions): ReturnFunctionType;
869
- declare function versionColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType;
870
-
871
456
  interface IConnection {
872
457
  pool: Pool;
873
458
  readonlyPool?: Pool;
@@ -889,4 +474,4 @@ interface InitializeOptions extends IConnection {
889
474
  */
890
475
  declare function initialize({ models, pool, readonlyPool, connections, expose }: InitializeOptions): Record<string, IReadonlyRepository<Entity> | IRepository<Entity>>;
891
476
 
892
- export { type ClassLike, ColumnBaseMetadata, type ColumnBaseMetadataOptions, ColumnCollectionMetadata, type ColumnCollectionMetadataOptions, type ColumnMetadata, ColumnModelMetadata, type ColumnModelMetadataOptions, type ColumnModifierMetadata, ColumnTypeMetadata, type ColumnTypeMetadataOptions, type CreateUpdateParams, Entity, type EntityFieldValue, type EntityPrimitiveOrId, type EntityStatic, type ExcludeEntityCollections, type ExcludeFunctions, type GetValueType, type IConnection, type IReadonlyRepository, type IRepository, type IRepositoryOptions, type IncludeFunctions, type InitializeOptions, type IsValueOfType, ModelMetadata, type ModelMetadataOptions, type NotEntity, type NotEntityBrand, type OmitEntityCollections, type OmitFunctions, type PickAsType, type PickByValueType, type PickFunctions, type Populated, type QueryResult, type QueryResultOptionalPopulated, type QueryResultPopulated, ReadonlyRepository, Repository, column, createDateColumn, getMetadataStorage, initialize, primaryColumn, table, updateDateColumn, versionColumn };
477
+ export { CreateUpdateParams, Entity, type EntityPrimitiveOrId, EntityStatic, ExcludeEntityCollections, ExcludeFunctions, type GetValueType, type IConnection, type IReadonlyRepository, type IRepository, type IRepositoryOptions, type IncludeFunctions, type InitializeOptions, type IsValueOfType, ModelMetadata, NotEntityBrand, type OmitEntityCollections, type OmitFunctions, type PickAsType, type PickByValueType, type PickFunctions, type Populated, type QueryResult, type QueryResultOptionalPopulated, type QueryResultPopulated, ReadonlyRepository, Repository, initialize };