@cpzxrobot/sdk 1.3.122 → 1.3.124

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/aiform_gateway.ts CHANGED
@@ -9,6 +9,7 @@ import type {
9
9
  AiformTemplateHistoryResponse,
10
10
  AiformTemplatePublishResponse,
11
11
  AiformReplyResponse,
12
+ AiformReplyDetailResponse,
12
13
  AiformConfirmResponse,
13
14
  AiformReplyListResponse,
14
15
  } from ".";
@@ -79,19 +80,22 @@ export class AiformGateway extends Object {
79
80
  * @param templateId 模板ID(可选,与factoryId二选一)
80
81
  * @param factoryId 工厂ID(可选,与templateId二选一)
81
82
  */
82
- uploadTemplateImage: async (templateId: number | null, factoryId?: number): Promise<any> => {
83
+ uploadTemplateImage: async (args: {
84
+ templateId?: number;
85
+ factoryId?: number;
86
+ }): Promise<any> => {
83
87
  const axios = await this.context.ready;
84
88
 
85
- if (!templateId && !factoryId) {
89
+ if (!args.templateId && !args.factoryId) {
86
90
  throw new Error('模板ID和工厂ID至少需要传一个');
87
91
  }
88
92
 
89
93
  const data: any = {};
90
- if (templateId) {
91
- data.templateId = templateId;
94
+ if (args.templateId) {
95
+ data.templateId = args.templateId;
92
96
  }
93
- if (factoryId) {
94
- data.factoryId = factoryId;
97
+ if (args.factoryId) {
98
+ data.factoryId = args.factoryId;
95
99
  }
96
100
 
97
101
  return axios.upload(`/api/v2/aiform/template/upload`,{
@@ -243,11 +247,13 @@ export class AiformGateway extends Object {
243
247
  },
244
248
 
245
249
  /**
246
- * 根据reply_id获取解析结果
250
+ * 按 replyId 轮询结果
251
+ * GET /api/v2/aiform/file/detail/reply/{replyId}
247
252
  * @param replyId reply记录ID
248
- * @returns Promise 包含解析结果详情
253
+ * @returns Promise 包含 replyId、status、result 和 accessUrl
254
+ * 注意:用于轮询 reply 的处理状态,status=1 处理中,status=2 成功,status=0 失败
249
255
  */
250
- getReplyDetail: async (replyId: number): Promise<AiformFileDetailResponse> => {
256
+ getReplyDetail: async (replyId: number): Promise<AiformReplyDetailResponse> => {
251
257
  const axios = await this.context.ready;
252
258
 
253
259
  if (!replyId) {
@@ -264,9 +270,11 @@ export class AiformGateway extends Object {
264
270
 
265
271
  /**
266
272
  * 根据解析结果提交反馈(reply)
273
+ * POST /api/v2/aiform/file/reply
267
274
  * @param code 文件业务编码
268
275
  * @param reply 用户的修改意见/反馈内容
269
- * @returns Promise 包含调整后的解析结果
276
+ * @returns Promise 包含 replyId、status 和 accessUrl
277
+ * 注意:接口为异步,立即返回 replyId 与 status=1,需使用 getReplyDetail 按 replyId 轮询直至 status=2 或 0
270
278
  */
271
279
  reply: async (code: string, reply: string): Promise<AiformReplyResponse> => {
272
280
  const axios = await this.context.ready;
@@ -67,17 +67,17 @@ class AiformGateway extends Object {
67
67
  * @param templateId 模板ID(可选,与factoryId二选一)
68
68
  * @param factoryId 工厂ID(可选,与templateId二选一)
69
69
  */
70
- uploadTemplateImage: (templateId, factoryId) => __awaiter(this, void 0, void 0, function* () {
70
+ uploadTemplateImage: (args) => __awaiter(this, void 0, void 0, function* () {
71
71
  const axios = yield this.context.ready;
72
- if (!templateId && !factoryId) {
72
+ if (!args.templateId && !args.factoryId) {
73
73
  throw new Error('模板ID和工厂ID至少需要传一个');
74
74
  }
75
75
  const data = {};
76
- if (templateId) {
77
- data.templateId = templateId;
76
+ if (args.templateId) {
77
+ data.templateId = args.templateId;
78
78
  }
79
- if (factoryId) {
80
- data.factoryId = factoryId;
79
+ if (args.factoryId) {
80
+ data.factoryId = args.factoryId;
81
81
  }
82
82
  return axios.upload(`/api/v2/aiform/template/upload`, {
83
83
  title: "请选择表格图片",
@@ -209,9 +209,11 @@ class AiformGateway extends Object {
209
209
  });
210
210
  }),
211
211
  /**
212
- * 根据reply_id获取解析结果
212
+ * 按 replyId 轮询结果
213
+ * GET /api/v2/aiform/file/detail/reply/{replyId}
213
214
  * @param replyId reply记录ID
214
- * @returns Promise 包含解析结果详情
215
+ * @returns Promise 包含 replyId、status、result 和 accessUrl
216
+ * 注意:用于轮询 reply 的处理状态,status=1 处理中,status=2 成功,status=0 失败
215
217
  */
216
218
  getReplyDetail: (replyId) => __awaiter(this, void 0, void 0, function* () {
217
219
  const axios = yield this.context.ready;
@@ -227,9 +229,11 @@ class AiformGateway extends Object {
227
229
  }),
228
230
  /**
229
231
  * 根据解析结果提交反馈(reply)
232
+ * POST /api/v2/aiform/file/reply
230
233
  * @param code 文件业务编码
231
234
  * @param reply 用户的修改意见/反馈内容
232
- * @returns Promise 包含调整后的解析结果
235
+ * @returns Promise 包含 replyId、status 和 accessUrl
236
+ * 注意:接口为异步,立即返回 replyId 与 status=1,需使用 getReplyDetail 按 replyId 轮询直至 status=2 或 0
233
237
  */
234
238
  reply: (code, reply) => __awaiter(this, void 0, void 0, function* () {
235
239
  const axios = yield this.context.ready;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.122",
3
+ "version": "1.3.124",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -933,8 +933,36 @@ interface AiformReplyResponse {
933
933
  code: number;
934
934
  /** 提示信息 */
935
935
  message: string;
936
- /** 调整后的解析结果 */
937
- data: AiformParseResultVO;
936
+ /** 提交结果 */
937
+ data: {
938
+ /** 新建 aiform_reply.id,用于轮询 */
939
+ replyId: number;
940
+ /** 提交后恒为 1 */
941
+ status: number;
942
+ /** 原图预签名链接(便于前端展示) */
943
+ accessUrl: string;
944
+ };
945
+ }
946
+
947
+ /**
948
+ * Reply轮询响应接口
949
+ */
950
+ interface AiformReplyDetailResponse {
951
+ /** 响应码 */
952
+ code: number;
953
+ /** 提示信息 */
954
+ message: string;
955
+ /** 轮询结果 */
956
+ data: {
957
+ /** 本条 reply 主键 */
958
+ replyId: number;
959
+ /** 状态:1处理中,2成功,0失败 */
960
+ status: number;
961
+ /** 仅 status=2 且已落库时有值 */
962
+ result?: AiformParseResultVO;
963
+ /** 原图预签名链接 */
964
+ accessUrl: string;
965
+ };
938
966
  }
939
967
 
940
968
  /**
@@ -1235,6 +1263,7 @@ declare module "@cpzxrobot/sdk" {
1235
1263
  AiformFileListResponse,
1236
1264
  AiformFileDetailResponse,
1237
1265
  AiformReplyResponse,
1266
+ AiformReplyDetailResponse,
1238
1267
  AiformConfirmResponse,
1239
1268
  AiformRecordReply,
1240
1269
  AiformReplyListResponse,