npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kavaa-dce-viewmodels

v1.0.7

Published

Contrats TypeScript purs pour le workspace documentaire DCE.

Readme

kavaa-dce-viewmodels

Contrats TypeScript purs pour le workspace documentaire DCE.

Ce package decrit la forme canonique des donnees consommees par le UI Kit DCE. Il ne contient aucun composant, aucun service Angular, aucun appel HTTP et aucun DTO backend. Son role est de stabiliser le contrat entre les APIs DCE, les applications hotes et kavaa-dce-ui-angular.

Sommaire

Role du package

kavaa-dce-viewmodels sert de couche de contrat partagee.

Il doit etre utilise pour:

  • typer les reponses adaptees depuis les APIs DCE;
  • typer les fixtures, mocks et tests;
  • typer les composants Angular du package kavaa-dce-ui-angular;
  • eviter que les composants UI dependent directement des DTO backend;
  • centraliser les statuts, niveaux de validation, actions et evenements UI.

Il ne doit pas contenir:

  • de dependance Angular;
  • de logique HttpClient;
  • de cache applicatif;
  • de regles de workflow calculees dans l'UI;
  • de DTO backend bruts si leur forme n'est pas celle attendue par l'interface.

Installation

Depuis le registre npm configure

Le scope @kavaa pointe vers Azure Artifacts dans ce depot:

@kavaa:registry=https://pkgs.dev.azure.com/kavaa/CDC-Carthage/_packaging/Kavaa_Feed/npm/registry/

Installez le package:

npm install kavaa-dce-viewmodels

Si l'authentification Azure Artifacts n'est pas encore configuree, executez le script fourni depuis la racine du repo:

.\tools\npm\set-azure-artifacts-auth.ps1

Si le fichier tools/npm/set-azure-artifacts-auth.ps1 n'existe pas dans le projet, le developpeur doit le creer avant de relancer l'authentification.

Creer le dossier:

New-Item -ItemType Directory -Force -Path .\tools\npm

Creer ensuite le fichier tools/npm/set-azure-artifacts-auth.ps1 avec ce contenu:

param(
  [string]$Organization = "kavaa",
  [string]$Project = "CDC-Carthage",
  [string]$Feed = "Kavaa_Feed"
)

$securePat = Read-Host "Colle le PAT Azure DevOps (Packaging Read & write)" -AsSecureString
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePat)

try {
  $pat = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
  if ([string]::IsNullOrWhiteSpace($pat)) {
    throw "PAT vide. Aucun fichier .npmrc n'a ete modifie."
  }

  $pat = $pat.Trim()
  if ($pat.Length -lt 50) {
    throw "PAT trop court ($($pat.Length) caracteres). Copie le token complet depuis Azure DevOps."
  }

  $encodedPat = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pat))
  $baseUrl = "pkgs.dev.azure.com/$Organization/$Project/_packaging/$Feed/npm"
  $userNpmrc = Join-Path $env:USERPROFILE ".npmrc"

  $content = @"
//$baseUrl/registry/:username=AzureDevOps
//$baseUrl/registry/:_password=$encodedPat
//$baseUrl/registry/:[email protected]
//$baseUrl/:username=AzureDevOps
//$baseUrl/:_password=$encodedPat
//$baseUrl/:[email protected]
"@

  Set-Content -LiteralPath $userNpmrc -Value $content -Encoding ASCII
  Write-Host "Azure Artifacts npm auth written to $userNpmrc"
}
finally {
  if ($bstr -ne [IntPtr]::Zero) {
    [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr)
  }
}

Le script demande un PAT Azure DevOps avec droits Packaging, puis ecrit les entrees necessaires dans le fichier utilisateur .npmrc.

Depannage installation Azure Artifacts

Si npm install ou npm publish renvoie 401 ou 404, le probleme n'est generalement pas le package. Le plus souvent, c'est le compte Azure DevOps, le token ou les droits sur le feed Kavaa_Feed.

Verifier d'abord que le scope @kavaa pointe vers le feed Azure Artifacts:

@kavaa:registry=https://pkgs.dev.azure.com/kavaa/CDC-Carthage/_packaging/Kavaa_Feed/npm/registry/

Puis tester l'authentification:

npm whoami --registry=https://pkgs.dev.azure.com/kavaa/CDC-Carthage/_packaging/Kavaa_Feed/npm/registry/

Si la commande renvoie E401, Incorrect or missing password ou Unable to authenticate, le token local est absent, expire ou invalide. Depuis la racine de ce repo, relancer:

.\tools\npm\set-azure-artifacts-auth.ps1

Si le fichier tools/npm/set-azure-artifacts-auth.ps1 n'existe pas dans le projet, le developpeur doit le creer avec le contenu indique plus haut dans la section Installation.

Quand le script demande le PAT, coller le nouveau PAT Azure DevOps complet. Le PAT doit etre cree dans Azure DevOps avec la permission:

Packaging: Read & write

Le script ecrit les credentials dans le fichier utilisateur:

C:\Users\<user>\.npmrc

Ne jamais mettre le PAT dans le .npmrc du projet et ne jamais le commiter.

Si la commande renvoie E404, VS800075 ou The package was not found, verifier deux choses:

  • l'URL du registry dans .npmrc est exactement celle affichee dans Artifacts > Kavaa_Feed > Connect to feed > npm;
  • l'utilisateur Azure DevOps a un role qui permet de lire ou publier sur Kavaa_Feed, par exemple Reader pour installer, ou Contributor, Feed Publisher ou Owner pour publier.

Apres correction, tester:

npm view kavaa-dce-viewmodels version --registry=https://pkgs.dev.azure.com/kavaa/CDC-Carthage/_packaging/Kavaa_Feed/npm/registry/
npm view kavaa-dce-ui-angular version --registry=https://pkgs.dev.azure.com/kavaa/CDC-Carthage/_packaging/Kavaa_Feed/npm/registry/

Puis installer:

npm install kavaa-dce-viewmodels kavaa-dce-ui-angular

Dans ce monorepo Nx

Le package est resolu via tsconfig.base.json:

{
  "paths": {
    "kavaa-dce-viewmodels": ["./libs/dce-viewmodels/src/index.ts"]
  }
}

Il peut donc etre importe directement dans les libs et applications du workspace:

import {
  ActorContext,
  GateStatus,
  type ChecklistWorkspaceViewModel
} from 'kavaa-dce-viewmodels';

Pre-requis TypeScript

Le workspace utilise:

  • TypeScript 5.9;
  • module et moduleResolution en nodenext;
  • strict: true;
  • customConditions: ['@kavaa/dce/source'] pour consommer les sources locales pendant le developpement.

Dans les imports relatifs du code source du package, les extensions .js sont attendues, meme si les fichiers sources sont en .ts.

Utilisation rapide

Construire un ViewModel minimal

import {
  ActorContext,
  GateStatus,
  ItemStatus,
  ValidationLevel,
  type ChecklistWorkspaceViewModel
} from 'kavaa-dce-viewmodels';

export const workspace: ChecklistWorkspaceViewModel = {
  meta: {
    contractVersion: '2.0',
    viewType: 'ChecklistWorkspace',
    generatedAt: new Date().toISOString(),
    tenantId: 'CDC',
    correlationId: 'corr-001'
  },
  header: {
    dossierId: 'PRJ-001',
    dossierLabel: 'Projet exemple',
    processCode: 'INVEST_DIRECT',
    processLabel: 'Investissement Direct',
    stepCode: 'PRE_ACCEPTANCE',
    stepLabel: 'Pre-acceptation',
    actorContext: ActorContext.Analyst,
    templateCode: 'CHK_PRE_ACCEPTANCE',
    templateVersion: 1
  },
  actorContext: ActorContext.Analyst,
  complianceGate: {
    status: GateStatus.Blocked,
    statusLabel: 'Bloque',
    completenessPct: 0,
    missingCount: 1,
    rejectedCount: 0,
    expiredCount: 0,
    uploadedPendingValidationCount: 0,
    waitingReviewCount: 0,
    isBlocking: true,
    isOverridable: false,
    blockingReasons: [
      {
        code: 'MISSING_REQUIRED_DOCUMENTS',
        label: 'Documents requis manquants',
        severity: 'BLOCKING'
      }
    ],
    checkedAt: new Date().toISOString()
  },
  summary: {
    totalItems: 1,
    requiredItems: 1,
    optionalItems: 0,
    validatedItems: 0,
    approvedItems: 0,
    uploadedItems: 0,
    missingItems: 1,
    rejectedItems: 0,
    expiredItems: 0,
    notApplicableItems: 0,
    waitingReviewItems: 0
  },
  items: [
    {
      itemId: 'ITM-BP-001',
      documentTypeCode: 'DOC_BP',
      documentTypeName: 'Business Plan',
      category: 'FINANCIER',
      sectionCode: 'FINANCIER',
      sectionLabel: 'Documents financiers',
      required: true,
      requiredValidationLevel: ValidationLevel.L1,
      currentValidationLevel: ValidationLevel.None,
      conditionalApplied: false,
      status: ItemStatus.Missing,
      statusLabel: 'Manquant',
      activeVersion: null,
      availableVersions: [],
      actions: {
        canUpload: true,
        canReplace: false,
        canValidate: false,
        canApprove: false,
        canReject: false,
        canDownloadActiveVersion: false,
        canViewHistory: true,
        disabledReasons: []
      },
      blockingReasons: []
    }
  ],
  sections: [
    {
      sectionCode: 'FINANCIER',
      sectionLabel: 'Documents financiers',
      displayOrder: 1,
      itemIds: ['ITM-BP-001'],
      summary: {
        total: 1,
        validated: 0,
        uploaded: 0,
        missing: 1,
        rejected: 0,
        expired: 0
      }
    }
  ]
};

Adapter un DTO backend

Le backend peut exposer une forme differente du ViewModel. Dans ce cas, creez un adapter cote host:

import {
  GateStatus,
  ItemStatus,
  type ChecklistWorkspaceViewModel
} from 'kavaa-dce-viewmodels';

export function toChecklistWorkspace(dto: DceWorkspaceDto): ChecklistWorkspaceViewModel {
  return {
    meta: {
      contractVersion: dto.contractVersion,
      viewType: 'ChecklistWorkspace',
      generatedAt: dto.generatedAt,
      tenantId: dto.tenant,
      correlationId: dto.correlationId
    },
    header: {
      dossierId: dto.dossier.id,
      dossierLabel: dto.dossier.label,
      processCode: dto.process.code,
      processLabel: dto.process.label,
      stepCode: dto.step.code,
      stepLabel: dto.step.label,
      actorContext: dto.actor,
      templateCode: dto.template.code,
      templateVersion: dto.template.version
    },
    actorContext: dto.actor,
    complianceGate: {
      status: dto.blocked ? GateStatus.Blocked : GateStatus.Ok,
      statusLabel: dto.blocked ? 'Bloque' : 'Conforme',
      completenessPct: dto.completenessPct,
      missingCount: dto.counters.missing,
      rejectedCount: dto.counters.rejected,
      expiredCount: dto.counters.expired,
      uploadedPendingValidationCount: dto.counters.pendingValidation,
      waitingReviewCount: dto.counters.waitingReview,
      isBlocking: dto.blocked,
      isOverridable: dto.overridable,
      blockingReasons: dto.reasons,
      checkedAt: dto.checkedAt
    },
    summary: dto.summary,
    items: dto.items.map((item) => ({
      itemId: item.id,
      documentTypeCode: item.documentType.code,
      documentTypeName: item.documentType.name,
      category: item.category,
      sectionCode: item.section.code,
      sectionLabel: item.section.label,
      required: item.required,
      requiredValidationLevel: item.requiredValidationLevel,
      currentValidationLevel: item.currentValidationLevel,
      conditionalApplied: item.conditionalApplied,
      status: item.status as ItemStatus,
      statusLabel: item.statusLabel,
      activeVersion: item.activeVersion,
      availableVersions: item.versions,
      actions: item.actions,
      blockingReasons: item.blockingReasons
    })),
    sections: dto.sections
  };
}

Contrat principal

ChecklistWorkspaceViewModel est la racine consommee par le UI Kit.

export interface ChecklistWorkspaceViewModel {
  meta: DceMetaViewModel;
  header: ChecklistHeaderViewModel;
  complianceGate: ComplianceGateViewModel;
  summary: ChecklistSummaryViewModel;
  items: ChecklistItemViewModel[];
  sections: ChecklistSectionViewModel[];
  auditSummary?: ChecklistAuditSummaryViewModel | null;
  committeeView?: CommitteeReadOnlyViewModel | null;
  actorContext: ActorContext | string;
  mode?: ChecklistRenderMode;
  links?: LinkMap;
}

Champs obligatoires:

| Champ | Type | Role | | --- | --- | --- | | meta | DceMetaViewModel | Version du contrat, tenant, date de generation et correlation technique. | | header | ChecklistHeaderViewModel | Contexte dossier, processus, etape, acteur et template. | | complianceGate | ComplianceGateViewModel | Etat global de conformite documentaire. | | summary | ChecklistSummaryViewModel | Compteurs globaux affiches dans la synthese. | | items | ChecklistItemViewModel[] | Pieces documentaires et actions autorisees. | | sections | ChecklistSectionViewModel[] | Regroupements visuels et metiers des items. | | actorContext | ActorContext | string | Acteur courant: analyste, promoteur, validateur, comite ou extension host. |

Champs optionnels:

| Champ | Type | Role | | --- | --- | --- | | auditSummary | ChecklistAuditSummaryViewModel | null | Timeline d'audit. | | committeeView | CommitteeReadOnlyViewModel | null | Projection lecture seule comite. | | mode | ChecklistRenderMode | Mode de rendu conseille a l'UI. | | links | LinkMap | Liens API ou navigation fournis par le host. |

Modeles exportes

DceMetaViewModel

Metadonnees techniques du contrat.

| Champ | Type | Description | | --- | --- | --- | | contractVersion | string | Version du contrat ViewModel. | | viewType | 'ChecklistWorkspace' | string | Type logique du ViewModel. | | generatedAt | string | Date ISO de generation. | | tenantId | string | Tenant ou organisation. | | correlationId | string | Identifiant de correlation pour support/debug. |

ChecklistHeaderViewModel

Contexte fonctionnel affiche en en-tete.

| Champ | Type | | --- | --- | | dossierId | string | | dossierLabel | string | | processCode | string | | processLabel | string | | stepCode | string | | stepLabel | string | | actorContext | ActorContext | string | | templateCode | string | | templateVersion | number |

ComplianceGateViewModel

Etat global de conformite.

| Champ | Type | Description | | --- | --- | --- | | status | GateStatus | OK, BLOCKED ou OVERRIDABLE. | | statusLabel | string | Libelle affiche. | | completenessPct | number | Pourcentage de completude. | | completionPercentage | number optionnel | Alias optionnel pour compatibilite. | | missingCount | number | Documents manquants. | | rejectedCount | number | Documents rejetes. | | expiredCount | number | Documents expires. | | uploadedPendingValidationCount | number | Documents deposes en attente de validation. | | waitingReviewCount | number | Documents en attente de validation superieure. | | isBlocking | boolean | Bloque l'avancement. | | isOverridable | boolean | Peut etre deroge ou approuve par niveau superieur. | | blockingReasons | BlockingReason[] | Raisons bloquantes ou avertissements. | | checkedAt | string | Date ISO du calcul. |

BlockingReason

| Champ | Type | Description | | --- | --- | --- | | code | string | Code stable exploitable par le host. | | label | string | Libelle utilisateur. | | severity | Severity | INFO, WARNING, BLOCKING ou ERROR. | | itemIds | string[] optionnel | Items concernes. |

ChecklistSummaryViewModel

Compteurs globaux du dossier documentaire.

| Champ | Type | | --- | --- | | totalItems | number | | requiredItems | number | | optionalItems | number | | validatedItems | number | | approvedItems | number | | uploadedItems | number | | missingItems | number | | rejectedItems | number | | expiredItems | number | | notApplicableItems | number | | waitingReviewItems | number |

ChecklistItemViewModel

Contrat d'un document attendu ou recu.

| Champ | Type | Description | | --- | --- | --- | | itemId | string | Identifiant stable de l'item. | | code | string optionnel | Code alternatif. | | label | string optionnel | Libelle alternatif. | | documentTypeCode | string | Code type document. | | documentTypeName | string | Nom type document. | | category | string | Categorie fonctionnelle. | | sectionCode | string | Code de section. | | sectionLabel | string | Libelle de section. | | required | boolean | Document obligatoire. | | requiredValidationLevel | ValidationLevel | Niveau requis: 0, 1 ou 2. | | currentValidationLevel | ValidationLevel | Niveau atteint. | | conditionalApplied | boolean | Regle conditionnelle appliquee. | | status | ItemStatus | Statut documentaire. | | statusLabel | string | Libelle affiche. | | activeVersion | DocumentVersionViewModel | null | Version active. | | availableVersions | DocumentVersionViewModel[] | Historique ou versions disponibles. | | actions | ChecklistItemActionsViewModel | Actions autorisees par le backend/host. | | blockingReasons | BlockingReason[] | Raisons propres a l'item. | | sections | string[] optionnel | Sections additionnelles si besoin host. |

ChecklistItemActionsViewModel

Les composants UI affichent les actions a partir de ce bloc. Le host reste responsable des autorisations.

| Champ | Type | | --- | --- | | canUpload | boolean | | canReplace | boolean | | canValidate | boolean | | canApprove | boolean | | canReject | boolean | | canDownloadActiveVersion | boolean | | canViewHistory | boolean | | disabledReasons | Partial<Record<ChecklistItemActionCode, string>> | string[] |

ChecklistItemActionCode vaut:

'upload' | 'replace' | 'validate' | 'approve' | 'reject' | 'download' | 'history'

DocumentVersionViewModel

Metadata d'une version documentaire.

| Champ | Type | Description | | --- | --- | --- | | versionId | string | Identifiant de version. | | documentVersionId | string optionnel | Identifiant alternatif utilise par certaines APIs. | | fileName | string | Nom du fichier. | | uploadedAt | string | Date ISO de depot. | | uploadedBy | string | Auteur du depot. | | fileSize | number | Taille du fichier. | | fileSizeBytes | number optionnel | Taille explicite en octets. | | mimeType | string | Type MIME. | | antivirusStatus | AntivirusStatus | Etat antivirus. | | classificationPlan | string optionnel | Plan de classement. | | checksum | string optionnel | Empreinte fichier. | | downloadUrl | string | null optionnel | URL de telechargement si fournie. | | validationLevel | ValidationLevel optionnel | Niveau associe. | | status | ItemStatus optionnel | Statut associe. |

AntivirusStatus vaut:

'PENDING' | 'CLEAN' | 'INFECTED' | 'ERROR' | 'UNKNOWN'

ChecklistSectionViewModel

Regroupement d'items.

| Champ | Type | | --- | --- | | sectionCode | string | | sectionLabel | string | | displayOrder | number | | itemIds | string[] | | summary | SectionSummaryViewModel |

SectionSummaryViewModel

Synthese par section.

| Champ | Type | | --- | --- | | total | number | | validated | number | | approved | number optionnel | | uploaded | number | | missing | number | | rejected | number | | expired | number | | notApplicable | number optionnel | | waitingReview | number optionnel |

ChecklistAuditSummaryViewModel

Synthese d'audit.

| Champ | Type | | --- | --- | | lastActionAt | string | null optionnel | | lastActionBy | string | null optionnel | | eventCount | number | | hasTechnicalErrors | boolean | | events | ChecklistAuditEventViewModel[] |

ChecklistAuditEventViewModel

Evenement d'audit.

| Champ | Type | | --- | --- | | eventId | string | | eventType | string | | timestamp | string | | actorDisplayName | string | | summary | string | | itemId | string optionnel | | itemLabel | string optionnel | | status | ItemStatus optionnel |

CommitteeReadOnlyViewModel

Projection lecture seule pour comite.

| Champ | Type | | --- | --- | | committeeDossierId | string | | title | string | | isCommitteeReady | boolean | | completenessPct | number | | generatedAt | string | null optionnel | | reportUrl | string | null optionnel | | canDownloadReport | boolean | | canOpenConsultation | boolean | | categories | CommitteeDocumentCategoryViewModel[] |

CommitteeDocumentCategoryViewModel

| Champ | Type | | --- | --- | | categoryCode | string | | categoryLabel | string | | status | ItemStatus | GateStatus | | documentCount | number | | readyCount | number |

UiErrorState

Etat d'erreur presentable par un composant UI.

| Champ | Type | | --- | --- | | code | string | | message | string | | detail | string optionnel | | severity | 'info' | 'warning' | 'error' optionnel | | retryAllowed | boolean optionnel | | correlationId | string optionnel |

LinkMap

Liens optionnels fournis par le host.

export interface LinkMap {
  self?: string;
  checklist?: string;
  items?: string;
  completeness?: string;
  report?: string;
  [key: string]: string | undefined;
}

Constantes et types metier

ItemStatus

| Constante | Valeur | Usage | | --- | --- | --- | | ItemStatus.Missing | MISSING | Document requis manquant. | | ItemStatus.Uploaded | UPLOADED | Document depose, pas encore valide. | | ItemStatus.Validated | VALIDATED | Validation L1 obtenue. | | ItemStatus.Approved | APPROVED | Approbation L2 obtenue. | | ItemStatus.Rejected | REJECTED | Document rejete. | | ItemStatus.Expired | EXPIRED | Document expire. | | ItemStatus.NotApplicable | NOT_APPLICABLE | Document hors perimetre. | | ItemStatus.PendingUpload | PENDING_UPLOAD | Depot attendu/en cours cote host. | | ItemStatus.ErrorTech | ERROR_TECH | Erreur technique. | | ItemStatus.Quarantined | QUARANTINED | Quarantaine antivirus ou controle technique. |

GateStatus

| Constante | Valeur | Usage | | --- | --- | --- | | GateStatus.Ok | OK | Dossier conforme. | | GateStatus.Blocked | BLOCKED | Dossier bloque par une condition documentaire. | | GateStatus.Overridable | OVERRIDABLE | Dossier non bloquant mais soumis a validation/derogation. |

ActorContext

| Constante | Valeur | | --- | --- | | ActorContext.Analyst | ANALYST | | ActorContext.Promoter | PROMOTER | | ActorContext.Validator | VALIDATOR | | ActorContext.Committee | COMMITTEE |

ValidationLevel

| Constante | Valeur | Usage | | --- | --- | --- | | ValidationLevel.None | 0 | Aucune validation. | | ValidationLevel.L1 | 1 | Validation de premier niveau. | | ValidationLevel.L2 | 2 | Approbation ou controle superieur. |

Autres types

export type ChecklistRenderMode = 'analyst' | 'promoter' | 'validator' | 'committee';
export type Severity = 'INFO' | 'WARNING' | 'BLOCKING' | 'ERROR';
export type UploadState = 'idle' | 'selecting' | 'uploading' | 'success' | 'error';
export type DecisionState = 'idle' | 'submitting' | 'error';

Evenements UI

Les evenements representent des intentions emises par l'UI. Ils ne declenchent pas eux-memes les APIs.

UploadConfirmedEvent

export interface UploadConfirmedEvent {
  itemId: string;
  file: File;
}

ItemIntentEvent

export interface ItemIntentEvent {
  itemId: string;
  documentVersionId?: string;
}

RejectionConfirmedEvent

export interface RejectionConfirmedEvent extends ItemIntentEvent {
  reason: string;
  comment?: string;
}

DceUiIntent

Union utile pour journaliser ou router les intentions.

export type DceUiIntent =
  | ({ type: 'uploadConfirmed' } & UploadConfirmedEvent)
  | ({ type: 'replaceRequested' } & ItemIntentEvent)
  | ({ type: 'validationConfirmed' } & ItemIntentEvent)
  | ({ type: 'approvalConfirmed' } & ItemIntentEvent)
  | ({ type: 'rejectionConfirmed' } & RejectionConfirmedEvent)
  | ({ type: 'openItemRequested' } & ItemIntentEvent)
  | { type: 'openAuditRequested' }
  | { type: 'openCommitteeReportRequested' };

Regles d'integration

1. Garder les ViewModels independants du backend

Le backend peut avoir ses propres DTO. Le host doit adapter ces DTO vers ChecklistWorkspaceViewModel avant de les donner a l'UI.

2. Calculer les droits et compteurs cote metier

Les champs suivants doivent deja etre calcules avant l'affichage:

  • complianceGate;
  • summary;
  • sections[].summary;
  • items[].actions;
  • items[].blockingReasons;
  • committeeView.

Le UI Kit affiche ces donnees, mais ne remplace pas le moteur de workflow.

3. Fournir des codes stables

Les champs code, sectionCode, documentTypeCode, blockingReasons[].code et eventType doivent rester stables. Ils servent a la navigation, au filtrage, au tracking et aux tests.

4. Synchroniser apres mutation

Apres une action utilisateur, l'application hote doit:

  1. appeler son API;
  2. attendre le succes;
  3. recharger le workspace;
  4. fournir un nouveau ChecklistWorkspaceViewModel.

Cette regle evite les etats UI divergents.

Developpement dans ce monorepo

Structure

libs/dce-viewmodels/
  package.json
  project.json
  src/
    index.ts
    lib/
      index.ts
      enums.ts
      checklist-workspace.viewmodel.ts
      checklist-item.viewmodel.ts
      compliance-gate.viewmodel.ts
      ...

Commandes utiles

Depuis la racine du repo:

npm run test:viewmodels
npx nx typecheck dce-viewmodels
npx nx build dce-viewmodels

Le script racine npm run build:viewmodels execute aussi nx build dce-viewmodels.

Publication

Le package declare:

{
  "name": "kavaa-dce-viewmodels",
  "version": "1.0.0",
  "type": "module",
  "exports": {
    ".": {
      "@kavaa/dce/source": "./src/index.ts",
      "types": "./dist/index.d.ts",
      "default": "./dist/index.js"
    }
  }
}

La publication depuis la racine est prevue par:

npm run publish:viewmodels

Checklist d'integration

  • Le package kavaa-dce-viewmodels est installe.
  • Les DTO backend sont adaptes vers ChecklistWorkspaceViewModel.
  • Les constantes ItemStatus, GateStatus, ActorContext et ValidationLevel sont utilisees au lieu de chaines dispersees.
  • Les compteurs summary sont coherents avec items.
  • Les actions items[].actions sont calculees cote host/backend.
  • Les raisons bloquantes ont des codes stables.
  • Les versions documentaires exposent un versionId ou documentVersionId exploitable par les APIs.
  • Les evenements UI sont traites comme des intentions.
  • Apres chaque mutation, le workspace est recharge.
  • Les tests couvrent au moins les scenarios BLOCKED, OVERRIDABLE, OK et erreur technique.

Regle d'or

kavaa-dce-viewmodels est le contrat. Les APIs produisent ou alimentent ce contrat, le package Angular l'affiche, et l'application hote orchestre les mutations metier.