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