tlnt-cli 1.6.0__tar.gz → 1.8.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.
Files changed (64) hide show
  1. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/PKG-INFO +7 -6
  2. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/README.md +6 -5
  3. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/pyproject.toml +2 -2
  4. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/pyproject.toml.orig +2 -2
  5. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/browser/login.py +2 -1
  6. tlnt_cli-1.8.0/src/tlnt/cli/commands/api.py +220 -0
  7. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/attendance.py +19 -0
  8. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/calendar.py +3 -1
  9. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/logout.py +2 -1
  10. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/notifications.py +11 -2
  11. tlnt_cli-1.8.0/src/tlnt/cli/commands/overtime.py +110 -0
  12. tlnt_cli-1.8.0/src/tlnt/cli/commands/payslip.py +59 -0
  13. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/profile.py +2 -1
  14. tlnt_cli-1.8.0/src/tlnt/cli/commands/reimbursement.py +21 -0
  15. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/timeoff.py +9 -1
  16. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/main.py +63 -15
  17. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/options.py +16 -0
  18. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/output.py +6 -1
  19. tlnt_cli-1.8.0/src/tlnt/core/api_endpoints.py +517 -0
  20. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/client.py +306 -9
  21. tlnt_cli-1.8.0/src/tlnt/core/curl.py +58 -0
  22. tlnt_cli-1.8.0/src/tlnt/core/device.py +66 -0
  23. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/http_client.py +12 -0
  24. tlnt_cli-1.8.0/src/tlnt/core/mekari.py +186 -0
  25. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/models.py +12 -0
  26. tlnt_cli-1.8.0/src/tlnt/core/services/__init__.py +86 -0
  27. tlnt_cli-1.8.0/src/tlnt/core/services/api.py +138 -0
  28. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/attendance.py +32 -61
  29. tlnt_cli-1.8.0/src/tlnt/core/services/device.py +67 -0
  30. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/login.py +17 -1
  31. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/logout.py +3 -0
  32. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/notifications.py +28 -0
  33. tlnt_cli-1.8.0/src/tlnt/core/services/overtime.py +19 -0
  34. tlnt_cli-1.8.0/src/tlnt/core/services/payslip.py +49 -0
  35. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/setup.py +2 -0
  36. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/status.py +25 -6
  37. tlnt_cli-1.8.0/src/tlnt/core/user_agent.py +72 -0
  38. tlnt_cli-1.6.0/src/tlnt/core/mekari.py +0 -174
  39. tlnt_cli-1.6.0/src/tlnt/core/services/__init__.py +0 -46
  40. tlnt_cli-1.6.0/src/tlnt/core/user_agent.py +0 -71
  41. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/LICENSE +0 -0
  42. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/__init__.py +0 -0
  43. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/__main__.py +0 -0
  44. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/browser/__init__.py +0 -0
  45. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/browser/oauth.py +0 -0
  46. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/browser/scripted.py +0 -0
  47. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/__init__.py +0 -0
  48. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/approvals.py +0 -0
  49. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/avatars.py +0 -0
  50. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/__init__.py +0 -0
  51. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/login.py +0 -0
  52. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/setup.py +0 -0
  53. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/status.py +0 -0
  54. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/update.py +0 -0
  55. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/commands/version.py +0 -0
  56. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/cli/prompts.py +0 -0
  57. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/__init__.py +0 -0
  58. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/config.py +0 -0
  59. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/logs.py +0 -0
  60. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/play_store.py +0 -0
  61. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/calendar.py +0 -0
  62. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/profile.py +0 -0
  63. {tlnt_cli-1.6.0 → tlnt_cli-1.8.0}/src/tlnt/core/services/timeoff.py +0 -0
  64. {tlnt_cli-1.6.0 → tlnt_cli-1.8.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.6.0
3
+ Version: 1.8.0
4
4
  Summary: CLI wrapper for HRIS attendance and employment workflows.
5
5
  Author: Fathiraz Arthuro
6
6
  License-Expression: MIT
@@ -25,11 +25,10 @@ Description-Content-Type: text/markdown
25
25
  `tlnt` is a Python CLI wrapper for Mekari Talenta employment data,
26
26
  notifications, attendance summaries and previews, and human-confirmed attendance actions.
27
27
 
28
- > [!WARNING]
29
- > `tlnt` is an unofficial, independent research and educational project. It
30
- > is not affiliated with Mekari or Talenta. Use it only when your account and
31
- > the actions you perform are authorized. Read the [full bilingual
32
- > disclaimer](docs/index.md#disclaimer) before using it.
28
+ > **Warning:** `tlnt` is an unofficial, independent research and educational
29
+ > project. It is not affiliated with Mekari or Talenta. Use it only when your
30
+ > account and the actions you perform are authorized. Read the [full bilingual
31
+ > disclaimer](https://tlnt-docs.vercel.app/#disclaimer) before using it.
33
32
 
34
33
  ## Install
35
34
 
@@ -105,6 +104,8 @@ The full command map, global options and output modes are in
105
104
  always ask for confirmation. The prompt reads standard input, so it guards
106
105
  against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
107
106
  - `--dry-run` never submits attendance.
107
+ - `--curl` sends nothing but prints the bearer token and request body; keep
108
+ that output out of chat, logs and tickets.
108
109
  - `TALENTA_READONLY=1` refuses every command that would change Talenta or
109
110
  local state.
110
111
  - The version checks only read public listings (PyPI and Google Play), never
@@ -8,11 +8,10 @@
8
8
  `tlnt` is a Python CLI wrapper for Mekari Talenta employment data,
9
9
  notifications, attendance summaries and previews, and human-confirmed attendance actions.
10
10
 
11
- > [!WARNING]
12
- > `tlnt` is an unofficial, independent research and educational project. It
13
- > is not affiliated with Mekari or Talenta. Use it only when your account and
14
- > the actions you perform are authorized. Read the [full bilingual
15
- > disclaimer](docs/index.md#disclaimer) before using it.
11
+ > **Warning:** `tlnt` is an unofficial, independent research and educational
12
+ > project. It is not affiliated with Mekari or Talenta. Use it only when your
13
+ > account and the actions you perform are authorized. Read the [full bilingual
14
+ > disclaimer](https://tlnt-docs.vercel.app/#disclaimer) before using it.
16
15
 
17
16
  ## Install
18
17
 
@@ -88,6 +87,8 @@ The full command map, global options and output modes are in
88
87
  always ask for confirmation. The prompt reads standard input, so it guards
89
88
  against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
90
89
  - `--dry-run` never submits attendance.
90
+ - `--curl` sends nothing but prints the bearer token and request body; keep
91
+ that output out of chat, logs and tickets.
91
92
  - `TALENTA_READONLY=1` refuses every command that would change Talenta or
92
93
  local state.
93
94
  - The version checks only read public listings (PyPI and Google Play), never
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "tlnt-cli"
7
- version = "1.6.0"
7
+ version = "1.8.0"
8
8
  description = "CLI wrapper for HRIS attendance and employment workflows."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -30,7 +30,7 @@ tlnt = "tlnt.cli.main:main"
30
30
  dev = ["pytest>=9,<10"]
31
31
  docs = [
32
32
  "mkdocs>=1.6,<2",
33
- "mkdocs-shadcn>=0.9,<1",
33
+ "mkdocs-shadcn>=0.12.2,<1",
34
34
  ]
35
35
 
36
36
  [tool.uv.build-backend]
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "tlnt-cli"
7
- version = "1.6.0"
7
+ version = "1.8.0"
8
8
  description = "CLI wrapper for HRIS attendance and employment workflows."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -26,7 +26,7 @@ tlnt = "tlnt.cli.main:main"
26
26
 
27
27
  [dependency-groups]
28
28
  dev = ["pytest>=9,<10"]
29
- docs = ["mkdocs>=1.6,<2", "mkdocs-shadcn>=0.9,<1"]
29
+ docs = ["mkdocs>=1.6,<2", "mkdocs-shadcn>=0.12.2,<1"]
30
30
 
31
31
  [tool.uv.build-backend]
32
32
  # Without this, uv would look for src/tlnt_cli; the import package is tlnt.
@@ -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,220 @@
1
+ from __future__ import annotations
2
+
3
+ import inspect
4
+ import json
5
+ import re
6
+ from collections.abc import Callable, Iterable, Mapping
7
+ from typing import Annotated, Any
8
+
9
+ import typer
10
+ from typer.models import CommandInfo
11
+
12
+ from tlnt.cli.options import CurlOption, JsonOption, VerboseOption
13
+ from tlnt.cli.output import action_banner, confirm, emit, require_writable, run
14
+ from tlnt.core.api_endpoints import API_ENDPOINTS, ApiEndpoint, command_names
15
+ from tlnt.core.models import Result
16
+ from tlnt.core.services.api import api_get as endpoint_get_action
17
+ from tlnt.core.services.api import api_post as endpoint_post_action
18
+ from tlnt.core.services.api import api_refusal
19
+
20
+ # Each generated group's usage panel and help, in the order --help lists them.
21
+ ENDPOINT_GROUPS = {
22
+ "time-sheet": ("Attendance", "Track time-sheet tasks and timers."),
23
+ "project": ("Attendance", "Read projects and their members."),
24
+ "shift-list": ("Attendance", "Read the shift list."),
25
+ "shift-request": ("Attendance", "Read shift requests."),
26
+ "multiple-shift": ("Attendance", "Check multiple-shift status for a date."),
27
+ "companies": ("Attendance", "Read and reject overtime plannings."),
28
+ "organisations": ("Attendance", "Read the company's attendance summaries."),
29
+ "approval": ("Approvals", "Approve or reject custom-form requests in bulk."),
30
+ "approval-request": ("Approvals", "Approve or reject requests in bulk."),
31
+ "request": ("Approvals", "List employees for a request."),
32
+ "history-request": ("Approvals", "Read change-shift and delegation history."),
33
+ "mekari-flex": ("Pay", "Check Mekari Flex status."),
34
+ "employee": ("People", "Read employees, leave and the org chart."),
35
+ "employees": ("People", "Read an employee's education and experience."),
36
+ "my-info": ("People", "Read your own files, family and education."),
37
+ "subordinates": ("People", "List your subordinates."),
38
+ "reprimand": ("People", "Read reprimands."),
39
+ "comment": ("People", "Read reprimand feedback."),
40
+ "organization": ("Company", "Read the organization structure."),
41
+ "branch": ("Company", "List company branches."),
42
+ "sbus": ("Company", "List the company's business units."),
43
+ "consultant": ("Company", "Read the consultant company."),
44
+ "onboarding": ("Company", "Read onboarding tasks, forms and documents."),
45
+ "custom-form": ("Company", "List custom forms."),
46
+ "custom-form-submissions": ("Company", "Read custom-form submissions."),
47
+ "dashboard": ("Company", "Read dashboard announcements, icons and reviews."),
48
+ "ems": ("Company", "Read company and mobile settings."),
49
+ "toggle": ("Company", "Read the app's feature toggles."),
50
+ "progress-bar": ("Company", "Read a progress bar by type."),
51
+ }
52
+ _CAMEL = re.compile(r"(?<=[a-z0-9])(?=[A-Z])")
53
+ _OUTPUT_OPTIONS = (
54
+ ("json_output", JsonOption),
55
+ ("verbose", VerboseOption),
56
+ ("curl", CurlOption),
57
+ )
58
+
59
+
60
+ def _json_body(body: str | None) -> Any:
61
+ if body is None:
62
+ return None
63
+ try:
64
+ return json.loads(body)
65
+ except ValueError as error:
66
+ raise typer.BadParameter("--body must be JSON") from error
67
+
68
+
69
+ def option_name(key: str) -> str:
70
+ """The option for a query or body key: inboxID is --inbox-id, per_page --per-page."""
71
+ return _CAMEL.sub("-", key).replace("_", "-").lower()
72
+
73
+
74
+ def argument_name(name: str) -> str:
75
+ """The metavar for a {name} slot: formId is FORM_ID, policy_id is POLICY_ID."""
76
+ return option_name(name).upper().replace("-", "_")
77
+
78
+
79
+ def _post(
80
+ row: ApiEndpoint,
81
+ args: dict[str, str],
82
+ given: dict[str, str],
83
+ json_output: bool,
84
+ verbose: bool,
85
+ ) -> None:
86
+ """Send one row's POST after the read-only check, the refusal and the prompt."""
87
+ require_writable(json_output)
88
+ if row.encoding == "json":
89
+ fields, json_body = {}, _json_body(given.get("body"))
90
+ else:
91
+ fields, json_body = given, None
92
+ refused = api_refusal(row, args, fields, json_body)
93
+ if refused is not None:
94
+ emit(refused, json_output)
95
+ return
96
+ action_banner("API post", enabled=not json_output)
97
+ shown = json.dumps(json_body if row.encoding == "json" else fields)
98
+ typer.echo(f"POST {row.fill(args)}", err=True)
99
+ typer.echo(f"Body: {shown}", err=True)
100
+ if not confirm("Send this request to Talenta?", default=False, err=True):
101
+ emit(Result(False, "api_post_cancelled", "API request cancelled"), json_output)
102
+ return
103
+ run(
104
+ "Sending API request...",
105
+ lambda: endpoint_post_action(row, args, fields, json_body),
106
+ json_output,
107
+ verbose,
108
+ )
109
+
110
+
111
+ def _option_help(row: ApiEndpoint, key: str) -> str:
112
+ if row.encoding == "json":
113
+ return f"JSON request body with the keys {', '.join(row.body)}."
114
+ sent = f"Sent as the {'query value' if row.method == 'GET' else 'body field'} {key}."
115
+ return f"{sent} Defaults to your user id." if key == row.user_key else sent
116
+
117
+
118
+ def _parameters(row: ApiEndpoint, keys: tuple[str, ...]) -> list[inspect.Parameter]:
119
+ """An argument per {name} slot, an option per key, then the output options."""
120
+ keyword = inspect.Parameter.KEYWORD_ONLY
121
+ arguments = [
122
+ inspect.Parameter(
123
+ f"arg_{index}",
124
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
125
+ annotation=Annotated[
126
+ str,
127
+ typer.Argument(
128
+ metavar=argument_name(name),
129
+ help=f"Value for {{{name}}} in the path.",
130
+ show_default=False,
131
+ ),
132
+ ],
133
+ )
134
+ for index, name in enumerate(row.args)
135
+ ]
136
+ options = [
137
+ inspect.Parameter(
138
+ f"opt_{index}",
139
+ keyword,
140
+ default=inspect.Parameter.empty if key in row.required else None,
141
+ annotation=Annotated[
142
+ str if key in row.required else str | None,
143
+ typer.Option(f"--{option_name(key)}", help=_option_help(row, key)),
144
+ ],
145
+ )
146
+ for index, key in enumerate(keys)
147
+ ]
148
+ output = [
149
+ inspect.Parameter(name, keyword, default=False, annotation=option)
150
+ for name, option in _OUTPUT_OPTIONS
151
+ ]
152
+ return arguments + options + output
153
+
154
+
155
+ def endpoint_command(row: ApiEndpoint) -> Callable[..., None]:
156
+ """The command for one row: its {name} slots are arguments, its names options."""
157
+ keys = ("body",) if row.encoding == "json" else row.query or row.body
158
+
159
+ def command(**values: Any) -> None:
160
+ args = {name: values[f"arg_{index}"] for index, name in enumerate(row.args)}
161
+ given = {
162
+ key: values[f"opt_{index}"]
163
+ for index, key in enumerate(keys)
164
+ if values[f"opt_{index}"] is not None
165
+ }
166
+ json_output, verbose = values["json_output"], values["verbose"]
167
+ if row.method == "POST":
168
+ _post(row, args, given, json_output, verbose)
169
+ return
170
+ run(
171
+ "Loading API response...",
172
+ lambda: endpoint_get_action(row, args, given),
173
+ json_output,
174
+ verbose,
175
+ )
176
+
177
+ parameters = _parameters(row, keys)
178
+ command.__signature__ = inspect.Signature(parameters)
179
+ command.__annotations__ = {parameter.name: parameter.annotation for parameter in parameters}
180
+ command.__doc__ = f"{row.summary}\n\n{row.method} {row.path}"
181
+ return command
182
+
183
+
184
+ def _command_name(info: CommandInfo) -> str:
185
+ return info.name or info.callback.__name__.replace("_", "-")
186
+
187
+
188
+ def register_endpoint_commands(
189
+ app: typer.Typer,
190
+ named: Mapping[str, typer.Typer],
191
+ rows: Iterable[ApiEndpoint] = API_ENDPOINTS,
192
+ ) -> None:
193
+ """Add one command per row: to its named group, or to its ENDPOINT_GROUPS group.
194
+
195
+ Typer keeps the last command registered under a name, so a clash with a
196
+ named command or group would replace it silently; it raises instead, and
197
+ so does a new group with no help panel.
198
+ """
199
+ names = command_names(rows)
200
+ roots = {_command_name(info) for info in app.registered_commands}
201
+ roots |= {info.name for info in app.registered_groups}
202
+ for group, command in names.values():
203
+ known = named.get(group)
204
+ if known is None and group in roots:
205
+ raise ValueError(f"tlnt {group} is already a named command")
206
+ if known is not None and command in map(_command_name, known.registered_commands):
207
+ raise ValueError(f"tlnt {group} {command} is already a named command")
208
+ if known is None and group not in ENDPOINT_GROUPS:
209
+ raise ValueError(f"tlnt {group} has no help panel")
210
+ used = {group for group, _ in names.values() if group not in named}
211
+ groups = {
212
+ group: typer.Typer(no_args_is_help=True, help=ENDPOINT_GROUPS[group][1])
213
+ for group in ENDPOINT_GROUPS
214
+ if group in used
215
+ }
216
+ for row, (group, command) in names.items():
217
+ target = named[group] if group in named else groups[group]
218
+ target.command(name=command)(endpoint_command(row))
219
+ for group, sub in groups.items():
220
+ app.add_typer(sub, name=group, rich_help_panel=ENDPOINT_GROUPS[group][0])
@@ -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 three commands differ only in the inbox they read."""
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
+ )