mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-05-24 21:55:04 +00:00
refactor: update validation data structure and improve function documentation
- Removed optional `repoId` from `ExtensionPublishValidationData` and adjusted related function to reflect this change. - Added a note in the `validateJsrPackageAsKunkunExtension` function documentation to clarify frontend/backend verification logic. - Updated `ExtPublishMetadata` to rename `repoId` to `repoNodeId` for clarity.
This commit is contained in:
parent
d8cf220b2c
commit
7bb70104bf
@ -209,6 +209,7 @@ export function jsrPackageExists(scope: string, name: string, version?: string):
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a Jsr package as a Kunkun extension
|
* Validate a Jsr package as a Kunkun extension
|
||||||
|
* !This function will also run in frontend, so if there is any verification logic that must be run in backend, do not add it here
|
||||||
* - check if jsr pkg is linked to a github repo
|
* - check if jsr pkg is linked to a github repo
|
||||||
* - check if jsr pkg is signed with github action
|
* - check if jsr pkg is signed with github action
|
||||||
* - check if user's github username is the same as repo's owner name
|
* - check if user's github username is the same as repo's owner name
|
||||||
@ -373,15 +374,6 @@ export async function validateJsrPackageAsKunkunExtension(payload: {
|
|||||||
}
|
}
|
||||||
const rekorInfo = await getInfoFromRekorLog(rekorLogId)
|
const rekorInfo = await getInfoFromRekorLog(rekorLogId)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Get GitHub Node ID */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
const githubRepoMetadata = await getGitHubRepoMetadata(
|
|
||||||
githubRepo.owner,
|
|
||||||
githubRepo.name,
|
|
||||||
payload.githubToken
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pkgJson: parseResult.output,
|
pkgJson: parseResult.output,
|
||||||
@ -397,8 +389,7 @@ export async function validateJsrPackageAsKunkunExtension(payload: {
|
|||||||
commit: rekorInfo.commit,
|
commit: rekorInfo.commit,
|
||||||
repo: githubRepo.name,
|
repo: githubRepo.name,
|
||||||
owner: githubRepo.owner,
|
owner: githubRepo.owner,
|
||||||
workflowPath: rekorInfo.workflowPath,
|
workflowPath: rekorInfo.workflowPath
|
||||||
repoId: githubRepoMetadata.node_id
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,7 @@ export const ExtensionPublishValidationData = v.object({
|
|||||||
commit: v.string(),
|
commit: v.string(),
|
||||||
repo: v.string(),
|
repo: v.string(),
|
||||||
owner: v.string(),
|
owner: v.string(),
|
||||||
workflowPath: v.string(),
|
workflowPath: v.string()
|
||||||
repoId: v.optional(v.string())
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
export type ExtensionPublishValidationData = v.InferOutput<typeof ExtensionPublishValidationData>
|
export type ExtensionPublishValidationData = v.InferOutput<typeof ExtensionPublishValidationData>
|
||||||
|
@ -2,6 +2,7 @@ import { ExtPackageJson, License } from "@kksh/api/models"
|
|||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
import {
|
import {
|
||||||
authenticatedUserIsMemberOfGitHubOrg,
|
authenticatedUserIsMemberOfGitHubOrg,
|
||||||
|
getGitHubRepoMetadata,
|
||||||
parseGitHubRepoFromUri,
|
parseGitHubRepoFromUri,
|
||||||
userIsPublicMemberOfGitHubOrg
|
userIsPublicMemberOfGitHubOrg
|
||||||
} from "../github"
|
} from "../github"
|
||||||
@ -237,6 +238,7 @@ export async function validateNpmPackageAsKunkunExtension(payload: {
|
|||||||
provenance.summary.sourceRepositoryDigest,
|
provenance.summary.sourceRepositoryDigest,
|
||||||
parseResult.output.readme ?? "README.md"
|
parseResult.output.readme ?? "README.md"
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
pkgJson: parseResult.output,
|
pkgJson: parseResult.output,
|
||||||
|
@ -21,7 +21,9 @@ export const ExtPublishMetadata = v.object({
|
|||||||
owner: v.string("GitHub owner of the extension"),
|
owner: v.string("GitHub owner of the extension"),
|
||||||
commit: v.string("Commit hash of the extension"),
|
commit: v.string("Commit hash of the extension"),
|
||||||
workflowPath: v.string("Workflow path of the extension"),
|
workflowPath: v.string("Workflow path of the extension"),
|
||||||
repoId: v.optional(v.string("GitHub repo node ID of the extension"))
|
repoNodeId: v.optional(
|
||||||
|
v.string("GitHub repo node ID of the extension (a string, not the number id)")
|
||||||
|
)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user