# jl-automation-common-modules

Shared Python library for all JobLogic automation projects. Provides reusable managers, handlers, and decorators used across Azure Function-based automations.

---

## Installation

```bash
pip install jl-automation-common-modules
```

Or pin directly from the Git repo (for internal use):

```txt
jl-automation-common-modules @ git+https://JobLogic@dev.azure.com/JobLogic/JobLogic%20Automations/_git/joblogic-automation-modules@v1.0.0
```

---

## Requirements

- Python 3.11+

---

## Available Modules

| Import | Purpose |
|---|---|
| `AutomationManager` | Base class for all automation Azure Functions |
| `SqlManager` | Async SQL Server connection management via `aioodbc` |
| `AuditManager` / `AuditData` | Structured audit logging |
| `MainSubSysApiManager` | HTTP client for the JobLogic main subsystem API |
| `CommonManager` / `ExecutionResult` | Shared execution helpers and result model |
| `SharePointManager` | SharePoint file and list operations via Microsoft Graph |
| `Configurations` | Azure App Configuration client |
| `slack_notification` | Decorator to post execution results to Slack |
| `teams_notification` | Decorator to post execution results to Teams |

---

## Quick Start

```python
from joblogic_automation_modules import AutomationManager, ExecutionResult
from joblogic_automation_modules import slack_notification, teams_notification

class MyAutomation(AutomationManager):

    @slack_notification()
    @teams_notification()
    async def start_processing(self, *args, **kwargs) -> ExecutionResult:
        # Lazy-loaded managers available on self:
        # self.db          → SqlManager
        # self.api         → MainSubSysApiManager
        # self.audit       → AuditManager
        # self.common      → CommonManager
        # self.sharepoint  → SharePointManager
        # self.config      → Configurations

        data = await self.common.get_reliable_report_data(report_id=123)

        return ExecutionResult(
            execution_time=await self.common.get_last_exec_time(),
            read_count=len(data),
            create_count=0,
            update_count=0,
            failure_count=0,
        )
```

---

## Versioning

This package follows [Semantic Versioning](https://semver.org/):

| Change type | Version bump |
|---|---|
| Bug fix | PATCH (`1.0.0 → 1.0.1`) |
| New feature (backwards compatible) | MINOR (`1.0.0 → 1.1.0`) |
| Breaking change | MAJOR (`1.0.0 → 2.0.0`) |

See [PUBLISHING.md](PUBLISHING.md) for release instructions.

---

## Contributing

For publishing a new version, see [PUBLISHING.md](PUBLISHING.md).  
For using this package in an automation repo, see [USAGE.md](USAGE.md).
