@automate.ax/integration-contracts 0.105.0 → 0.109.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.
- package/dist/airtable/api.js +6 -4
- package/dist/airtable/index.d.ts +997 -19
- package/dist/airtable/index.js +30 -2
- package/dist/airtable/schemas.d.ts +2034 -44
- package/dist/airtable/schemas.js +231 -47
- package/dist/brevo/api.d.ts +41 -0
- package/dist/brevo/api.js +74 -4
- package/dist/close/events.d.ts +13 -13
- package/dist/close/schemas.d.ts +9 -9
- package/dist/cloudflare/api.d.ts +93 -0
- package/dist/cloudflare/api.js +250 -0
- package/dist/cloudflare/events.d.ts +1340 -0
- package/dist/cloudflare/events.js +178 -0
- package/dist/cloudflare/index.d.ts +3 -0
- package/dist/cloudflare/index.js +3 -0
- package/dist/cloudflare/schemas.d.ts +608 -0
- package/dist/cloudflare/schemas.js +340 -0
- package/dist/linear/api.d.ts +1 -1
- package/dist/linear/api.js +9 -6
- package/dist/linear/index.d.ts +3479 -782
- package/dist/linear/index.js +249 -13
- package/dist/linear/schemas.d.ts +2724 -31
- package/dist/linear/schemas.js +515 -2
- package/dist/notion/schemas.d.ts +112 -112
- package/dist/outlook/schemas.d.ts +2 -2
- package/dist/resend/action-schemas.d.ts +9 -9
- package/dist/resend/index.d.ts +36 -36
- package/dist/resend/schemas.d.ts +40 -40
- package/dist/teams/schemas.d.ts +5 -5
- package/dist/triggers.d.ts +2 -1
- package/dist/whatsapp/index.d.ts +2 -2
- package/dist/whatsapp/schemas.d.ts +5 -5
- package/package.json +8 -2
- package/src/airtable/api.ts +7 -4
- package/src/airtable/index.ts +36 -1
- package/src/airtable/schemas.ts +294 -63
- package/src/brevo/api.ts +103 -8
- package/src/cloudflare/api.ts +340 -0
- package/src/cloudflare/events.ts +212 -0
- package/src/cloudflare/index.ts +3 -0
- package/src/cloudflare/schemas.ts +359 -0
- package/src/linear/api.ts +10 -6
- package/src/linear/index.ts +249 -26
- package/src/linear/schemas.ts +688 -2
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { encodableSchema } from "@automate.ax/codec"
|
|
3
|
+
|
|
4
|
+
const IDENTIFIER_SCHEMA = z.string().trim().min(1).max(32)
|
|
5
|
+
const RESPONSE_INFO_SCHEMA = z.object({
|
|
6
|
+
code: z.number().optional(),
|
|
7
|
+
documentationUrl: z.string().optional(),
|
|
8
|
+
message: z.string(),
|
|
9
|
+
source: z.object({ pointer: z.string().optional() }).optional(),
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
export const CLOUDFLARE_PAGE_INFO_SCHEMA = z.object({
|
|
13
|
+
count: z.number().int().nonnegative().optional(),
|
|
14
|
+
page: z.number().int().positive().optional(),
|
|
15
|
+
perPage: z.number().int().positive().optional(),
|
|
16
|
+
totalCount: z.number().int().nonnegative().optional(),
|
|
17
|
+
totalPages: z.number().int().nonnegative().optional(),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const CLOUDFLARE_ACCOUNT_SCHEMA = z.object({
|
|
21
|
+
id: IDENTIFIER_SCHEMA,
|
|
22
|
+
name: z.string().min(1),
|
|
23
|
+
settings: z
|
|
24
|
+
.object({
|
|
25
|
+
abuseContactEmail: z.string().nullable().optional(),
|
|
26
|
+
enforceTwoFactor: z.boolean().optional(),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
type: z.enum(["enterprise", "standard"]).optional(),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export const CLOUDFLARE_ZONE_SCHEMA = z.object({
|
|
33
|
+
account: z.object({
|
|
34
|
+
id: IDENTIFIER_SCHEMA,
|
|
35
|
+
name: z.string().optional(),
|
|
36
|
+
}),
|
|
37
|
+
activatedOn: z.string().nullable().optional(),
|
|
38
|
+
createdOn: z.string(),
|
|
39
|
+
developmentMode: z.number(),
|
|
40
|
+
id: IDENTIFIER_SCHEMA,
|
|
41
|
+
meta: z.object({
|
|
42
|
+
cdnOnly: z.boolean().optional(),
|
|
43
|
+
customCertificateQuota: z.number().int().optional(),
|
|
44
|
+
dnsOnly: z.boolean().optional(),
|
|
45
|
+
foundationDns: z.boolean().optional(),
|
|
46
|
+
pageRuleQuota: z.number().int().optional(),
|
|
47
|
+
phishingDetected: z.boolean().optional(),
|
|
48
|
+
step: z.number().int().optional(),
|
|
49
|
+
}),
|
|
50
|
+
modifiedOn: z.string(),
|
|
51
|
+
name: z.string().min(1).max(253),
|
|
52
|
+
nameServers: z.string().array(),
|
|
53
|
+
originalDnshost: z.string().nullable().optional(),
|
|
54
|
+
originalNameServers: z.string().array().nullable().optional(),
|
|
55
|
+
originalRegistrar: z.string().nullable().optional(),
|
|
56
|
+
paused: z.boolean(),
|
|
57
|
+
status: z.enum(["active", "initializing", "moved", "pending"]),
|
|
58
|
+
type: z.enum(["full", "internal", "partial", "secondary"]),
|
|
59
|
+
vanityNameServers: z.string().array().optional(),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export const CLOUDFLARE_DNS_RECORD_TYPE_SCHEMA = z.enum([
|
|
63
|
+
"A",
|
|
64
|
+
"AAAA",
|
|
65
|
+
"CAA",
|
|
66
|
+
"CERT",
|
|
67
|
+
"CNAME",
|
|
68
|
+
"DNSKEY",
|
|
69
|
+
"DS",
|
|
70
|
+
"HTTPS",
|
|
71
|
+
"LOC",
|
|
72
|
+
"MX",
|
|
73
|
+
"NAPTR",
|
|
74
|
+
"NS",
|
|
75
|
+
"OPENPGPKEY",
|
|
76
|
+
"PTR",
|
|
77
|
+
"SMIMEA",
|
|
78
|
+
"SRV",
|
|
79
|
+
"SSHFP",
|
|
80
|
+
"SVCB",
|
|
81
|
+
"TLSA",
|
|
82
|
+
"TXT",
|
|
83
|
+
"URI",
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
export const CLOUDFLARE_DNS_RECORD_SCHEMA = z.object({
|
|
87
|
+
comment: z.string().nullable().optional(),
|
|
88
|
+
commentModifiedOn: z.string().nullable().optional(),
|
|
89
|
+
content: z.string(),
|
|
90
|
+
createdOn: z.string(),
|
|
91
|
+
data: z.record(z.string(), encodableSchema).optional(),
|
|
92
|
+
id: IDENTIFIER_SCHEMA,
|
|
93
|
+
meta: z.record(z.string(), encodableSchema).optional(),
|
|
94
|
+
modifiedOn: z.string(),
|
|
95
|
+
name: z.string().min(1).max(255),
|
|
96
|
+
priority: z.number().int().min(0).max(65_535).optional(),
|
|
97
|
+
proxiable: z.boolean(),
|
|
98
|
+
proxied: z.boolean(),
|
|
99
|
+
settings: z.record(z.string(), encodableSchema).optional(),
|
|
100
|
+
tags: z.string().array().optional(),
|
|
101
|
+
tagsModifiedOn: z.string().nullable().optional(),
|
|
102
|
+
ttl: z.number().int().nonnegative(),
|
|
103
|
+
type: CLOUDFLARE_DNS_RECORD_TYPE_SCHEMA,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
export const CLOUDFLARE_HEALTH_CHECK_REGION_SCHEMA = z.enum([
|
|
107
|
+
"ALL_REGIONS",
|
|
108
|
+
"EEU",
|
|
109
|
+
"ENAM",
|
|
110
|
+
"IN",
|
|
111
|
+
"ME",
|
|
112
|
+
"NAF",
|
|
113
|
+
"NEAS",
|
|
114
|
+
"NSAM",
|
|
115
|
+
"OC",
|
|
116
|
+
"SAF",
|
|
117
|
+
"SEAS",
|
|
118
|
+
"SSAM",
|
|
119
|
+
"WEU",
|
|
120
|
+
"WNAM",
|
|
121
|
+
])
|
|
122
|
+
|
|
123
|
+
export const CLOUDFLARE_HTTP_HEALTH_CHECK_SCHEMA = z.object({
|
|
124
|
+
allowInsecure: z.boolean().optional(),
|
|
125
|
+
expectedBody: z.string().optional(),
|
|
126
|
+
expectedCodes: z.string().array().nullable().optional(),
|
|
127
|
+
followRedirects: z.boolean().optional(),
|
|
128
|
+
header: z.record(z.string(), z.string().array()).nullable().optional(),
|
|
129
|
+
method: z.enum(["GET", "HEAD"]).optional(),
|
|
130
|
+
path: z.string().optional(),
|
|
131
|
+
port: z.number().int().min(0).max(65_535).optional(),
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
export const CLOUDFLARE_TCP_HEALTH_CHECK_SCHEMA = z.object({
|
|
135
|
+
method: z.literal("connection_established").optional(),
|
|
136
|
+
port: z.number().int().min(0).max(65_535).optional(),
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
export const CLOUDFLARE_HEALTH_CHECK_SCHEMA = z.object({
|
|
140
|
+
address: z.string(),
|
|
141
|
+
checkRegions: CLOUDFLARE_HEALTH_CHECK_REGION_SCHEMA.array()
|
|
142
|
+
.nullable()
|
|
143
|
+
.optional(),
|
|
144
|
+
consecutiveFails: z.number().int().nonnegative().optional(),
|
|
145
|
+
consecutiveSuccesses: z.number().int().nonnegative().optional(),
|
|
146
|
+
createdOn: z.string().optional(),
|
|
147
|
+
description: z.string().optional(),
|
|
148
|
+
failureReason: z.string().optional(),
|
|
149
|
+
httpConfig: CLOUDFLARE_HTTP_HEALTH_CHECK_SCHEMA.nullable().optional(),
|
|
150
|
+
id: IDENTIFIER_SCHEMA.optional(),
|
|
151
|
+
interval: z.number().int().nonnegative().optional(),
|
|
152
|
+
modifiedOn: z.string().optional(),
|
|
153
|
+
name: z.string().regex(/^[A-Za-z0-9_-]+$/),
|
|
154
|
+
retries: z.number().int().nonnegative().optional(),
|
|
155
|
+
status: z.enum(["healthy", "suspended", "unknown", "unhealthy"]).optional(),
|
|
156
|
+
suspended: z.boolean().optional(),
|
|
157
|
+
tcpConfig: CLOUDFLARE_TCP_HEALTH_CHECK_SCHEMA.nullable().optional(),
|
|
158
|
+
timeout: z.number().int().nonnegative().optional(),
|
|
159
|
+
type: z.enum(["HTTP", "HTTPS", "TCP"]).optional(),
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
export const CLOUDFLARE_ALERT_TYPE_SCHEMA = z.enum([
|
|
163
|
+
"abuse_report_alert",
|
|
164
|
+
"access_custom_certificate_expiration_type",
|
|
165
|
+
"advanced_ddos_attack_l4_alert",
|
|
166
|
+
"advanced_ddos_attack_l7_alert",
|
|
167
|
+
"advanced_http_alert_error",
|
|
168
|
+
"bgp_hijack_notification",
|
|
169
|
+
"billing_usage_alert",
|
|
170
|
+
"block_notification_block_removed",
|
|
171
|
+
"block_notification_new_block",
|
|
172
|
+
"block_notification_review_rejected",
|
|
173
|
+
"bot_traffic_basic_alert",
|
|
174
|
+
"brand_protection_alert",
|
|
175
|
+
"brand_protection_digest",
|
|
176
|
+
"clickhouse_alert_fw_anomaly",
|
|
177
|
+
"clickhouse_alert_fw_ent_anomaly",
|
|
178
|
+
"cloudforce_one_request_notification",
|
|
179
|
+
"cni_maintenance_notification",
|
|
180
|
+
"custom_analytics",
|
|
181
|
+
"custom_bot_detection_alert",
|
|
182
|
+
"custom_ssl_certificate_event_type",
|
|
183
|
+
"dedicated_ssl_certificate_event_type",
|
|
184
|
+
"device_connectivity_anomaly_alert",
|
|
185
|
+
"dos_attack_l4",
|
|
186
|
+
"dos_attack_l7",
|
|
187
|
+
"expiring_service_token_alert",
|
|
188
|
+
"failing_logpush_job_disabled_alert",
|
|
189
|
+
"fbm_auto_advertisement",
|
|
190
|
+
"fbm_dosd_attack",
|
|
191
|
+
"fbm_volumetric_attack",
|
|
192
|
+
"health_check_status_notification",
|
|
193
|
+
"hostname_aop_custom_certificate_expiration_type",
|
|
194
|
+
"http_alert_edge_error",
|
|
195
|
+
"http_alert_origin_error",
|
|
196
|
+
"image_notification",
|
|
197
|
+
"image_resizing_notification",
|
|
198
|
+
"incident_alert",
|
|
199
|
+
"load_balancing_health_alert",
|
|
200
|
+
"load_balancing_pool_enablement_alert",
|
|
201
|
+
"logo_match_alert",
|
|
202
|
+
"magic_tunnel_health_check_event",
|
|
203
|
+
"magic_wan_tunnel_health",
|
|
204
|
+
"maintenance_event_notification",
|
|
205
|
+
"mtls_certificate_store_certificate_expiration_type",
|
|
206
|
+
"pages_event_alert",
|
|
207
|
+
"radar_notification",
|
|
208
|
+
"real_origin_monitoring",
|
|
209
|
+
"scriptmonitor_alert_new_code_change_detections",
|
|
210
|
+
"scriptmonitor_alert_new_hosts",
|
|
211
|
+
"scriptmonitor_alert_new_malicious_hosts",
|
|
212
|
+
"scriptmonitor_alert_new_malicious_scripts",
|
|
213
|
+
"scriptmonitor_alert_new_malicious_url",
|
|
214
|
+
"scriptmonitor_alert_new_max_length_resource_url",
|
|
215
|
+
"scriptmonitor_alert_new_resources",
|
|
216
|
+
"secondary_dns_all_primaries_failing",
|
|
217
|
+
"secondary_dns_primaries_failing",
|
|
218
|
+
"secondary_dns_warning",
|
|
219
|
+
"secondary_dns_zone_successfully_updated",
|
|
220
|
+
"secondary_dns_zone_validation_warning",
|
|
221
|
+
"security_insights_alert",
|
|
222
|
+
"sentinel_alert",
|
|
223
|
+
"stream_live_notifications",
|
|
224
|
+
"synthetic_test_latency_alert",
|
|
225
|
+
"synthetic_test_low_availability_alert",
|
|
226
|
+
"traffic_anomalies_alert",
|
|
227
|
+
"tunnel_health_event",
|
|
228
|
+
"tunnel_update_event",
|
|
229
|
+
"universal_ssl_event_type",
|
|
230
|
+
"web_analytics_metrics_update",
|
|
231
|
+
"zone_aop_custom_certificate_expiration_type",
|
|
232
|
+
])
|
|
233
|
+
|
|
234
|
+
const STRING_FILTER_SCHEMA = z.string().min(1).array().min(1)
|
|
235
|
+
export const CLOUDFLARE_NOTIFICATION_FILTERS_SCHEMA = z.object({
|
|
236
|
+
actions: STRING_FILTER_SCHEMA.optional(),
|
|
237
|
+
affectedAsns: STRING_FILTER_SCHEMA.optional(),
|
|
238
|
+
affectedComponents: STRING_FILTER_SCHEMA.optional(),
|
|
239
|
+
affectedLocations: STRING_FILTER_SCHEMA.optional(),
|
|
240
|
+
airportCode: STRING_FILTER_SCHEMA.optional(),
|
|
241
|
+
alertTriggerPreferences: STRING_FILTER_SCHEMA.optional(),
|
|
242
|
+
alertTriggerPreferencesValue: STRING_FILTER_SCHEMA.optional(),
|
|
243
|
+
enabled: STRING_FILTER_SCHEMA.optional(),
|
|
244
|
+
environment: STRING_FILTER_SCHEMA.optional(),
|
|
245
|
+
event: STRING_FILTER_SCHEMA.optional(),
|
|
246
|
+
eventSource: STRING_FILTER_SCHEMA.optional(),
|
|
247
|
+
eventType: STRING_FILTER_SCHEMA.optional(),
|
|
248
|
+
groupBy: STRING_FILTER_SCHEMA.optional(),
|
|
249
|
+
healthCheckId: STRING_FILTER_SCHEMA.optional(),
|
|
250
|
+
incidentImpact: z
|
|
251
|
+
.enum([
|
|
252
|
+
"INCIDENT_IMPACT_CRITICAL",
|
|
253
|
+
"INCIDENT_IMPACT_MAJOR",
|
|
254
|
+
"INCIDENT_IMPACT_MINOR",
|
|
255
|
+
"INCIDENT_IMPACT_NONE",
|
|
256
|
+
])
|
|
257
|
+
.array()
|
|
258
|
+
.min(1)
|
|
259
|
+
.optional(),
|
|
260
|
+
inputId: STRING_FILTER_SCHEMA.optional(),
|
|
261
|
+
insightClass: STRING_FILTER_SCHEMA.optional(),
|
|
262
|
+
limit: STRING_FILTER_SCHEMA.optional(),
|
|
263
|
+
logoTag: STRING_FILTER_SCHEMA.optional(),
|
|
264
|
+
megabitsPerSecond: STRING_FILTER_SCHEMA.optional(),
|
|
265
|
+
newHealth: STRING_FILTER_SCHEMA.optional(),
|
|
266
|
+
newStatus: STRING_FILTER_SCHEMA.optional(),
|
|
267
|
+
packetsPerSecond: STRING_FILTER_SCHEMA.optional(),
|
|
268
|
+
poolId: STRING_FILTER_SCHEMA.optional(),
|
|
269
|
+
popNames: STRING_FILTER_SCHEMA.optional(),
|
|
270
|
+
product: STRING_FILTER_SCHEMA.optional(),
|
|
271
|
+
projectId: STRING_FILTER_SCHEMA.optional(),
|
|
272
|
+
protocol: STRING_FILTER_SCHEMA.optional(),
|
|
273
|
+
queryTag: STRING_FILTER_SCHEMA.optional(),
|
|
274
|
+
requestsPerSecond: STRING_FILTER_SCHEMA.optional(),
|
|
275
|
+
selectors: STRING_FILTER_SCHEMA.optional(),
|
|
276
|
+
services: STRING_FILTER_SCHEMA.optional(),
|
|
277
|
+
slo: STRING_FILTER_SCHEMA.optional(),
|
|
278
|
+
status: STRING_FILTER_SCHEMA.optional(),
|
|
279
|
+
targetHostname: STRING_FILTER_SCHEMA.optional(),
|
|
280
|
+
targetIp: STRING_FILTER_SCHEMA.optional(),
|
|
281
|
+
targetZoneName: STRING_FILTER_SCHEMA.optional(),
|
|
282
|
+
trafficExclusions: z.literal("security_events").array().max(1).optional(),
|
|
283
|
+
tunnelId: STRING_FILTER_SCHEMA.optional(),
|
|
284
|
+
tunnelName: STRING_FILTER_SCHEMA.optional(),
|
|
285
|
+
type: STRING_FILTER_SCHEMA.optional(),
|
|
286
|
+
where: STRING_FILTER_SCHEMA.optional(),
|
|
287
|
+
zones: STRING_FILTER_SCHEMA.optional(),
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
export const CLOUDFLARE_NOTIFICATION_MECHANISMS_SCHEMA = z.object({
|
|
291
|
+
email: z.object({ id: z.email() }).array().optional(),
|
|
292
|
+
pagerduty: z
|
|
293
|
+
.object({ id: z.string().min(1) })
|
|
294
|
+
.array()
|
|
295
|
+
.optional(),
|
|
296
|
+
webhooks: z
|
|
297
|
+
.object({ id: z.string().min(1) })
|
|
298
|
+
.array()
|
|
299
|
+
.optional(),
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
export const CLOUDFLARE_NOTIFICATION_POLICY_SCHEMA = z.object({
|
|
303
|
+
alertInterval: z.string().optional(),
|
|
304
|
+
alertType: CLOUDFLARE_ALERT_TYPE_SCHEMA,
|
|
305
|
+
created: z.string().optional(),
|
|
306
|
+
description: z.string().optional(),
|
|
307
|
+
enabled: z.boolean(),
|
|
308
|
+
filters: CLOUDFLARE_NOTIFICATION_FILTERS_SCHEMA.optional(),
|
|
309
|
+
id: z.string().min(1).optional(),
|
|
310
|
+
mechanisms: CLOUDFLARE_NOTIFICATION_MECHANISMS_SCHEMA,
|
|
311
|
+
modified: z.string().optional(),
|
|
312
|
+
name: z.string().min(1),
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
export const CLOUDFLARE_AVAILABLE_ALERT_SCHEMA = z.object({
|
|
316
|
+
description: z.string().optional(),
|
|
317
|
+
displayName: z.string().optional(),
|
|
318
|
+
filterOptions: encodableSchema.optional(),
|
|
319
|
+
type: CLOUDFLARE_ALERT_TYPE_SCHEMA,
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
export const CLOUDFLARE_NOTIFICATION_HISTORY_SCHEMA = z.object({
|
|
323
|
+
alertBody: z.string().optional(),
|
|
324
|
+
alertType: z.string().optional(),
|
|
325
|
+
description: z.string().optional(),
|
|
326
|
+
id: z.string().optional(),
|
|
327
|
+
mechanism: z.string().optional(),
|
|
328
|
+
mechanismType: z.enum(["email", "pagerduty", "webhook"]).optional(),
|
|
329
|
+
name: z.string().optional(),
|
|
330
|
+
policyId: z.string().optional(),
|
|
331
|
+
sent: z.string().optional(),
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
export const CLOUDFLARE_DELETE_RESULT_SCHEMA = z.object({
|
|
335
|
+
id: z.string().min(1),
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
export const CLOUDFLARE_NOTIFICATION_WEBHOOK_SCHEMA = z.object({
|
|
339
|
+
createdAt: z.string().optional(),
|
|
340
|
+
id: z.string().min(1),
|
|
341
|
+
lastFailure: z.string().optional(),
|
|
342
|
+
lastSuccess: z.string().optional(),
|
|
343
|
+
name: z.string().optional(),
|
|
344
|
+
type: z
|
|
345
|
+
.enum([
|
|
346
|
+
"datadog",
|
|
347
|
+
"discord",
|
|
348
|
+
"feishu",
|
|
349
|
+
"gchat",
|
|
350
|
+
"generic",
|
|
351
|
+
"opsgenie",
|
|
352
|
+
"slack",
|
|
353
|
+
"splunk",
|
|
354
|
+
])
|
|
355
|
+
.optional(),
|
|
356
|
+
url: z.string().optional(),
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
export const CLOUDFLARE_API_RESPONSE_INFO_SCHEMA = RESPONSE_INFO_SCHEMA
|
package/src/linear/api.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { JsonObject } from "type-fest"
|
|
|
2
2
|
import * as z from "zod"
|
|
3
3
|
|
|
4
4
|
const LINEAR_GRAPHQL_URL = "https://api.linear.app/graphql"
|
|
5
|
-
const LINEAR_SECRET_SCHEMA = z.
|
|
6
|
-
accessToken: z.string().min(1),
|
|
7
|
-
})
|
|
5
|
+
const LINEAR_SECRET_SCHEMA = z.union([
|
|
6
|
+
z.object({ accessToken: z.string().min(1) }),
|
|
7
|
+
z.object({ apiKey: z.string().min(1) }),
|
|
8
|
+
])
|
|
8
9
|
const LINEAR_ERROR_SCHEMA = z.looseObject({
|
|
9
10
|
extensions: z.record(z.string(), z.json()).optional(),
|
|
10
11
|
message: z.string(),
|
|
@@ -94,10 +95,10 @@ export class LinearApiError extends Error {
|
|
|
94
95
|
* action. OAuth access tokens are resolved by the platform and never exposed to
|
|
95
96
|
* automation code.
|
|
96
97
|
*
|
|
97
|
-
* @param secret - Resolved Linear OAuth
|
|
98
|
+
* @param secret - Resolved Linear OAuth or personal API-key secret.
|
|
98
99
|
*/
|
|
99
100
|
export function getLinearApi(secret: Record<string, unknown>): LinearApi {
|
|
100
|
-
const
|
|
101
|
+
const credential = LINEAR_SECRET_SCHEMA.parse(secret)
|
|
101
102
|
|
|
102
103
|
return {
|
|
103
104
|
graphql: async (document, options) => {
|
|
@@ -108,7 +109,10 @@ export function getLinearApi(secret: Record<string, unknown>): LinearApi {
|
|
|
108
109
|
}),
|
|
109
110
|
headers: {
|
|
110
111
|
Accept: "application/json",
|
|
111
|
-
Authorization:
|
|
112
|
+
Authorization:
|
|
113
|
+
"accessToken" in credential
|
|
114
|
+
? `Bearer ${credential.accessToken}`
|
|
115
|
+
: credential.apiKey,
|
|
112
116
|
"Content-Type": "application/json",
|
|
113
117
|
},
|
|
114
118
|
method: "POST",
|