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

sakti-parser-fa

v0.8.1

Published

Simple TypeScript library for parsing Indonesian government budget Excel files (Sakti FA)

Readme

sakti-parser-fa

Simple TypeScript library for parsing Indonesian government budget Excel files (Sakti FA format).

npm version TypeScript License: MIT

✨ Features

  • 🌐 Universal - Works seamlessly in Node.js and browsers
  • 🎯 Simple API - Just pass ExcelJS worksheet data
  • 📝 TypeScript - Full type definitions included
  • 📊 Multiple formats - JSON and CSV output
  • 🚀 Zero platform deps - No file system dependencies
  • 🔧 Lightweight - Single purpose, minimal footprint

📦 Installation

npm install sakti-parser-fa

No additional dependencies needed! ExcelJS is included.

🚀 Quick Start

Node.js

import { SaktiParser, SaktiFormatter } from 'sakti-parser-fa';

// Parse Excel file directly with file path
const parser = new SaktiParser();
const result = await parser.parse('budget.xlsx');

// Format output
const formatter = new SaktiFormatter();
const json = formatter.format(result, { format: 'json' });
const csv = formatter.format(result, { format: 'csv' });

console.log('Metadata:', result.metadata);
console.log('Data rows:', result.data.length);

Browser (React/Vue/Vanilla)

import { SaktiParser, SaktiFormatter } from 'sakti-parser-fa';

async function parseExcelFile(file: File) {
  // Parse file directly - no ExcelJS needed!
  const parser = new SaktiParser();
  const result = await parser.parse(file);
  
  const formatter = new SaktiFormatter();
  return formatter.format(result, { format: 'json' });
}

// React example
function FileUpload() {
  const handleFile = async (e) => {
    const file = e.target.files[0];
    const parsed = await parseExcelFile(file);
    console.log(JSON.parse(parsed));
  };
  
  return <input type="file" accept=".xlsx" onChange={handleFile} />;
}

📋 Complete Example

import { SaktiParser, SaktiFormatter, type ParseResult } from 'sakti-parser-fa';

async function processBudget(filePath: string) {
  try {
    // 1. Parse SAKTI Excel file directly
    const parser = new SaktiParser();
    const result: ParseResult = await parser.parse(filePath);

    // 2. Access parsed data
    console.log('Ministry:', result.metadata.kementerian_nama);
    console.log('Period:', result.metadata.periode_text);
    console.log('Budget items:', result.data.length);

    // 3. Export as needed
    const formatter = new SaktiFormatter();
    
    // JSON with metadata
    const json = formatter.format(result, { 
      format: 'json', 
      includeMetadata: true 
    });
    
    // CSV without metadata  
    const csv = formatter.format(result, { 
      format: 'csv', 
      includeMetadata: false 
    });

    return { json, csv, result };
  } catch (error) {
    console.error('Failed to process budget file:', error);
    throw error;
  }
}

// Works with File objects too (browser)
async function processBudgetFromFile(file: File) {
  const parser = new SaktiParser();
  return await parser.parse(file);
}

// Works with ArrayBuffer too
async function processBudgetFromBuffer(buffer: ArrayBuffer) {
  const parser = new SaktiParser();
  return await parser.parse(buffer);
}

📚 API Reference

SaktiParser

Main parser class for processing SAKTI Excel files.

class SaktiParser {
  async parse(input: UniversalInput): Promise<ParseResult>
}

type UniversalInput = string | File | ArrayBuffer;

Parameters:

  • input - File path (string), File object, or ArrayBuffer

Returns: Promise resolving to ParseResult

SaktiFormatter

Formats parse results into different output formats.

class SaktiFormatter {
  format(result: ParseResult, options?: FormatOptions): string
}

interface FormatOptions {
  format?: 'json' | 'csv';          // Output format (default: 'json')
  includeMetadata?: boolean;        // Include metadata (default: true)
}

📊 Data Structure

ParseResult

interface ParseResult {
  metadata: Metadata;       // Document metadata
  data: ParsedData[];      // Parsed budget data
}

Metadata

interface Metadata {
  judul: string;                    // Document title
  periode_text: string;             // Period text (e.g., "Januari 2024")
  periode_bulan: number;            // Month number (1-12)
  periode_tahun: number;            // Year
  kementerian_kode: string;         // Ministry code
  kementerian_nama: string;         // Ministry name
  unit_kode: string;                // Unit code
  unit_nama: string;                // Unit name
  satuan_kerja_kode: string;        // Work unit code
  satuan_kerja_nama: string;        // Work unit name
}

ParsedData

Hierarchical budget data with up to 11 levels:

interface ParsedData {
  _level: number;                   // Current level (1-11)
  _parent: string;                  // Parent reference
  mata_anggaran: string;            // Budget type
  
  // Level 1-11 codes and descriptions
  level_1_kode: string;
  level_1_uraian: string;
  level_2_kode: string;
  level_2_uraian: string;
  // ... up to level_11_kode, level_11_uraian
  
  nilai_rupiah: number;             // Amount in rupiah
  nilai_total: number;              // Total amount
}

🛠️ Development

# Clone repository
git clone https://github.com/username/sakti-parser-fa.git
cd sakti-parser-fa

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Development mode
npm run dev

📝 Requirements

  • Node.js 18+
  • No additional dependencies (ExcelJS included)

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

MIT License - see the LICENSE file for details.

🙋‍♂️ Support


Made with ❤️ for Indonesian government budget transparency