@cheetah.js/orm 0.1.126 → 0.1.131

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/build.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ConnectionSettings } from '@cheetah.js/orm/driver/driver.interface';
2
+ declare const config: ConnectionSettings<any>;
3
+ export default config;
@@ -19,7 +19,13 @@ class BunDriverBase {
19
19
  if (this.sql) {
20
20
  return;
21
21
  }
22
- this.sql = new bun_1.SQL(this.connectionString);
22
+ this.sql = new bun_1.SQL({
23
+ url: this.connectionString,
24
+ max: 20,
25
+ idleTimeout: 20, // segundos antes de fechar idle
26
+ maxLifetime: 300, // recicla conexões a cada 5 min
27
+ connectionTimeout: 10
28
+ });
23
29
  await this.validateConnection();
24
30
  }
25
31
  async validateConnection() {
@@ -188,7 +188,8 @@ async function loadStatementsFromMigrations(options) {
188
188
  if (files.length < 1) {
189
189
  return [];
190
190
  }
191
- return extractStatementsFromFiles(files);
191
+ const orderedFiles = sortMigrationFiles(files);
192
+ return extractStatementsFromFiles(orderedFiles);
192
193
  }
193
194
  async function resolveMigrationPatterns(connection) {
194
195
  if (connection.migrationPath) {
@@ -272,6 +273,9 @@ function extractStatements(payload) {
272
273
  const matches = payload.match(/(CREATE\s+(?:TABLE|TYPE|INDEX|SCHEMA)[\s\S]*?;|ALTER\s+TABLE[\s\S]*?\bADD\b[\s\S]*?;)/gi) ?? [];
273
274
  return matches.map((statement) => statement.replace(/\s+/g, ' ').trim());
274
275
  }
276
+ function sortMigrationFiles(files) {
277
+ return [...files].sort((first, second) => path_1.default.basename(first).localeCompare(path_1.default.basename(second), undefined, { numeric: true }));
278
+ }
275
279
  async function prepareSchema(context, schema) {
276
280
  await context.executeSql(buildCreateSchemaStatement(schema));
277
281
  await ensureSearchPath(context, schema);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.126",
4
- "description": "A simple ORM for Cheetah.js",
3
+ "version": "0.1.131",
4
+ "description": "A simple ORM for Cheetah.js.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "bun",
56
56
  "value-object"
57
57
  ],
58
- "gitHead": "21e45a0718c8f4c55b7f03d5dad285481a382527"
58
+ "gitHead": "1770fe312c1227aa2928ebfc4f9ac82a8411d4e6"
59
59
  }