Socket
Book a DemoInstallSign in
Socket

@arcaelas/dynamite

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcaelas/dynamite

![Arcaelas Insiders](https://raw.githubusercontent.com/arcaelas/dist/main/banner/svg/dark.svg#gh-dark-mode-only) ![Arcaelas Insiders](https://raw.githubusercontent.com/arcaelas/dist/main/banner/svg/light.svg#gh-light-mode-only)

1.0.13
latest
Source
npmnpm
Version published
Weekly downloads
139
6850%
Maintainers
1
Weekly downloads
 
Created
Source

Arcaelas Insiders Arcaelas Insiders

Dinamite ORM

A decorator‑first, zero‑boilerplate ORM for DynamoDB (AWS SDK v3).

Auto‑provisions tables · Runs anywhere Node.js runs · Written in TypeScript only

npm size MIT

Contents

Install

npm i @arcaelas/dinamite
# peer deps (unless already installed)
npm i @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb pluralize

Hello World

import {
  connect,
  Table,
  Index, // PK
  CreatedAt,
  UpdatedAt,
  Default,
} from "@arcaelas/dinamite";

connect({
  region: "us-east-1",
  // DynamoDB Local example
  endpoint: "http://localhost:7007",
  credentials: { accessKeyId: "x", secretAccessKey: "x" },
});

class User extends Table {
  @Index() // Partition Key
  declare id: string;

  @Default(() => "")
  declare name: string;

  @CreatedAt() // ISO‑string timestamp
  declare created: string;

  @UpdatedAt()
  declare updated: string;
}

const bob = await User.create({ id: "u1", name: "Bob" });

bob.name = "Robert";
await bob.save(); // upsert

console.log(await User.where());
await bob.destroy();

First call auto‑creates a table users (usersnake + plural).

Decorators Reference

DecoratorPurposeExtras
@Index()Partition key. Exactly one «PK» per model.
@IndexSort()Sort key. Requires previous @Index().
@PrimaryKey()Shortcut: PK + SK on same property.
@Default(fn)Lazy default value, evaluated once per instance.
@Mutate(fn)Sequential value transformer. Runs before validators.
@Validate(fn\[])Sync validator(s); return true or error string.
@NotNull()Built‑in not‑null / not‑empty validation.
@CreatedAt()Timestamp (ISO) on first assignment.
@UpdatedAt()Timestamp (ISO) every assignment.
@Name("alias")Override table or column name.

Execution order: Default → Mutate[] → Validate[]

Model API

Static CRUD

User.create(data); // PutItem (auto‑table‑creation)
User.update(id, patch); // PutItem replacement
User.destroy(id); // DeleteItem
User.where(); // Scan → User[]

Instance CRUD

const u = new User({ id: "42", name: "Neo" });
await u.save(); // inserts

u.name = "The One";
await u.save(); // updates

await u.update({ name: "Thomas" });
await u.destroy();

Serialization

model.toJSON()only fields declared via decorators are included. Undefined values are stripped before marshall() (removeUndefinedValues).

Configuration

Connection

connect({
  region: "…",
  endpoint: "https://…", // optional – for DynamoDB Local
  credentials: {
    accessKeyId: "…",
    secretAccessKey: "…",
  },
});

Naming rules & pluralisation

  • PascalCase / camelCasesnake_case
  • Singular → plural using pluralize

Override with @Name("my_table").

Running on DynamoDB Local

docker run -p 7007:8000 amazon/dynamodb-local

Type Reference

type Inmutable = string | number | boolean | null | object;

type Mutate = (value: any) => Inmutable;
type Default = Inmutable | (() => Inmutable);
type Validate = (value: any) => true | string;

interface Column {
  name: string;
  default?: Default;
  mutate?: Mutate[];
  validate?: Validate[];
  index?: true; // PK
  indexSort?: true; // SK
  unique?: true; // not yet enforced
}

interface WrapperEntry {
  name: string; // physical table
  columns: Map<string | symbol, Column>; // property → Column
}

Internal state lives in src/core/wrapper.ts.

Recipes

Soft‑delete flag

class Post extends Table {
  @Index() declare id: string;
  @Default(() => false) declare deleted: boolean;

  async softDelete() {
    this.deleted = true;
    await this.save();
  }
}

Custom mutator – email normalisation

import { Mutate } from "@arcaelas/dinamite";

const lower: Mutate = (v) => String(v).toLowerCase();

class Subscriber extends Table {
  @Index() declare id: string;
  @Mutate(lower) declare email: string;
}

Using DynamoDB Streams + Lambda

Because tables are created at runtime you can safely deploy stacks without resources, then subscribe Lambdas to the physical table names emitted by Dinamite (Userusers, unless overridden).

Troubleshooting

ErrorExplanation & fix
Metadata no encontradaModel file imported before decorators executed – avoid circular imports; ensure connect() runs first.
PartitionKey faltanteNo @Index() in the model. Add one.
Two keys can not have the same namePK & SK attribute clash. Use @PrimaryKey() or distinct column names.
UnrecognizedClientExceptionWrong credentials / DynamoDB Local not running.

Contributing

  • Fork → feature → PR. Conventional commits (feat:, fix:…).
  • yarn test must pass (Jest + ESLint).
  • Document new features in this README.

Made with ❤️ by Miguel Alejandro – MIT License.

FAQs

Package last updated on 01 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.