@things-factory/work-shift 5.0.11 → 6.0.0-alpha.3

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,11 +1,11 @@
1
1
  {
2
2
  "name": "@things-factory/work-shift",
3
- "version": "5.0.11",
3
+ "version": "6.0.0-alpha.3",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
7
7
  "license": "MIT",
8
- "author": "heartyoh",
8
+ "author": "heartyoh <heartyoh@hatiolab.com>",
9
9
  "description": "Module to handle work shift",
10
10
  "publishConfig": {
11
11
  "access": "public",
@@ -24,9 +24,9 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/auth-base": "^5.0.11",
28
- "@things-factory/env": "^5.0.0",
29
- "@things-factory/shell": "^5.0.11"
27
+ "@things-factory/auth-base": "^6.0.0-alpha.3",
28
+ "@things-factory/env": "^6.0.0-alpha.3",
29
+ "@things-factory/shell": "^6.0.0-alpha.3"
30
30
  },
31
- "gitHead": "37cd4feb62e062899cae7029588d86a5d4b4036a"
31
+ "gitHead": "1e273b6485662da938cae8fdca035d994ef4a95d"
32
32
  }
@@ -1,8 +1,7 @@
1
1
  import moment from 'moment-timezone'
2
- import { getRepository } from 'typeorm'
3
2
 
4
3
  import { logger } from '@things-factory/env'
5
- import { Domain } from '@things-factory/shell'
4
+ import { Domain, getRepository } from '@things-factory/shell'
6
5
 
7
6
  import { WorkShift, WorkShiftDateType } from '../service/work-shift/work-shift'
8
7
  import { WorkDateWorkShiftPair } from '../service/work-shift/work-shift-type'
@@ -1,5 +1,6 @@
1
- import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
1
+ import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
2
2
  import { In } from 'typeorm'
3
+
3
4
  import { WorkShift } from './work-shift'
4
5
  import { WorkShiftPatch } from './work-shift-type'
5
6
 
@@ -10,7 +11,7 @@ export class WorkShiftMutation {
10
11
  @Mutation(returns => [WorkShift], { description: "To modify multiple WorkShifts' information" })
11
12
  async updateMultipleWorkShift(
12
13
  @Arg('patches', type => [WorkShiftPatch]) patches: WorkShiftPatch[],
13
- @Ctx() context: any
14
+ @Ctx() context: ResolverContext
14
15
  ): Promise<WorkShift[]> {
15
16
  const { domain, user, tx } = context.state
16
17
 
@@ -38,11 +39,14 @@ export class WorkShiftMutation {
38
39
  @Directive('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true)')
39
40
  @Directive('@transaction')
40
41
  @Mutation(returns => Boolean, { description: 'To delete multiple workShifts' })
41
- async deleteWorkShifts(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {
42
+ async deleteWorkShifts(
43
+ @Arg('ids', type => [String]) ids: string[],
44
+ @Ctx() context: ResolverContext
45
+ ): Promise<boolean> {
42
46
  const { domain, tx } = context.state
43
47
 
44
48
  await tx.getRepository(WorkShift).delete({
45
- domain,
49
+ domain: { id: domain.id },
46
50
  id: In(ids)
47
51
  })
48
52
 
@@ -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 { getWorkDateAndShift } from '../../controllers/index'
8
7
  import { WorkShift } from './work-shift'
@@ -11,7 +10,10 @@ import { WorkDateWorkShiftPair, WorkShiftList } from './work-shift-type'
11
10
  @Resolver(Domain)
12
11
  export class DomainWorkShiftQuery {
13
12
  @Query(returns => WorkDateWorkShiftPair, { description: 'To fetch a work date and work shift for given datetime' })
14
- async getWorkDateAndShift(@Arg('dateTime') dateTime: Date, @Ctx() context: any): Promise<WorkDateWorkShiftPair> {
13
+ async getWorkDateAndShift(
14
+ @Arg('dateTime') dateTime: Date,
15
+ @Ctx() context: ResolverContext
16
+ ): Promise<WorkDateWorkShiftPair> {
15
17
  const { domain } = context.state
16
18
 
17
19
  return await getWorkDateAndShift(domain, dateTime)
@@ -34,7 +36,7 @@ export class DomainWorkShiftQuery {
34
36
  @Resolver(WorkShift)
35
37
  export class WorkShiftQuery {
36
38
  @Query(returns => WorkShiftList, { description: 'To fetch multiple WorkShifts' })
37
- async workShifts(@Args() params: ListParam, @Ctx() context: any): Promise<WorkShiftList> {
39
+ async workShifts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<WorkShiftList> {
38
40
  const { domain } = context.state
39
41
 
40
42
  const queryBuilder = getQueryBuilderFromListParams({
@@ -50,16 +52,16 @@ export class WorkShiftQuery {
50
52
 
51
53
  @FieldResolver(type => Domain)
52
54
  async domain(@Root() workShift: WorkShift): Promise<Domain> {
53
- return await getRepository(Domain).findOne(workShift.domainId)
55
+ return await getRepository(Domain).findOneBy({ id: workShift.domainId })
54
56
  }
55
57
 
56
58
  @FieldResolver(type => User)
57
59
  async updater(@Root() workShift: WorkShift): Promise<User> {
58
- return await getRepository(User).findOne(workShift.updaterId)
60
+ return await getRepository(User).findOneBy({ id: workShift.updaterId })
59
61
  }
60
62
 
61
63
  @FieldResolver(type => User)
62
64
  async creator(@Root() workShift: WorkShift): Promise<User> {
63
- return await getRepository(User).findOne(workShift.creatorId)
65
+ return await getRepository(User).findOneBy({ id: workShift.creatorId })
64
66
  }
65
67
  }