@plolink/sdk 0.0.8 → 0.0.9
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/README.md +58 -4
- package/dist/{chunk-LHNCGCWW.js → chunk-4H4RACSE.js} +3 -137
- package/dist/chunk-4H4RACSE.js.map +1 -0
- package/dist/{chunk-WFBN23AH.cjs → chunk-NS3DJP2O.cjs} +2 -141
- package/dist/chunk-NS3DJP2O.cjs.map +1 -0
- package/dist/chunk-PJAJFV7D.js +139 -0
- package/dist/chunk-PJAJFV7D.js.map +1 -0
- package/dist/chunk-V6NFRYO2.cjs +145 -0
- package/dist/chunk-V6NFRYO2.cjs.map +1 -0
- package/dist/client-CAjIQKPm.d.cts +193 -0
- package/dist/client-CwNikk7i.d.ts +193 -0
- package/dist/common/index.cjs +19 -18
- package/dist/common/index.d.cts +2 -126
- package/dist/common/index.d.ts +2 -126
- package/dist/common/index.js +2 -1
- package/dist/index.cjs +18 -751
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -410
- package/dist/index.d.ts +4 -410
- package/dist/index.js +4 -735
- package/dist/index.js.map +1 -1
- package/dist/modules/billing/index.cjs +1 -1
- package/dist/modules/billing/index.d.cts +1 -1
- package/dist/modules/billing/index.d.ts +1 -1
- package/dist/modules/billing/index.js +1 -1
- package/dist/modules/info-sync/index.cjs +275 -0
- package/dist/modules/info-sync/index.cjs.map +1 -0
- package/dist/modules/info-sync/index.d.cts +431 -0
- package/dist/modules/info-sync/index.d.ts +431 -0
- package/dist/modules/info-sync/index.js +269 -0
- package/dist/modules/info-sync/index.js.map +1 -0
- package/dist/modules/psychology-test/index.cjs +475 -0
- package/dist/modules/psychology-test/index.cjs.map +1 -0
- package/dist/{client-DXKAtLg1.d.ts → modules/psychology-test/index.d.cts} +32 -196
- package/dist/{client-l6cekf09.d.cts → modules/psychology-test/index.d.ts} +32 -196
- package/dist/modules/psychology-test/index.js +473 -0
- package/dist/modules/psychology-test/index.js.map +1 -0
- package/dist/modules/rbac/index.d.cts +1 -1
- package/dist/modules/rbac/index.d.ts +1 -1
- package/dist/modules/report-writer/index.cjs +282 -0
- package/dist/modules/report-writer/index.cjs.map +1 -0
- package/dist/modules/report-writer/index.d.cts +476 -0
- package/dist/modules/report-writer/index.d.ts +476 -0
- package/dist/modules/report-writer/index.js +280 -0
- package/dist/modules/report-writer/index.js.map +1 -0
- package/dist/modules/team/index.d.cts +1 -1
- package/dist/modules/team/index.d.ts +1 -1
- package/dist/modules/video-psych-analysis/index.cjs +1 -1
- package/dist/modules/video-psych-analysis/index.d.cts +1 -1
- package/dist/modules/video-psych-analysis/index.d.ts +1 -1
- package/dist/modules/video-psych-analysis/index.js +1 -1
- package/dist/modules/virtual-account/index.d.cts +1 -1
- package/dist/modules/virtual-account/index.d.ts +1 -1
- package/dist/signature-B5LL3Zij.d.cts +126 -0
- package/dist/signature-B5LL3Zij.d.ts +126 -0
- package/package.json +16 -1
- package/dist/chunk-LHNCGCWW.js.map +0 -1
- package/dist/chunk-WFBN23AH.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { EventEmitter, TypedEventEmitter, environmentInfo, getEnvironment, isBrowser, isNode, isWebWorker } from './chunk-4H4RACSE.js';
|
|
2
|
+
export { Poller } from './chunk-IHAAKFEJ.js';
|
|
3
|
+
export { InfoSyncSignature } from './chunk-PJAJFV7D.js';
|
|
1
4
|
import { PlolinkError } from './chunk-MD4O7FWT.js';
|
|
2
5
|
export { PlolinkError } from './chunk-MD4O7FWT.js';
|
|
3
|
-
export { EventEmitter, InfoSyncSignature, TypedEventEmitter, environmentInfo, getEnvironment, isBrowser, isNode, isWebWorker } from './chunk-LHNCGCWW.js';
|
|
4
|
-
export { Poller } from './chunk-IHAAKFEJ.js';
|
|
5
6
|
import axios from 'axios';
|
|
6
7
|
|
|
7
8
|
// src/core/logger.ts
|
|
@@ -187,474 +188,6 @@ function createAxiosInstance(config, logger) {
|
|
|
187
188
|
return instance;
|
|
188
189
|
}
|
|
189
190
|
|
|
190
|
-
// src/modules/psychology-test/index.ts
|
|
191
|
-
var PsychologyTest = class {
|
|
192
|
-
constructor(client) {
|
|
193
|
-
this.client = client;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* 创建心理评测会话
|
|
197
|
-
*
|
|
198
|
-
* @description
|
|
199
|
-
* 创建心理评测会话记录(不返回题目)。
|
|
200
|
-
* 创建后需要调用 getSessionQuestions() 获取题目列表。
|
|
201
|
-
*
|
|
202
|
-
* @param params - 创建会话参数
|
|
203
|
-
* @returns 会话信息,包含会话ID
|
|
204
|
-
* @throws {PlolinkError} 当参数验证失败或创建失败时抛出
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```typescript
|
|
208
|
-
* // 1. 创建会话
|
|
209
|
-
* const { sessionId } = await client.psychologyTest.createTestSession({
|
|
210
|
-
* groupCodes: ['family_parenting', 'disc'],
|
|
211
|
-
* businessModule: 'talent_assessment',
|
|
212
|
-
* businessCode: 'job_match',
|
|
213
|
-
* businessId: 'clxxxx123456',
|
|
214
|
-
* needAnalysis: true,
|
|
215
|
-
* analysisPrompt: '请结合家庭养育方式和DISC行为模式,分析候选人的性格特点。'
|
|
216
|
-
* });
|
|
217
|
-
*
|
|
218
|
-
* console.log(`评测会话已创建: ${sessionId}`);
|
|
219
|
-
*
|
|
220
|
-
* // 2. 获取题目
|
|
221
|
-
* const questions = await client.psychologyTest.getSessionQuestions(sessionId);
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
async createTestSession(params) {
|
|
225
|
-
this.client.logger.info("Creating psychology test session", {
|
|
226
|
-
groupCodes: params.groupCodes,
|
|
227
|
-
businessModule: params.businessModule,
|
|
228
|
-
businessCode: params.businessCode,
|
|
229
|
-
needAnalysis: params.needAnalysis
|
|
230
|
-
});
|
|
231
|
-
if (!params.groupCodes || params.groupCodes.length === 0) {
|
|
232
|
-
throw new PlolinkError(
|
|
233
|
-
"groupCodes is required and cannot be empty",
|
|
234
|
-
"VALIDATION_ERROR"
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
if (!params.businessModule || !params.businessCode || !params.businessId) {
|
|
238
|
-
throw new PlolinkError(
|
|
239
|
-
"businessModule, businessCode, and businessId are required",
|
|
240
|
-
"VALIDATION_ERROR"
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
if (params.needAnalysis && !params.analysisPrompt) {
|
|
244
|
-
throw new PlolinkError(
|
|
245
|
-
"analysisPrompt is required when needAnalysis is true",
|
|
246
|
-
"VALIDATION_ERROR"
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
try {
|
|
250
|
-
const response = await this.client.axiosInstance.post(
|
|
251
|
-
"/api/v1/psychology/test-sessions",
|
|
252
|
-
params
|
|
253
|
-
);
|
|
254
|
-
this.client.logger.info("Psychology test session created successfully", {
|
|
255
|
-
sessionId: response.sessionId
|
|
256
|
-
});
|
|
257
|
-
return response;
|
|
258
|
-
} catch (error) {
|
|
259
|
-
this.client.logger.error("Failed to create psychology test session", { error });
|
|
260
|
-
throw error;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* 获取会话题目
|
|
265
|
-
*
|
|
266
|
-
* @description
|
|
267
|
-
* 获取心理评测会话的题目列表(动态生成,每次调用都会重新打乱题目顺序)。
|
|
268
|
-
*
|
|
269
|
-
* @param sessionId - 评测会话ID
|
|
270
|
-
* @returns 题目列表和题组摘要
|
|
271
|
-
* @throws {PlolinkError} 当会话不存在或获取失败时抛出
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* ```typescript
|
|
275
|
-
* const questions = await client.psychologyTest.getSessionQuestions('clxxxx789012');
|
|
276
|
-
*
|
|
277
|
-
* console.log(`共 ${questions.totalCount} 道题目`);
|
|
278
|
-
* console.log('题组摘要:', questions.groupSummary);
|
|
279
|
-
*
|
|
280
|
-
* // 展示题目
|
|
281
|
-
* questions.questions.forEach((q, index) => {
|
|
282
|
-
* console.log(`题目 ${index + 1}: ${q.content}`);
|
|
283
|
-
* });
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
async getSessionQuestions(sessionId) {
|
|
287
|
-
this.client.logger.info("Getting session questions", { sessionId });
|
|
288
|
-
if (!sessionId) {
|
|
289
|
-
throw new PlolinkError("sessionId is required", "VALIDATION_ERROR");
|
|
290
|
-
}
|
|
291
|
-
try {
|
|
292
|
-
const response = await this.client.axiosInstance.get(
|
|
293
|
-
`/api/v1/psychology/test-sessions/${sessionId}/questions`
|
|
294
|
-
);
|
|
295
|
-
this.client.logger.info("Session questions retrieved successfully", {
|
|
296
|
-
sessionId,
|
|
297
|
-
totalCount: response.totalCount
|
|
298
|
-
});
|
|
299
|
-
return response;
|
|
300
|
-
} catch (error) {
|
|
301
|
-
this.client.logger.error("Failed to get session questions", { error, sessionId });
|
|
302
|
-
throw error;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* 发起心理评测(已废弃)
|
|
307
|
-
*
|
|
308
|
-
* @deprecated 此方法已废弃,将在 v2.0 中移除。请使用 createTestSession() + getSessionQuestions() 替代。
|
|
309
|
-
*
|
|
310
|
-
* @description
|
|
311
|
-
* 根据题组代码列表发起心理评测会话,系统会自动生成打乱后的题目列表并返回。
|
|
312
|
-
*
|
|
313
|
-
* **迁移建议**:
|
|
314
|
-
* ```typescript
|
|
315
|
-
* // 旧方式(已废弃)
|
|
316
|
-
* const result = await client.psychologyTest.initiate(params);
|
|
317
|
-
*
|
|
318
|
-
* // 新方式(推荐)
|
|
319
|
-
* const { sessionId } = await client.psychologyTest.createTestSession(params);
|
|
320
|
-
* const result = await client.psychologyTest.getSessionQuestions(sessionId);
|
|
321
|
-
* ```
|
|
322
|
-
*
|
|
323
|
-
* @param params - 发起评测参数
|
|
324
|
-
* @returns 评测会话信息,包含会话ID和题目列表
|
|
325
|
-
* @throws {PlolinkError} 当参数验证失败或发起失败时抛出
|
|
326
|
-
*/
|
|
327
|
-
async initiate(params) {
|
|
328
|
-
this.client.logger.warn("Using deprecated initiate() method. Please use createTestSession() + getSessionQuestions() instead.");
|
|
329
|
-
this.client.logger.info("Initiating psychology test (deprecated)", {
|
|
330
|
-
groupCodes: params.groupCodes,
|
|
331
|
-
businessModule: params.businessModule,
|
|
332
|
-
businessCode: params.businessCode,
|
|
333
|
-
needAnalysis: params.needAnalysis
|
|
334
|
-
});
|
|
335
|
-
if (!params.groupCodes || params.groupCodes.length === 0) {
|
|
336
|
-
throw new PlolinkError(
|
|
337
|
-
"groupCodes is required and cannot be empty",
|
|
338
|
-
"VALIDATION_ERROR"
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
if (!params.businessModule || !params.businessCode || !params.businessId) {
|
|
342
|
-
throw new PlolinkError(
|
|
343
|
-
"businessModule, businessCode, and businessId are required",
|
|
344
|
-
"VALIDATION_ERROR"
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
if (params.needAnalysis && !params.analysisPrompt) {
|
|
348
|
-
throw new PlolinkError(
|
|
349
|
-
"analysisPrompt is required when needAnalysis is true",
|
|
350
|
-
"VALIDATION_ERROR"
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
try {
|
|
354
|
-
const { sessionId } = await this.createTestSession(params);
|
|
355
|
-
const questionsData = await this.getSessionQuestions(sessionId);
|
|
356
|
-
const response = {
|
|
357
|
-
sessionId,
|
|
358
|
-
...questionsData
|
|
359
|
-
};
|
|
360
|
-
this.client.logger.info("Psychology test initiated successfully (deprecated)", {
|
|
361
|
-
sessionId: response.sessionId,
|
|
362
|
-
totalCount: response.totalCount
|
|
363
|
-
});
|
|
364
|
-
return response;
|
|
365
|
-
} catch (error) {
|
|
366
|
-
this.client.logger.error("Failed to initiate psychology test", { error });
|
|
367
|
-
throw error;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* 提交心理评测
|
|
372
|
-
*
|
|
373
|
-
* @description
|
|
374
|
-
* 提交心理评测答题数据,系统会自动计算得分并生成 Markdown 描述。
|
|
375
|
-
* 如需 AI 分析则会加入异步队列,分析完成后会通过 Webhook 通知。
|
|
376
|
-
*
|
|
377
|
-
* @param params - 提交评测参数
|
|
378
|
-
* @returns 提交结果,包含计算结果和得分描述
|
|
379
|
-
* @throws {PlolinkError} 当参数验证失败或提交失败时抛出
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* const result = await client.psychologyTest.submit({
|
|
384
|
-
* sessionId: 'clxxxx789012',
|
|
385
|
-
* answers: [
|
|
386
|
-
* {
|
|
387
|
-
* groupCode: 'family_parenting',
|
|
388
|
-
* bankId: 'bank_123',
|
|
389
|
-
* questionId: 'q_001',
|
|
390
|
-
* questionCode: 'FP001A',
|
|
391
|
-
* answer: '1',
|
|
392
|
-
* timeSpent: 3500
|
|
393
|
-
* },
|
|
394
|
-
* // ... 更多答题记录
|
|
395
|
-
* ],
|
|
396
|
-
* duration: 480000
|
|
397
|
-
* });
|
|
398
|
-
*
|
|
399
|
-
* console.log('得分描述:', result.scoreDescription);
|
|
400
|
-
* console.log('计算结果:', result.calculationResults);
|
|
401
|
-
* ```
|
|
402
|
-
*/
|
|
403
|
-
async submit(params) {
|
|
404
|
-
this.client.logger.info("Submitting psychology test", {
|
|
405
|
-
sessionId: params.sessionId,
|
|
406
|
-
answersCount: params.answers.length
|
|
407
|
-
});
|
|
408
|
-
if (!params.sessionId) {
|
|
409
|
-
throw new PlolinkError(
|
|
410
|
-
"sessionId is required",
|
|
411
|
-
"VALIDATION_ERROR"
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
if (!params.answers || params.answers.length === 0) {
|
|
415
|
-
throw new PlolinkError(
|
|
416
|
-
"answers is required and cannot be empty",
|
|
417
|
-
"VALIDATION_ERROR"
|
|
418
|
-
);
|
|
419
|
-
}
|
|
420
|
-
try {
|
|
421
|
-
const response = await this.client.axiosInstance.post(
|
|
422
|
-
"/api/v1/psychology/test-sessions/submit",
|
|
423
|
-
params
|
|
424
|
-
);
|
|
425
|
-
this.client.logger.info("Psychology test submitted successfully", {
|
|
426
|
-
sessionId: response.sessionId
|
|
427
|
-
});
|
|
428
|
-
return response;
|
|
429
|
-
} catch (error) {
|
|
430
|
-
this.client.logger.error("Failed to submit psychology test", { error });
|
|
431
|
-
throw error;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* 获取心理评测详情
|
|
436
|
-
*
|
|
437
|
-
* @description
|
|
438
|
-
* 获取心理评测会话的完整信息,包括基本信息、计算结果、得分描述、AI分析结果等。
|
|
439
|
-
*
|
|
440
|
-
* @param sessionId - 评测会话ID
|
|
441
|
-
* @returns 评测会话详情
|
|
442
|
-
* @throws {PlolinkError} 当会话不存在或查询失败时抛出
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* ```typescript
|
|
446
|
-
* const detail = await client.psychologyTest.getDetail('clxxxx789012');
|
|
447
|
-
*
|
|
448
|
-
* console.log('评测状态:', detail.status);
|
|
449
|
-
* console.log('得分描述:', detail.scoreDescription);
|
|
450
|
-
*
|
|
451
|
-
* // 检查分析状态
|
|
452
|
-
* if (detail.analysisStatus === 'COMPLETED') {
|
|
453
|
-
* console.log('AI分析结果:', detail.analysisResult);
|
|
454
|
-
* } else if (detail.analysisStatus === 'ANALYZING') {
|
|
455
|
-
* console.log('AI分析进行中,请稍后查询');
|
|
456
|
-
* } else if (detail.analysisStatus === 'FAILED') {
|
|
457
|
-
* console.error('分析失败:', detail.analysisError);
|
|
458
|
-
* }
|
|
459
|
-
* ```
|
|
460
|
-
*/
|
|
461
|
-
async getDetail(sessionId) {
|
|
462
|
-
this.client.logger.info("Getting psychology test detail", { sessionId });
|
|
463
|
-
if (!sessionId) {
|
|
464
|
-
throw new PlolinkError(
|
|
465
|
-
"sessionId is required",
|
|
466
|
-
"VALIDATION_ERROR"
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
try {
|
|
470
|
-
const response = await this.client.axiosInstance.get(
|
|
471
|
-
`/api/v1/psychology/test-sessions/${sessionId}`
|
|
472
|
-
);
|
|
473
|
-
this.client.logger.info("Psychology test detail retrieved successfully", {
|
|
474
|
-
sessionId,
|
|
475
|
-
status: response.status,
|
|
476
|
-
analysisStatus: response.analysisStatus
|
|
477
|
-
});
|
|
478
|
-
return response;
|
|
479
|
-
} catch (error) {
|
|
480
|
-
this.client.logger.error("Failed to get psychology test detail", { error });
|
|
481
|
-
throw error;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* 获取心理评测答题记录
|
|
486
|
-
*
|
|
487
|
-
* @description
|
|
488
|
-
* 获取心理评测会话的所有答题记录。
|
|
489
|
-
*
|
|
490
|
-
* @param sessionId - 评测会话ID
|
|
491
|
-
* @returns 答题记录列表
|
|
492
|
-
* @throws {PlolinkError} 当会话不存在或查询失败时抛出
|
|
493
|
-
*
|
|
494
|
-
* @example
|
|
495
|
-
* ```typescript
|
|
496
|
-
* const answers = await client.psychologyTest.getAnswers('clxxxx789012');
|
|
497
|
-
*
|
|
498
|
-
* console.log(`共 ${answers.length} 条答题记录`);
|
|
499
|
-
* answers.forEach(answer => {
|
|
500
|
-
* console.log(`题目 ${answer.questionCode}: ${answer.answer}`);
|
|
501
|
-
* });
|
|
502
|
-
* ```
|
|
503
|
-
*/
|
|
504
|
-
async getAnswers(sessionId) {
|
|
505
|
-
this.client.logger.info("Getting psychology test answers", { sessionId });
|
|
506
|
-
if (!sessionId) {
|
|
507
|
-
throw new PlolinkError(
|
|
508
|
-
"sessionId is required",
|
|
509
|
-
"VALIDATION_ERROR"
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
try {
|
|
513
|
-
const response = await this.client.axiosInstance.get(
|
|
514
|
-
`/api/v1/psychology/test-sessions/${sessionId}/answers`
|
|
515
|
-
);
|
|
516
|
-
this.client.logger.info("Psychology test answers retrieved successfully", {
|
|
517
|
-
sessionId,
|
|
518
|
-
count: response.length
|
|
519
|
-
});
|
|
520
|
-
return response;
|
|
521
|
-
} catch (error) {
|
|
522
|
-
this.client.logger.error("Failed to get psychology test answers", { error });
|
|
523
|
-
throw error;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* 列表查询心理评测会话
|
|
528
|
-
*
|
|
529
|
-
* @description
|
|
530
|
-
* 查询心理评测会话列表,支持分页和多条件筛选。
|
|
531
|
-
* 此接口通常用于管理后台或业务系统查询评测记录。
|
|
532
|
-
*
|
|
533
|
-
* @param params - 查询参数
|
|
534
|
-
* @returns 会话列表和分页信息
|
|
535
|
-
* @throws {PlolinkError} 当查询失败时抛出
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```typescript
|
|
539
|
-
* // 查询所有评测会话
|
|
540
|
-
* const result = await client.psychologyTest.listTestSessions({
|
|
541
|
-
* page: 1,
|
|
542
|
-
* size: 20
|
|
543
|
-
* });
|
|
544
|
-
*
|
|
545
|
-
* console.log(`共 ${result.total} 条记录`);
|
|
546
|
-
* result.list.forEach(session => {
|
|
547
|
-
* console.log(`会话ID: ${session.id}, 状态: ${session.status}`);
|
|
548
|
-
* });
|
|
549
|
-
*
|
|
550
|
-
* // 按条件筛选
|
|
551
|
-
* const filtered = await client.psychologyTest.listTestSessions({
|
|
552
|
-
* page: 1,
|
|
553
|
-
* size: 20,
|
|
554
|
-
* businessModule: 'talent_assessment',
|
|
555
|
-
* status: 'COMPLETED',
|
|
556
|
-
* analysisStatus: 'COMPLETED'
|
|
557
|
-
* });
|
|
558
|
-
* ```
|
|
559
|
-
*/
|
|
560
|
-
async listTestSessions(params = {}) {
|
|
561
|
-
this.client.logger.info("Listing psychology test sessions", { params });
|
|
562
|
-
try {
|
|
563
|
-
const queryParams = new URLSearchParams();
|
|
564
|
-
if (params.page !== void 0) queryParams.append("page", String(params.page));
|
|
565
|
-
if (params.size !== void 0) queryParams.append("size", String(params.size));
|
|
566
|
-
if (params.businessModule) queryParams.append("businessModule", params.businessModule);
|
|
567
|
-
if (params.businessCode) queryParams.append("businessCode", params.businessCode);
|
|
568
|
-
if (params.status) queryParams.append("status", params.status);
|
|
569
|
-
if (params.analysisStatus) queryParams.append("analysisStatus", params.analysisStatus);
|
|
570
|
-
if (params.startDate) queryParams.append("startDate", params.startDate);
|
|
571
|
-
if (params.endDate) queryParams.append("endDate", params.endDate);
|
|
572
|
-
if (params.teamId) queryParams.append("teamId", params.teamId);
|
|
573
|
-
const url = `/api/admin/psychology/test-sessions${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
574
|
-
const response = await this.client.axiosInstance.get(url);
|
|
575
|
-
this.client.logger.info("Psychology test sessions listed successfully", {
|
|
576
|
-
total: response.total,
|
|
577
|
-
count: response.list.length
|
|
578
|
-
});
|
|
579
|
-
return response;
|
|
580
|
-
} catch (error) {
|
|
581
|
-
this.client.logger.error("Failed to list psychology test sessions", { error });
|
|
582
|
-
throw error;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* 删除心理评测会话
|
|
587
|
-
*
|
|
588
|
-
* @description
|
|
589
|
-
* 软删除心理评测会话记录。删除后数据不会真正从数据库移除,
|
|
590
|
-
* 但在正常查询中不会显示。此接口通常用于管理后台。
|
|
591
|
-
*
|
|
592
|
-
* @param sessionId - 评测会话ID
|
|
593
|
-
* @returns void
|
|
594
|
-
* @throws {PlolinkError} 当会话不存在或删除失败时抛出
|
|
595
|
-
*
|
|
596
|
-
* @example
|
|
597
|
-
* ```typescript
|
|
598
|
-
* // 删除评测会话
|
|
599
|
-
* await client.psychologyTest.deleteTestSession('clxxxx789012');
|
|
600
|
-
* console.log('评测会话已删除');
|
|
601
|
-
* ```
|
|
602
|
-
*/
|
|
603
|
-
async deleteTestSession(sessionId) {
|
|
604
|
-
this.client.logger.info("Deleting psychology test session", { sessionId });
|
|
605
|
-
if (!sessionId) {
|
|
606
|
-
throw new PlolinkError(
|
|
607
|
-
"sessionId is required",
|
|
608
|
-
"VALIDATION_ERROR"
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
try {
|
|
612
|
-
await this.client.axiosInstance.delete(
|
|
613
|
-
`/api/admin/psychology/test-sessions/${sessionId}`
|
|
614
|
-
);
|
|
615
|
-
this.client.logger.info("Psychology test session deleted successfully", {
|
|
616
|
-
sessionId
|
|
617
|
-
});
|
|
618
|
-
} catch (error) {
|
|
619
|
-
this.client.logger.error("Failed to delete psychology test session", { error });
|
|
620
|
-
throw error;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* 获取题库组列表
|
|
625
|
-
*
|
|
626
|
-
* @description
|
|
627
|
-
* 获取所有启用状态的题库组列表,返回基本信息用于选择。
|
|
628
|
-
* 此接口不需要管理员权限,普通用户即可调用。
|
|
629
|
-
*
|
|
630
|
-
* @returns 题库组列表
|
|
631
|
-
* @throws {PlolinkError} 当查询失败时抛出
|
|
632
|
-
*
|
|
633
|
-
* @example
|
|
634
|
-
* ```typescript
|
|
635
|
-
* const groups = await client.psychologyTest.listBankGroups();
|
|
636
|
-
* groups.forEach(g => {
|
|
637
|
-
* console.log(`${g.name} (${g.code}): ${g.testObjective}`);
|
|
638
|
-
* });
|
|
639
|
-
* ```
|
|
640
|
-
*/
|
|
641
|
-
async listBankGroups() {
|
|
642
|
-
this.client.logger.info("Listing psychology bank groups");
|
|
643
|
-
try {
|
|
644
|
-
const response = await this.client.axiosInstance.get(
|
|
645
|
-
"/api/v1/psychology/bank-groups"
|
|
646
|
-
);
|
|
647
|
-
this.client.logger.info("Psychology bank groups listed successfully", {
|
|
648
|
-
count: response.length
|
|
649
|
-
});
|
|
650
|
-
return response;
|
|
651
|
-
} catch (error) {
|
|
652
|
-
this.client.logger.error("Failed to list psychology bank groups", { error });
|
|
653
|
-
throw error;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
|
|
658
191
|
// src/core/client.ts
|
|
659
192
|
var PlolinkClient = class {
|
|
660
193
|
/**
|
|
@@ -689,7 +222,6 @@ var PlolinkClient = class {
|
|
|
689
222
|
this.config,
|
|
690
223
|
this.logger
|
|
691
224
|
);
|
|
692
|
-
this.psychologyTest = new PsychologyTest(this);
|
|
693
225
|
}
|
|
694
226
|
/**
|
|
695
227
|
* 验证 SDK 配置
|
|
@@ -760,269 +292,6 @@ var PlolinkClient = class {
|
|
|
760
292
|
}
|
|
761
293
|
};
|
|
762
294
|
|
|
763
|
-
// src/modules/info-sync/index.ts
|
|
764
|
-
var InfoSync = class {
|
|
765
|
-
constructor(client) {
|
|
766
|
-
this.client = client;
|
|
767
|
-
}
|
|
768
|
-
// ==================== Webhook 配置管理 ====================
|
|
769
|
-
/**
|
|
770
|
-
* 创建 Webhook 配置
|
|
771
|
-
*
|
|
772
|
-
* @description
|
|
773
|
-
* 为当前团队创建一个新的 Webhook 配置。
|
|
774
|
-
* 返回的 secretKey 仅在创建时返回一次,请立即保存。
|
|
775
|
-
*
|
|
776
|
-
* 每个团队最多可以创建 10 个 Webhook 配置。
|
|
777
|
-
*
|
|
778
|
-
* ⚠️ 重要: secretKey 仅在创建时返回,后续无法再次获取,请妥善保存
|
|
779
|
-
*
|
|
780
|
-
* @param params - 创建参数
|
|
781
|
-
* @returns 创建结果,包含配置 ID 和密钥
|
|
782
|
-
* @throws {PlolinkError} 当参数无效、配置数量超限或权限不足时抛出
|
|
783
|
-
*
|
|
784
|
-
* @example
|
|
785
|
-
* ```typescript
|
|
786
|
-
* const result = await infoSync.createWebhookConfig({
|
|
787
|
-
* name: 'Production Webhook',
|
|
788
|
-
* url: 'https://example.com/webhook/plolink',
|
|
789
|
-
* modules: ['report-writer', 'video-psych-analysis']
|
|
790
|
-
* });
|
|
791
|
-
*
|
|
792
|
-
* console.log(`配置 ID: ${result.id}`);
|
|
793
|
-
* console.log(`SecretKey: ${result.secretKey}`);
|
|
794
|
-
* // 请立即保存 secretKey,后续无法再次获取
|
|
795
|
-
* ```
|
|
796
|
-
*/
|
|
797
|
-
async createWebhookConfig(params) {
|
|
798
|
-
if (!params.name || params.name.trim().length === 0) {
|
|
799
|
-
throw new PlolinkError("name is required and cannot be empty", "INVALID_PARAMS");
|
|
800
|
-
}
|
|
801
|
-
if (!params.url || params.url.trim().length === 0) {
|
|
802
|
-
throw new PlolinkError("url is required and cannot be empty", "INVALID_PARAMS");
|
|
803
|
-
}
|
|
804
|
-
if (!params.url.startsWith("http://") && !params.url.startsWith("https://")) {
|
|
805
|
-
throw new PlolinkError("url must start with http:// or https://", "INVALID_PARAMS");
|
|
806
|
-
}
|
|
807
|
-
if (!Array.isArray(params.modules)) {
|
|
808
|
-
throw new PlolinkError("modules must be an array", "INVALID_PARAMS");
|
|
809
|
-
}
|
|
810
|
-
return this.client.axiosInstance.post("/api/v1/info-sync/webhook-configs", params);
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* 获取 Webhook 配置列表
|
|
814
|
-
*
|
|
815
|
-
* @description
|
|
816
|
-
* 获取当前团队的所有 Webhook 配置。
|
|
817
|
-
* 注意:列表中不包含 secretKey。
|
|
818
|
-
*
|
|
819
|
-
* @returns Webhook 配置列表
|
|
820
|
-
* @throws {PlolinkError} 当权限不足时抛出
|
|
821
|
-
*
|
|
822
|
-
* @example
|
|
823
|
-
* ```typescript
|
|
824
|
-
* const configs = await infoSync.listWebhookConfigs();
|
|
825
|
-
* configs.forEach(config => {
|
|
826
|
-
* console.log(`${config.name}: ${config.url}`);
|
|
827
|
-
* console.log(`订阅模块: ${config.modules.join(', ')}`);
|
|
828
|
-
* console.log(`状态: ${config.enabled ? '启用' : '禁用'}`);
|
|
829
|
-
* });
|
|
830
|
-
* ```
|
|
831
|
-
*/
|
|
832
|
-
async listWebhookConfigs() {
|
|
833
|
-
return this.client.axiosInstance.get("/api/v1/info-sync/webhook-configs");
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* 获取 Webhook 配置详情
|
|
837
|
-
*
|
|
838
|
-
* @description
|
|
839
|
-
* 获取指定 Webhook 配置的详细信息。
|
|
840
|
-
* 注意:不包含 secretKey。
|
|
841
|
-
*
|
|
842
|
-
* @param id - 配置 ID
|
|
843
|
-
* @returns Webhook 配置详情
|
|
844
|
-
* @throws {PlolinkError} 当配置不存在或权限不足时抛出
|
|
845
|
-
*
|
|
846
|
-
* @example
|
|
847
|
-
* ```typescript
|
|
848
|
-
* const config = await infoSync.getWebhookConfig('config-123');
|
|
849
|
-
* console.log(`名称: ${config.name}`);
|
|
850
|
-
* console.log(`URL: ${config.url}`);
|
|
851
|
-
* console.log(`订阅模块: ${config.modules.join(', ')}`);
|
|
852
|
-
* ```
|
|
853
|
-
*/
|
|
854
|
-
async getWebhookConfig(id) {
|
|
855
|
-
if (!id) {
|
|
856
|
-
throw new PlolinkError("id is required", "INVALID_PARAMS");
|
|
857
|
-
}
|
|
858
|
-
return this.client.axiosInstance.get(`/api/v1/info-sync/webhook-configs/${id}`);
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* 更新 Webhook 配置
|
|
862
|
-
*
|
|
863
|
-
* @description
|
|
864
|
-
* 更新指定 Webhook 配置的信息。
|
|
865
|
-
* 注意:不能更新 secretKey,如需更换密钥请删除后重新创建。
|
|
866
|
-
*
|
|
867
|
-
* @param id - 配置 ID
|
|
868
|
-
* @param params - 更新参数
|
|
869
|
-
* @throws {PlolinkError} 当参数无效、配置不存在或权限不足时抛出
|
|
870
|
-
*
|
|
871
|
-
* @example
|
|
872
|
-
* ```typescript
|
|
873
|
-
* // 禁用配置
|
|
874
|
-
* await infoSync.updateWebhookConfig('config-123', {
|
|
875
|
-
* enabled: false
|
|
876
|
-
* });
|
|
877
|
-
*
|
|
878
|
-
* // 更新订阅模块
|
|
879
|
-
* await infoSync.updateWebhookConfig('config-123', {
|
|
880
|
-
* modules: ['report-writer']
|
|
881
|
-
* });
|
|
882
|
-
*
|
|
883
|
-
* // 更新 URL
|
|
884
|
-
* await infoSync.updateWebhookConfig('config-123', {
|
|
885
|
-
* url: 'https://new-url.example.com/webhook'
|
|
886
|
-
* });
|
|
887
|
-
* ```
|
|
888
|
-
*/
|
|
889
|
-
async updateWebhookConfig(id, params) {
|
|
890
|
-
if (!id) {
|
|
891
|
-
throw new PlolinkError("id is required", "INVALID_PARAMS");
|
|
892
|
-
}
|
|
893
|
-
if (params.url && (!params.url.startsWith("http://") && !params.url.startsWith("https://"))) {
|
|
894
|
-
throw new PlolinkError("url must start with http:// or https://", "INVALID_PARAMS");
|
|
895
|
-
}
|
|
896
|
-
if (params.modules !== void 0 && !Array.isArray(params.modules)) {
|
|
897
|
-
throw new PlolinkError("modules must be an array", "INVALID_PARAMS");
|
|
898
|
-
}
|
|
899
|
-
await this.client.axiosInstance.put(`/api/v1/info-sync/webhook-configs/${id}`, params);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* 删除 Webhook 配置
|
|
903
|
-
*
|
|
904
|
-
* @description
|
|
905
|
-
* 永久删除指定的 Webhook 配置(软删除)。
|
|
906
|
-
* 删除后该配置将不再接收 Webhook 通知。
|
|
907
|
-
*
|
|
908
|
-
* ⚠️ 警告: 此操作不可逆,请确认后再执行
|
|
909
|
-
*
|
|
910
|
-
* @param id - 配置 ID
|
|
911
|
-
* @throws {PlolinkError} 当配置不存在或权限不足时抛出
|
|
912
|
-
*
|
|
913
|
-
* @example
|
|
914
|
-
* ```typescript
|
|
915
|
-
* await infoSync.deleteWebhookConfig('config-123');
|
|
916
|
-
* console.log('Webhook 配置已删除');
|
|
917
|
-
* ```
|
|
918
|
-
*/
|
|
919
|
-
async deleteWebhookConfig(id) {
|
|
920
|
-
if (!id) {
|
|
921
|
-
throw new PlolinkError("id is required", "INVALID_PARAMS");
|
|
922
|
-
}
|
|
923
|
-
await this.client.axiosInstance.delete(`/api/v1/info-sync/webhook-configs/${id}`);
|
|
924
|
-
}
|
|
925
|
-
// ==================== 同步记录查询 ====================
|
|
926
|
-
/**
|
|
927
|
-
* 查询同步记录列表
|
|
928
|
-
*
|
|
929
|
-
* @description
|
|
930
|
-
* 查询当前团队的同步记录,支持多种过滤条件和分页。
|
|
931
|
-
*
|
|
932
|
-
* @param params - 查询参数
|
|
933
|
-
* @returns 分页的同步记录列表
|
|
934
|
-
* @throws {PlolinkError} 当参数无效或权限不足时抛出
|
|
935
|
-
*
|
|
936
|
-
* @example
|
|
937
|
-
* ```typescript
|
|
938
|
-
* // 查询所有记录
|
|
939
|
-
* const result = await infoSync.listSyncRecords();
|
|
940
|
-
* console.log(`共 ${result.total} 条记录`);
|
|
941
|
-
*
|
|
942
|
-
* // 查询失败的 Webhook 同步记录
|
|
943
|
-
* const failed = await infoSync.listSyncRecords({
|
|
944
|
-
* type: 'WEBHOOK',
|
|
945
|
-
* status: 'FAILED'
|
|
946
|
-
* });
|
|
947
|
-
* console.log(`${failed.total} 条 Webhook 同步失败`);
|
|
948
|
-
*
|
|
949
|
-
* // 查询报告写作模块的记录
|
|
950
|
-
* const reports = await infoSync.listSyncRecords({
|
|
951
|
-
* businessModule: 'report-writer',
|
|
952
|
-
* page: 1,
|
|
953
|
-
* pageSize: 20
|
|
954
|
-
* });
|
|
955
|
-
* ```
|
|
956
|
-
*/
|
|
957
|
-
async listSyncRecords(params) {
|
|
958
|
-
return this.client.axiosInstance.get("/api/v1/info-sync/sync-records", {
|
|
959
|
-
params: params || {}
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* 获取同步记录详情
|
|
964
|
-
*
|
|
965
|
-
* @description
|
|
966
|
-
* 获取指定同步记录的详细信息,包括完整的历史记录。
|
|
967
|
-
*
|
|
968
|
-
* @param id - 记录 ID
|
|
969
|
-
* @returns 同步记录详情
|
|
970
|
-
* @throws {PlolinkError} 当记录不存在或权限不足时抛出
|
|
971
|
-
*
|
|
972
|
-
* @example
|
|
973
|
-
* ```typescript
|
|
974
|
-
* const record = await infoSync.getSyncRecord('record-123');
|
|
975
|
-
* console.log(`业务模块: ${record.businessModule}`);
|
|
976
|
-
* console.log(`业务代码: ${record.businessCode}`);
|
|
977
|
-
* console.log(`状态: ${record.status}`);
|
|
978
|
-
* console.log(`历史记录:`);
|
|
979
|
-
* record.history.forEach(item => {
|
|
980
|
-
* console.log(` ${new Date(item.time).toLocaleString()}: ${item.status} - ${item.message || ''}`);
|
|
981
|
-
* });
|
|
982
|
-
* ```
|
|
983
|
-
*/
|
|
984
|
-
async getSyncRecord(id) {
|
|
985
|
-
if (!id) {
|
|
986
|
-
throw new PlolinkError("id is required", "INVALID_PARAMS");
|
|
987
|
-
}
|
|
988
|
-
return this.client.axiosInstance.get(`/api/v1/info-sync/sync-records/${id}`);
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* 手动重试同步任务
|
|
992
|
-
*
|
|
993
|
-
* @description
|
|
994
|
-
* 手动重试失败的同步任务。
|
|
995
|
-
* 只能重试状态为 FAILED 的记录。
|
|
996
|
-
*
|
|
997
|
-
* 重试后记录状态将变为 PENDING,并重新提交到队列处理。
|
|
998
|
-
*
|
|
999
|
-
* @param id - 记录 ID
|
|
1000
|
-
* @throws {PlolinkError} 当记录不存在、状态不是 FAILED 或权限不足时抛出
|
|
1001
|
-
*
|
|
1002
|
-
* @example
|
|
1003
|
-
* ```typescript
|
|
1004
|
-
* // 查询失败记录
|
|
1005
|
-
* const failed = await infoSync.listSyncRecords({ status: 'FAILED' });
|
|
1006
|
-
*
|
|
1007
|
-
* // 重试所有失败记录
|
|
1008
|
-
* for (const record of failed.list) {
|
|
1009
|
-
* try {
|
|
1010
|
-
* await infoSync.retrySyncRecord(record.id);
|
|
1011
|
-
* console.log(`已重试: ${record.id}`);
|
|
1012
|
-
* } catch (error) {
|
|
1013
|
-
* console.error(`重试失败: ${record.id}`, error);
|
|
1014
|
-
* }
|
|
1015
|
-
* }
|
|
1016
|
-
* ```
|
|
1017
|
-
*/
|
|
1018
|
-
async retrySyncRecord(id) {
|
|
1019
|
-
if (!id) {
|
|
1020
|
-
throw new PlolinkError("id is required", "INVALID_PARAMS");
|
|
1021
|
-
}
|
|
1022
|
-
await this.client.axiosInstance.post(`/api/v1/info-sync/sync-records/${id}/retry`);
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
|
|
1026
295
|
// src/index.ts
|
|
1027
296
|
var VERSION = "1.0.0";
|
|
1028
297
|
var DEFAULT_CONFIG = {
|
|
@@ -1033,6 +302,6 @@ var DEFAULT_CONFIG = {
|
|
|
1033
302
|
backoffFactor: 1.5
|
|
1034
303
|
};
|
|
1035
304
|
|
|
1036
|
-
export { DEFAULT_CONFIG,
|
|
305
|
+
export { DEFAULT_CONFIG, InternalLogger, PlolinkClient, VERSION };
|
|
1037
306
|
//# sourceMappingURL=index.js.map
|
|
1038
307
|
//# sourceMappingURL=index.js.map
|