remult 2.7.29 → 2.7.31
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 +16 -4
- package/esm/server/remult-api-server.js +11 -4
- package/esm/src/filter/filter-interfaces.js +7 -2
- package/esm/src/valueConverters.js +3 -1
- package/package.json +1 -1
- package/server/get-remult-admin-html.js +1 -1
- package/server/remult-admin.d.ts +9 -5
- package/server/remult-admin.js +111 -97
- package/server/remult-api-server.d.ts +5 -2
- package/server/remult-api-server.js +14 -6
- package/src/column-interfaces.d.ts +5 -6
- package/src/filter/filter-interfaces.js +7 -2
- package/src/remult3/remult3.d.ts +43 -24
- package/src/valueConverters.js +3 -1
|
@@ -3,9 +3,11 @@ import { Filter } from '../src/filter/filter-interfaces.js';
|
|
|
3
3
|
import { getHtml } from './get-remult-admin-html.js';
|
|
4
4
|
import { getValueList } from '../src/remult3/RepositoryImplementation.js';
|
|
5
5
|
export default function remultAdminHtml(options) {
|
|
6
|
-
|
|
7
|
-
return getHtml()
|
|
8
|
-
|
|
6
|
+
const { rootPath, head } = options;
|
|
7
|
+
return getHtml()
|
|
8
|
+
.replace('<!--PLACE_HERE_HEAD-->', head)
|
|
9
|
+
.replace('<!--PLACE_HERE_BODY-->', `<script>
|
|
10
|
+
window.optionsFromServer = ${JSON.stringify({ rootPath })}
|
|
9
11
|
</script>`);
|
|
10
12
|
}
|
|
11
13
|
export function buildEntityInfo(options) {
|
|
@@ -59,6 +61,8 @@ export function buildEntityInfo(options) {
|
|
|
59
61
|
...relInfo,
|
|
60
62
|
where,
|
|
61
63
|
entityKey: relRepo.metadata.key,
|
|
64
|
+
key: x.key,
|
|
65
|
+
caption: x.caption,
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
continue;
|
|
@@ -89,9 +93,17 @@ export function buildEntityInfo(options) {
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
if (metadata.apiReadAllowed) {
|
|
96
|
+
let superKey = metadata.key;
|
|
97
|
+
let caption = metadata.caption;
|
|
98
|
+
const nbOfEntities = entities.filter(e => e.key === metadata.key).length;
|
|
99
|
+
if (nbOfEntities > 0) {
|
|
100
|
+
superKey = metadata.key + '_ext_' + nbOfEntities;
|
|
101
|
+
caption = metadata.caption + '*'.repeat(nbOfEntities);
|
|
102
|
+
}
|
|
92
103
|
entities.push({
|
|
104
|
+
superKey,
|
|
93
105
|
key: metadata.key,
|
|
94
|
-
caption
|
|
106
|
+
caption,
|
|
95
107
|
ids,
|
|
96
108
|
fields,
|
|
97
109
|
relations,
|
|
@@ -204,7 +204,10 @@ export class RemultServerImplementation {
|
|
|
204
204
|
}, r);
|
|
205
205
|
if (this.options.admin !== undefined && this.options.admin !== false) {
|
|
206
206
|
const admin = () => this.process(async (remult, req, res, orig, origResponse) => {
|
|
207
|
-
|
|
207
|
+
const allowed = isOfType(this.options.admin, 'allow')
|
|
208
|
+
? this.options.admin.allow
|
|
209
|
+
: this.options.admin;
|
|
210
|
+
if (remult.isAllowed(allowed)) {
|
|
208
211
|
if (orig?.params?.id === '__entities-metadata') {
|
|
209
212
|
res.success(buildEntityInfo({
|
|
210
213
|
remult,
|
|
@@ -212,10 +215,14 @@ export class RemultServerImplementation {
|
|
|
212
215
|
}));
|
|
213
216
|
}
|
|
214
217
|
else {
|
|
218
|
+
let head = '<title>Admin</title>';
|
|
219
|
+
if (isOfType(this.options.admin, 'allow') &&
|
|
220
|
+
this.options.admin.customHtmlHead) {
|
|
221
|
+
head = this.options.admin.customHtmlHead(remult);
|
|
222
|
+
}
|
|
215
223
|
origResponse.send(remultAdminHtml({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
baseUrl: this.options.rootPath + '/admin',
|
|
224
|
+
rootPath: this.options.rootPath ?? '/api',
|
|
225
|
+
head,
|
|
219
226
|
}));
|
|
220
227
|
}
|
|
221
228
|
}
|
|
@@ -720,8 +720,13 @@ export function buildFilterFromRequestParameters(entity, filterInfo) {
|
|
|
720
720
|
}),
|
|
721
721
|
});
|
|
722
722
|
}
|
|
723
|
-
if (not.length == 1
|
|
724
|
-
where
|
|
723
|
+
if (not.length == 1) {
|
|
724
|
+
if (!where.$not) {
|
|
725
|
+
where.$not = not[0].$not;
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
where.$not.push(not[0].$not);
|
|
729
|
+
}
|
|
725
730
|
}
|
|
726
731
|
else {
|
|
727
732
|
addAnd({
|
|
@@ -136,7 +136,9 @@ export class ValueConverters {
|
|
|
136
136
|
toJson: (value) => ValueConverters.Number.toDb(value),
|
|
137
137
|
fromInput: (x, type) => {
|
|
138
138
|
let r = +x;
|
|
139
|
-
if (x === null
|
|
139
|
+
if (x === null)
|
|
140
|
+
return null;
|
|
141
|
+
if (x === undefined)
|
|
140
142
|
return undefined;
|
|
141
143
|
return r;
|
|
142
144
|
},
|