Skip to content

Results

napt.results

Public API return types for NAPT.

This module defines dataclasses for return values from public API functions. These types represent the results of operations like discovery, building, packaging, and validation.

All dataclasses are frozen (immutable) to prevent accidental mutation of return values.

Example

Using result types:

from pathlib import Path
from napt.core import discover_recipe
from napt.results import DiscoverResult

result: DiscoverResult = discover_recipe(
    Path("recipes/Google/chrome.yaml"),
    Path("./downloads")
)
print(result.version)  # Attribute access, not dict access

Note

Only public API return types belong in this module. Domain types (like DiscoveredVersion) and internal types (like LoadContext) should remain co-located with their related logic.

DownloadResult dataclass

Result of a file download operation.

Attributes:

Name Type Description
file_path Path

Path to the downloaded file.

sha256 str

SHA-256 hex digest of the downloaded file.

headers dict

HTTP response headers from the download.

Source code in napt/results.py
@dataclass(frozen=True)
class DownloadResult:
    """Result of a file download operation.

    Attributes:
        file_path: Path to the downloaded file.
        sha256: SHA-256 hex digest of the downloaded file.
        headers: HTTP response headers from the download.
    """

    file_path: Path
    sha256: str
    headers: dict

DiscoverResult dataclass

Result from discovering a version and downloading an installer.

Attributes:

Name Type Description
app_name str

Application display name.

app_id str

Unique application identifier.

strategy str

Discovery strategy used (e.g., "web_scrape", "api_github").

version str

Extracted version string.

version_source str

How version was determined (e.g., "regex_in_url", "msi").

file_path Path

Path to the downloaded installer file.

sha256 str

SHA-256 hash of the downloaded file.

status str

Always "success" for successful discovery.

Source code in napt/results.py
@dataclass(frozen=True)
class DiscoverResult:
    """Result from discovering a version and downloading an installer.

    Attributes:
        app_name: Application display name.
        app_id: Unique application identifier.
        strategy: Discovery strategy used (e.g., "web_scrape", "api_github").
        version: Extracted version string.
        version_source: How version was determined (e.g., "regex_in_url", "msi").
        file_path: Path to the downloaded installer file.
        sha256: SHA-256 hash of the downloaded file.
        status: Always "success" for successful discovery.
    """

    app_name: str
    app_id: str
    strategy: str
    version: str
    version_source: str
    file_path: Path
    sha256: str
    status: str

BuildResult dataclass

Result from building a PSADT package.

Attributes:

Name Type Description
app_id str

Unique application identifier.

app_name str

Application display name.

version str

Application version.

build_dir Path

Path to the build directory (packagefiles subdirectory).

psadt_version str

PSADT version used for the build.

status str

Build status (typically "success").

build_types str

The build types setting used ("both", "app_only", or "update_only").

detection_script_path Path | None

Path to the generated detection script.

requirements_script_path Path | None

Path to the generated requirements script, if created. None if build_types is "app_only".

Source code in napt/results.py
@dataclass(frozen=True)
class BuildResult:
    """Result from building a PSADT package.

    Attributes:
        app_id: Unique application identifier.
        app_name: Application display name.
        version: Application version.
        build_dir: Path to the build directory (packagefiles subdirectory).
        psadt_version: PSADT version used for the build.
        status: Build status (typically "success").
        build_types: The build types setting used ("both", "app_only", or
            "update_only").
        detection_script_path: Path to the generated detection script.
        requirements_script_path: Path to the generated requirements script, if
            created. None if build_types is "app_only".
    """

    app_id: str
    app_name: str
    version: str
    build_dir: Path
    psadt_version: str
    status: str
    build_types: str
    detection_script_path: Path | None = None
    requirements_script_path: Path | None = None

PackageResult dataclass

Result from creating a .intunewin package.

Attributes:

Name Type Description
build_dir Path

Path to the build directory.

package_path Path

Path to the created .intunewin file.

app_id str

Unique application identifier.

version str

Application version.

status str

Packaging status (typically "success").

Source code in napt/results.py
@dataclass(frozen=True)
class PackageResult:
    """Result from creating a .intunewin package.

    Attributes:
        build_dir: Path to the build directory.
        package_path: Path to the created .intunewin file.
        app_id: Unique application identifier.
        version: Application version.
        status: Packaging status (typically "success").
    """

    build_dir: Path
    package_path: Path
    app_id: str
    version: str
    status: str

UploadResult dataclass

Result from uploading a .intunewin package to Microsoft Intune.

Attributes:

Name Type Description
app_id str

Unique application identifier (from recipe).

app_name str

Application display name.

version str

Application version uploaded.

intune_app_id str

Graph API object ID of the newly created Intune Win32 app.

package_path Path

Path to the uploaded .intunewin file.

status str

Always "success" for successful uploads.

Source code in napt/results.py
@dataclass(frozen=True)
class UploadResult:
    """Result from uploading a .intunewin package to Microsoft Intune.

    Attributes:
        app_id: Unique application identifier (from recipe).
        app_name: Application display name.
        version: Application version uploaded.
        intune_app_id: Graph API object ID of the newly created Intune Win32 app.
        package_path: Path to the uploaded .intunewin file.
        status: Always "success" for successful uploads.
    """

    app_id: str
    app_name: str
    version: str
    intune_app_id: str
    package_path: Path
    status: str

ValidationResult dataclass

Result from validating a recipe.

Attributes:

Name Type Description
status str

Validation status ("valid" or "invalid").

errors list[str]

List of error messages (empty if valid).

warnings list[str]

List of warning messages.

app_count int

Number of apps in the recipe.

recipe_path str

String path to the validated recipe file.

Source code in napt/results.py
@dataclass(frozen=True)
class ValidationResult:
    """Result from validating a recipe.

    Attributes:
        status: Validation status ("valid" or "invalid").
        errors: List of error messages (empty if valid).
        warnings: List of warning messages.
        app_count: Number of apps in the recipe.
        recipe_path: String path to the validated recipe file.
    """

    status: str
    errors: list[str]
    warnings: list[str]
    app_count: int
    recipe_path: str