oak-domain 2.5.2 → 2.6.2

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.
Files changed (171) hide show
  1. package/lib/actions/action.d.ts +16 -16
  2. package/lib/actions/action.js +17 -17
  3. package/lib/actions/relation.d.ts +5 -5
  4. package/lib/actions/relation.js +38 -38
  5. package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
  6. package/lib/base-app-domain/ActionDefDict.js +9 -9
  7. package/lib/base-app-domain/EntityDict.d.ts +14 -14
  8. package/lib/base-app-domain/EntityDict.js +2 -2
  9. package/lib/base-app-domain/Modi/Action.d.ts +10 -10
  10. package/lib/base-app-domain/Modi/Action.js +14 -14
  11. package/lib/base-app-domain/Modi/Schema.d.ts +146 -146
  12. package/lib/base-app-domain/Modi/Schema.js +2 -2
  13. package/lib/base-app-domain/Modi/Storage.d.ts +3 -3
  14. package/lib/base-app-domain/Modi/Storage.js +60 -60
  15. package/lib/base-app-domain/ModiEntity/Schema.d.ts +189 -189
  16. package/lib/base-app-domain/ModiEntity/Schema.js +2 -2
  17. package/lib/base-app-domain/ModiEntity/Storage.d.ts +3 -3
  18. package/lib/base-app-domain/ModiEntity/Storage.js +27 -27
  19. package/lib/base-app-domain/Oper/Schema.d.ts +144 -144
  20. package/lib/base-app-domain/Oper/Schema.js +2 -2
  21. package/lib/base-app-domain/Oper/Storage.d.ts +3 -3
  22. package/lib/base-app-domain/Oper/Storage.js +29 -29
  23. package/lib/base-app-domain/OperEntity/Schema.d.ts +205 -205
  24. package/lib/base-app-domain/OperEntity/Schema.js +2 -2
  25. package/lib/base-app-domain/OperEntity/Storage.d.ts +3 -3
  26. package/lib/base-app-domain/OperEntity/Storage.js +27 -27
  27. package/lib/base-app-domain/Storage.d.ts +3 -3
  28. package/lib/base-app-domain/Storage.js +17 -17
  29. package/lib/base-app-domain/User/Action.d.ts +10 -10
  30. package/lib/base-app-domain/User/Action.js +12 -12
  31. package/lib/base-app-domain/User/Schema.d.ts +180 -180
  32. package/lib/base-app-domain/User/Schema.js +2 -2
  33. package/lib/base-app-domain/User/Storage.d.ts +3 -3
  34. package/lib/base-app-domain/User/Storage.js +36 -36
  35. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +121 -121
  36. package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -2
  37. package/lib/base-app-domain/UserEntityGrant/Storage.d.ts +3 -3
  38. package/lib/base-app-domain/UserEntityGrant/Storage.js +28 -28
  39. package/lib/base-app-domain/_SubQuery.d.ts +44 -44
  40. package/lib/base-app-domain/_SubQuery.js +2 -2
  41. package/lib/base-app-domain/index.d.ts +3 -3
  42. package/lib/base-app-domain/index.js +6 -6
  43. package/lib/checkers/index.d.ts +5 -5
  44. package/lib/checkers/index.js +16 -16
  45. package/lib/compiler/env.d.ts +11 -11
  46. package/lib/compiler/env.js +39 -39
  47. package/lib/compiler/schemalBuilder.d.ts +2 -2
  48. package/lib/compiler/schemalBuilder.js +3355 -3355
  49. package/lib/compiler/uiBuilder.d.ts +1 -1
  50. package/lib/compiler/uiBuilder.js +3 -3
  51. package/lib/entities/Modi.d.ts +11 -11
  52. package/lib/entities/Modi.js +46 -46
  53. package/lib/entities/ModiEntity.d.ts +8 -8
  54. package/lib/entities/ModiEntity.js +15 -15
  55. package/lib/entities/Oper.d.ts +10 -10
  56. package/lib/entities/Oper.js +17 -17
  57. package/lib/entities/OperEntity.d.ts +8 -8
  58. package/lib/entities/OperEntity.js +15 -15
  59. package/lib/entities/User.d.ts +8 -8
  60. package/lib/entities/User.js +28 -28
  61. package/lib/entities/UserEntityGrant.d.ts +7 -7
  62. package/lib/entities/UserEntityGrant.js +12 -12
  63. package/lib/store/AsyncRowStore.d.ts +51 -48
  64. package/lib/store/AsyncRowStore.js +189 -183
  65. package/lib/store/CascadeStore.d.ts +91 -91
  66. package/lib/store/CascadeStore.js +1634 -1603
  67. package/lib/store/SyncRowStore.d.ts +29 -29
  68. package/lib/store/SyncRowStore.js +48 -48
  69. package/lib/store/TriggerExecutor.d.ts +32 -32
  70. package/lib/store/TriggerExecutor.js +532 -532
  71. package/lib/store/actionDef.d.ts +9 -9
  72. package/lib/store/actionDef.js +333 -333
  73. package/lib/store/checker.d.ts +26 -26
  74. package/lib/store/checker.js +829 -867
  75. package/lib/store/filter.d.ts +109 -109
  76. package/lib/store/filter.js +893 -893
  77. package/lib/store/modi.d.ts +13 -13
  78. package/lib/store/modi.js +216 -216
  79. package/lib/store/relation.d.ts +13 -13
  80. package/lib/store/relation.js +66 -66
  81. package/lib/store/selection.d.ts +19 -7
  82. package/lib/store/selection.js +265 -238
  83. package/lib/triggers/index.d.ts +6 -6
  84. package/lib/triggers/index.js +11 -11
  85. package/lib/triggers/modi.d.ts +5 -5
  86. package/lib/triggers/modi.js +72 -72
  87. package/lib/types/Action.d.ts +20 -20
  88. package/lib/types/Action.js +2 -2
  89. package/lib/types/AppLoader.d.ts +11 -11
  90. package/lib/types/AppLoader.js +10 -10
  91. package/lib/types/Aspect.d.ts +13 -12
  92. package/lib/types/Aspect.js +4 -4
  93. package/lib/types/Auth.d.ts +69 -69
  94. package/lib/types/Auth.js +2 -2
  95. package/lib/types/Connector.d.ts +27 -26
  96. package/lib/types/Connector.js +9 -9
  97. package/lib/types/Context.d.ts +7 -7
  98. package/lib/types/Context.js +3 -3
  99. package/lib/types/DataType.d.ts +18 -18
  100. package/lib/types/DataType.js +5 -5
  101. package/lib/types/Demand.d.ts +77 -77
  102. package/lib/types/Demand.js +9 -9
  103. package/lib/types/Endpoint.d.ts +11 -11
  104. package/lib/types/Endpoint.js +3 -3
  105. package/lib/types/Entity.d.ts +183 -183
  106. package/lib/types/Entity.js +14 -14
  107. package/lib/types/Exception.d.ts +100 -98
  108. package/lib/types/Exception.js +327 -283
  109. package/lib/types/Expression.d.ts +163 -163
  110. package/lib/types/Expression.js +427 -427
  111. package/lib/types/Geo.d.ts +18 -18
  112. package/lib/types/Geo.js +2 -2
  113. package/lib/types/Locale.d.ts +24 -24
  114. package/lib/types/Locale.js +2 -2
  115. package/lib/types/Logger.d.ts +5 -5
  116. package/lib/types/Logger.js +3 -3
  117. package/lib/types/Polyfill.d.ts +23 -23
  118. package/lib/types/Polyfill.js +2 -2
  119. package/lib/types/Port.d.ts +17 -17
  120. package/lib/types/Port.js +2 -2
  121. package/lib/types/RowStore.d.ts +12 -12
  122. package/lib/types/RowStore.js +34 -34
  123. package/lib/types/Storage.d.ts +56 -56
  124. package/lib/types/Storage.js +2 -2
  125. package/lib/types/Timer.d.ts +13 -13
  126. package/lib/types/Timer.js +2 -2
  127. package/lib/types/Trigger.d.ts +109 -109
  128. package/lib/types/Trigger.js +49 -49
  129. package/lib/types/Txn.d.ts +2 -2
  130. package/lib/types/Txn.js +3 -3
  131. package/lib/types/Watcher.d.ts +19 -19
  132. package/lib/types/Watcher.js +4 -4
  133. package/lib/types/index.d.ts +21 -21
  134. package/lib/types/index.js +24 -24
  135. package/lib/types/schema/DataTypes.d.ts +32 -32
  136. package/lib/types/schema/DataTypes.js +3 -3
  137. package/lib/utils/SimpleConnector.d.ts +35 -30
  138. package/lib/utils/SimpleConnector.js +134 -117
  139. package/lib/utils/assert.d.ts +5 -5
  140. package/lib/utils/assert.js +9 -9
  141. package/lib/utils/concurrent.d.ts +15 -15
  142. package/lib/utils/concurrent.js +89 -89
  143. package/lib/utils/cron.d.ts +1 -1
  144. package/lib/utils/cron.js +18 -18
  145. package/lib/utils/date.d.ts +1 -1
  146. package/lib/utils/date.js +18 -18
  147. package/lib/utils/geo.d.ts +4 -4
  148. package/lib/utils/geo.js +24 -24
  149. package/lib/utils/lodash.d.ts +20 -20
  150. package/lib/utils/lodash.js +55 -55
  151. package/lib/utils/random/random.d.ts +1 -1
  152. package/lib/utils/random/random.js +24 -24
  153. package/lib/utils/random/random.mp.d.ts +1 -1
  154. package/lib/utils/random/random.mp.js +25 -25
  155. package/lib/utils/random/random.web.d.ts +1 -1
  156. package/lib/utils/random/random.web.js +17 -17
  157. package/lib/utils/string.d.ts +22 -22
  158. package/lib/utils/string.js +70 -70
  159. package/lib/utils/url.d.ts +1 -0
  160. package/lib/utils/url.js +12 -0
  161. package/lib/utils/uuid.d.ts +12 -12
  162. package/lib/utils/uuid.js +194 -194
  163. package/lib/utils/validator.d.ts +23 -23
  164. package/lib/utils/validator.js +123 -123
  165. package/package.json +48 -48
  166. package/src/entities/Modi.ts +68 -68
  167. package/src/entities/ModiEntity.ts +24 -24
  168. package/src/entities/Oper.ts +28 -28
  169. package/src/entities/OperEntity.ts +24 -24
  170. package/src/entities/User.ts +44 -44
  171. package/src/entities/UserEntityGrant.ts +24 -24
@@ -1,283 +1,327 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- var tslib_1 = require("tslib");
5
- var OakException = /** @class */ (function (_super) {
6
- tslib_1.__extends(OakException, _super);
7
- function OakException(message) {
8
- var _newTarget = this.constructor;
9
- var _this = _super.call(this, message) || this;
10
- _this.name = _newTarget.name;
11
- if (typeof Error.captureStackTrace === 'function') {
12
- Error.captureStackTrace(_this, _newTarget);
13
- }
14
- if (typeof Object.setPrototypeOf === 'function') {
15
- Object.setPrototypeOf(_this, _newTarget.prototype);
16
- }
17
- else {
18
- _this.__proto__ = _newTarget.prototype;
19
- }
20
- return _this;
21
- }
22
- OakException.prototype.toString = function () {
23
- return JSON.stringify({
24
- name: this.constructor.name,
25
- message: this.message,
26
- });
27
- };
28
- return OakException;
29
- }(Error));
30
- exports.OakException = OakException;
31
- var OakDataException = /** @class */ (function (_super) {
32
- tslib_1.__extends(OakDataException, _super);
33
- function OakDataException() {
34
- return _super !== null && _super.apply(this, arguments) || this;
35
- }
36
- return OakDataException;
37
- }(OakException));
38
- exports.OakDataException = OakDataException;
39
- var OakUniqueViolationException = /** @class */ (function (_super) {
40
- tslib_1.__extends(OakUniqueViolationException, _super);
41
- function OakUniqueViolationException(rows, message) {
42
- var _this = _super.call(this, message || '您更新的数据违反了唯一性约束') || this;
43
- _this.rows = rows;
44
- return _this;
45
- }
46
- return OakUniqueViolationException;
47
- }(OakException));
48
- exports.OakUniqueViolationException = OakUniqueViolationException;
49
- var OakImportDataParseException = /** @class */ (function (_super) {
50
- tslib_1.__extends(OakImportDataParseException, _super);
51
- // message必传,描述具体错误的数据内容
52
- function OakImportDataParseException(message, line, header) {
53
- var _this = _super.call(this, message) || this;
54
- _this.line = line;
55
- _this.header = header;
56
- return _this;
57
- }
58
- return OakImportDataParseException;
59
- }(OakException));
60
- exports.OakImportDataParseException = OakImportDataParseException;
61
- var OakOperExistedException = /** @class */ (function (_super) {
62
- tslib_1.__extends(OakOperExistedException, _super);
63
- function OakOperExistedException() {
64
- return _super !== null && _super.apply(this, arguments) || this;
65
- }
66
- return OakOperExistedException;
67
- }(OakDataException));
68
- exports.OakOperExistedException = OakOperExistedException;
69
- var OakRowUnexistedException = /** @class */ (function (_super) {
70
- tslib_1.__extends(OakRowUnexistedException, _super);
71
- // 指定主键查询时却发现行不存在,一般发生在缓存中
72
- function OakRowUnexistedException(rows) {
73
- var _this = _super.call(this, "\u67E5\u8BE2".concat(rows.map(function (ele) { return ele.entity; }).join(','), "\u5BF9\u8C61\u65F6\u53D1\u73B0\u4E86\u7A7A\u6307\u9488\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u4E00\u81F4\u6027")) || this;
74
- _this.rows = rows;
75
- return _this;
76
- }
77
- OakRowUnexistedException.prototype.toString = function () {
78
- return JSON.stringify({ rows: this.rows });
79
- };
80
- OakRowUnexistedException.prototype.getRows = function () {
81
- return this.rows;
82
- };
83
- return OakRowUnexistedException;
84
- }(OakDataException));
85
- exports.OakRowUnexistedException = OakRowUnexistedException;
86
- var OakExternalException = /** @class */ (function (_super) {
87
- tslib_1.__extends(OakExternalException, _super);
88
- function OakExternalException() {
89
- return _super !== null && _super.apply(this, arguments) || this;
90
- }
91
- return OakExternalException;
92
- }(Error));
93
- exports.OakExternalException = OakExternalException;
94
- var OakUserException = /** @class */ (function (_super) {
95
- tslib_1.__extends(OakUserException, _super);
96
- function OakUserException() {
97
- return _super !== null && _super.apply(this, arguments) || this;
98
- }
99
- return OakUserException;
100
- }(OakException));
101
- exports.OakUserException = OakUserException;
102
- ;
103
- // 在系统更新数据时,以下三个异常应按规范依次抛出。
104
- /**
105
- * 数据不一致异常,系统认为现有的数据不允许相应的动作时抛此异常
106
- *
107
- */
108
- var OakRowInconsistencyException = /** @class */ (function (_super) {
109
- tslib_1.__extends(OakRowInconsistencyException, _super);
110
- function OakRowInconsistencyException(data, message) {
111
- var _this = _super.call(this, message) || this;
112
- _this.data = data;
113
- return _this;
114
- }
115
- OakRowInconsistencyException.prototype.getData = function () {
116
- return this.data;
117
- };
118
- OakRowInconsistencyException.prototype.toString = function () {
119
- return JSON.stringify({
120
- name: this.constructor.name,
121
- message: this.message,
122
- data: this.data,
123
- });
124
- };
125
- return OakRowInconsistencyException;
126
- }(OakUserException));
127
- exports.OakRowInconsistencyException = OakRowInconsistencyException;
128
- ;
129
- /**
130
- * 当输入的数据非法时抛此异常,attributes表示非法的属性
131
- */
132
- var OakInputIllegalException = /** @class */ (function (_super) {
133
- tslib_1.__extends(OakInputIllegalException, _super);
134
- function OakInputIllegalException(entity, attributes, message) {
135
- var _this = _super.call(this, message) || this;
136
- _this.entity = entity;
137
- _this.attributes = attributes;
138
- return _this;
139
- }
140
- OakInputIllegalException.prototype.getEntity = function () {
141
- return this.entity;
142
- };
143
- OakInputIllegalException.prototype.getAttributes = function () {
144
- return this.attributes;
145
- };
146
- OakInputIllegalException.prototype.addAttributesPrefix = function (prefix) {
147
- this.attributes = this.attributes.map(function (ele) { return "".concat(prefix, ".").concat(ele); });
148
- };
149
- OakInputIllegalException.prototype.toString = function () {
150
- return JSON.stringify({
151
- entity: this.entity,
152
- name: this.constructor.name,
153
- message: this.message,
154
- attributes: this.attributes,
155
- });
156
- };
157
- return OakInputIllegalException;
158
- }(OakUserException));
159
- exports.OakInputIllegalException = OakInputIllegalException;
160
- ;
161
- /**
162
- * 用户权限不够时抛的异常
163
- */
164
- var OakUserUnpermittedException = /** @class */ (function (_super) {
165
- tslib_1.__extends(OakUserUnpermittedException, _super);
166
- function OakUserUnpermittedException() {
167
- return _super !== null && _super.apply(this, arguments) || this;
168
- }
169
- return OakUserUnpermittedException;
170
- }(OakUserException));
171
- exports.OakUserUnpermittedException = OakUserUnpermittedException;
172
- ;
173
- /**
174
- * 用户未登录抛的异常
175
- */
176
- var OakUnloggedInException = /** @class */ (function (_super) {
177
- tslib_1.__extends(OakUnloggedInException, _super);
178
- function OakUnloggedInException(message) {
179
- return _super.call(this, message || '您尚未登录') || this;
180
- }
181
- return OakUnloggedInException;
182
- }(OakUserException));
183
- exports.OakUnloggedInException = OakUnloggedInException;
184
- ;
185
- /**
186
- * 用户未登录抛的异常
187
- */
188
- var OakRowLockedException = /** @class */ (function (_super) {
189
- tslib_1.__extends(OakRowLockedException, _super);
190
- function OakRowLockedException(message) {
191
- return _super.call(this, message || '该行数据正在被更新中,请稍后再试') || this;
192
- }
193
- return OakRowLockedException;
194
- }(OakUserException));
195
- exports.OakRowLockedException = OakRowLockedException;
196
- ;
197
- /**
198
- * 要插入行时,发现已经有相同的行数据
199
- */
200
- var OakCongruentRowExists = /** @class */ (function (_super) {
201
- tslib_1.__extends(OakCongruentRowExists, _super);
202
- function OakCongruentRowExists(entity, data, message) {
203
- var _this = _super.call(this, message) || this;
204
- _this.data = data;
205
- _this.entity = entity;
206
- return _this;
207
- }
208
- OakCongruentRowExists.prototype.getData = function () {
209
- return this.data;
210
- };
211
- OakCongruentRowExists.prototype.getEntity = function () {
212
- return this.entity;
213
- };
214
- OakCongruentRowExists.prototype.toString = function () {
215
- return JSON.stringify({
216
- name: this.constructor.name,
217
- message: this.message,
218
- data: this.data,
219
- entity: this.entity,
220
- });
221
- };
222
- return OakCongruentRowExists;
223
- }(OakUserException));
224
- exports.OakCongruentRowExists = OakCongruentRowExists;
225
- var OakDeadlock = /** @class */ (function (_super) {
226
- tslib_1.__extends(OakDeadlock, _super);
227
- function OakDeadlock(message) {
228
- return _super.call(this, message || '发现死锁') || this;
229
- }
230
- return OakDeadlock;
231
- }(OakUserException));
232
- exports.OakDeadlock = OakDeadlock;
233
- ;
234
- function makeException(data) {
235
- var name = data.name;
236
- switch (name) {
237
- case 'OakException': {
238
- return new OakException(data.message);
239
- }
240
- case 'OakUserException': {
241
- return new OakUserException(data.message);
242
- }
243
- case 'OakExternalException': {
244
- return new OakExternalException(data.message);
245
- }
246
- case 'OakRowInconsistencyException': {
247
- return new OakRowInconsistencyException(data.data, data.message);
248
- }
249
- case 'OakInputIllegalException': {
250
- return new OakInputIllegalException(data.entity, data.attributes, data.message);
251
- }
252
- case 'OakUserUnpermittedException': {
253
- return new OakUserUnpermittedException(data.message);
254
- }
255
- case 'OakUnloggedInException': {
256
- return new OakUnloggedInException(data.message);
257
- }
258
- case 'OakCongruentRowExists': {
259
- return new OakCongruentRowExists(data.entity, data.data, data.message);
260
- }
261
- case 'OakRowLockedException': {
262
- return new OakRowLockedException(data.message);
263
- }
264
- case 'OakRowUnexistedException': {
265
- return new OakRowUnexistedException(data.rows);
266
- }
267
- case 'OakDeadlock': {
268
- return new OakDeadlock(data.message);
269
- }
270
- case 'OakDataException': {
271
- return new OakDataException(data.message);
272
- }
273
- case 'OakUniqueViolationException': {
274
- return new OakUniqueViolationException(data.rows, data.message);
275
- }
276
- case 'OakImportDataParseException': {
277
- return new OakImportDataParseException(data.message, data.line, data.header);
278
- }
279
- default:
280
- return;
281
- }
282
- }
283
- exports.makeException = makeException;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ var tslib_1 = require("tslib");
5
+ var assert_1 = tslib_1.__importDefault(require("assert"));
6
+ var OakException = /** @class */ (function (_super) {
7
+ tslib_1.__extends(OakException, _super);
8
+ function OakException(message) {
9
+ var _newTarget = this.constructor;
10
+ var _this = _super.call(this, message) || this;
11
+ _this.name = _newTarget.name;
12
+ if (typeof Error.captureStackTrace === 'function') {
13
+ Error.captureStackTrace(_this, _newTarget);
14
+ }
15
+ if (typeof Object.setPrototypeOf === 'function') {
16
+ Object.setPrototypeOf(_this, _newTarget.prototype);
17
+ }
18
+ else {
19
+ _this.__proto__ = _newTarget.prototype;
20
+ }
21
+ _this.opRecord = {
22
+ a: 's',
23
+ d: {},
24
+ };
25
+ return _this;
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
+ };
46
+ OakException.prototype.toString = function () {
47
+ return JSON.stringify({
48
+ name: this.constructor.name,
49
+ message: this.message,
50
+ opRecord: this.opRecord,
51
+ });
52
+ };
53
+ return OakException;
54
+ }(Error));
55
+ exports.OakException = OakException;
56
+ var OakDataException = /** @class */ (function (_super) {
57
+ tslib_1.__extends(OakDataException, _super);
58
+ function OakDataException() {
59
+ return _super !== null && _super.apply(this, arguments) || this;
60
+ }
61
+ return OakDataException;
62
+ }(OakException));
63
+ exports.OakDataException = OakDataException;
64
+ var OakUniqueViolationException = /** @class */ (function (_super) {
65
+ tslib_1.__extends(OakUniqueViolationException, _super);
66
+ function OakUniqueViolationException(rows, message) {
67
+ var _this = _super.call(this, message || '您更新的数据违反了唯一性约束') || this;
68
+ _this.rows = rows;
69
+ return _this;
70
+ }
71
+ return OakUniqueViolationException;
72
+ }(OakException));
73
+ exports.OakUniqueViolationException = OakUniqueViolationException;
74
+ var OakImportDataParseException = /** @class */ (function (_super) {
75
+ tslib_1.__extends(OakImportDataParseException, _super);
76
+ // message必传,描述具体错误的数据内容
77
+ function OakImportDataParseException(message, line, header) {
78
+ var _this = _super.call(this, message) || this;
79
+ _this.line = line;
80
+ _this.header = header;
81
+ return _this;
82
+ }
83
+ return OakImportDataParseException;
84
+ }(OakException));
85
+ exports.OakImportDataParseException = OakImportDataParseException;
86
+ var OakOperExistedException = /** @class */ (function (_super) {
87
+ tslib_1.__extends(OakOperExistedException, _super);
88
+ function OakOperExistedException() {
89
+ return _super !== null && _super.apply(this, arguments) || this;
90
+ }
91
+ return OakOperExistedException;
92
+ }(OakDataException));
93
+ exports.OakOperExistedException = OakOperExistedException;
94
+ var OakRowUnexistedException = /** @class */ (function (_super) {
95
+ tslib_1.__extends(OakRowUnexistedException, _super);
96
+ // 指定主键查询时却发现行不存在,一般发生在缓存中
97
+ function OakRowUnexistedException(rows) {
98
+ var _this = _super.call(this, "\u67E5\u8BE2".concat(rows.map(function (ele) { return ele.entity; }).join(','), "\u5BF9\u8C61\u65F6\u53D1\u73B0\u4E86\u7A7A\u6307\u9488\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u4E00\u81F4\u6027")) || this;
99
+ _this.rows = rows;
100
+ return _this;
101
+ }
102
+ OakRowUnexistedException.prototype.toString = function () {
103
+ return JSON.stringify({ rows: this.rows });
104
+ };
105
+ OakRowUnexistedException.prototype.getRows = function () {
106
+ return this.rows;
107
+ };
108
+ return OakRowUnexistedException;
109
+ }(OakDataException));
110
+ exports.OakRowUnexistedException = OakRowUnexistedException;
111
+ var OakExternalException = /** @class */ (function (_super) {
112
+ tslib_1.__extends(OakExternalException, _super);
113
+ function OakExternalException() {
114
+ return _super !== null && _super.apply(this, arguments) || this;
115
+ }
116
+ return OakExternalException;
117
+ }(Error));
118
+ exports.OakExternalException = OakExternalException;
119
+ var OakUserException = /** @class */ (function (_super) {
120
+ tslib_1.__extends(OakUserException, _super);
121
+ function OakUserException() {
122
+ return _super !== null && _super.apply(this, arguments) || this;
123
+ }
124
+ return OakUserException;
125
+ }(OakException));
126
+ exports.OakUserException = OakUserException;
127
+ ;
128
+ // 在系统更新数据时,以下三个异常应按规范依次抛出。
129
+ /**
130
+ * 数据不一致异常,系统认为现有的数据不允许相应的动作时抛此异常
131
+ *
132
+ */
133
+ var OakRowInconsistencyException = /** @class */ (function (_super) {
134
+ tslib_1.__extends(OakRowInconsistencyException, _super);
135
+ function OakRowInconsistencyException(data, message) {
136
+ var _this = _super.call(this, message) || this;
137
+ (0, assert_1.default)(!data, '现在使用addData接口来传数据');
138
+ return _this;
139
+ }
140
+ OakRowInconsistencyException.prototype.toString = function () {
141
+ return JSON.stringify({
142
+ name: this.constructor.name,
143
+ message: this.message,
144
+ });
145
+ };
146
+ return OakRowInconsistencyException;
147
+ }(OakUserException));
148
+ exports.OakRowInconsistencyException = OakRowInconsistencyException;
149
+ ;
150
+ /**
151
+ * 当输入的数据非法时抛此异常,attributes表示非法的属性
152
+ */
153
+ var OakInputIllegalException = /** @class */ (function (_super) {
154
+ tslib_1.__extends(OakInputIllegalException, _super);
155
+ function OakInputIllegalException(entity, attributes, message) {
156
+ var _this = _super.call(this, message) || this;
157
+ _this.entity = entity;
158
+ _this.attributes = attributes;
159
+ return _this;
160
+ }
161
+ OakInputIllegalException.prototype.getEntity = function () {
162
+ return this.entity;
163
+ };
164
+ OakInputIllegalException.prototype.getAttributes = function () {
165
+ return this.attributes;
166
+ };
167
+ OakInputIllegalException.prototype.addAttributesPrefix = function (prefix) {
168
+ this.attributes = this.attributes.map(function (ele) { return "".concat(prefix, ".").concat(ele); });
169
+ };
170
+ OakInputIllegalException.prototype.toString = function () {
171
+ return JSON.stringify({
172
+ entity: this.entity,
173
+ name: this.constructor.name,
174
+ message: this.message,
175
+ attributes: this.attributes,
176
+ });
177
+ };
178
+ return OakInputIllegalException;
179
+ }(OakUserException));
180
+ exports.OakInputIllegalException = OakInputIllegalException;
181
+ ;
182
+ /**
183
+ * 用户权限不够时抛的异常
184
+ */
185
+ var OakUserUnpermittedException = /** @class */ (function (_super) {
186
+ tslib_1.__extends(OakUserUnpermittedException, _super);
187
+ function OakUserUnpermittedException() {
188
+ return _super !== null && _super.apply(this, arguments) || this;
189
+ }
190
+ return OakUserUnpermittedException;
191
+ }(OakUserException));
192
+ exports.OakUserUnpermittedException = OakUserUnpermittedException;
193
+ ;
194
+ /**
195
+ * 用户未登录抛的异常
196
+ */
197
+ var OakUnloggedInException = /** @class */ (function (_super) {
198
+ tslib_1.__extends(OakUnloggedInException, _super);
199
+ function OakUnloggedInException(message) {
200
+ return _super.call(this, message || '您尚未登录') || this;
201
+ }
202
+ return OakUnloggedInException;
203
+ }(OakUserException));
204
+ exports.OakUnloggedInException = OakUnloggedInException;
205
+ ;
206
+ /**
207
+ * 用户未登录抛的异常
208
+ */
209
+ var OakRowLockedException = /** @class */ (function (_super) {
210
+ tslib_1.__extends(OakRowLockedException, _super);
211
+ function OakRowLockedException(message) {
212
+ return _super.call(this, message || '该行数据正在被更新中,请稍后再试') || this;
213
+ }
214
+ return OakRowLockedException;
215
+ }(OakUserException));
216
+ exports.OakRowLockedException = OakRowLockedException;
217
+ ;
218
+ /**
219
+ * 要插入行时,发现已经有相同的行数据
220
+ */
221
+ var OakCongruentRowExists = /** @class */ (function (_super) {
222
+ tslib_1.__extends(OakCongruentRowExists, _super);
223
+ function OakCongruentRowExists(entity, data, message) {
224
+ var _this = _super.call(this, message) || this;
225
+ _this.data = data;
226
+ _this.entity = entity;
227
+ return _this;
228
+ }
229
+ OakCongruentRowExists.prototype.getData = function () {
230
+ return this.data;
231
+ };
232
+ OakCongruentRowExists.prototype.getEntity = function () {
233
+ return this.entity;
234
+ };
235
+ OakCongruentRowExists.prototype.toString = function () {
236
+ return JSON.stringify({
237
+ name: this.constructor.name,
238
+ message: this.message,
239
+ data: this.data,
240
+ entity: this.entity,
241
+ });
242
+ };
243
+ return OakCongruentRowExists;
244
+ }(OakUserException));
245
+ exports.OakCongruentRowExists = OakCongruentRowExists;
246
+ var OakDeadlock = /** @class */ (function (_super) {
247
+ tslib_1.__extends(OakDeadlock, _super);
248
+ function OakDeadlock(message) {
249
+ return _super.call(this, message || '发现死锁') || this;
250
+ }
251
+ return OakDeadlock;
252
+ }(OakUserException));
253
+ exports.OakDeadlock = OakDeadlock;
254
+ ;
255
+ function makeException(data) {
256
+ var name = data.name;
257
+ switch (name) {
258
+ case 'OakException': {
259
+ var e = new OakException(data.message);
260
+ e.setOpRecords(data.opRecords);
261
+ return e;
262
+ }
263
+ case 'OakUserException': {
264
+ var e = new OakUserException(data.message);
265
+ e.setOpRecords(data.opRecords);
266
+ return e;
267
+ }
268
+ case 'OakRowInconsistencyException': {
269
+ var e = new OakRowInconsistencyException(data.data, data.message);
270
+ e.setOpRecords(data.opRecords);
271
+ return e;
272
+ }
273
+ case 'OakInputIllegalException': {
274
+ var e = new OakInputIllegalException(data.entity, data.attributes, data.message);
275
+ e.setOpRecords(data.opRecords);
276
+ return e;
277
+ }
278
+ case 'OakUserUnpermittedException': {
279
+ var e = new OakUserUnpermittedException(data.message);
280
+ e.setOpRecords(data.opRecords);
281
+ return e;
282
+ }
283
+ case 'OakUnloggedInException': {
284
+ var e = new OakUnloggedInException(data.message);
285
+ e.setOpRecords(data.opRecords);
286
+ return e;
287
+ }
288
+ case 'OakCongruentRowExists': {
289
+ var e = new OakCongruentRowExists(data.entity, data.data, data.message);
290
+ e.setOpRecords(data.opRecords);
291
+ return e;
292
+ }
293
+ case 'OakRowLockedException': {
294
+ var e = new OakRowLockedException(data.message);
295
+ e.setOpRecords(data.opRecords);
296
+ return e;
297
+ }
298
+ case 'OakRowUnexistedException': {
299
+ var e = new OakRowUnexistedException(data.rows);
300
+ e.setOpRecords(data.opRecords);
301
+ return e;
302
+ }
303
+ case 'OakDeadlock': {
304
+ var e = new OakDeadlock(data.message);
305
+ e.setOpRecords(data.opRecords);
306
+ return e;
307
+ }
308
+ case 'OakDataException': {
309
+ var e = new OakDataException(data.message);
310
+ e.setOpRecords(data.opRecords);
311
+ return e;
312
+ }
313
+ case 'OakUniqueViolationException': {
314
+ var e = new OakUniqueViolationException(data.rows, data.message);
315
+ e.setOpRecords(data.opRecords);
316
+ return e;
317
+ }
318
+ case 'OakImportDataParseException': {
319
+ var e = new OakImportDataParseException(data.message, data.line, data.header);
320
+ e.setOpRecords(data.opRecords);
321
+ return e;
322
+ }
323
+ default:
324
+ return;
325
+ }
326
+ }
327
+ exports.makeException = makeException;