@things-factory/process 8.0.39 → 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/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -14
- package/client/actions/main.ts +0 -1
- package/client/bootstrap.ts +0 -8
- package/client/index.ts +0 -1
- package/client/pages/event/event-importer.ts +0 -86
- package/client/pages/event/event-list-page.ts +0 -324
- package/client/pages/gateway/gateway-importer.ts +0 -87
- package/client/pages/gateway/gateway-list-page.ts +0 -323
- package/client/pages/main.ts +0 -25
- package/client/pages/process/process-importer.ts +0 -87
- package/client/pages/process/process-list-page.ts +0 -324
- package/client/pages/process-instance/process-instance-importer.ts +0 -87
- package/client/pages/process-instance/process-instance-list-page.ts +0 -323
- package/client/pages/process-thread/process-thread-importer.ts +0 -87
- package/client/pages/process-thread/process-thread-list-page.ts +0 -323
- package/client/reducers/main.ts +0 -17
- package/client/route.ts +0 -27
- package/client/tsconfig.json +0 -13
- package/server/controllers/common.ts +0 -90
- package/server/controllers/index.ts +0 -0
- package/server/controllers/process-instance/abort.ts +0 -75
- package/server/controllers/process-instance/end.ts +0 -74
- package/server/controllers/process-instance/index.ts +0 -2
- package/server/controllers/process-thread/_abort.ts +0 -20
- package/server/controllers/process-thread/abort.ts +0 -48
- package/server/controllers/process-thread/end.ts +0 -54
- package/server/controllers/process-thread/index.ts +0 -3
- package/server/controllers/process-thread/start.ts +0 -49
- package/server/index.ts +0 -4
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -80
- package/server/service/index.ts +0 -44
- package/server/service/process/event-subscriber.ts +0 -17
- package/server/service/process/index.ts +0 -9
- package/server/service/process/process-history.ts +0 -108
- package/server/service/process/process-mutation.ts +0 -210
- package/server/service/process/process-query.ts +0 -120
- package/server/service/process/process-search-key-item-type.ts +0 -16
- package/server/service/process/process-type.ts +0 -65
- package/server/service/process/process.ts +0 -97
- package/server/service/process-instance/event-subscriber.ts +0 -44
- package/server/service/process-instance/index.ts +0 -10
- package/server/service/process-instance/process-instance-history.ts +0 -154
- package/server/service/process-instance/process-instance-mutation.ts +0 -33
- package/server/service/process-instance/process-instance-query.ts +0 -141
- package/server/service/process-instance/process-instance-subscription.ts +0 -46
- package/server/service/process-instance/process-instance-type.ts +0 -71
- package/server/service/process-instance/process-instance.ts +0 -147
- package/server/service/process-stats/index.ts +0 -3
- package/server/service/process-stats/process-stats-query.ts +0 -57
- package/server/service/process-stats/process-stats-type.ts +0 -31
- package/server/service/process-thread/event-subscriber.ts +0 -31
- package/server/service/process-thread/index.ts +0 -9
- package/server/service/process-thread/process-thread-mutation.ts +0 -34
- package/server/service/process-thread/process-thread-query.ts +0 -61
- package/server/service/process-thread/process-thread-subscription.ts +0 -42
- package/server/service/process-thread/process-thread-type.ts +0 -15
- package/server/service/process-thread/process-thread.ts +0 -90
- package/server/tsconfig.json +0 -10
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { filter, pipe } from 'graphql-yoga'
|
|
2
|
-
import { Resolver, Root, Subscription } from 'type-graphql'
|
|
3
|
-
|
|
4
|
-
import { pubsub } from '@things-factory/shell'
|
|
5
|
-
import { User } from '@things-factory/auth-base'
|
|
6
|
-
|
|
7
|
-
import { ProcessInstance } from './process-instance'
|
|
8
|
-
|
|
9
|
-
@Resolver(ProcessInstance)
|
|
10
|
-
export class ProcessInstanceSubscription {
|
|
11
|
-
@Subscription({
|
|
12
|
-
subscribe: ({ args, context, info }) => {
|
|
13
|
-
const { domain, user } = context.state
|
|
14
|
-
const subdomain = domain?.subdomain
|
|
15
|
-
|
|
16
|
-
if (!domain) {
|
|
17
|
-
throw new Error('domain required')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
|
21
|
-
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return pipe(
|
|
25
|
-
pubsub.subscribe('process-instance'),
|
|
26
|
-
filter(async (payload: { processInstance: ProcessInstance }) => {
|
|
27
|
-
const { processInstance } = payload
|
|
28
|
-
const { domainId } = processInstance
|
|
29
|
-
|
|
30
|
-
if (domainId !== domain?.id) {
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (processInstance.creatorId === user.id) {
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return await User.hasPrivilege('query', 'process-instance', domain, user)
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
processInstance(@Root() payload: { processInstance: ProcessInstance }): ProcessInstance {
|
|
44
|
-
return payload.processInstance
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Role } from '@things-factory/auth-base'
|
|
4
|
-
import { ObjectRef, ScalarDate, ScalarObject } from '@things-factory/shell'
|
|
5
|
-
import { ProcessInstance } from './process-instance'
|
|
6
|
-
|
|
7
|
-
@InputType()
|
|
8
|
-
export class ProcessInstanceDraft {
|
|
9
|
-
@Field(type => ID, { nullable: true })
|
|
10
|
-
id?: string
|
|
11
|
-
|
|
12
|
-
@Field()
|
|
13
|
-
name: string
|
|
14
|
-
|
|
15
|
-
@Field({ nullable: true })
|
|
16
|
-
processId: string
|
|
17
|
-
|
|
18
|
-
@Field({ nullable: true })
|
|
19
|
-
description?: string
|
|
20
|
-
|
|
21
|
-
@Field({ nullable: true })
|
|
22
|
-
reason?: string
|
|
23
|
-
|
|
24
|
-
@Field(type => ScalarDate, { nullable: true })
|
|
25
|
-
dueAt?: Date
|
|
26
|
-
|
|
27
|
-
@Field({ nullable: true })
|
|
28
|
-
refBy?: string
|
|
29
|
-
|
|
30
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
31
|
-
supervisoryRole?: Role
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@InputType()
|
|
35
|
-
export class ProcessInstanceIssue {
|
|
36
|
-
@Field(type => ID, { nullable: true })
|
|
37
|
-
id?: string
|
|
38
|
-
|
|
39
|
-
@Field({ nullable: true })
|
|
40
|
-
name?: string
|
|
41
|
-
|
|
42
|
-
@Field({ nullable: true })
|
|
43
|
-
processId?: string
|
|
44
|
-
|
|
45
|
-
@Field({ nullable: true })
|
|
46
|
-
description?: string
|
|
47
|
-
|
|
48
|
-
@Field({ nullable: true })
|
|
49
|
-
reason?: string
|
|
50
|
-
|
|
51
|
-
@Field(type => ScalarDate, { nullable: true })
|
|
52
|
-
dueAt?: Date
|
|
53
|
-
|
|
54
|
-
@Field({ nullable: true })
|
|
55
|
-
refBy?: string
|
|
56
|
-
|
|
57
|
-
@Field({ nullable: true })
|
|
58
|
-
viewSource?: string
|
|
59
|
-
|
|
60
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
61
|
-
supervisoryRole?: Role
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@ObjectType()
|
|
65
|
-
export class ProcessInstanceList {
|
|
66
|
-
@Field(type => [ProcessInstance])
|
|
67
|
-
items: ProcessInstance[]
|
|
68
|
-
|
|
69
|
-
@Field(type => Int)
|
|
70
|
-
total: number
|
|
71
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { Field, ID, Int, ObjectType, registerEnumType } from 'type-graphql'
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
CreateDateColumn,
|
|
5
|
-
Entity,
|
|
6
|
-
Index,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
OneToMany,
|
|
9
|
-
PrimaryGeneratedColumn,
|
|
10
|
-
RelationId,
|
|
11
|
-
UpdateDateColumn,
|
|
12
|
-
VersionColumn
|
|
13
|
-
} from 'typeorm'
|
|
14
|
-
|
|
15
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
16
|
-
import { Domain, ScalarObject } from '@things-factory/shell'
|
|
17
|
-
|
|
18
|
-
import { ProcessThread } from '../process-thread/process-thread'
|
|
19
|
-
import { Process } from '../process/process'
|
|
20
|
-
|
|
21
|
-
export enum ProcessInstanceStatus {
|
|
22
|
-
Started = 'started',
|
|
23
|
-
Pending = 'pending',
|
|
24
|
-
Ended = 'ended',
|
|
25
|
-
Aborted = 'aborted'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
registerEnumType(ProcessInstanceStatus, {
|
|
29
|
-
name: 'ProcessInstanceStatus',
|
|
30
|
-
description: 'state enumeration of a process instance'
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
@Entity()
|
|
34
|
-
@Index('ix_process_instance_0', (processInstance: ProcessInstance) => [processInstance.domain, processInstance.name], {
|
|
35
|
-
unique: false
|
|
36
|
-
})
|
|
37
|
-
@Index('ix_process_instance_1', (processInstance: ProcessInstance) => [processInstance.domain, processInstance.state], {
|
|
38
|
-
unique: false
|
|
39
|
-
})
|
|
40
|
-
@ObjectType({ description: 'Entity for ProcessInstance' })
|
|
41
|
-
export class ProcessInstance {
|
|
42
|
-
@PrimaryGeneratedColumn('uuid')
|
|
43
|
-
@Field(type => ID)
|
|
44
|
-
readonly id: string
|
|
45
|
-
|
|
46
|
-
@VersionColumn()
|
|
47
|
-
@Field({ nullable: true })
|
|
48
|
-
version?: number = 1
|
|
49
|
-
|
|
50
|
-
@ManyToOne(type => Domain)
|
|
51
|
-
@Field(type => Domain)
|
|
52
|
-
domain?: Domain
|
|
53
|
-
|
|
54
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.domain)
|
|
55
|
-
domainId?: string
|
|
56
|
-
|
|
57
|
-
@Column()
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
name?: string
|
|
60
|
-
|
|
61
|
-
@Column({ nullable: true })
|
|
62
|
-
@Field({ nullable: true })
|
|
63
|
-
description?: string
|
|
64
|
-
|
|
65
|
-
@Column({ nullable: true, default: '' })
|
|
66
|
-
@Field({ nullable: true })
|
|
67
|
-
key01?: string = ''
|
|
68
|
-
|
|
69
|
-
@Column({ nullable: true, default: '' })
|
|
70
|
-
@Field({ nullable: true })
|
|
71
|
-
key02?: string = ''
|
|
72
|
-
|
|
73
|
-
@Column({ nullable: true, default: '' })
|
|
74
|
-
@Field({ nullable: true })
|
|
75
|
-
key03?: string = ''
|
|
76
|
-
|
|
77
|
-
@Column({ nullable: true, default: '' })
|
|
78
|
-
@Field({ nullable: true })
|
|
79
|
-
key04?: string = ''
|
|
80
|
-
|
|
81
|
-
@Column({ nullable: true, default: '' })
|
|
82
|
-
@Field({ nullable: true })
|
|
83
|
-
key05?: string = ''
|
|
84
|
-
|
|
85
|
-
@OneToMany(type => ProcessThread, processThread => processThread.processInstance)
|
|
86
|
-
@Field(type => [ProcessThread])
|
|
87
|
-
processThreads?: ProcessThread[]
|
|
88
|
-
|
|
89
|
-
@Column({ nullable: true })
|
|
90
|
-
@Field({ nullable: true })
|
|
91
|
-
state?: ProcessInstanceStatus
|
|
92
|
-
|
|
93
|
-
@Column({ nullable: true })
|
|
94
|
-
@Field({ nullable: true })
|
|
95
|
-
reason?: string
|
|
96
|
-
|
|
97
|
-
@Column({ nullable: true })
|
|
98
|
-
@Field({ nullable: true })
|
|
99
|
-
refBy?: string
|
|
100
|
-
|
|
101
|
-
@ManyToOne(type => Process, { nullable: true })
|
|
102
|
-
@Field(type => Process, { nullable: true })
|
|
103
|
-
process?: Process
|
|
104
|
-
|
|
105
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.process)
|
|
106
|
-
processId?: string
|
|
107
|
-
|
|
108
|
-
@ManyToOne(type => Role, { nullable: true })
|
|
109
|
-
@Field(type => Role, { nullable: true })
|
|
110
|
-
supervisoryRole?: Role
|
|
111
|
-
|
|
112
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.supervisoryRole)
|
|
113
|
-
supervisoryRoleId?: string
|
|
114
|
-
|
|
115
|
-
@Column({ nullable: true })
|
|
116
|
-
@Field({ nullable: true })
|
|
117
|
-
dueAt?: Date
|
|
118
|
-
|
|
119
|
-
@CreateDateColumn()
|
|
120
|
-
@Field({ nullable: true })
|
|
121
|
-
createdAt?: Date
|
|
122
|
-
|
|
123
|
-
@UpdateDateColumn()
|
|
124
|
-
@Field({ nullable: true })
|
|
125
|
-
updatedAt?: Date
|
|
126
|
-
|
|
127
|
-
@Column({ nullable: true })
|
|
128
|
-
@Field({ nullable: true })
|
|
129
|
-
terminatedAt?: Date
|
|
130
|
-
|
|
131
|
-
@ManyToOne(type => User, { nullable: true })
|
|
132
|
-
@Field(type => User, { nullable: true })
|
|
133
|
-
creator?: User
|
|
134
|
-
|
|
135
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.creator)
|
|
136
|
-
creatorId?: string
|
|
137
|
-
|
|
138
|
-
@ManyToOne(type => User, { nullable: true })
|
|
139
|
-
@Field(type => User, { nullable: true })
|
|
140
|
-
updater?: User
|
|
141
|
-
|
|
142
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.updater)
|
|
143
|
-
updaterId?: string
|
|
144
|
-
|
|
145
|
-
@Field(type => String, { nullable: true })
|
|
146
|
-
thumbnail?: string
|
|
147
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { ProcessEvent, ProcessEventStatus } from './process-stats-type'
|
|
5
|
-
import { ProcessThread, ProcessThreadStatus } from '../process-thread/process-thread'
|
|
6
|
-
|
|
7
|
-
@Resolver(ProcessStatsQuery)
|
|
8
|
-
export class ProcessStatsQuery {
|
|
9
|
-
@Query(returns => [ProcessEvent], { description: 'To fetch process events by period' })
|
|
10
|
-
async processEvents(
|
|
11
|
-
@Arg('from') from: string,
|
|
12
|
-
@Arg('to') to: string,
|
|
13
|
-
@Ctx() context: ResolverContext
|
|
14
|
-
): Promise<ProcessEvent[]> {
|
|
15
|
-
const { domain, user } = context.state
|
|
16
|
-
|
|
17
|
-
if (!from) {
|
|
18
|
-
const beginOfToday = new Date()
|
|
19
|
-
beginOfToday.setHours(0, 0, 0, 0)
|
|
20
|
-
from = beginOfToday.toISOString().split('T').join(' ')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!to) {
|
|
24
|
-
const endOfToday = new Date()
|
|
25
|
-
endOfToday.setDate(endOfToday.getDate() + 1)
|
|
26
|
-
endOfToday.setHours(0, 0, 0, 0)
|
|
27
|
-
to = endOfToday.toISOString().split('T').join(' ')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const status = [ProcessThreadStatus.Ended, ProcessThreadStatus.Aborted]
|
|
31
|
-
|
|
32
|
-
var params = { filters: [{ name: 'terminatedAt', operator: 'between', value: [from, to] }] }
|
|
33
|
-
|
|
34
|
-
var doneItems = await getQueryBuilderFromListParams({
|
|
35
|
-
repository: getRepository(ProcessThread),
|
|
36
|
-
params,
|
|
37
|
-
domain,
|
|
38
|
-
alias: 'at'
|
|
39
|
-
})
|
|
40
|
-
.leftJoinAndSelect('at.processInstance', 'ai')
|
|
41
|
-
.andWhere('at.state IN (:...status)', { status })
|
|
42
|
-
.andWhere('at.assignee = :user', { user: user.id })
|
|
43
|
-
.getMany()
|
|
44
|
-
|
|
45
|
-
const processThreadDoneEvents = doneItems.map(({ id, processInstance, terminatedAt }) => {
|
|
46
|
-
return {
|
|
47
|
-
id,
|
|
48
|
-
name: processInstance.name,
|
|
49
|
-
date: terminatedAt,
|
|
50
|
-
state: ProcessEventStatus.Done,
|
|
51
|
-
type: 'process-thread'
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
return [...processThreadDoneEvents]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
export enum ProcessEventStatus {
|
|
4
|
-
Done = 'done',
|
|
5
|
-
Pending = 'pending',
|
|
6
|
-
Approved = 'approved',
|
|
7
|
-
Rejected = 'rejected'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
registerEnumType(ProcessEventStatus, {
|
|
11
|
-
name: 'ProcessEventStatus',
|
|
12
|
-
description: 'state enumeration of a Process Event'
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
@ObjectType()
|
|
16
|
-
export class ProcessEvent {
|
|
17
|
-
@Field({ nullable: true })
|
|
18
|
-
id?: string
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
name?: string
|
|
22
|
-
|
|
23
|
-
@Field({ nullable: true })
|
|
24
|
-
type?: string
|
|
25
|
-
|
|
26
|
-
@Field({ nullable: true })
|
|
27
|
-
state?: ProcessEventStatus
|
|
28
|
-
|
|
29
|
-
@Field({ nullable: true })
|
|
30
|
-
date?: Date
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { pubsub } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { ProcessThread } from './process-thread'
|
|
6
|
-
|
|
7
|
-
@EventSubscriber()
|
|
8
|
-
export class ProcessThreadSubscriber implements EntitySubscriberInterface<ProcessThread> {
|
|
9
|
-
listenTo() {
|
|
10
|
-
return ProcessThread
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async afterInsert(event: InsertEvent<ProcessThread>): Promise<any> {
|
|
14
|
-
const processThread = event.entity
|
|
15
|
-
|
|
16
|
-
pubsub.publish('process-thread', {
|
|
17
|
-
processThread
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
console.log('process-thread created', processThread.id)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async afterUpdate(event: UpdateEvent<ProcessThread>): Promise<any> {
|
|
24
|
-
const processThread = event.entity
|
|
25
|
-
|
|
26
|
-
pubsub.publish('process-thread', {
|
|
27
|
-
processThread
|
|
28
|
-
})
|
|
29
|
-
console.log('process-thread updated', processThread.id)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ProcessThread } from './process-thread'
|
|
2
|
-
import { ProcessThreadMutation } from './process-thread-mutation'
|
|
3
|
-
import { ProcessThreadQuery } from './process-thread-query'
|
|
4
|
-
import { ProcessThreadSubscription } from './process-thread-subscription'
|
|
5
|
-
import { ProcessThreadSubscriber } from './event-subscriber'
|
|
6
|
-
|
|
7
|
-
export const entities = [ProcessThread]
|
|
8
|
-
export const resolvers = [ProcessThreadQuery, ProcessThreadMutation, ProcessThreadSubscription]
|
|
9
|
-
export const subscribers = [ProcessThreadSubscriber]
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { abort, start } from '../../controllers/process-thread'
|
|
6
|
-
import { ProcessThread } from './process-thread'
|
|
7
|
-
|
|
8
|
-
@Resolver(ProcessThread)
|
|
9
|
-
export class ProcessThreadMutation {
|
|
10
|
-
/* transactions ... */
|
|
11
|
-
|
|
12
|
-
@Directive('@transaction')
|
|
13
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
14
|
-
@Mutation(returns => ProcessThread!, { nullable: true, description: 'To start ProcessThread' })
|
|
15
|
-
async startProcessThread(
|
|
16
|
-
@Arg('id') id: string,
|
|
17
|
-
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
18
|
-
@Arg('reason', { nullable: true }) reason: string,
|
|
19
|
-
@Ctx() context: ResolverContext
|
|
20
|
-
): Promise<ProcessThread> {
|
|
21
|
-
return await start(id, output, reason, context)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Directive('@transaction')
|
|
25
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
26
|
-
@Mutation(returns => ProcessThread, { description: 'To abort a ProcessThread' })
|
|
27
|
-
async abortProcessThread(
|
|
28
|
-
@Arg('id') id: string,
|
|
29
|
-
@Arg('reason', { nullable: true }) reason: string,
|
|
30
|
-
@Ctx() context: ResolverContext
|
|
31
|
-
): Promise<ProcessThread> {
|
|
32
|
-
return await abort({ id, reason }, context)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, Directive, 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 { ProcessInstance } from '../process-instance/process-instance'
|
|
7
|
-
import { ProcessThread, ProcessThreadStatus } from './process-thread'
|
|
8
|
-
import { ProcessThreadList } from './process-thread-type'
|
|
9
|
-
|
|
10
|
-
@Resolver(ProcessThread)
|
|
11
|
-
export class ProcessThreadQuery {
|
|
12
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
13
|
-
@Query(returns => ProcessThread!, { nullable: true, description: 'To fetch a ProcessThread' })
|
|
14
|
-
async processThread(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ProcessThread> {
|
|
15
|
-
const { domain } = context.state
|
|
16
|
-
|
|
17
|
-
return await getRepository(ProcessThread).findOne({
|
|
18
|
-
where: { domain: { id: domain.id }, id }
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
23
|
-
@Query(returns => ProcessThreadList, { description: 'To fetch multiple ProcessThreads' })
|
|
24
|
-
async processThreads(
|
|
25
|
-
@Args(type => ListParam) params: ListParam,
|
|
26
|
-
@Ctx() context: ResolverContext
|
|
27
|
-
): Promise<ProcessThreadList> {
|
|
28
|
-
const { domain } = context.state
|
|
29
|
-
|
|
30
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
31
|
-
domain,
|
|
32
|
-
params,
|
|
33
|
-
repository: getRepository(ProcessThread),
|
|
34
|
-
searchables: ['name', 'description']
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
38
|
-
|
|
39
|
-
return { items, total }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@FieldResolver(type => ProcessInstance)
|
|
43
|
-
async processInstance(@Root() processThread: ProcessThread): Promise<ProcessInstance> {
|
|
44
|
-
return await getRepository(ProcessInstance).findOneBy({ id: processThread.processInstanceId })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@FieldResolver(type => Domain)
|
|
48
|
-
async domain(@Root() processThread: ProcessThread): Promise<Domain> {
|
|
49
|
-
return await getRepository(Domain).findOneBy({ id: processThread.domainId })
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@FieldResolver(type => User)
|
|
53
|
-
async updater(@Root() processThread: ProcessThread): Promise<User> {
|
|
54
|
-
return processThread.updaterId && (await getRepository(User).findOneBy({ id: processThread.updaterId }))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@FieldResolver(type => User)
|
|
58
|
-
async creator(@Root() processThread: ProcessThread): Promise<User> {
|
|
59
|
-
return processThread.creatorId && (await getRepository(User).findOneBy({ id: processThread.creatorId }))
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { filter, pipe } from 'graphql-yoga'
|
|
2
|
-
import { Resolver, Root, Subscription } from 'type-graphql'
|
|
3
|
-
|
|
4
|
-
import { pubsub } from '@things-factory/shell'
|
|
5
|
-
import { User } from '@things-factory/auth-base'
|
|
6
|
-
|
|
7
|
-
import { ProcessThread } from './process-thread'
|
|
8
|
-
|
|
9
|
-
@Resolver(ProcessThread)
|
|
10
|
-
export class ProcessThreadSubscription {
|
|
11
|
-
@Subscription({
|
|
12
|
-
subscribe: ({ args, context, info }) => {
|
|
13
|
-
const { domain, user } = context.state
|
|
14
|
-
const subdomain = domain?.subdomain
|
|
15
|
-
|
|
16
|
-
if (!domain) {
|
|
17
|
-
throw new Error('domain required')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
|
21
|
-
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return pipe(
|
|
25
|
-
pubsub.subscribe('process-thread'),
|
|
26
|
-
filter(async (payload: { processThread: ProcessThread }) => {
|
|
27
|
-
const { processThread } = payload
|
|
28
|
-
const { domainId } = processThread
|
|
29
|
-
|
|
30
|
-
if (domainId !== domain?.id) {
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return await User.hasPrivilege('query', 'process-thread', domain, user)
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
processThread(@Root() payload: { processThread: ProcessThread }): ProcessThread {
|
|
40
|
-
return payload.processThread
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { ScalarObject } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { ProcessThread, ProcessThreadStatus } from './process-thread'
|
|
6
|
-
import { User } from '@things-factory/auth-base'
|
|
7
|
-
|
|
8
|
-
@ObjectType()
|
|
9
|
-
export class ProcessThreadList {
|
|
10
|
-
@Field(type => [ProcessThread])
|
|
11
|
-
items: ProcessThread[]
|
|
12
|
-
|
|
13
|
-
@Field(type => Int)
|
|
14
|
-
total: number
|
|
15
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType, registerEnumType } from 'type-graphql'
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
CreateDateColumn,
|
|
5
|
-
Entity,
|
|
6
|
-
Index,
|
|
7
|
-
OneToMany,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
PrimaryGeneratedColumn,
|
|
10
|
-
RelationId,
|
|
11
|
-
VersionColumn,
|
|
12
|
-
UpdateDateColumn
|
|
13
|
-
} from 'typeorm'
|
|
14
|
-
|
|
15
|
-
import { User } from '@things-factory/auth-base'
|
|
16
|
-
import { Domain, ScalarObject } from '@things-factory/shell'
|
|
17
|
-
|
|
18
|
-
import { ProcessInstance } from '../process-instance/process-instance'
|
|
19
|
-
|
|
20
|
-
export enum ProcessThreadStatus {
|
|
21
|
-
Assigned = 'assigned',
|
|
22
|
-
Started = 'started',
|
|
23
|
-
Delegated = 'delegated',
|
|
24
|
-
Submitted = 'submitted',
|
|
25
|
-
Escalated = 'escalated',
|
|
26
|
-
Rejected = 'rejected',
|
|
27
|
-
Ended = 'ended',
|
|
28
|
-
Aborted = 'aborted'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
registerEnumType(ProcessThreadStatus, {
|
|
32
|
-
name: 'ProcessThreadStatus',
|
|
33
|
-
description: 'state enumeration of a ProcessThread'
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
@Entity()
|
|
37
|
-
@ObjectType({ description: 'Entity for ProcessThread' })
|
|
38
|
-
export class ProcessThread {
|
|
39
|
-
@PrimaryGeneratedColumn('uuid')
|
|
40
|
-
@Field(type => ID)
|
|
41
|
-
readonly id: string
|
|
42
|
-
|
|
43
|
-
@ManyToOne(type => Domain)
|
|
44
|
-
@Field(type => Domain)
|
|
45
|
-
domain?: Domain
|
|
46
|
-
|
|
47
|
-
@RelationId((processThread: ProcessThread) => processThread.domain)
|
|
48
|
-
domainId?: string
|
|
49
|
-
|
|
50
|
-
@VersionColumn({ default: 1 })
|
|
51
|
-
@Field({ nullable: true })
|
|
52
|
-
version?: number = 1
|
|
53
|
-
|
|
54
|
-
@ManyToOne(type => ProcessInstance, processInstance => processInstance.processThreads)
|
|
55
|
-
@Field(type => ProcessInstance, { nullable: true })
|
|
56
|
-
processInstance?: ProcessInstance
|
|
57
|
-
|
|
58
|
-
@RelationId((processThread: ProcessThread) => processThread.processInstance)
|
|
59
|
-
processInstanceId?: string
|
|
60
|
-
|
|
61
|
-
@Column({ nullable: true })
|
|
62
|
-
@Field({ nullable: true })
|
|
63
|
-
state?: ProcessThreadStatus
|
|
64
|
-
|
|
65
|
-
@Column({ nullable: true })
|
|
66
|
-
@Field({ nullable: true })
|
|
67
|
-
terminatedAt?: Date
|
|
68
|
-
|
|
69
|
-
@CreateDateColumn()
|
|
70
|
-
@Field({ nullable: true })
|
|
71
|
-
createdAt?: Date
|
|
72
|
-
|
|
73
|
-
@UpdateDateColumn()
|
|
74
|
-
@Field({ nullable: true })
|
|
75
|
-
updatedAt?: Date
|
|
76
|
-
|
|
77
|
-
@ManyToOne(type => User, { nullable: true })
|
|
78
|
-
@Field(type => User, { nullable: true })
|
|
79
|
-
creator?: User
|
|
80
|
-
|
|
81
|
-
@RelationId((processThread: ProcessThread) => processThread.creator)
|
|
82
|
-
creatorId?: string
|
|
83
|
-
|
|
84
|
-
@ManyToOne(type => User, { nullable: true })
|
|
85
|
-
@Field(type => User, { nullable: true })
|
|
86
|
-
updater?: User
|
|
87
|
-
|
|
88
|
-
@RelationId((processThread: ProcessThread) => processThread.updater)
|
|
89
|
-
updaterId?: string
|
|
90
|
-
}
|