import { CodeMetaJson } from "../sources/codemeta-json.js"; import { NodePackageJsonData } from "../sources/node-package-json.js"; declare namespace template_helpers_d_exports { export { REPLACEMENTS, collectArrayField, collectField, dependencyNames, ensureArray, firstOf, hasDependencyWithId, isAuthoredBy, isOnGithubAccountOf, isValidUrl, mixedStringsToArray, nonEmpty, splitCommaSeparated, stripNamespace, stripUndefined, toAlias, toBasicLicense, toBasicLicenses, toBasicNames, toDelimitedString, toLocalUrl, toMarkdownLink, toMb, toOptionalMarkdownLink, toStatus, toStatusLegacy, usesPnpm }; } /** * Extract the first element from a `OneOrMany` value. * * Metadata sources may return a single record or an array of records. This * helper normalizes access so you can safely retrieve the first record * regardless of cardinality. */ export declare function firstOf(value: T | T[] | undefined): T | undefined; /** * Wrap a value in an array if it isn't one already. Returns an empty array for * `undefined` or `null`. */ export declare function ensureArray(value: null | T | T[] | undefined): T[]; /** * Collect values from all records in a `OneOrMany>` source. * Runs the accessor on each record's `.data` and returns all non-undefined * results. * * Useful for extracting a specific field from sources that may contain multiple * records (e.g. multiple Cargo.toml files in a workspace). */ export declare function collectField(source: T | T[] | undefined, accessor: (data: T['data']) => R | undefined): R[]; /** * Collect and flatten array values from all records in a * `OneOrMany>` source. Runs the accessor on each record's * `.data` and flattens the resulting arrays. */ export declare function collectArrayField(source: T | T[] | undefined, accessor: (data: T['data']) => R[] | undefined): R[]; /** * Return the array if non-empty, otherwise undefined. Useful for converting * empty collection results to undefined before `stripUndefined`. */ export declare function nonEmpty(array: T[]): T[] | undefined; /** * Split a string on commas, trimming each part and filtering out empty strings. * Returns an empty array for `undefined` or empty input. */ export declare function splitCommaSeparated(value: string | undefined): string[]; /** * Join an array of strings with a delimiter, filtering out undefined values. */ export declare function toDelimitedString(source: Array | string | string[] | undefined, delimiter?: string): string | undefined; /** * Convert a URL or path to a markdown link using its basename as the label. */ export declare function toMarkdownLink(value: string | undefined): string | undefined; /** * Wrap a value in a markdown link if a URL is provided, otherwise return the * value as-is. */ export declare function toOptionalMarkdownLink(name: string, url: string | undefined): string; /** * Convert bytes to megabytes (rounded). (MB, not MiB.) */ export declare function toMb(bytes: unknown): number | undefined; /** * Strip the namespace or directory prefix from a package name or path. */ export declare function stripNamespace(value: string): string; /** * Convert a package name to a human-friendly alias using title case and * brand-name corrections. */ export declare function toAlias(value: string | undefined): string | undefined; export declare const REPLACEMENTS: Map; /** * Takes any value and extracts all strings from it. Returns string[] if any * strings were found, or undefined otherwise. Optionally performs * case-insensitive string replacement with `replacements`. */ export declare function mixedStringsToArray(value: unknown, replacements?: Map): string[] | undefined; /** * Convert a filename or relative path to a local `file://` URL rooted at * `repoPath`. */ export declare function toLocalUrl(value: string | undefined, repoPath: string | undefined): string | undefined; /** * Recursively removes `undefined` values and empty objects from an object. Only * recurses into plain objects and arrays. Non-plain objects (like Date) are * preserved as-is. Array elements that are `undefined` are also removed. * Returns `undefined` if the entire input becomes empty after stripping. */ export declare function stripUndefined(value: T): T; /** * Strip the SPDX license URL prefix, returning just the license identifier. */ export declare function toBasicLicense(source: string | undefined): string | undefined; /** * Normalize one or more license values to plain SPDX identifiers, stripping URL * prefixes. */ export declare function toBasicLicenses(...sources: Array): string[] | undefined; type CodeMetaPersonOrOrg = NonNullable[number]; /** * Extract display names from an array of `CodeMetaPersonOrOrg`. */ export declare function toBasicNames(source: CodeMetaPersonOrOrg[] | undefined): string[] | undefined; /** * Check id a project uses a specific dependency */ export declare function hasDependencyWithId(id: string, codemeta: CodeMetaJson): boolean; /** * Simple list of all dependencies */ export declare function dependencyNames(codemeta: CodeMetaJson, filter?: 'all' | 'dev' | 'prod'): string[] | undefined; /** * Check if the project uses pnpm as its package manager. */ export declare function usesPnpm(packageJson: NodePackageJsonData): boolean; /** * True if project was authored by specific person(s). */ export declare function isAuthoredBy(codemetaAuthorName?: CodeMetaPersonOrOrg | CodeMetaPersonOrOrg[], expectedAuthorName?: string | string[]): boolean | undefined; /** * True if project is on a specific GitHub account(s). */ export declare function isOnGithubAccountOf(codeRepo?: string, githubUsername?: string | string[]): boolean | undefined; /** * Legacy heuristic project status based on authorship and GitHub account. */ export declare function toStatusLegacy(codeRepo?: string, codemetaAuthorName?: CodeMetaPersonOrOrg | CodeMetaPersonOrOrg[], authorName?: string | string[], githubUsername?: string | string[]): /** It's a fork on GitHub */ ('fork' | /** I am original author, local or on github */ 'source' | /** Someone else's local code */ 'unmaintained') | undefined; /** * Heuristic project status based on authorship and GitHub account. */ export declare function toStatus(codeRepo?: string, codemetaAuthorName?: CodeMetaPersonOrOrg | CodeMetaPersonOrOrg[], codemetaContributorOrMaintainerName?: CodeMetaPersonOrOrg | CodeMetaPersonOrOrg[], isGitHubFork?: boolean, myAuthorName?: string | string[], myGithubUsername?: string | string[]): 'author' | /** I wrote the repo */ 'maintainer' | /** I contribute or help maintain it */ 'observer' | /** I look at this repo */ 'unknown' /** It's unclear */; /** * True if valid url */ export declare function isValidUrl(value: string): boolean; //#endregion export { template_helpers_d_exports };