// Auto-generated by AutoCRUD Web Generator
import {
  resources as registry,
  applyCustomizations as applyCustomizationsImpl,
} from '../lib/resources';
import type { ResourceCustomizations as ResourceCustomizationsBase } from '../lib/resources';
import { setApiBasePath } from '../lib/client';
import { z } from 'zod';
import { characterApi } from './api/characterApi';
import { guildApi } from './api/guildApi';
import { skillApi } from './api/skillApi';
import { equipmentApi } from './api/equipmentApi';
import { petJobApi } from './api/pet-jobApi';
import { questApi } from './api/questApi';
import { gameEventApi } from './api/game-eventApi';
import { newChar1JobApi } from './api/new-char1-jobApi';
import { createNewCharacter2JobApi } from './api/create-new-character2-jobApi';
import { createNewCharacter4JobApi } from './api/create-new-character4-jobApi';
import { petApi } from './api/petApi';

// Inject API base path so blob URLs and other non-Axios URL constructions
// include the correct prefix (e.g. '/v1/autocrud/blobs/upload').
setApiBasePath('/v1/autocrud');

/** Union type of all resource names */
export type ResourceName =
  | 'character'
  | 'guild'
  | 'skill'
  | 'equipment'
  | 'pet-job'
  | 'quest'
  | 'game-event'
  | 'new-char1-job'
  | 'create-new-character2-job'
  | 'create-new-character4-job'
  | 'pet';

/** Per-resource field name union types */
export type CharacterFieldName =
  | 'name'
  | 'character_class'
  | 'valueAD__x'
  | 'level'
  | 'hp'
  | 'mp'
  | 'attack'
  | 'defense'
  | 'experience'
  | 'gold'
  | 'guild_id'
  | 'guild_name'
  | 'special_ability'
  | 'skill_ids'
  | 'equipments'
  | 'created_at';
export type GuildFieldName =
  | 'name'
  | 'description'
  | 'leader'
  | 'member_count'
  | 'level'
  | 'treasury'
  | 'founded_at';
export type SkillFieldName =
  | 'skname'
  | 'detail'
  | 'description'
  | 'required_level'
  | 'required_class';
export type EquipmentFieldName =
  | 'type'
  | 'name'
  | 'rarity'
  | 'owner_id'
  | 'character_class_req'
  | 'attack_bonus'
  | 'defense_bonus'
  | 'special_effects'
  | 'price'
  | 'icon';
export type PetJobFieldName =
  | 'payload'
  | 'status'
  | 'errmsg'
  | 'artifact'
  | 'retries'
  | 'max_retries'
  | 'periodic_interval_seconds'
  | 'periodic_max_runs'
  | 'periodic_runs'
  | 'periodic_initial_delay_seconds'
  | 'last_heartbeat_at';
export type QuestFieldName =
  | 'title'
  | 'description'
  | 'level_requirement'
  | 'difficulty'
  | 'quest_config'
  | 'rewards';
export type GameEventFieldName =
  | 'payload.event_type'
  | 'payload.character_name'
  | 'payload.character_id'
  | 'payload.description'
  | 'payload.reward_gold'
  | 'payload.reward_exp'
  | 'payload.extra_data'
  | 'payload.event_body'
  | 'payload.event_x.type'
  | 'payload.event_x.good'
  | 'payload.event_x.great'
  | 'payload.extra_values'
  | 'status'
  | 'errmsg'
  | 'artifact.process_times'
  | 'retries'
  | 'max_retries'
  | 'periodic_interval_seconds'
  | 'periodic_max_runs'
  | 'periodic_runs'
  | 'periodic_initial_delay_seconds'
  | 'last_heartbeat_at';
export type NewChar1JobFieldName =
  | 'payload.name'
  | 'status'
  | 'errmsg'
  | 'artifact'
  | 'retries'
  | 'max_retries'
  | 'periodic_interval_seconds'
  | 'periodic_max_runs'
  | 'periodic_runs'
  | 'periodic_initial_delay_seconds'
  | 'last_heartbeat_at';
export type CreateNewCharacter2JobFieldName =
  | 'payload.name'
  | 'status'
  | 'errmsg'
  | 'artifact'
  | 'retries'
  | 'max_retries'
  | 'periodic_interval_seconds'
  | 'periodic_max_runs'
  | 'periodic_runs'
  | 'periodic_initial_delay_seconds'
  | 'last_heartbeat_at';
export type CreateNewCharacter4JobFieldName =
  | 'payload.x'
  | 'payload.y'
  | 'payload.name'
  | 'payload.z.binary'
  | 'payload.z.filename'
  | 'payload.f.skname'
  | 'payload.f.detail'
  | 'payload.f.description'
  | 'payload.f.required_level'
  | 'payload.f.required_class'
  | 'status'
  | 'errmsg'
  | 'artifact'
  | 'retries'
  | 'max_retries'
  | 'periodic_interval_seconds'
  | 'periodic_max_runs'
  | 'periodic_runs'
  | 'periodic_initial_delay_seconds'
  | 'last_heartbeat_at';
export type PetFieldName = 'data';

/** Mapping from resource name to its field name union type */
export interface ResourceFieldMap {
  character: CharacterFieldName;
  guild: GuildFieldName;
  skill: SkillFieldName;
  equipment: EquipmentFieldName;
  'pet-job': PetJobFieldName;
  quest: QuestFieldName;
  'game-event': GameEventFieldName;
  'new-char1-job': NewChar1JobFieldName;
  'create-new-character2-job': CreateNewCharacter2JobFieldName;
  'create-new-character4-job': CreateNewCharacter4JobFieldName;
  pet: PetFieldName;
}

/** Type-safe customization config for all resources */
export type ResourceCustomizations = ResourceCustomizationsBase<ResourceFieldMap>;

/** Union type of all resource detail route paths */
export type ResourceDetailRoute =
  | '/autocrud-admin/character/$resourceId'
  | '/autocrud-admin/guild/$resourceId'
  | '/autocrud-admin/skill/$resourceId'
  | '/autocrud-admin/equipment/$resourceId'
  | '/autocrud-admin/pet-job/$resourceId'
  | '/autocrud-admin/quest/$resourceId'
  | '/autocrud-admin/game-event/$resourceId'
  | '/autocrud-admin/new-char1-job/$resourceId'
  | '/autocrud-admin/create-new-character2-job/$resourceId'
  | '/autocrud-admin/create-new-character4-job/$resourceId'
  | '/autocrud-admin/pet/$resourceId';

/** Union type of all resource list route paths */
export type ResourceListRoute =
  | '/autocrud-admin/character'
  | '/autocrud-admin/guild'
  | '/autocrud-admin/skill'
  | '/autocrud-admin/equipment'
  | '/autocrud-admin/pet-job'
  | '/autocrud-admin/quest'
  | '/autocrud-admin/game-event'
  | '/autocrud-admin/new-char1-job'
  | '/autocrud-admin/create-new-character2-job'
  | '/autocrud-admin/create-new-character4-job'
  | '/autocrud-admin/pet';

/** Mapping from resource name to detail route path */
const detailRoutes: Record<ResourceName, ResourceDetailRoute> = {
  character: '/autocrud-admin/character/$resourceId',
  guild: '/autocrud-admin/guild/$resourceId',
  skill: '/autocrud-admin/skill/$resourceId',
  equipment: '/autocrud-admin/equipment/$resourceId',
  'pet-job': '/autocrud-admin/pet-job/$resourceId',
  quest: '/autocrud-admin/quest/$resourceId',
  'game-event': '/autocrud-admin/game-event/$resourceId',
  'new-char1-job': '/autocrud-admin/new-char1-job/$resourceId',
  'create-new-character2-job': '/autocrud-admin/create-new-character2-job/$resourceId',
  'create-new-character4-job': '/autocrud-admin/create-new-character4-job/$resourceId',
  pet: '/autocrud-admin/pet/$resourceId',
};

/** Mapping from resource name to list route path */
const listRoutes: Record<ResourceName, ResourceListRoute> = {
  character: '/autocrud-admin/character',
  guild: '/autocrud-admin/guild',
  skill: '/autocrud-admin/skill',
  equipment: '/autocrud-admin/equipment',
  'pet-job': '/autocrud-admin/pet-job',
  quest: '/autocrud-admin/quest',
  'game-event': '/autocrud-admin/game-event',
  'new-char1-job': '/autocrud-admin/new-char1-job',
  'create-new-character2-job': '/autocrud-admin/create-new-character2-job',
  'create-new-character4-job': '/autocrud-admin/create-new-character4-job',
  pet: '/autocrud-admin/pet',
};

/** Get the detail route path for a resource (type-safe for TanStack Router) */
export function getResourceDetailRoute(resource: ResourceName): ResourceDetailRoute {
  return detailRoutes[resource];
}

/** Get the list route path for a resource (type-safe for TanStack Router) */
export function getResourceListRoute(resource: ResourceName): ResourceListRoute {
  return listRoutes[resource];
}

Object.assign(registry, {
  character: {
    name: 'character',
    label: 'Character',
    pluralLabel: 'Characters',
    displayNameField: 'name',
    schema: 'Character',
    fields: [
      {
        name: 'name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
        isUnique: true,
      },
      {
        name: 'character_class',
        label: 'Character Class',
        isArray: false,
        isRequired: true,
        isNullable: false,
        enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
      },
      {
        name: 'valueAD__x',
        label: 'ValueAD X',
        type: 'union',
        isArray: false,
        isRequired: false,
        isNullable: false,
        unionMeta: {
          discriminatorField: '__type',
          variants: [
            {
              tag: 'number',
              label: 'Number',
              type: 'number',
            },
            {
              tag: 'string',
              label: 'String',
              type: 'string',
            },
          ],
        },
      },
      {
        name: 'level',
        label: 'Level',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'hp',
        label: 'Hp',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'mp',
        label: 'Mp',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'attack',
        label: 'Attack',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'defense',
        label: 'Defense',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'experience',
        label: 'Experience',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'gold',
        label: 'Gold',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'guild_id',
        label: 'Guild Id',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
        ref: {
          resource: 'guild',
          type: 'resource_id',
          onDelete: 'set_null',
        },
      },
      {
        name: 'guild_name',
        label: 'Guild Name',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'special_ability',
        label: 'Special Ability',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'skill_ids',
        label: 'Skill Ids',
        type: 'string',
        isArray: true,
        isRequired: false,
        isNullable: false,
        ref: {
          resource: 'skill',
          type: 'resource_id',
          onDelete: 'dangling',
        },
      },
      {
        name: 'equipments',
        label: 'Equipments',
        type: 'union',
        isArray: true,
        isRequired: false,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'type',
          variants: [
            {
              tag: 'Equipment',
              label: 'Equipment',
              schemaName: 'Equipment',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'rarity',
                  label: 'Rarity',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                  enumValues: ['傳奇', '史詩', '普通', '稀有', '🚀 AutoCRUD 神器'],
                },
                {
                  name: 'owner_id',
                  label: 'Owner Id',
                  type: 'string',
                  isArray: false,
                  isRequired: false,
                  isNullable: true,
                  ref: {
                    resource: 'character',
                    type: 'resource_id',
                    onDelete: 'set_null',
                  },
                },
                {
                  name: 'character_class_req',
                  label: 'Character Class Req',
                  isArray: false,
                  isRequired: false,
                  isNullable: true,
                  enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
                },
                {
                  name: 'attack_bonus',
                  label: 'Attack Bonus',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'defense_bonus',
                  label: 'Defense Bonus',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'special_effects',
                  label: 'Special Effects',
                  type: 'string',
                  isArray: true,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'price',
                  label: 'Price',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'icon',
                  label: 'Icon',
                  type: 'binary',
                  isArray: false,
                  isRequired: false,
                  isNullable: true,
                },
              ],
            },
            {
              tag: 'Item',
              label: 'Item',
              schemaName: 'Item',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'description',
                  label: 'Description',
                  type: 'string',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'price',
                  label: 'Price',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'icon',
                  label: 'Icon',
                  type: 'binary',
                  isArray: false,
                  isRequired: false,
                  isNullable: true,
                },
              ],
            },
          ],
        },
      },
      {
        name: 'created_at',
        label: 'Created At',
        type: 'date',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
    ],
    zodSchema: z.object({
      name: z.string(),
      character_class: z.any(),
      valueAD__x: z.union([z.number(), z.string()]).optional(),
      level: z.number().int().optional(),
      hp: z.number().int().optional(),
      mp: z.number().int().optional(),
      attack: z.number().int().optional(),
      defense: z.number().int().optional(),
      experience: z.number().int().optional(),
      gold: z.number().int().optional(),
      guild_id: z.string().nullable().optional(),
      guild_name: z.string().nullable().optional(),
      special_ability: z.string().nullable().optional(),
      skill_ids: z.array(z.string()).optional(),
      equipments: z
        .array(
          z.discriminatedUnion('type', [
            z.object({
              type: z.literal('Equipment'),
              name: z.string(),
              rarity: z.any(),
              owner_id: z.string().nullable().optional(),
              character_class_req: z.any().nullable().optional(),
              attack_bonus: z.number().int().optional(),
              defense_bonus: z.number().int().optional(),
              special_effects: z.array(z.string()).optional(),
              price: z.number().int().optional(),
              icon: z.any().nullable().optional(),
            }),
            z.object({
              type: z.literal('Item'),
              name: z.string(),
              description: z.string().optional(),
              price: z.number().int().optional(),
              icon: z.any().nullable().optional(),
            }),
          ]),
        )
        .optional(),
      created_at: z.union([z.string(), z.date()]).optional(),
    }),
    apiClient: characterApi,
    maxFormDepth: 1,
    indexedFields: [
      'level',
      'name',
      'gold',
      'guild_name',
      'character_class',
      'guild_id',
      'skill_ids',
    ],
    customCreateActions: [
      {
        name: 'create-new-character0',
        label: 'New Character0',
        fields: [],
        zodSchema: z.object({}),
        apiMethod: characterApi.createNewCharacter0,
      },
      {
        name: 'create-new-character-background',
        label: 'New Character background',
        fields: [],
        zodSchema: z.object({}),
        apiMethod: characterApi.createNewCharacterBackground,
        asyncMode: 'background',
      },
      {
        name: 'new',
        label: 'New Character1',
        fields: [
          {
            name: 'name',
            label: 'Name',
            type: 'string',
            isArray: false,
            isRequired: true,
            isNullable: false,
            ref: {
              resource: 'equipment',
              type: 'resource_id',
              onDelete: 'dangling',
            },
          },
        ],
        zodSchema: z.object({
          name: z.string(),
        }),
        apiMethod: characterApi.createNewCharacter1,
        asyncMode: 'job',
        jobResourceName: 'new-char1-job',
      },
      {
        name: 'create-new-character2',
        label: 'New Character2',
        fields: [
          {
            name: 'name',
            label: 'Name',
            type: 'string',
            isArray: false,
            isRequired: true,
            isNullable: false,
            ref: {
              resource: 'equipment',
              type: 'resource_id',
              onDelete: 'dangling',
            },
          },
        ],
        zodSchema: z.object({
          name: z.string(),
        }),
        apiMethod: characterApi.createNewCharacter2,
        asyncMode: 'job',
        jobResourceName: 'create-new-character2-job',
      },
      {
        name: 'create-new-character4',
        label: 'New Character3',
        fields: [
          {
            name: 'x',
            label: 'X',
            type: 'union',
            isArray: false,
            isRequired: true,
            isNullable: false,
            unionMeta: {
              discriminatorField: '__type',
              variants: [
                {
                  tag: 'number',
                  label: 'Number',
                  type: 'number',
                },
                {
                  tag: 'string',
                  label: 'String',
                  type: 'string',
                },
              ],
            },
          },
          {
            name: 'y',
            label: 'Y',
            type: 'string',
            isArray: false,
            isRequired: true,
            isNullable: false,
          },
          {
            name: 'f.skname',
            label: 'Skname',
            type: 'string',
            isArray: false,
            isRequired: true,
            isNullable: false,
          },
          {
            name: 'f.detail',
            label: 'Detail',
            type: 'union',
            isArray: false,
            isRequired: true,
            isNullable: false,
            unionMeta: {
              discriminatorField: 'skill_type',
              variants: [
                {
                  tag: 'active',
                  label: 'Active',
                  schemaName: '__main___ActiveSkillData',
                  fields: [
                    {
                      name: 'mp_cost',
                      label: 'Mp Cost',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                    {
                      name: 'cooldown_seconds',
                      label: 'Cooldown Seconds',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                    {
                      name: 'damage',
                      label: 'Damage',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                  ],
                },
                {
                  tag: 'passive',
                  label: 'Passive',
                  schemaName: '__main___PassiveSkillData',
                  fields: [
                    {
                      name: 'buff_percentage',
                      label: 'Buff Percentage',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                  ],
                },
                {
                  tag: 'ultimate',
                  label: 'Ultimate',
                  schemaName: '__main___UltimateSkillData',
                  fields: [
                    {
                      name: 'mp_cost',
                      label: 'Mp Cost',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                    {
                      name: 'cooldown_seconds',
                      label: 'Cooldown Seconds',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                    {
                      name: 'damage',
                      label: 'Damage',
                      type: 'number',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                    {
                      name: 'area_of_effect',
                      label: 'Area Of Effect',
                      type: 'boolean',
                      isArray: false,
                      isRequired: false,
                      isNullable: false,
                    },
                  ],
                },
              ],
            },
          },
          {
            name: 'f.description',
            label: 'Description',
            type: 'string',
            isArray: false,
            isRequired: false,
            isNullable: false,
          },
          {
            name: 'f.required_level',
            label: 'Required Level',
            type: 'number',
            isArray: false,
            isRequired: false,
            isNullable: false,
          },
          {
            name: 'f.required_class',
            label: 'Required Class',
            isArray: false,
            isRequired: false,
            isNullable: true,
            enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
          },
          {
            name: 'name',
            label: 'Name',
            type: 'string',
            isArray: false,
            isRequired: true,
            isNullable: false,
            ref: {
              resource: 'equipment',
              type: 'resource_id',
              onDelete: 'dangling',
            },
          },
          {
            name: 'z',
            label: 'Z',
            type: 'file',
            isArray: false,
            isRequired: true,
            isNullable: false,
          },
        ],
        zodSchema: z.object({
          f: z.object({
            skname: z.string(),
            detail: z.discriminatedUnion('skill_type', [
              z.object({
                skill_type: z.literal('active'),
                mp_cost: z.number().int().optional(),
                cooldown_seconds: z.number().int().optional(),
                damage: z.number().int().optional(),
              }),
              z.object({
                skill_type: z.literal('passive'),
                buff_percentage: z.number().int().optional(),
              }),
              z.object({
                skill_type: z.literal('ultimate'),
                mp_cost: z.number().int().optional(),
                cooldown_seconds: z.number().int().optional(),
                damage: z.number().int().optional(),
                area_of_effect: z.boolean().optional(),
              }),
            ]),
            description: z.string().optional(),
            required_level: z.number().int().optional(),
            required_class: z.any().nullable().optional(),
          }),
          x: z.union([z.number(), z.string()]),
          y: z.string(),
          name: z.string(),
          z: z.instanceof(File),
        }),
        apiMethod: characterApi.createNewCharacter4,
        asyncMode: 'job',
        jobResourceName: 'create-new-character4-job',
      },
    ],
    customUpdateActions: [
      {
        name: 'update-char-name',
        label: 'New Character0',
        mode: 'update',
        fields: [],
        zodSchema: z.object({}),
        apiMethod: characterApi.updateCharName,
        asyncMode: 'background',
      },
    ],
  },
  guild: {
    name: 'guild',
    label: 'Guild',
    pluralLabel: 'Guilds',
    displayNameField: 'name',
    schema: 'Guild',
    fields: [
      {
        name: 'name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'description',
        label: 'Description',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'leader',
        label: 'Leader',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'member_count',
        label: 'Member Count',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'level',
        label: 'Level',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'treasury',
        label: 'Treasury',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'founded_at',
        label: 'Founded At',
        type: 'date',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
    ],
    zodSchema: z.object({
      name: z.string(),
      description: z.string(),
      leader: z.string(),
      member_count: z.number().int().optional(),
      level: z.number().int().optional(),
      treasury: z.number().int().optional(),
      founded_at: z.union([z.string(), z.date()]).optional(),
    }),
    apiClient: guildApi,
    maxFormDepth: 1,
  },
  skill: {
    name: 'skill',
    label: 'Skill',
    pluralLabel: 'Skills',
    displayNameField: 'skname',
    schema: 'Skill',
    fields: [
      {
        name: 'skname',
        label: 'Skname',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'detail',
        label: 'Detail',
        type: 'union',
        isArray: false,
        isRequired: true,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'skill_type',
          variants: [
            {
              tag: 'active',
              label: 'Active',
              schemaName: '__main___ActiveSkillData',
              fields: [
                {
                  name: 'mp_cost',
                  label: 'Mp Cost',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'cooldown_seconds',
                  label: 'Cooldown Seconds',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'damage',
                  label: 'Damage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'passive',
              label: 'Passive',
              schemaName: '__main___PassiveSkillData',
              fields: [
                {
                  name: 'buff_percentage',
                  label: 'Buff Percentage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'ultimate',
              label: 'Ultimate',
              schemaName: '__main___UltimateSkillData',
              fields: [
                {
                  name: 'mp_cost',
                  label: 'Mp Cost',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'cooldown_seconds',
                  label: 'Cooldown Seconds',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'damage',
                  label: 'Damage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'area_of_effect',
                  label: 'Area Of Effect',
                  type: 'boolean',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
          ],
        },
      },
      {
        name: 'description',
        label: 'Description',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'required_level',
        label: 'Required Level',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'required_class',
        label: 'Required Class',
        isArray: false,
        isRequired: false,
        isNullable: true,
        enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
      },
    ],
    zodSchema: z.object({
      skname: z.string(),
      detail: z.discriminatedUnion('skill_type', [
        z.object({
          skill_type: z.literal('active'),
          mp_cost: z.number().int().optional(),
          cooldown_seconds: z.number().int().optional(),
          damage: z.number().int().optional(),
        }),
        z.object({
          skill_type: z.literal('passive'),
          buff_percentage: z.number().int().optional(),
        }),
        z.object({
          skill_type: z.literal('ultimate'),
          mp_cost: z.number().int().optional(),
          cooldown_seconds: z.number().int().optional(),
          damage: z.number().int().optional(),
          area_of_effect: z.boolean().optional(),
        }),
      ]),
      description: z.string().optional(),
      required_level: z.number().int().optional(),
      required_class: z.any().nullable().optional(),
    }),
    apiClient: skillApi,
    maxFormDepth: 1,
    indexedFields: ['name', 'required_level'],
  },
  equipment: {
    name: 'equipment',
    label: 'Equipment',
    pluralLabel: 'Equipments',
    displayNameField: 'name',
    schema: 'Equipment',
    fields: [
      {
        name: 'type',
        label: 'Type',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
        enumValues: ['Equipment'],
        constValue: 'Equipment',
      },
      {
        name: 'name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'rarity',
        label: 'Rarity',
        isArray: false,
        isRequired: true,
        isNullable: false,
        enumValues: ['傳奇', '史詩', '普通', '稀有', '🚀 AutoCRUD 神器'],
      },
      {
        name: 'owner_id',
        label: 'Owner Id',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
        ref: {
          resource: 'character',
          type: 'resource_id',
          onDelete: 'set_null',
        },
      },
      {
        name: 'character_class_req',
        label: 'Character Class Req',
        isArray: false,
        isRequired: false,
        isNullable: true,
        enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
      },
      {
        name: 'attack_bonus',
        label: 'Attack Bonus',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'defense_bonus',
        label: 'Defense Bonus',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'special_effects',
        label: 'Special Effects',
        type: 'string',
        isArray: true,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'price',
        label: 'Price',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'icon',
        label: 'Icon',
        type: 'binary',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      type: z.literal('Equipment'),
      name: z.string(),
      rarity: z.any(),
      owner_id: z.string().nullable().optional(),
      character_class_req: z.any().nullable().optional(),
      attack_bonus: z.number().int().optional(),
      defense_bonus: z.number().int().optional(),
      special_effects: z.array(z.string()).optional(),
      price: z.number().int().optional(),
      icon: z.any().nullable().optional(),
    }),
    apiClient: equipmentApi,
    maxFormDepth: 1,
    indexedFields: ['owner_id'],
  },
  'pet-job': {
    name: 'pet-job',
    label: 'Pet Job',
    pluralLabel: 'Pet Jobs',
    schema: 'Job___main___Mount_____main___Dog__NoneType_',
    fields: [
      {
        name: 'payload',
        label: 'Payload',
        type: 'union',
        isArray: false,
        isRequired: true,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'type',
          variants: [
            {
              tag: 'Mount',
              label: 'Mount',
              schemaName: 'Mount',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'species',
                  label: 'Species',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'speed',
                  label: 'Speed',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'stamina',
                  label: 'Stamina',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'owner_id',
                  label: 'Owner Id',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                  ref: {
                    resource: 'character',
                    type: 'revision_id',
                  },
                },
              ],
            },
            {
              tag: 'Dog',
              label: 'Dog',
              schemaName: 'Dog',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'breed',
                  label: 'Breed',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'level',
                  label: 'Level',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'hp',
                  label: 'Hp',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'mp',
                  label: 'Mp',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'attack',
                  label: 'Attack',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'defense',
                  label: 'Defense',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'owner_id',
                  label: 'Owner Id',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                  ref: {
                    resource: 'character',
                    type: 'revision_id',
                  },
                },
              ],
            },
          ],
        },
      },
      {
        name: 'status',
        label: 'Status',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['completed', 'failed', 'pending', 'processing'],
      },
      {
        name: 'errmsg',
        label: 'Errmsg',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'artifact',
        label: 'Artifact',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'retries',
        label: 'Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'max_retries',
        label: 'Max Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_interval_seconds',
        label: 'Periodic Interval Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_max_runs',
        label: 'Periodic Max Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_runs',
        label: 'Periodic Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'periodic_initial_delay_seconds',
        label: 'Periodic Initial Delay Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'last_heartbeat_at',
        label: 'Last Heartbeat At',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      payload: z.discriminatedUnion('type', [
        z.object({
          type: z.literal('Mount'),
          name: z.string(),
          species: z.string(),
          speed: z.number().int().optional(),
          stamina: z.number().int().optional(),
          owner_id: z.string(),
        }),
        z.object({
          type: z.literal('Dog'),
          name: z.string(),
          breed: z.string(),
          level: z.number().int().optional(),
          hp: z.number().int().optional(),
          mp: z.number().int().optional(),
          attack: z.number().int().optional(),
          defense: z.number().int().optional(),
          owner_id: z.string(),
        }),
      ]),
      status: z.any().optional(),
      errmsg: z.string().nullable().optional(),
      artifact: z.record(z.string(), z.any()).nullable().optional(),
      retries: z.number().int().optional(),
      max_retries: z.number().int().nullable().optional(),
      periodic_interval_seconds: z.number().int().nullable().optional(),
      periodic_max_runs: z.number().int().nullable().optional(),
      periodic_runs: z.number().int().optional(),
      periodic_initial_delay_seconds: z.number().int().nullable().optional(),
      last_heartbeat_at: z.string().nullable().optional(),
    }),
    apiClient: petJobApi,
    maxFormDepth: 1,
    defaultHiddenFields: [
      'status',
      'errmsg',
      'artifact',
      'retries',
      'max_retries',
      'periodic_interval_seconds',
      'periodic_max_runs',
      'periodic_runs',
      'periodic_initial_delay_seconds',
      'last_heartbeat_at',
    ],
    isJob: true,
  },
  quest: {
    name: 'quest',
    label: 'Quest',
    pluralLabel: 'Quests',
    displayNameField: 'title',
    schema: 'Quest',
    fields: [
      {
        name: 'title',
        label: 'Title',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
        isUnique: true,
      },
      {
        name: 'description',
        label: 'Description',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'level_requirement',
        label: 'Level Requirement',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'difficulty',
        label: 'Difficulty',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'quest_config',
        label: 'Quest Config',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'rewards',
        label: 'Rewards',
        type: 'union',
        isArray: true,
        isRequired: false,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'type',
          variants: [
            {
              tag: 'QuestRewardItem',
              label: 'QuestRewardItem',
              schemaName: 'QuestRewardItem',
              fields: [
                {
                  name: 'item_name',
                  label: 'Item Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'quantity',
                  label: 'Quantity',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'extra_properties',
                  label: 'Extra Properties',
                  type: 'object',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'QuestRewardGold',
              label: 'QuestRewardGold',
              schemaName: 'QuestRewardGold',
              fields: [
                {
                  name: 'amount',
                  label: 'Amount',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'QuestRewardExp',
              label: 'QuestRewardExp',
              schemaName: 'QuestRewardExp',
              fields: [
                {
                  name: 'exp',
                  label: 'Exp',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'bonus_config',
                  label: 'Bonus Config',
                  type: 'object',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
          ],
        },
      },
    ],
    zodSchema: z.object({
      title: z.string(),
      description: z.string().optional(),
      level_requirement: z.number().int().optional(),
      difficulty: z.string().optional(),
      quest_config: z.record(z.string(), z.any()).optional(),
      rewards: z
        .array(
          z.discriminatedUnion('type', [
            z.object({
              type: z.literal('QuestRewardItem'),
              item_name: z.string(),
              quantity: z.number().int().optional(),
              extra_properties: z.record(z.string(), z.any()).optional(),
            }),
            z.object({ type: z.literal('QuestRewardGold'), amount: z.number().int().optional() }),
            z.object({
              type: z.literal('QuestRewardExp'),
              exp: z.number().int().optional(),
              bonus_config: z.record(z.string(), z.any()).optional(),
            }),
          ]),
        )
        .optional(),
    }),
    apiClient: questApi,
    maxFormDepth: 1,
    indexedFields: ['title', 'level_requirement', 'difficulty'],
  },
  'game-event': {
    name: 'game-event',
    label: 'Game Event',
    pluralLabel: 'Game Events',
    schema: 'GameEvent',
    fields: [
      {
        name: 'payload.event_type',
        label: 'Event Type',
        isArray: false,
        isRequired: true,
        isNullable: false,
        enumValues: [
          'daily_login',
          'equipment_enhance',
          'guild_reward',
          'level_up',
          'quest_complete',
          'raid_boss',
          'server_maintenance',
        ],
      },
      {
        name: 'payload.character_name',
        label: 'Character Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.character_id',
        label: 'Character Id',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: true,
        ref: {
          resource: 'character',
          type: 'revision_id',
        },
      },
      {
        name: 'payload.description',
        label: 'Description',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.reward_gold',
        label: 'Reward Gold',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.reward_exp',
        label: 'Reward Exp',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.extra_data',
        label: 'Extra Data',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.event_body',
        label: 'Event Body',
        type: 'union',
        isArray: false,
        isRequired: false,
        isNullable: true,
        unionMeta: {
          discriminatorField: 'type',
          variants: [
            {
              tag: 'EventBodyA',
              label: 'EventBodyA',
              schemaName: 'EventBodyA',
              fields: [
                {
                  name: 'extra_info_a',
                  label: 'Extra Info A',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'extra_value_a',
                  label: 'Extra Value A',
                  type: 'number',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'EventBodyB',
              label: 'EventBodyB',
              schemaName: 'EventBodyB',
              fields: [
                {
                  name: 'some_field',
                  label: 'Some Field',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'cooldown_seconds',
                  label: 'Cooldown Seconds',
                  type: 'number',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
              ],
            },
          ],
        },
      },
      {
        name: 'payload.event_x.type',
        label: 'Type',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['EventBodyX'],
        constValue: 'EventBodyX',
      },
      {
        name: 'payload.event_x.good',
        label: 'Good',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.event_x.great',
        label: 'Great',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.extra_values',
        label: 'Extra Values',
        type: 'object',
        isArray: true,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'status',
        label: 'Status',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['completed', 'failed', 'pending', 'processing'],
      },
      {
        name: 'errmsg',
        label: 'Errmsg',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'artifact.process_times',
        label: 'Process Times',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'retries',
        label: 'Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'max_retries',
        label: 'Max Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_interval_seconds',
        label: 'Periodic Interval Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_max_runs',
        label: 'Periodic Max Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_runs',
        label: 'Periodic Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'periodic_initial_delay_seconds',
        label: 'Periodic Initial Delay Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'last_heartbeat_at',
        label: 'Last Heartbeat At',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      payload: z
        .object({
          event_x: z
            .object({
              type: z.literal('EventBodyX').optional(),
              good: z.string().optional(),
              great: z.number().int().optional(),
            })
            .nullable()
            .optional(),
          event_type: z.any(),
          character_name: z.string(),
          character_id: z.string().nullable(),
          description: z.string(),
          reward_gold: z.number().int().optional(),
          reward_exp: z.number().int().optional(),
          extra_data: z.record(z.string(), z.any()).optional(),
          event_body: z
            .discriminatedUnion('type', [
              z.object({
                type: z.literal('EventBodyA'),
                extra_info_a: z.string(),
                extra_value_a: z.number().int(),
              }),
              z.object({
                type: z.literal('EventBodyB'),
                some_field: z.string(),
                cooldown_seconds: z.number().int(),
              }),
            ])
            .nullable()
            .optional(),
          extra_values: z.array(z.any()).optional(),
        })
        .nullable()
        .optional(),
      artifact: z
        .object({
          process_times: z.number().optional(),
        })
        .nullable()
        .optional(),
      status: z.any().optional(),
      errmsg: z.string().nullable().optional(),
      retries: z.number().int().optional(),
      max_retries: z.number().int().nullable().optional(),
      periodic_interval_seconds: z.number().int().nullable().optional(),
      periodic_max_runs: z.number().int().nullable().optional(),
      periodic_runs: z.number().int().optional(),
      periodic_initial_delay_seconds: z.number().int().nullable().optional(),
      last_heartbeat_at: z.string().nullable().optional(),
    }),
    apiClient: gameEventApi,
    maxFormDepth: 3,
    indexedFields: ['status', 'retries'],
    defaultHiddenFields: [
      'status',
      'errmsg',
      'artifact.process_times',
      'retries',
      'max_retries',
      'periodic_interval_seconds',
      'periodic_max_runs',
      'periodic_runs',
      'periodic_initial_delay_seconds',
      'last_heartbeat_at',
    ],
    isJob: true,
  },
  'new-char1-job': {
    name: 'new-char1-job',
    label: 'New Char1 Job',
    pluralLabel: 'New Char1 Jobs',
    schema: 'NewCharacterJob',
    fields: [
      {
        name: 'payload.name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'status',
        label: 'Status',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['completed', 'failed', 'pending', 'processing'],
      },
      {
        name: 'errmsg',
        label: 'Errmsg',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'artifact',
        label: 'Artifact',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'retries',
        label: 'Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'max_retries',
        label: 'Max Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_interval_seconds',
        label: 'Periodic Interval Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_max_runs',
        label: 'Periodic Max Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_runs',
        label: 'Periodic Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'periodic_initial_delay_seconds',
        label: 'Periodic Initial Delay Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'last_heartbeat_at',
        label: 'Last Heartbeat At',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      payload: z.object({
        name: z.string(),
      }),
      status: z.any().optional(),
      errmsg: z.string().nullable().optional(),
      artifact: z.record(z.string(), z.any()).nullable().optional(),
      retries: z.number().int().optional(),
      max_retries: z.number().int().nullable().optional(),
      periodic_interval_seconds: z.number().int().nullable().optional(),
      periodic_max_runs: z.number().int().nullable().optional(),
      periodic_runs: z.number().int().optional(),
      periodic_initial_delay_seconds: z.number().int().nullable().optional(),
      last_heartbeat_at: z.string().nullable().optional(),
    }),
    apiClient: newChar1JobApi,
    maxFormDepth: 2,
    indexedFields: ['status', 'retries'],
    defaultHiddenFields: [
      'status',
      'errmsg',
      'artifact',
      'retries',
      'max_retries',
      'periodic_interval_seconds',
      'periodic_max_runs',
      'periodic_runs',
      'periodic_initial_delay_seconds',
      'last_heartbeat_at',
    ],
    isJob: true,
    tableConfig: { canCreate: false },
  },
  'create-new-character2-job': {
    name: 'create-new-character2-job',
    label: 'Create New Character2 Job',
    pluralLabel: 'Create New Character2 Jobs',
    schema: 'CreateNewCharacter2CharacterJob',
    fields: [
      {
        name: 'payload.name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'status',
        label: 'Status',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['completed', 'failed', 'pending', 'processing'],
      },
      {
        name: 'errmsg',
        label: 'Errmsg',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'artifact',
        label: 'Artifact',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'retries',
        label: 'Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'max_retries',
        label: 'Max Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_interval_seconds',
        label: 'Periodic Interval Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_max_runs',
        label: 'Periodic Max Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_runs',
        label: 'Periodic Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'periodic_initial_delay_seconds',
        label: 'Periodic Initial Delay Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'last_heartbeat_at',
        label: 'Last Heartbeat At',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      payload: z.object({
        name: z.string(),
      }),
      status: z.any().optional(),
      errmsg: z.string().nullable().optional(),
      artifact: z.record(z.string(), z.any()).nullable().optional(),
      retries: z.number().int().optional(),
      max_retries: z.number().int().nullable().optional(),
      periodic_interval_seconds: z.number().int().nullable().optional(),
      periodic_max_runs: z.number().int().nullable().optional(),
      periodic_runs: z.number().int().optional(),
      periodic_initial_delay_seconds: z.number().int().nullable().optional(),
      last_heartbeat_at: z.string().nullable().optional(),
    }),
    apiClient: createNewCharacter2JobApi,
    maxFormDepth: 2,
    indexedFields: ['status', 'retries'],
    defaultHiddenFields: [
      'status',
      'errmsg',
      'artifact',
      'retries',
      'max_retries',
      'periodic_interval_seconds',
      'periodic_max_runs',
      'periodic_runs',
      'periodic_initial_delay_seconds',
      'last_heartbeat_at',
    ],
    isJob: true,
    tableConfig: { canCreate: false },
  },
  'create-new-character4-job': {
    name: 'create-new-character4-job',
    label: 'Create New Character4 Job',
    pluralLabel: 'Create New Character4 Jobs',
    schema: 'CreateNewCharacter4CharacterJob',
    fields: [
      {
        name: 'payload.x',
        label: 'X',
        type: 'union',
        isArray: false,
        isRequired: true,
        isNullable: false,
        unionMeta: {
          discriminatorField: '__type',
          variants: [
            {
              tag: 'number',
              label: 'Number',
              type: 'number',
            },
            {
              tag: 'string',
              label: 'String',
              type: 'string',
            },
          ],
        },
      },
      {
        name: 'payload.y',
        label: 'Y',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.name',
        label: 'Name',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.z.binary',
        label: 'Binary',
        type: 'binary',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.z.filename',
        label: 'Filename',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'payload.f.skname',
        label: 'Skname',
        type: 'string',
        isArray: false,
        isRequired: true,
        isNullable: false,
      },
      {
        name: 'payload.f.detail',
        label: 'Detail',
        type: 'union',
        isArray: false,
        isRequired: true,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'skill_type',
          variants: [
            {
              tag: 'active',
              label: 'Active',
              schemaName: 'autocrud_resource_manager_pydantic_converter_ActiveSkillData',
              fields: [
                {
                  name: 'mp_cost',
                  label: 'Mp Cost',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'cooldown_seconds',
                  label: 'Cooldown Seconds',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'damage',
                  label: 'Damage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'passive',
              label: 'Passive',
              schemaName: 'autocrud_resource_manager_pydantic_converter_PassiveSkillData',
              fields: [
                {
                  name: 'buff_percentage',
                  label: 'Buff Percentage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
            {
              tag: 'ultimate',
              label: 'Ultimate',
              schemaName: 'autocrud_resource_manager_pydantic_converter_UltimateSkillData',
              fields: [
                {
                  name: 'mp_cost',
                  label: 'Mp Cost',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'cooldown_seconds',
                  label: 'Cooldown Seconds',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'damage',
                  label: 'Damage',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'area_of_effect',
                  label: 'Area Of Effect',
                  type: 'boolean',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
              ],
            },
          ],
        },
      },
      {
        name: 'payload.f.description',
        label: 'Description',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.f.required_level',
        label: 'Required Level',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'payload.f.required_class',
        label: 'Required Class',
        isArray: false,
        isRequired: false,
        isNullable: true,
        enumValues: ['⚔️ 戰士', '🏹 弓箭手', '💾 數據守護者', '🔮 法師'],
      },
      {
        name: 'status',
        label: 'Status',
        isArray: false,
        isRequired: false,
        isNullable: false,
        enumValues: ['completed', 'failed', 'pending', 'processing'],
      },
      {
        name: 'errmsg',
        label: 'Errmsg',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'artifact',
        label: 'Artifact',
        type: 'object',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'retries',
        label: 'Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'max_retries',
        label: 'Max Retries',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_interval_seconds',
        label: 'Periodic Interval Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_max_runs',
        label: 'Periodic Max Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'periodic_runs',
        label: 'Periodic Runs',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: false,
      },
      {
        name: 'periodic_initial_delay_seconds',
        label: 'Periodic Initial Delay Seconds',
        type: 'number',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
      {
        name: 'last_heartbeat_at',
        label: 'Last Heartbeat At',
        type: 'string',
        isArray: false,
        isRequired: false,
        isNullable: true,
      },
    ],
    zodSchema: z.object({
      payload: z.object({
        z: z.object({
          binary: z.any(),
          filename: z.string().nullable().optional(),
        }),
        f: z.object({
          skname: z.string(),
          detail: z.discriminatedUnion('skill_type', [
            z.object({
              skill_type: z.literal('active'),
              mp_cost: z.number().int().optional(),
              cooldown_seconds: z.number().int().optional(),
              damage: z.number().int().optional(),
            }),
            z.object({
              skill_type: z.literal('passive'),
              buff_percentage: z.number().int().optional(),
            }),
            z.object({
              skill_type: z.literal('ultimate'),
              mp_cost: z.number().int().optional(),
              cooldown_seconds: z.number().int().optional(),
              damage: z.number().int().optional(),
              area_of_effect: z.boolean().optional(),
            }),
          ]),
          description: z.string().optional(),
          required_level: z.number().int().optional(),
          required_class: z.any().nullable().optional(),
        }),
        x: z.union([z.number(), z.string()]),
        y: z.string(),
        name: z.string(),
      }),
      status: z.any().optional(),
      errmsg: z.string().nullable().optional(),
      artifact: z.record(z.string(), z.any()).nullable().optional(),
      retries: z.number().int().optional(),
      max_retries: z.number().int().nullable().optional(),
      periodic_interval_seconds: z.number().int().nullable().optional(),
      periodic_max_runs: z.number().int().nullable().optional(),
      periodic_runs: z.number().int().optional(),
      periodic_initial_delay_seconds: z.number().int().nullable().optional(),
      last_heartbeat_at: z.string().nullable().optional(),
    }),
    apiClient: createNewCharacter4JobApi,
    maxFormDepth: 3,
    indexedFields: ['status', 'retries'],
    defaultHiddenFields: [
      'status',
      'errmsg',
      'artifact',
      'retries',
      'max_retries',
      'periodic_interval_seconds',
      'periodic_max_runs',
      'periodic_runs',
      'periodic_initial_delay_seconds',
      'last_heartbeat_at',
    ],
    isJob: true,
    tableConfig: { canCreate: false },
  },
  pet: {
    name: 'pet',
    label: 'Pet',
    pluralLabel: 'Pets',
    schema: 'Pet',
    fields: [
      {
        name: 'data',
        label: 'Pet',
        type: 'union',
        isArray: false,
        isRequired: true,
        isNullable: false,
        unionMeta: {
          discriminatorField: 'type',
          variants: [
            {
              tag: 'Mount',
              label: 'Mount',
              schemaName: 'Mount',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'species',
                  label: 'Species',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'speed',
                  label: 'Speed',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'stamina',
                  label: 'Stamina',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'owner_id',
                  label: 'Owner Id',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                  ref: {
                    resource: 'character',
                    type: 'revision_id',
                  },
                },
              ],
            },
            {
              tag: 'Dog',
              label: 'Dog',
              schemaName: 'Dog',
              fields: [
                {
                  name: 'name',
                  label: 'Name',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'breed',
                  label: 'Breed',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                },
                {
                  name: 'level',
                  label: 'Level',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'hp',
                  label: 'Hp',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'mp',
                  label: 'Mp',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'attack',
                  label: 'Attack',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'defense',
                  label: 'Defense',
                  type: 'number',
                  isArray: false,
                  isRequired: false,
                  isNullable: false,
                },
                {
                  name: 'owner_id',
                  label: 'Owner Id',
                  type: 'string',
                  isArray: false,
                  isRequired: true,
                  isNullable: false,
                  ref: {
                    resource: 'character',
                    type: 'revision_id',
                  },
                },
              ],
            },
          ],
        },
      },
    ],
    zodSchema: z.object({
      data: z.discriminatedUnion('type', [
        z.object({
          type: z.literal('Mount'),
          name: z.string(),
          species: z.string(),
          speed: z.number().int().optional(),
          stamina: z.number().int().optional(),
          owner_id: z.string(),
        }),
        z.object({
          type: z.literal('Dog'),
          name: z.string(),
          breed: z.string(),
          level: z.number().int().optional(),
          hp: z.number().int().optional(),
          mp: z.number().int().optional(),
          attack: z.number().int().optional(),
          defense: z.number().int().optional(),
          owner_id: z.string(),
        }),
      ]),
    }),
    apiClient: petApi,
    maxFormDepth: 1,
    isUnion: true,
  },
});

import { asyncCreateJobs } from '../lib/resources';
Object.assign(asyncCreateJobs, {
  'new-char1-job': 'character',
  'create-new-character2-job': 'character',
  'create-new-character4-job': 'character',
});

/**
 * Apply type-safe customizations to the generated resources.
 * Call this in main.tsx after the resources are registered.
 */
export function applyCustomizations(customizations: ResourceCustomizations): void {
  applyCustomizationsImpl(customizations);
}

export { registry as resources };
