dex-connector-linear 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.
- dex_connector_linear-0.1.0/.gitignore +16 -0
- dex_connector_linear-0.1.0/LICENSE +21 -0
- dex_connector_linear-0.1.0/PKG-INFO +42 -0
- dex_connector_linear-0.1.0/README.md +30 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/README.md +51 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/__init__.py +3 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/flow.py +66 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/integration_test.py +127 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/start.py +53 -0
- dex_connector_linear-0.1.0/examples/list_workflow_states/worker.py +51 -0
- dex_connector_linear-0.1.0/pyproject.toml +38 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/__init__.py +98 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/__init__.py +2 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/config.py +31 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/connection.py +268 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/definitions.py +143 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/mock.py +410 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/models.py +554 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/refresh.py +9 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/steps.py +390 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/_generated/timestamps.py +60 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/client.py +465 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/connection.py +5 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/dex-connector.json +257 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/documents.py +14 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/linearmock/__init__.py +6 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/models.py +5 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/operations.py +945 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/py.typed +0 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/steps.py +5 -0
- dex_connector_linear-0.1.0/src/dex_connectors/linear/wire.py +335 -0
- dex_connector_linear-0.1.0/tests/refresh_agreement_cases.json +548 -0
- dex_connector_linear-0.1.0/tests/test_client.py +72 -0
- dex_connector_linear-0.1.0/tests/test_conformance.py +41 -0
- dex_connector_linear-0.1.0/tests/test_refresh_agreement.py +278 -0
- dex_connector_linear-0.1.0/tests/test_wire.py +80 -0
- dex_connector_linear-0.1.0/uv.lock +866 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
node_modules/
|
|
5
|
+
dist/
|
|
6
|
+
sdkpython/dist/dex_connectors_sdk-0.1.0-py3-none-any.whl
|
|
7
|
+
/.bin/dexcli
|
|
8
|
+
/.bin/dex-server-zd
|
|
9
|
+
/sdkpython/.dexcli-data/
|
|
10
|
+
site/.catalog.yaml
|
|
11
|
+
coverage/
|
|
12
|
+
*.out
|
|
13
|
+
*.test
|
|
14
|
+
go.work
|
|
15
|
+
go.work.sum
|
|
16
|
+
.idea/
|
|
@@ -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,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,30 @@
|
|
|
1
|
+
# Linear Python connector
|
|
2
|
+
|
|
3
|
+
`dex-connector-linear` provides seven operation-specific Dex Steps for Linear:
|
|
4
|
+
`searchIssues`, `getIssue`, `createIssue`, `updateIssue`, `addComment`,
|
|
5
|
+
`findUserByEmail`, and `listWorkflowStates`. The signed Issue webhook Trigger
|
|
6
|
+
remains Go-only. Python requires `dex-connectors-sdk==0.5.0` and Dex Python SDK
|
|
7
|
+
1.28.0 or newer.
|
|
8
|
+
|
|
9
|
+
The generated project connection supports the manifest's personal API key and
|
|
10
|
+
Linear OAuth methods. OAuth access tokens refresh before expiry and once after
|
|
11
|
+
an HTTP 401 through the generated connection and SDK credential source. Shared
|
|
12
|
+
connections do not expose the client secret or refresh token to applications.
|
|
13
|
+
Configure credentials in Dex Web **Connections**; never place them in Flow
|
|
14
|
+
input or persisted values. See the [Linear setup guide](../README.md#linear-setup)
|
|
15
|
+
for provider application pages, scopes, and credential fields.
|
|
16
|
+
|
|
17
|
+
The [workflow-state example](examples/list_workflow_states) is the runnable
|
|
18
|
+
consuming application. It uses the static connection `linear` and only wires
|
|
19
|
+
the `listed` branch. Other branches fail the Flow. Its real Dex integration
|
|
20
|
+
test exercises a 429 retry, result persistence, and an unwired rejection with an
|
|
21
|
+
inert provider stand-in. The 54 provider replay scenarios compare Python
|
|
22
|
+
requests and outcomes to Go recordings. Live Linear behavior and OAuth consent
|
|
23
|
+
were not verified for this Python port.
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
uv sync --locked
|
|
27
|
+
uv run pytest
|
|
28
|
+
uv run ruff check src tests examples
|
|
29
|
+
uv run mypy src/dex_connectors/linear
|
|
30
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Linear workflow states in a Dex Flow
|
|
2
|
+
|
|
3
|
+
This runnable Flow lists a team's workflow states through the static `linear`
|
|
4
|
+
connection. Create that connection in Dex Web **Connections**, using a personal
|
|
5
|
+
API key or Linear OAuth as described in the [connector guide](../../../README.md#linear-setup).
|
|
6
|
+
The team UUID is the Flow input. The `listed` branch completes with the states;
|
|
7
|
+
other optional branches fail the Flow.
|
|
8
|
+
|
|
9
|
+
From `connectors/linear/python`, generate strict FDG 2.0 with the installed
|
|
10
|
+
Python interpreter:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
dexcli visualize examples/list_workflow_states/flow.py \
|
|
14
|
+
--schema-version 2.0 --json --python .venv/bin/python \
|
|
15
|
+
--out /tmp/linear-python-workflow-states
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The command reports `valid: true`. Start `dexcli dev` with that flow rendering
|
|
19
|
+
directory, configure `linear / linear` in Dex Web, and set
|
|
20
|
+
`DEX_CONNECTOR_CONFIG_FILE` to its saved owner-only project file. Then run:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
uv sync --locked
|
|
24
|
+
DEX_FLOW_SERVICE_ADDRESS=127.0.0.1:8801 \
|
|
25
|
+
DEX_CONNECTOR_CONFIG_FILE=/path/to/connections.json \
|
|
26
|
+
uv run python -m examples.list_workflow_states.worker
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
In another terminal, use the checked-in Client entrypoint with a unique Flow ID
|
|
30
|
+
and the team UUID from Linear **Settings > Teams > the team > Copy team ID**:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
DEX_FLOW_SERVICE_ADDRESS=127.0.0.1:8801 \
|
|
34
|
+
DEX_CONNECTOR_CONFIG_FILE=/path/to/connections.json \
|
|
35
|
+
uv run python -m examples.list_workflow_states.start \
|
|
36
|
+
linear-states-001 2f6b7c1e-3d4a-4b5c-8d6e-7f8091a2b3c4
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The entrypoint calls `start_workflow_state_flow` in
|
|
40
|
+
[`start.py`](start.py). The Worker in [`worker.py`](worker.py) loads the current
|
|
41
|
+
credential source through `new_project_connection` and registers the Flow in
|
|
42
|
+
[`flow.py`](flow.py). To run the real Dex Worker and Client integration test with
|
|
43
|
+
an inert provider stand-in, set `DEX_FLOW_SERVICE_ADDRESS` to the local
|
|
44
|
+
`dexcli dev` address and run:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
DEX_FLOW_SERVICE_ADDRESS=127.0.0.1:8801 \
|
|
48
|
+
uv run pytest examples/list_workflow_states/integration_test.py
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Live Linear behavior and OAuth consent were not verified for this Python port.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""List the states that an application can use to move Linear issues."""
|
|
4
|
+
|
|
5
|
+
import dex
|
|
6
|
+
from dex_connectors.sdk import QueryResult
|
|
7
|
+
|
|
8
|
+
from dex_connectors.linear import (
|
|
9
|
+
Connection,
|
|
10
|
+
ListWorkflowStatesInput,
|
|
11
|
+
ListWorkflowStatesOutput,
|
|
12
|
+
new_list_workflow_states_step,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
CONNECTION_NAME = "linear"
|
|
16
|
+
FLOW_TYPE = "LinearListWorkflowStatesPython"
|
|
17
|
+
_STATES = dex.Attribute("linear-workflow-states", ListWorkflowStatesOutput)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# dex:group group-id:workflow-states group-label:"Workflow states"
|
|
21
|
+
# dex:explanation text:"Persist the team states returned by Linear."
|
|
22
|
+
class CompleteWorkflowStates(dex.Step[QueryResult[ListWorkflowStatesOutput]]):
|
|
23
|
+
"""Persist and return the team's workflow states."""
|
|
24
|
+
|
|
25
|
+
def get_step_type(self) -> str:
|
|
26
|
+
"""Return the stable completion Step identity."""
|
|
27
|
+
return "CompleteWorkflowStates"
|
|
28
|
+
|
|
29
|
+
def execute(self, context: dex.Context, input: QueryResult[ListWorkflowStatesOutput]) -> dex.StepDecision:
|
|
30
|
+
"""Save the safe provider result and complete the Flow."""
|
|
31
|
+
_STATES.set(context, input.value)
|
|
32
|
+
return dex.graceful_complete(input.value)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ListWorkflowStatesFlow(dex.Flow[ListWorkflowStatesInput]):
|
|
36
|
+
"""Read one team's workflow states through the static Linear connection."""
|
|
37
|
+
|
|
38
|
+
def __init__(self, connection: Connection) -> None:
|
|
39
|
+
if connection is None or connection.reference.name != CONNECTION_NAME:
|
|
40
|
+
raise ValueError("workflow state Flow requires the static Linear connection")
|
|
41
|
+
self.complete = CompleteWorkflowStates()
|
|
42
|
+
self.list_states = new_list_workflow_states_step(
|
|
43
|
+
step_type="ListLinearWorkflowStates",
|
|
44
|
+
step_input_type=ListWorkflowStatesInput,
|
|
45
|
+
annotations={
|
|
46
|
+
"groupId": "workflow-states",
|
|
47
|
+
"groupLabel": "Workflow states",
|
|
48
|
+
"explanation": "Read the team's available Linear workflow states.",
|
|
49
|
+
},
|
|
50
|
+
connection=connection,
|
|
51
|
+
connection_name=CONNECTION_NAME,
|
|
52
|
+
map_to_operation_input=lambda input: input,
|
|
53
|
+
listed=self.complete,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def get_flow_type(self) -> str:
|
|
57
|
+
"""Return the stable Flow identity."""
|
|
58
|
+
return "LinearListWorkflowStatesPython"
|
|
59
|
+
|
|
60
|
+
def get_steps(self) -> dex.StepList[ListWorkflowStatesInput]:
|
|
61
|
+
"""Register the provider Query and completion Step."""
|
|
62
|
+
return dex.StepList.start_step(self.list_states).other_steps(self.complete)
|
|
63
|
+
|
|
64
|
+
def get_persistence_schema(self) -> dex.PersistenceSchema:
|
|
65
|
+
"""Register the persisted states Attribute."""
|
|
66
|
+
return dex.PersistenceSchema.of(_STATES)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Exercise the Linear example through a real Dex Worker and Client."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import tempfile
|
|
9
|
+
from datetime import timedelta
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from uuid import uuid4
|
|
12
|
+
|
|
13
|
+
import dex
|
|
14
|
+
import httpx
|
|
15
|
+
import pytest
|
|
16
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
17
|
+
|
|
18
|
+
from dex_connectors.linear import ListWorkflowStatesInput, ListWorkflowStatesOutput, new_project_connection
|
|
19
|
+
|
|
20
|
+
from .flow import CONNECTION_NAME, ListWorkflowStatesFlow
|
|
21
|
+
|
|
22
|
+
TEAM_ID = "2f6b7c1e-3d4a-4b5c-8d6e-7f8091a2b3c4"
|
|
23
|
+
STATE_ID = "22222222-2222-4222-8222-222222222222"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.asyncio
|
|
27
|
+
async def test_example_lists_states_and_fails_unwired_rejection(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
28
|
+
"""Verify real Worker dispatch, retry, persistence, and optional branch failure."""
|
|
29
|
+
server_address = os.environ["DEX_FLOW_SERVICE_ADDRESS"]
|
|
30
|
+
requests: list[httpx.Request] = []
|
|
31
|
+
|
|
32
|
+
def answer(request: httpx.Request) -> httpx.Response:
|
|
33
|
+
requests.append(request)
|
|
34
|
+
document = json.loads(request.content)
|
|
35
|
+
if document["variables"]["teamId"] != TEAM_ID:
|
|
36
|
+
return httpx.Response(401, json={"errors": [{"extensions": {"code": "UNAUTHENTICATED"}}]})
|
|
37
|
+
if len(requests) == 1:
|
|
38
|
+
return httpx.Response(429, headers={"Retry-After": "1"}, json={"errors": []})
|
|
39
|
+
return httpx.Response(
|
|
40
|
+
200,
|
|
41
|
+
json={
|
|
42
|
+
"data": {
|
|
43
|
+
"workflowStates": {
|
|
44
|
+
"nodes": [
|
|
45
|
+
{
|
|
46
|
+
"id": STATE_ID,
|
|
47
|
+
"name": "Todo",
|
|
48
|
+
"type": "unstarted",
|
|
49
|
+
"position": 1,
|
|
50
|
+
"color": "#eeeeee",
|
|
51
|
+
"team": {"id": TEAM_ID},
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
async with httpx.AsyncClient(transport=httpx.MockTransport(answer)) as provider_http_client:
|
|
60
|
+
with tempfile.TemporaryDirectory(prefix="linear-python-dex-") as temporary_directory:
|
|
61
|
+
directory = Path(temporary_directory)
|
|
62
|
+
config_path = directory / "connections.json"
|
|
63
|
+
config_path.write_text(
|
|
64
|
+
json.dumps(
|
|
65
|
+
{
|
|
66
|
+
"schemaVersion": "connectors.dex.dev/local-connections/v1alpha1",
|
|
67
|
+
"connections": [
|
|
68
|
+
{
|
|
69
|
+
"connectorId": "linear",
|
|
70
|
+
"connectionName": CONNECTION_NAME,
|
|
71
|
+
"modulePath": (
|
|
72
|
+
"github.com/superdurable/dex-connectors-library/connectors/linear"
|
|
73
|
+
),
|
|
74
|
+
"provider": "linear",
|
|
75
|
+
"authMethodId": "personal-api-key",
|
|
76
|
+
"configuration": {},
|
|
77
|
+
"credentials": {
|
|
78
|
+
"api_key": "lin_" + "api_" + "SENTINELKEY0123456789abcdefghijklmnopqrst"
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"triggerBindings": [],
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
config_path.chmod(0o600)
|
|
87
|
+
monkeypatch.setenv("DEX_CONNECTOR_CONFIG_FILE", str(config_path))
|
|
88
|
+
project = await load_from_environment({"DEX_CONNECTOR_CONFIG_FILE": str(config_path)})
|
|
89
|
+
connection = new_project_connection(project, CONNECTION_NAME, provider_http_client)
|
|
90
|
+
flow = ListWorkflowStatesFlow(connection)
|
|
91
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
92
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(str(directory / "blobs"), 1 << 24))
|
|
93
|
+
try:
|
|
94
|
+
worker = dex.AsyncWorker(registry, cache, dex.WorkerOptions(server_address=server_address))
|
|
95
|
+
worker_task = asyncio.create_task(worker.start())
|
|
96
|
+
try:
|
|
97
|
+
await worker.wait_pull_registered(timeout=15)
|
|
98
|
+
async with dex.AsyncClient(
|
|
99
|
+
registry, cache, dex.ClientOptions(server_address=server_address)
|
|
100
|
+
) as client:
|
|
101
|
+
success_id = f"linear-python-states-{uuid4().hex}"
|
|
102
|
+
await client.start_flow(flow, success_id, ListWorkflowStatesInput(TEAM_ID))
|
|
103
|
+
success = await asyncio.wait_for(
|
|
104
|
+
client.wait_for_flow(success_id, timedelta(seconds=25)), 30
|
|
105
|
+
)
|
|
106
|
+
assert success.status == dex.FlowStatus.COMPLETED, success.error_message
|
|
107
|
+
states = success.single_output(ListWorkflowStatesOutput)
|
|
108
|
+
assert states.team_id == TEAM_ID
|
|
109
|
+
assert len(states.states) == 1 and states.states[0].id == STATE_ID
|
|
110
|
+
assert len(requests) == 2
|
|
111
|
+
|
|
112
|
+
failure_id = f"linear-python-states-{uuid4().hex}"
|
|
113
|
+
await client.start_flow(
|
|
114
|
+
flow, failure_id, ListWorkflowStatesInput("00000000-0000-4000-8000-000000000000")
|
|
115
|
+
)
|
|
116
|
+
failed = await asyncio.wait_for(
|
|
117
|
+
client.wait_for_flow(failure_id, timedelta(seconds=20)), 30
|
|
118
|
+
)
|
|
119
|
+
assert failed.status == dex.FlowStatus.FAILED
|
|
120
|
+
assert "providerRejected" in (failed.error_message or "")
|
|
121
|
+
finally:
|
|
122
|
+
await worker.stop()
|
|
123
|
+
await worker_task
|
|
124
|
+
finally:
|
|
125
|
+
cache.close()
|
|
126
|
+
await connection.aclose()
|
|
127
|
+
await project.close()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Start a Linear workflow-state Flow with one team UUID."""
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import asyncio
|
|
7
|
+
import os
|
|
8
|
+
import tempfile
|
|
9
|
+
|
|
10
|
+
import dex
|
|
11
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
12
|
+
|
|
13
|
+
from dex_connectors.linear import ListWorkflowStatesInput, new_project_connection
|
|
14
|
+
|
|
15
|
+
from .flow import CONNECTION_NAME, ListWorkflowStatesFlow
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def start_workflow_state_flow(flow_id: str, team_id: str) -> str:
|
|
19
|
+
"""Start one Flow using the configured Linear connection."""
|
|
20
|
+
project = await load_from_environment()
|
|
21
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
22
|
+
try:
|
|
23
|
+
flow = ListWorkflowStatesFlow(connection)
|
|
24
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
25
|
+
with tempfile.TemporaryDirectory(prefix="dex-linear-start-") as cache_directory:
|
|
26
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 24))
|
|
27
|
+
try:
|
|
28
|
+
async with dex.AsyncClient(
|
|
29
|
+
registry,
|
|
30
|
+
cache,
|
|
31
|
+
dex.ClientOptions(
|
|
32
|
+
server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")
|
|
33
|
+
),
|
|
34
|
+
) as client:
|
|
35
|
+
return await client.start_flow(flow, flow_id, ListWorkflowStatesInput(team_id))
|
|
36
|
+
finally:
|
|
37
|
+
cache.close()
|
|
38
|
+
finally:
|
|
39
|
+
await connection.aclose()
|
|
40
|
+
await project.close()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main() -> None:
|
|
44
|
+
"""Read the Flow ID and team UUID from the command line."""
|
|
45
|
+
parser = argparse.ArgumentParser(description="List Linear workflow states")
|
|
46
|
+
parser.add_argument("flow_id")
|
|
47
|
+
parser.add_argument("team_id")
|
|
48
|
+
arguments = parser.parse_args()
|
|
49
|
+
print(asyncio.run(start_workflow_state_flow(arguments.flow_id, arguments.team_id)))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
main()
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Serve the Linear workflow-state example."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import dex
|
|
11
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
12
|
+
|
|
13
|
+
from dex_connectors.linear import new_project_connection
|
|
14
|
+
|
|
15
|
+
from .flow import CONNECTION_NAME, ListWorkflowStatesFlow
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def run_worker() -> None:
|
|
19
|
+
"""Load a Dex Web connection and run the Flow until shutdown."""
|
|
20
|
+
project = await load_from_environment()
|
|
21
|
+
connection = None
|
|
22
|
+
cache = None
|
|
23
|
+
try:
|
|
24
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
25
|
+
registry = dex.Registry([ListWorkflowStatesFlow(connection)], allow_async_handlers=True)
|
|
26
|
+
cache_directory = os.environ.get(
|
|
27
|
+
"DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-linear-python-states-blobs")
|
|
28
|
+
)
|
|
29
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
|
|
30
|
+
worker = dex.AsyncWorker(
|
|
31
|
+
registry,
|
|
32
|
+
cache,
|
|
33
|
+
dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
|
|
34
|
+
)
|
|
35
|
+
async with worker:
|
|
36
|
+
await worker.start()
|
|
37
|
+
finally:
|
|
38
|
+
if connection is not None:
|
|
39
|
+
await connection.aclose()
|
|
40
|
+
if cache is not None:
|
|
41
|
+
cache.close()
|
|
42
|
+
await project.close()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main() -> None:
|
|
46
|
+
"""Run the Linear Worker from the command line."""
|
|
47
|
+
asyncio.run(run_worker())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
main()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dex-connector-linear"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Dex-native Linear connector"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
dependencies = ["dex-connectors-sdk==0.7.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
|
|
14
|
+
|
|
15
|
+
[dependency-groups]
|
|
16
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7"]
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.wheel]
|
|
19
|
+
packages = ["src/dex_connectors"]
|
|
20
|
+
|
|
21
|
+
[tool.pytest.ini_options]
|
|
22
|
+
testpaths = ["tests"]
|
|
23
|
+
pythonpath = [".", "src"]
|
|
24
|
+
asyncio_mode = "auto"
|
|
25
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
26
|
+
|
|
27
|
+
[tool.mypy]
|
|
28
|
+
python_version = "3.11"
|
|
29
|
+
strict = true
|
|
30
|
+
mypy_path = "src"
|
|
31
|
+
explicit_package_bases = true
|
|
32
|
+
|
|
33
|
+
[tool.ruff]
|
|
34
|
+
target-version = "py311"
|
|
35
|
+
line-length = 110
|
|
36
|
+
|
|
37
|
+
[tool.ruff.lint]
|
|
38
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -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,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')
|