@steedos/objectql 2.1.82 → 2.1.86

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 (261) hide show
  1. package/lib/actions/field_updates.js +15 -15
  2. package/lib/actions/field_updates.js.map +1 -1
  3. package/lib/actions/index.js +3 -3
  4. package/lib/actions/index.js.map +1 -1
  5. package/lib/actions/workflow_notifications.js +10 -10
  6. package/lib/actions/workflow_notifications.js.map +1 -1
  7. package/lib/actions/workflow_rule.js +19 -19
  8. package/lib/actions/workflow_rule.js.map +1 -1
  9. package/lib/driver/index.js +1 -0
  10. package/lib/driver/index.js.map +1 -1
  11. package/lib/driver/metadata.js +3 -3
  12. package/lib/driver/metadata.js.map +1 -1
  13. package/lib/driver/meteorMongo.js +36 -36
  14. package/lib/driver/meteorMongo.js.map +1 -1
  15. package/lib/driver/mongo.js +43 -43
  16. package/lib/driver/mongo.js.map +1 -1
  17. package/lib/driver/mysql.js +2 -2
  18. package/lib/driver/mysql.js.map +1 -1
  19. package/lib/driver/oracle.js +5 -5
  20. package/lib/driver/oracle.js.map +1 -1
  21. package/lib/driver/postgres.js +2 -2
  22. package/lib/driver/postgres.js.map +1 -1
  23. package/lib/driver/sqlite3.js +2 -2
  24. package/lib/driver/sqlite3.js.map +1 -1
  25. package/lib/driver/sqlserver.js +4 -4
  26. package/lib/driver/sqlserver.js.map +1 -1
  27. package/lib/dynamic-load/actions.js +22 -18
  28. package/lib/dynamic-load/actions.js.map +1 -1
  29. package/lib/dynamic-load/approval_process.js +15 -10
  30. package/lib/dynamic-load/approval_process.js.map +1 -1
  31. package/lib/dynamic-load/button.js +25 -18
  32. package/lib/dynamic-load/button.js.map +1 -1
  33. package/lib/dynamic-load/chart.js +20 -23
  34. package/lib/dynamic-load/chart.js.map +1 -1
  35. package/lib/dynamic-load/field.js +21 -16
  36. package/lib/dynamic-load/field.js.map +1 -1
  37. package/lib/dynamic-load/flow_role.js +12 -8
  38. package/lib/dynamic-load/flow_role.js.map +1 -1
  39. package/lib/dynamic-load/index.d.ts +1 -0
  40. package/lib/dynamic-load/index.js +20 -19
  41. package/lib/dynamic-load/index.js.map +1 -1
  42. package/lib/dynamic-load/layout.js +19 -14
  43. package/lib/dynamic-load/layout.js.map +1 -1
  44. package/lib/dynamic-load/listview.js +14 -11
  45. package/lib/dynamic-load/listview.js.map +1 -1
  46. package/lib/dynamic-load/method.js +9 -6
  47. package/lib/dynamic-load/method.js.map +1 -1
  48. package/lib/dynamic-load/object_translations.js +29 -51
  49. package/lib/dynamic-load/object_translations.js.map +1 -1
  50. package/lib/dynamic-load/originalObject.js +1 -1
  51. package/lib/dynamic-load/originalObject.js.map +1 -1
  52. package/lib/dynamic-load/package.d.ts +9 -0
  53. package/lib/dynamic-load/package.js +507 -0
  54. package/lib/dynamic-load/package.js.map +1 -0
  55. package/lib/dynamic-load/page.js +20 -23
  56. package/lib/dynamic-load/page.js.map +1 -1
  57. package/lib/dynamic-load/permission.js +61 -65
  58. package/lib/dynamic-load/permission.js.map +1 -1
  59. package/lib/dynamic-load/permissionset.js +30 -25
  60. package/lib/dynamic-load/permissionset.js.map +1 -1
  61. package/lib/dynamic-load/preload_data.js +55 -74
  62. package/lib/dynamic-load/preload_data.js.map +1 -1
  63. package/lib/dynamic-load/profile.js +33 -28
  64. package/lib/dynamic-load/profile.js.map +1 -1
  65. package/lib/dynamic-load/query.js +20 -23
  66. package/lib/dynamic-load/query.js.map +1 -1
  67. package/lib/dynamic-load/restrictionRules.js +18 -23
  68. package/lib/dynamic-load/restrictionRules.js.map +1 -1
  69. package/lib/dynamic-load/role.js +12 -8
  70. package/lib/dynamic-load/role.js.map +1 -1
  71. package/lib/dynamic-load/shareRules.js +18 -23
  72. package/lib/dynamic-load/shareRules.js.map +1 -1
  73. package/lib/dynamic-load/tab.js +4 -3
  74. package/lib/dynamic-load/tab.js.map +1 -1
  75. package/lib/dynamic-load/tabs.js +9 -7
  76. package/lib/dynamic-load/tabs.js.map +1 -1
  77. package/lib/dynamic-load/translations.js +23 -17
  78. package/lib/dynamic-load/translations.js.map +1 -1
  79. package/lib/dynamic-load/trigger.js +14 -10
  80. package/lib/dynamic-load/trigger.js.map +1 -1
  81. package/lib/dynamic-load/validation_rule.js +13 -8
  82. package/lib/dynamic-load/validation_rule.js.map +1 -1
  83. package/lib/dynamic-load/workflow.js +38 -25
  84. package/lib/dynamic-load/workflow.js.map +1 -1
  85. package/lib/errors/index.js +2 -1
  86. package/lib/errors/index.js.map +1 -1
  87. package/lib/formula/core.js +105 -91
  88. package/lib/formula/core.js.map +1 -1
  89. package/lib/formula/field_formula.js +26 -20
  90. package/lib/formula/field_formula.js.map +1 -1
  91. package/lib/formula/index.js +26 -26
  92. package/lib/formula/index.js.map +1 -1
  93. package/lib/formula/params.js +1 -1
  94. package/lib/formula/params.js.map +1 -1
  95. package/lib/formula/recompute.js +27 -25
  96. package/lib/formula/recompute.js.map +1 -1
  97. package/lib/formula/simple_params.js +2 -2
  98. package/lib/formula/simple_params.js.map +1 -1
  99. package/lib/formula/util.js +33 -23
  100. package/lib/formula/util.js.map +1 -1
  101. package/lib/index.js +15 -15
  102. package/lib/index.js.map +1 -1
  103. package/lib/metadata-register/_base.d.ts +1 -0
  104. package/lib/metadata-register/_base.js +45 -15
  105. package/lib/metadata-register/_base.js.map +1 -1
  106. package/lib/metadata-register/app.js +8 -8
  107. package/lib/metadata-register/chart.js +1 -1
  108. package/lib/metadata-register/chart.js.map +1 -1
  109. package/lib/metadata-register/index.js +72 -72
  110. package/lib/metadata-register/index.js.map +1 -1
  111. package/lib/metadata-register/layout.js +18 -16
  112. package/lib/metadata-register/layout.js.map +1 -1
  113. package/lib/metadata-register/object.d.ts +0 -1
  114. package/lib/metadata-register/object.js +17 -35
  115. package/lib/metadata-register/object.js.map +1 -1
  116. package/lib/metadata-register/page.js +1 -1
  117. package/lib/metadata-register/page.js.map +1 -1
  118. package/lib/metadata-register/permissionFields.js +2 -2
  119. package/lib/metadata-register/permissionFields.js.map +1 -1
  120. package/lib/metadata-register/permissionset.js +6 -6
  121. package/lib/metadata-register/profile.js +6 -6
  122. package/lib/metadata-register/query.js +1 -1
  123. package/lib/metadata-register/query.js.map +1 -1
  124. package/lib/metadata-register/restrictionRules.js +2 -2
  125. package/lib/metadata-register/restrictionRules.js.map +1 -1
  126. package/lib/metadata-register/shareRules.js +2 -2
  127. package/lib/metadata-register/shareRules.js.map +1 -1
  128. package/lib/metadata-register/tab.js +1 -1
  129. package/lib/metadata-register/tab.js.map +1 -1
  130. package/lib/metadata-register/tabs.js +18 -16
  131. package/lib/metadata-register/tabs.js.map +1 -1
  132. package/lib/services/datasourceServiceFactory.d.ts +1 -0
  133. package/lib/services/datasourceServiceFactory.js +51 -0
  134. package/lib/services/datasourceServiceFactory.js.map +1 -0
  135. package/lib/services/helpers/graphql.js +86 -87
  136. package/lib/services/helpers/graphql.js.map +1 -1
  137. package/lib/services/helpers/index.js +2 -2
  138. package/lib/services/helpers/index.js.map +1 -1
  139. package/lib/services/helpers/rest.js +1 -1
  140. package/lib/services/helpers/rest.js.map +1 -1
  141. package/lib/services/index.d.ts +3 -0
  142. package/lib/services/index.js +10 -4
  143. package/lib/services/index.js.map +1 -1
  144. package/lib/services/objectService.js +143 -143
  145. package/lib/services/objectService.js.map +1 -1
  146. package/lib/services/objectServiceDispatcher.js +92 -92
  147. package/lib/services/objectServiceDispatcher.js.map +1 -1
  148. package/lib/{metadata-register/objectServiceManager.d.ts → services/objectServiceFactory.d.ts} +0 -0
  149. package/lib/{metadata-register/objectServiceManager.js → services/objectServiceFactory.js} +5 -5
  150. package/lib/services/objectServiceFactory.js.map +1 -0
  151. package/lib/summary/core.js +51 -44
  152. package/lib/summary/core.js.map +1 -1
  153. package/lib/summary/field_summary.js +21 -16
  154. package/lib/summary/field_summary.js.map +1 -1
  155. package/lib/summary/index.js +25 -22
  156. package/lib/summary/index.js.map +1 -1
  157. package/lib/summary/recompute.js +13 -11
  158. package/lib/summary/recompute.js.map +1 -1
  159. package/lib/ts-types/index.js +3 -3
  160. package/lib/ts-types/index.js.map +1 -1
  161. package/lib/typeorm/driver.js +58 -58
  162. package/lib/typeorm/driver.js.map +1 -1
  163. package/lib/typeorm/index.js +2 -1
  164. package/lib/typeorm/index.js.map +1 -1
  165. package/lib/typeorm/util.js +2 -2
  166. package/lib/typeorm/util.js.map +1 -1
  167. package/lib/types/app.js +41 -35
  168. package/lib/types/app.js.map +1 -1
  169. package/lib/types/config.js +52 -45
  170. package/lib/types/config.js.map +1 -1
  171. package/lib/types/connection.js +20 -18
  172. package/lib/types/connection.js.map +1 -1
  173. package/lib/types/dashboard.js +10 -7
  174. package/lib/types/dashboard.js.map +1 -1
  175. package/lib/types/datasource.d.ts +14 -1
  176. package/lib/types/datasource.js +205 -192
  177. package/lib/types/datasource.js.map +1 -1
  178. package/lib/types/field.d.ts +2 -2
  179. package/lib/types/field.js +6 -6
  180. package/lib/types/field.js.map +1 -1
  181. package/lib/types/field_permission.js +8 -8
  182. package/lib/types/field_permission.js.map +1 -1
  183. package/lib/types/index.js +11 -10
  184. package/lib/types/index.js.map +1 -1
  185. package/lib/types/list_view.d.ts +1 -1
  186. package/lib/types/list_view.js +1 -1
  187. package/lib/types/list_view.js.map +1 -1
  188. package/lib/types/object.d.ts +11 -11
  189. package/lib/types/object.js +208 -201
  190. package/lib/types/object.js.map +1 -1
  191. package/lib/types/object_dynamic_load.js +105 -155
  192. package/lib/types/object_dynamic_load.js.map +1 -1
  193. package/lib/types/object_events.js +5 -5
  194. package/lib/types/object_events.js.map +1 -1
  195. package/lib/types/object_layouts.js +7 -7
  196. package/lib/types/object_layouts.js.map +1 -1
  197. package/lib/types/object_permission.d.ts +1 -1
  198. package/lib/types/object_permission.js +1 -1
  199. package/lib/types/object_permission.js.map +1 -1
  200. package/lib/types/report.js +10 -7
  201. package/lib/types/report.js.map +1 -1
  202. package/lib/types/restrictionRule.js +11 -11
  203. package/lib/types/restrictionRule.js.map +1 -1
  204. package/lib/types/schema.d.ts +1 -1
  205. package/lib/types/schema.js +41 -19
  206. package/lib/types/schema.js.map +1 -1
  207. package/lib/types/shareRule.js +11 -11
  208. package/lib/types/shareRule.js.map +1 -1
  209. package/lib/types/trigger.js +2 -2
  210. package/lib/types/trigger.js.map +1 -1
  211. package/lib/types/validation_rules.js +5 -5
  212. package/lib/types/validation_rules.js.map +1 -1
  213. package/lib/util/convert.d.ts +2 -0
  214. package/lib/util/convert.js +130 -0
  215. package/lib/util/convert.js.map +1 -0
  216. package/lib/util/field.js +5 -3
  217. package/lib/util/field.js.map +1 -1
  218. package/lib/util/function_expression.js +5 -3
  219. package/lib/util/function_expression.js.map +1 -1
  220. package/lib/util/index.d.ts +2 -7
  221. package/lib/util/index.js +86 -166
  222. package/lib/util/index.js.map +1 -1
  223. package/lib/util/locale.js +5 -3
  224. package/lib/util/locale.js.map +1 -1
  225. package/lib/util/permission_shares.js +2 -2
  226. package/lib/util/permission_shares.js.map +1 -1
  227. package/lib/util/suffix.js +22 -16
  228. package/lib/util/suffix.js.map +1 -1
  229. package/lib/util/transform.js +11 -11
  230. package/lib/util/transform.js.map +1 -1
  231. package/lib/validators/index.js +3 -2
  232. package/lib/validators/index.js.map +1 -1
  233. package/package.json +13 -13
  234. package/src/dynamic-load/chart.ts +6 -1
  235. package/src/dynamic-load/index.ts +1 -0
  236. package/src/dynamic-load/object_translations.ts +19 -10
  237. package/src/dynamic-load/package.ts +303 -0
  238. package/src/dynamic-load/page.ts +7 -1
  239. package/src/dynamic-load/permission.ts +1 -5
  240. package/src/dynamic-load/preload_data.ts +2 -3
  241. package/src/dynamic-load/query.ts +6 -1
  242. package/src/dynamic-load/restrictionRules.ts +6 -2
  243. package/src/dynamic-load/shareRules.ts +5 -1
  244. package/src/dynamic-load/translations.ts +3 -1
  245. package/src/metadata-register/_base.ts +23 -0
  246. package/src/metadata-register/object.ts +1 -20
  247. package/src/services/datasourceServiceFactory.ts +37 -0
  248. package/src/services/helpers/graphql.ts +5 -3
  249. package/src/services/index.ts +7 -0
  250. package/src/services/objectService.ts +5 -4
  251. package/src/{metadata-register/objectServiceManager.ts → services/objectServiceFactory.ts} +4 -4
  252. package/src/types/datasource.ts +81 -72
  253. package/src/types/field.ts +2 -2
  254. package/src/types/list_view.ts +1 -1
  255. package/src/types/object.ts +11 -11
  256. package/src/types/object_dynamic_load.ts +5 -47
  257. package/src/types/object_permission.ts +1 -1
  258. package/src/types/schema.ts +11 -1
  259. package/src/util/convert.ts +130 -0
  260. package/src/util/index.ts +6 -120
  261. package/lib/metadata-register/objectServiceManager.js.map +0 -1
@@ -7,7 +7,6 @@ var index_1 = require("../services/index");
7
7
  var driver_1 = require("../driver");
8
8
  var _ = require("lodash");
9
9
  var _1 = require(".");
10
- var objectServiceManager_1 = require("../metadata-register/objectServiceManager");
11
10
  var index_2 = require("../services/index");
12
11
  var path = require("path");
13
12
  var Fiber = require('fibers');
@@ -24,6 +23,7 @@ var SteedosDatabaseDriverType;
24
23
  var SteedosDataSourceType = /** @class */ (function () {
25
24
  function SteedosDataSourceType(datasource_name, config, schema) {
26
25
  this._objects = {};
26
+ this._cacheObjects = [];
27
27
  this._objectsConfig = {};
28
28
  this._objectsRolesPermission = {};
29
29
  this._objectsSpaceRolesPermission = {};
@@ -73,6 +73,26 @@ var SteedosDataSourceType = /** @class */ (function () {
73
73
  enumerable: false,
74
74
  configurable: true
75
75
  });
76
+ Object.defineProperty(SteedosDataSourceType.prototype, "cacheObjects", {
77
+ get: function () {
78
+ return this._cacheObjects;
79
+ },
80
+ set: function (value) {
81
+ this._cacheObjects = value;
82
+ },
83
+ enumerable: false,
84
+ configurable: true
85
+ });
86
+ Object.defineProperty(SteedosDataSourceType.prototype, "service", {
87
+ get: function () {
88
+ return this._service;
89
+ },
90
+ set: function (value) {
91
+ this._service = value;
92
+ },
93
+ enumerable: false,
94
+ configurable: true
95
+ });
76
96
  Object.defineProperty(SteedosDataSourceType.prototype, "enable_space", {
77
97
  get: function () {
78
98
  return this._enable_space;
@@ -98,15 +118,30 @@ var SteedosDataSourceType = /** @class */ (function () {
98
118
  configurable: true
99
119
  });
100
120
  SteedosDataSourceType.prototype.getObjects = function () {
101
- return tslib_1.__awaiter(this, void 0, void 0, function () {
102
- return tslib_1.__generator(this, function (_a) {
103
- switch (_a.label) {
121
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
122
+ return (0, tslib_1.__generator)(this, function (_a) {
123
+ // if(!this.schema.metadataRegister){
124
+ // return this._objects
125
+ // }
126
+ // return await this.schema.metadataRegister.getObjectsConfig(this.name);
127
+ return [2 /*return*/, this.getCacheObjects()];
128
+ });
129
+ });
130
+ };
131
+ SteedosDataSourceType.prototype.getCacheObjects = function () {
132
+ return this.cacheObjects;
133
+ };
134
+ SteedosDataSourceType.prototype.flushCacheObjects = function () {
135
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
136
+ var _a;
137
+ return (0, tslib_1.__generator)(this, function (_b) {
138
+ switch (_b.label) {
104
139
  case 0:
105
- if (!this.schema.metadataRegister) {
106
- return [2 /*return*/, this._objects];
107
- }
140
+ _a = this;
108
141
  return [4 /*yield*/, this.schema.metadataRegister.getObjectsConfig(this.name)];
109
- case 1: return [2 /*return*/, _a.sent()];
142
+ case 1:
143
+ _a.cacheObjects = _b.sent();
144
+ return [2 /*return*/];
110
145
  }
111
146
  });
112
147
  });
@@ -122,7 +157,7 @@ var SteedosDataSourceType = /** @class */ (function () {
122
157
  if (localObject) {
123
158
  return localObject;
124
159
  }
125
- return index_2.getObjectDispatcher(objectApiName);
160
+ return (0, index_2.getObjectDispatcher)(objectApiName);
126
161
  };
127
162
  SteedosDataSourceType.prototype.getLocalObject = function (objectApiName) {
128
163
  return this._objects[objectApiName];
@@ -134,16 +169,23 @@ var SteedosDataSourceType = /** @class */ (function () {
134
169
  return this._objectsConfig[objectName];
135
170
  };
136
171
  SteedosDataSourceType.prototype.setObject = function (objectApiName, objectConfig) {
137
- return tslib_1.__awaiter(this, void 0, void 0, function () {
138
- var serviceName, object;
139
- return tslib_1.__generator(this, function (_a) {
172
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
173
+ var serviceName, object, findIndex;
174
+ return (0, tslib_1.__generator)(this, function (_a) {
140
175
  switch (_a.label) {
141
176
  case 0:
142
- serviceName = index_1.getObjectServiceName(objectApiName);
177
+ serviceName = (0, index_1.getObjectServiceName)(objectApiName);
143
178
  object = new _1.SteedosObjectType(objectApiName, this, objectConfig);
144
179
  this._objectsConfig[objectApiName] = objectConfig;
180
+ findIndex = _.findIndex(this.cacheObjects, function (item) { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.name) === objectApiName; });
181
+ if (findIndex != -1) {
182
+ this.cacheObjects[findIndex] = Object.assign({ service: { name: serviceName } }, { metadata: objectConfig });
183
+ }
184
+ else {
185
+ this.cacheObjects.push(Object.assign({ service: { name: serviceName } }, { metadata: objectConfig }));
186
+ }
145
187
  this._objects[objectApiName] = object;
146
- return [4 /*yield*/, objectServiceManager_1.createObjectService(this._schema.metadataBroker, serviceName, objectConfig)];
188
+ return [4 /*yield*/, (0, index_2.createObjectService)(this._schema.metadataBroker, serviceName, objectConfig)];
147
189
  case 1:
148
190
  _a.sent();
149
191
  return [2 /*return*/, object];
@@ -195,59 +237,25 @@ var SteedosDataSourceType = /** @class */ (function () {
195
237
  this._adapter = new driver_1.SteedosMySqlDriver(driverConfig);
196
238
  break;
197
239
  default:
198
- throw new Error("the driver " + this.config.driver + " is not supported");
240
+ throw new Error("the driver ".concat(this.config.driver, " is not supported"));
199
241
  }
200
242
  }
201
243
  else {
202
244
  this._adapter = this.config.driver;
203
245
  }
204
246
  };
205
- SteedosDataSourceType.prototype.initObjects = function () {
206
- var e_1, _a;
207
- return tslib_1.__awaiter(this, void 0, void 0, function () {
208
- var objects, self, _b, _c, object, objectConfig, localObjectConfig, _db, e_1_1;
209
- var _this = this;
210
- return tslib_1.__generator(this, function (_d) {
211
- switch (_d.label) {
212
- case 0: return [4 /*yield*/, this.getObjects()];
213
- case 1:
214
- objects = _d.sent();
215
- self = this;
216
- _d.label = 2;
217
- case 2:
218
- _d.trys.push([2, 8, 9, 14]);
219
- _b = tslib_1.__asyncValues(_.values(objects));
220
- _d.label = 3;
221
- case 3: return [4 /*yield*/, _b.next()];
222
- case 4:
223
- if (!(_c = _d.sent(), !_c.done)) return [3 /*break*/, 7];
224
- object = _c.value;
225
- objectConfig = object.metadata;
226
- localObjectConfig = _1.getObjectConfig(objectConfig.name);
247
+ SteedosDataSourceType.prototype.initObject = function (objectConfig) {
248
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
249
+ var localObjectConfig, _db;
250
+ return (0, tslib_1.__generator)(this, function (_a) {
251
+ switch (_a.label) {
252
+ case 0:
253
+ localObjectConfig = (0, _1.getObjectConfig)(objectConfig.name);
227
254
  if (localObjectConfig) {
228
255
  objectConfig.listeners = localObjectConfig.listeners;
229
256
  objectConfig.methods = localObjectConfig.methods;
230
257
  }
231
- // if(self._schema.metadataBroker){
232
- // const res = await self._schema.metadataRegister.object(object)
233
- // if(res){
234
- // self.setObject(object.name, object);
235
- // }
236
- // }else{
237
- // self.setObject(object.name, object);
238
- // }
239
- return [4 /*yield*/, self.setObject(objectConfig.name, objectConfig)];
240
- case 5:
241
- // if(self._schema.metadataBroker){
242
- // const res = await self._schema.metadataRegister.object(object)
243
- // if(res){
244
- // self.setObject(object.name, object);
245
- // }
246
- // }else{
247
- // self.setObject(object.name, object);
248
- // }
249
- _d.sent();
250
- if (this.name === "default") {
258
+ if (this.name === "meteor") {
251
259
  try {
252
260
  _db = Creator.createCollection(objectConfig);
253
261
  Creator.Collections[_db._name] = _db;
@@ -256,70 +264,69 @@ var SteedosDataSourceType = /** @class */ (function () {
256
264
  // console.log(`error`, error) //此处无需打印日志,@steedos/core 在init Creator 时,会兼容此部分的异常逻辑。
257
265
  }
258
266
  }
259
- _d.label = 6;
260
- case 6: return [3 /*break*/, 3];
261
- case 7: return [3 /*break*/, 14];
262
- case 8:
267
+ return [4 /*yield*/, this.setObject(objectConfig.name, objectConfig)];
268
+ case 1:
269
+ _a.sent();
270
+ return [2 /*return*/];
271
+ }
272
+ });
273
+ });
274
+ };
275
+ SteedosDataSourceType.prototype.initObjects = function () {
276
+ var e_1, _a;
277
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
278
+ var objects, self, _b, _c, object, objectConfig, e_1_1;
279
+ return (0, tslib_1.__generator)(this, function (_d) {
280
+ switch (_d.label) {
281
+ case 0:
282
+ objects = this.cacheObjects;
283
+ self = this;
284
+ _d.label = 1;
285
+ case 1:
286
+ _d.trys.push([1, 7, 8, 13]);
287
+ _b = (0, tslib_1.__asyncValues)(_.values(objects));
288
+ _d.label = 2;
289
+ case 2: return [4 /*yield*/, _b.next()];
290
+ case 3:
291
+ if (!(_c = _d.sent(), !_c.done)) return [3 /*break*/, 6];
292
+ object = _c.value;
293
+ objectConfig = object.metadata;
294
+ return [4 /*yield*/, self.initObject(objectConfig)];
295
+ case 4:
296
+ _d.sent();
297
+ _d.label = 5;
298
+ case 5: return [3 /*break*/, 2];
299
+ case 6: return [3 /*break*/, 13];
300
+ case 7:
263
301
  e_1_1 = _d.sent();
264
302
  e_1 = { error: e_1_1 };
265
- return [3 /*break*/, 14];
266
- case 9:
267
- _d.trys.push([9, , 12, 13]);
268
- if (!(_c && !_c.done && (_a = _b.return))) return [3 /*break*/, 11];
303
+ return [3 /*break*/, 13];
304
+ case 8:
305
+ _d.trys.push([8, , 11, 12]);
306
+ if (!(_c && !_c.done && (_a = _b.return))) return [3 /*break*/, 10];
269
307
  return [4 /*yield*/, _a.call(_b)];
270
- case 10:
308
+ case 9:
271
309
  _d.sent();
272
- _d.label = 11;
273
- case 11: return [3 /*break*/, 13];
274
- case 12:
310
+ _d.label = 10;
311
+ case 10: return [3 /*break*/, 12];
312
+ case 11:
275
313
  if (e_1) throw e_1.error;
276
314
  return [7 /*endfinally*/];
277
- case 13: return [7 /*endfinally*/];
278
- case 14:
279
- // _.each(objects, (object) => {
280
- // const obj = this.getObject(object.name);
281
- // if(obj){
282
- // // 加try catch是因为有错误时不应该影响下一个对象加载
283
- // try{
284
- // obj.initMasterDetails();
285
- // }
286
- // catch(ex){
287
- // console.error(ex);
288
- // }
289
- // }
290
- // });
291
- // _.each(objects, (object) => {
292
- // const obj = this.getObject(object.name);
293
- // if(obj){
294
- // // 加try catch是因为有错误时不应该影响下一个对象加载
295
- // try{
296
- // obj.checkMasterDetails();
297
- // }
298
- // catch(ex){
299
- // console.error(ex);
300
- // }
301
- // }
302
- // });
303
- _.each(this.config.objectsRolesPermission, function (objectRolesPermission, object_name) {
304
- _.each(objectRolesPermission, function (objectRolePermission, role_name) {
305
- objectRolePermission.name = role_name;
306
- _this.setObjectPermission(object_name, objectRolePermission);
307
- });
308
- });
309
- return [2 /*return*/, true];
315
+ case 12: return [7 /*endfinally*/];
316
+ case 13: return [2 /*return*/, true];
310
317
  }
311
318
  });
312
319
  });
313
320
  };
314
321
  SteedosDataSourceType.prototype.loadFiles = function () {
315
- return tslib_1.__awaiter(this, void 0, void 0, function () {
322
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
316
323
  var _a, _b, objectPath, filePath, e_2_1;
317
324
  var e_2, _c;
318
- return tslib_1.__generator(this, function (_d) {
325
+ return (0, tslib_1.__generator)(this, function (_d) {
319
326
  switch (_d.label) {
320
327
  case 0:
321
328
  _d.trys.push([0, 5, 6, 7]);
322
- _a = tslib_1.__values(this.config.objectFiles), _b = _a.next();
329
+ _a = (0, tslib_1.__values)(this.config.objectFiles), _b = _a.next();
323
330
  _d.label = 1;
324
331
  case 1:
325
332
  if (!!_b.done) return [3 /*break*/, 4];
@@ -328,7 +335,7 @@ var SteedosDataSourceType = /** @class */ (function () {
328
335
  if (!path.isAbsolute(objectPath)) {
329
336
  filePath = path.join(process.cwd(), objectPath);
330
337
  }
331
- return [4 /*yield*/, _1.addAllConfigFiles(filePath, this._name, null)];
338
+ return [4 /*yield*/, (0, _1.addAllConfigFiles)(filePath, this._name, null)];
332
339
  case 2:
333
340
  _d.sent();
334
341
  _d.label = 3;
@@ -383,8 +390,8 @@ var SteedosDataSourceType = /** @class */ (function () {
383
390
  }
384
391
  };
385
392
  SteedosDataSourceType.prototype.getRoles = function (userId) {
386
- return tslib_1.__awaiter(this, void 0, void 0, function () {
387
- return tslib_1.__generator(this, function (_a) {
393
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
394
+ return (0, tslib_1.__generator)(this, function (_a) {
388
395
  switch (_a.label) {
389
396
  case 0:
390
397
  if (!this._getRoles) return [3 /*break*/, 2];
@@ -396,8 +403,8 @@ var SteedosDataSourceType = /** @class */ (function () {
396
403
  });
397
404
  };
398
405
  SteedosDataSourceType.prototype.find = function (tableName, query, userId) {
399
- return tslib_1.__awaiter(this, void 0, void 0, function () {
400
- return tslib_1.__generator(this, function (_a) {
406
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
407
+ return (0, tslib_1.__generator)(this, function (_a) {
401
408
  switch (_a.label) {
402
409
  case 0: return [4 /*yield*/, this._adapter.find(tableName, query, userId)];
403
410
  case 1: return [2 /*return*/, _a.sent()];
@@ -406,8 +413,8 @@ var SteedosDataSourceType = /** @class */ (function () {
406
413
  });
407
414
  };
408
415
  SteedosDataSourceType.prototype.aggregate = function (tableName, query, externalPipeline, userId) {
409
- return tslib_1.__awaiter(this, void 0, void 0, function () {
410
- return tslib_1.__generator(this, function (_a) {
416
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
417
+ return (0, tslib_1.__generator)(this, function (_a) {
411
418
  switch (_a.label) {
412
419
  case 0: return [4 /*yield*/, this._adapter.aggregate(tableName, query, externalPipeline, userId)];
413
420
  case 1: return [2 /*return*/, _a.sent()];
@@ -416,8 +423,8 @@ var SteedosDataSourceType = /** @class */ (function () {
416
423
  });
417
424
  };
418
425
  SteedosDataSourceType.prototype.findOne = function (tableName, id, query, userId) {
419
- return tslib_1.__awaiter(this, void 0, void 0, function () {
420
- return tslib_1.__generator(this, function (_a) {
426
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
427
+ return (0, tslib_1.__generator)(this, function (_a) {
421
428
  switch (_a.label) {
422
429
  case 0: return [4 /*yield*/, this._adapter.findOne(tableName, id, query, userId)];
423
430
  case 1: return [2 /*return*/, _a.sent()];
@@ -426,8 +433,8 @@ var SteedosDataSourceType = /** @class */ (function () {
426
433
  });
427
434
  };
428
435
  SteedosDataSourceType.prototype.insert = function (tableName, doc, userId) {
429
- return tslib_1.__awaiter(this, void 0, void 0, function () {
430
- return tslib_1.__generator(this, function (_a) {
436
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
437
+ return (0, tslib_1.__generator)(this, function (_a) {
431
438
  switch (_a.label) {
432
439
  case 0: return [4 /*yield*/, this._adapter.insert(tableName, doc, userId)];
433
440
  case 1: return [2 /*return*/, _a.sent()];
@@ -436,8 +443,8 @@ var SteedosDataSourceType = /** @class */ (function () {
436
443
  });
437
444
  };
438
445
  SteedosDataSourceType.prototype.update = function (tableName, id, doc, userId) {
439
- return tslib_1.__awaiter(this, void 0, void 0, function () {
440
- return tslib_1.__generator(this, function (_a) {
446
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
447
+ return (0, tslib_1.__generator)(this, function (_a) {
441
448
  switch (_a.label) {
442
449
  case 0: return [4 /*yield*/, this._adapter.update(tableName, id, doc, userId)];
443
450
  case 1: return [2 /*return*/, _a.sent()];
@@ -446,8 +453,8 @@ var SteedosDataSourceType = /** @class */ (function () {
446
453
  });
447
454
  };
448
455
  SteedosDataSourceType.prototype.updateOne = function (tableName, id, doc, userId) {
449
- return tslib_1.__awaiter(this, void 0, void 0, function () {
450
- return tslib_1.__generator(this, function (_a) {
456
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
457
+ return (0, tslib_1.__generator)(this, function (_a) {
451
458
  switch (_a.label) {
452
459
  case 0: return [4 /*yield*/, this._adapter.updateOne(tableName, id, doc, userId)];
453
460
  case 1: return [2 /*return*/, _a.sent()];
@@ -456,8 +463,8 @@ var SteedosDataSourceType = /** @class */ (function () {
456
463
  });
457
464
  };
458
465
  SteedosDataSourceType.prototype.updateMany = function (tableName, queryFilters, doc, userId) {
459
- return tslib_1.__awaiter(this, void 0, void 0, function () {
460
- return tslib_1.__generator(this, function (_a) {
466
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
467
+ return (0, tslib_1.__generator)(this, function (_a) {
461
468
  switch (_a.label) {
462
469
  case 0: return [4 /*yield*/, this._adapter.updateMany(tableName, queryFilters, doc, userId)];
463
470
  case 1: return [2 /*return*/, _a.sent()];
@@ -466,8 +473,8 @@ var SteedosDataSourceType = /** @class */ (function () {
466
473
  });
467
474
  };
468
475
  SteedosDataSourceType.prototype.delete = function (tableName, id, userId) {
469
- return tslib_1.__awaiter(this, void 0, void 0, function () {
470
- return tslib_1.__generator(this, function (_a) {
476
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
477
+ return (0, tslib_1.__generator)(this, function (_a) {
471
478
  switch (_a.label) {
472
479
  case 0: return [4 /*yield*/, this._adapter.delete(tableName, id, userId)];
473
480
  case 1: return [2 /*return*/, _a.sent()];
@@ -476,8 +483,8 @@ var SteedosDataSourceType = /** @class */ (function () {
476
483
  });
477
484
  };
478
485
  SteedosDataSourceType.prototype.count = function (tableName, query, userId) {
479
- return tslib_1.__awaiter(this, void 0, void 0, function () {
480
- return tslib_1.__generator(this, function (_a) {
486
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
487
+ return (0, tslib_1.__generator)(this, function (_a) {
481
488
  switch (_a.label) {
482
489
  case 0: return [4 /*yield*/, this._adapter.count(tableName, query, userId)];
483
490
  case 1: return [2 /*return*/, _a.sent()];
@@ -486,8 +493,8 @@ var SteedosDataSourceType = /** @class */ (function () {
486
493
  });
487
494
  };
488
495
  SteedosDataSourceType.prototype.directFind = function (tableName, query, userId) {
489
- return tslib_1.__awaiter(this, void 0, void 0, function () {
490
- return tslib_1.__generator(this, function (_a) {
496
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
497
+ return (0, tslib_1.__generator)(this, function (_a) {
491
498
  switch (_a.label) {
492
499
  case 0: return [4 /*yield*/, this._adapter.find(tableName, query, userId)];
493
500
  case 1: return [2 /*return*/, _a.sent()];
@@ -496,8 +503,8 @@ var SteedosDataSourceType = /** @class */ (function () {
496
503
  });
497
504
  };
498
505
  SteedosDataSourceType.prototype.directInsert = function (tableName, doc, userId) {
499
- return tslib_1.__awaiter(this, void 0, void 0, function () {
500
- return tslib_1.__generator(this, function (_a) {
506
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
507
+ return (0, tslib_1.__generator)(this, function (_a) {
501
508
  switch (_a.label) {
502
509
  case 0: return [4 /*yield*/, this._adapter.directInsert(tableName, doc, userId)];
503
510
  case 1: return [2 /*return*/, _a.sent()];
@@ -506,8 +513,8 @@ var SteedosDataSourceType = /** @class */ (function () {
506
513
  });
507
514
  };
508
515
  SteedosDataSourceType.prototype.directUpdate = function (tableName, id, doc, userId) {
509
- return tslib_1.__awaiter(this, void 0, void 0, function () {
510
- return tslib_1.__generator(this, function (_a) {
516
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
517
+ return (0, tslib_1.__generator)(this, function (_a) {
511
518
  switch (_a.label) {
512
519
  case 0: return [4 /*yield*/, this._adapter.directUpdate(tableName, id, doc, userId)];
513
520
  case 1: return [2 /*return*/, _a.sent()];
@@ -516,8 +523,8 @@ var SteedosDataSourceType = /** @class */ (function () {
516
523
  });
517
524
  };
518
525
  SteedosDataSourceType.prototype.directDelete = function (tableName, id, userId) {
519
- return tslib_1.__awaiter(this, void 0, void 0, function () {
520
- return tslib_1.__generator(this, function (_a) {
526
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
527
+ return (0, tslib_1.__generator)(this, function (_a) {
521
528
  switch (_a.label) {
522
529
  case 0: return [4 /*yield*/, this._adapter.directDelete(tableName, id, userId)];
523
530
  case 1: return [2 /*return*/, _a.sent()];
@@ -526,8 +533,8 @@ var SteedosDataSourceType = /** @class */ (function () {
526
533
  });
527
534
  };
528
535
  SteedosDataSourceType.prototype.directAggregate = function (tableName, query, externalPipeline, userId) {
529
- return tslib_1.__awaiter(this, void 0, void 0, function () {
530
- return tslib_1.__generator(this, function (_a) {
536
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
537
+ return (0, tslib_1.__generator)(this, function (_a) {
531
538
  switch (_a.label) {
532
539
  case 0: return [4 /*yield*/, this._adapter.directAggregate(tableName, query, externalPipeline, userId)];
533
540
  case 1: return [2 /*return*/, _a.sent()];
@@ -536,8 +543,8 @@ var SteedosDataSourceType = /** @class */ (function () {
536
543
  });
537
544
  };
538
545
  SteedosDataSourceType.prototype.directAggregatePrefixalPipeline = function (tableName, query, prefixalPipeline, userId) {
539
- return tslib_1.__awaiter(this, void 0, void 0, function () {
540
- return tslib_1.__generator(this, function (_a) {
546
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
547
+ return (0, tslib_1.__generator)(this, function (_a) {
541
548
  switch (_a.label) {
542
549
  case 0: return [4 /*yield*/, this._adapter.directAggregatePrefixalPipeline(tableName, query, prefixalPipeline, userId)];
543
550
  case 1: return [2 /*return*/, _a.sent()];
@@ -546,8 +553,8 @@ var SteedosDataSourceType = /** @class */ (function () {
546
553
  });
547
554
  };
548
555
  SteedosDataSourceType.prototype._makeNewID = function (tableName) {
549
- return tslib_1.__awaiter(this, void 0, void 0, function () {
550
- return tslib_1.__generator(this, function (_a) {
556
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
557
+ return (0, tslib_1.__generator)(this, function (_a) {
551
558
  switch (_a.label) {
552
559
  case 0: return [4 /*yield*/, this._adapter._makeNewID(tableName)];
553
560
  case 1: return [2 /*return*/, _a.sent()];
@@ -563,8 +570,8 @@ var SteedosDataSourceType = /** @class */ (function () {
563
570
  configurable: true
564
571
  });
565
572
  SteedosDataSourceType.prototype.dropEntities = function () {
566
- return tslib_1.__awaiter(this, void 0, void 0, function () {
567
- return tslib_1.__generator(this, function (_a) {
573
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
574
+ return (0, tslib_1.__generator)(this, function (_a) {
568
575
  switch (_a.label) {
569
576
  case 0:
570
577
  if (!this._adapter.dropEntities) return [3 /*break*/, 2];
@@ -581,8 +588,8 @@ var SteedosDataSourceType = /** @class */ (function () {
581
588
  }
582
589
  };
583
590
  SteedosDataSourceType.prototype.dropTables = function () {
584
- return tslib_1.__awaiter(this, void 0, void 0, function () {
585
- return tslib_1.__generator(this, function (_a) {
591
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
592
+ return (0, tslib_1.__generator)(this, function (_a) {
586
593
  switch (_a.label) {
587
594
  case 0:
588
595
  if (!this._adapter.dropEntities) return [3 /*break*/, 2];
@@ -594,8 +601,8 @@ var SteedosDataSourceType = /** @class */ (function () {
594
601
  });
595
602
  };
596
603
  SteedosDataSourceType.prototype.createTables = function () {
597
- return tslib_1.__awaiter(this, void 0, void 0, function () {
598
- return tslib_1.__generator(this, function (_a) {
604
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
605
+ return (0, tslib_1.__generator)(this, function (_a) {
599
606
  switch (_a.label) {
600
607
  case 0:
601
608
  if (!this._adapter.createTables) return [3 /*break*/, 2];
@@ -607,63 +614,69 @@ var SteedosDataSourceType = /** @class */ (function () {
607
614
  });
608
615
  };
609
616
  SteedosDataSourceType.prototype.init = function () {
610
- return tslib_1.__awaiter(this, void 0, void 0, function () {
611
- return tslib_1.__generator(this, function (_a) {
612
- switch (_a.label) {
613
- case 0: return [4 /*yield*/, this.initObjects()];
617
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
618
+ var broker, _a;
619
+ return (0, tslib_1.__generator)(this, function (_b) {
620
+ switch (_b.label) {
621
+ case 0:
622
+ // await this.flushCacheObjects();
623
+ // await this.initObjects();
624
+ this.initObjectPermissions();
625
+ if (!!this.service) return [3 /*break*/, 2];
626
+ broker = this._schema.metadataBroker;
627
+ _a = this;
628
+ return [4 /*yield*/, (0, index_2.createDataSourceService)(broker, this)];
614
629
  case 1:
615
- _a.sent();
616
- return [4 /*yield*/, this.initTypeORM()];
617
- case 2:
618
- _a.sent();
619
- return [2 /*return*/];
630
+ _a.service = _b.sent();
631
+ _b.label = 2;
632
+ case 2: return [2 /*return*/];
620
633
  }
621
634
  });
622
635
  });
623
636
  };
624
- SteedosDataSourceType.prototype.initTypeORM = function () {
625
- return tslib_1.__awaiter(this, void 0, void 0, function () {
626
- var _objects, _a, _b, self_1;
627
- return tslib_1.__generator(this, function (_c) {
628
- switch (_c.label) {
629
- case 0:
630
- _objects = {};
631
- _b = (_a = _).map;
632
- return [4 /*yield*/, this.getObjects()];
633
- case 1:
634
- _b.apply(_a, [_c.sent(), function (item) {
635
- if (item && item.metadata) {
636
- _objects[item.metadata.name] = item.metadata;
637
- }
638
- }]);
639
- if (this._adapter.init) {
640
- self_1 = this;
641
- Fiber(function () {
642
- var fiber = Fiber.current;
643
- self_1._adapter.init(_objects).then(function (result) {
644
- fiber.run();
645
- }).catch(function (result) {
646
- console.error(result);
647
- fiber.run();
648
- });
649
- Fiber.yield();
650
- }).run();
651
- }
652
- return [2 /*return*/];
653
- }
637
+ /**
638
+ * 初始化数据源上配置的对象权限。
639
+ */
640
+ SteedosDataSourceType.prototype.initObjectPermissions = function () {
641
+ var _this = this;
642
+ _.each(this.config.objectsRolesPermission, function (objectRolesPermission, object_name) {
643
+ _.each(objectRolesPermission, function (objectRolePermission, role_name) {
644
+ objectRolePermission.name = role_name;
645
+ _this.setObjectPermission(object_name, objectRolePermission);
654
646
  });
655
647
  });
656
648
  };
649
+ SteedosDataSourceType.prototype.initTypeORM = function () {
650
+ var _objects = {};
651
+ _.map(this.cacheObjects, function (item) {
652
+ if (item && item.metadata) {
653
+ _objects[item.metadata.name] = item.metadata;
654
+ }
655
+ });
656
+ if (this._adapter.init) {
657
+ var self_1 = this;
658
+ Fiber(function () {
659
+ var fiber = Fiber.current;
660
+ self_1._adapter.init(_objects).then(function (result) {
661
+ fiber.run();
662
+ }).catch(function (result) {
663
+ console.error(result);
664
+ fiber.run();
665
+ });
666
+ Fiber.yield();
667
+ }).run();
668
+ }
669
+ };
657
670
  // 暂时保留,兼容creator bootstrap接口
658
671
  SteedosDataSourceType.prototype.getAppsConfig = function () {
659
- return _1.getAppConfigs();
672
+ return (0, _1.getAppConfigs)();
660
673
  };
661
674
  SteedosDataSourceType.prototype.getDashboardsConfig = function () {
662
- return _1.getDashboardConfigs();
675
+ return (0, _1.getDashboardConfigs)();
663
676
  };
664
677
  SteedosDataSourceType.prototype.connect = function () {
665
- return tslib_1.__awaiter(this, void 0, void 0, function () {
666
- return tslib_1.__generator(this, function (_a) {
678
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
679
+ return (0, tslib_1.__generator)(this, function (_a) {
667
680
  switch (_a.label) {
668
681
  case 0:
669
682
  if (!this._adapter.connect) return [3 /*break*/, 2];
@@ -685,8 +698,8 @@ var SteedosDataSourceType = /** @class */ (function () {
685
698
  });
686
699
  };
687
700
  SteedosDataSourceType.prototype.close = function () {
688
- return tslib_1.__awaiter(this, void 0, void 0, function () {
689
- return tslib_1.__generator(this, function (_a) {
701
+ return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
702
+ return (0, tslib_1.__generator)(this, function (_a) {
690
703
  if (this._adapter.close)
691
704
  this._adapter.close();
692
705
  return [2 /*return*/];
@@ -697,7 +710,7 @@ var SteedosDataSourceType = /** @class */ (function () {
697
710
  }());
698
711
  exports.SteedosDataSourceType = SteedosDataSourceType;
699
712
  function getDataSource(datasourceName, schema) {
700
- return (schema ? schema : _1.getSteedosSchema()).getDataSource(datasourceName);
713
+ return (schema ? schema : (0, _1.getSteedosSchema)()).getDataSource(datasourceName);
701
714
  }
702
715
  exports.getDataSource = getDataSource;
703
716
  //# sourceMappingURL=datasource.js.map