remult 0.25.0 → 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.
@@ -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
- this.rel.find(op).then((val) => {
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(val.filter((x) => {
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
- }, (err) => {
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];
@@ -70,3 +70,4 @@ remult.apiClient.url='localhost:3007/api
70
70
  //[ ] V3 - all these fields will also appear in the where etc... in the typescript api - but we will not enforce them
71
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?
72
72
  //y2 - should enforce integer - currently we probably round / truncate it
73
+ //p1 - adjust react tutorial to esm
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -27,7 +27,7 @@ declare class PendingInStatements {
27
27
  private rel;
28
28
  private key;
29
29
  private options;
30
- resolve(): void;
30
+ resolve(): Promise<void>;
31
31
  find(where: any): Promise<any[]>;
32
32
  values: Map<any, {
33
33
  value: any;
@@ -144,56 +144,82 @@ var PendingInStatements = /** @class */ (function () {
144
144
  this.values = new Map();
145
145
  }
146
146
  PendingInStatements.prototype.resolve = function () {
147
- var _a;
148
- var _this = this;
149
- var values = tslib_1.__spreadArray([], tslib_1.__read(this.values.values()), false);
150
- if (values.length == 1) {
151
- this.rel.find(this.options).then(values[0].resolve, values[0].reject);
152
- return;
153
- }
154
- var op = tslib_1.__assign({}, this.options);
155
- op.where = (_a = {}, _a[this.key] = values.map(function (v) { return v.value; }), _a);
156
- this.rel.find(op).then(function (val) {
157
- var e_4, _a;
158
- var _loop_1 = function (value) {
159
- value.resolve(val.filter(function (x) {
160
- var ref = (0, getEntityRef_js_1.getEntityRef)(x);
161
- var field = ref.fields.find(_this.key);
162
- var rel = (0, relationInfoMember_js_1.getRelationInfo)(field.metadata.options);
163
- var val = (rel === null || rel === void 0 ? void 0 : rel.type) === 'reference'
164
- ? field.getId()
165
- : x[_this.key];
166
- return value.value == val;
167
- }));
168
- };
169
- try {
170
- for (var _b = tslib_1.__values(_this.values.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
171
- var value = _c.value;
172
- _loop_1(value);
173
- }
174
- }
175
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
176
- finally {
177
- try {
178
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
179
- }
180
- finally { if (e_4) throw e_4.error; }
181
- }
182
- }, function (err) {
183
- var e_5, _a;
184
- try {
185
- for (var _b = tslib_1.__values(_this.values.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
186
- var value = _c.value;
187
- value.reject(err);
188
- }
189
- }
190
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
191
- finally {
192
- try {
193
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
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
- finally { if (e_5) throw e_5.error; }
196
- }
222
+ });
197
223
  });
198
224
  };
199
225
  PendingInStatements.prototype.find = function (where) {
@@ -71,3 +71,4 @@ remult.apiClient.url='localhost:3007/api
71
71
  //[ ] V3 - all these fields will also appear in the where etc... in the typescript api - but we will not enforce them
72
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?
73
73
  //y2 - should enforce integer - currently we probably round / truncate it
74
+ //p1 - adjust react tutorial to esm