remult 3.2.2 → 3.2.3

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.
@@ -1372,6 +1372,15 @@ export class rowHelperImplementation extends rowHelperBase {
1372
1372
  repo;
1373
1373
  edp;
1374
1374
  _isNew;
1375
+ async _updateResultsFromServerAction(rowInfo) {
1376
+ await this._updateEntityBasedOnApi(rowInfo.data, true);
1377
+ if (this._isNew != rowInfo.isNewRow) {
1378
+ this._isNew = rowInfo.isNewRow;
1379
+ this.originalId = rowInfo.id;
1380
+ }
1381
+ if (!rowInfo.wasChanged)
1382
+ this.originalValues = this.copyDataToObject();
1383
+ }
1375
1384
  constructor(info, instance, repo, edp, remult, _isNew, excludeRelationMembers) {
1376
1385
  super(info.fieldsMetadata, instance, remult, _isNew, excludeRelationMembers);
1377
1386
  this.info = info;
@@ -193,7 +193,7 @@ export function BackendMethod(options) {
193
193
  reg(controllerOptions.key +
194
194
  '/' +
195
195
  (options?.apiPrefix ? options.apiPrefix + '/' : '') +
196
- key, options ? options.queue ?? false : false, options.allowed, async (d, req, res) => {
196
+ key, options ? (options.queue ?? false) : false, options.allowed, async (d, req, res) => {
197
197
  d.args = d.args.map((x) => (isCustomUndefined(x) ? undefined : x));
198
198
  let allowed = options.allowed;
199
199
  try {
@@ -295,7 +295,7 @@ export function BackendMethod(options) {
295
295
  id: defs.getOriginalId(),
296
296
  },
297
297
  }, baseUrl, http);
298
- await defs._updateEntityBasedOnApi(r.rowInfo.data, true);
298
+ await defs._updateResultsFromServerAction(r.rowInfo);
299
299
  return r.result;
300
300
  }
301
301
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "3.2.2",
3
+ "version": "3.2.3",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -6,7 +6,7 @@ import type { EntityOptions } from '../entity.js';
6
6
  import { Filter } from '../filter/filter-interfaces.js';
7
7
  import { type GroupByOptions, type GroupByResult, type ControllerRef, type ControllerRefForControllerBase, type EntityFilter, type EntityMetadata, type EntityOrderBy, type EntityRef, type EntityRefForEntityBase, type FieldRef, type FieldsMetadata, type FieldsRef, type FieldsRefForEntityBase, type FindFirstOptions, type FindFirstOptionsBase, type FindOptions, type IdMetadata, type LiveQuery, type LoadOptions, type MembersOnly, type NumericKeys, type Repository, type RepositoryRelations, type idType } from './remult3.js';
8
8
  import type { QueryOptions, RefSubscriber, UpsertOptions } from './remult3.js';
9
- import type { entityEventListener } from '../__EntityValueProvider.js';
9
+ import type { entityEventListener, packedRowInfo } from '../__EntityValueProvider.js';
10
10
  import { type DataProvider, type EntityDataProvider, type EntityDataProviderGroupByOptions, type EntityDataProviderFindOptions, type ErrorInfo, EntityError } from '../data-interfaces.js';
11
11
  import type { Unsubscribe } from '../live-query/SubscriptionChannel.js';
12
12
  import { RelationLoader } from './relation-loader.js';
@@ -136,6 +136,7 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
136
136
  private repo;
137
137
  private edp;
138
138
  private _isNew;
139
+ _updateResultsFromServerAction(rowInfo: packedRowInfo): Promise<void>;
139
140
  constructor(info: EntityFullInfo<T>, instance: T, repo: RepositoryImplementation<T>, edp: EntityDataProvider, remult: Remult, _isNew: boolean, excludeRelationMembers?: Set<string>);
140
141
  repository: Repository<unknown>;
141
142
  clone(): T;
@@ -2273,6 +2273,24 @@ var rowHelperImplementation = /** @class */ (function (_super) {
2273
2273
  context_js_1.Remult.entityRefInit(_this, instance);
2274
2274
  return _this;
2275
2275
  }
2276
+ rowHelperImplementation.prototype._updateResultsFromServerAction = function (rowInfo) {
2277
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
2278
+ return tslib_1.__generator(this, function (_a) {
2279
+ switch (_a.label) {
2280
+ case 0: return [4 /*yield*/, this._updateEntityBasedOnApi(rowInfo.data, true)];
2281
+ case 1:
2282
+ _a.sent();
2283
+ if (this._isNew != rowInfo.isNewRow) {
2284
+ this._isNew = rowInfo.isNewRow;
2285
+ this.originalId = rowInfo.id;
2286
+ }
2287
+ if (!rowInfo.wasChanged)
2288
+ this.originalValues = this.copyDataToObject();
2289
+ return [2 /*return*/];
2290
+ }
2291
+ });
2292
+ });
2293
+ };
2276
2294
  rowHelperImplementation.prototype.clone = function () {
2277
2295
  var data = this.toApiJson(true, true);
2278
2296
  return this.repo.fromJson(data, this.isNew());
@@ -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];