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.
@@ -3,6 +3,7 @@ import type { ClassType } from '../classType.js';
3
3
  import type { Remult } from '../src/context.js';
4
4
  import { EntityFilter } from '../src/remult3/remult3.js';
5
5
  export interface EntityUIInfo {
6
+ superKey: string;
6
7
  key: string;
7
8
  caption: string;
8
9
  fields: FieldUIInfo[];
@@ -12,6 +13,8 @@ export interface EntityUIInfo {
12
13
  color?: string;
13
14
  }
14
15
  export interface EntityRelationToManyInfo extends RelationFields {
16
+ key: string;
17
+ caption: string;
15
18
  entityKey: string;
16
19
  where?: any;
17
20
  }
@@ -35,13 +38,14 @@ export interface FieldRelationToOneInfo extends RelationFields {
35
38
  captionField: string;
36
39
  where?: any;
37
40
  }
38
- export interface AdminOptions extends DisplayOptions {
41
+ export interface AdminEntitiesOptions {
39
42
  entities: ClassType<any>[];
40
43
  remult: Remult;
41
44
  }
42
- export interface DisplayOptions {
43
- baseUrl?: string;
45
+ export interface AdminDisplayOptions {
46
+ rootPath: string;
47
+ head: string;
44
48
  }
45
- export default function remultAdminHtml(options: AdminOptions): string;
46
- export declare function buildEntityInfo(options: AdminOptions): EntityUIInfo[];
49
+ export default function remultAdminHtml(options: AdminDisplayOptions): string;
50
+ export declare function buildEntityInfo(options: AdminEntitiesOptions): EntityUIInfo[];
47
51
  export type RelationsToOneValues = Record<string, Map<any, any>>;
@@ -8,122 +8,136 @@ var filter_interfaces_js_1 = require("../src/filter/filter-interfaces.js");
8
8
  var get_remult_admin_html_js_1 = require("./get-remult-admin-html.js");
9
9
  var RepositoryImplementation_js_1 = require("../src/remult3/RepositoryImplementation.js");
10
10
  function remultAdminHtml(options) {
11
- var _a = tslib_1.__assign({}, options), remult = _a.remult, entities = _a.entities, optionsFromServer = tslib_1.__rest(_a, ["remult", "entities"]);
12
- return (0, get_remult_admin_html_js_1.getHtml)().replace('<!--PLACE_HERE-->', "<script>\n const optionsFromServer = ".concat(JSON.stringify(optionsFromServer), "\n</script>"));
11
+ var rootPath = options.rootPath, head = options.head;
12
+ return (0, get_remult_admin_html_js_1.getHtml)()
13
+ .replace('<!--PLACE_HERE_HEAD-->', head)
14
+ .replace('<!--PLACE_HERE_BODY-->', "<script>\n window.optionsFromServer = ".concat(JSON.stringify({ rootPath: rootPath }), "\n</script>"));
13
15
  }
14
16
  function buildEntityInfo(options) {
15
- var e_1, _a, e_2, _b, e_3, _c;
16
- var _d, _e;
17
+ var e_1, _a;
18
+ var _b, _c;
17
19
  var entities = [];
18
- try {
19
- for (var _f = tslib_1.__values(options.entities.map(function (e) { return options.remult.repo(e).metadata; })), _g = _f.next(); !_g.done; _g = _f.next()) {
20
- var metadata = _g.value;
21
- var fields = [];
22
- var relations = [];
23
- var ids = {};
24
- try {
25
- for (var _h = (e_2 = void 0, tslib_1.__values(metadata.idMetadata.fields)), _j = _h.next(); !_j.done; _j = _h.next()) {
26
- var f = _j.value;
27
- ids[f.key] = true;
28
- }
20
+ var _loop_1 = function (metadata) {
21
+ var e_2, _f, e_3, _g;
22
+ var fields = [];
23
+ var relations = [];
24
+ var ids = {};
25
+ try {
26
+ for (var _h = (e_2 = void 0, tslib_1.__values(metadata.idMetadata.fields)), _j = _h.next(); !_j.done; _j = _h.next()) {
27
+ var f = _j.value;
28
+ ids[f.key] = true;
29
29
  }
30
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
31
- finally {
32
- try {
33
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
34
- }
35
- finally { if (e_2) throw e_2.error; }
30
+ }
31
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
32
+ finally {
33
+ try {
34
+ if (_j && !_j.done && (_f = _h.return)) _f.call(_h);
36
35
  }
37
- var _loop_1 = function (x) {
38
- if (!x.includedInApi(undefined))
39
- return "continue";
40
- try {
41
- var relation = void 0;
42
- var valFieldKey = x.key;
43
- var info = (0, relationInfoMember_js_1.getRelationFieldInfo)(x);
44
- if (info) {
45
- var relInfo = info.getFields();
46
- var relRepo = options.remult.repo(info.toEntity);
47
- var where = typeof info.options.findOptions === 'object' &&
48
- info.options.findOptions.where
49
- ? filter_interfaces_js_1.Filter.entityFilterToJson(relRepo.metadata, info.options.findOptions.where)
50
- : undefined;
51
- var idField_1 = relRepo.metadata.idMetadata.field.key;
52
- if (info.type === 'reference' || info.type === 'toOne') {
53
- if (info.type == 'toOne') {
54
- for (var key in relInfo.fields) {
55
- if (Object.prototype.hasOwnProperty.call(relInfo.fields, key)) {
56
- var element = relInfo.fields[key];
57
- valFieldKey = element;
58
- }
36
+ finally { if (e_2) throw e_2.error; }
37
+ }
38
+ var _loop_2 = function (x) {
39
+ if (!x.includedInApi(undefined))
40
+ return "continue";
41
+ try {
42
+ var relation = void 0;
43
+ var valFieldKey = x.key;
44
+ var info = (0, relationInfoMember_js_1.getRelationFieldInfo)(x);
45
+ if (info) {
46
+ var relInfo = info.getFields();
47
+ var relRepo = options.remult.repo(info.toEntity);
48
+ var where = typeof info.options.findOptions === 'object' &&
49
+ info.options.findOptions.where
50
+ ? filter_interfaces_js_1.Filter.entityFilterToJson(relRepo.metadata, info.options.findOptions.where)
51
+ : undefined;
52
+ var idField_1 = relRepo.metadata.idMetadata.field.key;
53
+ if (info.type === 'reference' || info.type === 'toOne') {
54
+ if (info.type == 'toOne') {
55
+ for (var key in relInfo.fields) {
56
+ if (Object.prototype.hasOwnProperty.call(relInfo.fields, key)) {
57
+ var element = relInfo.fields[key];
58
+ valFieldKey = element;
59
59
  }
60
60
  }
61
- if (relRepo.metadata.apiReadAllowed) {
62
- relation = tslib_1.__assign(tslib_1.__assign({}, relInfo), { where: where, entityKey: relRepo.metadata.key, idField: idField_1, captionField: (_d = relRepo.metadata.fields
63
- .toArray()
64
- .find(function (x) { return x.key != idField_1 && x.valueType == String; })) === null || _d === void 0 ? void 0 : _d.key });
65
- }
66
61
  }
67
- else if (info.type === 'toMany') {
68
- if (relRepo.metadata.apiReadAllowed) {
69
- relations.push(tslib_1.__assign(tslib_1.__assign({}, relInfo), { where: where, entityKey: relRepo.metadata.key }));
70
- }
71
- return "continue";
62
+ if (relRepo.metadata.apiReadAllowed) {
63
+ relation = tslib_1.__assign(tslib_1.__assign({}, relInfo), { where: where, entityKey: relRepo.metadata.key, idField: idField_1, captionField: (_b = relRepo.metadata.fields
64
+ .toArray()
65
+ .find(function (x) { return x.key != idField_1 && x.valueType == String; })) === null || _b === void 0 ? void 0 : _b.key });
72
66
  }
73
67
  }
74
- fields.push({
75
- key: x.key,
76
- readOnly: !x.apiUpdateAllowed(),
77
- values: (0, RepositoryImplementation_js_1.getValueList)(x),
78
- valFieldKey: valFieldKey,
79
- caption: x.caption,
80
- relationToOne: relation,
81
- inputType: x.inputType,
82
- type: x.valueConverter.fieldTypeInDb == 'json'
83
- ? 'json'
84
- : x.valueType === Number
85
- ? 'number'
86
- : x.valueType === Boolean
87
- ? 'boolean'
88
- : x.valueType === Date
89
- ? 'date'
90
- : 'string',
91
- });
92
- }
93
- catch (error) {
94
- console.error("[remult-admin] Error with ".concat(metadata.key, ".").concat(x.key, " field."));
95
- console.error("[remult-admin]", error);
96
- }
97
- };
98
- try {
99
- for (var _k = (e_3 = void 0, tslib_1.__values(metadata.fields.toArray())), _l = _k.next(); !_l.done; _l = _k.next()) {
100
- var x = _l.value;
101
- _loop_1(x);
68
+ else if (info.type === 'toMany') {
69
+ if (relRepo.metadata.apiReadAllowed) {
70
+ relations.push(tslib_1.__assign(tslib_1.__assign({}, relInfo), { where: where, entityKey: relRepo.metadata.key, key: x.key, caption: x.caption }));
71
+ }
72
+ return "continue";
73
+ }
102
74
  }
75
+ fields.push({
76
+ key: x.key,
77
+ readOnly: !x.apiUpdateAllowed(),
78
+ values: (0, RepositoryImplementation_js_1.getValueList)(x),
79
+ valFieldKey: valFieldKey,
80
+ caption: x.caption,
81
+ relationToOne: relation,
82
+ inputType: x.inputType,
83
+ type: x.valueConverter.fieldTypeInDb == 'json'
84
+ ? 'json'
85
+ : x.valueType === Number
86
+ ? 'number'
87
+ : x.valueType === Boolean
88
+ ? 'boolean'
89
+ : x.valueType === Date
90
+ ? 'date'
91
+ : 'string',
92
+ });
103
93
  }
104
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
105
- finally {
106
- try {
107
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
108
- }
109
- finally { if (e_3) throw e_3.error; }
94
+ catch (error) {
95
+ console.error("[remult-admin] Error with ".concat(metadata.key, ".").concat(x.key, " field."));
96
+ console.error("[remult-admin]", error);
110
97
  }
111
- if (metadata.apiReadAllowed) {
112
- entities.push({
113
- key: metadata.key,
114
- caption: metadata.caption,
115
- ids: ids,
116
- fields: fields,
117
- relations: relations,
118
- defaultOrderBy: (_e = metadata.options.defaultOrderBy) !== null && _e !== void 0 ? _e : { id: 'asc' },
119
- });
98
+ };
99
+ try {
100
+ for (var _k = (e_3 = void 0, tslib_1.__values(metadata.fields.toArray())), _l = _k.next(); !_l.done; _l = _k.next()) {
101
+ var x = _l.value;
102
+ _loop_2(x);
120
103
  }
121
104
  }
105
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
106
+ finally {
107
+ try {
108
+ if (_l && !_l.done && (_g = _k.return)) _g.call(_k);
109
+ }
110
+ finally { if (e_3) throw e_3.error; }
111
+ }
112
+ if (metadata.apiReadAllowed) {
113
+ var superKey = metadata.key;
114
+ var caption = metadata.caption;
115
+ var nbOfEntities = entities.filter(function (e) { return e.key === metadata.key; }).length;
116
+ if (nbOfEntities > 0) {
117
+ superKey = metadata.key + '_ext_' + nbOfEntities;
118
+ caption = metadata.caption + '*'.repeat(nbOfEntities);
119
+ }
120
+ entities.push({
121
+ superKey: superKey,
122
+ key: metadata.key,
123
+ caption: caption,
124
+ ids: ids,
125
+ fields: fields,
126
+ relations: relations,
127
+ defaultOrderBy: (_c = metadata.options.defaultOrderBy) !== null && _c !== void 0 ? _c : { id: 'asc' },
128
+ });
129
+ }
130
+ };
131
+ try {
132
+ for (var _d = tslib_1.__values(options.entities.map(function (e) { return options.remult.repo(e).metadata; })), _e = _d.next(); !_e.done; _e = _d.next()) {
133
+ var metadata = _e.value;
134
+ _loop_1(metadata);
135
+ }
122
136
  }
123
137
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
124
138
  finally {
125
139
  try {
126
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
140
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
127
141
  }
128
142
  finally { if (e_1) throw e_1.error; }
129
143
  }
@@ -52,10 +52,13 @@ export interface RemultServerOptions<RequestType> {
52
52
  * @example
53
53
  * admin: true
54
54
  * @example
55
- * admin: ()=> remult.isAllowed('admin')
55
+ * admin: () => remult.isAllowed('admin')
56
56
  * @see [allowed](http://remult.dev/docs/allowed.html)
57
57
  */
58
- admin?: Allowed;
58
+ admin?: Allowed | {
59
+ allow: Allowed;
60
+ customHtmlHead?: (remult: Remult) => string;
61
+ };
59
62
  /** Storage to use for backend methods that use queue */
60
63
  queueStorage?: QueueStorage;
61
64
  /**
@@ -364,9 +364,13 @@ var RemultServerImplementation = /** @class */ (function () {
364
364
  if (this.options.admin !== undefined && this.options.admin !== false) {
365
365
  var admin = function () {
366
366
  return _this.process(function (remult, req, res, orig, origResponse) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
367
- var _a, _b;
368
- return tslib_1.__generator(this, function (_c) {
369
- if (remult.isAllowed(this.options.admin)) {
367
+ var allowed, head;
368
+ var _a, _b, _c;
369
+ return tslib_1.__generator(this, function (_d) {
370
+ allowed = (0, isOfType_js_1.isOfType)(this.options.admin, 'allow')
371
+ ? this.options.admin.allow
372
+ : this.options.admin;
373
+ if (remult.isAllowed(allowed)) {
370
374
  if (((_a = orig === null || orig === void 0 ? void 0 : orig.params) === null || _a === void 0 ? void 0 : _a.id) === '__entities-metadata') {
371
375
  res.success((0, remult_admin_js_1.buildEntityInfo)({
372
376
  remult: remult,
@@ -374,10 +378,14 @@ var RemultServerImplementation = /** @class */ (function () {
374
378
  }));
375
379
  }
376
380
  else {
381
+ head = '<title>Admin</title>';
382
+ if ((0, isOfType_js_1.isOfType)(this.options.admin, 'allow') &&
383
+ this.options.admin.customHtmlHead) {
384
+ head = this.options.admin.customHtmlHead(remult);
385
+ }
377
386
  origResponse.send((0, remult_admin_js_1.default)({
378
- remult: remult,
379
- entities: this.options.entities,
380
- baseUrl: this.options.rootPath + '/admin',
387
+ rootPath: (_c = this.options.rootPath) !== null && _c !== void 0 ? _c : '/api',
388
+ head: head,
381
389
  }));
382
390
  }
383
391
  }
@@ -29,6 +29,8 @@ export interface FieldOptions<entityType = unknown, valueType = unknown> {
29
29
  /**
30
30
  * Determines whether this field can be updated via the API. This setting can also
31
31
  * be controlled based on user roles or other access control checks.
32
+ *
33
+ * _It happens after entity level authorization AND if it's allowed._
32
34
  * @example
33
35
  * // Prevent API from updating this field
34
36
  * @Fields.string({ allowApiUpdate: false })
@@ -122,8 +124,7 @@ export interface FieldOptions<entityType = unknown, valueType = unknown> {
122
124
  export interface FieldMetadata<valueType = unknown, entityType = unknown> {
123
125
  /** The field's member name in an object.
124
126
  * @example
125
- * const taskRepo = remult.repo(Task);
126
- * console.log(taskRepo.metadata.fields.title.key);
127
+ * console.log(repo(Task).metadata.fields.title.key);
127
128
  * // result: title
128
129
  */
129
130
  readonly key: entityType extends object ? keyof entityType & string : string;
@@ -154,8 +155,7 @@ export interface FieldMetadata<valueType = unknown, entityType = unknown> {
154
155
  readonly allowNull: boolean;
155
156
  /** The class that contains this field
156
157
  * @example
157
- * const taskRepo = remult.repo(Task);
158
- * Task == taskRepo.metadata.fields.title.target //will return true
158
+ * Task == repo(Task).metadata.fields.title.target //will return true
159
159
  */
160
160
  readonly target: ClassType<valueType>;
161
161
  /**
@@ -179,9 +179,8 @@ export interface FieldMetadata<valueType = unknown, entityType = unknown> {
179
179
  * Determines if the current user is allowed to update a specific entity instance.
180
180
 
181
181
  * @example
182
- * const taskRepo = remult.repo(Task);
183
182
  * // Check if the current user is allowed to update a specific task
184
- * if (taskRepo.metadata.apiUpdateAllowed(task)){
183
+ * if (repo(Task).metadata.apiUpdateAllowed(task)){
185
184
  * // Allow user to edit the entity
186
185
  * }
187
186
  * @see {@link FieldOptions#allowApiUpdate} for configuration details
@@ -936,8 +936,13 @@ function buildFilterFromRequestParameters(entity, filterInfo) {
936
936
  }
937
937
  finally { if (e_5) throw e_5.error; }
938
938
  }
939
- if (not.length == 1 && !where.$not) {
940
- where = not[0];
939
+ if (not.length == 1) {
940
+ if (!where.$not) {
941
+ where.$not = not[0].$not;
942
+ }
943
+ else {
944
+ where.$not.push(not[0].$not);
945
+ }
941
946
  }
942
947
  else {
943
948
  addAnd({
@@ -212,8 +212,7 @@ export interface EntityMetadata<entityType = unknown> {
212
212
  /** true if the current user is allowed to update an entity instance
213
213
  * @see {@link EntityOptions.allowApiUpdate
214
214
  * @example
215
- * const taskRepo = remult.repo(Task);
216
- * if (taskRepo.metadata.apiUpdateAllowed(task)){
215
+ * if (repo(Task).metadata.apiUpdateAllowed(task)){
217
216
  * // Allow user to edit the entity
218
217
  * }
219
218
  */
@@ -221,8 +220,7 @@ export interface EntityMetadata<entityType = unknown> {
221
220
  /** true if the current user is allowed to read from entity
222
221
  * @see {@link EntityOptions.allowApiRead}
223
222
  * @example
224
- * const taskRepo = remult.repo(Task);
225
- * if (taskRepo.metadata.apiReadAllowed){
223
+ * if (repo(Task).metadata.apiReadAllowed){
226
224
  * await taskRepo.find()
227
225
  * }
228
226
  */
@@ -230,8 +228,7 @@ export interface EntityMetadata<entityType = unknown> {
230
228
  /** true if the current user is allowed to delete an entity instance
231
229
  * * @see {@link EntityOptions.allowApiDelete}
232
230
  * @example
233
- * const taskRepo = remult.repo(Task);
234
- * if (taskRepo.metadata.apiDeleteAllowed(task)){
231
+ * if (repo(Task).metadata.apiDeleteAllowed(task)){
235
232
  * // display delete button
236
233
  * }
237
234
  */
@@ -239,8 +236,7 @@ export interface EntityMetadata<entityType = unknown> {
239
236
  /** true if the current user is allowed to create an entity instance
240
237
  * @see {@link EntityOptions.allowApiInsert}
241
238
  * @example
242
- * const taskRepo = remult.repo(Task);
243
- * if (taskRepo.metadata.apiInsertAllowed(task)){
239
+ * if (repo(Task).metadata.apiInsertAllowed(task)){
244
240
  * // display insert button
245
241
  * }
246
242
  */
@@ -389,7 +385,7 @@ export type GroupByResult<entityType, groupByFields extends (keyof entityType)[]
389
385
  } & {
390
386
  $count: number;
391
387
  };
392
- /**used to perform CRUD operations on an `entityType` */
388
+ /** used to perform CRUD operations on an `entityType` */
393
389
  export interface Repository<entityType> {
394
390
  /** returns a result array based on the provided options */
395
391
  find(options?: FindOptions<entityType>): Promise<entityType[]>;
@@ -611,13 +607,36 @@ export interface Repository<entityType> {
611
607
  *
612
608
  */
613
609
  create(item?: Partial<MembersOnly<entityType>>): entityType;
610
+ /**
611
+ * Translates an entity to a json object.
612
+ * - Ready to be sent to the client _(Date & co are managed)_
613
+ * - Strip out fields that are not allowed to be sent to the client! Check: [Field.includeInApi](http://remult.dev/docs/ref_field#includeinapi)
614
+ *
615
+ * @example
616
+ * ```ts
617
+ * const tasks = repo(Task).toJson(repo(Task).find())
618
+ * ```
619
+ *
620
+ * @param item Can be an array or a single entity, awaitable or not
621
+ */
614
622
  toJson(item: Promise<entityType[]>): Promise<any[]>;
615
623
  toJson(item: entityType[]): any[];
616
624
  toJson(item: Promise<entityType>): Promise<any>;
617
625
  toJson(item: entityType): any;
618
- /** Translates a json object to an item instance */
619
- fromJson(x: any[], isNew?: boolean): entityType[];
620
- fromJson(x: any, isNew?: boolean): entityType;
626
+ /**
627
+ * Translates a json object to an item instance.
628
+ *
629
+ * @example
630
+ * ```ts
631
+ * const data = // from the server
632
+ * const tasks = repo(Task).fromJson(data)
633
+ * ```
634
+ *
635
+ * @param data Can be an array or a single element
636
+ * @param isNew To help the creation of the instance
637
+ */
638
+ fromJson(data: any[], isNew?: boolean): entityType[];
639
+ fromJson(data: any, isNew?: boolean): entityType;
621
640
  /** returns an `entityRef` for an item returned by `create`, `find` etc... */
622
641
  getEntityRef(item: entityType): EntityRef<entityType>;
623
642
  /** Provides information about the fields of the Repository's entity
@@ -709,26 +728,26 @@ export interface LiveQueryChangeInfo<entityType> {
709
728
  export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
710
729
  /** Determines the number of rows returned by the request, on the browser the default is 100 rows
711
730
  * @example
712
- * await this.remult.repo(Products).find({
713
- * limit:10,
714
- * page:2
731
+ * await repo(Products).find({
732
+ * limit: 10,
733
+ * page: 2
715
734
  * })
716
735
  */
717
736
  limit?: number;
718
737
  /** Determines the page number that will be used to extract the data
719
738
  * @example
720
- * await this.remult.repo(Products).find({
721
- * limit:10,
722
- * page:2
739
+ * await repo(Products).find({
740
+ * limit: 10,
741
+ * page: 2
723
742
  * })
724
743
  */
725
744
  page?: number;
726
745
  }
727
746
  /** Determines the order of items returned .
728
747
  * @example
729
- * await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
748
+ * await repo(Products).find({ orderBy: { name: "asc" }})
730
749
  * @example
731
- * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
750
+ * await repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
732
751
  */
733
752
  export declare type EntityOrderBy<entityType> = {
734
753
  [Properties in keyof Partial<MembersOnly<entityType>>]?: 'asc' | 'desc';
@@ -985,13 +1004,13 @@ export interface LoadOptions<entityType> {
985
1004
  * Example usage:
986
1005
  * ```
987
1006
  * // Deprecated usage with 'load' option
988
- * await remult.repo(Order).find({
1007
+ * await repo(Order).find({
989
1008
  * load: (o) => [o.customer],
990
1009
  * });
991
1010
  *
992
1011
  *
993
1012
  * // Preferred usage with 'Relations.toOne' and 'include' option
994
- * await remult.repo(Order).find({
1013
+ * await repo(Order).find({
995
1014
  * include: { customer: true },
996
1015
  * });
997
1016
  * ```
@@ -1029,9 +1048,9 @@ export interface FindOptionsBase<entityType> extends LoadOptions<entityType> {
1029
1048
  where?: EntityFilter<entityType>;
1030
1049
  /** Determines the order of items returned .
1031
1050
  * @example
1032
- * await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
1051
+ * await repo(Products).find({ orderBy: { name: "asc" }})
1033
1052
  * @example
1034
- * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
1053
+ * await repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
1035
1054
  */
1036
1055
  orderBy?: EntityOrderBy<entityType>;
1037
1056
  }
@@ -138,7 +138,9 @@ var ValueConverters = /** @class */ (function () {
138
138
  toJson: function (value) { return ValueConverters.Number.toDb(value); },
139
139
  fromInput: function (x, type) {
140
140
  var r = +x;
141
- if (x === null || x === undefined)
141
+ if (x === null)
142
+ return null;
143
+ if (x === undefined)
142
144
  return undefined;
143
145
  return r;
144
146
  },