dex-connector-linear 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-linear
3
+ Version: 0.1.0
4
+ Summary: Dex-native Linear connector
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: dex-connectors-sdk==0.7.0
9
+ Requires-Dist: dex-python-sdk>=1.28.0
10
+ Requires-Dist: httpx>=0.27
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Linear Python connector
14
+
15
+ `dex-connector-linear` provides seven operation-specific Dex Steps for Linear:
16
+ `searchIssues`, `getIssue`, `createIssue`, `updateIssue`, `addComment`,
17
+ `findUserByEmail`, and `listWorkflowStates`. The signed Issue webhook Trigger
18
+ remains Go-only. Python requires `dex-connectors-sdk==0.5.0` and Dex Python SDK
19
+ 1.28.0 or newer.
20
+
21
+ The generated project connection supports the manifest's personal API key and
22
+ Linear OAuth methods. OAuth access tokens refresh before expiry and once after
23
+ an HTTP 401 through the generated connection and SDK credential source. Shared
24
+ connections do not expose the client secret or refresh token to applications.
25
+ Configure credentials in Dex Web **Connections**; never place them in Flow
26
+ input or persisted values. See the [Linear setup guide](../README.md#linear-setup)
27
+ for provider application pages, scopes, and credential fields.
28
+
29
+ The [workflow-state example](examples/list_workflow_states) is the runnable
30
+ consuming application. It uses the static connection `linear` and only wires
31
+ the `listed` branch. Other branches fail the Flow. Its real Dex integration
32
+ test exercises a 429 retry, result persistence, and an unwired rejection with an
33
+ inert provider stand-in. The 54 provider replay scenarios compare Python
34
+ requests and outcomes to Go recordings. Live Linear behavior and OAuth consent
35
+ were not verified for this Python port.
36
+
37
+ ```sh
38
+ uv sync --locked
39
+ uv run pytest
40
+ uv run ruff check src tests examples
41
+ uv run mypy src/dex_connectors/linear
42
+ ```
@@ -0,0 +1,24 @@
1
+ dex_connectors/linear/__init__.py,sha256=DYuNBNHOJAdM-fRFloSD3nyusuQy1cI0l-ERjDc-zGI,2391
2
+ dex_connectors/linear/client.py,sha256=N33wE5LZy7_7nMyrsoaW6hDq-Jt7exu8ApYsM1Q7BRY,18013
3
+ dex_connectors/linear/connection.py,sha256=Kq376pQTJUpcsX76PUFdsX03Gt-BiYL1UrubS_s0Igc,190
4
+ dex_connectors/linear/dex-connector.json,sha256=Csez9fkxuTwCvVvFhvf8u5yjacxdS3iFfC0gdyD4WzQ,5989
5
+ dex_connectors/linear/documents.py,sha256=tl31JkbZBDU3bDZEPOhOD2-vykRuq1V13OAJrCmU3R4,2890
6
+ dex_connectors/linear/models.py,sha256=eCXoUJ1nrmiGHBQw7P8AFC7spCVRNqyJ5EZAhGKkR5Y,164
7
+ dex_connectors/linear/operations.py,sha256=F5gwa2aRIYlte0788w8gqpPUHbvoPoNZ5nXFrCkQcjk,38118
8
+ dex_connectors/linear/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ dex_connectors/linear/steps.py,sha256=ODcflmoYdBt5d1WAq5VR6Ey7XCX1k-uDEsDFIDb-cO8,171
10
+ dex_connectors/linear/wire.py,sha256=itNWrvnWuWm8505bDaXEIBpBqQYWjPQ7UQ0gAMu7LrI,12580
11
+ dex_connectors/linear/_generated/__init__.py,sha256=ShfMsAGzSt4xuhCaf20ibgtfXl4pXomZb00ovUw6CeI,66
12
+ dex_connectors/linear/_generated/config.py,sha256=KC1Q67jNssow-9NztsnBGNNcub08_MRAYpHB0H_i1KY,860
13
+ dex_connectors/linear/_generated/connection.py,sha256=Nd8ODe15RtcS2EocSpx5-yUL5Pyb4_T97h_iK7JkvLk,15149
14
+ dex_connectors/linear/_generated/definitions.py,sha256=2vejvIDy79bRUNfqaJp0PXYWIN0UUggj1yUjx9V8qKA,6659
15
+ dex_connectors/linear/_generated/mock.py,sha256=an0EiMd4_bduQ3GQ015OfytNloj-fdrnQ7wlRqaPTT8,26826
16
+ dex_connectors/linear/_generated/models.py,sha256=QVUNXh0zPEIGsPz8DuaRYd54iwTk_aKeS2yJGhwrigA,30337
17
+ dex_connectors/linear/_generated/refresh.py,sha256=cxItaTEOZzxt6zXhlH_O7E3MgUmVKkpK6xzV2nnc8ZM,1680
18
+ dex_connectors/linear/_generated/steps.py,sha256=tqvxauGGr1t9P5tlVS-Yj9d9w16UXBuukXztNhJTm_A,18227
19
+ dex_connectors/linear/_generated/timestamps.py,sha256=Z8VwrE60w-33InIMgEMLiMPTFyRjj6oBq8tUro8Ssi8,3164
20
+ dex_connectors/linear/linearmock/__init__.py,sha256=sEODfqQ6BJ0_cxRmH7FUHlzuhGC26jntpGD0cmUtm_U,167
21
+ dex_connector_linear-0.1.0.dist-info/METADATA,sha256=_199sNPGlTQXC_Xxhi5_vrIN8kGer6qITiUV2_KSRzA,1827
22
+ dex_connector_linear-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
23
+ dex_connector_linear-0.1.0.dist-info/licenses/LICENSE,sha256=WNj87Zd5micrAShl1LujOPM6PDzDqjlNLrryDZ4hE0M,1070
24
+ dex_connector_linear-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
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,98 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Linear Queries and Mutations for Dex Flows."""
4
+
5
+ from .client import Client, Config, Credentials
6
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
7
+ from .models import (
8
+ AddCommentInput,
9
+ AddCommentOutput,
10
+ CreateIssueInput,
11
+ CreateIssueOutput,
12
+ CycleReference,
13
+ FindUserByEmailInput,
14
+ GetIssueInput,
15
+ Issue,
16
+ IssueLabel,
17
+ IssueReference,
18
+ IssueSearchFilter,
19
+ IssueSummary,
20
+ ListWorkflowStatesInput,
21
+ ListWorkflowStatesOutput,
22
+ ProjectReference,
23
+ SearchIssuesInput,
24
+ SearchIssuesOutput,
25
+ TeamReference,
26
+ UpdateIssueInput,
27
+ UpdateIssueOutput,
28
+ User,
29
+ UserReference,
30
+ WorkflowState,
31
+ WorkflowStateReference,
32
+ )
33
+ from .operations import (
34
+ AddCommentOperation,
35
+ CreateIssueOperation,
36
+ FindUserByEmailOperation,
37
+ GetIssueOperation,
38
+ ListWorkflowStatesOperation,
39
+ SearchIssuesOperation,
40
+ UpdateIssueOperation,
41
+ )
42
+ from .steps import (
43
+ new_add_comment_step,
44
+ new_create_issue_step,
45
+ new_find_user_by_email_step,
46
+ new_get_issue_step,
47
+ new_list_workflow_states_step,
48
+ new_search_issues_step,
49
+ new_update_issue_step,
50
+ )
51
+
52
+ __all__ = [
53
+ "AddCommentInput",
54
+ "AddCommentOperation",
55
+ "AddCommentOutput",
56
+ "Client",
57
+ "Config",
58
+ "Connection",
59
+ "CreateIssueInput",
60
+ "CreateIssueOperation",
61
+ "CreateIssueOutput",
62
+ "Credentials",
63
+ "CycleReference",
64
+ "FindUserByEmailInput",
65
+ "FindUserByEmailOperation",
66
+ "GetIssueInput",
67
+ "GetIssueOperation",
68
+ "Issue",
69
+ "IssueLabel",
70
+ "IssueReference",
71
+ "IssueSearchFilter",
72
+ "IssueSummary",
73
+ "ListWorkflowStatesInput",
74
+ "ListWorkflowStatesOperation",
75
+ "ListWorkflowStatesOutput",
76
+ "ProjectReference",
77
+ "SearchIssuesInput",
78
+ "SearchIssuesOperation",
79
+ "SearchIssuesOutput",
80
+ "TeamReference",
81
+ "UpdateIssueInput",
82
+ "UpdateIssueOperation",
83
+ "UpdateIssueOutput",
84
+ "User",
85
+ "UserReference",
86
+ "WorkflowState",
87
+ "WorkflowStateReference",
88
+ "new_add_comment_step",
89
+ "new_connection",
90
+ "new_connection_with_operations",
91
+ "new_create_issue_step",
92
+ "new_find_user_by_email_step",
93
+ "new_get_issue_step",
94
+ "new_list_workflow_states_step",
95
+ "new_project_connection",
96
+ "new_search_issues_step",
97
+ "new_update_issue_step",
98
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,31 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from dex_connectors.sdk import SecretString
8
+
9
+
10
+ @dataclass(frozen=True, slots=True)
11
+ class Config:
12
+
13
+ max_response_bytes: int = 4194304
14
+ webhook_max_body_bytes: int = 1048576
15
+ webhook_signature_tolerance_seconds: float = 60
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.linear.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ auth_method_id: str = "personal-api-key"
24
+ api_key: SecretString | None = None
25
+ webhook_signing_secret: SecretString = SecretString('')
26
+ oauth_client_id: str | None = None
27
+ oauth_client_secret: SecretString | None = None
28
+ access_token: SecretString | None = None
29
+ refresh_token: SecretString | None = None
30
+
31
+ setattr(Credentials, '__module__', 'dex_connectors.linear.client')
@@ -0,0 +1,268 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+ from dex_connectors.sdk import ConnectionRef, Mutation, Query, Call, SecretString, CredentialRefreshDriver
9
+ from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
10
+ from dex_connectors.sdk.projectconfig.provider import RefreshingCredentialProvider
11
+ from dex_connectors.sdk.oauthtoken import ManifestCredentialRefreshDriver
12
+
13
+ from ..client import Client, Config, Credentials
14
+ from .definitions import CONNECTOR_ID, ADD_COMMENT_DEFINITION, CREATE_ISSUE_DEFINITION, FIND_USER_BY_EMAIL_DEFINITION, GET_ISSUE_DEFINITION, LIST_WORKFLOW_STATES_DEFINITION, SEARCH_ISSUES_DEFINITION, UPDATE_ISSUE_DEFINITION
15
+ from .refresh import AUTHORIZATION, CREDENTIAL_FIELDS
16
+ from ..models import AddCommentInput, AddCommentOutput, CreateIssueInput, CreateIssueOutput, FindUserByEmailInput, GetIssueInput, Issue, ListWorkflowStatesInput, ListWorkflowStatesOutput, SearchIssuesInput, SearchIssuesOutput, UpdateIssueInput, UpdateIssueOutput, User
17
+
18
+ class Connection:
19
+
20
+ __slots__ = ('_search_issues', '_get_issue', '_create_issue', '_update_issue', '_add_comment', '_find_user_by_email', '_list_workflow_states', '_client', 'reference')
21
+
22
+ def __init__(self,
23
+ reference: ConnectionRef,
24
+ search_issues: Query[SearchIssuesInput, SearchIssuesOutput],
25
+ get_issue: Query[GetIssueInput, Issue],
26
+ create_issue: Mutation[CreateIssueInput, CreateIssueOutput],
27
+ update_issue: Mutation[UpdateIssueInput, UpdateIssueOutput],
28
+ add_comment: Mutation[AddCommentInput, AddCommentOutput],
29
+ find_user_by_email: Query[FindUserByEmailInput, User],
30
+ list_workflow_states: Query[ListWorkflowStatesInput, ListWorkflowStatesOutput],
31
+ client: Client | None = None,
32
+ ) -> None:
33
+ reference.validate()
34
+ if reference.provider != CONNECTOR_ID or search_issues is None or get_issue is None or create_issue is None or update_issue is None or add_comment is None or find_user_by_email is None or list_workflow_states is None:
35
+ raise ValueError("Linear connection provider and operations are required")
36
+ if search_issues.definition().operation != SEARCH_ISSUES_DEFINITION.operation:
37
+ raise ValueError("Linear connection operation identity differs")
38
+ if get_issue.definition().operation != GET_ISSUE_DEFINITION.operation:
39
+ raise ValueError("Linear connection operation identity differs")
40
+ if create_issue.definition().operation != CREATE_ISSUE_DEFINITION.operation:
41
+ raise ValueError("Linear connection operation identity differs")
42
+ if update_issue.definition().operation != UPDATE_ISSUE_DEFINITION.operation:
43
+ raise ValueError("Linear connection operation identity differs")
44
+ if add_comment.definition().operation != ADD_COMMENT_DEFINITION.operation:
45
+ raise ValueError("Linear connection operation identity differs")
46
+ if find_user_by_email.definition().operation != FIND_USER_BY_EMAIL_DEFINITION.operation:
47
+ raise ValueError("Linear connection operation identity differs")
48
+ if list_workflow_states.definition().operation != LIST_WORKFLOW_STATES_DEFINITION.operation:
49
+ raise ValueError("Linear connection operation identity differs")
50
+ self.reference = reference
51
+ self._search_issues = search_issues
52
+ self._get_issue = get_issue
53
+ self._create_issue = create_issue
54
+ self._update_issue = update_issue
55
+ self._add_comment = add_comment
56
+ self._find_user_by_email = find_user_by_email
57
+ self._list_workflow_states = list_workflow_states
58
+ self._client = client
59
+
60
+ def search_issues(self) -> Query[SearchIssuesInput, SearchIssuesOutput]:
61
+ return self._search_issues
62
+
63
+ def get_issue(self) -> Query[GetIssueInput, Issue]:
64
+ return self._get_issue
65
+
66
+ def create_issue(self) -> Mutation[CreateIssueInput, CreateIssueOutput]:
67
+ return self._create_issue
68
+
69
+ def update_issue(self) -> Mutation[UpdateIssueInput, UpdateIssueOutput]:
70
+ return self._update_issue
71
+
72
+ def add_comment(self) -> Mutation[AddCommentInput, AddCommentOutput]:
73
+ return self._add_comment
74
+
75
+ def find_user_by_email(self) -> Query[FindUserByEmailInput, User]:
76
+ return self._find_user_by_email
77
+
78
+ def list_workflow_states(self) -> Query[ListWorkflowStatesInput, ListWorkflowStatesOutput]:
79
+ return self._list_workflow_states
80
+
81
+ async def aclose(self) -> None:
82
+ if self._client is not None:
83
+ await self._client.aclose()
84
+
85
+ def __repr__(self) -> str:
86
+ return "linear.Connection([REDACTED])"
87
+
88
+ def __reduce__(self) -> tuple[object, ...]:
89
+ raise TypeError("Linear connections cannot be serialized")
90
+
91
+ setattr(Connection, '__module__', 'dex_connectors.linear.connection')
92
+
93
+
94
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
95
+ if client is None:
96
+ raise ValueError("Linear client is required")
97
+ return Connection(reference, client.search_issues(), client.get_issue(), client.create_issue(), client.update_issue(), client.add_comment(), client.find_user_by_email(), client.list_workflow_states(), client)
98
+
99
+ setattr(new_connection, '__module__', 'dex_connectors.linear.connection')
100
+
101
+
102
+ def new_connection_with_operations(
103
+ search_issues: Query[SearchIssuesInput, SearchIssuesOutput],
104
+ get_issue: Query[GetIssueInput, Issue],
105
+ create_issue: Mutation[CreateIssueInput, CreateIssueOutput],
106
+ update_issue: Mutation[UpdateIssueInput, UpdateIssueOutput],
107
+ add_comment: Mutation[AddCommentInput, AddCommentOutput],
108
+ find_user_by_email: Query[FindUserByEmailInput, User],
109
+ list_workflow_states: Query[ListWorkflowStatesInput, ListWorkflowStatesOutput],
110
+ reference: ConnectionRef,
111
+ ) -> Connection:
112
+ return Connection(reference, search_issues, get_issue, create_issue, update_issue, add_comment, find_user_by_email, list_workflow_states)
113
+
114
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.linear.connection')
115
+
116
+
117
+ def decode_credentials(material: dict[str, Any], *, shared: bool = False) -> Credentials:
118
+ if not isinstance(material, dict):
119
+ raise ValueError("Linear stored credential does not match the connector credential fields")
120
+ if set(material) - set(('api_key', 'webhook_signing_secret', 'oauth_client_id', 'oauth_client_secret', 'access_token', 'refresh_token', 'auth_method')):
121
+ raise ValueError("Linear stored credential does not match the connector credential fields")
122
+ is_shared = shared
123
+ api_key = material.get("api_key")
124
+ if api_key is not None and not (isinstance(api_key, str)):
125
+ raise ValueError("Linear credential api_key has an invalid type")
126
+ webhook_signing_secret = material.get("webhook_signing_secret")
127
+ if webhook_signing_secret is not None and not (isinstance(webhook_signing_secret, str)):
128
+ raise ValueError("Linear credential webhook_signing_secret has an invalid type")
129
+ oauth_client_id = material.get("oauth_client_id")
130
+ if oauth_client_id is not None and not (isinstance(oauth_client_id, str)):
131
+ raise ValueError("Linear credential oauth_client_id has an invalid type")
132
+ oauth_client_secret = material.get("oauth_client_secret")
133
+ if oauth_client_secret is not None and not (isinstance(oauth_client_secret, str)):
134
+ raise ValueError("Linear credential oauth_client_secret has an invalid type")
135
+ access_token = material.get("access_token")
136
+ if access_token is not None and not (isinstance(access_token, str)):
137
+ raise ValueError("Linear credential access_token has an invalid type")
138
+ refresh_token = material.get("refresh_token")
139
+ if refresh_token is not None and not (isinstance(refresh_token, str)):
140
+ raise ValueError("Linear credential refresh_token has an invalid type")
141
+ selected_method = material.get('auth_method')
142
+ if selected_method is None:
143
+ selected_method = ''
144
+ if not isinstance(selected_method, str):
145
+ raise ValueError("Linear credential auth_method is invalid")
146
+ method = selected_method or "personal-api-key"
147
+ values: dict[str, Any] = {'auth_method_id': method}
148
+ if method == "personal-api-key":
149
+ if not api_key:
150
+ raise ValueError("Linear credential api_key is required")
151
+ if api_key:
152
+ values["api_key"] = SecretString(api_key)
153
+ values["webhook_signing_secret"] = SecretString(webhook_signing_secret or '')
154
+ elif method == "linear-oauth":
155
+ if not oauth_client_id:
156
+ raise ValueError("Linear credential oauth_client_id is required")
157
+ if oauth_client_id:
158
+ values["oauth_client_id"] = oauth_client_id
159
+ if not oauth_client_secret and not is_shared:
160
+ raise ValueError("Linear credential oauth_client_secret is required")
161
+ if oauth_client_secret:
162
+ values["oauth_client_secret"] = SecretString(oauth_client_secret)
163
+ if not access_token:
164
+ raise ValueError("Linear credential access_token is required")
165
+ if access_token:
166
+ values["access_token"] = SecretString(access_token)
167
+ if not refresh_token and not is_shared:
168
+ raise ValueError("Linear credential refresh_token is required")
169
+ if refresh_token:
170
+ values["refresh_token"] = SecretString(refresh_token)
171
+ values["webhook_signing_secret"] = SecretString(webhook_signing_secret or '')
172
+ else:
173
+ raise ValueError("Linear credential auth_method is invalid")
174
+ return Credentials(**values)
175
+
176
+
177
+ def decode_shared_credentials(material: dict[str, Any]) -> Credentials:
178
+ return decode_credentials(material, shared=True)
179
+
180
+
181
+ def encode_credentials(credentials: Credentials) -> dict[str, Any]:
182
+ material: dict[str, Any] = {}
183
+ method = credentials.auth_method_id or "personal-api-key"
184
+ material['auth_method'] = method
185
+ if method == "personal-api-key":
186
+ if (credentials.api_key.reveal() if credentials.api_key is not None else ''):
187
+ material["api_key"] = (credentials.api_key.reveal() if credentials.api_key is not None else '')
188
+ if (credentials.webhook_signing_secret.reveal() if credentials.webhook_signing_secret is not None else ''):
189
+ material["webhook_signing_secret"] = (credentials.webhook_signing_secret.reveal() if credentials.webhook_signing_secret is not None else '')
190
+ elif method == "linear-oauth":
191
+ if credentials.oauth_client_id:
192
+ material["oauth_client_id"] = credentials.oauth_client_id
193
+ if (credentials.oauth_client_secret.reveal() if credentials.oauth_client_secret is not None else ''):
194
+ material["oauth_client_secret"] = (credentials.oauth_client_secret.reveal() if credentials.oauth_client_secret is not None else '')
195
+ if (credentials.access_token.reveal() if credentials.access_token is not None else ''):
196
+ material["access_token"] = (credentials.access_token.reveal() if credentials.access_token is not None else '')
197
+ if (credentials.refresh_token.reveal() if credentials.refresh_token is not None else ''):
198
+ material["refresh_token"] = (credentials.refresh_token.reveal() if credentials.refresh_token is not None else '')
199
+ if (credentials.webhook_signing_secret.reveal() if credentials.webhook_signing_secret is not None else ''):
200
+ material["webhook_signing_secret"] = (credentials.webhook_signing_secret.reveal() if credentials.webhook_signing_secret is not None else '')
201
+ else:
202
+ raise ValueError("Linear credential auth_method is invalid")
203
+ decode_credentials(material)
204
+ return material
205
+
206
+
207
+ class _ProjectCredentialSource:
208
+ def __init__(self, project: LoadedProject, key: ConnectionKey, http_client: httpx.AsyncClient, settings: dict[str, Any]) -> None:
209
+ self.provider = RefreshingCredentialProvider(
210
+ project.connections, key, decode_credentials, encode_credentials, decode_shared_credentials
211
+ )
212
+ self.driver = ManifestCredentialRefreshDriver[Credentials]("Linear", AUTHORIZATION, CREDENTIAL_FIELDS, http_client, settings=settings)
213
+
214
+ async def resolve(self, call: Call) -> Credentials:
215
+ return await self.provider.resolve_with_refresh(call, self.driver)
216
+
217
+ async def resolve_with_refresh(self, call: Call, driver: CredentialRefreshDriver[Credentials] | None = None) -> Credentials:
218
+ return await self.provider.resolve_with_refresh(call, driver or self.driver)
219
+
220
+ async def resolve_after_rejection(self, call: Call, driver: CredentialRefreshDriver[Credentials] | None = None) -> Credentials:
221
+ return await self.provider.resolve_after_rejection(call, driver or self.driver)
222
+
223
+
224
+ def new_project_connection(
225
+ project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
226
+ ) -> Connection:
227
+ if project is None:
228
+ raise ValueError("Linear connection requires loaded project configuration")
229
+ reference = ConnectionRef(CONNECTOR_ID, connection_name)
230
+ reference.validate()
231
+ key = ConnectionKey(CONNECTOR_ID, connection_name)
232
+ matching = [
233
+ entry
234
+ for entry in project.configuration.connections
235
+ if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
236
+ ]
237
+ if len(matching) != 1:
238
+ raise ValueError("Linear project connection is missing or duplicated")
239
+ if matching[0].provider != CONNECTOR_ID:
240
+ raise ValueError("Linear project connection provider differs")
241
+ config = _decode_config(matching[0].configuration)
242
+ http_client = http_client or httpx.AsyncClient()
243
+ client = Client(config, _ProjectCredentialSource(project, key, http_client, matching[0].configuration), http_client)
244
+ return new_connection(client, reference)
245
+
246
+ setattr(new_project_connection, '__module__', 'dex_connectors.linear.connection')
247
+
248
+
249
+ def _decode_config(value: dict[str, Any]) -> Config:
250
+ if set(value) - {"maxResponseBytes", "webhookMaxBodyBytes", "webhookSignatureTolerance"}:
251
+ raise ValueError("Linear configuration has unknown fields")
252
+ config_arguments: dict[str, Any] = {}
253
+ if "maxResponseBytes" in value:
254
+ max_response_bytes = value["maxResponseBytes"]
255
+ if not (type(max_response_bytes) is int):
256
+ raise ValueError("Linear configuration maxResponseBytes has an invalid type")
257
+ config_arguments['max_response_bytes'] = max_response_bytes
258
+ if "webhookMaxBodyBytes" in value:
259
+ webhook_max_body_bytes = value["webhookMaxBodyBytes"]
260
+ if not (type(webhook_max_body_bytes) is int):
261
+ raise ValueError("Linear configuration webhookMaxBodyBytes has an invalid type")
262
+ config_arguments['webhook_max_body_bytes'] = webhook_max_body_bytes
263
+ if "webhookSignatureTolerance" in value:
264
+ webhook_signature_tolerance = value["webhookSignatureTolerance"]
265
+ if not (type(webhook_signature_tolerance) is int):
266
+ raise ValueError("Linear configuration webhookSignatureTolerance has an invalid type")
267
+ config_arguments['webhook_signature_tolerance_seconds'] = webhook_signature_tolerance / 1_000_000_000
268
+ return Config(**config_arguments)
@@ -0,0 +1,143 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ # ruff: noqa
4
+
5
+ from datetime import timedelta
6
+
7
+ from dex_connectors.sdk import (
8
+ BranchDefinition,
9
+ MutationDefinition,
10
+ OperationRef,
11
+ QueryDefinition,
12
+ RetryPolicy,
13
+ StepDefaults,
14
+ default_connector_step_execute_retry_policy,
15
+ )
16
+
17
+ CONNECTOR_ID = "linear"
18
+ PROVIDER = "linear"
19
+ SEARCH_ISSUES_OPERATION_ID = "searchIssues"
20
+ GET_ISSUE_OPERATION_ID = "getIssue"
21
+ CREATE_ISSUE_OPERATION_ID = "createIssue"
22
+ UPDATE_ISSUE_OPERATION_ID = "updateIssue"
23
+ ADD_COMMENT_OPERATION_ID = "addComment"
24
+ FIND_USER_BY_EMAIL_OPERATION_ID = "findUserByEmail"
25
+ LIST_WORKFLOW_STATES_OPERATION_ID = "listWorkflowStates"
26
+ ADDED = "added"
27
+ CREATED = "created"
28
+ DEFECT = "defect"
29
+ FOUND = "found"
30
+ INVALID_RESPONSE = "invalidResponse"
31
+ LISTED = "listed"
32
+ NOT_FOUND = "notFound"
33
+ PROVIDER_REJECTED = "providerRejected"
34
+ SEARCHED = "searched"
35
+ UPDATED = "updated"
36
+
37
+ SEARCH_ISSUES_DEFINITION = QueryDefinition(
38
+ OperationRef(CONNECTOR_ID, SEARCH_ISSUES_OPERATION_ID),
39
+ (
40
+ BranchDefinition(SEARCHED, "One page of matching issue summaries was read; it can be empty.", False),
41
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the search, such as an invalid cursor, missing team access, or a rejected credential.", True),
42
+ BranchDefinition(INVALID_RESPONSE, "Linear returned an invalid or oversized page of issues.", True),
43
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
44
+ ),
45
+ StepDefaults(
46
+ timedelta(seconds=30),
47
+ 2,
48
+ execute_retry=default_connector_step_execute_retry_policy(),
49
+ ),
50
+ )
51
+
52
+ GET_ISSUE_DEFINITION = QueryDefinition(
53
+ OperationRef(CONNECTOR_ID, GET_ISSUE_OPERATION_ID),
54
+ (
55
+ BranchDefinition(FOUND, "The issue was read.", False),
56
+ BranchDefinition(NOT_FOUND, "The issue does not exist, was deleted, or the connection cannot see its team.", True),
57
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the issue read.", True),
58
+ BranchDefinition(INVALID_RESPONSE, "Linear returned an invalid or oversized issue.", True),
59
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
60
+ ),
61
+ StepDefaults(
62
+ timedelta(seconds=30),
63
+ 2,
64
+ execute_retry=default_connector_step_execute_retry_policy(),
65
+ ),
66
+ )
67
+
68
+ CREATE_ISSUE_DEFINITION = MutationDefinition(
69
+ OperationRef(CONNECTOR_ID, CREATE_ISSUE_OPERATION_ID),
70
+ (
71
+ BranchDefinition(CREATED, "Linear created the issue, or an earlier attempt of this Step already had, and the issue was read.", False),
72
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the issue, such as an unknown team, a workflow state or label of another team, or missing permission; unless Linear rejected the credential or permission, a read-back by the Step's UUID found no issue.", True),
73
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
74
+ ),
75
+ StepDefaults(
76
+ timedelta(seconds=30),
77
+ 2,
78
+ execute_retry=default_connector_step_execute_retry_policy(),
79
+ ),
80
+ )
81
+
82
+ UPDATE_ISSUE_DEFINITION = MutationDefinition(
83
+ OperationRef(CONNECTOR_ID, UPDATE_ISSUE_OPERATION_ID),
84
+ (
85
+ BranchDefinition(UPDATED, "Linear applied the change and returned the issue.", False),
86
+ BranchDefinition(NOT_FOUND, "The issue does not exist, was deleted, or the connection cannot see its team; nothing was changed.", True),
87
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the change, such as a workflow state or label of another team, an unknown assignee, or missing permission.", True),
88
+ BranchDefinition(INVALID_RESPONSE, "Linear returned an invalid or oversized issue, so the change may have been applied; repeating the Step is safe.", True),
89
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
90
+ ),
91
+ StepDefaults(
92
+ timedelta(seconds=30),
93
+ 2,
94
+ execute_retry=default_connector_step_execute_retry_policy(),
95
+ ),
96
+ )
97
+
98
+ ADD_COMMENT_DEFINITION = MutationDefinition(
99
+ OperationRef(CONNECTOR_ID, ADD_COMMENT_OPERATION_ID),
100
+ (
101
+ BranchDefinition(ADDED, "Linear added the comment, or an earlier attempt of this Step already had, and the comment was read.", False),
102
+ BranchDefinition(NOT_FOUND, "The issue does not exist, was deleted, or the connection cannot see its team; nothing was added.", True),
103
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the comment, such as missing permission; unless Linear rejected the credential or permission, a read-back by the Step's UUID found no comment.", True),
104
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
105
+ ),
106
+ StepDefaults(
107
+ timedelta(seconds=30),
108
+ 2,
109
+ execute_retry=default_connector_step_execute_retry_policy(),
110
+ ),
111
+ )
112
+
113
+ FIND_USER_BY_EMAIL_DEFINITION = QueryDefinition(
114
+ OperationRef(CONNECTOR_ID, FIND_USER_BY_EMAIL_OPERATION_ID),
115
+ (
116
+ BranchDefinition(FOUND, "The user was found.", False),
117
+ BranchDefinition(NOT_FOUND, "No user of the workspace has the email, or the user is disabled and disabled users were not requested.", True),
118
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the user lookup.", True),
119
+ BranchDefinition(INVALID_RESPONSE, "Linear returned an invalid or oversized user list.", True),
120
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
121
+ ),
122
+ StepDefaults(
123
+ timedelta(seconds=30),
124
+ 2,
125
+ execute_retry=default_connector_step_execute_retry_policy(),
126
+ ),
127
+ )
128
+
129
+ LIST_WORKFLOW_STATES_DEFINITION = QueryDefinition(
130
+ OperationRef(CONNECTOR_ID, LIST_WORKFLOW_STATES_OPERATION_ID),
131
+ (
132
+ BranchDefinition(LISTED, "The team's workflow states were read.", False),
133
+ BranchDefinition(NOT_FOUND, "The team does not exist or the connection cannot see it.", True),
134
+ BranchDefinition(PROVIDER_REJECTED, "Linear conclusively rejected the read.", True),
135
+ BranchDefinition(INVALID_RESPONSE, "Linear returned an invalid or oversized list of workflow states.", True),
136
+ BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
137
+ ),
138
+ StepDefaults(
139
+ timedelta(seconds=30),
140
+ 2,
141
+ execute_retry=default_connector_step_execute_retry_policy(),
142
+ ),
143
+ )