π File detail
services/settingsSync/types.ts
π― Use case
This file lives under βservices/β, which covers long-lived services (LSP, MCP, OAuth, tool execution, memory, compaction, voice, settings sync, β¦). On the API surface it exposes UserSyncContentSchema, UserSyncDataSchema, UserSyncData, SettingsSyncFetchResult, and SettingsSyncUploadResult (and more) β mainly types, interfaces, or factory objects. Dependencies touch schema validation. It composes internal code from utils (relative imports). What the file header says: Settings Sync Types Zod schemas and types for the user settings sync API. Based on the backend API contract from anthropic/anthropic#218817.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
Settings Sync Types Zod schemas and types for the user settings sync API. Based on the backend API contract from anthropic/anthropic#218817.
π€ Exports (heuristic)
UserSyncContentSchemaUserSyncDataSchemaUserSyncDataSettingsSyncFetchResultSettingsSyncUploadResultSYNC_KEYS
π External import roots
Package roots from from "β¦" (relative paths omitted).
zod
π₯οΈ Source preview
/**
* Settings Sync Types
*
* Zod schemas and types for the user settings sync API.
* Based on the backend API contract from anthropic/anthropic#218817.
*/
import { z } from 'zod/v4'
import { lazySchema } from '../../utils/lazySchema.js'
/**
* Content portion of user sync data - flat key-value storage.
* Keys are opaque strings (typically file paths).
* Values are UTF-8 string content (JSON, Markdown, etc).
*/
export const UserSyncContentSchema = lazySchema(() =>
z.object({
entries: z.record(z.string(), z.string()),
}),
)
/**
* Full response from GET /api/claude_code/user_settings
*/
export const UserSyncDataSchema = lazySchema(() =>
z.object({
userId: z.string(),
version: z.number(),
lastModified: z.string(), // ISO 8601 timestamp
checksum: z.string(), // MD5 hash
content: UserSyncContentSchema(),
}),
)
export type UserSyncData = z.infer<ReturnType<typeof UserSyncDataSchema>>
/**
* Result from fetching user settings
*/
export type SettingsSyncFetchResult = {
success: boolean
data?: UserSyncData
isEmpty?: boolean // true if 404 (no data exists)
error?: string
skipRetry?: boolean
}
/**
* Result from uploading user settings
*/
export type SettingsSyncUploadResult = {
success: boolean
checksum?: string
lastModified?: string
error?: string
}
/**
* Keys used for sync entries
*/
export const SYNC_KEYS = {
USER_SETTINGS: '~/.claude/settings.json',
USER_MEMORY: '~/.claude/CLAUDE.md',
projectSettings: (projectId: string) =>
`projects/${projectId}/.claude/settings.local.json`,
projectMemory: (projectId: string) => `projects/${projectId}/CLAUDE.local.md`,
} as const