tlnt-cli 1.6.0__tar.gz → 1.7.0__tar.gz
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.
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/PKG-INFO +3 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/README.md +2 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/pyproject.toml +1 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/pyproject.toml.orig +1 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/browser/login.py +2 -1
- tlnt_cli-1.7.0/src/tlnt/cli/commands/api.py +44 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/attendance.py +19 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/calendar.py +3 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/logout.py +2 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/notifications.py +11 -2
- tlnt_cli-1.7.0/src/tlnt/cli/commands/overtime.py +110 -0
- tlnt_cli-1.7.0/src/tlnt/cli/commands/payslip.py +59 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/profile.py +2 -1
- tlnt_cli-1.7.0/src/tlnt/cli/commands/reimbursement.py +21 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/timeoff.py +9 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/main.py +39 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/options.py +16 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/output.py +6 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/client.py +240 -9
- tlnt_cli-1.7.0/src/tlnt/core/curl.py +58 -0
- tlnt_cli-1.7.0/src/tlnt/core/device.py +66 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/http_client.py +12 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/mekari.py +69 -10
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/models.py +12 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/__init__.py +2 -1
- tlnt_cli-1.7.0/src/tlnt/core/services/api.py +85 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/attendance.py +24 -12
- tlnt_cli-1.7.0/src/tlnt/core/services/device.py +67 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/login.py +17 -1
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/logout.py +3 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/notifications.py +28 -0
- tlnt_cli-1.7.0/src/tlnt/core/services/overtime.py +19 -0
- tlnt_cli-1.7.0/src/tlnt/core/services/payslip.py +49 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/setup.py +2 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/status.py +25 -6
- tlnt_cli-1.7.0/src/tlnt/core/user_agent.py +72 -0
- tlnt_cli-1.6.0/src/tlnt/core/user_agent.py +0 -71
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/LICENSE +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/__init__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/__main__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/browser/__init__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/browser/oauth.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/browser/scripted.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/__init__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/approvals.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/avatars.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/__init__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/login.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/setup.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/status.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/update.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/commands/version.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/cli/prompts.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/__init__.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/config.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/logs.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/play_store.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/calendar.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/profile.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/services/timeoff.py +0 -0
- {tlnt_cli-1.6.0 → tlnt_cli-1.7.0}/src/tlnt/core/session.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tlnt-cli
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: CLI wrapper for HRIS attendance and employment workflows.
|
|
5
5
|
Author: Fathiraz Arthuro
|
|
6
6
|
License-Expression: MIT
|
|
@@ -105,6 +105,8 @@ The full command map, global options and output modes are in
|
|
|
105
105
|
always ask for confirmation. The prompt reads standard input, so it guards
|
|
106
106
|
against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
|
|
107
107
|
- `--dry-run` never submits attendance.
|
|
108
|
+
- `--curl` sends nothing but prints the bearer token and request body; keep
|
|
109
|
+
that output out of chat, logs and tickets.
|
|
108
110
|
- `TALENTA_READONLY=1` refuses every command that would change Talenta or
|
|
109
111
|
local state.
|
|
110
112
|
- The version checks only read public listings (PyPI and Google Play), never
|
|
@@ -88,6 +88,8 @@ The full command map, global options and output modes are in
|
|
|
88
88
|
always ask for confirmation. The prompt reads standard input, so it guards
|
|
89
89
|
against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
|
|
90
90
|
- `--dry-run` never submits attendance.
|
|
91
|
+
- `--curl` sends nothing but prints the bearer token and request body; keep
|
|
92
|
+
that output out of chat, logs and tickets.
|
|
91
93
|
- `TALENTA_READONLY=1` refuses every command that would change Talenta or
|
|
92
94
|
local state.
|
|
93
95
|
- The version checks only read public listings (PyPI and Google Play), never
|
|
@@ -17,6 +17,7 @@ from playwright.sync_api import sync_playwright
|
|
|
17
17
|
|
|
18
18
|
from tlnt.browser.oauth import authorize_url, code_from_url, pkce_pair
|
|
19
19
|
from tlnt.core.client import MekariClient
|
|
20
|
+
from tlnt.core.device import device_identity
|
|
20
21
|
from tlnt.core.mekari import (
|
|
21
22
|
DASHBOARD_TALENTA_URL,
|
|
22
23
|
MEKARI_DOMAIN,
|
|
@@ -285,7 +286,7 @@ class BrowserLogin:
|
|
|
285
286
|
context_factory: Callable[[], AbstractContextManager[Any]] = chrome_context,
|
|
286
287
|
credentials: Credentials | None = None,
|
|
287
288
|
) -> None:
|
|
288
|
-
self.client = client or MekariClient()
|
|
289
|
+
self.client = client or MekariClient(device=device_identity())
|
|
289
290
|
self._owns_client = client is None
|
|
290
291
|
self.context_factory = context_factory
|
|
291
292
|
self.credentials = credentials
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
|
|
8
|
+
from tlnt.cli.output import run
|
|
9
|
+
from tlnt.core.services.api import api_get as api_get_action
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _params(values: list[str]) -> dict[str, str]:
|
|
13
|
+
params: dict[str, str] = {}
|
|
14
|
+
for value in values:
|
|
15
|
+
key, separator, text = value.partition("=")
|
|
16
|
+
if not key or not separator:
|
|
17
|
+
raise typer.BadParameter("--param takes key=value")
|
|
18
|
+
params[key] = text
|
|
19
|
+
return params
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def api_get(
|
|
23
|
+
path: Annotated[
|
|
24
|
+
str,
|
|
25
|
+
typer.Argument(
|
|
26
|
+
help="Path as listed in docs/apk-parity.md, e.g. time-off/balance-detail."
|
|
27
|
+
),
|
|
28
|
+
],
|
|
29
|
+
param: Annotated[
|
|
30
|
+
list[str] | None,
|
|
31
|
+
typer.Option("--param", "-p", help="Query value as key=value; repeat for more."),
|
|
32
|
+
] = None,
|
|
33
|
+
json_output: JsonOption = False,
|
|
34
|
+
verbose: VerboseOption = False,
|
|
35
|
+
curl: CurlOption = False,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Read any Talenta mobile API path (GET only)."""
|
|
38
|
+
params = _params(param or [])
|
|
39
|
+
run(
|
|
40
|
+
"Loading API response...",
|
|
41
|
+
lambda: api_get_action(path, params),
|
|
42
|
+
json_output,
|
|
43
|
+
verbose,
|
|
44
|
+
)
|
|
@@ -12,6 +12,7 @@ from tlnt.cli.approvals import run_approval
|
|
|
12
12
|
from tlnt.cli.output import action_banner, confirm, emit, require_writable, spinner
|
|
13
13
|
from tlnt.cli.options import (
|
|
14
14
|
AvatarsOption,
|
|
15
|
+
CurlOption,
|
|
15
16
|
InteractiveOption,
|
|
16
17
|
JsonOption,
|
|
17
18
|
VerboseOption,
|
|
@@ -47,7 +48,12 @@ def _run_attendance(
|
|
|
47
48
|
interactive: bool = False,
|
|
48
49
|
verbose: bool = False,
|
|
49
50
|
avatars: bool = False,
|
|
51
|
+
validate_location: bool = False,
|
|
50
52
|
) -> None:
|
|
53
|
+
if validate_location and not dry_run:
|
|
54
|
+
raise typer.BadParameter(
|
|
55
|
+
"--validate-location requires --dry-run.",
|
|
56
|
+
)
|
|
51
57
|
if not dry_run:
|
|
52
58
|
require_writable(json_output)
|
|
53
59
|
if interactive:
|
|
@@ -88,6 +94,7 @@ def _run_attendance(
|
|
|
88
94
|
latitude=latitude,
|
|
89
95
|
longitude=longitude,
|
|
90
96
|
location_id=location_id,
|
|
97
|
+
validate_location=validate_location,
|
|
91
98
|
),
|
|
92
99
|
json_output,
|
|
93
100
|
avatars=avatars,
|
|
@@ -150,6 +157,13 @@ def _clock_command(event_type: str, label: str, doc: str) -> Callable[..., None]
|
|
|
150
157
|
bool,
|
|
151
158
|
typer.Option("--dry-run", help="Preview without submitting attendance."),
|
|
152
159
|
] = False,
|
|
160
|
+
validate_location: Annotated[
|
|
161
|
+
bool,
|
|
162
|
+
typer.Option(
|
|
163
|
+
"--validate-location",
|
|
164
|
+
help="With --dry-run, also call validate_location before preview.",
|
|
165
|
+
),
|
|
166
|
+
] = False,
|
|
153
167
|
notes: Annotated[
|
|
154
168
|
str,
|
|
155
169
|
typer.Option("--notes", help="Optional attendance note."),
|
|
@@ -168,6 +182,7 @@ def _clock_command(event_type: str, label: str, doc: str) -> Callable[..., None]
|
|
|
168
182
|
json_output: JsonOption = False,
|
|
169
183
|
avatars: AvatarsOption = False,
|
|
170
184
|
verbose: VerboseOption = False,
|
|
185
|
+
curl: CurlOption = False,
|
|
171
186
|
) -> None:
|
|
172
187
|
_run_attendance(
|
|
173
188
|
event_type,
|
|
@@ -182,6 +197,7 @@ def _clock_command(event_type: str, label: str, doc: str) -> Callable[..., None]
|
|
|
182
197
|
interactive=interactive,
|
|
183
198
|
verbose=verbose,
|
|
184
199
|
avatars=avatars,
|
|
200
|
+
validate_location=validate_location,
|
|
185
201
|
)
|
|
186
202
|
|
|
187
203
|
command.__doc__ = doc
|
|
@@ -212,6 +228,7 @@ def attendance_summary_list(
|
|
|
212
228
|
] = None,
|
|
213
229
|
json_output: JsonOption = False,
|
|
214
230
|
verbose: VerboseOption = False,
|
|
231
|
+
curl: CurlOption = False,
|
|
215
232
|
) -> None:
|
|
216
233
|
"""Read attendance summaries for a date."""
|
|
217
234
|
emit(summary_list_action(_attendance_date(selected_date)), json_output)
|
|
@@ -224,6 +241,7 @@ def attendance_summary_metrics(
|
|
|
224
241
|
] = None,
|
|
225
242
|
json_output: JsonOption = False,
|
|
226
243
|
verbose: VerboseOption = False,
|
|
244
|
+
curl: CurlOption = False,
|
|
227
245
|
) -> None:
|
|
228
246
|
"""Read attendance summary metrics for a date."""
|
|
229
247
|
emit(summary_metrics_action(_attendance_date(selected_date)), json_output)
|
|
@@ -258,6 +276,7 @@ def attendance_approve(
|
|
|
258
276
|
interactive: InteractiveOption = False,
|
|
259
277
|
json_output: JsonOption = False,
|
|
260
278
|
verbose: VerboseOption = False,
|
|
279
|
+
curl: CurlOption = False,
|
|
261
280
|
) -> None:
|
|
262
281
|
"""Approve a live attendance request after confirmation."""
|
|
263
282
|
run_approval(
|
|
@@ -5,7 +5,7 @@ from typing import Annotated, Any
|
|
|
5
5
|
|
|
6
6
|
import typer
|
|
7
7
|
|
|
8
|
-
from tlnt.cli.options import JsonOption, VerboseOption
|
|
8
|
+
from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
|
|
9
9
|
from tlnt.cli.output import run
|
|
10
10
|
from tlnt.core.services import calendar as calendar_service
|
|
11
11
|
|
|
@@ -64,6 +64,7 @@ def _filtered_command(name: str, label: str, doc: str) -> Callable[..., None]:
|
|
|
64
64
|
user_id: Annotated[str | None, typer.Option("--user-id")] = None,
|
|
65
65
|
json_output: JsonOption = False,
|
|
66
66
|
verbose: VerboseOption = False,
|
|
67
|
+
curl: CurlOption = False,
|
|
67
68
|
) -> None:
|
|
68
69
|
params = _calendar_params(
|
|
69
70
|
start_date, end_date, limit, month, year, page,
|
|
@@ -96,6 +97,7 @@ calendar_activity = _filtered_command(
|
|
|
96
97
|
def calendar_my_birthday(
|
|
97
98
|
json_output: JsonOption = False,
|
|
98
99
|
verbose: VerboseOption = False,
|
|
100
|
+
curl: CurlOption = False,
|
|
99
101
|
) -> None:
|
|
100
102
|
"""Read your birthday date."""
|
|
101
103
|
run(
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from tlnt.cli.output import require_writable, run
|
|
2
|
-
from tlnt.cli.options import JsonOption, VerboseOption
|
|
2
|
+
from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
|
|
3
3
|
from tlnt.core.services.logout import logout as logout_action
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def logout(
|
|
7
7
|
json_output: JsonOption = False,
|
|
8
8
|
verbose: VerboseOption = False,
|
|
9
|
+
curl: CurlOption = False,
|
|
9
10
|
) -> None:
|
|
10
11
|
"""Log out of Talenta and remove the saved session."""
|
|
11
12
|
require_writable(json_output)
|
|
@@ -4,13 +4,14 @@ from typing import Annotated
|
|
|
4
4
|
import typer
|
|
5
5
|
|
|
6
6
|
from tlnt.cli.output import run
|
|
7
|
-
from tlnt.cli.options import AvatarsOption, JsonOption, VerboseOption
|
|
7
|
+
from tlnt.cli.options import AvatarsOption, CurlOption, JsonOption, VerboseOption
|
|
8
8
|
from tlnt.core.models import Result
|
|
9
9
|
from tlnt.core.services.notifications import (
|
|
10
10
|
notification_attendance_list as notification_attendance_list_action,
|
|
11
11
|
notification_count as notification_count_action,
|
|
12
12
|
notification_detail as notification_detail_action,
|
|
13
13
|
notification_list as notification_list_action,
|
|
14
|
+
notification_overtime_list as notification_overtime_list_action,
|
|
14
15
|
notification_timeoff_list as notification_timeoff_list_action,
|
|
15
16
|
)
|
|
16
17
|
|
|
@@ -18,6 +19,7 @@ from tlnt.core.services.notifications import (
|
|
|
18
19
|
def notification_count(
|
|
19
20
|
json_output: JsonOption = False,
|
|
20
21
|
verbose: VerboseOption = False,
|
|
22
|
+
curl: CurlOption = False,
|
|
21
23
|
) -> None:
|
|
22
24
|
"""Read Talenta notification counts."""
|
|
23
25
|
run("Loading notification counts...", notification_count_action, json_output, verbose)
|
|
@@ -26,7 +28,7 @@ def notification_count(
|
|
|
26
28
|
def _inbox_list_command(
|
|
27
29
|
action: Callable[..., Result], label: str, doc: str
|
|
28
30
|
) -> Callable[..., None]:
|
|
29
|
-
"""One inbox list; the
|
|
31
|
+
"""One inbox list; the list commands differ only in the inbox they read."""
|
|
30
32
|
|
|
31
33
|
def command(
|
|
32
34
|
page: Annotated[
|
|
@@ -44,6 +46,7 @@ def _inbox_list_command(
|
|
|
44
46
|
json_output: JsonOption = False,
|
|
45
47
|
avatars: AvatarsOption = False,
|
|
46
48
|
verbose: VerboseOption = False,
|
|
49
|
+
curl: CurlOption = False,
|
|
47
50
|
) -> None:
|
|
48
51
|
if page < 1:
|
|
49
52
|
raise typer.BadParameter("page must be at least 1")
|
|
@@ -76,6 +79,11 @@ notification_timeoff_list = _inbox_list_command(
|
|
|
76
79
|
"Loading time-off notifications...",
|
|
77
80
|
"Read Talenta time-off notifications.",
|
|
78
81
|
)
|
|
82
|
+
notification_overtime_list = _inbox_list_command(
|
|
83
|
+
lambda *filters: notification_overtime_list_action(*filters),
|
|
84
|
+
"Loading overtime notifications...",
|
|
85
|
+
"Read Talenta overtime notifications.",
|
|
86
|
+
)
|
|
79
87
|
|
|
80
88
|
|
|
81
89
|
def notification_detail(
|
|
@@ -86,6 +94,7 @@ def notification_detail(
|
|
|
86
94
|
json_output: JsonOption = False,
|
|
87
95
|
avatars: AvatarsOption = False,
|
|
88
96
|
verbose: VerboseOption = False,
|
|
97
|
+
curl: CurlOption = False,
|
|
89
98
|
) -> None:
|
|
90
99
|
"""Read one Talenta inbox notification detail."""
|
|
91
100
|
if inbox_id < 1:
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from tlnt.cli.approvals import run_approval
|
|
8
|
+
from tlnt.cli.options import CurlOption, InteractiveOption, JsonOption, VerboseOption
|
|
9
|
+
from tlnt.cli.output import dig, run
|
|
10
|
+
from tlnt.core.models import Result
|
|
11
|
+
from tlnt.core.services import positive_id
|
|
12
|
+
from tlnt.core.services.notifications import (
|
|
13
|
+
notification_detail as notification_detail_action,
|
|
14
|
+
notification_overtime_list as notification_overtime_list_action,
|
|
15
|
+
overtime_approve as overtime_approve_action,
|
|
16
|
+
)
|
|
17
|
+
from tlnt.core.services.overtime import overtime_detail as overtime_detail_action
|
|
18
|
+
from tlnt.core.services.overtime import overtime_list as overtime_list_action
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def overtime_list(
|
|
22
|
+
json_output: JsonOption = False,
|
|
23
|
+
verbose: VerboseOption = False,
|
|
24
|
+
curl: CurlOption = False,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""List Talenta overtime requests."""
|
|
27
|
+
run("Loading overtime requests...", overtime_list_action, json_output, verbose)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def overtime_detail(
|
|
31
|
+
request_id: Annotated[
|
|
32
|
+
int,
|
|
33
|
+
typer.Argument(help="Overtime request ID."),
|
|
34
|
+
],
|
|
35
|
+
json_output: JsonOption = False,
|
|
36
|
+
verbose: VerboseOption = False,
|
|
37
|
+
curl: CurlOption = False,
|
|
38
|
+
) -> None:
|
|
39
|
+
"""Read one overtime request."""
|
|
40
|
+
if request_id < 1:
|
|
41
|
+
raise typer.BadParameter("request_id must be at least 1")
|
|
42
|
+
run(
|
|
43
|
+
"Loading overtime request...",
|
|
44
|
+
lambda: overtime_detail_action(request_id),
|
|
45
|
+
json_output,
|
|
46
|
+
verbose,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _overtime_approval_fields(detail: Result) -> tuple[int, str] | Result:
|
|
51
|
+
inbox = dig(detail.data, "inbox")
|
|
52
|
+
# A detail carries one sub-object per request kind; only the item's own
|
|
53
|
+
# kind is a dict, so overtime_request is the positive sign (inbox_type is
|
|
54
|
+
# 0 on every detail and says nothing).
|
|
55
|
+
overtime = dig(inbox, "overtime_request")
|
|
56
|
+
if not isinstance(overtime, dict):
|
|
57
|
+
return Result(
|
|
58
|
+
False,
|
|
59
|
+
"invalid_input",
|
|
60
|
+
"This inbox item is not an overtime request; approve attendance with "
|
|
61
|
+
"`tlnt attendance approve` or time off with `tlnt timeoff approve`",
|
|
62
|
+
)
|
|
63
|
+
message = inbox.get("message") if isinstance(inbox, dict) else None
|
|
64
|
+
# fk_ref and overtime_request.id name the same request (the bulk `id`);
|
|
65
|
+
# when both are present they must agree.
|
|
66
|
+
ids = {
|
|
67
|
+
positive_id(raw_id)
|
|
68
|
+
for raw_id in (dig(inbox, "fk_ref"), overtime.get("id"))
|
|
69
|
+
if raw_id is not None
|
|
70
|
+
}
|
|
71
|
+
request_id = ids.pop() if len(ids) == 1 else None
|
|
72
|
+
if request_id is None or not isinstance(message, str):
|
|
73
|
+
return Result(
|
|
74
|
+
False,
|
|
75
|
+
"remote_error",
|
|
76
|
+
"Mekari returned an invalid overtime approval response",
|
|
77
|
+
detail.status_code,
|
|
78
|
+
detail.data,
|
|
79
|
+
)
|
|
80
|
+
return int(request_id), message
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def overtime_approve(
|
|
84
|
+
inbox_id: Annotated[
|
|
85
|
+
int | None,
|
|
86
|
+
typer.Argument(help="Talenta inbox ID."),
|
|
87
|
+
] = None,
|
|
88
|
+
interactive: InteractiveOption = False,
|
|
89
|
+
json_output: JsonOption = False,
|
|
90
|
+
verbose: VerboseOption = False,
|
|
91
|
+
curl: CurlOption = False,
|
|
92
|
+
) -> None:
|
|
93
|
+
"""Approve an overtime request after confirmation."""
|
|
94
|
+
run_approval(
|
|
95
|
+
inbox_id,
|
|
96
|
+
"", # the bulk endpoint takes no reason
|
|
97
|
+
interactive,
|
|
98
|
+
json_output,
|
|
99
|
+
verbose,
|
|
100
|
+
noun="overtime",
|
|
101
|
+
id_label="Overtime request ID",
|
|
102
|
+
list_command="tlnt notification overtime-list",
|
|
103
|
+
cancelled_code="overtime_approval_cancelled",
|
|
104
|
+
list_page=lambda: notification_overtime_list_action(page=1),
|
|
105
|
+
load_detail=notification_detail_action,
|
|
106
|
+
fields=_overtime_approval_fields,
|
|
107
|
+
submit=lambda inbox_id, request_id, _message, _reason: overtime_approve_action(
|
|
108
|
+
inbox_id, request_id
|
|
109
|
+
),
|
|
110
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
|
|
8
|
+
from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
|
|
9
|
+
from tlnt.cli.output import run
|
|
10
|
+
from tlnt.core.services.payslip import payslip as payslip_action
|
|
11
|
+
from tlnt.core.services.payslip import payslip_download as payslip_download_action
|
|
12
|
+
|
|
13
|
+
MonthOption = Annotated[
|
|
14
|
+
int | None,
|
|
15
|
+
typer.Option("--month", min=1, max=12, help="Payslip month (1-12); needs --year."),
|
|
16
|
+
]
|
|
17
|
+
YearOption = Annotated[
|
|
18
|
+
int | None,
|
|
19
|
+
typer.Option("--year", min=2000, max=2100, help="Payslip year; needs --month."),
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _period(month: int | None, year: int | None) -> None:
|
|
24
|
+
# Mekari answers an invalid period with the employee record, so never send one.
|
|
25
|
+
if (month is None) != (year is None):
|
|
26
|
+
raise typer.BadParameter("--month and --year go together")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def payslip_show(
|
|
30
|
+
month: MonthOption = None,
|
|
31
|
+
year: YearOption = None,
|
|
32
|
+
json_output: JsonOption = False,
|
|
33
|
+
verbose: VerboseOption = False,
|
|
34
|
+
curl: CurlOption = False,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Read a payslip (the latest period without --month/--year)."""
|
|
37
|
+
_period(month, year)
|
|
38
|
+
run("Loading payslip...", lambda: payslip_action(month, year), json_output, verbose)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def payslip_download(
|
|
42
|
+
month: MonthOption = None,
|
|
43
|
+
year: YearOption = None,
|
|
44
|
+
output: Annotated[
|
|
45
|
+
Path | None,
|
|
46
|
+
typer.Option("--output", help="PDF path; default payslip-YYYY-MM.pdf here."),
|
|
47
|
+
] = None,
|
|
48
|
+
json_output: JsonOption = False,
|
|
49
|
+
verbose: VerboseOption = False,
|
|
50
|
+
curl: CurlOption = False,
|
|
51
|
+
) -> None:
|
|
52
|
+
"""Save a payslip PDF (owner-only file mode)."""
|
|
53
|
+
_period(month, year)
|
|
54
|
+
run(
|
|
55
|
+
"Downloading payslip...",
|
|
56
|
+
lambda: payslip_download_action(month, year, output),
|
|
57
|
+
json_output,
|
|
58
|
+
verbose,
|
|
59
|
+
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from tlnt.cli.output import run
|
|
2
|
-
from tlnt.cli.options import AvatarsOption, JsonOption, VerboseOption
|
|
2
|
+
from tlnt.cli.options import AvatarsOption, CurlOption, JsonOption, VerboseOption
|
|
3
3
|
from tlnt.core.services.profile import profile as profile_action
|
|
4
4
|
|
|
5
5
|
|
|
@@ -7,6 +7,7 @@ def profile(
|
|
|
7
7
|
json_output: JsonOption = False,
|
|
8
8
|
avatars: AvatarsOption = False,
|
|
9
9
|
verbose: VerboseOption = False,
|
|
10
|
+
curl: CurlOption = False,
|
|
10
11
|
) -> None:
|
|
11
12
|
"""Read employment information with the saved mobile token."""
|
|
12
13
|
run("Loading profile...", profile_action, json_output, verbose, avatars=avatars)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
|
|
4
|
+
from tlnt.cli.output import run
|
|
5
|
+
from tlnt.core.services.payslip import (
|
|
6
|
+
reimbursement_policies as reimbursement_policies_action,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def reimbursement_policies(
|
|
11
|
+
json_output: JsonOption = False,
|
|
12
|
+
verbose: VerboseOption = False,
|
|
13
|
+
curl: CurlOption = False,
|
|
14
|
+
) -> None:
|
|
15
|
+
"""List your reimbursement policies and remaining balances."""
|
|
16
|
+
run(
|
|
17
|
+
"Loading reimbursement policies...",
|
|
18
|
+
lambda: reimbursement_policies_action(),
|
|
19
|
+
json_output,
|
|
20
|
+
verbose,
|
|
21
|
+
)
|
|
@@ -9,7 +9,7 @@ from rich.prompt import Prompt
|
|
|
9
9
|
|
|
10
10
|
from tlnt.cli import prompts
|
|
11
11
|
from tlnt.cli.approvals import run_approval
|
|
12
|
-
from tlnt.cli.options import InteractiveOption, JsonOption, VerboseOption
|
|
12
|
+
from tlnt.cli.options import CurlOption, InteractiveOption, JsonOption, VerboseOption
|
|
13
13
|
from tlnt.cli.output import (
|
|
14
14
|
action_banner,
|
|
15
15
|
confirm,
|
|
@@ -32,6 +32,7 @@ from tlnt.core.services.notifications import (
|
|
|
32
32
|
def timeoff_types_list(
|
|
33
33
|
json_output: JsonOption = False,
|
|
34
34
|
verbose: VerboseOption = False,
|
|
35
|
+
curl: CurlOption = False,
|
|
35
36
|
) -> None:
|
|
36
37
|
"""Read available time-off types."""
|
|
37
38
|
run(
|
|
@@ -73,6 +74,7 @@ def timeoff_balance(
|
|
|
73
74
|
] = False,
|
|
74
75
|
json_output: JsonOption = False,
|
|
75
76
|
verbose: VerboseOption = False,
|
|
77
|
+
curl: CurlOption = False,
|
|
76
78
|
) -> None:
|
|
77
79
|
"""Read the signed-in user's time-off balances."""
|
|
78
80
|
run(
|
|
@@ -102,6 +104,7 @@ def timeoff_delegation_list(
|
|
|
102
104
|
] = "",
|
|
103
105
|
json_output: JsonOption = False,
|
|
104
106
|
verbose: VerboseOption = False,
|
|
107
|
+
curl: CurlOption = False,
|
|
105
108
|
) -> None:
|
|
106
109
|
"""Search employees available for time-off delegation."""
|
|
107
110
|
if page < 1:
|
|
@@ -149,6 +152,7 @@ def timeoff_list(
|
|
|
149
152
|
] = False,
|
|
150
153
|
json_output: JsonOption = False,
|
|
151
154
|
verbose: VerboseOption = False,
|
|
155
|
+
curl: CurlOption = False,
|
|
152
156
|
) -> None:
|
|
153
157
|
"""Read time-off requests."""
|
|
154
158
|
if page < 1:
|
|
@@ -179,6 +183,7 @@ def timeoff_detail(
|
|
|
179
183
|
],
|
|
180
184
|
json_output: JsonOption = False,
|
|
181
185
|
verbose: VerboseOption = False,
|
|
186
|
+
curl: CurlOption = False,
|
|
182
187
|
) -> None:
|
|
183
188
|
"""Read one time-off request."""
|
|
184
189
|
if request_id < 1:
|
|
@@ -336,6 +341,7 @@ def timeoff_request(
|
|
|
336
341
|
interactive: InteractiveOption = False,
|
|
337
342
|
json_output: JsonOption = False,
|
|
338
343
|
verbose: VerboseOption = False,
|
|
344
|
+
curl: CurlOption = False,
|
|
339
345
|
) -> None:
|
|
340
346
|
"""Request a full-day or half-day time off."""
|
|
341
347
|
require_writable(json_output)
|
|
@@ -398,6 +404,7 @@ def timeoff_cancel(
|
|
|
398
404
|
interactive: InteractiveOption = False,
|
|
399
405
|
json_output: JsonOption = False,
|
|
400
406
|
verbose: VerboseOption = False,
|
|
407
|
+
curl: CurlOption = False,
|
|
401
408
|
) -> None:
|
|
402
409
|
"""Cancel a time-off request after confirmation."""
|
|
403
410
|
require_writable(json_output)
|
|
@@ -497,6 +504,7 @@ def timeoff_approve(
|
|
|
497
504
|
interactive: InteractiveOption = False,
|
|
498
505
|
json_output: JsonOption = False,
|
|
499
506
|
verbose: VerboseOption = False,
|
|
507
|
+
curl: CurlOption = False,
|
|
500
508
|
) -> None:
|
|
501
509
|
"""Approve a time-off request after confirmation."""
|
|
502
510
|
run_approval(
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Annotated
|
|
6
|
+
from typing import Annotated, Any
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
|
+
from typer.core import TyperGroup
|
|
9
10
|
|
|
11
|
+
from tlnt.cli.commands.api import api_get
|
|
10
12
|
from tlnt.cli.commands.attendance import (
|
|
11
13
|
attendance_approve,
|
|
12
14
|
attendance_clockin,
|
|
@@ -29,6 +31,7 @@ from tlnt.cli.commands.notifications import (
|
|
|
29
31
|
notification_count,
|
|
30
32
|
notification_detail,
|
|
31
33
|
notification_list,
|
|
34
|
+
notification_overtime_list,
|
|
32
35
|
notification_timeoff_list,
|
|
33
36
|
)
|
|
34
37
|
from tlnt.cli.commands.timeoff import (
|
|
@@ -41,6 +44,9 @@ from tlnt.cli.commands.timeoff import (
|
|
|
41
44
|
timeoff_request,
|
|
42
45
|
timeoff_types_list,
|
|
43
46
|
)
|
|
47
|
+
from tlnt.cli.commands.overtime import overtime_approve, overtime_detail, overtime_list
|
|
48
|
+
from tlnt.cli.commands.payslip import payslip_download, payslip_show
|
|
49
|
+
from tlnt.cli.commands.reimbursement import reimbursement_policies
|
|
44
50
|
from tlnt.cli.commands.profile import profile
|
|
45
51
|
from tlnt.cli.commands.setup import setup
|
|
46
52
|
from tlnt.cli.commands.status import status
|
|
@@ -50,11 +56,23 @@ from tlnt.cli.commands.version import print_version
|
|
|
50
56
|
from tlnt.cli.options import VerboseOption
|
|
51
57
|
from tlnt.core import config, play_store
|
|
52
58
|
from tlnt.core import mekari as mekari_constants
|
|
59
|
+
from tlnt.core.curl import CurlPreview
|
|
53
60
|
from tlnt.core.logs import configure_logging
|
|
54
61
|
from tlnt.core.logs import logger
|
|
55
62
|
|
|
63
|
+
class _CurlGroup(TyperGroup):
|
|
64
|
+
"""Print the curl preview --curl raises instead of sending; sub-apps run inside invoke."""
|
|
65
|
+
|
|
66
|
+
def invoke(self, ctx: typer.Context) -> Any:
|
|
67
|
+
try:
|
|
68
|
+
return super().invoke(ctx)
|
|
69
|
+
except CurlPreview as preview:
|
|
70
|
+
typer.echo(str(preview))
|
|
71
|
+
|
|
72
|
+
|
|
56
73
|
# Define the main app and sub-apps
|
|
57
74
|
app = typer.Typer(
|
|
75
|
+
cls=_CurlGroup,
|
|
58
76
|
no_args_is_help=True,
|
|
59
77
|
help=(
|
|
60
78
|
"[bold cyan]tlnt[/] — unofficial CLI for Mekari Talenta.\n\n"
|
|
@@ -92,6 +110,7 @@ notification_app.command(name="count")(notification_count)
|
|
|
92
110
|
notification_app.command(name="list")(notification_list)
|
|
93
111
|
notification_app.command(name="attendance-list")(notification_attendance_list)
|
|
94
112
|
notification_app.command(name="timeoff-list")(notification_timeoff_list)
|
|
113
|
+
notification_app.command(name="overtime-list")(notification_overtime_list)
|
|
95
114
|
notification_app.command(name="detail")(notification_detail)
|
|
96
115
|
app.add_typer(notification_app, name="notification", rich_help_panel="Workflows")
|
|
97
116
|
|
|
@@ -113,6 +132,25 @@ calendar_app.command(name="birthday")(calendar_birthday)
|
|
|
113
132
|
calendar_app.command(name="activity")(calendar_activity)
|
|
114
133
|
app.add_typer(calendar_app, name="calendar", rich_help_panel="Workflows")
|
|
115
134
|
|
|
135
|
+
overtime_app = typer.Typer(no_args_is_help=True, help="Read and approve overtime requests.")
|
|
136
|
+
overtime_app.command(name="list")(overtime_list)
|
|
137
|
+
overtime_app.command(name="detail")(overtime_detail)
|
|
138
|
+
overtime_app.command(name="approve")(overtime_approve)
|
|
139
|
+
app.add_typer(overtime_app, name="overtime", rich_help_panel="Workflows")
|
|
140
|
+
|
|
141
|
+
payslip_app = typer.Typer(no_args_is_help=True, help="Read and save payslips.")
|
|
142
|
+
payslip_app.command(name="show")(payslip_show)
|
|
143
|
+
payslip_app.command(name="download")(payslip_download)
|
|
144
|
+
app.add_typer(payslip_app, name="payslip", rich_help_panel="Workflows")
|
|
145
|
+
|
|
146
|
+
reimbursement_app = typer.Typer(no_args_is_help=True, help="Read reimbursement policies.")
|
|
147
|
+
reimbursement_app.command(name="policies")(reimbursement_policies)
|
|
148
|
+
app.add_typer(reimbursement_app, name="reimbursement", rich_help_panel="Workflows")
|
|
149
|
+
|
|
150
|
+
api_app = typer.Typer(no_args_is_help=True, help="Read any Talenta mobile API path.")
|
|
151
|
+
api_app.command(name="get")(api_get)
|
|
152
|
+
app.add_typer(api_app, name="api", rich_help_panel="Workflows")
|
|
153
|
+
|
|
116
154
|
|
|
117
155
|
_log = logger.bind(component="cli")
|
|
118
156
|
|