bigal 10.4.0-beta1 → 10.4.1
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/CHANGELOG.md +4 -0
- package/Entity.d.ts +2 -2
- package/decorators/column.d.ts +2 -2
- package/decorators/createDateColumn.d.ts +1 -1
- package/decorators/primaryColumn.d.ts +2 -2
- package/decorators/table.d.ts +1 -1
- package/decorators/updateDateColumn.d.ts +1 -1
- package/decorators/versionColumn.d.ts +1 -1
- package/metadata/ColumnCollectionMetadata.js +27 -27
- package/metadata/ColumnCollectionMetadata.js.map +1 -1
- package/metadata/ColumnMetadata.d.ts +1 -1
- package/metadata/ColumnModelMetadata.js +14 -14
- package/metadata/ColumnModelMetadata.js.map +1 -1
- package/metadata/ModelMetadata.d.ts +2 -2
- package/metadata/ModelMetadata.js +14 -14
- package/metadata/ModelMetadata.js.map +1 -1
- package/package.json +14 -14
- package/query/Comparer.d.ts +1 -1
- package/query/CreateOptions.d.ts +3 -3
- package/query/CreateUpdateOptions.d.ts +1 -1
- package/query/DeleteOptions.d.ts +1 -1
- package/query/OnConflictOptions.d.ts +2 -2
- package/query/Sort.d.ts +6 -6
- package/query/WhereQuery.d.ts +8 -8
- package/types/CreateUpdateParams.d.ts +1 -1
- package/types/EntityPrimitiveOrId.d.ts +1 -1
- package/types/ExcludeEntityCollections.d.ts +1 -1
- package/types/ExcludeFunctions.d.ts +1 -1
- package/types/GetValueType.d.ts +1 -1
- package/types/IncludeFunctions.d.ts +1 -1
- package/types/IsValueOfType.d.ts +1 -1
- package/types/OmitEntityCollections.d.ts +1 -1
- package/types/OmitFunctions.d.ts +1 -1
- package/types/PickAsType.d.ts +1 -1
- package/types/PickByValueType.d.ts +1 -1
- package/types/PickFunctions.d.ts +1 -1
- package/types/Populated.d.ts +1 -1
- package/types/QueryResult.d.ts +1 -1
- package/types/QueryResultOptionalPopulated.d.ts +1 -1
- package/types/QueryResultPopulated.d.ts +1 -1
package/CHANGELOG.md
CHANGED
package/Entity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CreateUpdateParams } from './types';
|
|
2
|
-
export
|
|
2
|
+
export type EntityFieldValue = boolean[] | Date | number[] | Record<string, unknown> | string[] | boolean | number | string | unknown | null;
|
|
3
3
|
export declare abstract class Entity {
|
|
4
4
|
abstract id: unknown;
|
|
5
5
|
static beforeCreate(values: CreateUpdateParams<Entity>): CreateUpdateParams<Entity> | Promise<CreateUpdateParams<Entity>>;
|
|
@@ -8,7 +8,7 @@ export declare abstract class Entity {
|
|
|
8
8
|
export interface NotEntityBrand {
|
|
9
9
|
_notEntityBrand: void;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type NotEntity<T> = NotEntityBrand & T;
|
|
12
12
|
export interface EntityStatic<T extends Entity> {
|
|
13
13
|
beforeCreate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
|
|
14
14
|
beforeUpdate?: (values: CreateUpdateParams<any>) => CreateUpdateParams<any> | Promise<CreateUpdateParams<any>>;
|
package/decorators/column.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ColumnCollectionOptions } from './ColumnCollectionOptions';
|
|
2
2
|
import type { ColumnModelOptions } from './ColumnModelOptions';
|
|
3
3
|
import type { ColumnTypeOptions } from './ColumnTypeOptions';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type ColumnOptions = ColumnCollectionOptions | ColumnModelOptions | ColumnTypeOptions;
|
|
5
|
+
type ReturnFunctionType = (object: object, propertyName: string) => void;
|
|
6
6
|
export declare function column(options?: ColumnOptions): ReturnFunctionType;
|
|
7
7
|
export declare function column(dbColumnName: string, options?: ColumnOptions): ReturnFunctionType;
|
|
8
8
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColumnTypeOptions } from './ColumnTypeOptions';
|
|
2
|
-
|
|
2
|
+
type ReturnFunctionType = (object: object, propertyName: string) => void;
|
|
3
3
|
export declare function createDateColumn(options?: ColumnTypeOptions): ReturnFunctionType;
|
|
4
4
|
export declare function createDateColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType;
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ColumnModelOptions } from './ColumnModelOptions';
|
|
2
2
|
import type { ColumnTypeOptions } from './ColumnTypeOptions';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type ColumnOptions = ColumnModelOptions | ColumnTypeOptions;
|
|
4
|
+
type ReturnFunctionType = (object: object, propertyName: string) => void;
|
|
5
5
|
export declare function primaryColumn(options?: ColumnOptions): ReturnFunctionType;
|
|
6
6
|
export declare function primaryColumn(dbColumnName: string, options?: ColumnOptions): ReturnFunctionType;
|
|
7
7
|
export {};
|
package/decorators/table.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TableOptions } from './TableOptions';
|
|
2
|
-
|
|
2
|
+
type ReturnFunctionType = (object: any) => void;
|
|
3
3
|
export declare function table(options?: TableOptions): ReturnFunctionType;
|
|
4
4
|
export declare function table(dbName: string, options: TableOptions): ReturnFunctionType;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColumnTypeOptions } from './ColumnTypeOptions';
|
|
2
|
-
|
|
2
|
+
type ReturnFunctionType = (object: object, propertyName: string) => void;
|
|
3
3
|
export declare function updateDateColumn(options?: ColumnTypeOptions): ReturnFunctionType;
|
|
4
4
|
export declare function updateDateColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType;
|
|
5
5
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ColumnTypeOptions } from './ColumnTypeOptions';
|
|
2
|
-
|
|
2
|
+
type ReturnFunctionType = (object: object, propertyName: string) => void;
|
|
3
3
|
export declare function versionColumn(options?: ColumnTypeOptions): ReturnFunctionType;
|
|
4
4
|
export declare function versionColumn(dbColumnName: string, options?: ColumnTypeOptions): ReturnFunctionType;
|
|
5
5
|
export {};
|
|
@@ -3,6 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ColumnCollectionMetadata = void 0;
|
|
4
4
|
const ColumnBaseMetadata_1 = require("./ColumnBaseMetadata");
|
|
5
5
|
class ColumnCollectionMetadata extends ColumnBaseMetadata_1.ColumnBaseMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* Type of the items in the collection
|
|
8
|
+
*/
|
|
9
|
+
get collection() {
|
|
10
|
+
if (this._collectionString) {
|
|
11
|
+
return this._collectionString;
|
|
12
|
+
}
|
|
13
|
+
if (!this._collectionFn) {
|
|
14
|
+
throw new Error(`Unable to determine collection type for ${this.target}#${this.propertyName}`);
|
|
15
|
+
}
|
|
16
|
+
// Need to defer evaluation until runtime to avoid cyclical dependency issues.
|
|
17
|
+
this._collectionString = this._collectionFn();
|
|
18
|
+
return this._collectionString;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Name of the junction table for multi-multi associations
|
|
22
|
+
*/
|
|
23
|
+
get through() {
|
|
24
|
+
if (this._throughString) {
|
|
25
|
+
return this._throughString;
|
|
26
|
+
}
|
|
27
|
+
if (this._throughFn) {
|
|
28
|
+
this._throughString = this._throughFn();
|
|
29
|
+
return this._throughString;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
6
33
|
constructor({ target, //
|
|
7
34
|
name, propertyName, required, insert, update, primary, createDate, updateDate, version, collection, via, through, }) {
|
|
8
35
|
super({
|
|
@@ -31,33 +58,6 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata_1.ColumnBaseMetadata {
|
|
|
31
58
|
this._throughFn = through;
|
|
32
59
|
}
|
|
33
60
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Type of the items in the collection
|
|
36
|
-
*/
|
|
37
|
-
get collection() {
|
|
38
|
-
if (this._collectionString) {
|
|
39
|
-
return this._collectionString;
|
|
40
|
-
}
|
|
41
|
-
if (!this._collectionFn) {
|
|
42
|
-
throw new Error(`Unable to determine collection type for ${this.target}#${this.propertyName}`);
|
|
43
|
-
}
|
|
44
|
-
// Need to defer evaluation until runtime to avoid cyclical dependency issues.
|
|
45
|
-
this._collectionString = this._collectionFn();
|
|
46
|
-
return this._collectionString;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Name of the junction table for multi-multi associations
|
|
50
|
-
*/
|
|
51
|
-
get through() {
|
|
52
|
-
if (this._throughString) {
|
|
53
|
-
return this._throughString;
|
|
54
|
-
}
|
|
55
|
-
if (this._throughFn) {
|
|
56
|
-
this._throughString = this._throughFn();
|
|
57
|
-
return this._throughString;
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
61
|
}
|
|
62
62
|
exports.ColumnCollectionMetadata = ColumnCollectionMetadata;
|
|
63
63
|
//# sourceMappingURL=ColumnCollectionMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnCollectionMetadata.js","sourceRoot":"./","sources":["metadata/ColumnCollectionMetadata.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAiB1D,MAAa,wBAAyB,SAAQ,uCAAkB;
|
|
1
|
+
{"version":3,"file":"ColumnCollectionMetadata.js","sourceRoot":"./","sources":["metadata/ColumnCollectionMetadata.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAiB1D,MAAa,wBAAyB,SAAQ,uCAAkB;IAS9D;;OAEG;IACH,IAAW,UAAU;QACnB,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,OAAO,IAAI,CAAC,iBAAiB,CAAC;SAC/B;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;SAChG;QAED,8EAA8E;QAC9E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAOD;;OAEG;IACH,IAAW,OAAO;QAChB,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,cAAc,CAAC;SAC5B;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,YAAmB,EACjB,MAAM,EAAE,EAAE;IACV,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,OAAO,EACP,UAAU,EACV,GAAG,EACH,OAAO,GACyB;QAChC,KAAK,CAAC;YACJ,MAAM;YACN,IAAI;YACJ,YAAY;YACZ,QAAQ;YACR,MAAM;YACN,MAAM;YACN,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC;SACrC;aAAM;YACL,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC;SACjC;QAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;SAC/B;aAAM,IAAI,OAAO,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;SAC3B;IACH,CAAC;CACF;AAzFD,4DAyFC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ColumnCollectionMetadata } from './ColumnCollectionMetadata';
|
|
2
2
|
import type { ColumnModelMetadata } from './ColumnModelMetadata';
|
|
3
3
|
import type { ColumnTypeMetadata } from './ColumnTypeMetadata';
|
|
4
|
-
export
|
|
4
|
+
export type ColumnMetadata = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
|
|
@@ -3,6 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ColumnModelMetadata = void 0;
|
|
4
4
|
const ColumnBaseMetadata_1 = require("./ColumnBaseMetadata");
|
|
5
5
|
class ColumnModelMetadata extends ColumnBaseMetadata_1.ColumnBaseMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the model represented by this column id
|
|
8
|
+
*/
|
|
9
|
+
get model() {
|
|
10
|
+
if (this._modelString) {
|
|
11
|
+
return this._modelString;
|
|
12
|
+
}
|
|
13
|
+
if (!this._modelFn) {
|
|
14
|
+
throw new Error(`Unable to determine model type for ${this.target}#${this.propertyName}`);
|
|
15
|
+
}
|
|
16
|
+
// Need to defer evaluation until runtime to avoid cyclical dependency issues.
|
|
17
|
+
this._modelString = this._modelFn();
|
|
18
|
+
return this._modelString;
|
|
19
|
+
}
|
|
6
20
|
constructor({ target, //
|
|
7
21
|
name, propertyName, required, insert, update, primary, createDate, updateDate, version, model, }) {
|
|
8
22
|
super({
|
|
@@ -24,20 +38,6 @@ class ColumnModelMetadata extends ColumnBaseMetadata_1.ColumnBaseMetadata {
|
|
|
24
38
|
this._modelFn = model;
|
|
25
39
|
}
|
|
26
40
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Name of the model represented by this column id
|
|
29
|
-
*/
|
|
30
|
-
get model() {
|
|
31
|
-
if (this._modelString) {
|
|
32
|
-
return this._modelString;
|
|
33
|
-
}
|
|
34
|
-
if (!this._modelFn) {
|
|
35
|
-
throw new Error(`Unable to determine model type for ${this.target}#${this.propertyName}`);
|
|
36
|
-
}
|
|
37
|
-
// Need to defer evaluation until runtime to avoid cyclical dependency issues.
|
|
38
|
-
this._modelString = this._modelFn();
|
|
39
|
-
return this._modelString;
|
|
40
|
-
}
|
|
41
41
|
}
|
|
42
42
|
exports.ColumnModelMetadata = ColumnModelMetadata;
|
|
43
43
|
//# sourceMappingURL=ColumnModelMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnModelMetadata.js","sourceRoot":"./","sources":["metadata/ColumnModelMetadata.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAS1D,MAAa,mBAAoB,SAAQ,uCAAkB;
|
|
1
|
+
{"version":3,"file":"ColumnModelMetadata.js","sourceRoot":"./","sources":["metadata/ColumnModelMetadata.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAS1D,MAAa,mBAAoB,SAAQ,uCAAkB;IAKzD;;OAEG;IACH,IAAW,KAAK;QACd,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO,IAAI,CAAC,YAAY,CAAC;SAC1B;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;SAC3F;QAED,8EAA8E;QAC9E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,YAAmB,EACjB,MAAM,EAAE,EAAE;IACV,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,OAAO,EACP,KAAK,GACsB;QAC3B,KAAK,CAAC;YACJ,MAAM;YACN,IAAI;YACJ,YAAY;YACZ,QAAQ;YACR,MAAM;YACN,MAAM;YACN,OAAO;YACP,UAAU;YACV,UAAU;YACV,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACvB;IACH,CAAC;CACF;AAtDD,kDAsDC"}
|
|
@@ -2,8 +2,8 @@ import type { Entity, EntityStatic } from '../Entity';
|
|
|
2
2
|
import type { ColumnCollectionMetadata } from './ColumnCollectionMetadata';
|
|
3
3
|
import type { ColumnModelMetadata } from './ColumnModelMetadata';
|
|
4
4
|
import type { ColumnTypeMetadata } from './ColumnTypeMetadata';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type Column = ColumnCollectionMetadata | ColumnModelMetadata | ColumnTypeMetadata;
|
|
6
|
+
type ColumnByStringId = Record<string, Column>;
|
|
7
7
|
export interface ModelMetadataOptions<T extends Entity> {
|
|
8
8
|
name: string;
|
|
9
9
|
type: EntityStatic<T>;
|
|
@@ -26,20 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ModelMetadata = void 0;
|
|
27
27
|
const _ = __importStar(require("lodash"));
|
|
28
28
|
class ModelMetadata {
|
|
29
|
-
constructor({ name, //
|
|
30
|
-
type, connection, tableName, readonly = false, }) {
|
|
31
|
-
this._columns = [];
|
|
32
|
-
this._createDateColumns = [];
|
|
33
|
-
this._updateDateColumns = [];
|
|
34
|
-
this._versionDateColumns = [];
|
|
35
|
-
this.columnsByColumnName = {};
|
|
36
|
-
this.columnsByPropertyName = {};
|
|
37
|
-
this.name = name;
|
|
38
|
-
this.type = type;
|
|
39
|
-
this.connection = connection;
|
|
40
|
-
this.tableName = tableName || _.snakeCase(name);
|
|
41
|
-
this.readonly = readonly;
|
|
42
|
-
}
|
|
43
29
|
set columns(columns) {
|
|
44
30
|
this._columns = columns;
|
|
45
31
|
this.columnsByColumnName = {};
|
|
@@ -76,6 +62,20 @@ class ModelMetadata {
|
|
|
76
62
|
get versionColumns() {
|
|
77
63
|
return this._versionDateColumns;
|
|
78
64
|
}
|
|
65
|
+
constructor({ name, //
|
|
66
|
+
type, connection, tableName, readonly = false, }) {
|
|
67
|
+
this._columns = [];
|
|
68
|
+
this._createDateColumns = [];
|
|
69
|
+
this._updateDateColumns = [];
|
|
70
|
+
this._versionDateColumns = [];
|
|
71
|
+
this.columnsByColumnName = {};
|
|
72
|
+
this.columnsByPropertyName = {};
|
|
73
|
+
this.name = name;
|
|
74
|
+
this.type = type;
|
|
75
|
+
this.connection = connection;
|
|
76
|
+
this.tableName = tableName || _.snakeCase(name);
|
|
77
|
+
this.readonly = readonly;
|
|
78
|
+
}
|
|
79
79
|
}
|
|
80
80
|
exports.ModelMetadata = ModelMetadata;
|
|
81
81
|
//# sourceMappingURL=ModelMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelMetadata.js","sourceRoot":"./","sources":["metadata/ModelMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAmB5B,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"ModelMetadata.js","sourceRoot":"./","sources":["metadata/ModelMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAmB5B,MAAa,aAAa;IAWxB,IAAW,OAAO,CAAC,OAA0B;QAC3C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAEhC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YAC/C,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;YAEzD,IAAI,MAAM,CAAC,OAAO,EAAE;gBAClB,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;aACjC;YAED,IAAI,MAAM,CAAC,UAAU,EAAE;gBACrB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtC;YAED,IAAI,MAAM,CAAC,UAAU,EAAE;gBACrB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtC;YAED,IAAI,MAAM,CAAC,OAAO,EAAE;gBAClB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACvC;SACF;IACH,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAgBD,YAAmB,EACjB,IAAI,EAAE,EAAE;IACR,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAQ,GAAG,KAAK,GACQ;QA7ElB,aAAQ,GAAsB,EAAE,CAAC;QAIjC,uBAAkB,GAAa,EAAE,CAAC;QAElC,uBAAkB,GAAa,EAAE,CAAC;QAElC,wBAAmB,GAAa,EAAE,CAAC;QA2DpC,wBAAmB,GAAqB,EAAE,CAAC;QAE3C,0BAAqB,GAAqB,EAAE,CAAC;QASlD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AArFD,sCAqFC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bigal",
|
|
3
|
-
"version": "10.4.
|
|
3
|
+
"version": "10.4.1",
|
|
4
4
|
"description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,42 +19,42 @@
|
|
|
19
19
|
"node": ">=14"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@types/lodash": "^4.14.
|
|
22
|
+
"@types/lodash": "^4.14.191",
|
|
23
23
|
"@types/node": ">=14",
|
|
24
24
|
"@types/pg": "^8.6.5",
|
|
25
25
|
"lodash": "^4.17.21",
|
|
26
26
|
"pg": "^8.8.0",
|
|
27
|
-
"postgres-pool": "^6.0.
|
|
27
|
+
"postgres-pool": "^6.0.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@faker-js/faker": "^7.6.0",
|
|
31
|
-
"@types/chai": "^4.3.
|
|
32
|
-
"@types/mocha": "10.0.
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
34
|
-
"@typescript-eslint/parser": "^5.
|
|
35
|
-
"chai": "^4.3.
|
|
36
|
-
"eslint": "^8.
|
|
31
|
+
"@types/chai": "^4.3.4",
|
|
32
|
+
"@types/mocha": "10.0.1",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.45.1",
|
|
34
|
+
"@typescript-eslint/parser": "^5.45.1",
|
|
35
|
+
"chai": "^4.3.7",
|
|
36
|
+
"eslint": "^8.29.0",
|
|
37
37
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
38
38
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
39
39
|
"eslint-config-prettier": "^8.5.0",
|
|
40
40
|
"eslint-plugin-import": "^2.26.0",
|
|
41
|
-
"eslint-plugin-jsdoc": "^39.6.
|
|
41
|
+
"eslint-plugin-jsdoc": "^39.6.4",
|
|
42
42
|
"eslint-plugin-mocha": "10.1.0",
|
|
43
43
|
"eslint-plugin-prettier": "^4.2.1",
|
|
44
44
|
"eslint-plugin-promise": "^6.1.1",
|
|
45
45
|
"eslint-plugin-security": "^1.5.0",
|
|
46
|
-
"husky": "^8.0.
|
|
47
|
-
"lint-staged": "^13.0
|
|
46
|
+
"husky": "^8.0.2",
|
|
47
|
+
"lint-staged": "^13.1.0",
|
|
48
48
|
"markdownlint-cli": "^0.32.2",
|
|
49
49
|
"mocha": "^10.1.0",
|
|
50
50
|
"npm-run-all": "^4.1.5",
|
|
51
51
|
"pinst": "^3.0.0",
|
|
52
|
-
"prettier": "^2.
|
|
52
|
+
"prettier": "^2.8.0",
|
|
53
53
|
"rimraf": "^3.0.2",
|
|
54
54
|
"strict-event-emitter-types": "^2.0.0",
|
|
55
55
|
"ts-mockito": "^2.6.1",
|
|
56
56
|
"ts-node": "^10.9.1",
|
|
57
|
-
"typescript": "^4.
|
|
57
|
+
"typescript": "^4.9.3"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"check:types": "tsc -p tsconfig.lint.json --noEmit",
|
package/query/Comparer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Comparer = '!' | '<' | '<=' | '>' | '>=' | 'contains' | 'endsWith' | 'like' | 'or' | 'startsWith';
|
package/query/CreateOptions.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { OmitEntityCollections, OmitFunctions } from '../types';
|
|
|
3
3
|
import type { DoNotReturnRecords } from './DoNotReturnRecords';
|
|
4
4
|
import type { OnConflictOptions } from './OnConflictOptions';
|
|
5
5
|
import type { ReturnSelect } from './ReturnSelect';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
6
|
+
type CreateOnConflictOptions<T extends Entity, K extends string & keyof OmitFunctions<OmitEntityCollections<T>> = string & keyof OmitFunctions<OmitEntityCollections<T>>> = OnConflictOptions<T, K> & Partial<DoNotReturnRecords | ReturnSelect<T>>;
|
|
7
|
+
type CreateOptionalOnConflictOptions<T extends Entity, K extends string & keyof OmitFunctions<OmitEntityCollections<T>> = string & keyof OmitFunctions<OmitEntityCollections<T>>> = Partial<OnConflictOptions<T, K>> & (DoNotReturnRecords | ReturnSelect<T>);
|
|
8
|
+
export type CreateOptions<T extends Entity, K extends string & keyof OmitFunctions<OmitEntityCollections<T>> = string & keyof OmitFunctions<OmitEntityCollections<T>>> = CreateOnConflictOptions<T, K> | CreateOptionalOnConflictOptions<T, K>;
|
|
9
9
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Entity } from '../Entity';
|
|
2
2
|
import type { DoNotReturnRecords } from './DoNotReturnRecords';
|
|
3
3
|
import type { ReturnSelect } from './ReturnSelect';
|
|
4
|
-
export
|
|
4
|
+
export type CreateUpdateOptions<T extends Entity> = DoNotReturnRecords | ReturnSelect<T>;
|
package/query/DeleteOptions.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ interface ReturnRecords<T extends Entity, K extends keyof T> {
|
|
|
8
8
|
returnRecords: true;
|
|
9
9
|
returnSelect?: (K & string & keyof OmitFunctions<OmitEntityCollections<T>>)[];
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type DeleteOptions<T extends Entity, K extends keyof T = keyof T> = ReturnRecords<T, K> | ReturnSelect<T, K>;
|
|
12
12
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Entity } from '../Entity';
|
|
2
2
|
import type { OmitEntityCollections, OmitFunctions } from '../types';
|
|
3
3
|
import type { WhereQuery } from './WhereQuery';
|
|
4
|
-
|
|
4
|
+
type OnConflictTargets<T extends Entity, K extends string & keyof OmitFunctions<OmitEntityCollections<T>> = string & keyof OmitFunctions<OmitEntityCollections<T>>> = K[] | {
|
|
5
5
|
columns: K[];
|
|
6
6
|
where: WhereQuery<T>;
|
|
7
7
|
};
|
|
@@ -21,5 +21,5 @@ export interface OnConflictMergeOptions<T extends Entity, K extends string & key
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type OnConflictOptions<T extends Entity, K extends string & keyof OmitFunctions<OmitEntityCollections<T>> = string & keyof OmitFunctions<OmitEntityCollections<T>>> = OnConflictIgnoreOptions<T, K> | OnConflictMergeOptions<T, K>;
|
|
25
25
|
export {};
|
package/query/Sort.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Entity } from '../Entity';
|
|
2
2
|
import type { ExcludeFunctions, OmitEntityCollections, OmitFunctions } from '../types';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
3
|
+
export type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>}`;
|
|
4
|
+
type ValidateMultipleSorts<T extends Entity, TNextSortPart extends string, TPreviouslyValidatedSortString extends string, TSortString extends string> = TNextSortPart extends `, ${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TNextSortPart extends `${infer TValidatedSortPart}${TRestSortPart}` ? `${TPreviouslyValidatedSortString}${TValidatedSortPart}` : never, TSortString> : `${TPreviouslyValidatedSortString}, ${SortString<T>}`;
|
|
5
|
+
export type MultipleSortString<T extends Entity, TSortString extends string = string> = TSortString extends `${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TSortString extends `${infer TPreviouslyValidatedSortString}${TRestSortPart}` ? TPreviouslyValidatedSortString : never, TSortString> : SortString<T>;
|
|
6
|
+
export type SortObjectValue = -1 | 'asc' | 'desc' | 1;
|
|
7
|
+
export type SortObject<T extends Entity> = {
|
|
8
8
|
[K in keyof T as ExcludeFunctions<OmitEntityCollections<T>, K>]?: SortObjectValue;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type Sort<T extends Entity> = MultipleSortString<T> | SortObject<T>;
|
|
11
11
|
export interface OrderBy<T extends Entity> {
|
|
12
12
|
propertyName: string & keyof OmitFunctions<OmitEntityCollections<T>>;
|
|
13
13
|
descending?: boolean;
|
package/query/WhereQuery.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { Entity, NotEntityBrand } from '../Entity';
|
|
2
2
|
import type { ExcludeEntityCollections, ExcludeFunctions } from '../types';
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
4
|
+
export type LiteralValues<TValue> = (TValue | null)[] | TValue | null;
|
|
5
|
+
export 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;
|
|
6
|
+
export type StringConstraint<TValue extends string> = {
|
|
7
7
|
[P in 'contains' | 'endsWith' | 'like' | 'startsWith']?: LiteralValues<ExcludeUndefined<TValue>>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type NumberOrDateConstraint<TValue extends Date | number> = {
|
|
10
10
|
[P in '<' | '<=' | '>' | '>=']?: LiteralValues<ExcludeUndefined<TValue>>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type NegatableConstraint<TValue> = TValue | {
|
|
13
13
|
'!': TValue;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type WhereQueryStatement<TValue> = [TValue] extends [string] ? NegatableConstraint<StringConstraint<TValue> | WhereClauseValue<TValue>> : TValue extends string ? NegatableConstraint<StringConstraint<TValue> | WhereClauseValue<TValue>> : TValue extends Date | number ? NegatableConstraint<NumberOrDateConstraint<TValue> | WhereClauseValue<TValue>> : NegatableConstraint<WhereClauseValue<TValue>>;
|
|
16
|
+
export type WhereQuery<T extends Entity> = {
|
|
17
17
|
[K in keyof T as ExcludeEntityCollections<T[K], ExcludeFunctions<T[K], K>>]?: K extends 'id' ? WhereQueryStatement<T | T[K]> : T[K] extends (infer U)[] | undefined ? WhereQueryStatement<ExcludeUndefined<U>> : NegatableConstraint<LiteralValues<ExcludeUndefined<T[K]>>> | WhereQueryStatement<ExcludeUndefined<T[K]>>;
|
|
18
18
|
} & {
|
|
19
19
|
or?: WhereQuery<T>[];
|
|
@@ -4,6 +4,6 @@ import type { ExcludeFunctions } from './ExcludeFunctions';
|
|
|
4
4
|
/**
|
|
5
5
|
* Changes all Entity value properties to Primitive (string|number) | Pick<Entity, 'id'>
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type CreateUpdateParams<T extends Entity> = {
|
|
8
8
|
[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'>;
|
|
9
9
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Entity } from '../Entity';
|
|
2
|
-
export
|
|
2
|
+
export 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'>;
|
|
@@ -2,4 +2,4 @@ import type { Entity, NotEntityBrand } from '../Entity';
|
|
|
2
2
|
/**
|
|
3
3
|
* Removes all entity collection properties. To be used as a re-map key function
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type ExcludeEntityCollections<T, K extends PropertyKey> = T extends NotEntityBrand[] | undefined ? K : T extends Entity[] | undefined ? never : K;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Removes all functions and entity collection properties. To be used as a re-map key function
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ExcludeFunctions<T, K extends PropertyKey> = T extends Function ? never : K;
|
package/types/GetValueType.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GetValueType<T, TValueType> = T extends TValueType[] ? T extends (infer U)[] ? Extract<U, TValueType> : never : T extends TValueType ? T : never;
|
package/types/IsValueOfType.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type IsValueOfType<T, K extends PropertyKey, TValueType> = T extends TValueType | TValueType[] | undefined ? K : never;
|
|
@@ -2,6 +2,6 @@ import type { ExcludeEntityCollections } from './ExcludeEntityCollections';
|
|
|
2
2
|
/**
|
|
3
3
|
* Removes all entity collection properties
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type OmitEntityCollections<T> = {
|
|
6
6
|
[K in keyof T as ExcludeEntityCollections<T[K], K>]: T[K];
|
|
7
7
|
};
|
package/types/OmitFunctions.d.ts
CHANGED
package/types/PickAsType.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GetValueType } from './GetValueType';
|
|
2
2
|
import type { IsValueOfType } from './IsValueOfType';
|
|
3
|
-
export
|
|
3
|
+
export type PickByValueType<T, TValueType> = {
|
|
4
4
|
[K in keyof T as IsValueOfType<T[K], K, TValueType>]: GetValueType<T[K], TValueType>;
|
|
5
5
|
};
|
package/types/PickFunctions.d.ts
CHANGED
package/types/Populated.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import type { QueryResult } from './QueryResult';
|
|
|
4
4
|
/**
|
|
5
5
|
* Removes primitives from specified properties and make non-optional. Allow singular Entity properties to be null.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Populated<T extends Entity, K extends keyof T, TPropertyType extends Entity, TPropertyKeys extends keyof TPropertyType> = {
|
|
8
8
|
[P in K]-?: Extract<T[P], Entity | Entity[]> extends Entity ? undefined extends T[P] ? QueryResult<Pick<TPropertyType, TPropertyKeys | keyof PickFunctions<TPropertyType> | 'id'>> | null : QueryResult<Pick<TPropertyType, TPropertyKeys | keyof PickFunctions<TPropertyType> | 'id'>> : QueryResult<Pick<TPropertyType, TPropertyKeys | keyof PickFunctions<TPropertyType> | 'id'>>[];
|
|
9
9
|
};
|
package/types/QueryResult.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import type { ExcludeEntityCollections } from './ExcludeEntityCollections';
|
|
|
4
4
|
* Changes all properties with Entity values to Primitive (string|number). Removes any properties that with values
|
|
5
5
|
* of Entity arrays
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type QueryResult<T extends Entity> = Extract<{
|
|
8
8
|
[K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, K>]: T[K] extends NotEntityBrand | undefined ? T[K] : Exclude<T[K], Entity>;
|
|
9
9
|
}, T>;
|
|
@@ -4,6 +4,6 @@ import type { QueryResult } from './QueryResult';
|
|
|
4
4
|
/**
|
|
5
5
|
* Allows a QueryResult type with specific properties optionally populated. If the property is populated, only the id property is needed
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type QueryResultOptionalPopulated<T extends Entity, K extends keyof T> = Omit<QueryResult<T>, K> & {
|
|
8
8
|
[P in K]-?: T[P] extends [] ? undefined extends T[P] ? EntityPrimitiveOrId<T[P]> | null : EntityPrimitiveOrId<T[P]> : EntityPrimitiveOrId<T[P]>;
|
|
9
9
|
};
|
|
@@ -4,6 +4,6 @@ import type { QueryResult } from './QueryResult';
|
|
|
4
4
|
/**
|
|
5
5
|
* Allows a QueryResult type with specific populated properties
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type QueryResultPopulated<T extends Entity, K extends keyof T> = Omit<QueryResult<T>, K> & {
|
|
8
8
|
[P in K]-?: Extract<T[P], Entity | Entity[]> extends Entity ? undefined extends T[P] ? QueryResult<GetValueType<T[P], Entity>> | null : QueryResult<GetValueType<T[P], Entity>> : QueryResult<GetValueType<T[P], Entity>>[];
|
|
9
9
|
};
|