返回 DeepSeek-Reasonix
types.ts
1 // The subset of an account the registry needs: identity + namespace + trust.
2 export interface RegistryUser {
3 id: number;
4 handle: string;
5 role: "member" | "admin";
6 emailVerified: boolean;
7 }
8
9 export type PackageKind = "skill" | "plugin" | "mcp";
10 export type InstallKind = "auto" | PackageKind;
11
12 // A `packages` row as stored in D1.
13 export interface PackageRow {
14 id: number;
15 kind: PackageKind;
16 scope_handle: string;
17 name: string;
18 slug: string;
19 summary: string;
20 description: string;
21 source: string;
22 install_kind: InstallKind;
23 homepage: string;
24 repo_url: string;
25 tags: string;
26 latest_version: string;
27 install_count: number;
28 star_count: number;
29 verified: number;
30 status: string;
31 publisher_id: number;
32 created_at: string;
33 updated_at: string;
34 }
35
36 // The public, camel-cased view served by the API.
37 export interface PackageDTO {
38 kind: PackageKind;
39 handle: string;
40 name: string;
41 slug: string;
42 summary: string;
43 description: string;
44 source: string;
45 installKind: PackageKind;
46 homepage: string;
47 repoUrl: string;
48 tags: string[];
49 latestVersion: string;
50 installCount: number;
51 starCount: number;
52 verified: boolean;
53 status: string;
54 createdAt: string;
55 updatedAt: string;
56 }
57
58 export interface VersionRow {
59 id: number;
60 version: string;
61 source: string;
62 content_hash: string;
63 risk_level: string;
64 created_at: string;
65 }
66
67 export interface EventRow {
68 type: string;
69 slug: string | null;
70 actor_handle: string;
71 summary: string;
72 created_at: string;
73 }
74
75 function splitTags(tags: string): string[] {
76 return tags
77 .split(",")
78 .map((t) => t.trim())
79 .filter(Boolean);
80 }
81
82 export function toPackageDTO(row: PackageRow): PackageDTO {
83 return {
84 kind: row.kind,
85 handle: row.scope_handle,
86 name: row.name,
87 slug: row.slug,
88 summary: row.summary,
89 description: row.description,
90 source: row.source,
91 // Legacy rows may contain `auto` or a mismatched explicit installer. The
92 // declared public kind is authoritative for every API consumer.
93 installKind: row.kind,
94 homepage: row.homepage,
95 repoUrl: row.repo_url,
96 tags: splitTags(row.tags),
97 latestVersion: row.latest_version,
98 installCount: row.install_count,
99 starCount: row.star_count,
100 verified: row.verified === 1,
101 status: row.status,
102 createdAt: row.created_at,
103 updatedAt: row.updated_at,
104 };
105 }
106
106 lines TYPESCRIPT