remult 0.25.8-exp.3 → 0.25.8-exp.4
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/src/CompoundIdField.js +8 -2
- package/esm/src/data-api.js +15 -1
- package/esm/src/remult3/RepositoryImplementation.js +1 -1
- package/esm/src/remult3/remult3.js +1 -3
- package/package.json +1 -1
- package/src/CompoundIdField.js +8 -2
- package/src/data-api.js +23 -5
- package/src/remult3/RepositoryImplementation.js +1 -1
- package/src/remult3/remult3.js +1 -3
|
@@ -22,11 +22,17 @@ export class CompoundIdField {
|
|
|
22
22
|
return Promise.resolve('');
|
|
23
23
|
}
|
|
24
24
|
getId(instance) {
|
|
25
|
+
let get = (field) => {
|
|
26
|
+
return instance[field.key];
|
|
27
|
+
};
|
|
28
|
+
if (typeof instance === 'function') {
|
|
29
|
+
get = instance;
|
|
30
|
+
}
|
|
25
31
|
let r = '';
|
|
26
32
|
this.fields.forEach((c) => {
|
|
27
33
|
if (r.length > 0)
|
|
28
34
|
r += ',';
|
|
29
|
-
r +=
|
|
35
|
+
r += c.valueConverter.toJson(get(c));
|
|
30
36
|
});
|
|
31
37
|
return r;
|
|
32
38
|
}
|
|
@@ -49,7 +55,7 @@ export class CompoundIdField {
|
|
|
49
55
|
let val = value.toString();
|
|
50
56
|
let id = val.split(',');
|
|
51
57
|
this.fields.forEach((c, i) => {
|
|
52
|
-
result[c.key] = id[i];
|
|
58
|
+
result[c.key] = c.valueConverter.fromJson(id[i]);
|
|
53
59
|
});
|
|
54
60
|
return result;
|
|
55
61
|
}
|
package/esm/src/data-api.js
CHANGED
|
@@ -23,16 +23,30 @@ export class DataApi {
|
|
|
23
23
|
}
|
|
24
24
|
async httpPost(res, req, body, serializeContext) {
|
|
25
25
|
const action = req?.get('__action');
|
|
26
|
-
|
|
26
|
+
function validateWhereInBody() {
|
|
27
|
+
if (!body?.where) {
|
|
28
|
+
throw {
|
|
29
|
+
message: `POST with action ${action} must have a where clause in the body`,
|
|
30
|
+
httpStatusCode: 400,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (action?.startsWith(liveQueryAction)) {
|
|
35
|
+
validateWhereInBody();
|
|
27
36
|
return this.liveQuery(res, req, body, serializeContext, action.substring(liveQueryAction.length));
|
|
37
|
+
}
|
|
28
38
|
switch (action) {
|
|
29
39
|
case 'get':
|
|
40
|
+
validateWhereInBody();
|
|
30
41
|
return this.getArray(res, req, body);
|
|
31
42
|
case 'count':
|
|
43
|
+
validateWhereInBody();
|
|
32
44
|
return this.count(res, req, body);
|
|
33
45
|
case 'deleteMany':
|
|
46
|
+
validateWhereInBody();
|
|
34
47
|
return this.deleteMany(res, req, body);
|
|
35
48
|
case 'updateMany':
|
|
49
|
+
validateWhereInBody();
|
|
36
50
|
return this.updateManyImplementation(res, req, body);
|
|
37
51
|
case 'endLiveQuery':
|
|
38
52
|
await this.remult.liveQueryStorage.remove(body.id);
|
|
@@ -1186,7 +1186,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1186
1186
|
return this.instance[y.key];
|
|
1187
1187
|
};
|
|
1188
1188
|
if (this.metadata.idMetadata.field instanceof CompoundIdField)
|
|
1189
|
-
return this.metadata.idMetadata.field.
|
|
1189
|
+
return this.metadata.idMetadata.field.getId(getVal);
|
|
1190
1190
|
return getVal(this.metadata.idMetadata.field);
|
|
1191
1191
|
}
|
|
1192
1192
|
saveMoreOriginalData() {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//
|
|
3
|
-
//y1 - review that with deleteMany, and updateMany I've taken a similar approach to get, that when the filter is complex, we go to post - one reason is that delete doesn't accept a body.
|
|
4
|
-
//y1 - should the remult api be deleteMany({id:[1,2]}) or deleteMany({where:{id:[1,2]}})
|
|
2
|
+
//p1 - should the remult api be deleteMany({id:[1,2]}) or deleteMany({where:{id:[1,2]}})
|
|
5
3
|
//p1 - in this video I'll use remult to turn a frontend app to a fullstack app
|
|
6
4
|
//y1 - getFields didn't work for kobi in the home component
|
|
7
5
|
//y1 - consider replacing all errors with error classes that extend the base Error class
|
package/package.json
CHANGED
package/src/CompoundIdField.js
CHANGED
|
@@ -28,11 +28,17 @@ var CompoundIdField = /** @class */ (function () {
|
|
|
28
28
|
return Promise.resolve('');
|
|
29
29
|
};
|
|
30
30
|
CompoundIdField.prototype.getId = function (instance) {
|
|
31
|
+
var get = function (field) {
|
|
32
|
+
return instance[field.key];
|
|
33
|
+
};
|
|
34
|
+
if (typeof instance === 'function') {
|
|
35
|
+
get = instance;
|
|
36
|
+
}
|
|
31
37
|
var r = '';
|
|
32
38
|
this.fields.forEach(function (c) {
|
|
33
39
|
if (r.length > 0)
|
|
34
40
|
r += ',';
|
|
35
|
-
r +=
|
|
41
|
+
r += c.valueConverter.toJson(get(c));
|
|
36
42
|
});
|
|
37
43
|
return r;
|
|
38
44
|
};
|
|
@@ -48,7 +54,7 @@ var CompoundIdField = /** @class */ (function () {
|
|
|
48
54
|
var val = value.toString();
|
|
49
55
|
var id = val.split(',');
|
|
50
56
|
this.fields.forEach(function (c, i) {
|
|
51
|
-
result[c.key] = id[i];
|
|
57
|
+
result[c.key] = c.valueConverter.fromJson(id[i]);
|
|
52
58
|
});
|
|
53
59
|
return result;
|
|
54
60
|
};
|
package/src/data-api.js
CHANGED
|
@@ -25,13 +25,23 @@ var DataApi = /** @class */ (function () {
|
|
|
25
25
|
};
|
|
26
26
|
DataApi.prototype.httpPost = function (res, req, body, serializeContext) {
|
|
27
27
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
28
|
+
function validateWhereInBody() {
|
|
29
|
+
if (!(body === null || body === void 0 ? void 0 : body.where)) {
|
|
30
|
+
throw {
|
|
31
|
+
message: "POST with action ".concat(action, " must have a where clause in the body"),
|
|
32
|
+
httpStatusCode: 400,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
28
36
|
var action, _a;
|
|
29
37
|
return tslib_1.__generator(this, function (_b) {
|
|
30
38
|
switch (_b.label) {
|
|
31
39
|
case 0:
|
|
32
40
|
action = req === null || req === void 0 ? void 0 : req.get('__action');
|
|
33
|
-
if (action === null || action === void 0 ? void 0 : action.startsWith(rest_data_provider_js_1.liveQueryAction))
|
|
41
|
+
if (action === null || action === void 0 ? void 0 : action.startsWith(rest_data_provider_js_1.liveQueryAction)) {
|
|
42
|
+
validateWhereInBody();
|
|
34
43
|
return [2 /*return*/, this.liveQuery(res, req, body, serializeContext, action.substring(rest_data_provider_js_1.liveQueryAction.length))];
|
|
44
|
+
}
|
|
35
45
|
_a = action;
|
|
36
46
|
switch (_a) {
|
|
37
47
|
case 'get': return [3 /*break*/, 1];
|
|
@@ -41,10 +51,18 @@ var DataApi = /** @class */ (function () {
|
|
|
41
51
|
case 'endLiveQuery': return [3 /*break*/, 5];
|
|
42
52
|
}
|
|
43
53
|
return [3 /*break*/, 7];
|
|
44
|
-
case 1:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
case
|
|
54
|
+
case 1:
|
|
55
|
+
validateWhereInBody();
|
|
56
|
+
return [2 /*return*/, this.getArray(res, req, body)];
|
|
57
|
+
case 2:
|
|
58
|
+
validateWhereInBody();
|
|
59
|
+
return [2 /*return*/, this.count(res, req, body)];
|
|
60
|
+
case 3:
|
|
61
|
+
validateWhereInBody();
|
|
62
|
+
return [2 /*return*/, this.deleteMany(res, req, body)];
|
|
63
|
+
case 4:
|
|
64
|
+
validateWhereInBody();
|
|
65
|
+
return [2 /*return*/, this.updateManyImplementation(res, req, body)];
|
|
48
66
|
case 5: return [4 /*yield*/, this.remult.liveQueryStorage.remove(body.id)];
|
|
49
67
|
case 6:
|
|
50
68
|
_b.sent();
|
|
@@ -1956,7 +1956,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1956
1956
|
return _this.instance[y.key];
|
|
1957
1957
|
};
|
|
1958
1958
|
if (this.metadata.idMetadata.field instanceof CompoundIdField_js_1.CompoundIdField)
|
|
1959
|
-
return this.metadata.idMetadata.field.
|
|
1959
|
+
return this.metadata.idMetadata.field.getId(getVal);
|
|
1960
1960
|
return getVal(this.metadata.idMetadata.field);
|
|
1961
1961
|
};
|
|
1962
1962
|
rowHelperImplementation.prototype.saveMoreOriginalData = function () {
|
package/src/remult3/remult3.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//
|
|
4
|
-
//y1 - review that with deleteMany, and updateMany I've taken a similar approach to get, that when the filter is complex, we go to post - one reason is that delete doesn't accept a body.
|
|
5
|
-
//y1 - should the remult api be deleteMany({id:[1,2]}) or deleteMany({where:{id:[1,2]}})
|
|
3
|
+
//p1 - should the remult api be deleteMany({id:[1,2]}) or deleteMany({where:{id:[1,2]}})
|
|
6
4
|
//p1 - in this video I'll use remult to turn a frontend app to a fullstack app
|
|
7
5
|
//y1 - getFields didn't work for kobi in the home component
|
|
8
6
|
//y1 - consider replacing all errors with error classes that extend the base Error class
|