@spaceflow/core 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaceflow/core",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Spaceflow 核心能力库",
5
5
  "license": "MIT",
6
6
  "author": "Lydanne",
@@ -385,7 +385,36 @@ export class GiteaAdapter implements GitProvider {
385
385
  // ============ Issue 操作 ============
386
386
 
387
387
  async createIssue(owner: string, repo: string, options: CreateIssueOption): Promise<Issue> {
388
- return this.request<Issue>("POST", `/repos/${owner}/${repo}/issues`, options);
388
+ const body: Record<string, unknown> = {
389
+ title: options.title,
390
+ body: options.body,
391
+ assignees: options.assignees,
392
+ milestone: options.milestone,
393
+ due_date: options.due_date,
394
+ };
395
+ if (options.labels?.length) {
396
+ body.labels = await this.resolveLabelIds(owner, repo, options.labels);
397
+ }
398
+ return this.request<Issue>("POST", `/repos/${owner}/${repo}/issues`, body);
399
+ }
400
+
401
+ /**
402
+ * 将标签名称列表转换为 Gitea label ID 列表
403
+ */
404
+ protected async resolveLabelIds(owner: string, repo: string, names: string[]): Promise<number[]> {
405
+ const allLabels = await this.request<Array<{ id: number; name: string }>>(
406
+ "GET",
407
+ `/repos/${owner}/${repo}/labels`,
408
+ );
409
+ const nameToId = new Map(allLabels.map((l) => [l.name.toLowerCase(), l.id]));
410
+ const ids: number[] = [];
411
+ for (const name of names) {
412
+ const id = nameToId.get(name.toLowerCase());
413
+ if (id !== undefined) {
414
+ ids.push(id);
415
+ }
416
+ }
417
+ return ids;
389
418
  }
390
419
 
391
420
  async listIssueComments(owner: string, repo: string, index: number): Promise<IssueComment[]> {
@@ -277,8 +277,8 @@ export interface CreateIssueOption {
277
277
  body?: string;
278
278
  /** 指派人用户名列表 */
279
279
  assignees?: string[];
280
- /** 标签 ID 列表 */
281
- labels?: number[];
280
+ /** 标签名称列表,各平台 adapter 内部负责名称到 ID 的转换 */
281
+ labels?: string[];
282
282
  /** 里程碑 ID */
283
283
  milestone?: number;
284
284
  /** 截止日期 */