@things-factory/shell 6.0.0-zeta.27 → 6.0.0-zeta.40
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/dist-server/graphql-local-client.d.ts +3 -3
- package/dist-server/service/domain/domain-resolver.js +18 -6
- package/dist-server/service/domain/domain-resolver.js.map +1 -1
- package/dist-server/service/domain/domain-types.d.ts +2 -0
- package/dist-server/service/domain/domain-types.js +5 -0
- package/dist-server/service/domain/domain-types.js.map +1 -1
- package/dist-server/service/domain/domain.js +12 -11
- package/dist-server/service/domain/domain.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/service/domain/domain-resolver.ts +22 -7
- package/server/service/domain/domain-types.ts +4 -0
- package/server/service/domain/domain.ts +30 -29
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "6.0.0-zeta.
|
3
|
+
"version": "6.0.0-zeta.40",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"@operato/typeorm-history": "^1.1.65",
|
53
53
|
"@operato/utils": "^1.0.1",
|
54
54
|
"@things-factory/ejs-remote": "^6.0.0-zeta.1",
|
55
|
-
"@things-factory/env": "^6.0.0-zeta.
|
55
|
+
"@things-factory/env": "^6.0.0-zeta.30",
|
56
56
|
"@things-factory/styles": "^6.0.0-zeta.27",
|
57
57
|
"@things-factory/utils": "^6.0.0-zeta.27",
|
58
58
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
@@ -131,5 +131,5 @@
|
|
131
131
|
"pg": "^8.7.3",
|
132
132
|
"sqlite3": "^5.0.8"
|
133
133
|
},
|
134
|
-
"gitHead": "
|
134
|
+
"gitHead": "8f2076b1512cc74d339c08577690a0c42fe4d3c3"
|
135
135
|
}
|
@@ -4,7 +4,8 @@ import { In, Repository } from 'typeorm'
|
|
4
4
|
import { slugger } from '@things-factory/utils'
|
5
5
|
|
6
6
|
import { getRepository } from '../../initializers/database'
|
7
|
-
import {
|
7
|
+
import { getQueryBuilderFromListParams } from '../../utils/get-query-builder-from-list-params'
|
8
|
+
|
8
9
|
import { ListParam } from '../common-types/list-param'
|
9
10
|
import { Domain } from './domain'
|
10
11
|
import { DomainList, DomainPatch } from './domain-types'
|
@@ -22,12 +23,13 @@ export class DomainResolver {
|
|
22
23
|
@Directive('@privilege(category: "system", privilege: "query", superUserGranted: true)')
|
23
24
|
@Query(returns => DomainList, { description: 'To fetch multiple domain' })
|
24
25
|
async domains(@Args() params: ListParam, @Ctx() context: any): Promise<DomainList> {
|
25
|
-
const queryBuilder =
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
const queryBuilder = await getQueryBuilderFromListParams({
|
27
|
+
repository: getRepository(Domain),
|
28
|
+
alias: 'ContactPoint',
|
29
|
+
params,
|
29
30
|
searchables: ['name', 'description', 'subdomain']
|
30
31
|
})
|
32
|
+
|
31
33
|
const [items, total] = await queryBuilder.getManyAndCount()
|
32
34
|
|
33
35
|
return { items, total }
|
@@ -46,6 +48,7 @@ export class DomainResolver {
|
|
46
48
|
return true
|
47
49
|
}
|
48
50
|
|
51
|
+
@Directive('@transaction')
|
49
52
|
@Directive('@privilege(category: "system", privilege: "mutation", superUserGranted: true)')
|
50
53
|
@Mutation(returns => Domain, { description: 'To create domain' })
|
51
54
|
async createDomain(@Arg('domainInput') domainInput: DomainPatch) {
|
@@ -61,12 +64,14 @@ export class DomainResolver {
|
|
61
64
|
return await domainRepo.save({ name, description, subdomain })
|
62
65
|
}
|
63
66
|
|
67
|
+
@Directive('@transaction')
|
64
68
|
@Directive('@privilege(category: "system", privilege: "mutation", superUserGranted: true)')
|
65
69
|
@Mutation(returns => Domain, { description: 'To delete domain' })
|
66
70
|
async deleteDomain(@Arg('name') name: string) {
|
67
71
|
return await getRepository(Domain).delete({ name })
|
68
72
|
}
|
69
73
|
|
74
|
+
@Directive('@transaction')
|
70
75
|
@Directive('@privilege(category: "system", privilege: "mutation", superUserGranted: true)')
|
71
76
|
@Mutation(returns => Boolean, { description: 'To delete multiple domains' })
|
72
77
|
async deleteDomains(@Arg('names', () => [String]) names: string[]) {
|
@@ -76,18 +81,24 @@ export class DomainResolver {
|
|
76
81
|
await getRepository(Domain).delete({ id: In(domainIds) })
|
77
82
|
}
|
78
83
|
|
84
|
+
@Directive('@transaction')
|
79
85
|
@Directive('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)')
|
80
86
|
@Mutation(returns => Domain, { description: 'To update domain' })
|
81
87
|
async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {
|
82
88
|
const repository = getRepository(Domain)
|
83
89
|
const domain: Domain = await repository.findOneBy({ name })
|
84
90
|
|
91
|
+
var owner = patch.ownerUser?.id
|
92
|
+
delete patch.ownerUser
|
93
|
+
|
85
94
|
return await repository.save({
|
86
95
|
...domain,
|
87
|
-
...patch
|
96
|
+
...patch,
|
97
|
+
owner
|
88
98
|
} as any)
|
89
99
|
}
|
90
100
|
|
101
|
+
@Directive('@transaction')
|
91
102
|
@Directive('@privilege(category: "system", privilege: "mutation", superUserGranted: true)')
|
92
103
|
@Mutation(returns => Boolean, { description: 'To update multiple domains' })
|
93
104
|
async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {
|
@@ -103,9 +114,13 @@ export class DomainResolver {
|
|
103
114
|
updateRecord.subdomain = slugger(updateRecord.name)
|
104
115
|
}
|
105
116
|
|
117
|
+
var owner = updateRecord.ownerUser?.id
|
118
|
+
delete updateRecord.ownerUser
|
119
|
+
|
106
120
|
await domainRepo.save({
|
107
121
|
...domain,
|
108
|
-
...updateRecord
|
122
|
+
...updateRecord,
|
123
|
+
owner
|
109
124
|
} as any)
|
110
125
|
})
|
111
126
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { ObjectType, InputType, Field, Int } from 'type-graphql'
|
2
2
|
import { Domain } from './domain'
|
3
|
+
import { ObjectRef } from '../common-types/object-ref'
|
3
4
|
|
4
5
|
@InputType()
|
5
6
|
export class DomainInput {
|
@@ -41,6 +42,9 @@ export class DomainPatch {
|
|
41
42
|
|
42
43
|
@Field({ nullable: true })
|
43
44
|
theme?: string
|
45
|
+
|
46
|
+
@Field(type => ObjectRef, { nullable: true })
|
47
|
+
ownerUser?: ObjectRef
|
44
48
|
}
|
45
49
|
|
46
50
|
@ObjectType()
|
@@ -2,9 +2,9 @@ import { Column, CreateDateColumn, Entity, Index, UpdateDateColumn } from 'typeo
|
|
2
2
|
import { ObjectType, Field, ID } from 'type-graphql'
|
3
3
|
import { config } from '@things-factory/env'
|
4
4
|
|
5
|
-
const numericTypes = [
|
6
|
-
const generatedStrategy = ['uuid','rowid',
|
7
|
-
const domainPrimaryOption =config.get('domainPrimaryOption')
|
5
|
+
const numericTypes = ['int', 'int2', 'int4', 'int8', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint']
|
6
|
+
const generatedStrategy = ['uuid', 'rowid', 'increment', 'identity']
|
7
|
+
const domainPrimaryOption = config.get('domainPrimaryOption')
|
8
8
|
const domainPrimaryType = domainPrimaryOption?.type
|
9
9
|
const domainPrimaryStrategy = domainPrimaryOption?.strategy
|
10
10
|
|
@@ -14,33 +14,34 @@ const domainPrimaryStrategy = domainPrimaryOption?.strategy
|
|
14
14
|
export class Domain {
|
15
15
|
@Field(type => ID)
|
16
16
|
@Column(
|
17
|
-
domainPrimaryOption
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
17
|
+
domainPrimaryOption
|
18
|
+
? {
|
19
|
+
type: domainPrimaryType,
|
20
|
+
primary: true,
|
21
|
+
transformer: {
|
22
|
+
//from(value: DatabaseType): EntityType
|
23
|
+
from: value => {
|
24
|
+
return value
|
25
|
+
},
|
26
|
+
//to(value: EntityType): DatabaseType
|
27
|
+
to: value => {
|
28
|
+
if (!value) {
|
29
|
+
value = 0
|
30
|
+
}
|
31
|
+
if (numericTypes.indexOf(domainPrimaryType) >= 0) {
|
32
|
+
return parseInt(value)
|
33
|
+
} else {
|
34
|
+
return value
|
35
|
+
}
|
36
|
+
}
|
37
|
+
},
|
38
|
+
generated: generatedStrategy.indexOf(domainPrimaryStrategy) >= 0 ? domainPrimaryStrategy : false
|
39
|
+
}
|
40
|
+
: {
|
41
|
+
type: 'uuid',
|
42
|
+
primary: true,
|
43
|
+
generated: 'uuid'
|
36
44
|
}
|
37
|
-
},
|
38
|
-
generated:generatedStrategy.indexOf(domainPrimaryStrategy)>=0?domainPrimaryStrategy:false
|
39
|
-
}:{
|
40
|
-
type: 'uuid',
|
41
|
-
primary:true,
|
42
|
-
generated:'uuid'
|
43
|
-
}
|
44
45
|
)
|
45
46
|
readonly id: string
|
46
47
|
|