types.ts
 1  import { z } from 'zod/v4'
 2  import { lazySchema } from '../../utils/lazySchema.js'
 3  import type { SettingsJson } from '../../utils/settings/types.js'
 4  
 5  /**
 6   * Schema for the remotely managed settings response.
 7   * Note: Uses permissive z.record() instead of SettingsSchema to avoid circular dependency.
 8   * Full validation is performed in index.ts after parsing using SettingsSchema.safeParse().
 9   */
10  export const RemoteManagedSettingsResponseSchema = lazySchema(() =>
11    z.object({
12      uuid: z.string(), // Settings UUID
13      checksum: z.string(),
14      settings: z.record(z.string(), z.unknown()) as z.ZodType<SettingsJson>,
15    }),
16  )
17  
18  export type RemoteManagedSettingsResponse = z.infer<
19    ReturnType<typeof RemoteManagedSettingsResponseSchema>
20  >
21  
22  /**
23   * Result of fetching remotely managed settings
24   */
25  export type RemoteManagedSettingsFetchResult = {
26    success: boolean
27    settings?: SettingsJson | null // null means 304 Not Modified (cache is valid)
28    checksum?: string
29    error?: string
30    skipRetry?: boolean // If true, don't retry on failure (e.g., auth errors)
31  }