render-lab-tasks-jira 0.1.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 (24) hide show
  1. render_lab_tasks_jira-0.1.0/.gitignore +11 -0
  2. render_lab_tasks_jira-0.1.0/LICENSE +21 -0
  3. render_lab_tasks_jira-0.1.0/PKG-INFO +71 -0
  4. render_lab_tasks_jira-0.1.0/README.md +58 -0
  5. render_lab_tasks_jira-0.1.0/pyproject.toml +22 -0
  6. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/__init__.py +1 -0
  7. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/_app.py +3 -0
  8. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/add_attachment.py +18 -0
  9. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/assign_issue.py +18 -0
  10. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/client.py +244 -0
  11. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/comment.py +18 -0
  12. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/create_issue.py +18 -0
  13. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/get_issue.py +18 -0
  14. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/jql.py +18 -0
  15. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/link_issues.py +18 -0
  16. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/list_transitions.py +18 -0
  17. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/py.typed +0 -0
  18. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/retry.py +3 -0
  19. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/tasks.py +35 -0
  20. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/transition.py +18 -0
  21. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/types.py +117 -0
  22. render_lab_tasks_jira-0.1.0/src/render_lab_tasks_jira/update_issue.py +18 -0
  23. render_lab_tasks_jira-0.1.0/tests/test_contracts.py +8 -0
  24. render_lab_tasks_jira-0.1.0/tests/test_search.py +61 -0
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ *.egg-info/
9
+ .env
10
+ .env.*
11
+ !.env.example
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Render Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.5
2
+ Name: render-lab-tasks-jira
3
+ Version: 0.1.0
4
+ Summary: jira tasks for Render Workflows
5
+ Project-URL: Repository, https://github.com/render-lab/render-tasks-python
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: httpx<0.29,>=0.28
10
+ Requires-Dist: render-lab-tasks-core<0.2,>=0.1.0
11
+ Requires-Dist: render==1.0.1
12
+ Description-Content-Type: text/markdown
13
+
14
+ # render-lab-tasks-jira
15
+
16
+ Python port of all 10 registered tasks in the pinned TypeScript pack at
17
+ `45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
18
+
19
+ From the repository, install this pack and its supporting core together:
20
+
21
+ ```sh
22
+ pip install render-lab-tasks-jira==0.1.0
23
+ ```
24
+
25
+ Import task definitions from `render_lab_tasks_jira.tasks`. Combine its `app` with
26
+ other pack apps using `Workflows.from_workflows(...)` and call tasks with
27
+ `await ctx.run(task, input)`. Package roots do not register tasks. JSON fields
28
+ retain the TS spelling; Python functions use snake_case.
29
+
30
+ ## Tasks
31
+
32
+ | Registered name | Python export (also exposes `_impl`) |
33
+ | --- | --- |
34
+ | `jira.addAttachment` | `add_attachment` |
35
+ | `jira.assignIssue` | `assign_issue` |
36
+ | `jira.comment` | `comment` |
37
+ | `jira.createIssue` | `create_issue` |
38
+ | `jira.getIssue` | `get_issue` |
39
+ | `jira.jql` | `jql` |
40
+ | `jira.linkIssues` | `link_issues` |
41
+ | `jira.listTransitions` | `list_transitions` |
42
+ | `jira.transition` | `transition` |
43
+ | `jira.updateIssue` | `update_issue` |
44
+
45
+ ## Dependencies and retries
46
+
47
+ Raw implementations accept context first and keyword-only `deps`. The `.client`
48
+ module exports typed `Port`, `Deps`, and `Client` classes (also vendor-named aliases).
49
+ Inject a fake port, or pass a caller-owned `httpx.AsyncClient` to `Client` for custom
50
+ transport/configuration. Default dependencies close their HTTP clients after the
51
+ operation. Credentials resolve at first use. HTTP and SDK retries are disabled;
52
+ `retry.py` owns durable retry settings. DTO types live in `.types`.
53
+
54
+ ## Environment
55
+
56
+ | Variable | Contract |
57
+ | --- | --- |
58
+ | `JIRA_BASE_URL` | Required Jira site URL. |
59
+ | `JIRA_EMAIL` | Required account email for Basic authentication. |
60
+ | `JIRA_API_TOKEN` | Required account API token. |
61
+
62
+ ## Verification and limitations
63
+
64
+ Plain text descriptions/comments become Atlassian Document Format, with one paragraph per line. JQL uses the current `/rest/api/3/search/jql` endpoint and requests summary/status fields explicitly. It returns one page (default 50); `limit: 0` makes no request. Limits must be non-negative integers. This deliberately corrects the pinned TS transport (ADR-0007); live Jira validation remains pending. Attachments use UTF-8 text and reject CR/LF/quotes in filenames before HTTP (ADR-0006). This is not a binary media upload API.
65
+
66
+ Shared JSON fixtures compare the Python task output with the actual pinned TS
67
+ implementation. REST fixtures also compare HTTP requests; HubSpot and Linear
68
+ fixtures compare source SDK arguments with HTTP payloads/GraphQL variables.
69
+ No live vendor calls were made for this batch. Registered-task parity does not
70
+ claim live readiness or all supporting TS exports. See the root verification
71
+ tracker and docs/porting-batches.md. Licensed under MIT.
@@ -0,0 +1,58 @@
1
+ # render-lab-tasks-jira
2
+
3
+ Python port of all 10 registered tasks in the pinned TypeScript pack at
4
+ `45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
5
+
6
+ From the repository, install this pack and its supporting core together:
7
+
8
+ ```sh
9
+ pip install render-lab-tasks-jira==0.1.0
10
+ ```
11
+
12
+ Import task definitions from `render_lab_tasks_jira.tasks`. Combine its `app` with
13
+ other pack apps using `Workflows.from_workflows(...)` and call tasks with
14
+ `await ctx.run(task, input)`. Package roots do not register tasks. JSON fields
15
+ retain the TS spelling; Python functions use snake_case.
16
+
17
+ ## Tasks
18
+
19
+ | Registered name | Python export (also exposes `_impl`) |
20
+ | --- | --- |
21
+ | `jira.addAttachment` | `add_attachment` |
22
+ | `jira.assignIssue` | `assign_issue` |
23
+ | `jira.comment` | `comment` |
24
+ | `jira.createIssue` | `create_issue` |
25
+ | `jira.getIssue` | `get_issue` |
26
+ | `jira.jql` | `jql` |
27
+ | `jira.linkIssues` | `link_issues` |
28
+ | `jira.listTransitions` | `list_transitions` |
29
+ | `jira.transition` | `transition` |
30
+ | `jira.updateIssue` | `update_issue` |
31
+
32
+ ## Dependencies and retries
33
+
34
+ Raw implementations accept context first and keyword-only `deps`. The `.client`
35
+ module exports typed `Port`, `Deps`, and `Client` classes (also vendor-named aliases).
36
+ Inject a fake port, or pass a caller-owned `httpx.AsyncClient` to `Client` for custom
37
+ transport/configuration. Default dependencies close their HTTP clients after the
38
+ operation. Credentials resolve at first use. HTTP and SDK retries are disabled;
39
+ `retry.py` owns durable retry settings. DTO types live in `.types`.
40
+
41
+ ## Environment
42
+
43
+ | Variable | Contract |
44
+ | --- | --- |
45
+ | `JIRA_BASE_URL` | Required Jira site URL. |
46
+ | `JIRA_EMAIL` | Required account email for Basic authentication. |
47
+ | `JIRA_API_TOKEN` | Required account API token. |
48
+
49
+ ## Verification and limitations
50
+
51
+ Plain text descriptions/comments become Atlassian Document Format, with one paragraph per line. JQL uses the current `/rest/api/3/search/jql` endpoint and requests summary/status fields explicitly. It returns one page (default 50); `limit: 0` makes no request. Limits must be non-negative integers. This deliberately corrects the pinned TS transport (ADR-0007); live Jira validation remains pending. Attachments use UTF-8 text and reject CR/LF/quotes in filenames before HTTP (ADR-0006). This is not a binary media upload API.
52
+
53
+ Shared JSON fixtures compare the Python task output with the actual pinned TS
54
+ implementation. REST fixtures also compare HTTP requests; HubSpot and Linear
55
+ fixtures compare source SDK arguments with HTTP payloads/GraphQL variables.
56
+ No live vendor calls were made for this batch. Registered-task parity does not
57
+ claim live readiness or all supporting TS exports. See the root verification
58
+ tracker and docs/porting-batches.md. Licensed under MIT.
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27,<2"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "render-lab-tasks-jira"
7
+ version = "0.1.0"
8
+ description = "jira tasks for Render Workflows"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.12"
13
+ dependencies = ["render==1.0.1", "httpx>=0.28,<0.29", "render-lab-tasks-core>=0.1.0,<0.2"]
14
+
15
+ [project.urls]
16
+ Repository = "https://github.com/render-lab/render-tasks-python"
17
+
18
+ [tool.uv.sources]
19
+ render-lab-tasks-core = { workspace = true }
20
+
21
+ [tool.hatch.build.targets.wheel]
22
+ packages = ["src/render_lab_tasks_jira"]
@@ -0,0 +1 @@
1
+ """Import .tasks explicitly to register durable tasks."""
@@ -0,0 +1,3 @@
1
+ from render import Workflows
2
+
3
+ app = Workflows()
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import AddAttachmentInput, AddAttachmentResult
7
+
8
+
9
+ async def add_attachment_impl(
10
+ ctx: TaskContext, input: AddAttachmentInput, *, deps: Deps | None = None
11
+ ) -> AddAttachmentResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.add_attachment(input)
14
+
15
+
16
+ @app.task(name="jira.addAttachment", retry=JIRA_RETRY)
17
+ async def add_attachment(ctx: TaskContext, input: AddAttachmentInput) -> AddAttachmentResult:
18
+ return await add_attachment_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import AssignIssueInput, AssignIssueResult
7
+
8
+
9
+ async def assign_issue_impl(
10
+ ctx: TaskContext, input: AssignIssueInput, *, deps: Deps | None = None
11
+ ) -> AssignIssueResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.assign_issue(input)
14
+
15
+
16
+ @app.task(name="jira.assignIssue", retry=JIRA_RETRY)
17
+ async def assign_issue(ctx: TaskContext, input: AssignIssueInput) -> AssignIssueResult:
18
+ return await assign_issue_impl(ctx, input)
@@ -0,0 +1,244 @@
1
+ """Injected vendor interface and one-attempt async HTTP adapter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ import json
7
+ import math
8
+ import os
9
+ import uuid
10
+ from collections.abc import AsyncIterator, Mapping
11
+ from contextlib import asynccontextmanager
12
+ from dataclasses import dataclass
13
+ from typing import Any, Protocol
14
+
15
+ import httpx
16
+ from render_lab_tasks_core.http import HttpClient, enc, nullish, pick, required
17
+
18
+ from . import types as t
19
+
20
+
21
+ def js_string(raw: Mapping[str, Any], key: str) -> str:
22
+ if key not in raw:
23
+ return "undefined"
24
+ if raw[key] is None:
25
+ return "null"
26
+ return str(raw[key])
27
+
28
+
29
+ def text_to_adf(text: str) -> dict[str, Any]:
30
+ return {
31
+ "type": "doc",
32
+ "version": 1,
33
+ "content": [
34
+ {"type": "paragraph", "content": [{"type": "text", "text": line}] if line else []}
35
+ for line in text.split("\n")
36
+ ],
37
+ }
38
+
39
+
40
+ def to_issue(raw: Any, base: str) -> dict[str, Any]:
41
+ raw = raw or {}
42
+ key = js_string(raw, "key")
43
+ fields = raw.get("fields") or {}
44
+ return {
45
+ "key": key,
46
+ "summary": nullish(fields.get("summary"), ""),
47
+ "status": nullish((fields.get("status") or {}).get("name"), ""),
48
+ "assignee": (fields.get("assignee") or {}).get("displayName"),
49
+ "issueType": nullish((fields.get("issuetype") or {}).get("name"), ""),
50
+ "url": base + "/browse/" + key,
51
+ }
52
+
53
+
54
+ class Port(Protocol):
55
+ async def add_attachment(self, input: t.AddAttachmentInput) -> t.AddAttachmentResult: ...
56
+ async def assign_issue(self, input: t.AssignIssueInput) -> t.AssignIssueResult: ...
57
+ async def comment(self, input: t.CommentInput) -> t.CommentResult: ...
58
+ async def create_issue(self, input: t.CreateIssueInput) -> t.CreateIssueResult: ...
59
+ async def get_issue(self, input: t.GetIssueInput) -> t.JiraIssueDetail: ...
60
+ async def jql(self, input: t.JqlInput) -> list[t.JiraIssue]: ...
61
+ async def link_issues(self, input: t.LinkIssuesInput) -> t.LinkIssuesResult: ...
62
+ async def list_transitions(self, input: t.ListTransitionsInput) -> list[t.JiraTransition]: ...
63
+ async def transition(self, input: t.TransitionInput) -> t.TransitionResult: ...
64
+ async def update_issue(self, input: t.UpdateIssueInput) -> t.UpdateIssueResult: ...
65
+
66
+
67
+ @dataclass(frozen=True)
68
+ class Deps:
69
+ jira: Port
70
+
71
+
72
+ class Client:
73
+ def __init__(self, http: httpx.AsyncClient, env: Mapping[str, str] | None = None) -> None:
74
+ self.env = os.environ if env is None else env
75
+ self.http = HttpClient(
76
+ http, lambda: self.base_url() + "/rest/api/3", auth=self._auth, label="Jira API"
77
+ )
78
+
79
+ def base_url(self) -> str:
80
+ return required(self.env, "JIRA_BASE_URL").rstrip("/")
81
+
82
+ def _auth(self) -> dict[str, str]:
83
+ raw = required(self.env, "JIRA_EMAIL") + ":" + required(self.env, "JIRA_API_TOKEN")
84
+ return {
85
+ "authorization": "Basic " + base64.b64encode(raw.encode()).decode(),
86
+ "accept": "application/json",
87
+ }
88
+
89
+ async def _json(self, path: str, **kwargs: Any) -> Any:
90
+ text = await self.http.call(path, response_type="text", **kwargs)
91
+ return json.loads(text) if text else {}
92
+
93
+ async def create_issue(self, input: t.CreateIssueInput) -> Any:
94
+ fields: dict[str, Any] = {
95
+ "project": {"key": input["projectKey"]},
96
+ "summary": input["summary"],
97
+ "issuetype": {"name": nullish(input.get("issueType"), "Task")},
98
+ }
99
+ if input.get("labels") is not None:
100
+ fields["labels"] = input["labels"]
101
+ if input.get("description"):
102
+ fields["description"] = text_to_adf(input["description"])
103
+ data = await self._json("/issue", method="POST", body={"fields": fields})
104
+ id = js_string(data, "id")
105
+ key = js_string(data, "key")
106
+ return {"id": id, "key": key, "url": self.base_url() + "/browse/" + key}
107
+
108
+ async def transition(self, input: t.TransitionInput) -> Any:
109
+ path = f"/issue/{enc(input['issueKey'])}/transitions"
110
+ data = await self._json(path)
111
+ match = next(
112
+ (
113
+ r
114
+ for r in nullish(data.get("transitions"), [])
115
+ if r["id"] == input["to"] or r["name"].lower() == input["to"].lower()
116
+ ),
117
+ None,
118
+ )
119
+ await self.http.call(
120
+ path,
121
+ method="POST",
122
+ body={"transition": {"id": match["id"] if match is not None else input["to"]}},
123
+ response_type="text",
124
+ )
125
+ return pick(input, "issueKey", "to")
126
+
127
+ async def comment(self, input: t.CommentInput) -> Any:
128
+ data = await self._json(
129
+ f"/issue/{enc(input['issueKey'])}/comment",
130
+ method="POST",
131
+ body={"body": text_to_adf(input["body"])},
132
+ )
133
+ return {"issueKey": input["issueKey"], "commentId": js_string(data, "id")}
134
+
135
+ async def jql(self, input: t.JqlInput) -> Any:
136
+ limit = nullish(input.get("limit"), 50)
137
+ if (
138
+ isinstance(limit, bool)
139
+ or not isinstance(limit, (int, float))
140
+ or not math.isfinite(limit)
141
+ or limit < 0
142
+ or int(limit) != limit
143
+ ):
144
+ raise ValueError("limit must be a non-negative integer")
145
+ if limit == 0:
146
+ return []
147
+ data = await self._json(
148
+ "/search/jql",
149
+ method="POST",
150
+ body={
151
+ "jql": input["jql"],
152
+ "maxResults": int(limit),
153
+ "fields": ["summary", "status"],
154
+ },
155
+ )
156
+ return [
157
+ pick(to_issue(r, self.base_url()), "key", "summary", "status", "url")
158
+ for r in nullish(data.get("issues"), [])
159
+ ]
160
+
161
+ async def get_issue(self, input: t.GetIssueInput) -> Any:
162
+ return to_issue(await self._json(f"/issue/{enc(input['issueKey'])}"), self.base_url())
163
+
164
+ async def update_issue(self, input: t.UpdateIssueInput) -> Any:
165
+ await self.http.call(
166
+ f"/issue/{enc(input['issueKey'])}",
167
+ method="PUT",
168
+ body={"fields": input["fields"]},
169
+ response_type="text",
170
+ )
171
+ return {"key": input["issueKey"], "updated": True}
172
+
173
+ async def assign_issue(self, input: t.AssignIssueInput) -> Any:
174
+ await self.http.call(
175
+ f"/issue/{enc(input['issueKey'])}/assignee",
176
+ method="PUT",
177
+ body={"accountId": input["accountId"]},
178
+ response_type="text",
179
+ )
180
+ return {"key": input["issueKey"], "assigned": True}
181
+
182
+ async def list_transitions(self, input: t.ListTransitionsInput) -> Any:
183
+ data = await self._json(f"/issue/{enc(input['issueKey'])}/transitions")
184
+ return [
185
+ {
186
+ "id": js_string(r, "id"),
187
+ "name": js_string(r, "name"),
188
+ "toStatus": nullish((r.get("to") or {}).get("name"), ""),
189
+ }
190
+ for r in nullish(data.get("transitions"), [])
191
+ ]
192
+
193
+ async def link_issues(self, input: t.LinkIssuesInput) -> Any:
194
+ await self.http.call(
195
+ "/issueLink",
196
+ method="POST",
197
+ body={
198
+ "type": {"name": input["type"]},
199
+ "inwardIssue": {"key": input["inwardIssue"]},
200
+ "outwardIssue": {"key": input["outwardIssue"]},
201
+ },
202
+ response_type="text",
203
+ )
204
+ return {"linked": True}
205
+
206
+ async def add_attachment(self, input: t.AddAttachmentInput) -> Any:
207
+ filename = input["filename"]
208
+ if any(c in filename for c in ("\r", "\n", '"')):
209
+ raise ValueError("filename must not contain CR, LF, or quotes")
210
+ boundary = "----renderTasksJira" + uuid.uuid4().hex
211
+ raw = (
212
+ f"--{boundary}\r\n"
213
+ f'Content-Disposition: form-data; name="file"; filename="{filename}"\r\n'
214
+ "Content-Type: application/octet-stream\r\n\r\n"
215
+ + input["content"]
216
+ + f"\r\n--{boundary}--\r\n"
217
+ )
218
+ data = await self.http.call(
219
+ f"/issue/{enc(input['issueKey'])}/attachments",
220
+ method="POST",
221
+ raw_body=raw,
222
+ headers={
223
+ "content-type": f"multipart/form-data; boundary={boundary}",
224
+ "X-Atlassian-Token": "no-check",
225
+ },
226
+ )
227
+ first = (data[0] if data else {}) if isinstance(data, list) else data or {}
228
+ return {"id": js_string(first, "id"), "filename": js_string(first, "filename")}
229
+
230
+
231
+ @asynccontextmanager
232
+ async def dependencies(deps: Deps | None) -> AsyncIterator[Deps]:
233
+ if deps is not None:
234
+ yield deps
235
+ else:
236
+ async with httpx.AsyncClient(
237
+ timeout=30, transport=httpx.AsyncHTTPTransport(retries=0)
238
+ ) as http:
239
+ yield Deps(jira=Client(http))
240
+
241
+
242
+ JiraPort = Port
243
+ JiraClient = Client
244
+ JiraDeps = Deps
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import CommentInput, CommentResult
7
+
8
+
9
+ async def comment_impl(
10
+ ctx: TaskContext, input: CommentInput, *, deps: Deps | None = None
11
+ ) -> CommentResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.comment(input)
14
+
15
+
16
+ @app.task(name="jira.comment", retry=JIRA_RETRY)
17
+ async def comment(ctx: TaskContext, input: CommentInput) -> CommentResult:
18
+ return await comment_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import CreateIssueInput, CreateIssueResult
7
+
8
+
9
+ async def create_issue_impl(
10
+ ctx: TaskContext, input: CreateIssueInput, *, deps: Deps | None = None
11
+ ) -> CreateIssueResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.create_issue(input)
14
+
15
+
16
+ @app.task(name="jira.createIssue", retry=JIRA_RETRY)
17
+ async def create_issue(ctx: TaskContext, input: CreateIssueInput) -> CreateIssueResult:
18
+ return await create_issue_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import GetIssueInput, JiraIssueDetail
7
+
8
+
9
+ async def get_issue_impl(
10
+ ctx: TaskContext, input: GetIssueInput, *, deps: Deps | None = None
11
+ ) -> JiraIssueDetail:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.get_issue(input)
14
+
15
+
16
+ @app.task(name="jira.getIssue", retry=JIRA_RETRY)
17
+ async def get_issue(ctx: TaskContext, input: GetIssueInput) -> JiraIssueDetail:
18
+ return await get_issue_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import JiraIssue, JqlInput
7
+
8
+
9
+ async def jql_impl(
10
+ ctx: TaskContext, input: JqlInput, *, deps: Deps | None = None
11
+ ) -> list[JiraIssue]:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.jql(input)
14
+
15
+
16
+ @app.task(name="jira.jql", retry=JIRA_RETRY)
17
+ async def jql(ctx: TaskContext, input: JqlInput) -> list[JiraIssue]:
18
+ return await jql_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import LinkIssuesInput, LinkIssuesResult
7
+
8
+
9
+ async def link_issues_impl(
10
+ ctx: TaskContext, input: LinkIssuesInput, *, deps: Deps | None = None
11
+ ) -> LinkIssuesResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.link_issues(input)
14
+
15
+
16
+ @app.task(name="jira.linkIssues", retry=JIRA_RETRY)
17
+ async def link_issues(ctx: TaskContext, input: LinkIssuesInput) -> LinkIssuesResult:
18
+ return await link_issues_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import JiraTransition, ListTransitionsInput
7
+
8
+
9
+ async def list_transitions_impl(
10
+ ctx: TaskContext, input: ListTransitionsInput, *, deps: Deps | None = None
11
+ ) -> list[JiraTransition]:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.list_transitions(input)
14
+
15
+
16
+ @app.task(name="jira.listTransitions", retry=JIRA_RETRY)
17
+ async def list_transitions(ctx: TaskContext, input: ListTransitionsInput) -> list[JiraTransition]:
18
+ return await list_transitions_impl(ctx, input)
@@ -0,0 +1,3 @@
1
+ from render import Retry
2
+
3
+ JIRA_RETRY = Retry(max_retries=3, wait_duration_ms=1000, backoff_scaling=2)
@@ -0,0 +1,35 @@
1
+ from ._app import app
2
+ from .add_attachment import add_attachment, add_attachment_impl
3
+ from .assign_issue import assign_issue, assign_issue_impl
4
+ from .comment import comment, comment_impl
5
+ from .create_issue import create_issue, create_issue_impl
6
+ from .get_issue import get_issue, get_issue_impl
7
+ from .jql import jql, jql_impl
8
+ from .link_issues import link_issues, link_issues_impl
9
+ from .list_transitions import list_transitions, list_transitions_impl
10
+ from .transition import transition, transition_impl
11
+ from .update_issue import update_issue, update_issue_impl
12
+
13
+ __all__ = [
14
+ "app",
15
+ "add_attachment",
16
+ "add_attachment_impl",
17
+ "assign_issue",
18
+ "assign_issue_impl",
19
+ "comment",
20
+ "comment_impl",
21
+ "create_issue",
22
+ "create_issue_impl",
23
+ "get_issue",
24
+ "get_issue_impl",
25
+ "jql",
26
+ "jql_impl",
27
+ "link_issues",
28
+ "link_issues_impl",
29
+ "list_transitions",
30
+ "list_transitions_impl",
31
+ "transition",
32
+ "transition_impl",
33
+ "update_issue",
34
+ "update_issue_impl",
35
+ ]
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import TransitionInput, TransitionResult
7
+
8
+
9
+ async def transition_impl(
10
+ ctx: TaskContext, input: TransitionInput, *, deps: Deps | None = None
11
+ ) -> TransitionResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.transition(input)
14
+
15
+
16
+ @app.task(name="jira.transition", retry=JIRA_RETRY)
17
+ async def transition(ctx: TaskContext, input: TransitionInput) -> TransitionResult:
18
+ return await transition_impl(ctx, input)
@@ -0,0 +1,117 @@
1
+ """JSON contracts ported from the pinned TypeScript pack."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, NotRequired, TypedDict
6
+
7
+ type Json = str | float | bool | None | list[Json] | dict[str, Json]
8
+
9
+
10
+ class JiraIssue(TypedDict):
11
+ key: str
12
+ summary: str
13
+ status: str
14
+ url: str
15
+
16
+
17
+ class CreateIssueInput(TypedDict):
18
+ projectKey: str
19
+ summary: str
20
+ description: NotRequired[str]
21
+ issueType: NotRequired[str]
22
+ labels: NotRequired[list[str]]
23
+
24
+
25
+ class CreateIssueResult(TypedDict):
26
+ id: str
27
+ key: str
28
+ url: str
29
+
30
+
31
+ class TransitionInput(TypedDict):
32
+ issueKey: str
33
+ to: str
34
+
35
+
36
+ class TransitionResult(TypedDict):
37
+ issueKey: str
38
+ to: str
39
+
40
+
41
+ class CommentInput(TypedDict):
42
+ issueKey: str
43
+ body: str
44
+
45
+
46
+ class CommentResult(TypedDict):
47
+ issueKey: str
48
+ commentId: str
49
+
50
+
51
+ class JqlInput(TypedDict):
52
+ jql: str
53
+ limit: NotRequired[float]
54
+
55
+
56
+ class JiraIssueDetail(TypedDict):
57
+ key: str
58
+ summary: str
59
+ status: str
60
+ assignee: str | None
61
+ issueType: str
62
+ url: str
63
+
64
+
65
+ class GetIssueInput(TypedDict):
66
+ issueKey: str
67
+
68
+
69
+ class UpdateIssueInput(TypedDict):
70
+ issueKey: str
71
+ fields: dict[str, Json]
72
+
73
+
74
+ class UpdateIssueResult(TypedDict):
75
+ key: str
76
+ updated: Literal[True]
77
+
78
+
79
+ class AssignIssueInput(TypedDict):
80
+ issueKey: str
81
+ accountId: str
82
+
83
+
84
+ class AssignIssueResult(TypedDict):
85
+ key: str
86
+ assigned: Literal[True]
87
+
88
+
89
+ class ListTransitionsInput(TypedDict):
90
+ issueKey: str
91
+
92
+
93
+ class JiraTransition(TypedDict):
94
+ id: str
95
+ name: str
96
+ toStatus: str
97
+
98
+
99
+ class LinkIssuesInput(TypedDict):
100
+ type: str
101
+ inwardIssue: str
102
+ outwardIssue: str
103
+
104
+
105
+ class LinkIssuesResult(TypedDict):
106
+ linked: Literal[True]
107
+
108
+
109
+ class AddAttachmentInput(TypedDict):
110
+ issueKey: str
111
+ filename: str
112
+ content: str
113
+
114
+
115
+ class AddAttachmentResult(TypedDict):
116
+ id: str
117
+ filename: str
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import JIRA_RETRY
6
+ from .types import UpdateIssueInput, UpdateIssueResult
7
+
8
+
9
+ async def update_issue_impl(
10
+ ctx: TaskContext, input: UpdateIssueInput, *, deps: Deps | None = None
11
+ ) -> UpdateIssueResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.jira.update_issue(input)
14
+
15
+
16
+ @app.task(name="jira.updateIssue", retry=JIRA_RETRY)
17
+ async def update_issue(ctx: TaskContext, input: UpdateIssueInput) -> UpdateIssueResult:
18
+ return await update_issue_impl(ctx, input)
@@ -0,0 +1,8 @@
1
+ import pytest
2
+
3
+ from tests.batch_contracts import check_fixture, fixtures
4
+
5
+
6
+ @pytest.mark.parametrize("case", fixtures("jira"))
7
+ async def test_ts_contract(case, ctx, monkeypatch):
8
+ await check_fixture(case, ctx, monkeypatch)
@@ -0,0 +1,61 @@
1
+ import json
2
+
3
+ import httpx
4
+ import pytest
5
+ from render_lab_tasks_jira.client import Client
6
+
7
+ ENV = {
8
+ "JIRA_BASE_URL": "https://example.atlassian.net",
9
+ "JIRA_EMAIL": "test@example.test",
10
+ "JIRA_API_TOKEN": "test-token",
11
+ }
12
+
13
+
14
+ @pytest.mark.parametrize("limit", [None, 3.0])
15
+ async def test_enhanced_search_requests_dto_fields_and_only_one_page(limit):
16
+ requests = []
17
+
18
+ async def handle(request):
19
+ requests.append(request)
20
+ return httpx.Response(
21
+ 200,
22
+ json={
23
+ "issues": [
24
+ {"key": "TEST-1", "fields": {"summary": "Title", "status": {"name": "Open"}}}
25
+ ],
26
+ "isLast": False,
27
+ "nextPageToken": "unused",
28
+ },
29
+ )
30
+
31
+ async with httpx.AsyncClient(transport=httpx.MockTransport(handle)) as http:
32
+ result = await Client(http, ENV).jql({"jql": "project=TEST", "limit": limit})
33
+ assert result == [
34
+ {
35
+ "key": "TEST-1",
36
+ "summary": "Title",
37
+ "status": "Open",
38
+ "url": "https://example.atlassian.net/browse/TEST-1",
39
+ }
40
+ ]
41
+ assert len(requests) == 1
42
+ request = requests[0]
43
+ assert request.method == "POST"
44
+ assert str(request.url) == "https://example.atlassian.net/rest/api/3/search/jql"
45
+ assert json.loads(request.content) == {
46
+ "jql": "project=TEST",
47
+ "maxResults": 50 if limit is None else 3,
48
+ "fields": ["summary", "status"],
49
+ }
50
+
51
+
52
+ @pytest.mark.parametrize("limit", [-1, 1.5, True, "5", float("inf"), float("nan")])
53
+ async def test_invalid_limit_fails_before_credentials_or_http(limit):
54
+ async with httpx.AsyncClient() as http:
55
+ with pytest.raises(ValueError, match="non-negative integer"):
56
+ await Client(http, {}).jql({"jql": "project=TEST", "limit": limit})
57
+
58
+
59
+ async def test_zero_limit_needs_no_credentials():
60
+ async with httpx.AsyncClient() as http:
61
+ assert await Client(http, {}).jql({"jql": "project=TEST", "limit": 0}) == []