فهرست منبع

feat: add color to project

Adam 2 ماه پیش
والد
کامیت
9a34965432

+ 3 - 0
packages/opencode/src/project/project.ts

@@ -18,6 +18,7 @@ export namespace Project {
       vcs: z.literal("git").optional(),
       name: z.string().optional(),
       icon: z.string().optional(),
+      color: z.string().optional(),
       time: z.object({
         created: z.number(),
         updated: z.number().optional(),
@@ -134,11 +135,13 @@ export namespace Project {
       projectID: z.string(),
       name: z.string().optional(),
       icon: z.string().optional(),
+      color: z.string().optional(),
     }),
     async (input) => {
       return await Storage.update<Info>(["project", input.projectID], (draft) => {
         if (input.name !== undefined) draft.name = input.name
         if (input.icon !== undefined) draft.icon = input.icon
+        if (input.color !== undefined) draft.color = input.color
         draft.time.updated = Date.now()
       })
     },

+ 1 - 1
packages/opencode/src/server/project.ts

@@ -54,7 +54,7 @@ export const ProjectRoute = new Hono()
     "/:projectID",
     describeRoute({
       summary: "Update project",
-      description: "Update project properties such as name and icon.",
+      description: "Update project properties such as name, icon and color.",
       operationId: "project.update",
       responses: {
         200: {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 416 - 82
packages/sdk/js/openapi.json


+ 43 - 0
packages/sdk/js/src/v2/gen/sdk.gen.ts

@@ -51,6 +51,8 @@ import type {
   PermissionRespondResponses,
   ProjectCurrentResponses,
   ProjectListResponses,
+  ProjectUpdateErrors,
+  ProjectUpdateResponses,
   ProviderAuthResponses,
   ProviderListResponses,
   ProviderOauthAuthorizeErrors,
@@ -231,6 +233,47 @@ export class Project extends HeyApiClient {
       ...params,
     })
   }
+
+  /**
+   * Update project
+   *
+   * Update project properties such as name, icon and color.
+   */
+  public update<ThrowOnError extends boolean = false>(
+    parameters: {
+      projectID: string
+      directory?: string
+      name?: string
+      icon?: string
+      color?: string
+    },
+    options?: Options<never, ThrowOnError>,
+  ) {
+    const params = buildClientParams(
+      [parameters],
+      [
+        {
+          args: [
+            { in: "path", key: "projectID" },
+            { in: "query", key: "directory" },
+            { in: "body", key: "name" },
+            { in: "body", key: "icon" },
+            { in: "body", key: "color" },
+          ],
+        },
+      ],
+    )
+    return (options?.client ?? this.client).patch<ProjectUpdateResponses, ProjectUpdateErrors, ThrowOnError>({
+      url: "/project/{projectID}",
+      ...options,
+      ...params,
+      headers: {
+        "Content-Type": "application/json",
+        ...options?.headers,
+        ...params.headers,
+      },
+    })
+  }
 }
 
 export class Pty extends HeyApiClient {

+ 40 - 1
packages/sdk/js/src/v2/gen/types.gen.ts

@@ -745,8 +745,10 @@ export type GlobalEvent = {
 export type Project = {
   id: string
   worktree: string
-  vcsDir?: string
   vcs?: "git"
+  name?: string
+  icon?: string
+  color?: string
   time: {
     created: number
     updated?: number
@@ -1716,6 +1718,43 @@ export type ProjectCurrentResponses = {
 
 export type ProjectCurrentResponse = ProjectCurrentResponses[keyof ProjectCurrentResponses]
 
+export type ProjectUpdateData = {
+  body?: {
+    name?: string
+    icon?: string
+    color?: string
+  }
+  path: {
+    projectID: string
+  }
+  query?: {
+    directory?: string
+  }
+  url: "/project/{projectID}"
+}
+
+export type ProjectUpdateErrors = {
+  /**
+   * Bad request
+   */
+  400: BadRequestError
+  /**
+   * Not found
+   */
+  404: NotFoundError
+}
+
+export type ProjectUpdateError = ProjectUpdateErrors[keyof ProjectUpdateErrors]
+
+export type ProjectUpdateResponses = {
+  /**
+   * Updated project information
+   */
+  200: Project
+}
+
+export type ProjectUpdateResponse = ProjectUpdateResponses[keyof ProjectUpdateResponses]
+
 export type PtyListData = {
   body?: never
   path?: never

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است