@things-factory/process 7.0.0-alpha.0 → 7.0.0-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/process",
3
- "version": "7.0.0-alpha.0",
3
+ "version": "7.0.0-alpha.1",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -31,15 +31,15 @@
31
31
  "@operato/graphql": "^2.0.0-alpha.0",
32
32
  "@operato/grist-editor": "^2.0.0-alpha.0",
33
33
  "@operato/shell": "^2.0.0-alpha.0",
34
- "@things-factory/attachment-base": "^7.0.0-alpha.0",
35
- "@things-factory/auth-base": "^7.0.0-alpha.0",
36
- "@things-factory/board-service": "^7.0.0-alpha.0",
37
- "@things-factory/context-ui": "^7.0.0-alpha.0",
38
- "@things-factory/organization": "^7.0.0-alpha.0",
39
- "@things-factory/scheduler-client": "^7.0.0-alpha.0",
40
- "@things-factory/shell": "^7.0.0-alpha.0",
41
- "@things-factory/worklist": "^7.0.0-alpha.0",
34
+ "@things-factory/attachment-base": "^7.0.0-alpha.1",
35
+ "@things-factory/auth-base": "^7.0.0-alpha.1",
36
+ "@things-factory/board-service": "^7.0.0-alpha.1",
37
+ "@things-factory/context-ui": "^7.0.0-alpha.1",
38
+ "@things-factory/organization": "^7.0.0-alpha.1",
39
+ "@things-factory/scheduler-client": "^7.0.0-alpha.1",
40
+ "@things-factory/shell": "^7.0.0-alpha.1",
41
+ "@things-factory/worklist": "^7.0.0-alpha.1",
42
42
  "moment-timezone": "^0.5.40"
43
43
  },
44
- "gitHead": "0eb7f1db7ca559df530b3242c48456fc565ef4c0"
44
+ "gitHead": "778315d165d7f15e147583a45d5079c3d7cbce38"
45
45
  }
@@ -1,15 +1,15 @@
1
- import { withFilter } from 'graphql-subscriptions'
1
+ import { filter, pipe } from 'graphql-yoga'
2
2
  import { Resolver, Root, Subscription } from 'type-graphql'
3
3
 
4
+ import { pubsub } from '@things-factory/shell'
4
5
  import { User } from '@things-factory/auth-base'
5
- import { getRepository, pubsub } from '@things-factory/shell'
6
6
 
7
7
  import { ProcessInstance } from './process-instance'
8
8
 
9
9
  @Resolver(ProcessInstance)
10
10
  export class ProcessInstanceSubscription {
11
11
  @Subscription({
12
- subscribe: (_, args, context, info) => {
12
+ subscribe: ({ args, context, info }) => {
13
13
  const { domain, user } = context.state
14
14
  const subdomain = domain?.subdomain
15
15
 
@@ -21,9 +21,9 @@ export class ProcessInstanceSubscription {
21
21
  throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
22
22
  }
23
23
 
24
- return withFilter(
25
- () => pubsub.asyncIterator('process-instance'),
26
- async (payload, variables, context, info) => {
24
+ return pipe(
25
+ pubsub.subscribe('process-instance'),
26
+ filter(async (payload: { processInstance: ProcessInstance }) => {
27
27
  const { processInstance } = payload
28
28
  const { domainId } = processInstance
29
29
 
@@ -35,15 +35,9 @@ export class ProcessInstanceSubscription {
35
35
  return true
36
36
  }
37
37
 
38
- // check if the user has that role
39
- const userWithRoles: User = await getRepository(User).findOne({
40
- where: { id: user.id },
41
- relations: ['roles']
42
- })
43
-
44
- return !!userWithRoles.roles.find(role => role.id === processInstance.assigneeRoleId)
45
- }
46
- )(_, args, context, info)
38
+ return await User.hasPrivilege('query', 'process-instance', domain, user)
39
+ })
40
+ )
47
41
  }
48
42
  })
49
43
  processInstance(@Root() payload: { processInstance: ProcessInstance }): ProcessInstance {
@@ -1,14 +1,15 @@
1
- import { withFilter } from 'graphql-subscriptions'
1
+ import { filter, pipe } from 'graphql-yoga'
2
2
  import { Resolver, Root, Subscription } from 'type-graphql'
3
3
 
4
4
  import { pubsub } from '@things-factory/shell'
5
+ import { User } from '@things-factory/auth-base'
5
6
 
6
7
  import { ProcessThread } from './process-thread'
7
8
 
8
9
  @Resolver(ProcessThread)
9
10
  export class ProcessThreadSubscription {
10
11
  @Subscription({
11
- subscribe: (_, args, context, info) => {
12
+ subscribe: ({ args, context, info }) => {
12
13
  const { domain, user } = context.state
13
14
  const subdomain = domain?.subdomain
14
15
 
@@ -20,9 +21,9 @@ export class ProcessThreadSubscription {
20
21
  throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)
21
22
  }
22
23
 
23
- return withFilter(
24
- () => pubsub.asyncIterator('process-thread'),
25
- async (payload, variables, context, info) => {
24
+ return pipe(
25
+ pubsub.subscribe('process-thread'),
26
+ filter(async (payload: { processThread: ProcessThread }) => {
26
27
  const { processThread } = payload
27
28
  const { domainId } = processThread
28
29
 
@@ -30,9 +31,9 @@ export class ProcessThreadSubscription {
30
31
  return false
31
32
  }
32
33
 
33
- return processThread.assigneeId === user.id
34
- }
35
- )(_, args, context, info)
34
+ return await User.hasPrivilege('query', 'process-thread', domain, user)
35
+ })
36
+ )
36
37
  }
37
38
  })
38
39
  processThread(@Root() payload: { processThread: ProcessThread }): ProcessThread {