remult 2.7.32 → 2.7.34

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.
@@ -2,6 +2,7 @@ import { getRelationFieldInfo, } from '../src/remult3/relationInfoMember.js';
2
2
  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
+ import { InputTypes } from '../inputTypes.js';
5
6
  export default function remultAdminHtml(options) {
6
7
  const { rootPath, head } = options;
7
8
  return getHtml()
@@ -76,7 +77,7 @@ export function buildEntityInfo(options) {
76
77
  caption: x.caption,
77
78
  relationToOne: relation,
78
79
  inputType: x.inputType,
79
- type: x.valueConverter.fieldTypeInDb == 'json'
80
+ type: x.inputType === InputTypes.json
80
81
  ? 'json'
81
82
  : x.valueType === Number
82
83
  ? 'number'
@@ -95,7 +96,7 @@ export function buildEntityInfo(options) {
95
96
  if (metadata.apiReadAllowed) {
96
97
  let superKey = metadata.key;
97
98
  let caption = metadata.caption;
98
- const nbOfEntities = entities.filter(e => e.key === metadata.key).length;
99
+ const nbOfEntities = entities.filter((e) => e.key === metadata.key).length;
99
100
  if (nbOfEntities > 0) {
100
101
  superKey = metadata.key + '_ext_' + nbOfEntities;
101
102
  caption = metadata.caption + '*'.repeat(nbOfEntities);
@@ -7,6 +7,7 @@ import { relationInfoMemberInOptions } from './relationInfoMember.js';
7
7
  import { remultStatic } from '../remult-static.js';
8
8
  import { addValidator } from './addValidator.js';
9
9
  import { isOfType } from '../isOfType.js';
10
+ import { InputTypes } from '../../inputTypes.js';
10
11
  const validateNumber = createValueValidator((x) => {
11
12
  return !isNaN(x) && isFinite(x);
12
13
  });
@@ -22,9 +23,13 @@ export class Fields {
22
23
  if (op.valueConverter && !op.valueConverter.fieldTypeInDb)
23
24
  //@ts-ignore
24
25
  op.valueConverter.fieldTypeInDb = 'json';
26
+ if (op.valueType && !op.valueType.inputType)
27
+ //@ts-ignore
28
+ op.valueType.inputType = InputTypes.json;
25
29
  return Field(undefined, {
26
30
  valueConverter: {
27
31
  fieldTypeInDb: 'json',
32
+ inputType: InputTypes.json,
28
33
  },
29
34
  }, ...options);
30
35
  }
@@ -51,6 +51,8 @@ export class ValueConverters {
51
51
  var d = val;
52
52
  if (typeof d === 'string' || typeof d === 'number')
53
53
  d = new Date(d);
54
+ if (d === undefined)
55
+ return undefined;
54
56
  if (!d || d == null)
55
57
  return null;
56
58
  if (d.getHours() == 0)
package/inputTypes.d.ts CHANGED
@@ -6,4 +6,5 @@ export declare class InputTypes {
6
6
  static email: string;
7
7
  static tel: string;
8
8
  static time: string;
9
+ static json: string;
9
10
  }
package/inputTypes.js CHANGED
@@ -11,6 +11,7 @@ var InputTypes = /** @class */ (function () {
11
11
  InputTypes.email = 'email';
12
12
  InputTypes.tel = 'tel';
13
13
  InputTypes.time = 'time';
14
+ InputTypes.json = 'json';
14
15
  return InputTypes;
15
16
  }());
16
17
  exports.InputTypes = InputTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "2.7.32",
3
+ "version": "2.7.34",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -217,6 +217,11 @@ var KnexEntityDataProvider = /** @class */ (function () {
217
217
  });
218
218
  });
219
219
  };
220
+ KnexEntityDataProvider.prototype.getEntityFrom = function (e) {
221
+ if (this.entity.options.sqlExpression)
222
+ return this.knex.fromRaw(e.$entityName);
223
+ return this.knex(e.$entityName);
224
+ };
220
225
  KnexEntityDataProvider.prototype.count = function (where) {
221
226
  return tslib_1.__awaiter(this, void 0, void 0, function () {
222
227
  var e, br, r, result, row, key, element;
@@ -230,7 +235,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
230
235
  return [4 /*yield*/, br.resolveWhere()];
231
236
  case 2:
232
237
  r = _a.sent();
233
- return [4 /*yield*/, this.knex(e.$entityName)
238
+ return [4 /*yield*/, this.getEntityFrom(e)
234
239
  .count()
235
240
  .where(function (b) { return r.forEach(function (w) { return w(b); }); })];
236
241
  case 3:
@@ -279,7 +284,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
279
284
  }
280
285
  finally { if (e_3) throw e_3.error; }
281
286
  }
282
- query = this.knex(e.$entityName).select(cols);
287
+ query = this.getEntityFrom(e).select(cols);
283
288
  if (!(options === null || options === void 0 ? void 0 : options.where)) return [3 /*break*/, 3];
284
289
  br = new FilterConsumerBridgeToKnexRequest(e, this.rawSqlWrapIdentifier);
285
290
  options.where.__applyToConsumer(br);
@@ -395,7 +400,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
395
400
  case 10: return [4 /*yield*/, f.resolveWhere()];
396
401
  case 11:
397
402
  where = _d.sent();
398
- return [4 /*yield*/, this.knex(e.$entityName)
403
+ return [4 /*yield*/, this.getEntityFrom(e)
399
404
  .update(updateObject)
400
405
  .where(function (b) { return where.forEach(function (w) { return w(b); }); })];
401
406
  case 12:
@@ -418,7 +423,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
418
423
  return [4 /*yield*/, f.resolveWhere()];
419
424
  case 2:
420
425
  where = _a.sent();
421
- return [4 /*yield*/, this.knex(e.$entityName)
426
+ return [4 /*yield*/, this.getEntityFrom(e)
422
427
  .delete()
423
428
  .where(function (b) { return where.forEach(function (w) { return w(b); }); })];
424
429
  case 3:
@@ -472,7 +477,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
472
477
  finally { if (e_5) throw e_5.error; }
473
478
  return [7 /*endfinally*/];
474
479
  case 10:
475
- insert = this.knex(e.$entityName).insert(insertObject);
480
+ insert = this.getEntityFrom(e).insert(insertObject);
476
481
  if (!(0, RepositoryImplementation_js_1.isAutoIncrement)(this.entity.idMetadata.field)) return [3 /*break*/, 15];
477
482
  if (!(this.knex.client.config.client === 'mysql2' ||
478
483
  this.knex.client.config.client === 'mysql')) return [3 /*break*/, 12];