@automate.ax/integration-contracts 0.88.2 → 0.88.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/github/additional-events.d.ts +219 -16710
  2. package/dist/github/additional-events.js +67 -98
  3. package/dist/github/index.d.ts +97 -2
  4. package/dist/github/index.js +382 -5
  5. package/dist/github/openapi-types.d.ts +21 -0
  6. package/dist/github/openapi-types.generated.d.ts +52350 -0
  7. package/dist/github/openapi-types.generated.js +1 -0
  8. package/dist/github/openapi-types.js +1 -0
  9. package/dist/github/resources.d.ts +7435 -17936
  10. package/dist/github/resources.js +40 -135
  11. package/dist/github/rest-schemas.d.ts +11 -0
  12. package/dist/github/rest-schemas.generated.json +1 -0
  13. package/dist/github/rest-schemas.js +24 -0
  14. package/dist/github/schemas.d.ts +4554 -7321
  15. package/dist/github/schemas.js +68 -77
  16. package/dist/github/webhook-operations.d.ts +52 -0
  17. package/dist/github/webhook-operations.js +134 -0
  18. package/dist/github/webhook-schemas.d.ts +12 -0
  19. package/dist/github/webhook-schemas.generated.json +1 -0
  20. package/dist/github/webhook-schemas.js +28 -0
  21. package/dist/linear/schemas.d.ts +1 -1
  22. package/dist/vercel/index.d.ts +12 -12
  23. package/dist/vercel/schemas.d.ts +18 -18
  24. package/package.json +6 -3
  25. package/src/github/additional-events.ts +631 -273
  26. package/src/github/index.ts +761 -8
  27. package/src/github/openapi-types.generated.ts +52352 -0
  28. package/src/github/openapi-types.ts +59 -0
  29. package/src/github/resources.ts +106 -303
  30. package/src/github/rest-schemas.generated.json +1 -0
  31. package/src/github/rest-schemas.ts +35 -0
  32. package/src/github/schemas.ts +593 -195
  33. package/src/github/webhook-operations.ts +171 -0
  34. package/src/github/webhook-schemas.generated.json +1 -0
  35. package/src/github/webhook-schemas.ts +43 -0
@@ -0,0 +1,59 @@
1
+ import type { Encodable } from "@automate.ax/codec"
2
+ import type { components } from "./openapi-types.generated"
3
+ import type { GitHubRestResourceName } from "./rest-schemas"
4
+ import type { GitHubWebhookAction } from "./webhook-operations"
5
+
6
+ type GitHubOpenApiSchemas = components["schemas"]
7
+
8
+ /** Generated component names that represent webhook operation roots. */
9
+ type GitHubWebhookSchemaName = Extract<
10
+ keyof GitHubOpenApiSchemas,
11
+ `webhook-event-${string}`
12
+ >
13
+
14
+ /** Frozen GitHub OpenAPI webhook operation identifier. */
15
+ export type GitHubWebhookOperation =
16
+ GitHubWebhookSchemaName extends `webhook-event-${infer TOperation}`
17
+ ? TOperation
18
+ : never
19
+
20
+ type GitHubEncodable<TValue> = 0 extends 1 & TValue
21
+ ? Encodable
22
+ : unknown extends TValue
23
+ ? Encodable
24
+ : TValue extends null | undefined | boolean | number | string
25
+ ? TValue
26
+ : TValue extends Record<string, never>
27
+ ? Record<string, Encodable>
28
+ : TValue extends readonly (infer TItem)[]
29
+ ? GitHubEncodable<TItem>[]
30
+ : TValue extends object
31
+ ? keyof TValue extends never
32
+ ? Record<string, Encodable>
33
+ : { [TKey in keyof TValue]: GitHubEncodable<TValue[TKey]> }
34
+ : never
35
+
36
+ /** Public response type generated from the frozen GitHub REST contract. */
37
+ export type GitHubRestResource<TResource extends GitHubRestResourceName> =
38
+ GitHubEncodable<GitHubOpenApiSchemas[`rest-response-${TResource}`]>
39
+
40
+ /** Public event type generated from the frozen GitHub webhook contract. */
41
+ export type GitHubWebhookPayload<TOperation extends GitHubWebhookOperation> =
42
+ TOperation extends GitHubWebhookOperation
43
+ ? GitHubWebhookPayloadForOperation<TOperation>
44
+ : never
45
+
46
+ /** Exact generated payload for one classified webhook operation. */
47
+ type GitHubWebhookPayloadForOperation<
48
+ TOperation extends GitHubWebhookOperation,
49
+ > =
50
+ GitHubEncodable<
51
+ GitHubOpenApiSchemas[Extract<
52
+ `webhook-event-${TOperation}`,
53
+ keyof GitHubOpenApiSchemas
54
+ >]
55
+ > extends infer TPayload
56
+ ? GitHubWebhookAction<TOperation> extends never
57
+ ? TPayload
58
+ : Omit<TPayload, "action"> & { action: GitHubWebhookAction<TOperation> }
59
+ : never
@@ -1,357 +1,160 @@
1
- import type { Encodable } from "@automate.ax/codec"
2
- import type { Octokit } from "@octokit/rest"
3
1
  import * as z from "zod"
2
+ import type { GitHubRestResource } from "./openapi-types"
3
+ import { githubRestResourceSchema } from "./rest-schemas"
4
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
5
+ /** Complete repository response exposed by repository actions. */
6
+ export type GitHubRepository = GitHubRestResource<"repository">
10
7
 
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
8
+ /** Installation repository summary exposed by repository listing. */
9
+ export type GitHubRepositorySummary = GitHubRestResource<"repository-summary">
16
10
 
17
- /** Official repository content response used by the content schema. */
18
- type GitHubRepositoryContent = Awaited<
19
- ReturnType<Octokit["rest"]["repos"]["getContent"]>
20
- >["data"] &
21
- Encodable
11
+ /** File, directory, symlink, or submodule repository content response. */
12
+ export type GitHubRepositoryContent = GitHubRestResource<"repository-content">
22
13
 
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
14
+ /** Repository file write response. */
15
+ export type GitHubRepositoryFileCommit = GitHubRestResource<"file-commit">
28
16
 
29
- /** Official file-deletion response used by the deletion schema. */
30
- type GitHubRepositoryFileDeletion = Awaited<
31
- ReturnType<Octokit["rest"]["repos"]["deleteFile"]>
32
- >["data"] &
33
- Encodable
17
+ /** Repository file deletion response. */
18
+ export type GitHubRepositoryFileDeletion = GitHubRestResource<"file-deletion">
34
19
 
35
- /** Official branch response used by the branch schema. */
36
- type GitHubBranch = Awaited<
37
- ReturnType<Octokit["rest"]["repos"]["getBranch"]>
38
- >["data"] &
39
- Encodable
20
+ /** Complete repository branch response. */
21
+ export type GitHubBranch = GitHubRestResource<"branch">
40
22
 
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
23
+ /** Repository branch-list item. */
24
+ export type GitHubBranchSummary = GitHubRestResource<"branch-summary">
46
25
 
47
- /** Official Git reference response used by the reference schema. */
48
- type GitHubReference = Awaited<
49
- ReturnType<Octokit["rest"]["git"]["createRef"]>
50
- >["data"] &
51
- Encodable
26
+ /** Git reference response. */
27
+ export type GitHubReference = GitHubRestResource<"reference">
52
28
 
53
- /** Official Actions workflow response used by the workflow schema. */
54
- type GitHubWorkflow = Awaited<
55
- ReturnType<Octokit["rest"]["actions"]["getWorkflow"]>
56
- >["data"] &
57
- Encodable
29
+ /** GitHub Actions workflow response. */
30
+ export type GitHubWorkflow = GitHubRestResource<"workflow">
58
31
 
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
32
+ /** GitHub Actions workflow-run response. */
33
+ export type GitHubWorkflowRun = GitHubRestResource<"workflow-run">
64
34
 
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
35
+ /** GitHub Actions workflow-job response. */
36
+ export type GitHubWorkflowJob = GitHubRestResource<"workflow-job">
70
37
 
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
38
+ /** Pull-request file response. */
39
+ export type GitHubPullRequestFile = GitHubRestResource<"pull-request-file">
76
40
 
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
41
+ /** Pull-request review response. */
42
+ export type GitHubPullRequestReview = GitHubRestResource<"pull-request-review">
82
43
 
83
- /** Official review-comment response used by the comment schema. */
84
- type GitHubPullRequestReviewComment = Awaited<
85
- ReturnType<Octokit["rest"]["pulls"]["getReviewComment"]>
86
- >["data"] &
87
- Encodable
44
+ /** Pull-request review-comment response. */
45
+ export type GitHubPullRequestReviewComment =
46
+ GitHubRestResource<"pull-request-review-comment">
88
47
 
89
- /** Official reviewer-request response used by the reviewer schema. */
90
- type GitHubPullRequestReviewRequest = Awaited<
91
- ReturnType<Octokit["rest"]["pulls"]["requestReviewers"]>
92
- >["data"] &
93
- Encodable
48
+ /** Pull-request reviewer-request response. */
49
+ export type GitHubPullRequestReviewRequest =
50
+ GitHubRestResource<"pull-request-review-request">
94
51
 
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
52
+ /** Pull-request branch-update response. */
53
+ export type GitHubPullRequestBranchUpdate =
54
+ GitHubRestResource<"pull-request-branch-update">
100
55
 
101
- /** Official release response used by the release schema. */
102
- type GitHubRelease = Awaited<
103
- ReturnType<Octokit["rest"]["repos"]["getRelease"]>
104
- >["data"] &
105
- Encodable
56
+ /** GitHub release response. */
57
+ export type GitHubRelease = GitHubRestResource<"release">
106
58
 
107
- /** Official release-asset response used by the asset schema. */
108
- type GitHubReleaseAsset = Awaited<
109
- ReturnType<Octokit["rest"]["repos"]["getReleaseAsset"]>
110
- >["data"] &
111
- Encodable
59
+ /** GitHub release-asset response. */
60
+ export type GitHubReleaseAsset = GitHubRestResource<"release-asset">
112
61
 
113
- /** Official deployment response used by the deployment schema. */
114
- type GitHubDeployment = Awaited<
115
- ReturnType<Octokit["rest"]["repos"]["getDeployment"]>
116
- >["data"] &
117
- Encodable
62
+ /** GitHub deployment response. */
63
+ export type GitHubDeployment = GitHubRestResource<"deployment">
118
64
 
119
- /** Official deployment-creation response used by its result schema. */
120
- type GitHubDeploymentCreation = Awaited<
121
- ReturnType<Octokit["rest"]["repos"]["createDeployment"]>
122
- >["data"] &
123
- Encodable
65
+ /** GitHub deployment-creation response or provider message. */
66
+ export type GitHubDeploymentCreation = GitHubRestResource<"deployment-creation">
124
67
 
125
- /** Official deployment-status response used by the status schema. */
126
- type GitHubDeploymentStatus = Awaited<
127
- ReturnType<Octokit["rest"]["repos"]["createDeploymentStatus"]>
128
- >["data"] &
129
- Encodable
68
+ /** GitHub deployment-status response. */
69
+ export type GitHubDeploymentStatus = GitHubRestResource<"deployment-status">
130
70
 
131
- /** Official commit-status response used by the status schema. */
132
- type GitHubCommitStatus = Awaited<
133
- ReturnType<Octokit["rest"]["repos"]["createCommitStatus"]>
134
- >["data"] &
135
- Encodable
71
+ /** GitHub commit-status response. */
72
+ export type GitHubCommitStatus = GitHubRestResource<"commit-status">
136
73
 
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
74
+ /** GitHub check-run response. */
75
+ export type GitHubCheckRun = GitHubRestResource<"check-run">
142
76
 
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
77
+ /** Combined commit-status response. */
78
+ export type GitHubCombinedCommitStatus =
79
+ GitHubRestResource<"combined-commit-status">
148
80
 
149
81
  /** 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
82
+ export type GitHubWorkflowDispatchResult =
83
+ GitHubRestResource<"workflow-dispatch">
154
84
 
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
- )
85
+ export const GITHUB_REPOSITORY_SCHEMA =
86
+ githubRestResourceSchema<GitHubRepository>("repository")
263
87
  export const GITHUB_REPOSITORY_SUMMARY_SCHEMA =
264
- githubResourceSchema<GitHubRepositorySummary>(GITHUB_REPOSITORY_BASE_SCHEMA)
88
+ githubRestResourceSchema<GitHubRepositorySummary>("repository-summary")
265
89
  export const GITHUB_REPOSITORY_CONTENT_SCHEMA =
266
- githubResourceSchema<GitHubRepositoryContent>(
267
- GITHUB_REPOSITORY_CONTENT_BASE_SCHEMA,
268
- )
90
+ githubRestResourceSchema<GitHubRepositoryContent>("repository-content")
269
91
  export const GITHUB_REPOSITORY_FILE_COMMIT_SCHEMA =
270
- githubResourceSchema<GitHubRepositoryFileCommit>(
271
- GITHUB_FILE_COMMIT_BASE_SCHEMA,
272
- )
92
+ githubRestResourceSchema<GitHubRepositoryFileCommit>("file-commit")
273
93
  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
- )
94
+ githubRestResourceSchema<GitHubRepositoryFileDeletion>("file-deletion")
95
+ export const GITHUB_BRANCH_SCHEMA =
96
+ githubRestResourceSchema<GitHubBranch>("branch")
280
97
  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
- )
98
+ githubRestResourceSchema<GitHubBranchSummary>("branch-summary")
99
+ export const GITHUB_REFERENCE_SCHEMA =
100
+ githubRestResourceSchema<GitHubReference>("reference")
101
+ export const GITHUB_WORKFLOW_SCHEMA =
102
+ githubRestResourceSchema<GitHubWorkflow>("workflow")
288
103
  export const GITHUB_WORKFLOW_RUN_SCHEMA =
289
- githubResourceSchema<GitHubWorkflowRun>(GITHUB_WORKFLOW_RUN_BASE_SCHEMA)
104
+ githubRestResourceSchema<GitHubWorkflowRun>("workflow-run")
290
105
  export const GITHUB_WORKFLOW_JOB_SCHEMA =
291
- githubResourceSchema<GitHubWorkflowJob>(GITHUB_WORKFLOW_JOB_BASE_SCHEMA)
106
+ githubRestResourceSchema<GitHubWorkflowJob>("workflow-job")
292
107
  export const GITHUB_PULL_REQUEST_FILE_SCHEMA =
293
- githubResourceSchema<GitHubPullRequestFile>(
294
- GITHUB_PULL_REQUEST_FILE_BASE_SCHEMA,
295
- )
108
+ githubRestResourceSchema<GitHubPullRequestFile>("pull-request-file")
296
109
  export const GITHUB_PULL_REQUEST_REVIEW_RESOURCE_SCHEMA =
297
- githubResourceSchema<GitHubPullRequestReview>(
298
- GITHUB_PULL_REQUEST_REVIEW_BASE_SCHEMA,
299
- )
110
+ githubRestResourceSchema<GitHubPullRequestReview>("pull-request-review")
300
111
  export const GITHUB_PULL_REQUEST_REVIEW_REQUEST_SCHEMA =
301
- githubResourceSchema<GitHubPullRequestReviewRequest>(
302
- GITHUB_PULL_REQUEST_REVIEW_BASE_SCHEMA,
112
+ githubRestResourceSchema<GitHubPullRequestReviewRequest>(
113
+ "pull-request-review-request",
303
114
  )
304
115
  export const GITHUB_PULL_REQUEST_REVIEW_COMMENT_SCHEMA =
305
- githubResourceSchema<GitHubPullRequestReviewComment>(
306
- GITHUB_PULL_REQUEST_REVIEW_COMMENT_BASE_SCHEMA,
116
+ githubRestResourceSchema<GitHubPullRequestReviewComment>(
117
+ "pull-request-review-comment",
307
118
  )
308
119
  export const GITHUB_PULL_REQUEST_BRANCH_UPDATE_SCHEMA =
309
- githubResourceSchema<GitHubPullRequestBranchUpdate>(
310
- GITHUB_PULL_REQUEST_BRANCH_UPDATE_BASE_SCHEMA,
120
+ githubRestResourceSchema<GitHubPullRequestBranchUpdate>(
121
+ "pull-request-branch-update",
311
122
  )
312
- export const GITHUB_RELEASE_SCHEMA = githubResourceSchema<GitHubRelease>(
313
- GITHUB_RELEASE_BASE_SCHEMA,
314
- )
123
+ export const GITHUB_RELEASE_SCHEMA =
124
+ githubRestResourceSchema<GitHubRelease>("release")
315
125
  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
- )
126
+ githubRestResourceSchema<GitHubReleaseAsset>("release-asset")
127
+ export const GITHUB_DEPLOYMENT_SCHEMA =
128
+ githubRestResourceSchema<GitHubDeployment>("deployment")
320
129
  export const GITHUB_DEPLOYMENT_CREATION_SCHEMA =
321
- githubResourceSchema<GitHubDeploymentCreation>(
322
- GITHUB_DEPLOYMENT_CREATION_BASE_SCHEMA,
323
- )
130
+ githubRestResourceSchema<GitHubDeploymentCreation>("deployment-creation")
324
131
  export const GITHUB_DEPLOYMENT_STATUS_SCHEMA =
325
- githubResourceSchema<GitHubDeploymentStatus>(
326
- GITHUB_DEPLOYMENT_STATUS_BASE_SCHEMA,
327
- )
132
+ githubRestResourceSchema<GitHubDeploymentStatus>("deployment-status")
328
133
  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
- )
134
+ githubRestResourceSchema<GitHubCommitStatus>("commit-status")
135
+ export const GITHUB_CHECK_RUN_SCHEMA =
136
+ githubRestResourceSchema<GitHubCheckRun>("check-run")
333
137
  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
- })
138
+ githubRestResourceSchema<GitHubCombinedCommitStatus>("combined-commit-status")
139
+ export const GITHUB_WORKFLOW_DISPATCH_RESULT_SCHEMA = z.preprocess(
140
+ normalizeGitHubJsonResponse,
141
+ githubRestResourceSchema<GitHubWorkflowDispatchResult>("workflow-dispatch"),
142
+ )
348
143
  export const GITHUB_EMPTY_RESPONSE_SCHEMA = z.object({})
349
144
 
350
145
  /**
351
- * Validates a provider resource while preserving its official Octokit type.
146
+ * Octokit returns text when GitHub omits or mislabels the JSON content type.
147
+ * Leave malformed text untouched so output validation fails terminally outside
148
+ * the action handler instead of throwing a retryable post-side-effect error.
352
149
  *
353
- * @param schema - Runtime schema for the resource's stable fields.
150
+ * @param value - Octokit response data.
354
151
  */
355
- function githubResourceSchema<T>(schema: z.ZodType): z.ZodType<T> {
356
- return z.custom<T>((value) => schema.safeParse(value).success)
152
+ function normalizeGitHubJsonResponse(value: unknown): unknown {
153
+ if (typeof value !== "string") return value
154
+ try {
155
+ const parsed: unknown = JSON.parse(value)
156
+ return parsed
157
+ } catch {
158
+ return value
159
+ }
357
160
  }