@things-factory/work-shift 7.0.1-beta.8 → 7.0.1-rc.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.
Files changed (30) hide show
  1. package/dist-client/pages/work-shift.js.map +1 -1
  2. package/dist-client/route.js.map +1 -1
  3. package/dist-client/tsconfig.tsbuildinfo +1 -1
  4. package/dist-server/controllers/index.d.ts +2 -0
  5. package/dist-server/controllers/work-shift-range.d.ts +12 -0
  6. package/dist-server/controllers/work-shift-range.js +13 -8
  7. package/dist-server/controllers/work-shift-range.js.map +1 -1
  8. package/dist-server/controllers/work-shift-schedule.d.ts +3 -0
  9. package/dist-server/controllers/work-shift-schedule.js +2 -3
  10. package/dist-server/controllers/work-shift-schedule.js.map +1 -1
  11. package/dist-server/index.d.ts +2 -0
  12. package/dist-server/service/index.d.ts +5 -0
  13. package/dist-server/service/work-shift/index.d.ts +5 -0
  14. package/dist-server/service/work-shift/work-shift-mutation.d.ts +6 -0
  15. package/dist-server/service/work-shift/work-shift-mutation.js +2 -2
  16. package/dist-server/service/work-shift/work-shift-mutation.js.map +1 -1
  17. package/dist-server/service/work-shift/work-shift-query.d.ts +14 -0
  18. package/dist-server/service/work-shift/work-shift-query.js +5 -5
  19. package/dist-server/service/work-shift/work-shift-query.js.map +1 -1
  20. package/dist-server/service/work-shift/work-shift-type.d.ts +19 -0
  21. package/dist-server/service/work-shift/work-shift-type.js +6 -6
  22. package/dist-server/service/work-shift/work-shift-type.js.map +1 -1
  23. package/dist-server/service/work-shift/work-shift.d.ts +24 -0
  24. package/dist-server/service/work-shift/work-shift.js +5 -5
  25. package/dist-server/service/work-shift/work-shift.js.map +1 -1
  26. package/dist-server/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +5 -5
  28. package/server/controllers/work-shift-range.ts +25 -7
  29. package/server/service/work-shift/work-shift-query.ts +4 -1
  30. package/server/service/work-shift/work-shift.ts +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/work-shift",
3
- "version": "7.0.1-beta.8",
3
+ "version": "7.0.1-rc.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -27,10 +27,10 @@
27
27
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
28
28
  },
29
29
  "dependencies": {
30
- "@things-factory/auth-base": "^7.0.1-beta.8",
31
- "@things-factory/env": "^7.0.1-beta.6",
32
- "@things-factory/shell": "^7.0.1-beta.8",
30
+ "@things-factory/auth-base": "^7.0.1-rc.0",
31
+ "@things-factory/env": "^7.0.1-rc.0",
32
+ "@things-factory/shell": "^7.0.1-rc.0",
33
33
  "moment-timezone": "^0.5.40"
34
34
  },
35
- "gitHead": "d2ca60f7fca6feb2b7cb86b4f825378573fcc335"
35
+ "gitHead": "45476b164b69aef2c211d9a5257897f42d8e2f5f"
36
36
  }
@@ -10,7 +10,7 @@ export async function getDateRangeForWorkShift(
10
10
  domain: Domain,
11
11
  workDate: string,
12
12
  workShiftName: string,
13
- options: { timezone?: string; format?: string }
13
+ options?: { timezone?: string; format?: string }
14
14
  ): Promise<Date[]> {
15
15
  const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
16
16
  const { timezone, format } = dateOptions
@@ -30,13 +30,19 @@ export async function getDateRangeForWorkShift(
30
30
 
31
31
  const convertedFromDate = theDay.clone().add(fromDate, 'day')
32
32
  const convertedToDate = theDay.clone().add(toDate, 'day')
33
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
33
+ const from = moment
34
+ .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
35
+ .toDate()
34
36
  const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
35
37
 
36
38
  return [from, to]
37
39
  }
38
40
 
39
- export async function getDateRangeForWorkDate(domain: Domain, workDate: string, options: { timezone?: string; format?: string }) {
41
+ export async function getDateRangeForWorkDate(
42
+ domain: Domain,
43
+ workDate: string,
44
+ options?: { timezone?: string; format?: string }
45
+ ) {
40
46
  const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }
41
47
  const { timezone, format } = dateOptions
42
48
 
@@ -63,8 +69,12 @@ export async function getDateRangeForWorkDate(domain: Domain, workDate: string,
63
69
 
64
70
  const convertedFromDate = theDay.clone().add(fromDate, 'day')
65
71
  const convertedToDate = theDay.clone().add(toDate, 'day')
66
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
67
- const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone).toDate()
72
+ const from = moment
73
+ .tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
74
+ .toDate()
75
+ const to = moment
76
+ .tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
77
+ .toDate()
68
78
 
69
79
  if (!beginDate) {
70
80
  beginDate = from
@@ -189,7 +199,11 @@ export async function getLatestWorkDateAndShift(domain: Domain, dateTime: Date,
189
199
  if (j > 0) {
190
200
  const { name, fromDate, fromTime, toDate, toTime } = workShifts[j - 1]
191
201
 
192
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
202
+ const from = moment.tz(
203
+ `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
204
+ 'YYYY-MM-DD HH:mm:ss',
205
+ timezone
206
+ )
193
207
  const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
194
208
 
195
209
  return {
@@ -204,7 +218,11 @@ export async function getLatestWorkDateAndShift(domain: Domain, dateTime: Date,
204
218
  const convertedFromDate = days[i - 1].clone().add(fromDate, 'day')
205
219
  const convertedToDate = days[i - 1].clone().add(toDate, 'day')
206
220
 
207
- const from = moment.tz(`${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
221
+ const from = moment.tz(
222
+ `${convertedFromDate.format('YYYY-MM-DD')} ${fromTime}`,
223
+ 'YYYY-MM-DD HH:mm:ss',
224
+ timezone
225
+ )
208
226
  const to = moment.tz(`${convertedToDate.format('YYYY-MM-DD')} ${toTime}`, 'YYYY-MM-DD HH:mm:ss', timezone)
209
227
 
210
228
  return {
@@ -33,7 +33,10 @@ export class DomainWorkShiftQuery {
33
33
  @Resolver(WorkShift)
34
34
  export class WorkShiftQuery {
35
35
  @Query(returns => WorkShiftList, { description: 'To fetch multiple WorkShifts' })
36
- async workShifts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<WorkShiftList> {
36
+ async workShifts(
37
+ @Args(type => ListParam) params: ListParam,
38
+ @Ctx() context: ResolverContext
39
+ ): Promise<WorkShiftList> {
37
40
  const { domain } = context.state
38
41
 
39
42
  const queryBuilder = getQueryBuilderFromListParams({
@@ -77,14 +77,14 @@ export class WorkShift {
77
77
  updatedAt?: Date
78
78
 
79
79
  @ManyToOne(type => User, { nullable: true })
80
- @Field({ nullable: true })
80
+ @Field(type => User, { nullable: true })
81
81
  creator?: User
82
82
 
83
83
  @RelationId((workShift: WorkShift) => workShift.creator)
84
84
  creatorId?: string
85
85
 
86
86
  @ManyToOne(type => User, { nullable: true })
87
- @Field({ nullable: true })
87
+ @Field(type => User, { nullable: true })
88
88
  updater?: User
89
89
 
90
90
  @RelationId((workShift: WorkShift) => workShift.updater)