remult 0.24.2-exp.1 → 0.25.1
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/esm/remult-mongo.js +1 -1
- package/esm/src/remult3/relation-loader.js +16 -5
- package/esm/src/remult3/remult3.js +2 -0
- package/esm/src/validators.js +3 -0
- package/package.json +1 -1
- package/remult-mongo.js +1 -1
- package/src/remult3/relation-loader.d.ts +1 -1
- package/src/remult3/relation-loader.js +75 -49
- package/src/remult3/remult3.js +2 -0
- package/src/validators.js +3 -0
package/esm/remult-mongo.js
CHANGED
|
@@ -140,7 +140,7 @@ class MongoEntityDataProvider {
|
|
|
140
140
|
for (const f of this.entity.fields) {
|
|
141
141
|
if (!f.dbReadOnly && !f.isServerExpression) {
|
|
142
142
|
if (keys.includes(f.key)) {
|
|
143
|
-
newR[f.key] =
|
|
143
|
+
newR[f.key] = toDb(f, data[f.key]);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -88,7 +88,7 @@ class PendingInStatements {
|
|
|
88
88
|
rel;
|
|
89
89
|
key;
|
|
90
90
|
options;
|
|
91
|
-
resolve() {
|
|
91
|
+
async resolve() {
|
|
92
92
|
const values = [...this.values.values()];
|
|
93
93
|
if (values.length == 1) {
|
|
94
94
|
this.rel.find(this.options).then(values[0].resolve, values[0].reject);
|
|
@@ -96,9 +96,19 @@ class PendingInStatements {
|
|
|
96
96
|
}
|
|
97
97
|
var op = { ...this.options };
|
|
98
98
|
op.where = { [this.key]: values.map((v) => v.value) };
|
|
99
|
-
|
|
99
|
+
op.limit = 1000;
|
|
100
|
+
op.page = 1;
|
|
101
|
+
let vals = [];
|
|
102
|
+
try {
|
|
103
|
+
while (true) {
|
|
104
|
+
const val = await this.rel.find(op);
|
|
105
|
+
vals.push(...val);
|
|
106
|
+
if (val.length < op.limit)
|
|
107
|
+
break;
|
|
108
|
+
op.page++;
|
|
109
|
+
}
|
|
100
110
|
for (const value of this.values.values()) {
|
|
101
|
-
value.resolve(
|
|
111
|
+
value.resolve(vals.filter((x) => {
|
|
102
112
|
const ref = getEntityRef(x);
|
|
103
113
|
const field = ref.fields.find(this.key);
|
|
104
114
|
const rel = getRelationInfo(field.metadata.options);
|
|
@@ -108,11 +118,12 @@ class PendingInStatements {
|
|
|
108
118
|
return value.value == val;
|
|
109
119
|
}));
|
|
110
120
|
}
|
|
111
|
-
}
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
112
123
|
for (const value of this.values.values()) {
|
|
113
124
|
value.reject(err);
|
|
114
125
|
}
|
|
115
|
-
}
|
|
126
|
+
}
|
|
116
127
|
}
|
|
117
128
|
find(where) {
|
|
118
129
|
const val = where[this.key];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {};
|
|
2
|
+
//y1 - discuss limit and include queries
|
|
2
3
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
3
4
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
4
5
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
@@ -69,3 +70,4 @@ remult.apiClient.url='localhost:3007/api
|
|
|
69
70
|
//[ ] V3 - all these fields will also appear in the where etc... in the typescript api - but we will not enforce them
|
|
70
71
|
//y2 - consider if field types should include validation in them by default (string,number that it's not NaN etc...) and if so, what message?
|
|
71
72
|
//y2 - should enforce integer - currently we probably round / truncate it
|
|
73
|
+
//p1 - adjust react tutorial to esm
|
package/esm/src/validators.js
CHANGED
|
@@ -123,3 +123,6 @@ export function createValidatorWithArgs(validate, defaultMessage) {
|
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
+
//y1 - talk about the 3rd parameter as message
|
|
127
|
+
//y1 - talk about the changed signature breaking existing validations and preventing the usage of unique outside the normal flow
|
|
128
|
+
//y1 - talk about the defaultMessage value now being a function that get's too many arguments, that makes it's reuse that much harder
|
package/package.json
CHANGED
package/remult-mongo.js
CHANGED
|
@@ -256,7 +256,7 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
256
256
|
f_1 = _e.value;
|
|
257
257
|
if (!f_1.dbReadOnly && !f_1.isServerExpression) {
|
|
258
258
|
if (keys.includes(f_1.key)) {
|
|
259
|
-
newR[f_1.key] =
|
|
259
|
+
newR[f_1.key] = toDb(f_1, data[f_1.key]);
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
}
|
|
@@ -144,56 +144,82 @@ var PendingInStatements = /** @class */ (function () {
|
|
|
144
144
|
this.values = new Map();
|
|
145
145
|
}
|
|
146
146
|
PendingInStatements.prototype.resolve = function () {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
147
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
148
|
+
var values, op, vals, val, _loop_1, _a, _b, value, err_1, _c, _d, value;
|
|
149
|
+
var _e, e_4, _f, e_5, _g;
|
|
150
|
+
var _this = this;
|
|
151
|
+
return tslib_1.__generator(this, function (_h) {
|
|
152
|
+
switch (_h.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
values = tslib_1.__spreadArray([], tslib_1.__read(this.values.values()), false);
|
|
155
|
+
if (values.length == 1) {
|
|
156
|
+
this.rel.find(this.options).then(values[0].resolve, values[0].reject);
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
op = tslib_1.__assign({}, this.options);
|
|
160
|
+
op.where = (_e = {}, _e[this.key] = values.map(function (v) { return v.value; }), _e);
|
|
161
|
+
op.limit = 1000;
|
|
162
|
+
op.page = 1;
|
|
163
|
+
vals = [];
|
|
164
|
+
_h.label = 1;
|
|
165
|
+
case 1:
|
|
166
|
+
_h.trys.push([1, 5, , 6]);
|
|
167
|
+
_h.label = 2;
|
|
168
|
+
case 2:
|
|
169
|
+
if (!true) return [3 /*break*/, 4];
|
|
170
|
+
return [4 /*yield*/, this.rel.find(op)];
|
|
171
|
+
case 3:
|
|
172
|
+
val = _h.sent();
|
|
173
|
+
vals.push.apply(vals, tslib_1.__spreadArray([], tslib_1.__read(val), false));
|
|
174
|
+
if (val.length < op.limit)
|
|
175
|
+
return [3 /*break*/, 4];
|
|
176
|
+
op.page++;
|
|
177
|
+
return [3 /*break*/, 2];
|
|
178
|
+
case 4:
|
|
179
|
+
_loop_1 = function (value) {
|
|
180
|
+
value.resolve(vals.filter(function (x) {
|
|
181
|
+
var ref = (0, getEntityRef_js_1.getEntityRef)(x);
|
|
182
|
+
var field = ref.fields.find(_this.key);
|
|
183
|
+
var rel = (0, relationInfoMember_js_1.getRelationInfo)(field.metadata.options);
|
|
184
|
+
var val = (rel === null || rel === void 0 ? void 0 : rel.type) === 'reference'
|
|
185
|
+
? field.getId()
|
|
186
|
+
: x[_this.key];
|
|
187
|
+
return value.value == val;
|
|
188
|
+
}));
|
|
189
|
+
};
|
|
190
|
+
try {
|
|
191
|
+
for (_a = tslib_1.__values(this.values.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
192
|
+
value = _b.value;
|
|
193
|
+
_loop_1(value);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
197
|
+
finally {
|
|
198
|
+
try {
|
|
199
|
+
if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
|
|
200
|
+
}
|
|
201
|
+
finally { if (e_4) throw e_4.error; }
|
|
202
|
+
}
|
|
203
|
+
return [3 /*break*/, 6];
|
|
204
|
+
case 5:
|
|
205
|
+
err_1 = _h.sent();
|
|
206
|
+
try {
|
|
207
|
+
for (_c = tslib_1.__values(this.values.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
208
|
+
value = _d.value;
|
|
209
|
+
value.reject(err_1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
213
|
+
finally {
|
|
214
|
+
try {
|
|
215
|
+
if (_d && !_d.done && (_g = _c.return)) _g.call(_c);
|
|
216
|
+
}
|
|
217
|
+
finally { if (e_5) throw e_5.error; }
|
|
218
|
+
}
|
|
219
|
+
return [3 /*break*/, 6];
|
|
220
|
+
case 6: return [2 /*return*/];
|
|
194
221
|
}
|
|
195
|
-
|
|
196
|
-
}
|
|
222
|
+
});
|
|
197
223
|
});
|
|
198
224
|
};
|
|
199
225
|
PendingInStatements.prototype.find = function (where) {
|
package/src/remult3/remult3.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//y1 - discuss limit and include queries
|
|
3
4
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
4
5
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
5
6
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
@@ -70,3 +71,4 @@ remult.apiClient.url='localhost:3007/api
|
|
|
70
71
|
//[ ] V3 - all these fields will also appear in the where etc... in the typescript api - but we will not enforce them
|
|
71
72
|
//y2 - consider if field types should include validation in them by default (string,number that it's not NaN etc...) and if so, what message?
|
|
72
73
|
//y2 - should enforce integer - currently we probably round / truncate it
|
|
74
|
+
//p1 - adjust react tutorial to esm
|
package/src/validators.js
CHANGED
|
@@ -195,3 +195,6 @@ function createValidatorWithArgs(validate, defaultMessage) {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
exports.createValidatorWithArgs = createValidatorWithArgs;
|
|
198
|
+
//y1 - talk about the 3rd parameter as message
|
|
199
|
+
//y1 - talk about the changed signature breaking existing validations and preventing the usage of unique outside the normal flow
|
|
200
|
+
//y1 - talk about the defaultMessage value now being a function that get's too many arguments, that makes it's reuse that much harder
|