@bettercms-ai/convert 0.2.1 → 0.3.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
@@ -175,6 +175,29 @@ interface PendingPath {
175
175
  reason: PendingReason;
176
176
  message?: string;
177
177
  }
178
+ /**
179
+ * One path that was already DECLARED before this run — and how honestly.
180
+ *
181
+ * 🔴 `readsFromCms: false` IS THE INTERESTING ROW. An element carrying a `data-bcms-field` (or a
182
+ * `data-bcms-props` / `data-bcms-layout-field`) that gets its copy some other way — a hand-written
183
+ * declaration on markup that still renders a literal, or reads it from the project's own data
184
+ * module — is DECLARED: the publisher writes into it and the editor can click it. It is simply not
185
+ * reading through this package's helper. Reporting it `NO_ORIGINAL` said the opposite of the truth
186
+ * — a path nobody had declared — and sent an agent to convert an element that was already done.
187
+ *
188
+ * The row is informative; `paths.alreadyDeclared` is the number the arithmetic uses, and both
189
+ * shapes count towards it.
190
+ */
191
+ interface DeclaredPath {
192
+ route: string;
193
+ scope: "page" | "layout";
194
+ path: string;
195
+ kind: string;
196
+ /** The file the declaration was found on. */
197
+ file?: string;
198
+ /** Does the declaring element read this value through the committed helper? */
199
+ readsFromCms: boolean;
200
+ }
178
201
  /** One file the conversion touched, and the tier that produced it. A file is exactly one tier. */
179
202
  interface ReceiptFile {
180
203
  path: string;
@@ -187,6 +210,13 @@ interface ConversionReceipt {
187
210
  declared: number;
188
211
  rewritten: number;
189
212
  alreadyDeclared: number;
213
+ /**
214
+ * One row per already-declared path, saying whether it reads from the CMS. @see DeclaredPath
215
+ *
216
+ * OPTIONAL, because a receipt written by an older version of this package does not carry it and
217
+ * a reader must not require it. The COUNT above is the contract; this is the detail.
218
+ */
219
+ declarations?: DeclaredPath[];
190
220
  pending: PendingPath[];
191
221
  };
192
222
  occurrences: {
@@ -205,6 +235,8 @@ interface ConversionReceipt {
205
235
  * a reviewer can see what to look for, and so the scan has somewhere to disagree with.
206
236
  */
207
237
  dynamicBindings: DynamicBinding[];
238
+ /** Facts about the repository that shaped this run. OPTIONAL: an older receipt carries none. */
239
+ notes?: ReceiptNote[];
208
240
  }
209
241
  /**
210
242
  * One binding whose `data-bcms-field` is an expression, and where its value is written literally.
@@ -226,6 +258,19 @@ interface DynamicBinding {
226
258
  literal: string;
227
259
  }[];
228
260
  }
261
+ /**
262
+ * Something about the REPOSITORY that changed what this run could see, named rather than swallowed.
263
+ *
264
+ * Not a path and not a refusal: a note is about a file the conversion READ, and it explains why a
265
+ * later reason may name the wrong cause. `TSCONFIG_UNREADABLE` is the first — a project config this
266
+ * package could not parse declares no `paths` aliases as far as it is concerned, so every aliased
267
+ * import resolves to nothing and the component behind it reads as one the page does not import.
268
+ */
269
+ interface ReceiptNote {
270
+ code: "TSCONFIG_UNREADABLE";
271
+ file: string;
272
+ message: string;
273
+ }
229
274
  /** Raised when the receipt does not add up. Never caught inside this package. */
230
275
  declare class ReceiptInvariantError extends Error {
231
276
  readonly code = "RECEIPT_INVARIANT";
@@ -712,6 +757,14 @@ declare function isSourceCandidate(path: string): boolean;
712
757
  * specifiers only, which is a smaller conversion and a true one.
713
758
  */
714
759
  declare function aliasesFrom(sources: SourceFile[]): Map<string, string[]>;
760
+ /**
761
+ * The project configs this package could not read, by path — a receipt NOTE, never a silent skip.
762
+ *
763
+ * A config that fails even the tolerant reader is one whose `paths` aliases nobody can resolve, so
764
+ * an aliased import reads as "not imported" and the refusal that follows names the wrong cause.
765
+ * The note says which file to look at. @see ConversionReceipt.notes
766
+ */
767
+ declare function unreadableConfigs(sources: SourceFile[]): string[];
715
768
  /** The repository path a specifier names, or null when it is not among the files we were given. */
716
769
  declare function resolveSpecifier(fromFile: string, specifier: string, files: Set<string>, aliases: Map<string, string[]>): string | null;
717
770
  /** What one local name was imported from, and WHICH export of it. */
@@ -963,6 +1016,9 @@ interface ComponentizePlan {
963
1016
  * `COMPONENT_CONFLICT` a file already sits at the component's path and this package did
964
1017
  * not write it.
965
1018
  * `REGISTRY_CONFLICT` the same, for the registry or the sections library.
1019
+ * `REGISTRY_UNREADABLE` the registry IS ours, and its tables cannot be read back. It is
1020
+ * rewritten whole every run, so rebuilding it from what this run
1021
+ * happened to see would drop the components it already names.
966
1022
  * `ROUTE_FILE_AMBIGUOUS` two files serve one route; the repository's own router has to
967
1023
  * pick, and a codemod that picks differently edits a dead page.
968
1024
  * `DIALECT_UNSUPPORTED` the page is svelte / vue / html; nothing is written for it.
@@ -971,7 +1027,7 @@ interface ComponentizePlan {
971
1027
  * `NOT_IN_SOURCE` no file we were given renders the group, or the route names no
972
1028
  * page file this package can find.
973
1029
  */
974
- type SectionPendingReason = "SECTION_ROOT_AMBIGUOUS" | "SECTION_NOT_CONTIGUOUS" | "SECTION_FREE_IDENTIFIERS" | "COMPONENT_CONFLICT" | "REGISTRY_CONFLICT" | "ROUTE_FILE_AMBIGUOUS" | "DIALECT_UNSUPPORTED" | "HELPER_CONFLICT" | "SNAPSHOT_INVALID" | "NOT_IN_SOURCE";
1030
+ type SectionPendingReason = "SECTION_ROOT_AMBIGUOUS" | "SECTION_NOT_CONTIGUOUS" | "SECTION_FREE_IDENTIFIERS" | "COMPONENT_CONFLICT" | "REGISTRY_CONFLICT" | "REGISTRY_UNREADABLE" | "ROUTE_FILE_AMBIGUOUS" | "DIALECT_UNSUPPORTED" | "HELPER_CONFLICT" | "SNAPSHOT_INVALID" | "NOT_IN_SOURCE";
975
1031
  interface PendingSection {
976
1032
  route: string;
977
1033
  groupKey: string;
@@ -998,6 +1054,17 @@ interface SectionsReceipt {
998
1054
  * account for every section of the plan if "done earlier" is a bucket of its own.
999
1055
  */
1000
1056
  alreadyExtracted: number;
1057
+ /**
1058
+ * The repository ALREADY has the component: the page imports it, and the registry now names it.
1059
+ *
1060
+ * 🔴 ITS OWN BUCKET, AND ORTHOGONAL TO PLACEMENT. Nothing was written for these — the file was
1061
+ * somebody's before this run and stays theirs — so counting them `extracted` would claim
1062
+ * authorship of bytes this package never produced, and counting them `pending` would say the CMS
1063
+ * has no component for a section it plainly does. Whether the page's call sites were then
1064
+ * replaced by the loop is a separate question, answered by `extracted` for the sections this run
1065
+ * did cut.
1066
+ */
1067
+ registered: number;
1001
1068
  pending: PendingSection[];
1002
1069
  }
1003
1070
  interface ComponentizeReceipt {
@@ -1013,6 +1080,15 @@ interface ComponentizeReceipt {
1013
1080
  * that does not place them has done exactly what it was told.
1014
1081
  */
1015
1082
  planPending: number;
1083
+ /**
1084
+ * Facts about the repository that shaped this run — the same list the conversion receipt carries.
1085
+ *
1086
+ * A tsconfig this package cannot read declares no `paths` aliases as far as it is concerned, and
1087
+ * THIS lane resolves a page's `<Hero />` through exactly those aliases: the section then reads as
1088
+ * one the page does not import, and `SECTION_ROOT_AMBIGUOUS` names the wrong cause. The note is
1089
+ * what points at the real one.
1090
+ */
1091
+ notes?: ReceiptNote[];
1016
1092
  }
1017
1093
  /** Raised when the receipt does not account for every section. Never caught inside this package. */
1018
1094
  declare class SectionInvariantError extends Error {
@@ -1126,4 +1202,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
1126
1202
  receipt: ConversionReceipt;
1127
1203
  }>;
1128
1204
 
1129
- 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 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 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, walkAst };
1205
+ 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 };