@arcaelas/dynamite 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SECURITY.md +41 -0
- package/build/index.d.ts +130 -0
- package/build/index.js +2 -0
- package/build/index.js.map +7 -0
- package/package.json +35 -11
- package/tsconfig.json +5 -5
- package/.eslintrc.js +0 -0
- package/.prettierrc +0 -0
- package/__tests__/crud.spec.ts +0 -77
- package/__tests__/decorators.spec.ts +0 -134
- package/__tests__/instance-crud.spec.ts +0 -86
- package/jest.config.ts +0 -23
- package/src/core/table.ts +0 -226
- package/src/core/wrapper.ts +0 -103
- package/src/decorators/created_at.ts +0 -17
- package/src/decorators/default.ts +0 -56
- package/src/decorators/index.ts +0 -26
- package/src/decorators/index_sort.ts +0 -32
- package/src/decorators/mutate.ts +0 -54
- package/src/decorators/name.ts +0 -50
- package/src/decorators/not_null.ts +0 -21
- package/src/decorators/primary_key.ts +0 -26
- package/src/decorators/updated_at.ts +0 -18
- package/src/decorators/validate.ts +0 -59
- package/src/index.ts +0 -14
- package/src/utils/naming.ts +0 -12
package/SECURITY.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Security Policies and Procedures
|
|
2
|
+
|
|
3
|
+
This document outlines security procedures and general policies for the `standard`
|
|
4
|
+
project.
|
|
5
|
+
|
|
6
|
+
- [Reporting a Bug](https://github.com/arcaelas/dynamite/issues)
|
|
7
|
+
- [Read Wiki - BETA](https://github.com/arcaelas/dynamite/wiki)
|
|
8
|
+
|
|
9
|
+
## Reporting a Bug
|
|
10
|
+
|
|
11
|
+
The `standard` team and community take all security bugs in `standard` seriously.
|
|
12
|
+
Thank you for improving the security of `standard`. We appreciate your efforts and
|
|
13
|
+
responsible disclosure and will make every effort to acknowledge your
|
|
14
|
+
contributions.
|
|
15
|
+
|
|
16
|
+
Report security bugs by emailing the lead maintainer at arcaelas12@gmail.com.
|
|
17
|
+
|
|
18
|
+
The lead maintainer will acknowledge your email within 48 hours, and will send a
|
|
19
|
+
more detailed response within 48 hours indicating the next steps in handling
|
|
20
|
+
your report. After the initial reply to your report, the security team will
|
|
21
|
+
endeavor to keep you informed of the progress towards a fix and full
|
|
22
|
+
announcement, and may ask for additional information or guidance.
|
|
23
|
+
|
|
24
|
+
Report security bugs in third-party modules to the person or team maintaining
|
|
25
|
+
the module.
|
|
26
|
+
|
|
27
|
+
## Disclosure Policy
|
|
28
|
+
|
|
29
|
+
When the security team receives a security bug report, they will assign it to a
|
|
30
|
+
primary handler. This person will coordinate the fix and release process,
|
|
31
|
+
involving the following steps:
|
|
32
|
+
|
|
33
|
+
- Confirm the problem and determine the affected versions.
|
|
34
|
+
- Audit code to find any potential similar problems.
|
|
35
|
+
- Prepare fixes for all releases still under maintenance. These fixes will be
|
|
36
|
+
released as fast as possible to npm.
|
|
37
|
+
|
|
38
|
+
## Comments on this Policy
|
|
39
|
+
|
|
40
|
+
If you have suggestions on how this process could be improved please submit a
|
|
41
|
+
pull request.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
declare module "core/wrapper" {
|
|
2
|
+
export type Inmutable = string | number | boolean | null | object;
|
|
3
|
+
export type Mutate = (value: any) => Inmutable;
|
|
4
|
+
export type Default = Inmutable | (() => Inmutable);
|
|
5
|
+
export type Validate = (value: any) => true | string;
|
|
6
|
+
export interface Column {
|
|
7
|
+
/** nombre físico en la tabla (DynamoDB) */
|
|
8
|
+
name: string;
|
|
9
|
+
default?: Default;
|
|
10
|
+
mutate?: Mutate[];
|
|
11
|
+
validate?: Validate[];
|
|
12
|
+
index?: true;
|
|
13
|
+
indexSort?: true;
|
|
14
|
+
unique?: true;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuración completa por tabla
|
|
18
|
+
*/
|
|
19
|
+
export interface WrapperEntry {
|
|
20
|
+
/** Nombre físico de la tabla (snake_plural o @Name) */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Columnas asociadas a la clase. key = propiedad (string|symbol) */
|
|
23
|
+
columns: Map<string | symbol, Column>;
|
|
24
|
+
}
|
|
25
|
+
export type Wrapper = Map<Function, WrapperEntry>;
|
|
26
|
+
/**
|
|
27
|
+
* Mapa singleton (clase → configuración)
|
|
28
|
+
* Exportado como default para uso interno de la librería.
|
|
29
|
+
*/
|
|
30
|
+
const wrapper: Wrapper;
|
|
31
|
+
export default wrapper;
|
|
32
|
+
/**
|
|
33
|
+
* Buffer privado en cada instancia de Table donde se guardan
|
|
34
|
+
* los valores procesados por los setters virtuales.
|
|
35
|
+
*
|
|
36
|
+
* Se exporta para que los decoradores puedan leer/escribir,
|
|
37
|
+
* pero **NO** se vuelve a exportar desde la raíz del paquete.
|
|
38
|
+
*/
|
|
39
|
+
export const STORE: unique symbol;
|
|
40
|
+
/**
|
|
41
|
+
* Asegura que exista la entrada en el wrapper para la clase dada.
|
|
42
|
+
* Devuelve la entrada (recién creada o existente).
|
|
43
|
+
*/
|
|
44
|
+
export function ensureConfig(ctor: Function, tableName: string): WrapperEntry;
|
|
45
|
+
/**
|
|
46
|
+
* Obtiene (o crea) el objeto Column para una propiedad concreta.
|
|
47
|
+
*/
|
|
48
|
+
export function ensureColumn(entry: WrapperEntry, prop: string | symbol, columnName: string): Column;
|
|
49
|
+
}
|
|
50
|
+
declare module "core/table" {
|
|
51
|
+
import { DynamoDBClientConfig } from "@aws-sdk/client-dynamodb";
|
|
52
|
+
import { STORE, WrapperEntry } from "core/wrapper";
|
|
53
|
+
export function connect(cfg: DynamoDBClientConfig): void;
|
|
54
|
+
export default class Table<T extends object = object> {
|
|
55
|
+
private [STORE];
|
|
56
|
+
constructor(data?: Partial<T>);
|
|
57
|
+
toJSON(): Record<string, unknown>;
|
|
58
|
+
save(): Promise<this>;
|
|
59
|
+
update(patch: Partial<T>): Promise<this>;
|
|
60
|
+
destroy(): Promise<void>;
|
|
61
|
+
static create<M extends Table>(this: new (d?: Partial<M>) => M, data: Partial<M>): Promise<M>;
|
|
62
|
+
static update<M extends Table>(this: new (d?: Partial<M>) => M, id: string, record: Partial<M>): Promise<void>;
|
|
63
|
+
static destroy<M extends Table>(this: new () => M, id: string): Promise<null>;
|
|
64
|
+
static where<M extends Table>(this: new (d?: any) => M): Promise<M[]>;
|
|
65
|
+
}
|
|
66
|
+
export { STORE };
|
|
67
|
+
export type { WrapperEntry };
|
|
68
|
+
}
|
|
69
|
+
declare module "utils/naming" {
|
|
70
|
+
export function toSnakePlural(input: string): string;
|
|
71
|
+
}
|
|
72
|
+
declare module "decorators/default" {
|
|
73
|
+
export default function Default(factory: () => unknown): PropertyDecorator;
|
|
74
|
+
}
|
|
75
|
+
declare module "decorators/index" {
|
|
76
|
+
export default function Index(): PropertyDecorator;
|
|
77
|
+
}
|
|
78
|
+
declare module "decorators/index_sort" {
|
|
79
|
+
export default function IndexSort(): PropertyDecorator;
|
|
80
|
+
}
|
|
81
|
+
declare module "decorators/mutate" {
|
|
82
|
+
import type { Mutate } from "core/wrapper";
|
|
83
|
+
export default function Mutate(fn: Mutate): PropertyDecorator;
|
|
84
|
+
}
|
|
85
|
+
declare module "decorators/name" {
|
|
86
|
+
export default function Name(label: string): ClassDecorator & PropertyDecorator;
|
|
87
|
+
}
|
|
88
|
+
declare module "decorators/validate" {
|
|
89
|
+
export default function Validate(validators: ((v: unknown) => true | string) | ((v: unknown) => true | string)[]): PropertyDecorator;
|
|
90
|
+
}
|
|
91
|
+
declare module "decorators/created_at" {
|
|
92
|
+
/**
|
|
93
|
+
* Asigna automáticamente la fecha de creación en nuevas instancias.
|
|
94
|
+
*/
|
|
95
|
+
export default function CreatedAt(): PropertyDecorator;
|
|
96
|
+
}
|
|
97
|
+
declare module "decorators/not_null" {
|
|
98
|
+
/**
|
|
99
|
+
* Decorador wrapper que asegura no-null / no-empty.
|
|
100
|
+
*/
|
|
101
|
+
export default function NotNull(): PropertyDecorator;
|
|
102
|
+
}
|
|
103
|
+
declare module "decorators/primary_key" {
|
|
104
|
+
/**
|
|
105
|
+
* Atajo para definir clave primaria compuesta (PK + SK).
|
|
106
|
+
* El parámetro `name` queda reservado por si en el futuro
|
|
107
|
+
* se almacena un identificador lógico de índice, pero hoy
|
|
108
|
+
* NO se pasa a ningún decorador interno.
|
|
109
|
+
*/
|
|
110
|
+
export default function PrimaryKey(name?: string): PropertyDecorator;
|
|
111
|
+
}
|
|
112
|
+
declare module "decorators/updated_at" {
|
|
113
|
+
/**
|
|
114
|
+
* Actualiza automáticamente la marca temporal en cada asignación.
|
|
115
|
+
*/
|
|
116
|
+
export default function UpdatedAt(): PropertyDecorator;
|
|
117
|
+
}
|
|
118
|
+
declare module "index" {
|
|
119
|
+
export { connect, default as Table } from "core/table";
|
|
120
|
+
export { default as Default } from "decorators/default";
|
|
121
|
+
export { default as Index } from "decorators/index";
|
|
122
|
+
export { default as IndexSort } from "decorators/index_sort";
|
|
123
|
+
export { default as Mutate } from "decorators/mutate";
|
|
124
|
+
export { default as Name } from "decorators/name";
|
|
125
|
+
export { default as Validate } from "decorators/validate";
|
|
126
|
+
export { default as CreatedAt } from "decorators/created_at";
|
|
127
|
+
export { default as NotNull } from "decorators/not_null";
|
|
128
|
+
export { default as PrimaryKey } from "decorators/primary_key";
|
|
129
|
+
export { default as UpdatedAt } from "decorators/updated_at";
|
|
130
|
+
}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var R=Object.create;var P=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var F=(r,t)=>{for(var e in t)P(r,e,{get:t[e],enumerable:!0})},v=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!W.call(r,o)&&o!==e&&P(r,o,{get:()=>t[o],enumerable:!(n=$(t,o))||n.enumerable});return r};var B=(r,t,e)=>(e=r!=null?R(q(r)):{},v(t||!r||!r.__esModule?P(e,"default",{value:r,enumerable:!0}):e,r)),L=r=>v(P({},"__esModule",{value:!0}),r);var _={};F(_,{CreatedAt:()=>M,Default:()=>h,Index:()=>g,IndexSort:()=>b,Mutate:()=>x,Name:()=>D,NotNull:()=>N,PrimaryKey:()=>O,Table:()=>w,UpdatedAt:()=>k,Validate:()=>S,connect:()=>I});module.exports=L(_);var c=require("@aws-sdk/client-dynamodb"),p=require("@aws-sdk/util-dynamodb");var C=new Map,E=C,u=Symbol("dynamite:values");function f(r,t){let e=C.get(r);return e||(e={name:t,columns:new Map},C.set(r,e)),e}function m(r,t,e){let n=r.columns.get(t);return n||(n={name:e,mutate:[],validate:[]},r.columns.set(t,n)),n}var l;function I(r){l=new c.DynamoDBClient(r)}async function j(r){if(!l)throw new Error("connect() no llamado");let t=E.get(r);if(!t)throw new Error(`Clase ${r.name} no registrada en wrapper`);let e=[...t.columns.values()],n=e.find(d=>d.index);if(!n)throw new Error(`PartitionKey faltante en ${r.name}`);let o=e.find(d=>d.indexSort),a=new Map;a.set(n.name,"S"),o&&a.set(o.name,"S");let i=[{AttributeName:n.name,KeyType:"HASH"}];o&&o.name!==n.name&&i.push({AttributeName:o.name,KeyType:"RANGE"}),await l.send(new c.CreateTableCommand({TableName:t.name,BillingMode:"PAY_PER_REQUEST",AttributeDefinitions:[...a].map(([d,K])=>({AttributeName:d,AttributeType:K})),KeySchema:i}))}u;var w=class{constructor(t={}){T(),y(Object.getPrototypeOf(this).constructor).columns.forEach(n=>{n.name in t||(this[n.name]=void 0)}),Object.assign(this,t)}toJSON(){let t=y(Object.getPrototypeOf(this).constructor),e=this[u]??{},n={};for(let[o,a]of t.columns)o in e?n[a.name]=e[o]:o in this&&(n[a.name]=this[o]);return n}async save(){let t=this.id,e=this.constructor,n=this.toJSON();if(t==null){delete n.id;let o=await e.create(n);Object.assign(this,o)}else await e.update(String(t),n);return this}async update(t){let e=this.id;if(e==null)throw new Error("update() requiere id");return Object.assign(this,t),await this.constructor.update(String(e),this.toJSON()),this}async destroy(){let t=this.id;if(t==null)throw new Error("destroy() requiere id");await this.constructor.destroy(String(t))}static async create(t){let e=y(this),n=new this(t).toJSON(),o=()=>l.send(new c.PutItemCommand({TableName:e.name,Item:(0,p.marshall)(n,{removeUndefinedValues:!0})}));try{await o()}catch(a){if(a?.name==="ResourceNotFoundException")await j(this),await o();else throw a}return new this(t)}static async update(t,e){let n=y(this),o={...e,id:t},a=()=>l.send(new c.PutItemCommand({TableName:n.name,Item:(0,p.marshall)(o,{removeUndefinedValues:!0})}));try{await a()}catch(i){if(i?.name==="ResourceNotFoundException")await j(this),await a();else throw i}}static async destroy(t){T();try{await l.send(new c.DeleteItemCommand({TableName:y(this).name,Key:(0,p.marshall)({id:t})}))}catch(e){if(e.name==="ResourceNotFoundException")return null;throw e}return null}static async where(){T();try{return((await l.send(new c.ScanCommand({TableName:y(this).name}))).Items??[]).map(e=>new this((0,p.unmarshall)(e)))}catch(t){if(t.name==="ResourceNotFoundException")return[];throw t}}};function T(){if(!l)throw new Error("connect() debe llamarse antes de usar Table")}function y(r){let t=E.get(r);if(!t)throw new Error(`Metadata no encontrada para ${r.name}`);return t}var A=B(require("pluralize"));function s(r){let t=r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase();return(0,A.default)(t)}function h(r){if(typeof r!="function")throw new TypeError("@Default requiere una funci\xF3n factory");return(t,e)=>{let n=t.constructor,o=f(n,s(n.name)),a=m(o,e,String(e));if(a.default)throw new Error(`@Default duplicado en '${String(e)}'`);a.default=r,Object.getOwnPropertyDescriptor(n.prototype,e)?.set||U(n.prototype,a,e)}}function U(r,t,e){Object.defineProperty(r,e,{get(){return(this[u]??{})[e]},set(n){let o=this[u]??={};if(n===void 0&&t.default!==void 0&&(n=typeof t.default=="function"?t.default():t.default),t.mutate)for(let a of t.mutate)n=a(n);if(t.validate)for(let a of t.validate){let i=a(n);if(i!==!0)throw new Error(typeof i=="string"?i:"Validaci\xF3n fallida")}o[e]=n},enumerable:!0,configurable:!0})}function g(){return(r,t)=>{let e=r.constructor,n=f(e,s(e.name)),o=[...n.columns.values()].find(i=>i.index);if(o&&o!==n.columns.get(t))throw new Error(`La tabla ${e.name} ya tiene PartitionKey (${o.name})`);let a=m(n,t,String(t));a.index=!0}}function b(){return(r,t)=>{let e=r.constructor,n=f(e,s(e.name));if(![...n.columns.values()].some(d=>d.index))throw new Error(`PartitionKey no definido en ${e.name}; declara @Index primero`);let a=[...n.columns.values()].find(d=>d.indexSort);if(a&&a!==n.columns.get(t))throw new Error(`La tabla ${e.name} ya tiene SortKey (${a.name})`);let i=m(n,t,String(t));i.indexSort=!0}}function x(r){if(typeof r!="function")throw new TypeError("@Mutate requiere funci\xF3n");return(t,e)=>{let n=t.constructor,o=f(n,s(n.name)),a=m(o,e,String(e));a.mutate??=[],a.mutate.push(r),Object.getOwnPropertyDescriptor(n.prototype,e)?.set||H(n.prototype,a,e)}}function H(r,t,e){Object.defineProperty(r,e,{get(){return(this[u]??{})[e]},set(n){let o=this[u]??={};if(n===void 0&&t.default!==void 0&&(n=typeof t.default=="function"?t.default():t.default),t.mutate)for(let a of t.mutate)n=a(n);if(t.validate)for(let a of t.validate){let i=a(n);if(i!==!0)throw new Error(typeof i=="string"?i:"Validaci\xF3n fallida")}o[e]=n},enumerable:!0,configurable:!0})}function D(r){if(!r||typeof r!="string")throw new TypeError("@Name requiere una cadena no vac\xEDa");return(t,e)=>{let n=e===void 0?t:t.constructor,o=f(n,s(n.name));if(e===void 0){let a=s(n.name);if(o.name!==a&&o.name!==r&&o.name)throw new Error(`La clase ${n.name} ya tiene un @Name distinto (${o.name})`);o.name=r}else{let a=m(o,e,r);if(a.name&&a.name!==r)throw new Error(`La columna '${String(e)}' ya tiene @Name distinto (${a.name})`);a.name=r}}}function S(r){let t=Array.isArray(r)?r:[r];if(!t.length||t.some(e=>typeof e!="function"))throw new TypeError("@Validate requiere funciones");return(e,n)=>{let o=e.constructor,a=f(o,s(o.name)),i=m(a,n,String(n));i.validate??=[],i.validate.push(...t),Object.getOwnPropertyDescriptor(o.prototype,n)?.set||J(o.prototype,i,n)}}function J(r,t,e){Object.defineProperty(r,e,{get(){return(this[u]??{})[e]},set(n){let o=this[u]??={};if(n===void 0&&t.default!==void 0&&(n=typeof t.default=="function"?t.default():t.default),t.mutate)for(let a of t.mutate)n=a(n);if(t.validate)for(let a of t.validate){let i=a(n);if(i!==!0)throw new Error(typeof i=="string"?i:"Validaci\xF3n fallida")}o[e]=n},enumerable:!0,configurable:!0})}function M(){return h(()=>new Date().toISOString())}function N(){return S((r,t)=>!(r==null||typeof r=="string"&&r.trim()===""))}function O(r="primary"){if(typeof r!="string"||!r.trim())throw new TypeError("@PrimaryKey requiere un nombre de \xEDndice v\xE1lido");return(t,e)=>{g()(t,e),b()(t,e)}}function k(){return x(()=>new Date().toISOString())}0&&(module.exports={CreatedAt,Default,Index,IndexSort,Mutate,Name,NotNull,PrimaryKey,Table,UpdatedAt,Validate,connect});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/core/table.ts", "../src/core/wrapper.ts", "../src/utils/naming.ts", "../src/decorators/default.ts", "../src/decorators/index.ts", "../src/decorators/index_sort.ts", "../src/decorators/mutate.ts", "../src/decorators/name.ts", "../src/decorators/validate.ts", "../src/decorators/created_at.ts", "../src/decorators/not_null.ts", "../src/decorators/primary_key.ts", "../src/decorators/updated_at.ts"],
|
|
4
|
+
"sourcesContent": ["export { connect, default as Table } from \"./core/table\";\n\n// Decoradores\nexport { default as Default } from \"./decorators/default\";\nexport { default as Index } from \"./decorators/index\";\nexport { default as IndexSort } from \"./decorators/index_sort\";\nexport { default as Mutate } from \"./decorators/mutate\";\nexport { default as Name } from \"./decorators/name\";\nexport { default as Validate } from \"./decorators/validate\";\n\nexport { default as CreatedAt } from \"./decorators/created_at\";\nexport { default as NotNull } from \"./decorators/not_null\";\nexport { default as PrimaryKey } from \"./decorators/primary_key\";\nexport { default as UpdatedAt } from \"./decorators/updated_at\";\n", "/* src/core/table.ts\n * Dinamite ORM \u2014 runtime\n * --------------------------------------------------\n * CRUD + autocreaci\u00F3n de tablas (DynamoDB v3)\n * Serializaci\u00F3n estricta mediante toJSON()\n * \u00A9 2025 Miguel Alejandro\n */\nimport {\n CreateTableCommand,\n DeleteItemCommand,\n DynamoDBClient,\n DynamoDBClientConfig,\n PutItemCommand,\n ScanCommand,\n} from \"@aws-sdk/client-dynamodb\";\nimport { marshall, unmarshall } from \"@aws-sdk/util-dynamodb\";\nimport wrapper, { STORE, WrapperEntry } from \"./wrapper\";\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Conexi\u00F3n global \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\nlet client: DynamoDBClient | undefined;\nexport function connect(cfg: DynamoDBClientConfig): void {\n client = new DynamoDBClient(cfg);\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Creaci\u00F3n autom\u00E1tica de tablas a partir del wrapper \u2500\u2500\u2500\u2500\u2500\u2500 */\nasync function createTable(ctor: Function): Promise<void> {\n if (!client) throw new Error(\"connect() no llamado\");\n const meta = wrapper.get(ctor);\n if (!meta) throw new Error(`Clase ${ctor.name} no registrada en wrapper`);\n\n const cols = [...meta.columns.values()];\n const pk = cols.find((c) => c.index);\n if (!pk) throw new Error(`PartitionKey faltante en ${ctor.name}`);\n\n const sk = cols.find((c) => c.indexSort);\n\n const attr = new Map<string, \"S\" | \"N\" | \"B\">();\n attr.set(pk.name, \"S\");\n if (sk) attr.set(sk.name, \"S\");\n\n type KS = { AttributeName: string; KeyType: \"HASH\" | \"RANGE\" };\n const schema: KS[] = [{ AttributeName: pk.name, KeyType: \"HASH\" }];\n if (sk && sk.name !== pk.name)\n schema.push({ AttributeName: sk.name, KeyType: \"RANGE\" });\n\n await client.send(\n new CreateTableCommand({\n TableName: meta.name,\n BillingMode: \"PAY_PER_REQUEST\",\n AttributeDefinitions: [...attr].map(([AttributeName, AttributeType]) => ({\n AttributeName,\n AttributeType,\n })),\n KeySchema: schema,\n })\n );\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\nexport default class Table<T extends object = object> {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n private [STORE]!: { [K in keyof T]?: T[K] };\n\n constructor(data: Partial<T> = {}) {\n requireClient();\n const meta = mustMeta(Object.getPrototypeOf(this).constructor);\n\n /* defaults via setters */\n meta.columns.forEach((c) => {\n if (!(c.name in data)) (this as any)[c.name] = undefined;\n });\n\n Object.assign(this, data);\n }\n\n /* -------- serializa SOLO columnas v\u00E1lidas -------- */\n toJSON(): Record<string, unknown> {\n const meta = mustMeta(Object.getPrototypeOf(this).constructor);\n const buf = (this as any)[STORE] ?? {};\n const out: Record<string, unknown> = {};\n\n for (const [prop, col] of meta.columns) {\n if (prop in buf) out[col.name] = buf[prop];\n else if (prop in this) out[col.name] = (this as any)[prop];\n }\n return out;\n }\n\n /* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 M\u00E9todos de instancia \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n async save(): Promise<this> {\n // @ts-ignore\n const id: unknown = this.id;\n const Ctor = this.constructor as typeof Table<any>;\n const record = this.toJSON();\n\n if (id === undefined || id === null) {\n delete (record as any).id;\n const fresh = await (Ctor as any).create(record);\n Object.assign(this, fresh);\n } else {\n await (Ctor as any).update(String(id), record);\n }\n return this;\n }\n\n async update(patch: Partial<T>): Promise<this> {\n // @ts-ignore\n const id: unknown = this.id;\n if (id === undefined || id === null)\n throw new Error(\"update() requiere id\");\n\n Object.assign(this, patch);\n const Ctor = this.constructor as typeof Table<any>;\n await (Ctor as any).update(String(id), this.toJSON());\n return this;\n }\n\n async destroy(): Promise<void> {\n // @ts-ignore\n const id: unknown = this.id;\n if (id === undefined || id === null)\n throw new Error(\"destroy() requiere id\");\n const Ctor = this.constructor as typeof Table<any>;\n await (Ctor as any).destroy(String(id));\n }\n\n /* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 CRUD est\u00E1ticos \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n static async create<M extends Table>(\n this: new (d?: Partial<M>) => M,\n data: Partial<M>\n ): Promise<M> {\n const meta = mustMeta(this);\n const payload = new this(data).toJSON(); // filtrado\n\n const put = () =>\n client!.send(\n new PutItemCommand({\n TableName: meta.name,\n Item: marshall(payload, { removeUndefinedValues: true }),\n })\n );\n\n try {\n await put();\n } catch (err: any) {\n if (err?.name === \"ResourceNotFoundException\") {\n await createTable(this);\n await put();\n } else throw err;\n }\n return new this(data);\n }\n\n static async update<M extends Table>(\n this: new (d?: Partial<M>) => M,\n id: string,\n record: Partial<M> // \u2190 ya es JSON completo desde instancia\n ): Promise<void> {\n const meta = mustMeta(this);\n const payload = { ...record, id };\n\n const put = () =>\n client!.send(\n new PutItemCommand({\n TableName: meta.name,\n Item: marshall(payload, { removeUndefinedValues: true }),\n })\n );\n\n try {\n await put();\n } catch (err: any) {\n if (err?.name === \"ResourceNotFoundException\") {\n await createTable(this);\n await put();\n } else throw err;\n }\n }\n\n static async destroy<M extends Table>(\n this: new () => M,\n id: string\n ): Promise<null> {\n requireClient();\n try {\n await client!.send(\n new DeleteItemCommand({\n TableName: mustMeta(this).name,\n Key: marshall({ id }),\n })\n );\n } catch (err: any) {\n if (err.name === \"ResourceNotFoundException\") return null;\n throw err;\n }\n return null;\n }\n\n static async where<M extends Table>(this: new (d?: any) => M): Promise<M[]> {\n requireClient();\n try {\n const res = await client!.send(\n new ScanCommand({ TableName: mustMeta(this).name })\n );\n return (res.Items ?? []).map((i) => new this(unmarshall(i)));\n } catch (err: any) {\n if (err.name === \"ResourceNotFoundException\") return [];\n throw err;\n }\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Utilidades internas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\nfunction requireClient(): void {\n if (!client) throw new Error(\"connect() debe llamarse antes de usar Table\");\n}\nfunction mustMeta(ctor: Function): WrapperEntry {\n const meta = wrapper.get(ctor);\n if (!meta) throw new Error(`Metadata no encontrada para ${ctor.name}`);\n return meta;\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Exportaciones internas \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\nexport { STORE };\nexport type { WrapperEntry };\n", "/* src/core/wrapper.ts\n * -------------------------------------------------\n * Registro central (in-memory) de la configuraci\u00F3n\n * declarativa de cada modelo. Agn\u00F3stico: no depende\n * de DynamoDB ni de otros m\u00F3dulos de la librer\u00EDa.\n *\n * \u00A9 2025 Miguel Alejandro\n */\n\n/* ------------------------------------------------------------------ */\n/* 1. Tipos utilitarios */\n/* ------------------------------------------------------------------ */\nexport type Inmutable = string | number | boolean | null | object;\n\nexport type Mutate = (value: any) => Inmutable;\nexport type Default = Inmutable | (() => Inmutable);\nexport type Validate = (value: any) => true | string;\n\n/* ------------------------------------------------------------------ */\n/* 2. Descripci\u00F3n de columna y tabla */\n/* ------------------------------------------------------------------ */\nexport interface Column {\n /** nombre f\u00EDsico en la tabla (DynamoDB) */\n name: string;\n\n /* Decoradores b\u00E1sicos */\n default?: Default;\n mutate?: Mutate[];\n validate?: Validate[];\n\n /* Metadatos de \u00EDndice / unicidad */\n index?: true; // Partition Key\n indexSort?: true; // Sort Key\n unique?: true; // constraint l\u00F3gico (no se valida en Dynamo)\n}\n\n/**\n * Configuraci\u00F3n completa por tabla\n */\nexport interface WrapperEntry {\n /** Nombre f\u00EDsico de la tabla (snake_plural o @Name) */\n name: string;\n\n /** Columnas asociadas a la clase. key = propiedad (string|symbol) */\n columns: Map<string | symbol, Column>;\n}\n\n/* ------------------------------------------------------------------ */\n/* 3. Contenedor global */\n/* ------------------------------------------------------------------ */\nexport type Wrapper = Map<Function, WrapperEntry>;\n\n/**\n * Mapa singleton (clase \u2192 configuraci\u00F3n)\n * Exportado como default para uso interno de la librer\u00EDa.\n */\nconst wrapper: Wrapper = new Map();\nexport default wrapper;\n\n/* ------------------------------------------------------------------ */\n/* 4. S\u00EDmbolo de almacenamiento de valores reales */\n/* ------------------------------------------------------------------ */\n/**\n * Buffer privado en cada instancia de Table donde se guardan\n * los valores procesados por los setters virtuales.\n *\n * Se exporta para que los decoradores puedan leer/escribir,\n * pero **NO** se vuelve a exportar desde la ra\u00EDz del paquete.\n */\nexport const STORE: unique symbol = Symbol(\"dynamite:values\");\n\n/* ------------------------------------------------------------------ */\n/* 5. Peque\u00F1os helpers opcionales */\n/* ------------------------------------------------------------------ */\n\n/**\n * Asegura que exista la entrada en el wrapper para la clase dada.\n * Devuelve la entrada (reci\u00E9n creada o existente).\n */\nexport function ensureConfig(ctor: Function, tableName: string): WrapperEntry {\n let entry = wrapper.get(ctor);\n if (!entry) {\n entry = { name: tableName, columns: new Map() };\n wrapper.set(ctor, entry);\n }\n return entry;\n}\n\n/**\n * Obtiene (o crea) el objeto Column para una propiedad concreta.\n */\nexport function ensureColumn(\n entry: WrapperEntry,\n prop: string | symbol,\n columnName: string\n): Column {\n let col = entry.columns.get(prop);\n if (!col) {\n col = { name: columnName, mutate: [], validate: [] };\n entry.columns.set(prop, col);\n }\n return col;\n}\n", "/* src/utils/naming.ts\n * -------------------------------------------------\n * Convierte Camel/Pascal \u2192 snake_case y pluraliza.\n * Se importa all\u00ED donde se necesite.\n */\nimport pluralize from \"pluralize\";\n\nexport function toSnakePlural(input: string): string {\n // camelCase / PascalCase \u2192 snake_case\n const snake = input.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\").toLowerCase();\n return pluralize(snake); // \u201Cuser\u201D \u2192 \u201Cusers\u201D, \u201Cstatus\u201D \u2192 \u201Cstatuses\u201D\u2026\n}\n", "/*\n * Dinamite ORM \u2014 @Default\n * -----------------------\n * Registra un valor por defecto y crea (si falta) el\n * getter/setter virtual de la propiedad.\n */\n\nimport { Column, STORE, ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function Default(factory: () => unknown): PropertyDecorator {\n if (typeof factory !== \"function\") {\n throw new TypeError(\"@Default requiere una funci\u00F3n factory\");\n }\n\n return (target: object, prop: string | symbol): void => {\n const ctor = (target as any).constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n const column = ensureColumn(entry, prop, String(prop));\n\n if (column.default)\n throw new Error(`@Default duplicado en '${String(prop)}'`);\n column.default = factory;\n\n if (!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set) {\n defineVirtual(ctor.prototype, column, prop);\n }\n };\n}\n\n/* ------------------------------------------------------------------ */\nfunction defineVirtual(proto: any, col: Column, prop: string | symbol): void {\n Object.defineProperty(proto, prop, {\n get() {\n return (this[STORE] ?? {})[prop];\n },\n set(val: unknown) {\n const buf = (this[STORE] ??= {});\n\n if (val === undefined && col.default !== undefined) {\n val = typeof col.default === \"function\" ? col.default() : col.default;\n }\n if (col.mutate) for (const m of col.mutate) val = m(val);\n if (col.validate) {\n for (const v of col.validate) {\n const r = v(val);\n if (r !== true)\n throw new Error(typeof r === \"string\" ? r : \"Validaci\u00F3n fallida\");\n }\n }\n buf[prop] = val;\n },\n enumerable: true,\n configurable: true,\n });\n}\n", "/*\n * Dinamite ORM \u2014 @Index (Partition Key)\n * -------------------------------------\n * Marca la propiedad como clave de partici\u00F3n.\n */\n\nimport { ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function Index(): PropertyDecorator {\n return (target: object, prop: string | symbol): void => {\n const ctor = (target as any).constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n\n /* Evitar duplicados */\n const already = [...entry.columns.values()].find((c) => c.index);\n if (already && already !== entry.columns.get(prop)) {\n throw new Error(\n `La tabla ${ctor.name} ya tiene PartitionKey (${already.name})`\n );\n }\n\n const col = ensureColumn(entry, prop, String(prop));\n col.index = true;\n };\n}\n", "/*\n * Dinamite ORM \u2014 @IndexSort (Sort Key)\n * ------------------------------------\n * Marca la propiedad como clave de ordenamiento.\n */\n\nimport { ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function IndexSort(): PropertyDecorator {\n return (target: object, prop: string | symbol): void => {\n const ctor = (target as any).constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n\n const pkExists = [...entry.columns.values()].some((c) => c.index);\n if (!pkExists) {\n throw new Error(\n `PartitionKey no definido en ${ctor.name}; declara @Index primero`\n );\n }\n\n const already = [...entry.columns.values()].find((c) => c.indexSort);\n if (already && already !== entry.columns.get(prop)) {\n throw new Error(\n `La tabla ${ctor.name} ya tiene SortKey (${already.name})`\n );\n }\n\n const col = ensureColumn(entry, prop, String(prop));\n col.indexSort = true;\n };\n}\n", "/*\n * Dinamite ORM \u2014 @Mutate\n * ----------------------\n * Registra funciones transformadoras para un campo y virtualiza\n * la propiedad si a\u00FAn no existe.\n */\n\nimport type { Column, Mutate } from \"../core/wrapper\";\nimport { STORE, ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function Mutate(fn: Mutate): PropertyDecorator {\n if (typeof fn !== \"function\") throw new TypeError(\"@Mutate requiere funci\u00F3n\");\n\n return (target: object, prop: string | symbol): void => {\n const ctor = (target as any).constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n const col = ensureColumn(entry, prop, String(prop));\n\n col.mutate ??= [];\n col.mutate.push(fn);\n\n if (!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set) {\n defineVirtual(ctor.prototype, col, prop);\n }\n };\n}\n\n/* ------------------------------------------------------------------ */\nfunction defineVirtual(proto: any, col: Column, prop: string | symbol): void {\n Object.defineProperty(proto, prop, {\n get() {\n return (this[STORE] ?? {})[prop];\n },\n set(val: unknown) {\n const buf = (this[STORE] ??= {});\n\n if (val === undefined && col.default !== undefined) {\n val = typeof col.default === \"function\" ? col.default() : col.default;\n }\n if (col.mutate) for (const m of col.mutate) val = m(val);\n if (col.validate) {\n for (const v of col.validate) {\n const r = v(val);\n if (r !== true)\n throw new Error(typeof r === \"string\" ? r : \"Validaci\u00F3n fallida\");\n }\n }\n buf[prop] = val;\n },\n enumerable: true,\n configurable: true,\n });\n}\n", "/*\n * Dinamite ORM \u2014 @Name\n * --------------------\n * \u2022 @Name(\"tabla\") \u2192 nombre f\u00EDsico de la tabla\n * \u2022 @Name(\"columna\") \u2192 alias de columna\n *\n * Permite sobrescribir el nombre AUTO-generado (snake_plural)\n * sin lanzar conflicto.\n */\n\nimport { ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function Name(\n label: string\n): ClassDecorator & PropertyDecorator {\n if (!label || typeof label !== \"string\") {\n throw new TypeError(\"@Name requiere una cadena no vac\u00EDa\");\n }\n\n return (target: any, prop?: string | symbol): void => {\n const ctor = prop === undefined ? target : target.constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n\n if (prop === undefined) {\n /* ---------- Nombre de la tabla ---------- */\n\n const auto = toSnakePlural(ctor.name);\n\n // Solo error si ya se modific\u00F3 conscientemente antes.\n if (entry.name !== auto && entry.name !== label && entry.name) {\n throw new Error(\n `La clase ${ctor.name} ya tiene un @Name distinto (${entry.name})`\n );\n }\n entry.name = label;\n } else {\n /* ---------- Alias de columna ---------- */\n\n const col = ensureColumn(entry, prop, label);\n\n if (col.name && col.name !== label) {\n throw new Error(\n `La columna '${String(prop)}' ya tiene @Name distinto (${col.name})`\n );\n }\n col.name = label;\n }\n };\n}\n", "/*\n * Dinamite ORM \u2014 @Validate\n * ------------------------\n * Registra validadores y crea virtual si falta.\n */\n\nimport { Column, STORE, ensureColumn, ensureConfig } from \"../core/wrapper\";\nimport { toSnakePlural } from \"../utils/naming\";\n\nexport default function Validate(\n validators:\n | ((v: unknown) => true | string)\n | ((v: unknown) => true | string)[]\n): PropertyDecorator {\n const list = Array.isArray(validators) ? validators : [validators];\n if (!list.length || list.some((v) => typeof v !== \"function\")) {\n throw new TypeError(\"@Validate requiere funciones\");\n }\n\n return (target: object, prop: string | symbol): void => {\n const ctor = (target as any).constructor;\n const entry = ensureConfig(ctor, toSnakePlural(ctor.name));\n const col = ensureColumn(entry, prop, String(prop));\n\n col.validate ??= [];\n col.validate.push(...list);\n\n if (!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set) {\n defineVirtual(ctor.prototype, col, prop);\n }\n };\n}\n\n/* ------------------------------------------------------------------ */\nfunction defineVirtual(proto: any, col: Column, prop: string | symbol): void {\n Object.defineProperty(proto, prop, {\n get() {\n return (this[STORE] ?? {})[prop];\n },\n set(val: unknown) {\n const buf = (this[STORE] ??= {});\n\n if (val === undefined && col.default !== undefined) {\n val = typeof col.default === \"function\" ? col.default() : col.default;\n }\n if (col.mutate) for (const m of col.mutate) val = m(val);\n if (col.validate) {\n for (const v of col.validate) {\n const r = v(val);\n if (r !== true)\n throw new Error(typeof r === \"string\" ? r : \"Validaci\u00F3n fallida\");\n }\n }\n buf[prop] = val;\n },\n enumerable: true,\n configurable: true,\n });\n}\n", "/*\n * Dinamite ORM \u2014 @CreatedAt Decorator (wrapper)\n * -------------------------------------------\n * Establece un valor por defecto con la fecha/hora actual (ISO\u2011string)\n * usando @Default.\n *\n * \u00A9 2025 Miguel Alejandro\n */\n\nimport Default from \"./default\";\n\n/**\n * Asigna autom\u00E1ticamente la fecha de creaci\u00F3n en nuevas instancias.\n */\nexport default function CreatedAt(): PropertyDecorator {\n return Default(() => new Date().toISOString());\n}\n", "/*\n * Dinamite ORM \u2014 @NotNull Decorator (wrapper)\n * ------------------------------------------\n * Valida que el valor no sea null, undefined ni cadena vac\u00EDa.\n * Internamente aplica @Validate con una funci\u00F3n sincr\u00F3nica.\n *\n * \u00A9 2025 Miguel Alejandro\n */\n\nimport Validate from \"./validate\";\n\n/**\n * Decorador wrapper que asegura no-null / no-empty.\n */\nexport default function NotNull(): PropertyDecorator {\n return (Validate as any)((value, key) => {\n if (value === null || value === undefined) return false;\n if (typeof value === \"string\" && value.trim() === \"\") return false;\n return true;\n });\n}\n", "/*\n * Dinamite ORM \u2014 @PrimaryKey\n * --------------------------\n * Declara simult\u00E1neamente Partition Key y Sort Key\n * sobre la misma propiedad.\n */\n\nimport Index from \"./index\";\nimport IndexSort from \"./index_sort\";\n\n/**\n * Atajo para definir clave primaria compuesta (PK + SK).\n * El par\u00E1metro `name` queda reservado por si en el futuro\n * se almacena un identificador l\u00F3gico de \u00EDndice, pero hoy\n * NO se pasa a ning\u00FAn decorador interno.\n */\nexport default function PrimaryKey(name = \"primary\"): PropertyDecorator {\n if (typeof name !== \"string\" || !name.trim()) {\n throw new TypeError(\"@PrimaryKey requiere un nombre de \u00EDndice v\u00E1lido\");\n }\n\n return (target: object, prop: string | symbol): void => {\n Index()(target, prop); // Partition Key\n IndexSort()(target, prop); // Sort Key\n };\n}\n", "/*\n * Dinamite ORM \u2014 @UpdatedAt Decorator (wrapper)\n * --------------------------------------------\n * Actualiza la fecha/hora cada vez que la propiedad recibe un nuevo valor\n * (incluyendo actualizaciones mediante Model.save()).\n * Internamente aplica @Mutate con una factory de timestamp ISO.\n *\n * \u00A9 2025 Miguel Alejandro\n */\n\nimport Mutate from \"./mutate\";\n\n/**\n * Actualiza autom\u00E1ticamente la marca temporal en cada asignaci\u00F3n.\n */\nexport default function UpdatedAt(): PropertyDecorator {\n return Mutate(() => new Date().toISOString());\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,YAAAC,EAAA,UAAAC,EAAA,cAAAC,EAAA,WAAAC,EAAA,SAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,YAAAC,IAAA,eAAAC,EAAAd,GCOA,IAAAe,EAOO,oCACPC,EAAqC,kCCyCrC,IAAMC,EAAmB,IAAI,IACtBC,EAAQD,EAYFE,EAAuB,OAAO,iBAAiB,EAUrD,SAASC,EAAaC,EAAgBC,EAAiC,CAC5E,IAAIC,EAAQN,EAAQ,IAAII,CAAI,EAC5B,OAAKE,IACHA,EAAQ,CAAE,KAAMD,EAAW,QAAS,IAAI,GAAM,EAC9CL,EAAQ,IAAII,EAAME,CAAK,GAElBA,CACT,CAKO,SAASC,EACdD,EACAE,EACAC,EACQ,CACR,IAAIC,EAAMJ,EAAM,QAAQ,IAAIE,CAAI,EAChC,OAAKE,IACHA,EAAM,CAAE,KAAMD,EAAY,OAAQ,CAAC,EAAG,SAAU,CAAC,CAAE,EACnDH,EAAM,QAAQ,IAAIE,EAAME,CAAG,GAEtBA,CACT,CDnFA,IAAIC,EACG,SAASC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,EAAI,OAAQ,QAAWO,KAAKP,EAAI,OAAQK,EAAME,EAAEF,CAAG,EACvD,GAAIL,EAAI,SACN,QAAWP,KAAKO,EAAI,SAAU,CAC5B,IAAMQ,EAAIf,EAAEY,CAAG,EACf,GAAIG,IAAM,GACR,MAAM,IAAI,MAAM,OAAOA,GAAM,SAAWA,EAAI,uBAAoB,CACpE,CAEFF,EAAIX,CAAI,EAAIU,CACd,EACA,WAAY,GACZ,aAAc,EAChB,CAAC,CACH,CC5Ce,SAARI,GAAgD,CACrD,OAAOC,EAAQ,IAAM,IAAI,KAAK,EAAE,YAAY,CAAC,CAC/C,CCFe,SAARC,GAA8C,CACnD,OAAQC,EAAiB,CAACC,EAAOC,IAC3B,EAAAD,GAAU,MACV,OAAOA,GAAU,UAAYA,EAAM,KAAK,IAAM,GAEnD,CACH,CCJe,SAARE,EAA4BC,EAAO,UAA8B,CACtE,GAAI,OAAOA,GAAS,UAAY,CAACA,EAAK,KAAK,EACzC,MAAM,IAAI,UAAU,uDAAiD,EAGvE,MAAO,CAACC,EAAgBC,IAAgC,CACtDC,EAAM,EAAEF,EAAQC,CAAI,EACpBE,EAAU,EAAEH,EAAQC,CAAI,CAC1B,CACF,CCVe,SAARG,GAAgD,CACrD,OAAOC,EAAO,IAAM,IAAI,KAAK,EAAE,YAAY,CAAC,CAC9C",
|
|
6
|
+
"names": ["index_exports", "__export", "CreatedAt", "Default", "Index", "IndexSort", "Mutate", "Name", "NotNull", "PrimaryKey", "Table", "UpdatedAt", "Validate", "connect", "__toCommonJS", "import_client_dynamodb", "import_util_dynamodb", "wrapper", "wrapper_default", "STORE", "ensureConfig", "ctor", "tableName", "entry", "ensureColumn", "prop", "columnName", "col", "client", "connect", "cfg", "createTable", "ctor", "meta", "wrapper_default", "cols", "pk", "c", "sk", "attr", "schema", "AttributeName", "AttributeType", "STORE", "Table", "data", "requireClient", "mustMeta", "buf", "out", "prop", "col", "id", "Ctor", "record", "fresh", "patch", "payload", "put", "err", "i", "import_pluralize", "toSnakePlural", "input", "snake", "pluralize", "Default", "factory", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "column", "ensureColumn", "defineVirtual", "proto", "col", "STORE", "val", "buf", "m", "v", "r", "Index", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "already", "c", "col", "ensureColumn", "IndexSort", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "c", "already", "col", "ensureColumn", "Mutate", "fn", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "col", "ensureColumn", "defineVirtual", "proto", "STORE", "val", "buf", "m", "v", "r", "Name", "label", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "auto", "col", "ensureColumn", "Validate", "validators", "list", "v", "target", "prop", "ctor", "entry", "ensureConfig", "toSnakePlural", "col", "ensureColumn", "defineVirtual", "proto", "STORE", "val", "buf", "m", "r", "CreatedAt", "Default", "NotNull", "Validate", "value", "key", "PrimaryKey", "name", "target", "prop", "Index", "IndexSort", "UpdatedAt", "Mutate"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"author": {
|
|
3
|
+
"email": "comunity@arcaelas.com",
|
|
4
|
+
"name": "Arcaelas Insiders",
|
|
5
|
+
"url": "https://github.com/arcaelas"
|
|
6
|
+
},
|
|
7
|
+
"bugs": {
|
|
8
|
+
"email": "community@arcaelas.com",
|
|
9
|
+
"url": "https://github.com/arcaelas/dynamite/issues"
|
|
10
|
+
},
|
|
6
11
|
"dependencies": {
|
|
7
12
|
"@aws-sdk/client-dynamodb": "3.329.0",
|
|
8
13
|
"@aws-sdk/lib-dynamodb": "3.329.0",
|
|
9
14
|
"pluralize": "^8.0.0",
|
|
10
15
|
"uuid": "^11.1.0"
|
|
11
16
|
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"test": "jest",
|
|
14
|
-
"test:watch": "jest --watch",
|
|
15
|
-
"test:coverage": "jest --coverage",
|
|
16
|
-
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
|
|
17
|
-
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@types/jest": "^30.0.0",
|
|
20
19
|
"@types/node": "^24.0.6",
|
|
@@ -25,5 +24,30 @@
|
|
|
25
24
|
"tsconfig-paths": "^4.2.0",
|
|
26
25
|
"tsx": "^4.20.3",
|
|
27
26
|
"typescript": "^5.8.3"
|
|
28
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"build/",
|
|
30
|
+
"*.md",
|
|
31
|
+
"*.json"
|
|
32
|
+
],
|
|
33
|
+
"homepage": "https://github.com/arcaelas/dynamite",
|
|
34
|
+
"license": "ISC",
|
|
35
|
+
"main": "build/index.js",
|
|
36
|
+
"name": "@arcaelas/dynamite",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/arcaelas/dynamite.git"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc && node esbuild.js",
|
|
47
|
+
"commit": "npm publish --access=public",
|
|
48
|
+
"postpublish": "rm -rf build",
|
|
49
|
+
"prepublishOnly": "yarn test && npm version patch",
|
|
50
|
+
"test": "jest && yarn build"
|
|
51
|
+
},
|
|
52
|
+
"version": "1.0.2"
|
|
29
53
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": ["src/**/*"
|
|
2
|
+
"include": ["src/**/*"],
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"target": "ES2022",
|
|
5
|
-
"module": "
|
|
5
|
+
"module": "amd",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"baseUrl": "./",
|
|
8
8
|
"paths": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"strict": true,
|
|
17
17
|
"noImplicitAny": false,
|
|
18
18
|
"skipLibCheck": true,
|
|
19
|
-
"
|
|
19
|
+
"outFile": "./build/index.d.ts",
|
|
20
20
|
"declaration": true,
|
|
21
|
-
"
|
|
21
|
+
"emitDeclarationOnly": true,
|
|
22
22
|
"resolveJsonModule": true,
|
|
23
23
|
"experimentalDecorators": true,
|
|
24
24
|
"emitDecoratorMetadata": true,
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"useDefineForClassFields": false,
|
|
29
29
|
"strictPropertyInitialization": false
|
|
30
30
|
},
|
|
31
|
-
"exclude": ["node_modules", "**/*.test.ts"]
|
|
31
|
+
"exclude": ["node_modules", "**/*.test.ts", "__tests__/**/*", "build/**/*"]
|
|
32
32
|
}
|
package/.eslintrc.js
DELETED
|
File without changes
|
package/.prettierrc
DELETED
|
File without changes
|
package/__tests__/crud.spec.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/* __tests__/crud.spec.ts
|
|
2
|
-
* -----------------------------------------------------------
|
|
3
|
-
* CRUD end-to-end contra DynamoDB Local (puerto 7007)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { DeleteTableCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
7
|
-
|
|
8
|
-
import { connect, default as Table } from "../src/core/table";
|
|
9
|
-
import wrapper from "../src/core/wrapper";
|
|
10
|
-
|
|
11
|
-
import Default from "../src/decorators/default";
|
|
12
|
-
import Name from "../src/decorators/name";
|
|
13
|
-
import NotNull from "../src/decorators/not_null";
|
|
14
|
-
import PrimaryKey from "../src/decorators/primary_key";
|
|
15
|
-
|
|
16
|
-
const ddbCfg = {
|
|
17
|
-
region: "local",
|
|
18
|
-
endpoint: "http://localhost:7007",
|
|
19
|
-
credentials: { accessKeyId: "x", secretAccessKey: "x" },
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
beforeAll(() => connect(ddbCfg));
|
|
23
|
-
|
|
24
|
-
afterEach(async () => {
|
|
25
|
-
/* Eliminar todas las tablas creadas por los tests */
|
|
26
|
-
const ddb = new DynamoDBClient(ddbCfg);
|
|
27
|
-
for (const e of wrapper.values()) {
|
|
28
|
-
try {
|
|
29
|
-
await ddb.send(new DeleteTableCommand({ TableName: e.name }));
|
|
30
|
-
} catch (_) {
|
|
31
|
-
/* tabla puede no existir */
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
wrapper.clear();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe("CRUD Dinamite ORM (DynamoDB Local)", () => {
|
|
38
|
-
jest.setTimeout(10_000);
|
|
39
|
-
|
|
40
|
-
it("create → update → where → destroy", async () => {
|
|
41
|
-
@Name("crud_users1")
|
|
42
|
-
class User extends Table {
|
|
43
|
-
@PrimaryKey()
|
|
44
|
-
declare id: string;
|
|
45
|
-
|
|
46
|
-
@NotNull()
|
|
47
|
-
declare email: string;
|
|
48
|
-
|
|
49
|
-
@Default(() => new Date().toISOString())
|
|
50
|
-
declare created_at: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* ---------- create (auto-crea tabla) ---------- */
|
|
54
|
-
const u1 = await User.create({ id: "u1", email: "a@b.com" });
|
|
55
|
-
expect(u1.email).toBe("a@b.com");
|
|
56
|
-
|
|
57
|
-
/* ---------- update ---------- */
|
|
58
|
-
await User.update("u1", { email: "c@d.com" });
|
|
59
|
-
const [after] = await User.where();
|
|
60
|
-
expect(after.email).toBe("c@d.com");
|
|
61
|
-
|
|
62
|
-
/* ---------- destroy ---------- */
|
|
63
|
-
await User.destroy("u1");
|
|
64
|
-
expect(await User.where()).toHaveLength(0);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("where() devuelve [] si la tabla no existe", async () => {
|
|
68
|
-
@Name("ghosts")
|
|
69
|
-
class Ghost extends Table {
|
|
70
|
-
@PrimaryKey()
|
|
71
|
-
declare id: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const rows = await Ghost.where();
|
|
75
|
-
expect(rows).toEqual([]);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* __tests__/decorators.spec.ts
|
|
2
|
-
* -----------------------------------------------------------
|
|
3
|
-
* Suite para verificar todos los decoradores Dinamite ORM.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import wrapper, { STORE } from "../src/core/wrapper";
|
|
7
|
-
|
|
8
|
-
import CreatedAt from "../src/decorators/created_at";
|
|
9
|
-
import Default from "../src/decorators/default";
|
|
10
|
-
import Index from "../src/decorators/index";
|
|
11
|
-
import IndexSort from "../src/decorators/index_sort";
|
|
12
|
-
import Mutate from "../src/decorators/mutate";
|
|
13
|
-
import Name from "../src/decorators/name";
|
|
14
|
-
import NotNull from "../src/decorators/not_null";
|
|
15
|
-
import PrimaryKey from "../src/decorators/primary_key";
|
|
16
|
-
import UpdatedAt from "../src/decorators/updated_at";
|
|
17
|
-
import Validate from "../src/decorators/validate";
|
|
18
|
-
|
|
19
|
-
describe("Decoradores Dinamite ORM", () => {
|
|
20
|
-
beforeEach(() => wrapper.clear());
|
|
21
|
-
|
|
22
|
-
/* ---------------------------------------------------------- */
|
|
23
|
-
it("nombre de tabla por defecto (snake_plural) cuando no se usa @Name", () => {
|
|
24
|
-
class Book {
|
|
25
|
-
@NotNull()
|
|
26
|
-
declare title: string;
|
|
27
|
-
}
|
|
28
|
-
const meta = wrapper.get(Book)!;
|
|
29
|
-
expect(meta.name).toBe("books"); // Book → books
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
/* ---------------------------------------------------------- */
|
|
33
|
-
it("@Name (clase y propiedad)", () => {
|
|
34
|
-
@Name("usuarios")
|
|
35
|
-
class User {
|
|
36
|
-
@Name("correo")
|
|
37
|
-
declare email: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const meta = wrapper.get(User)!;
|
|
41
|
-
expect(meta.name).toBe("usuarios");
|
|
42
|
-
expect(meta.columns.get("email")!.name).toBe("correo");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
/* ---------------------------------------------------------- */
|
|
46
|
-
it("@Index + @IndexSort (PK + SK)", () => {
|
|
47
|
-
class Post {
|
|
48
|
-
@Index() // Partition Key
|
|
49
|
-
declare slug: string;
|
|
50
|
-
|
|
51
|
-
@IndexSort() // Sort Key
|
|
52
|
-
declare created: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const meta = wrapper.get(Post)!;
|
|
56
|
-
const pkCol = meta.columns.get("slug")!;
|
|
57
|
-
const skCol = meta.columns.get("created")!;
|
|
58
|
-
|
|
59
|
-
expect(pkCol.index).toBe(true);
|
|
60
|
-
expect(skCol.indexSort).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
/* ---------------------------------------------------------- */
|
|
64
|
-
it("@PrimaryKey (combinado)", () => {
|
|
65
|
-
class Comment {
|
|
66
|
-
@PrimaryKey()
|
|
67
|
-
declare id: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const meta = wrapper.get(Comment)!;
|
|
71
|
-
const col = meta.columns.get("id")!;
|
|
72
|
-
|
|
73
|
-
expect(col.index).toBe(true);
|
|
74
|
-
expect(col.indexSort).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
/* ---------------------------------------------------------- */
|
|
78
|
-
it("@Default + @Mutate + @Validate pipeline", () => {
|
|
79
|
-
@Name("tests")
|
|
80
|
-
class Model {
|
|
81
|
-
@Default(() => 10)
|
|
82
|
-
@Mutate((v) => (v as number) * 2)
|
|
83
|
-
@Validate((v) => ((v as number) >= 20 ? true : "menor a 20"))
|
|
84
|
-
declare score: number;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const m = new Model();
|
|
88
|
-
(m as any).score = undefined; // dispara pipeline
|
|
89
|
-
expect(m.score).toBe(20);
|
|
90
|
-
expect((m as any)[STORE].score).toBe(20);
|
|
91
|
-
|
|
92
|
-
expect(() => {
|
|
93
|
-
m.score = 5 as any;
|
|
94
|
-
}).toThrow("menor a 20");
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
/* ---------------------------------------------------------- */
|
|
98
|
-
it("@NotNull rechaza null/undefined/cadena vacía", () => {
|
|
99
|
-
class File {
|
|
100
|
-
@NotNull()
|
|
101
|
-
declare path: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const f = new File();
|
|
105
|
-
expect(() => ((f as any).path = null)).toThrow();
|
|
106
|
-
expect(() => ((f as any).path = " ")).toThrow();
|
|
107
|
-
f.path = "/tmp/file";
|
|
108
|
-
expect(f.path).toBe("/tmp/file");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
/* ---------------------------------------------------------- */
|
|
112
|
-
it("@CreatedAt y @UpdatedAt gestionan timestamps", () => {
|
|
113
|
-
class Audit {
|
|
114
|
-
@CreatedAt()
|
|
115
|
-
declare created: string;
|
|
116
|
-
|
|
117
|
-
@UpdatedAt()
|
|
118
|
-
declare updated: string;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const a = new Audit();
|
|
122
|
-
(a as any).created = undefined;
|
|
123
|
-
(a as any).updated = undefined;
|
|
124
|
-
|
|
125
|
-
const firstCreated = a.created;
|
|
126
|
-
const firstUpdated = a.updated;
|
|
127
|
-
|
|
128
|
-
return new Promise((r) => setTimeout(r, 10)).then(() => {
|
|
129
|
-
(a as any).updated = undefined;
|
|
130
|
-
expect(a.created).toBe(firstCreated);
|
|
131
|
-
expect(a.updated).not.toBe(firstUpdated);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|