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

tsaef

v0.3.0

Published

TypeScript library for the ArchiMate Exchange Format (AEF)

Downloads

212

Readme

tsaef

npm version npm downloads

TypeScript library for reading, writing, and manipulating ArchiMate Exchange Format (AEF) models.

The ArchiMate Exchange Format is the Open Group's standard XML interchange format, supported by all major ArchiMate tools (Archi, BiZZdesign, Sparx EA, etc.). This is distinct from Archi's proprietary .archimate format — for that, see tsarchi.

Install

npm install tsaef

Quick start

import { TsAEF, Archimate, Serializer } from "tsaef";

// Load an existing AEF model from disk
const tsaef = new TsAEF();
const model = await tsaef.load("model.xml");

// Read elements
console.log(model.getElements());

// Add an element
const app = model.upsertElement(
  "Order Service",
  "ApplicationComponent",
  "Handles order processing",
);

// Add a property
model.addProperty(app, "vendor", "Acme Corp");

// Add a relationship
const cap = model.upsertElement("Order Management", "Capability");
model.upsertRelationship(app.identifier, cap.identifier, "Realization");

// Save back to disk
await tsaef.save("model-updated.xml", model);

Create a model from scratch

import { Archimate, Serializer } from "tsaef";

const model = Archimate.create("My Architecture");
const app = model.upsertElement("Payments Service", "ApplicationComponent");
model.addProperty(app, "status", "Active");

const xml = Serializer.serialize(model);

Validate a model

import { Validator } from "tsaef";

const validator = new Validator();
const result = validator.validate(model, {
  checkReferences: true,
  validateNamespaces: true,
  strict: false,
});

if (!result.success) {
  console.error(result.errors);
}

API

TsAEF

Facade for file I/O.

| Method | Description | | ------------------- | -------------------------------------------------------- | | load(path) | Parse an AEF XML file and return an Archimate instance | | save(path, model) | Serialize and write an Archimate instance to disk |

Archimate

Core domain class. All mutations happen directly on the returned objects.

Static

  • Archimate.create(name, identifier?) — create an empty model

Model metadata

  • getId(), getName()

Elements

  • getElements(), getElementById(id), getElementByName(name)
  • findElements(name, type), findElementsByName(name), findElementsByType(type)
  • findElementsWithProperty(propertyName, propertyValue)
  • upsertElement(name, type, documentation?) — insert or return existing

Relationships

  • getRelationships(), getRelationshipById(id)
  • findRelationshipsForElement(id, direction?) — 'source' | 'target' | 'both'
  • hasRelationship(source, target, type), findRelationship(source, target, type)
  • upsertRelationship(source, target, type) — insert or return existing

Properties

  • getPropertyDefinitions()
  • addProperty(target, name, value) — auto-creates the property definition if needed
  • removeProperty(target, name)
  • getPropertyByName(target, name)

Views (read-only — layout is managed by modelling tools)

  • getViews(), getViewById(id), getViewByName(name)

Utilities

  • generateId() — generate a random AEF-compatible identifier
  • toObject() — return the underlying plain Model object

Parser

  • Parser.parse(xml: string): Archimate — parse an AEF XML string

Serializer

  • Serializer.serialize(model: Archimate): string — produce a valid AEF XML string

Validator

  • validator.validate(model, options?) — returns { success, errors, warnings }

Options: checkReferences (default true), validateNamespaces, strict

Error types

Errors thrown by this library are typed so callers can discriminate them:

import { ParseError, IOError } from "tsaef";

try {
  const model = await tsaef.load("model.xml");
} catch (e) {
  if (e instanceof IOError) {
    /* file not found, permission denied, etc. */
  }
  if (e instanceof ParseError) {
    /* malformed XML */
  }
}

ValidationError is also exported for callers who want to throw on a failed validate() result.

PropertyFormatter

Extensible value formatter for use when populating properties programmatically.

import { PropertyFormatter } from "tsaef";

PropertyFormatter.format("hello world", { type: "string", options: { cleanup: true } });
PropertyFormatter.format("2024-01-01", { type: "date", options: { dateFormat: "yyyy-mm-dd" } });
PropertyFormatter.format("true", {
  type: "boolean",
  options: { trueValue: "Yes", falseValue: "No" },
});

// Register a custom formatter
PropertyFormatter.registerFormatter("myFormatter", (value) => String(value).toUpperCase());

AEF element types

All ArchiMate 3.1 element and relationship types are exported as Zod enums with TypeScript types:

import { ArchiMateElementTypes, ArchiMateRelationshipTypes } from "tsaef";
import type { ArchiMateElementType, ArchiMateRelationshipType } from "tsaef";

Requirements

Node.js 20 or later.

License

ISC