oak-domain 2.5.1 → 2.6.1

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 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakDataException = exports.OakException = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ var assert_1 = tslib_1.__importDefault(require("assert"));
5
6
  var OakException = /** @class */ (function (_super) {
6
7
  tslib_1.__extends(OakException, _super);
7
8
  function OakException(message) {
@@ -17,12 +18,36 @@ var OakException = /** @class */ (function (_super) {
17
18
  else {
18
19
  _this.__proto__ = _newTarget.prototype;
19
20
  }
21
+ _this.opRecord = {
22
+ a: 's',
23
+ d: {},
24
+ };
20
25
  return _this;
21
26
  }
27
+ OakException.prototype.addData = function (entity, rows) {
28
+ var d = this.opRecord.d;
29
+ var addSingleRow = function (rowRoot, row) {
30
+ var id = row.id;
31
+ if (rowRoot[id]) {
32
+ Object.assign(rowRoot[id], row);
33
+ }
34
+ else {
35
+ rowRoot[id] = row;
36
+ }
37
+ };
38
+ if (!d[entity]) {
39
+ d[entity] = {};
40
+ }
41
+ rows.forEach(function (row) { return addSingleRow(d[entity], row); });
42
+ };
43
+ OakException.prototype.setOpRecords = function (opRecord) {
44
+ this.opRecord = opRecord;
45
+ };
22
46
  OakException.prototype.toString = function () {
23
47
  return JSON.stringify({
24
48
  name: this.constructor.name,
25
49
  message: this.message,
50
+ opRecord: this.opRecord,
26
51
  });
27
52
  };
28
53
  return OakException;
@@ -109,17 +134,13 @@ var OakRowInconsistencyException = /** @class */ (function (_super) {
109
134
  tslib_1.__extends(OakRowInconsistencyException, _super);
110
135
  function OakRowInconsistencyException(data, message) {
111
136
  var _this = _super.call(this, message) || this;
112
- _this.data = data;
137
+ (0, assert_1.default)(!data, '现在使用addData接口来传数据');
113
138
  return _this;
114
139
  }
115
- OakRowInconsistencyException.prototype.getData = function () {
116
- return this.data;
117
- };
118
140
  OakRowInconsistencyException.prototype.toString = function () {
119
141
  return JSON.stringify({
120
142
  name: this.constructor.name,
121
143
  message: this.message,
122
- data: this.data,
123
144
  });
124
145
  };
125
146
  return OakRowInconsistencyException;
@@ -235,46 +256,69 @@ function makeException(data) {
235
256
  var name = data.name;
236
257
  switch (name) {
237
258
  case 'OakException': {
238
- return new OakException(data.message);
259
+ var e = new OakException(data.message);
260
+ e.setOpRecords(data.opRecords);
261
+ return e;
239
262
  }
240
263
  case 'OakUserException': {
241
- return new OakUserException(data.message);
242
- }
243
- case 'OakExternalException': {
244
- return new OakExternalException(data.message);
264
+ var e = new OakUserException(data.message);
265
+ e.setOpRecords(data.opRecords);
266
+ return e;
245
267
  }
246
268
  case 'OakRowInconsistencyException': {
247
- return new OakRowInconsistencyException(data.data, data.message);
269
+ var e = new OakRowInconsistencyException(data.data, data.message);
270
+ e.setOpRecords(data.opRecords);
271
+ return e;
248
272
  }
249
273
  case 'OakInputIllegalException': {
250
- return new OakInputIllegalException(data.entity, data.attributes, data.message);
274
+ var e = new OakInputIllegalException(data.entity, data.attributes, data.message);
275
+ e.setOpRecords(data.opRecords);
276
+ return e;
251
277
  }
252
278
  case 'OakUserUnpermittedException': {
253
- return new OakUserUnpermittedException(data.message);
279
+ var e = new OakUserUnpermittedException(data.message);
280
+ e.setOpRecords(data.opRecords);
281
+ return e;
254
282
  }
255
283
  case 'OakUnloggedInException': {
256
- return new OakUnloggedInException(data.message);
284
+ var e = new OakUnloggedInException(data.message);
285
+ e.setOpRecords(data.opRecords);
286
+ return e;
257
287
  }
258
288
  case 'OakCongruentRowExists': {
259
- return new OakCongruentRowExists(data.entity, data.data, data.message);
289
+ var e = new OakCongruentRowExists(data.entity, data.data, data.message);
290
+ e.setOpRecords(data.opRecords);
291
+ return e;
260
292
  }
261
293
  case 'OakRowLockedException': {
262
- return new OakRowLockedException(data.message);
294
+ var e = new OakRowLockedException(data.message);
295
+ e.setOpRecords(data.opRecords);
296
+ return e;
263
297
  }
264
298
  case 'OakRowUnexistedException': {
265
- return new OakRowUnexistedException(data.rows);
299
+ var e = new OakRowUnexistedException(data.rows);
300
+ e.setOpRecords(data.opRecords);
301
+ return e;
266
302
  }
267
303
  case 'OakDeadlock': {
268
- return new OakDeadlock(data.message);
304
+ var e = new OakDeadlock(data.message);
305
+ e.setOpRecords(data.opRecords);
306
+ return e;
269
307
  }
270
308
  case 'OakDataException': {
271
- return new OakDataException(data.message);
309
+ var e = new OakDataException(data.message);
310
+ e.setOpRecords(data.opRecords);
311
+ return e;
272
312
  }
273
313
  case 'OakUniqueViolationException': {
274
- return new OakUniqueViolationException(data.rows, data.message);
314
+ var e = new OakUniqueViolationException(data.rows, data.message);
315
+ e.setOpRecords(data.opRecords);
316
+ return e;
275
317
  }
276
318
  case 'OakImportDataParseException': {
277
- return new OakImportDataParseException(data.message, data.line, data.header);
319
+ var e = new OakImportDataParseException(data.message, data.line, data.header);
320
+ e.setOpRecords(data.opRecords);
321
+ return e;
278
322
  }
279
323
  default:
280
324
  return;
@@ -8,7 +8,7 @@ export declare class SimpleConnector<ED extends EntityDict, BackCxt extends Asyn
8
8
  private serverUrl;
9
9
  private makeException;
10
10
  private contextBuilder;
11
- constructor(serverUrl: string, makeException: (exceptionData: any) => OakException, contextBuilder: (str: string | undefined) => (store: AsyncRowStore<ED, BackCxt>) => Promise<BackCxt>);
11
+ constructor(serverUrl: string, makeException: (exceptionData: any) => OakException<ED>, contextBuilder: (str: string | undefined) => (store: AsyncRowStore<ED, BackCxt>) => Promise<BackCxt>);
12
12
  callAspect(name: string, params: any, context: FrontCxt): Promise<{
13
13
  result: any;
14
14
  opRecords: OpRecord<ED>[];
@@ -23,7 +23,7 @@ export declare class SimpleConnector<ED extends EntityDict, BackCxt extends Asyn
23
23
  body: any;
24
24
  headers?: Record<string, any> | undefined;
25
25
  };
26
- serializeException(exception: OakException, headers: IncomingHttpHeaders, body: any): {
26
+ serializeException(exception: OakException<ED>, headers: IncomingHttpHeaders, body: any): {
27
27
  body: any;
28
28
  headers?: Record<string, any> | undefined;
29
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },