airbyte-agent-shopify 0.1.23__tar.gz → 0.1.24__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.
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/CHANGELOG.md +5 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/PKG-INFO +3 -3
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/README.md +2 -2
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/__init__.py +6 -6
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/cloud_utils/client.py +62 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/connector_model_loader.py +1 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/executor/hosted_executor.py +54 -25
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/executor/local_executor.py +5 -12
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/security.py +5 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/types.py +4 -0
- airbyte_agent_shopify-0.1.24/airbyte_agent_shopify/_vendored/connector_sdk/utils.py +127 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/validation.py +131 -3
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/connector.py +112 -9
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/pyproject.toml +1 -1
- airbyte_agent_shopify-0.1.23/airbyte_agent_shopify/_vendored/connector_sdk/utils.py +0 -60
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/.gitignore +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/AUTH.md +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/REFERENCE.md +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/auth_strategies.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/auth_template.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/cloud_utils/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/constants.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/exceptions.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/executor/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/executor/models.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/extensions.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/adapters/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/adapters/httpx_adapter.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/config.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/exceptions.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/protocols.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http/response.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/http_client.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/introspection.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/logging/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/logging/logger.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/logging/types.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/observability/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/observability/config.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/observability/models.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/observability/redactor.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/observability/session.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/performance/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/performance/instrumentation.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/performance/metrics.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/base.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/components.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/connector.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/extensions.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/schema/operations.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/secrets.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/telemetry/__init__.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/telemetry/config.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/telemetry/events.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/telemetry/tracker.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/_vendored/connector_sdk/validation_replication.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/connector_model.py +0 -0
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/models.py +65 -65
- {airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/types.py +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Shopify changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.24] - 2026-01-30
|
|
4
|
+
- Updated connector definition (YAML version 0.1.3)
|
|
5
|
+
- Source commit: b184da3e
|
|
6
|
+
- SDK version: 0.1.0
|
|
7
|
+
|
|
3
8
|
## [0.1.23] - 2026-01-30
|
|
4
9
|
- Updated connector definition (YAML version 0.1.3)
|
|
5
10
|
- Source commit: 5f65d643
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: airbyte-agent-shopify
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.24
|
|
4
4
|
Summary: Airbyte Shopify Connector for AI platforms
|
|
5
5
|
Project-URL: Homepage, https://github.com/airbytehq/airbyte-agent-connectors
|
|
6
6
|
Project-URL: Documentation, https://docs.airbyte.com/ai-agents/
|
|
@@ -171,7 +171,7 @@ See the official [Shopify API reference](https://shopify.dev/docs/api/admin-rest
|
|
|
171
171
|
|
|
172
172
|
## Version information
|
|
173
173
|
|
|
174
|
-
- **Package version:** 0.1.
|
|
174
|
+
- **Package version:** 0.1.24
|
|
175
175
|
- **Connector version:** 0.1.3
|
|
176
|
-
- **Generated with Connector SDK commit SHA:**
|
|
176
|
+
- **Generated with Connector SDK commit SHA:** b184da3e22ef8521d2eeebf3c96a0fe8da2424f5
|
|
177
177
|
- **Changelog:** [View changelog](https://github.com/airbytehq/airbyte-agent-connectors/blob/main/connectors/shopify/CHANGELOG.md)
|
|
@@ -138,7 +138,7 @@ See the official [Shopify API reference](https://shopify.dev/docs/api/admin-rest
|
|
|
138
138
|
|
|
139
139
|
## Version information
|
|
140
140
|
|
|
141
|
-
- **Package version:** 0.1.
|
|
141
|
+
- **Package version:** 0.1.24
|
|
142
142
|
- **Connector version:** 0.1.3
|
|
143
|
-
- **Generated with Connector SDK commit SHA:**
|
|
143
|
+
- **Generated with Connector SDK commit SHA:** b184da3e22ef8521d2eeebf3c96a0fe8da2424f5
|
|
144
144
|
- **Changelog:** [View changelog](https://github.com/airbytehq/airbyte-agent-connectors/blob/main/connectors/shopify/CHANGELOG.md)
|
{airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/__init__.py
RENAMED
|
@@ -13,14 +13,14 @@ from .models import (
|
|
|
13
13
|
CustomerAddressList,
|
|
14
14
|
MarketingConsent,
|
|
15
15
|
OrderAddress,
|
|
16
|
-
Transaction,
|
|
17
|
-
Refund,
|
|
18
16
|
LineItem,
|
|
19
17
|
Fulfillment,
|
|
18
|
+
Transaction,
|
|
19
|
+
Refund,
|
|
20
20
|
Order,
|
|
21
21
|
OrderList,
|
|
22
|
-
ProductImage,
|
|
23
22
|
ProductVariant,
|
|
23
|
+
ProductImage,
|
|
24
24
|
Product,
|
|
25
25
|
ProductList,
|
|
26
26
|
ProductVariantList,
|
|
@@ -187,14 +187,14 @@ __all__ = [
|
|
|
187
187
|
"CustomerAddressList",
|
|
188
188
|
"MarketingConsent",
|
|
189
189
|
"OrderAddress",
|
|
190
|
-
"Transaction",
|
|
191
|
-
"Refund",
|
|
192
190
|
"LineItem",
|
|
193
191
|
"Fulfillment",
|
|
192
|
+
"Transaction",
|
|
193
|
+
"Refund",
|
|
194
194
|
"Order",
|
|
195
195
|
"OrderList",
|
|
196
|
-
"ProductImage",
|
|
197
196
|
"ProductVariant",
|
|
197
|
+
"ProductImage",
|
|
198
198
|
"Product",
|
|
199
199
|
"ProductList",
|
|
200
200
|
"ProductVariantList",
|
|
@@ -161,6 +161,68 @@ class AirbyteCloudClient:
|
|
|
161
161
|
connector_id = connectors[0]["id"]
|
|
162
162
|
return connector_id
|
|
163
163
|
|
|
164
|
+
async def create_source(
|
|
165
|
+
self,
|
|
166
|
+
name: str,
|
|
167
|
+
connector_definition_id: str,
|
|
168
|
+
external_user_id: str,
|
|
169
|
+
credentials: dict[str, Any],
|
|
170
|
+
replication_config: dict[str, Any] | None = None,
|
|
171
|
+
) -> str:
|
|
172
|
+
"""Create a new source on Airbyte Agent Platform.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
name: Source name
|
|
176
|
+
connector_definition_id: UUID of the connector definition
|
|
177
|
+
external_user_id: User identifier
|
|
178
|
+
credentials: Connector auth config dict
|
|
179
|
+
replication_config: Optional replication settings (e.g., start_date for
|
|
180
|
+
connectors with x-airbyte-replication-config). Required for REPLICATION
|
|
181
|
+
mode sources like Intercom.
|
|
182
|
+
|
|
183
|
+
Returns:
|
|
184
|
+
The created source ID (UUID string)
|
|
185
|
+
|
|
186
|
+
Raises:
|
|
187
|
+
httpx.HTTPStatusError: If creation fails
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
source_id = await client.create_source(
|
|
191
|
+
name="My Gong Source",
|
|
192
|
+
connector_definition_id="32382e40-3b49-4b99-9c5c-4076501914e7",
|
|
193
|
+
external_user_id="my-workspace",
|
|
194
|
+
credentials={"access_key": "...", "access_key_secret": "..."}
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
# For REPLICATION mode sources (e.g., Intercom):
|
|
198
|
+
source_id = await client.create_source(
|
|
199
|
+
name="My Intercom Source",
|
|
200
|
+
connector_definition_id="d8313939-3782-41b0-be29-b3ca20d8dd3a",
|
|
201
|
+
external_user_id="my-workspace",
|
|
202
|
+
credentials={"access_token": "..."},
|
|
203
|
+
replication_config={"start_date": "2024-01-01T00:00:00Z"}
|
|
204
|
+
)
|
|
205
|
+
"""
|
|
206
|
+
token = await self.get_bearer_token()
|
|
207
|
+
url = f"{self.API_BASE_URL}/v1/integrations/connectors"
|
|
208
|
+
headers = {"Authorization": f"Bearer {token}"}
|
|
209
|
+
|
|
210
|
+
request_body: dict[str, Any] = {
|
|
211
|
+
"name": name,
|
|
212
|
+
"definition_id": connector_definition_id,
|
|
213
|
+
"external_user_id": external_user_id,
|
|
214
|
+
"credentials": credentials,
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if replication_config is not None:
|
|
218
|
+
request_body["replication_config"] = replication_config
|
|
219
|
+
|
|
220
|
+
response = await self._http_client.post(url, json=request_body, headers=headers)
|
|
221
|
+
response.raise_for_status()
|
|
222
|
+
|
|
223
|
+
data = response.json()
|
|
224
|
+
return data["id"]
|
|
225
|
+
|
|
164
226
|
async def execute_connector(
|
|
165
227
|
self,
|
|
166
228
|
connector_id: str,
|
|
@@ -1014,6 +1014,7 @@ def _parse_security_scheme_to_option(scheme_name: str, scheme: Any) -> AuthOptio
|
|
|
1014
1014
|
type=single_auth.type,
|
|
1015
1015
|
config=single_auth.config,
|
|
1016
1016
|
user_config_spec=single_auth.user_config_spec,
|
|
1017
|
+
untested=getattr(scheme, "x_airbyte_untested", False),
|
|
1017
1018
|
)
|
|
1018
1019
|
|
|
1019
1020
|
|
|
@@ -19,19 +19,26 @@ class HostedExecutor:
|
|
|
19
19
|
instead of directly calling external services. The cloud API handles all
|
|
20
20
|
connector logic, secrets management, and execution.
|
|
21
21
|
|
|
22
|
-
The executor
|
|
22
|
+
The executor uses the AirbyteCloudClient to:
|
|
23
23
|
1. Authenticate with the Airbyte Platform (bearer token with caching)
|
|
24
|
-
2. Look up the user's connector
|
|
24
|
+
2. Look up the user's connector (if connector_id not provided)
|
|
25
25
|
3. Execute the connector operation via the cloud API
|
|
26
26
|
|
|
27
27
|
Implements ExecutorProtocol.
|
|
28
28
|
|
|
29
29
|
Example:
|
|
30
|
-
# Create executor with
|
|
30
|
+
# Create executor with explicit connector_id (no lookup needed)
|
|
31
|
+
executor = HostedExecutor(
|
|
32
|
+
airbyte_client_id="client_abc123",
|
|
33
|
+
airbyte_client_secret="secret_xyz789",
|
|
34
|
+
connector_id="existing-source-uuid",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Or create executor with user ID for lookup
|
|
31
38
|
executor = HostedExecutor(
|
|
32
|
-
external_user_id="user-123",
|
|
33
39
|
airbyte_client_id="client_abc123",
|
|
34
40
|
airbyte_client_secret="secret_xyz789",
|
|
41
|
+
external_user_id="user-123",
|
|
35
42
|
connector_definition_id="abc123-def456-ghi789",
|
|
36
43
|
)
|
|
37
44
|
|
|
@@ -51,28 +58,48 @@ class HostedExecutor:
|
|
|
51
58
|
|
|
52
59
|
def __init__(
|
|
53
60
|
self,
|
|
54
|
-
external_user_id: str,
|
|
55
61
|
airbyte_client_id: str,
|
|
56
62
|
airbyte_client_secret: str,
|
|
57
|
-
|
|
63
|
+
connector_id: str | None = None,
|
|
64
|
+
external_user_id: str | None = None,
|
|
65
|
+
connector_definition_id: str | None = None,
|
|
58
66
|
):
|
|
59
67
|
"""Initialize hosted executor.
|
|
60
68
|
|
|
69
|
+
Either provide connector_id directly OR (external_user_id + connector_definition_id)
|
|
70
|
+
for lookup.
|
|
71
|
+
|
|
61
72
|
Args:
|
|
62
|
-
external_user_id: User identifier in the Airbyte system
|
|
63
73
|
airbyte_client_id: Airbyte client ID for authentication
|
|
64
74
|
airbyte_client_secret: Airbyte client secret for authentication
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
connector_id: Direct connector/source ID (skips lookup if provided)
|
|
76
|
+
external_user_id: User identifier in the Airbyte system (for lookup)
|
|
77
|
+
connector_definition_id: Connector definition ID (for lookup)
|
|
78
|
+
|
|
79
|
+
Raises:
|
|
80
|
+
ValueError: If neither connector_id nor (external_user_id + connector_definition_id) provided
|
|
67
81
|
|
|
68
82
|
Example:
|
|
83
|
+
# With explicit connector_id (no lookup)
|
|
84
|
+
executor = HostedExecutor(
|
|
85
|
+
airbyte_client_id="client_abc123",
|
|
86
|
+
airbyte_client_secret="secret_xyz789",
|
|
87
|
+
connector_id="existing-source-uuid",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# With lookup by user + definition
|
|
69
91
|
executor = HostedExecutor(
|
|
70
|
-
external_user_id="user-123",
|
|
71
92
|
airbyte_client_id="client_abc123",
|
|
72
93
|
airbyte_client_secret="secret_xyz789",
|
|
94
|
+
external_user_id="user-123",
|
|
73
95
|
connector_definition_id="abc123-def456-ghi789",
|
|
74
96
|
)
|
|
75
97
|
"""
|
|
98
|
+
# Validate: either connector_id OR (external_user_id + connector_definition_id) required
|
|
99
|
+
if not connector_id and not (external_user_id and connector_definition_id):
|
|
100
|
+
raise ValueError("Either connector_id OR (external_user_id + connector_definition_id) must be provided")
|
|
101
|
+
|
|
102
|
+
self._connector_id = connector_id
|
|
76
103
|
self._external_user_id = external_user_id
|
|
77
104
|
self._connector_definition_id = connector_definition_id
|
|
78
105
|
|
|
@@ -86,10 +113,9 @@ class HostedExecutor:
|
|
|
86
113
|
"""Execute connector via cloud API (ExecutorProtocol implementation).
|
|
87
114
|
|
|
88
115
|
Flow:
|
|
89
|
-
1.
|
|
90
|
-
2.
|
|
91
|
-
3.
|
|
92
|
-
4. Parse the response into ExecutionResult
|
|
116
|
+
1. Use provided connector_id or look up from external_user_id + definition_id
|
|
117
|
+
2. Execute the connector operation via the cloud API
|
|
118
|
+
3. Parse the response into ExecutionResult
|
|
93
119
|
|
|
94
120
|
Args:
|
|
95
121
|
config: Execution configuration (entity, action, params)
|
|
@@ -98,7 +124,7 @@ class HostedExecutor:
|
|
|
98
124
|
ExecutionResult with success/failure status
|
|
99
125
|
|
|
100
126
|
Raises:
|
|
101
|
-
ValueError: If no connector or multiple connectors found for user
|
|
127
|
+
ValueError: If no connector or multiple connectors found for user (when doing lookup)
|
|
102
128
|
httpx.HTTPStatusError: If API returns 4xx/5xx status code
|
|
103
129
|
httpx.RequestError: If network request fails
|
|
104
130
|
|
|
@@ -114,23 +140,26 @@ class HostedExecutor:
|
|
|
114
140
|
|
|
115
141
|
with tracer.start_as_current_span("airbyte.hosted_executor.execute") as span:
|
|
116
142
|
# Add span attributes for observability
|
|
117
|
-
|
|
143
|
+
if self._connector_definition_id:
|
|
144
|
+
span.set_attribute("connector.definition_id", self._connector_definition_id)
|
|
118
145
|
span.set_attribute("connector.entity", config.entity)
|
|
119
146
|
span.set_attribute("connector.action", config.action)
|
|
120
|
-
|
|
147
|
+
if self._external_user_id:
|
|
148
|
+
span.set_attribute("user.external_id", self._external_user_id)
|
|
121
149
|
if config.params:
|
|
122
150
|
# Only add non-sensitive param keys
|
|
123
151
|
span.set_attribute("connector.param_keys", list(config.params.keys()))
|
|
124
152
|
|
|
125
153
|
try:
|
|
126
|
-
#
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
# Use provided connector_id or look it up
|
|
155
|
+
if self._connector_id:
|
|
156
|
+
connector_id = self._connector_id
|
|
157
|
+
else:
|
|
158
|
+
# Look up connector by external_user_id + definition_id
|
|
159
|
+
connector_id = await self._cloud_client.get_connector_id(
|
|
160
|
+
external_user_id=self._external_user_id, # type: ignore[arg-type]
|
|
161
|
+
connector_definition_id=self._connector_definition_id, # type: ignore[arg-type]
|
|
162
|
+
)
|
|
134
163
|
|
|
135
164
|
span.set_attribute("connector.connector_id", connector_id)
|
|
136
165
|
|
|
@@ -36,6 +36,7 @@ from ..types import (
|
|
|
36
36
|
EndpointDefinition,
|
|
37
37
|
EntityDefinition,
|
|
38
38
|
)
|
|
39
|
+
from ..utils import find_matching_auth_options
|
|
39
40
|
|
|
40
41
|
from .models import (
|
|
41
42
|
ActionNotSupportedError,
|
|
@@ -356,8 +357,8 @@ class LocalExecutor:
|
|
|
356
357
|
) -> tuple[AuthOption, dict[str, SecretStr]]:
|
|
357
358
|
"""Infer authentication scheme from provided credentials.
|
|
358
359
|
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
Uses shared utility find_matching_auth_options to match credentials
|
|
361
|
+
against each auth option's required fields.
|
|
361
362
|
|
|
362
363
|
Args:
|
|
363
364
|
user_credentials: User-provided credentials
|
|
@@ -375,16 +376,8 @@ class LocalExecutor:
|
|
|
375
376
|
# Get the credential keys provided by the user
|
|
376
377
|
provided_keys = set(user_credentials.keys())
|
|
377
378
|
|
|
378
|
-
#
|
|
379
|
-
matching_options
|
|
380
|
-
for option in options:
|
|
381
|
-
if option.user_config_spec and option.user_config_spec.required:
|
|
382
|
-
required_fields = set(option.user_config_spec.required)
|
|
383
|
-
if required_fields.issubset(provided_keys):
|
|
384
|
-
matching_options.append(option)
|
|
385
|
-
elif not option.user_config_spec or not option.user_config_spec.required:
|
|
386
|
-
# Option has no required fields - it matches any credentials
|
|
387
|
-
matching_options.append(option)
|
|
379
|
+
# Use shared utility to find matching options
|
|
380
|
+
matching_options = find_matching_auth_options(provided_keys, options)
|
|
388
381
|
|
|
389
382
|
# Handle matching results
|
|
390
383
|
if len(matching_options) == 0:
|
|
@@ -199,6 +199,11 @@ class SecurityScheme(BaseModel):
|
|
|
199
199
|
alias="x-airbyte-token-extract",
|
|
200
200
|
description="List of fields to extract from OAuth2 token responses and use as server variables",
|
|
201
201
|
)
|
|
202
|
+
x_airbyte_untested: bool = Field(
|
|
203
|
+
False,
|
|
204
|
+
alias="x-airbyte-untested",
|
|
205
|
+
description="Mark this auth scheme as untested to skip cassette coverage validation",
|
|
206
|
+
)
|
|
202
207
|
|
|
203
208
|
@field_validator("x_airbyte_token_extract", mode="after")
|
|
204
209
|
@classmethod
|
|
@@ -90,6 +90,10 @@ class AuthOption(BaseModel):
|
|
|
90
90
|
None,
|
|
91
91
|
description="User-facing credential specification from x-airbyte-auth-config",
|
|
92
92
|
)
|
|
93
|
+
untested: bool = Field(
|
|
94
|
+
False,
|
|
95
|
+
description="Mark this auth scheme as untested to skip cassette coverage validation",
|
|
96
|
+
)
|
|
93
97
|
|
|
94
98
|
|
|
95
99
|
class AuthConfig(BaseModel):
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""Utility functions for working with connectors."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import AsyncIterator
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from .types import AuthOption
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
async def save_download(
|
|
14
|
+
download_iterator: AsyncIterator[bytes],
|
|
15
|
+
path: str | Path,
|
|
16
|
+
*,
|
|
17
|
+
overwrite: bool = False,
|
|
18
|
+
) -> Path:
|
|
19
|
+
"""Save a download iterator to a file.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
download_iterator: AsyncIterator[bytes] from a download operation
|
|
23
|
+
path: File path where content should be saved
|
|
24
|
+
overwrite: Whether to overwrite existing file (default: False)
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
Absolute Path to the saved file
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
FileExistsError: If file exists and overwrite=False
|
|
31
|
+
OSError: If file cannot be written
|
|
32
|
+
|
|
33
|
+
Example:
|
|
34
|
+
>>> from .utils import save_download
|
|
35
|
+
>>>
|
|
36
|
+
>>> # Download and save a file
|
|
37
|
+
>>> result = await connector.download_article_attachment(id="123")
|
|
38
|
+
>>> file_path = await save_download(result, "./downloads/attachment.pdf")
|
|
39
|
+
>>> print(f"Downloaded to {file_path}")
|
|
40
|
+
Downloaded to /absolute/path/to/downloads/attachment.pdf
|
|
41
|
+
>>>
|
|
42
|
+
>>> # Overwrite existing file
|
|
43
|
+
>>> file_path = await save_download(result, "./downloads/attachment.pdf", overwrite=True)
|
|
44
|
+
"""
|
|
45
|
+
# Convert to Path object
|
|
46
|
+
file_path = Path(path).expanduser().resolve()
|
|
47
|
+
|
|
48
|
+
# Check if file exists
|
|
49
|
+
if file_path.exists() and not overwrite:
|
|
50
|
+
raise FileExistsError(f"File already exists: {file_path}. Use overwrite=True to replace it.")
|
|
51
|
+
|
|
52
|
+
# Create parent directories if needed
|
|
53
|
+
file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
|
|
55
|
+
# Stream content to file
|
|
56
|
+
try:
|
|
57
|
+
with open(file_path, "wb") as f:
|
|
58
|
+
async for chunk in download_iterator:
|
|
59
|
+
f.write(chunk)
|
|
60
|
+
except Exception as e:
|
|
61
|
+
# Clean up partial file on error
|
|
62
|
+
if file_path.exists():
|
|
63
|
+
file_path.unlink()
|
|
64
|
+
raise OSError(f"Failed to write file {file_path}: {e}") from e
|
|
65
|
+
|
|
66
|
+
return file_path
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def find_matching_auth_options(
|
|
70
|
+
provided_keys: set[str],
|
|
71
|
+
auth_options: list[AuthOption],
|
|
72
|
+
) -> list[AuthOption]:
|
|
73
|
+
"""Find auth options that match the provided credential keys.
|
|
74
|
+
|
|
75
|
+
This is the single source of truth for auth scheme inference logic,
|
|
76
|
+
used by both the executor (at runtime) and validation (for cassettes).
|
|
77
|
+
|
|
78
|
+
Matching logic:
|
|
79
|
+
- An option matches if all its required fields are present in provided_keys
|
|
80
|
+
- Options with no required fields match any credentials
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
provided_keys: Set of credential/auth_config keys
|
|
84
|
+
auth_options: List of AuthOption from the connector model
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
List of AuthOption that match the provided keys
|
|
88
|
+
"""
|
|
89
|
+
matching_options: list[AuthOption] = []
|
|
90
|
+
|
|
91
|
+
for option in auth_options:
|
|
92
|
+
if option.user_config_spec and option.user_config_spec.required:
|
|
93
|
+
required_fields = set(option.user_config_spec.required)
|
|
94
|
+
if required_fields.issubset(provided_keys):
|
|
95
|
+
matching_options.append(option)
|
|
96
|
+
elif not option.user_config_spec or not option.user_config_spec.required:
|
|
97
|
+
# Option has no required fields - it matches any credentials
|
|
98
|
+
matching_options.append(option)
|
|
99
|
+
|
|
100
|
+
return matching_options
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def infer_auth_scheme_name(
|
|
104
|
+
provided_keys: set[str],
|
|
105
|
+
auth_options: list[AuthOption],
|
|
106
|
+
) -> str | None:
|
|
107
|
+
"""Infer the auth scheme name from provided credential keys.
|
|
108
|
+
|
|
109
|
+
Uses find_matching_auth_options to find matches, then returns
|
|
110
|
+
the scheme name only if exactly one option matches.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
provided_keys: Set of credential/auth_config keys
|
|
114
|
+
auth_options: List of AuthOption from the connector model
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
The scheme_name if exactly one match, None otherwise
|
|
118
|
+
"""
|
|
119
|
+
if not provided_keys or not auth_options:
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
matching = find_matching_auth_options(provided_keys, auth_options)
|
|
123
|
+
|
|
124
|
+
if len(matching) == 1:
|
|
125
|
+
return matching[0].scheme_name
|
|
126
|
+
|
|
127
|
+
return None
|
|
@@ -21,7 +21,8 @@ from .connector_model_loader import (
|
|
|
21
21
|
load_connector_model,
|
|
22
22
|
)
|
|
23
23
|
from .testing.spec_loader import load_test_spec
|
|
24
|
-
from .types import Action, EndpointDefinition
|
|
24
|
+
from .types import Action, ConnectorModel, EndpointDefinition
|
|
25
|
+
from .utils import infer_auth_scheme_name
|
|
25
26
|
from .validation_replication import validate_replication_compatibility
|
|
26
27
|
|
|
27
28
|
|
|
@@ -53,6 +54,112 @@ def build_cassette_map(cassettes_dir: Path) -> Dict[Tuple[str, str], List[Path]]
|
|
|
53
54
|
return dict(cassette_map)
|
|
54
55
|
|
|
55
56
|
|
|
57
|
+
def build_auth_scheme_coverage(
|
|
58
|
+
cassettes_dir: Path,
|
|
59
|
+
auth_options: list | None = None,
|
|
60
|
+
) -> Tuple[Dict[str | None, List[Path]], List[Tuple[Path, set[str]]]]:
|
|
61
|
+
"""Build a map of auth_scheme -> list of cassette paths.
|
|
62
|
+
|
|
63
|
+
For multi-auth connectors, infers the auth scheme from the cassette's auth_config
|
|
64
|
+
keys using the same matching logic as the executor.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
cassettes_dir: Directory containing cassette YAML files
|
|
68
|
+
auth_options: List of AuthOption from the connector model (for inference)
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Tuple of:
|
|
72
|
+
- Dictionary mapping auth_scheme names (or None for single-auth) to cassette paths
|
|
73
|
+
- List of (cassette_path, auth_config_keys) for cassettes that couldn't be matched
|
|
74
|
+
"""
|
|
75
|
+
auth_scheme_map: Dict[str | None, List[Path]] = defaultdict(list)
|
|
76
|
+
unmatched_cassettes: List[Tuple[Path, set[str]]] = []
|
|
77
|
+
|
|
78
|
+
if not cassettes_dir.exists() or not cassettes_dir.is_dir():
|
|
79
|
+
return {}, []
|
|
80
|
+
|
|
81
|
+
for cassette_file in cassettes_dir.glob("*.yaml"):
|
|
82
|
+
try:
|
|
83
|
+
spec = load_test_spec(cassette_file, auth_config={})
|
|
84
|
+
|
|
85
|
+
# First, check if auth_scheme is explicitly set in the cassette
|
|
86
|
+
if spec.auth_scheme:
|
|
87
|
+
auth_scheme_map[spec.auth_scheme].append(cassette_file)
|
|
88
|
+
# Otherwise, try to infer from auth_config keys
|
|
89
|
+
elif spec.auth_config and auth_options:
|
|
90
|
+
auth_config_keys = set(spec.auth_config.keys())
|
|
91
|
+
inferred_scheme = infer_auth_scheme_name(auth_config_keys, auth_options)
|
|
92
|
+
if inferred_scheme is not None:
|
|
93
|
+
auth_scheme_map[inferred_scheme].append(cassette_file)
|
|
94
|
+
else:
|
|
95
|
+
# Couldn't infer - track as unmatched
|
|
96
|
+
unmatched_cassettes.append((cassette_file, auth_config_keys))
|
|
97
|
+
else:
|
|
98
|
+
# No auth_scheme and no auth_config - treat as None
|
|
99
|
+
auth_scheme_map[None].append(cassette_file)
|
|
100
|
+
except Exception:
|
|
101
|
+
continue
|
|
102
|
+
|
|
103
|
+
return dict(auth_scheme_map), unmatched_cassettes
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def validate_auth_scheme_coverage(
|
|
107
|
+
config: ConnectorModel,
|
|
108
|
+
cassettes_dir: Path,
|
|
109
|
+
) -> Tuple[bool, List[str], List[str], List[str], List[Tuple[Path, set[str]]]]:
|
|
110
|
+
"""Validate that each auth scheme has at least one cassette.
|
|
111
|
+
|
|
112
|
+
For multi-auth connectors, every defined auth scheme must have coverage
|
|
113
|
+
unless marked with x-airbyte-untested: true.
|
|
114
|
+
For single-auth connectors, this check is skipped (existing cassette checks suffice).
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
config: Loaded connector model
|
|
118
|
+
cassettes_dir: Directory containing cassette files
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
Tuple of (is_valid, errors, warnings, covered_schemes, unmatched_cassettes)
|
|
122
|
+
"""
|
|
123
|
+
errors: List[str] = []
|
|
124
|
+
warnings: List[str] = []
|
|
125
|
+
|
|
126
|
+
# Skip check for single-auth connectors
|
|
127
|
+
if not config.auth.is_multi_auth():
|
|
128
|
+
return True, errors, warnings, [], []
|
|
129
|
+
|
|
130
|
+
# Get all defined auth schemes, separating tested from untested
|
|
131
|
+
options = config.auth.options or []
|
|
132
|
+
|
|
133
|
+
# Build auth scheme coverage from cassettes (pass options for inference)
|
|
134
|
+
auth_scheme_coverage, unmatched_cassettes = build_auth_scheme_coverage(cassettes_dir, options)
|
|
135
|
+
tested_schemes = {opt.scheme_name for opt in options if not opt.untested}
|
|
136
|
+
untested_schemes = {opt.scheme_name for opt in options if opt.untested}
|
|
137
|
+
covered_schemes = {scheme for scheme in auth_scheme_coverage.keys() if scheme is not None}
|
|
138
|
+
|
|
139
|
+
# Find missing tested schemes (errors)
|
|
140
|
+
missing_tested = tested_schemes - covered_schemes
|
|
141
|
+
for scheme in sorted(missing_tested):
|
|
142
|
+
errors.append(
|
|
143
|
+
f"Auth scheme '{scheme}' has no cassette coverage. "
|
|
144
|
+
f"Record at least one cassette using this authentication method, "
|
|
145
|
+
f"or add 'x-airbyte-untested: true' to skip this check."
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Warn about untested schemes without coverage
|
|
149
|
+
missing_untested = untested_schemes - covered_schemes
|
|
150
|
+
for scheme in sorted(missing_untested):
|
|
151
|
+
warnings.append(
|
|
152
|
+
f"Auth scheme '{scheme}' is marked as untested (x-airbyte-untested: true) " f"and has no cassette coverage. Validation skipped."
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Warn about cassettes that couldn't be matched to any auth scheme
|
|
156
|
+
for cassette_path, auth_config_keys in unmatched_cassettes:
|
|
157
|
+
warnings.append(f"Cassette '{cassette_path.name}' could not be matched to any auth scheme. " f"auth_config keys: {sorted(auth_config_keys)}")
|
|
158
|
+
|
|
159
|
+
is_valid = len(missing_tested) == 0
|
|
160
|
+
return is_valid, errors, warnings, sorted(covered_schemes), unmatched_cassettes
|
|
161
|
+
|
|
162
|
+
|
|
56
163
|
def validate_response_against_schema(response_body: Any, schema: Dict[str, Any]) -> Tuple[bool, List[str]]:
|
|
57
164
|
"""Validate a response body against a JSON schema.
|
|
58
165
|
|
|
@@ -588,6 +695,9 @@ def validate_connector_readiness(connector_dir: str | Path) -> Dict[str, Any]:
|
|
|
588
695
|
cassettes_dir = connector_path / "tests" / "cassettes"
|
|
589
696
|
cassette_map = build_cassette_map(cassettes_dir)
|
|
590
697
|
|
|
698
|
+
# Validate auth scheme coverage for multi-auth connectors
|
|
699
|
+
auth_valid, auth_errors, auth_warnings, auth_covered_schemes, auth_unmatched_cassettes = validate_auth_scheme_coverage(config, cassettes_dir)
|
|
700
|
+
|
|
591
701
|
validation_results = []
|
|
592
702
|
total_operations = 0
|
|
593
703
|
operations_with_cassettes = 0
|
|
@@ -827,8 +937,12 @@ def validate_connector_readiness(connector_dir: str | Path) -> Dict[str, Any]:
|
|
|
827
937
|
if replication_result.get("registry_found", False):
|
|
828
938
|
total_warnings += len(replication_warnings)
|
|
829
939
|
|
|
830
|
-
#
|
|
831
|
-
|
|
940
|
+
# Merge auth scheme validation errors/warnings into totals
|
|
941
|
+
total_errors += len(auth_errors)
|
|
942
|
+
total_warnings += len(auth_warnings)
|
|
943
|
+
|
|
944
|
+
# Update success criteria to include replication and auth scheme validation
|
|
945
|
+
success = operations_missing_cassettes == 0 and cassettes_invalid == 0 and total_operations > 0 and len(replication_errors) == 0 and auth_valid
|
|
832
946
|
|
|
833
947
|
# Check for preferred_for_check on at least one list operation
|
|
834
948
|
has_preferred_check = False
|
|
@@ -849,12 +963,26 @@ def validate_connector_readiness(connector_dir: str | Path) -> Dict[str, Any]:
|
|
|
849
963
|
"to enable reliable health checks."
|
|
850
964
|
)
|
|
851
965
|
|
|
966
|
+
# Build auth scheme validation result
|
|
967
|
+
options = config.auth.options or []
|
|
968
|
+
tested_schemes = [opt.scheme_name for opt in options if not opt.untested]
|
|
969
|
+
untested_schemes_list = [opt.scheme_name for opt in options if opt.untested]
|
|
970
|
+
missing_tested = [s for s in tested_schemes if s not in auth_covered_schemes]
|
|
971
|
+
|
|
852
972
|
return {
|
|
853
973
|
"success": success,
|
|
854
974
|
"connector_name": config.name,
|
|
855
975
|
"connector_path": str(connector_path),
|
|
856
976
|
"validation_results": validation_results,
|
|
857
977
|
"replication_validation": replication_result,
|
|
978
|
+
"auth_scheme_validation": {
|
|
979
|
+
"valid": auth_valid,
|
|
980
|
+
"errors": auth_errors,
|
|
981
|
+
"warnings": auth_warnings,
|
|
982
|
+
"covered_schemes": auth_covered_schemes,
|
|
983
|
+
"missing_schemes": missing_tested,
|
|
984
|
+
"untested_schemes": untested_schemes_list,
|
|
985
|
+
},
|
|
858
986
|
"readiness_warnings": readiness_warnings,
|
|
859
987
|
"summary": {
|
|
860
988
|
"total_operations": total_operations,
|
{airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/connector.py
RENAMED
|
@@ -72,6 +72,7 @@ from .types import (
|
|
|
72
72
|
)
|
|
73
73
|
if TYPE_CHECKING:
|
|
74
74
|
from .models import ShopifyAuthConfig
|
|
75
|
+
|
|
75
76
|
# Import response models and envelope models at runtime
|
|
76
77
|
from .models import (
|
|
77
78
|
ShopifyCheckResult,
|
|
@@ -299,6 +300,7 @@ class ShopifyConnector:
|
|
|
299
300
|
external_user_id: str | None = None,
|
|
300
301
|
airbyte_client_id: str | None = None,
|
|
301
302
|
airbyte_client_secret: str | None = None,
|
|
303
|
+
connector_id: str | None = None,
|
|
302
304
|
on_token_refresh: Any | None = None,
|
|
303
305
|
shop: str | None = None ):
|
|
304
306
|
"""
|
|
@@ -306,20 +308,28 @@ class ShopifyConnector:
|
|
|
306
308
|
|
|
307
309
|
Supports both local and hosted execution modes:
|
|
308
310
|
- Local mode: Provide `auth_config` for direct API calls
|
|
309
|
-
- Hosted mode: Provide
|
|
311
|
+
- Hosted mode: Provide Airbyte credentials with either `connector_id` or `external_user_id`
|
|
310
312
|
|
|
311
313
|
Args:
|
|
312
314
|
auth_config: Typed authentication configuration (required for local mode)
|
|
313
|
-
external_user_id: External user ID (
|
|
315
|
+
external_user_id: External user ID (for hosted mode lookup)
|
|
314
316
|
airbyte_client_id: Airbyte OAuth client ID (required for hosted mode)
|
|
315
317
|
airbyte_client_secret: Airbyte OAuth client secret (required for hosted mode)
|
|
318
|
+
connector_id: Specific connector/source ID (for hosted mode, skips lookup)
|
|
316
319
|
on_token_refresh: Optional callback for OAuth2 token refresh persistence.
|
|
317
320
|
Called with new_tokens dict when tokens are refreshed. Can be sync or async.
|
|
318
321
|
Example: lambda tokens: save_to_database(tokens) shop: Your Shopify store name (e.g., 'my-store' from my-store.myshopify.com)
|
|
319
322
|
Examples:
|
|
320
323
|
# Local mode (direct API calls)
|
|
321
324
|
connector = ShopifyConnector(auth_config=ShopifyAuthConfig(api_key="...", shop="..."))
|
|
322
|
-
# Hosted mode (
|
|
325
|
+
# Hosted mode with explicit connector_id (no lookup needed)
|
|
326
|
+
connector = ShopifyConnector(
|
|
327
|
+
airbyte_client_id="client_abc123",
|
|
328
|
+
airbyte_client_secret="secret_xyz789",
|
|
329
|
+
connector_id="existing-source-uuid"
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
# Hosted mode with lookup by external_user_id
|
|
323
333
|
connector = ShopifyConnector(
|
|
324
334
|
external_user_id="user-123",
|
|
325
335
|
airbyte_client_id="client_abc123",
|
|
@@ -337,21 +347,24 @@ class ShopifyConnector:
|
|
|
337
347
|
on_token_refresh=save_tokens
|
|
338
348
|
)
|
|
339
349
|
"""
|
|
340
|
-
# Hosted mode:
|
|
341
|
-
|
|
350
|
+
# Hosted mode: Airbyte credentials + either connector_id OR external_user_id
|
|
351
|
+
is_hosted = airbyte_client_id and airbyte_client_secret and (connector_id or external_user_id)
|
|
352
|
+
|
|
353
|
+
if is_hosted:
|
|
342
354
|
from ._vendored.connector_sdk.executor import HostedExecutor
|
|
343
355
|
self._executor = HostedExecutor(
|
|
344
|
-
external_user_id=external_user_id,
|
|
345
356
|
airbyte_client_id=airbyte_client_id,
|
|
346
357
|
airbyte_client_secret=airbyte_client_secret,
|
|
347
|
-
|
|
358
|
+
connector_id=connector_id,
|
|
359
|
+
external_user_id=external_user_id,
|
|
360
|
+
connector_definition_id=str(ShopifyConnectorModel.id) if not connector_id else None,
|
|
348
361
|
)
|
|
349
362
|
else:
|
|
350
363
|
# Local mode: auth_config required
|
|
351
364
|
if not auth_config:
|
|
352
365
|
raise ValueError(
|
|
353
|
-
"Either provide (
|
|
354
|
-
"or auth_config for local mode"
|
|
366
|
+
"Either provide Airbyte credentials (airbyte_client_id, airbyte_client_secret) with "
|
|
367
|
+
"connector_id or external_user_id for hosted mode, or auth_config for local mode"
|
|
355
368
|
)
|
|
356
369
|
|
|
357
370
|
from ._vendored.connector_sdk.executor import LocalExecutor
|
|
@@ -1048,6 +1061,96 @@ class ShopifyConnector:
|
|
|
1048
1061
|
)
|
|
1049
1062
|
return entity_def.entity_schema if entity_def else None
|
|
1050
1063
|
|
|
1064
|
+
@property
|
|
1065
|
+
def connector_id(self) -> str | None:
|
|
1066
|
+
"""Get the connector/source ID (only available in hosted mode).
|
|
1067
|
+
|
|
1068
|
+
Returns:
|
|
1069
|
+
The connector ID if in hosted mode, None if in local mode.
|
|
1070
|
+
|
|
1071
|
+
Example:
|
|
1072
|
+
connector = await ShopifyConnector.create_hosted(...)
|
|
1073
|
+
print(f"Created connector: {connector.connector_id}")
|
|
1074
|
+
"""
|
|
1075
|
+
if hasattr(self, '_executor') and hasattr(self._executor, '_connector_id'):
|
|
1076
|
+
return self._executor._connector_id
|
|
1077
|
+
return None
|
|
1078
|
+
|
|
1079
|
+
# ===== HOSTED MODE FACTORY =====
|
|
1080
|
+
|
|
1081
|
+
@classmethod
|
|
1082
|
+
async def create_hosted(
|
|
1083
|
+
cls,
|
|
1084
|
+
*,
|
|
1085
|
+
external_user_id: str,
|
|
1086
|
+
airbyte_client_id: str,
|
|
1087
|
+
airbyte_client_secret: str,
|
|
1088
|
+
auth_config: "ShopifyAuthConfig",
|
|
1089
|
+
name: str | None = None,
|
|
1090
|
+
replication_config: dict[str, Any] | None = None,
|
|
1091
|
+
) -> "ShopifyConnector":
|
|
1092
|
+
"""
|
|
1093
|
+
Create a new hosted connector on Airbyte Cloud.
|
|
1094
|
+
|
|
1095
|
+
This factory method:
|
|
1096
|
+
1. Creates a source on Airbyte Cloud with the provided credentials
|
|
1097
|
+
2. Returns a connector configured with the new connector_id
|
|
1098
|
+
|
|
1099
|
+
Args:
|
|
1100
|
+
external_user_id: Workspace identifier in Airbyte Cloud
|
|
1101
|
+
airbyte_client_id: Airbyte OAuth client ID
|
|
1102
|
+
airbyte_client_secret: Airbyte OAuth client secret
|
|
1103
|
+
auth_config: Typed auth config (same as local mode)
|
|
1104
|
+
name: Optional source name (defaults to connector name + external_user_id)
|
|
1105
|
+
replication_config: Optional replication settings dict.
|
|
1106
|
+
Required for connectors with x-airbyte-replication-config (REPLICATION mode sources).
|
|
1107
|
+
|
|
1108
|
+
Returns:
|
|
1109
|
+
A ShopifyConnector instance configured in hosted mode
|
|
1110
|
+
|
|
1111
|
+
Example:
|
|
1112
|
+
# Create a new hosted connector with API key auth
|
|
1113
|
+
connector = await ShopifyConnector.create_hosted(
|
|
1114
|
+
external_user_id="my-workspace",
|
|
1115
|
+
airbyte_client_id="client_abc",
|
|
1116
|
+
airbyte_client_secret="secret_xyz",
|
|
1117
|
+
auth_config=ShopifyAuthConfig(api_key="...", shop="..."),
|
|
1118
|
+
)
|
|
1119
|
+
|
|
1120
|
+
# Use the connector
|
|
1121
|
+
result = await connector.execute("entity", "list", {})
|
|
1122
|
+
"""
|
|
1123
|
+
from ._vendored.connector_sdk.cloud_utils import AirbyteCloudClient
|
|
1124
|
+
|
|
1125
|
+
client = AirbyteCloudClient(
|
|
1126
|
+
client_id=airbyte_client_id,
|
|
1127
|
+
client_secret=airbyte_client_secret,
|
|
1128
|
+
)
|
|
1129
|
+
|
|
1130
|
+
try:
|
|
1131
|
+
# Build credentials from auth_config
|
|
1132
|
+
credentials = auth_config.model_dump(exclude_none=True)
|
|
1133
|
+
replication_config_dict = replication_config.model_dump(exclude_none=True) if replication_config else None
|
|
1134
|
+
|
|
1135
|
+
# Create source on Airbyte Cloud
|
|
1136
|
+
source_name = name or f"{cls.connector_name} - {external_user_id}"
|
|
1137
|
+
source_id = await client.create_source(
|
|
1138
|
+
name=source_name,
|
|
1139
|
+
connector_definition_id=str(ShopifyConnectorModel.id),
|
|
1140
|
+
external_user_id=external_user_id,
|
|
1141
|
+
credentials=credentials,
|
|
1142
|
+
replication_config=replication_config_dict,
|
|
1143
|
+
)
|
|
1144
|
+
finally:
|
|
1145
|
+
await client.close()
|
|
1146
|
+
|
|
1147
|
+
# Return connector configured with the new connector_id
|
|
1148
|
+
return cls(
|
|
1149
|
+
airbyte_client_id=airbyte_client_id,
|
|
1150
|
+
airbyte_client_secret=airbyte_client_secret,
|
|
1151
|
+
connector_id=source_id,
|
|
1152
|
+
)
|
|
1153
|
+
|
|
1051
1154
|
|
|
1052
1155
|
|
|
1053
1156
|
class CustomersQuery:
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"""Utility functions for working with connectors."""
|
|
2
|
-
|
|
3
|
-
from collections.abc import AsyncIterator
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
async def save_download(
|
|
8
|
-
download_iterator: AsyncIterator[bytes],
|
|
9
|
-
path: str | Path,
|
|
10
|
-
*,
|
|
11
|
-
overwrite: bool = False,
|
|
12
|
-
) -> Path:
|
|
13
|
-
"""Save a download iterator to a file.
|
|
14
|
-
|
|
15
|
-
Args:
|
|
16
|
-
download_iterator: AsyncIterator[bytes] from a download operation
|
|
17
|
-
path: File path where content should be saved
|
|
18
|
-
overwrite: Whether to overwrite existing file (default: False)
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
Absolute Path to the saved file
|
|
22
|
-
|
|
23
|
-
Raises:
|
|
24
|
-
FileExistsError: If file exists and overwrite=False
|
|
25
|
-
OSError: If file cannot be written
|
|
26
|
-
|
|
27
|
-
Example:
|
|
28
|
-
>>> from .utils import save_download
|
|
29
|
-
>>>
|
|
30
|
-
>>> # Download and save a file
|
|
31
|
-
>>> result = await connector.download_article_attachment(id="123")
|
|
32
|
-
>>> file_path = await save_download(result, "./downloads/attachment.pdf")
|
|
33
|
-
>>> print(f"Downloaded to {file_path}")
|
|
34
|
-
Downloaded to /absolute/path/to/downloads/attachment.pdf
|
|
35
|
-
>>>
|
|
36
|
-
>>> # Overwrite existing file
|
|
37
|
-
>>> file_path = await save_download(result, "./downloads/attachment.pdf", overwrite=True)
|
|
38
|
-
"""
|
|
39
|
-
# Convert to Path object
|
|
40
|
-
file_path = Path(path).expanduser().resolve()
|
|
41
|
-
|
|
42
|
-
# Check if file exists
|
|
43
|
-
if file_path.exists() and not overwrite:
|
|
44
|
-
raise FileExistsError(f"File already exists: {file_path}. Use overwrite=True to replace it.")
|
|
45
|
-
|
|
46
|
-
# Create parent directories if needed
|
|
47
|
-
file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
48
|
-
|
|
49
|
-
# Stream content to file
|
|
50
|
-
try:
|
|
51
|
-
with open(file_path, "wb") as f:
|
|
52
|
-
async for chunk in download_iterator:
|
|
53
|
-
f.write(chunk)
|
|
54
|
-
except Exception as e:
|
|
55
|
-
# Clean up partial file on error
|
|
56
|
-
if file_path.exists():
|
|
57
|
-
file_path.unlink()
|
|
58
|
-
raise OSError(f"Failed to write file {file_path}: {e}") from e
|
|
59
|
-
|
|
60
|
-
return file_path
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/models.py
RENAMED
|
@@ -119,55 +119,6 @@ class OrderAddress(BaseModel):
|
|
|
119
119
|
latitude: Union[float | None, Any] = Field(default=None)
|
|
120
120
|
longitude: Union[float | None, Any] = Field(default=None)
|
|
121
121
|
|
|
122
|
-
class Transaction(BaseModel):
|
|
123
|
-
"""An order transaction"""
|
|
124
|
-
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
125
|
-
|
|
126
|
-
id: Union[int, Any] = Field(default=None)
|
|
127
|
-
order_id: Union[int | None, Any] = Field(default=None)
|
|
128
|
-
kind: Union[str | None, Any] = Field(default=None)
|
|
129
|
-
gateway: Union[str | None, Any] = Field(default=None)
|
|
130
|
-
status: Union[str | None, Any] = Field(default=None)
|
|
131
|
-
message: Union[str | None, Any] = Field(default=None)
|
|
132
|
-
created_at: Union[str | None, Any] = Field(default=None)
|
|
133
|
-
test: Union[bool | None, Any] = Field(default=None)
|
|
134
|
-
authorization: Union[str | None, Any] = Field(default=None)
|
|
135
|
-
location_id: Union[int | None, Any] = Field(default=None)
|
|
136
|
-
user_id: Union[int | None, Any] = Field(default=None)
|
|
137
|
-
parent_id: Union[int | None, Any] = Field(default=None)
|
|
138
|
-
processed_at: Union[str | None, Any] = Field(default=None)
|
|
139
|
-
device_id: Union[int | None, Any] = Field(default=None)
|
|
140
|
-
error_code: Union[str | None, Any] = Field(default=None)
|
|
141
|
-
source_name: Union[str | None, Any] = Field(default=None)
|
|
142
|
-
receipt: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
143
|
-
currency_exchange_adjustment: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
144
|
-
amount: Union[str | None, Any] = Field(default=None)
|
|
145
|
-
currency: Union[str | None, Any] = Field(default=None)
|
|
146
|
-
payment_id: Union[str | None, Any] = Field(default=None)
|
|
147
|
-
total_unsettled_set: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
148
|
-
manual_payment_gateway: Union[bool | None, Any] = Field(default=None)
|
|
149
|
-
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
150
|
-
|
|
151
|
-
class Refund(BaseModel):
|
|
152
|
-
"""An order refund"""
|
|
153
|
-
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
154
|
-
|
|
155
|
-
id: Union[int, Any] = Field(default=None)
|
|
156
|
-
order_id: Union[int | None, Any] = Field(default=None)
|
|
157
|
-
created_at: Union[str | None, Any] = Field(default=None)
|
|
158
|
-
note: Union[str | None, Any] = Field(default=None)
|
|
159
|
-
user_id: Union[int | None, Any] = Field(default=None)
|
|
160
|
-
processed_at: Union[str | None, Any] = Field(default=None)
|
|
161
|
-
restock: Union[bool | None, Any] = Field(default=None)
|
|
162
|
-
duties: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
163
|
-
total_duties_set: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
164
|
-
return_: Union[dict[str, Any] | None, Any] = Field(default=None, alias="return")
|
|
165
|
-
refund_line_items: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
166
|
-
transactions: Union[list[Transaction] | None, Any] = Field(default=None)
|
|
167
|
-
order_adjustments: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
168
|
-
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
169
|
-
refund_shipping_lines: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
170
|
-
|
|
171
122
|
class LineItem(BaseModel):
|
|
172
123
|
"""LineItem type definition"""
|
|
173
124
|
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
@@ -225,6 +176,55 @@ class Fulfillment(BaseModel):
|
|
|
225
176
|
name: Union[str | None, Any] = Field(default=None)
|
|
226
177
|
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
227
178
|
|
|
179
|
+
class Transaction(BaseModel):
|
|
180
|
+
"""An order transaction"""
|
|
181
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
182
|
+
|
|
183
|
+
id: Union[int, Any] = Field(default=None)
|
|
184
|
+
order_id: Union[int | None, Any] = Field(default=None)
|
|
185
|
+
kind: Union[str | None, Any] = Field(default=None)
|
|
186
|
+
gateway: Union[str | None, Any] = Field(default=None)
|
|
187
|
+
status: Union[str | None, Any] = Field(default=None)
|
|
188
|
+
message: Union[str | None, Any] = Field(default=None)
|
|
189
|
+
created_at: Union[str | None, Any] = Field(default=None)
|
|
190
|
+
test: Union[bool | None, Any] = Field(default=None)
|
|
191
|
+
authorization: Union[str | None, Any] = Field(default=None)
|
|
192
|
+
location_id: Union[int | None, Any] = Field(default=None)
|
|
193
|
+
user_id: Union[int | None, Any] = Field(default=None)
|
|
194
|
+
parent_id: Union[int | None, Any] = Field(default=None)
|
|
195
|
+
processed_at: Union[str | None, Any] = Field(default=None)
|
|
196
|
+
device_id: Union[int | None, Any] = Field(default=None)
|
|
197
|
+
error_code: Union[str | None, Any] = Field(default=None)
|
|
198
|
+
source_name: Union[str | None, Any] = Field(default=None)
|
|
199
|
+
receipt: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
200
|
+
currency_exchange_adjustment: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
201
|
+
amount: Union[str | None, Any] = Field(default=None)
|
|
202
|
+
currency: Union[str | None, Any] = Field(default=None)
|
|
203
|
+
payment_id: Union[str | None, Any] = Field(default=None)
|
|
204
|
+
total_unsettled_set: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
205
|
+
manual_payment_gateway: Union[bool | None, Any] = Field(default=None)
|
|
206
|
+
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
207
|
+
|
|
208
|
+
class Refund(BaseModel):
|
|
209
|
+
"""An order refund"""
|
|
210
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
211
|
+
|
|
212
|
+
id: Union[int, Any] = Field(default=None)
|
|
213
|
+
order_id: Union[int | None, Any] = Field(default=None)
|
|
214
|
+
created_at: Union[str | None, Any] = Field(default=None)
|
|
215
|
+
note: Union[str | None, Any] = Field(default=None)
|
|
216
|
+
user_id: Union[int | None, Any] = Field(default=None)
|
|
217
|
+
processed_at: Union[str | None, Any] = Field(default=None)
|
|
218
|
+
restock: Union[bool | None, Any] = Field(default=None)
|
|
219
|
+
duties: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
220
|
+
total_duties_set: Union[dict[str, Any] | None, Any] = Field(default=None)
|
|
221
|
+
return_: Union[dict[str, Any] | None, Any] = Field(default=None, alias="return")
|
|
222
|
+
refund_line_items: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
223
|
+
transactions: Union[list[Transaction] | None, Any] = Field(default=None)
|
|
224
|
+
order_adjustments: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
225
|
+
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
226
|
+
refund_shipping_lines: Union[list[dict[str, Any]] | None, Any] = Field(default=None)
|
|
227
|
+
|
|
228
228
|
class Order(BaseModel):
|
|
229
229
|
"""A Shopify order"""
|
|
230
230
|
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
@@ -329,22 +329,6 @@ class OrderList(BaseModel):
|
|
|
329
329
|
|
|
330
330
|
orders: Union[list[Order], Any] = Field(default=None)
|
|
331
331
|
|
|
332
|
-
class ProductImage(BaseModel):
|
|
333
|
-
"""A product image"""
|
|
334
|
-
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
335
|
-
|
|
336
|
-
id: Union[int, Any] = Field(default=None)
|
|
337
|
-
product_id: Union[int | None, Any] = Field(default=None)
|
|
338
|
-
position: Union[int | None, Any] = Field(default=None)
|
|
339
|
-
created_at: Union[str | None, Any] = Field(default=None)
|
|
340
|
-
updated_at: Union[str | None, Any] = Field(default=None)
|
|
341
|
-
alt: Union[str | None, Any] = Field(default=None)
|
|
342
|
-
width: Union[int | None, Any] = Field(default=None)
|
|
343
|
-
height: Union[int | None, Any] = Field(default=None)
|
|
344
|
-
src: Union[str | None, Any] = Field(default=None)
|
|
345
|
-
variant_ids: Union[list[int] | None, Any] = Field(default=None)
|
|
346
|
-
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
347
|
-
|
|
348
332
|
class ProductVariant(BaseModel):
|
|
349
333
|
"""A product variant"""
|
|
350
334
|
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
@@ -376,6 +360,22 @@ class ProductVariant(BaseModel):
|
|
|
376
360
|
requires_shipping: Union[bool | None, Any] = Field(default=None)
|
|
377
361
|
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
378
362
|
|
|
363
|
+
class ProductImage(BaseModel):
|
|
364
|
+
"""A product image"""
|
|
365
|
+
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
|
366
|
+
|
|
367
|
+
id: Union[int, Any] = Field(default=None)
|
|
368
|
+
product_id: Union[int | None, Any] = Field(default=None)
|
|
369
|
+
position: Union[int | None, Any] = Field(default=None)
|
|
370
|
+
created_at: Union[str | None, Any] = Field(default=None)
|
|
371
|
+
updated_at: Union[str | None, Any] = Field(default=None)
|
|
372
|
+
alt: Union[str | None, Any] = Field(default=None)
|
|
373
|
+
width: Union[int | None, Any] = Field(default=None)
|
|
374
|
+
height: Union[int | None, Any] = Field(default=None)
|
|
375
|
+
src: Union[str | None, Any] = Field(default=None)
|
|
376
|
+
variant_ids: Union[list[int] | None, Any] = Field(default=None)
|
|
377
|
+
admin_graphql_api_id: Union[str | None, Any] = Field(default=None)
|
|
378
|
+
|
|
379
379
|
class Product(BaseModel):
|
|
380
380
|
"""A Shopify product"""
|
|
381
381
|
model_config = ConfigDict(extra="allow", populate_by_name=True)
|
{airbyte_agent_shopify-0.1.23 → airbyte_agent_shopify-0.1.24}/airbyte_agent_shopify/types.py
RENAMED
|
File without changes
|