@salesforce/metadata-plugins 1.0.0 → 1.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/schema/SchemaParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAA6C,MAAM,0BAA0B,CAAC;AASpG,qBAAa,YAAa,YAAW,eAAe,CAAC,aAAa,CAAC;IACjE,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,QAAQ,CAAC,SAAS,sBAA6B;IAE/C,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAKnD;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IA2HhF;;OAEG;IACH,QAAQ,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB;IAyBhD;;;OAGG;IACG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmDnE;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAuC1B;;;OAGG;YACW,eAAe;IA6D7B;;OAEG;YACW,WAAW;IAqGzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAqDrB,OAAO,CAAC,oBAAoB;CAiB7B"}
1
+ {"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/schema/SchemaParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAA6C,MAAM,0BAA0B,CAAC;AASpG,qBAAa,YAAa,YAAW,eAAe,CAAC,aAAa,CAAC;IACjE,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,QAAQ,CAAC,SAAS,sBAA6B;IAE/C,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAKnD;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IA8HhF;;OAEG;IACH,QAAQ,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,gBAAgB;IAyBhD;;;OAGG;IACG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmDnE;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAuC1B;;;OAGG;YACW,eAAe;IA6D7B;;OAEG;YACW,WAAW;IA2HzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAsDrB,OAAO,CAAC,oBAAoB;CAiB7B"}
@@ -69,6 +69,9 @@ export class SchemaParser {
69
69
  discoveredObjectCount: discovered.length,
70
70
  fieldOnlyObjectCount: discovered.filter((d) => !d.objectMetaPath).length,
71
71
  });
72
+ const triggerObjectName = this.getTriggerObjectName(triggerFilePath);
73
+ logger.info(`Trigger object: ${triggerObjectName}`);
74
+ span.setAttribute('triggerObject', triggerObjectName);
72
75
  const allObjects = [];
73
76
  const allRelationships = [];
74
77
  let parseFailures = 0;
@@ -86,11 +89,11 @@ export class SchemaParser {
86
89
  objectName: disc.objectName,
87
90
  hasObjectMeta: String(!!disc.objectMetaPath),
88
91
  });
92
+ if (disc.objectName === triggerObjectName) {
93
+ throw error;
94
+ }
89
95
  }
90
96
  }
91
- const triggerObjectName = this.getTriggerObjectName(triggerFilePath);
92
- logger.info(`Trigger object: ${triggerObjectName}`);
93
- span.setAttribute('triggerObject', triggerObjectName);
94
97
  const relatedNames = this.findRelatedObjects(triggerObjectName, allObjects, allRelationships, logger);
95
98
  const objects = allObjects.filter((o) => relatedNames.has(o.apiName));
96
99
  const objectNames = new Set(objects.map((o) => o.apiName));
@@ -339,15 +342,31 @@ export class SchemaParser {
339
342
  if (objectMetaPath) {
340
343
  const readResult = await this.platformContext.fileSystem.readFile(objectMetaPath);
341
344
  if (!readResult.success || !readResult.data) {
342
- const msg = readResult.error?.message ?? 'Unknown error';
343
345
  throw ErrorBuilder.create()
344
346
  .category(ErrorCategory.Dependency)
345
- .message(`Failed to read file: ${msg}`)
347
+ .message(`Failed to read ${this.platformContext.fileSystem.basename(objectMetaPath)}: ${readResult.error?.message ?? 'file is empty or unreadable'}`)
348
+ .context({ filePath: objectMetaPath, objectName })
349
+ .build();
350
+ }
351
+ let parsed;
352
+ try {
353
+ parsed = this.xmlParser.parse(readResult.data);
354
+ }
355
+ catch {
356
+ throw ErrorBuilder.create()
357
+ .category(ErrorCategory.Parsing)
358
+ .message(`Invalid XML in ${this.platformContext.fileSystem.basename(objectMetaPath)}`)
346
359
  .context({ filePath: objectMetaPath, objectName })
347
360
  .build();
348
361
  }
349
- const parsed = this.xmlParser.parse(readResult.data);
350
- customObject = parsed.CustomObject || {};
362
+ if (!parsed.CustomObject) {
363
+ throw ErrorBuilder.create()
364
+ .category(ErrorCategory.Parsing)
365
+ .message(`Invalid object metadata in ${this.platformContext.fileSystem.basename(objectMetaPath)}: missing CustomObject root element`)
366
+ .context({ filePath: objectMetaPath, objectName })
367
+ .build();
368
+ }
369
+ customObject = parsed.CustomObject;
351
370
  if (customObject.nameField?.type === 'AutoNumber') {
352
371
  nameFieldType = 'AutoNumber';
353
372
  }
@@ -418,19 +437,18 @@ export class SchemaParser {
418
437
  const rawType = fieldXml.type || 'Text';
419
438
  const isRelationship = rawType === 'Lookup' || rawType === 'MasterDetail';
420
439
  const referenceTo = fieldXml.referenceTo;
421
- // Build display type string
440
+ // Build display type string with physical constraints
422
441
  let dataType = rawType;
423
- if (rawType === 'Text' && fieldXml.length) {
424
- dataType = `Text(${fieldXml.length})`;
425
- }
426
- else if (rawType === 'Html' && fieldXml.length) {
427
- dataType = `Html(${fieldXml.length})`;
442
+ const stringTypesWithLength = ['Text', 'TextArea', 'LongTextArea', 'Html', 'EncryptedText'];
443
+ const numericTypesWithPrecision = ['Number', 'Currency', 'Percent'];
444
+ if (stringTypesWithLength.includes(rawType) && fieldXml.length) {
445
+ dataType = `${rawType}(${fieldXml.length})`;
428
446
  }
429
- else if (rawType === 'Number') {
430
- const p = fieldXml.precision || '';
431
- const s = fieldXml.scale || '';
432
- if (p || s) {
433
- dataType = `Number(${p},${s})`;
447
+ else if (numericTypesWithPrecision.includes(rawType)) {
448
+ const p = fieldXml.precision;
449
+ if (p !== null && p !== undefined) {
450
+ const s = fieldXml.scale !== null && fieldXml.scale !== undefined ? fieldXml.scale : 0;
451
+ dataType = `${rawType}(${p}, ${s})`;
434
452
  }
435
453
  }
436
454
  const field = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/metadata-plugins",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Visualizer implementations for Salesforce metadata",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",