codemod 2.0.0-alpha.2 → 2.0.0-alpha.4

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/types/index.d.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  /// <reference path="llrt/index.d.ts" />
3
3
  /// <reference path="modules/ast-grep.d.ts" />
4
4
  /// <reference path="modules/llm.d.ts" />
5
- /// <reference path="modules/metrics.d.ts" />
6
5
  /// <reference path="modules/runtime.d.ts" />
7
6
  /// <reference path="modules/workflow.d.ts" />
8
7
  /// <reference path="modules/langs.d.ts" />
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -589,10 +589,31 @@ declare module "codemod:ast-grep" {
589
589
  */
590
590
  export type Transform<T extends TypesMap> = Codemod<T>;
591
591
 
592
+ /**
593
+ * Any JSON a transform reports about its file. A `jssg` step's `data`
594
+ * lists it per file, or folds it with the step's reducer. Explicit `null`
595
+ * is reported; missing or `undefined` data is omitted.
596
+ *
597
+ * @example
598
+ * ```ts
599
+ * return { edit: null, data: { props: props.map((p) => p.text()) } };
600
+ * ```
601
+ */
602
+ export type TransformData =
603
+ | string
604
+ | number
605
+ | boolean
606
+ | null
607
+ | readonly TransformData[]
608
+ | { readonly [key: string]: TransformData };
609
+
610
+ /** The new text (`edit`, or `null` for no change), and data to report. */
611
+ export type TransformResult = { edit?: string | null; data?: TransformData };
612
+
592
613
  export type Codemod<T extends TypesMap> = (
593
614
  root: SgRoot<T>,
594
615
  options: TransformOptions<T>,
595
- ) => Promise<string | null>;
616
+ ) => Promise<string | null | TransformResult>;
596
617
 
597
618
  export type GetSelectorOptions<_T extends TypesMap> = {
598
619
  params: Record<string, string>;