remult 0.27.12 → 0.27.14
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/server/get-remult-admin-html.js +1 -1
- package/esm/server/remult-admin.js +2 -0
- package/esm/server/remult-api-server.js +3 -1
- package/esm/src/data-providers/sql-database.js +2 -25
- package/esm/src/remult3/RepositoryImplementation.js +8 -1
- package/esm/src/remult3/relationInfoMember.js +2 -2
- package/esm/src/remult3/remult3.js +1 -0
- package/package.json +1 -1
- package/server/get-remult-admin-html.js +1 -1
- package/server/remult-admin.d.ts +4 -0
- package/server/remult-admin.js +12 -10
- package/server/remult-api-server.js +9 -7
- package/src/data-providers/sql-database.js +10 -69
- package/src/remult3/RepositoryImplementation.js +8 -1
- package/src/remult3/relationInfoMember.js +2 -2
- package/src/remult3/remult3.d.ts +5 -1
- package/src/remult3/remult3.js +1 -0
|
@@ -70,6 +70,7 @@ export function buildEntityInfo(options) {
|
|
|
70
70
|
valFieldKey,
|
|
71
71
|
caption: x.caption,
|
|
72
72
|
relationToOne: relation,
|
|
73
|
+
inputType: x.inputType,
|
|
73
74
|
type: x.valueConverter.fieldTypeInDb == 'json'
|
|
74
75
|
? 'json'
|
|
75
76
|
: x.valueType === Number
|
|
@@ -88,6 +89,7 @@ export function buildEntityInfo(options) {
|
|
|
88
89
|
ids,
|
|
89
90
|
fields,
|
|
90
91
|
relations,
|
|
92
|
+
defaultOrderBy: metadata.options.defaultOrderBy ?? { id: 'asc' },
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -16,6 +16,8 @@ import { isOfType } from '../src/isOfType.js';
|
|
|
16
16
|
import { initDataProviderOrJson } from './initDataProviderOrJson.js';
|
|
17
17
|
export function createRemultServerCore(options, serverCoreOptions) {
|
|
18
18
|
const safeOptions = options ?? {};
|
|
19
|
+
if (!safeOptions.entities)
|
|
20
|
+
safeOptions.entities = [];
|
|
19
21
|
if (!safeOptions.subscriptionServer) {
|
|
20
22
|
safeOptions.subscriptionServer = new SseSubscriptionServer();
|
|
21
23
|
}
|
|
@@ -327,12 +329,12 @@ export class RemultServerImplementation {
|
|
|
327
329
|
},
|
|
328
330
|
});
|
|
329
331
|
}
|
|
332
|
+
await what(remult, myReq, myRes, genReq, origRes, req);
|
|
330
333
|
}
|
|
331
334
|
finally {
|
|
332
335
|
remultStatic.asyncContext.setInInitRequest(false);
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
|
-
await what(remult, myReq, myRes, genReq, origRes, req);
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
340
|
catch (err) {
|
|
@@ -502,29 +502,6 @@ class myDummySQLCommand {
|
|
|
502
502
|
return val.toString();
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
async function bulkInsert(array, db) {
|
|
506
|
-
if (array.length == 0)
|
|
507
|
-
return;
|
|
508
|
-
const chunkSize = 250;
|
|
509
|
-
for (let i = 0; i < array.length; i += chunkSize) {
|
|
510
|
-
const items = array.slice(i, i + chunkSize);
|
|
511
|
-
// do whatever
|
|
512
|
-
const c = db.createCommand();
|
|
513
|
-
let sql = 'insert into ' +
|
|
514
|
-
(await items[0]._.metadata.dbName) +
|
|
515
|
-
' (' +
|
|
516
|
-
(await Promise.all(items[0]._.metadata.fields.toArray().map((f) => f.dbName))).join(',') +
|
|
517
|
-
') values ';
|
|
518
|
-
sql += items
|
|
519
|
-
.map((row) => '(' +
|
|
520
|
-
row.$.toArray()
|
|
521
|
-
.map((f) => c.param(f.metadata.valueConverter.toDb(f.value)))
|
|
522
|
-
.join(', ') +
|
|
523
|
-
')')
|
|
524
|
-
.join(',');
|
|
525
|
-
await c.execute(sql);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
505
|
export function getRowAfterUpdate(meta, dataProvider, data, id, operation) {
|
|
529
506
|
const idFilter = id !== undefined ? meta.idMetadata.getIdFilter(id) : {};
|
|
530
507
|
return dataProvider
|
|
@@ -614,9 +591,9 @@ export async function groupByImpl(options, e, r, orderByNullFirst, limitSyntax)
|
|
|
614
591
|
orderBy += ' desc';
|
|
615
592
|
if (orderByNullFirst) {
|
|
616
593
|
if (x.isDescending)
|
|
617
|
-
|
|
594
|
+
orderBy += ' nulls last';
|
|
618
595
|
else
|
|
619
|
-
|
|
596
|
+
orderBy += ' nulls first';
|
|
620
597
|
}
|
|
621
598
|
}
|
|
622
599
|
if (orderBy)
|
|
@@ -713,7 +713,9 @@ export class RepositoryImplementation {
|
|
|
713
713
|
//I've used define property to hide this member from console.lo g
|
|
714
714
|
get: () => row,
|
|
715
715
|
});
|
|
716
|
+
row.id = row.getId();
|
|
716
717
|
row.saveOriginalData();
|
|
718
|
+
row.originalId = row.id;
|
|
717
719
|
return result;
|
|
718
720
|
}
|
|
719
721
|
}
|
|
@@ -1412,6 +1414,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1412
1414
|
updatedRow = (await this.edp.find({ where: await this.getIdFilter() }))[0];
|
|
1413
1415
|
}
|
|
1414
1416
|
else {
|
|
1417
|
+
if (this.id === undefined)
|
|
1418
|
+
throw new Error('Invalid operation, id is undefined');
|
|
1415
1419
|
updatedRow = await this.edp.update(this.id, changesOnly);
|
|
1416
1420
|
}
|
|
1417
1421
|
}
|
|
@@ -1488,8 +1492,11 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1488
1492
|
}
|
|
1489
1493
|
this.__assertValidity();
|
|
1490
1494
|
try {
|
|
1491
|
-
if (doDelete)
|
|
1495
|
+
if (doDelete) {
|
|
1496
|
+
if (this.id === undefined)
|
|
1497
|
+
throw new Error('Invalid operation, id is undefined');
|
|
1492
1498
|
await this.edp.delete(this.id);
|
|
1499
|
+
}
|
|
1493
1500
|
if (!this.repo._dataProvider.isProxy) {
|
|
1494
1501
|
if (this.info.entityInfo.deleted)
|
|
1495
1502
|
await this.info.entityInfo.deleted(this.instance, e);
|
|
@@ -38,7 +38,7 @@ export function verifyFieldRelationInfo(repo, remult, dp) {
|
|
|
38
38
|
compoundIdField: undefined,
|
|
39
39
|
};
|
|
40
40
|
function buildError(what) {
|
|
41
|
-
return Error(`Error for relation: "${
|
|
41
|
+
return Error(`Error for relation: "${repo.metadata.key}.${field.key}", ` +
|
|
42
42
|
what);
|
|
43
43
|
}
|
|
44
44
|
let hasFields = () => relationField || relFields.fields;
|
|
@@ -70,7 +70,7 @@ export function verifyFieldRelationInfo(repo, remult, dp) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
if (!hasFields())
|
|
73
|
-
throw buildError(`No matching field found on target. Please specify field/fields`);
|
|
73
|
+
throw buildError(`No matching field found on target "${toRepo.metadata.key}". Please specify field/fields`);
|
|
74
74
|
}
|
|
75
75
|
function requireField(field, meta) {
|
|
76
76
|
const result = meta.fields.find(field);
|
|
@@ -17,6 +17,7 @@ const wnn = [
|
|
|
17
17
|
export const flags = {
|
|
18
18
|
error500RetryCount: 4,
|
|
19
19
|
};
|
|
20
|
+
//p1 - add aggregate to query
|
|
20
21
|
//p1 - add parameter all to deleteMany, and updateMany
|
|
21
22
|
//p1 filter.apply ApiPreFilter
|
|
22
23
|
/*p1 - add id and use uuid by default, but allow changes with Fields.id.defaultIdProvider NO but defaultProvider yes???
|