@alpha.consultings/eloquent-orm.js 1.0.8 → 1.0.10

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [1.0.10](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.9...v1.0.10) (2026-03-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * make latest release summary mdx-safe for docs lint ([a4149bd](https://github.com/MetalDz/Eloquent-ORM.js/commit/a4149bd672972ed952c2e1d7d4092214d64ca058))
7
+ * support nodenext local ts imports in cli ts runtime ([27d383e](https://github.com/MetalDz/Eloquent-ORM.js/commit/27d383e547034d5ab1978872af167e15abe36376))
8
+
9
+ ## [1.0.9](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.8...v1.0.9) (2026-03-28)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add esm-safe package entry and document nodenext imports ([ccf1105](https://github.com/MetalDz/Eloquent-ORM.js/commit/ccf11057385d0ad00530ad41ba34b41f575fae02))
15
+ * patch dist cjs factory export after build ([2499e1a](https://github.com/MetalDz/Eloquent-ORM.js/commit/2499e1a08bc47835d59668a02e3cf6baa6b284d2))
16
+
1
17
  ## [1.0.8](https://github.com/MetalDz/Eloquent-ORM.js/compare/v1.0.7...v1.0.8) (2026-03-28)
2
18
 
3
19
 
@@ -1,6 +1,6 @@
1
1
  # Package Update Summary
2
2
 
3
- Version: `1.0.8`
3
+ Version: `1.0.10`
4
4
 
5
5
  This file is the source of truth for the release-focused quick info block that appears in `README.md`.
6
6
 
@@ -14,16 +14,22 @@ npm run docs:sync-package-metadata
14
14
 
15
15
  <!-- release-lineup:start -->
16
16
  Latest Release:
17
- - `v1.0.8 latest`
17
+ - `v1.0.10 latest`
18
18
 
19
19
  Old Release:
20
- - `v1.0.7`
20
+ - `v1.0.9`
21
21
  <!-- release-lineup:end -->
22
22
 
23
+ ## Latest Release Headline
24
+
25
+ <!-- latest-package-headline:start -->
26
+ - Patched. Added an ESM-safe package entry for NodeNext consumers and stabilized CommonJS `Factory` export behavior.
27
+ <!-- latest-package-headline:end -->
28
+
23
29
  ## Latest Release Summary
24
30
 
25
31
  <!-- latest-package-update:start -->
26
- - Document release behavior for `docs:` commits so semantic-release publishes documentation updates as patch releases.
32
+ - Add an ESM-safe package entry for NodeNext consumers, keep CommonJS root imports from eagerly loading `Factory`, and verify installed-package ESM imports in pack-smoke.
27
33
  <!-- latest-package-update:end -->
28
34
 
29
35
  ## Synced Quick Info
@@ -31,11 +37,11 @@ Old Release:
31
37
  <!-- package-quick-info:start -->
32
38
  Quick info:
33
39
  - Package: `@alpha.consultings/eloquent-orm.js`
34
- - Version: `v1.0.8`
35
- - Latest release: `v1.0.8 latest`
36
- - What's new: Fix release
37
- - Old release: `v1.0.7`
38
- - Latest update: Document release behavior for `docs:` commits so semantic-release publishes documentation updates as patch releases.
40
+ - Version: `v1.0.10`
41
+ - Latest release: `v1.0.10 latest`
42
+ - What's new: [Patched. Added an ESM-safe package entry for NodeNext consumers and stabilized CommonJS `Factory` export behavior.](https://alphaconsultings.mintlify.app/release/latest-release-summary)
43
+ - Old release: `v1.0.9`
44
+ - Latest update: Add an ESM-safe package entry for NodeNext consumers, keep CommonJS root imports from eagerly loading `Factory`, and verify installed-package ESM imports in pack-smoke.
39
45
  - Official docs: https://alphaconsultings.mintlify.app
40
46
  - Quick start: https://alphaconsultings.mintlify.app/getting-started/quick-start
41
47
  - Release history: https://alphaconsultings.mintlify.app/release/history
@@ -44,6 +50,7 @@ Quick info:
44
50
 
45
51
  ## Update Rule
46
52
 
53
+ - Refresh the `latest-package-headline` summary on every fix, minor, or major release.
47
54
  - Refresh the `latest-package-update` summary on every fix, minor, or major release.
48
- - Keep the quick info short and focused on the most useful runtime or package changes.
49
- - Let the sync script refresh package name, version, docs URL, and README output.
55
+ - Keep the headline short and linkable, and keep the detailed update exact and release-specific.
56
+ - Let the sync script refresh package name, version, docs URL, README output, and the latest release summary docs page.
package/README.md CHANGED
@@ -17,11 +17,11 @@ Laravel-inspired ORM + CLI for Node.js + TypeScript with SQL and MongoDB runtime
17
17
  <!-- package-quick-info:start -->
18
18
  Quick info:
19
19
  - Package: `@alpha.consultings/eloquent-orm.js`
20
- - Version: `v1.0.8`
21
- - Latest release: `v1.0.8 latest`
22
- - What's new: Fix release
23
- - Old release: `v1.0.7`
24
- - Latest update: Document release behavior for `docs:` commits so semantic-release publishes documentation updates as patch releases.
20
+ - Version: `v1.0.10`
21
+ - Latest release: `v1.0.10 latest`
22
+ - What's new: [Patched. Added an ESM-safe package entry for NodeNext consumers and stabilized CommonJS `Factory` export behavior.](https://alphaconsultings.mintlify.app/release/latest-release-summary)
23
+ - Old release: `v1.0.9`
24
+ - Latest update: Add an ESM-safe package entry for NodeNext consumers, keep CommonJS root imports from eagerly loading `Factory`, and verify installed-package ESM imports in pack-smoke.
25
25
  - Official docs: https://alphaconsultings.mintlify.app
26
26
  - Quick start: https://alphaconsultings.mintlify.app/getting-started/quick-start
27
27
  - Release history: https://alphaconsultings.mintlify.app/release/history
@@ -186,6 +186,7 @@ async function makeMigration(modelName, options = {}) {
186
186
  }
187
187
  const loadedModels = [];
188
188
  const pendingPivotMigrations = new Map();
189
+ const failedFiles = new Set();
189
190
  const timestampSeed = new Date()
190
191
  .toISOString()
191
192
  .replace(/[-:.TZ]/g, "")
@@ -227,6 +228,7 @@ async function makeMigration(modelName, options = {}) {
227
228
  });
228
229
  }
229
230
  catch (err) {
231
+ failedFiles.add(file);
230
232
  console.error(chalk_1.default.red(`ERROR: Error processing ${file}:`));
231
233
  console.error(err instanceof Error ? err.message : err);
232
234
  }
@@ -454,6 +456,7 @@ export async function down(db: { query(sql: string): Promise<void> }) {
454
456
  }
455
457
  }
456
458
  catch (err) {
459
+ failedFiles.add(file);
457
460
  console.error(chalk_1.default.red(`ERROR: Error processing ${file}:`));
458
461
  console.error(err instanceof Error ? err.message : err);
459
462
  }
@@ -488,6 +491,16 @@ export async function down(db: { query(sql: string): Promise<void> }) {
488
491
  catch {
489
492
  console.warn(chalk_1.default.yellow("WARN: Could not close DB connections cleanly."));
490
493
  }
494
+ if (failedFiles.size > 0) {
495
+ const failureSummary = `ERROR: Migration generation failed for ${failedFiles.size} model` +
496
+ `${failedFiles.size === 1 ? "" : "s"}: ${[...failedFiles].join(", ")}`;
497
+ console.error(chalk_1.default.red(failureSummary));
498
+ if (options.exit !== false) {
499
+ process.exit(1);
500
+ return;
501
+ }
502
+ throw new Error(failureSummary);
503
+ }
491
504
  console.log(chalk_1.default.cyanBright(`OK: Migration generation complete in ${isTest ? "TEST" : "DEVELOPMENT"} mode.\n`));
492
505
  if (options.exit !== false) {
493
506
  process.exit(0);
@@ -23,13 +23,42 @@ const PACKAGE_NAME = (() => {
23
23
  }
24
24
  })();
25
25
  function resolveExistingModulePath(basePath) {
26
- const candidates = [
27
- basePath,
28
- `${basePath}.ts`,
29
- `${basePath}.js`,
30
- path_1.default.join(basePath, "index.ts"),
31
- path_1.default.join(basePath, "index.js"),
32
- ];
26
+ const extension = path_1.default.extname(basePath).toLowerCase();
27
+ const withoutExtension = extension.length > 0 ? basePath.slice(0, -extension.length) : basePath;
28
+ const candidates = [];
29
+ const seen = new Set();
30
+ const addCandidate = (candidate) => {
31
+ if (seen.has(candidate)) {
32
+ return;
33
+ }
34
+ seen.add(candidate);
35
+ candidates.push(candidate);
36
+ };
37
+ if (extension === ".js" || extension === ".mjs" || extension === ".cjs") {
38
+ // NodeNext TypeScript source commonly imports local modules using `.js`
39
+ // specifiers even though the source file on disk is `.ts`.
40
+ addCandidate(`${withoutExtension}.ts`);
41
+ addCandidate(`${withoutExtension}.tsx`);
42
+ addCandidate(`${withoutExtension}.mts`);
43
+ addCandidate(`${withoutExtension}.cts`);
44
+ }
45
+ addCandidate(basePath);
46
+ if (!extension) {
47
+ addCandidate(`${basePath}.ts`);
48
+ addCandidate(`${basePath}.tsx`);
49
+ addCandidate(`${basePath}.mts`);
50
+ addCandidate(`${basePath}.cts`);
51
+ addCandidate(`${basePath}.js`);
52
+ addCandidate(`${basePath}.mjs`);
53
+ addCandidate(`${basePath}.cjs`);
54
+ addCandidate(path_1.default.join(basePath, "index.ts"));
55
+ addCandidate(path_1.default.join(basePath, "index.tsx"));
56
+ addCandidate(path_1.default.join(basePath, "index.mts"));
57
+ addCandidate(path_1.default.join(basePath, "index.cts"));
58
+ addCandidate(path_1.default.join(basePath, "index.js"));
59
+ addCandidate(path_1.default.join(basePath, "index.mjs"));
60
+ addCandidate(path_1.default.join(basePath, "index.cjs"));
61
+ }
33
62
  return candidates.find((candidate) => fs_1.default.existsSync(candidate)) ?? null;
34
63
  }
35
64
  function resolveLocalRequest(request, fromFilePath) {
package/dist/index.js CHANGED
@@ -14,8 +14,7 @@ Object.defineProperty(exports, "MongoModel", { enumerable: true, get: function (
14
14
  Object.defineProperty(exports, "MorphRegistry", { enumerable: true, get: function () { return BaseModel_1.MorphRegistry; } });
15
15
  var PivotHelperMixin_1 = require("./core/orm/mixins/PivotHelperMixin");
16
16
  Object.defineProperty(exports, "PivotHelperMixin", { enumerable: true, get: function () { return PivotHelperMixin_1.PivotHelperMixin; } });
17
- var Factory_1 = require("./cli/utils/factories/Factory");
18
- Object.defineProperty(exports, "Factory", { enumerable: true, get: function () { return Factory_1.Factory; } });
17
+ Object.defineProperty(exports, "Factory", { enumerable: true, get: function () { return require("./cli/utils/factories/Factory").Factory; } });
19
18
  var CoreModel_1 = require("./core/model/CoreModel");
20
19
  Object.defineProperty(exports, "CoreModel", { enumerable: true, get: function () { return CoreModel_1.CoreModel; } });
21
20
  var SchemaBlueprint_1 = require("./core/schema/SchemaBlueprint");
@@ -0,0 +1,143 @@
1
+ import { faker } from "@faker-js/faker";
2
+
3
+ export class Factory {
4
+ faker = faker;
5
+
6
+ async create(attrs = {}, index = 0) {
7
+ const base = this.definition(index);
8
+ const merged = { ...base, ...attrs };
9
+
10
+ if (this.beforeCreate) {
11
+ const modified = await this.beforeCreate(merged, index);
12
+ if (modified && typeof modified === "object") {
13
+ Object.assign(merged, modified);
14
+ }
15
+ }
16
+
17
+ let instance = new this.model();
18
+
19
+ if (this.#hasInstanceCreate(instance)) {
20
+ const created = await instance.create(merged);
21
+ if (created) {
22
+ instance = created;
23
+ }
24
+ } else if (this.#hasStaticCreate(this.model)) {
25
+ return this.model.create(merged);
26
+ } else if (this.#hasInstanceSave(instance)) {
27
+ Object.assign(instance, merged);
28
+ await instance.save();
29
+ } else {
30
+ throw new Error(`Model '${this.model.name}' has no valid create/save method.`);
31
+ }
32
+
33
+ if (this.afterCreate) {
34
+ await this.afterCreate(instance);
35
+ }
36
+
37
+ return instance;
38
+ }
39
+
40
+ async createMany(count, callback, concurrency = 1) {
41
+ const results = [];
42
+
43
+ const executeCreate = async (index) => {
44
+ const model = await this.create({}, index);
45
+ if (callback) {
46
+ await callback(model, index);
47
+ }
48
+ results[index] = model;
49
+ };
50
+
51
+ if (concurrency <= 1) {
52
+ for (let index = 0; index < count; index += 1) {
53
+ await executeCreate(index);
54
+ }
55
+ return results;
56
+ }
57
+
58
+ let active = 0;
59
+ let index = 0;
60
+ let settled = false;
61
+
62
+ return new Promise((resolve, reject) => {
63
+ const maybeResolve = () => {
64
+ if (!settled && index >= count && active === 0) {
65
+ settled = true;
66
+ resolve(results);
67
+ }
68
+ };
69
+
70
+ const next = () => {
71
+ if (settled) {
72
+ return;
73
+ }
74
+
75
+ while (active < concurrency && index < count && !settled) {
76
+ const currentIndex = index++;
77
+ active += 1;
78
+
79
+ void executeCreate(currentIndex)
80
+ .catch((error) => {
81
+ if (settled) {
82
+ return;
83
+ }
84
+ settled = true;
85
+ reject(error);
86
+ })
87
+ .finally(() => {
88
+ active -= 1;
89
+ if (settled) {
90
+ return;
91
+ }
92
+ next();
93
+ });
94
+ }
95
+
96
+ maybeResolve();
97
+ };
98
+
99
+ next();
100
+ });
101
+ }
102
+
103
+ async related(factoryOrCtor, count = 1) {
104
+ const factory =
105
+ typeof factoryOrCtor === "function"
106
+ ? new factoryOrCtor()
107
+ : factoryOrCtor;
108
+
109
+ if (count === 1) {
110
+ return factory.create();
111
+ }
112
+
113
+ return factory.createMany(count);
114
+ }
115
+
116
+ async relatedPivot(
117
+ factory,
118
+ pivotTable,
119
+ foreignKey,
120
+ relatedKey,
121
+ foreignId,
122
+ relatedIds,
123
+ extraPivotAttrs
124
+ ) {
125
+ await factory.createPivot(foreignId, relatedIds, extraPivotAttrs);
126
+
127
+ console.log(
128
+ `[Pivot Attached] Table "${pivotTable}" (${foreignKey} -> ${relatedKey})`
129
+ );
130
+ }
131
+
132
+ #hasInstanceCreate(obj) {
133
+ return typeof obj?.create === "function";
134
+ }
135
+
136
+ #hasStaticCreate(ctor) {
137
+ return typeof ctor?.create === "function";
138
+ }
139
+
140
+ #hasInstanceSave(obj) {
141
+ return typeof obj?.save === "function";
142
+ }
143
+ }
package/esm/index.mjs ADDED
@@ -0,0 +1,32 @@
1
+ import cjsPackage from "../dist/index.js";
2
+ import { Factory } from "./Factory.mjs";
3
+
4
+ export { Factory };
5
+
6
+ export const {
7
+ BaseModel,
8
+ Model,
9
+ SqlModel,
10
+ MongoModel,
11
+ MorphRegistry,
12
+ PivotHelperMixin,
13
+ CoreModel,
14
+ column,
15
+ validate,
16
+ relation,
17
+ mixin,
18
+ validateSchema,
19
+ SchemaValidator,
20
+ SchemaBuilder,
21
+ CacheManager,
22
+ setupCache,
23
+ registerModels,
24
+ isModelRegistered,
25
+ setModelRegistryStrictMode,
26
+ isModelRegistryStrictMode,
27
+ } = cjsPackage;
28
+
29
+ export default {
30
+ ...cjsPackage,
31
+ Factory,
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpha.consultings/eloquent-orm.js",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "A Laravel Eloquent-inspired ORM Multi Driver SQL & NoSQL and Cache System and Artisan CLI like for Node.js Lovers",
5
5
  "keywords": [
6
6
  "orm",
@@ -46,8 +46,15 @@
46
46
  "exports": {
47
47
  ".": {
48
48
  "types": "./dist/index.d.ts",
49
+ "import": "./esm/index.mjs",
49
50
  "require": "./dist/index.js",
50
- "default": "./dist/index.js"
51
+ "default": "./esm/index.mjs"
52
+ },
53
+ "./Factory": {
54
+ "types": "./dist/cli/utils/factories/Factory.d.ts",
55
+ "import": "./esm/Factory.mjs",
56
+ "require": "./dist/cli/utils/factories/Factory.js",
57
+ "default": "./esm/Factory.mjs"
51
58
  },
52
59
  "./Model": {
53
60
  "types": "./dist/Model.d.ts",
@@ -61,6 +68,7 @@
61
68
  },
62
69
  "files": [
63
70
  "dist",
71
+ "esm/**/*",
64
72
  "src/cli/templates/**/*",
65
73
  "README.md",
66
74
  "CHANGELOG.md",
@@ -71,7 +79,7 @@
71
79
  "docs:sync-supported": "node scripts/sync-supported-versions.cjs",
72
80
  "docs:sync-config": "node scripts/sync-mintlify-configs.cjs",
73
81
  "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
74
- "build": "npm run docs:sync-package-metadata && npm run docs:sync-supported && npm run clean && tsc -p tsconfig.build.json",
82
+ "build": "npm run docs:sync-package-metadata && npm run docs:sync-supported && npm run clean && tsc -p tsconfig.build.json && node scripts/patch-dist-cjs-factory-entry.cjs",
75
83
  "typecheck": "tsc -p . --noEmit --skipLibCheck",
76
84
  "docs:dev": "npm run docs:sync-package-metadata && npm run docs:sync-config && node scripts/run-mintlify.cjs dev",
77
85
  "docs:build": "npm run docs:sync-package-metadata && npm run docs:sync-supported && npm run docs:sync-config && node scripts/run-mintlify.cjs validate",