@@ -21,7 +21,7 @@ export const router = t.router({
21
21
. meta ( { openapi : { method : "GET" , path : "/version" , description : "Get version of ComfyPR" } } )
22
22
. input ( z . object ( { } ) )
23
23
. output ( z . object ( { version : z . string ( ) } ) )
24
- . query ( ( { } ) => ( { version : pkg . version } ) ) ,
24
+ . query ( ( { } ) => ( { version : pkg . version } ) ) ,
25
25
dumpCsv : t . procedure
26
26
. meta ( { openapi : { method : "GET" , path : "/dump.csv" , description : "Get csv dump" } } )
27
27
. input ( z . object ( { } ) )
@@ -40,20 +40,22 @@ export const router = t.router({
40
40
analyzePullsStatus : t . procedure
41
41
. meta ( { openapi : { method : "GET" , path : "/analyze-pulls-status" , description : "Get current worker" } } )
42
42
. input ( z . object ( { skip : z . number ( ) , limit : z . number ( ) } ) . partial ( ) )
43
- . output ( z . object ( {
44
- updated : z . string ( ) , // deprecated
45
- pull_updated : z . string ( ) ,
46
- repo_updated : z . string ( ) ,
47
- on_registry : z . boolean ( ) ,
48
- state : z . enum ( [ "OPEN" , "MERGED" , "CLOSED" ] ) ,
49
- url : z . string ( ) ,
50
- head : z . string ( ) ,
51
- comments : z . number ( ) ,
52
- lastcomment : z . string ( ) ,
53
- ownername : z . string ( ) . optional ( ) ,
54
- repository : z . string ( ) . optional ( ) ,
55
- author_email : z . string ( ) . optional ( ) ,
56
- } ) )
43
+ . output (
44
+ z . object ( {
45
+ updated : z . string ( ) , // deprecated
46
+ pull_updated : z . string ( ) ,
47
+ repo_updated : z . string ( ) ,
48
+ on_registry : z . boolean ( ) ,
49
+ state : z . enum ( [ "OPEN" , "MERGED" , "CLOSED" ] ) ,
50
+ url : z . string ( ) ,
51
+ head : z . string ( ) ,
52
+ comments : z . number ( ) ,
53
+ lastcomment : z . string ( ) ,
54
+ ownername : z . string ( ) . optional ( ) ,
55
+ repository : z . string ( ) . optional ( ) ,
56
+ author_email : z . string ( ) . optional ( ) ,
57
+ } ) ,
58
+ )
57
59
. query ( async ( { input : { limit = 0 , skip = 0 } } ) => ( await analyzePullsStatus ( { limit, skip } ) ) as any ) ,
58
60
getRepoUrls : t . procedure
59
61
. meta ( { openapi : { method : "GET" , path : "/repo-urls" , description : "Get repo urls" } } )
@@ -100,15 +102,19 @@ export const router = t.router({
100
102
openapi : { method : "GET" , path : "/github-contributor-analyze" , description : "Get github contributor analyze" } ,
101
103
} )
102
104
. input ( z . object ( { url : z . string ( ) } ) )
103
- . output ( z . object ( {
104
- repoUrl : z . string ( ) ,
105
- contributors : z . array ( z . object ( {
106
- count : z . number ( ) ,
107
- name : z . string ( ) ,
108
- email : z . string ( ) ,
109
- } ) ) ,
110
- updatedAt : z . date ( ) ,
111
- } ) )
105
+ . output (
106
+ z . object ( {
107
+ repoUrl : z . string ( ) ,
108
+ contributors : z . array (
109
+ z . object ( {
110
+ count : z . number ( ) ,
111
+ name : z . string ( ) ,
112
+ email : z . string ( ) ,
113
+ } ) ,
114
+ ) ,
115
+ updatedAt : z . date ( ) ,
116
+ } ) ,
117
+ )
112
118
. query ( async ( { input : { url } } ) => {
113
119
// await import { githubContributorAnalyze } from "../tasks/github-contributor-analyze/githubContributorAnalyze";
114
120
const { githubContributorAnalyze } = await import ( "../tasks/github-contributor-analyze/githubContributorAnalyze" ) ;
@@ -121,21 +127,25 @@ export const router = t.router({
121
127
openapi : { method : "GET" , path : "/tasks/gh-design/meta" , description : "Get github design task metadata" } ,
122
128
} )
123
129
. input ( z . object ( { } ) )
124
- . output ( z . object ( {
125
- meta : z . object ( {
126
- name : z . string ( ) . optional ( ) ,
127
- description : z . string ( ) . optional ( ) ,
128
- slackChannelName : z . string ( ) . optional ( ) ,
129
- slackMessageTemplate : z . string ( ) . optional ( ) ,
130
- repoUrls : z . array ( z . string ( ) ) . optional ( ) ,
131
- requestReviewers : z . array ( z . string ( ) ) . optional ( ) ,
132
- matchLabels : z . string ( ) . optional ( ) ,
133
- slackChannelId : z . string ( ) . optional ( ) ,
134
- lastRunAt : z . date ( ) . optional ( ) ,
135
- lastStatus : z . enum ( [ "success" , "error" , "running" ] ) . optional ( ) ,
136
- lastError : z . string ( ) . optional ( ) ,
137
- } ) . nullable ( )
138
- } ) )
130
+ . output (
131
+ z . object ( {
132
+ meta : z
133
+ . object ( {
134
+ name : z . string ( ) . optional ( ) ,
135
+ description : z . string ( ) . optional ( ) ,
136
+ slackChannelName : z . string ( ) . optional ( ) ,
137
+ slackMessageTemplate : z . string ( ) . optional ( ) ,
138
+ repoUrls : z . array ( z . string ( ) ) . optional ( ) ,
139
+ requestReviewers : z . array ( z . string ( ) ) . optional ( ) ,
140
+ matchLabels : z . string ( ) . optional ( ) ,
141
+ slackChannelId : z . string ( ) . optional ( ) ,
142
+ lastRunAt : z . date ( ) . optional ( ) ,
143
+ lastStatus : z . enum ( [ "success" , "error" , "running" ] ) . optional ( ) ,
144
+ lastError : z . string ( ) . optional ( ) ,
145
+ } )
146
+ . nullable ( ) ,
147
+ } ) ,
148
+ )
139
149
. query ( async ( ) => {
140
150
try {
141
151
const meta = await GithubDesignTaskMeta . findOne ( { coll : "GithubDesignTask" } ) ;
@@ -150,58 +160,65 @@ export const router = t.router({
150
160
. meta ( {
151
161
openapi : { method : "PATCH" , path : "/tasks/gh-design/meta" , description : "Update github design task metadata" } ,
152
162
} )
153
- . input ( z . object ( {
154
- slackMessageTemplate : z . string ( )
155
- . min ( 1 , "Slack message template cannot be empty" )
156
- . refine (
157
- ( template ) => template . includes ( "{{ITEM_TYPE}}" ) ,
158
- "Slack message template must include {{ITEM_TYPE}} placeholder"
159
- )
160
- . refine (
161
- ( template ) => template . includes ( "{{URL}}" ) ,
162
- "Slack message template must include {{URL}} placeholder"
163
- )
164
- . refine (
165
- ( template ) => template . includes ( "{{TITLE}}" ) ,
166
- "Slack message template must include {{TITLE}} placeholder"
167
- )
168
- . optional ( ) ,
169
- requestReviewers : z . array ( z . string ( ) . min ( 1 , "Reviewer username cannot be empty" ) ) . optional ( ) ,
170
- repoUrls : z . array (
171
- z . string ( )
172
- . url ( "Repository URL must be a valid URL" )
163
+ . input (
164
+ z . object ( {
165
+ slackMessageTemplate : z
166
+ . string ( )
167
+ . min ( 1 , "Slack message template cannot be empty" )
173
168
. refine (
174
- ( url ) => url . startsWith ( "https://github.com ") ,
175
- "Repository URL must start with https://github.com"
169
+ ( template ) => template . includes ( "{{ITEM_TYPE}} ") ,
170
+ "Slack message template must include {{ITEM_TYPE}} placeholder" ,
176
171
)
177
- ) . optional ( ) ,
178
- } ) )
179
- . output ( z . object ( {
180
- success : z . boolean ( ) ,
181
- meta : z . object ( {
182
- name : z . string ( ) . optional ( ) ,
183
- description : z . string ( ) . optional ( ) ,
184
- slackChannelName : z . string ( ) . optional ( ) ,
185
- slackMessageTemplate : z . string ( ) . optional ( ) ,
186
- repoUrls : z . array ( z . string ( ) ) . optional ( ) ,
187
- requestReviewers : z . array ( z . string ( ) ) . optional ( ) ,
188
- matchLabels : z . string ( ) . optional ( ) ,
189
- slackChannelId : z . string ( ) . optional ( ) ,
190
- lastRunAt : z . date ( ) . optional ( ) ,
191
- lastStatus : z . enum ( [ "success" , "error" , "running" ] ) . optional ( ) ,
192
- lastError : z . string ( ) . optional ( ) ,
193
- } ) . nullable ( )
194
- } ) )
172
+ . refine ( ( template ) => template . includes ( "{{URL}}" ) , "Slack message template must include {{URL}} placeholder" )
173
+ . refine (
174
+ ( template ) => template . includes ( "{{TITLE}}" ) ,
175
+ "Slack message template must include {{TITLE}} placeholder" ,
176
+ )
177
+ . optional ( ) ,
178
+ requestReviewers : z . array ( z . string ( ) . min ( 1 , "Reviewer username cannot be empty" ) ) . optional ( ) ,
179
+ repoUrls : z
180
+ . array (
181
+ z
182
+ . string ( )
183
+ . url ( "Repository URL must be a valid URL" )
184
+ . refine (
185
+ ( url ) => url . startsWith ( "https://github.com" ) ,
186
+ "Repository URL must start with https://github.com" ,
187
+ ) ,
188
+ )
189
+ . optional ( ) ,
190
+ } ) ,
191
+ )
192
+ . output (
193
+ z . object ( {
194
+ success : z . boolean ( ) ,
195
+ meta : z
196
+ . object ( {
197
+ name : z . string ( ) . optional ( ) ,
198
+ description : z . string ( ) . optional ( ) ,
199
+ slackChannelName : z . string ( ) . optional ( ) ,
200
+ slackMessageTemplate : z . string ( ) . optional ( ) ,
201
+ repoUrls : z . array ( z . string ( ) ) . optional ( ) ,
202
+ requestReviewers : z . array ( z . string ( ) ) . optional ( ) ,
203
+ matchLabels : z . string ( ) . optional ( ) ,
204
+ slackChannelId : z . string ( ) . optional ( ) ,
205
+ lastRunAt : z . date ( ) . optional ( ) ,
206
+ lastStatus : z . enum ( [ "success" , "error" , "running" ] ) . optional ( ) ,
207
+ lastError : z . string ( ) . optional ( ) ,
208
+ } )
209
+ . nullable ( ) ,
210
+ } ) ,
211
+ )
195
212
. mutation ( async ( { input } ) => {
196
- throw new Error ( "Meta editing functionality is temporarily disabled. This feature is under maintenance." ) ;
213
+ throw new Error ( "Meta editing functionality is temporarily disabled. This feature is under maintenance." ) ;
197
214
// TODO: add back later
198
215
try {
199
216
const updateData : any = { } ;
200
217
if ( input . slackMessageTemplate !== undefined ) updateData . slackMessageTemplate = input . slackMessageTemplate ;
201
218
if ( input . requestReviewers !== undefined ) updateData . requestReviewers = input . requestReviewers ;
202
219
if ( input . repoUrls !== undefined ) updateData . repoUrls = input . repoUrls ;
203
220
204
- const meta = await GithubDesignTaskMeta . $set ( updateData ) ;
221
+ const meta = await GithubDesignTaskMeta . $upsert ( updateData ) ;
205
222
return { success : true , meta } ;
206
223
} catch ( error ) {
207
224
console . error ( "Failed to update metadata:" , error ) ;
0 commit comments