Files
system-docs/05_INTEGRACIONES/airtable-mapping.md
ARCHITECT 6597d87053 Add Airtable mapping documentation
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 01:09:52 +00:00

183 lines
3.8 KiB
Markdown

# Mapeo HST - Airtable
**Estado:** Implementado
**Última actualización:** 2026-01-04
---
## Descripción
Sistema de mapeo bidireccional entre los tags semánticos HST/FLG almacenados en PostgreSQL y las múltiples bases de Airtable utilizadas por el equipo.
---
## Bases Airtable
| Base | ID | Tablas | Columna en map |
|------|-----|--------|----------------|
| hst_flg | appxaEAneiaYtO8NC | hst, flg | airtable_hst_flg |
| hst_psn | appOyP8gZfm9Bdcgm | hst | airtable_hst_psn |
| lumalia | appZgRKY5sG6E9zJy | hst in | airtable_lumalia |
| lum | apps8bynpQRuMPEid | hst in | airtable_lum |
| tuzzaro | appDaK3LcfWFrlc5u | hst in | airtable_tuzzaro |
| psn | appWIVTR5cYd3aIDJ | hst in | airtable_psn |
| bck | apprqWlmqdj98YIUt | hst in | airtable_bck |
| pff | appAyCPZAtkPhkOAh | hst in | airtable_pff |
---
## Tabla de Mapeo
**Schema:** `map`
**Tabla:** `airtable_map`
**Ubicación:** PostgreSQL en servidor HST (72.62.2.84)
### Estructura
```sql
CREATE TABLE map.airtable_map (
id SERIAL PRIMARY KEY,
als VARCHAR(255), -- Alias del tag
mrf_hst VARCHAR(64), -- Hash MRF en HST
airtable_hst_flg VARCHAR(20),
airtable_hst_psn VARCHAR(20),
airtable_lumalia VARCHAR(20),
airtable_lum VARCHAR(20),
airtable_tuzzaro VARCHAR(20),
airtable_psn VARCHAR(20),
airtable_bck VARCHAR(20),
airtable_pff VARCHAR(20),
created_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX idx_map_als ON map.airtable_map(als);
CREATE INDEX idx_map_mrf ON map.airtable_map(mrf_hst);
```
### Contenido
| Origen | Registros |
|--------|-----------|
| hst | 963 |
| flg | 65 |
| **Total** | **1028** |
---
## Lógica de Matching
El mapeo se realiza por **alias normalizado**:
1. Lowercase
2. Eliminar espacios extra
3. Eliminar "/" en conectores (ej: "M12 / 6p" → "M12 6p")
4. Normalizar variantes:
- `prototipo` se omite
- `especificaciones``especificación`
### Formato de Alias
```
{ref} {nombre}
```
Ejemplos:
- `spe m12 6p female`
- `flg spain`
- `hst acero inoxidable`
- `rbc cable de cinta`
---
## Grupos HST
| Grupo | Descripción | Cantidad |
|-------|-------------|----------|
| hst | Tags principales | 717 |
| spe | Especificaciones técnicas | 142 |
| vsn | Visiones | 40 |
| vue | Vistas | 21 |
| msn | Misiones/Proyectos | (pendiente) |
---
## Conectores Añadidos
Conectores técnicos sincronizados con Airtable:
### JST
- jst jwpf 2p/3p/4p female/male
- jst sm 2p/3p/4p female/male
### Roscas M
- M8 4p female/male
- M12 2+2p/4p/6p/8p female/male
- M15 3p female/male
- M16 2p/2+4p female/male/screw
- M20 3p/4p screw
- M25 2+2p female/male
- M29 4p female/male
- mr30 female/male
### Otros
- xt30 female/male
- xt60 female/male
- ethernet
- utp, ftp, s/ftp, sf/utp
- rbc (ribbon cable / cable de cinta)
---
## Convenciones de Nombres
| Campo | Español | Inglés |
|-------|---------|--------|
| nombre_es | hembra/macho | - |
| nombre_en | - | female/male |
| Roscas | M8, M12, M16... (mayúsculas) | M8, M12, M16... |
| Resto | minúsculas | minúsculas |
---
## Archivos
| Ubicación | Archivo | Descripción |
|-----------|---------|-------------|
| HST Server | /hst/map/airtable_map.sql | Schema SQL |
| R2 | documentos adjuntos/architect/airtable_map.md | Listado completo |
| R2 | documentos adjuntos/architect/proyectos_msn.md | 108 proyectos pendientes |
---
## Pendientes
- [ ] Añadir 108 proyectos al grupo `msn`
- [ ] Sincronización automática bidireccional
- [ ] Webhook para cambios en Airtable
---
## Uso
### Consultar mapeo
```sql
SELECT * FROM map.airtable_map WHERE als LIKE '%spain%';
```
### Obtener ID de Airtable para un tag HST
```sql
SELECT als, airtable_hst_flg, airtable_lumalia
FROM map.airtable_map
WHERE mrf_hst = 'abc123...';
```
### Buscar por ID de Airtable
```sql
SELECT als, mrf_hst
FROM map.airtable_map
WHERE airtable_hst_flg = 'recXXXXXXXX';
```