@bettercms-ai/convert 0.4.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -164,7 +164,9 @@ declare function locate(brief: BriefLike, sources: SourceFile[], options?: Locat
164
164
  * sentence appears in three files" and "this field is bound" are different questions — and a path
165
165
  * is only `rewritten` when EVERY located occurrence of it was.
166
166
  */
167
- type PendingReason = "NO_ORIGINAL" | "NOT_IN_SOURCE" | "DIALECT_UNSUPPORTED" | "IN_EXPRESSION" | "IN_SCRIPT_OR_COMMENT" | "IN_DATA_FILE" | "AMBIGUOUS_LITERAL" | "KIND_MISMATCH" | "SUBSTRING_ONLY" | "PROP_TARGET_NOT_FOUND" | "PROP_DRILLED_DEEP" | "REPEATER_FIXED_LENGTH" | "DYNAMIC_PARAMS_UNAVAILABLE" | "BRIEF_META_UNPLACED" | "PARSE_ERROR" | "TIER3_UNVERIFIABLE";
167
+ type PendingReason = "NO_ORIGINAL" | "NOT_IN_SOURCE" | "DIALECT_UNSUPPORTED" | "IN_EXPRESSION" | "IN_SCRIPT_OR_COMMENT" | "IN_DATA_FILE" | "AMBIGUOUS_LITERAL" | "KIND_MISMATCH" | "SUBSTRING_ONLY" | "PROP_TARGET_NOT_FOUND" | "PROP_DRILLED_DEEP" | "REPEATER_FIXED_LENGTH" | "DYNAMIC_PARAMS_UNAVAILABLE" | "BRIEF_META_UNPLACED" | "PARSE_ERROR" | "TIER3_UNVERIFIABLE"
168
+ /** @see CANVAS_REASONS — these two are about the SITE's live-preview lane, not a brief path. */
169
+ | "CANVAS_BRIDGE_MANUAL" | "SSR_DRAFT_ROUTE";
168
170
  interface PendingPath {
169
171
  route: string;
170
172
  scope: "page" | "layout";
@@ -174,6 +176,10 @@ interface PendingPath {
174
176
  file?: string;
175
177
  reason: PendingReason;
176
178
  message?: string;
179
+ /** 1-based line in `file`, when the reason points at one place a human has to go. */
180
+ line?: number;
181
+ /** What to do about it, in prose — a recipe, not a diagnosis. @see message */
182
+ hint?: string;
177
183
  }
178
184
  /**
179
185
  * One path that was already DECLARED before this run — and how honestly.
@@ -237,6 +243,14 @@ interface ConversionReceipt {
237
243
  dynamicBindings: DynamicBinding[];
238
244
  /** Facts about the repository that shaped this run. OPTIONAL: an older receipt carries none. */
239
245
  notes?: ReceiptNote[];
246
+ /**
247
+ * Can the visual editor push drafts to this site? OPTIONAL: an older receipt carries none, and a
248
+ * reader must treat absent as unknown rather than as `"pending"`.
249
+ */
250
+ canvas?: {
251
+ lane: "bridge" | "pending";
252
+ files?: string[];
253
+ };
240
254
  }
241
255
  /**
242
256
  * One binding whose `data-bcms-field` is an expression, and where its value is written literally.
@@ -725,6 +739,35 @@ declare function helperSource(dialect: Dialect): string;
725
739
  */
726
740
  declare function isKnownHelper(content: string, dialect: Dialect): number | null;
727
741
 
742
+ /** The recipe an Astro site needs instead — never auto-migrate a site to SSR. */
743
+ declare const SSR_DRAFT_RECIPE: string;
744
+ interface CanvasSource {
745
+ path: string;
746
+ content: string;
747
+ /** The babel AST from `parseFile("jsx", …)`. Absent for every non-jsx dialect. */
748
+ ast?: unknown;
749
+ }
750
+ interface CanvasResult {
751
+ lane: "bridge" | "pending";
752
+ /** Files the bridge was installed in. */
753
+ files: string[];
754
+ /** Rewritten contents, by path. Empty when the lane is pending. */
755
+ edits: Map<string, string>;
756
+ pending: PendingPath[];
757
+ }
758
+ /**
759
+ * The one row every Astro conversion carries. Exported so a test names it instead of restating it.
760
+ */
761
+ declare const ASTRO_LANE_PENDING: PendingPath;
762
+ /**
763
+ * Install the draft bridge, or say why not.
764
+ *
765
+ * `routes` maps a brief route (`/about`) to its slug, so a route written as a literal in the page
766
+ * can name itself. An Astro project is refused wholesale: bridging it needs a server render, which
767
+ * is a deploy-shaped decision and never a codemod's.
768
+ */
769
+ declare function canvasBridge(sources: CanvasSource[], routes: Map<string, string>): CanvasResult;
770
+
728
771
  /**
729
772
  * Which files in a repository can possibly render a page's copy.
730
773
  *
@@ -1249,4 +1292,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
1249
1292
  receipt: ConversionReceipt;
1250
1293
  }>;
1251
1294
 
1252
- export { type AstNode, type AttrBinding, type Brief, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DeclaredPath, type Dialect, type DynamicBinding, type FileDeclaration, type FindSitesResult, HELPER_PATH, HELPER_VERSION, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionsReceipt, type Site, type SiteWhere, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, type ValidationCode, ValidationError, aliasesFrom, assertReceipt, assertSections, attrsFor, briefDigest, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, findSites, findSitesTolerant, flat, helperSource, importsIn, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeOfFile, stripTags, unreadableConfigs, walkAst };
1295
+ export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type Brief, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DeclaredPath, type Dialect, type DynamicBinding, type FileDeclaration, type FindSitesResult, HELPER_PATH, HELPER_VERSION, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionsReceipt, type Site, type SiteWhere, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, type ValidationCode, ValidationError, aliasesFrom, assertReceipt, assertSections, attrsFor, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, findSites, findSitesTolerant, flat, helperSource, importsIn, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeOfFile, stripTags, unreadableConfigs, walkAst };