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