@adeu/core 1.15.1 → 1.16.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adeu/core",
3
- "version": "1.15.1",
3
+ "version": "1.16.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -551,4 +551,23 @@ describe("Resolved Bugs Core Engine Verification", () => {
551
551
  const text = await extractTextFromBuffer(buf, true);
552
552
  expect(text).toContain("updated text");
553
553
  });
554
+
555
+ it("Unparseable String Core: process_batch throws validation error instead of TypeError for raw strings", async () => {
556
+ const doc = await createTestDocument();
557
+ addParagraph(doc, "original text");
558
+ const engine = new RedlineEngine(doc);
559
+
560
+ let caught: any = null;
561
+ try {
562
+ engine.process_batch([
563
+ "modify original text to updated text"
564
+ ] as any);
565
+ } catch (e) {
566
+ caught = e;
567
+ }
568
+
569
+ expect(caught).toBeDefined();
570
+ expect(caught.name).toBe("BatchValidationError");
571
+ expect(caught.message).toContain("Invalid change format");
572
+ });
554
573
  });
package/src/engine.ts CHANGED
@@ -1228,6 +1228,12 @@ export class RedlineEngine {
1228
1228
 
1229
1229
  for (let i = 0; i < edits.length; i++) {
1230
1230
  const edit = edits[i];
1231
+ if (typeof edit !== "object" || edit === null) {
1232
+ errors.push(
1233
+ `- Edit ${i + 1} Failed: Invalid change format. Expected a JSON object, but received a primitive ${typeof edit}. Do not pass raw strings.`
1234
+ );
1235
+ continue;
1236
+ }
1231
1237
  if (!edit.target_text) continue;
1232
1238
 
1233
1239
  const is_regex = (edit as any).regex || false;
@@ -1506,10 +1512,10 @@ export class RedlineEngine {
1506
1512
  ): any {
1507
1513
  this.skipped_details = [];
1508
1514
  const actions = changes.filter((c) =>
1509
- ["accept", "reject", "reply"].includes(c.type),
1515
+ c !== null && typeof c === "object" && ["accept", "reject", "reply"].includes(c.type),
1510
1516
  );
1511
1517
  const edits = changes.filter(
1512
- (c) => !["accept", "reject", "reply"].includes(c.type),
1518
+ (c) => c === null || typeof c !== "object" || !["accept", "reject", "reply"].includes(c.type),
1513
1519
  );
1514
1520
 
1515
1521
  // BUG-7: Unified single-pass validation in wet-run / standard mode
@@ -1673,11 +1679,17 @@ export class RedlineEngine {
1673
1679
  const resolved_edits: [any, string | null][] = [];
1674
1680
 
1675
1681
  for (const edit of edits) {
1682
+ if (typeof edit !== "object" || edit === null) {
1683
+ skipped++;
1684
+ continue;
1685
+ }
1676
1686
  edit._applied_status = false;
1677
1687
  edit._error_msg = null;
1678
1688
  }
1679
1689
 
1680
1690
  for (const edit of edits) {
1691
+ if (typeof edit !== "object" || edit === null) continue;
1692
+
1681
1693
  if (
1682
1694
  edit._resolved_start_idx !== undefined &&
1683
1695
  edit._resolved_start_idx !== null