import { type Operation } from "effection"; import type { PackageJson } from "type-fest"; import type { PolicyArgs, PolicyHandlerResult, PolicyShape } from "../policy.js"; /** * A policy handler especially for policies that target package.json. * * @remarks * Package JSON handlers can be implemented in two ways: * - As an async function returning a Promise * - As an Effection generator function returning an Operation * * Both styles are supported to allow gradual migration and flexibility. * * @alpha */ export type PackageJsonHandler = (json: J, args: PolicyArgs) => Operation | Promise; /** * Input arguments for defining a package.json policy. * * @alpha */ export interface DefinePackagePolicyArgs { /** * The name of the policy. */ name: string; /** * A description of the policy's purpose. */ description: string; /** * The handler function that receives the parsed package.json and policy arguments. */ handler: PackageJsonHandler; /** * Optional default configuration for the policy. */ defaultConfig?: C; } /** * Define a repo policy for package.json files. * * @remarks * This is a helper function that creates a policy pre-configured to match * package.json files. The handler receives the parsed JSON content. * * @example * ```typescript * const MyPackagePolicy = definePackagePolicy({ * name: "MyPackagePolicy", * description: "Ensures package.json has required fields", * handler: async (json, { file }) => { * if (!json.name) { * return { error: "Missing name", fixable: false }; * } * return true; * }, * }); * ``` * * @alpha */ export declare function definePackagePolicy(args: DefinePackagePolicyArgs): PolicyShape; /** * Alias for definePackagePolicy. * @alpha */ export declare const packagePolicy: typeof definePackagePolicy; //# sourceMappingURL=definePackagePolicy.d.ts.map