UNPKG

@shopify/cli-kit

Version:

A set of utilities, interfaces, and models that are common across all the platform features

207 lines (206 loc) • 7.54 kB
import { zod } from './schema.js'; declare const NotificationSchema: zod.ZodObject<{ id: zod.ZodString; message: zod.ZodString; type: zod.ZodEnum<["info", "warning", "error"]>; frequency: zod.ZodEnum<["always", "once", "once_a_day", "once_a_week"]>; ownerChannel: zod.ZodString; cta: zod.ZodOptional<zod.ZodObject<{ label: zod.ZodString; url: zod.ZodString; }, "strip", zod.ZodTypeAny, { url: string; label: string; }, { url: string; label: string; }>>; title: zod.ZodOptional<zod.ZodString>; minVersion: zod.ZodOptional<zod.ZodString>; maxVersion: zod.ZodOptional<zod.ZodString>; minDate: zod.ZodOptional<zod.ZodString>; maxDate: zod.ZodOptional<zod.ZodString>; commands: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>; surface: zod.ZodOptional<zod.ZodString>; }, "strip", zod.ZodTypeAny, { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }, { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }>; export type Notification = zod.infer<typeof NotificationSchema>; declare const NotificationsSchema: zod.ZodObject<{ notifications: zod.ZodArray<zod.ZodObject<{ id: zod.ZodString; message: zod.ZodString; type: zod.ZodEnum<["info", "warning", "error"]>; frequency: zod.ZodEnum<["always", "once", "once_a_day", "once_a_week"]>; ownerChannel: zod.ZodString; cta: zod.ZodOptional<zod.ZodObject<{ label: zod.ZodString; url: zod.ZodString; }, "strip", zod.ZodTypeAny, { url: string; label: string; }, { url: string; label: string; }>>; title: zod.ZodOptional<zod.ZodString>; minVersion: zod.ZodOptional<zod.ZodString>; maxVersion: zod.ZodOptional<zod.ZodString>; minDate: zod.ZodOptional<zod.ZodString>; maxDate: zod.ZodOptional<zod.ZodString>; commands: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>; surface: zod.ZodOptional<zod.ZodString>; }, "strip", zod.ZodTypeAny, { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }, { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }>, "many">; }, "strip", zod.ZodTypeAny, { notifications: { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }[]; }, { notifications: { id: string; type: "error" | "info" | "warning"; message: string; frequency: "always" | "once" | "once_a_day" | "once_a_week"; ownerChannel: string; title?: string | undefined; cta?: { url: string; label: string; } | undefined; minVersion?: string | undefined; maxVersion?: string | undefined; minDate?: string | undefined; maxDate?: string | undefined; commands?: string[] | undefined; surface?: string | undefined; }[]; }>; export type Notifications = zod.infer<typeof NotificationsSchema>; /** * Shows notifications to the user if they meet the criteria specified in the notifications.json file. * * @param currentSurfaces - The surfaces present in the current project (usually for app extensions). * @param environment - Process environment variables. * @returns - A promise that resolves when the notifications have been shown. */ export declare function showNotificationsIfNeeded(currentSurfaces?: string[], environment?: NodeJS.ProcessEnv): Promise<void>; /** * Get notifications list from cache, that is updated in the background from bin/fetch-notifications.json. * * @returns A Notifications object. */ export declare function getNotifications(): Promise<Notifications>; /** * Fetch notifications from the CDN and chache them. * * @returns A string with the notifications. */ export declare function fetchNotifications(): Promise<Notifications>; /** * Fetch notifications in background as a detached process. * * @param currentCommand - The current Shopify command being run. * @param argv - The arguments passed to the current process. * @param environment - Process environment variables. */ export declare function fetchNotificationsInBackground(currentCommand: string, argv?: string[], environment?: NodeJS.ProcessEnv): void; /** * Filters notifications based on the version of the CLI. * * @param notifications - The notifications to filter. * @param commandId - The command ID to filter by. * @param currentSurfaces - The surfaces present in the current project (usually for app extensions). * @param today - The current date. * @param currentVersion - The current version of the CLI. * @returns - The filtered notifications. */ export declare function filterNotifications(notifications: Notification[], commandId: string, currentSurfaces?: string[], today?: Date, currentVersion?: string): Notification[]; /** * Returns a string with the filters from a notification, one by line. * * @param notification - The notification to get the filters from. * @returns A string with human-readable filters from the notification. */ export declare function stringifyFilters(notification: Notification): string; export {};