@things-factory/shell 8.0.38 → 9.0.0-9.0.0-beta.59.0
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/_index.html +0 -1
- package/bin/things-factory-migration +6 -3
- package/client/themes/calendar-theme.css +3 -1
- package/client/themes/index.css +2 -1
- package/dist-server/index.d.ts +12 -12
- package/dist-server/index.js +12 -12
- package/dist-server/index.js.map +1 -1
- package/dist-server/initializers/database.js +4 -10
- package/dist-server/initializers/database.js.map +1 -1
- package/dist-server/initializers/ormconfig.d.ts +2 -0
- package/dist-server/initializers/ormconfig.js +30 -0
- package/dist-server/initializers/ormconfig.js.map +1 -0
- package/dist-server/middlewares/domain-middleware.js +2 -2
- package/dist-server/middlewares/domain-middleware.js.map +1 -1
- package/dist-server/middlewares/index.d.ts +1 -1
- package/dist-server/middlewares/index.js +3 -3
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/migrations/1000000000000-SeedDomain.js +4 -4
- package/dist-server/migrations/1000000000000-SeedDomain.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/process-cleaner.d.ts +1 -0
- package/dist-server/process-cleaner.js +92 -0
- package/dist-server/process-cleaner.js.map +1 -0
- package/dist-server/routers/domain-router.js +3 -3
- package/dist-server/routers/domain-router.js.map +1 -1
- package/dist-server/routers/global-router.js +6 -6
- package/dist-server/routers/global-router.js.map +1 -1
- package/dist-server/routers/index.d.ts +3 -3
- package/dist-server/routers/index.js +3 -3
- package/dist-server/routers/index.js.map +1 -1
- package/dist-server/schema.js +5 -4
- package/dist-server/schema.js.map +1 -1
- package/dist-server/server-dev.js +37 -39
- package/dist-server/server-dev.js.map +1 -1
- package/dist-server/server.js +34 -36
- package/dist-server/server.js.map +1 -1
- package/dist-server/service/attribute-set/attribute-set-item-type.js +3 -3
- package/dist-server/service/attribute-set/attribute-set-item-type.js.map +1 -1
- package/dist-server/service/attribute-set/attribute-set-mutation.d.ts +2 -2
- package/dist-server/service/attribute-set/attribute-set-mutation.js +16 -16
- package/dist-server/service/attribute-set/attribute-set-mutation.js.map +1 -1
- package/dist-server/service/attribute-set/attribute-set-query.d.ts +3 -3
- package/dist-server/service/attribute-set/attribute-set-query.js +15 -15
- package/dist-server/service/attribute-set/attribute-set-query.js.map +1 -1
- package/dist-server/service/attribute-set/attribute-set-type.d.ts +2 -2
- package/dist-server/service/attribute-set/attribute-set-type.js +5 -5
- package/dist-server/service/attribute-set/attribute-set-type.js.map +1 -1
- package/dist-server/service/attribute-set/attribute-set.d.ts +1 -1
- package/dist-server/service/attribute-set/attribute-set.js +2 -2
- package/dist-server/service/attribute-set/attribute-set.js.map +1 -1
- package/dist-server/service/attribute-set/index.d.ts +3 -3
- package/dist-server/service/attribute-set/index.js +5 -5
- package/dist-server/service/attribute-set/index.js.map +1 -1
- package/dist-server/service/common-types/index.d.ts +6 -6
- package/dist-server/service/common-types/index.js +6 -6
- package/dist-server/service/common-types/index.js.map +1 -1
- package/dist-server/service/common-types/list-param.js +2 -2
- package/dist-server/service/common-types/list-param.js.map +1 -1
- package/dist-server/service/common-types/log.js +2 -2
- package/dist-server/service/common-types/log.js.map +1 -1
- package/dist-server/service/common-types/scalar-object.d.ts +2 -1
- package/dist-server/service/common-types/scalar-object.js +2 -2
- package/dist-server/service/common-types/scalar-object.js.map +1 -1
- package/dist-server/service/directive-transaction/index.d.ts +1 -1
- package/dist-server/service/directive-transaction/index.js +1 -1
- package/dist-server/service/directive-transaction/index.js.map +1 -1
- package/dist-server/service/directive-transaction/transaction.js +2 -2
- package/dist-server/service/directive-transaction/transaction.js.map +1 -1
- package/dist-server/service/domain/domain-mutation.d.ts +2 -2
- package/dist-server/service/domain/domain-mutation.js +21 -21
- package/dist-server/service/domain/domain-mutation.js.map +1 -1
- package/dist-server/service/domain/domain-query.js +6 -6
- package/dist-server/service/domain/domain-query.js.map +1 -1
- package/dist-server/service/domain/domain-types.d.ts +2 -2
- package/dist-server/service/domain/domain-types.js +6 -6
- package/dist-server/service/domain/domain-types.js.map +1 -1
- package/dist-server/service/domain/index.d.ts +3 -3
- package/dist-server/service/domain/index.js +5 -5
- package/dist-server/service/domain/index.js.map +1 -1
- package/dist-server/service/index.d.ts +7 -7
- package/dist-server/service/index.js +16 -16
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/subscription-data/data-resolver.d.ts +1 -1
- package/dist-server/service/subscription-data/data-resolver.js +4 -4
- package/dist-server/service/subscription-data/data-resolver.js.map +1 -1
- package/dist-server/service/subscription-data/data-types.d.ts +1 -1
- package/dist-server/service/subscription-data/data-types.js +5 -5
- package/dist-server/service/subscription-data/data-types.js.map +1 -1
- package/dist-server/service/subscription-data/index.d.ts +1 -1
- package/dist-server/service/subscription-data/index.js +2 -2
- package/dist-server/service/subscription-data/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/typeorm/encrypt-transform.js +3 -3
- package/dist-server/typeorm/encrypt-transform.js.map +1 -1
- package/dist-server/utils/get-times-for-period.d.ts +24 -4
- package/dist-server/utils/get-times-for-period.js +42 -5
- package/dist-server/utils/get-times-for-period.js.map +1 -1
- package/dist-server/utils/index.d.ts +8 -8
- package/dist-server/utils/index.js +8 -8
- package/dist-server/utils/index.js.map +1 -1
- package/dist-server/utils/list-param-adjuster.d.ts +1 -1
- package/dist-server/utils/list-param-adjuster.js.map +1 -1
- package/dist-server/utils/list-params-converter.d.ts +2 -2
- package/dist-server/utils/list-params-converter.js +2 -2
- package/dist-server/utils/list-params-converter.js.map +1 -1
- package/dist-server/utils/list-query-builder.d.ts +1 -1
- package/dist-server/utils/list-query-builder.js +7 -7
- package/dist-server/utils/list-query-builder.js.map +1 -1
- package/dist-server/utils/publish-progress.js +2 -2
- package/dist-server/utils/publish-progress.js.map +1 -1
- package/package.json +14 -19
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +2 -1
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
- package/views/public/home.html +0 -1
- package/client/hot-client/hot.js +0 -140
- package/client/hot-client/index.js +0 -103
- package/client/hot-client/log.js +0 -44
- package/client/hot-client/socket.js +0 -63
- package/client/scene/scene-components.js +0 -3
- package/client/scene/scene-player.js +0 -103
- package/client/scene/scene-viewer.js +0 -106
- package/client/scene/things-scene-components.import +0 -1
- package/ormconfig.js +0 -31
- package/server/graphql-local-client.ts +0 -59
- package/server/index.ts +0 -13
- package/server/initializers/database.ts +0 -96
- package/server/initializers/naming-strategy.ts +0 -14
- package/server/middlewares/domain-middleware.ts +0 -60
- package/server/middlewares/index.ts +0 -43
- package/server/migrations/1000000000000-SeedDomain.ts +0 -37
- package/server/migrations/index.ts +0 -9
- package/server/pubsub-log-transport.ts +0 -59
- package/server/pubsub.ts +0 -84
- package/server/routers/domain-router.ts +0 -13
- package/server/routers/global-router.ts +0 -76
- package/server/routers/graphql-router.ts +0 -3
- package/server/routers/index.ts +0 -3
- package/server/schema.ts +0 -163
- package/server/server-dev.ts +0 -305
- package/server/server.ts +0 -296
- package/server/service/attribute-set/attribute-set-item-type.ts +0 -65
- package/server/service/attribute-set/attribute-set-mutation.ts +0 -125
- package/server/service/attribute-set/attribute-set-query.ts +0 -36
- package/server/service/attribute-set/attribute-set-type.ts +0 -46
- package/server/service/attribute-set/attribute-set.ts +0 -35
- package/server/service/attribute-set/index.ts +0 -6
- package/server/service/common-types/index.ts +0 -6
- package/server/service/common-types/list-param.ts +0 -61
- package/server/service/common-types/log.ts +0 -17
- package/server/service/common-types/object-ref.ts +0 -13
- package/server/service/common-types/scalar-any.ts +0 -44
- package/server/service/common-types/scalar-date.ts +0 -22
- package/server/service/common-types/scalar-object.ts +0 -15
- package/server/service/directive-transaction/index.ts +0 -1
- package/server/service/directive-transaction/transaction.ts +0 -40
- package/server/service/domain/domain-mutation.ts +0 -120
- package/server/service/domain/domain-query.ts +0 -55
- package/server/service/domain/domain-types.ts +0 -69
- package/server/service/domain/domain.ts +0 -112
- package/server/service/domain/index.ts +0 -6
- package/server/service/index.ts +0 -32
- package/server/service/subscription-data/data-resolver.ts +0 -37
- package/server/service/subscription-data/data-types.ts +0 -16
- package/server/service/subscription-data/index.ts +0 -4
- package/server/typeorm/encrypt-transform.ts +0 -70
- package/server/typeorm/get-data-encryption-key.ts +0 -13
- package/server/typeorm/json5-transform.ts +0 -26
- package/server/typeorm/round-transform.ts +0 -20
- package/server/utils/condition-builder.ts +0 -145
- package/server/utils/get-domain.ts +0 -228
- package/server/utils/get-query-builder-from-list-params.ts +0 -469
- package/server/utils/get-times-for-period.ts +0 -60
- package/server/utils/index.ts +0 -8
- package/server/utils/list-param-adjuster.ts +0 -21
- package/server/utils/list-params-converter.ts +0 -200
- package/server/utils/list-query-builder.ts +0 -120
- package/server/utils/publish-progress.ts +0 -23
@@ -1,125 +0,0 @@
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
2
|
-
import { In } from 'typeorm'
|
3
|
-
|
4
|
-
import { AttributeSet } from './attribute-set'
|
5
|
-
import { NewAttributeSet, AttributeSetPatch } from './attribute-set-type'
|
6
|
-
|
7
|
-
@Resolver(AttributeSet)
|
8
|
-
export class AttributeSetMutation {
|
9
|
-
@Directive('@transaction')
|
10
|
-
@Directive('@privilege(superUserGranted: true)')
|
11
|
-
@Mutation(returns => AttributeSet, { description: 'To create new AttributeSet' })
|
12
|
-
async createAttributeSet(@Arg('attribute') attribute: NewAttributeSet, @Ctx() context: any): Promise<AttributeSet> {
|
13
|
-
const { tx } = context.state
|
14
|
-
|
15
|
-
return await tx.getRepository(AttributeSet).save({
|
16
|
-
...attribute
|
17
|
-
})
|
18
|
-
}
|
19
|
-
|
20
|
-
@Directive('@transaction')
|
21
|
-
@Directive('@privilege(superUserGranted: true)')
|
22
|
-
@Mutation(returns => AttributeSet, { description: 'To modify AttributeSet information' })
|
23
|
-
async updateAttributeSet(
|
24
|
-
@Arg('id') id: string,
|
25
|
-
@Arg('patch') patch: AttributeSetPatch,
|
26
|
-
@Ctx() context: any
|
27
|
-
): Promise<AttributeSet> {
|
28
|
-
const { tx } = context.state
|
29
|
-
|
30
|
-
const repository = tx.getRepository(AttributeSet)
|
31
|
-
const attribute = await repository.findOne({
|
32
|
-
where: { id }
|
33
|
-
})
|
34
|
-
|
35
|
-
return await repository.save({
|
36
|
-
...attribute,
|
37
|
-
...patch
|
38
|
-
})
|
39
|
-
}
|
40
|
-
|
41
|
-
@Directive('@transaction')
|
42
|
-
@Directive('@privilege(superUserGranted: true)')
|
43
|
-
@Mutation(returns => [AttributeSet], { description: "To modify multiple AttributeSets' information" })
|
44
|
-
async updateMultipleAttributeSet(
|
45
|
-
@Arg('patches', type => [AttributeSetPatch]) patches: AttributeSetPatch[],
|
46
|
-
@Ctx() context: any
|
47
|
-
): Promise<AttributeSet[]> {
|
48
|
-
const { tx } = context.state
|
49
|
-
|
50
|
-
let results = []
|
51
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
52
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
53
|
-
const attributeRepo = tx.getRepository(AttributeSet)
|
54
|
-
|
55
|
-
if (_createRecords.length > 0) {
|
56
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
57
|
-
const newRecord = _createRecords[i]
|
58
|
-
|
59
|
-
const result = await attributeRepo.save({
|
60
|
-
...newRecord
|
61
|
-
})
|
62
|
-
|
63
|
-
results.push({ ...result, cuFlag: '+' })
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
if (_updateRecords.length > 0) {
|
68
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
69
|
-
const updateRecord = _updateRecords[i]
|
70
|
-
const attribute = await attributeRepo.findOneBy({ id: updateRecord.id })
|
71
|
-
|
72
|
-
const result = await attributeRepo.save({
|
73
|
-
...attribute,
|
74
|
-
...updateRecord
|
75
|
-
})
|
76
|
-
|
77
|
-
results.push({ ...result, cuFlag: 'M' })
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
return results
|
82
|
-
}
|
83
|
-
|
84
|
-
@Directive('@transaction')
|
85
|
-
@Directive('@privilege(superUserGranted: true)')
|
86
|
-
@Mutation(returns => Boolean, { description: 'To delete AttributeSet' })
|
87
|
-
async deleteAttributeSet(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {
|
88
|
-
const { tx } = context.state
|
89
|
-
|
90
|
-
await tx.getRepository(AttributeSet).delete({ id })
|
91
|
-
|
92
|
-
return true
|
93
|
-
}
|
94
|
-
|
95
|
-
@Directive('@transaction')
|
96
|
-
@Directive('@privilege(superUserGranted: true)')
|
97
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple AttributeSets' })
|
98
|
-
async deleteAttributeSets(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
|
99
|
-
const { tx } = context.state
|
100
|
-
|
101
|
-
await tx.getRepository(AttributeSet).delete({
|
102
|
-
id: In(ids)
|
103
|
-
})
|
104
|
-
|
105
|
-
return true
|
106
|
-
}
|
107
|
-
|
108
|
-
@Directive('@transaction')
|
109
|
-
@Directive('@privilege(superUserGranted: true)')
|
110
|
-
@Mutation(returns => Boolean, { description: 'To import multiple AttributeSets' })
|
111
|
-
async importAttributeSets(
|
112
|
-
@Arg('attributes', type => [AttributeSetPatch]) attributes: AttributeSetPatch[],
|
113
|
-
@Ctx() context: any
|
114
|
-
): Promise<boolean> {
|
115
|
-
const { tx } = context.state
|
116
|
-
|
117
|
-
await Promise.all(
|
118
|
-
attributes.map(async (attribute: AttributeSetPatch) => {
|
119
|
-
await tx.getRepository(AttributeSet).save(attribute)
|
120
|
-
})
|
121
|
-
)
|
122
|
-
|
123
|
-
return true
|
124
|
-
}
|
125
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
2
|
-
import { AttributeSet } from './attribute-set'
|
3
|
-
import { AttributeSetList } from './attribute-set-type'
|
4
|
-
import { ListParam } from '../common-types'
|
5
|
-
import { getRepository } from '../../initializers/database'
|
6
|
-
import { getQueryBuilderFromListParams } from '../../utils'
|
7
|
-
|
8
|
-
@Resolver(AttributeSet)
|
9
|
-
export class AttributeSetQuery {
|
10
|
-
@Query(returns => AttributeSet!, { nullable: true, description: 'To fetch a AttributeSet' })
|
11
|
-
async attributeSet(@Arg('id') id: string, @Ctx() context: any): Promise<AttributeSet> {
|
12
|
-
return await getRepository(AttributeSet).findOne({
|
13
|
-
where: { id }
|
14
|
-
})
|
15
|
-
}
|
16
|
-
|
17
|
-
@Query(returns => AttributeSet!, { nullable: true, description: 'To fetch a AttributeSet by Entity name' })
|
18
|
-
async attributeSetByEntity(@Arg('entity') entity: string, @Ctx() context: any): Promise<AttributeSet> {
|
19
|
-
return await getRepository(AttributeSet).findOne({
|
20
|
-
where: { entity }
|
21
|
-
})
|
22
|
-
}
|
23
|
-
|
24
|
-
@Query(returns => AttributeSetList, { description: 'To fetch multiple AttributeSets' })
|
25
|
-
async attributeSets(@Args(type => ListParam) params: ListParam, @Ctx() context: any): Promise<AttributeSetList> {
|
26
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
27
|
-
params,
|
28
|
-
repository: await getRepository(AttributeSet),
|
29
|
-
searchables: ['entity', 'description']
|
30
|
-
})
|
31
|
-
|
32
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
33
|
-
|
34
|
-
return { items, total }
|
35
|
-
}
|
36
|
-
}
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
2
|
-
|
3
|
-
import { AttributeSet } from './attribute-set'
|
4
|
-
import { AttributeSetItemPatch } from './attribute-set-item-type'
|
5
|
-
|
6
|
-
@InputType()
|
7
|
-
export class NewAttributeSet {
|
8
|
-
@Field()
|
9
|
-
entity: string
|
10
|
-
|
11
|
-
@Field({ nullable: true })
|
12
|
-
description?: string
|
13
|
-
|
14
|
-
@Field(type => [AttributeSetItemPatch], { nullable: true })
|
15
|
-
items?: AttributeSetItemPatch[]
|
16
|
-
|
17
|
-
@Field({ nullable: true })
|
18
|
-
active?: boolean
|
19
|
-
}
|
20
|
-
|
21
|
-
@InputType()
|
22
|
-
export class AttributeSetPatch {
|
23
|
-
@Field(type => ID, { nullable: true })
|
24
|
-
id?: string
|
25
|
-
|
26
|
-
@Field({ nullable: true })
|
27
|
-
entity?: string
|
28
|
-
|
29
|
-
@Field({ nullable: true })
|
30
|
-
description?: string
|
31
|
-
|
32
|
-
@Field(type => [AttributeSetItemPatch], { nullable: true })
|
33
|
-
items?: AttributeSetItemPatch[]
|
34
|
-
|
35
|
-
@Field({ nullable: true })
|
36
|
-
cuFlag?: string
|
37
|
-
}
|
38
|
-
|
39
|
-
@ObjectType()
|
40
|
-
export class AttributeSetList {
|
41
|
-
@Field(type => [AttributeSet])
|
42
|
-
items: AttributeSet[]
|
43
|
-
|
44
|
-
@Field(type => Int)
|
45
|
-
total: number
|
46
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { CreateDateColumn, UpdateDateColumn, Entity, Index, Column, PrimaryGeneratedColumn } from 'typeorm'
|
2
|
-
import { ObjectType, Field, ID } from 'type-graphql'
|
3
|
-
|
4
|
-
import { AttributeSetItem } from './attribute-set-item-type'
|
5
|
-
|
6
|
-
@Entity()
|
7
|
-
@Index('ix_attribute_set_0', (attributeSet: AttributeSet) => [attributeSet.entity], {
|
8
|
-
unique: true
|
9
|
-
})
|
10
|
-
@ObjectType({ description: 'Entity for AttributeSet' })
|
11
|
-
export class AttributeSet {
|
12
|
-
@PrimaryGeneratedColumn('uuid')
|
13
|
-
@Field(type => ID)
|
14
|
-
readonly id: string
|
15
|
-
|
16
|
-
@Column({ nullable: true, default: '' })
|
17
|
-
@Field({ nullable: true })
|
18
|
-
entity: string = ''
|
19
|
-
|
20
|
-
@Column({ nullable: true, default: '' })
|
21
|
-
@Field({ nullable: true })
|
22
|
-
description: string = ''
|
23
|
-
|
24
|
-
@Column('simple-json', { nullable: true })
|
25
|
-
@Field(type => [AttributeSetItem], { nullable: true })
|
26
|
-
items: AttributeSetItem[]
|
27
|
-
|
28
|
-
@CreateDateColumn()
|
29
|
-
@Field({ nullable: true })
|
30
|
-
createdAt?: Date
|
31
|
-
|
32
|
-
@UpdateDateColumn()
|
33
|
-
@Field({ nullable: true })
|
34
|
-
updatedAt?: Date
|
35
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { AttributeSet } from './attribute-set'
|
2
|
-
import { AttributeSetQuery } from './attribute-set-query'
|
3
|
-
import { AttributeSetMutation } from './attribute-set-mutation'
|
4
|
-
|
5
|
-
export const entities = [AttributeSet]
|
6
|
-
export const resolvers = [AttributeSetQuery, AttributeSetMutation]
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import { ArgsType, Field, InputType, Int, registerEnumType } from 'type-graphql'
|
2
|
-
|
3
|
-
import { ScalarAny } from './scalar-any'
|
4
|
-
|
5
|
-
export enum InheritedValueType {
|
6
|
-
None = 'None',
|
7
|
-
Only = 'Only',
|
8
|
-
Include = 'Include'
|
9
|
-
}
|
10
|
-
|
11
|
-
registerEnumType(InheritedValueType, {
|
12
|
-
name: 'InheritedValueType'
|
13
|
-
})
|
14
|
-
|
15
|
-
@InputType()
|
16
|
-
export class Sorting {
|
17
|
-
@Field({ description: 'Field name to sort by' })
|
18
|
-
name: string
|
19
|
-
|
20
|
-
@Field({ nullable: true, description: 'Set to true if descending sort. Default is "false"' })
|
21
|
-
desc?: boolean
|
22
|
-
}
|
23
|
-
|
24
|
-
@InputType()
|
25
|
-
export class Pagination {
|
26
|
-
@Field(type => Int, { nullable: true })
|
27
|
-
page?: number
|
28
|
-
|
29
|
-
@Field(type => Int, { nullable: true })
|
30
|
-
limit?: number
|
31
|
-
}
|
32
|
-
|
33
|
-
@InputType()
|
34
|
-
export class Filter {
|
35
|
-
@Field()
|
36
|
-
name: string
|
37
|
-
|
38
|
-
@Field()
|
39
|
-
operator: string
|
40
|
-
|
41
|
-
@Field(type => ScalarAny, { nullable: true })
|
42
|
-
value?: any
|
43
|
-
|
44
|
-
@Field({ nullable: true })
|
45
|
-
relation?: boolean
|
46
|
-
}
|
47
|
-
|
48
|
-
@ArgsType()
|
49
|
-
export class ListParam {
|
50
|
-
@Field(type => [Filter], { nullable: true })
|
51
|
-
filters?: Filter[]
|
52
|
-
|
53
|
-
@Field(type => Pagination, { nullable: true })
|
54
|
-
pagination?: Pagination
|
55
|
-
|
56
|
-
@Field(type => [Sorting], { nullable: true })
|
57
|
-
sortings?: Sorting[]
|
58
|
-
|
59
|
-
@Field(type => InheritedValueType, { nullable: true })
|
60
|
-
inherited?: InheritedValueType
|
61
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { ObjectType, Field } from 'type-graphql'
|
2
|
-
import { ScalarObject } from './scalar-object'
|
3
|
-
|
4
|
-
@ObjectType()
|
5
|
-
export class Log {
|
6
|
-
@Field(() => ScalarObject, { description: 'the source of the log' })
|
7
|
-
source: object
|
8
|
-
|
9
|
-
@Field({ description: 'log level (error, warning, info, ..)' })
|
10
|
-
level: string
|
11
|
-
|
12
|
-
@Field({ description: 'log body message' })
|
13
|
-
message: string
|
14
|
-
|
15
|
-
@Field({ description: 'timestamp the log occurred' })
|
16
|
-
timestamp: string
|
17
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { InputType, Field, ID } from 'type-graphql'
|
2
|
-
|
3
|
-
@InputType()
|
4
|
-
export class ObjectRef {
|
5
|
-
@Field(() => ID, { description: 'Field id' })
|
6
|
-
id: string
|
7
|
-
|
8
|
-
@Field({ nullable: true, description: 'Field name' })
|
9
|
-
name?: string
|
10
|
-
|
11
|
-
@Field({ nullable: true, description: 'Field description' })
|
12
|
-
description?: string
|
13
|
-
}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { GraphQLScalarType, Kind } from 'graphql'
|
2
|
-
|
3
|
-
function parseObject(ast) {
|
4
|
-
const value = Object.create(null)
|
5
|
-
ast.fields.forEach(field => {
|
6
|
-
value[field.name.value] = parseAst(field.value)
|
7
|
-
})
|
8
|
-
return value
|
9
|
-
}
|
10
|
-
|
11
|
-
function parseAst(ast) {
|
12
|
-
switch (ast.kind) {
|
13
|
-
case Kind.INT:
|
14
|
-
return parseInt(ast.value)
|
15
|
-
case Kind.FLOAT:
|
16
|
-
return parseFloat(ast.value)
|
17
|
-
case Kind.BOOLEAN:
|
18
|
-
return ast.value
|
19
|
-
case Kind.STRING:
|
20
|
-
return ast.value
|
21
|
-
case Kind.LIST:
|
22
|
-
return ast.values.map(parseAst)
|
23
|
-
case Kind.OBJECT:
|
24
|
-
return parseObject(ast)
|
25
|
-
default:
|
26
|
-
return null
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
export const ScalarAny = new GraphQLScalarType({
|
31
|
-
name: 'Any',
|
32
|
-
description: 'Any Scalar type (String, Boolean, Int, Float, Object, List)',
|
33
|
-
serialize(value) {
|
34
|
-
// Implement your own behavior here by setting the 'result' variable
|
35
|
-
return value
|
36
|
-
},
|
37
|
-
parseValue(value) {
|
38
|
-
// Implement your own behavior here by setting the 'result' variable
|
39
|
-
return value
|
40
|
-
},
|
41
|
-
parseLiteral(ast) {
|
42
|
-
return parseAst(ast)
|
43
|
-
}
|
44
|
-
})
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { GraphQLScalarType, Kind } from 'graphql'
|
2
|
-
|
3
|
-
export const ScalarDate = new GraphQLScalarType({
|
4
|
-
name: 'Date',
|
5
|
-
description: 'Date custom scalar type',
|
6
|
-
parseValue(value) {
|
7
|
-
return new Date(value as string | number) // value from the client
|
8
|
-
},
|
9
|
-
serialize(value) {
|
10
|
-
/**
|
11
|
-
* Note: Allow value to be date only like "2021-01-31" to be serialize before passing data to clientside for TypeGraphql.
|
12
|
-
* Usage: When database column datatype is "date" and data do not contain any time component.
|
13
|
-
*/
|
14
|
-
return new Date(value as any).getTime() // value sent to the client
|
15
|
-
},
|
16
|
-
parseLiteral(ast) {
|
17
|
-
if (ast.kind === Kind.INT) {
|
18
|
-
return new Date(+ast.value) // ast value is always in string format
|
19
|
-
}
|
20
|
-
return null
|
21
|
-
}
|
22
|
-
})
|
@@ -1,15 +0,0 @@
|
|
1
|
-
const { GraphQLScalarType } = require('graphql')
|
2
|
-
|
3
|
-
export const ScalarObject = new GraphQLScalarType({
|
4
|
-
name: 'Object',
|
5
|
-
description: 'Can be anything',
|
6
|
-
parseValue(value) {
|
7
|
-
return value
|
8
|
-
},
|
9
|
-
serialize(value) {
|
10
|
-
return value
|
11
|
-
},
|
12
|
-
parseLiteral(ast) {
|
13
|
-
return ast
|
14
|
-
}
|
15
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './transaction'
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { defaultFieldResolver, GraphQLSchema } from 'graphql'
|
2
|
-
import gql from 'graphql-tag'
|
3
|
-
|
4
|
-
import { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils'
|
5
|
-
|
6
|
-
import { getDataSource } from '../../initializers/database'
|
7
|
-
|
8
|
-
const DIRECTIVE = 'transaction'
|
9
|
-
|
10
|
-
export const transactionDirectiveTypeDefs = gql`
|
11
|
-
directive @${DIRECTIVE} on FIELD_DEFINITION
|
12
|
-
`
|
13
|
-
export const transactionDirectiveResolver = (schema: GraphQLSchema) =>
|
14
|
-
mapSchema(schema, {
|
15
|
-
[MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName) => {
|
16
|
-
const transactionDirective = getDirective(schema, fieldConfig, DIRECTIVE)?.[0]
|
17
|
-
if (transactionDirective) {
|
18
|
-
const { resolve = defaultFieldResolver } = fieldConfig
|
19
|
-
|
20
|
-
fieldConfig.resolve = async function (source, args, context, info) {
|
21
|
-
return await getDataSource('tx').transaction(async tx => {
|
22
|
-
/* local-graphql-client로부터 invoke인 경우에는 context.req, context.res 가 없으므로, 빈 오브젝트로 대체해준다. */
|
23
|
-
let wrap = context.app.createContext(context.req || {}, context.res || {})
|
24
|
-
|
25
|
-
wrap.state = {
|
26
|
-
...context.state,
|
27
|
-
tx
|
28
|
-
}
|
29
|
-
wrap.t = context.t
|
30
|
-
|
31
|
-
let result = await resolve.call(this, source, args, wrap, info)
|
32
|
-
|
33
|
-
return result
|
34
|
-
})
|
35
|
-
}
|
36
|
-
|
37
|
-
return fieldConfig
|
38
|
-
}
|
39
|
-
}
|
40
|
-
})
|
@@ -1,120 +0,0 @@
|
|
1
|
-
import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver, Root } from 'type-graphql'
|
2
|
-
import { In, Repository } from 'typeorm'
|
3
|
-
|
4
|
-
import { slugger } from '@things-factory/utils'
|
5
|
-
|
6
|
-
import { getRepository } from '../../initializers/database'
|
7
|
-
|
8
|
-
import { Domain, IPList } from './domain'
|
9
|
-
import { DomainPatch } from './domain-types'
|
10
|
-
import { ScalarObject } from '../common-types'
|
11
|
-
|
12
|
-
@Resolver(Domain)
|
13
|
-
export class DomainMutation {
|
14
|
-
@Directive('@transaction')
|
15
|
-
@Directive('@privilege(superUserGranted: true)')
|
16
|
-
@Mutation(returns => Domain, { description: 'To create domain (Only superuser is granted this privilege.)' })
|
17
|
-
async createDomain(@Arg('domainInput') domainInput: DomainPatch) {
|
18
|
-
const { name, description } = domainInput
|
19
|
-
const domainRepo: Repository<Domain> = getRepository(Domain)
|
20
|
-
const subdomain: string = slugger(name)
|
21
|
-
|
22
|
-
const domain: Domain = await domainRepo.findOneBy({ subdomain })
|
23
|
-
if (domain) {
|
24
|
-
throw new Error('domain is duplicated')
|
25
|
-
}
|
26
|
-
|
27
|
-
return await domainRepo.save({ name, description, subdomain })
|
28
|
-
}
|
29
|
-
|
30
|
-
@Directive('@transaction')
|
31
|
-
@Directive('@privilege(superUserGranted: true)')
|
32
|
-
@Mutation(returns => Domain, { description: 'To delete domain (Only superuser is granted this privilege.)' })
|
33
|
-
async deleteDomain(@Arg('name') name: string) {
|
34
|
-
return await getRepository(Domain).delete({ name })
|
35
|
-
}
|
36
|
-
|
37
|
-
@Directive('@transaction')
|
38
|
-
@Directive('@privilege(superUserGranted: true)')
|
39
|
-
@Mutation(returns => Boolean, {
|
40
|
-
description: 'To delete multiple domains (Only superuser is granted this privilege.)'
|
41
|
-
})
|
42
|
-
async deleteDomains(@Arg('names', () => [String]) names: string[]) {
|
43
|
-
const domains: Domain[] = await getRepository(Domain).find({ where: { name: In(names) } })
|
44
|
-
const domainIds: string[] = domains.map(domain => domain.id)
|
45
|
-
|
46
|
-
await getRepository(Domain).delete({ id: In(domainIds) })
|
47
|
-
}
|
48
|
-
|
49
|
-
@Directive('@transaction')
|
50
|
-
@Directive('@privilege(superUserGranted: true)')
|
51
|
-
@Mutation(returns => Domain, {
|
52
|
-
description: 'To update domain (Only superuser is granted this privilege.)'
|
53
|
-
})
|
54
|
-
async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {
|
55
|
-
const repository = getRepository(Domain)
|
56
|
-
const domain: Domain = await repository.findOneBy({ name })
|
57
|
-
|
58
|
-
if (patch.parent && patch.parent.id == domain.id) {
|
59
|
-
delete patch.parent
|
60
|
-
}
|
61
|
-
|
62
|
-
return await repository.save({
|
63
|
-
...domain,
|
64
|
-
...patch
|
65
|
-
} as any)
|
66
|
-
}
|
67
|
-
|
68
|
-
@Directive('@transaction')
|
69
|
-
@Directive('@privilege(superUserGranted: true)')
|
70
|
-
@Mutation(returns => Boolean, {
|
71
|
-
description: 'To update multiple domains (Only superuser is granted this privilege.)'
|
72
|
-
})
|
73
|
-
async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {
|
74
|
-
const domainRepo: Repository<Domain> = getRepository(Domain)
|
75
|
-
|
76
|
-
const patchIds = patches.filter((patch: any) => patch.id)
|
77
|
-
|
78
|
-
if (patchIds.length > 0) {
|
79
|
-
patchIds.forEach(async updateRecord => {
|
80
|
-
const domain: Domain = await domainRepo.findOne({ where: { id: updateRecord.id } })
|
81
|
-
|
82
|
-
if (updateRecord.name) {
|
83
|
-
updateRecord.subdomain = slugger(updateRecord.name)
|
84
|
-
}
|
85
|
-
|
86
|
-
if (updateRecord.parent && updateRecord.parent.id == domain.id) {
|
87
|
-
delete updateRecord.parent
|
88
|
-
}
|
89
|
-
|
90
|
-
await domainRepo.save({
|
91
|
-
...domain,
|
92
|
-
...updateRecord
|
93
|
-
} as any)
|
94
|
-
})
|
95
|
-
}
|
96
|
-
|
97
|
-
return true
|
98
|
-
}
|
99
|
-
|
100
|
-
@Directive('@transaction')
|
101
|
-
@Directive(
|
102
|
-
'@privilege(category: "security", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'
|
103
|
-
)
|
104
|
-
@Mutation(returns => ScalarObject, { nullable: true, description: 'To update secure IP list for domain' })
|
105
|
-
async updateSecureIPList(
|
106
|
-
@Arg('iplist', type => ScalarObject) iplist: IPList,
|
107
|
-
@Ctx() context: any
|
108
|
-
): Promise<IPList | null> {
|
109
|
-
const { domain } = context.state
|
110
|
-
const repository = getRepository(Domain)
|
111
|
-
// const domain: Domain = await repository.findOneBy({ id })
|
112
|
-
|
113
|
-
const { iplist: result } = await repository.save({
|
114
|
-
...domain,
|
115
|
-
iplist
|
116
|
-
} as any)
|
117
|
-
|
118
|
-
return result
|
119
|
-
}
|
120
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver, FieldResolver, Root } from 'type-graphql'
|
2
|
-
import { In, Repository } from 'typeorm'
|
3
|
-
|
4
|
-
import { getRepository } from '../../initializers/database'
|
5
|
-
import { getQueryBuilderFromListParams } from '../../utils/get-query-builder-from-list-params'
|
6
|
-
|
7
|
-
import { ListParam } from '../common-types/list-param.js'
|
8
|
-
import { Domain, IPList } from './domain.js'
|
9
|
-
import { DomainList } from './domain-types.js'
|
10
|
-
import { ScalarObject } from '../common-types/scalar-object.js'
|
11
|
-
import { config } from '@things-factory/env'
|
12
|
-
|
13
|
-
@Resolver(Domain)
|
14
|
-
export class DomainQuery {
|
15
|
-
@Directive('@privilege(superUserGranted: true)')
|
16
|
-
@Query(returns => [String], { description: 'To fetch domain' })
|
17
|
-
async domainTypes(@Ctx() context: any): Promise<String[]> {
|
18
|
-
return config.get('domainTypes') || ['domain']
|
19
|
-
}
|
20
|
-
|
21
|
-
@Directive('@privilege(superUserGranted: true)')
|
22
|
-
@Query(returns => Domain, { description: 'To fetch domain' })
|
23
|
-
async domain(@Arg('id') id: string, @Ctx() context: any): Promise<Domain> {
|
24
|
-
const repository = getRepository(Domain)
|
25
|
-
|
26
|
-
return await repository.findOneBy({ id })
|
27
|
-
}
|
28
|
-
|
29
|
-
@Directive('@privilege(superUserGranted: true)')
|
30
|
-
@Query(returns => DomainList, { description: 'To fetch all domains (Only superuser is granted this privilege.)' })
|
31
|
-
async domains(@Args(type => ListParam) params: ListParam, @Ctx() context: any): Promise<DomainList> {
|
32
|
-
const queryBuilder = await getQueryBuilderFromListParams({
|
33
|
-
repository: getRepository(Domain),
|
34
|
-
alias: 'ContactPoint',
|
35
|
-
params,
|
36
|
-
searchables: ['name', 'description', 'subdomain']
|
37
|
-
})
|
38
|
-
|
39
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
40
|
-
|
41
|
-
return { items, total }
|
42
|
-
}
|
43
|
-
|
44
|
-
@Directive('@privilege(category: "security", privilege: "query", domainOwnerGranted: true, superUserGranted: true)')
|
45
|
-
@Query(returns => ScalarObject, { nullable: true, description: 'To fetch domain' })
|
46
|
-
async secureIPList(@Ctx() context: any): Promise<IPList | null> {
|
47
|
-
const { domain } = context.state
|
48
|
-
return domain.iplist
|
49
|
-
}
|
50
|
-
|
51
|
-
@FieldResolver(type => Domain)
|
52
|
-
async parent(@Root() domain: Domain): Promise<Domain> {
|
53
|
-
return domain.parentId && (await getRepository(Domain).findOneBy({ id: domain.parentId }))
|
54
|
-
}
|
55
|
-
}
|