@inforge/migrations-tools-cli 1.2.0 → 1.2.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.
- package/dist/index.js +14 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -508,43 +508,24 @@ var TriggersHandler = class {
|
|
|
508
508
|
triggerNames,
|
|
509
509
|
status
|
|
510
510
|
});
|
|
511
|
-
const query = `
|
|
512
|
-
SELECT Id, Name
|
|
513
|
-
FROM ApexTrigger
|
|
514
|
-
WHERE Name IN (${triggerNames.map((n) => `'${n}'`).join(", ")})
|
|
515
|
-
`;
|
|
516
|
-
await this.logger.debug("Executing Tooling API query", { query });
|
|
517
511
|
try {
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
records: result.records
|
|
522
|
-
});
|
|
523
|
-
if (result.records.length === 0) {
|
|
524
|
-
await this.logger.error("No triggers found with specified names", null, {
|
|
525
|
-
triggerNames,
|
|
526
|
-
query
|
|
527
|
-
});
|
|
528
|
-
throw new Error("No triggers found with the specified names");
|
|
529
|
-
}
|
|
530
|
-
const updates = result.records.map((trigger) => ({
|
|
531
|
-
Id: trigger.Id,
|
|
532
|
-
Status: status
|
|
512
|
+
const updates = triggerNames.map((name) => ({
|
|
513
|
+
fullName: name,
|
|
514
|
+
status
|
|
533
515
|
}));
|
|
534
|
-
await this.logger.debug("Preparing
|
|
535
|
-
const results = await connection.
|
|
536
|
-
await this.logger.debug("
|
|
516
|
+
await this.logger.debug("Preparing Metadata API update", { updates });
|
|
517
|
+
const results = await connection.metadata.update("ApexTrigger", updates);
|
|
518
|
+
await this.logger.debug("Metadata API update results", {
|
|
537
519
|
results: Array.isArray(results) ? results : [results]
|
|
538
520
|
});
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
521
|
+
const resultArray = Array.isArray(results) ? results : [results];
|
|
522
|
+
const failures = resultArray.filter((r) => !r.success);
|
|
523
|
+
if (failures.length > 0) {
|
|
524
|
+
await this.logger.error("Some triggers failed to update", null, {
|
|
525
|
+
failures,
|
|
526
|
+
totalAttempted: resultArray.length
|
|
527
|
+
});
|
|
528
|
+
throw new Error(`Failed to update ${failures.length} trigger(s): ${JSON.stringify(failures)}`);
|
|
548
529
|
}
|
|
549
530
|
await this.logger.info("Successfully updated trigger status", {
|
|
550
531
|
triggerCount: triggerNames.length,
|
package/package.json
CHANGED