/** * NinSys API Response Schemas * * Zod runtime validation for `/v2/pluginator/*` responses. Phase 3 audit * (P0 #4, API [1-3]) flagged that all auth/usage/subscription/registry * responses were `as { ... }` casts — a no-op at runtime. The v2.20.2 * subscription-shape flatten that landed in v2.11.62 is exactly the kind * of silent shape drift that schema validation catches at the response * boundary instead of at render time. * * Pattern: `safeParse` at the response boundary; on failure, throw the * appropriate typed error (AuthError / NetworkError) so callers see a * clear "API contract drift" message rather than `undefined.foo`. * * @since v2.11.65 */ import { z } from 'zod'; /** * The shape of `data.user` in auth/login, /verify, /session responses. * Mirrors `ApiUser` interface in auth-service.ts. */ export declare const ApiUserSchema: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodNullable; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>; /** * Login response. May be a 2FA challenge OR a full session. Optional fields * accommodate both cases. */ export declare const LoginResponseDataSchema: z.ZodObject<{ user: z.ZodOptional; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>>; token: z.ZodOptional; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; requires2FA: z.ZodOptional; challengeToken: z.ZodOptional; }, "strip", z.ZodTypeAny, { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }, { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }>; export declare const LoginResponseSchema: z.ZodObject<{ data: z.ZodObject<{ user: z.ZodOptional; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>>; token: z.ZodOptional; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; requires2FA: z.ZodOptional; challengeToken: z.ZodOptional; }, "strip", z.ZodTypeAny, { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }, { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }>; }, "strip", z.ZodTypeAny, { data: { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }; }, { data: { requires2FA?: boolean | undefined; user?: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; } | undefined; token?: string | undefined; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; challengeToken?: string | undefined; }; }>; /** * 2FA verification response — always returns full session. */ export declare const Verify2FAResponseDataSchema: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodNullable; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>; token: z.ZodString; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; }, "strip", z.ZodTypeAny, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }>; export declare const Verify2FAResponseSchema: z.ZodObject<{ data: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodNullable; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>; token: z.ZodString; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; }, "strip", z.ZodTypeAny, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }>; }, "strip", z.ZodTypeAny, { data: { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }; }, { data: { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; token: string; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }; }>; /** * Session response (`GET /v2/pluginator/auth/session`) — returns user info * but NO new token (the existing one is still valid). */ export declare const SessionResponseDataSchema: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodNullable; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; }, "strip", z.ZodTypeAny, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }>; export declare const SessionResponseSchema: z.ZodObject<{ data: z.ZodObject<{ user: z.ZodObject<{ id: z.ZodString; email: z.ZodString; name: z.ZodNullable; subscriptionTier: z.ZodEnum<["free", "plus", "pro", "max"]>; hasPlusDiscount: z.ZodBoolean; createdAt: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }, { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }>; tierExpiresAt: z.ZodOptional>; expiresAt: z.ZodOptional>; }, "strip", z.ZodTypeAny, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }, { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }>; }, "strip", z.ZodTypeAny, { data: { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }; }, { data: { user: { id: string; email: string; name: string | null; subscriptionTier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; createdAt: string; }; tierExpiresAt?: string | null | undefined; expiresAt?: string | null | undefined; }; }>; /** * Subscription response (`GET /v2/pluginator/subscription`) post-v2.20.2 * flat shape. Status enum matches API exactly: 'canceling' (one L), 'none' * (replaces the old 'canceled'). */ export declare const SubscriptionResponseDataSchema: z.ZodObject<{ status: z.ZodEnum<["active", "past_due", "canceling", "none"]>; tier: z.ZodEnum<["free", "plus", "pro", "max"]>; currentPeriodEnd: z.ZodNullable; cancelAtPeriodEnd: z.ZodBoolean; priceFormatted: z.ZodNullable; billingPeriod: z.ZodNullable>; tierExpiresAt: z.ZodNullable; downgradeToTier: z.ZodNullable>; hasPlusDiscount: z.ZodBoolean; }, "strip", z.ZodTypeAny, { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }, { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }>; export declare const SubscriptionResponseSchema: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodObject<{ status: z.ZodEnum<["active", "past_due", "canceling", "none"]>; tier: z.ZodEnum<["free", "plus", "pro", "max"]>; currentPeriodEnd: z.ZodNullable; cancelAtPeriodEnd: z.ZodBoolean; priceFormatted: z.ZodNullable; billingPeriod: z.ZodNullable>; tierExpiresAt: z.ZodNullable; downgradeToTier: z.ZodNullable>; hasPlusDiscount: z.ZodBoolean; }, "strip", z.ZodTypeAny, { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }, { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }>; }, "strip", z.ZodTypeAny, { data: { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }; success: boolean; }, { data: { tier: "free" | "plus" | "pro" | "max"; hasPlusDiscount: boolean; status: "active" | "past_due" | "canceling" | "none"; tierExpiresAt: string | null; currentPeriodEnd: string | null; cancelAtPeriodEnd: boolean; priceFormatted: string | null; billingPeriod: "monthly" | "annual" | null; downgradeToTier: "free" | "plus" | "pro" | "max" | null; }; success: boolean; }>; export declare const UsageReportSchema: z.ZodObject<{ tier: z.ZodEnum<["free", "plus", "pro", "max"]>; today: z.ZodObject<{ updateChecks: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; downloads: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; syncs: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; migrations: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; templateDownloads: z.ZodOptional>; }, "strip", z.ZodTypeAny, { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }, { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }>; }, "strip", z.ZodTypeAny, { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }, { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }>; export declare const UsageResponseSchema: z.ZodObject<{ data: z.ZodObject<{ tier: z.ZodEnum<["free", "plus", "pro", "max"]>; today: z.ZodObject<{ updateChecks: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; downloads: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; syncs: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; migrations: z.ZodObject<{ used: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { used: number; limit: number; remaining: number; }, { used: number; limit: number; remaining: number; }>; templateDownloads: z.ZodOptional>; }, "strip", z.ZodTypeAny, { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }, { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }>; }, "strip", z.ZodTypeAny, { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }, { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }>; }, "strip", z.ZodTypeAny, { data: { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }; }, { data: { tier: "free" | "plus" | "pro" | "max"; today: { updateChecks: { used: number; limit: number; remaining: number; }; downloads: { used: number; limit: number; remaining: number; }; syncs: { used: number; limit: number; remaining: number; }; migrations: { used: number; limit: number; remaining: number; }; templateDownloads?: { used: number; limit: number; remaining: number; } | undefined; }; }; }>; /** * Limit check response from `GET /v2/pluginator/usage/check/{action}`. */ export declare const LimitCheckResponseDataSchema: z.ZodObject<{ allowed: z.ZodBoolean; current: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { limit: number; remaining: number; allowed: boolean; current: number; }, { limit: number; remaining: number; allowed: boolean; current: number; }>; export declare const LimitCheckResponseSchema: z.ZodObject<{ data: z.ZodObject<{ allowed: z.ZodBoolean; current: z.ZodNumber; limit: z.ZodNumber; remaining: z.ZodNumber; }, "strip", z.ZodTypeAny, { limit: number; remaining: number; allowed: boolean; current: number; }, { limit: number; remaining: number; allowed: boolean; current: number; }>; }, "strip", z.ZodTypeAny, { data: { limit: number; remaining: number; allowed: boolean; current: number; }; }, { data: { limit: number; remaining: number; allowed: boolean; current: number; }; }>; /** * Validate a parsed JSON body against a schema. Returns the parsed data on * success; throws a descriptive error on failure (caller maps to * AuthError/NetworkError as appropriate). Truncates the issue list to the * first 3 to keep error messages readable. */ export declare function validateApiResponse(schema: z.ZodType, raw: unknown, context: string): T; //# sourceMappingURL=api-schema.d.ts.map