// 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 { 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 { gameEventApi } from './api/game-eventApi';
import { petApi } from './api/petApi';

/** Union type of all resource names */
export type ResourceName = 'character' | 'guild' | 'skill' | 'equipment' | 'pet-job' | 'game-event' | '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' | 'retries' | 'periodic_interval_seconds' | 'periodic_max_runs' | 'periodic_runs' | 'periodic_initial_delay_seconds';
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.aa' | 'status' | 'errmsg' | 'retries' | 'periodic_interval_seconds' | 'periodic_max_runs' | 'periodic_runs' | 'periodic_initial_delay_seconds';
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;
  'game-event': GameEventFieldName;
  '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/game-event/$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/game-event'
  | '/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',
  'game-event': '/autocrud-admin/game-event/$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',
  'game-event': '/autocrud-admin/game-event',
  '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.enum(["⚔️ 戰士", "🏹 弓箭手", "💾 數據守護者", "🔮 法師"]),
    valueAD__x: z.union([z.number().int(), 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.enum(["傳奇", "史詩", "普通", "稀有", "🚀 AutoCRUD 神器"]), owner_id: z.string().nullable().optional(), character_class_req: z.enum(["⚔️ 戰士", "🏹 弓箭手", "💾 數據守護者", "🔮 法師"]).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,
    customCreateActions: [
      {
        name: 'new',
        label: 'New Character1',
        fields: [
          {
                    name: "name",
                    label: "Name",
                    type: "string",
                    isArray: false,
                    isRequired: true,
                    isNullable: false
          }
],
        zodSchema: z.object({
    name: z.string()
        }),
        apiMethod: characterApi.createNewCharacter1,
      },
      {
        name: 'create-new-character2',
        label: 'New Character2',
        fields: [
          {
                    name: "name",
                    label: "Name",
                    type: "string",
                    isArray: false,
                    isRequired: true,
                    isNullable: false
          }
],
        zodSchema: z.object({
    name: z.string()
        }),
        apiMethod: characterApi.createNewCharacter2,
      },
      {
        name: 'create-new-character4',
        label: 'New Character3',
        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: "type",
                              variants: [
                                        {
                                                  tag: "active",
                                                  label: "Active",
                                                  schemaName: "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: "PassiveSkillData",
                                                  fields: [
                                                            {
                                                                      name: "buff_percentage",
                                                                      label: "Buff Percentage",
                                                                      type: "number",
                                                                      isArray: false,
                                                                      isRequired: false,
                                                                      isNullable: false
                                                            }
                                                  ]
                                        },
                                        {
                                                  tag: "ultimate",
                                                  label: "Ultimate",
                                                  schemaName: "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('type', [z.object({ type: z.literal('active'), mp_cost: z.number().int().optional(), cooldown_seconds: z.number().int().optional(), damage: z.number().int().optional() }), z.object({ type: z.literal('passive'), buff_percentage: z.number().int().optional() }), z.object({ 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.enum(["⚔️ 戰士", "🏹 弓箭手", "💾 數據守護者", "🔮 法師"]).nullable().optional()
        }),
        apiMethod: characterApi.createNewCharacter4,
      }
    ],
  },
  '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: "type",
                  variants: [
                        {
                              tag: "active",
                              label: "Active",
                              schemaName: "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: "PassiveSkillData",
                              fields: [
                                    {
                                          name: "buff_percentage",
                                          label: "Buff Percentage",
                                          type: "number",
                                          isArray: false,
                                          isRequired: false,
                                          isNullable: false
                                    }
                              ]
                        },
                        {
                              tag: "ultimate",
                              label: "Ultimate",
                              schemaName: "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('type', [z.object({ type: z.literal('active'), mp_cost: z.number().int().optional(), cooldown_seconds: z.number().int().optional(), damage: z.number().int().optional() }), z.object({ type: z.literal('passive'), buff_percentage: z.number().int().optional() }), z.object({ 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.enum(["⚔️ 戰士", "🏹 弓箭手", "💾 數據守護者", "🔮 法師"]).nullable().optional()
    }),
    apiClient: skillApi,
    maxFormDepth: 1,
  },
  '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.enum(["傳奇", "史詩", "普通", "稀有", "🚀 AutoCRUD 神器"]),
    owner_id: z.string().nullable().optional(),
    character_class_req: z.enum(["⚔️ 戰士", "🏹 弓箭手", "💾 數據守護者", "🔮 法師"]).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,
  },
  'pet-job': {
    name: 'pet-job',
    label: 'Pet Job',
    pluralLabel: 'Pet Jobs',
    schema: 'Job___main___Mount_____main___Dog_',
    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: "resource_id",
                                                onDelete: "set_null"
                                          }
                                    }
                              ]
                        },
                        {
                              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: "resource_id",
                                                onDelete: "set_null"
                                          }
                                    }
                              ]
                        }
                  ]
            }
      },
      {
            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: "retries",
            label: "Retries",
            type: "number",
            isArray: false,
            isRequired: false,
            isNullable: false
      },
      {
            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
      }
],
    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.enum(["completed", "failed", "pending", "processing"]).optional(),
    errmsg: z.string().nullable().optional(),
    retries: z.number().int().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()
    }),
    apiClient: petJobApi,
    maxFormDepth: 1,
    defaultHiddenFields: ["status","errmsg","retries","periodic_interval_seconds","periodic_max_runs","periodic_runs","periodic_initial_delay_seconds"],
  },
  '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
                                    },
                                    {
                                          name: "content",
                                          label: "Content",
                                          type: "binary",
                                          isArray: false,
                                          isRequired: true,
                                          isNullable: true
                                    }
                              ]
                        },
                        {
                              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: true,
            isNullable: false,
            enumValues: [
                  "EventBodyX"
            ],
            constValue: "EventBodyX"
      },
      {
            name: "payload.event_x.good",
            label: "Good",
            type: "string",
            isArray: false,
            isRequired: true,
            isNullable: false
      },
      {
            name: "payload.event_x.great",
            label: "Great",
            type: "number",
            isArray: false,
            isRequired: true,
            isNullable: false
      },
      {
            name: "payload.aa",
            label: "Aa",
            type: "number",
            isArray: false,
            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: "retries",
            label: "Retries",
            type: "number",
            isArray: false,
            isRequired: false,
            isNullable: false
      },
      {
            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
      }
],
    zodSchema: z.object({
    payload: z.object({
        event_x: z.object({
            type: z.literal('EventBodyX'),
            good: z.string(),
            great: z.number().int()
        }),
        event_type: z.enum(["daily_login", "equipment_enhance", "guild_reward", "level_up", "quest_complete", "raid_boss", "server_maintenance"]),
        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(), content: z.any().nullable() }), z.object({ type: z.literal('EventBodyB'), some_field: z.string(), cooldown_seconds: z.number().int() })]).nullable().optional(),
        aa: z.union([z.number().int(), z.number()]).optional()
    }),
    status: z.enum(["completed", "failed", "pending", "processing"]).optional(),
    errmsg: z.string().nullable().optional(),
    retries: z.number().int().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()
    }),
    apiClient: gameEventApi,
    maxFormDepth: 3,
    defaultHiddenFields: ["status","errmsg","retries","periodic_interval_seconds","periodic_max_runs","periodic_runs","periodic_initial_delay_seconds"],
  },
  '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: "resource_id",
                                                onDelete: "set_null"
                                          }
                                    }
                              ]
                        },
                        {
                              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: "resource_id",
                                                onDelete: "set_null"
                                          }
                                    }
                              ]
                        }
                  ]
            }
      }
],
    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,
  }
});

/**
 * 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 };
