@mostajs/crm
v0.0.1
Published
CRM trading domain (clients, employees, suppliers, orders, comments, proformas). Thin domain module composing @mostajs/workflow (8-state order lifecycle + immutable history + state colors) and @mostajs/numbering (order/proforma references). Implements onl
Maintainers
Readme
@mostajs/crm
Domaine CRM trading (clients, employés, fournisseurs, commandes, commentaires, proformats). Module mince qui compose
@mostajs/workflow(automate de commande à 9 états + historique immuable + couleurs +party),@mostajs/numbering(n° commande / réf proforma) et@mostajs/i18n(libellés d'état FR/EN/AR). N'implémente que ses entités + règles métier.
Auteur : Dr Hamid MADANI [email protected] · Licence : AGPL-3.0-or-later Consommateur : application TRADING — déployée sur https://crm.amia.fr (amia).
Installation
npm i @mostajs/crm @mostajs/workflow @mostajs/statemachine @mostajs/trigger @mostajs/numbering @mostajs/i18nExemple
import { createCrm, createMemoryRepositories } from "@mostajs/crm";
const crm = createCrm({ repositories: createMemoryRepositories(), locale: "fr" });
const client = await crm.repositories.clients.save({ nom: "Doe", societe: "ACME" });
const order = await crm.createOrder({ clientId: client.id, text: "100x widgets" });
// order.number ≈ "2026-05-31-001" ; order.state = "init"
await crm.transitionOrder(order.id, "notification_attente", { actorId: "u1" }, { comment: "envoyé" });
await crm.orderHistory(order.id); // historique immuable (qui / quand / from→to)
crm.orderStateLabel("notification_attente"); // i18n : "Notification — en attente" (fr)
crm.orderStateColors()["client_informe"]; // "#10B981"Automate de commande (preset orderWorkflow)
init (admin/manager/employé) → notification_attente (émetteur) → relance_emetteur_attente (émetteur) → reponse_attente (destinataire) → relance_destinataire_attente (destinataire) → validation_attente (émetteur) → finalisation_attente (destinataire) → client_informe (émetteur). annulee depuis tout état non terminal.
Chaque état porte une couleur (#RRGGBB), une party (sender/receiver) et un libellé = clé i18n (order:state.<id>, traduit FR/EN/AR via @mostajs/i18n).
Entités (CDC §3)
Client, Employee (statut Libre/Occupé, userId), Supplier, Order (number, clientId, assigneeId, text, attachments, state), Comment, Proforma (ref, orderId, supplierId, pdfFileId).
Composition
| Capacité | Module |
|---|---|
| états + historique immuable + couleurs/party | @mostajs/workflow (→ statemachine + audit) |
| n° commande / réf proforma | @mostajs/numbering |
| libellés d'état | @mostajs/i18n |
| persistance (v0.1) | @mostajs/repository/orm |
| fichiers PDF/images (v0.1) | @mostajs/storage |
| droits Admin/Employé (v0.1) | @mostajs/auth + @mostajs/rbac |
Statut
v0.0.1 — cœur implémenté et testé (entités, dépôts mémoire, createOrder/assignFreeEmployee/transitionOrder/addProforma/listProformas, couleurs + i18n). Feuille de route : docs/03-PLAN-DEV-CRM.md (0.1 repos ORM + storage + rbac ; 0.2 pages/handlers UI ; 1.0 = 14 livrables). Étude : docs/01-ETUDE-ETAT-ART-CRM-07062026.md.
