@salesforce/metadata-plugins 1.0.0 → 1.0.2
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;
|
|
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;IA4DrB,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
|
|
347
|
+
.message(`Failed to read ${this.platformContext.fileSystem.basename(objectMetaPath)}: ${readResult.error?.message ?? 'file is empty or unreadable'}`)
|
|
346
348
|
.context({ filePath: objectMetaPath, objectName })
|
|
347
349
|
.build();
|
|
348
350
|
}
|
|
349
|
-
|
|
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)}`)
|
|
359
|
+
.context({ filePath: objectMetaPath, objectName })
|
|
360
|
+
.build();
|
|
361
|
+
}
|
|
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,21 +437,24 @@ 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
|
-
|
|
440
|
+
const isFormula = !!fieldXml.formula;
|
|
441
|
+
// Build display type string with physical constraints
|
|
422
442
|
let dataType = rawType;
|
|
423
|
-
|
|
424
|
-
|
|
443
|
+
const stringTypesWithLength = ['Text', 'TextArea', 'LongTextArea', 'Html', 'EncryptedText'];
|
|
444
|
+
const numericTypesWithPrecision = ['Number', 'Currency', 'Percent'];
|
|
445
|
+
if (stringTypesWithLength.includes(rawType) && fieldXml.length) {
|
|
446
|
+
dataType = `${rawType}(${fieldXml.length})`;
|
|
425
447
|
}
|
|
426
|
-
else if (rawType
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const s = fieldXml.scale || '';
|
|
432
|
-
if (p || s) {
|
|
433
|
-
dataType = `Number(${p},${s})`;
|
|
448
|
+
else if (numericTypesWithPrecision.includes(rawType)) {
|
|
449
|
+
const p = fieldXml.precision;
|
|
450
|
+
if (p !== null && p !== undefined) {
|
|
451
|
+
const s = fieldXml.scale !== null && fieldXml.scale !== undefined ? fieldXml.scale : 0;
|
|
452
|
+
dataType = `${rawType}(${p}, ${s})`;
|
|
434
453
|
}
|
|
435
454
|
}
|
|
455
|
+
if (isFormula) {
|
|
456
|
+
dataType = `Formula(${dataType})`;
|
|
457
|
+
}
|
|
436
458
|
const field = {
|
|
437
459
|
apiName,
|
|
438
460
|
label: fieldXml.label || apiName,
|