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

@osfarm/agroedei-edifact-daplos-reader

v1.0.10

Published

Parser pour fichiers Daplos (.dap) - Conversion vers JSON

Readme

Agroedei Edifact Daplos Reader

Un package NPM qui lit des fichiers Daplos (.dap) et les convertit en JSON.

Transformations

  • Coordonnées GPS converties en Wgs84
  • Dates converties en JSON
  • Tous les codes reconnus sont complétés avec les libellés en français correspondants

Resources and specifications

  • https://agroedieurope.fr/les-actions/un-cefact/

Installation

npm install

Utilisation

Script de test

Convertir un fichier DAP en JSON :

node test-convert.js -i <fichier-entree.dap> -o <fichier-sortie.json>

Exemple :

node test-convert.js -i "test/testdata/Gaec du Lunerotte.dap" -o "out/result.json"

Utilisation programmatique

import { parseDapDocument, simplifyDapDocumentForExport, parseDaplosFile } from './parse.js';
import fs from 'fs';

// Méthode 1 : À partir d'un Buffer
const buffer = fs.readFileSync('fichier.dap');
const jsonData = parseDaplosFile(buffer);
console.log(jsonData);

// Méthode 2 : À partir d'une chaîne décodée
const decoder = new TextDecoder('windows-1252');
const content = decoder.decode(buffer);
const doc = parseDapDocument(content);
const jsonData = simplifyDapDocumentForExport(doc);
console.log(jsonData);

Utilisation avec TypeScript

Le module inclut des définitions de types TypeScript pour une utilisation type-safe :

import { parseDaplosFile, AEE_CODES } from '@osfarm/agroedei-edifact-daplos-reader';
import type { SimplifiedDapDocument, Crop, Intervention } from '@osfarm/agroedei-edifact-daplos-reader';
import fs from 'fs';

// Parser un fichier DAP
const buffer = fs.readFileSync('fichier.dap');
const data: SimplifiedDapDocument = parseDaplosFile(buffer);

// Accès type-safe aux cultures
data.crops.forEach((crop: Crop) => {
  console.log(`Culture: ${crop.crop_name_fr}`);
  console.log(`Surface: ${crop.area_ha} ha`);
  
  // Accès aux interventions
  crop.interventions?.forEach((intervention: Intervention) => {
    console.log(`  ${intervention.date}: ${intervention.nature_label}`);
  });
});

// Accès aux codes AEE
const inputNatures = AEE_CODES.input_nature;
console.log(inputNatures['ZIU']); // "Herbicide"

Types disponibles :

  • SimplifiedDapDocument : Structure complète du document parsé
  • Crop : Informations sur une culture/parcelle
  • Intervention : Opération agricole effectuée
  • Input : Intrant utilisé dans une intervention
  • FieldPoint : Point GPS d'une parcelle
  • Coordinate : Coordonnées [longitude, latitude] en WGS84

Format des fichiers DAP

Les fichiers DAP (Daplos) sont des fichiers texte à largeur fixe avec encodage Windows-1252 et fins de ligne CRLF.
Chaque ligne commence par une clé de 2 caractères, suivie de champs de largeur fixe concaténés sans séparateurs.

La définition des lignes se trouve dans dict/daplos_2.yml.

Structure du projet

  • parse.js : Module principal de parsing
  • test-convert.js : Script de test pour la conversion
  • dict/ : Fichiers de référence (cultures, unités, spécifications)
  • test/testdata/ : Fichiers d'exemple
  • out/ : Dossier de sortie pour les fichiers JSON générés