@things-factory/code-base 5.0.11 → 6.0.0-alpha.3
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/service/common-code/common-code-mutation.js +10 -7
- package/dist-server/service/common-code/common-code-mutation.js.map +1 -1
- package/dist-server/service/common-code/common-code-query.js +11 -13
- package/dist-server/service/common-code/common-code-query.js.map +1 -1
- package/dist-server/service/common-code/common-code.js +3 -4
- package/dist-server/service/common-code/common-code.js.map +1 -1
- package/dist-server/service/common-code-detail/common-code-detail-mutation.js +8 -8
- package/dist-server/service/common-code-detail/common-code-detail-mutation.js.map +1 -1
- package/dist-server/service/common-code-detail/common-code-detail-query.js +8 -10
- package/dist-server/service/common-code-detail/common-code-detail-query.js.map +1 -1
- package/dist-server/service/common-code-detail/common-code-detail-type.js +2 -3
- package/dist-server/service/common-code-detail/common-code-detail-type.js.map +1 -1
- package/dist-server/service/common-code-detail/common-code-detail.js +3 -4
- package/dist-server/service/common-code-detail/common-code-detail.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/service/common-code/common-code-mutation.ts +24 -14
- package/server/service/common-code/common-code-query.ts +11 -12
- package/server/service/common-code-detail/common-code-detail-mutation.ts +17 -14
- package/server/service/common-code-detail/common-code-detail-query.ts +8 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/code-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@things-factory/auth-base": "^
|
|
27
|
+
"@things-factory/auth-base": "^6.0.0-alpha.3"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1e273b6485662da938cae8fdca035d994ef4a95d"
|
|
30
30
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import {
|
|
2
|
+
import { In } from 'typeorm'
|
|
3
|
+
|
|
4
|
+
import { getRepository } from '@things-factory/shell'
|
|
3
5
|
|
|
4
6
|
import { CommonCodeDetail } from '../common-code-detail/common-code-detail'
|
|
5
7
|
import { CommonCode } from './common-code'
|
|
@@ -9,7 +11,10 @@ import { CommonCodePatch, NewCommonCode } from './common-code-type'
|
|
|
9
11
|
export class CommonCodeMutation {
|
|
10
12
|
@Directive('@transaction')
|
|
11
13
|
@Mutation(returns => CommonCode, { description: 'To create new CommonCode' })
|
|
12
|
-
async createCommonCode(
|
|
14
|
+
async createCommonCode(
|
|
15
|
+
@Arg('commonCode') commonCode: NewCommonCode,
|
|
16
|
+
@Ctx() context: ResolverContext
|
|
17
|
+
): Promise<CommonCode> {
|
|
13
18
|
const { domain, user, tx } = context.state
|
|
14
19
|
|
|
15
20
|
const details = await getRepository(CommonCodeDetail).findByIds(commonCode.details || [])
|
|
@@ -28,13 +33,13 @@ export class CommonCodeMutation {
|
|
|
28
33
|
async updateCommonCode(
|
|
29
34
|
@Arg('name') name: string,
|
|
30
35
|
@Arg('patch') patch: CommonCodePatch,
|
|
31
|
-
@Ctx() context:
|
|
36
|
+
@Ctx() context: ResolverContext
|
|
32
37
|
): Promise<CommonCode> {
|
|
33
38
|
const { domain, user, tx } = context.state
|
|
34
39
|
|
|
35
40
|
const repository = tx.getRepository(CommonCode)
|
|
36
41
|
const commonCode = await repository.findOne({
|
|
37
|
-
where: { domain, name },
|
|
42
|
+
where: { domain: { id: domain.id }, name },
|
|
38
43
|
relations: ['details']
|
|
39
44
|
})
|
|
40
45
|
|
|
@@ -59,7 +64,7 @@ export class CommonCodeMutation {
|
|
|
59
64
|
@Mutation(returns => [CommonCode], { description: "To modify multiple CommonCodes' information" })
|
|
60
65
|
async updateMultipleCommonCode(
|
|
61
66
|
@Arg('patches', type => [CommonCodePatch]) patches: CommonCodePatch[],
|
|
62
|
-
@Ctx() context:
|
|
67
|
+
@Ctx() context: ResolverContext
|
|
63
68
|
): Promise<CommonCode[]> {
|
|
64
69
|
const { domain, user, tx } = context.state
|
|
65
70
|
|
|
@@ -73,7 +78,7 @@ export class CommonCodeMutation {
|
|
|
73
78
|
const newRecord = _createRecords[i]
|
|
74
79
|
|
|
75
80
|
const result = await commonCodeRepo.save({
|
|
76
|
-
...newRecord,
|
|
81
|
+
...(newRecord as any),
|
|
77
82
|
domain,
|
|
78
83
|
creator: user,
|
|
79
84
|
updater: user
|
|
@@ -86,11 +91,11 @@ export class CommonCodeMutation {
|
|
|
86
91
|
if (_updateRecords.length > 0) {
|
|
87
92
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
88
93
|
const newRecord = _updateRecords[i]
|
|
89
|
-
const commonCode = await commonCodeRepo.
|
|
94
|
+
const commonCode = await commonCodeRepo.findOneBy({ id: newRecord.id })
|
|
90
95
|
|
|
91
96
|
const result = await commonCodeRepo.save({
|
|
92
97
|
...commonCode,
|
|
93
|
-
...newRecord,
|
|
98
|
+
...(newRecord as any),
|
|
94
99
|
updater: user
|
|
95
100
|
})
|
|
96
101
|
|
|
@@ -103,20 +108,23 @@ export class CommonCodeMutation {
|
|
|
103
108
|
|
|
104
109
|
@Directive('@transaction')
|
|
105
110
|
@Mutation(returns => Boolean, { description: 'To delete CommonCode' })
|
|
106
|
-
async deleteCommonCode(@Arg('id') id: string, @Ctx() context:
|
|
111
|
+
async deleteCommonCode(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
107
112
|
const { domain, tx } = context.state
|
|
108
113
|
|
|
109
|
-
await tx.getRepository(CommonCode).delete({ domain, id })
|
|
114
|
+
await tx.getRepository(CommonCode).delete({ domain: { id: domain.id }, id })
|
|
110
115
|
return true
|
|
111
116
|
}
|
|
112
117
|
|
|
113
118
|
@Directive('@transaction')
|
|
114
119
|
@Mutation(returns => Boolean, { description: 'To delete multiple CommonCodes' })
|
|
115
|
-
async deleteCommonCodes(
|
|
120
|
+
async deleteCommonCodes(
|
|
121
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
122
|
+
@Ctx() context: ResolverContext
|
|
123
|
+
): Promise<boolean> {
|
|
116
124
|
const { domain, tx } = context.state
|
|
117
125
|
|
|
118
126
|
await tx.getRepository(CommonCode).delete({
|
|
119
|
-
domain,
|
|
127
|
+
domain: { id: domain.id },
|
|
120
128
|
id: In(ids)
|
|
121
129
|
})
|
|
122
130
|
|
|
@@ -127,13 +135,15 @@ export class CommonCodeMutation {
|
|
|
127
135
|
@Mutation(returns => Boolean, { description: 'To import multiple CommonCodes' })
|
|
128
136
|
async importCommonCodes(
|
|
129
137
|
@Arg('commonCodes', type => [CommonCodePatch]) commonCodes: CommonCodePatch[],
|
|
130
|
-
@Ctx() context:
|
|
138
|
+
@Ctx() context: ResolverContext
|
|
131
139
|
): Promise<boolean> {
|
|
132
140
|
const { domain, tx } = context.state
|
|
133
141
|
|
|
134
142
|
await Promise.all(
|
|
135
143
|
commonCodes.map(async (commonCode: CommonCodePatch) => {
|
|
136
|
-
const createdCommonCode: CommonCode = await tx
|
|
144
|
+
const createdCommonCode: CommonCode = await tx
|
|
145
|
+
.getRepository(CommonCode)
|
|
146
|
+
.save({ domain, ...(commonCode as any) })
|
|
137
147
|
})
|
|
138
148
|
)
|
|
139
149
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { CommonCodeDetail } from '../common-code-detail/common-code-detail'
|
|
8
7
|
import { CommonCode } from './common-code'
|
|
@@ -11,16 +10,16 @@ import { CommonCodeList } from './common-code-type'
|
|
|
11
10
|
@Resolver(CommonCode)
|
|
12
11
|
export class CommonCodeQuery {
|
|
13
12
|
@Query(returns => CommonCode!, { nullable: true, description: 'To fetch a CommonCode' })
|
|
14
|
-
async commonCode(@Arg('name') name: string, @Ctx() context:
|
|
13
|
+
async commonCode(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<CommonCode> {
|
|
15
14
|
const { domain } = context.state
|
|
16
15
|
|
|
17
16
|
return await getRepository(CommonCode).findOne({
|
|
18
|
-
where: { domain, name }
|
|
17
|
+
where: { domain: { id: domain.id }, name }
|
|
19
18
|
})
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
@Query(returns => CommonCodeList, { description: 'To fetch multiple CommonCodes' })
|
|
23
|
-
async commonCodes(@Args() params: ListParam, @Ctx() context:
|
|
22
|
+
async commonCodes(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<CommonCodeList> {
|
|
24
23
|
const { domain } = context.state
|
|
25
24
|
|
|
26
25
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -39,32 +38,32 @@ export class CommonCodeQuery {
|
|
|
39
38
|
async partnerCommonCode(
|
|
40
39
|
@Arg('name') name: string,
|
|
41
40
|
@Arg('partnerDomainId') partnerDomainId: string,
|
|
42
|
-
@Ctx() context:
|
|
41
|
+
@Ctx() context: ResolverContext
|
|
43
42
|
): Promise<CommonCode> {
|
|
44
43
|
return await getRepository(CommonCode).findOne({
|
|
45
|
-
where: { domain: partnerDomainId, name }
|
|
44
|
+
where: { domain: { id: partnerDomainId }, name }
|
|
46
45
|
})
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
@FieldResolver(type => [CommonCodeDetail])
|
|
50
49
|
async details(@Root() commonCode: CommonCode): Promise<CommonCodeDetail[]> {
|
|
51
|
-
return await getRepository(CommonCodeDetail).
|
|
52
|
-
commonCode
|
|
50
|
+
return await getRepository(CommonCodeDetail).findBy({
|
|
51
|
+
commonCode: { id: commonCode.id }
|
|
53
52
|
})
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
@FieldResolver(type => Domain)
|
|
57
56
|
async domain(@Root() commonCode: CommonCode): Promise<Domain> {
|
|
58
|
-
return await getRepository(Domain).
|
|
57
|
+
return await getRepository(Domain).findOneBy({ id: commonCode.domainId })
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
@FieldResolver(type => User)
|
|
62
61
|
async updater(@Root() commonCode: CommonCode): Promise<User> {
|
|
63
|
-
return await getRepository(User).
|
|
62
|
+
return await getRepository(User).findOneBy({ id: commonCode.updaterId })
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
@FieldResolver(type => User)
|
|
67
66
|
async creator(@Root() commonCode: CommonCode): Promise<User> {
|
|
68
|
-
return await getRepository(User).
|
|
67
|
+
return await getRepository(User).findOneBy({ id: commonCode.creatorId })
|
|
69
68
|
}
|
|
70
69
|
}
|
|
@@ -11,12 +11,12 @@ export class CommonCodeDetailMutation {
|
|
|
11
11
|
@Mutation(returns => CommonCodeDetail, { description: 'To create new CommonCodeDetail' })
|
|
12
12
|
async createCommonCodeDetail(
|
|
13
13
|
@Arg('commonCodeDetail') commonCodeDetail: NewCommonCodeDetail,
|
|
14
|
-
@Ctx() context:
|
|
14
|
+
@Ctx() context: ResolverContext
|
|
15
15
|
): Promise<CommonCodeDetail> {
|
|
16
16
|
const { domain, user, tx } = context.state
|
|
17
17
|
|
|
18
18
|
if (commonCodeDetail && commonCodeDetail.commonCode.id) {
|
|
19
|
-
commonCodeDetail.commonCode = await tx.getRepository(CommonCode).
|
|
19
|
+
commonCodeDetail.commonCode = await tx.getRepository(CommonCode).findOneBy({ id: commonCodeDetail.commonCode.id })
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return await tx.getRepository(CommonCodeDetail).save({
|
|
@@ -32,17 +32,17 @@ export class CommonCodeDetailMutation {
|
|
|
32
32
|
async updateCommonCodeDetail(
|
|
33
33
|
@Arg('id') id: string,
|
|
34
34
|
@Arg('patch') patch: CommonCodeDetailPatch,
|
|
35
|
-
@Ctx() context:
|
|
35
|
+
@Ctx() context: ResolverContext
|
|
36
36
|
): Promise<CommonCodeDetail> {
|
|
37
37
|
const { domain, user, tx } = context.state
|
|
38
38
|
|
|
39
39
|
const repository = tx.getRepository(CommonCodeDetail)
|
|
40
40
|
const commonCodeDetail = await repository.findOne({
|
|
41
|
-
where: { domain, id }
|
|
41
|
+
where: { domain: { id: domain.id }, id }
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
if (patch.commonCode && patch.commonCode.id) {
|
|
45
|
-
patch.commonCode = await tx.getRepository(CommonCode).
|
|
45
|
+
patch.commonCode = await tx.getRepository(CommonCode).findOneBy({ id: patch.commonCode.id })
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return await repository.save({
|
|
@@ -56,7 +56,7 @@ export class CommonCodeDetailMutation {
|
|
|
56
56
|
@Mutation(returns => [CommonCodeDetail], { description: "To modify multiple CommonCodeDetails' information" })
|
|
57
57
|
async updateMultipleCommonCodeDetail(
|
|
58
58
|
@Arg('patches', type => [CommonCodeDetailPatch]) patches: CommonCodeDetailPatch[],
|
|
59
|
-
@Ctx() context:
|
|
59
|
+
@Ctx() context: ResolverContext
|
|
60
60
|
): Promise<CommonCodeDetail[]> {
|
|
61
61
|
const { domain, user, tx } = context.state
|
|
62
62
|
|
|
@@ -71,7 +71,7 @@ export class CommonCodeDetailMutation {
|
|
|
71
71
|
const newRecord = _createRecords[i]
|
|
72
72
|
|
|
73
73
|
if (newRecord.commonCode && newRecord.commonCode.id) {
|
|
74
|
-
newRecord.commonCode = await commonCodeRepo.
|
|
74
|
+
newRecord.commonCode = await commonCodeRepo.findOneBy({ id: newRecord.commonCode.id })
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const result = await commonCodeDetailRepo.save({
|
|
@@ -88,10 +88,10 @@ export class CommonCodeDetailMutation {
|
|
|
88
88
|
if (_updateRecords.length > 0) {
|
|
89
89
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
90
90
|
const newRecord = _updateRecords[i]
|
|
91
|
-
const commonCodeDetail = await commonCodeDetailRepo.
|
|
91
|
+
const commonCodeDetail = await commonCodeDetailRepo.findOneBy({ id: newRecord.id })
|
|
92
92
|
|
|
93
93
|
if (newRecord.commonCode && newRecord.commonCode.id) {
|
|
94
|
-
newRecord.commonCode = await commonCodeRepo.
|
|
94
|
+
newRecord.commonCode = await commonCodeRepo.findOneBy({ id: newRecord.commonCode.id })
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
const result = await commonCodeDetailRepo.save({
|
|
@@ -109,20 +109,23 @@ export class CommonCodeDetailMutation {
|
|
|
109
109
|
|
|
110
110
|
@Directive('@transaction')
|
|
111
111
|
@Mutation(returns => Boolean, { description: 'To delete CommonCodeDetail' })
|
|
112
|
-
async deleteCommonCodeDetail(@Arg('id') id: string, @Ctx() context:
|
|
112
|
+
async deleteCommonCodeDetail(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
113
113
|
const { domain, tx } = context.state
|
|
114
114
|
|
|
115
|
-
await tx.getRepository(CommonCodeDetail).delete({ domain, id })
|
|
115
|
+
await tx.getRepository(CommonCodeDetail).delete({ domain: { id: domain.id }, id })
|
|
116
116
|
return true
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
@Directive('@transaction')
|
|
120
120
|
@Mutation(returns => Boolean, { description: 'To delete multiple CommonCodeDetails' })
|
|
121
|
-
async deleteCommonCodeDetails(
|
|
121
|
+
async deleteCommonCodeDetails(
|
|
122
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
123
|
+
@Ctx() context: ResolverContext
|
|
124
|
+
): Promise<boolean> {
|
|
122
125
|
const { domain, tx } = context.state
|
|
123
126
|
|
|
124
127
|
await tx.getRepository(CommonCodeDetail).delete({
|
|
125
|
-
domain,
|
|
128
|
+
domain: { id: domain.id },
|
|
126
129
|
id: In(ids)
|
|
127
130
|
})
|
|
128
131
|
|
|
@@ -133,7 +136,7 @@ export class CommonCodeDetailMutation {
|
|
|
133
136
|
@Mutation(returns => Boolean, { description: 'To import multiple CommonCodeDetails' })
|
|
134
137
|
async importCommonCodeDetails(
|
|
135
138
|
@Arg('commonCodeDetails', type => [CommonCodeDetailPatch]) commonCodeDetails: CommonCodeDetailPatch[],
|
|
136
|
-
@Ctx() context:
|
|
139
|
+
@Ctx() context: ResolverContext
|
|
137
140
|
): Promise<boolean> {
|
|
138
141
|
const { domain, tx } = context.state
|
|
139
142
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
import { getRepository } from 'typeorm'
|
|
3
2
|
|
|
4
3
|
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
5
|
|
|
7
6
|
import { CommonCode } from '../common-code/common-code'
|
|
8
7
|
import { CommonCodeDetail } from './common-code-detail'
|
|
@@ -11,16 +10,16 @@ import { CommonCodeDetailList } from './common-code-detail-type'
|
|
|
11
10
|
@Resolver(CommonCodeDetail)
|
|
12
11
|
export class CommonCodeDetailQuery {
|
|
13
12
|
@Query(returns => CommonCodeDetail, { description: 'To fetch a CommonCodeDetail' })
|
|
14
|
-
async commonCodeDetail(@Arg('id') id: string, @Ctx() context:
|
|
13
|
+
async commonCodeDetail(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<CommonCodeDetail> {
|
|
15
14
|
const { domain } = context.state
|
|
16
15
|
|
|
17
16
|
return await getRepository(CommonCodeDetail).findOne({
|
|
18
|
-
where: { domain, id }
|
|
17
|
+
where: { domain: { id: domain.id }, id }
|
|
19
18
|
})
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
@Query(returns => CommonCodeDetailList, { description: 'To fetch multiple CommonCodeDetails' })
|
|
23
|
-
async commonCodeDetails(@Args() params: ListParam, @Ctx() context:
|
|
22
|
+
async commonCodeDetails(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<CommonCodeDetailList> {
|
|
24
23
|
const { domain } = context.state
|
|
25
24
|
|
|
26
25
|
const queryBuilder = getQueryBuilderFromListParams({
|
|
@@ -38,21 +37,21 @@ export class CommonCodeDetailQuery {
|
|
|
38
37
|
|
|
39
38
|
@FieldResolver(type => CommonCode)
|
|
40
39
|
async commonCode(commonCodeDetail): Promise<CommonCode> {
|
|
41
|
-
return await getRepository(CommonCode).
|
|
40
|
+
return await getRepository(CommonCode).findOneBy({ id: commonCodeDetail.commonCodeId })
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
@FieldResolver(type => Domain)
|
|
45
44
|
async domain(@Root() commonCodeDetail: CommonCodeDetail): Promise<Domain> {
|
|
46
|
-
return await getRepository(Domain).
|
|
45
|
+
return await getRepository(Domain).findOneBy({ id: commonCodeDetail.domainId })
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
@FieldResolver(type => User)
|
|
50
49
|
async updater(@Root() commonCodeDetail: CommonCodeDetail): Promise<User> {
|
|
51
|
-
return await getRepository(User).
|
|
50
|
+
return await getRepository(User).findOneBy({ id: commonCodeDetail.updaterId })
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
@FieldResolver(type => User)
|
|
55
54
|
async creator(@Root() commonCodeDetail: CommonCodeDetail): Promise<User> {
|
|
56
|
-
return await getRepository(User).
|
|
55
|
+
return await getRepository(User).findOneBy({ id: commonCodeDetail.creatorId })
|
|
57
56
|
}
|
|
58
57
|
}
|