(sectionId, field, author = "agent")
| 743 | } |
| 744 | |
| 745 | function deleteSectionContent(sectionId, field, author = "agent") { |
| 746 | const section = findSectionOrThrow(sectionId); |
| 747 | const normalizedField = safeString(field).trim(); |
| 748 | if (!normalizedField) { |
| 749 | throw new CanvasError("invalid_field", "Field name is required."); |
| 750 | } |
| 751 | if (!section.content || !Object.prototype.hasOwnProperty.call(section.content, normalizedField)) { |
| 752 | return { section, field: normalizedField, removed: false }; |
| 753 | } |
| 754 | delete section.content[normalizedField]; |
| 755 | section.lastModified = nowIso(); |
| 756 | stateCache.lastUpdated = section.lastModified; |
| 757 | addChange({ |
| 758 | type: "file_modified", |
| 759 | summary: `Field removed from ${section.name}.${normalizedField}.`, |
| 760 | timestamp: section.lastModified, |
| 761 | sectionId: section.id, |
| 762 | }); |
| 763 | if (author === "human") { |
| 764 | addNote(sectionId, `Removed field "${normalizedField}".`, "human"); |
| 765 | } |
| 766 | return { section, field: normalizedField, removed: true }; |
| 767 | } |
| 768 | |
| 769 | function getSectionGuide(sectionId) { |
| 770 | const section = findSectionOrThrow(sectionId); |
no test coverage detected