@things-factory/resource-base 8.0.5 → 9.0.0-beta.12

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,59 +0,0 @@
1
- import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
2
-
3
- import { User } from '@things-factory/auth-base'
4
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
5
-
6
- import { Entity } from '../entity/entity'
7
- import { EntityColumn } from './entity-column'
8
- import { EntityColumnList } from './entity-column-type'
9
-
10
- @Resolver(EntityColumn)
11
- export class EntityColumnQuery {
12
- @Query(returns => EntityColumn, { description: 'To fetch a EntityColumn' })
13
- async entityColumn(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<EntityColumn> {
14
- const { domain } = context.state
15
-
16
- return await getRepository(EntityColumn).findOne({
17
- where: { domain: { id: domain.id }, id }
18
- })
19
- }
20
-
21
- @Query(returns => EntityColumnList, { description: 'To fetch multiple EntityColumns' })
22
- async entityColumns(
23
- @Args(type => ListParam) params: ListParam,
24
- @Ctx() context: ResolverContext
25
- ): Promise<EntityColumnList> {
26
- const { domain } = context.state
27
-
28
- const queryBuilder = getQueryBuilderFromListParams({
29
- repository: getRepository(EntityColumn),
30
- params,
31
- domain,
32
- searchables: ['name', 'description']
33
- })
34
-
35
- const [items, total] = await queryBuilder.getManyAndCount()
36
-
37
- return { items, total }
38
- }
39
-
40
- @FieldResolver(type => Entity)
41
- async entity(@Root() entityColumn: EntityColumn): Promise<Entity> {
42
- return await getRepository(Entity).findOneBy({ id: entityColumn.entityId })
43
- }
44
-
45
- @FieldResolver(type => Domain)
46
- async domain(@Root() entityColumn: EntityColumn): Promise<Domain> {
47
- return await getRepository(Domain).findOneBy({ id: entityColumn.domainId })
48
- }
49
-
50
- @FieldResolver(type => User)
51
- async updater(@Root() entityColumn: EntityColumn): Promise<User> {
52
- return await getRepository(User).findOneBy({ id: entityColumn.updaterId })
53
- }
54
-
55
- @FieldResolver(type => User)
56
- async creator(@Root() entityColumn: EntityColumn): Promise<User> {
57
- return await getRepository(User).findOneBy({ id: entityColumn.creatorId })
58
- }
59
- }
@@ -1,228 +0,0 @@
1
- import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
- import { ObjectRef } from '@things-factory/shell'
3
- import { EntityColumn } from './entity-column'
4
-
5
- @InputType()
6
- export class NewEntityColumn {
7
- @Field()
8
- name: string
9
-
10
- @Field({ nullable: true })
11
- description?: string
12
-
13
- @Field()
14
- entity: ObjectRef
15
-
16
- @Field({ nullable: true })
17
- rank?: number
18
-
19
- @Field({ nullable: true })
20
- term?: string
21
-
22
- @Field()
23
- colType: string
24
-
25
- @Field({ nullable: true })
26
- colSize?: number
27
-
28
- @Field({ nullable: true })
29
- nullable?: boolean
30
-
31
- @Field({ nullable: true })
32
- refType?: string
33
-
34
- @Field({ nullable: true })
35
- refName?: string
36
-
37
- @Field({ nullable: true })
38
- refUrl?: string
39
-
40
- @Field({ nullable: true })
41
- refParams?: string
42
-
43
- @Field({ nullable: true })
44
- refRelated?: string
45
-
46
- @Field(type => Int, { nullable: true })
47
- searchRank?: number
48
-
49
- @Field(type => Int, { nullable: true })
50
- sortRank?: number
51
-
52
- @Field({ nullable: true })
53
- reverseSort?: boolean
54
-
55
- @Field({ nullable: true })
56
- virtualField?: boolean
57
-
58
- @Field({ nullable: true })
59
- searchName?: string
60
-
61
- @Field({ nullable: true })
62
- searchEditor?: string
63
-
64
- @Field({ nullable: true })
65
- searchOper?: string
66
-
67
- @Field({ nullable: true })
68
- searchInitVal?: string
69
-
70
- @Field(type => Int, { nullable: true })
71
- gridRank?: number
72
-
73
- @Field({ nullable: true })
74
- gridEditor?: string
75
-
76
- @Field({ nullable: true })
77
- gridFormat?: string
78
-
79
- @Field({ nullable: true })
80
- gridValidator?: string
81
-
82
- @Field(type => Int, { nullable: true })
83
- gridWidth?: number
84
-
85
- @Field({ nullable: true })
86
- gridAlign?: string
87
-
88
- @Field(type => Int, { nullable: true })
89
- uniqRank?: number
90
-
91
- @Field({ nullable: true })
92
- formEditor?: string
93
-
94
- @Field({ nullable: true })
95
- formValidator?: string
96
-
97
- @Field({ nullable: true })
98
- formFormat?: string
99
-
100
- @Field({ nullable: true })
101
- defVal?: string
102
-
103
- @Field({ nullable: true })
104
- rangeVal?: string
105
-
106
- @Field({ nullable: true })
107
- ignoreOnSav?: boolean
108
- }
109
-
110
- @InputType()
111
- export class EntityColumnPatch {
112
- @Field(type => ID, { nullable: true })
113
- id?: string
114
-
115
- @Field({ nullable: true })
116
- name?: string
117
-
118
- @Field({ nullable: true })
119
- description?: string
120
-
121
- @Field({ nullable: true })
122
- entity?: ObjectRef
123
-
124
- @Field(type => Int, { nullable: true })
125
- rank?: number
126
-
127
- @Field({ nullable: true })
128
- term?: string
129
-
130
- @Field({ nullable: true })
131
- colType?: string
132
-
133
- @Field(type => Int, { nullable: true })
134
- colSize?: number
135
-
136
- @Field({ nullable: true })
137
- nullable?: boolean
138
-
139
- @Field({ nullable: true })
140
- refType?: string
141
-
142
- @Field({ nullable: true })
143
- refName?: string
144
-
145
- @Field({ nullable: true })
146
- refUrl?: string
147
-
148
- @Field({ nullable: true })
149
- refParams?: string
150
-
151
- @Field({ nullable: true })
152
- refRelated?: string
153
-
154
- @Field(type => Int, { nullable: true })
155
- searchRank?: number
156
-
157
- @Field({ nullable: true })
158
- sortRank?: number
159
-
160
- @Field({ nullable: true })
161
- reverseSort?: boolean
162
-
163
- @Field({ nullable: true })
164
- virtualField?: boolean
165
-
166
- @Field({ nullable: true })
167
- searchName?: string
168
-
169
- @Field({ nullable: true })
170
- searchEditor?: string
171
-
172
- @Field({ nullable: true })
173
- searchOper?: string
174
-
175
- @Field({ nullable: true })
176
- searchInitVal?: string
177
-
178
- @Field(type => Int, { nullable: true })
179
- gridRank?: number
180
-
181
- @Field({ nullable: true })
182
- gridEditor?: string
183
-
184
- @Field({ nullable: true })
185
- gridFormat?: string
186
-
187
- @Field({ nullable: true })
188
- gridValidator?: string
189
-
190
- @Field(type => Int, { nullable: true })
191
- gridWidth?: number
192
-
193
- @Field({ nullable: true })
194
- gridAlign?: string
195
-
196
- @Field(type => Int, { nullable: true })
197
- uniqRank?: number
198
-
199
- @Field({ nullable: true })
200
- formEditor?: string
201
-
202
- @Field({ nullable: true })
203
- formValidator?: string
204
-
205
- @Field({ nullable: true })
206
- formFormat?: string
207
-
208
- @Field({ nullable: true })
209
- defVal?: string
210
-
211
- @Field({ nullable: true })
212
- rangeVal?: string
213
-
214
- @Field({ nullable: true })
215
- ignoreOnSav?: boolean
216
-
217
- @Field({ nullable: true })
218
- cuFlag?: string
219
- }
220
-
221
- @ObjectType()
222
- export class EntityColumnList {
223
- @Field(type => [EntityColumn])
224
- items: EntityColumn[]
225
-
226
- @Field(type => Int)
227
- total: number
228
- }
@@ -1,266 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import {
3
- Column,
4
- CreateDateColumn,
5
- Entity as ORMEntity,
6
- Index,
7
- ManyToOne,
8
- PrimaryGeneratedColumn,
9
- RelationId,
10
- UpdateDateColumn
11
- } from 'typeorm'
12
-
13
- import { User } from '@things-factory/auth-base'
14
- import { Domain } from '@things-factory/shell'
15
-
16
- import { Entity } from '../entity/entity'
17
-
18
- @ORMEntity()
19
- @Index('ix_entity_col_0', (entityColumn: EntityColumn) => [entityColumn.entity, entityColumn.name], {
20
- unique: true
21
- })
22
- @Index('ix_entity_col_1', (entityColumn: EntityColumn) => [entityColumn.entity, entityColumn.rank])
23
- @ObjectType({ description: 'Entity for EntityColumn' })
24
- export class EntityColumn {
25
- @PrimaryGeneratedColumn('uuid')
26
- @Field(type => ID)
27
- readonly id: string
28
-
29
- @ManyToOne(type => Domain)
30
- @Field(type => Domain)
31
- domain?: Domain
32
-
33
- @RelationId((entityColumn: EntityColumn) => entityColumn.domain)
34
- domainId?: string
35
-
36
- @ManyToOne(type => Entity, entity => entity.columns)
37
- @Field(type => Entity)
38
- entity: Entity
39
-
40
- @RelationId((entityColumn: EntityColumn) => entityColumn.entity)
41
- entityId?: string
42
-
43
- @Column()
44
- @Field()
45
- name: string
46
-
47
- @Column({
48
- nullable: true
49
- })
50
- @Field({ nullable: true })
51
- description?: string
52
-
53
- @Column('int', {
54
- nullable: true
55
- })
56
- @Field({ nullable: true })
57
- rank?: number
58
-
59
- @Column({
60
- nullable: true
61
- })
62
- @Field({ nullable: true })
63
- term?: string
64
-
65
- @Column()
66
- @Field()
67
- colType: string
68
-
69
- @Column('int', {
70
- nullable: true
71
- })
72
- @Field({ nullable: true })
73
- colSize?: number
74
-
75
- @Column({
76
- nullable: true,
77
- default: true
78
- })
79
- @Field({ nullable: true })
80
- nullable?: boolean
81
-
82
- @Column({
83
- nullable: true
84
- })
85
- @Field({ nullable: true })
86
- refType?: string
87
-
88
- @Column({
89
- nullable: true
90
- })
91
- @Field({ nullable: true })
92
- refName?: string
93
-
94
- @Column({
95
- nullable: true
96
- })
97
- @Field({ nullable: true })
98
- refUrl?: string
99
-
100
- @Column({
101
- nullable: true
102
- })
103
- @Field({ nullable: true })
104
- refParams?: string
105
-
106
- @Column({
107
- nullable: true
108
- })
109
- @Field({ nullable: true })
110
- refRelated?: string
111
-
112
- @Column('int', {
113
- nullable: true
114
- })
115
- @Field({ nullable: true })
116
- searchRank?: number
117
-
118
- @Column('int', {
119
- nullable: true
120
- })
121
- @Field({ nullable: true })
122
- sortRank?: number
123
-
124
- @Column({
125
- nullable: true,
126
- default: false
127
- })
128
- @Field({ nullable: true })
129
- reverseSort?: boolean
130
-
131
- @Column({
132
- nullable: true,
133
- default: false
134
- })
135
- @Field({ nullable: true })
136
- virtualField?: boolean
137
-
138
- @Column({
139
- nullable: true
140
- })
141
- @Field({ nullable: true })
142
- searchName?: string
143
-
144
- @Column({
145
- nullable: true
146
- })
147
- @Field({ nullable: true })
148
- searchEditor?: string
149
-
150
- @Column({
151
- nullable: true
152
- })
153
- @Field({ nullable: true })
154
- searchOper?: string
155
-
156
- @Column({
157
- nullable: true
158
- })
159
- @Field({ nullable: true })
160
- searchInitVal?: string
161
-
162
- @Column('int', {
163
- nullable: true
164
- })
165
- @Field({ nullable: true })
166
- gridRank?: number
167
-
168
- @Column({
169
- nullable: true
170
- })
171
- @Field({ nullable: true })
172
- gridEditor?: string
173
-
174
- @Column({
175
- nullable: true
176
- })
177
- @Field({ nullable: true })
178
- gridFormat?: string
179
-
180
- @Column({
181
- nullable: true
182
- })
183
- @Field({ nullable: true })
184
- gridValidator?: string
185
-
186
- @Column('int', {
187
- nullable: true
188
- })
189
- @Field({ nullable: true })
190
- gridWidth?: number
191
-
192
- @Column({
193
- nullable: true
194
- })
195
- @Field({ nullable: true })
196
- gridAlign?: string
197
-
198
- @Column('int', {
199
- nullable: true
200
- })
201
- @Field({ nullable: true })
202
- uniqRank?: number
203
-
204
- @Column({
205
- nullable: true
206
- })
207
- @Field({ nullable: true })
208
- formEditor?: string
209
-
210
- @Column({
211
- nullable: true
212
- })
213
- @Field({ nullable: true })
214
- formValidator?: string
215
-
216
- @Column({
217
- nullable: true
218
- })
219
- @Field({ nullable: true })
220
- formFormat?: string
221
-
222
- @Column({
223
- nullable: true
224
- })
225
- @Field({ nullable: true })
226
- defVal?: string
227
-
228
- @Column({
229
- nullable: true
230
- })
231
- @Field({ nullable: true })
232
- rangeVal?: string
233
-
234
- @Column({
235
- nullable: true,
236
- default: false
237
- })
238
- @Field({ nullable: true })
239
- ignoreOnSav?: boolean
240
-
241
- @CreateDateColumn()
242
- @Field({ nullable: true })
243
- createdAt?: Date
244
-
245
- @UpdateDateColumn()
246
- @Field({ nullable: true })
247
- updatedAt?: Date
248
-
249
- @ManyToOne(type => User, {
250
- nullable: true
251
- })
252
- @Field(type => User, { nullable: true })
253
- creator?: User
254
-
255
- @RelationId((entityColumn: EntityColumn) => entityColumn.creator)
256
- creatorId?: string
257
-
258
- @ManyToOne(type => User, {
259
- nullable: true
260
- })
261
- @Field(type => User, { nullable: true })
262
- updater?: User
263
-
264
- @RelationId((entityColumn: EntityColumn) => entityColumn.updater)
265
- updaterId?: string
266
- }
@@ -1,6 +0,0 @@
1
- import { EntityColumn } from './entity-column'
2
- import { EntityColumnQuery } from './entity-column-query'
3
- import { EntityColumnMutation } from './entity-column-mutation'
4
-
5
- export const entities = [EntityColumn]
6
- export const resolvers = [EntityColumnQuery, EntityColumnMutation]
@@ -1,12 +0,0 @@
1
- import { Arg, Ctx, Query, Resolver } from 'type-graphql'
2
- import { getConnection } from 'typeorm'
3
-
4
- import { EntityMetadata } from './entity-metadata'
5
-
6
- @Resolver(EntityMetadata)
7
- export class EntityMetadataQuery {
8
- @Query(returns => EntityMetadata, { description: 'To fetch a EntityMetadata' })
9
- async entityMetadata(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<EntityMetadata> {
10
- return (await getConnection().getMetadata(name)) as any
11
- }
12
- }
@@ -1,81 +0,0 @@
1
- import { Field, Int, ObjectType } from 'type-graphql'
2
-
3
- import { ScalarAny } from '@things-factory/shell'
4
-
5
- @ObjectType({ description: 'RelationType of EntityColumn' })
6
- export class EntityRelationMetadata {
7
- @Field({ nullable: true })
8
- isOneToMany?: boolean
9
-
10
- @Field({ nullable: true })
11
- isOneToOne?: boolean
12
-
13
- @Field({ nullable: true })
14
- isManyToOne?: boolean
15
-
16
- @Field({ nullable: true })
17
- relationType?: boolean
18
-
19
- @Field(type => [EntityColumnMetadata], { nullable: true })
20
- joinColumns?: EntityColumnMetadata[]
21
-
22
- @Field({ nullable: true })
23
- joinTableName?: string
24
- }
25
-
26
- @ObjectType({ description: 'EntityColumn of Entity' })
27
- export class EntityColumnMetadata {
28
- @Field()
29
- propertyName: string
30
-
31
- @Field(type => ScalarAny)
32
- type: any
33
-
34
- @Field(type => Int, { nullable: true })
35
- width?: number
36
-
37
- @Field(type => ScalarAny, { nullable: true })
38
- target?: string | Function
39
-
40
- @Field(type => [ScalarAny], { nullable: true })
41
- enum?: any[]
42
-
43
- @Field({ nullable: true })
44
- generatedType?: 'VIRTUAL' | 'STORED'
45
-
46
- @Field({ nullable: true })
47
- isArray?: boolean
48
-
49
- @Field()
50
- isNullable: boolean
51
-
52
- @Field({ nullable: true })
53
- isPrimary: boolean
54
-
55
- @Field({ nullable: true })
56
- isReadonly: boolean
57
-
58
- @Field({ nullable: true })
59
- isUpdateDate: boolean
60
-
61
- @Field({ nullable: true })
62
- isVersion: boolean
63
-
64
- @Field({ nullable: true })
65
- length: number
66
-
67
- @Field(type => ScalarAny, { nullable: true })
68
- referenceColumn?: any
69
-
70
- @Field(type => EntityRelationMetadata, { nullable: true })
71
- relationMetadata?: EntityRelationMetadata
72
- }
73
-
74
- @ObjectType({ description: 'Entity for EntityMetadata' })
75
- export class EntityMetadata {
76
- @Field()
77
- name: string
78
-
79
- @Field(type => [EntityColumnMetadata], { nullable: true })
80
- columns?: EntityColumnMetadata[]
81
- }
@@ -1,5 +0,0 @@
1
- import { EntityMetadata } from './entity-metadata'
2
- import { EntityMetadataQuery } from './entity-metadata-query'
3
-
4
- export const entities = [EntityMetadata]
5
- export const resolvers = [EntityMetadataQuery]
@@ -1,24 +0,0 @@
1
- import { entities as EntityEntities, resolvers as EntityResolvers } from './entity'
2
- import { entities as EntityColumnEntities, resolvers as EntityColumnResolvers } from './entity-column'
3
- import { entities as EntityMetadataEntities, resolvers as EntityMetadataResolvers } from './entity-metadata'
4
-
5
- /* EXPORT ENTITY TYPES */
6
- export * from './entity-metadata/entity-metadata'
7
- export * from './entity-column/entity-column'
8
- export * from './entity/entity'
9
-
10
- export const entities = [
11
- /* ENTITIES */
12
- ...EntityMetadataEntities,
13
- ...EntityColumnEntities,
14
- ...EntityEntities
15
- ]
16
-
17
- export const schema = {
18
- resolverClasses: [
19
- /* RESOLVER CLASSES */
20
- ...EntityMetadataResolvers,
21
- ...EntityColumnResolvers,
22
- ...EntityResolvers
23
- ]
24
- }