from typing import NotRequired, List, Any, Dict

from debputy.manifest_parser.base_types import DebputyParsedContent, OctalMode
from debputy.manifest_parser.declarative_parser import parser_from_typed_dict


class PackagerProvidedFileJsonDescription(DebputyParsedContent):
    stem: str
    installed_path: str
    default_mode: NotRequired[OctalMode]
    default_priority: NotRequired[int]
    allow_name_segment: NotRequired[bool]
    allow_architecture_segment: NotRequired[bool]


class ManifestVariableJsonDescription(DebputyParsedContent):
    name: str
    value: str
    reference_documentation: NotRequired[str]


class PluginJsonMetadata(DebputyParsedContent):
    api_compat_version: int
    module: NotRequired[str]
    plugin_initializer: NotRequired[str]
    packager_provided_files: NotRequired[List[Any]]
    manifest_variables: NotRequired[List[Any]]


PLUGIN_METADATA_PARSER = parser_from_typed_dict(PluginJsonMetadata)
PLUGIN_PPF_PARSER = parser_from_typed_dict(PackagerProvidedFileJsonDescription)
PLUGIN_MANIFEST_VARS_PARSER = parser_from_typed_dict(ManifestVariableJsonDescription)
