rotacloud 1.1.1 → 1.2.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/cjs/interfaces/index.d.ts +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/query-params/index.d.ts +0 -1
- package/dist/cjs/interfaces/query-params/index.js +0 -1
- package/dist/cjs/interfaces/terminal.interface.d.ts +1 -0
- package/dist/cjs/interfaces/time-zone.interface.d.ts +7 -0
- package/dist/cjs/rotacloud.d.ts +2 -1
- package/dist/cjs/rotacloud.js +1 -0
- package/dist/cjs/services/accounts.service.d.ts +26 -7
- package/dist/cjs/services/accounts.service.js +10 -20
- package/dist/cjs/services/attendance.service.d.ts +30 -11
- package/dist/cjs/services/attendance.service.js +16 -26
- package/dist/cjs/services/auth.service.js +1 -3
- package/dist/cjs/services/availability.service.d.ts +3 -3
- package/dist/cjs/services/availability.service.js +8 -18
- package/dist/cjs/services/daily-budgets.service.d.ts +19 -7
- package/dist/cjs/services/daily-budgets.service.js +12 -22
- package/dist/cjs/services/daily-revenue.service.d.ts +18 -6
- package/dist/cjs/services/daily-revenue.service.js +11 -21
- package/dist/cjs/services/day-notes.service.d.ts +27 -8
- package/dist/cjs/services/day-notes.service.js +15 -25
- package/dist/cjs/services/days-off.service.d.ts +17 -5
- package/dist/cjs/services/days-off.service.js +13 -23
- package/dist/cjs/services/groups.service.d.ts +27 -8
- package/dist/cjs/services/groups.service.js +12 -22
- package/dist/cjs/services/index.d.ts +1 -0
- package/dist/cjs/services/index.js +1 -0
- package/dist/cjs/services/leave-embargoes.service.d.ts +27 -8
- package/dist/cjs/services/leave-embargoes.service.js +16 -26
- package/dist/cjs/services/leave-request.service.d.ts +27 -8
- package/dist/cjs/services/leave-request.service.js +15 -25
- package/dist/cjs/services/leave.service.d.ts +28 -10
- package/dist/cjs/services/leave.service.js +13 -46
- package/dist/cjs/services/locations.service.d.ts +27 -8
- package/dist/cjs/services/locations.service.js +16 -26
- package/dist/cjs/services/pins.service.d.ts +12 -5
- package/dist/cjs/services/pins.service.js +1 -1
- package/dist/cjs/services/roles.service.d.ts +27 -8
- package/dist/cjs/services/roles.service.js +16 -26
- package/dist/cjs/services/service.d.ts +12 -3
- package/dist/cjs/services/service.js +1 -2
- package/dist/cjs/services/settings.service.d.ts +1 -1
- package/dist/cjs/services/settings.service.js +1 -1
- package/dist/cjs/services/shifts.service.d.ts +30 -11
- package/dist/cjs/services/shifts.service.js +21 -31
- package/dist/cjs/services/terminals-active.service.d.ts +20 -8
- package/dist/cjs/services/terminals-active.service.js +16 -26
- package/dist/cjs/services/terminals.service.d.ts +27 -8
- package/dist/cjs/services/terminals.service.js +13 -23
- package/dist/cjs/services/time-zone.service.d.ts +14 -0
- package/dist/cjs/services/time-zone.service.js +82 -0
- package/dist/cjs/services/toil-accruals.service.d.ts +4 -4
- package/dist/cjs/services/toil-accruals.service.js +12 -22
- package/dist/cjs/services/toil-allowance.service.d.ts +3 -3
- package/dist/cjs/services/toil-allowance.service.js +9 -19
- package/dist/cjs/services/users-clock-in.service.d.ts +22 -10
- package/dist/cjs/services/users-clock-in.service.js +5 -5
- package/dist/cjs/services/users.service.d.ts +28 -9
- package/dist/cjs/services/users.service.js +16 -26
- package/dist/cjs/version.js +1 -1
- package/dist/mjs/interfaces/index.d.ts +1 -0
- package/dist/mjs/interfaces/index.js +1 -0
- package/dist/mjs/interfaces/query-params/index.d.ts +0 -1
- package/dist/mjs/interfaces/query-params/index.js +0 -1
- package/dist/mjs/interfaces/terminal.interface.d.ts +1 -0
- package/dist/mjs/interfaces/time-zone.interface.d.ts +7 -0
- package/dist/mjs/rotacloud.d.ts +2 -1
- package/dist/mjs/rotacloud.js +2 -1
- package/dist/mjs/services/accounts.service.d.ts +26 -7
- package/dist/mjs/services/accounts.service.js +2 -4
- package/dist/mjs/services/attendance.service.d.ts +30 -11
- package/dist/mjs/services/attendance.service.js +8 -10
- package/dist/mjs/services/auth.service.js +1 -3
- package/dist/mjs/services/availability.service.d.ts +3 -3
- package/dist/mjs/services/availability.service.js +3 -5
- package/dist/mjs/services/daily-budgets.service.d.ts +19 -7
- package/dist/mjs/services/daily-budgets.service.js +4 -6
- package/dist/mjs/services/daily-revenue.service.d.ts +18 -6
- package/dist/mjs/services/daily-revenue.service.js +3 -5
- package/dist/mjs/services/day-notes.service.d.ts +27 -8
- package/dist/mjs/services/day-notes.service.js +7 -9
- package/dist/mjs/services/days-off.service.d.ts +17 -5
- package/dist/mjs/services/days-off.service.js +5 -7
- package/dist/mjs/services/groups.service.d.ts +27 -8
- package/dist/mjs/services/groups.service.js +4 -6
- package/dist/mjs/services/index.d.ts +1 -0
- package/dist/mjs/services/index.js +1 -0
- package/dist/mjs/services/leave-embargoes.service.d.ts +27 -8
- package/dist/mjs/services/leave-embargoes.service.js +8 -10
- package/dist/mjs/services/leave-request.service.d.ts +27 -8
- package/dist/mjs/services/leave-request.service.js +7 -9
- package/dist/mjs/services/leave.service.d.ts +28 -10
- package/dist/mjs/services/leave.service.js +5 -12
- package/dist/mjs/services/locations.service.d.ts +27 -8
- package/dist/mjs/services/locations.service.js +8 -10
- package/dist/mjs/services/pins.service.d.ts +12 -5
- package/dist/mjs/services/pins.service.js +1 -1
- package/dist/mjs/services/roles.service.d.ts +27 -8
- package/dist/mjs/services/roles.service.js +8 -10
- package/dist/mjs/services/service.d.ts +12 -3
- package/dist/mjs/services/service.js +0 -2
- package/dist/mjs/services/settings.service.d.ts +1 -1
- package/dist/mjs/services/settings.service.js +1 -1
- package/dist/mjs/services/shifts.service.d.ts +30 -11
- package/dist/mjs/services/shifts.service.js +13 -15
- package/dist/mjs/services/terminals-active.service.d.ts +20 -8
- package/dist/mjs/services/terminals-active.service.js +8 -10
- package/dist/mjs/services/terminals.service.d.ts +27 -8
- package/dist/mjs/services/terminals.service.js +5 -7
- package/dist/mjs/services/time-zone.service.d.ts +14 -0
- package/dist/mjs/services/time-zone.service.js +25 -0
- package/dist/mjs/services/toil-accruals.service.d.ts +4 -4
- package/dist/mjs/services/toil-accruals.service.js +4 -6
- package/dist/mjs/services/toil-allowance.service.d.ts +3 -3
- package/dist/mjs/services/toil-allowance.service.js +1 -3
- package/dist/mjs/services/users-clock-in.service.d.ts +22 -10
- package/dist/mjs/services/users-clock-in.service.js +5 -5
- package/dist/mjs/services/users.service.d.ts +28 -9
- package/dist/mjs/services/users.service.js +8 -10
- package/dist/mjs/version.js +1 -1
- package/package.json +1 -1
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/query-params/index.ts +0 -1
- package/src/interfaces/terminal.interface.ts +1 -0
- package/src/interfaces/time-zone.interface.ts +7 -0
- package/src/rotacloud.ts +2 -0
- package/src/services/accounts.service.ts +30 -14
- package/src/services/attendance.service.ts +57 -28
- package/src/services/auth.service.ts +1 -3
- package/src/services/availability.service.ts +14 -13
- package/src/services/daily-budgets.service.ts +41 -20
- package/src/services/daily-revenue.service.ts +37 -19
- package/src/services/day-notes.service.ts +51 -25
- package/src/services/days-off.service.ts +46 -25
- package/src/services/groups.service.ts +40 -20
- package/src/services/index.ts +1 -0
- package/src/services/leave-embargoes.service.ts +54 -25
- package/src/services/leave-request.service.ts +53 -24
- package/src/services/leave.service.ts +41 -27
- package/src/services/locations.service.ts +54 -25
- package/src/services/pins.service.ts +11 -6
- package/src/services/roles.service.ts +49 -25
- package/src/services/service.ts +35 -9
- package/src/services/settings.service.ts +2 -2
- package/src/services/shifts.service.ts +62 -36
- package/src/services/terminals-active.service.ts +36 -23
- package/src/services/terminals.service.ts +36 -18
- package/src/services/time-zone.service.ts +34 -0
- package/src/services/toil-accruals.service.ts +9 -11
- package/src/services/toil-allowance.service.ts +3 -5
- package/src/services/users-clock-in.service.ts +30 -16
- package/src/services/users.service.ts +49 -26
- package/src/version.ts +1 -1
- package/dist/cjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
- package/dist/mjs/interfaces/query-params/internal-query-params.interface.d.ts +0 -5
- package/src/interfaces/query-params/internal-query-params.interface.ts +0 -5
- /package/dist/cjs/interfaces/{query-params/internal-query-params.interface.js → time-zone.interface.js} +0 -0
- /package/dist/mjs/interfaces/{query-params/internal-query-params.interface.js → time-zone.interface.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { Terminal, TerminalLocation } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options } from './index.js';
|
|
3
|
+
import { Service, Options, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
interface LaunchTerminal {
|
|
6
6
|
terminal: number;
|
|
@@ -13,20 +13,23 @@ interface PingTerminal {
|
|
|
13
13
|
device: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class TerminalsActiveService extends Service {
|
|
16
|
+
export class TerminalsActiveService extends Service<Terminal> {
|
|
17
17
|
private apiPath = '/terminals_active';
|
|
18
18
|
|
|
19
19
|
launchTerminal(data: LaunchTerminal): Promise<Terminal>;
|
|
20
|
-
launchTerminal(data: LaunchTerminal, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
20
|
+
launchTerminal(data: LaunchTerminal, options: { rawResponse: true } & Options): Promise<AxiosResponse<Terminal>>;
|
|
21
21
|
launchTerminal(data: LaunchTerminal, options: Options): Promise<Terminal>;
|
|
22
22
|
launchTerminal(data: LaunchTerminal, options?: Options) {
|
|
23
23
|
return super
|
|
24
|
-
.fetch<Terminal>(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
.fetch<Terminal>(
|
|
25
|
+
{
|
|
26
|
+
url: this.apiPath,
|
|
27
|
+
data,
|
|
28
|
+
method: 'POST',
|
|
29
|
+
},
|
|
30
|
+
options,
|
|
31
|
+
)
|
|
32
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
pingTerminal(id: number, data: PingTerminal): Promise<number>;
|
|
@@ -34,22 +37,27 @@ export class TerminalsActiveService extends Service {
|
|
|
34
37
|
id: number,
|
|
35
38
|
data: PingTerminal,
|
|
36
39
|
options: { rawResponse: true } & Options,
|
|
37
|
-
): Promise<AxiosResponse<
|
|
40
|
+
): Promise<AxiosResponse<number>>;
|
|
38
41
|
pingTerminal(id: number, data: PingTerminal, options: Options): Promise<number>;
|
|
39
42
|
pingTerminal(id: number, data: PingTerminal, options?: Options) {
|
|
40
43
|
return super
|
|
41
|
-
.fetch({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
|
|
42
|
-
.then((res) =>
|
|
44
|
+
.fetch<number>({ url: `${this.apiPath}/${id}`, data, method: 'POST' }, options)
|
|
45
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
list(): AsyncGenerator<Terminal>;
|
|
49
|
+
list<F extends keyof Terminal>(
|
|
50
|
+
options: { fields: F[] } & OptionsExtended<Terminal>,
|
|
51
|
+
): AsyncGenerator<Pick<Terminal, F>>;
|
|
52
|
+
list(options?: OptionsExtended<Terminal>): AsyncGenerator<Terminal>;
|
|
53
|
+
async *list(options?: OptionsExtended<Terminal>) {
|
|
54
|
+
yield* super.iterator({ url: this.apiPath }, options);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
listAll(
|
|
52
|
-
|
|
57
|
+
listAll(): Promise<Terminal[]>;
|
|
58
|
+
listAll<F extends keyof Terminal>(options: { fields: F[] } & OptionsExtended<Terminal>): Promise<Pick<Terminal, F>[]>;
|
|
59
|
+
listAll(options?: OptionsExtended<Terminal>): Promise<Terminal[]>;
|
|
60
|
+
async listAll(options?: OptionsExtended<Terminal>) {
|
|
53
61
|
const users = [] as Terminal[];
|
|
54
62
|
for await (const user of this.list(options)) {
|
|
55
63
|
users.push(user);
|
|
@@ -57,16 +65,21 @@ export class TerminalsActiveService extends Service {
|
|
|
57
65
|
return users;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
listByPage(
|
|
61
|
-
|
|
68
|
+
listByPage(): AsyncGenerator<AxiosResponse<Terminal[]>>;
|
|
69
|
+
listByPage<F extends keyof Terminal>(
|
|
70
|
+
options: { fields: F[] } & OptionsExtended<Terminal>,
|
|
71
|
+
): AsyncGenerator<AxiosResponse<Pick<Terminal, F>[]>>;
|
|
72
|
+
listByPage(options?: OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Terminal[]>>;
|
|
73
|
+
listByPage(options?: OptionsExtended<Terminal>) {
|
|
74
|
+
return super.iterator({ url: this.apiPath }, options).byPage();
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
closeTerminal(id: number): Promise<number>;
|
|
65
|
-
closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
78
|
+
closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
66
79
|
closeTerminal(id: number, options: Options): Promise<number>;
|
|
67
80
|
closeTerminal(id: number, options?: Options) {
|
|
68
81
|
return super
|
|
69
|
-
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
70
|
-
.then((res) =>
|
|
82
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
|
|
83
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
71
84
|
}
|
|
72
85
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { Terminal } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
type RequiredProps = 'name' | 'timezone';
|
|
6
6
|
|
|
7
|
-
export class TerminalsService extends Service {
|
|
7
|
+
export class TerminalsService extends Service<Terminal> {
|
|
8
8
|
private apiPath = '/terminals';
|
|
9
9
|
|
|
10
10
|
create(data: RequirementsOf<Terminal, RequiredProps>): Promise<Terminal>;
|
|
@@ -16,16 +16,24 @@ export class TerminalsService extends Service {
|
|
|
16
16
|
create(data: RequirementsOf<Terminal, RequiredProps>, options?: Options) {
|
|
17
17
|
return super
|
|
18
18
|
.fetch<Terminal>({ url: this.apiPath, data, method: 'POST' })
|
|
19
|
-
.then((res) =>
|
|
19
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
get(id: number): Promise<Terminal>;
|
|
23
|
-
get
|
|
24
|
-
|
|
23
|
+
get<F extends keyof Terminal>(
|
|
24
|
+
id: number,
|
|
25
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<Terminal>,
|
|
26
|
+
): Promise<AxiosResponse<Pick<Terminal, F>>>;
|
|
27
|
+
get<F extends keyof Terminal>(
|
|
28
|
+
id: number,
|
|
29
|
+
options: { fields: F[] } & OptionsExtended<Terminal>,
|
|
30
|
+
): Promise<Pick<Terminal, F>>;
|
|
31
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<Terminal>>;
|
|
32
|
+
get(id: number, options?: OptionsExtended<Terminal>): Promise<Terminal>;
|
|
25
33
|
get(id: number, options?: Options) {
|
|
26
34
|
return super
|
|
27
35
|
.fetch<Terminal>({ url: `${this.apiPath}/${id}` }, options)
|
|
28
|
-
.then((res) =>
|
|
36
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
update(id: number, data: Partial<Terminal>): Promise<Terminal>;
|
|
@@ -42,26 +50,31 @@ export class TerminalsService extends Service {
|
|
|
42
50
|
data,
|
|
43
51
|
method: 'POST',
|
|
44
52
|
})
|
|
45
|
-
.then((res) =>
|
|
53
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
closeTerminal(id: number): Promise<number>;
|
|
49
|
-
closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
57
|
+
closeTerminal(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
50
58
|
closeTerminal(id: number, options: Options): Promise<number>;
|
|
51
59
|
closeTerminal(id: number, options?: Options) {
|
|
52
60
|
return super
|
|
53
|
-
.fetch({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
54
|
-
.then((res) =>
|
|
61
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
62
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
55
63
|
}
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
list(): AsyncGenerator<Terminal>;
|
|
66
|
+
list<F extends keyof Terminal>(
|
|
67
|
+
options: { fields: F[] } & OptionsExtended<Terminal>,
|
|
68
|
+
): AsyncGenerator<Pick<Terminal, F>>;
|
|
69
|
+
list(options?: OptionsExtended<Terminal>): AsyncGenerator<Terminal>;
|
|
70
|
+
async *list(options?: OptionsExtended<Terminal>) {
|
|
71
|
+
yield* super.iterator({ url: this.apiPath }, options);
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
listAll(
|
|
64
|
-
|
|
74
|
+
listAll(): Promise<Terminal[]>;
|
|
75
|
+
listAll<F extends keyof Terminal>(options: { fields: F[] } & OptionsExtended<Terminal>): Promise<Pick<Terminal, F>[]>;
|
|
76
|
+
listAll(options?: OptionsExtended<Terminal>): Promise<Terminal[]>;
|
|
77
|
+
async listAll(options?: OptionsExtended<Terminal>) {
|
|
65
78
|
const users = [] as Terminal[];
|
|
66
79
|
for await (const user of this.list(options)) {
|
|
67
80
|
users.push(user);
|
|
@@ -69,7 +82,12 @@ export class TerminalsService extends Service {
|
|
|
69
82
|
return users;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
listByPage(
|
|
73
|
-
|
|
85
|
+
listByPage(): AsyncGenerator<AxiosResponse<Terminal[]>>;
|
|
86
|
+
listByPage<F extends keyof Terminal>(
|
|
87
|
+
options: { fields: F[] } & OptionsExtended<Terminal>,
|
|
88
|
+
): AsyncGenerator<AxiosResponse<Pick<Terminal, F>[]>>;
|
|
89
|
+
listByPage(options?: OptionsExtended<Terminal>): AsyncGenerator<AxiosResponse<Terminal[]>>;
|
|
90
|
+
listByPage(options?: OptionsExtended<Terminal>) {
|
|
91
|
+
return super.iterator({ url: this.apiPath }, options).byPage();
|
|
74
92
|
}
|
|
75
93
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Service, Options } from './index.js';
|
|
3
|
+
|
|
4
|
+
import { TimeZone } from '../interfaces/index.js';
|
|
5
|
+
|
|
6
|
+
export class TimeZoneService extends Service<TimeZone> {
|
|
7
|
+
private apiPath = '/timezones';
|
|
8
|
+
|
|
9
|
+
get(id: number): Promise<TimeZone>;
|
|
10
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<TimeZone, any>>;
|
|
11
|
+
get(id: number, options: Options): Promise<TimeZone>;
|
|
12
|
+
get(id: number, options?: Options) {
|
|
13
|
+
return super
|
|
14
|
+
.fetch<TimeZone>({ url: `${this.apiPath}/${id}` }, options)
|
|
15
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async *list(options?: Options) {
|
|
19
|
+
yield* super.iterator({ url: this.apiPath }, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
listAll(options?: Options): Promise<TimeZone[]>;
|
|
23
|
+
async listAll(options?: Options) {
|
|
24
|
+
const timezones = [] as TimeZone[];
|
|
25
|
+
for await (const timezone of this.list(options)) {
|
|
26
|
+
timezones.push(timezone);
|
|
27
|
+
}
|
|
28
|
+
return timezones;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
listByPage(options?: Options) {
|
|
32
|
+
return super.iterator({ url: this.apiPath }, options).byPage();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -17,7 +17,7 @@ export class ToilAccrualsService extends Service {
|
|
|
17
17
|
create(data: RequirementsOf<ToilAccrual, RequiredProps>, options?: Options) {
|
|
18
18
|
return super
|
|
19
19
|
.fetch<ToilAccrual>({ url: this.apiPath, data, method: 'POST' })
|
|
20
|
-
.then((res) =>
|
|
20
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
get(id: number): Promise<ToilAccrual>;
|
|
@@ -26,16 +26,14 @@ export class ToilAccrualsService extends Service {
|
|
|
26
26
|
get(id: number, options?: Options) {
|
|
27
27
|
return super
|
|
28
28
|
.fetch<ToilAccrual>({ url: `${this.apiPath}/${id}` }, options)
|
|
29
|
-
.then((res) =>
|
|
29
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async *list(query
|
|
33
|
-
|
|
34
|
-
yield res;
|
|
35
|
-
}
|
|
32
|
+
async *list(query?: ToilAccrualsQueryParams, options?: Options) {
|
|
33
|
+
yield* super.iterator<ToilAccrual>({ url: this.apiPath, params: query }, options);
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
async listAll(query
|
|
36
|
+
async listAll(query?: ToilAccrualsQueryParams, options?: Options): Promise<ToilAccrual[]> {
|
|
39
37
|
const toilAccruals = [] as ToilAccrual[];
|
|
40
38
|
for await (const accrual of this.list(query, options)) {
|
|
41
39
|
toilAccruals.push(accrual);
|
|
@@ -43,16 +41,16 @@ export class ToilAccrualsService extends Service {
|
|
|
43
41
|
return toilAccruals;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
listByPage(query
|
|
44
|
+
listByPage(query?: ToilAccrualsQueryParams, options?: Options) {
|
|
47
45
|
return super.iterator<ToilAccrual>({ url: this.apiPath, params: query }, options).byPage();
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
delete(id: number): Promise<number>;
|
|
51
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
49
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
52
50
|
delete(id: number, options: Options): Promise<number>;
|
|
53
51
|
delete(id: number, options?: Options) {
|
|
54
52
|
return super
|
|
55
|
-
.fetch<
|
|
56
|
-
.then((res) =>
|
|
53
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' })
|
|
54
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
57
55
|
}
|
|
58
56
|
}
|
|
@@ -2,13 +2,11 @@ import { Options, Service } from './service';
|
|
|
2
2
|
import { ToilAllowanceQueryParams } from '../interfaces/query-params/toil-allowance-query-params.interface';
|
|
3
3
|
import { ToilAllowance } from '../interfaces/toil-allowance.interface';
|
|
4
4
|
|
|
5
|
-
export class ToilAllowanceService extends Service {
|
|
5
|
+
export class ToilAllowanceService extends Service<ToilAllowance> {
|
|
6
6
|
private apiPath = '/toil_allowance';
|
|
7
7
|
|
|
8
8
|
async *list(year: number, query: ToilAllowanceQueryParams, options?: Options) {
|
|
9
|
-
|
|
10
|
-
yield res;
|
|
11
|
-
}
|
|
9
|
+
yield* super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options);
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
async listAll(year: number, query: ToilAllowanceQueryParams, options?: Options): Promise<ToilAllowance[]> {
|
|
@@ -20,6 +18,6 @@ export class ToilAllowanceService extends Service {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
listByPage(year: number, query: ToilAllowanceQueryParams, options?: Options) {
|
|
23
|
-
return super.iterator
|
|
21
|
+
return super.iterator({ url: `${this.apiPath}/${year}`, params: query }, options).byPage();
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { UserBreak, UserClockedIn, UserClockedOut, TerminalLocation } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
interface UserClockIn {
|
|
6
6
|
method: string;
|
|
@@ -24,26 +24,35 @@ interface UserBreakRequest {
|
|
|
24
24
|
type RequiredPropsClockIn = 'method';
|
|
25
25
|
type RequiredPropsBreak = 'method' | 'action';
|
|
26
26
|
|
|
27
|
-
export class UsersClockInService extends Service {
|
|
27
|
+
export class UsersClockInService extends Service<UserClockedIn> {
|
|
28
28
|
private apiPath = '/users_clocked_in';
|
|
29
29
|
|
|
30
30
|
getClockedInUser(id: number): Promise<UserClockedIn>;
|
|
31
|
-
getClockedInUser(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<UserClockedIn
|
|
31
|
+
getClockedInUser(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<UserClockedIn>>;
|
|
32
32
|
getClockedInUser(id: number, options: Options): Promise<UserClockedIn>;
|
|
33
33
|
getClockedInUser(id: number, options?: Options) {
|
|
34
34
|
return super
|
|
35
35
|
.fetch<UserClockedIn>({ url: `${this.apiPath}/${id}` }, options)
|
|
36
|
-
.then((res) =>
|
|
36
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
list(): AsyncGenerator<UserClockedIn>;
|
|
40
|
+
list<F extends keyof UserClockedIn>(
|
|
41
|
+
options: { fields: F[] } & OptionsExtended<UserClockedIn>,
|
|
42
|
+
): AsyncGenerator<Pick<UserClockedIn, F>>;
|
|
43
|
+
list(options?: OptionsExtended<UserClockedIn>): AsyncGenerator<UserClockedIn>;
|
|
44
|
+
async *list(options?: OptionsExtended<UserClockedIn>) {
|
|
40
45
|
for await (const res of super.iterator<UserClockedIn>({ url: this.apiPath }, options)) {
|
|
41
46
|
yield res;
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
listAll(
|
|
46
|
-
|
|
50
|
+
listAll(): Promise<UserClockedIn[]>;
|
|
51
|
+
listAll<F extends keyof UserClockedIn>(
|
|
52
|
+
options: { fields: F[] } & OptionsExtended<UserClockedIn>,
|
|
53
|
+
): Promise<Pick<UserClockedIn, F>[]>;
|
|
54
|
+
listAll(options?: OptionsExtended<UserClockedIn>): Promise<UserClockedIn[]>;
|
|
55
|
+
async listAll(options?: OptionsExtended<UserClockedIn>) {
|
|
47
56
|
const users = [] as UserClockedIn[];
|
|
48
57
|
for await (const user of this.list(options)) {
|
|
49
58
|
users.push(user);
|
|
@@ -51,7 +60,12 @@ export class UsersClockInService extends Service {
|
|
|
51
60
|
return users;
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
listByPage(
|
|
63
|
+
listByPage(): AsyncGenerator<AxiosResponse<UserClockedIn[]>>;
|
|
64
|
+
listByPage<F extends keyof UserClockedIn>(
|
|
65
|
+
options: { fields: F[] } & OptionsExtended<UserClockedIn>,
|
|
66
|
+
): AsyncGenerator<AxiosResponse<Pick<UserClockedIn, F>[]>>;
|
|
67
|
+
listByPage(options?: OptionsExtended<UserClockedIn>): AsyncGenerator<AxiosResponse<UserClockedIn[]>>;
|
|
68
|
+
listByPage(options?: OptionsExtended<UserClockedIn>) {
|
|
55
69
|
return super.iterator<UserClockedIn>({ url: this.apiPath }, options).byPage();
|
|
56
70
|
}
|
|
57
71
|
|
|
@@ -59,12 +73,12 @@ export class UsersClockInService extends Service {
|
|
|
59
73
|
clockIn(
|
|
60
74
|
data: RequirementsOf<UserClockIn, RequiredPropsClockIn>,
|
|
61
75
|
options: { rawResponse: true } & Options,
|
|
62
|
-
): Promise<AxiosResponse<UserClockedIn
|
|
76
|
+
): Promise<AxiosResponse<UserClockedIn>>;
|
|
63
77
|
clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options: Options): Promise<UserClockedIn>;
|
|
64
78
|
clockIn(data: RequirementsOf<UserClockIn, RequiredPropsClockIn>, options?: Options) {
|
|
65
79
|
return super
|
|
66
80
|
.fetch<UserClockedIn>({ url: this.apiPath, data, method: 'POST' })
|
|
67
|
-
.then((res) =>
|
|
81
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
68
82
|
}
|
|
69
83
|
|
|
70
84
|
clockOut(id: number, data: UserClockOut): Promise<UserClockedOut>;
|
|
@@ -72,12 +86,12 @@ export class UsersClockInService extends Service {
|
|
|
72
86
|
id: number,
|
|
73
87
|
data: UserClockOut,
|
|
74
88
|
options: { rawResponse: true } & Options,
|
|
75
|
-
): Promise<AxiosResponse<UserClockedOut
|
|
89
|
+
): Promise<AxiosResponse<UserClockedOut>>;
|
|
76
90
|
clockOut(id: number, data: UserClockOut, options: Options): Promise<UserClockedOut>;
|
|
77
91
|
clockOut(id: number, data: UserClockOut, options?: Options) {
|
|
78
92
|
return super
|
|
79
93
|
.fetch<UserClockedOut>({ url: `${this.apiPath}/${id}`, data, method: 'DELETE' })
|
|
80
|
-
.then((res) =>
|
|
94
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
81
95
|
}
|
|
82
96
|
|
|
83
97
|
startBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>): Promise<UserBreak>;
|
|
@@ -85,7 +99,7 @@ export class UsersClockInService extends Service {
|
|
|
85
99
|
id: number,
|
|
86
100
|
data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>,
|
|
87
101
|
options: { rawResponse: true } & Options,
|
|
88
|
-
): Promise<AxiosResponse<UserBreak
|
|
102
|
+
): Promise<AxiosResponse<UserBreak>>;
|
|
89
103
|
startBreak(
|
|
90
104
|
id: number,
|
|
91
105
|
data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>,
|
|
@@ -94,7 +108,7 @@ export class UsersClockInService extends Service {
|
|
|
94
108
|
startBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options?: Options) {
|
|
95
109
|
return super
|
|
96
110
|
.fetch<UserBreak>({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
|
|
97
|
-
.then((res) =>
|
|
111
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
endBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>): Promise<UserBreak>;
|
|
@@ -102,7 +116,7 @@ export class UsersClockInService extends Service {
|
|
|
102
116
|
id: number,
|
|
103
117
|
data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>,
|
|
104
118
|
options: { rawResponse: true } & Options,
|
|
105
|
-
): Promise<AxiosResponse<UserBreak
|
|
119
|
+
): Promise<AxiosResponse<UserBreak>>;
|
|
106
120
|
endBreak(
|
|
107
121
|
id: number,
|
|
108
122
|
data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>,
|
|
@@ -111,6 +125,6 @@ export class UsersClockInService extends Service {
|
|
|
111
125
|
endBreak(id: number, data: RequirementsOf<UserBreakRequest, RequiredPropsBreak>, options?: Options) {
|
|
112
126
|
return super
|
|
113
127
|
.fetch<UserBreak>({ url: `${this.apiPath}/${id}`, data, method: 'POST' })
|
|
114
|
-
.then((res) =>
|
|
128
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
115
129
|
}
|
|
116
130
|
}
|
|
@@ -1,43 +1,57 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import { User } from '../interfaces/index.js';
|
|
3
|
-
import { Service, Options, RequirementsOf } from './index.js';
|
|
3
|
+
import { Service, Options, RequirementsOf, OptionsExtended } from './index.js';
|
|
4
4
|
|
|
5
5
|
import { UsersQueryParams } from '../interfaces/query-params/users-query-params.interface.js';
|
|
6
6
|
|
|
7
7
|
type RequiredProps = 'first_name' | 'last_name';
|
|
8
8
|
|
|
9
|
-
export class UsersService extends Service {
|
|
9
|
+
export class UsersService extends Service<User> {
|
|
10
10
|
private apiPath = '/users';
|
|
11
11
|
|
|
12
12
|
create(data: RequirementsOf<User, RequiredProps>): Promise<User>;
|
|
13
13
|
create(
|
|
14
14
|
data: RequirementsOf<User, RequiredProps>,
|
|
15
15
|
options: { rawResponse: true } & Options,
|
|
16
|
-
): Promise<AxiosResponse<User
|
|
16
|
+
): Promise<AxiosResponse<User>>;
|
|
17
17
|
create(data: RequirementsOf<User, RequiredProps>, options: Options): Promise<User>;
|
|
18
18
|
create(data: RequirementsOf<User, RequiredProps>, options?: Options) {
|
|
19
19
|
return super
|
|
20
|
-
.fetch<User>({ url: this.apiPath, data, method: 'POST' })
|
|
21
|
-
.then((res) =>
|
|
20
|
+
.fetch<User>({ url: this.apiPath, data, method: 'POST' }, options)
|
|
21
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
get(id: number): Promise<User>;
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
get<F extends keyof User>(
|
|
26
|
+
id: number,
|
|
27
|
+
options: { fields: F[]; rawResponse: true } & OptionsExtended<User>,
|
|
28
|
+
): Promise<AxiosResponse<Pick<User, F>>>;
|
|
29
|
+
get<F extends keyof User>(id: number, options: { fields: F[] } & OptionsExtended<User>): Promise<Pick<User, F>>;
|
|
30
|
+
get(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<User>>;
|
|
31
|
+
get(id: number, options?: OptionsExtended<User>): Promise<User>;
|
|
32
|
+
get(id: number, options?: OptionsExtended<User>) {
|
|
28
33
|
return super
|
|
29
34
|
.fetch<User>({ url: `${this.apiPath}/${id}` }, options)
|
|
30
|
-
.then((res) =>
|
|
35
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
38
|
+
list(query?: UsersQueryParams): AsyncGenerator<User>;
|
|
39
|
+
list<F extends keyof User>(
|
|
40
|
+
query: UsersQueryParams,
|
|
41
|
+
options: { fields: F[] } & OptionsExtended<User>,
|
|
42
|
+
): AsyncGenerator<Pick<User, F>>;
|
|
43
|
+
list(query?: UsersQueryParams, options?: OptionsExtended<User>): AsyncGenerator<User>;
|
|
44
|
+
async *list(query?: UsersQueryParams, options?: OptionsExtended<User>) {
|
|
45
|
+
yield* super.iterator({ url: this.apiPath, params: query }, options);
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
listAll(query
|
|
40
|
-
|
|
48
|
+
listAll(query?: UsersQueryParams): Promise<User[]>;
|
|
49
|
+
listAll<F extends keyof User>(
|
|
50
|
+
query: UsersQueryParams,
|
|
51
|
+
options: { fields: F[] } & OptionsExtended<User>,
|
|
52
|
+
): Promise<Pick<User, F>[]>;
|
|
53
|
+
listAll(query?: UsersQueryParams, options?: OptionsExtended<User>): Promise<User[]>;
|
|
54
|
+
async listAll(query?: UsersQueryParams, options?: OptionsExtended<User>) {
|
|
41
55
|
const users = [] as User[];
|
|
42
56
|
for await (const user of this.list(query, options)) {
|
|
43
57
|
users.push(user);
|
|
@@ -45,8 +59,14 @@ export class UsersService extends Service {
|
|
|
45
59
|
return users;
|
|
46
60
|
}
|
|
47
61
|
|
|
48
|
-
listByPage(query
|
|
49
|
-
|
|
62
|
+
listByPage(query?: UsersQueryParams): AsyncGenerator<AxiosResponse<User[]>>;
|
|
63
|
+
listByPage<F extends keyof User>(
|
|
64
|
+
query: UsersQueryParams,
|
|
65
|
+
options: { fields: F[] } & OptionsExtended<User>,
|
|
66
|
+
): AsyncGenerator<AxiosResponse<Pick<User, F>[]>>;
|
|
67
|
+
listByPage(query?: UsersQueryParams, options?: OptionsExtended<User>): AsyncGenerator<AxiosResponse<User[]>>;
|
|
68
|
+
listByPage(query?: UsersQueryParams, options?: OptionsExtended<User>) {
|
|
69
|
+
return super.iterator({ url: this.apiPath, params: query }, options).byPage();
|
|
50
70
|
}
|
|
51
71
|
|
|
52
72
|
update(id: number, data: Partial<User>): Promise<User>;
|
|
@@ -54,20 +74,23 @@ export class UsersService extends Service {
|
|
|
54
74
|
update(id: number, data: Partial<User>, options: Options): Promise<User>;
|
|
55
75
|
update(id: number, data: Partial<User>, options?: Options) {
|
|
56
76
|
return super
|
|
57
|
-
.fetch<User>(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
.fetch<User>(
|
|
78
|
+
{
|
|
79
|
+
url: `${this.apiPath}/${id}`,
|
|
80
|
+
data,
|
|
81
|
+
method: 'POST',
|
|
82
|
+
},
|
|
83
|
+
options,
|
|
84
|
+
)
|
|
85
|
+
.then((res) => (options?.rawResponse ? res : res.data));
|
|
63
86
|
}
|
|
64
87
|
|
|
65
88
|
delete(id: number): Promise<number>;
|
|
66
|
-
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<
|
|
89
|
+
delete(id: number, options: { rawResponse: true } & Options): Promise<AxiosResponse<void>>;
|
|
67
90
|
delete(id: number, options: Options): Promise<number>;
|
|
68
91
|
delete(id: number, options?: Options) {
|
|
69
92
|
return super
|
|
70
|
-
.fetch<
|
|
71
|
-
.then((res) =>
|
|
93
|
+
.fetch<void>({ url: `${this.apiPath}/${id}`, method: 'DELETE' }, options)
|
|
94
|
+
.then((res) => (options?.rawResponse ? res : res.status));
|
|
72
95
|
}
|
|
73
96
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const Version = { version: '1.
|
|
1
|
+
export const Version = { version: '1.2.0' };
|
|
File without changes
|
|
File without changes
|