@arcaelas/dynamite 1.0.10 → 1.0.14
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/README.md +1165 -152
- package/package.json +8 -10
- package/SECURITY.md +0 -41
- package/build/__tests__/crud.spec.d.ts +0 -7
- package/build/__tests__/crud.spec.js +0 -287
- package/build/__tests__/crud.spec.js.map +0 -1
- package/build/__tests__/debug-decorators.spec.d.ts +0 -7
- package/build/__tests__/debug-decorators.spec.js +0 -143
- package/build/__tests__/debug-decorators.spec.js.map +0 -1
- package/build/__tests__/decorators.spec.d.ts +0 -7
- package/build/__tests__/decorators.spec.js +0 -203
- package/build/__tests__/decorators.spec.js.map +0 -1
- package/build/__tests__/instance-crud.spec.d.ts +0 -7
- package/build/__tests__/instance-crud.spec.js +0 -184
- package/build/__tests__/instance-crud.spec.js.map +0 -1
- package/build/src/core/client.d.ts +0 -65
- package/build/src/core/client.js +0 -152
- package/build/src/core/client.js.map +0 -1
- package/build/src/core/table.d.ts +0 -164
- package/build/src/core/table.js +0 -406
- package/build/src/core/table.js.map +0 -1
- package/build/src/core/wrapper.d.ts +0 -54
- package/build/src/core/wrapper.js +0 -27
- package/build/src/core/wrapper.js.map +0 -1
- package/build/src/decorators/created_at.d.ts +0 -8
- package/build/src/decorators/created_at.js +0 -18
- package/build/src/decorators/created_at.js.map +0 -1
- package/build/src/decorators/default.d.ts +0 -8
- package/build/src/decorators/default.js +0 -57
- package/build/src/decorators/default.js.map +0 -1
- package/build/src/decorators/index.d.ts +0 -8
- package/build/src/decorators/index.js +0 -26
- package/build/src/decorators/index.js.map +0 -1
- package/build/src/decorators/index_sort.d.ts +0 -8
- package/build/src/decorators/index_sort.js +0 -30
- package/build/src/decorators/index_sort.js.map +0 -1
- package/build/src/decorators/mutate.d.ts +0 -9
- package/build/src/decorators/mutate.js +0 -60
- package/build/src/decorators/mutate.js.map +0 -1
- package/build/src/decorators/name.d.ts +0 -8
- package/build/src/decorators/name.js +0 -42
- package/build/src/decorators/name.js.map +0 -1
- package/build/src/decorators/not_null.d.ts +0 -8
- package/build/src/decorators/not_null.js +0 -20
- package/build/src/decorators/not_null.js.map +0 -1
- package/build/src/decorators/primary_key.d.ts +0 -8
- package/build/src/decorators/primary_key.js +0 -26
- package/build/src/decorators/primary_key.js.map +0 -1
- package/build/src/decorators/updated_at.d.ts +0 -8
- package/build/src/decorators/updated_at.js +0 -18
- package/build/src/decorators/updated_at.js.map +0 -1
- package/build/src/decorators/validate.d.ts +0 -8
- package/build/src/decorators/validate.js +0 -60
- package/build/src/decorators/validate.js.map +0 -1
- package/build/src/index.d.ts +0 -13
- package/build/src/index.js +0 -38
- package/build/src/index.js.map +0 -1
- package/build/src/utils/batch-relations.d.ts +0 -14
- package/build/src/utils/batch-relations.js +0 -130
- package/build/src/utils/batch-relations.js.map +0 -1
- package/build/src/utils/naming.d.ts +0 -8
- package/build/src/utils/naming.js +0 -18
- package/build/src/utils/naming.js.map +0 -1
- package/build/src/utils/projection.d.ts +0 -12
- package/build/src/utils/projection.js +0 -50
- package/build/src/utils/projection.js.map +0 -1
- package/build/src/utils/relations.d.ts +0 -23
- package/build/src/utils/relations.js +0 -205
- package/build/src/utils/relations.js.map +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureColumn = exports.ensureConfig = exports.STORE = void 0;
|
|
4
|
-
const wrapper = new Map();
|
|
5
|
-
exports.STORE = Symbol("dynamite:values");
|
|
6
|
-
exports.default = wrapper;
|
|
7
|
-
/** Get or create wrapper entry for a constructor */
|
|
8
|
-
const ensureConfig = (ctor, tableName) => {
|
|
9
|
-
const existing = wrapper.get(ctor);
|
|
10
|
-
if (existing)
|
|
11
|
-
return existing;
|
|
12
|
-
const entry = { name: tableName, columns: new Map(), relations: new Map() };
|
|
13
|
-
wrapper.set(ctor, entry);
|
|
14
|
-
return entry;
|
|
15
|
-
};
|
|
16
|
-
exports.ensureConfig = ensureConfig;
|
|
17
|
-
/** Get or create column configuration for a property */
|
|
18
|
-
const ensureColumn = (entry, prop, columnName) => {
|
|
19
|
-
const existing = entry.columns.get(prop);
|
|
20
|
-
if (existing)
|
|
21
|
-
return existing;
|
|
22
|
-
const col = { name: columnName, mutate: [], validate: [] };
|
|
23
|
-
entry.columns.set(prop, col);
|
|
24
|
-
return col;
|
|
25
|
-
};
|
|
26
|
-
exports.ensureColumn = ensureColumn;
|
|
27
|
-
//# sourceMappingURL=wrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/core/wrapper.ts"],"names":[],"mappings":";;;AAkEA,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;AACrC,QAAA,KAAK,GAAkB,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC9D,kBAAe,OAAO,CAAC;AAEvB,oDAAoD;AAC7C,MAAM,YAAY,GAAG,CAC1B,IAAc,EACd,SAAiB,EACH,EAAE;IAChB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;IAC5E,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AATW,QAAA,YAAY,gBASvB;AAEF,wDAAwD;AACjD,MAAM,YAAY,GAAG,CAC1B,KAAmB,EACnB,IAAqB,EACrB,UAAkB,EACV,EAAE;IACV,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC3D,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAVW,QAAA,YAAY,gBAUvB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file created_at.ts
|
|
3
|
-
* @descripcion Decorador @CreatedAt para timestamp de creación
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para establecer timestamp automático de creación */
|
|
8
|
-
export default function CreatedAt(): PropertyDecorator;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file created_at.ts
|
|
4
|
-
* @descripcion Decorador @CreatedAt para timestamp de creación
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.default = CreatedAt;
|
|
13
|
-
const default_1 = __importDefault(require("./default"));
|
|
14
|
-
/** Decorador para establecer timestamp automático de creación */
|
|
15
|
-
function CreatedAt() {
|
|
16
|
-
return (0, default_1.default)(() => new Date().toISOString());
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=created_at.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"created_at.js","sourceRoot":"","sources":["../../../src/decorators/created_at.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAKH,4BAEC;AALD,wDAAgC;AAEhC,iEAAiE;AACjE,SAAwB,SAAS;IAC/B,OAAO,IAAA,iBAAO,EAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file default.ts
|
|
3
|
-
* @descripcion Decorador @Default para valores por defecto
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para establecer valores por defecto en propiedades */
|
|
8
|
-
export default function Default(factory: any): PropertyDecorator;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file default.ts
|
|
4
|
-
* @descripcion Decorador @Default para valores por defecto
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = Default;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para establecer valores por defecto en propiedades */
|
|
13
|
-
function Default(factory) {
|
|
14
|
-
return (target, prop) => {
|
|
15
|
-
const ctor = target.constructor;
|
|
16
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
17
|
-
const column = (0, wrapper_1.ensureColumn)(entry, prop, String(prop));
|
|
18
|
-
if (column.default)
|
|
19
|
-
throw new Error(`@Default duplicado en '${String(prop)}'`);
|
|
20
|
-
column.default = typeof factory === "function" ? factory : () => factory;
|
|
21
|
-
!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set &&
|
|
22
|
-
defineVirtual(ctor.prototype, column, prop);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/** Define propiedad virtual con getter/setter para manejo de defaults */
|
|
26
|
-
function defineVirtual(proto, col, prop) {
|
|
27
|
-
Object.defineProperty(proto, prop, {
|
|
28
|
-
get() {
|
|
29
|
-
return (this[wrapper_1.STORE] ?? {})[prop];
|
|
30
|
-
},
|
|
31
|
-
set(val) {
|
|
32
|
-
const buf = (this[wrapper_1.STORE] ??= {});
|
|
33
|
-
val =
|
|
34
|
-
val === undefined && col.default !== undefined
|
|
35
|
-
? typeof col.default === "function"
|
|
36
|
-
? col.default()
|
|
37
|
-
: col.default
|
|
38
|
-
: val;
|
|
39
|
-
if (col.mutate)
|
|
40
|
-
for (const m of col.mutate)
|
|
41
|
-
val = m(val);
|
|
42
|
-
if (col.validate) {
|
|
43
|
-
for (const v of col.validate) {
|
|
44
|
-
const r = v(val);
|
|
45
|
-
r !== true &&
|
|
46
|
-
(() => {
|
|
47
|
-
throw new Error(typeof r === "string" ? r : "Validación fallida");
|
|
48
|
-
})();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
buf[prop] = val;
|
|
52
|
-
},
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=default.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/decorators/default.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,0BAWC;AAfD,6CAA4E;AAC5E,4CAAgD;AAEhD,mEAAmE;AACnE,SAAwB,OAAO,CAAC,OAAY;IAC1C,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,MAAM,IAAI,GAAI,MAAc,CAAC,WAAW,CAAC;QACzC,MAAM,KAAK,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM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G,CAAC,QAAQ,EAAE,CAAC;oBAC7B,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;oBACjB,CAAC,KAAK,IAAI;wBACR,CAAC,GAAG,EAAE;4BACJ,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;wBACpE,CAAC,CAAC,EAAE,CAAC;gBACT,CAAC;YACH,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAClB,CAAC;QACD,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file index.ts
|
|
4
|
-
* @descripcion Decorador @Index para Partition Key
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = Index;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para marcar propiedad como Partition Key */
|
|
13
|
-
function Index() {
|
|
14
|
-
return (target, prop) => {
|
|
15
|
-
const ctor = target.constructor;
|
|
16
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
17
|
-
const already = [...entry.columns.values()].find((c) => c.index);
|
|
18
|
-
already &&
|
|
19
|
-
already !== entry.columns.get(prop) &&
|
|
20
|
-
(() => {
|
|
21
|
-
throw new Error(`La tabla ${ctor.name} ya tiene PartitionKey (${already.name})`);
|
|
22
|
-
})();
|
|
23
|
-
(0, wrapper_1.ensureColumn)(entry, prop, String(prop)).index = true;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,wBAcC;AAlBD,6CAA6D;AAC7D,4CAAgD;AAEhD,yDAAyD;AACzD,SAAwB,KAAK;IAC3B,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,MAAM,IAAI,GAAI,MAAc,CAAC,WAAW,CAAC;QACzC,MAAM,KAAK,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACjE,OAAO;YACL,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YACnC,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,KAAK,CACb,YAAY,IAAI,CAAC,IAAI,2BAA2B,OAAO,CAAC,IAAI,GAAG,CAChE,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QACP,IAAA,sBAAY,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file index_sort.ts
|
|
4
|
-
* @descripcion Decorador @IndexSort para Sort Key
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = IndexSort;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para marcar propiedad como Sort Key */
|
|
13
|
-
function IndexSort() {
|
|
14
|
-
return (target, prop) => {
|
|
15
|
-
const ctor = target.constructor;
|
|
16
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
17
|
-
![...entry.columns.values()].some((c) => c.index) &&
|
|
18
|
-
(() => {
|
|
19
|
-
throw new Error(`PartitionKey no definido en ${ctor.name}; declara @Index primero`);
|
|
20
|
-
})();
|
|
21
|
-
const already = [...entry.columns.values()].find((c) => c.indexSort);
|
|
22
|
-
already &&
|
|
23
|
-
already !== entry.columns.get(prop) &&
|
|
24
|
-
(() => {
|
|
25
|
-
throw new Error(`La tabla ${ctor.name} ya tiene SortKey (${already.name})`);
|
|
26
|
-
})();
|
|
27
|
-
(0, wrapper_1.ensureColumn)(entry, prop, String(prop)).indexSort = true;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=index_sort.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index_sort.js","sourceRoot":"","sources":["../../../src/decorators/index_sort.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,4BAoBC;AAxBD,6CAA6D;AAC7D,4CAAgD;AAEhD,oDAAoD;AACpD,SAAwB,SAAS;IAC/B,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,MAAM,IAAI,GAAI,MAAc,CAAC,WAAW,CAAC;QACzC,MAAM,KAAK,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YAC/C,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,CAAC,IAAI,0BAA0B,CACnE,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrE,OAAO;YACL,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YACnC,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,KAAK,CACb,YAAY,IAAI,CAAC,IAAI,sBAAsB,OAAO,CAAC,IAAI,GAAG,CAC3D,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QACP,IAAA,sBAAY,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file mutate.ts
|
|
3
|
-
* @descripcion Decorador @Mutate para transformaciones
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
import type { Mutate } from "../core/wrapper";
|
|
8
|
-
/** Decorador para aplicar transformaciones automáticas a propiedades */
|
|
9
|
-
export default function Mutate(fn: Mutate): PropertyDecorator;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file mutate.ts
|
|
4
|
-
* @descripcion Decorador @Mutate para transformaciones
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = Mutate;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para aplicar transformaciones automáticas a propiedades */
|
|
13
|
-
function Mutate(fn) {
|
|
14
|
-
typeof fn !== "function" &&
|
|
15
|
-
(() => {
|
|
16
|
-
throw new TypeError("@Mutate requiere función");
|
|
17
|
-
})();
|
|
18
|
-
return (target, prop) => {
|
|
19
|
-
const ctor = target.constructor;
|
|
20
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
21
|
-
const col = (0, wrapper_1.ensureColumn)(entry, prop, String(prop));
|
|
22
|
-
col.mutate ??= [];
|
|
23
|
-
col.mutate.push(fn);
|
|
24
|
-
!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set &&
|
|
25
|
-
defineVirtual(ctor.prototype, col, prop);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** Define propiedad virtual con getter/setter para manejo de mutaciones */
|
|
29
|
-
function defineVirtual(proto, col, prop) {
|
|
30
|
-
Object.defineProperty(proto, prop, {
|
|
31
|
-
get() {
|
|
32
|
-
return (this[wrapper_1.STORE] ?? {})[prop];
|
|
33
|
-
},
|
|
34
|
-
set(val) {
|
|
35
|
-
const buf = (this[wrapper_1.STORE] ??= {});
|
|
36
|
-
val =
|
|
37
|
-
val === undefined && col.default !== undefined
|
|
38
|
-
? typeof col.default === "function"
|
|
39
|
-
? col.default()
|
|
40
|
-
: col.default
|
|
41
|
-
: val;
|
|
42
|
-
if (col.mutate)
|
|
43
|
-
for (const m of col.mutate)
|
|
44
|
-
val = m(val);
|
|
45
|
-
if (col.validate) {
|
|
46
|
-
for (const v of col.validate) {
|
|
47
|
-
const r = v(val);
|
|
48
|
-
r !== true &&
|
|
49
|
-
(() => {
|
|
50
|
-
throw new Error(typeof r === "string" ? r : "Validación fallida");
|
|
51
|
-
})();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
buf[prop] = val;
|
|
55
|
-
},
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=mutate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mutate.js","sourceRoot":"","sources":["../../../src/decorators/mutate.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAOH,yBAcC;AAlBD,6CAAoE;AACpE,4CAAgD;AAEhD,wEAAwE;AACxE,SAAwB,MAAM,CAAC,EAAU;IACvC,OAAO,EAAE,KAAK,UAAU;QACtB,CAAC,GAAG,EAAE;YACJ,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAC;QAClD,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,MAAM,IAAI,GAAI,MAAc,CAAC,WAAW,CAAC;QACzC,MAAM,KAAK,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,GAAG,GAAG,IAAA,sBAAY,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC;QAClB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,GAAG;YACzD,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,SAAS,aAAa,CAAC,KAAU,EAAE,GAAW,EAAE,IAAqB;IACnE,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE;QACjC,GAAG;YACD,OAAO,CAAC,IAAI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*/
|
|
7
|
-
/** Decorador para establecer nombres personalizados de tablas y columnas */
|
|
8
|
-
export default function Name(label: string): ClassDecorator & PropertyDecorator;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file name.ts
|
|
4
|
-
* @descripcion Decorador @Name para tablas y columnas
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = Name;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para establecer nombres personalizados de tablas y columnas */
|
|
13
|
-
function Name(label) {
|
|
14
|
-
(!label || typeof label !== "string") &&
|
|
15
|
-
(() => {
|
|
16
|
-
throw new TypeError("@Name requiere una cadena no vacía");
|
|
17
|
-
})();
|
|
18
|
-
return (target, prop) => {
|
|
19
|
-
const ctor = prop === undefined ? target : target.constructor;
|
|
20
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
21
|
-
if (prop === undefined) {
|
|
22
|
-
const auto = (0, naming_1.toSnakePlural)(ctor.name);
|
|
23
|
-
entry.name !== auto &&
|
|
24
|
-
entry.name !== label &&
|
|
25
|
-
entry.name &&
|
|
26
|
-
(() => {
|
|
27
|
-
throw new Error(`La clase ${ctor.name} ya tiene un @Name distinto (${entry.name})`);
|
|
28
|
-
})();
|
|
29
|
-
entry.name = label;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const col = (0, wrapper_1.ensureColumn)(entry, prop, label);
|
|
33
|
-
col.name &&
|
|
34
|
-
col.name !== label &&
|
|
35
|
-
(() => {
|
|
36
|
-
throw new Error(`La columna '${String(prop)}' ya tiene @Name distinto (${col.name})`);
|
|
37
|
-
})();
|
|
38
|
-
col.name = label;
|
|
39
|
-
}
|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C,GAAG,CAAC,IAAI;gBACN,GAAG,CAAC,IAAI,KAAK,KAAK;gBAClB,CAAC,GAAG,EAAE;oBACJ,MAAM,IAAI,KAAK,CACb,eAAe,MAAM,CAAC,IAAI,CAAC,8BAA8B,GAAG,CAAC,IAAI,GAAG,CACrE,CAAC;gBACJ,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file not_null.ts
|
|
3
|
-
* @descripcion Decorador @NotNull para validación no-null
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para validar que el valor no sea nulo, indefinido o string vacío */
|
|
8
|
-
export default function NotNull(): PropertyDecorator;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file not_null.ts
|
|
4
|
-
* @descripcion Decorador @NotNull para validación no-null
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.default = NotNull;
|
|
13
|
-
const validate_1 = __importDefault(require("./validate"));
|
|
14
|
-
/** Decorador para validar que el valor no sea nulo, indefinido o string vacío */
|
|
15
|
-
function NotNull() {
|
|
16
|
-
return validate_1.default((value) => value !== null &&
|
|
17
|
-
value !== undefined &&
|
|
18
|
-
(typeof value !== "string" || value.trim() !== ""));
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=not_null.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not_null.js","sourceRoot":"","sources":["../../../src/decorators/not_null.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAKH,0BAOC;AAVD,0DAAkC;AAElC,iFAAiF;AACjF,SAAwB,OAAO;IAC7B,OAAQ,kBAAgB,CACtB,CAAC,KAAU,EAAE,EAAE,CACb,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,SAAS;QACnB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file primary_key.ts
|
|
3
|
-
* @descripcion Decorador @PrimaryKey para clave primaria compuesta
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para marcar propiedad como clave primaria compuesta (Index + IndexSort) */
|
|
8
|
-
export default function PrimaryKey(name?: string): PropertyDecorator;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file primary_key.ts
|
|
4
|
-
* @descripcion Decorador @PrimaryKey para clave primaria compuesta
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.default = PrimaryKey;
|
|
13
|
-
const index_1 = __importDefault(require("./index"));
|
|
14
|
-
const index_sort_1 = __importDefault(require("./index_sort"));
|
|
15
|
-
/** Decorador para marcar propiedad como clave primaria compuesta (Index + IndexSort) */
|
|
16
|
-
function PrimaryKey(name = "primary") {
|
|
17
|
-
(typeof name !== "string" || !name.trim()) &&
|
|
18
|
-
(() => {
|
|
19
|
-
throw new TypeError("@PrimaryKey requiere un nombre de índice válido");
|
|
20
|
-
})();
|
|
21
|
-
return (target, prop) => {
|
|
22
|
-
(0, index_1.default)()(target, prop);
|
|
23
|
-
(0, index_sort_1.default)()(target, prop);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=primary_key.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primary_key.js","sourceRoot":"","sources":["../../../src/decorators/primary_key.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAMH,6BASC;AAbD,oDAA4B;AAC5B,8DAAqC;AAErC,wFAAwF;AACxF,SAAwB,UAAU,CAAC,IAAI,GAAG,SAAS;IACjD,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,GAAG,EAAE;YACJ,MAAM,IAAI,SAAS,CAAC,iDAAiD,CAAC,CAAC;QACzE,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,IAAA,eAAK,GAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACtB,IAAA,oBAAS,GAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file updated_at.ts
|
|
3
|
-
* @descripcion Decorador @UpdatedAt para timestamp de actualización
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para establecer timestamp automático de actualización */
|
|
8
|
-
export default function UpdatedAt(): PropertyDecorator;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file updated_at.ts
|
|
4
|
-
* @descripcion Decorador @UpdatedAt para timestamp de actualización
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.default = UpdatedAt;
|
|
13
|
-
const mutate_1 = __importDefault(require("./mutate"));
|
|
14
|
-
/** Decorador para establecer timestamp automático de actualización */
|
|
15
|
-
function UpdatedAt() {
|
|
16
|
-
return (0, mutate_1.default)(() => new Date().toISOString());
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=updated_at.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updated_at.js","sourceRoot":"","sources":["../../../src/decorators/updated_at.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAKH,4BAEC;AALD,sDAA8B;AAE9B,sEAAsE;AACtE,SAAwB,SAAS;IAC/B,OAAO,IAAA,gBAAM,EAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file validate.ts
|
|
3
|
-
* @descripcion Decorador @Validate para validaciones
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Decorador para aplicar validaciones a propiedades */
|
|
8
|
-
export default function Validate(validators: ((v: unknown) => true | string) | ((v: unknown) => true | string)[]): PropertyDecorator;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file validate.ts
|
|
4
|
-
* @descripcion Decorador @Validate para validaciones
|
|
5
|
-
* @autor Miguel Alejandro
|
|
6
|
-
* @fecha 2025-01-27
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.default = Validate;
|
|
10
|
-
const wrapper_1 = require("../core/wrapper");
|
|
11
|
-
const naming_1 = require("../utils/naming");
|
|
12
|
-
/** Decorador para aplicar validaciones a propiedades */
|
|
13
|
-
function Validate(validators) {
|
|
14
|
-
const list = Array.isArray(validators) ? validators : [validators];
|
|
15
|
-
if (!list.length || list.some((v) => typeof v !== "function")) {
|
|
16
|
-
throw new TypeError("@Validate requiere funciones");
|
|
17
|
-
}
|
|
18
|
-
return (target, prop) => {
|
|
19
|
-
const ctor = target.constructor;
|
|
20
|
-
const entry = (0, wrapper_1.ensureConfig)(ctor, (0, naming_1.toSnakePlural)(ctor.name));
|
|
21
|
-
const col = (0, wrapper_1.ensureColumn)(entry, prop, String(prop));
|
|
22
|
-
col.validate ??= [];
|
|
23
|
-
col.validate.push(...list);
|
|
24
|
-
!Object.getOwnPropertyDescriptor(ctor.prototype, prop)?.set &&
|
|
25
|
-
defineVirtual(ctor.prototype, col, prop);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** Define propiedad virtual con getter/setter para manejo de validaciones */
|
|
29
|
-
function defineVirtual(proto, col, prop) {
|
|
30
|
-
Object.defineProperty(proto, prop, {
|
|
31
|
-
get() {
|
|
32
|
-
return (this[wrapper_1.STORE] ?? {})[prop];
|
|
33
|
-
},
|
|
34
|
-
set(val) {
|
|
35
|
-
const buf = (this[wrapper_1.STORE] ??= {});
|
|
36
|
-
val =
|
|
37
|
-
val === undefined && col.default !== undefined
|
|
38
|
-
? typeof col.default === "function"
|
|
39
|
-
? col.default()
|
|
40
|
-
: col.default
|
|
41
|
-
: val;
|
|
42
|
-
if (col.mutate)
|
|
43
|
-
for (const m of col.mutate)
|
|
44
|
-
val = m(val);
|
|
45
|
-
if (col.validate) {
|
|
46
|
-
for (const v of col.validate) {
|
|
47
|
-
const r = v(val);
|
|
48
|
-
r !== true &&
|
|
49
|
-
(() => {
|
|
50
|
-
throw new Error(typeof r === "string" ? r : "Validación fallida");
|
|
51
|
-
})();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
buf[prop] = val;
|
|
55
|
-
},
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/decorators/validate.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAMH,2BAkBC;AAtBD,6CAA4E;AAC5E,4CAAgD;AAEhD,wDAAwD;AACxD,SAAwB,QAAQ,CAC9B,UAEqC;IAErC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACnE,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,CAAC,MAAc,EAAE,IAAqB,EAAQ,EAAE;QACrD,MAAM,IAAI,GAAI,MAAc,CAAC,WAAW,CAAC;QACzC,MAAM,KAAK,GAAG,IAAA,sBAAY,EAAC,IAAI,EAAE,IAAA,sBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3D,MAAM,GAAG,GAAG,IAAA,sBAAY,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC;QACpB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,SAA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C,IAAI,CAAC,GAAG,GAAG,CAAC;QAClB,CAAC;QACD,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;AACL,CAAC"}
|
package/build/src/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { Dynamite } from "./core/client";
|
|
2
|
-
export { default as Table } from "./core/table";
|
|
3
|
-
export { default as CreatedAt } from "./decorators/created_at";
|
|
4
|
-
export { default as Default } from "./decorators/default";
|
|
5
|
-
export { default as Index } from "./decorators/index";
|
|
6
|
-
export { default as IndexSort } from "./decorators/index_sort";
|
|
7
|
-
export { default as Mutate } from "./decorators/mutate";
|
|
8
|
-
export { default as Name } from "./decorators/name";
|
|
9
|
-
export { default as NotNull } from "./decorators/not_null";
|
|
10
|
-
export { default as PrimaryKey } from "./decorators/primary_key";
|
|
11
|
-
export { default as UpdatedAt } from "./decorators/updated_at";
|
|
12
|
-
export { default as Validate } from "./decorators/validate";
|
|
13
|
-
export { belongsTo, hasMany } from "./utils/relations";
|
package/build/src/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hasMany = exports.belongsTo = exports.Validate = exports.UpdatedAt = exports.PrimaryKey = exports.NotNull = exports.Name = exports.Mutate = exports.IndexSort = exports.Index = exports.Default = exports.CreatedAt = exports.Table = exports.Dynamite = void 0;
|
|
7
|
-
// Core classes
|
|
8
|
-
var client_1 = require("./core/client");
|
|
9
|
-
Object.defineProperty(exports, "Dynamite", { enumerable: true, get: function () { return client_1.Dynamite; } });
|
|
10
|
-
var table_1 = require("./core/table");
|
|
11
|
-
Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return __importDefault(table_1).default; } });
|
|
12
|
-
// Legacy connection removed - use Dynamite class instead
|
|
13
|
-
// Decorators
|
|
14
|
-
var created_at_1 = require("./decorators/created_at");
|
|
15
|
-
Object.defineProperty(exports, "CreatedAt", { enumerable: true, get: function () { return __importDefault(created_at_1).default; } });
|
|
16
|
-
var default_1 = require("./decorators/default");
|
|
17
|
-
Object.defineProperty(exports, "Default", { enumerable: true, get: function () { return __importDefault(default_1).default; } });
|
|
18
|
-
var index_1 = require("./decorators/index");
|
|
19
|
-
Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return __importDefault(index_1).default; } });
|
|
20
|
-
var index_sort_1 = require("./decorators/index_sort");
|
|
21
|
-
Object.defineProperty(exports, "IndexSort", { enumerable: true, get: function () { return __importDefault(index_sort_1).default; } });
|
|
22
|
-
var mutate_1 = require("./decorators/mutate");
|
|
23
|
-
Object.defineProperty(exports, "Mutate", { enumerable: true, get: function () { return __importDefault(mutate_1).default; } });
|
|
24
|
-
var name_1 = require("./decorators/name");
|
|
25
|
-
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return __importDefault(name_1).default; } });
|
|
26
|
-
var not_null_1 = require("./decorators/not_null");
|
|
27
|
-
Object.defineProperty(exports, "NotNull", { enumerable: true, get: function () { return __importDefault(not_null_1).default; } });
|
|
28
|
-
var primary_key_1 = require("./decorators/primary_key");
|
|
29
|
-
Object.defineProperty(exports, "PrimaryKey", { enumerable: true, get: function () { return __importDefault(primary_key_1).default; } });
|
|
30
|
-
var updated_at_1 = require("./decorators/updated_at");
|
|
31
|
-
Object.defineProperty(exports, "UpdatedAt", { enumerable: true, get: function () { return __importDefault(updated_at_1).default; } });
|
|
32
|
-
var validate_1 = require("./decorators/validate");
|
|
33
|
-
Object.defineProperty(exports, "Validate", { enumerable: true, get: function () { return __importDefault(validate_1).default; } });
|
|
34
|
-
// Relations
|
|
35
|
-
var relations_1 = require("./utils/relations");
|
|
36
|
-
Object.defineProperty(exports, "belongsTo", { enumerable: true, get: function () { return relations_1.belongsTo; } });
|
|
37
|
-
Object.defineProperty(exports, "hasMany", { enumerable: true, get: function () { return relations_1.hasMany; } });
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,eAAe;AACf,wCAAyC;AAAhC,kGAAA,QAAQ,OAAA;AACjB,sCAAgD;AAAvC,+GAAA,OAAO,OAAS;AAEzB,yDAAyD;AAEzD,aAAa;AACb,sDAA+D;AAAtD,wHAAA,OAAO,OAAa;AAC7B,gDAA0D;AAAjD,mHAAA,OAAO,OAAW;AAC3B,4CAAsD;AAA7C,+GAAA,OAAO,OAAS;AACzB,sDAA+D;AAAtD,wHAAA,OAAO,OAAa;AAC7B,8CAAwD;AAA/C,iHAAA,OAAO,OAAU;AAC1B,0CAAoD;AAA3C,6GAAA,OAAO,OAAQ;AACxB,kDAA2D;AAAlD,oHAAA,OAAO,OAAW;AAC3B,wDAAiE;AAAxD,0HAAA,OAAO,OAAc;AAC9B,sDAA+D;AAAtD,wHAAA,OAAO,OAAa;AAC7B,kDAA4D;AAAnD,qHAAA,OAAO,OAAY;AAE5B,YAAY;AACZ,+CAAuD;AAA9C,sGAAA,SAAS,OAAA;AAAE,oGAAA,OAAO,OAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file batch-relations.ts
|
|
3
|
-
* @description Optimized batch loading for relations
|
|
4
|
-
* @autor Miguel Alejandro
|
|
5
|
-
* @fecha 2025-01-27
|
|
6
|
-
*/
|
|
7
|
-
/** Batch loader para hasMany relations */
|
|
8
|
-
export declare const batchLoadHasMany: (Model: any, parentItems: any[], relation: any) => Promise<Map<any, any>>;
|
|
9
|
-
/** Batch loader para belongsTo relations con cache */
|
|
10
|
-
export declare const batchLoadBelongsTo: (Model: any, parentItems: any[], relation: any) => Promise<Map<any, any>>;
|
|
11
|
-
/** Optimized processIncludes con batch loading */
|
|
12
|
-
export declare const processIncludesBatch: (Model: any, items: any[], include: any, depth?: number) => Promise<any[]>;
|
|
13
|
-
/** Clear expired cache entries */
|
|
14
|
-
export declare const cleanupRelationCache: () => void;
|