@steedos/objectql 2.2.21 → 2.2.24

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 (51) hide show
  1. package/lib/driver/metadata.js +10 -3
  2. package/lib/driver/metadata.js.map +1 -1
  3. package/lib/dynamic-load/package.js +1 -1
  4. package/lib/dynamic-load/package.js.map +1 -1
  5. package/lib/dynamic-load/trigger.d.ts +2 -1
  6. package/lib/dynamic-load/trigger.js +65 -9
  7. package/lib/dynamic-load/trigger.js.map +1 -1
  8. package/lib/dynamic-load/validation_rule.d.ts +2 -1
  9. package/lib/dynamic-load/validation_rule.js +10 -3
  10. package/lib/dynamic-load/validation_rule.js.map +1 -1
  11. package/lib/services/datasourceServiceFactory.js +19 -0
  12. package/lib/services/datasourceServiceFactory.js.map +1 -1
  13. package/lib/services/helpers/graphql.d.ts +1 -0
  14. package/lib/services/helpers/graphql.js +12 -1
  15. package/lib/services/helpers/graphql.js.map +1 -1
  16. package/lib/services/objectService.js +93 -16
  17. package/lib/services/objectService.js.map +1 -1
  18. package/lib/types/datasource.d.ts +2 -0
  19. package/lib/types/datasource.js +50 -0
  20. package/lib/types/datasource.js.map +1 -1
  21. package/lib/types/field.js +3 -0
  22. package/lib/types/field.js.map +1 -1
  23. package/lib/types/listeners.d.ts +1 -0
  24. package/lib/types/object.d.ts +1 -0
  25. package/lib/types/object.js +12 -0
  26. package/lib/types/object.js.map +1 -1
  27. package/lib/types/object_dynamic_load.js +2 -2
  28. package/lib/types/object_dynamic_load.js.map +1 -1
  29. package/lib/types/validation_rules.js +7 -2
  30. package/lib/types/validation_rules.js.map +1 -1
  31. package/lib/util/index.d.ts +2 -0
  32. package/lib/util/index.js +17 -1
  33. package/lib/util/index.js.map +1 -1
  34. package/lib/util/transform.js +2 -1
  35. package/lib/util/transform.js.map +1 -1
  36. package/package.json +9 -9
  37. package/src/driver/metadata.ts +10 -3
  38. package/src/dynamic-load/package.ts +1 -1
  39. package/src/dynamic-load/trigger.ts +66 -8
  40. package/src/dynamic-load/validation_rule.ts +14 -2
  41. package/src/services/datasourceServiceFactory.ts +19 -1
  42. package/src/services/helpers/graphql.ts +11 -0
  43. package/src/services/objectService.ts +41 -2
  44. package/src/types/datasource.ts +27 -0
  45. package/src/types/field.ts +3 -0
  46. package/src/types/listeners.ts +1 -0
  47. package/src/types/object.ts +12 -0
  48. package/src/types/object_dynamic_load.ts +3 -2
  49. package/src/types/validation_rules.ts +7 -2
  50. package/src/util/index.ts +16 -0
  51. package/src/util/transform.ts +2 -1
@@ -299,6 +299,18 @@ export class SteedosObjectType extends SteedosObjectProperties {
299
299
  })
300
300
  }
301
301
 
302
+ removeListener(listener_name: string, config: SteedosListenerConfig) {
303
+ this.listeners[listener_name] = config
304
+ _TRIGGERKEYS.forEach((key) => {
305
+ try {
306
+ let event = config[key];
307
+ delete this._triggersQueue[key][`${listener_name}_${event.name}`]
308
+ } catch (error) {
309
+
310
+ }
311
+ })
312
+ }
313
+
302
314
  private setTrigger(name: string, when: string, todo: Function, on = 'server') {
303
315
  let triggerConfig: SteedosTriggerTypeConfig = {
304
316
  name: name,
@@ -100,7 +100,8 @@ export const addObjectConfigFiles = async (filePath: string, datasource: string,
100
100
  // await loadObjectPermissions(filePath, serviceName);
101
101
  await loadSourceProfiles(filePath, serviceName);
102
102
  await loadSourcePermissionset(filePath, serviceName);
103
- loadObjectValidationRules(filePath);
103
+
104
+ loadObjectValidationRules(filePath, serviceName);
104
105
 
105
106
  loadSourceRoles(filePath);
106
107
 
@@ -285,10 +286,10 @@ export const removeObjectListenerConfig = (_id, listenTo, when)=>{
285
286
  export const loadStandardMetadata = async (serviceName: string, datasourceApiName: string) => {
286
287
  await loadStandardBaseObjects(serviceName);
287
288
  if (dbMetadataLoaing != true) {
288
- dbMetadataLoaing = true;
289
289
  await loadStandardProfiles(serviceName);
290
290
  await loadStandardPermissionsets(serviceName);
291
291
  await loadDbMetadatas(datasourceApiName);
292
+ dbMetadataLoaing = true;
292
293
  }
293
294
  }
294
295
 
@@ -1,3 +1,8 @@
1
+ /*
2
+ * @Author: sunhaolin@hotoa.com
3
+ * @Date: 2021-05-24 12:32:57
4
+ * @Description:
5
+ */
1
6
 
2
7
  import { computeFormula } from '../formula';
3
8
  import { SteedosTriggerContextConfig } from "./trigger";
@@ -8,13 +13,13 @@ export async function runValidationRules(method: string, context: SteedosTrigger
8
13
  let spaceId = userSession.spaceId;
9
14
  let userId = userSession.userId + '';
10
15
  let doc = context.doc;
11
- let validationRules = await getObject('object_validation_rules').find({ filters: [['space', '=', spaceId], ['object_name', '=', objectName], ['active', '=', true]] });
16
+ let validationRules = await getObject('object_validation_rules').find({ filters: [['object_name', '=', objectName], ['active', '=', true]] });
12
17
  for (const vr of validationRules) {
13
18
  let result;
14
19
  try {
15
20
  result = await computeFormula(vr.error_condition_formula, objectName, doc, userId, spaceId);
16
21
  } catch (error) {
17
- throw new Error('object_validation_rules_wrong_formula');
22
+ throw new Error(`公式错误,请检查错误条件公式。${error.message.replace(/\:/g, '')}`);
18
23
  }
19
24
  if (result) {
20
25
  throw new Error(vr.error_message);
package/src/util/index.ts CHANGED
@@ -1014,4 +1014,20 @@ export function parserFilters(filters){
1014
1014
  return query;
1015
1015
  }
1016
1016
 
1017
+
1018
+ export function clearRequireCache(filename) {
1019
+ /* istanbul ignore next */
1020
+ Object.keys(require.cache).forEach(function (key) {
1021
+ if (key == filename) {
1022
+ delete require.cache[key];
1023
+ }
1024
+ });
1025
+ };
1026
+
1027
+ export function loadService(broker, filename){
1028
+ clearRequireCache(filename);
1029
+ return broker.loadService(filename);
1030
+ }
1031
+
1032
+
1017
1033
  loadCoreValidators();
@@ -44,7 +44,8 @@ function transformListenerToTrigger(object: SteedosObjectTypeConfig, when: strin
44
44
  let trigger: any = {
45
45
  on: 'server',
46
46
  when: getTriggerWhen(when),
47
- todo: transformTrigger(object, when, todo)
47
+ todo: transformTrigger(object, when, todo),
48
+ metadataServiceName: json.metadataServiceName
48
49
  }
49
50
 
50
51
  if (json._id) {