@webtypen/webframez-core 0.2.28 → 0.2.30
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.
|
@@ -13,6 +13,7 @@ export type DataBuilderSchema = {
|
|
|
13
13
|
fields: {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
};
|
|
16
|
+
newDataHandler?: Function;
|
|
16
17
|
};
|
|
17
18
|
export type DataBuilderType = {
|
|
18
19
|
key: string;
|
|
@@ -75,6 +76,15 @@ export declare class DataBuilder {
|
|
|
75
76
|
status: string;
|
|
76
77
|
data: any;
|
|
77
78
|
}>;
|
|
79
|
+
detailsNewData(db: any, req: any): Promise<{
|
|
80
|
+
status: string;
|
|
81
|
+
message: string;
|
|
82
|
+
data?: undefined;
|
|
83
|
+
} | {
|
|
84
|
+
status: string;
|
|
85
|
+
data: any;
|
|
86
|
+
message?: undefined;
|
|
87
|
+
}>;
|
|
78
88
|
apiAutoComplete(req: any): Promise<{
|
|
79
89
|
status: string;
|
|
80
90
|
data: void;
|
|
@@ -177,7 +177,7 @@ class DataBuilder {
|
|
|
177
177
|
loadType(req) {
|
|
178
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
179
|
const type = this.getTypeFromRequest(req);
|
|
180
|
-
const data = Object.assign(Object.assign({}, (yield this.typeForFrontend(type, req))), { fieldtypes: this.getFieldTypesFrontend() });
|
|
180
|
+
const data = Object.assign(Object.assign({}, (yield this.typeForFrontend(type, req))), { fieldtypes: this.getFieldTypesFrontend(), new_data_handler: type.schema && type.schema.newDataHandler && typeof type.schema.newDataHandler === "function" ? true : false });
|
|
181
181
|
return {
|
|
182
182
|
status: "success",
|
|
183
183
|
data: Object.assign(Object.assign({}, data), { schema: Object.assign(Object.assign({}, (data.schema ? data.schema : {})), { fields: yield this.getFieldsFrontend(type.schema
|
|
@@ -425,6 +425,31 @@ class DataBuilder {
|
|
|
425
425
|
};
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
|
+
detailsNewData(db, req) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
const type = this.getTypeFromRequest(req);
|
|
431
|
+
if (!type || !type.schema || !type.schema.fields) {
|
|
432
|
+
throw new Error("Missing schema fields ...");
|
|
433
|
+
}
|
|
434
|
+
if (!type.schema || !type.schema.newDataHandler || typeof type.schema.newDataHandler !== "function") {
|
|
435
|
+
throw new Error("Missing newDataHandler-Function ...");
|
|
436
|
+
}
|
|
437
|
+
let data = null;
|
|
438
|
+
try {
|
|
439
|
+
data = yield type.schema.newDataHandler(req);
|
|
440
|
+
}
|
|
441
|
+
catch (e) {
|
|
442
|
+
console.error(e);
|
|
443
|
+
}
|
|
444
|
+
if (data === null || data === undefined) {
|
|
445
|
+
return { status: "error", message: "Unexpected error generating the forms 'new-data' ..." };
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
status: "success",
|
|
449
|
+
data: data,
|
|
450
|
+
};
|
|
451
|
+
});
|
|
452
|
+
}
|
|
428
453
|
apiAutoComplete(req) {
|
|
429
454
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
455
|
const type = this.getTypeFromRequest(req);
|
|
@@ -27,6 +27,9 @@ class DataBuilderController extends Controller_1.Controller {
|
|
|
27
27
|
else if (req.body.__builder_rest_api === "details") {
|
|
28
28
|
return res.send(yield this.builder.details(db.client.db(null), req));
|
|
29
29
|
}
|
|
30
|
+
else if (req.body.__builder_rest_api === "details-newdata") {
|
|
31
|
+
return res.send(yield this.builder.detailsNewData(db.client.db(null), req));
|
|
32
|
+
}
|
|
30
33
|
else if (req.body.__builder_rest_api === "save") {
|
|
31
34
|
return res.send(yield this.builder.save(db.client.db(null), req));
|
|
32
35
|
}
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ export type DataBuilderSchema = {
|
|
|
12
12
|
getAggregation?: any;
|
|
13
13
|
events?: { [key: string]: any };
|
|
14
14
|
fields: { [key: string]: any };
|
|
15
|
+
newDataHandler?: Function;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export type DataBuilderType = {
|
|
@@ -223,6 +224,7 @@ export class DataBuilder {
|
|
|
223
224
|
const data = {
|
|
224
225
|
...(await this.typeForFrontend(type, req)),
|
|
225
226
|
fieldtypes: this.getFieldTypesFrontend(),
|
|
227
|
+
new_data_handler: type.schema && type.schema.newDataHandler && typeof type.schema.newDataHandler === "function" ? true : false,
|
|
226
228
|
};
|
|
227
229
|
return {
|
|
228
230
|
status: "success",
|
|
@@ -513,6 +515,33 @@ export class DataBuilder {
|
|
|
513
515
|
};
|
|
514
516
|
}
|
|
515
517
|
|
|
518
|
+
async detailsNewData(db: any, req: any) {
|
|
519
|
+
const type = this.getTypeFromRequest(req);
|
|
520
|
+
if (!type || !type.schema || !type.schema.fields) {
|
|
521
|
+
throw new Error("Missing schema fields ...");
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (!type.schema || !type.schema.newDataHandler || typeof type.schema.newDataHandler !== "function") {
|
|
525
|
+
throw new Error("Missing newDataHandler-Function ...");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
let data: any = null;
|
|
529
|
+
try {
|
|
530
|
+
data = await type.schema.newDataHandler(req);
|
|
531
|
+
} catch (e: any) {
|
|
532
|
+
console.error(e);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (data === null || data === undefined) {
|
|
536
|
+
return { status: "error", message: "Unexpected error generating the forms 'new-data' ..." };
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return {
|
|
540
|
+
status: "success",
|
|
541
|
+
data: data,
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
516
545
|
async apiAutoComplete(req: any) {
|
|
517
546
|
const type = this.getTypeFromRequest(req);
|
|
518
547
|
const field = req.body.__builder_field ? await this.getField(req, type, req.body.__builder_field) : null;
|
|
@@ -18,6 +18,8 @@ export class DataBuilderController extends Controller {
|
|
|
18
18
|
return res.send(await this.builder.apiAutoComplete(req));
|
|
19
19
|
} else if (req.body.__builder_rest_api === "details") {
|
|
20
20
|
return res.send(await this.builder.details(db.client.db(null), req));
|
|
21
|
+
} else if (req.body.__builder_rest_api === "details-newdata") {
|
|
22
|
+
return res.send(await this.builder.detailsNewData(db.client.db(null), req));
|
|
21
23
|
} else if (req.body.__builder_rest_api === "save") {
|
|
22
24
|
return res.send(await this.builder.save(db.client.db(null), req));
|
|
23
25
|
} else if (req.body.__builder_rest_api === "type") {
|