• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

typeorm / typeorm / 14796576772

02 May 2025 01:52PM UTC coverage: 45.367% (-30.9%) from 76.309%
14796576772

Pull #11434

github

web-flow
Merge ec4ce2d00 into fadad1a74
Pull Request #11434: feat: release PR releases using pkg.pr.new

5216 of 12761 branches covered (40.87%)

Branch coverage included in aggregate %.

11439 of 23951 relevant lines covered (47.76%)

15712.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/src/util/InstanceChecker.ts
1
import type { MongoEntityManager } from "../entity-manager/MongoEntityManager"
2
import type { SqljsEntityManager } from "../entity-manager/SqljsEntityManager"
3
import type { EntitySchema } from "../entity-schema/EntitySchema"
4
import type { FindOperator } from "../find-options/FindOperator"
5
import type { EqualOperator } from "../find-options/EqualOperator"
6
import type { Query } from "../driver/Query"
7
import type { RdbmsSchemaBuilder } from "../schema-builder/RdbmsSchemaBuilder"
8
import type { Subject } from "../persistence/Subject"
9
import type { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder"
10
import type { UpdateQueryBuilder } from "../query-builder/UpdateQueryBuilder"
11
import type { DeleteQueryBuilder } from "../query-builder/DeleteQueryBuilder"
12
import type { SoftDeleteQueryBuilder } from "../query-builder/SoftDeleteQueryBuilder"
13
import type { InsertQueryBuilder } from "../query-builder/InsertQueryBuilder"
14
import type { RelationQueryBuilder } from "../query-builder/RelationQueryBuilder"
15
import type { Brackets } from "../query-builder/Brackets"
16
import type { Table } from "../schema-builder/table/Table"
17
import type { TableCheck } from "../schema-builder/table/TableCheck"
18
import type { TableColumn } from "../schema-builder/table/TableColumn"
19
import type { TableExclusion } from "../schema-builder/table/TableExclusion"
20
import type { TableForeignKey } from "../schema-builder/table/TableForeignKey"
21
import type { TableIndex } from "../schema-builder/table/TableIndex"
22
import type { TableUnique } from "../schema-builder/table/TableUnique"
23
import type { View } from "../schema-builder/view/View"
24
import type { NotBrackets } from "../query-builder/NotBrackets"
25
import type { EntityMetadata } from "../metadata/EntityMetadata"
26
import type { ColumnMetadata } from "../metadata/ColumnMetadata"
27
import type { MssqlParameter } from "../driver/sqlserver/MssqlParameter"
28
import { DataSource } from "../data-source"
29
import { BaseEntity } from "../repository/BaseEntity"
30

31
export class InstanceChecker {
36✔
32
    static isMssqlParameter(obj: unknown): obj is MssqlParameter {
33
        return this.check(obj, "MssqlParameter")
×
34
    }
35
    static isEntityMetadata(obj: unknown): obj is EntityMetadata {
36
        return this.check(obj, "EntityMetadata")
1,204,593✔
37
    }
38
    static isColumnMetadata(obj: unknown): obj is ColumnMetadata {
39
        return this.check(obj, "ColumnMetadata")
76,103✔
40
    }
41
    static isSelectQueryBuilder(obj: unknown): obj is SelectQueryBuilder<any> {
42
        return this.check(obj, "SelectQueryBuilder")
24✔
43
    }
44
    static isInsertQueryBuilder(obj: unknown): obj is InsertQueryBuilder<any> {
45
        return this.check(obj, "InsertQueryBuilder")
35,461✔
46
    }
47
    static isDeleteQueryBuilder(obj: unknown): obj is DeleteQueryBuilder<any> {
48
        return this.check(obj, "DeleteQueryBuilder")
517✔
49
    }
50
    static isUpdateQueryBuilder(obj: unknown): obj is UpdateQueryBuilder<any> {
51
        return this.check(obj, "UpdateQueryBuilder")
2,366✔
52
    }
53
    static isSoftDeleteQueryBuilder(
54
        obj: unknown,
55
    ): obj is SoftDeleteQueryBuilder<any> {
56
        return this.check(obj, "SoftDeleteQueryBuilder")
148✔
57
    }
58
    static isRelationQueryBuilder(
59
        obj: unknown,
60
    ): obj is RelationQueryBuilder<any> {
61
        return this.check(obj, "RelationQueryBuilder")
276✔
62
    }
63
    static isBrackets(obj: unknown): obj is Brackets {
64
        return this.check(obj, "Brackets") || this.check(obj, "NotBrackets")
26,944✔
65
    }
66
    static isNotBrackets(obj: unknown): obj is NotBrackets {
67
        return this.check(obj, "NotBrackets")
4,947✔
68
    }
69
    static isSubject(obj: unknown): obj is Subject {
70
        return this.check(obj, "Subject")
114,369✔
71
    }
72
    static isRdbmsSchemaBuilder(obj: unknown): obj is RdbmsSchemaBuilder {
73
        return this.check(obj, "RdbmsSchemaBuilder")
35✔
74
    }
75
    static isMongoEntityManager(obj: unknown): obj is MongoEntityManager {
76
        return this.check(obj, "MongoEntityManager")
181,442✔
77
    }
78
    static isSqljsEntityManager(obj: unknown): obj is SqljsEntityManager {
79
        return this.check(obj, "SqljsEntityManager")
5✔
80
    }
81
    static isEntitySchema(obj: unknown): obj is EntitySchema {
82
        return this.check(obj, "EntitySchema")
111,691✔
83
    }
84
    static isBaseEntityConstructor(obj: unknown): obj is typeof BaseEntity {
85
        return (
4,682✔
86
            typeof obj === "function" &&
9,107✔
87
            typeof (obj as typeof BaseEntity).hasId === "function" &&
88
            typeof (obj as typeof BaseEntity).save === "function" &&
89
            typeof (obj as typeof BaseEntity).useDataSource === "function"
90
        )
91
    }
92
    static isFindOperator(obj: unknown): obj is FindOperator<any> {
93
        return (
114,828✔
94
            this.check(obj, "FindOperator") || this.check(obj, "EqualOperator")
197,677✔
95
        )
96
    }
97
    static isEqualOperator(obj: unknown): obj is EqualOperator<any> {
98
        return this.check(obj, "EqualOperator")
2,639✔
99
    }
100
    static isQuery(obj: unknown): obj is Query {
101
        return this.check(obj, "Query")
51,116✔
102
    }
103
    static isTable(obj: unknown): obj is Table {
104
        return this.check(obj, "Table")
1,959,961✔
105
    }
106
    static isTableCheck(obj: unknown): obj is TableCheck {
107
        return this.check(obj, "TableCheck")
16✔
108
    }
109
    static isTableColumn(obj: unknown): obj is TableColumn {
110
        return this.check(obj, "TableColumn")
286✔
111
    }
112
    static isTableExclusion(obj: unknown): obj is TableExclusion {
113
        return this.check(obj, "TableExclusion")
×
114
    }
115
    static isTableForeignKey(obj: unknown): obj is TableForeignKey {
116
        return this.check(obj, "TableForeignKey")
1,211,004✔
117
    }
118
    static isTableIndex(obj: unknown): obj is TableIndex {
119
        return this.check(obj, "TableIndex")
15,027✔
120
    }
121
    static isTableUnique(obj: unknown): obj is TableUnique {
122
        return this.check(obj, "TableUnique")
17✔
123
    }
124
    static isView(obj: unknown): obj is View {
125
        return this.check(obj, "View")
1,322,497✔
126
    }
127
    static isDataSource(obj: unknown): obj is DataSource {
128
        return this.check(obj, "DataSource")
153,334✔
129
    }
130

131
    private static check(obj: unknown, name: string) {
132
        return (
6,694,496✔
133
            typeof obj === "object" &&
14,299,152✔
134
            obj !== null &&
135
            (obj as { "@instanceof": symbol })["@instanceof"] ===
136
                Symbol.for(name)
137
        )
138
    }
139
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc