perf: lazy-load js-yaml (~107KB) as needed (#2551)

- Closes: #2532
This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent 3fe5e4004a
commit d833edb65b
18 changed files with 413 additions and 134 deletions
+6 -1
View File
@@ -1,5 +1,6 @@
import { z } from 'zod';
import { isRecord } from '../../../utils/basic';
import { linkSchema } from '../common/link';
import { preprocessToArray } from '../common/preprocess-to-array';
import { severitySchema } from '../common/severity';
@@ -187,11 +188,15 @@ const notificationControlSchema = notificationBaseSchema.extend({
});
export type NotificationControl = z.infer<typeof notificationControlSchema>;
// A context item is a preformatted string or a structured object that is
// YAML-dumped at render time (see NotificationContextController).
const notificationContextItemSchema = z.union([z.string(), z.custom<object>(isRecord)]);
const notificationSchema = z.object({
heading: notificationDetailSchema.optional(),
body: notificationDetailSchema.optional(),
metadata: notificationDetailSchema.array().optional(),
context: z.string().array().optional(),
context: notificationContextItemSchema.array().optional(),
link: linkSchema.optional(),
in_progress: z.boolean().optional(),
controls: notificationControlSchema.array().optional(),