fromSections

View as MarkdownOpen in Claude

Static factory method that reconstructs a PomBuilder from an array of PomSectionData objects. Use this to restore a prompt serialized via toJson() or toDict().

Parameters

sections
PomSectionData[]Required

Array of section data objects. Each may include title, body, bullets, numbered, numberedBullets, and nested subsections. Untitled sections are allowed and still render, but they are not addressable by title — they are dropped from the title lookup, so hasSection() and getSection() cannot find them.

Returns

PomBuilder — a new builder populated with the given sections.

Example

1import { PomBuilder } from '@signalwire/sdk';
2
3const data = [
4 { title: 'Intro', body: 'Welcome.' },
5 { title: 'Rules', bullets: ['Be nice.', 'Stay on topic.'] },
6];
7
8const pom = PomBuilder.fromSections(data);
9console.log(pom.renderMarkdown());