nui-lambda-shared-utils 1.0.2__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nui_lambda_shared_utils-1.1.0/.editorconfig +23 -0
- nui_lambda_shared_utils-1.1.0/.markdownlint-cli2.yaml +47 -0
- nui_lambda_shared_utils-1.1.0/CLAUDE.md +358 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/CONTRIBUTING.md +11 -2
- nui_lambda_shared_utils-1.1.0/PKG-INFO +422 -0
- nui_lambda_shared_utils-1.1.0/README.md +357 -0
- nui_lambda_shared_utils-1.1.0/docs/README.md +162 -0
- nui_lambda_shared_utils-1.1.0/docs/development/testing.md +465 -0
- {nui_lambda_shared_utils-1.0.2/docs → nui_lambda_shared_utils-1.1.0/docs/getting-started}/configuration.md +6 -16
- {nui_lambda_shared_utils-1.0.2/docs → nui_lambda_shared_utils-1.1.0/docs/getting-started}/installation.md +10 -1
- {nui_lambda_shared_utils-1.0.2/docs → nui_lambda_shared_utils-1.1.0/docs/getting-started}/quickstart.md +66 -1
- nui_lambda_shared_utils-1.1.0/docs/guides/cli-tools.md +270 -0
- nui_lambda_shared_utils-1.1.0/docs/guides/powertools-integration.md +593 -0
- nui_lambda_shared_utils-1.1.0/docs/guides/slack-integration.md +497 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/__init__.py +9 -2
- nui_lambda_shared_utils-1.1.0/nui_lambda_shared_utils/cli.py +225 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/db_client.py +2 -107
- nui_lambda_shared_utils-1.1.0/nui_lambda_shared_utils/powertools_helpers.py +240 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_client.py +17 -6
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_formatter.py +3 -21
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_setup/__init__.py +1 -1
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_setup/channel_creator.py +1 -1
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_setup/channel_definitions.py +1 -1
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/slack_setup/setup_helpers.py +4 -4
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils.egg-info/SOURCES.txt +12 -6
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/pyproject.toml +8 -2
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_base_client.py +22 -22
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_db_client.py +0 -79
- nui_lambda_shared_utils-1.1.0/tests/test_powertools_helpers.py +371 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_slack_client.py +136 -2
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_slack_formatter.py +6 -19
- nui_lambda_shared_utils-1.0.2/CLAUDE.md +0 -218
- nui_lambda_shared_utils-1.0.2/PKG-INFO +0 -433
- nui_lambda_shared_utils-1.0.2/README.md +0 -373
- nui_lambda_shared_utils-1.0.2/docs/README.md +0 -115
- nui_lambda_shared_utils-1.0.2/docs/index.md +0 -64
- nui_lambda_shared_utils-1.0.2/docs/slack_config.yaml.template +0 -22
- nui_lambda_shared_utils-1.0.2/nui_lambda_shared_utils/slack_setup_cli.py +0 -194
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/.github/workflows/ci.yml +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/.github/workflows/publish.yml +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/.github/workflows/test.yml +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/LICENSE +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/MANIFEST.in +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/mypy.ini +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/base_client.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/cloudwatch_metrics.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/config.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/error_handler.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/es_client.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/es_query_builder.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/secrets_helper.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/timezone.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/nui_lambda_shared_utils/utils.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/pytest.ini +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/requirements-test.txt +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/setup.cfg +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/setup.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/__init__.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_aws_utils.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_cloudwatch_metrics.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_config.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_error_handler.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_es_client.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_es_query_builder.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_secrets_helper.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_timezone.py +0 -0
- {nui_lambda_shared_utils-1.0.2 → nui_lambda_shared_utils-1.1.0}/tests/test_utils.py +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
|
|
9
|
+
[*.py]
|
|
10
|
+
indent_style = space
|
|
11
|
+
indent_size = 4
|
|
12
|
+
max_line_length = 120
|
|
13
|
+
|
|
14
|
+
[*.{yml,yaml}]
|
|
15
|
+
indent_style = space
|
|
16
|
+
indent_size = 2
|
|
17
|
+
|
|
18
|
+
[*.md]
|
|
19
|
+
trim_trailing_whitespace = false
|
|
20
|
+
max_line_length = off
|
|
21
|
+
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Markdownlint configuration for nui-lambda-shared-utils
|
|
2
|
+
# Extends workspace config with project-specific overrides
|
|
3
|
+
|
|
4
|
+
config:
|
|
5
|
+
# Enable all rules by default
|
|
6
|
+
default: true
|
|
7
|
+
|
|
8
|
+
# MD013: Line length - disabled (technical docs need long lines for URLs/commands)
|
|
9
|
+
MD013: false
|
|
10
|
+
|
|
11
|
+
# MD033: Inline HTML - allowed (needed for complex formatting)
|
|
12
|
+
MD033: false
|
|
13
|
+
|
|
14
|
+
# MD036: No emphasis as heading - disabled (acceptable in planning docs)
|
|
15
|
+
MD036: false
|
|
16
|
+
|
|
17
|
+
# MD040: Fenced code language - disabled (not all code blocks need language tags)
|
|
18
|
+
MD040: false
|
|
19
|
+
|
|
20
|
+
# MD041: First line heading - disabled (docs may start with metadata)
|
|
21
|
+
MD041: false
|
|
22
|
+
|
|
23
|
+
# MD024: Multiple headings with same content - allowed with different levels
|
|
24
|
+
MD024:
|
|
25
|
+
siblings_only: true
|
|
26
|
+
|
|
27
|
+
# MD034: Bare URLs - allowed (sometimes intentional)
|
|
28
|
+
MD034: false
|
|
29
|
+
|
|
30
|
+
# MD046: Code block style - prefer fenced
|
|
31
|
+
MD046:
|
|
32
|
+
style: "fenced"
|
|
33
|
+
|
|
34
|
+
# MD060: Table column style - disabled (minor formatting preference)
|
|
35
|
+
MD060: false
|
|
36
|
+
|
|
37
|
+
# File patterns to check
|
|
38
|
+
globs:
|
|
39
|
+
- "**/*.md"
|
|
40
|
+
|
|
41
|
+
# Exclusions
|
|
42
|
+
ignores:
|
|
43
|
+
- "node_modules/**"
|
|
44
|
+
- "vendor/**"
|
|
45
|
+
- ".git/**"
|
|
46
|
+
- "venv/**"
|
|
47
|
+
- ".venv/**"
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Quick Links
|
|
6
|
+
|
|
7
|
+
📚 **Documentation**: See [docs/README.md](docs/README.md) for comprehensive guides
|
|
8
|
+
|
|
9
|
+
- [Quick Start Guide](docs/getting-started/quickstart.md) - Usage patterns and examples
|
|
10
|
+
- [Configuration Guide](docs/getting-started/configuration.md) - Environment setup and credentials
|
|
11
|
+
- [Slack Integration](docs/guides/slack-integration.md) - Messaging, formatting, and file uploads
|
|
12
|
+
- [Testing Guide](docs/development/testing.md) - Test strategies and coverage
|
|
13
|
+
|
|
14
|
+
🔧 **Development**: Jump to [Development Commands](#development-commands) below
|
|
15
|
+
|
|
16
|
+
## Navigation Guide
|
|
17
|
+
|
|
18
|
+
**Are you...**
|
|
19
|
+
|
|
20
|
+
- 🆕 **New to this package?** → Start with [docs/getting-started/quickstart.md](docs/getting-started/quickstart.md)
|
|
21
|
+
- 🔧 **Contributing code?** → See [Development Commands](#development-commands) below
|
|
22
|
+
- 🧪 **Writing tests?** → See [docs/development/testing.md](docs/development/testing.md)
|
|
23
|
+
- 📦 **Deploying/publishing?** → See [Package Building](#package-building-and-publishing) below
|
|
24
|
+
- 💬 **Integrating Slack?** → See [docs/guides/slack-integration.md](docs/guides/slack-integration.md)
|
|
25
|
+
|
|
26
|
+
## Project Overview
|
|
27
|
+
|
|
28
|
+
This is `nui-lambda-shared-utils`, a Python package providing production-ready utilities for AWS Lambda functions. Built and battle-tested on the NUI platform, it offers standardized integrations for Slack, Elasticsearch, database operations, CloudWatch metrics, and error handling patterns. The package is designed to be generic and configurable for any AWS Lambda environment.
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
### Core Module Structure
|
|
33
|
+
|
|
34
|
+
- **Configuration System** (`config.py`) - Environment-aware configuration with AWS Secrets Manager integration
|
|
35
|
+
- **Secrets Management** (`secrets_helper.py`) - Centralized credential handling with caching
|
|
36
|
+
- **Slack Integration** (`slack_client.py`, `slack_formatter.py`) - Rich messaging, threading, and file uploads
|
|
37
|
+
- **Elasticsearch** (`es_client.py`, `es_query_builder.py`) - Query builders and health monitoring
|
|
38
|
+
- **Database** (`db_client.py`) - Connection pooling with retry logic
|
|
39
|
+
- **Metrics** (`cloudwatch_metrics.py`) - Batched CloudWatch publishing with decorators
|
|
40
|
+
- **Error Handling** (`error_handler.py`) - Retry patterns with exponential backoff
|
|
41
|
+
- **Timezone Utils** (`timezone.py`) - Timezone conversion and formatting utilities
|
|
42
|
+
|
|
43
|
+
### Optional Dependencies
|
|
44
|
+
|
|
45
|
+
The package uses optional extras to minimize Lambda bundle size:
|
|
46
|
+
|
|
47
|
+
- `elasticsearch` - Elasticsearch client and query builders
|
|
48
|
+
- `database` - MySQL/PostgreSQL drivers
|
|
49
|
+
- `slack` - Slack SDK
|
|
50
|
+
- `all` - All integrations
|
|
51
|
+
- `dev` - Development and testing tools
|
|
52
|
+
|
|
53
|
+
### Slack Workspace Automation
|
|
54
|
+
|
|
55
|
+
The `slack_setup/` submodule provides automated Slack workspace configuration:
|
|
56
|
+
|
|
57
|
+
- **Channel Creation** - Programmatic channel and permission setup
|
|
58
|
+
- **Template System** - YAML-based channel definitions
|
|
59
|
+
- **CLI Tool** - `slack-channel-setup` command for automation
|
|
60
|
+
- **Generic Design** - Adaptable for any Slack workspace, not NUI-specific
|
|
61
|
+
|
|
62
|
+
## Design Principles
|
|
63
|
+
|
|
64
|
+
### Keeping the Package Generic
|
|
65
|
+
|
|
66
|
+
This package is intentionally designed to avoid vendor-specific assumptions:
|
|
67
|
+
|
|
68
|
+
**✅ DO:**
|
|
69
|
+
|
|
70
|
+
- Use configurable defaults (e.g., `currency` as required parameter)
|
|
71
|
+
- Accept parameters for service-specific values (e.g., `service_name` in alerts)
|
|
72
|
+
- Provide flexible configuration via environment variables or programmatic setup
|
|
73
|
+
- Keep utility functions generic and reusable
|
|
74
|
+
|
|
75
|
+
**❌ DON'T:**
|
|
76
|
+
|
|
77
|
+
- Hardcode service names, currency codes, or business logic
|
|
78
|
+
- Add domain-specific database query methods (use generic `query()`, `execute()` methods)
|
|
79
|
+
- Create mapping dictionaries for specific organizations (emoji maps, status codes, etc.)
|
|
80
|
+
- Assume specific table schemas or column names
|
|
81
|
+
|
|
82
|
+
**Examples:**
|
|
83
|
+
|
|
84
|
+
- ❌ Hardcoded organization-specific mappings and constants
|
|
85
|
+
- ✅ Accept values as parameters or via configuration
|
|
86
|
+
- ❌ Default values that assume specific geography/currency/timezone
|
|
87
|
+
- ✅ Required parameters or configurable defaults
|
|
88
|
+
- ❌ Database methods that assume specific table schemas
|
|
89
|
+
- ✅ Generic query methods that accept SQL and parameters
|
|
90
|
+
|
|
91
|
+
### When Adding New Features
|
|
92
|
+
|
|
93
|
+
Before adding convenience methods or defaults:
|
|
94
|
+
|
|
95
|
+
1. **Ask**: "Is this specific to NUI, or useful for any Lambda project?"
|
|
96
|
+
2. **Check**: Could this be made configurable rather than hardcoded?
|
|
97
|
+
3. **Test**: Can someone use this without NUI-specific knowledge?
|
|
98
|
+
|
|
99
|
+
If a feature is NUI-specific:
|
|
100
|
+
|
|
101
|
+
- Consider if it belongs in this shared package
|
|
102
|
+
- Document it clearly as an example pattern users can adapt
|
|
103
|
+
- Provide configuration options to override defaults
|
|
104
|
+
|
|
105
|
+
## Development Commands
|
|
106
|
+
|
|
107
|
+
### Environment Setup
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Install package in development mode with all dependencies
|
|
111
|
+
pip install -e .[dev]
|
|
112
|
+
|
|
113
|
+
# Install with specific integrations only
|
|
114
|
+
pip install -e .[slack,elasticsearch]
|
|
115
|
+
|
|
116
|
+
# Set up virtual environment
|
|
117
|
+
python -m venv venv
|
|
118
|
+
source venv/bin/activate # Linux/Mac
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Testing
|
|
122
|
+
|
|
123
|
+
**See [docs/development/testing.md](docs/development/testing.md) for comprehensive testing guide**
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Run all tests
|
|
127
|
+
pytest
|
|
128
|
+
|
|
129
|
+
# Run with coverage reporting
|
|
130
|
+
pytest --cov=nui_lambda_shared_utils --cov-report=html
|
|
131
|
+
|
|
132
|
+
# Run only unit tests (skip integration tests requiring AWS)
|
|
133
|
+
pytest -m "not integration"
|
|
134
|
+
|
|
135
|
+
# Run specific test categories
|
|
136
|
+
pytest -m unit # Unit tests only
|
|
137
|
+
pytest -m integration # Integration tests only
|
|
138
|
+
pytest -m slow # Slow tests only
|
|
139
|
+
|
|
140
|
+
# Run single test file
|
|
141
|
+
pytest tests/test_slack_client.py -v
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Code Quality
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Format code with Black (line length: 120)
|
|
148
|
+
black nui_lambda_shared_utils/ tests/
|
|
149
|
+
|
|
150
|
+
# Check formatting without changes
|
|
151
|
+
black --check nui_lambda_shared_utils/
|
|
152
|
+
|
|
153
|
+
# Type checking with MyPy
|
|
154
|
+
mypy nui_lambda_shared_utils/ --config-file mypy.ini
|
|
155
|
+
|
|
156
|
+
# Run linting (currently configured to use Black)
|
|
157
|
+
black --check nui_lambda_shared_utils/
|
|
158
|
+
|
|
159
|
+
# Lint markdown documentation
|
|
160
|
+
npx markdownlint-cli2 '**/*.md'
|
|
161
|
+
|
|
162
|
+
# Auto-fix markdown formatting issues
|
|
163
|
+
npx markdownlint-cli2 --fix '**/*.md'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Package Building and Publishing
|
|
167
|
+
|
|
168
|
+
**See [docs/getting-started/installation.md](docs/getting-started/installation.md) for installation details**
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Build package
|
|
172
|
+
python -m build
|
|
173
|
+
|
|
174
|
+
# Install build tools
|
|
175
|
+
pip install build twine
|
|
176
|
+
|
|
177
|
+
# Publish to PyPI (requires credentials)
|
|
178
|
+
python -m twine upload dist/*
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Configuration Patterns
|
|
182
|
+
|
|
183
|
+
### Environment Variables
|
|
184
|
+
|
|
185
|
+
The package expects these environment variables for runtime configuration:
|
|
186
|
+
|
|
187
|
+
- `ES_HOST` - Elasticsearch endpoint
|
|
188
|
+
- `ES_CREDENTIALS_SECRET` - AWS secret name for ES credentials
|
|
189
|
+
- `DB_CREDENTIALS_SECRET` - AWS secret name for database credentials
|
|
190
|
+
- `SLACK_CREDENTIALS_SECRET` - AWS secret name for Slack token
|
|
191
|
+
- `AWS_REGION` - AWS region for services
|
|
192
|
+
|
|
193
|
+
### AWS Secrets Format
|
|
194
|
+
|
|
195
|
+
Secrets should follow standardized JSON structures:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
// Elasticsearch
|
|
199
|
+
{"host": "elastic:9200", "username": "user", "password": "pass"}
|
|
200
|
+
|
|
201
|
+
// Database
|
|
202
|
+
{"host": "db-host", "port": 3306, "username": "user", "password": "pass", "database": "db"}
|
|
203
|
+
|
|
204
|
+
// Slack
|
|
205
|
+
{"bot_token": "xoxb-...", "webhook_url": "https://hooks.slack.com/..."}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Programmatic Configuration
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
import nui_lambda_shared_utils as nui
|
|
212
|
+
|
|
213
|
+
# Configure specific settings
|
|
214
|
+
nui.configure(
|
|
215
|
+
es_host="localhost:9200",
|
|
216
|
+
slack_credentials_secret="dev/slack-token"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Or use Config object
|
|
220
|
+
config = nui.Config(es_host="prod:9200")
|
|
221
|
+
nui.set_config(config)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Common Usage Patterns
|
|
225
|
+
|
|
226
|
+
For detailed usage examples and integration patterns, see:
|
|
227
|
+
|
|
228
|
+
- **[Quick Start Guide](docs/getting-started/quickstart.md)** - Common usage patterns for all components
|
|
229
|
+
- **[Slack Integration Guide](docs/guides/slack-integration.md)** - Slack messaging, blocks, threading, and file uploads
|
|
230
|
+
- **[Configuration Guide](docs/getting-started/configuration.md)** - Environment setup and AWS Secrets integration
|
|
231
|
+
|
|
232
|
+
### Quick Reference
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
# See docs/getting-started/quickstart.md for complete examples
|
|
236
|
+
from nui_lambda_shared_utils import SlackClient, MetricsPublisher, with_retry
|
|
237
|
+
|
|
238
|
+
# Slack messaging with rich formatting
|
|
239
|
+
slack = SlackClient()
|
|
240
|
+
slack.send_message(channel="#alerts", text="Alert message")
|
|
241
|
+
|
|
242
|
+
# CloudWatch metrics publishing
|
|
243
|
+
metrics = MetricsPublisher(namespace="MyService")
|
|
244
|
+
metrics.put_metric("ProcessedItems", count, "Count")
|
|
245
|
+
|
|
246
|
+
# Error handling with automatic retries
|
|
247
|
+
@with_retry(max_attempts=3)
|
|
248
|
+
def critical_operation():
|
|
249
|
+
pass
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Testing Strategy
|
|
253
|
+
|
|
254
|
+
### Test Categories (pytest markers)
|
|
255
|
+
|
|
256
|
+
- `@pytest.mark.unit` - Fast unit tests with mocking
|
|
257
|
+
- `@pytest.mark.integration` - Tests requiring AWS services
|
|
258
|
+
- `@pytest.mark.slow` - Long-running tests
|
|
259
|
+
|
|
260
|
+
### AWS Testing
|
|
261
|
+
|
|
262
|
+
Integration tests use `moto` for AWS service mocking. Some tests require real AWS credentials for full integration testing.
|
|
263
|
+
|
|
264
|
+
### Test Structure
|
|
265
|
+
|
|
266
|
+
```text
|
|
267
|
+
tests/
|
|
268
|
+
├── test_<module>.py # Main module tests
|
|
269
|
+
├── conftest.py # Shared fixtures
|
|
270
|
+
└── fixtures/ # Test data files
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Contribution Guidelines
|
|
274
|
+
|
|
275
|
+
### Pull Request Checklist
|
|
276
|
+
|
|
277
|
+
Before submitting PRs, ensure:
|
|
278
|
+
|
|
279
|
+
- [ ] **No hardcoded organization-specific values** (service names, currencies, business logic)
|
|
280
|
+
- [ ] **Configuration options** provided for any defaults
|
|
281
|
+
- [ ] **Tests pass** with `pytest --cov`
|
|
282
|
+
- [ ] **Code formatted** with Black (`black nui_lambda_shared_utils/ tests/`)
|
|
283
|
+
- [ ] **Type hints** included for public APIs
|
|
284
|
+
- [ ] **Documentation updated** in docs/ for new features
|
|
285
|
+
- [ ] **Generic naming** - avoid organization-specific terminology in public APIs
|
|
286
|
+
|
|
287
|
+
### Code Review Focus Areas
|
|
288
|
+
|
|
289
|
+
Reviewers should check for:
|
|
290
|
+
|
|
291
|
+
- Generic utility patterns vs vendor-specific code
|
|
292
|
+
- Configurable defaults rather than hardcoded values
|
|
293
|
+
- Clear documentation of any platform assumptions
|
|
294
|
+
- Reusability across different AWS Lambda projects
|
|
295
|
+
|
|
296
|
+
## Package Distribution
|
|
297
|
+
|
|
298
|
+
### Version Management
|
|
299
|
+
|
|
300
|
+
Version is defined in both `setup.py` and `pyproject.toml` and should be kept in sync. The package follows semantic versioning.
|
|
301
|
+
|
|
302
|
+
### PyPI Publishing
|
|
303
|
+
|
|
304
|
+
The package is published to PyPI as `nui-lambda-shared-utils` with GitHub Actions automation for releases.
|
|
305
|
+
|
|
306
|
+
### CLI Tools
|
|
307
|
+
|
|
308
|
+
The package provides `slack-channel-setup` CLI tool for automating Slack workspace channel creation and configuration from YAML files. This is a generic tool useful for any team managing Slack workspaces.
|
|
309
|
+
|
|
310
|
+
**Usage:**
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# Create channels from YAML config
|
|
314
|
+
slack-channel-setup --config channels.yaml
|
|
315
|
+
|
|
316
|
+
# Check which channels exist
|
|
317
|
+
slack-channel-setup --config channels.yaml --check-only
|
|
318
|
+
|
|
319
|
+
# Generate environment variables
|
|
320
|
+
slack-channel-setup --config channels.yaml --output channels.env --output-format env
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## AWS Lambda Integration
|
|
324
|
+
|
|
325
|
+
### Bundle Size Optimization
|
|
326
|
+
|
|
327
|
+
- Use specific extras (`[slack]`, `[elasticsearch]`) rather than `[all]`
|
|
328
|
+
- Optional imports prevent failure if dependencies aren't installed
|
|
329
|
+
- Core utilities work without optional dependencies
|
|
330
|
+
|
|
331
|
+
### Lambda Layer Usage
|
|
332
|
+
|
|
333
|
+
The package is designed to work well in Lambda layers for sharing across multiple functions.
|
|
334
|
+
|
|
335
|
+
### Environment Integration
|
|
336
|
+
|
|
337
|
+
- Automatic AWS region detection
|
|
338
|
+
- Secrets Manager integration with credential caching
|
|
339
|
+
- CloudWatch metrics with proper dimensions
|
|
340
|
+
|
|
341
|
+
## Documentation Organization
|
|
342
|
+
|
|
343
|
+
This project follows a clear documentation structure:
|
|
344
|
+
|
|
345
|
+
- **[CLAUDE.md](CLAUDE.md)** (this file) - Development workflows, commands, testing strategies
|
|
346
|
+
- **[README.md](README.md)** - User-facing PyPI package description with quick start examples
|
|
347
|
+
- **[docs/](docs/README.md)** - Comprehensive usage guides and references
|
|
348
|
+
- `getting-started/` - Installation, configuration, quick start patterns
|
|
349
|
+
- `guides/` - Component-specific how-to guides (Slack, ES, Database, etc.)
|
|
350
|
+
- `development/` - Testing strategies, contributing guidelines
|
|
351
|
+
- `templates/` - Configuration file templates (Slack setup YAML)
|
|
352
|
+
- `archive/` - Historical documentation and migration notes
|
|
353
|
+
|
|
354
|
+
**For Claude Code users**: The docs/ directory contains detailed usage patterns,
|
|
355
|
+
configuration examples, and integration guides that complement these development instructions.
|
|
356
|
+
|
|
357
|
+
**For new package users**: Start with [docs/getting-started/quickstart.md](docs/getting-started/quickstart.md)
|
|
358
|
+
for working code examples and common patterns.
|
|
@@ -14,18 +14,21 @@ We welcome contributions to the NUI Lambda Shared Utilities project! This docume
|
|
|
14
14
|
|
|
15
15
|
1. Fork the repository on GitHub
|
|
16
16
|
2. Clone your fork locally:
|
|
17
|
+
|
|
17
18
|
```bash
|
|
18
19
|
git clone https://github.com/your-username/nui-lambda-shared-utils.git
|
|
19
20
|
cd nui-lambda-shared-utils
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
3. Create a virtual environment:
|
|
24
|
+
|
|
23
25
|
```bash
|
|
24
26
|
python -m venv venv
|
|
25
27
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
4. Install development dependencies:
|
|
31
|
+
|
|
29
32
|
```bash
|
|
30
33
|
pip install -e .[dev]
|
|
31
34
|
```
|
|
@@ -74,6 +77,7 @@ make lint # If Makefile exists
|
|
|
74
77
|
### Submitting Changes
|
|
75
78
|
|
|
76
79
|
1. Create a new branch for your feature/fix:
|
|
80
|
+
|
|
77
81
|
```bash
|
|
78
82
|
git checkout -b feature/your-feature-name
|
|
79
83
|
```
|
|
@@ -85,11 +89,13 @@ make lint # If Makefile exists
|
|
|
85
89
|
- Documentation is updated
|
|
86
90
|
|
|
87
91
|
3. Commit your changes:
|
|
92
|
+
|
|
88
93
|
```bash
|
|
89
94
|
git commit -m "Add: brief description of your changes"
|
|
90
95
|
```
|
|
91
96
|
|
|
92
97
|
4. Push to your fork:
|
|
98
|
+
|
|
93
99
|
```bash
|
|
94
100
|
git push origin feature/your-feature-name
|
|
95
101
|
```
|
|
@@ -101,7 +107,6 @@ make lint # If Makefile exists
|
|
|
101
107
|
- **Title**: Use a clear, descriptive title
|
|
102
108
|
- **Description**: Explain what your changes do and why
|
|
103
109
|
- **Testing**: Include information about how you tested your changes
|
|
104
|
-
- **Breaking Changes**: Clearly mark any breaking changes
|
|
105
110
|
|
|
106
111
|
### Commit Message Format
|
|
107
112
|
|
|
@@ -115,6 +120,7 @@ Use conventional commits format:
|
|
|
115
120
|
- `chore:` for maintenance tasks
|
|
116
121
|
|
|
117
122
|
Examples:
|
|
123
|
+
|
|
118
124
|
- `feat: add retry decorator for database operations`
|
|
119
125
|
- `fix: handle missing environment variables gracefully`
|
|
120
126
|
- `docs: update configuration examples in README`
|
|
@@ -185,6 +191,7 @@ class MyUtility:
|
|
|
185
191
|
- Use `test_<functionality>_<condition>_<expected_result>` pattern
|
|
186
192
|
|
|
187
193
|
Example:
|
|
194
|
+
|
|
188
195
|
```python
|
|
189
196
|
class TestSlackClient:
|
|
190
197
|
def test_send_message_success_returns_true(self):
|
|
@@ -242,6 +249,7 @@ def example_function(param1: str, param2: Optional[int] = None) -> Dict[str, Any
|
|
|
242
249
|
### README Updates
|
|
243
250
|
|
|
244
251
|
When adding new functionality, update the README.md with:
|
|
252
|
+
|
|
245
253
|
- Usage examples
|
|
246
254
|
- Configuration options
|
|
247
255
|
- Any new dependencies
|
|
@@ -274,8 +282,9 @@ By contributing to this project, you agree that your contributions will be licen
|
|
|
274
282
|
## Questions?
|
|
275
283
|
|
|
276
284
|
If you have questions about contributing, please:
|
|
285
|
+
|
|
277
286
|
- Open an issue with the "question" label
|
|
278
287
|
- Check the existing documentation
|
|
279
288
|
- Look at similar implementations in the codebase
|
|
280
289
|
|
|
281
|
-
Thank you for contributing! 🎉
|
|
290
|
+
Thank you for contributing! 🎉
|