import { DatasourceAction, ReadShape } from "./action.js";

//#region src/search-engines.d.ts
/** What a server route handler gets. Only the part these handlers read. */
type HandlerContext = {
  request: Request;
};
/** The pages of one public record page: the query that lists its records, and the path of one record's page. */
type SitemapRecordPages = {
  query: DatasourceAction<ReadShape>;
  path: (record: {
    id: string;
    fields: Record<string, unknown>;
  }) => string;
};
/** What the sitemap lists. Only pages a signed-out visitor can open belong here. */
type SitemapSources = {
  /** The paths of public pages that show no single record, like `"/"` or `"/bikes"`. */
  pages: ReadonlyArray<string>;
  /** Each public record page, with one entry per record its query returns. */
  records?: ReadonlyArray<SitemapRecordPages>;
};
/**
 * Answers `/robots.txt`: search engines may crawl the app, AI training crawlers
 * may not, and the `Sitemap:` line points to the app's `/sitemap.xml`. An
 * app's own `public/robots.txt` wins over this route.
 *
 * @example
 * // src/routes/robots[.]txt.ts
 * export const Route = createFileRoute("/robots.txt")({
 *   server: { handlers: { GET: robotsTxt() } },
 * })
 */
declare function robotsTxt(): (ctx: HandlerContext) => Response;
/**
 * Answers `/sitemap.xml` with the app's public pages and one page per public
 * record. It reads the records as a signed-out visitor and keeps the file for
 * a day, so search engines get only public records and the datasource is read
 * at most once a day per region. A new publish starts a new file.
 *
 * @example
 * // src/routes/sitemap[.]xml.ts
 * export const Route = createFileRoute("/sitemap.xml")({
 *   server: {
 *     handlers: {
 *       GET: sitemapXml({
 *         pages: ["/", "/bikes"],
 *         records: [{ query: bikesQuery, path: (bike) => `/bikes/${bike.id}` }],
 *       }),
 *     },
 *   },
 * })
 */
declare function sitemapXml(sources: SitemapSources): (ctx: HandlerContext) => Promise<Response>;
//#endregion
export { SitemapRecordPages, SitemapSources, robotsTxt, sitemapXml };