@automate.ax/integration-contracts 0.126.0 → 0.127.1

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,614 @@
1
+ import { encodableSchema } from "@automate.ax/codec"
2
+ import * as z from "zod"
3
+
4
+ export const AXIOM_ID_SCHEMA = z.string().trim().min(1)
5
+ export const AXIOM_DEFAULT_EDGE_ORIGIN = "https://us-east-1.aws.edge.axiom.co"
6
+ export const AXIOM_EDGE_URL_SCHEMA = z
7
+ .url()
8
+ .refine((value) => {
9
+ const url = new URL(value)
10
+ return (
11
+ url.protocol === "https:" &&
12
+ url.port === "" &&
13
+ url.hostname.endsWith(".edge.axiom.co") &&
14
+ !url.username &&
15
+ !url.password &&
16
+ url.pathname === "/" &&
17
+ !url.search &&
18
+ !url.hash
19
+ )
20
+ }, "Use the HTTPS base origin of an Axiom edge deployment.")
21
+ .prefault(AXIOM_DEFAULT_EDGE_ORIGIN)
22
+ export const AXIOM_TIME_SCHEMA = z.string().trim().min(1)
23
+ export const AXIOM_DATASET_KIND_SCHEMA = z.enum([
24
+ "axiom:events:v1",
25
+ "otel:logs:v1",
26
+ "otel:metrics:v1",
27
+ "otel:traces:v1",
28
+ ])
29
+ export const AXIOM_DATASET_FIELD_SCHEMA = z.object({
30
+ description: z.string().optional(),
31
+ hidden: z.boolean().optional(),
32
+ name: AXIOM_ID_SCHEMA,
33
+ type: z.string().min(1),
34
+ unit: z.string().optional(),
35
+ })
36
+
37
+ export const AXIOM_INGEST_STATUS_SCHEMA = z
38
+ .object({
39
+ blocksCreated: z.number().int().nonnegative(),
40
+ failed: z.number().int().nonnegative(),
41
+ failures: z
42
+ .object({
43
+ error: z.string(),
44
+ timestamp: z.string(),
45
+ })
46
+ .catchall(encodableSchema)
47
+ .array()
48
+ .optional(),
49
+ ingested: z.number().int().nonnegative(),
50
+ processedBytes: z.number().int().nonnegative(),
51
+ walLength: z.number().int().nonnegative(),
52
+ })
53
+ .catchall(encodableSchema)
54
+
55
+ export const AXIOM_QUERY_OPTIONS_SCHEMA = z.object({
56
+ disableCache: z.boolean().optional(),
57
+ disableStats: z.boolean().optional(),
58
+ disableTrace: z.boolean().optional(),
59
+ displayNull: z.enum(["", "auto", "null", "span", "zero"]).optional(),
60
+ maxDataPoints: z.number().int().positive().optional(),
61
+ maxSeries: z.number().int().positive().optional(),
62
+ noAggregation: z.boolean().optional(),
63
+ noFill: z.boolean().optional(),
64
+ noInterpolation: z.boolean().optional(),
65
+ priority: z.enum(["high", "low", "medium"]).optional(),
66
+ resolution: z.string().optional(),
67
+ shownColumns: z.string().max(10_000).optional(),
68
+ timeSeriesVariant: z.enum(["", "area", "bars", "line", "lines"]).optional(),
69
+ timeSeriesView: z
70
+ .enum(["", "charts", "charts|resultsTable", "resultsTable"])
71
+ .optional(),
72
+ })
73
+
74
+ export const AXIOM_APL_REQUEST_SCHEMA = z.object({
75
+ apl: z.string().trim().min(1),
76
+ cursor: z.string().optional(),
77
+ defaultLimit: z.number().int().positive().optional(),
78
+ defaultOrder: z
79
+ .object({ desc: z.boolean().optional(), field: z.string().min(1) })
80
+ .array()
81
+ .optional(),
82
+ endTime: AXIOM_TIME_SCHEMA.prefault("now"),
83
+ includeCursor: z.boolean().optional(),
84
+ includeCursorField: z.boolean().optional(),
85
+ libraries: AXIOM_ID_SCHEMA.array().optional(),
86
+ queryOptions: AXIOM_QUERY_OPTIONS_SCHEMA.optional(),
87
+ startTime: AXIOM_TIME_SCHEMA.prefault("now-30m"),
88
+ variables: z.record(z.string(), z.record(z.string(), z.json())).optional(),
89
+ })
90
+
91
+ const AXIOM_QUERY_MESSAGE_SCHEMA = z.object({
92
+ code: z.string().optional(),
93
+ count: z.number().int(),
94
+ msg: z.string(),
95
+ priority: z.string(),
96
+ })
97
+
98
+ export const AXIOM_QUERY_RESULT_SCHEMA = z
99
+ .object({
100
+ datasetNames: z.string().array(),
101
+ fieldsMetaMap: z
102
+ .record(
103
+ z.string(),
104
+ z
105
+ .object({
106
+ description: z.string().optional(),
107
+ hidden: z.boolean().optional(),
108
+ name: z.string(),
109
+ type: z.string(),
110
+ unit: z.string().optional(),
111
+ })
112
+ .catchall(encodableSchema)
113
+ .array(),
114
+ )
115
+ .optional(),
116
+ format: z.literal("tabular"),
117
+ status: z
118
+ .object({
119
+ blocksExamined: z.number().int().nonnegative(),
120
+ cacheStatus: z.number().int().nonnegative(),
121
+ continuationToken: z.string().optional(),
122
+ elapsedTime: z.number().int().nonnegative(),
123
+ isEstimate: z.boolean().optional(),
124
+ isPartial: z.boolean(),
125
+ maxBlockTime: z.string(),
126
+ maxCursor: z.string().optional(),
127
+ messages: AXIOM_QUERY_MESSAGE_SCHEMA.array().optional(),
128
+ minBlockTime: z.string(),
129
+ minCursor: z.string().optional(),
130
+ numGroups: z.number().int().nonnegative(),
131
+ rowsExamined: z.number().int().nonnegative(),
132
+ rowsMatched: z.number().int().nonnegative(),
133
+ })
134
+ .catchall(encodableSchema),
135
+ tables: z
136
+ .object({
137
+ buckets: z
138
+ .object({
139
+ field: z.string(),
140
+ size: z.number(),
141
+ })
142
+ .optional(),
143
+ columns: z.json().array().array().optional(),
144
+ fields: z
145
+ .object({
146
+ agg: z.record(z.string(), encodableSchema).optional(),
147
+ name: z.string(),
148
+ type: z.string(),
149
+ })
150
+ .array(),
151
+ groups: z.object({ name: z.string().optional() }).array(),
152
+ name: z.string(),
153
+ order: z.object({ desc: z.boolean(), field: z.string() }).array(),
154
+ range: z
155
+ .object({
156
+ end: z.string(),
157
+ field: z.string(),
158
+ start: z.string(),
159
+ })
160
+ .optional(),
161
+ sources: z.object({ name: z.string() }).array(),
162
+ })
163
+ .catchall(encodableSchema)
164
+ .array(),
165
+ })
166
+ .catchall(encodableSchema)
167
+
168
+ export const AXIOM_METRICS_RESULT_SCHEMA = z.record(z.string(), z.json())
169
+ export const AXIOM_METRIC_INFO_SCHEMA = z.object({
170
+ temporality: z.string(),
171
+ type: z.string(),
172
+ unit: z.string().nullable(),
173
+ })
174
+ export const AXIOM_METRICS_INFO_SCHEMA = z.record(
175
+ z.string(),
176
+ AXIOM_METRIC_INFO_SCHEMA,
177
+ )
178
+ export const AXIOM_METRIC_DISCOVERY_SCHEMA = z.object({
179
+ datasetName: AXIOM_ID_SCHEMA,
180
+ edgeUrl: AXIOM_EDGE_URL_SCHEMA,
181
+ endTime: AXIOM_TIME_SCHEMA.prefault("now"),
182
+ startTime: AXIOM_TIME_SCHEMA.prefault("now-30m"),
183
+ })
184
+ export const AXIOM_METRIC_TAG_DISCOVERY_SCHEMA =
185
+ AXIOM_METRIC_DISCOVERY_SCHEMA.extend({
186
+ metric: AXIOM_ID_SCHEMA,
187
+ })
188
+ export const AXIOM_DATASET_TAG_VALUE_DISCOVERY_SCHEMA =
189
+ AXIOM_METRIC_DISCOVERY_SCHEMA.extend({
190
+ tag: AXIOM_ID_SCHEMA,
191
+ })
192
+ export const AXIOM_METRIC_TAG_VALUE_DISCOVERY_SCHEMA =
193
+ AXIOM_METRIC_TAG_DISCOVERY_SCHEMA.extend({
194
+ tag: AXIOM_ID_SCHEMA,
195
+ })
196
+
197
+ export const AXIOM_DATASET_SCHEMA = z
198
+ .object({
199
+ canWrite: z.boolean().optional(),
200
+ created: z.string(),
201
+ description: z.string(),
202
+ edgeDeployment: z.string().optional(),
203
+ edgeDeploymentUrl: z.string().optional(),
204
+ id: AXIOM_ID_SCHEMA,
205
+ kind: AXIOM_DATASET_KIND_SCHEMA,
206
+ mapFields: z.string().array().optional(),
207
+ name: AXIOM_ID_SCHEMA,
208
+ retentionDays: z.number().int().nonnegative().optional(),
209
+ sharedByOrg: z.string().optional(),
210
+ updatedAt: z.string(),
211
+ useRetentionPeriod: z.boolean().optional(),
212
+ who: z.string(),
213
+ })
214
+ .catchall(encodableSchema)
215
+
216
+ export const AXIOM_ANNOTATION_SCHEMA = z.object({
217
+ datasets: AXIOM_ID_SCHEMA.array().min(1),
218
+ description: z.string().max(512).optional(),
219
+ endTime: z.string().nullable().optional(),
220
+ id: AXIOM_ID_SCHEMA,
221
+ time: z.string(),
222
+ title: z.string().max(256).optional(),
223
+ type: z
224
+ .string()
225
+ .regex(/^[a-z0-9-]+$/)
226
+ .max(256),
227
+ url: z.string().max(512).optional(),
228
+ })
229
+
230
+ export const AXIOM_MONITOR_TYPE_SCHEMA = z.enum([
231
+ "AnomalyDetection",
232
+ "MatchEvent",
233
+ "Threshold",
234
+ ])
235
+ export const AXIOM_MONITOR_SCHEMA = z
236
+ .object({
237
+ alertOnNoData: z.boolean().optional(),
238
+ aplQuery: z.string().trim().min(1).optional(),
239
+ columnName: z.string().optional(),
240
+ compareDays: z.number().int().min(1).max(7).optional(),
241
+ description: z.string().optional(),
242
+ disabled: z.boolean().optional(),
243
+ disabledUntil: z.string().nullable().optional(),
244
+ intervalMinutes: z.number().int().positive(),
245
+ mplQuery: z.string().trim().min(1).optional(),
246
+ name: z.string().trim().min(1),
247
+ notifierIds: AXIOM_ID_SCHEMA.array().optional(),
248
+ notifyByGroup: z.boolean().optional(),
249
+ notifyEveryRun: z.boolean().optional(),
250
+ operator: z
251
+ .enum(["Above", "AboveOrBelow", "AboveOrEqual", "Below", "BelowOrEqual"])
252
+ .optional(),
253
+ rangeMinutes: z.number().int().positive(),
254
+ resolvable: z.boolean().optional(),
255
+ secondDelay: z.number().int().min(0).max(86_400).optional(),
256
+ skipResolved: z.boolean().optional(),
257
+ threshold: z.number().optional(),
258
+ tolerance: z.number().min(0).max(100).optional(),
259
+ triggerAfterNPositiveResults: z.number().int().positive().optional(),
260
+ triggerFromNRuns: z.number().int().positive().optional(),
261
+ type: AXIOM_MONITOR_TYPE_SCHEMA,
262
+ })
263
+ .refine(({ aplQuery, mplQuery }) => Boolean(aplQuery) !== Boolean(mplQuery), {
264
+ message: "Provide exactly one of aplQuery or mplQuery.",
265
+ })
266
+ export const AXIOM_MONITOR_WITH_ID_SCHEMA = AXIOM_MONITOR_SCHEMA.and(
267
+ z
268
+ .object({
269
+ createdAt: z.string().optional(),
270
+ createdBy: z.string().optional(),
271
+ id: AXIOM_ID_SCHEMA,
272
+ updatedAt: z.string().optional(),
273
+ })
274
+ .catchall(encodableSchema),
275
+ )
276
+
277
+ export const AXIOM_ALERT_HISTORY_SCHEMA = z.object({
278
+ checkId: AXIOM_ID_SCHEMA,
279
+ name: z.string(),
280
+ state: z.enum(["closed", "open"]),
281
+ timestamp: z.string(),
282
+ })
283
+
284
+ const HEADER_MAP_SCHEMA = z.record(z.string().min(1), z.string())
285
+ export const AXIOM_NOTIFIER_PROPERTIES_SCHEMA = z.union([
286
+ z.object({ email: z.object({ emails: z.email().array().min(1) }) }),
287
+ z.object({ slack: z.object({ slackUrl: z.url() }) }),
288
+ z.object({ webhook: z.object({ url: z.url() }) }),
289
+ z.object({
290
+ customWebhook: z.object({
291
+ body: z.string().min(1),
292
+ headers: HEADER_MAP_SCHEMA.optional(),
293
+ secretHeaders: HEADER_MAP_SCHEMA.optional(),
294
+ url: z.url(),
295
+ }),
296
+ }),
297
+ z.object({
298
+ pagerduty: z.object({
299
+ routingKey: z.string().min(1).optional(),
300
+ token: z.string().min(1).optional(),
301
+ }),
302
+ }),
303
+ z.object({
304
+ opsgenie: z.object({
305
+ apiKey: z.string().min(1),
306
+ isEU: z.boolean().optional(),
307
+ }),
308
+ }),
309
+ z.object({
310
+ discord: z.object({
311
+ discordChannel: z.string().min(1),
312
+ discordToken: z.string().min(1),
313
+ }),
314
+ }),
315
+ z.object({ discordWebhook: z.object({ discordWebhookUrl: z.url() }) }),
316
+ z.object({ microsoftTeams: z.object({ microsoftTeamsUrl: z.url() }) }),
317
+ ])
318
+
319
+ export const AXIOM_NOTIFIER_SCHEMA = z
320
+ .object({
321
+ createdAt: z.string().optional(),
322
+ createdBy: z.string().optional(),
323
+ disabledUntil: z.string().nullable().optional(),
324
+ id: AXIOM_ID_SCHEMA.optional(),
325
+ name: z.string().trim().min(1),
326
+ properties: AXIOM_NOTIFIER_PROPERTIES_SCHEMA,
327
+ updatedAt: z.string().optional(),
328
+ })
329
+ .catchall(encodableSchema)
330
+ export const AXIOM_NOTIFIER_WITH_ID_SCHEMA = AXIOM_NOTIFIER_SCHEMA.extend({
331
+ id: AXIOM_ID_SCHEMA,
332
+ })
333
+
334
+ export const AXIOM_SAVED_QUERY_SCHEMA = z.object({
335
+ dataset: z.string().optional(),
336
+ id: AXIOM_ID_SCHEMA.optional(),
337
+ kind: z.literal("apl"),
338
+ metadata: z.record(z.string(), z.string()),
339
+ name: z.string().trim().min(1),
340
+ query: AXIOM_APL_REQUEST_SCHEMA,
341
+ who: z.string(),
342
+ })
343
+ export const AXIOM_SAVED_QUERY_WITH_ID_SCHEMA = AXIOM_SAVED_QUERY_SCHEMA.extend(
344
+ {
345
+ id: AXIOM_ID_SCHEMA,
346
+ },
347
+ )
348
+
349
+ const AXIOM_CHART_QUERY_SCHEMA = z
350
+ .object({
351
+ apl: z.string().trim().min(1).optional(),
352
+ mpl: z.string().trim().min(1).optional(),
353
+ queryOptions: z.record(z.string(), encodableSchema).optional(),
354
+ })
355
+ .catchall(encodableSchema)
356
+ .refine(({ apl, mpl }) => Boolean(apl) !== Boolean(mpl), {
357
+ message: "Provide exactly one of query.apl or query.mpl.",
358
+ })
359
+ const AXIOM_DASHBOARD_CHART_FIELDS = {
360
+ id: AXIOM_ID_SCHEMA,
361
+ name: z.string().min(1).max(500).optional(),
362
+ sectionId: z.uuid().optional(),
363
+ }
364
+ const AXIOM_DASHBOARD_QUERY_CHART_FIELDS = {
365
+ ...AXIOM_DASHBOARD_CHART_FIELDS,
366
+ query: AXIOM_CHART_QUERY_SCHEMA,
367
+ }
368
+ const AXIOM_STATISTIC_COLOR_SCHEMA = z.string().max(200)
369
+ const AXIOM_STATISTIC_COLOR_PROPS_SCHEMA = z.object({
370
+ background: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
371
+ chartFillColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
372
+ labelColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
373
+ textColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
374
+ })
375
+ const AXIOM_STATISTIC_THRESHOLD_SCHEMA = z.enum([
376
+ "Above",
377
+ "AboveOrEqual",
378
+ "Below",
379
+ "BelowOrEqual",
380
+ "AboveOrBelow",
381
+ ])
382
+ const AXIOM_SMART_FILTER_BASE_FIELDS = {
383
+ active: z.boolean().optional(),
384
+ id: z.string().max(200),
385
+ name: z.string().max(200),
386
+ }
387
+ const AXIOM_SMART_FILTER_SCHEMA = z.discriminatedUnion("type", [
388
+ z.object({
389
+ ...AXIOM_SMART_FILTER_BASE_FIELDS,
390
+ type: z.literal("search"),
391
+ }),
392
+ z
393
+ .object({
394
+ ...AXIOM_SMART_FILTER_BASE_FIELDS,
395
+ options: z.json().optional(),
396
+ query: z.record(z.string(), encodableSchema).optional(),
397
+ selectType: z.enum(["list", "query"]),
398
+ type: z.literal("select"),
399
+ })
400
+ .catchall(encodableSchema),
401
+ ])
402
+
403
+ export const AXIOM_DASHBOARD_CHART_SCHEMA = z.discriminatedUnion("type", [
404
+ z
405
+ .object({
406
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
407
+ type: z.literal("TimeSeries"),
408
+ })
409
+ .catchall(encodableSchema),
410
+ z
411
+ .object({
412
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
413
+ type: z.literal("Heatmap"),
414
+ })
415
+ .catchall(encodableSchema),
416
+ z
417
+ .object({
418
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
419
+ type: z.literal("LogStream"),
420
+ })
421
+ .catchall(encodableSchema),
422
+ z
423
+ .object({
424
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
425
+ type: z.literal("Pie"),
426
+ })
427
+ .catchall(encodableSchema),
428
+ z
429
+ .object({
430
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
431
+ type: z.literal("Scatter"),
432
+ })
433
+ .catchall(encodableSchema),
434
+ z
435
+ .object({
436
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
437
+ type: z.literal("Table"),
438
+ })
439
+ .catchall(encodableSchema),
440
+ z
441
+ .object({
442
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
443
+ type: z.literal("TopK"),
444
+ })
445
+ .catchall(encodableSchema),
446
+ z
447
+ .object({
448
+ ...AXIOM_DASHBOARD_QUERY_CHART_FIELDS,
449
+ background: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
450
+ chartFillColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
451
+ chartHeight: z.union([z.string().max(100), z.number()]).optional(),
452
+ colorScheme: z
453
+ .enum([
454
+ "Blue",
455
+ "Brown",
456
+ "Green",
457
+ "Grey",
458
+ "Orange",
459
+ "Pink",
460
+ "Purple",
461
+ "Red",
462
+ "Teal",
463
+ "Yellow",
464
+ ])
465
+ .optional(),
466
+ customUnits: z.string().max(200).optional(),
467
+ errorColorProps: AXIOM_STATISTIC_COLOR_PROPS_SCHEMA.optional(),
468
+ errorThreshold: AXIOM_STATISTIC_THRESHOLD_SCHEMA.optional(),
469
+ errorThresholdValue: z.string().max(100).optional(),
470
+ hideValue: z.boolean().optional(),
471
+ invertTheme: z.boolean().optional(),
472
+ labelColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
473
+ okColorProps: AXIOM_STATISTIC_COLOR_PROPS_SCHEMA.optional(),
474
+ showChart: z.union([z.boolean(), z.string()]).optional(),
475
+ textColor: AXIOM_STATISTIC_COLOR_SCHEMA.optional(),
476
+ type: z.literal("Statistic"),
477
+ warningColorProps: AXIOM_STATISTIC_COLOR_PROPS_SCHEMA.optional(),
478
+ warningThreshold: AXIOM_STATISTIC_THRESHOLD_SCHEMA.optional(),
479
+ warningThresholdValue: z.string().max(100).optional(),
480
+ })
481
+ .catchall(encodableSchema),
482
+ z
483
+ .object({
484
+ ...AXIOM_DASHBOARD_CHART_FIELDS,
485
+ text: z.string().min(1).max(100_000),
486
+ type: z.literal("Note"),
487
+ variant: z.literal("default").optional(),
488
+ })
489
+ .catchall(encodableSchema),
490
+ z
491
+ .object({
492
+ ...AXIOM_DASHBOARD_CHART_FIELDS,
493
+ columns: z.object({
494
+ dataset: z.boolean(),
495
+ history: z.boolean(),
496
+ notifiers: z.boolean(),
497
+ status: z.boolean(),
498
+ type: z.boolean(),
499
+ }),
500
+ selectedMonitors: z.string().min(1).max(200).array().min(1).max(200),
501
+ type: z.literal("MonitorList"),
502
+ })
503
+ .catchall(encodableSchema),
504
+ z
505
+ .object({
506
+ ...AXIOM_DASHBOARD_CHART_FIELDS,
507
+ filters: AXIOM_SMART_FILTER_SCHEMA.array().min(1).max(50),
508
+ logo: z.string().max(2_000).optional(),
509
+ logoDark: z.string().max(2_000).optional(),
510
+ type: z.literal("SmartFilter"),
511
+ })
512
+ .catchall(encodableSchema),
513
+ z
514
+ .object({
515
+ ...AXIOM_DASHBOARD_CHART_FIELDS,
516
+ type: z.literal("Spacer"),
517
+ })
518
+ .catchall(encodableSchema),
519
+ ])
520
+ export const AXIOM_DASHBOARD_DOCUMENT_SCHEMA = z.object({
521
+ against: z
522
+ .enum([
523
+ "",
524
+ "-12h",
525
+ "-1d",
526
+ "-1h",
527
+ "-1w",
528
+ "-2w",
529
+ "-30d",
530
+ "-3d",
531
+ "-3h",
532
+ "-3w",
533
+ "-60d",
534
+ "-6h",
535
+ "-7d",
536
+ "-90d",
537
+ ])
538
+ .optional(),
539
+ againstTimestamp: z.string().max(100).optional(),
540
+ charts: AXIOM_DASHBOARD_CHART_SCHEMA.array().max(200),
541
+ description: z.string().max(1_000).optional(),
542
+ layout: z
543
+ .object({
544
+ h: z.number().int().min(1).max(100),
545
+ i: AXIOM_ID_SCHEMA,
546
+ maxH: z.number().int().min(1).max(100).optional(),
547
+ maxW: z.number().int().min(1).max(12).optional(),
548
+ minH: z.number().min(0.5).max(100).optional(),
549
+ minW: z.number().int().min(1).max(12).optional(),
550
+ static: z.boolean().optional(),
551
+ w: z.number().int().min(1).max(12),
552
+ x: z.number().int().min(0).max(11),
553
+ y: z.number().int().nonnegative().nullable(),
554
+ })
555
+ .array()
556
+ .max(200),
557
+ name: z.string().min(1).max(100),
558
+ owner: z.string().min(1),
559
+ refreshTime: z.union([z.literal(15), z.literal(60), z.literal(300)]),
560
+ schemaVersion: z.literal(2),
561
+ sections: z
562
+ .object({
563
+ defaultCollapsed: z.boolean().optional(),
564
+ id: z.uuid(),
565
+ title: z.string().min(1),
566
+ })
567
+ .array()
568
+ .optional(),
569
+ timeWindowEnd: z.string().min(1).max(100),
570
+ timeWindowStart: z.string().min(1).max(100),
571
+ uid: AXIOM_ID_SCHEMA.optional(),
572
+ })
573
+
574
+ export const AXIOM_DASHBOARD_RESOURCE_SCHEMA = z
575
+ .object({
576
+ createdAt: z.string(),
577
+ createdBy: z.string(),
578
+ dashboard: AXIOM_DASHBOARD_DOCUMENT_SCHEMA,
579
+ id: AXIOM_ID_SCHEMA,
580
+ uid: AXIOM_ID_SCHEMA,
581
+ updatedAt: z.string(),
582
+ updatedBy: z.string(),
583
+ version: z.number().int().positive(),
584
+ })
585
+ .catchall(encodableSchema)
586
+ export const AXIOM_DASHBOARD_WRITE_SCHEMA = z.object({
587
+ dashboard: AXIOM_DASHBOARD_RESOURCE_SCHEMA,
588
+ overwritten: z.boolean().optional(),
589
+ status: z.enum(["created", "updated"]),
590
+ })
591
+
592
+ export const AXIOM_MONITOR_NOTIFICATION_SCHEMA = z.object({
593
+ action: z.enum(["Closed", "Open"]),
594
+ event: z.object({
595
+ body: z.string(),
596
+ description: z.string(),
597
+ groupKeys: z.string().array().nullable(),
598
+ groupValues: z.json().array().nullable(),
599
+ matchedEvent: z.record(z.string(), z.json()).nullable(),
600
+ monitorId: AXIOM_ID_SCHEMA,
601
+ queryEndTime: z.string(),
602
+ queryStartTime: z.string(),
603
+ timestamp: z.string(),
604
+ title: z.string(),
605
+ value: z.number(),
606
+ }),
607
+ })
608
+
609
+ export const AXIOM_EMPTY_SCHEMA = z.union([
610
+ z.null(),
611
+ z.object({}).transform(() => null),
612
+ z.undefined().transform(() => null),
613
+ ])
614
+ export const AXIOM_JSON_OBJECT_SCHEMA = z.record(z.string(), encodableSchema)
package/src/triggers.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { airtableTriggerContracts } from "./airtable"
2
2
  import type { apifyTriggerContracts } from "./apify"
3
+ import type { axiomTriggerContracts } from "./axiom"
3
4
  import type { automateTriggerContracts } from "./automate"
4
5
  import type { asanaTriggerContracts } from "./asana"
5
6
  import type { brevoTriggerContracts } from "./brevo"
@@ -31,6 +32,7 @@ import type { z } from "zod"
31
32
 
32
33
  export type TriggerContractMap = typeof airtableTriggerContracts &
33
34
  typeof apifyTriggerContracts &
35
+ typeof axiomTriggerContracts &
34
36
  typeof automateTriggerContracts &
35
37
  typeof asanaTriggerContracts &
36
38
  typeof brevoTriggerContracts &