Skip to content

Commit

Permalink
chore: log messages more consistently during export
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeneos committed Aug 22, 2024
1 parent 1760b5a commit e0f25fd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/vlocity-deploy/src/export/datapackExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ export class DatapackExporter {
* @param id Id of the object to export
*/
public async exportObject(id: string, context?: DatapackExportOptions): Promise<ExportResult> {
this.logger.info(`Exporting sobject with id: ${id}`);
this.logger.verbose(`Export SObject ${id}`);
const timer = new Timer();
const data = await this.lookupService.lookupById(id);
if (!data) {
throw new Error(`No object with id [${id}] does not exist in target org`);
throw new Error(`No SObject with id [${id}] does not exist in target org`);
}

await this.buildDatapack(data, context ?? {});
Expand All @@ -158,7 +158,7 @@ export class DatapackExporter {
const describe = await this.schema.describeSObjectById(record.id);
const matchingKey = await this.getMatchingKey(describe, record, context?.scope);
const exportStack = this.getExportPath(context.parent);
this.logger.info(`Building ${describe.name} (${record.Id}) datapack: ${matchingKey}`);
this.logger.verbose(`Build ${describe.name} (${record.Id}) datapack: ${matchingKey}`);

if (exportStack.includes(record.id)) {
this.logger.warn(`Internal reference detected for ${matchingKey}: ${exportStack.join(' -> ')}`);
Expand Down Expand Up @@ -508,7 +508,9 @@ export class DatapackExporter {
// If matching key fields are empty use auto-generated matching key
const allFieldsEmpty = matchingKeyFields.every(field => data[field] === '' || data[field] === undefined || data[field] === null);
if (allFieldsEmpty) {
this.logger.warn(`${data['id']} (${describe.name}) all matching key fields empty -- using auto-generated matching key instead`);
if (matchingKeyFields.length > 0) {
this.logger.warn(`${data['id']} (${describe.name}) all matching key fields [${matchingKeyFields.join(',')}] empty -- using auto-generated matching key instead`);
}
return this.getAutoMatchingKey(describe, data['id'], scope);
}

Expand Down Expand Up @@ -537,10 +539,6 @@ export class DatapackExporter {
return matchingKey;
}

private isAutoGeneratedMatchingKey(matchingKey: string) {
return matchingKey.includes('/auto-generated/');
}

private ignoreField(type: DescribeSObjectResult, field: Field, scope?: string) {
if (field.autoNumber || field.calculated) {
this.logger.debug(`Ignore field ${field.name} on ${type.name} as it is auto-number or calculated`);
Expand Down Expand Up @@ -589,9 +587,9 @@ export class DatapackExporter {

const detectedFields = this.guessMatchingFields(type);
if (detectedFields.length > 0) {
this.logger.warn(`No matching fields defined for ${type.name} - using fields: ${detectedFields}`);
this.logger.warn(`No matching fields defined for ${type.name} -- using fields: [${detectedFields}]`);
} else {
this.logger.warn(`No matching fields defined for ${type.name} - no unique fields found`);
this.logger.warn(`No matching fields defined for ${type.name} -- using auto-generated matching keys`);
}
return detectedFields;
}
Expand Down

0 comments on commit e0f25fd

Please sign in to comment.