remult 0.25.5-exp.5 → 0.25.5-exp.7
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/graphql.js +5 -2
- package/esm/src/remult3/remult3.js +17 -0
- package/esm/src/server-action.js +9 -12
- package/graphql.js +5 -2
- package/internals.d.ts +1 -1
- package/package.json +1 -1
- package/src/remult3/remult3.js +17 -0
- package/src/server-action.d.ts +1 -1
- package/src/server-action.js +9 -12
package/esm/graphql.js
CHANGED
|
@@ -413,6 +413,9 @@ export function remultGraphql(options) {
|
|
|
413
413
|
const refType = ri.toEntity;
|
|
414
414
|
ref = entities.find((i) => i.entityType === refType);
|
|
415
415
|
}
|
|
416
|
+
if (!ref) {
|
|
417
|
+
throw new Error(`Entity "${ri.toEntity.name}" that is used by the relation "${f.key}" in "${meta.entityType.name}" was not found in the 'entities' array.`);
|
|
418
|
+
}
|
|
416
419
|
notARealField = ri.type === 'toOne' || ri.type === 'toMany';
|
|
417
420
|
const refKey = ref.key;
|
|
418
421
|
switch (ri.type) {
|
|
@@ -448,11 +451,11 @@ export function remultGraphql(options) {
|
|
|
448
451
|
order: 10,
|
|
449
452
|
comment: `List all \`${getMetaType(meta)}\` of \`${refKey}\``,
|
|
450
453
|
});
|
|
451
|
-
currentType.query.resultProcessors.push((r) => {
|
|
454
|
+
currentType.query.resultProcessors.push((r, y) => {
|
|
452
455
|
r[f.key] = async (args, req, gqlInfo) => {
|
|
453
456
|
const remult = await options.getRemultFromRequest(req);
|
|
454
457
|
const myRepo = remult.repo(meta.entityType);
|
|
455
|
-
const item = myRepo.fromJson(
|
|
458
|
+
const item = myRepo.fromJson(y);
|
|
456
459
|
let relRepo = myRepo.relations(item)[f.key];
|
|
457
460
|
return handleRequestWithDataApiContextBasedOnRepo(relRepo, async (dApi, response, setResult, arg1, meta) => {
|
|
458
461
|
return await connectionImplementation(setResult, itemsKey, createResultPromise, dApi, upsertTypes(getMetaType(ref)), arg1, meta, totalCountKey);
|
|
@@ -2,6 +2,16 @@ export {};
|
|
|
2
2
|
//y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
|
|
3
3
|
//y1 - talk about the parameter issue with backend methods
|
|
4
4
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
5
|
+
//p1 - live query with include
|
|
6
|
+
//p1 - relation from order details to order gave a compound id info - and it is not true - same for the relation to product
|
|
7
|
+
//p1 - include admin in remult
|
|
8
|
+
//p1 - new row when there are relations, looks funny (see product)
|
|
9
|
+
//p1 - the + row in the bottom should extend to the full width
|
|
10
|
+
/*y2 -
|
|
11
|
+
@Fields.string<Category>({
|
|
12
|
+
allowApiUpdate: (c) => getEntityRef(c).isNew(),
|
|
13
|
+
})
|
|
14
|
+
Description = ""*/
|
|
5
15
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
6
16
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
7
17
|
//y2 - how to run a transaction as a user
|
|
@@ -79,3 +89,10 @@ remult.apiClient.url='localhost:3007/api
|
|
|
79
89
|
//y2 - should enforce integer - currently we probably round / truncate it
|
|
80
90
|
//p1 - adjust react tutorial to esm
|
|
81
91
|
//p1 - write docs on with remult - and usage in init api
|
|
92
|
+
/*y1 - discuss sql stuff:
|
|
93
|
+
https://discord.com/channels/975754286384418847/975754286384418852/1198997156678357043
|
|
94
|
+
https://codesandbox.io/p/devbox/demo-sql-expression-forked-f94p6m?file=%2Fsrc%2Findex.ts%3A21%2C3-21%2C12&workspaceId=c0f7eccf-c151-423b-ac8e-0f0f3e1ad350
|
|
95
|
+
https://codesandbox.io/p/devbox/demo-sql-expression-forked-c2jhyc?file=%2Fsrc%2Findex.ts%3A37%2C50&workspaceId=7e9d0505-ea79-46f1-8973-50cadde4fa96
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
*/
|
package/esm/src/server-action.js
CHANGED
|
@@ -92,7 +92,7 @@ export class myServerAction extends Action {
|
|
|
92
92
|
await doTransaction(remult, async () => {
|
|
93
93
|
if (!remult.isAllowedForInstance(undefined, this.options.allowed))
|
|
94
94
|
throw new ForbiddenError();
|
|
95
|
-
info.args = await prepareReceivedArgs(this.types, info.args, remult, ds, res);
|
|
95
|
+
info.args = await prepareReceivedArgs(this.types(), info.args, remult, ds, res);
|
|
96
96
|
try {
|
|
97
97
|
result.data = await this.originalMethod(info.args);
|
|
98
98
|
}
|
|
@@ -119,17 +119,20 @@ export function BackendMethod(options) {
|
|
|
119
119
|
const originalMethod = descriptor ? descriptor.value : target;
|
|
120
120
|
let result = originalMethod;
|
|
121
121
|
checkTarget(target);
|
|
122
|
-
|
|
122
|
+
function getTypes() {
|
|
123
123
|
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
124
124
|
if (options.paramTypes)
|
|
125
125
|
types =
|
|
126
126
|
typeof options.paramTypes === 'function'
|
|
127
127
|
? options.paramTypes()
|
|
128
128
|
: options.paramTypes;
|
|
129
|
+
return types;
|
|
130
|
+
}
|
|
131
|
+
if (target.prototype !== undefined) {
|
|
129
132
|
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
|
|
130
|
-
let serverAction = new myServerAction((options?.apiPrefix ? options.apiPrefix + '/' : '') + key,
|
|
133
|
+
let serverAction = new myServerAction((options?.apiPrefix ? options.apiPrefix + '/' : '') + key, () => getTypes(), options, (args) => originalMethod.apply(undefined, args));
|
|
131
134
|
serverAction.doWork = async (args, self, url, http) => {
|
|
132
|
-
args = prepareArgsToSend(
|
|
135
|
+
args = prepareArgsToSend(getTypes(), args);
|
|
133
136
|
if (options.blockUser === false) {
|
|
134
137
|
return await remultStatic.actionInfo.runActionWithoutBlockingUI(async () => (await serverAction.run({ args }, url, http)).data);
|
|
135
138
|
}
|
|
@@ -152,12 +155,6 @@ export function BackendMethod(options) {
|
|
|
152
155
|
else
|
|
153
156
|
return result;
|
|
154
157
|
}
|
|
155
|
-
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
156
|
-
if (options.paramTypes)
|
|
157
|
-
types =
|
|
158
|
-
typeof options.paramTypes === 'function'
|
|
159
|
-
? options.paramTypes()
|
|
160
|
-
: options.paramTypes;
|
|
161
158
|
let x = remultStatic.classHelpers.get(target.constructor);
|
|
162
159
|
if (!x) {
|
|
163
160
|
x = new ClassHelper();
|
|
@@ -181,7 +178,7 @@ export function BackendMethod(options) {
|
|
|
181
178
|
let remult = req;
|
|
182
179
|
let r;
|
|
183
180
|
await doTransaction(remult, async () => {
|
|
184
|
-
d.args = await prepareReceivedArgs(
|
|
181
|
+
d.args = await prepareReceivedArgs(getTypes(), d.args, remult, remult.dataProvider, res);
|
|
185
182
|
if (remultStatic.allEntities.includes(constructor)) {
|
|
186
183
|
let repo = remult.repo(constructor);
|
|
187
184
|
let y;
|
|
@@ -252,7 +249,7 @@ export function BackendMethod(options) {
|
|
|
252
249
|
}
|
|
253
250
|
},
|
|
254
251
|
doWork: async function (args, self, baseUrl, http) {
|
|
255
|
-
args = prepareArgsToSend(
|
|
252
|
+
args = prepareArgsToSend(getTypes(), args);
|
|
256
253
|
if (remultStatic.allEntities.includes(target.constructor)) {
|
|
257
254
|
let defs = getEntityRef(self);
|
|
258
255
|
await defs.__validateEntity();
|
package/graphql.js
CHANGED
|
@@ -505,6 +505,9 @@ function remultGraphql(options) {
|
|
|
505
505
|
var refType_1 = ri.toEntity;
|
|
506
506
|
ref = entities.find(function (i) { return i.entityType === refType_1; });
|
|
507
507
|
}
|
|
508
|
+
if (!ref) {
|
|
509
|
+
throw new Error("Entity \"".concat(ri.toEntity.name, "\" that is used by the relation \"").concat(f.key, "\" in \"").concat(meta.entityType.name, "\" was not found in the 'entities' array."));
|
|
510
|
+
}
|
|
508
511
|
notARealField = ri.type === 'toOne' || ri.type === 'toMany';
|
|
509
512
|
var refKey = ref.key;
|
|
510
513
|
switch (ri.type) {
|
|
@@ -557,7 +560,7 @@ function remultGraphql(options) {
|
|
|
557
560
|
order: 10,
|
|
558
561
|
comment: "List all `".concat(getMetaType(meta), "` of `").concat(refKey, "`"),
|
|
559
562
|
});
|
|
560
|
-
currentType.query.resultProcessors.push(function (r) {
|
|
563
|
+
currentType.query.resultProcessors.push(function (r, y) {
|
|
561
564
|
r[f.key] = function (args, req, gqlInfo) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
562
565
|
var remult, myRepo, item, relRepo;
|
|
563
566
|
var _this = this;
|
|
@@ -567,7 +570,7 @@ function remultGraphql(options) {
|
|
|
567
570
|
case 1:
|
|
568
571
|
remult = _a.sent();
|
|
569
572
|
myRepo = remult.repo(meta.entityType);
|
|
570
|
-
item = myRepo.fromJson(
|
|
573
|
+
item = myRepo.fromJson(y);
|
|
571
574
|
relRepo = myRepo.relations(item)[f.key];
|
|
572
575
|
return [2 /*return*/, handleRequestWithDataApiContextBasedOnRepo_1(relRepo, function (dApi, response, setResult, arg1, meta) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
573
576
|
return tslib_1.__generator(this, function (_a) {
|
package/internals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getRelationInfo, getRelationFieldInfo, RelationFieldInfo, RelationInfo, } from './src/remult3/relationInfoMember.js';
|
|
1
|
+
export { getRelationInfo, getRelationFieldInfo, RelationFieldInfo, RelationInfo, RelationFields, } from './src/remult3/relationInfoMember.js';
|
|
2
2
|
export { decorateColumnSettings, controllerRefImpl, getControllerRef, } from './src/remult3/RepositoryImplementation.js';
|
|
3
3
|
export { getEntitySettings } from './src/remult3/getEntityRef.js';
|
|
4
4
|
export { __updateEntityBasedOnWhere } from './src/filter/filter-interfaces.js';
|
package/package.json
CHANGED
package/src/remult3/remult3.js
CHANGED
|
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
//y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
|
|
4
4
|
//y1 - talk about the parameter issue with backend methods
|
|
5
5
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
6
|
+
//p1 - live query with include
|
|
7
|
+
//p1 - relation from order details to order gave a compound id info - and it is not true - same for the relation to product
|
|
8
|
+
//p1 - include admin in remult
|
|
9
|
+
//p1 - new row when there are relations, looks funny (see product)
|
|
10
|
+
//p1 - the + row in the bottom should extend to the full width
|
|
11
|
+
/*y2 -
|
|
12
|
+
@Fields.string<Category>({
|
|
13
|
+
allowApiUpdate: (c) => getEntityRef(c).isNew(),
|
|
14
|
+
})
|
|
15
|
+
Description = ""*/
|
|
6
16
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
7
17
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
8
18
|
//y2 - how to run a transaction as a user
|
|
@@ -80,3 +90,10 @@ remult.apiClient.url='localhost:3007/api
|
|
|
80
90
|
//y2 - should enforce integer - currently we probably round / truncate it
|
|
81
91
|
//p1 - adjust react tutorial to esm
|
|
82
92
|
//p1 - write docs on with remult - and usage in init api
|
|
93
|
+
/*y1 - discuss sql stuff:
|
|
94
|
+
https://discord.com/channels/975754286384418847/975754286384418852/1198997156678357043
|
|
95
|
+
https://codesandbox.io/p/devbox/demo-sql-expression-forked-f94p6m?file=%2Fsrc%2Findex.ts%3A21%2C3-21%2C12&workspaceId=c0f7eccf-c151-423b-ac8e-0f0f3e1ad350
|
|
96
|
+
https://codesandbox.io/p/devbox/demo-sql-expression-forked-c2jhyc?file=%2Fsrc%2Findex.ts%3A37%2C50&workspaceId=7e9d0505-ea79-46f1-8973-50cadde4fa96
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
*/
|
package/src/server-action.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class myServerAction extends Action<inArgs, result> {
|
|
|
28
28
|
private types;
|
|
29
29
|
private options;
|
|
30
30
|
originalMethod: (args: any[]) => any;
|
|
31
|
-
constructor(name: string, types: any[], options: BackendMethodOptions<any>, originalMethod: (args: any[]) => any);
|
|
31
|
+
constructor(name: string, types: () => any[], options: BackendMethodOptions<any>, originalMethod: (args: any[]) => any);
|
|
32
32
|
protected execute(info: inArgs, remult: Remult, res: DataApiResponse): Promise<result>;
|
|
33
33
|
}
|
|
34
34
|
export interface BackendMethodOptions<type> {
|
package/src/server-action.js
CHANGED
|
@@ -145,7 +145,7 @@ var myServerAction = /** @class */ (function (_super) {
|
|
|
145
145
|
if (!remult.isAllowedForInstance(undefined, this.options.allowed))
|
|
146
146
|
throw new ForbiddenError();
|
|
147
147
|
_a = info;
|
|
148
|
-
return [4 /*yield*/, prepareReceivedArgs(this.types, info.args, remult, ds, res)];
|
|
148
|
+
return [4 /*yield*/, prepareReceivedArgs(this.types(), info.args, remult, ds, res)];
|
|
149
149
|
case 1:
|
|
150
150
|
_a.args = _c.sent();
|
|
151
151
|
_c.label = 2;
|
|
@@ -191,21 +191,24 @@ function BackendMethod(options) {
|
|
|
191
191
|
var originalMethod = descriptor ? descriptor.value : target;
|
|
192
192
|
var result = originalMethod;
|
|
193
193
|
(0, Fields_js_1.checkTarget)(target);
|
|
194
|
-
|
|
194
|
+
function getTypes() {
|
|
195
195
|
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
196
196
|
if (options.paramTypes)
|
|
197
197
|
types =
|
|
198
198
|
typeof options.paramTypes === 'function'
|
|
199
199
|
? options.paramTypes()
|
|
200
200
|
: options.paramTypes;
|
|
201
|
+
return types;
|
|
202
|
+
}
|
|
203
|
+
if (target.prototype !== undefined) {
|
|
201
204
|
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
|
|
202
|
-
var serverAction_1 = new myServerAction(((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') + key,
|
|
205
|
+
var serverAction_1 = new myServerAction(((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') + key, function () { return getTypes(); }, options, function (args) { return originalMethod.apply(undefined, args); });
|
|
203
206
|
serverAction_1.doWork = function (args, self, url, http) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
204
207
|
var _this = this;
|
|
205
208
|
return tslib_1.__generator(this, function (_a) {
|
|
206
209
|
switch (_a.label) {
|
|
207
210
|
case 0:
|
|
208
|
-
args = prepareArgsToSend(
|
|
211
|
+
args = prepareArgsToSend(getTypes(), args);
|
|
209
212
|
if (!(options.blockUser === false)) return [3 /*break*/, 2];
|
|
210
213
|
return [4 /*yield*/, remult_static_js_1.remultStatic.actionInfo.runActionWithoutBlockingUI(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
211
214
|
switch (_a.label) {
|
|
@@ -246,12 +249,6 @@ function BackendMethod(options) {
|
|
|
246
249
|
else
|
|
247
250
|
return result;
|
|
248
251
|
}
|
|
249
|
-
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
250
|
-
if (options.paramTypes)
|
|
251
|
-
types =
|
|
252
|
-
typeof options.paramTypes === 'function'
|
|
253
|
-
? options.paramTypes()
|
|
254
|
-
: options.paramTypes;
|
|
255
252
|
var x = remult_static_js_1.remultStatic.classHelpers.get(target.constructor);
|
|
256
253
|
if (!x) {
|
|
257
254
|
x = new context_js_1.ClassHelper();
|
|
@@ -289,7 +286,7 @@ function BackendMethod(options) {
|
|
|
289
286
|
switch (_e.label) {
|
|
290
287
|
case 0:
|
|
291
288
|
_a = d;
|
|
292
|
-
return [4 /*yield*/, prepareReceivedArgs(
|
|
289
|
+
return [4 /*yield*/, prepareReceivedArgs(getTypes(), d.args, remult_1, remult_1.dataProvider, res)];
|
|
293
290
|
case 1:
|
|
294
291
|
_a.args = _e.sent();
|
|
295
292
|
if (!remult_static_js_1.remultStatic.allEntities.includes(constructor)) return [3 /*break*/, 13];
|
|
@@ -410,7 +407,7 @@ function BackendMethod(options) {
|
|
|
410
407
|
return tslib_1.__generator(this, function (_h) {
|
|
411
408
|
switch (_h.label) {
|
|
412
409
|
case 0:
|
|
413
|
-
args = prepareArgsToSend(
|
|
410
|
+
args = prepareArgsToSend(getTypes(), args);
|
|
414
411
|
if (!remult_static_js_1.remultStatic.allEntities.includes(target.constructor)) return [3 /*break*/, 8];
|
|
415
412
|
defs = (0, getEntityRef_js_1.getEntityRef)(self);
|
|
416
413
|
return [4 /*yield*/, defs.__validateEntity()];
|