@bettercms-ai/convert 0.7.0 → 0.8.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
@@ -283,9 +283,15 @@ interface DynamicBinding {
283
283
  * later reason may name the wrong cause. `TSCONFIG_UNREADABLE` is the first — a project config this
284
284
  * package could not parse declares no `paths` aliases as far as it is concerned, so every aliased
285
285
  * import resolves to nothing and the component behind it reads as one the page does not import.
286
+ *
287
+ * `PRIMITIVE_LIST` is the second, and it is about a CONVERSION rather than a silence: an array of
288
+ * primitives or tuples renders exactly the paths the codemod wrote into it, so every row's text is
289
+ * editable and the NUMBER of rows is still the template's — a row added in the CMS does not appear
290
+ * and a deleted one falls back to the template's own copy. The paths are `rewritten` and true; what
291
+ * the note adds is that ceiling. @see bindLists
286
292
  */
287
293
  interface ReceiptNote {
288
- code: "TSCONFIG_UNREADABLE";
294
+ code: "TSCONFIG_UNREADABLE" | "TSCONFIG_EXTENDS_ONLY" | "PRIMITIVE_LIST";
289
295
  file: string;
290
296
  message: string;
291
297
  }
@@ -716,7 +722,7 @@ declare function attrsFor(path: string, kind: string, props?: AttrBinding[], sco
716
722
  declare function propsAttribute(props: AttrBinding[]): string;
717
723
 
718
724
  /** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */
719
- declare const HELPER_VERSION = 5;
725
+ declare const HELPER_VERSION = 6;
720
726
  /** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */
721
727
  declare const HELPER_PATH: Record<Dialect, string | null>;
722
728
  /** The directory the snapshots live in, at the repository root. */
@@ -794,18 +800,41 @@ interface DataSplice {
794
800
  end: number;
795
801
  text: string;
796
802
  }
803
+ /** What one drill did, or why it could not. @see drillProp, which is the implementation. */
804
+ type DrillOutcome = {
805
+ ok: true;
806
+ edits: {
807
+ file: string;
808
+ splices: DataSplice[];
809
+ }[];
810
+ } | {
811
+ ok: false;
812
+ reason: PendingReason;
813
+ };
797
814
  interface DataContext {
798
815
  content: string;
799
816
  parsed: ParsedFile;
800
817
  dialect: Dialect;
801
818
  /** The name `bcmsRowsAs` is imported under here. @see scope.ts */
802
819
  rowsAs: string;
820
+ /** The names `bcmsList` and `bcmsTuples` are imported under here. @see bindLists */
821
+ list: string;
822
+ tuples: string;
803
823
  /** The name `bcms` is imported under here — the scalar lane's read. @see scope.ts */
804
824
  read: string;
805
825
  /** The identifier a page's snapshot is imported under in this file. @see scope.ts */
806
826
  snapshotName: (slug: string) => string;
807
827
  /** How this file reads its route parameter, on a dynamic route. Null off one. */
808
828
  slug: string | null;
829
+ /**
830
+ * Follow one prop from a call site in THIS file into the component that renders it.
831
+ *
832
+ * Handed in rather than imported: the drill needs every source file, the alias table and the set
833
+ * of files this conversion already rewrites, and none of that is one file's business. Absent on
834
+ * a caller that cannot drill (the tests of this lane alone), which makes a row leaf passed as a
835
+ * prop the refusal it was before. @see index.ts
836
+ */
837
+ drill?: (component: string, prop: string, kind: string) => Promise<DrillOutcome>;
809
838
  }
810
839
  interface DataResult {
811
840
  splices: DataSplice[];
@@ -813,6 +842,16 @@ interface DataResult {
813
842
  usesRead: boolean;
814
843
  /** Did anything here write a `bcmsRowsAs(…)` read? */
815
844
  usesRows: boolean;
845
+ /** Did anything here write a `bcmsList(…)` / `bcmsTuples(…)` read? @see bindLists */
846
+ usesList: boolean;
847
+ usesTuples: boolean;
848
+ /**
849
+ * One sentence per list this lane bound, for the receipt's `PRIMITIVE_LIST` notes.
850
+ *
851
+ * The FILE is the caller's to add: this lane is handed one file's bytes and does not know its
852
+ * name, exactly as `findSites` does not. @see ReceiptNote
853
+ */
854
+ notes: string[];
816
855
  /** The page slugs whose snapshot this lane now reads, so the file imports them. */
817
856
  slugs: string[];
818
857
  /** Target keys this plan bound. */
@@ -827,6 +866,24 @@ interface DataResult {
827
866
  key: string;
828
867
  reason: PendingReason;
829
868
  }[];
869
+ /** Edits to the COMPONENT files this lane drilled a row leaf into. @see DataContext.drill */
870
+ componentEdits: {
871
+ file: string;
872
+ splices: DataSplice[];
873
+ }[];
874
+ /**
875
+ * One drilled row leaf: the component file that now declares it, and the call site's own entry.
876
+ *
877
+ * The receipt records both halves of a prop conversion — the element is in another file and the
878
+ * path it reads is at the call site — and a reader cannot verify either half from the other
879
+ * alone. @see DynamicBinding
880
+ */
881
+ props: {
882
+ file: string;
883
+ prop: string;
884
+ path: string;
885
+ literal: string;
886
+ }[];
830
887
  }
831
888
  /**
832
889
  * Bind every repeater group whose copy lives in a data literal in this same file.
@@ -835,7 +892,7 @@ interface DataResult {
835
892
  * account for are returned in `refused` with the reason, and are never partially written — a group
836
893
  * half bound is a row whose second field silently stops reflecting.
837
894
  */
838
- declare function bindDataLiterals(ctx: DataContext, members: DataMember[]): DataResult;
895
+ declare function bindDataLiterals(ctx: DataContext, members: DataMember[]): Promise<DataResult>;
839
896
 
840
897
  /**
841
898
  * An image whose `original` is a BUILT url, and the import the template actually renders.
@@ -986,6 +1043,17 @@ declare function aliasesFrom(sources: SourceFile[]): Map<string, string[]>;
986
1043
  * The note says which file to look at. @see ConversionReceipt.notes
987
1044
  */
988
1045
  declare function unreadableConfigs(sources: SourceFile[]): string[];
1046
+ /**
1047
+ * Project configs whose aliases are NOT in them — they `extends` another file.
1048
+ *
1049
+ * 🔴 AN ABSENT ALIAS TABLE LOOKS EXACTLY LIKE A PROJECT THAT HAS NONE, and the two have opposite
1050
+ * consequences: the second converts relative imports and is complete, the first refuses every
1051
+ * component reached through `@components/*` with the file sitting right there. `extends` chains
1052
+ * are not followed — the base may be a published package (`@tsconfig/strict`) rather than a file
1053
+ * in the tree — so the honest answer is to say so in the receipt rather than to resolve nothing
1054
+ * silently. @see aliasesFrom
1055
+ */
1056
+ declare function extendedConfigs(sources: SourceFile[]): string[];
989
1057
  /** The repository path a specifier names, or null when it is not among the files we were given. */
990
1058
  declare function resolveSpecifier(fromFile: string, specifier: string, files: Set<string>, aliases: Map<string, string[]>): string | null;
991
1059
  /** What one local name was imported from, and WHICH export of it. */
@@ -1470,4 +1538,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
1470
1538
  receipt: ConversionReceipt;
1471
1539
  }>;
1472
1540
 
1473
- 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 DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, type FileDeclaration, type FindSitesResult, HELPER_PATH, HELPER_VERSION, type ImageResult, type ImageTarget, 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, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, 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 };
1541
+ 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 DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, type FileDeclaration, type FindSitesResult, HELPER_PATH, HELPER_VERSION, type ImageResult, type ImageTarget, 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, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, 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 };