polyv-live-cli 1.0.2

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +417 -0
  3. package/dist/commands/channel.commands.d.ts +9 -0
  4. package/dist/commands/channel.commands.d.ts.map +1 -0
  5. package/dist/commands/channel.commands.js +439 -0
  6. package/dist/commands/channel.commands.js.map +1 -0
  7. package/dist/commands/index.d.ts +3 -0
  8. package/dist/commands/index.d.ts.map +1 -0
  9. package/dist/commands/index.js +8 -0
  10. package/dist/commands/index.js.map +1 -0
  11. package/dist/commands/stream.commands.d.ts +3 -0
  12. package/dist/commands/stream.commands.d.ts.map +1 -0
  13. package/dist/commands/stream.commands.js +272 -0
  14. package/dist/commands/stream.commands.js.map +1 -0
  15. package/dist/config/auth.d.ts +11 -0
  16. package/dist/config/auth.d.ts.map +1 -0
  17. package/dist/config/auth.js +124 -0
  18. package/dist/config/auth.js.map +1 -0
  19. package/dist/config/loader.d.ts +22 -0
  20. package/dist/config/loader.d.ts.map +1 -0
  21. package/dist/config/loader.js +127 -0
  22. package/dist/config/loader.js.map +1 -0
  23. package/dist/config/manager.d.ts +20 -0
  24. package/dist/config/manager.d.ts.map +1 -0
  25. package/dist/config/manager.js +258 -0
  26. package/dist/config/manager.js.map +1 -0
  27. package/dist/config/validator.d.ts +43 -0
  28. package/dist/config/validator.d.ts.map +1 -0
  29. package/dist/config/validator.js +222 -0
  30. package/dist/config/validator.js.map +1 -0
  31. package/dist/handlers/base.handler.d.ts +15 -0
  32. package/dist/handlers/base.handler.d.ts.map +1 -0
  33. package/dist/handlers/base.handler.js +122 -0
  34. package/dist/handlers/base.handler.js.map +1 -0
  35. package/dist/handlers/channel.handler.d.ts +31 -0
  36. package/dist/handlers/channel.handler.d.ts.map +1 -0
  37. package/dist/handlers/channel.handler.js +690 -0
  38. package/dist/handlers/channel.handler.js.map +1 -0
  39. package/dist/handlers/index.d.ts +4 -0
  40. package/dist/handlers/index.d.ts.map +1 -0
  41. package/dist/handlers/index.js +10 -0
  42. package/dist/handlers/index.js.map +1 -0
  43. package/dist/handlers/stream.handler.d.ts +25 -0
  44. package/dist/handlers/stream.handler.d.ts.map +1 -0
  45. package/dist/handlers/stream.handler.js +241 -0
  46. package/dist/handlers/stream.handler.js.map +1 -0
  47. package/dist/index.d.ts +4 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +342 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/services/channel.service.d.ts +25 -0
  52. package/dist/services/channel.service.d.ts.map +1 -0
  53. package/dist/services/channel.service.js +672 -0
  54. package/dist/services/channel.service.js.map +1 -0
  55. package/dist/services/index.d.ts +3 -0
  56. package/dist/services/index.d.ts.map +1 -0
  57. package/dist/services/index.js +8 -0
  58. package/dist/services/index.js.map +1 -0
  59. package/dist/services/stream.service.d.ts +29 -0
  60. package/dist/services/stream.service.d.ts.map +1 -0
  61. package/dist/services/stream.service.js +489 -0
  62. package/dist/services/stream.service.js.map +1 -0
  63. package/dist/types/auth.d.ts +31 -0
  64. package/dist/types/auth.d.ts.map +1 -0
  65. package/dist/types/auth.js +14 -0
  66. package/dist/types/auth.js.map +1 -0
  67. package/dist/types/channel.d.ts +262 -0
  68. package/dist/types/channel.d.ts.map +1 -0
  69. package/dist/types/channel.js +3 -0
  70. package/dist/types/channel.js.map +1 -0
  71. package/dist/types/config.d.ts +82 -0
  72. package/dist/types/config.d.ts.map +1 -0
  73. package/dist/types/config.js +56 -0
  74. package/dist/types/config.js.map +1 -0
  75. package/dist/types/index.d.ts +6 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/types/index.js +22 -0
  78. package/dist/types/index.js.map +1 -0
  79. package/dist/types/signature.d.ts +22 -0
  80. package/dist/types/signature.d.ts.map +1 -0
  81. package/dist/types/signature.js +3 -0
  82. package/dist/types/signature.js.map +1 -0
  83. package/dist/types/stream.d.ts +104 -0
  84. package/dist/types/stream.d.ts.map +1 -0
  85. package/dist/types/stream.js +3 -0
  86. package/dist/types/stream.js.map +1 -0
  87. package/dist/utils/confirmation.d.ts +12 -0
  88. package/dist/utils/confirmation.d.ts.map +1 -0
  89. package/dist/utils/confirmation.js +164 -0
  90. package/dist/utils/confirmation.js.map +1 -0
  91. package/dist/utils/errors.d.ts +40 -0
  92. package/dist/utils/errors.d.ts.map +1 -0
  93. package/dist/utils/errors.js +113 -0
  94. package/dist/utils/errors.js.map +1 -0
  95. package/dist/utils/formatter.d.ts +8 -0
  96. package/dist/utils/formatter.d.ts.map +1 -0
  97. package/dist/utils/formatter.js +93 -0
  98. package/dist/utils/formatter.js.map +1 -0
  99. package/dist/utils/index.d.ts +4 -0
  100. package/dist/utils/index.d.ts.map +1 -0
  101. package/dist/utils/index.js +20 -0
  102. package/dist/utils/index.js.map +1 -0
  103. package/dist/utils/signature.d.ts +9 -0
  104. package/dist/utils/signature.d.ts.map +1 -0
  105. package/dist/utils/signature.js +77 -0
  106. package/dist/utils/signature.js.map +1 -0
  107. package/package.json +86 -0
@@ -0,0 +1,690 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ChannelHandler = void 0;
37
+ const base_handler_1 = require("./base.handler");
38
+ const channel_service_1 = require("../services/channel.service");
39
+ const errors_1 = require("../utils/errors");
40
+ class ChannelHandler extends base_handler_1.BaseHandler {
41
+ constructor(authConfig, serviceConfig) {
42
+ super();
43
+ this.channelService = new channel_service_1.ChannelService(authConfig, serviceConfig);
44
+ }
45
+ async create(options) {
46
+ return this.executeWithErrorHandling(async () => {
47
+ this.validateCreateOptions(options);
48
+ const request = this.transformToCreateRequest(options);
49
+ const channel = await this.channelService.createChannel(request);
50
+ this.displayChannelCreated(channel, options.output);
51
+ }, 'channel.create');
52
+ }
53
+ async listChannels(options = {}) {
54
+ return this.executeWithErrorHandling(async () => {
55
+ this.validateListOptions(options);
56
+ const request = this.transformToListRequest(options);
57
+ const channels = await this.channelService.listChannels(request);
58
+ this.displayChannelsList(channels, request, options.output);
59
+ }, 'channel.list');
60
+ }
61
+ async getChannelDetail(options) {
62
+ return this.executeWithErrorHandling(async () => {
63
+ this.validateGetOptions(options);
64
+ const request = this.transformToDetailRequest(options);
65
+ const channelDetail = await this.channelService.getChannelDetail(request);
66
+ this.displayChannelDetail(channelDetail, options.output);
67
+ }, 'channel.get');
68
+ }
69
+ async updateChannel(options) {
70
+ return this.executeWithErrorHandling(async () => {
71
+ this.validateUpdateOptions(options);
72
+ const request = this.transformToUpdateRequest(options);
73
+ await this.channelService.updateChannel(request);
74
+ this.displayChannelUpdated(options);
75
+ }, 'channel.update');
76
+ }
77
+ async deleteChannel(options) {
78
+ return this.executeWithErrorHandling(async () => {
79
+ this.validateSingleDeleteOptions(options);
80
+ if (!options.force) {
81
+ const { confirmDeletion } = await Promise.resolve().then(() => __importStar(require('../utils/confirmation')));
82
+ const confirmed = await confirmDeletion(`Are you sure you want to delete channel '${options.channelId}'? This action cannot be undone.`, 'yes');
83
+ if (!confirmed) {
84
+ this.displayInfo('Channel deletion cancelled by user');
85
+ return;
86
+ }
87
+ }
88
+ await this.channelService.deleteChannel(options.channelId);
89
+ this.displayChannelDeleted(options);
90
+ }, 'channel.delete');
91
+ }
92
+ async deleteChannels(options) {
93
+ return this.executeWithErrorHandling(async () => {
94
+ this.validateDeleteOptions(options);
95
+ const request = this.transformToDeleteRequest(options);
96
+ await this.channelService.batchDeleteChannels(request);
97
+ this.displayChannelsDeleted(options);
98
+ }, 'channel.delete');
99
+ }
100
+ validateCreateOptions(options) {
101
+ const errors = [];
102
+ if (!options.name || typeof options.name !== 'string') {
103
+ errors.push('Channel name is required and must be a string');
104
+ }
105
+ else if (options.name.trim().length === 0) {
106
+ errors.push('Channel name cannot be empty');
107
+ }
108
+ else if (options.name.length > 100) {
109
+ errors.push('Channel name cannot exceed 100 characters');
110
+ }
111
+ if (options.description !== undefined) {
112
+ if (typeof options.description !== 'string') {
113
+ errors.push('Description must be a string');
114
+ }
115
+ else if (options.description.length > 500) {
116
+ errors.push('Description cannot exceed 500 characters');
117
+ }
118
+ }
119
+ if (options.maxViewers !== undefined) {
120
+ if (typeof options.maxViewers !== 'number' || options.maxViewers < 0) {
121
+ errors.push('Max viewers must be a non-negative number');
122
+ }
123
+ else if (options.maxViewers > 100000) {
124
+ errors.push('Max viewers cannot exceed 100,000');
125
+ }
126
+ }
127
+ if (options.autoRecord !== undefined && typeof options.autoRecord !== 'boolean') {
128
+ errors.push('Auto record must be a boolean value');
129
+ }
130
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
131
+ errors.push('Output format must be either "table" or "json"');
132
+ }
133
+ if (options.scene !== undefined) {
134
+ const validScenes = ['topclass', 'cloudclass', 'telecast', 'akt'];
135
+ if (!validScenes.includes(options.scene)) {
136
+ errors.push(`Scene must be one of: ${validScenes.join(', ')}`);
137
+ }
138
+ }
139
+ if (options.template !== undefined) {
140
+ const validTemplates = ['ppt', 'video'];
141
+ if (!validTemplates.includes(options.template)) {
142
+ errors.push(`Template must be one of: ${validTemplates.join(', ')}`);
143
+ }
144
+ }
145
+ if (options.password !== undefined) {
146
+ if (typeof options.password !== 'string') {
147
+ errors.push('Password must be a string');
148
+ }
149
+ else if (options.password.length < 6 || options.password.length > 16) {
150
+ errors.push('Password must be 6-16 characters long');
151
+ }
152
+ else if (!/^[a-zA-Z0-9]+$/.test(options.password)) {
153
+ errors.push('Password must contain only alphanumeric characters');
154
+ }
155
+ }
156
+ if (errors.length > 0) {
157
+ throw new errors_1.PolyVValidationError(`Channel creation options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
158
+ }
159
+ }
160
+ transformToCreateRequest(options) {
161
+ const request = {
162
+ name: options.name.trim(),
163
+ newScene: options.scene || 'topclass',
164
+ template: options.template || 'ppt'
165
+ };
166
+ if (options.password) {
167
+ request.channelPasswd = options.password;
168
+ }
169
+ return request;
170
+ }
171
+ displayChannelCreated(channel, format = 'table') {
172
+ const displayData = {
173
+ channelId: channel.channelId,
174
+ name: channel.name,
175
+ userId: channel.userId,
176
+ password: channel.channelPasswd ? '***' : '-',
177
+ scene: channel.newScene,
178
+ template: channel.template,
179
+ status: channel.status || 'waiting',
180
+ created: channel.createdAt ? channel.createdAt.toLocaleString() : 'Just now'
181
+ };
182
+ this.displaySuccess('Channel created successfully', displayData, format);
183
+ if (format === 'table') {
184
+ this.displayInfo('Channel is ready for streaming configuration');
185
+ if (channel.channelPasswd) {
186
+ this.displayWarning('Channel password has been set - remember to provide it to viewers');
187
+ }
188
+ }
189
+ }
190
+ validateListOptions(options) {
191
+ const errors = [];
192
+ if (options.page !== undefined) {
193
+ if (typeof options.page !== 'number' || !Number.isInteger(options.page) || options.page < 1) {
194
+ errors.push('Page must be a positive integer (minimum 1)');
195
+ }
196
+ }
197
+ if (options.limit !== undefined) {
198
+ if (typeof options.limit !== 'number' || !Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100) {
199
+ errors.push('Limit must be an integer between 1 and 100');
200
+ }
201
+ }
202
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
203
+ errors.push('Output format must be either "table" or "json"');
204
+ }
205
+ if (options.categoryId !== undefined && (typeof options.categoryId !== 'string' || options.categoryId.trim().length === 0)) {
206
+ errors.push('Category ID must be a non-empty string');
207
+ }
208
+ if (options.keyword !== undefined && (typeof options.keyword !== 'string' || options.keyword.trim().length === 0)) {
209
+ errors.push('Keyword must be a non-empty string');
210
+ }
211
+ if (options.labelId !== undefined && (typeof options.labelId !== 'string' || options.labelId.trim().length === 0)) {
212
+ errors.push('Label ID must be a non-empty string');
213
+ }
214
+ if (errors.length > 0) {
215
+ throw new errors_1.PolyVValidationError(`Channel list options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
216
+ }
217
+ }
218
+ validateGetOptions(options) {
219
+ const errors = [];
220
+ if (!options.channelId) {
221
+ errors.push('Channel ID is required');
222
+ }
223
+ else if (typeof options.channelId !== 'string') {
224
+ errors.push('Channel ID must be a string');
225
+ }
226
+ else if (options.channelId.trim().length === 0) {
227
+ errors.push('Channel ID cannot be empty');
228
+ }
229
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
230
+ errors.push('Output format must be either "table" or "json"');
231
+ }
232
+ if (errors.length > 0) {
233
+ throw new errors_1.PolyVValidationError(`Channel get options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
234
+ }
235
+ }
236
+ validateUpdateOptions(options) {
237
+ const errors = [];
238
+ if (!options.channelId) {
239
+ errors.push('Channel ID is required');
240
+ }
241
+ else if (typeof options.channelId !== 'string') {
242
+ errors.push('Channel ID must be a string');
243
+ }
244
+ else if (options.channelId.trim().length === 0) {
245
+ errors.push('Channel ID cannot be empty');
246
+ }
247
+ const updateFields = [
248
+ 'name', 'description', 'publisher', 'password', 'maxViewers',
249
+ 'autoRecord', 'startTime', 'endTime', 'pageView', 'likes',
250
+ 'coverImg', 'splashImg'
251
+ ];
252
+ const hasUpdateField = updateFields.some(field => options[field] !== undefined);
253
+ if (!hasUpdateField) {
254
+ errors.push('At least one update parameter must be provided');
255
+ }
256
+ if (options.name !== undefined) {
257
+ if (typeof options.name !== 'string') {
258
+ errors.push('Channel name must be a string');
259
+ }
260
+ else if (options.name.trim().length === 0) {
261
+ errors.push('Channel name cannot be empty');
262
+ }
263
+ else if (options.name.length > 100) {
264
+ errors.push('Channel name cannot exceed 100 characters');
265
+ }
266
+ }
267
+ if (options.description !== undefined) {
268
+ if (typeof options.description !== 'string') {
269
+ errors.push('Description must be a string');
270
+ }
271
+ else if (options.description.length > 500) {
272
+ errors.push('Description cannot exceed 500 characters');
273
+ }
274
+ }
275
+ if (options.publisher !== undefined) {
276
+ if (typeof options.publisher !== 'string') {
277
+ errors.push('Publisher must be a string');
278
+ }
279
+ }
280
+ if (options.password !== undefined) {
281
+ if (typeof options.password !== 'string') {
282
+ errors.push('Password must be a string');
283
+ }
284
+ else if (options.password.length < 6 || options.password.length > 16) {
285
+ errors.push('Password must be 6-16 characters long');
286
+ }
287
+ else if (!/^[a-zA-Z0-9]+$/.test(options.password)) {
288
+ errors.push('Password must contain only alphanumeric characters');
289
+ }
290
+ }
291
+ if (options.maxViewers !== undefined) {
292
+ if (typeof options.maxViewers !== 'number' || options.maxViewers <= 0) {
293
+ errors.push('Max viewers must be a positive number');
294
+ }
295
+ }
296
+ if (options.autoRecord !== undefined && typeof options.autoRecord !== 'boolean') {
297
+ errors.push('Auto record must be a boolean value');
298
+ }
299
+ if (options.startTime !== undefined) {
300
+ if (typeof options.startTime !== 'number' || options.startTime < 0) {
301
+ errors.push('Start time must be a non-negative timestamp');
302
+ }
303
+ }
304
+ if (options.endTime !== undefined) {
305
+ if (typeof options.endTime !== 'number' || options.endTime < 0) {
306
+ errors.push('End time must be a non-negative timestamp');
307
+ }
308
+ if (options.startTime !== undefined && options.endTime <= options.startTime) {
309
+ errors.push('End time must be greater than start time');
310
+ }
311
+ }
312
+ if (options.pageView !== undefined) {
313
+ if (typeof options.pageView !== 'number' || options.pageView < 0) {
314
+ errors.push('Page view count must be a non-negative number');
315
+ }
316
+ }
317
+ if (options.likes !== undefined) {
318
+ if (typeof options.likes !== 'number' || options.likes < 0) {
319
+ errors.push('Likes count must be a non-negative number');
320
+ }
321
+ }
322
+ if (options.coverImg !== undefined && typeof options.coverImg !== 'string') {
323
+ errors.push('Cover image URL must be a string');
324
+ }
325
+ if (options.splashImg !== undefined && typeof options.splashImg !== 'string') {
326
+ errors.push('Splash image URL must be a string');
327
+ }
328
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
329
+ errors.push('Output format must be either "table" or "json"');
330
+ }
331
+ if (errors.length > 0) {
332
+ throw new errors_1.PolyVValidationError(`Channel update options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
333
+ }
334
+ }
335
+ transformToUpdateRequest(options) {
336
+ const request = {
337
+ channelId: options.channelId.trim()
338
+ };
339
+ const basicSetting = {};
340
+ let hasBasicSetting = false;
341
+ if (options.name !== undefined) {
342
+ basicSetting.name = options.name.trim();
343
+ hasBasicSetting = true;
344
+ }
345
+ if (options.description !== undefined) {
346
+ basicSetting.desc = options.description;
347
+ hasBasicSetting = true;
348
+ }
349
+ if (options.publisher !== undefined) {
350
+ basicSetting.publisher = options.publisher;
351
+ hasBasicSetting = true;
352
+ }
353
+ if (options.password !== undefined) {
354
+ basicSetting.channelPasswd = options.password;
355
+ hasBasicSetting = true;
356
+ }
357
+ if (options.maxViewers !== undefined) {
358
+ basicSetting.maxViewer = options.maxViewers;
359
+ hasBasicSetting = true;
360
+ }
361
+ if (options.startTime !== undefined) {
362
+ basicSetting.startTime = options.startTime;
363
+ hasBasicSetting = true;
364
+ }
365
+ if (options.endTime !== undefined) {
366
+ basicSetting.endTime = options.endTime;
367
+ hasBasicSetting = true;
368
+ }
369
+ if (options.pageView !== undefined) {
370
+ basicSetting.pageView = options.pageView;
371
+ hasBasicSetting = true;
372
+ }
373
+ if (options.likes !== undefined) {
374
+ basicSetting.likes = options.likes;
375
+ hasBasicSetting = true;
376
+ }
377
+ if (options.coverImg !== undefined) {
378
+ basicSetting.coverImg = options.coverImg;
379
+ hasBasicSetting = true;
380
+ }
381
+ if (options.splashImg !== undefined) {
382
+ basicSetting.splashImg = options.splashImg;
383
+ hasBasicSetting = true;
384
+ }
385
+ if (hasBasicSetting) {
386
+ request.basicSetting = basicSetting;
387
+ }
388
+ return request;
389
+ }
390
+ displayChannelUpdated(options) {
391
+ const updateSummary = [];
392
+ if (options.name !== undefined)
393
+ updateSummary.push(`Name: ${options.name}`);
394
+ if (options.description !== undefined)
395
+ updateSummary.push(`Description: ${options.description}`);
396
+ if (options.publisher !== undefined)
397
+ updateSummary.push(`Publisher: ${options.publisher}`);
398
+ if (options.password !== undefined)
399
+ updateSummary.push('Password: ***');
400
+ if (options.maxViewers !== undefined)
401
+ updateSummary.push(`Max Viewers: ${options.maxViewers}`);
402
+ if (options.startTime !== undefined)
403
+ updateSummary.push(`Start Time: ${new Date(options.startTime).toLocaleString()}`);
404
+ if (options.endTime !== undefined)
405
+ updateSummary.push(`End Time: ${new Date(options.endTime).toLocaleString()}`);
406
+ if (options.pageView !== undefined)
407
+ updateSummary.push(`Page Views: ${options.pageView}`);
408
+ if (options.likes !== undefined)
409
+ updateSummary.push(`Likes: ${options.likes}`);
410
+ if (options.coverImg !== undefined)
411
+ updateSummary.push(`Cover Image: ${options.coverImg}`);
412
+ if (options.splashImg !== undefined)
413
+ updateSummary.push(`Splash Image: ${options.splashImg}`);
414
+ this.displaySuccess(`Channel ${options.channelId} updated successfully`);
415
+ if (updateSummary.length > 0) {
416
+ this.displayInfo('Updated fields:');
417
+ updateSummary.forEach(summary => this.displayInfo(` • ${summary}`));
418
+ }
419
+ if (options.password) {
420
+ this.displayWarning('Channel password has been updated - remember to provide it to viewers');
421
+ }
422
+ }
423
+ validateSingleDeleteOptions(options) {
424
+ const errors = [];
425
+ if (!options.channelId) {
426
+ errors.push('Channel ID is required');
427
+ }
428
+ else if (typeof options.channelId !== 'string') {
429
+ errors.push('Channel ID must be a string');
430
+ }
431
+ else if (options.channelId.trim().length === 0) {
432
+ errors.push('Channel ID cannot be empty');
433
+ }
434
+ if (options.force !== undefined && typeof options.force !== 'boolean') {
435
+ errors.push('Force flag must be a boolean value');
436
+ }
437
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
438
+ errors.push('Output format must be either "table" or "json"');
439
+ }
440
+ if (errors.length > 0) {
441
+ throw new errors_1.PolyVValidationError(`Channel delete options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
442
+ }
443
+ }
444
+ validateDeleteOptions(options) {
445
+ const errors = [];
446
+ if (!options.channelIds) {
447
+ errors.push('Channel IDs are required');
448
+ }
449
+ else if (!Array.isArray(options.channelIds)) {
450
+ errors.push('Channel IDs must be an array');
451
+ }
452
+ else if (options.channelIds.length === 0) {
453
+ errors.push('At least one channel ID must be provided');
454
+ }
455
+ else if (options.channelIds.length > 100) {
456
+ errors.push('Cannot delete more than 100 channels at once');
457
+ }
458
+ else {
459
+ for (let i = 0; i < options.channelIds.length; i++) {
460
+ const channelId = options.channelIds[i];
461
+ if (typeof channelId !== 'string') {
462
+ errors.push(`Channel ID at position ${i + 1} must be a string`);
463
+ }
464
+ else if (channelId.trim().length === 0) {
465
+ errors.push(`Channel ID at position ${i + 1} cannot be empty`);
466
+ }
467
+ }
468
+ }
469
+ if (options.output !== undefined && !['table', 'json'].includes(options.output)) {
470
+ errors.push('Output format must be either "table" or "json"');
471
+ }
472
+ if (errors.length > 0) {
473
+ throw new errors_1.PolyVValidationError(`Channel delete options validation failed: ${errors.join(', ')}`, 'options', options, 'validation_failed');
474
+ }
475
+ }
476
+ transformToDeleteRequest(options) {
477
+ return {
478
+ channelIds: options.channelIds.map((id) => id.trim())
479
+ };
480
+ }
481
+ displayChannelsDeleted(options) {
482
+ const channelCount = options.channelIds.length;
483
+ const channelText = channelCount === 1 ? 'channel' : 'channels';
484
+ this.displaySuccess(`Successfully deleted ${channelCount} ${channelText}`);
485
+ if (options.output === 'json') {
486
+ const jsonData = {
487
+ deleted: true,
488
+ channelIds: options.channelIds,
489
+ count: channelCount
490
+ };
491
+ this.displayData(jsonData, 'json');
492
+ }
493
+ else {
494
+ this.displayInfo('Deleted channels:');
495
+ options.channelIds.forEach((channelId) => {
496
+ this.displayInfo(` • Channel ${channelId}`);
497
+ });
498
+ }
499
+ }
500
+ displayChannelDeleted(options) {
501
+ this.displaySuccess(`Successfully deleted channel ${options.channelId}`);
502
+ if (options.output === 'json') {
503
+ const jsonData = {
504
+ deleted: true,
505
+ channelId: options.channelId,
506
+ timestamp: new Date().toISOString()
507
+ };
508
+ this.displayData(jsonData, 'json');
509
+ }
510
+ else {
511
+ this.displayInfo(`Channel ${options.channelId} has been permanently deleted`);
512
+ this.displayWarning('This action cannot be undone');
513
+ }
514
+ }
515
+ transformToListRequest(options) {
516
+ const request = {};
517
+ if (options.page !== undefined) {
518
+ request.page = options.page;
519
+ }
520
+ if (options.limit !== undefined) {
521
+ request.limit = options.limit;
522
+ }
523
+ if (options.categoryId) {
524
+ request.categoryId = options.categoryId.trim();
525
+ }
526
+ if (options.keyword) {
527
+ request.keyword = options.keyword.trim();
528
+ }
529
+ if (options.labelId) {
530
+ request.labelId = options.labelId.trim();
531
+ }
532
+ return request;
533
+ }
534
+ transformToDetailRequest(options) {
535
+ return {
536
+ channelId: options.channelId.trim()
537
+ };
538
+ }
539
+ displayChannelsList(channels, request, format = 'table') {
540
+ if (channels.length === 0) {
541
+ this.displayInfo('No channels found');
542
+ return;
543
+ }
544
+ if (format === 'json') {
545
+ const jsonData = {
546
+ channels: channels.map(channel => ({
547
+ channelId: channel.channelId,
548
+ name: channel.name,
549
+ status: channel.status,
550
+ scene: channel.scene,
551
+ template: channel.template,
552
+ createdAt: channel.createdAt.toISOString(),
553
+ description: channel.description,
554
+ maxViewers: channel.maxViewers
555
+ })),
556
+ pagination: {
557
+ page: request.page ?? 1,
558
+ limit: request.limit ?? 20,
559
+ total: channels.length
560
+ }
561
+ };
562
+ this.displayData(jsonData, 'json');
563
+ }
564
+ else {
565
+ const tableData = channels.map(channel => ({
566
+ 'Channel ID': channel.channelId,
567
+ 'Name': channel.name,
568
+ 'Status': channel.status,
569
+ 'Scene': channel.scene,
570
+ 'Template': channel.template,
571
+ 'Created': channel.createdAt.toLocaleDateString()
572
+ }));
573
+ this.displaySuccess(`Found ${channels.length} channels`, tableData, 'table');
574
+ const page = request.page ?? 1;
575
+ const limit = request.limit ?? 20;
576
+ this.displayInfo(`Page ${page}, showing up to ${limit} channels per page`);
577
+ }
578
+ }
579
+ displayChannelDetail(channelDetail, format = 'table') {
580
+ if (format === 'json') {
581
+ const jsonData = {
582
+ channelId: channelDetail.channelId,
583
+ name: channelDetail.name,
584
+ scene: channelDetail.scene,
585
+ newScene: channelDetail.newScene,
586
+ template: channelDetail.template,
587
+ channelPasswd: channelDetail.channelPasswd ? '***masked***' : null,
588
+ publisher: channelDetail.publisher,
589
+ startTime: channelDetail.startTime,
590
+ endTime: channelDetail.endTime,
591
+ pureRtcEnabled: channelDetail.pureRtcEnabled,
592
+ pageView: channelDetail.pageView,
593
+ likes: channelDetail.likes,
594
+ coverImg: channelDetail.coverImg,
595
+ splashImg: channelDetail.splashImg,
596
+ splashEnabled: channelDetail.splashEnabled,
597
+ bgImg: channelDetail.bgImg,
598
+ desc: channelDetail.desc,
599
+ consultingMenuEnabled: channelDetail.consultingMenuEnabled,
600
+ maxViewerRestrict: channelDetail.maxViewerRestrict,
601
+ maxViewer: channelDetail.maxViewer,
602
+ watchStatus: channelDetail.watchStatus,
603
+ watchStatusText: channelDetail.watchStatusText,
604
+ userCategory: channelDetail.userCategory,
605
+ authSettings: channelDetail.authSettings,
606
+ linkMicLimit: channelDetail.linkMicLimit,
607
+ createdAccountId: channelDetail.createdAccountId,
608
+ createdAccountEmail: channelDetail.createdAccountEmail,
609
+ createdTime: channelDetail.createdTime,
610
+ labelData: channelDetail.labelData,
611
+ clientAloneTemplateBackgroundUrl: channelDetail.clientAloneTemplateBackgroundUrl,
612
+ liveCdnBackgroundUrl: channelDetail.liveCdnBackgroundUrl,
613
+ pushUrl: channelDetail.pushUrl ? '***masked***' : null,
614
+ pushSecret: channelDetail.pushSecret ? '***masked***' : null,
615
+ streamType: channelDetail.streamType,
616
+ onlyOutEnabled: channelDetail.onlyOutEnabled
617
+ };
618
+ this.displayData(jsonData, 'json');
619
+ }
620
+ else {
621
+ this.displaySuccess(`Channel Details: ${channelDetail.name}`, null, 'table');
622
+ const basicInfo = {
623
+ 'Channel ID': channelDetail.channelId.toString(),
624
+ 'Name': channelDetail.name,
625
+ 'Publisher': channelDetail.publisher || '-',
626
+ 'Description': channelDetail.desc || '-',
627
+ 'Status': `${channelDetail.watchStatus} (${channelDetail.watchStatusText})`,
628
+ 'Scene': channelDetail.newScene !== 'undefined' ? channelDetail.newScene : channelDetail.scene,
629
+ 'Template': channelDetail.template !== 'undefined' ? channelDetail.template : '-'
630
+ };
631
+ this.displayInfo('📋 Basic Information');
632
+ this.displayData(basicInfo, 'table');
633
+ const configInfo = {
634
+ 'Channel Password': channelDetail.channelPasswd ? 'Set (***masked***)' : 'Not set',
635
+ 'Pure RTC': channelDetail.pureRtcEnabled === 'Y' ? 'Enabled' : 'Disabled',
636
+ 'Max Viewer Restrict': channelDetail.maxViewerRestrict === 'Y' ? 'Enabled' : 'Disabled',
637
+ 'Max Viewers': channelDetail.maxViewer > 0 ? channelDetail.maxViewer.toString() : 'Unlimited',
638
+ 'Link Mic Limit': channelDetail.linkMicLimit.toString(),
639
+ 'Consulting Menu': channelDetail.consultingMenuEnabled === 'Y' ? 'Enabled' : 'Disabled',
640
+ 'Splash Page': channelDetail.splashEnabled === 'Y' ? 'Enabled' : 'Disabled'
641
+ };
642
+ this.displayInfo('⚙️ Configuration');
643
+ this.displayData(configInfo, 'table');
644
+ const statsInfo = {
645
+ 'Page Views': channelDetail.pageView.toString(),
646
+ 'Likes': channelDetail.likes.toString(),
647
+ 'Start Time': channelDetail.startTime > 0 ? new Date(channelDetail.startTime).toLocaleString() : 'Not set',
648
+ 'End Time': channelDetail.endTime > 0 ? new Date(channelDetail.endTime).toLocaleString() : 'Not set',
649
+ 'Created Time': new Date(channelDetail.createdTime).toLocaleString(),
650
+ 'Created By': channelDetail.createdAccountEmail || channelDetail.createdAccountId
651
+ };
652
+ this.displayInfo('📊 Statistics & Timing');
653
+ this.displayData(statsInfo, 'table');
654
+ if (channelDetail.userCategory) {
655
+ const categoryInfo = {
656
+ 'Category ID': channelDetail.userCategory.categoryId.toString(),
657
+ 'Category Name': channelDetail.userCategory.categoryName,
658
+ 'Rank': channelDetail.userCategory.rank.toString()
659
+ };
660
+ this.displayInfo('📁 Category Information');
661
+ this.displayData(categoryInfo, 'table');
662
+ }
663
+ if (channelDetail.authSettings && channelDetail.authSettings.length > 0) {
664
+ const authSummary = channelDetail.authSettings.map((auth) => ({
665
+ 'Rank': auth.rank.toString(),
666
+ 'Type': auth.authType,
667
+ 'Enabled': auth.enabled,
668
+ 'Global Setting': auth.globalSettingEnabled
669
+ }));
670
+ this.displayInfo('🔐 Authentication Settings');
671
+ this.displayData(authSummary, 'table');
672
+ }
673
+ if (channelDetail.labelData && channelDetail.labelData.length > 0) {
674
+ this.displayInfo(`Labels: ${channelDetail.labelData.join(', ')}`);
675
+ }
676
+ const urls = [];
677
+ if (channelDetail.coverImg)
678
+ urls.push(`Cover Image: ${channelDetail.coverImg}`);
679
+ if (channelDetail.splashImg)
680
+ urls.push(`Splash Image: ${channelDetail.splashImg}`);
681
+ if (channelDetail.bgImg)
682
+ urls.push(`Background Image: ${channelDetail.bgImg}`);
683
+ if (urls.length > 0) {
684
+ this.displayInfo('Images:\n' + urls.join('\n'));
685
+ }
686
+ }
687
+ }
688
+ }
689
+ exports.ChannelHandler = ChannelHandler;
690
+ //# sourceMappingURL=channel.handler.js.map