pinia-orm-edge 1.8.1-28576565.35880c8 → 1.9.0-28577554.c800a89
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/dist/helpers.cjs +1 -1
- package/dist/helpers.mjs +1 -1
- package/dist/index.cjs +13 -7
- package/dist/index.mjs +13 -7
- package/dist/shared/{pinia-orm.000eebbf.mjs → pinia-orm.07af123e.mjs} +3 -3
- package/dist/shared/{pinia-orm.2be56be4.cjs → pinia-orm.9bb2aea1.cjs} +3 -3
- package/package.json +4 -4
package/dist/helpers.cjs
CHANGED
package/dist/helpers.mjs
CHANGED
package/dist/index.cjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
const Utils = require('./shared/pinia-orm.
|
3
|
+
const Utils = require('./shared/pinia-orm.9bb2aea1.cjs');
|
4
4
|
const pinia = require('pinia');
|
5
5
|
const normalizr = require('@pinia-orm/normalizr');
|
6
6
|
const CastAttribute = require('./shared/pinia-orm.a7e3e0f3.cjs');
|
@@ -667,11 +667,12 @@ class BelongsToMany extends Relation {
|
|
667
667
|
const relationResults = [];
|
668
668
|
relatedModels.forEach((relatedModel) => {
|
669
669
|
const pivot = pivotModels[`[${parentModel[this.parentKey]},${relatedModel[this.relatedKey]}]`]?.[0] ?? null;
|
670
|
+
if (!pivot) {
|
671
|
+
return;
|
672
|
+
}
|
670
673
|
const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson());
|
671
674
|
relatedModelCopy.$setRelation("pivot", pivot);
|
672
|
-
|
673
|
-
relationResults.push(relatedModelCopy);
|
674
|
-
}
|
675
|
+
relationResults.push(relatedModelCopy);
|
675
676
|
});
|
676
677
|
parentModel.$setRelation(relation, relationResults);
|
677
678
|
});
|
@@ -1050,10 +1051,17 @@ class Query {
|
|
1050
1051
|
if (this.model.$entity() !== this.model.$baseEntity()) {
|
1051
1052
|
this.where(this.model.$typeKey(), this.model.$fields()[this.model.$typeKey()].make());
|
1052
1053
|
}
|
1053
|
-
|
1054
|
+
let models = this.select();
|
1055
|
+
if (!this.orders) {
|
1056
|
+
models = this.filterLimit(models);
|
1057
|
+
}
|
1054
1058
|
if (!Utils.isEmpty(models)) {
|
1055
1059
|
this.eagerLoadRelations(models);
|
1056
1060
|
}
|
1061
|
+
if (this.orders) {
|
1062
|
+
models = this.filterOrder(models);
|
1063
|
+
models = this.filterLimit(models);
|
1064
|
+
}
|
1057
1065
|
if (triggerHook) {
|
1058
1066
|
models.forEach((model) => model.$self().retrieved(model));
|
1059
1067
|
}
|
@@ -1087,8 +1095,6 @@ class Query {
|
|
1087
1095
|
}
|
1088
1096
|
let models = this.storeFind(ids);
|
1089
1097
|
models = this.filterWhere(models);
|
1090
|
-
models = this.filterOrder(models);
|
1091
|
-
models = this.filterLimit(models);
|
1092
1098
|
this.wheres = originalWheres;
|
1093
1099
|
return models;
|
1094
1100
|
}
|
package/dist/index.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { i as isArray, t as throwError, a as assert, g as generateId, b as isNullish, c as compareWithOperator, d as generateKey, e as isEmpty, f as isFunction, h as groupBy, o as orderBy, j as equals } from './shared/pinia-orm.
|
1
|
+
import { i as isArray, t as throwError, a as assert, g as generateId, b as isNullish, c as compareWithOperator, d as generateKey, e as isEmpty, f as isFunction, h as groupBy, o as orderBy, j as equals } from './shared/pinia-orm.07af123e.mjs';
|
2
2
|
import { defineStore, acceptHMRUpdate } from 'pinia';
|
3
3
|
import { schema, normalize } from '@pinia-orm/normalizr';
|
4
4
|
export { C as CastAttribute } from './shared/pinia-orm.4ff2e12f.mjs';
|
@@ -665,11 +665,12 @@ class BelongsToMany extends Relation {
|
|
665
665
|
const relationResults = [];
|
666
666
|
relatedModels.forEach((relatedModel) => {
|
667
667
|
const pivot = pivotModels[`[${parentModel[this.parentKey]},${relatedModel[this.relatedKey]}]`]?.[0] ?? null;
|
668
|
+
if (!pivot) {
|
669
|
+
return;
|
670
|
+
}
|
668
671
|
const relatedModelCopy = relatedModel.$newInstance(relatedModel.$toJson());
|
669
672
|
relatedModelCopy.$setRelation("pivot", pivot);
|
670
|
-
|
671
|
-
relationResults.push(relatedModelCopy);
|
672
|
-
}
|
673
|
+
relationResults.push(relatedModelCopy);
|
673
674
|
});
|
674
675
|
parentModel.$setRelation(relation, relationResults);
|
675
676
|
});
|
@@ -1048,10 +1049,17 @@ class Query {
|
|
1048
1049
|
if (this.model.$entity() !== this.model.$baseEntity()) {
|
1049
1050
|
this.where(this.model.$typeKey(), this.model.$fields()[this.model.$typeKey()].make());
|
1050
1051
|
}
|
1051
|
-
|
1052
|
+
let models = this.select();
|
1053
|
+
if (!this.orders) {
|
1054
|
+
models = this.filterLimit(models);
|
1055
|
+
}
|
1052
1056
|
if (!isEmpty(models)) {
|
1053
1057
|
this.eagerLoadRelations(models);
|
1054
1058
|
}
|
1059
|
+
if (this.orders) {
|
1060
|
+
models = this.filterOrder(models);
|
1061
|
+
models = this.filterLimit(models);
|
1062
|
+
}
|
1055
1063
|
if (triggerHook) {
|
1056
1064
|
models.forEach((model) => model.$self().retrieved(model));
|
1057
1065
|
}
|
@@ -1085,8 +1093,6 @@ class Query {
|
|
1085
1093
|
}
|
1086
1094
|
let models = this.storeFind(ids);
|
1087
1095
|
models = this.filterWhere(models);
|
1088
|
-
models = this.filterOrder(models);
|
1089
|
-
models = this.filterLimit(models);
|
1090
1096
|
this.wheres = originalWheres;
|
1091
1097
|
return models;
|
1092
1098
|
}
|
@@ -35,7 +35,7 @@ function orderBy(collection, iteratees, directions, flags = "SORT_REGULAR") {
|
|
35
35
|
let index = -1;
|
36
36
|
const result = collection.map((value) => {
|
37
37
|
const criteria = iteratees.map((iteratee) => {
|
38
|
-
return typeof iteratee === "function" ? iteratee(value) : value
|
38
|
+
return typeof iteratee === "function" ? iteratee(value) : getValue(value, iteratee, false);
|
39
39
|
});
|
40
40
|
return { criteria, index: ++index, value };
|
41
41
|
});
|
@@ -119,13 +119,13 @@ function generateKey(key, params) {
|
|
119
119
|
const stringifiedKey = JSON.stringify(keyValues);
|
120
120
|
return typeof process === "undefined" ? btoa(stringifiedKey) : stringifiedKey;
|
121
121
|
}
|
122
|
-
function getValue(obj, keys) {
|
122
|
+
function getValue(obj, keys, ifNotFoundReturnObject = true) {
|
123
123
|
keys = typeof keys === "string" ? keys.split(".") : keys;
|
124
124
|
const key = keys.shift();
|
125
125
|
if (obj && Object.prototype.hasOwnProperty.call(obj, key) && keys.length === 0) {
|
126
126
|
return obj[key];
|
127
127
|
} else if (!obj || !Object.prototype.hasOwnProperty.call(obj, key)) {
|
128
|
-
return obj;
|
128
|
+
return ifNotFoundReturnObject ? obj : void 0;
|
129
129
|
} else {
|
130
130
|
return getValue(obj[key], keys);
|
131
131
|
}
|
@@ -37,7 +37,7 @@ function orderBy(collection, iteratees, directions, flags = "SORT_REGULAR") {
|
|
37
37
|
let index = -1;
|
38
38
|
const result = collection.map((value) => {
|
39
39
|
const criteria = iteratees.map((iteratee) => {
|
40
|
-
return typeof iteratee === "function" ? iteratee(value) : value
|
40
|
+
return typeof iteratee === "function" ? iteratee(value) : getValue(value, iteratee, false);
|
41
41
|
});
|
42
42
|
return { criteria, index: ++index, value };
|
43
43
|
});
|
@@ -121,13 +121,13 @@ function generateKey(key, params) {
|
|
121
121
|
const stringifiedKey = JSON.stringify(keyValues);
|
122
122
|
return typeof process === "undefined" ? btoa(stringifiedKey) : stringifiedKey;
|
123
123
|
}
|
124
|
-
function getValue(obj, keys) {
|
124
|
+
function getValue(obj, keys, ifNotFoundReturnObject = true) {
|
125
125
|
keys = typeof keys === "string" ? keys.split(".") : keys;
|
126
126
|
const key = keys.shift();
|
127
127
|
if (obj && Object.prototype.hasOwnProperty.call(obj, key) && keys.length === 0) {
|
128
128
|
return obj[key];
|
129
129
|
} else if (!obj || !Object.prototype.hasOwnProperty.call(obj, key)) {
|
130
|
-
return obj;
|
130
|
+
return ifNotFoundReturnObject ? obj : void 0;
|
131
131
|
} else {
|
132
132
|
return getValue(obj[key], keys);
|
133
133
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pinia-orm-edge",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.9.0-28577554.c800a89",
|
4
4
|
"description": "The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.",
|
5
5
|
"keywords": [
|
6
6
|
"vue",
|
@@ -46,14 +46,14 @@
|
|
46
46
|
"pinia": "^2.1.7"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.
|
49
|
+
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-28577554.c800a89"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@nuxt/eslint-config": "^0.3.10",
|
53
53
|
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
54
54
|
"@pinia/testing": "^0.1.3",
|
55
55
|
"@size-limit/preset-small-lib": "^11.1.2",
|
56
|
-
"@types/node": "^20.12.
|
56
|
+
"@types/node": "^20.12.8",
|
57
57
|
"@types/prettier": "^3.0.0",
|
58
58
|
"@types/uuid": "^9.0.8",
|
59
59
|
"@typescript-eslint/parser": "^7.8.0",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"typescript": "^5.4.5",
|
76
76
|
"unbuild": "^2.0.0",
|
77
77
|
"uuid": "^9.0.1",
|
78
|
-
"vite": "^5.2.
|
78
|
+
"vite": "^5.2.11",
|
79
79
|
"vitest": "^1.5.3",
|
80
80
|
"vue": "^3.4.26",
|
81
81
|
"vue-demi": "^0.14.7",
|