@things-factory/resource-base 8.0.0-beta.0 → 8.0.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/resource-base",
3
- "version": "8.0.0-beta.0",
3
+ "version": "8.0.0-beta.2",
4
4
  "main": "dist-server/index.js",
5
5
  "things-factory": true,
6
6
  "author": "",
@@ -23,7 +23,7 @@
23
23
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/auth-base": "^8.0.0-beta.0"
26
+ "@things-factory/auth-base": "^8.0.0-beta.2"
27
27
  },
28
- "gitHead": "add6fb8224b2cb19cbea47bed6a5ecb0424c9a28"
28
+ "gitHead": "f03431a09435511b2595515658f9cb8f78ba4ebb"
29
29
  }
package/server/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './service'
@@ -1,148 +0,0 @@
1
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
- import { In } from 'typeorm'
3
-
4
- import { Entity } from './entity'
5
- import { EntityPatch, NewEntity } from './entity-type'
6
-
7
- @Resolver(Entity)
8
- export class EntityMutation {
9
- @Directive('@transaction')
10
- @Mutation(returns => Entity, { description: 'To create new Entity' })
11
- async createEntity(@Arg('entity') entity: NewEntity, @Ctx() context: ResolverContext): Promise<Entity> {
12
- const { domain, user, tx } = context.state
13
-
14
- const repository = tx.getRepository(Entity)
15
-
16
- if (entity.master) {
17
- entity.master = (await repository.findOne({ where: { id: entity.master } })) as any
18
- }
19
-
20
- return await repository.save({
21
- ...(entity as any),
22
- domain,
23
- creator: user,
24
- updater: user
25
- })
26
- }
27
-
28
- @Directive('@transaction')
29
- @Mutation(returns => Entity, { description: "To modify Entity' information" })
30
- async updateEntity(@Arg('id', type => String) id: string, @Arg('patch', type => EntityPatch) patch: EntityPatch, @Ctx() context: ResolverContext): Promise<Entity> {
31
- const { domain, user, tx } = context.state
32
-
33
- const repository = tx.getRepository(Entity)
34
- const entity = repository.findOne({
35
- where: { domain: { id: domain.id }, id },
36
- relations: ['master', 'children']
37
- })
38
-
39
- if (patch.master) {
40
- patch.master = (await repository.findOne({ where: { domain: { id: domain.id }, id: patch.master } })) as any
41
- }
42
-
43
- if (patch.children && patch.children.length) {
44
- patch.children = (await repository.findBy({ id: In(patch.children) })) as any
45
- }
46
-
47
- return await repository.save({
48
- ...entity,
49
- ...(patch as any),
50
- updater: user
51
- })
52
- }
53
-
54
- @Directive('@transaction')
55
- @Mutation(returns => [Entity], { description: "To modify multiple Entitys' information" })
56
- async updateMultipleEntity(@Arg('patches', type => [EntityPatch]) patches: EntityPatch[], @Ctx() context: ResolverContext): Promise<Entity[]> {
57
- const { domain, user, tx } = context.state
58
-
59
- let results = []
60
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
61
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
62
- const entityRepo = tx.getRepository(Entity)
63
-
64
- if (_createRecords.length > 0) {
65
- for (let i = 0; i < _createRecords.length; i++) {
66
- const newRecord = _createRecords[i]
67
-
68
- if (newRecord.master) {
69
- newRecord.master = (await tx.getRepository(Entity).findOne({ where: { domain: { id: domain.id }, id: newRecord.master } })) as any
70
- }
71
-
72
- if (newRecord.children && newRecord.children.length) {
73
- newRecord.children = (await tx.getRepository(Entity).findBy({ id: In(newRecord.children) })) as any
74
- }
75
-
76
- const result = await entityRepo.save({
77
- ...(newRecord as any),
78
- domain,
79
- creator: user,
80
- updater: user
81
- })
82
-
83
- results.push({ ...result, cuFlag: '+' })
84
- }
85
- }
86
-
87
- if (_updateRecords.length > 0) {
88
- for (let i = 0; i < _updateRecords.length; i++) {
89
- const updateRecord = _updateRecords[i]
90
- const entity = await entityRepo.findOneBy({ id: updateRecord.id })
91
-
92
- if (updateRecord.master) {
93
- updateRecord.master = (await tx.getRepository(Entity).findOne({ where: { domain: { id: domain.id }, id: updateRecord.master } })) as any
94
- }
95
-
96
- if (updateRecord.children && updateRecord.children.length) {
97
- updateRecord.children = (await tx.getRepository(Entity).findBy({ id: In(updateRecord.children) })) as any
98
- }
99
-
100
- const result = await entityRepo.save({
101
- ...entity,
102
- ...(updateRecord as any),
103
- updater: user
104
- })
105
-
106
- results.push({ ...result, cuFlag: 'M' })
107
- }
108
- }
109
-
110
- return results
111
- }
112
-
113
- @Directive('@transaction')
114
- @Mutation(returns => Boolean, { description: 'To delete Entity' })
115
- async deleteEntity(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
116
- const { domain, tx } = context.state
117
- const entityRepo = tx.getRepository(Entity)
118
-
119
- const entity: Entity = await entityRepo.findOne({
120
- where: { domain: { id: domain.id }, id },
121
- relations: ['columns']
122
- })
123
-
124
- if (entity.columns.length) throw new Error('cannot delete Entity because columns of entity exists')
125
- else await entityRepo.delete(entity.id)
126
-
127
- return true
128
- }
129
-
130
- @Directive('@transaction')
131
- @Mutation(returns => Boolean, { description: 'To delete multiple Entities' })
132
- async deleteEntities(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
133
- const { domain, tx } = context.state
134
- const entityRepo = tx.getRepository(Entity)
135
-
136
- for (const id of ids) {
137
- const entity: Entity = await entityRepo.findOne({
138
- where: { domain: { id: domain.id }, id },
139
- relations: ['columns']
140
- })
141
-
142
- if (entity.columns.length) throw new Error('cannot delete Entity because columns of entity exists')
143
- else await entityRepo.delete(entity.id)
144
- }
145
-
146
- return true
147
- }
148
- }
@@ -1,77 +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 { EntityColumn } from '../entity-column/entity-column'
7
- import { Entity } from './entity'
8
- import { EntityList } from './entity-type'
9
-
10
- @Resolver(Entity)
11
- export class EntityQuery {
12
- @Query(returns => Entity, { description: 'To fetch a Entity' })
13
- async entity(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Entity> {
14
- const { domain } = context.state
15
-
16
- return await getRepository(Entity).findOne({
17
- where: { domain: { id: domain.id }, id }
18
- })
19
- }
20
-
21
- @Query(returns => EntityList, { description: 'To fetch multiple Entities' })
22
- async entities(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<EntityList> {
23
- const { domain } = context.state
24
-
25
- const queryBuilder = getQueryBuilderFromListParams({
26
- repository: getRepository(Entity),
27
- params,
28
- domain,
29
- searchables: ['name', 'description']
30
- })
31
-
32
- const [items, total] = await queryBuilder.getManyAndCount()
33
-
34
- return { items, total }
35
- }
36
-
37
- @FieldResolver(type => Entity)
38
- async master(@Root() entity: Entity): Promise<Entity> {
39
- return await getRepository(Entity).findOneBy({ id: entity.masterId })
40
- }
41
-
42
- @FieldResolver(type => [Entity])
43
- async children(@Root() entity: Entity): Promise<Entity[]> {
44
- return await getRepository(Entity).find({
45
- where: {
46
- master: { id: entity.id }
47
- }
48
- })
49
- }
50
-
51
- @FieldResolver(type => [EntityColumn])
52
- async columns(@Root() entity: Entity): Promise<EntityColumn[]> {
53
- return await getRepository(EntityColumn).find({
54
- where: {
55
- entity: { id: entity.id }
56
- },
57
- order: {
58
- rank: 'ASC'
59
- }
60
- })
61
- }
62
-
63
- @FieldResolver(type => Domain)
64
- async domain(@Root() entity: Entity): Promise<Domain> {
65
- return await getRepository(Domain).findOneBy({ id: entity.domainId })
66
- }
67
-
68
- @FieldResolver(type => User)
69
- async updater(@Root() entity: Entity): Promise<User> {
70
- return await getRepository(User).findOneBy({ id: entity.updaterId })
71
- }
72
-
73
- @FieldResolver(type => User)
74
- async creator(@Root() entity: Entity): Promise<User> {
75
- return await getRepository(User).findOneBy({ id: entity.creatorId })
76
- }
77
- }
@@ -1,135 +0,0 @@
1
- import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
2
-
3
- import { Entity } from './entity'
4
-
5
- @InputType()
6
- export class NewEntity {
7
- @Field()
8
- name: string
9
-
10
- @Field({ nullable: true })
11
- description?: string
12
-
13
- @Field()
14
- bundle: string
15
-
16
- @Field()
17
- tableName: string
18
-
19
- @Field({ nullable: true })
20
- searchUrl?: string
21
-
22
- @Field({ nullable: true })
23
- multiSaveUrl?: string
24
-
25
- @Field({ nullable: true })
26
- idType?: string
27
-
28
- @Field({ nullable: true })
29
- idField?: string
30
-
31
- @Field({ nullable: true })
32
- titleField?: string
33
-
34
- @Field({ nullable: true })
35
- master?: string
36
-
37
- @Field({ nullable: true })
38
- association?: string
39
-
40
- @Field({ nullable: true })
41
- dataProp?: string
42
-
43
- @Field({ nullable: true })
44
- refField?: string
45
-
46
- @Field({ nullable: true })
47
- delStrategy?: string
48
-
49
- @Field(type => Int, { nullable: true })
50
- fixedColumns?: number
51
-
52
- @Field({ nullable: true })
53
- active?: boolean
54
-
55
- @Field({ nullable: true })
56
- extEntity?: boolean
57
-
58
- @Field(type => [String], { nullable: true })
59
- columns?: string[]
60
- }
61
-
62
- @InputType()
63
- export class EntityPatch {
64
- @Field(type => ID, { nullable: true })
65
- id?: string
66
-
67
- @Field({ nullable: true })
68
- name?: string
69
-
70
- @Field({ nullable: true })
71
- description?: string
72
-
73
- @Field({ nullable: true })
74
- bundle?: string
75
-
76
- @Field({ nullable: true })
77
- tableName?: string
78
-
79
- @Field({ nullable: true })
80
- searchUrl?: string
81
-
82
- @Field({ nullable: true })
83
- multiSaveUrl?: string
84
-
85
- @Field({ nullable: true })
86
- idType?: string
87
-
88
- @Field({ nullable: true })
89
- idField?: string
90
-
91
- @Field({ nullable: true })
92
- titleField?: string
93
-
94
- @Field({ nullable: true })
95
- master?: string
96
-
97
- @Field({ nullable: true })
98
- association?: string
99
-
100
- @Field({ nullable: true })
101
- dataProp?: string
102
-
103
- @Field({ nullable: true })
104
- refField?: string
105
-
106
- @Field({ nullable: true })
107
- delStrategy?: string
108
-
109
- @Field(type => Int, { nullable: true })
110
- fixedColumns?: number
111
-
112
- @Field({ nullable: true })
113
- active?: boolean
114
-
115
- @Field({ nullable: true })
116
- extEntity?: boolean
117
-
118
- @Field(type => [String], { nullable: true })
119
- columns?: string[]
120
-
121
- @Field(type => [String], { nullable: true })
122
- children: string[]
123
-
124
- @Field({ nullable: true })
125
- cuFlag?: string
126
- }
127
-
128
- @ObjectType()
129
- export class EntityList {
130
- @Field(type => [Entity])
131
- items: Entity[]
132
-
133
- @Field(type => Int)
134
- total: number
135
- }
@@ -1,168 +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
- OneToMany,
9
- PrimaryGeneratedColumn,
10
- RelationId,
11
- UpdateDateColumn
12
- } from 'typeorm'
13
-
14
- import { User } from '@things-factory/auth-base'
15
- import { Domain } from '@things-factory/shell'
16
-
17
- import { EntityColumn } from '../entity-column/entity-column'
18
-
19
- @ORMEntity()
20
- @Index('ix_entity_0', (entity: Entity) => [entity.domain, entity.name], { unique: true })
21
- @Index('ix_entity_1', (entity: Entity) => [entity.domain])
22
- @Index('ix_entity_2', (entity: Entity) => [entity.bundle])
23
- @Index('ix_entity_3', (entity: Entity) => [entity.domain, entity.master])
24
- @ObjectType({ description: 'Entity for Entity' })
25
- export class Entity {
26
- @PrimaryGeneratedColumn('uuid')
27
- @Field(type => ID)
28
- readonly id: string
29
-
30
- @ManyToOne(type => Domain)
31
- @Field(type => Domain)
32
- domain?: Domain
33
-
34
- @RelationId((entity: Entity) => entity.domain)
35
- domainId?: string
36
-
37
- @Column()
38
- @Field()
39
- name: string
40
-
41
- @Column({
42
- nullable: true
43
- })
44
- @Field({ nullable: true })
45
- description?: string
46
-
47
- @Column()
48
- @Field()
49
- bundle: string
50
-
51
- @Column()
52
- @Field()
53
- tableName: string
54
-
55
- @Column({
56
- nullable: true
57
- })
58
- @Field({ nullable: true })
59
- searchUrl?: string
60
-
61
- @Column({
62
- nullable: true
63
- })
64
- @Field({ nullable: true })
65
- multiSaveUrl?: string
66
-
67
- @Column({
68
- nullable: true
69
- })
70
- @Field({ nullable: true })
71
- idType?: string
72
-
73
- @Column({
74
- nullable: true
75
- })
76
- @Field({ nullable: true })
77
- idField?: string
78
-
79
- @Column({
80
- nullable: true
81
- })
82
- @Field({ nullable: true })
83
- titleField?: string
84
-
85
- @ManyToOne(type => Entity, master => master.children)
86
- @Field(type => Entity, { nullable: true })
87
- master?: Entity
88
-
89
- @RelationId((entity: Entity) => entity.master)
90
- masterId?: string
91
-
92
- @OneToMany(type => Entity, child => child.master)
93
- @Field(type => [Entity], { nullable: true })
94
- children?: Entity[]
95
-
96
- @Column({
97
- nullable: true
98
- })
99
- @Field({ nullable: true })
100
- association?: string
101
-
102
- @Column({
103
- nullable: true
104
- })
105
- @Field({ nullable: true })
106
- dataProp?: string
107
-
108
- @Column({
109
- nullable: true
110
- })
111
- @Field({ nullable: true })
112
- refField?: string
113
-
114
- @Column({
115
- nullable: true
116
- })
117
- @Field({ nullable: true })
118
- delStrategy?: string
119
-
120
- @Column('int', {
121
- nullable: true
122
- })
123
- @Field({ nullable: true })
124
- fixedColumns?: number
125
-
126
- @Column({
127
- nullable: true,
128
- default: true
129
- })
130
- @Field({ nullable: true })
131
- active?: boolean
132
-
133
- @Column({
134
- nullable: true
135
- })
136
- @Field({ nullable: true })
137
- extEntity?: boolean
138
-
139
- @OneToMany(type => EntityColumn, entityColumn => entityColumn.entity)
140
- @Field(type => [EntityColumn], { nullable: true })
141
- columns?: EntityColumn[]
142
-
143
- @CreateDateColumn()
144
- @Field({ nullable: true })
145
- createdAt?: Date
146
-
147
- @UpdateDateColumn()
148
- @Field({ nullable: true })
149
- updatedAt?: Date
150
-
151
- @ManyToOne(type => User, {
152
- nullable: true
153
- })
154
- @Field(type => User, { nullable: true })
155
- creator?: User
156
-
157
- @RelationId((entity: Entity) => entity.creator)
158
- creatorId?: string
159
-
160
- @ManyToOne(type => User, {
161
- nullable: true
162
- })
163
- @Field(type => User, { nullable: true })
164
- updater?: User
165
-
166
- @RelationId((entity: Entity) => entity.updater)
167
- updaterId?: string
168
- }
@@ -1,6 +0,0 @@
1
- import { Entity } from './entity'
2
- import { EntityQuery } from './entity-query'
3
- import { EntityMutation } from './entity-mutation'
4
-
5
- export const entities = [Entity]
6
- export const resolvers = [EntityQuery, EntityMutation]
@@ -1,130 +0,0 @@
1
- import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
- import { In } from 'typeorm'
3
-
4
- import { Entity } from '../entity/entity'
5
- import { EntityColumn } from './entity-column'
6
- import { EntityColumnPatch, NewEntityColumn } from './entity-column-type'
7
-
8
- @Resolver(EntityColumn)
9
- export class EntityColumnMutation {
10
- @Directive('@transaction')
11
- @Mutation(returns => EntityColumn, { description: 'To create new EntityColumn' })
12
- async createEntityColumn(
13
- @Arg('entityColumn') entityColumn: NewEntityColumn,
14
- @Ctx() context: ResolverContext
15
- ): Promise<EntityColumn> {
16
- const { domain, user, tx } = context.state
17
-
18
- if (entityColumn.entity) {
19
- entityColumn.entity = (await tx.getRepository(Entity).findOne({ where: { id: entityColumn.entity.id } })) as any
20
- }
21
-
22
- return await tx.getRepository(EntityColumn).save({
23
- ...(entityColumn as any),
24
- domain,
25
- creator: user,
26
- updater: user
27
- })
28
- }
29
-
30
- @Directive('@transaction')
31
- @Mutation(returns => EntityColumn, { description: 'To modify EntityColumn information' })
32
- async updateEntityColumn(
33
- @Arg('id') id: string,
34
- @Arg('patch') patch: EntityColumnPatch,
35
- @Ctx() context: ResolverContext
36
- ): Promise<EntityColumn> {
37
- const { domain, user, tx } = context.state
38
-
39
- const repository = tx.getRepository(EntityColumn)
40
- const entityColumn = await repository.findOne({
41
- where: { domain: { id: domain.id }, id }
42
- })
43
-
44
- if (patch.entity) {
45
- patch.entity = (await tx.getRepository(Entity).findOneBy({ id: patch.entity.id })) as any
46
- }
47
-
48
- return await repository.save({
49
- ...entityColumn,
50
- ...(patch as any),
51
- updater: user
52
- })
53
- }
54
-
55
- @Directive('@transaction')
56
- @Mutation(returns => [EntityColumn], { description: "To modify multiple Entitys' information" })
57
- async updateMultipleEntityColumn(
58
- @Arg('patches', type => [EntityColumnPatch]) patches: EntityColumnPatch[],
59
- @Ctx() context: ResolverContext
60
- ): Promise<EntityColumn[]> {
61
- const { domain, user, tx } = context.state
62
-
63
- let results = []
64
- const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
65
- const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
66
- const entityColumnRepo = tx.getRepository(EntityColumn)
67
-
68
- if (_createRecords.length > 0) {
69
- for (let i = 0; i < _createRecords.length; i++) {
70
- const newRecord = _createRecords[i]
71
-
72
- if (newRecord.entity) {
73
- newRecord.entity = (await tx.getRepository(Entity).findOneBy({ id: newRecord.entity.id })) as any
74
- }
75
-
76
- const result = await entityColumnRepo.save({
77
- ...(newRecord as any),
78
- domain,
79
- creator: user,
80
- updater: user
81
- })
82
-
83
- results.push({ ...result, cuFlag: '+' })
84
- }
85
- }
86
-
87
- if (_updateRecords.length > 0) {
88
- for (let i = 0; i < _updateRecords.length; i++) {
89
- const updateRecord = _updateRecords[i]
90
- const entity = await entityColumnRepo.findOneBy({ id: updateRecord.id })
91
-
92
- if (updateRecord.entity) {
93
- updateRecord.entity = (await tx.getRepository(Entity).findOneBy({ id: updateRecord.entity.id })) as any
94
- }
95
-
96
- const result = await entityColumnRepo.save({
97
- ...entity,
98
- ...(updateRecord as any),
99
- updater: user
100
- })
101
-
102
- results.push({ ...result, cuFlag: 'M' })
103
- }
104
- }
105
-
106
- return results
107
- }
108
-
109
- @Directive('@transaction')
110
- @Mutation(returns => Boolean, { description: 'To delete EntityColumn' })
111
- async deleteEntityColumn(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
112
- const { domain, tx } = context.state
113
-
114
- await tx.getRepository(EntityColumn).delete({ domain: { id: domain.id }, id })
115
- return true
116
- }
117
-
118
- @Directive('@transaction')
119
- @Mutation(returns => Boolean, { description: 'To delete multiple EntityColumns' })
120
- async deleteEntityColumns(
121
- @Arg('ids', type => [String]) ids: string[],
122
- @Ctx() context: ResolverContext
123
- ): Promise<boolean> {
124
- const { domain, tx } = context.state
125
-
126
- await tx.getRepository(EntityColumn).delete({ domain: { id: domain.id }, id: In(ids) })
127
-
128
- return true
129
- }
130
- }
@@ -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
- }