Skip to content

Commit d01412d

Browse files
committed
docs: update README files for Babel compilation instructions
Replace manual Babel compilation commands with a Docker command in both English and Russian README files for improved clarity and ease of use.
1 parent 56cb440 commit d01412d

File tree

3 files changed

+87
-8
lines changed

3 files changed

+87
-8
lines changed

CLAUDE.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
ModulePhoneBook is a MikoPBX extension module that provides caller ID management and contact storage. It integrates with Asterisk PBX for real-time caller identification on inbound and outbound calls.
8+
9+
## Build Commands
10+
11+
### JavaScript Compilation
12+
```bash
13+
docker run --rm -v /Users/nb/PhpstormProjects/mikopbx:/workspace ghcr.io/mikopbx/babel-compiler:latest /workspace/Extensions/[module]/public/assets/js/src/[file] extension`
14+
```
15+
16+
### PHP Syntax Check
17+
```bash
18+
php -l Lib/PhoneBookConf.php
19+
```
20+
21+
### Code Quality (PHPStan)
22+
Run phpstan after creating new PHP code to validate quality.
23+
24+
### Dependencies
25+
```bash
26+
composer install
27+
```
28+
29+
## Architecture
30+
31+
### Directory Structure
32+
- `App/Controllers/` - Phalcon MVC controllers (ModulePhoneBookController)
33+
- `App/Forms/` - Phalcon form definitions
34+
- `Lib/` - Core business logic
35+
- `PhoneBookConf.php` - PBX integration, REST API callbacks, Asterisk dialplan generation
36+
- `PhoneBookAgi.php` - Asterisk AGI handler for real-time caller ID lookup
37+
- `PhoneBookImport.php` - Excel import processor using PhpSpreadsheet
38+
- `MikoPBXVersion.php` - Version compatibility helpers
39+
- `Models/` - Phalcon ORM models (PhoneBook, Settings)
40+
- `Setup/` - Module installation logic (PbxExtensionSetup)
41+
- `agi-bin/` - Asterisk AGI scripts
42+
- `Messages/` - i18n translation files (26 languages)
43+
- `public/assets/js/src/` - Source JavaScript files (ES6)
44+
- `public/assets/js/` - Compiled JavaScript files
45+
46+
### Data Flow
47+
1. **Inbound calls**: Asterisk dialplan → `agi_phone_book.php``PhoneBookAgi::setCallerId('in')` → Sets CALLERID(name)
48+
2. **Outbound calls**: CONNECTED_LINE_SEND_SUB → `PhoneBookAgi::setCallerId('out')` → Sets CONNECTEDLINE(name)
49+
3. **Web UI**: DataTable with server-side processing via AJAX to `ModulePhoneBookController::getNewRecordsAction()`
50+
51+
### Phone Number Storage Format
52+
Numbers are normalized for consistent storage and fast lookups:
53+
- Strip all non-digit characters
54+
- Keep last 9 digits only
55+
- Prepend "1"
56+
- Example: `+7 (906) 555-43-43``1065554343`
57+
58+
### Database
59+
SQLite database at runtime: `/storage/usbdisk1/mikopbx/custom_modules/ModulePhoneBook/db/module.db`
60+
61+
Tables:
62+
- `m_PhoneBook` - contacts (id, number, number_rep, call_id, search_index)
63+
- `m_ModulePhoneBook` - settings (disableInputMask)
64+
65+
### Key Integration Points
66+
- `PhoneBookConf::moduleRestAPICallback()` - REST API entry point for Excel import
67+
- `PhoneBookConf::generateIncomingRoutBeforeDial()` - Injects AGI into inbound routes
68+
- `PhoneBookConf::generateOutRoutContext()` - Injects connected line handling for outbound
69+
- `PhoneBookConf::extensionGenContexts()` - Generates `[phone-book-out]` Asterisk context
70+
71+
### Frontend
72+
- Uses Semantic UI components and DataTables
73+
- Input masking for phone numbers (toggleable via settings)
74+
- State persistence in localStorage for page length and search
75+
- Files in `public/assets/js/src/` must be compiled with Babel to `public/assets/js/`
76+
77+
## Module Configuration
78+
79+
`module.json` defines module metadata including:
80+
- `moduleUniqueID`: "ModulePhoneBook"
81+
- `min_pbx_version`: "2024.1.114"
82+
83+
## CI/CD
84+
85+
GitHub Actions workflow (`.github/workflows/build.yml`) uses shared MikoPBX workflow for building and publishing releases.

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ SQLite database at `/storage/usbdisk1/mikopbx/custom_modules/ModulePhoneBook/db/
171171

172172
```bash
173173
# Compile ES6 to ES5 with Babel
174-
babel public/assets/js/src/module-phonebook-datatable.js \
175-
--out-dir public/assets/js \
176-
--source-maps inline \
177-
--presets airbnb
174+
docker run --rm -v ~/mikopbx:/workspace ghcr.io/mikopbx/babel-compiler:latest /workspace/Extensions/[module]/public/assets/js/src/[file] extension`
178175
```
179176

180177
### PHP Syntax Check

README.ru.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ SQLite база данных: `/storage/usbdisk1/mikopbx/custom_modules/ModulePh
171171

172172
```bash
173173
# Компиляция ES6 в ES5 с помощью Babel
174-
babel public/assets/js/src/module-phonebook-datatable.js \
175-
--out-dir public/assets/js \
176-
--source-maps inline \
177-
--presets airbnb
174+
docker run --rm -v ~/mikopbx:/workspace ghcr.io/mikopbx/babel-compiler:latest /workspace/Extensions/[module]/public/assets/js/src/[file] extension`
178175
```
179176

180177
### Проверка синтаксиса PHP

0 commit comments

Comments
 (0)