@arcaelas/dynamite 1.0.25 → 1.0.29

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 CHANGED
@@ -47,5 +47,5 @@
47
47
  "prepublishOnly": "yarn build",
48
48
  "postpublish": "find src -type f \\( -name '*.js' -o -name '*.d.ts' -o -name '*.map' \\) -delete"
49
49
  },
50
- "version": "1.0.25"
50
+ "version": "1.0.29"
51
51
  }
@@ -54,8 +54,10 @@ class Dynamite {
54
54
  constructor(config) {
55
55
  this.connected = false;
56
56
  this.synced = false;
57
- const { tables, ...clientConfig } = config;
58
- this.client = new client_dynamodb_1.DynamoDBClient(clientConfig);
57
+ const { tables, ...options } = config;
58
+ this.client = new client_dynamodb_1.DynamoDBClient({
59
+ ...options,
60
+ });
59
61
  this.tables = tables;
60
62
  }
61
63
  /**
@@ -89,7 +91,7 @@ class Dynamite {
89
91
  if (relation?.type === "ManyToMany" && relation.pivotTable) {
90
92
  pivot_tables.set(relation.pivotTable, {
91
93
  foreignKey: relation.foreignKey || "source_id",
92
- relatedKey: relation.relatedKey || "target_id"
94
+ relatedKey: relation.relatedKey || "target_id",
93
95
  });
94
96
  }
95
97
  }
package/src/core/table.js CHANGED
@@ -790,10 +790,10 @@ class Table {
790
790
  return 0;
791
791
  });
792
792
  }
793
- // 3. Aplicar paginación DESPUÉS de ordenar (soporta skip como alias de offset)
794
- const targetSkip = queryOptions.skip ?? queryOptions.offset ?? 0;
795
- const targetLimit = queryOptions.limit ?? allItems.length;
796
- allItems = allItems.slice(targetSkip, targetSkip + targetLimit);
793
+ // 3. Aplicar paginación DESPUÉS de ordenar (skip es alias de offset)
794
+ const offset = queryOptions.skip ?? queryOptions.offset ?? 0;
795
+ const limit = queryOptions.limit ?? allItems.length;
796
+ allItems = allItems.slice(offset, offset + limit);
797
797
  const instances = allItems.map((item) => {
798
798
  // Mapear nombres de DB → propiedades TS
799
799
  const mapped_item = this._mapDBToProperties(item);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const index_1 = require("./index");
13
+ class User extends index_1.Table {
14
+ }
15
+ __decorate([
16
+ (0, index_1.PrimaryKey)(),
17
+ (0, index_1.Default)(() => crypto.randomUUID()),
18
+ __metadata("design:type", Object)
19
+ ], User.prototype, "id", void 0);
20
+ __decorate([
21
+ (0, index_1.Default)(() => "customer"),
22
+ __metadata("design:type", Object)
23
+ ], User.prototype, "role", void 0);
24
+ __decorate([
25
+ (0, index_1.CreatedAt)(),
26
+ __metadata("design:type", Object)
27
+ ], User.prototype, "created_at", void 0);
28
+ __decorate([
29
+ (0, index_1.UpdatedAt)(),
30
+ __metadata("design:type", Object)
31
+ ], User.prototype, "updated_at", void 0);
32
+ (async function () {
33
+ const dynamite = new index_1.Dynamite({ tables: [User] });
34
+ await dynamite.connect();
35
+ console.log("Connected successfully");
36
+ })();
37
+ //# sourceMappingURL=index.test.js.map
@@ -12,6 +12,7 @@ interface IncludeOptions {
12
12
  attributes?: string[];
13
13
  limit?: number;
14
14
  offset?: number;
15
+ skip?: number;
15
16
  order?: 'asc' | 'desc';
16
17
  include?: Record<string, IncludeOptions | boolean>;
17
18
  }
@@ -43,8 +43,9 @@ const batchLoadHasMany = async (items, relation, options = {}) => {
43
43
  }
44
44
  // Aplicar limit por grupo
45
45
  if (options.limit) {
46
+ const offset = options.skip ?? options.offset ?? 0;
46
47
  for (const [key, groupItems] of grouped) {
47
- grouped.set(key, groupItems.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit));
48
+ grouped.set(key, groupItems.slice(offset, offset + options.limit));
48
49
  }
49
50
  }
50
51
  return grouped;
@@ -115,8 +116,9 @@ const batchLoadManyToMany = async (items, relation, options = {}) => {
115
116
  }
116
117
  // [7] Apply limit per group
117
118
  if (options.limit) {
119
+ const offset = options.skip ?? options.offset ?? 0;
118
120
  for (const [key, items_arr] of grouped) {
119
- grouped.set(key, items_arr.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit));
121
+ grouped.set(key, items_arr.slice(offset, offset + options.limit));
120
122
  }
121
123
  }
122
124
  return grouped;