remult 3.3.0-next.1 → 3.3.0

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,7 +13,7 @@ export interface UpsertOptions<entityType> {
13
13
  export interface EntityRefBase<entityType> extends Subscribable {
14
14
  hasErrors(): boolean;
15
15
  undoChanges(): void;
16
- save(): Promise<entityType>;
16
+ save(options?: InsertOrUpdateOptions): Promise<entityType>;
17
17
  reload(): Promise<entityType>;
18
18
  delete(): Promise<void>;
19
19
  isNew(): boolean;
@@ -555,19 +555,19 @@ export interface Repository<entityType> {
555
555
  * @example
556
556
  * await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
557
557
  */
558
- insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
559
- insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
558
+ insert(item: Partial<MembersOnly<entityType>>[], options?: InsertOrUpdateOptions): Promise<entityType[]>;
559
+ insert(item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
560
560
  /** Updates an item, based on its `id`
561
561
  * @example
562
562
  * taskRepo.update(task.id,{...task,completed:true})
563
563
  */
564
- update(id: idType<entityType>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
565
- update(id: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
564
+ update(id: idType<entityType>, item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
565
+ update(id: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>, options?: InsertOrUpdateOptions): Promise<entityType>;
566
566
  /**
567
567
  * Updates all items that match the `where` condition.
568
568
  */
569
569
  updateMany(options: {
570
- where: EntityFilter<entityType>;
570
+ where: EntityFilter<entityType> | 'all';
571
571
  set: Partial<MembersOnly<entityType>>;
572
572
  }): Promise<number>;
573
573
  /**
@@ -607,7 +607,7 @@ export interface Repository<entityType> {
607
607
  * Deletes all items that match the `where` condition.
608
608
  */
609
609
  deleteMany(options: {
610
- where: EntityFilter<entityType>;
610
+ where: EntityFilter<entityType> | 'all';
611
611
  }): Promise<number>;
612
612
  /** Creates an instance of an item. It'll not be saved to the data source unless `save` or `insert` will be called.
613
613
  *
@@ -1198,6 +1198,9 @@ export declare type EntityIdFields<entityType> = {
1198
1198
  export declare type EntitySelectFields<entityType> = {
1199
1199
  [Properties in keyof Partial<MembersOnly<entityType>>]?: boolean;
1200
1200
  };
1201
+ export declare type InsertOrUpdateOptions = {
1202
+ select: 'none';
1203
+ };
1201
1204
  export interface ClassFieldDecoratorContextStub<entityType, valueType> {
1202
1205
  readonly access: {
1203
1206
  set(object: entityType, value: valueType | null): void;
@@ -295,7 +295,7 @@ function BackendMethod(options) {
295
295
  reg(controllerOptions.key +
296
296
  '/' +
297
297
  ((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
298
- key, options ? (_b = options.queue) !== null && _b !== void 0 ? _b : false : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
298
+ key, options ? ((_b = options.queue) !== null && _b !== void 0 ? _b : false) : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
299
299
  var allowed, remult_1, r_1, err_3;
300
300
  var _this = this;
301
301
  return tslib_1.__generator(this, function (_a) {
@@ -475,7 +475,7 @@ function BackendMethod(options) {
475
475
  http])];
476
476
  case 4:
477
477
  r = _k.sent();
478
- return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data, true)];
478
+ return [4 /*yield*/, defs._updateResultsFromServerAction(r.rowInfo)];
479
479
  case 5:
480
480
  _k.sent();
481
481
  return [2 /*return*/, r.result];
@@ -2,7 +2,9 @@ import type { ValueConverter } from './column-interfaces.js';
2
2
  export declare class ValueConverters {
3
3
  static readonly Date: ValueConverter<Date>;
4
4
  static readonly DateOnly: ValueConverter<Date>;
5
- static readonly DateOnlyString: ValueConverter<Date>;
5
+ static readonly DateOnlyString: ValueConverter<Date> & {
6
+ zeroDate: Date;
7
+ };
6
8
  static readonly Boolean: ValueConverter<Boolean>;
7
9
  static readonly Number: ValueConverter<number>;
8
10
  static readonly String: ValueConverter<String>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValueConverters = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var inputTypes_js_1 = require("../inputTypes.js");
6
+ var zeroDate = new Date('0000-01-01');
6
7
  var ValueConverters = /** @class */ (function () {
7
8
  function ValueConverters() {
8
9
  }
@@ -71,6 +72,8 @@ var ValueConverters = /** @class */ (function () {
71
72
  fromJson: function (value) {
72
73
  if (!value || value == '' || value == '0000-00-00')
73
74
  return null;
75
+ if (value == '0000-01-01')
76
+ return zeroDate;
74
77
  var d = new Date(Date.parse(value));
75
78
  d.setMinutes(d.getMinutes() + d.getTimezoneOffset());
76
79
  return d;
@@ -92,6 +95,8 @@ var ValueConverters = /** @class */ (function () {
92
95
  },
93
96
  };
94
97
  ValueConverters.DateOnlyString = tslib_1.__assign(tslib_1.__assign({}, ValueConverters.DateOnly), { toDb: function (d) {
98
+ if (d === zeroDate)
99
+ return '00000000';
95
100
  var val = ValueConverters.DateOnly.toJson(d);
96
101
  if (!val)
97
102
  return undefined;
@@ -101,12 +106,10 @@ var ValueConverters = /** @class */ (function () {
101
106
  return null;
102
107
  if (!val)
103
108
  return undefined;
104
- return new Date(val.substring(0, 4) +
105
- '-' +
106
- val.substring(4, 6) +
107
- '-' +
108
- val.substring(6, 8));
109
- } });
109
+ if (val === '00000000')
110
+ return zeroDate;
111
+ return new Date(Number(val.substring(0, 4)), Number(val.substring(4, 6)) - 1, Number(val.substring(6, 8)));
112
+ }, zeroDate: zeroDate });
110
113
  ValueConverters.Boolean = {
111
114
  toDb: function (val) { return val; },
112
115
  inputType: inputTypes_js_1.InputTypes.checkbox,