dex-connector-shopify 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 (26) hide show
  1. dex_connector_shopify-0.1.0/.gitignore +6 -0
  2. dex_connector_shopify-0.1.0/PKG-INFO +49 -0
  3. dex_connector_shopify-0.1.0/README.md +38 -0
  4. dex_connector_shopify-0.1.0/examples/resource_read/__init__.py +3 -0
  5. dex_connector_shopify-0.1.0/examples/resource_read/flow.py +95 -0
  6. dex_connector_shopify-0.1.0/examples/resource_read/worker.py +51 -0
  7. dex_connector_shopify-0.1.0/pyproject.toml +37 -0
  8. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/__init__.py +50 -0
  9. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/__init__.py +2 -0
  10. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/config.py +25 -0
  11. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/connection.py +139 -0
  12. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/definitions.py +58 -0
  13. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/mock.py +119 -0
  14. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/models.py +66 -0
  15. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/_generated/steps.py +134 -0
  16. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/client.py +337 -0
  17. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/connection.py +50 -0
  18. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/dex-connector.json +87 -0
  19. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/models.py +22 -0
  20. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/py.typed +0 -0
  21. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/shopifymock/__init__.py +44 -0
  22. dex_connector_shopify-0.1.0/src/dex_connectors/shopify/steps.py +33 -0
  23. dex_connector_shopify-0.1.0/tests/test_conformance.py +34 -0
  24. dex_connector_shopify-0.1.0/tests/test_manifest_contract.py +15 -0
  25. dex_connector_shopify-0.1.0/tests/test_operations.py +146 -0
  26. dex_connector_shopify-0.1.0/uv.lock +932 -0
@@ -0,0 +1,6 @@
1
+ /.dex-local/dexcli
2
+ /.dex-local/dex-server-zd
3
+ /.dex-local/data/
4
+ /.dex-local/cli.log
5
+ /.dex-local/visualize.json
6
+ /.dex-local/visualize.err
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-shopify
3
+ Version: 0.1.0
4
+ Summary: Shopify connector for Dex Flows
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: dex-connectors-sdk==0.1.0
8
+ Requires-Dist: dex-python-sdk>=1.28.0
9
+ Requires-Dist: httpx>=0.27
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Shopify connector for Python
13
+
14
+ Install with `pip install dex-connector-shopify==0.1.0`. The package requires
15
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
16
+ manifest Queries `getOrder` and `listOrders` with the same branches, defaults,
17
+ and failure classification as the Go module.
18
+
19
+ ## Operations
20
+
21
+ | Operation | Factory | Happy branch | Optional branches |
22
+ | --- | --- | --- | --- |
23
+ | `getOrder` | `new_get_order_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
24
+ | `listOrders` | `new_list_orders_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
25
+
26
+ Requests go to `https://<shopSubdomain>.myshopify.com/admin/api/2026-10`.
27
+ `getOrder` requires a positive order ID and unwraps Shopify's `order` object;
28
+ `listOrders` reads orders in any status with an optional `limit` of at most
29
+ 250. HTTP 404 selects `notFound`; 408, 429, 5xx, and transport failures retry;
30
+ 401, 403, and other non-200 responses select `providerRejected`.
31
+
32
+ ## Authorization
33
+
34
+ Create a Dex Web connection named `shopify` as described in the
35
+ [connector README](../README.md#authentication-and-configuration). The Admin
36
+ API access token travels only in `X-Shopify-Access-Token` and is resolved for
37
+ every attempt.
38
+
39
+ ## Example
40
+
41
+ [`examples/resource_read`](examples/resource_read/flow.py) reads one order and
42
+ records it. Run the Worker with
43
+ `uv run python -m examples.resource_read.worker` after `dexcli dev` has loaded
44
+ a project containing the `shopify` connection.
45
+
46
+ ## Tests
47
+
48
+ `shopifymock.Mock` scripts both Queries and defaults to the manifest answers.
49
+ Run `uv run pytest tests` for provider parity and manifest contract checks.
@@ -0,0 +1,38 @@
1
+ # Shopify connector for Python
2
+
3
+ Install with `pip install dex-connector-shopify==0.1.0`. The package requires
4
+ `dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
5
+ manifest Queries `getOrder` and `listOrders` with the same branches, defaults,
6
+ and failure classification as the Go module.
7
+
8
+ ## Operations
9
+
10
+ | Operation | Factory | Happy branch | Optional branches |
11
+ | --- | --- | --- | --- |
12
+ | `getOrder` | `new_get_order_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
13
+ | `listOrders` | `new_list_orders_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
14
+
15
+ Requests go to `https://<shopSubdomain>.myshopify.com/admin/api/2026-10`.
16
+ `getOrder` requires a positive order ID and unwraps Shopify's `order` object;
17
+ `listOrders` reads orders in any status with an optional `limit` of at most
18
+ 250. HTTP 404 selects `notFound`; 408, 429, 5xx, and transport failures retry;
19
+ 401, 403, and other non-200 responses select `providerRejected`.
20
+
21
+ ## Authorization
22
+
23
+ Create a Dex Web connection named `shopify` as described in the
24
+ [connector README](../README.md#authentication-and-configuration). The Admin
25
+ API access token travels only in `X-Shopify-Access-Token` and is resolved for
26
+ every attempt.
27
+
28
+ ## Example
29
+
30
+ [`examples/resource_read`](examples/resource_read/flow.py) reads one order and
31
+ records it. Run the Worker with
32
+ `uv run python -m examples.resource_read.worker` after `dexcli dev` has loaded
33
+ a project containing the `shopify` connection.
34
+
35
+ ## Tests
36
+
37
+ `shopifymock.Mock` scripts both Queries and defaults to the manifest answers.
38
+ Run `uv run pytest tests` for provider parity and manifest contract checks.
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Shopify resource read example Flow."""
@@ -0,0 +1,95 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable Shopify resource read Flow using the listPayments Query."""
4
+
5
+ from dataclasses import dataclass, field
6
+
7
+ import dex
8
+ from dex_connectors.sdk import QueryResult
9
+
10
+ from dex_connectors.shopify import Connection, GetOrderInput, Order, new_get_order_step
11
+
12
+ FLOW_TYPE = "ShopifyResourceRead"
13
+ CONNECTION_NAME = "shopify"
14
+ _READ_STEP_TYPE = "ReadShopifyResource"
15
+
16
+
17
+ @dataclass(frozen=True, slots=True)
18
+ class ResourceReadRequest:
19
+ """Positive Shopify order ID to read."""
20
+
21
+ order_id: int = field(default=0, metadata={"dex_json_name": "orderID"})
22
+
23
+
24
+ @dataclass(frozen=True, slots=True)
25
+ class ResourceReadOutcome:
26
+ """The order Shopify returned."""
27
+
28
+ value: Order = field(default_factory=Order)
29
+
30
+
31
+ _OUTCOME = dex.Attribute("shopify-resource-read-outcome", ResourceReadOutcome)
32
+
33
+
34
+ def map_to_operation_input(request: ResourceReadRequest) -> GetOrderInput:
35
+ """Read the requested order."""
36
+ return GetOrderInput(request.order_id)
37
+
38
+
39
+ # dex:group group-id:resource-read group-label:"Resource read"
40
+ # dex:explanation text:"Validate the request before reading the provider."
41
+ class _PrepareRequest(dex.Step[ResourceReadRequest]):
42
+ def get_step_type(self) -> str:
43
+ return "PrepareResourceRead"
44
+
45
+ def execute(self, context: dex.Context, input: ResourceReadRequest) -> dex.StepDecision:
46
+ if input.order_id <= 0:
47
+ return dex.force_fail("OrderID must be positive")
48
+ return dex.go_to(dex.StepRef(_READ_STEP_TYPE), input)
49
+
50
+
51
+ # dex:group group-id:resource-read group-label:"Resource read"
52
+ # dex:explanation text:"Record the order and complete the Flow."
53
+ class _CompleteRead(dex.Step[QueryResult[Order]]):
54
+ def get_step_type(self) -> str:
55
+ return "CompleteResourceRead"
56
+
57
+ def execute(self, context: dex.Context, input: QueryResult[Order]) -> dex.StepDecision:
58
+ outcome = ResourceReadOutcome(input.value)
59
+ _OUTCOME.set(context, outcome)
60
+ return dex.graceful_complete(outcome)
61
+
62
+
63
+ class ResourceReadFlow(dex.Flow[ResourceReadRequest]):
64
+ """Read one Shopify order through the static shopify connection."""
65
+
66
+ def __init__(self, connection: Connection) -> None:
67
+ if connection.reference.name != CONNECTION_NAME:
68
+ raise ValueError("resource read requires the static shopify connection")
69
+ self._prepare = _PrepareRequest()
70
+ self._complete = _CompleteRead()
71
+ self._read = new_get_order_step(
72
+ step_type=_READ_STEP_TYPE,
73
+ step_input_type=ResourceReadRequest,
74
+ annotations={
75
+ "groupId": "shopify",
76
+ "groupLabel": "Shopify",
77
+ "explanation": "Read the requested Shopify resource.",
78
+ },
79
+ connection=connection,
80
+ connection_name=CONNECTION_NAME,
81
+ map_to_operation_input=map_to_operation_input,
82
+ found=self._complete,
83
+ )
84
+
85
+ def get_flow_type(self) -> str:
86
+ """Return the stable Flow identity used in Dex Web."""
87
+ return FLOW_TYPE
88
+
89
+ def get_steps(self) -> dex.StepList[ResourceReadRequest]:
90
+ """Register request preparation, the Shopify read, and completion Steps."""
91
+ return dex.StepList.start_step(self._prepare).other_steps(self._read, self._complete)
92
+
93
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
94
+ """Persist the order outcome."""
95
+ return dex.PersistenceSchema.of(_OUTCOME)
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the Shopify resource read 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.shopify import new_project_connection
14
+
15
+ from .flow import CONNECTION_NAME, ResourceReadFlow
16
+
17
+
18
+ async def run_worker() -> None:
19
+ """Load the named Dex Web connection and serve Shopify resource reads."""
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([ResourceReadFlow(connection)], allow_async_handlers=True)
26
+ cache_directory = os.environ.get(
27
+ "DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-shopify-resource-read-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 until the Worker stops or the process receives an interrupt."""
47
+ asyncio.run(run_worker())
48
+
49
+
50
+ if __name__ == "__main__":
51
+ main()
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dex-connector-shopify"
7
+ version = "0.1.0"
8
+ description = "Shopify connector for Dex Flows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
13
+
14
+ [dependency-groups]
15
+ dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
16
+
17
+ [tool.hatch.build.targets.wheel]
18
+ packages = ["src/dex_connectors"]
19
+
20
+ [tool.pytest.ini_options]
21
+ testpaths = ["tests"]
22
+ pythonpath = [".", "src"]
23
+ asyncio_mode = "auto"
24
+ asyncio_default_fixture_loop_scope = "function"
25
+
26
+ [tool.mypy]
27
+ python_version = "3.11"
28
+ strict = true
29
+ mypy_path = "src"
30
+ explicit_package_bases = true
31
+
32
+ [tool.ruff]
33
+ target-version = "py311"
34
+ line-length = 110
35
+
36
+ [tool.ruff.lint]
37
+ select = ["E", "F", "I", "UP", "B"]
@@ -0,0 +1,50 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Shopify order Queries for Dex connector Steps."""
4
+
5
+ from .client import (
6
+ CONNECTOR_ID,
7
+ DEFECT,
8
+ FOUND,
9
+ GET_ORDER_DEFINITION,
10
+ INVALID_RESPONSE,
11
+ LIST_ORDERS_DEFINITION,
12
+ LISTED,
13
+ NOT_FOUND,
14
+ PROVIDER_REJECTED,
15
+ Client,
16
+ Config,
17
+ Credentials,
18
+ GetOrderOperation,
19
+ ListOrdersOperation,
20
+ )
21
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
22
+ from .models import GetOrderInput, ListOrdersInput, Order, OrderPage
23
+ from .steps import new_get_order_step, new_list_orders_step
24
+
25
+ __all__ = [
26
+ "Client",
27
+ "Config",
28
+ "Connection",
29
+ "Credentials",
30
+ "GetOrderInput",
31
+ "GetOrderOperation",
32
+ "ListOrdersInput",
33
+ "ListOrdersOperation",
34
+ "Order",
35
+ "OrderPage",
36
+ "new_connection",
37
+ "new_connection_with_operations",
38
+ "new_get_order_step",
39
+ "new_list_orders_step",
40
+ "new_project_connection",
41
+ "CONNECTOR_ID",
42
+ "DEFECT",
43
+ "FOUND",
44
+ "GET_ORDER_DEFINITION",
45
+ "INVALID_RESPONSE",
46
+ "LIST_ORDERS_DEFINITION",
47
+ "LISTED",
48
+ "NOT_FOUND",
49
+ "PROVIDER_REJECTED",
50
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,25 @@
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
+ shop_subdomain: str
14
+ timeout_seconds: float = 15
15
+ max_response_bytes: int = 2097152
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.shopify.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ access_token: SecretString
24
+
25
+ setattr(Credentials, '__module__', 'dex_connectors.shopify.client')
@@ -0,0 +1,139 @@
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, Query, Call, SecretString
9
+ from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
10
+
11
+ from ..client import Client, Config, Credentials
12
+ from .definitions import CONNECTOR_ID, GET_ORDER_DEFINITION, LIST_ORDERS_DEFINITION
13
+ from ..models import GetOrderInput, ListOrdersInput, Order, OrderPage
14
+
15
+ class Connection:
16
+
17
+ __slots__ = ('_list_orders', '_get_order', '_client', 'reference')
18
+
19
+ def __init__(self,
20
+ reference: ConnectionRef,
21
+ list_orders: Query[ListOrdersInput, OrderPage],
22
+ get_order: Query[GetOrderInput, Order],
23
+ client: Client | None = None,
24
+ ) -> None:
25
+ reference.validate()
26
+ if reference.provider != CONNECTOR_ID or list_orders is None or get_order is None:
27
+ raise ValueError("Shopify connection provider and operations are required")
28
+ if list_orders.definition().operation != LIST_ORDERS_DEFINITION.operation:
29
+ raise ValueError("Shopify connection operation identity differs")
30
+ if get_order.definition().operation != GET_ORDER_DEFINITION.operation:
31
+ raise ValueError("Shopify connection operation identity differs")
32
+ self.reference = reference
33
+ self._list_orders = list_orders
34
+ self._get_order = get_order
35
+ self._client = client
36
+
37
+ def list_orders(self) -> Query[ListOrdersInput, OrderPage]:
38
+ return self._list_orders
39
+
40
+ def get_order(self) -> Query[GetOrderInput, Order]:
41
+ return self._get_order
42
+
43
+ async def aclose(self) -> None:
44
+ if self._client is not None:
45
+ await self._client.aclose()
46
+
47
+ def __repr__(self) -> str:
48
+ return "shopify.Connection([REDACTED])"
49
+
50
+ def __reduce__(self) -> tuple[object, ...]:
51
+ raise TypeError("Shopify connections cannot be serialized")
52
+
53
+ setattr(Connection, '__module__', 'dex_connectors.shopify.connection')
54
+
55
+
56
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
57
+ if client is None:
58
+ raise ValueError("Shopify client is required")
59
+ return Connection(reference, client.list_orders(), client.get_order(), client)
60
+
61
+ setattr(new_connection, '__module__', 'dex_connectors.shopify.connection')
62
+
63
+
64
+ def new_connection_with_operations(
65
+ list_orders: Query[ListOrdersInput, OrderPage],
66
+ get_order: Query[GetOrderInput, Order],
67
+ reference: ConnectionRef,
68
+ ) -> Connection:
69
+ return Connection(reference, list_orders, get_order)
70
+
71
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.shopify.connection')
72
+
73
+
74
+ class _ProjectCredentialSource:
75
+
76
+ def __init__(self, project: LoadedProject, key: ConnectionKey) -> None:
77
+ self.project = project
78
+ self.key = key
79
+
80
+ async def resolve(self, call: Call) -> Credentials:
81
+ material = await self.project.resolve_credential(self.key, str(call.id))
82
+ if not isinstance(material, dict):
83
+ raise ValueError("Shopify stored credential does not match the connector credential fields")
84
+ if set(material) - set(('access_token',)):
85
+ raise ValueError("Shopify stored credential does not match the connector credential fields")
86
+ access_token = material.get("access_token")
87
+ if access_token is not None and not (isinstance(access_token, str)):
88
+ raise ValueError("Shopify credential access_token has an invalid type")
89
+ if not access_token:
90
+ raise ValueError("Shopify credential access_token is required")
91
+ return Credentials(SecretString(access_token))
92
+
93
+
94
+ def new_project_connection(
95
+ project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
96
+ ) -> Connection:
97
+ if project is None:
98
+ raise ValueError("Shopify connection requires loaded project configuration")
99
+ reference = ConnectionRef(CONNECTOR_ID, connection_name)
100
+ reference.validate()
101
+ key = ConnectionKey(CONNECTOR_ID, connection_name)
102
+ matching = [
103
+ entry
104
+ for entry in project.configuration.connections
105
+ if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
106
+ ]
107
+ if len(matching) != 1:
108
+ raise ValueError("Shopify project connection is missing or duplicated")
109
+ if matching[0].provider != CONNECTOR_ID:
110
+ raise ValueError("Shopify project connection provider differs")
111
+ config = _decode_config(matching[0].configuration)
112
+ client = Client(config, _ProjectCredentialSource(project, key), http_client)
113
+ return new_connection(client, reference)
114
+
115
+ setattr(new_project_connection, '__module__', 'dex_connectors.shopify.connection')
116
+
117
+
118
+ def _decode_config(value: dict[str, Any]) -> Config:
119
+ if set(value) - {"shopSubdomain", "timeout", "maxResponseBytes"}:
120
+ raise ValueError("Shopify configuration has unknown fields")
121
+ config_arguments: dict[str, Any] = {}
122
+ if "shopSubdomain" in value:
123
+ shop_subdomain = value["shopSubdomain"]
124
+ if not (isinstance(shop_subdomain, str)):
125
+ raise ValueError("Shopify configuration shopSubdomain has an invalid type")
126
+ config_arguments['shop_subdomain'] = shop_subdomain
127
+ else:
128
+ raise ValueError("Shopify configuration shopSubdomain is required")
129
+ if "timeout" in value:
130
+ timeout = value["timeout"]
131
+ if not (type(timeout) is int):
132
+ raise ValueError("Shopify configuration timeout has an invalid type")
133
+ config_arguments['timeout_seconds'] = timeout / 1_000_000_000
134
+ if "maxResponseBytes" in value:
135
+ max_response_bytes = value["maxResponseBytes"]
136
+ if not (type(max_response_bytes) is int):
137
+ raise ValueError("Shopify configuration maxResponseBytes has an invalid type")
138
+ config_arguments['max_response_bytes'] = max_response_bytes
139
+ return Config(**config_arguments)
@@ -0,0 +1,58 @@
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 = "shopify"
18
+ PROVIDER = "shopify"
19
+ LIST_ORDERS_OPERATION_ID = "listOrders"
20
+ GET_ORDER_OPERATION_ID = "getOrder"
21
+ DEFECT = "defect"
22
+ FOUND = "found"
23
+ INVALID_RESPONSE = "invalidResponse"
24
+ LISTED = "listed"
25
+ NOT_FOUND = "notFound"
26
+ PROVIDER_REJECTED = "providerRejected"
27
+
28
+ LIST_ORDERS_DEFINITION = QueryDefinition(
29
+ OperationRef(CONNECTOR_ID, LIST_ORDERS_OPERATION_ID),
30
+ (
31
+ BranchDefinition(LISTED, "List one page of Shopify orders.", False),
32
+ BranchDefinition(NOT_FOUND, "The requested resource was not found.", True),
33
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request.", True),
34
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
35
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
36
+ ),
37
+ StepDefaults(
38
+ timedelta(seconds=30),
39
+ 2,
40
+ execute_retry=default_connector_step_execute_retry_policy(),
41
+ ),
42
+ )
43
+
44
+ GET_ORDER_DEFINITION = QueryDefinition(
45
+ OperationRef(CONNECTOR_ID, GET_ORDER_OPERATION_ID),
46
+ (
47
+ BranchDefinition(FOUND, "Read one Shopify order.", False),
48
+ BranchDefinition(NOT_FOUND, "The requested resource was not found.", True),
49
+ BranchDefinition(PROVIDER_REJECTED, "The provider conclusively rejected the request.", True),
50
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
51
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
52
+ ),
53
+ StepDefaults(
54
+ timedelta(seconds=30),
55
+ 2,
56
+ execute_retry=default_connector_step_execute_retry_policy(),
57
+ ),
58
+ )