bigal 16.0.0-beta.1 → 16.0.0-beta.2
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 +6 -0
- package/dist/index.cjs +10 -18
- package/dist/index.d.cts +205 -164
- package/dist/index.d.mts +205 -164
- package/dist/index.d.ts +205 -164
- package/dist/index.mjs +10 -18
- package/docs/guide/migration-v16.md +9 -23
- package/docs/guide/models.md +7 -9
- package/docs/guide/relationships.md +24 -9
- package/docs/reference/api.md +10 -7
- package/package.json +1 -1
- package/scripts/migrate-v16.ts +17 -4
- package/skills/upgrade-v16/SKILL.md +36 -12
- package/skills/using-bigal/SKILL.md +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [16.0.0-beta.2](https://github.com/bigalorm/bigal/compare/v16.0.0-beta.1...v16.0.0-beta.2) (2026-03-24)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- Type-safe populate, EntityOrId, and model registry ([1d68830](https://github.com/bigalorm/bigal/commit/1d688306e1574ae4f3275700c1325b7410daadf3))
|
|
6
|
+
|
|
1
7
|
## [16.0.0-beta.1](https://github.com/bigalorm/bigal/compare/v15.11.4...v16.0.0-beta.1) (2026-03-23)
|
|
2
8
|
|
|
3
9
|
### ⚠ BREAKING CHANGES
|
package/dist/index.cjs
CHANGED
|
@@ -2387,6 +2387,7 @@ class ReadonlyRepository {
|
|
|
2387
2387
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
2388
2388
|
* @returns Database record or null
|
|
2389
2389
|
*/
|
|
2390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- runtime; IReadonlyRepository interface provides typed generics
|
|
2390
2391
|
findOne(args = {}) {
|
|
2391
2392
|
const { stack } = new Error(`${this.model.name}.findOne()`);
|
|
2392
2393
|
let select;
|
|
@@ -2464,6 +2465,7 @@ class ReadonlyRepository {
|
|
|
2464
2465
|
* @param {string|number} [options.limit] - Number of results to return
|
|
2465
2466
|
* @returns Query instance
|
|
2466
2467
|
*/
|
|
2468
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- runtime; FindOneResult interface provides type safety for consumers
|
|
2467
2469
|
populate(propertyName, options) {
|
|
2468
2470
|
if (select && !select.has(propertyName)) {
|
|
2469
2471
|
for (const column of modelInstance.model.columns) {
|
|
@@ -2602,6 +2604,7 @@ ${stack ?? ""}`;
|
|
|
2602
2604
|
* @param {string|number} [args.limit] - Number of results to return
|
|
2603
2605
|
* @returns Database records
|
|
2604
2606
|
*/
|
|
2607
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- runtime; IReadonlyRepository interface provides typed generics
|
|
2605
2608
|
find(args = {}) {
|
|
2606
2609
|
const { stack } = new Error(`${this.model.name}.find()`);
|
|
2607
2610
|
let select;
|
|
@@ -2690,6 +2693,7 @@ ${stack ?? ""}`;
|
|
|
2690
2693
|
* @param {string|number} [options.limit] - Number of results to return
|
|
2691
2694
|
* @returns Query instance
|
|
2692
2695
|
*/
|
|
2696
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- runtime; FindResult interface provides type safety for consumers
|
|
2693
2697
|
populate(propertyName, options) {
|
|
2694
2698
|
if (select && !select.has(propertyName)) {
|
|
2695
2699
|
for (const column of modelInstance.model.columns) {
|
|
@@ -3619,26 +3623,20 @@ function initialize(options) {
|
|
|
3619
3623
|
}
|
|
3620
3624
|
return instance;
|
|
3621
3625
|
}
|
|
3622
|
-
function resolveModelName$1(ref) {
|
|
3623
|
-
if (typeof ref === "string") {
|
|
3624
|
-
return ref;
|
|
3625
|
-
}
|
|
3626
|
-
return ref().modelName;
|
|
3627
|
-
}
|
|
3628
3626
|
function validateRelationships(model, repositoriesByModelNameLowered) {
|
|
3629
3627
|
for (const entry of model.belongsToEntries) {
|
|
3630
|
-
const modelName =
|
|
3628
|
+
const modelName = entry.builder.modelRef;
|
|
3631
3629
|
if (!repositoriesByModelNameLowered[modelName.toLowerCase()]) {
|
|
3632
3630
|
throw new Error(`belongsTo reference from "${model.modelName}.${entry.propertyName}" points to model "${modelName}" which is not registered`);
|
|
3633
3631
|
}
|
|
3634
3632
|
}
|
|
3635
3633
|
for (const entry of model.hasManyEntries) {
|
|
3636
|
-
const modelName =
|
|
3634
|
+
const modelName = entry.builder.modelRef;
|
|
3637
3635
|
if (!repositoriesByModelNameLowered[modelName.toLowerCase()]) {
|
|
3638
3636
|
throw new Error(`hasMany reference from "${model.modelName}.${entry.propertyName}" points to model "${modelName}" which is not registered`);
|
|
3639
3637
|
}
|
|
3640
3638
|
if (entry.builder.throughRef) {
|
|
3641
|
-
const throughName =
|
|
3639
|
+
const throughName = entry.builder.throughRef;
|
|
3642
3640
|
if (!repositoriesByModelNameLowered[throughName.toLowerCase()]) {
|
|
3643
3641
|
throw new Error(`hasMany.through reference from "${model.modelName}.${entry.propertyName}" points to junction model "${throughName}" which is not registered`);
|
|
3644
3642
|
}
|
|
@@ -4150,12 +4148,6 @@ function hasMany(modelRef) {
|
|
|
4150
4148
|
return new HasManyBuilder(modelRef);
|
|
4151
4149
|
}
|
|
4152
4150
|
|
|
4153
|
-
function resolveModelName(ref) {
|
|
4154
|
-
if (typeof ref === "string") {
|
|
4155
|
-
return ref;
|
|
4156
|
-
}
|
|
4157
|
-
return ref().modelName;
|
|
4158
|
-
}
|
|
4159
4151
|
function buildColumnTypeMetadata(entry, propertyName, tableName) {
|
|
4160
4152
|
return new ColumnTypeMetadata(entry.toColumnTypeMetadataOptions(propertyName, tableName));
|
|
4161
4153
|
}
|
|
@@ -4164,7 +4156,7 @@ function buildColumnModelMetadata(entry, propertyName, tableName) {
|
|
|
4164
4156
|
target: tableName,
|
|
4165
4157
|
name: entry.dbColumnName,
|
|
4166
4158
|
propertyName,
|
|
4167
|
-
model:
|
|
4159
|
+
model: entry.modelRef
|
|
4168
4160
|
});
|
|
4169
4161
|
}
|
|
4170
4162
|
function buildColumnCollectionMetadata(entry, propertyName, tableName) {
|
|
@@ -4175,9 +4167,9 @@ function buildColumnCollectionMetadata(entry, propertyName, tableName) {
|
|
|
4175
4167
|
required: false,
|
|
4176
4168
|
insert: false,
|
|
4177
4169
|
update: false,
|
|
4178
|
-
collection:
|
|
4170
|
+
collection: entry.modelRef,
|
|
4179
4171
|
via: entry.viaPropertyName ?? "",
|
|
4180
|
-
through: entry.throughRef
|
|
4172
|
+
through: entry.throughRef ?? void 0
|
|
4181
4173
|
});
|
|
4182
4174
|
}
|
|
4183
4175
|
function table(tableName, schemaDefinition, options) {
|