@steedos/service-metadata-objects 2.1.52 → 2.1.53

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.
@@ -22,7 +22,7 @@ async function getBaseObjectConfig(ctx, datasourceName) {
22
22
  serviceName,
23
23
  metadataType,
24
24
  metadataApiName: metadataApiName,
25
- });
25
+ }, {meta: ctx.meta});
26
26
  return configs && configs.length > 0 ? configs[0]?.metadata : null;
27
27
  }
28
28
 
@@ -35,8 +35,9 @@ async function getObjectConfigs(ctx, objectApiName) {
35
35
  serviceName,
36
36
  metadataType,
37
37
  metadataApiName: objectApiName,
38
- }
38
+ }, {meta: ctx.meta}
39
39
  );
40
+ // console.log(`getObjectConfigs ==== `, getObjectConfigs.length);
40
41
  return _.compact(_.map(objectConfigs, "metadata"));
41
42
  }
42
43
 
@@ -105,8 +106,8 @@ export async function refreshObject(ctx, objectApiName) {
105
106
  let objectConfig: any = {};
106
107
 
107
108
  const objectConfigs = await getObjectConfigs(ctx, objectApiName);
108
-
109
109
  if (objectConfigs.length == 0) {
110
+ // console.log(`refreshObject objectConfigs`, objectConfigs.length)
110
111
  return null;
111
112
  }
112
113
 
@@ -144,6 +145,7 @@ export async function refreshObject(ctx, objectApiName) {
144
145
  }
145
146
 
146
147
  if (!mainConfig) {
148
+ console.log(`refreshObject mainConfig`, mainConfigs.length, mainConfig)
147
149
  return null;
148
150
  }
149
151
 
@@ -232,7 +234,9 @@ export async function refreshObject(ctx, objectApiName) {
232
234
  if (maxSortNoField) {
233
235
  objectConfig.fields_serial_number = maxSortNoField.sort_no;
234
236
  }
235
- } catch (error) {}
237
+ } catch (error) {
238
+ console.log(`refreshObject error`, error)
239
+ }
236
240
 
237
241
  return objectConfig;
238
242
  }
@@ -20,6 +20,12 @@ module.exports = {
20
20
  dependencies: ['metadata'],
21
21
 
22
22
  events: {
23
+ [`delete.metadata.${METADATA_TYPE}`]: {
24
+ async handler(ctx) {
25
+ const { objectApiName } = ctx.params;
26
+ return await this.objetActionHandlers.handleDeleteObject(ctx, objectApiName);
27
+ }
28
+ },
23
29
  [`$METADATA.${METADATA_TYPE}.*`]: {
24
30
  async handler(ctx) {
25
31
  return await this.objetActionHandlers.refresh(ctx);
@@ -209,6 +215,9 @@ module.exports = {
209
215
  await this.summaryActionHandler.add(objectConfig);
210
216
  }, async (objectConfig)=>{
211
217
  await this.lookupActionHandler.deleteAll(objectConfig);
218
+ await this.masterDetailActionHandler.deleteAll(objectConfig);
219
+ await this.formulaActionHandler.deleteAll(objectConfig);
220
+ await this.summaryActionHandler.deleteAll(objectConfig);
212
221
  }, async (objectConfig)=>{
213
222
  /**
214
223
  * 重算公式关系链时,可能存在待重算的对象还未进入缓存(但已经过了公式关系链计算过程)。所以进行延时
@@ -16,6 +16,20 @@ export class SummaryActionHandler {
16
16
  this.broker = broker;
17
17
  }
18
18
 
19
+ async deleteAll(objectConfig){
20
+ try {
21
+ if (!objectConfig) {
22
+ return;
23
+ }
24
+ // console.log(`deleteAll summary`, this.cacherKey(objectConfig.name, '*'))
25
+ await this.broker.call('metadata.fuzzyDelete', {key: this.cacherKey(objectConfig.name, '*')}, {meta: {}})
26
+ return true
27
+ } catch (error) {
28
+ this.broker.logger.error(error);
29
+ }
30
+ return false
31
+ }
32
+
19
33
  async getObjectConfig(objectApiName: string) {
20
34
  const data = await this.broker.call('objects.get', { objectApiName: objectApiName })
21
35
  return data ? data.metadata : null;