@plolink/sdk 0.0.5 → 0.0.8

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 (56) hide show
  1. package/README.md +40 -26
  2. package/dist/{chunk-4H4RACSE.js → chunk-LHNCGCWW.js} +137 -3
  3. package/dist/chunk-LHNCGCWW.js.map +1 -0
  4. package/dist/{chunk-NS3DJP2O.cjs → chunk-WFBN23AH.cjs} +141 -2
  5. package/dist/chunk-WFBN23AH.cjs.map +1 -0
  6. package/dist/client-DXKAtLg1.d.ts +848 -0
  7. package/dist/client-l6cekf09.d.cts +848 -0
  8. package/dist/common/index.cjs +18 -14
  9. package/dist/common/index.d.cts +126 -1
  10. package/dist/common/index.d.ts +126 -1
  11. package/dist/common/index.js +1 -1
  12. package/dist/index.cjs +751 -13
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +410 -3
  15. package/dist/index.d.ts +410 -3
  16. package/dist/index.js +735 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/modules/billing/index.cjs +1 -1
  19. package/dist/modules/billing/index.d.cts +1 -1
  20. package/dist/modules/billing/index.d.ts +1 -1
  21. package/dist/modules/billing/index.js +1 -1
  22. package/dist/modules/rbac/index.d.cts +1 -1
  23. package/dist/modules/rbac/index.d.ts +1 -1
  24. package/dist/modules/team/index.d.cts +1 -1
  25. package/dist/modules/team/index.d.ts +1 -1
  26. package/dist/modules/video-psych-analysis/index.cjs +123 -4
  27. package/dist/modules/video-psych-analysis/index.cjs.map +1 -1
  28. package/dist/modules/video-psych-analysis/index.d.cts +231 -93
  29. package/dist/modules/video-psych-analysis/index.d.ts +231 -93
  30. package/dist/modules/video-psych-analysis/index.js +123 -4
  31. package/dist/modules/video-psych-analysis/index.js.map +1 -1
  32. package/dist/modules/virtual-account/index.d.cts +1 -1
  33. package/dist/modules/virtual-account/index.d.ts +1 -1
  34. package/package.json +1 -16
  35. package/dist/chunk-4H4RACSE.js.map +0 -1
  36. package/dist/chunk-NS3DJP2O.cjs.map +0 -1
  37. package/dist/client-CAjIQKPm.d.cts +0 -193
  38. package/dist/client-CwNikk7i.d.ts +0 -193
  39. package/dist/modules/agent/index.cjs +0 -21
  40. package/dist/modules/agent/index.cjs.map +0 -1
  41. package/dist/modules/agent/index.d.cts +0 -71
  42. package/dist/modules/agent/index.d.ts +0 -71
  43. package/dist/modules/agent/index.js +0 -19
  44. package/dist/modules/agent/index.js.map +0 -1
  45. package/dist/modules/chat/index.cjs +0 -20
  46. package/dist/modules/chat/index.cjs.map +0 -1
  47. package/dist/modules/chat/index.d.cts +0 -68
  48. package/dist/modules/chat/index.d.ts +0 -68
  49. package/dist/modules/chat/index.js +0 -18
  50. package/dist/modules/chat/index.js.map +0 -1
  51. package/dist/modules/psych/index.cjs +0 -20
  52. package/dist/modules/psych/index.cjs.map +0 -1
  53. package/dist/modules/psych/index.d.cts +0 -69
  54. package/dist/modules/psych/index.d.ts +0 -69
  55. package/dist/modules/psych/index.js +0 -18
  56. package/dist/modules/psych/index.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,10 +1,169 @@
1
- export { I as InternalLogger, P as PlolinkClient } from './client-CwNikk7i.js';
1
+ import { P as PlolinkClient } from './client-DXKAtLg1.js';
2
+ export { I as InternalLogger, a as PsychologyTest } from './client-DXKAtLg1.js';
2
3
  export { P as Poller } from './poller-DWKZjuSw.js';
3
- export { EventEmitter, TypedEventEmitter, environmentInfo, getEnvironment, isBrowser, isNode, isWebWorker } from './common/index.js';
4
+ export { EventEmitter, InfoSyncSignature, TypedEventEmitter, environmentInfo, getEnvironment, isBrowser, isNode, isWebWorker } from './common/index.js';
4
5
  export { L as LogLevel, b as LoggerFunction, P as PollerOptions, a as PollerSnapshot, S as SDKConfig } from './core-77EbLgbp.js';
5
6
  export { A as AssignRoleParams, R as RoleType, S as ScopeType } from './shared-6ZepUSPW.js';
6
7
  import 'axios';
7
8
 
9
+ /**
10
+ * 信息同步模块类型定义
11
+ */
12
+ /**
13
+ * 同步类型枚举
14
+ */
15
+ declare enum InfoSyncType {
16
+ /** 内部同步 */
17
+ INTERNAL = "INTERNAL",
18
+ /** Webhook 同步 */
19
+ WEBHOOK = "WEBHOOK"
20
+ }
21
+ /**
22
+ * 同步状态枚举
23
+ */
24
+ declare enum InfoSyncStatus {
25
+ /** 待同步 */
26
+ PENDING = "PENDING",
27
+ /** 同步中 */
28
+ SYNCING = "SYNCING",
29
+ /** 已完成 */
30
+ COMPLETED = "COMPLETED",
31
+ /** 同步失败 */
32
+ FAILED = "FAILED"
33
+ }
34
+ /**
35
+ * 历史记录项
36
+ */
37
+ interface InfoSyncHistoryItem {
38
+ /** 时间戳(毫秒) */
39
+ time: number;
40
+ /** 状态 */
41
+ status: InfoSyncStatus;
42
+ /** 消息 */
43
+ message?: string;
44
+ /** 下次重试时间(毫秒) */
45
+ nextRetryTime?: number;
46
+ }
47
+ /**
48
+ * 同步记录
49
+ */
50
+ interface InfoSyncRecord {
51
+ /** 记录 ID */
52
+ id: string;
53
+ /** 业务模块 */
54
+ businessModule: string;
55
+ /** 业务 ID */
56
+ businessId: string;
57
+ /** 业务代码 */
58
+ businessCode: string;
59
+ /** 业务数据 */
60
+ data: Record<string, unknown>;
61
+ /** 同步类型 */
62
+ type: InfoSyncType;
63
+ /** 同步状态 */
64
+ status: InfoSyncStatus;
65
+ /** Webhook URL(仅 type=WEBHOOK 时有值) */
66
+ webhookUrl?: string | null;
67
+ /** Webhook 配置 ID(仅 type=WEBHOOK 时有值) */
68
+ webhookConfigId?: string | null;
69
+ /** 历史记录 */
70
+ history: InfoSyncHistoryItem[];
71
+ /** 创建者 ID */
72
+ creatorId: string;
73
+ /** 团队 ID */
74
+ teamId: string;
75
+ /** 备注 */
76
+ comment?: string | null;
77
+ /** 创建时间(ISO 格式) */
78
+ createdAt: string;
79
+ /** 更新时间(ISO 格式) */
80
+ updatedAt: string;
81
+ }
82
+ /**
83
+ * Webhook 配置
84
+ */
85
+ interface WebhookConfig {
86
+ /** 配置 ID */
87
+ id: string;
88
+ /** 团队 ID */
89
+ teamId: string;
90
+ /** 配置名称 */
91
+ name: string;
92
+ /** Webhook URL */
93
+ url: string;
94
+ /** 订阅的模块列表(空数组表示订阅所有模块) */
95
+ modules: string[];
96
+ /** 是否启用 */
97
+ enabled: boolean;
98
+ /** 创建者 ID */
99
+ creatorId: string;
100
+ /** 创建时间(ISO 格式) */
101
+ createdAt: string;
102
+ /** 更新时间(ISO 格式) */
103
+ updatedAt: string;
104
+ }
105
+ /**
106
+ * 创建 Webhook 配置参数
107
+ */
108
+ interface CreateWebhookConfigParams {
109
+ /** 配置名称 */
110
+ name: string;
111
+ /** Webhook URL */
112
+ url: string;
113
+ /** 订阅的模块列表(空数组表示订阅所有模块) */
114
+ modules: string[];
115
+ }
116
+ /**
117
+ * 创建 Webhook 配置响应
118
+ */
119
+ interface CreateWebhookConfigResponse {
120
+ /** 配置 ID */
121
+ id: string;
122
+ /** 密钥(仅在创建时返回一次) */
123
+ secretKey: string;
124
+ }
125
+ /**
126
+ * 更新 Webhook 配置参数
127
+ */
128
+ interface UpdateWebhookConfigParams {
129
+ /** 配置名称 */
130
+ name?: string;
131
+ /** Webhook URL */
132
+ url?: string;
133
+ /** 订阅的模块列表 */
134
+ modules?: string[];
135
+ /** 是否启用 */
136
+ enabled?: boolean;
137
+ }
138
+ /**
139
+ * 同步记录查询参数
140
+ */
141
+ interface InfoSyncQueryParams {
142
+ /** 业务模块(可选,用于过滤) */
143
+ businessModule?: string;
144
+ /** 同步状态(可选,用于过滤) */
145
+ status?: InfoSyncStatus;
146
+ /** 同步类型(可选,用于过滤) */
147
+ type?: InfoSyncType;
148
+ /** 页码(默认 1) */
149
+ page?: number;
150
+ /** 每页数量(默认 20) */
151
+ pageSize?: number;
152
+ }
153
+ /**
154
+ * 同步记录列表响应
155
+ */
156
+ interface InfoSyncListResponse {
157
+ /** 记录列表 */
158
+ list: InfoSyncRecord[];
159
+ /** 总数 */
160
+ total: number;
161
+ /** 当前页码 */
162
+ page: number;
163
+ /** 每页数量 */
164
+ pageSize: number;
165
+ }
166
+
8
167
  /**
9
168
  * Plolink SDK 统一错误类
10
169
  *
@@ -57,6 +216,254 @@ declare class PlolinkError extends Error {
57
216
  toString(): string;
58
217
  }
59
218
 
219
+ /**
220
+ * 信息同步模块
221
+ *
222
+ * @description
223
+ * 提供信息同步功能,包括:
224
+ * - Webhook 配置管理(创建/查询/更新/删除)
225
+ * - 同步记录查询
226
+ * - 手动重试
227
+ * - 签名验证工具(用于验证 Webhook 请求)
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * import { PlolinkClient } from '@plolink/sdk';
232
+ *
233
+ * const client = new PlolinkClient({
234
+ * token: 'your-session-id-or-api-key'
235
+ * });
236
+ *
237
+ * // 创建 Webhook 配置
238
+ * const result = await client.infoSync.createWebhookConfig({
239
+ * name: 'Production Webhook',
240
+ * url: 'https://example.com/webhook/plolink',
241
+ * modules: ['report-writer', 'video-psych-analysis']
242
+ * });
243
+ * console.log(`SecretKey (仅展示一次): ${result.secretKey}`);
244
+ *
245
+ * // 查询同步记录
246
+ * const records = await client.infoSync.listSyncRecords({
247
+ * businessModule: 'report-writer',
248
+ * status: 'FAILED'
249
+ * });
250
+ * console.log(`找到 ${records.total} 条失败记录`);
251
+ * ```
252
+ *
253
+ * @module info-sync
254
+ */
255
+
256
+ /**
257
+ * 信息同步模块
258
+ */
259
+ declare class InfoSync {
260
+ private client;
261
+ constructor(client: PlolinkClient);
262
+ /**
263
+ * 创建 Webhook 配置
264
+ *
265
+ * @description
266
+ * 为当前团队创建一个新的 Webhook 配置。
267
+ * 返回的 secretKey 仅在创建时返回一次,请立即保存。
268
+ *
269
+ * 每个团队最多可以创建 10 个 Webhook 配置。
270
+ *
271
+ * ⚠️ 重要: secretKey 仅在创建时返回,后续无法再次获取,请妥善保存
272
+ *
273
+ * @param params - 创建参数
274
+ * @returns 创建结果,包含配置 ID 和密钥
275
+ * @throws {PlolinkError} 当参数无效、配置数量超限或权限不足时抛出
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const result = await infoSync.createWebhookConfig({
280
+ * name: 'Production Webhook',
281
+ * url: 'https://example.com/webhook/plolink',
282
+ * modules: ['report-writer', 'video-psych-analysis']
283
+ * });
284
+ *
285
+ * console.log(`配置 ID: ${result.id}`);
286
+ * console.log(`SecretKey: ${result.secretKey}`);
287
+ * // 请立即保存 secretKey,后续无法再次获取
288
+ * ```
289
+ */
290
+ createWebhookConfig(params: CreateWebhookConfigParams): Promise<CreateWebhookConfigResponse>;
291
+ /**
292
+ * 获取 Webhook 配置列表
293
+ *
294
+ * @description
295
+ * 获取当前团队的所有 Webhook 配置。
296
+ * 注意:列表中不包含 secretKey。
297
+ *
298
+ * @returns Webhook 配置列表
299
+ * @throws {PlolinkError} 当权限不足时抛出
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const configs = await infoSync.listWebhookConfigs();
304
+ * configs.forEach(config => {
305
+ * console.log(`${config.name}: ${config.url}`);
306
+ * console.log(`订阅模块: ${config.modules.join(', ')}`);
307
+ * console.log(`状态: ${config.enabled ? '启用' : '禁用'}`);
308
+ * });
309
+ * ```
310
+ */
311
+ listWebhookConfigs(): Promise<WebhookConfig[]>;
312
+ /**
313
+ * 获取 Webhook 配置详情
314
+ *
315
+ * @description
316
+ * 获取指定 Webhook 配置的详细信息。
317
+ * 注意:不包含 secretKey。
318
+ *
319
+ * @param id - 配置 ID
320
+ * @returns Webhook 配置详情
321
+ * @throws {PlolinkError} 当配置不存在或权限不足时抛出
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * const config = await infoSync.getWebhookConfig('config-123');
326
+ * console.log(`名称: ${config.name}`);
327
+ * console.log(`URL: ${config.url}`);
328
+ * console.log(`订阅模块: ${config.modules.join(', ')}`);
329
+ * ```
330
+ */
331
+ getWebhookConfig(id: string): Promise<WebhookConfig>;
332
+ /**
333
+ * 更新 Webhook 配置
334
+ *
335
+ * @description
336
+ * 更新指定 Webhook 配置的信息。
337
+ * 注意:不能更新 secretKey,如需更换密钥请删除后重新创建。
338
+ *
339
+ * @param id - 配置 ID
340
+ * @param params - 更新参数
341
+ * @throws {PlolinkError} 当参数无效、配置不存在或权限不足时抛出
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * // 禁用配置
346
+ * await infoSync.updateWebhookConfig('config-123', {
347
+ * enabled: false
348
+ * });
349
+ *
350
+ * // 更新订阅模块
351
+ * await infoSync.updateWebhookConfig('config-123', {
352
+ * modules: ['report-writer']
353
+ * });
354
+ *
355
+ * // 更新 URL
356
+ * await infoSync.updateWebhookConfig('config-123', {
357
+ * url: 'https://new-url.example.com/webhook'
358
+ * });
359
+ * ```
360
+ */
361
+ updateWebhookConfig(id: string, params: UpdateWebhookConfigParams): Promise<void>;
362
+ /**
363
+ * 删除 Webhook 配置
364
+ *
365
+ * @description
366
+ * 永久删除指定的 Webhook 配置(软删除)。
367
+ * 删除后该配置将不再接收 Webhook 通知。
368
+ *
369
+ * ⚠️ 警告: 此操作不可逆,请确认后再执行
370
+ *
371
+ * @param id - 配置 ID
372
+ * @throws {PlolinkError} 当配置不存在或权限不足时抛出
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * await infoSync.deleteWebhookConfig('config-123');
377
+ * console.log('Webhook 配置已删除');
378
+ * ```
379
+ */
380
+ deleteWebhookConfig(id: string): Promise<void>;
381
+ /**
382
+ * 查询同步记录列表
383
+ *
384
+ * @description
385
+ * 查询当前团队的同步记录,支持多种过滤条件和分页。
386
+ *
387
+ * @param params - 查询参数
388
+ * @returns 分页的同步记录列表
389
+ * @throws {PlolinkError} 当参数无效或权限不足时抛出
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * // 查询所有记录
394
+ * const result = await infoSync.listSyncRecords();
395
+ * console.log(`共 ${result.total} 条记录`);
396
+ *
397
+ * // 查询失败的 Webhook 同步记录
398
+ * const failed = await infoSync.listSyncRecords({
399
+ * type: 'WEBHOOK',
400
+ * status: 'FAILED'
401
+ * });
402
+ * console.log(`${failed.total} 条 Webhook 同步失败`);
403
+ *
404
+ * // 查询报告写作模块的记录
405
+ * const reports = await infoSync.listSyncRecords({
406
+ * businessModule: 'report-writer',
407
+ * page: 1,
408
+ * pageSize: 20
409
+ * });
410
+ * ```
411
+ */
412
+ listSyncRecords(params?: InfoSyncQueryParams): Promise<InfoSyncListResponse>;
413
+ /**
414
+ * 获取同步记录详情
415
+ *
416
+ * @description
417
+ * 获取指定同步记录的详细信息,包括完整的历史记录。
418
+ *
419
+ * @param id - 记录 ID
420
+ * @returns 同步记录详情
421
+ * @throws {PlolinkError} 当记录不存在或权限不足时抛出
422
+ *
423
+ * @example
424
+ * ```typescript
425
+ * const record = await infoSync.getSyncRecord('record-123');
426
+ * console.log(`业务模块: ${record.businessModule}`);
427
+ * console.log(`业务代码: ${record.businessCode}`);
428
+ * console.log(`状态: ${record.status}`);
429
+ * console.log(`历史记录:`);
430
+ * record.history.forEach(item => {
431
+ * console.log(` ${new Date(item.time).toLocaleString()}: ${item.status} - ${item.message || ''}`);
432
+ * });
433
+ * ```
434
+ */
435
+ getSyncRecord(id: string): Promise<InfoSyncRecord>;
436
+ /**
437
+ * 手动重试同步任务
438
+ *
439
+ * @description
440
+ * 手动重试失败的同步任务。
441
+ * 只能重试状态为 FAILED 的记录。
442
+ *
443
+ * 重试后记录状态将变为 PENDING,并重新提交到队列处理。
444
+ *
445
+ * @param id - 记录 ID
446
+ * @throws {PlolinkError} 当记录不存在、状态不是 FAILED 或权限不足时抛出
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * // 查询失败记录
451
+ * const failed = await infoSync.listSyncRecords({ status: 'FAILED' });
452
+ *
453
+ * // 重试所有失败记录
454
+ * for (const record of failed.list) {
455
+ * try {
456
+ * await infoSync.retrySyncRecord(record.id);
457
+ * console.log(`已重试: ${record.id}`);
458
+ * } catch (error) {
459
+ * console.error(`重试失败: ${record.id}`, error);
460
+ * }
461
+ * }
462
+ * ```
463
+ */
464
+ retrySyncRecord(id: string): Promise<void>;
465
+ }
466
+
60
467
  /**
61
468
  * Plolink SDK 主入口
62
469
  *
@@ -95,4 +502,4 @@ declare const DEFAULT_CONFIG: {
95
502
  readonly backoffFactor: 1.5;
96
503
  };
97
504
 
98
- export { DEFAULT_CONFIG, PlolinkError, VERSION };
505
+ export { DEFAULT_CONFIG, InfoSync, PlolinkClient, PlolinkError, VERSION };