import { z } from 'zod'; // SWOT分析データ(基本構造) export const swotDataSchema = z.object({ 業界: z.string(), 商材: z.string(), 内部環境: z.string(), 外部環境: z.string(), 業界トレンド: z.array(z.string()), ニーズ: z.array( z.object({ 市場ニーズ: z.string(), ユーザのモーメント: z.string(), }), ), 王道: z.object({ 焦点: z.string(), 訴求: z.string(), }), 多道: z.object({ 焦点: z.string(), 訴求: z.string(), }), 強み: z.object({ 訴求: z.array(z.string()), 一番の強み: z .object({ 訴求: z.string(), 言い換え: z.string(), 強み: z.string().optional(), 弱み: z.string().optional(), ユーザ感情: z.string(), 選定理由: z.string(), }) .optional(), 一番の弱み: z .object({ 訴求: z.string(), 言い換え: z.string(), 強み: z.string().optional(), 弱み: z.string().optional(), ユーザ感情: z.string(), 選定理由: z.string(), }) .optional(), 顧客: z.string(), }), 弱み: z.object({ 訴求: z.array(z.string()), 一番の強み: z .object({ 訴求: z.string(), 言い換え: z.string(), 強み: z.string().optional(), 弱み: z.string().optional(), ユーザ感情: z.string(), 選定理由: z.string(), }) .optional(), 一番の弱み: z .object({ 訴求: z.string(), 言い換え: z.string(), 強み: z.string().optional(), 弱み: z.string().optional(), ユーザ感情: z.string(), 選定理由: z.string(), }) .optional(), 顧客: z.string(), }), 共通: z.object({ 訴求: z.array(z.string()), 顧客: z.string(), }), 機会の生成元: z.array( z.object({ 機会: z.string().optional(), 脅威: z.string().optional(), 生成元テーマ: z.array(z.string()), }), ), 機会: z.array(z.string()), 脅威の生成元: z.array( z.object({ 機会: z.string().optional(), 脅威: z.string().optional(), 生成元テーマ: z.array(z.string()), }), ), 脅威: z.array(z.string()), 積極化戦略: z.object({ テーマ: z.string(), 戦略の内容: z.string(), 戦略の根拠: z.string(), 関連する内部環境: z.string(), 関連する外部環境: z.string(), 想定競合URL: z.array(z.string()), }), 差別化戦略: z.object({ テーマ: z.string(), 戦略の内容: z.string(), 戦略の根拠: z.string(), 関連する内部環境: z.string(), 関連する外部環境: z.string(), 想定競合URL: z.array(z.string()), }), 改善戦略: z.object({ テーマ: z.string(), 戦略の内容: z.string(), 戦略の根拠: z.string(), 関連する内部環境: z.string(), 関連する外部環境: z.string(), 想定競合URL: z.array(z.string()), }), 防衛戦略: z.object({ テーマ: z.string(), 戦略の内容: z.string(), 戦略の根拠: z.string(), 関連する内部環境: z.string(), 関連する外部環境: z.string(), 想定競合URL: z.array(z.string()), }), 概要: z.string(), }); export type SwotData = z.infer; // SWOTテーブル(構造化データ) export const swotTableSchema = z.object({ PoD: z.array(z.string()), PoF: z.array(z.string()), PoP: z.array(z.string()), 概要: z.string(), }); export type SwotTable = z.infer; // 拡張SwotData(scoreDict, scoreTotalを含む) // 注意: scoreDictとscoreTotalは実際のJSONではstring型で格納される export const swotDataWithScoresSchema = swotDataSchema.extend({ scoreDict: z.union([z.string(), z.any()]).optional(), // JSONでは文字列 "{}" scoreTotal: z.union([z.string(), z.number()]).optional(), // JSONでは文字列 "100" }); export type SwotDataWithScores = z.infer; // SwotData without 概要 field (for second element) export const swotDataWithoutSummarySchema = swotDataSchema.omit({ 概要: true }); export type SwotDataWithoutSummary = z.infer; // getPoxのGradio APIレスポンス型(タプル形式) export const getPoxGradioResponseSchema = z.tuple([ swotDataWithScoresSchema, // 第1要素: SwotDataWithScores(scoreDict, scoreTotalを含む) swotDataWithoutSummarySchema, // 第2要素: SwotData(概要なし) z.string(), // 第3要素: 分析概要 swotTableSchema, // 第4要素: SwotTable z.string(), // 第5要素: 戦略推奨 z.string(), // 第6要素: メタデータ/追加情報 ]); export type GetPoxGradioResponse = z.infer;