feat(commands): multi-select ordered command pipeline with step reordering and single-pass composition (AI-05, AI-07)

This commit is contained in:
Yun Chan 2026-10-31 02:54:54 +09:00
parent f49acf0105
commit 10af20a0ad
157 changed files with 29455 additions and 913 deletions

View file

@ -1,5 +1,10 @@
import type { D3roSupabaseClient, Subscription } from '@d3ro/api-client'
import type { SupabaseClient } from '@supabase/supabase-js'
import {
isSupportedWebProvider,
isSupportedWebTier,
resolveWebEntitlement
} from './entitlement'
export interface DashboardRecentEntry {
id: string
@ -55,8 +60,6 @@ export class DashboardClientError extends Error {
}
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
const TIERS = new Set(['free', 'pro', 'pro_plus'])
const PROVIDERS = new Set(['none', 'stripe', 'payple', 'google_play', 'app_store', 'admin'])
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
@ -152,11 +155,9 @@ function normalizeSubscription(value: unknown): DashboardSubscription {
const periodEnd = normalizeDate(value.current_period_end, true)
const cancelAt = normalizeDate(value.cancel_at, true)
if (
typeof value.tier !== 'string'
|| !TIERS.has(value.tier)
!isSupportedWebTier(value.tier)
|| (value.status !== null && typeof value.status !== 'string')
|| typeof value.provider !== 'string'
|| !PROVIDERS.has(value.provider)
|| !isSupportedWebProvider(value.provider)
|| overageCredits === null
|| (value.current_period_end !== null && periodEnd === null)
|| (value.cancel_at !== null && cancelAt === null)
@ -164,14 +165,15 @@ function normalizeSubscription(value: unknown): DashboardSubscription {
) {
throw new DashboardClientError('invalid-response', 'Subscription response shape is invalid')
}
const resolved = resolveWebEntitlement(value)
return {
tier: value.tier as Subscription['tier'],
status: value.status,
provider: value.provider as Subscription['provider'],
overageCredits,
currentPeriodEnd: periodEnd,
cancelAt,
autoRenewing: value.auto_renewing
tier: resolved.tier,
status: resolved.status,
provider: resolved.provider,
overageCredits: resolved.overageCredits,
currentPeriodEnd: resolved.currentPeriodEnd,
cancelAt: resolved.cancelAt,
autoRenewing: resolved.autoRenewing
}
}