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

@vytches/ddd-acl

v0.28.0

Published

Anti-Corruption Layer for external system integration

Downloads

345

Readme

@vytches/ddd-acl

npm version TypeScript License: MIT

Anti-Corruption Layer for external system integration

Provides adapters, translators, registries, and middleware to protect your domain model from external system changes.

Installation

pnpm add @vytches/ddd-acl

What's included

Application layer

| Export | Kind | Description | | ------------------------ | --------- | ----------------------------------------- | | ApplicationError | class | Base error for application-layer failures | | BaseApplicationService | class | Base class for application services | | IApplicationService | interface | Contract for application services |

Errors

| Export | Kind | Description | | ---------------------- | ----- | --------------------------------------- | | ACLError | class | General ACL operation failure | | AdapterNotFoundError | class | No adapter registered for given context | | TranslationError | class | Model translation failure |

Middleware

| Export | Kind | Description | | ------------------- | ----- | --------------------------------------------------------------------- | | BaseACLMiddleware | class | Base class for ACL middleware (extend to add cross-cutting behaviour) |

Registries

| Export | Kind | Description | | ------------------------- | --------- | ------------------------------------------------------------------------------------ | | ACLRegistry | class | Global registry of ACL adapters; supports fromDefinitions(), importFromContext() | | BaseACLRegistry | class | Foundation class for custom registries | | ContextACLRegistry | class | Bounded-context-scoped registry | | VersionedACLRegistry | class | Registry that supports multiple adapter versions | | VersionedACLAdapter | class | Adapter with version tracking | | ACLRegistrationMetadata | interface | Metadata stored alongside a registered adapter | | ImportOptions | interface | Options for ACLRegistry.importFromContext() |

Adapters

| Export | Kind | Description | | -------------------- | --------- | ------------------------------------------------------- | | BaseACLAdapter | class | Abstract base — extend and implement performOperation | | SimpleACLAdapter | class | Concrete adapter for straightforward integrations | | EnhancedACLAdapter | class | Adapter with built-in middleware pipeline support | | defineACLAdapter | function | Factory helper to create AdapterDefinition objects | | AdapterDefinition | interface | Shape used by defineACLAdapter and fromDefinitions |

Translator

| Export | Kind | Description | | --------------------- | ----- | ------------------------------------------------------------- | | BaseModelTranslator | class | Abstract translator — implement toExternal / fromExternal |

Typed operations

| Export | Kind | Description | | ---------------- | ----- | ------------------------------------------------------- | | TypedOperation | class | Wraps an operation name with input/output generic types |

Interfaces

| Export | Kind | Description | | --------------------- | --------- | --------------------------------------------------- | | IACLAdapter | interface | Core adapter contract | | IEnhancedACLAdapter | interface | Adapter with middleware support | | IExternalAPI | interface | External system communication contract | | IModelTranslator | interface | Bidirectional translation contract | | ACLMiddleware | interface | Middleware function signature | | ACLContextInfo | interface | Metadata about the external system context | | ExecuteOptions | interface | Per-call options (version, timeout, correlationId…) |

Quick start

import {
  SimpleACLAdapter,
  BaseModelTranslator,
  ACLRegistry,
  defineACLAdapter,
} from '@vytches/ddd-acl';

interface Order {
  id: string;
  total: number;
}
interface ExternalOrder {
  order_id: string;
  amount: number;
}

class OrderTranslator extends BaseModelTranslator<Order, ExternalOrder> {
  toExternal(o: Order): ExternalOrder {
    return { order_id: o.id, amount: o.total };
  }
  fromExternal(e: ExternalOrder): Order {
    return { id: e.order_id, total: e.amount };
  }
}

const adapter = new SimpleACLAdapter(
  { contextName: 'Payments', externalSystem: 'PaymentsAPI' },
  new OrderTranslator(),
  paymentsApiClient,
  ['create', 'refund']
);

// Declarative registration
const registry = ACLRegistry.fromDefinitions([
  defineACLAdapter({ context: 'Payments', adapter }),
]);

const resolved = registry.resolve('Payments');
const result = await resolved.execute('create', order);

Middleware

import { BaseACLMiddleware } from '@vytches/ddd-acl';

class LoggingMiddleware extends BaseACLMiddleware {
  async execute(operation, model, options, next) {
    console.log(`ACL ${operation} started`);
    const result = await next();
    console.log(`ACL ${operation} done`);
    return result;
  }
}

// Attach to EnhancedACLAdapter
enhancedAdapter.use(new LoggingMiddleware());

Model translation with validation

import { BaseModelTranslator } from '@vytches/ddd-acl';
import { Result } from '@vytches/ddd-utils';

class ValidatedOrderTranslator extends BaseModelTranslator<
  Order,
  ExternalOrder
> {
  toExternal(o: Order): ExternalOrder {
    /* ... */
  }
  fromExternal(e: ExternalOrder): Order {
    /* ... */
  }

  validateDomain(o: Order): Result<void, Error> {
    if (!o.id) return Result.fail(new Error('Order ID required'));
    return Result.ok();
  }
}

Package boundaries

@vytches/ddd-acl has no runtime dependencies on other @vytches/ddd-* packages (uses only native TypeScript). Consumers typically also install @vytches/ddd-utils for the Result type.

License

MIT