diff --git a/src/index.ts b/src/index.ts index 02297cd..af04c58 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,3 +20,4 @@ export { export { npmRegistryDownloadsApiUrl, npmRegistryUrl } from "./npm-registry"; export { packageManifestSchema, type PackageManifest } from "./package-manifest"; export { personSchema, type Person } from "./person"; +export { repositorySchema, type Repository } from "./repository"; diff --git a/src/repository.ts b/src/repository.ts new file mode 100644 index 0000000..ba2cf53 --- /dev/null +++ b/src/repository.ts @@ -0,0 +1,22 @@ +import { z } from "zod"; + +/** +Zod schema for the repository for a package. +*/ +export const repositorySchema = z.object({ + /** Machine-readable repository URL (e.g., `https://github.com/user/repo.git`). */ + url: z.string(), + + /** Repository type (e.g., `git`). */ + type: z.string().optional(), + + /** Directory in a monorepo where the package's source code is located. */ + directory: z.string().optional(), +}); + +/** +`Repository` describes the repository for a package. + +@see {@link https://docs.npmjs.com/cli/v10/configuring-npm/package-json#repository} +*/ +export type Repository = z.infer;