UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

63 lines 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AIDigitalHumanServiceSdk = void 0; const polyv_live_api_sdk_1 = require("polyv-live-api-sdk"); class AIDigitalHumanServiceSdk { constructor(authConfig, config) { this.client = new polyv_live_api_sdk_1.PolyVClient({ appId: authConfig.appId, appSecret: authConfig.appSecret, baseUrl: config?.baseUrl || 'https://api.polyv.net', }); this.v4Ai = this.client.v4Ai; } async listDigitalHumans(pageNumber = 1, pageSize = 10) { if (pageNumber < 1) { throw new Error('pageNumber must be greater than 0'); } if (pageSize < 1) { throw new Error('pageSize must be greater than 0'); } const cappedPageSize = Math.min(pageSize, 1000); const result = await this.v4Ai.listDigitalHumans({ pageNumber, pageSize: cappedPageSize, }); return this.unwrapData(result) || { pageNumber: 1, pageSize: 10, totalPages: 0, totalItems: 0, contents: [], }; } async listOrganizations(aiDigitalHumanIds) { if (!aiDigitalHumanIds || aiDigitalHumanIds.trim() === '') { throw new Error('aiDigitalHumanIds is required'); } const ids = aiDigitalHumanIds.split(',').map(id => id.trim()).filter(id => id.length > 0); if (ids.length > 100) { throw new Error(`aiDigitalHumanIds count (${ids.length}) exceeds maximum of 100`); } const result = await this.v4Ai.listOrganizations({ aiDigitalHumanIds }); return this.unwrapData(result) || []; } async setOrganizations(params) { if (!params || params.length === 0) { throw new Error('config is required'); } if (params.length > 100) { throw new Error(`config count (${params.length}) exceeds maximum of 100`); } await this.client.httpClient.post('/live/v4/ai/digital-human/set-organizations', { setOrganizations: params }); return true; } unwrapData(value) { if (value && typeof value === 'object' && 'data' in value) { return value.data; } return value; } } exports.AIDigitalHumanServiceSdk = AIDigitalHumanServiceSdk; //# sourceMappingURL=ai-digital-human-service.js.map