dex-connector-github 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dex_connector_github-0.1.0.dist-info/METADATA +39 -0
- dex_connector_github-0.1.0.dist-info/RECORD +21 -0
- dex_connector_github-0.1.0.dist-info/WHEEL +4 -0
- dex_connector_github-0.1.0.dist-info/licenses/LICENSE +21 -0
- dex_connectors/github/__init__.py +47 -0
- dex_connectors/github/_generated/__init__.py +2 -0
- dex_connectors/github/_generated/config.py +34 -0
- dex_connectors/github/_generated/connection.py +245 -0
- dex_connectors/github/_generated/definitions.py +143 -0
- dex_connectors/github/_generated/mock.py +665 -0
- dex_connectors/github/_generated/models.py +464 -0
- dex_connectors/github/_generated/refresh.py +9 -0
- dex_connectors/github/_generated/steps.py +385 -0
- dex_connectors/github/_generated/timestamps.py +60 -0
- dex_connectors/github/client.py +367 -0
- dex_connectors/github/connection.py +5 -0
- dex_connectors/github/dex-connector.json +304 -0
- dex_connectors/github/githubmock/__init__.py +6 -0
- dex_connectors/github/models.py +5 -0
- dex_connectors/github/operations.py +861 -0
- dex_connectors/github/steps.py +5 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable, Mapping
|
|
6
|
+
from typing import Any, TypeVar
|
|
7
|
+
|
|
8
|
+
import dex
|
|
9
|
+
from dex_connectors.sdk import (
|
|
10
|
+
QueryResult,
|
|
11
|
+
QueryStep,
|
|
12
|
+
QueryStepConfig,
|
|
13
|
+
StepAnnotations,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from ..connection import Connection
|
|
17
|
+
from ..models import AuthenticatedProfile, CommitPage, GetAuthenticatedProfileInput, ListCommitsInput, ListMergedPullRequestsInput, ListPublicRepositoriesInput, ListPullRequestFilesInput, ListReleasesInput, MergedPullRequestPage, PublicRepositories, PullRequestFilePage, ReleasePage
|
|
18
|
+
|
|
19
|
+
StepInput = TypeVar("StepInput")
|
|
20
|
+
|
|
21
|
+
def new_get_authenticated_profile_step(
|
|
22
|
+
*,
|
|
23
|
+
step_type: str,
|
|
24
|
+
step_input_type: type[StepInput],
|
|
25
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
26
|
+
connection: Connection,
|
|
27
|
+
connection_name: str,
|
|
28
|
+
map_to_operation_input: Callable[[StepInput], GetAuthenticatedProfileInput],
|
|
29
|
+
profile_loaded: dex.StepTarget[QueryResult[AuthenticatedProfile]],
|
|
30
|
+
verified_email_required: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
31
|
+
insufficient_scope: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
32
|
+
authorization_revoked: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
33
|
+
not_found: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
34
|
+
provider_rejected: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
35
|
+
invalid_response: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
36
|
+
defect: dex.StepTarget[QueryResult[AuthenticatedProfile]] | None = None,
|
|
37
|
+
result_attribute: dex.Attribute[QueryResult[AuthenticatedProfile]] | None = None,
|
|
38
|
+
step_options_override: dex.StepOptions | None = None,
|
|
39
|
+
) -> QueryStep[StepInput, GetAuthenticatedProfileInput, AuthenticatedProfile]:
|
|
40
|
+
if connection is None or connection.reference.name != connection_name:
|
|
41
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
42
|
+
if isinstance(annotations, StepAnnotations):
|
|
43
|
+
step_annotations = annotations
|
|
44
|
+
else:
|
|
45
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
46
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
47
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
48
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
49
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
50
|
+
branches = {
|
|
51
|
+
"profileLoaded": profile_loaded,
|
|
52
|
+
}
|
|
53
|
+
if verified_email_required is not None:
|
|
54
|
+
branches["verifiedEmailRequired"] = verified_email_required
|
|
55
|
+
if insufficient_scope is not None:
|
|
56
|
+
branches["insufficientScope"] = insufficient_scope
|
|
57
|
+
if authorization_revoked is not None:
|
|
58
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
59
|
+
if not_found is not None:
|
|
60
|
+
branches["notFound"] = not_found
|
|
61
|
+
if provider_rejected is not None:
|
|
62
|
+
branches["providerRejected"] = provider_rejected
|
|
63
|
+
if invalid_response is not None:
|
|
64
|
+
branches["invalidResponse"] = invalid_response
|
|
65
|
+
if defect is not None:
|
|
66
|
+
branches["defect"] = defect
|
|
67
|
+
return QueryStep(
|
|
68
|
+
QueryStepConfig(
|
|
69
|
+
step_type=step_type,
|
|
70
|
+
step_input_type=step_input_type,
|
|
71
|
+
annotations=step_annotations,
|
|
72
|
+
operation=_bound_operation(connection, "get_authenticated_profile"),
|
|
73
|
+
connection=connection.reference,
|
|
74
|
+
map_to_operation_input=map_to_operation_input,
|
|
75
|
+
branches=branches,
|
|
76
|
+
result_attribute=result_attribute,
|
|
77
|
+
step_options_override=step_options_override,
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
setattr(new_get_authenticated_profile_step, '__module__', 'dex_connectors.github.steps')
|
|
82
|
+
|
|
83
|
+
def new_list_public_repositories_step(
|
|
84
|
+
*,
|
|
85
|
+
step_type: str,
|
|
86
|
+
step_input_type: type[StepInput],
|
|
87
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
88
|
+
connection: Connection,
|
|
89
|
+
connection_name: str,
|
|
90
|
+
map_to_operation_input: Callable[[StepInput], ListPublicRepositoriesInput],
|
|
91
|
+
repositories_loaded: dex.StepTarget[QueryResult[PublicRepositories]],
|
|
92
|
+
insufficient_scope: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
93
|
+
authorization_revoked: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
94
|
+
not_found: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
95
|
+
provider_rejected: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
96
|
+
invalid_response: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
97
|
+
defect: dex.StepTarget[QueryResult[PublicRepositories]] | None = None,
|
|
98
|
+
result_attribute: dex.Attribute[QueryResult[PublicRepositories]] | None = None,
|
|
99
|
+
step_options_override: dex.StepOptions | None = None,
|
|
100
|
+
) -> QueryStep[StepInput, ListPublicRepositoriesInput, PublicRepositories]:
|
|
101
|
+
if connection is None or connection.reference.name != connection_name:
|
|
102
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
103
|
+
if isinstance(annotations, StepAnnotations):
|
|
104
|
+
step_annotations = annotations
|
|
105
|
+
else:
|
|
106
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
107
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
108
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
109
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
110
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
111
|
+
branches = {
|
|
112
|
+
"repositoriesLoaded": repositories_loaded,
|
|
113
|
+
}
|
|
114
|
+
if insufficient_scope is not None:
|
|
115
|
+
branches["insufficientScope"] = insufficient_scope
|
|
116
|
+
if authorization_revoked is not None:
|
|
117
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
118
|
+
if not_found is not None:
|
|
119
|
+
branches["notFound"] = not_found
|
|
120
|
+
if provider_rejected is not None:
|
|
121
|
+
branches["providerRejected"] = provider_rejected
|
|
122
|
+
if invalid_response is not None:
|
|
123
|
+
branches["invalidResponse"] = invalid_response
|
|
124
|
+
if defect is not None:
|
|
125
|
+
branches["defect"] = defect
|
|
126
|
+
return QueryStep(
|
|
127
|
+
QueryStepConfig(
|
|
128
|
+
step_type=step_type,
|
|
129
|
+
step_input_type=step_input_type,
|
|
130
|
+
annotations=step_annotations,
|
|
131
|
+
operation=_bound_operation(connection, "list_public_repositories"),
|
|
132
|
+
connection=connection.reference,
|
|
133
|
+
map_to_operation_input=map_to_operation_input,
|
|
134
|
+
branches=branches,
|
|
135
|
+
result_attribute=result_attribute,
|
|
136
|
+
step_options_override=step_options_override,
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
setattr(new_list_public_repositories_step, '__module__', 'dex_connectors.github.steps')
|
|
141
|
+
|
|
142
|
+
def new_list_merged_pull_requests_step(
|
|
143
|
+
*,
|
|
144
|
+
step_type: str,
|
|
145
|
+
step_input_type: type[StepInput],
|
|
146
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
147
|
+
connection: Connection,
|
|
148
|
+
connection_name: str,
|
|
149
|
+
map_to_operation_input: Callable[[StepInput], ListMergedPullRequestsInput],
|
|
150
|
+
listed: dex.StepTarget[QueryResult[MergedPullRequestPage]],
|
|
151
|
+
insufficient_scope: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
152
|
+
authorization_revoked: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
153
|
+
not_found: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
154
|
+
provider_rejected: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
155
|
+
invalid_response: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
156
|
+
defect: dex.StepTarget[QueryResult[MergedPullRequestPage]] | None = None,
|
|
157
|
+
result_attribute: dex.Attribute[QueryResult[MergedPullRequestPage]] | None = None,
|
|
158
|
+
step_options_override: dex.StepOptions | None = None,
|
|
159
|
+
) -> QueryStep[StepInput, ListMergedPullRequestsInput, MergedPullRequestPage]:
|
|
160
|
+
if connection is None or connection.reference.name != connection_name:
|
|
161
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
162
|
+
if isinstance(annotations, StepAnnotations):
|
|
163
|
+
step_annotations = annotations
|
|
164
|
+
else:
|
|
165
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
166
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
167
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
168
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
169
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
170
|
+
branches = {
|
|
171
|
+
"listed": listed,
|
|
172
|
+
}
|
|
173
|
+
if insufficient_scope is not None:
|
|
174
|
+
branches["insufficientScope"] = insufficient_scope
|
|
175
|
+
if authorization_revoked is not None:
|
|
176
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
177
|
+
if not_found is not None:
|
|
178
|
+
branches["notFound"] = not_found
|
|
179
|
+
if provider_rejected is not None:
|
|
180
|
+
branches["providerRejected"] = provider_rejected
|
|
181
|
+
if invalid_response is not None:
|
|
182
|
+
branches["invalidResponse"] = invalid_response
|
|
183
|
+
if defect is not None:
|
|
184
|
+
branches["defect"] = defect
|
|
185
|
+
return QueryStep(
|
|
186
|
+
QueryStepConfig(
|
|
187
|
+
step_type=step_type,
|
|
188
|
+
step_input_type=step_input_type,
|
|
189
|
+
annotations=step_annotations,
|
|
190
|
+
operation=_bound_operation(connection, "list_merged_pull_requests"),
|
|
191
|
+
connection=connection.reference,
|
|
192
|
+
map_to_operation_input=map_to_operation_input,
|
|
193
|
+
branches=branches,
|
|
194
|
+
result_attribute=result_attribute,
|
|
195
|
+
step_options_override=step_options_override,
|
|
196
|
+
)
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
setattr(new_list_merged_pull_requests_step, '__module__', 'dex_connectors.github.steps')
|
|
200
|
+
|
|
201
|
+
def new_list_pull_request_files_step(
|
|
202
|
+
*,
|
|
203
|
+
step_type: str,
|
|
204
|
+
step_input_type: type[StepInput],
|
|
205
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
206
|
+
connection: Connection,
|
|
207
|
+
connection_name: str,
|
|
208
|
+
map_to_operation_input: Callable[[StepInput], ListPullRequestFilesInput],
|
|
209
|
+
listed: dex.StepTarget[QueryResult[PullRequestFilePage]],
|
|
210
|
+
insufficient_scope: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
211
|
+
authorization_revoked: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
212
|
+
not_found: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
213
|
+
provider_rejected: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
214
|
+
invalid_response: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
215
|
+
defect: dex.StepTarget[QueryResult[PullRequestFilePage]] | None = None,
|
|
216
|
+
result_attribute: dex.Attribute[QueryResult[PullRequestFilePage]] | None = None,
|
|
217
|
+
step_options_override: dex.StepOptions | None = None,
|
|
218
|
+
) -> QueryStep[StepInput, ListPullRequestFilesInput, PullRequestFilePage]:
|
|
219
|
+
if connection is None or connection.reference.name != connection_name:
|
|
220
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
221
|
+
if isinstance(annotations, StepAnnotations):
|
|
222
|
+
step_annotations = annotations
|
|
223
|
+
else:
|
|
224
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
225
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
226
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
227
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
228
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
229
|
+
branches = {
|
|
230
|
+
"listed": listed,
|
|
231
|
+
}
|
|
232
|
+
if insufficient_scope is not None:
|
|
233
|
+
branches["insufficientScope"] = insufficient_scope
|
|
234
|
+
if authorization_revoked is not None:
|
|
235
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
236
|
+
if not_found is not None:
|
|
237
|
+
branches["notFound"] = not_found
|
|
238
|
+
if provider_rejected is not None:
|
|
239
|
+
branches["providerRejected"] = provider_rejected
|
|
240
|
+
if invalid_response is not None:
|
|
241
|
+
branches["invalidResponse"] = invalid_response
|
|
242
|
+
if defect is not None:
|
|
243
|
+
branches["defect"] = defect
|
|
244
|
+
return QueryStep(
|
|
245
|
+
QueryStepConfig(
|
|
246
|
+
step_type=step_type,
|
|
247
|
+
step_input_type=step_input_type,
|
|
248
|
+
annotations=step_annotations,
|
|
249
|
+
operation=_bound_operation(connection, "list_pull_request_files"),
|
|
250
|
+
connection=connection.reference,
|
|
251
|
+
map_to_operation_input=map_to_operation_input,
|
|
252
|
+
branches=branches,
|
|
253
|
+
result_attribute=result_attribute,
|
|
254
|
+
step_options_override=step_options_override,
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
setattr(new_list_pull_request_files_step, '__module__', 'dex_connectors.github.steps')
|
|
259
|
+
|
|
260
|
+
def new_list_releases_step(
|
|
261
|
+
*,
|
|
262
|
+
step_type: str,
|
|
263
|
+
step_input_type: type[StepInput],
|
|
264
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
265
|
+
connection: Connection,
|
|
266
|
+
connection_name: str,
|
|
267
|
+
map_to_operation_input: Callable[[StepInput], ListReleasesInput],
|
|
268
|
+
listed: dex.StepTarget[QueryResult[ReleasePage]],
|
|
269
|
+
insufficient_scope: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
270
|
+
authorization_revoked: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
271
|
+
not_found: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
272
|
+
provider_rejected: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
273
|
+
invalid_response: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
274
|
+
defect: dex.StepTarget[QueryResult[ReleasePage]] | None = None,
|
|
275
|
+
result_attribute: dex.Attribute[QueryResult[ReleasePage]] | None = None,
|
|
276
|
+
step_options_override: dex.StepOptions | None = None,
|
|
277
|
+
) -> QueryStep[StepInput, ListReleasesInput, ReleasePage]:
|
|
278
|
+
if connection is None or connection.reference.name != connection_name:
|
|
279
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
280
|
+
if isinstance(annotations, StepAnnotations):
|
|
281
|
+
step_annotations = annotations
|
|
282
|
+
else:
|
|
283
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
284
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
285
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
286
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
287
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
288
|
+
branches = {
|
|
289
|
+
"listed": listed,
|
|
290
|
+
}
|
|
291
|
+
if insufficient_scope is not None:
|
|
292
|
+
branches["insufficientScope"] = insufficient_scope
|
|
293
|
+
if authorization_revoked is not None:
|
|
294
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
295
|
+
if not_found is not None:
|
|
296
|
+
branches["notFound"] = not_found
|
|
297
|
+
if provider_rejected is not None:
|
|
298
|
+
branches["providerRejected"] = provider_rejected
|
|
299
|
+
if invalid_response is not None:
|
|
300
|
+
branches["invalidResponse"] = invalid_response
|
|
301
|
+
if defect is not None:
|
|
302
|
+
branches["defect"] = defect
|
|
303
|
+
return QueryStep(
|
|
304
|
+
QueryStepConfig(
|
|
305
|
+
step_type=step_type,
|
|
306
|
+
step_input_type=step_input_type,
|
|
307
|
+
annotations=step_annotations,
|
|
308
|
+
operation=_bound_operation(connection, "list_releases"),
|
|
309
|
+
connection=connection.reference,
|
|
310
|
+
map_to_operation_input=map_to_operation_input,
|
|
311
|
+
branches=branches,
|
|
312
|
+
result_attribute=result_attribute,
|
|
313
|
+
step_options_override=step_options_override,
|
|
314
|
+
)
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
setattr(new_list_releases_step, '__module__', 'dex_connectors.github.steps')
|
|
318
|
+
|
|
319
|
+
def new_list_commits_step(
|
|
320
|
+
*,
|
|
321
|
+
step_type: str,
|
|
322
|
+
step_input_type: type[StepInput],
|
|
323
|
+
annotations: StepAnnotations | Mapping[str, str],
|
|
324
|
+
connection: Connection,
|
|
325
|
+
connection_name: str,
|
|
326
|
+
map_to_operation_input: Callable[[StepInput], ListCommitsInput],
|
|
327
|
+
listed: dex.StepTarget[QueryResult[CommitPage]],
|
|
328
|
+
insufficient_scope: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
329
|
+
authorization_revoked: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
330
|
+
not_found: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
331
|
+
provider_rejected: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
332
|
+
invalid_response: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
333
|
+
defect: dex.StepTarget[QueryResult[CommitPage]] | None = None,
|
|
334
|
+
result_attribute: dex.Attribute[QueryResult[CommitPage]] | None = None,
|
|
335
|
+
step_options_override: dex.StepOptions | None = None,
|
|
336
|
+
) -> QueryStep[StepInput, ListCommitsInput, CommitPage]:
|
|
337
|
+
if connection is None or connection.reference.name != connection_name:
|
|
338
|
+
raise ValueError("GitHub Step connection name must match its connection reference")
|
|
339
|
+
if isinstance(annotations, StepAnnotations):
|
|
340
|
+
step_annotations = annotations
|
|
341
|
+
else:
|
|
342
|
+
if not isinstance(annotations, Mapping) or set(annotations) != {"groupId", "groupLabel", "explanation"}:
|
|
343
|
+
raise ValueError("GitHub Step annotations require groupId, groupLabel, and explanation")
|
|
344
|
+
if any(not isinstance(value, str) for value in annotations.values()):
|
|
345
|
+
raise ValueError("GitHub Step annotations must be strings")
|
|
346
|
+
step_annotations = StepAnnotations(annotations["groupId"], annotations["groupLabel"], annotations["explanation"])
|
|
347
|
+
branches = {
|
|
348
|
+
"listed": listed,
|
|
349
|
+
}
|
|
350
|
+
if insufficient_scope is not None:
|
|
351
|
+
branches["insufficientScope"] = insufficient_scope
|
|
352
|
+
if authorization_revoked is not None:
|
|
353
|
+
branches["authorizationRevoked"] = authorization_revoked
|
|
354
|
+
if not_found is not None:
|
|
355
|
+
branches["notFound"] = not_found
|
|
356
|
+
if provider_rejected is not None:
|
|
357
|
+
branches["providerRejected"] = provider_rejected
|
|
358
|
+
if invalid_response is not None:
|
|
359
|
+
branches["invalidResponse"] = invalid_response
|
|
360
|
+
if defect is not None:
|
|
361
|
+
branches["defect"] = defect
|
|
362
|
+
return QueryStep(
|
|
363
|
+
QueryStepConfig(
|
|
364
|
+
step_type=step_type,
|
|
365
|
+
step_input_type=step_input_type,
|
|
366
|
+
annotations=step_annotations,
|
|
367
|
+
operation=_bound_operation(connection, "list_commits"),
|
|
368
|
+
connection=connection.reference,
|
|
369
|
+
map_to_operation_input=map_to_operation_input,
|
|
370
|
+
branches=branches,
|
|
371
|
+
result_attribute=result_attribute,
|
|
372
|
+
step_options_override=step_options_override,
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
setattr(new_list_commits_step, '__module__', 'dex_connectors.github.steps')
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _bound_operation(connection: Connection, operation_name: str) -> Any:
|
|
380
|
+
source = getattr(connection, operation_name, None)
|
|
381
|
+
if source is None:
|
|
382
|
+
source = getattr(getattr(connection, "operations", None), operation_name, None)
|
|
383
|
+
if source is None:
|
|
384
|
+
raise ValueError(f"connection operation {operation_name} is missing")
|
|
385
|
+
return source() if callable(source) else source
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
"""Go time.Time JSON input parsing for generated connector models."""
|
|
5
|
+
|
|
6
|
+
import re
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
|
|
9
|
+
_GO_TIME = re.compile(
|
|
10
|
+
r"^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{1,2}):([0-9]{2}):([0-9]{2})"
|
|
11
|
+
r"(?:[.,]([0-9]+))?(Z|([+-])([0-9]{2}):([0-9]{2}))$"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _parts(value: str, field_name: str) -> tuple[str, str, int, int]:
|
|
16
|
+
match = _GO_TIME.fullmatch(value)
|
|
17
|
+
if match is None:
|
|
18
|
+
raise ValueError(f"{field_name}: invalid Go time.Time JSON timestamp")
|
|
19
|
+
year, month, day, hour, minute, second, fraction, zone, sign, zone_hour, zone_minute = match.groups()
|
|
20
|
+
year_number, month_number, day_number = int(year), int(month), int(day)
|
|
21
|
+
is_leap = year_number % 4 == 0 and (year_number % 100 != 0 or year_number % 400 == 0)
|
|
22
|
+
month_days = (31, 29 if is_leap else 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
|
|
23
|
+
if not (1 <= month_number <= 12 and 1 <= day_number <= month_days[month_number - 1]
|
|
24
|
+
and int(hour) <= 23 and int(minute) <= 59 and int(second) <= 59):
|
|
25
|
+
raise ValueError(f"{field_name}: invalid Go time.Time JSON timestamp")
|
|
26
|
+
offset_minutes = 0
|
|
27
|
+
if zone != "Z":
|
|
28
|
+
if int(zone_hour) > 24 or int(zone_minute) > 60:
|
|
29
|
+
raise ValueError(f"{field_name}: invalid Go time.Time JSON offset")
|
|
30
|
+
offset_minutes = (int(zone_hour) * 60 + int(zone_minute)) * (1 if sign == "+" else -1)
|
|
31
|
+
return year, f"{month}-{day}T{int(hour):02d}:{minute}:{second}", offset_minutes, int((fraction or "")[:9].ljust(9, "0"))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def canonical_go_timestamp(value: str, field_name: str) -> str:
|
|
35
|
+
"""Parse Go's accepted JSON timestamp spellings and format like MarshalJSON."""
|
|
36
|
+
year, clock, offset_minutes, nanoseconds = _parts(value, field_name)
|
|
37
|
+
fraction = f"{nanoseconds:09d}".rstrip("0")
|
|
38
|
+
if abs(offset_minutes) >= 24 * 60:
|
|
39
|
+
return value
|
|
40
|
+
offset = "Z" if offset_minutes == 0 else f"{'+' if offset_minutes > 0 else '-'}{abs(offset_minutes) // 60:02d}:{abs(offset_minutes) % 60:02d}"
|
|
41
|
+
return f"{year}-{clock}{'.' + fraction if fraction else ''}{offset}"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def parse_go_datetime(value: str, field_name: str) -> datetime:
|
|
45
|
+
"""Decode a Go timestamp only when Python datetime preserves its value."""
|
|
46
|
+
year, _, offset_minutes, nanoseconds = _parts(value, field_name)
|
|
47
|
+
if int(year) == 0 or nanoseconds % 1000 or abs(offset_minutes) >= 24 * 60:
|
|
48
|
+
raise ValueError(f"{field_name}: Go time.Time JSON timestamp cannot be represented exactly as datetime")
|
|
49
|
+
canonical = canonical_go_timestamp(value, field_name)
|
|
50
|
+
return datetime.fromisoformat(canonical.replace("Z", "+00:00"))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def validate_go_datetime(value: datetime, field_name: str) -> datetime:
|
|
54
|
+
"""Reject Python datetimes that cannot round-trip through Go JSON time."""
|
|
55
|
+
if not isinstance(value, datetime):
|
|
56
|
+
raise ValueError(f"{field_name}: expected a datetime or Go time.Time JSON timestamp")
|
|
57
|
+
offset = value.utcoffset() if value.tzinfo is not None else None
|
|
58
|
+
if offset is None or offset.total_seconds() % 60:
|
|
59
|
+
raise ValueError(f"{field_name}: datetime requires a whole-minute timezone offset")
|
|
60
|
+
return value
|