Huakun Shen 0cc744592f
Feature: add author, size, readme display for extension store page (#74)
* fix: update email field in KunkunExtManifest to be optional and nullable

* refactor: update Supabase type generation command and enhance database types structure

- Changed the Supabase type generation command to include a specific project reference and output path.
- Refactored the database types in `database.types.ts` for improved readability and added new fields, including `extension_state` and `package_json` in the `ext_publish` table.
- Ensured consistent formatting across type definitions for better maintainability.

* feat: add optional README path to ExtPackageJson and enhance tests for README retrieval

* feat: add optional readmeContent to ExtensionPublishValidationData and retrieve README in validateJsrPackageAsKunkunExtension

* feat: add optional readme field to database types for improved package metadata

* feat: enhance StoreExtDetail to display package metadata including author and contributors

- Added packageJson prop to StoreExtDetail for improved extension metadata display.
- Implemented rendering of author and contributors from packageJson.
- Integrated README content display in StoreExtDetail if available.
- Updated +page.svelte to parse and provide packageJson data using valibot for validation.

* feat: enhance TauriLink component to support conditional rendering based on Tauri environment

- Added detection for Tauri environment using the browser variable.
- Updated the TauriLink component to render a button when in Tauri, and an anchor tag for external links otherwise.
- Improved user experience by ensuring appropriate link behavior based on the application context.

* feat: add unpacked size to npm registry

* feat: replace size in ext_publish table to tarball_size, add unpacked_size (only applicable to npm)

* feat: add pretty-bytes dependency and update debug package version

- Added `pretty-bytes` package with version 6.1.1 to `package.json`.
- Updated `debug` package to use `supports-color@9.4.0` in `pnpm-lock.yaml` for improved compatibility.

* feat: add tarball_size field to database types for improved package metadata

* feat: add readme fetching for npm registry, readme from github

* fix: remove console.log from NPM API test to clean up output

* style: update extension store details

* style: update README section in StoreExtDetail component for improved styling

* fix: update command input placeholder text in English, Russian, and Chinese translations for clarity

* chore: bump version to 0.1.18 in package.json

* fix: lint
2025-01-23 07:07:29 -05:00

81 lines
2.2 KiB
TypeScript

import { ExtPackageJson, License } from "@kksh/api/models"
import * as v from "valibot"
export const RawRekorLogEntry = v.object({
attestation: v.object({ data: v.string() }),
body: v.string(),
integratedTime: v.number(),
logID: v.string(),
logIndex: v.number(),
verification: v.object({
inclusionProof: v.object({
checkpoint: v.string(),
hashes: v.array(v.string()),
logIndex: v.number(),
rootHash: v.string(),
treeSize: v.number()
}),
signedEntryTimestamp: v.string()
})
})
export type RawRekorLogEntry = v.InferOutput<typeof RawRekorLogEntry>
export const RawRekorLog = v.record(v.string(), RawRekorLogEntry)
export type RawRekorLog = v.InferOutput<typeof RawRekorLog>
export const SigstoreAttestation = v.object({
type: v.optional(v.string()),
subject: v.array(
v.object({ name: v.string(), digest: v.object({ sha256: v.optional(v.string()) }) })
),
predicateType: v.string(),
predicate: v.object({
buildDefinition: v.object({
buildType: v.string(),
resolvedDependencies: v.array(
v.object({
uri: v.string(),
digest: v.object({ gitCommit: v.string() })
})
),
internalParameters: v.object({
github: v.object({
eventName: v.optional(v.string()),
repositoryId: v.optional(v.string()),
repositoryOwnerId: v.optional(v.string())
})
}),
externalParameters: v.object({
workflow: v.object({
ref: v.string(),
repository: v.string(),
path: v.string()
})
})
}),
runDetails: v.object({
builder: v.object({ id: v.string() }),
metadata: v.object({ invocationId: v.string() })
})
})
})
export type SigstoreAttestation = v.InferOutput<typeof SigstoreAttestation>
export const ExtensionPublishValidationData = v.object({
pkgJson: ExtPackageJson,
tarballUrl: v.string(),
readmeContent: v.optional(v.string()),
shasum: v.string(),
apiVersion: v.string(),
rekorLogIndex: v.string(),
tarballSize: v.number(),
unpackedSize: v.optional(v.number()),
license: License,
github: v.object({
githubActionInvocationId: v.string(),
commit: v.string(),
repo: v.string(),
owner: v.string(),
workflowPath: v.string()
})
})
export type ExtensionPublishValidationData = v.InferOutput<typeof ExtensionPublishValidationData>