From 79efd648ac1bd41fee581d6d01cf8ed8c1aceb14 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Mon, 8 Dec 2025 11:02:59 -0800 Subject: [PATCH] condense parameters Signed-off-by: Meredith Lancaster --- packages/attest/src/artifact-metadata.ts | 35 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/attest/src/artifact-metadata.ts b/packages/attest/src/artifact-metadata.ts index 6aa11a96..95519b85 100644 --- a/packages/attest/src/artifact-metadata.ts +++ b/packages/attest/src/artifact-metadata.ts @@ -5,22 +5,37 @@ import {RequestHeaders} from '@octokit/types' const CREATE_STORAGE_RECORD_REQUEST = 'POST /orgs/{owner}/artifacts/metadata/storage-record' const DEFAULT_RETRY_COUNT = 5 +export type ArtifactParams = { + name: string + digest: string + version?: string + status?: string +} + +export type PackageRegistryParams = { + registryUrl: string + artifactUrl?: string + registryRepo?: string + path?: string +} + export type WriteOptions = { retry?: number headers?: RequestHeaders } /** - * Writes a storage record on behalf of an artifact - * @param artifactName - The name of the artifact. - * @param artifactDigest - The digest of the artifact. + * Writes a storage record on behalf of an artifact that has been attested + * @param artifactParams - parameters for the artifact. + * @param packageRegistryParams - parameters for the package registry. * @param token - The GitHub token for authentication. + * @param options - Optional parameters for the write operation. * @returns The ID of the storage record. * @throws Error if the storage record fails to persist. */ export const createStorageRecord = async ( - artifactName: string, - artifactDigest: string, + artifactParams: ArtifactParams, + packageRegistryParams: PackageRegistryParams, token: string, options: WriteOptions = {} ): Promise => { @@ -32,8 +47,14 @@ export const createStorageRecord = async ( owner: github.context.repo.owner, repo: github.context.repo.repo, headers: options.headers, - artifact_name: artifactName, - artifact_digest: artifactDigest, + artifact_name: artifactParams.name, + artifact_digest: artifactParams.digest, + artifact_version: artifactParams.version, + artifact_status: artifactParams.status, + registry_url: packageRegistryParams.registryUrl, + artifact_url: packageRegistryParams.artifactUrl, + registry_repo: packageRegistryParams.registryRepo, + path: packageRegistryParams.path }) const data =