@automate.ax/integration-contracts 0.86.2 → 0.87.0

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.
@@ -0,0 +1,357 @@
1
+ import type { Encodable } from "@automate.ax/codec"
2
+ import type { Octokit } from "@octokit/rest"
3
+ import * as z from "zod"
4
+
5
+ /** Official repository response used by the exported runtime schema. */
6
+ type GitHubRepository = Awaited<
7
+ ReturnType<Octokit["rest"]["repos"]["get"]>
8
+ >["data"] &
9
+ Encodable
10
+
11
+ /** Official installation repository summary used by the list schema. */
12
+ type GitHubRepositorySummary = Awaited<
13
+ ReturnType<Octokit["rest"]["apps"]["listReposAccessibleToInstallation"]>
14
+ >["data"]["repositories"][number] &
15
+ Encodable
16
+
17
+ /** Official repository content response used by the content schema. */
18
+ type GitHubRepositoryContent = Awaited<
19
+ ReturnType<Octokit["rest"]["repos"]["getContent"]>
20
+ >["data"] &
21
+ Encodable
22
+
23
+ /** Official file-write response used by the file commit schema. */
24
+ type GitHubRepositoryFileCommit = Awaited<
25
+ ReturnType<Octokit["rest"]["repos"]["createOrUpdateFileContents"]>
26
+ >["data"] &
27
+ Encodable
28
+
29
+ /** Official file-deletion response used by the deletion schema. */
30
+ type GitHubRepositoryFileDeletion = Awaited<
31
+ ReturnType<Octokit["rest"]["repos"]["deleteFile"]>
32
+ >["data"] &
33
+ Encodable
34
+
35
+ /** Official branch response used by the branch schema. */
36
+ type GitHubBranch = Awaited<
37
+ ReturnType<Octokit["rest"]["repos"]["getBranch"]>
38
+ >["data"] &
39
+ Encodable
40
+
41
+ /** Official branch summary used by the branch list schema. */
42
+ type GitHubBranchSummary = Awaited<
43
+ ReturnType<Octokit["rest"]["repos"]["listBranches"]>
44
+ >["data"][number] &
45
+ Encodable
46
+
47
+ /** Official Git reference response used by the reference schema. */
48
+ type GitHubReference = Awaited<
49
+ ReturnType<Octokit["rest"]["git"]["createRef"]>
50
+ >["data"] &
51
+ Encodable
52
+
53
+ /** Official Actions workflow response used by the workflow schema. */
54
+ type GitHubWorkflow = Awaited<
55
+ ReturnType<Octokit["rest"]["actions"]["getWorkflow"]>
56
+ >["data"] &
57
+ Encodable
58
+
59
+ /** Official Actions workflow-run response used by the run schema. */
60
+ type GitHubWorkflowRun = Awaited<
61
+ ReturnType<Octokit["rest"]["actions"]["getWorkflowRun"]>
62
+ >["data"] &
63
+ Encodable
64
+
65
+ /** Official Actions job response used by the job schema. */
66
+ type GitHubWorkflowJob = Awaited<
67
+ ReturnType<Octokit["rest"]["actions"]["listJobsForWorkflowRun"]>
68
+ >["data"]["jobs"][number] &
69
+ Encodable
70
+
71
+ /** Official pull request file response used by the file schema. */
72
+ type GitHubPullRequestFile = Awaited<
73
+ ReturnType<Octokit["rest"]["pulls"]["listFiles"]>
74
+ >["data"][number] &
75
+ Encodable
76
+
77
+ /** Official pull request review response used by the review schema. */
78
+ type GitHubPullRequestReview = Awaited<
79
+ ReturnType<Octokit["rest"]["pulls"]["createReview"]>
80
+ >["data"] &
81
+ Encodable
82
+
83
+ /** Official review-comment response used by the comment schema. */
84
+ type GitHubPullRequestReviewComment = Awaited<
85
+ ReturnType<Octokit["rest"]["pulls"]["getReviewComment"]>
86
+ >["data"] &
87
+ Encodable
88
+
89
+ /** Official reviewer-request response used by the reviewer schema. */
90
+ type GitHubPullRequestReviewRequest = Awaited<
91
+ ReturnType<Octokit["rest"]["pulls"]["requestReviewers"]>
92
+ >["data"] &
93
+ Encodable
94
+
95
+ /** Official pull request branch-update response used by its schema. */
96
+ type GitHubPullRequestBranchUpdate = Awaited<
97
+ ReturnType<Octokit["rest"]["pulls"]["updateBranch"]>
98
+ >["data"] &
99
+ Encodable
100
+
101
+ /** Official release response used by the release schema. */
102
+ type GitHubRelease = Awaited<
103
+ ReturnType<Octokit["rest"]["repos"]["getRelease"]>
104
+ >["data"] &
105
+ Encodable
106
+
107
+ /** Official release-asset response used by the asset schema. */
108
+ type GitHubReleaseAsset = Awaited<
109
+ ReturnType<Octokit["rest"]["repos"]["getReleaseAsset"]>
110
+ >["data"] &
111
+ Encodable
112
+
113
+ /** Official deployment response used by the deployment schema. */
114
+ type GitHubDeployment = Awaited<
115
+ ReturnType<Octokit["rest"]["repos"]["getDeployment"]>
116
+ >["data"] &
117
+ Encodable
118
+
119
+ /** Official deployment-creation response used by its result schema. */
120
+ type GitHubDeploymentCreation = Awaited<
121
+ ReturnType<Octokit["rest"]["repos"]["createDeployment"]>
122
+ >["data"] &
123
+ Encodable
124
+
125
+ /** Official deployment-status response used by the status schema. */
126
+ type GitHubDeploymentStatus = Awaited<
127
+ ReturnType<Octokit["rest"]["repos"]["createDeploymentStatus"]>
128
+ >["data"] &
129
+ Encodable
130
+
131
+ /** Official commit-status response used by the status schema. */
132
+ type GitHubCommitStatus = Awaited<
133
+ ReturnType<Octokit["rest"]["repos"]["createCommitStatus"]>
134
+ >["data"] &
135
+ Encodable
136
+
137
+ /** Official check-run response used by the check-run schema. */
138
+ type GitHubCheckRun = Awaited<
139
+ ReturnType<Octokit["rest"]["checks"]["get"]>
140
+ >["data"] &
141
+ Encodable
142
+
143
+ /** Official combined-status response used by the combined status schema. */
144
+ type GitHubCombinedCommitStatus = Awaited<
145
+ ReturnType<Octokit["rest"]["repos"]["getCombinedStatusForRef"]>
146
+ >["data"] &
147
+ Encodable
148
+
149
+ /** Current GitHub REST response for a successful workflow dispatch. */
150
+ export interface GitHubWorkflowDispatchResult
151
+ extends Record<string, Encodable> {
152
+ /** Web URL for the created workflow run. */
153
+ html_url: string
154
+
155
+ /** API URL for the created workflow run. */
156
+ run_url: string
157
+
158
+ /** Stable ID of the created workflow run. */
159
+ workflow_run_id: number
160
+ }
161
+
162
+ const GITHUB_REPOSITORY_BASE_SCHEMA = z.looseObject({
163
+ full_name: z.string(),
164
+ id: z.number().int().positive(),
165
+ name: z.string(),
166
+ })
167
+ const GITHUB_REPOSITORY_CONTENT_BASE_SCHEMA = z.union([
168
+ z.looseObject({ path: z.string(), sha: z.string(), type: z.string() }),
169
+ z
170
+ .looseObject({ path: z.string(), sha: z.string(), type: z.string() })
171
+ .array(),
172
+ ])
173
+ const GITHUB_FILE_COMMIT_BASE_SCHEMA = z.looseObject({
174
+ commit: z.looseObject({ sha: z.string() }),
175
+ content: z.looseObject({ path: z.string(), sha: z.string() }).nullable(),
176
+ })
177
+ const GITHUB_BRANCH_BASE_SCHEMA = z.looseObject({
178
+ commit: z.looseObject({ sha: z.string() }),
179
+ name: z.string(),
180
+ })
181
+ const GITHUB_REFERENCE_BASE_SCHEMA = z.looseObject({
182
+ object: z.looseObject({ sha: z.string(), type: z.string() }),
183
+ ref: z.string(),
184
+ })
185
+ const GITHUB_WORKFLOW_BASE_SCHEMA = z.looseObject({
186
+ id: z.number().int().positive(),
187
+ name: z.string(),
188
+ path: z.string(),
189
+ state: z.string(),
190
+ })
191
+ const GITHUB_WORKFLOW_RUN_BASE_SCHEMA = z.looseObject({
192
+ conclusion: z.string().nullable(),
193
+ html_url: z.string(),
194
+ id: z.number().int().positive(),
195
+ status: z.string().nullable(),
196
+ })
197
+ const GITHUB_WORKFLOW_JOB_BASE_SCHEMA = z.looseObject({
198
+ conclusion: z.string().nullable(),
199
+ id: z.number().int().positive(),
200
+ name: z.string(),
201
+ status: z.string(),
202
+ })
203
+ const GITHUB_PULL_REQUEST_FILE_BASE_SCHEMA = z.looseObject({
204
+ filename: z.string(),
205
+ sha: z.string(),
206
+ status: z.string(),
207
+ })
208
+ const GITHUB_PULL_REQUEST_REVIEW_BASE_SCHEMA = z.looseObject({
209
+ id: z.number().int().positive(),
210
+ state: z.string(),
211
+ })
212
+ const GITHUB_PULL_REQUEST_REVIEW_COMMENT_BASE_SCHEMA = z.looseObject({
213
+ body: z.string(),
214
+ id: z.number().int().positive(),
215
+ path: z.string(),
216
+ })
217
+ const GITHUB_PULL_REQUEST_BRANCH_UPDATE_BASE_SCHEMA = z.looseObject({
218
+ message: z.string(),
219
+ url: z.string(),
220
+ })
221
+ const GITHUB_RELEASE_BASE_SCHEMA = z.looseObject({
222
+ draft: z.boolean(),
223
+ id: z.number().int().positive(),
224
+ prerelease: z.boolean(),
225
+ tag_name: z.string(),
226
+ })
227
+ const GITHUB_RELEASE_ASSET_BASE_SCHEMA = z.looseObject({
228
+ browser_download_url: z.string(),
229
+ id: z.number().int().positive(),
230
+ name: z.string(),
231
+ size: z.number().int().nonnegative(),
232
+ state: z.string(),
233
+ })
234
+ const GITHUB_DEPLOYMENT_BASE_SCHEMA = z.looseObject({
235
+ environment: z.string(),
236
+ id: z.number().int().positive(),
237
+ ref: z.string(),
238
+ })
239
+ const GITHUB_DEPLOYMENT_CREATION_BASE_SCHEMA = z.union([
240
+ GITHUB_DEPLOYMENT_BASE_SCHEMA,
241
+ z.looseObject({ message: z.string() }),
242
+ ])
243
+ const GITHUB_DEPLOYMENT_STATUS_BASE_SCHEMA = z.looseObject({
244
+ id: z.number().int().positive(),
245
+ state: z.string(),
246
+ })
247
+ const GITHUB_COMMIT_STATUS_BASE_SCHEMA = z.looseObject({
248
+ context: z.string(),
249
+ id: z.number().int().positive(),
250
+ state: z.string(),
251
+ })
252
+ const GITHUB_CHECK_RUN_BASE_SCHEMA = z.looseObject({
253
+ conclusion: z.string().nullable(),
254
+ head_sha: z.string(),
255
+ id: z.number().int().positive(),
256
+ name: z.string(),
257
+ status: z.string(),
258
+ })
259
+
260
+ export const GITHUB_REPOSITORY_SCHEMA = githubResourceSchema<GitHubRepository>(
261
+ GITHUB_REPOSITORY_BASE_SCHEMA,
262
+ )
263
+ export const GITHUB_REPOSITORY_SUMMARY_SCHEMA =
264
+ githubResourceSchema<GitHubRepositorySummary>(GITHUB_REPOSITORY_BASE_SCHEMA)
265
+ export const GITHUB_REPOSITORY_CONTENT_SCHEMA =
266
+ githubResourceSchema<GitHubRepositoryContent>(
267
+ GITHUB_REPOSITORY_CONTENT_BASE_SCHEMA,
268
+ )
269
+ export const GITHUB_REPOSITORY_FILE_COMMIT_SCHEMA =
270
+ githubResourceSchema<GitHubRepositoryFileCommit>(
271
+ GITHUB_FILE_COMMIT_BASE_SCHEMA,
272
+ )
273
+ export const GITHUB_REPOSITORY_FILE_DELETION_SCHEMA =
274
+ githubResourceSchema<GitHubRepositoryFileDeletion>(
275
+ GITHUB_FILE_COMMIT_BASE_SCHEMA,
276
+ )
277
+ export const GITHUB_BRANCH_SCHEMA = githubResourceSchema<GitHubBranch>(
278
+ GITHUB_BRANCH_BASE_SCHEMA,
279
+ )
280
+ export const GITHUB_BRANCH_SUMMARY_SCHEMA =
281
+ githubResourceSchema<GitHubBranchSummary>(GITHUB_BRANCH_BASE_SCHEMA)
282
+ export const GITHUB_REFERENCE_SCHEMA = githubResourceSchema<GitHubReference>(
283
+ GITHUB_REFERENCE_BASE_SCHEMA,
284
+ )
285
+ export const GITHUB_WORKFLOW_SCHEMA = githubResourceSchema<GitHubWorkflow>(
286
+ GITHUB_WORKFLOW_BASE_SCHEMA,
287
+ )
288
+ export const GITHUB_WORKFLOW_RUN_SCHEMA =
289
+ githubResourceSchema<GitHubWorkflowRun>(GITHUB_WORKFLOW_RUN_BASE_SCHEMA)
290
+ export const GITHUB_WORKFLOW_JOB_SCHEMA =
291
+ githubResourceSchema<GitHubWorkflowJob>(GITHUB_WORKFLOW_JOB_BASE_SCHEMA)
292
+ export const GITHUB_PULL_REQUEST_FILE_SCHEMA =
293
+ githubResourceSchema<GitHubPullRequestFile>(
294
+ GITHUB_PULL_REQUEST_FILE_BASE_SCHEMA,
295
+ )
296
+ export const GITHUB_PULL_REQUEST_REVIEW_RESOURCE_SCHEMA =
297
+ githubResourceSchema<GitHubPullRequestReview>(
298
+ GITHUB_PULL_REQUEST_REVIEW_BASE_SCHEMA,
299
+ )
300
+ export const GITHUB_PULL_REQUEST_REVIEW_REQUEST_SCHEMA =
301
+ githubResourceSchema<GitHubPullRequestReviewRequest>(
302
+ GITHUB_PULL_REQUEST_REVIEW_BASE_SCHEMA,
303
+ )
304
+ export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_SCHEMA =
305
+ githubResourceSchema<GitHubPullRequestReviewComment>(
306
+ GITHUB_PULL_REQUEST_REVIEW_COMMENT_BASE_SCHEMA,
307
+ )
308
+ export const GITHUB_PULL_REQUEST_BRANCH_UPDATE_SCHEMA =
309
+ githubResourceSchema<GitHubPullRequestBranchUpdate>(
310
+ GITHUB_PULL_REQUEST_BRANCH_UPDATE_BASE_SCHEMA,
311
+ )
312
+ export const GITHUB_RELEASE_SCHEMA = githubResourceSchema<GitHubRelease>(
313
+ GITHUB_RELEASE_BASE_SCHEMA,
314
+ )
315
+ export const GITHUB_RELEASE_ASSET_SCHEMA =
316
+ githubResourceSchema<GitHubReleaseAsset>(GITHUB_RELEASE_ASSET_BASE_SCHEMA)
317
+ export const GITHUB_DEPLOYMENT_SCHEMA = githubResourceSchema<GitHubDeployment>(
318
+ GITHUB_DEPLOYMENT_BASE_SCHEMA,
319
+ )
320
+ export const GITHUB_DEPLOYMENT_CREATION_SCHEMA =
321
+ githubResourceSchema<GitHubDeploymentCreation>(
322
+ GITHUB_DEPLOYMENT_CREATION_BASE_SCHEMA,
323
+ )
324
+ export const GITHUB_DEPLOYMENT_STATUS_SCHEMA =
325
+ githubResourceSchema<GitHubDeploymentStatus>(
326
+ GITHUB_DEPLOYMENT_STATUS_BASE_SCHEMA,
327
+ )
328
+ export const GITHUB_COMMIT_STATUS_SCHEMA =
329
+ githubResourceSchema<GitHubCommitStatus>(GITHUB_COMMIT_STATUS_BASE_SCHEMA)
330
+ export const GITHUB_CHECK_RUN_SCHEMA = githubResourceSchema<GitHubCheckRun>(
331
+ GITHUB_CHECK_RUN_BASE_SCHEMA,
332
+ )
333
+ export const GITHUB_COMBINED_COMMIT_STATUS_SCHEMA =
334
+ githubResourceSchema<GitHubCombinedCommitStatus>(
335
+ z.looseObject({
336
+ sha: z.string(),
337
+ state: z.string(),
338
+ statuses: GITHUB_COMMIT_STATUS_BASE_SCHEMA.array(),
339
+ total_count: z.number().int().nonnegative(),
340
+ }),
341
+ )
342
+ export const GITHUB_WORKFLOW_DISPATCH_RESULT_SCHEMA: z.ZodType<GitHubWorkflowDispatchResult> =
343
+ z.object({
344
+ html_url: z.string(),
345
+ run_url: z.string(),
346
+ workflow_run_id: z.number().int().positive(),
347
+ })
348
+ export const GITHUB_EMPTY_RESPONSE_SCHEMA = z.object({})
349
+
350
+ /**
351
+ * Validates a provider resource while preserving its official Octokit type.
352
+ *
353
+ * @param schema - Runtime schema for the resource's stable fields.
354
+ */
355
+ function githubResourceSchema<T>(schema: z.ZodType): z.ZodType<T> {
356
+ return z.custom<T>((value) => schema.safeParse(value).success)
357
+ }
@@ -3,6 +3,9 @@ import type { webhooks } from "@octokit/openapi-webhooks-types"
3
3
  import type { Octokit } from "@octokit/rest"
4
4
  import * as z from "zod"
5
5
 
6
+ export * from "./resources"
7
+ export * from "./additional-events"
8
+
6
9
  const GITHUB_EVENT_BASE_SCHEMA = z.looseObject({
7
10
  installation: z.looseObject({ id: z.number().int().positive() }),
8
11
  repository: z.looseObject({