返回 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 version: string;
60 source: string;
61 content_hash: string;
62 risk_level: string;
63 created_at: string;
64 }
65
66 export interface EventRow {
67 type: string;
68 slug: string | null;
69 actor_handle: string;
70 summary: string;
71 created_at: string;
72 }
73
74 function splitTags(tags: string): string[] {
75 return tags
76 .split(",")
77 .map((t) => t.trim())
78 .filter(Boolean);
79 }
80
81 export function toPackageDTO(row: PackageRow): PackageDTO {
82 return {
83 kind: row.kind,
84 handle: row.scope_handle,
85 name: row.name,
86 slug: row.slug,
87 summary: row.summary,
88 description: row.description,
89 source: row.source,
90 // Legacy rows may contain `auto` or a mismatched explicit installer. The
91 // declared public kind is authoritative for every API consumer.
92 installKind: row.kind,
93 homepage: row.homepage,
94 repoUrl: row.repo_url,
95 tags: splitTags(row.tags),
96 latestVersion: row.latest_version,
97 installCount: row.install_count,
98 starCount: row.star_count,
99 verified: row.verified === 1,
100 status: row.status,
101 createdAt: row.created_at,
102 updatedAt: row.updated_at,
103 };
104 }
105
105 lines TYPESCRIPT