zentao-api 0.6.0 → 0.6.2

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/dist/index.d.ts CHANGED
@@ -6,4 +6,4 @@ export { defineModuleActions, defineModules, type DefineModulesOptions, type Exp
6
6
  export { request, type BuiltinRequestName, type RequestParamsFor, type RequestResultFor, } from './request/index.js';
7
7
  export { pickFields, pickFieldsSingle, filterData, searchData, sortData, processData, } from './utils/index.js';
8
8
  export { BUILD, VERSION } from './version.js';
9
- export type { ApiListResponse, ApiResponse, ClientRequestBodyType, ClientRequestOptions, ClientResponseType, DataRecord, DataRecordFilter, DataRecordFilterGroup, GlobalOptions, HttpMethod, ListPagerInfo, LoginResponse, ModuleAction, ModuleActionMethod, ModuleActionName, ModuleActionPagerGetterMap, ModuleActionParam, ModuleActionParamOption, ModuleActionRequest, ModuleActionRequestBody, ModuleActionResponse, ModuleActionResultType, ModuleActionType, ModuleDefinition, ModuleName, Pager, ProcessListOptions, ProcessSingleOptions, RequestOptions, ResponseData, ServerConfig, SortExpr, SortFn, ZentaoProfile, ZentaoProfileConfig, ZentaoProfileRecord, ZentaoProfilesStore, ZentaoClientOptions, } from './types/index.js';
9
+ export type { ApiListResponse, ApiResponse, ClientRequestBodyType, ClientRequestOptions, ClientResponseType, DataRecord, DataRecordFilter, DataRecordFilterGroup, FileCreateParams, FileCreateResult, FileUploadDataInput, FileUploadPathInput, FileUploadSource, GlobalOptions, HttpMethod, ListPagerInfo, LoginResponse, ModuleAction, ModuleActionMethod, ModuleActionName, ModuleActionPagerGetterMap, ModuleActionParam, ModuleActionParamOption, ModuleActionRequest, ModuleActionRequestBody, ModuleActionRequestMediaType, ModuleActionResponse, ModuleActionResultType, ModuleActionType, ModuleDefinition, ModuleName, Pager, ProcessListOptions, ProcessSingleOptions, RequestOptions, ResponseData, ServerConfig, SortExpr, SortFn, ZentaoProfile, ZentaoProfileConfig, ZentaoProfileRecord, ZentaoProfilesStore, ZentaoClientOptions, } from './types/index.js';
@@ -27,6 +27,11 @@ export declare const ERRORS: {
27
27
  readonly E_INVALID_PARAM: "Invalid value for parameter {param}: {value}";
28
28
  readonly E_INVALID_REQUEST_NAME: "Request name must use the form \"moduleName\", \"moduleName/methodName\", or \"moduleName/<objectID>\".";
29
29
  readonly E_API_FAILED: "ZenTao API returned failure: {message}";
30
+ readonly E_UPLOAD_PATH_UNSUPPORTED: "Local file paths are not supported in browser runtimes. Pass a File or Blob instead.";
31
+ readonly E_UPLOAD_FILE_NOT_FOUND: "Upload file not found: {path}";
32
+ readonly E_UPLOAD_FILE_READ_FAILED: "Failed to read upload file: {path}";
33
+ readonly E_UPLOAD_FILE_TOO_LARGE: "Upload file is {size} bytes and exceeds the {limit} byte limit.";
34
+ readonly E_INVALID_UPLOAD_SOURCE: "Invalid upload source for field: {field}";
30
35
  };
31
36
  /** SDK 已知错误码,对应 {@link ERRORS} 的 key。 */
32
37
  export type ErrorCode = keyof typeof ERRORS;
@@ -27,6 +27,11 @@ export const ERRORS = {
27
27
  E_INVALID_PARAM: 'Invalid value for parameter {param}: {value}',
28
28
  E_INVALID_REQUEST_NAME: 'Request name must use the form "moduleName", "moduleName/methodName", or "moduleName/<objectID>".',
29
29
  E_API_FAILED: 'ZenTao API returned failure: {message}',
30
+ E_UPLOAD_PATH_UNSUPPORTED: 'Local file paths are not supported in browser runtimes. Pass a File or Blob instead.',
31
+ E_UPLOAD_FILE_NOT_FOUND: 'Upload file not found: {path}',
32
+ E_UPLOAD_FILE_READ_FAILED: 'Failed to read upload file: {path}',
33
+ E_UPLOAD_FILE_TOO_LARGE: 'Upload file is {size} bytes and exceeds the {limit} byte limit.',
34
+ E_INVALID_UPLOAD_SOURCE: 'Invalid upload source for field: {field}',
30
35
  };
31
36
  /**
32
37
  * SDK 统一错误类型。
@@ -1,7 +1,9 @@
1
- import type { ModuleAction, ModuleActionParam, ModuleDefinition } from '../types/index.js';
1
+ import type { ModuleAction, ModuleActionParam, ModuleActionRequestMediaType, ModuleDefinition } from '../types/index.js';
2
2
  /** 导出的模块动作定义。 */
3
3
  export type ExportedModuleAction = Omit<ModuleAction, 'requestBody'> & {
4
4
  bodyParams: ModuleActionParam[];
5
+ /** 请求体媒体类型;省略时为 `application/json`。 */
6
+ bodyMediaType?: ModuleActionRequestMediaType;
5
7
  };
6
8
  /** 导出的模块定义。 */
7
9
  export type ExportedModuleDefinition = Omit<ModuleDefinition, 'actions'> & {
@@ -30,6 +30,7 @@ export function exportRegistry(options = {}) {
30
30
  const { requestBody, ...exportedAction } = action;
31
31
  return {
32
32
  ...exportedAction,
33
+ ...(requestBody?.mediaType ? { bodyMediaType: requestBody.mediaType } : {}),
33
34
  bodyParams: requestBody
34
35
  ? getModuleActionParams(module.name, action.name, { roles: ['body'] })
35
36
  : [],
@@ -3406,6 +3406,9 @@ export declare const BUILTIN_MODULES: ({
3406
3406
  name?: undefined;
3407
3407
  parent?: undefined;
3408
3408
  comment?: undefined;
3409
+ deadline?: undefined;
3410
+ status?: undefined;
3411
+ mailto?: undefined;
3409
3412
  resolution?: undefined;
3410
3413
  resolvedDate?: undefined;
3411
3414
  resolvedBuild?: undefined;
@@ -3507,6 +3510,9 @@ export declare const BUILTIN_MODULES: ({
3507
3510
  name?: undefined;
3508
3511
  parent?: undefined;
3509
3512
  comment?: undefined;
3513
+ deadline?: undefined;
3514
+ status?: undefined;
3515
+ mailto?: undefined;
3510
3516
  resolution?: undefined;
3511
3517
  resolvedDate?: undefined;
3512
3518
  resolvedBuild?: undefined;
@@ -3558,6 +3564,9 @@ export declare const BUILTIN_MODULES: ({
3558
3564
  story?: undefined;
3559
3565
  assignedTo?: undefined;
3560
3566
  comment?: undefined;
3567
+ deadline?: undefined;
3568
+ status?: undefined;
3569
+ mailto?: undefined;
3561
3570
  resolution?: undefined;
3562
3571
  resolvedDate?: undefined;
3563
3572
  resolvedBuild?: undefined;
@@ -3650,6 +3659,9 @@ export declare const BUILTIN_MODULES: ({
3650
3659
  story?: undefined;
3651
3660
  name?: undefined;
3652
3661
  parent?: undefined;
3662
+ deadline?: undefined;
3663
+ status?: undefined;
3664
+ mailto?: undefined;
3653
3665
  resolution?: undefined;
3654
3666
  resolvedDate?: undefined;
3655
3667
  resolvedBuild?: undefined;
@@ -3697,6 +3709,81 @@ export declare const BUILTIN_MODULES: ({
3697
3709
  assignedTo?: undefined;
3698
3710
  name?: undefined;
3699
3711
  parent?: undefined;
3712
+ deadline?: undefined;
3713
+ status?: undefined;
3714
+ mailto?: undefined;
3715
+ resolution?: undefined;
3716
+ resolvedDate?: undefined;
3717
+ resolvedBuild?: undefined;
3718
+ };
3719
+ required?: undefined;
3720
+ };
3721
+ };
3722
+ pagerGetter?: undefined;
3723
+ resultGetter?: undefined;
3724
+ params?: undefined;
3725
+ } | {
3726
+ name: "confirm";
3727
+ display: string;
3728
+ type: "action";
3729
+ method: "put";
3730
+ path: string;
3731
+ resultType: "text";
3732
+ pathParams: {
3733
+ bugID: string;
3734
+ scope?: undefined;
3735
+ scopeID?: undefined;
3736
+ productID?: undefined;
3737
+ moduleID?: undefined;
3738
+ };
3739
+ requestBody: {
3740
+ required: true;
3741
+ type: "object";
3742
+ schema: {
3743
+ type: string;
3744
+ properties: {
3745
+ assignedTo: {
3746
+ type: string;
3747
+ description: string;
3748
+ };
3749
+ type: {
3750
+ type: string;
3751
+ description: string;
3752
+ };
3753
+ pri: {
3754
+ type: string;
3755
+ description: string;
3756
+ format: string;
3757
+ };
3758
+ deadline: {
3759
+ type: string;
3760
+ description: string;
3761
+ };
3762
+ status: {
3763
+ type: string;
3764
+ description: string;
3765
+ };
3766
+ mailto: {
3767
+ type: string;
3768
+ items: {
3769
+ type: string;
3770
+ };
3771
+ description: string;
3772
+ };
3773
+ comment: {
3774
+ type: string;
3775
+ description: string;
3776
+ };
3777
+ productID?: undefined;
3778
+ title?: undefined;
3779
+ openedBuild?: undefined;
3780
+ project?: undefined;
3781
+ execution?: undefined;
3782
+ severity?: undefined;
3783
+ steps?: undefined;
3784
+ story?: undefined;
3785
+ name?: undefined;
3786
+ parent?: undefined;
3700
3787
  resolution?: undefined;
3701
3788
  resolvedDate?: undefined;
3702
3789
  resolvedBuild?: undefined;
@@ -3759,6 +3846,9 @@ export declare const BUILTIN_MODULES: ({
3759
3846
  story?: undefined;
3760
3847
  name?: undefined;
3761
3848
  parent?: undefined;
3849
+ deadline?: undefined;
3850
+ status?: undefined;
3851
+ mailto?: undefined;
3762
3852
  };
3763
3853
  required: string[];
3764
3854
  };
@@ -7400,6 +7490,7 @@ export declare const BUILTIN_MODULES: ({
7400
7490
  path: string;
7401
7491
  resultType: "list";
7402
7492
  pagerGetter: string;
7493
+ resultGetter: string;
7403
7494
  pathParams: {
7404
7495
  spaceID: string;
7405
7496
  libID: string;
@@ -7408,7 +7499,6 @@ export declare const BUILTIN_MODULES: ({
7408
7499
  docID?: undefined;
7409
7500
  moduleID?: undefined;
7410
7501
  };
7411
- resultGetter: string;
7412
7502
  requestBody?: undefined;
7413
7503
  } | {
7414
7504
  name: "productDocs";
@@ -8455,6 +8545,11 @@ export declare const BUILTIN_MODULES: ({
8455
8545
  type: string;
8456
8546
  description: string;
8457
8547
  };
8548
+ objectID: {
8549
+ type: string;
8550
+ description: string;
8551
+ format: string;
8552
+ };
8458
8553
  begin: {
8459
8554
  type: string;
8460
8555
  description: string;
@@ -8504,6 +8599,11 @@ export declare const BUILTIN_MODULES: ({
8504
8599
  type: string;
8505
8600
  description: string;
8506
8601
  };
8602
+ objectID: {
8603
+ type: string;
8604
+ description: string;
8605
+ format: string;
8606
+ };
8507
8607
  begin: {
8508
8608
  type: string;
8509
8609
  description: string;
@@ -9008,6 +9108,7 @@ export declare const BUILTIN_MODULES: ({
9008
9108
  path: string;
9009
9109
  resultType: "list";
9010
9110
  pagerGetter: string;
9111
+ resultGetter: string;
9011
9112
  params: ({
9012
9113
  name: string;
9013
9114
  required: false;
@@ -9036,7 +9137,6 @@ export declare const BUILTIN_MODULES: ({
9036
9137
  defaultValue?: undefined;
9037
9138
  options?: undefined;
9038
9139
  })[];
9039
- resultGetter: string;
9040
9140
  } | {
9041
9141
  name: "issues";
9042
9142
  display: string;
@@ -9381,6 +9481,9 @@ export type BuiltinActionMeta = {
9381
9481
  close: {
9382
9482
  resultType: 'text';
9383
9483
  };
9484
+ confirm: {
9485
+ resultType: 'text';
9486
+ };
9384
9487
  resolve: {
9385
9488
  resultType: 'text';
9386
9489
  };
@@ -2857,7 +2857,7 @@ export const BUILTIN_MODULES = [
2857
2857
  {
2858
2858
  name: 'bug',
2859
2859
  display: 'Bug',
2860
- description: 'Bug管理,支持获取Bug列表,支持获取项目/产品/执行下的Bug、产品的Bug模块树、创建Bug、获取Bug详情、修改Bug、修改Bug模块、删除Bug、删除Bug模块、激活Bug、关闭Bug、解决Bug',
2860
+ description: 'Bug管理,支持获取Bug列表,支持获取项目/产品/执行下的Bug、产品的Bug模块树、创建Bug、获取Bug详情、修改Bug、修改Bug模块、删除Bug、删除Bug模块、激活Bug、关闭Bug、确认Bug、解决Bug',
2861
2861
  actions: [
2862
2862
  {
2863
2863
  name: 'list',
@@ -3196,6 +3196,57 @@ export const BUILTIN_MODULES = [
3196
3196
  }
3197
3197
  },
3198
3198
  },
3199
+ }, {
3200
+ name: 'confirm',
3201
+ display: '确认Bug',
3202
+ type: 'action',
3203
+ method: 'put',
3204
+ path: '/bugs/{bugID}/confirm',
3205
+ resultType: 'text',
3206
+ pathParams: {
3207
+ bugID: 'Bug ID',
3208
+ },
3209
+ requestBody: {
3210
+ required: true,
3211
+ type: 'object',
3212
+ schema: {
3213
+ "type": "object",
3214
+ "properties": {
3215
+ "assignedTo": {
3216
+ "type": "string",
3217
+ "description": "指派给"
3218
+ },
3219
+ "type": {
3220
+ "type": "string",
3221
+ "description": "Bug类型(codeerror 代码错误 | config 配置相关 | install 安装部署 | security 安全相关 | performance 性能问题 | standard 标准规范 | automation 测试脚本 | designdefect 设计缺陷 | others 其他)"
3222
+ },
3223
+ "pri": {
3224
+ "type": "integer",
3225
+ "description": "优先级,默认是3",
3226
+ "format": "int32"
3227
+ },
3228
+ "deadline": {
3229
+ "type": "string",
3230
+ "description": "截止日期"
3231
+ },
3232
+ "status": {
3233
+ "type": "string",
3234
+ "description": "状态"
3235
+ },
3236
+ "mailto": {
3237
+ "type": "array",
3238
+ "items": {
3239
+ "type": "string"
3240
+ },
3241
+ "description": "抄送给"
3242
+ },
3243
+ "comment": {
3244
+ "type": "string",
3245
+ "description": "备注"
3246
+ }
3247
+ }
3248
+ },
3249
+ },
3199
3250
  }, {
3200
3251
  name: 'resolve',
3201
3252
  display: '解决Bug',
@@ -3885,7 +3936,7 @@ export const BUILTIN_MODULES = [
3885
3936
  },
3886
3937
  "assignedTo": {
3887
3938
  "type": "string",
3888
- "description": "任务名称"
3939
+ "description": "指派给"
3889
3940
  },
3890
3941
  "consumed": {
3891
3942
  "type": "number",
@@ -3894,11 +3945,11 @@ export const BUILTIN_MODULES = [
3894
3945
  },
3895
3946
  "realStarted": {
3896
3947
  "type": "string",
3897
- "description": "实际开始"
3948
+ "description": "实际开始,精确到秒"
3898
3949
  },
3899
3950
  "finishedDate": {
3900
3951
  "type": "string",
3901
- "description": "实际完成"
3952
+ "description": "实际完成,精确到秒"
3902
3953
  },
3903
3954
  "comment": {
3904
3955
  "type": "string",
@@ -3934,7 +3985,7 @@ export const BUILTIN_MODULES = [
3934
3985
  },
3935
3986
  "realStarted": {
3936
3987
  "type": "string",
3937
- "description": "实际开始"
3988
+ "description": "实际开始,精确到秒"
3938
3989
  },
3939
3990
  "consumed": {
3940
3991
  "type": "number",
@@ -6565,11 +6616,11 @@ export const BUILTIN_MODULES = [
6565
6616
  path: '/doc/team/spaces/{spaceID}/libs/{libID}/docs',
6566
6617
  resultType: 'list',
6567
6618
  pagerGetter: 'pager',
6619
+ resultGetter: 'docs',
6568
6620
  pathParams: {
6569
6621
  spaceID: '空间ID',
6570
6622
  libID: '文档库ID',
6571
6623
  },
6572
- resultGetter: 'docs',
6573
6624
  }, {
6574
6625
  name: 'productDocs',
6575
6626
  display: '获取产品文档列表',
@@ -6880,7 +6931,7 @@ export const BUILTIN_MODULES = [
6880
6931
  },
6881
6932
  "content": {
6882
6933
  "type": "string",
6883
- "description": "文档内容,支持HTML标签"
6934
+ "description": "文档正文,使用HTML格式;纯文本可直接传递"
6884
6935
  }
6885
6936
  },
6886
6937
  "required": [
@@ -6917,7 +6968,7 @@ export const BUILTIN_MODULES = [
6917
6968
  },
6918
6969
  "content": {
6919
6970
  "type": "string",
6920
- "description": "文档内容,支持HTML标签"
6971
+ "description": "文档正文,使用HTML格式;纯文本可直接传递"
6921
6972
  }
6922
6973
  },
6923
6974
  "required": [
@@ -6954,7 +7005,7 @@ export const BUILTIN_MODULES = [
6954
7005
  },
6955
7006
  "content": {
6956
7007
  "type": "string",
6957
- "description": "文档内容,支持HTML标签"
7008
+ "description": "文档正文,使用HTML格式;纯文本可直接传递"
6958
7009
  }
6959
7010
  },
6960
7011
  "required": [
@@ -6991,7 +7042,7 @@ export const BUILTIN_MODULES = [
6991
7042
  },
6992
7043
  "content": {
6993
7044
  "type": "string",
6994
- "description": "文档内容,支持HTML标签"
7045
+ "description": "文档正文,使用HTML格式;纯文本可直接传递"
6995
7046
  }
6996
7047
  },
6997
7048
  "required": [
@@ -7023,7 +7074,7 @@ export const BUILTIN_MODULES = [
7023
7074
  },
7024
7075
  "parentID": {
7025
7076
  "type": "integer",
7026
- "description": "父目录",
7077
+ "description": "父目录ID,必须属于当前文档库",
7027
7078
  "format": "int32"
7028
7079
  }
7029
7080
  },
@@ -7055,7 +7106,7 @@ export const BUILTIN_MODULES = [
7055
7106
  },
7056
7107
  "parentID": {
7057
7108
  "type": "integer",
7058
- "description": "父目录",
7109
+ "description": "父目录ID,必须属于当前文档库",
7059
7110
  "format": "int32"
7060
7111
  }
7061
7112
  },
@@ -7087,7 +7138,7 @@ export const BUILTIN_MODULES = [
7087
7138
  },
7088
7139
  "parentID": {
7089
7140
  "type": "integer",
7090
- "description": "父目录",
7141
+ "description": "父目录ID,必须属于当前文档库",
7091
7142
  "format": "int32"
7092
7143
  }
7093
7144
  },
@@ -7119,7 +7170,7 @@ export const BUILTIN_MODULES = [
7119
7170
  },
7120
7171
  "parentID": {
7121
7172
  "type": "integer",
7122
- "description": "父目录",
7173
+ "description": "父目录ID,必须属于当前文档库",
7123
7174
  "format": "int32"
7124
7175
  }
7125
7176
  },
@@ -7258,7 +7309,7 @@ export const BUILTIN_MODULES = [
7258
7309
  },
7259
7310
  "content": {
7260
7311
  "type": "string",
7261
- "description": "文档内容,支持HTML标签"
7312
+ "description": "文档正文,使用HTML格式;纯文本可直接传递。接口不接受块编辑器的JSON快照,修改块编辑器文档后会保存为HTML格式"
7262
7313
  }
7263
7314
  },
7264
7315
  "required": [
@@ -7365,7 +7416,12 @@ export const BUILTIN_MODULES = [
7365
7416
  },
7366
7417
  "name": {
7367
7418
  "type": "string",
7368
- "description": "待办名称"
7419
+ "description": "待办名称,type为custom时必填;type为非custom时由关联对象的名称或标题自动生成"
7420
+ },
7421
+ "objectID": {
7422
+ "type": "integer",
7423
+ "description": "关联对象ID,type为非custom时必填,必须是type对应对象的ID",
7424
+ "format": "int32"
7369
7425
  },
7370
7426
  "begin": {
7371
7427
  "type": "string",
@@ -7386,8 +7442,7 @@ export const BUILTIN_MODULES = [
7386
7442
  },
7387
7443
  "required": [
7388
7444
  "date",
7389
- "type",
7390
- "name"
7445
+ "type"
7391
7446
  ]
7392
7447
  },
7393
7448
  },
@@ -7417,7 +7472,12 @@ export const BUILTIN_MODULES = [
7417
7472
  },
7418
7473
  "name": {
7419
7474
  "type": "string",
7420
- "description": "待办名称"
7475
+ "description": "待办名称,type为custom时必填;type为非custom时由关联对象的名称或标题自动生成"
7476
+ },
7477
+ "objectID": {
7478
+ "type": "integer",
7479
+ "description": "关联对象ID,type为非custom时必填,必须是type对应对象的ID",
7480
+ "format": "int32"
7421
7481
  },
7422
7482
  "begin": {
7423
7483
  "type": "string",
@@ -7438,8 +7498,7 @@ export const BUILTIN_MODULES = [
7438
7498
  },
7439
7499
  "required": [
7440
7500
  "date",
7441
- "type",
7442
- "name"
7501
+ "type"
7443
7502
  ]
7444
7503
  },
7445
7504
  },
@@ -8153,17 +8212,19 @@ export const BUILTIN_MODULES = [
8153
8212
  path: '/my/meetings',
8154
8213
  resultType: 'list',
8155
8214
  pagerGetter: 'pager',
8215
+ resultGetter: 'meetings',
8156
8216
  params: [
8157
8217
  {
8158
8218
  name: 'browseType',
8159
8219
  required: false,
8160
8220
  type: 'string',
8161
- description: '状态,默认是all',
8162
- defaultValue: 'all',
8221
+ description: '状态,默认是futureMeeting',
8222
+ defaultValue: 'futureMeeting',
8163
8223
  options: [
8224
+ { value: 'futureMeeting', label: '我参加的(未开始)' },
8164
8225
  { value: 'all', label: '全部' },
8165
8226
  { value: 'booked', label: '我预约的' },
8166
- { value: 'participate', label: '我参加的' },
8227
+ { value: 'participate', label: '我参加的(全部)' },
8167
8228
  ],
8168
8229
  },
8169
8230
  {
@@ -8193,7 +8254,6 @@ export const BUILTIN_MODULES = [
8193
8254
  description: '页码,从第1页开始',
8194
8255
  },
8195
8256
  ],
8196
- resultGetter: 'meetings',
8197
8257
  }, {
8198
8258
  name: 'issues',
8199
8259
  display: '指派给我的问题',
@@ -166,6 +166,16 @@ export function applyBuiltinOverrides() {
166
166
  return action;
167
167
  });
168
168
  });
169
+ // OpenAPI 使用 JSON 描述 SDK 的本地文件路径入参,但实际请求仍需转换为 multipart/form-data
170
+ extendModuleAction('file', 'create', (action) => {
171
+ if (action.requestBody) {
172
+ action.requestBody.mediaType = 'multipart/form-data';
173
+ const properties = action.requestBody.schema?.properties;
174
+ if (properties?.file)
175
+ properties.file.format = 'binary';
176
+ }
177
+ return action;
178
+ });
169
179
  // 修改 BUG 列表选项
170
180
  extendModuleAction('bug', 'list', (action) => {
171
181
  const params = action.params;