@things-factory/code-base 5.0.7 → 6.0.0-alpha.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/dist-server/index.js +3 -16
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/service/common-code/common-code-mutation.js +49 -57
- package/dist-server/service/common-code/common-code-mutation.js.map +1 -1
- package/dist-server/service/common-code/common-code-query.js +51 -64
- package/dist-server/service/common-code/common-code-query.js.map +1 -1
- package/dist-server/service/common-code/common-code-type.js +24 -32
- package/dist-server/service/common-code/common-code-type.js.map +1 -1
- package/dist-server/service/common-code/common-code.js +26 -35
- package/dist-server/service/common-code/common-code.js.map +1 -1
- package/dist-server/service/common-code/index.js.map +1 -1
- package/dist-server/service/common-code-detail/common-code-detail-mutation.js +47 -58
- 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 +40 -53
- 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 +28 -37
- 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 +30 -39
- package/dist-server/service/common-code-detail/common-code-detail.js.map +1 -1
- package/dist-server/service/common-code-detail/index.js.map +1 -1
- package/dist-server/service/index.js +3 -16
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- 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
|
@@ -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
|
}
|