@things-factory/process 8.0.0-beta.9 → 8.0.2
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/client/actions/main.ts +1 -0
- package/client/bootstrap.ts +8 -0
- package/client/index.ts +1 -0
- package/client/pages/event/event-importer.ts +86 -0
- package/client/pages/event/event-list-page.ts +324 -0
- package/client/pages/gateway/gateway-importer.ts +87 -0
- package/client/pages/gateway/gateway-list-page.ts +323 -0
- package/client/pages/main.ts +25 -0
- package/client/pages/process/process-importer.ts +87 -0
- package/client/pages/process/process-list-page.ts +324 -0
- package/client/pages/process-instance/process-instance-importer.ts +87 -0
- package/client/pages/process-instance/process-instance-list-page.ts +323 -0
- package/client/pages/process-thread/process-thread-importer.ts +87 -0
- package/client/pages/process-thread/process-thread-list-page.ts +323 -0
- package/client/reducers/main.ts +17 -0
- package/client/route.ts +27 -0
- package/client/tsconfig.json +13 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/server/controllers/common.ts +90 -0
- package/server/controllers/index.ts +0 -0
- package/server/controllers/process-instance/abort.ts +75 -0
- package/server/controllers/process-instance/end.ts +74 -0
- package/server/controllers/process-instance/index.ts +2 -0
- package/server/controllers/process-thread/_abort.ts +20 -0
- package/server/controllers/process-thread/abort.ts +48 -0
- package/server/controllers/process-thread/end.ts +54 -0
- package/server/controllers/process-thread/index.ts +3 -0
- package/server/controllers/process-thread/start.ts +49 -0
- package/server/index.ts +4 -0
- package/server/middlewares/index.ts +3 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +80 -0
- package/server/service/index.ts +44 -0
- package/server/service/process/event-subscriber.ts +17 -0
- package/server/service/process/index.ts +9 -0
- package/server/service/process/process-history.ts +108 -0
- package/server/service/process/process-mutation.ts +210 -0
- package/server/service/process/process-query.ts +120 -0
- package/server/service/process/process-search-key-item-type.ts +16 -0
- package/server/service/process/process-type.ts +65 -0
- package/server/service/process/process.ts +97 -0
- package/server/service/process-instance/event-subscriber.ts +44 -0
- package/server/service/process-instance/index.ts +10 -0
- package/server/service/process-instance/process-instance-history.ts +154 -0
- package/server/service/process-instance/process-instance-mutation.ts +33 -0
- package/server/service/process-instance/process-instance-query.ts +141 -0
- package/server/service/process-instance/process-instance-subscription.ts +46 -0
- package/server/service/process-instance/process-instance-type.ts +71 -0
- package/server/service/process-instance/process-instance.ts +147 -0
- package/server/service/process-stats/index.ts +3 -0
- package/server/service/process-stats/process-stats-query.ts +57 -0
- package/server/service/process-stats/process-stats-type.ts +31 -0
- package/server/service/process-thread/event-subscriber.ts +31 -0
- package/server/service/process-thread/index.ts +9 -0
- package/server/service/process-thread/process-thread-mutation.ts +34 -0
- package/server/service/process-thread/process-thread-query.ts +61 -0
- package/server/service/process-thread/process-thread-subscription.ts +42 -0
- package/server/service/process-thread/process-thread-type.ts +15 -0
- package/server/service/process-thread/process-thread.ts +90 -0
- package/server/tsconfig.json +10 -0
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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]
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
}
|