@arcaelas/dynamite 1.0.18 → 1.0.19
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/package.json +1 -1
- package/src/@types/index.d.ts +102 -67
- package/src/index.d.ts +5 -4
- package/src/index.js +21 -6
- package/src/@types/index.js +0 -9
package/package.json
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"test:db:stop": "docker stop dynamite-test-db && docker rm dynamite-test-db || true",
|
|
56
56
|
"test:db:clean": "docker stop dynamite-test-db && docker rm dynamite-test-db; docker run -d -p 8000:8000 --name dynamite-test-db amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb"
|
|
57
57
|
},
|
|
58
|
-
"version": "1.0.
|
|
58
|
+
"version": "1.0.19",
|
|
59
59
|
"jest": {
|
|
60
60
|
"preset": "ts-jest",
|
|
61
61
|
"testEnvironment": "node",
|
package/src/@types/index.d.ts
CHANGED
|
@@ -1,102 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@file index.ts
|
|
3
|
+
@descripcion Tipos públicos de Dynamite ORM
|
|
4
|
+
@autor Miguel Alejandro
|
|
5
|
+
@fecha 2025-08-07
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Brands para tipos especiales
|
|
1
9
|
export declare const HasManyBrand: unique symbol;
|
|
2
10
|
export declare const BelongsToBrand: unique symbol;
|
|
3
11
|
export declare const HasOneBrand: unique symbol;
|
|
4
12
|
export declare const NonAttributeBrand: unique symbol;
|
|
5
13
|
export declare const CreationOptionalBrand: unique symbol;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
export type BelongsTo<T> = (T | null) & {
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type NonAttribute<T> = T & {
|
|
16
|
-
[NonAttributeBrand]?: true;
|
|
17
|
-
};
|
|
18
|
-
export type CreationOptional<T> = T & {
|
|
19
|
-
[CreationOptionalBrand]?: true;
|
|
20
|
-
};
|
|
14
|
+
|
|
15
|
+
// Relaciones y atributos especiales
|
|
16
|
+
export type HasMany<T> = T[] & { [HasManyBrand]?: true };
|
|
17
|
+
export type BelongsTo<T> = (T | null) & { [BelongsToBrand]?: true };
|
|
18
|
+
export type HasOne<T> = (T | null) & { [HasOneBrand]?: true };
|
|
19
|
+
export type NonAttribute<T> = T & { [NonAttributeBrand]?: true };
|
|
20
|
+
export type CreationOptional<T> = T & { [CreationOptionalBrand]?: true };
|
|
21
|
+
|
|
22
|
+
// Atributos inferidos (excluye relaciones, non-attributes y funciones)
|
|
21
23
|
export type InferAttributes<T> = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
[K in keyof T as T[K] extends (...args: any[]) => any
|
|
25
|
+
? never
|
|
26
|
+
: T[K] extends { [HasManyBrand]?: true }
|
|
27
|
+
? never
|
|
28
|
+
: T[K] extends { [BelongsToBrand]?: true }
|
|
29
|
+
? never
|
|
30
|
+
: T[K] extends { [HasOneBrand]?: true }
|
|
31
|
+
? never
|
|
32
|
+
: T[K] extends { [NonAttributeBrand]?: true }
|
|
33
|
+
? never
|
|
34
|
+
: K]: T[K];
|
|
31
35
|
};
|
|
36
|
+
|
|
32
37
|
export type FilterableAttributes<T> = {
|
|
33
|
-
|
|
38
|
+
[K in keyof InferAttributes<T>]: InferAttributes<T>[K];
|
|
34
39
|
};
|
|
40
|
+
|
|
35
41
|
export type WhereOptions<T> = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
where?: Partial<FilterableAttributes<T>>;
|
|
43
|
+
skip?: number;
|
|
44
|
+
limit?: number;
|
|
45
|
+
order?: "ASC" | "DESC";
|
|
46
|
+
attributes?: (keyof FilterableAttributes<T>)[];
|
|
47
|
+
include?: {
|
|
48
|
+
[K in keyof T]?: T[K] extends HasMany<any> | BelongsTo<any> | HasOne<any>
|
|
49
|
+
? IncludeRelationOptions | true
|
|
50
|
+
: never;
|
|
51
|
+
};
|
|
44
52
|
};
|
|
53
|
+
|
|
45
54
|
/** Filtros de query sin cláusula where */
|
|
46
55
|
export type QueryFilters<T> = Omit<WhereOptions<T>, "where">;
|
|
56
|
+
|
|
47
57
|
/** @deprecated Usa QueryFilters */
|
|
48
58
|
export type WhereOptionsWithoutWhere<T> = QueryFilters<T>;
|
|
49
|
-
|
|
59
|
+
|
|
60
|
+
export type QueryOperator =
|
|
61
|
+
| "="
|
|
62
|
+
| "!="
|
|
63
|
+
| "<"
|
|
64
|
+
| "<="
|
|
65
|
+
| ">"
|
|
66
|
+
| ">="
|
|
67
|
+
| "in"
|
|
68
|
+
| "not-in"
|
|
69
|
+
| "contains"
|
|
70
|
+
| "begins-with";
|
|
71
|
+
|
|
50
72
|
/** Entrada de validador con soporte lazy */
|
|
51
73
|
export interface ValidatorEntry {
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
fn: (value: any) => boolean | string;
|
|
75
|
+
lazy?: boolean;
|
|
54
76
|
}
|
|
77
|
+
|
|
78
|
+
// Tipos para core/wrapper
|
|
55
79
|
export interface Column {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
name: string;
|
|
81
|
+
index?: true;
|
|
82
|
+
indexSort?: true;
|
|
83
|
+
primaryKey?: boolean;
|
|
84
|
+
nullable?: boolean;
|
|
85
|
+
unique?: true;
|
|
86
|
+
createdAt?: boolean;
|
|
87
|
+
updatedAt?: boolean;
|
|
88
|
+
softDelete?: boolean;
|
|
89
|
+
lazy_validators?: ((value: any) => boolean | string)[];
|
|
90
|
+
relation?: RelationMetadata;
|
|
67
91
|
}
|
|
92
|
+
|
|
68
93
|
export interface RelationMetadata {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
94
|
+
type: "hasMany" | "belongsTo" | "hasOne";
|
|
95
|
+
targetModel: () => any;
|
|
96
|
+
foreignKey: string;
|
|
97
|
+
localKey?: string;
|
|
73
98
|
}
|
|
99
|
+
|
|
74
100
|
export interface WrapperEntry {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
name: string;
|
|
102
|
+
columns: Map<string | symbol, Column>;
|
|
103
|
+
relations: Map<string | symbol, RelationMetadata>;
|
|
78
104
|
}
|
|
105
|
+
|
|
79
106
|
/** Alias para WrapperEntry (usado internamente con SCHEMA symbol) */
|
|
80
107
|
export type SchemaEntry = WrapperEntry;
|
|
108
|
+
|
|
109
|
+
// Tipos internos del where de Table
|
|
81
110
|
export type IncludeRelationOptions = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
where?: Record<string, any>;
|
|
112
|
+
attributes?: string[];
|
|
113
|
+
order?: "ASC" | "DESC";
|
|
114
|
+
skip?: number;
|
|
115
|
+
limit?: number;
|
|
116
|
+
include?: Record<string, IncludeRelationOptions | true>;
|
|
88
117
|
};
|
|
118
|
+
|
|
89
119
|
/** Opciones de query para métodos where(), first(), last(), etc. */
|
|
90
120
|
export type QueryOptions<T> = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
order?: "ASC" | "DESC";
|
|
122
|
+
skip?: number;
|
|
123
|
+
limit?: number;
|
|
124
|
+
attributes?: (keyof InferAttributes<T>)[];
|
|
125
|
+
include?: {
|
|
126
|
+
[K in keyof T]?: T[K] extends HasMany<any> | BelongsTo<any> | HasOne<any>
|
|
127
|
+
? IncludeRelationOptions | true
|
|
128
|
+
: never;
|
|
129
|
+
};
|
|
98
130
|
};
|
|
131
|
+
|
|
99
132
|
/** @deprecated Usa QueryOptions */
|
|
100
133
|
export type WhereQueryOptions<T> = QueryOptions<T>;
|
|
134
|
+
|
|
135
|
+
// Tipos utilitarios para decoradores
|
|
101
136
|
export type Mutate = (value: any) => any;
|
|
102
137
|
export type Validate = (value: any) => boolean | string;
|
package/src/index.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ export { Dynamite } from "./core/client";
|
|
|
8
8
|
export { default as Table } from "./core/table";
|
|
9
9
|
export { decorator, relationDecorator, SCHEMA, VALUES } from "./core/decorator";
|
|
10
10
|
export { Index, IndexSort, PrimaryKey } from "./decorators/indexes";
|
|
11
|
-
export { CreatedAt,
|
|
12
|
-
export { Default, Mutate,
|
|
13
|
-
export {
|
|
14
|
-
export type {
|
|
11
|
+
export { CreatedAt, DeleteAt, UpdatedAt } from "./decorators/timestamps";
|
|
12
|
+
export { Default, Mutate, Name, NotNull, Serialize, Validate, } from "./decorators/transforms";
|
|
13
|
+
export { BelongsTo, HasMany, HasOne } from "./decorators/relations";
|
|
14
|
+
export type { IncludeRelationOptions, QueryOperator, QueryOptions, } from "./core/table";
|
|
15
|
+
export * from "./@types/index";
|
|
15
16
|
export { TransactionContext } from "./core/client";
|
package/src/index.js
CHANGED
|
@@ -5,11 +5,25 @@
|
|
|
5
5
|
* @autor Miguel Alejandro
|
|
6
6
|
* @fecha 2025-01-28
|
|
7
7
|
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
8
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
24
|
};
|
|
11
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TransactionContext = exports.HasOne = exports.
|
|
26
|
+
exports.TransactionContext = exports.HasOne = exports.HasMany = exports.BelongsTo = exports.Validate = exports.Serialize = exports.NotNull = exports.Name = exports.Mutate = exports.Default = exports.UpdatedAt = exports.DeleteAt = exports.CreatedAt = exports.PrimaryKey = exports.IndexSort = exports.Index = exports.VALUES = exports.SCHEMA = exports.relationDecorator = exports.decorator = exports.Table = exports.Dynamite = void 0;
|
|
13
27
|
// Clases núcleo
|
|
14
28
|
var client_1 = require("./core/client");
|
|
15
29
|
Object.defineProperty(exports, "Dynamite", { enumerable: true, get: function () { return client_1.Dynamite; } });
|
|
@@ -29,22 +43,23 @@ Object.defineProperty(exports, "PrimaryKey", { enumerable: true, get: function (
|
|
|
29
43
|
// Decoradores - Timestamps
|
|
30
44
|
var timestamps_1 = require("./decorators/timestamps");
|
|
31
45
|
Object.defineProperty(exports, "CreatedAt", { enumerable: true, get: function () { return timestamps_1.CreatedAt; } });
|
|
32
|
-
Object.defineProperty(exports, "UpdatedAt", { enumerable: true, get: function () { return timestamps_1.UpdatedAt; } });
|
|
33
46
|
Object.defineProperty(exports, "DeleteAt", { enumerable: true, get: function () { return timestamps_1.DeleteAt; } });
|
|
47
|
+
Object.defineProperty(exports, "UpdatedAt", { enumerable: true, get: function () { return timestamps_1.UpdatedAt; } });
|
|
34
48
|
// Decoradores - Transformación
|
|
35
49
|
var transforms_1 = require("./decorators/transforms");
|
|
36
50
|
Object.defineProperty(exports, "Default", { enumerable: true, get: function () { return transforms_1.Default; } });
|
|
37
51
|
Object.defineProperty(exports, "Mutate", { enumerable: true, get: function () { return transforms_1.Mutate; } });
|
|
38
|
-
Object.defineProperty(exports, "Validate", { enumerable: true, get: function () { return transforms_1.Validate; } });
|
|
39
|
-
Object.defineProperty(exports, "Serialize", { enumerable: true, get: function () { return transforms_1.Serialize; } });
|
|
40
|
-
Object.defineProperty(exports, "NotNull", { enumerable: true, get: function () { return transforms_1.NotNull; } });
|
|
41
52
|
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return transforms_1.Name; } });
|
|
53
|
+
Object.defineProperty(exports, "NotNull", { enumerable: true, get: function () { return transforms_1.NotNull; } });
|
|
54
|
+
Object.defineProperty(exports, "Serialize", { enumerable: true, get: function () { return transforms_1.Serialize; } });
|
|
55
|
+
Object.defineProperty(exports, "Validate", { enumerable: true, get: function () { return transforms_1.Validate; } });
|
|
42
56
|
// Decoradores - Relaciones
|
|
43
57
|
var relations_1 = require("./decorators/relations");
|
|
44
|
-
Object.defineProperty(exports, "HasMany", { enumerable: true, get: function () { return relations_1.HasMany; } });
|
|
45
58
|
Object.defineProperty(exports, "BelongsTo", { enumerable: true, get: function () { return relations_1.BelongsTo; } });
|
|
59
|
+
Object.defineProperty(exports, "HasMany", { enumerable: true, get: function () { return relations_1.HasMany; } });
|
|
46
60
|
Object.defineProperty(exports, "HasOne", { enumerable: true, get: function () { return relations_1.HasOne; } });
|
|
47
61
|
// Re-exportar TransactionContext para compatibilidad
|
|
62
|
+
__exportStar(require("./@types/index"), exports);
|
|
48
63
|
var client_2 = require("./core/client");
|
|
49
64
|
Object.defineProperty(exports, "TransactionContext", { enumerable: true, get: function () { return client_2.TransactionContext; } });
|
|
50
65
|
//# sourceMappingURL=index.js.map
|
package/src/@types/index.js
DELETED