dex-connector-pipedrive 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_pipedrive-0.1.0/.gitignore +16 -0
- dex_connector_pipedrive-0.1.0/LICENSE +21 -0
- dex_connector_pipedrive-0.1.0/PKG-INFO +26 -0
- dex_connector_pipedrive-0.1.0/README.md +13 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/README.md +15 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/__init__.py +3 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/flow.py +58 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/integration_test.py +119 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/start.py +53 -0
- dex_connector_pipedrive-0.1.0/examples/deal_lookup/worker.py +46 -0
- dex_connector_pipedrive-0.1.0/pyproject.toml +41 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/__init__.py +51 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/__init__.py +2 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/config.py +30 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/connection.py +252 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/definitions.py +130 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/mock.py +371 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/models.py +247 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/refresh.py +9 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/steps.py +343 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/_generated/timestamps.py +60 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/client.py +465 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/connection.py +8 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/dex-connector.json +229 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/models.py +270 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/operations.py +996 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/pipedrivemock/__init__.py +6 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/py.typed +0 -0
- dex_connector_pipedrive-0.1.0/src/dex_connectors/pipedrive/steps.py +10 -0
- dex_connector_pipedrive-0.1.0/tests/refresh_agreement_cases.json +1031 -0
- dex_connector_pipedrive-0.1.0/tests/test_client.py +167 -0
- dex_connector_pipedrive-0.1.0/tests/test_conformance.py +47 -0
- dex_connector_pipedrive-0.1.0/tests/test_refresh_agreement.py +278 -0
- dex_connector_pipedrive-0.1.0/uv.lock +934 -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,26 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dex-connector-pipedrive
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dex-native Pipedrive CRM connector
|
|
5
|
+
Project-URL: Source, https://github.com/superdurable/dex-connectors-library/tree/main/connectors/pipedrive/python
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: dex-connectors-sdk==0.7.0
|
|
10
|
+
Requires-Dist: dex-python-sdk>=1.28.0
|
|
11
|
+
Requires-Dist: httpx>=0.27
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Pipedrive Python connector
|
|
15
|
+
|
|
16
|
+
`dex-connector-pipedrive` exposes the six manifest operations: `searchObjects`, `getObject`, `listObjects`, `upsertObject`, `createObject`, and `updateObject`. It requires `dex-connectors-sdk==0.7.0` and `dex-python-sdk>=1.28.0`. The package has no Triggers.
|
|
17
|
+
|
|
18
|
+
Load a named Pipedrive connection from Dex project configuration with `new_project_connection(project, "pipedrive-crm")`. The generated connection binds Personal API token credentials or Pipedrive OAuth credentials and handles refresh through the generated manifest driver. Provider calls resolve credentials at dispatch time; never put a token in Flow input or an Attribute.
|
|
19
|
+
|
|
20
|
+
See the runnable [deal lookup example](examples/deal_lookup/README.md) for a Flow, Worker, start command, and a real Dex integration test. `getObject` returns a complete record; search returns partial records, which can be hydrated through `getObject`. Non-happy branches are optional and fail an example Flow unless explicitly wired for a business reaction. The source of truth for authorization and configuration is the connector's [`connector.yaml`](../connector.yaml).
|
|
21
|
+
|
|
22
|
+
`listObjects` accepts the Go JSON timestamp spellings for `updatedSince` and `updatedUntil`, including comma fractions and offsets through 24:60, and sends the filters as whole-second UTC times.
|
|
23
|
+
|
|
24
|
+
Open-ended `fields` and `customFields` values retain their JSON number spelling when Python can encode it unchanged. A number that would round or change spelling makes a read select `invalidResponse`; an already accepted write can instead be `uncertain`.
|
|
25
|
+
|
|
26
|
+
Run the package checks from this directory with `uv sync` and `uv run pytest`. Run provider replay from the repository root with `make test-connector-conformance CONNECTOR_DIRECTORY=connectors/pipedrive`. Live Pipedrive authorization and API behavior are unverified.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Pipedrive Python connector
|
|
2
|
+
|
|
3
|
+
`dex-connector-pipedrive` exposes the six manifest operations: `searchObjects`, `getObject`, `listObjects`, `upsertObject`, `createObject`, and `updateObject`. It requires `dex-connectors-sdk==0.7.0` and `dex-python-sdk>=1.28.0`. The package has no Triggers.
|
|
4
|
+
|
|
5
|
+
Load a named Pipedrive connection from Dex project configuration with `new_project_connection(project, "pipedrive-crm")`. The generated connection binds Personal API token credentials or Pipedrive OAuth credentials and handles refresh through the generated manifest driver. Provider calls resolve credentials at dispatch time; never put a token in Flow input or an Attribute.
|
|
6
|
+
|
|
7
|
+
See the runnable [deal lookup example](examples/deal_lookup/README.md) for a Flow, Worker, start command, and a real Dex integration test. `getObject` returns a complete record; search returns partial records, which can be hydrated through `getObject`. Non-happy branches are optional and fail an example Flow unless explicitly wired for a business reaction. The source of truth for authorization and configuration is the connector's [`connector.yaml`](../connector.yaml).
|
|
8
|
+
|
|
9
|
+
`listObjects` accepts the Go JSON timestamp spellings for `updatedSince` and `updatedUntil`, including comma fractions and offsets through 24:60, and sends the filters as whole-second UTC times.
|
|
10
|
+
|
|
11
|
+
Open-ended `fields` and `customFields` values retain their JSON number spelling when Python can encode it unchanged. A number that would round or change spelling makes a read select `invalidResponse`; an already accepted write can instead be `uncertain`.
|
|
12
|
+
|
|
13
|
+
Run the package checks from this directory with `uv sync` and `uv run pytest`. Run provider replay from the repository root with `make test-connector-conformance CONNECTOR_DIRECTORY=connectors/pipedrive`. Live Pipedrive authorization and API behavior are unverified.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Pipedrive deal lookup (Python)
|
|
2
|
+
|
|
3
|
+
This runnable Flow reads one complete Pipedrive deal through the static `pipedrive-crm` connection. Create that connection in Dex Web with a Personal API token or Pipedrive OAuth app, following the authorization guide shown there. The Flow starts with `GetObjectInput(object_type="deals", object_id="42")` and returns a `CRMObject` when Pipedrive finds the deal. The optional `notFound`, `providerRejected`, `invalidResponse`, and `defect` branches are intentionally unwired and fail the Flow.
|
|
4
|
+
|
|
5
|
+
From the repository root, generate and validate the strict FDG 2.0 graph before using Dex Web:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
dexcli visualize connectors/pipedrive/python/examples/deal_lookup/flow.py \
|
|
9
|
+
--language python --python connectors/pipedrive/python/.venv/bin/python \
|
|
10
|
+
--schema-version 2.0 --json --out /tmp/pipedrive-deal-lookup
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Start `dexcli dev` on free local ports. Set `DEX_FLOW_SERVICE_ADDRESS` to its Dex gRPC address and `DEX_CONNECTOR_CONFIG_FILE` to the owner-only project connection file written by Dex Web. From `connectors/pipedrive/python`, run `uv sync --locked`, then `uv run python -m examples.deal_lookup.worker` in one terminal. Start a Flow with `uv run python -m examples.deal_lookup.start <unique-flow-id> <deal-id>`.
|
|
14
|
+
|
|
15
|
+
The automated integration test uses a real Dex Worker and Client with a local HTTP stand-in. Run it from `connectors/pipedrive/python` with `DEX_FLOW_SERVICE_ADDRESS` set to a running `dexcli dev` instance: `uv run pytest examples/deal_lookup/integration_test.py`. Live Pipedrive authorization and API behavior remain unverified.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Read one deal using the static Pipedrive connection."""
|
|
4
|
+
|
|
5
|
+
import dex
|
|
6
|
+
from dex_connectors.sdk import QueryResult
|
|
7
|
+
|
|
8
|
+
from dex_connectors.pipedrive import Connection, CRMObject, GetObjectInput, new_get_object_step
|
|
9
|
+
|
|
10
|
+
CONNECTION_NAME = "pipedrive-crm"
|
|
11
|
+
_RESULT = dex.Attribute("pipedrive-deal-lookup-result", CRMObject)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# dex:group group-id:deal-lookup group-label:"Deal lookup"
|
|
15
|
+
# dex:explanation text:"Persist the complete Pipedrive deal and complete the Flow."
|
|
16
|
+
class _DealFound(dex.Step[QueryResult[CRMObject]]):
|
|
17
|
+
def get_step_type(self) -> str:
|
|
18
|
+
"""Return the stable completion Step identity."""
|
|
19
|
+
return "CompletePipedriveDealLookup"
|
|
20
|
+
|
|
21
|
+
def execute(self, context: dex.Context, input: QueryResult[CRMObject]) -> dex.StepDecision:
|
|
22
|
+
"""Persist the safe record and return it to the caller."""
|
|
23
|
+
_RESULT.set(context, input.value)
|
|
24
|
+
return dex.graceful_complete(input.value)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class DealLookupFlow(dex.Flow[GetObjectInput]):
|
|
28
|
+
"""Fetch one complete Pipedrive deal by its decimal ID."""
|
|
29
|
+
|
|
30
|
+
def __init__(self, connection: Connection) -> None:
|
|
31
|
+
if connection.reference.name != CONNECTION_NAME:
|
|
32
|
+
raise ValueError("deal lookup requires the static Pipedrive connection")
|
|
33
|
+
self._found = _DealFound()
|
|
34
|
+
self._get = new_get_object_step(
|
|
35
|
+
step_type="GetPipedriveDeal",
|
|
36
|
+
step_input_type=GetObjectInput,
|
|
37
|
+
annotations={
|
|
38
|
+
"groupId": "deal-lookup",
|
|
39
|
+
"groupLabel": "Deal lookup",
|
|
40
|
+
"explanation": "Read one complete deal from Pipedrive by ID.",
|
|
41
|
+
},
|
|
42
|
+
connection=connection,
|
|
43
|
+
connection_name=CONNECTION_NAME,
|
|
44
|
+
map_to_operation_input=lambda input: input,
|
|
45
|
+
found=self._found,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def get_flow_type(self) -> str:
|
|
49
|
+
"""Return the stable Flow identity."""
|
|
50
|
+
return "PipedriveDealLookupPython"
|
|
51
|
+
|
|
52
|
+
def get_steps(self) -> dex.StepList[GetObjectInput]:
|
|
53
|
+
"""Start with the provider Query and complete when found."""
|
|
54
|
+
return dex.StepList.start_step(self._get).other_steps(self._found)
|
|
55
|
+
|
|
56
|
+
def get_persistence_schema(self) -> dex.PersistenceSchema:
|
|
57
|
+
"""Register the returned deal Attribute."""
|
|
58
|
+
return dex.PersistenceSchema.of(_RESULT)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Exercise the Pipedrive deal lookup through a real Dex Worker and Client."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import tempfile
|
|
9
|
+
import threading
|
|
10
|
+
from datetime import timedelta
|
|
11
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from uuid import uuid4
|
|
14
|
+
|
|
15
|
+
import dex
|
|
16
|
+
import pytest
|
|
17
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
18
|
+
|
|
19
|
+
from dex_connectors.pipedrive import CRMObject, GetObjectInput, new_project_connection
|
|
20
|
+
|
|
21
|
+
from .flow import CONNECTION_NAME, DealLookupFlow
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
async def test_deal_lookup_retries_and_completes_in_real_dex(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
26
|
+
"""Prove provider retry, successful routing, and an unwired optional branch."""
|
|
27
|
+
server_address = os.environ["DEX_FLOW_SERVICE_ADDRESS"]
|
|
28
|
+
requests: list[str] = []
|
|
29
|
+
|
|
30
|
+
class ProviderHandler(BaseHTTPRequestHandler):
|
|
31
|
+
def do_GET(self) -> None:
|
|
32
|
+
requests.append(self.path)
|
|
33
|
+
if self.path.endswith("/404"):
|
|
34
|
+
self.send_response(404)
|
|
35
|
+
content = b'{"success":false}'
|
|
36
|
+
elif len(requests) == 1:
|
|
37
|
+
self.send_response(503)
|
|
38
|
+
content = b'{"success":false}'
|
|
39
|
+
else:
|
|
40
|
+
self.send_response(200)
|
|
41
|
+
content = b'{"success":true,"data":{"id":42,"title":"Acme renewal"}}'
|
|
42
|
+
self.send_header("Content-Type", "application/json")
|
|
43
|
+
self.send_header("Content-Length", str(len(content)))
|
|
44
|
+
self.end_headers()
|
|
45
|
+
self.wfile.write(content)
|
|
46
|
+
|
|
47
|
+
def log_message(self, format: str, *arguments: object) -> None:
|
|
48
|
+
pass # The stand-in has no useful diagnostics and must not print credentials.
|
|
49
|
+
|
|
50
|
+
provider = ThreadingHTTPServer(("127.0.0.1", 0), ProviderHandler)
|
|
51
|
+
provider_thread = threading.Thread(target=provider.serve_forever, daemon=True)
|
|
52
|
+
provider_thread.start()
|
|
53
|
+
try:
|
|
54
|
+
with tempfile.TemporaryDirectory(prefix="pipedrive-python-dex-") as directory:
|
|
55
|
+
root = Path(directory)
|
|
56
|
+
connections_path = root / "connections.json"
|
|
57
|
+
connections_path.write_text(
|
|
58
|
+
json.dumps(
|
|
59
|
+
{
|
|
60
|
+
"schemaVersion": "connectors.dex.dev/local-connections/v1alpha1",
|
|
61
|
+
"connections": [
|
|
62
|
+
{
|
|
63
|
+
"connectorId": "pipedrive",
|
|
64
|
+
"connectionName": CONNECTION_NAME,
|
|
65
|
+
"modulePath": (
|
|
66
|
+
"github.com/superdurable/dex-connectors-library/connectors/pipedrive"
|
|
67
|
+
),
|
|
68
|
+
"provider": "pipedrive",
|
|
69
|
+
"authMethodId": "api-token",
|
|
70
|
+
"configuration": {"endpoint": f"http://127.0.0.1:{provider.server_port}"},
|
|
71
|
+
"credentials": {"api_token": "pipedrive-inert-example-token"},
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"triggerBindings": [],
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
connections_path.chmod(0o600)
|
|
79
|
+
monkeypatch.setenv("DEX_CONNECTOR_CONFIG_FILE", str(connections_path))
|
|
80
|
+
project = await load_from_environment({"DEX_CONNECTOR_CONFIG_FILE": str(connections_path)})
|
|
81
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
82
|
+
flow = DealLookupFlow(connection)
|
|
83
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
84
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(str(root / "blobs"), 1 << 24))
|
|
85
|
+
try:
|
|
86
|
+
worker = dex.AsyncWorker(registry, cache, dex.WorkerOptions(server_address=server_address))
|
|
87
|
+
worker_task = asyncio.create_task(worker.start())
|
|
88
|
+
try:
|
|
89
|
+
await worker.wait_pull_registered(timeout=15)
|
|
90
|
+
async with dex.AsyncClient(
|
|
91
|
+
registry, cache, dex.ClientOptions(server_address=server_address)
|
|
92
|
+
) as client:
|
|
93
|
+
successful_id = f"pipedrive-python-deal-{uuid4().hex}"
|
|
94
|
+
await client.start_flow(flow, successful_id, GetObjectInput("deals", "42"))
|
|
95
|
+
success = await asyncio.wait_for(
|
|
96
|
+
client.wait_for_flow(successful_id, timedelta(seconds=30)), 40
|
|
97
|
+
)
|
|
98
|
+
assert success.status == dex.FlowStatus.COMPLETED, success.error_message
|
|
99
|
+
assert success.single_output(CRMObject).id == "42"
|
|
100
|
+
assert requests == ["/api/v2/deals/42", "/api/v2/deals/42"]
|
|
101
|
+
|
|
102
|
+
missing_id = f"pipedrive-python-deal-{uuid4().hex}"
|
|
103
|
+
await client.start_flow(flow, missing_id, GetObjectInput("deals", "404"))
|
|
104
|
+
missing = await asyncio.wait_for(
|
|
105
|
+
client.wait_for_flow(missing_id, timedelta(seconds=20)), 30
|
|
106
|
+
)
|
|
107
|
+
assert missing.status == dex.FlowStatus.FAILED
|
|
108
|
+
assert "notFound" in (missing.error_message or "")
|
|
109
|
+
finally:
|
|
110
|
+
await worker.stop()
|
|
111
|
+
await worker_task
|
|
112
|
+
finally:
|
|
113
|
+
cache.close()
|
|
114
|
+
await connection.aclose()
|
|
115
|
+
await project.close()
|
|
116
|
+
finally:
|
|
117
|
+
provider.shutdown()
|
|
118
|
+
provider.server_close()
|
|
119
|
+
provider_thread.join(timeout=5)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Start a Pipedrive deal lookup against the local Dex service."""
|
|
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.pipedrive import GetObjectInput, new_project_connection
|
|
14
|
+
|
|
15
|
+
from .flow import CONNECTION_NAME, DealLookupFlow
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def start_deal_lookup(flow_id: str, deal_id: str) -> str:
|
|
19
|
+
"""Submit a deal ID to the registered Flow."""
|
|
20
|
+
project = await load_from_environment()
|
|
21
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
22
|
+
try:
|
|
23
|
+
flow = DealLookupFlow(connection)
|
|
24
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
25
|
+
with tempfile.TemporaryDirectory(prefix="pipedrive-python-start-blobs-") 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, GetObjectInput("deals", deal_id))
|
|
36
|
+
finally:
|
|
37
|
+
cache.close()
|
|
38
|
+
finally:
|
|
39
|
+
await connection.aclose()
|
|
40
|
+
await project.close()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main() -> None:
|
|
44
|
+
"""Accept a unique Flow ID and decimal deal ID."""
|
|
45
|
+
parser = argparse.ArgumentParser(description="Start a Pipedrive deal lookup")
|
|
46
|
+
parser.add_argument("flow_id")
|
|
47
|
+
parser.add_argument("deal_id")
|
|
48
|
+
arguments = parser.parse_args()
|
|
49
|
+
print(asyncio.run(start_deal_lookup(arguments.flow_id, arguments.deal_id)))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
main()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Worker entrypoint for the Pipedrive deal lookup Flow."""
|
|
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.pipedrive import new_project_connection
|
|
14
|
+
|
|
15
|
+
from .flow import CONNECTION_NAME, DealLookupFlow
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def run_worker() -> None:
|
|
19
|
+
"""Load the named connection and serve deal lookups."""
|
|
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([DealLookupFlow(connection)], allow_async_handlers=True)
|
|
26
|
+
cache_directory = os.environ.get(
|
|
27
|
+
"DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-pipedrive-deal-lookup-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
|
+
if __name__ == "__main__":
|
|
46
|
+
asyncio.run(run_worker())
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dex-connector-pipedrive"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Dex-native Pipedrive CRM 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
|
+
[project.urls]
|
|
16
|
+
Source = "https://github.com/superdurable/dex-connectors-library/tree/main/connectors/pipedrive/python"
|
|
17
|
+
|
|
18
|
+
[dependency-groups]
|
|
19
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "PyYAML>=6", "types-PyYAML>=6"]
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/dex_connectors"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
testpaths = ["tests"]
|
|
26
|
+
pythonpath = [".", "src"]
|
|
27
|
+
asyncio_mode = "auto"
|
|
28
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
29
|
+
|
|
30
|
+
[tool.mypy]
|
|
31
|
+
python_version = "3.11"
|
|
32
|
+
strict = true
|
|
33
|
+
mypy_path = "src"
|
|
34
|
+
explicit_package_bases = true
|
|
35
|
+
|
|
36
|
+
[tool.ruff]
|
|
37
|
+
target-version = "py311"
|
|
38
|
+
line-length = 110
|
|
39
|
+
|
|
40
|
+
[tool.ruff.lint]
|
|
41
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Pipedrive connector for Dex Python applications."""
|
|
4
|
+
|
|
5
|
+
from .client import Client as Client
|
|
6
|
+
from .client import Config as Config
|
|
7
|
+
from .client import Credentials as Credentials
|
|
8
|
+
from .connection import Connection as Connection
|
|
9
|
+
from .connection import new_connection as new_connection
|
|
10
|
+
from .connection import new_connection_with_operations as new_connection_with_operations
|
|
11
|
+
from .connection import new_project_connection as new_project_connection
|
|
12
|
+
from .models import CreateObjectInput as CreateObjectInput
|
|
13
|
+
from .models import CRMObject as CRMObject
|
|
14
|
+
from .models import GetObjectInput as GetObjectInput
|
|
15
|
+
from .models import ListObjectsInput as ListObjectsInput
|
|
16
|
+
from .models import ObjectPage as ObjectPage
|
|
17
|
+
from .models import SearchObjectsInput as SearchObjectsInput
|
|
18
|
+
from .models import UpdateObjectInput as UpdateObjectInput
|
|
19
|
+
from .models import UpsertedObject as UpsertedObject
|
|
20
|
+
from .models import UpsertObjectInput as UpsertObjectInput
|
|
21
|
+
from .steps import new_create_object_step as new_create_object_step
|
|
22
|
+
from .steps import new_get_object_step as new_get_object_step
|
|
23
|
+
from .steps import new_list_objects_step as new_list_objects_step
|
|
24
|
+
from .steps import new_search_objects_step as new_search_objects_step
|
|
25
|
+
from .steps import new_update_object_step as new_update_object_step
|
|
26
|
+
from .steps import new_upsert_object_step as new_upsert_object_step
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"Client",
|
|
30
|
+
"Config",
|
|
31
|
+
"Credentials",
|
|
32
|
+
"Connection",
|
|
33
|
+
"new_connection",
|
|
34
|
+
"new_connection_with_operations",
|
|
35
|
+
"new_project_connection",
|
|
36
|
+
"CreateObjectInput",
|
|
37
|
+
"CRMObject",
|
|
38
|
+
"GetObjectInput",
|
|
39
|
+
"ListObjectsInput",
|
|
40
|
+
"ObjectPage",
|
|
41
|
+
"SearchObjectsInput",
|
|
42
|
+
"UpdateObjectInput",
|
|
43
|
+
"UpsertedObject",
|
|
44
|
+
"UpsertObjectInput",
|
|
45
|
+
"new_create_object_step",
|
|
46
|
+
"new_get_object_step",
|
|
47
|
+
"new_list_objects_step",
|
|
48
|
+
"new_search_objects_step",
|
|
49
|
+
"new_update_object_step",
|
|
50
|
+
"new_upsert_object_step",
|
|
51
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
endpoint: str = "https://api.pipedrive.com"
|
|
14
|
+
max_response_bytes: int = 1048576
|
|
15
|
+
|
|
16
|
+
setattr(Config, '__module__', 'dex_connectors.pipedrive.client')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True, slots=True)
|
|
20
|
+
class Credentials:
|
|
21
|
+
|
|
22
|
+
auth_method_id: str = "api-token"
|
|
23
|
+
api_token: SecretString | None = None
|
|
24
|
+
oauth_client_id: str | None = None
|
|
25
|
+
oauth_client_secret: SecretString | None = None
|
|
26
|
+
access_token: SecretString | None = None
|
|
27
|
+
refresh_token: SecretString | None = None
|
|
28
|
+
api_domain: str = ''
|
|
29
|
+
|
|
30
|
+
setattr(Credentials, '__module__', 'dex_connectors.pipedrive.client')
|