---
suivi: 1250
date: 2026-08-07
sujet: Explorateur SharePoint chantier sous onglet DOCUMENTS marché
chantier: sharepoint / suivi-chantier / marches
type: feature
statut: poussé
hash: c59b7cf7
fichiers:
  - app/Support/SharePointArborescenceStructures.php
  - app/Services/SharePointService.php
  - app/Services/SharePointChantierExplorerService.php
  - app/Http/Controllers/MarcheChantierExplorerController.php
  - routes/web.php
  - resources/js/Components/SharePoint/SharePointGedExplorer.vue
  - resources/js/Components/SharePoint/MarcheChantierExplorer.vue
  - resources/js/Pages/Marches/Show.vue
  - tests/Unit/SharePointChantierExplorerServiceTest.php
  - database/data/journal_mises_a_jour_post_2026_06_12.php
  - public/build/
  - docs/suivi/SUIVI_1250_explorateur_sharepoint_marche.md
---

# SUIVI #1250 — Explorateur SharePoint chantier (fiche marché)

## PROMPT ENVOYÉ

Explorateur SharePoint du dossier chantier sous l'onglet DOCUMENTS du marché.
Réutiliser GED / inventaire, croisement piloté/libre par `item_id`, dossiers
structurels protégés, écritures après verrouillage bibliothèque, lazy load,
HelpHint, journal, commit+push.

## FICHES LUES

- `#1226` — `SharePointGedExplorer` déjà réutilisable (DnD + Outlook + picker) ;
  dropzone dépôt factures non extractible → réutiliser l'explorateur GED.
- `#1232` — inventaire : croisement ERP, listage `/children`, jeton app vs délégué.
- `#1236` / `#1239` — croiser sur `item_id`, jamais l'URL.
- `#1241` / `#1243` / `#1245` — arborescence `05_SUIVI_CHANTIER` migrée.
- `#1227` — `UploadDocumentAllowlist` MIME réelle.
- `#1215` — `HelpHint.vue`.
- `#1108` — échec Graph visible.
- Pas de fiche `#1248` dans `docs/suivi/` au moment du lot → pas de conflit détecté
  avec DCE/dossier marché (écran AO / liste marchés, a priori disjoint de `Show.vue`).

## SYNTHÈSE

### Objet 1 — Réutilisation

| Choix | Pourquoi |
|-------|----------|
| **`SharePointGedExplorer.vue`** | UI complète (liste, DnD, Outlook, rename, delete, mkdir, aperçu). Props `apiBase` + `showErpLockStatus` ajoutés. |
| **Pas** `SharePointChantierInventaireService` | Parcours profond inventaire admin (180–225 dossiers) — inadapté au lazy UI. |
| **Nouveau** `SharePointChantierExplorerService` + `MarcheChantierExplorerController` | Racine chantier, croisement ERP, guards, **écritures en jeton applicatif**. |

Racine d'exploration = `05_SUIVI_CHANTIER` du **programme** (pas le dossier marché).

### Objet 2 — Piloté / libre

Critère : présence de l'`item_id` dans une index SQL unique (`buildErpItemIndex`) :
`marche_documents`, `avenant_documents`, `appels_offres` (DCE + estimatif), `ao_devis`.
Jamais l'URL. Libellés précis selon le porteur. Lien « Gérer » vers l'écran d'origine.

Signalés libres faute d'`item_id` : dossiers AO id 2 et 3 (`sharepoint_folder_url` seule).

### Objet 3 — Noms réservés

```
05_SUIVI_CHANTIER
1_DCE, 2_AO, 3_DOSSIER_MARCHE, 4_PRESTATAIRES, 5_PHOTOS
1_ADMINISTRATIF, 2_CONTRATS_ET_AVENANTS, 3_SUIVI_OPERATIONNEL, 4_DOC_LIBRES
COMPTES_RENDUS, COURRIERS, MISES_EN_DEMEURE, CONSTATS, RAPPORTS_TECHNIQUES, AUTRE
```

`_old_*` = libres. Dossiers marché `{POSTE}_{FOURNISSEUR}` = libres (id stocké en base).

### Trois états

| État | Critère | Signal | Actions |
|------|---------|--------|---------|
| Piloté | `item_id` en base | cadenas gris, ligne grisée, lien Gérer | ouvrir |
| Libre | non référencé | aspect normal | ouvrir, DL, rename, delete, dépôt, mkdir |
| Structurel | nom réservé | cadenas, sans lien | ouvrir seulement |

### Auth Graph (critique)

- GED programme : écritures via **`getAccessToken()` (délégué utilisateur)** → cassé pour
  Membres/Visiteurs après passage bibliothèque en Lecture.
- Explorateur chantier (#1250) : **`getAppAccessToken()` / `client_credentials`**
  (`uploadFichierApp`, rename/delete/create/list en `useAppToken=true`).
- Principal applicatif Azure (`services.azure.client_id` + secret) conserve Sites.ReadWrite.All
  applicatif — indépendant des ACL groupe SharePoint.
- Test prod n°11 obligatoire pour confirmer l'écriture réelle après verrouillage.

### Coût Graph

| Moment | Appels |
|--------|--------|
| Rendu fiche marché | **0** (bouton « Ouvrir l'explorateur ») |
| Première ouverture | 1 find `05_SUIVI_CHANTIER` + 1 list enfants (= 5 racines) |
| Dépliage dossier | 1 list (+ walk métadonnées breadcrumb si profondeur) |

### Sérialisation

`Marches/Show.vue` touché — rebase `origin/main` avant build. Pas de `#1248` concurrent
sur cette page au moment du lot.

## DÉPLOIEMENT / TEST

```text
git pull origin main
php artisan route:clear
php artisan view:clear
php artisan journal:sync
```

Pas de migrate.

## LEÇON

Après verrouillage SharePoint utilisateurs, tout chemin d'écriture ERP qui reste sur
jeton **délégué** échoue pour Membres. Les nouveaux points d'écriture documentaire
doivent utiliser le jeton **applicatif**. La GED programme reste en délégué — dette
à traiter (sinon dépôt GED cassé pour non-admins).
