@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,120 +0,0 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Attachment } from '@things-factory/attachment-base'
|
|
4
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Process } from './process'
|
|
8
|
-
import { ProcessList } from './process-type'
|
|
9
|
-
|
|
10
|
-
@Resolver(Process)
|
|
11
|
-
export class ProcessQuery {
|
|
12
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
13
|
-
@Query(returns => Process!, { nullable: true, description: 'To fetch a Process' })
|
|
14
|
-
async process(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Process> {
|
|
15
|
-
const { domain } = context.state
|
|
16
|
-
|
|
17
|
-
return await getRepository(Process).findOne({
|
|
18
|
-
where: { domain: { id: domain.id }, id }
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
23
|
-
@Query(returns => Process!, { nullable: true, description: 'To fetch a Process by name' })
|
|
24
|
-
async processByName(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Process> {
|
|
25
|
-
const { domain } = context.state
|
|
26
|
-
|
|
27
|
-
return await getRepository(Process).findOne({
|
|
28
|
-
where: { domain: { id: domain.id }, name }
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
33
|
-
@Query(returns => ProcessList, { description: 'To fetch multiple Processes' })
|
|
34
|
-
async processes(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ProcessList> {
|
|
35
|
-
const { domain } = context.state
|
|
36
|
-
|
|
37
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
38
|
-
domain,
|
|
39
|
-
params,
|
|
40
|
-
repository: getRepository(Process),
|
|
41
|
-
alias: 'process',
|
|
42
|
-
searchables: ['name', 'description', 'supervisoryRole']
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
46
|
-
|
|
47
|
-
return { items, total }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Directive('@privilege(category: "process", privilege: "query", domainOwnerGranted: true)')
|
|
51
|
-
@Query(returns => ProcessList, { description: 'To fetch the list of processes that I can report on' })
|
|
52
|
-
async supervisableProcesses(
|
|
53
|
-
@Args(type => ListParam) params: ListParam,
|
|
54
|
-
@Ctx() context: ResolverContext
|
|
55
|
-
): Promise<ProcessList> {
|
|
56
|
-
var { domain, user } = context.state
|
|
57
|
-
|
|
58
|
-
/* 조회한 사용자가 assigner 역할을 가진 process-instance 리스트만 반환 */
|
|
59
|
-
user = await getRepository(User).findOne({
|
|
60
|
-
where: { id: user.id },
|
|
61
|
-
relations: ['roles']
|
|
62
|
-
})
|
|
63
|
-
const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)
|
|
64
|
-
|
|
65
|
-
if (!roles.length) {
|
|
66
|
-
return { items: [], total: 0 }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const [items, total] = await getQueryBuilderFromListParams({
|
|
70
|
-
repository: getRepository(Process),
|
|
71
|
-
params,
|
|
72
|
-
domain,
|
|
73
|
-
alias: 'process',
|
|
74
|
-
searchables: ['name', 'description']
|
|
75
|
-
})
|
|
76
|
-
.andWhere(`process.supervisoryRole IN (:...roles)`, { roles })
|
|
77
|
-
.getManyAndCount()
|
|
78
|
-
|
|
79
|
-
return { items, total }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@FieldResolver(type => Role)
|
|
83
|
-
async supervisoryRole(@Root() process: Process): Promise<Role> {
|
|
84
|
-
return (
|
|
85
|
-
process.supervisoryRole ||
|
|
86
|
-
(process.supervisoryRoleId &&
|
|
87
|
-
(await getRepository(Role).findOneBy({
|
|
88
|
-
id: process.supervisoryRoleId
|
|
89
|
-
})))
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@FieldResolver(type => String)
|
|
94
|
-
async thumbnail(@Root() process: Process): Promise<string | undefined> {
|
|
95
|
-
const attachment: Attachment = await getRepository(Attachment).findOne({
|
|
96
|
-
where: {
|
|
97
|
-
domain: { id: process.domainId },
|
|
98
|
-
refType: Process.name,
|
|
99
|
-
refBy: process.id
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
return attachment?.fullpath
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@FieldResolver(type => Domain)
|
|
107
|
-
async domain(@Root() process: Process): Promise<Domain> {
|
|
108
|
-
return await getRepository(Domain).findOneBy({ id: process.domainId })
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
@FieldResolver(type => User)
|
|
112
|
-
async updater(@Root() process: Process): Promise<User> {
|
|
113
|
-
return await getRepository(User).findOneBy({ id: process.updaterId })
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@FieldResolver(type => User)
|
|
117
|
-
async creator(@Root() process: Process): Promise<User> {
|
|
118
|
-
return await getRepository(User).findOneBy({ id: process.creatorId })
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Field, ObjectType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
@ObjectType({ description: 'Entity for ProcessSearchKeyItem' })
|
|
4
|
-
export class ProcessSearchKeyItem {
|
|
5
|
-
@Field()
|
|
6
|
-
name: string
|
|
7
|
-
|
|
8
|
-
@Field({ nullable: true })
|
|
9
|
-
description?: string
|
|
10
|
-
|
|
11
|
-
@Field({ nullable: true })
|
|
12
|
-
inputKey: string
|
|
13
|
-
|
|
14
|
-
@Field({ nullable: true })
|
|
15
|
-
tKey?: string
|
|
16
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
-
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
-
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
4
|
-
|
|
5
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Process, ProcessStatus } from './process'
|
|
8
|
-
import { ProcessSearchKeyItem } from './process-search-key-item-type'
|
|
9
|
-
|
|
10
|
-
@InputType()
|
|
11
|
-
export class NewProcess {
|
|
12
|
-
@Field()
|
|
13
|
-
name: string
|
|
14
|
-
|
|
15
|
-
@Field({ nullable: true })
|
|
16
|
-
description?: string
|
|
17
|
-
|
|
18
|
-
@Field(type => ScalarObject, { nullable: true })
|
|
19
|
-
searchKeys?: ProcessSearchKeyItem[]
|
|
20
|
-
|
|
21
|
-
@Field({ nullable: true })
|
|
22
|
-
state?: ProcessStatus
|
|
23
|
-
|
|
24
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
25
|
-
supervisoryRole?: ObjectRef
|
|
26
|
-
|
|
27
|
-
@Field(type => GraphQLUpload, { nullable: true })
|
|
28
|
-
thumbnail?: FileUpload
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@InputType()
|
|
32
|
-
export class ProcessPatch {
|
|
33
|
-
@Field(type => ID, { nullable: true })
|
|
34
|
-
id?: string
|
|
35
|
-
|
|
36
|
-
@Field({ nullable: true })
|
|
37
|
-
name?: string
|
|
38
|
-
|
|
39
|
-
@Field({ nullable: true })
|
|
40
|
-
description?: string
|
|
41
|
-
|
|
42
|
-
@Field(type => ScalarObject, { nullable: true })
|
|
43
|
-
searchKeys?: ProcessSearchKeyItem[]
|
|
44
|
-
|
|
45
|
-
@Field({ nullable: true })
|
|
46
|
-
state?: ProcessStatus
|
|
47
|
-
|
|
48
|
-
@Field(type => ObjectRef, { nullable: true })
|
|
49
|
-
supervisoryRole?: ObjectRef
|
|
50
|
-
|
|
51
|
-
@Field(type => GraphQLUpload, { nullable: true })
|
|
52
|
-
thumbnail?: FileUpload
|
|
53
|
-
|
|
54
|
-
@Field({ nullable: true })
|
|
55
|
-
cuFlag?: string
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@ObjectType()
|
|
59
|
-
export class ProcessList {
|
|
60
|
-
@Field(type => [Process])
|
|
61
|
-
items: Process[]
|
|
62
|
-
|
|
63
|
-
@Field(type => Int)
|
|
64
|
-
total: number
|
|
65
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType, registerEnumType } from 'type-graphql'
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
CreateDateColumn,
|
|
5
|
-
Entity,
|
|
6
|
-
Index,
|
|
7
|
-
ManyToOne,
|
|
8
|
-
PrimaryGeneratedColumn,
|
|
9
|
-
RelationId,
|
|
10
|
-
UpdateDateColumn,
|
|
11
|
-
VersionColumn
|
|
12
|
-
} from 'typeorm'
|
|
13
|
-
|
|
14
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
15
|
-
import { Domain } from '@things-factory/shell'
|
|
16
|
-
|
|
17
|
-
import { ProcessSearchKeyItem } from './process-search-key-item-type'
|
|
18
|
-
|
|
19
|
-
export enum ProcessStatus {
|
|
20
|
-
Draft = 'draft',
|
|
21
|
-
Released = 'released',
|
|
22
|
-
Deprecated = 'deprecated'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
registerEnumType(ProcessStatus, {
|
|
26
|
-
name: 'ProcessStatus',
|
|
27
|
-
description: 'state enumeration of a process'
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
@Entity()
|
|
31
|
-
@Index('ix_process_0', (process: Process) => [process.domain, process.name], { unique: true })
|
|
32
|
-
@Index('ix_process_1', (process: Process) => [process.domain, process.state], { unique: false })
|
|
33
|
-
@ObjectType({ description: 'Entity for Process' })
|
|
34
|
-
export class Process {
|
|
35
|
-
@PrimaryGeneratedColumn('uuid')
|
|
36
|
-
@Field(type => ID)
|
|
37
|
-
readonly id: string
|
|
38
|
-
|
|
39
|
-
@VersionColumn()
|
|
40
|
-
@Field({ nullable: true })
|
|
41
|
-
version?: number = 1
|
|
42
|
-
|
|
43
|
-
@ManyToOne(type => Domain)
|
|
44
|
-
@Field(type => Domain, { nullable: true })
|
|
45
|
-
domain?: Domain
|
|
46
|
-
|
|
47
|
-
@RelationId((process: Process) => process.domain)
|
|
48
|
-
domainId?: string
|
|
49
|
-
|
|
50
|
-
@Column()
|
|
51
|
-
@Field({ nullable: true })
|
|
52
|
-
name?: string
|
|
53
|
-
|
|
54
|
-
@Column({ nullable: true })
|
|
55
|
-
@Field({ nullable: true })
|
|
56
|
-
description?: string
|
|
57
|
-
|
|
58
|
-
@Column({ nullable: true })
|
|
59
|
-
@Field({ nullable: true })
|
|
60
|
-
state?: ProcessStatus
|
|
61
|
-
|
|
62
|
-
@Column('simple-json', { nullable: true })
|
|
63
|
-
@Field(type => [ProcessSearchKeyItem], { nullable: true })
|
|
64
|
-
searchKeys?: ProcessSearchKeyItem[]
|
|
65
|
-
|
|
66
|
-
@ManyToOne(type => Role, { nullable: true })
|
|
67
|
-
@Field(type => Role, { nullable: true, description: 'The final authority on a given process.' })
|
|
68
|
-
supervisoryRole?: Role
|
|
69
|
-
|
|
70
|
-
@RelationId((process: Process) => process.supervisoryRole)
|
|
71
|
-
supervisoryRoleId?: string
|
|
72
|
-
|
|
73
|
-
@CreateDateColumn()
|
|
74
|
-
@Field({ nullable: true })
|
|
75
|
-
createdAt?: Date
|
|
76
|
-
|
|
77
|
-
@UpdateDateColumn()
|
|
78
|
-
@Field({ nullable: true })
|
|
79
|
-
updatedAt?: Date
|
|
80
|
-
|
|
81
|
-
@ManyToOne(type => User, { nullable: true })
|
|
82
|
-
@Field(type => User, { nullable: true })
|
|
83
|
-
creator?: User
|
|
84
|
-
|
|
85
|
-
@RelationId((process: Process) => process.creator)
|
|
86
|
-
creatorId?: string
|
|
87
|
-
|
|
88
|
-
@ManyToOne(type => User, { nullable: true })
|
|
89
|
-
@Field(type => User, { nullable: true })
|
|
90
|
-
updater?: User
|
|
91
|
-
|
|
92
|
-
@RelationId((process: Process) => process.updater)
|
|
93
|
-
updaterId?: string
|
|
94
|
-
|
|
95
|
-
@Field(type => String, { nullable: true })
|
|
96
|
-
thumbnail?: string
|
|
97
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { HistoryEntitySubscriber } from '@operato/typeorm-history'
|
|
4
|
-
import { pubsub } from '@things-factory/shell'
|
|
5
|
-
|
|
6
|
-
import { ProcessInstance } from './process-instance'
|
|
7
|
-
import { ProcessInstanceHistory } from './process-instance-history'
|
|
8
|
-
|
|
9
|
-
@EventSubscriber()
|
|
10
|
-
export class ProcessInstanceSubscriber implements EntitySubscriberInterface<ProcessInstance> {
|
|
11
|
-
listenTo() {
|
|
12
|
-
return ProcessInstance
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async afterInsert(event: InsertEvent<ProcessInstance>): Promise<any | void> {
|
|
16
|
-
const { entity: processInstance, manager: tx } = event
|
|
17
|
-
|
|
18
|
-
pubsub.publish('process-instance', {
|
|
19
|
-
processInstance
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async afterUpdate(event: UpdateEvent<ProcessInstance>): Promise<any | void> {
|
|
24
|
-
const { entity: processInstance, manager: tx } = event
|
|
25
|
-
|
|
26
|
-
pubsub.publish('process-instance', {
|
|
27
|
-
processInstance
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@EventSubscriber()
|
|
33
|
-
export class ProcessInstanceHistoryEntitySubscriber extends HistoryEntitySubscriber<
|
|
34
|
-
ProcessInstance,
|
|
35
|
-
ProcessInstanceHistory
|
|
36
|
-
> {
|
|
37
|
-
public get entity() {
|
|
38
|
-
return ProcessInstance
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public get historyEntity() {
|
|
42
|
-
return ProcessInstanceHistory
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProcessInstance } from './process-instance'
|
|
2
|
-
import { ProcessInstanceHistory } from './process-instance-history'
|
|
3
|
-
import { ProcessInstanceMutation } from './process-instance-mutation'
|
|
4
|
-
import { ProcessInstanceQuery } from './process-instance-query'
|
|
5
|
-
import { ProcessInstanceSubscription } from './process-instance-subscription'
|
|
6
|
-
import { ProcessInstanceHistoryEntitySubscriber, ProcessInstanceSubscriber } from './event-subscriber'
|
|
7
|
-
|
|
8
|
-
export const entities = [ProcessInstance, ProcessInstanceHistory]
|
|
9
|
-
export const resolvers = [ProcessInstanceQuery, ProcessInstanceMutation, ProcessInstanceSubscription]
|
|
10
|
-
export const subscribers = [ProcessInstanceSubscriber, ProcessInstanceHistoryEntitySubscriber]
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { Field, ID, Int, ObjectType } from 'type-graphql'
|
|
2
|
-
import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
HistoryActionColumn,
|
|
6
|
-
HistoryActionType,
|
|
7
|
-
HistoryEntityInterface,
|
|
8
|
-
HistoryOriginalIdColumn
|
|
9
|
-
} from '@operato/typeorm-history'
|
|
10
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
11
|
-
import { config } from '@things-factory/env'
|
|
12
|
-
import { Domain, ScalarObject } from '@things-factory/shell'
|
|
13
|
-
|
|
14
|
-
import { ProcessInstance, ProcessInstanceStatus } from './process-instance'
|
|
15
|
-
|
|
16
|
-
const ORMCONFIG = config.get('ormconfig', {})
|
|
17
|
-
const DATABASE_TYPE = ORMCONFIG.type
|
|
18
|
-
|
|
19
|
-
@Entity()
|
|
20
|
-
@Index(
|
|
21
|
-
'ix_process_instance_history_0',
|
|
22
|
-
(processInstanceHistory: ProcessInstanceHistory) => [
|
|
23
|
-
processInstanceHistory.originalId,
|
|
24
|
-
processInstanceHistory.version
|
|
25
|
-
],
|
|
26
|
-
{ unique: true }
|
|
27
|
-
)
|
|
28
|
-
@Index(
|
|
29
|
-
'ix_process_instance_history_1',
|
|
30
|
-
(processInstanceHistory: ProcessInstanceHistory) => [
|
|
31
|
-
processInstanceHistory.domain,
|
|
32
|
-
processInstanceHistory.originalId,
|
|
33
|
-
processInstanceHistory.version
|
|
34
|
-
],
|
|
35
|
-
{ unique: true }
|
|
36
|
-
)
|
|
37
|
-
@ObjectType({ description: 'History Entity of ProcessInstance' })
|
|
38
|
-
export class ProcessInstanceHistory implements HistoryEntityInterface<ProcessInstance> {
|
|
39
|
-
@PrimaryGeneratedColumn('uuid')
|
|
40
|
-
@Field(type => ID)
|
|
41
|
-
readonly id: string
|
|
42
|
-
|
|
43
|
-
@Column({
|
|
44
|
-
nullable: true,
|
|
45
|
-
default: 1
|
|
46
|
-
})
|
|
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
|
-
@Column({ nullable: true })
|
|
86
|
-
@Field({ nullable: true })
|
|
87
|
-
state?: ProcessInstanceStatus
|
|
88
|
-
|
|
89
|
-
@Column({ nullable: true })
|
|
90
|
-
@Field({ nullable: true })
|
|
91
|
-
reason?: string
|
|
92
|
-
|
|
93
|
-
@Column({ nullable: true })
|
|
94
|
-
@Field({ nullable: true })
|
|
95
|
-
refBy?: string
|
|
96
|
-
|
|
97
|
-
@ManyToOne(type => Role, { nullable: true })
|
|
98
|
-
@Field(type => Role, { nullable: true })
|
|
99
|
-
supervisoryRole?: Role
|
|
100
|
-
|
|
101
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.supervisoryRole)
|
|
102
|
-
supervisoryRoleId?: string
|
|
103
|
-
|
|
104
|
-
@Column({ nullable: true })
|
|
105
|
-
@Field({ nullable: true })
|
|
106
|
-
dueAt?: Date
|
|
107
|
-
|
|
108
|
-
@Column()
|
|
109
|
-
@Field({ nullable: true })
|
|
110
|
-
createdAt?: Date
|
|
111
|
-
|
|
112
|
-
@Column()
|
|
113
|
-
@Field({ nullable: true })
|
|
114
|
-
updatedAt?: Date
|
|
115
|
-
|
|
116
|
-
@Column({ nullable: true })
|
|
117
|
-
@Field({ nullable: true })
|
|
118
|
-
terminatedAt?: Date
|
|
119
|
-
|
|
120
|
-
@ManyToOne(type => User, { nullable: true })
|
|
121
|
-
@Field(type => User, { nullable: true })
|
|
122
|
-
creator?: User
|
|
123
|
-
|
|
124
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.creator)
|
|
125
|
-
creatorId?: string
|
|
126
|
-
|
|
127
|
-
@ManyToOne(type => User, { nullable: true })
|
|
128
|
-
@Field(type => User, { nullable: true })
|
|
129
|
-
updater?: User
|
|
130
|
-
|
|
131
|
-
@RelationId((processInstance: ProcessInstance) => processInstance.updater)
|
|
132
|
-
updaterId?: string
|
|
133
|
-
|
|
134
|
-
@HistoryOriginalIdColumn()
|
|
135
|
-
public originalId!: string
|
|
136
|
-
|
|
137
|
-
@HistoryActionColumn({
|
|
138
|
-
nullable: false,
|
|
139
|
-
type:
|
|
140
|
-
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
141
|
-
? 'enum'
|
|
142
|
-
: DATABASE_TYPE == 'oracle'
|
|
143
|
-
? 'varchar2'
|
|
144
|
-
: DATABASE_TYPE == 'mssql'
|
|
145
|
-
? 'nvarchar'
|
|
146
|
-
: 'varchar',
|
|
147
|
-
enum:
|
|
148
|
-
DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
149
|
-
? HistoryActionType
|
|
150
|
-
: undefined,
|
|
151
|
-
length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10
|
|
152
|
-
})
|
|
153
|
-
public action!: HistoryActionType
|
|
154
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { ScalarObject } from '@things-factory/shell'
|
|
4
|
-
|
|
5
|
-
import { abort, end } from '../../controllers/process-instance'
|
|
6
|
-
import { ProcessInstance } from './process-instance'
|
|
7
|
-
import { ProcessInstanceIssue, ProcessInstanceDraft } from './process-instance-type'
|
|
8
|
-
|
|
9
|
-
@Resolver(ProcessInstance)
|
|
10
|
-
export class ProcessInstanceMutation {
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
13
|
-
@Mutation(returns => ProcessInstance, { description: 'To end a ProcessInstance' })
|
|
14
|
-
async endProcessInstance(
|
|
15
|
-
@Arg('id') id: string,
|
|
16
|
-
@Arg('output', type => ScalarObject, { nullable: true }) output: { [key: string]: any },
|
|
17
|
-
@Arg('reason', { nullable: true }) reason: string,
|
|
18
|
-
@Ctx() context: ResolverContext
|
|
19
|
-
): Promise<ProcessInstance> {
|
|
20
|
-
return await end({ id, output, reason }, context)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Directive('@transaction')
|
|
24
|
-
@Directive('@privilege(category: "process", privilege: "mutation", domainOwnerGranted: true)')
|
|
25
|
-
@Mutation(returns => ProcessInstance, { description: 'To abort a ProcessInstance' })
|
|
26
|
-
async abortProcessInstance(
|
|
27
|
-
@Arg('id') id: string,
|
|
28
|
-
@Arg('reason', { nullable: true }) reason: string,
|
|
29
|
-
@Ctx() context: ResolverContext
|
|
30
|
-
): Promise<ProcessInstance> {
|
|
31
|
-
return await abort({ id, reason }, context)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Attachment } from '@things-factory/attachment-base'
|
|
4
|
-
import { Role, User } from '@things-factory/auth-base'
|
|
5
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { ProcessThread } from '../process-thread/process-thread'
|
|
8
|
-
import { Process } from '../process/process'
|
|
9
|
-
import { ProcessInstance, ProcessInstanceStatus } from './process-instance'
|
|
10
|
-
import { ProcessInstanceList } from './process-instance-type'
|
|
11
|
-
|
|
12
|
-
@Resolver(ProcessInstance)
|
|
13
|
-
export class ProcessInstanceQuery {
|
|
14
|
-
@Directive('@privilege(category: "process-instance", privilege: "query", domainOwnerGranted: true)')
|
|
15
|
-
@Query(returns => ProcessInstance!, { nullable: true, description: 'To fetch a ProcessInstance' })
|
|
16
|
-
async processInstance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ProcessInstance> {
|
|
17
|
-
const { domain } = context.state
|
|
18
|
-
|
|
19
|
-
return await getRepository(ProcessInstance).findOne({
|
|
20
|
-
where: { domain: { id: domain.id }, id }
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Directive('@privilege(category: "process-instance", privilege: "query", domainOwnerGranted: true)')
|
|
25
|
-
@Query(returns => ProcessInstanceList, { description: 'To fetch multiple ProcessInstances' })
|
|
26
|
-
async processInstances(
|
|
27
|
-
@Args(type => ListParam) params: ListParam,
|
|
28
|
-
@Ctx() context: ResolverContext
|
|
29
|
-
): Promise<ProcessInstanceList> {
|
|
30
|
-
const { domain } = context.state
|
|
31
|
-
|
|
32
|
-
const [items, total] = await getQueryBuilderFromListParams({
|
|
33
|
-
domain,
|
|
34
|
-
params,
|
|
35
|
-
repository: getRepository(ProcessInstance),
|
|
36
|
-
searchables: ['name', 'description']
|
|
37
|
-
}).getManyAndCount()
|
|
38
|
-
|
|
39
|
-
return { items, total }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Directive('@privilege(category: "process-instance", privilege: "query", domainOwnerGranted: true)')
|
|
43
|
-
@Query(returns => ProcessInstanceList, { description: 'To fetch multiple process instances by process' })
|
|
44
|
-
async processInstancesByProcess(
|
|
45
|
-
@Arg('processId') processId: string,
|
|
46
|
-
@Args(type => ListParam) params: ListParam,
|
|
47
|
-
@Ctx() context: ResolverContext
|
|
48
|
-
): Promise<ProcessInstanceList> {
|
|
49
|
-
const { domain } = context.state
|
|
50
|
-
|
|
51
|
-
const process = await getRepository(Process).findOneBy({ id: processId })
|
|
52
|
-
const searchables = process?.searchKeys?.map((item, index) => `key0${index + 1}`) || []
|
|
53
|
-
|
|
54
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
55
|
-
repository: getRepository(ProcessInstance),
|
|
56
|
-
params,
|
|
57
|
-
domain,
|
|
58
|
-
alias: 'pi',
|
|
59
|
-
searchables: ['name', 'description'].concat(searchables)
|
|
60
|
-
}).where('pi.process = :process', { process: processId })
|
|
61
|
-
|
|
62
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
63
|
-
|
|
64
|
-
return { items, total }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@FieldResolver(type => Process)
|
|
68
|
-
async process(@Root() processInstance: ProcessInstance): Promise<Process> {
|
|
69
|
-
const { processId } = processInstance
|
|
70
|
-
|
|
71
|
-
return await getRepository(Process).findOneBy({ id: processId })
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@FieldResolver(type => [ProcessThread])
|
|
75
|
-
async processThreads(
|
|
76
|
-
@Root() processInstance: ProcessInstance,
|
|
77
|
-
@Ctx() context: ResolverContext
|
|
78
|
-
): Promise<ProcessThread[]> {
|
|
79
|
-
const { user } = context.state
|
|
80
|
-
const { supervisoryRoleId } = processInstance
|
|
81
|
-
|
|
82
|
-
if (supervisoryRoleId) {
|
|
83
|
-
/* only user having supervisoryRole can get whole processThreads */
|
|
84
|
-
const roles = (
|
|
85
|
-
(await getRepository(User).findOne({
|
|
86
|
-
where: { id: user.id },
|
|
87
|
-
relations: ['roles']
|
|
88
|
-
})) as User
|
|
89
|
-
).roles.map(role => role.id)
|
|
90
|
-
|
|
91
|
-
if (!roles.includes(supervisoryRoleId)) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return await getRepository(ProcessThread).findBy({
|
|
97
|
-
processInstance: { id: processInstance.id }
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@FieldResolver(type => Role)
|
|
102
|
-
async supervisoryRole(@Root() processInstance: ProcessInstance): Promise<Role> {
|
|
103
|
-
return (
|
|
104
|
-
processInstance.supervisoryRole ||
|
|
105
|
-
(processInstance.supervisoryRoleId &&
|
|
106
|
-
(await getRepository(Role).findOneBy({
|
|
107
|
-
id: processInstance.supervisoryRoleId
|
|
108
|
-
})))
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@FieldResolver(type => String)
|
|
113
|
-
async thumbnail(@Root() processInstance: ProcessInstance): Promise<string | undefined> {
|
|
114
|
-
const { processId } = processInstance
|
|
115
|
-
const attachment: Attachment =
|
|
116
|
-
processId &&
|
|
117
|
-
(await getRepository(Attachment).findOne({
|
|
118
|
-
where: {
|
|
119
|
-
domain: { id: processInstance.domainId },
|
|
120
|
-
refBy: processId
|
|
121
|
-
}
|
|
122
|
-
}))
|
|
123
|
-
|
|
124
|
-
return attachment?.fullpath
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@FieldResolver(type => Domain)
|
|
128
|
-
async domain(@Root() processInstance: ProcessInstance): Promise<Domain> {
|
|
129
|
-
return await getRepository(Domain).findOneBy({ id: processInstance.domainId })
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@FieldResolver(type => User)
|
|
133
|
-
async updater(@Root() processInstance: ProcessInstance): Promise<User> {
|
|
134
|
-
return processInstance.updaterId && (await getRepository(User).findOneBy({ id: processInstance.updaterId }))
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@FieldResolver(type => User)
|
|
138
|
-
async creator(@Root() processInstance: ProcessInstance): Promise<User> {
|
|
139
|
-
return processInstance.creatorId && (await getRepository(User).findOneBy({ id: processInstance.creatorId }))
|
|
140
|
-
}
|
|
141
|
-
}
|