'object', 'properties' => array( 'generator' => array( 'type' => 'string', 'description' => __( 'Which generator to preview a run for.', 'ai-product-tools' ), 'enum' => array( 'description', 'title', 'seo_meta', 'faq', 'image_alt' ), ), 'product_ids' => array( 'type' => 'array', 'description' => __( 'WooCommerce product ids to include, 1 to 100, each unique. A run uses the store AI key: Free covers 1 product per call and Business covers several. On Free, the bulk generators in the WordPress admin cover many products per run.', 'ai-product-tools' ), 'items' => array( 'type' => 'integer', 'minimum' => 1 ), 'minItems' => 1, 'maxItems' => 100, 'uniqueItems' => true, ), 'destination' => array( 'type' => 'string', 'description' => __( 'Where a confirmed run would write: directly to the product (apply), or to the review queue when available on this plan (review). Default apply.', 'ai-product-tools' ), 'enum' => array( 'apply', 'review' ), 'default' => 'apply', ), 'overwrite' => array( 'type' => 'string', 'description' => __( 'Whether a confirmed run replaces existing content, or only fills empty fields. Default replace.', 'ai-product-tools' ), 'enum' => array( 'replace', 'empty_only' ), 'default' => 'replace', ), ), 'required' => array( 'generator', 'product_ids' ), 'additionalProperties' => false, ); } /** * @return array */ public static function previewOutput(): array { return array( 'type' => 'object', 'properties' => array( 'confirm_token' => array( 'type' => 'string', 'description' => __( 'Pass this unchanged to confirm-content-run within 15 minutes.', 'ai-product-tools' ) ), 'expires_at' => array( 'type' => 'string', 'description' => __( 'UTC ISO 8601 timestamp the confirm_token stops working.', 'ai-product-tools' ) ), 'generator' => array( 'type' => 'string' ), 'run_pin' => self::runPinSchema(), 'blueprints' => self::blueprintGroupListSchema(), 'product_count' => array( 'type' => 'integer', 'description' => __( 'Products a confirmed run would act on (after skips).', 'ai-product-tools' ) ), 'skipped' => self::skippedListSchema(), 'destination' => array( 'type' => 'string', 'enum' => array( 'apply', 'review' ) ), 'overwrite' => array( 'type' => 'string', 'enum' => array( 'replace', 'empty_only' ) ), 'plan_limits' => self::planLimitsSchema(), 'execution' => array( 'type' => 'object', 'properties' => array( 'mode' => array( 'type' => 'string', 'enum' => array( 'sync', 'queued', 'deep_link' ) ), 'estimated_ai_calls' => array( 'type' => 'object', 'properties' => array( 'min' => array( 'type' => 'integer' ), 'max' => array( 'type' => 'integer' ), ), ), ), ), 'summary' => array( 'type' => 'string', 'description' => __( 'One translated sentence describing what a confirmed run would do.', 'ai-product-tools' ) ), ), 'required' => array( 'confirm_token', 'generator', 'product_count', 'execution', 'summary' ), ); } /** * @return array */ public static function confirmInput(): array { return array( 'type' => 'object', 'properties' => array( 'confirm_token' => array( 'type' => 'string', 'description' => __( 'The confirm_token a preview-content-run call returned.', 'ai-product-tools' ), 'pattern' => '^[a-f0-9]{32}$', ), 'expected_product_count' => array( 'type' => 'integer', 'description' => __( 'The product_count the preview returned, echoed back as a safety check.', 'ai-product-tools' ), 'minimum' => 1, ), ), 'required' => array( 'confirm_token', 'expected_product_count' ), 'additionalProperties' => false, ); } /** * @return array */ public static function confirmOutput(): array { return array( 'type' => 'object', 'properties' => array( 'status' => array( 'type' => 'string', 'enum' => array( 'completed', 'partial', 'queued', 'deep_link', 'failed' ) ), 'generator' => array( 'type' => 'string' ), 'run_pin' => self::runPinSchema(), 'blueprints' => self::blueprintGroupListSchema(), 'applied' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'product_id' => array( 'type' => 'integer' ), 'result_key' => array( 'type' => 'string' ), 'blueprint' => array( 'type' => array( 'object', 'null' ), 'properties' => array( 'id' => array( 'type' => array( 'integer', 'null' ) ), 'name' => array( 'type' => 'string' ), 'revision' => array( 'type' => array( 'integer', 'null' ) ), ), ), 'fields' => self::fieldOutcomeListSchema(), 'snapshot_taken' => array( 'type' => 'boolean' ), ), ), ), 'staged' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'product_id' => array( 'type' => 'integer' ), 'result_key' => array( 'type' => 'string' ), 'fields' => self::fieldOutcomeListSchema(), ), ), ), 'held_back' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'product_id' => array( 'type' => 'integer' ), 'result_key' => array( 'type' => 'string' ), 'reason' => array( 'type' => 'string' ), 'message' => array( 'type' => 'string' ), ), ), ), 'skipped' => self::skippedListSchema(), 'failed' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'product_id' => array( 'type' => 'integer' ), 'code' => array( 'type' => 'string' ), 'message' => array( 'type' => 'string' ), ), ), ), 'plan_limits' => self::planLimitsSchema(), 'job_id' => array( 'type' => 'integer', 'description' => __( 'Only present when status is queued.', 'ai-product-tools' ) ), 'job_url' => array( 'type' => 'string', 'description' => __( 'Only present when status is queued.', 'ai-product-tools' ) ), 'deep_link' => array( 'type' => 'string', 'description' => __( 'Only present when status is deep_link, or when anything was held back.', 'ai-product-tools' ) ), 'message' => array( 'type' => 'string' ), ), 'required' => array( 'status', 'generator', 'applied', 'staged', 'held_back', 'skipped', 'failed', 'plan_limits', 'message' ), ); } /** * @return array */ private static function runPinSchema(): array { return array( 'type' => 'object', 'properties' => array( 'id' => array( 'type' => 'integer' ), 'hash' => array( 'type' => 'string' ), 'created_at' => array( 'type' => 'string' ), ), ); } /** * @return array */ private static function blueprintGroupListSchema(): array { return array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'blueprint_id' => array( 'type' => array( 'integer', 'null' ) ), 'name' => array( 'type' => 'string' ), 'revision' => array( 'type' => array( 'integer', 'null' ) ), 'builtin' => array( 'type' => 'boolean' ), 'product_count' => array( 'type' => 'integer' ), ), ), ); } /** * @return array */ private static function skippedListSchema(): array { return array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'product_id' => array( 'type' => 'integer' ), 'reason' => array( 'type' => 'string', 'enum' => array( 'not_found', 'forbidden', 'conflict', 'changed_since_preview' ) ), ), ), ); } /** * @return array */ private static function planLimitsSchema(): array { return array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'key' => array( 'type' => 'string' ), 'reason' => array( 'type' => 'string' ), ), ), ); } /** * @return array */ private static function fieldOutcomeListSchema(): array { return array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'field' => array( 'type' => 'string' ), 'outcome' => array( 'type' => 'string' ), ), ), ); } }