chore: migrate project to pnpm and update workspace configuration - Added pnpm workspace configuration in pnpm-workspace.yaml to manage packages. - Updated prepare.sh script to use pnpm for installing and building packages. - Modified testapp/package.json scripts to use pnpm instead of npm. - Enhanced tsconfig.client.json and tsconfig.json with additional options and exclusions. - Updated typings README.md to reflect the use of pnpm for installation and building. streamline build process in prepare script and update dependency installation Refactor code structure for improved readability and maintainability refactor: optimize Dockerfile for better layer caching and dependency installation refactor: migrate typings from '@lib/typings/ce' to '@openvidu-meet/typings' - Updated imports across multiple components and services to use the new '@openvidu-meet/typings' package. - Removed legacy typings references and adjusted paths in the frontend and webcomponent projects. - Cleaned up the typings package structure and added build scripts for TypeScript. - Removed the sync-types.sh script as it is no longer needed with the new structure. - Updated README and package.json files to reflect the new package name and structure. feat: add nodemon configuration for API documentation updates and enhance development scripts feat: implement type checking in watch mode and update development scripts feat: enhance development scripts with wait-for-typings and watch-typings utilities fix: remove obsolete sync:backend script and enhance dev script with preserveWatchOutput option feat: enhance development scripts with typings guard and improve watch behavior Refactors build and dev scripts Simplifies and consolidates build and development-related scripts for improved maintainability. - Updates the build process to be more streamlined. - Improves the development workflow by consolidating common tasks. - Removes redundant scripts. Replaces prepare script with meet script Replaces the old `prepare.sh` script with a new `meet.sh` script to provide a more user-friendly and comprehensive interface for building and managing the project. - Integrates command-line arguments for different build targets. - Includes documentation generation for web components and REST APIs. - Provides improved error handling and user feedback. - Simplifies the build process with `pnpm`. chore: update typescript version to 5.9.2 across multiple package.json files refactor: replace constructor injection with inject function for AppDataService feat: add commands to build webcomponent and run unit tests meet.sh: add end-to-end testing support for webcomponent with optional Playwright browser installation chore: update pnpm version to 10 and streamline test commands in workflows meet.sh: rename build_webcomponent_only to build_webcomponent and streamline dependency installation gitignore: add test-results directory to ignore list meet.sh: rename build_webcomponent_only to build_webcomponent for consistency Updated pnpm-lock.yml refactor: streamline build scripts and enhance service start options in meet.sh ci: update OpenVidu Meet actions to use meet-pnpm-migration version refactor: update import paths for WebComponentCommand and WebComponentEvent to use shared typings fix: add moduleNameMapper for typings path in jest configuration fix: correct action version syntax for OpenVidu Meet setup in workflow fix: update typings imports to use shared @openvidu-meet/typings package fix: add skip-install and skip-typings options to meet.sh and update workflows meet.sh: add development mode command and update start services options fix: format code in meeting.component.ts and remove unused export in public-api.ts added openvidu-components-angular to the local workspace and watch for changes in dev mode fix: update Node.js action to v5 and streamline build steps in wc-unit-test.yaml fix: remove pnpm install from build scripts in package.json fix: update backend unit test workflow and add test unit command in meet.sh fix: update unit test command in package.json to use pnpm exec Updates import path for LiveKit permissions Updates the import path for LiveKit permissions to align with the new typings package location, ensuring the test suite remains functional after the project's dependencies are migrated. fix: remove redundant dependency installation and build steps in start_services function fix: update Node.js setup action version and adjust OpenVidu actions for pnpm migration fix: update tsconfig.json to exclude specific type declaration paths fix: remove deprecated dependencies and update openapi-generate-html version fix: update build messages and streamline start commands for production and CI modes fix: update OpenVidu Meet and Testapp actions to use main branch and streamline pre-startup commands Refactors type import for auth mode Updates the import path for the authentication transport mode type. This change ensures consistency across the application by using a centralized type definition. Refactors backend integration tests Streamlines the backend integration test workflow. Consolidates test jobs for better organization and efficiency. Leverages matrix testing for recordings API with different storage providers. Improves AWS runner management for recording tests. Adds artifact cleanup to prevent storage bloat. Sets up Node.js and pnpm Adds Node.js and pnpm setup steps to the integration test workflow. This enables the use of pnpm for managing dependencies during integration tests. Refactors test commands to use pnpm exec Updates the test commands in package.json to use `pnpm exec` for running Jest. This ensures that the Jest CLI is executed within the pnpm managed environment, resolving potential path and dependency issues. Refactors imports to use the new typings package Updates imports to use the new `@openvidu-meet/typings` package. Removes now-unnecessary module name mappings. This change is part of the pnpm migration, ensuring correct resolution of shared types. Enhances backend integration tests and updates Node.js setup Simplifies integration tests execution Updates integration test scripts to streamline execution. - Uses a single, parameterized script to run all backend integration tests. - Removes redundant prefixes from test script names. Refactors jest configuration to include moduleNameMapper for improved module resolution Updates Jest integration test commands to use experimental VM modules and adjusts TypeScript root directory settings for better output structure Ensures OpenVidu Meet logs are uploaded Guarantees OpenVidu Meet logs are uploaded as artifacts, regardless of test outcome. Moves log upload to ensure consistent capture, and does so for all test scenarios. Commented backend integration tests Fix build script to specify TypeScript configuration file Refactor integration test command to use pnpm bin for jest execution Update integration test commands to use relative paths for Jest execution Revert "Commented backend integration tests" This reverts commit 1da8cddb55e29036c2a816244f4bc8b665ede581. Change log upload condition to trigger on failure for OpenVidu Meet logs Add caching step for OpenVidu local deployment images in backend integration tests Revert "Add caching step for OpenVidu local deployment images in backend integration tests" This reverts commit bf4692d168c671100a88c09853a460ec5417979d. Enhance AWS runner setup with storage provider matrix and update job names for clarity Refactor AWS runner setup to separate jobs for S3, ABS, and GCS, enhancing clarity and maintainability Update README.md to enhance structure and clarity, including detailed sections on prerequisites, getting started, development, and documentation. Refactor Dockerfile and entrypoint script, remove deprecated image creation scripts, and enhance meet.sh with Docker build functionality and base href support Update README.md to reflect changes in Docker image build commands using meet.sh Update package.json to correct versioning and remove redundant entries Added browser sync for live reloading chore: update @typescript-eslint packages to version 8.46.1 in frontend and pnpm-lock.yaml fix: correct argument skipping logic and ensure typings are built in install_dependencies function Adapt project structure backend: add TypeScript type annotations for Router instances in route files fix: update path for nodemon configuration in dev:rest-api-docs script fix: update paths in webcomponent documentation generation scripts fix: update Dockerfile and entrypoint script for correct directory structure and improve error handling fix: update .dockerignore and Dockerfile for improved directory handling and permissions; add backend type checker script Added all tests files Updates OpenVidu Meet action refs to main Updates the OpenVidu Meet GitHub Action references in the CI workflows to point to the `main` branch. This ensures that the workflows use the latest version of the action.
489 lines
17 KiB
JavaScript
489 lines
17 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* Generates documentation for the OpenVidu Meet WebComponent
|
|
*/
|
|
class WebComponentDocGenerator {
|
|
constructor() {
|
|
this.typingsPath = path.join(__dirname, '../meet-ce/typings/src/webcomponent');
|
|
this.webComponentPath = path.join(__dirname, '../meet-ce/frontend/webcomponent/src/components/OpenViduMeet.ts');
|
|
}
|
|
|
|
/**
|
|
* Reads and parses a TypeScript file to extract enum documentation
|
|
*/
|
|
parseEnumFile(filePath) {
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
const lines = content.split('\n');
|
|
|
|
const enums = [];
|
|
let currentEnum = null;
|
|
let currentItem = null;
|
|
let inEnum = false;
|
|
let inComment = false;
|
|
let commentLines = [];
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
const line = lines[i].trim();
|
|
|
|
// Detect start of enum
|
|
if (line.startsWith('export enum')) {
|
|
inEnum = true;
|
|
currentEnum = {
|
|
name: line.match(/export enum (\w+)/)[1],
|
|
items: []
|
|
};
|
|
continue;
|
|
}
|
|
|
|
// Detect end of enum
|
|
if (inEnum && line === '}') {
|
|
if (currentItem) {
|
|
currentEnum.items.push(currentItem);
|
|
}
|
|
enums.push(currentEnum);
|
|
inEnum = false;
|
|
currentEnum = null;
|
|
currentItem = null;
|
|
continue;
|
|
}
|
|
|
|
if (!inEnum) continue;
|
|
|
|
// Handle multi-line comments
|
|
if (line.startsWith('/**')) {
|
|
inComment = true;
|
|
commentLines = [];
|
|
continue;
|
|
}
|
|
|
|
if (inComment) {
|
|
if (line.endsWith('*/')) {
|
|
inComment = false;
|
|
continue;
|
|
}
|
|
|
|
// Extract comment content
|
|
const commentContent = line.replace(/^\*\s?/, '').trim();
|
|
if (commentContent) {
|
|
commentLines.push(commentContent);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
// Parse enum item
|
|
if (line.includes('=') && !line.startsWith('//')) {
|
|
// Save previous item if exists
|
|
if (currentItem) {
|
|
currentEnum.items.push(currentItem);
|
|
}
|
|
|
|
const match = line.match(/(\w+)\s*=\s*'([^']+)'/);
|
|
if (match) {
|
|
// Extract @required text if present
|
|
const requiredComment = commentLines.find(c => c.includes('@required'));
|
|
let requiredText = '';
|
|
if (requiredComment) {
|
|
const requiredMatch = requiredComment.match(/@required\s*(.*)/);
|
|
requiredText = requiredMatch ? requiredMatch[1].trim() : '';
|
|
}
|
|
|
|
currentItem = {
|
|
name: match[1],
|
|
value: match[2],
|
|
description: commentLines.filter(line => !line.includes('@')).join(' '),
|
|
isPrivate: commentLines.some(c => c.includes('@private')),
|
|
isModerator: commentLines.some(c => c.includes('@moderator')),
|
|
isRequired: commentLines.some(c => c.includes('@required')),
|
|
requiredText: requiredText
|
|
};
|
|
commentLines = [];
|
|
}
|
|
}
|
|
}
|
|
|
|
return enums;
|
|
}
|
|
|
|
/**
|
|
* Extracts payload information from interface definitions
|
|
*/
|
|
extractPayloads(filePath) {
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
const payloads = {};
|
|
|
|
// Find the payload interface
|
|
const interfaceMatch = content.match(/export interface \w+Payloads\s*{([\s\S]*?)^}/m);
|
|
if (!interfaceMatch) return payloads;
|
|
|
|
const interfaceContent = interfaceMatch[1];
|
|
const lines = interfaceContent.split('\n');
|
|
|
|
let currentKey = null;
|
|
let inComment = false;
|
|
let commentLines = [];
|
|
|
|
for (const line of lines) {
|
|
const trimmed = line.trim();
|
|
|
|
if (trimmed.startsWith('/**')) {
|
|
inComment = true;
|
|
commentLines = [];
|
|
continue;
|
|
}
|
|
|
|
if (inComment) {
|
|
if (trimmed.endsWith('*/')) {
|
|
inComment = false;
|
|
continue;
|
|
}
|
|
|
|
const commentContent = trimmed.replace(/^\*\s?/, '').trim();
|
|
if (commentContent && !commentContent.includes('@')) {
|
|
commentLines.push(commentContent);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
// Parse payload property - looking for patterns like [WebComponentEvent.JOIN]: {
|
|
const propMatch = trimmed.match(/\[\w+\.(\w+)\]:\s*({[\s\S]*?}|[^,;]+)[,;]?/);
|
|
if (propMatch) {
|
|
const enumValue = propMatch[1];
|
|
let type = propMatch[2].trim();
|
|
|
|
// If it's a multi-line object, we need to collect the full definition
|
|
if (type.startsWith('{') && !type.endsWith('}')) {
|
|
// Find the closing brace
|
|
let braceCount = 1;
|
|
let i = lines.indexOf(line) + 1;
|
|
while (i < lines.length && braceCount > 0) {
|
|
const nextLine = lines[i].trim();
|
|
type += '\n' + nextLine;
|
|
for (const char of nextLine) {
|
|
if (char === '{') braceCount++;
|
|
if (char === '}') braceCount--;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
payloads[enumValue] = {
|
|
type: type.replace(/[,;]$/, ''), // Remove trailing comma or semicolon
|
|
description: commentLines.join(' ')
|
|
};
|
|
commentLines = [];
|
|
}
|
|
}
|
|
|
|
return payloads;
|
|
}
|
|
|
|
/**
|
|
* Extracts WebComponent attributes from the OpenViduMeet.ts file
|
|
*/
|
|
extractWebComponentAttributes() {
|
|
const content = fs.readFileSync(this.webComponentPath, 'utf8');
|
|
const attributes = [];
|
|
|
|
// Look for @attribute JSDoc comments
|
|
const attributeMatches = content.match(/@attribute\s+([^\s]+)\s*-\s*([^\n]+)/g);
|
|
if (attributeMatches) {
|
|
attributeMatches.forEach(match => {
|
|
const parts = match.match(/@attribute\s+([^\s]+)\s*-\s*(.+)/);
|
|
if (parts) {
|
|
attributes.push({
|
|
name: parts[1],
|
|
description: parts[2].trim()
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
return attributes;
|
|
}
|
|
|
|
/**
|
|
* Generates markdown table for events (only public events)
|
|
*/
|
|
generateEventsTable() {
|
|
const enums = this.parseEnumFile(path.join(this.typingsPath, 'event.model.ts'));
|
|
const payloads = this.extractPayloads(path.join(this.typingsPath, 'event.model.ts'));
|
|
|
|
const eventEnum = enums.find(e => e.name === 'WebComponentEvent');
|
|
if (!eventEnum) return '';
|
|
|
|
let markdown = '| Event | Description | Payload |\n';
|
|
markdown += '|-------|-------------|------------|\n';
|
|
|
|
for (const item of eventEnum.items) {
|
|
// Skip private events
|
|
if (item.isPrivate) continue;
|
|
|
|
const payload = payloads[item.name];
|
|
const payloadInfo = payload ? this.formatPayload(payload.type) : '-';
|
|
|
|
markdown += `| \`${item.value}\` | ${item.description || 'No description available'} | ${payloadInfo} |\n`;
|
|
}
|
|
|
|
return markdown;
|
|
}
|
|
|
|
/**
|
|
* Generates markdown table for commands/methods (only public methods)
|
|
*/
|
|
generateCommandsTable() {
|
|
const enums = this.parseEnumFile(path.join(this.typingsPath, 'command.model.ts'));
|
|
const payloads = this.extractPayloads(path.join(this.typingsPath, 'command.model.ts'));
|
|
|
|
const commandEnum = enums.find(e => e.name === 'WebComponentCommand');
|
|
if (!commandEnum) return '';
|
|
|
|
let markdown = '| Method | Command | Description | Parameters | Access Level |\n';
|
|
markdown += '|--------|---------|-------------|------------|-------------|\n';
|
|
|
|
for (const item of commandEnum.items) {
|
|
// Skip private commands
|
|
if (item.isPrivate) continue;
|
|
|
|
const payload = payloads[item.name];
|
|
|
|
// Generate method name from command name and payload
|
|
const methodName = this.generateMethodName(item.name, item.value, payload);
|
|
|
|
const params = payload ? this.formatMethodParameters(payload.type) : '-';
|
|
|
|
// Determine access level based on @moderator annotation
|
|
const accessLevel = this.getAccessLevel(item);
|
|
|
|
markdown += `| \`${methodName}\` | \`${item.value}\` | ${item.description || 'No description available'} | ${params} | ${accessLevel} |\n`;
|
|
}
|
|
|
|
return markdown;
|
|
}
|
|
|
|
/**
|
|
* Generates method name and signature from command enum
|
|
*/
|
|
generateMethodName(commandName, commandValue, payload) {
|
|
// Convert COMMAND_NAME to camelCase method name
|
|
const methodName = commandName
|
|
.toLowerCase()
|
|
.split('_')
|
|
.map((word, index) => index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1))
|
|
.join('');
|
|
|
|
// If there's no payload or payload is void, no parameters needed
|
|
if (!payload || payload.type === 'void') {
|
|
return `${methodName}()`;
|
|
}
|
|
|
|
// Extract parameter names from payload type
|
|
if (payload.type.includes('{') && payload.type.includes('}')) {
|
|
// Remove comments (both single-line // and multi-line /* */)
|
|
const cleanedType = payload.type
|
|
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove /* */ comments
|
|
.replace(/\/\/.*$/gm, ''); // Remove // comments
|
|
|
|
const properties = cleanedType
|
|
.replace(/[{}]/g, '')
|
|
.split(';')
|
|
.map(prop => prop.trim())
|
|
.filter(prop => prop && !prop.startsWith('//') && !prop.startsWith('/*'))
|
|
.map(prop => {
|
|
const [key] = prop.split(':').map(s => s.trim());
|
|
return key;
|
|
})
|
|
.filter(key => key); // Remove empty keys
|
|
|
|
if (properties.length > 0) {
|
|
return `${methodName}(${properties.join(', ')})`;
|
|
}
|
|
}
|
|
|
|
// Fallback: no parameters
|
|
return `${methodName}()`;
|
|
}
|
|
|
|
/**
|
|
* Determines the access level of a command based on its @moderator annotation
|
|
*/
|
|
getAccessLevel(item) {
|
|
return item.isModerator ? 'Moderator' : 'All';
|
|
}
|
|
|
|
/**
|
|
* Generates markdown table for attributes/properties
|
|
*/
|
|
generateAttributesTable() {
|
|
const propertyEnums = this.parseEnumFile(path.join(this.typingsPath, 'properties.model.ts'));
|
|
const propertyEnum = propertyEnums.find(e => e.name === 'WebComponentProperty');
|
|
|
|
let markdown = '| Attribute | Description | Required |\n';
|
|
markdown += '|-----------|-------------|----------|\n';
|
|
|
|
// Add attributes from the properties enum only
|
|
if (propertyEnum) {
|
|
for (const item of propertyEnum.items) {
|
|
// Format required column with additional text if present
|
|
let requiredColumn = 'No';
|
|
if (item.isRequired) {
|
|
requiredColumn = item.requiredText ? `Yes (${item.requiredText})` : 'Yes';
|
|
}
|
|
|
|
// Use description from JSDoc comments, fallback to hardcoded if not available
|
|
const description = item.description || this.getDescriptionForAttribute(item.value);
|
|
|
|
markdown += `| \`${item.value}\` | ${description} | ${requiredColumn} |\n`;
|
|
}
|
|
}
|
|
|
|
return markdown;
|
|
}
|
|
|
|
/**
|
|
* Formats payload type information for display in events table
|
|
*/
|
|
formatPayload(type) {
|
|
if (type === 'void' || type === '{}') {
|
|
return 'None';
|
|
}
|
|
|
|
// Handle object types
|
|
if (type.includes('{') && type.includes('}')) {
|
|
const properties = type
|
|
.replace(/[{}]/g, '')
|
|
.split(';')
|
|
.map(prop => prop.trim())
|
|
.filter(prop => prop)
|
|
.map(prop => {
|
|
const [key, value] = prop.split(':').map(s => s.trim());
|
|
return `"${key}": "${value}"`;
|
|
});
|
|
|
|
if (properties.length > 0) {
|
|
const tab = ' ';
|
|
const jsonContent = '{ <br>' + tab + properties.join(',<br>' + tab) + '<br>}';
|
|
return `<pre><code>${jsonContent}</code></pre>`;
|
|
} else {
|
|
return '<pre><code>{}</code></pre>';
|
|
}
|
|
}
|
|
|
|
return `\`${type}\``;
|
|
}
|
|
|
|
/**
|
|
* Formats method parameters for display
|
|
*/
|
|
formatMethodParameters(type) {
|
|
if (type === 'void') {
|
|
return '-';
|
|
}
|
|
|
|
// Handle object types
|
|
if (type.includes('{') && type.includes('}')) {
|
|
// Remove comments (both single-line // and multi-line /* */)
|
|
const cleanedType = type
|
|
.replace(/\/\*[\s\S]*?\*\//g, '') // Remove /* */ comments
|
|
.replace(/\/\/.*$/gm, ''); // Remove // comments
|
|
|
|
const properties = cleanedType
|
|
.replace(/[{}]/g, '')
|
|
.split(';')
|
|
.map(prop => prop.trim())
|
|
.filter(prop => prop && !prop.startsWith('//') && !prop.startsWith('/*'))
|
|
.map(prop => {
|
|
const [key, value] = prop.split(':').map(s => s.trim());
|
|
return `• \`${key}\`: ${value}`;
|
|
})
|
|
.filter(param => param && !param.includes('undefined')); // Remove malformed parameters
|
|
|
|
return properties.length > 0 ? properties.join('<br>') : 'object';
|
|
}
|
|
|
|
return type;
|
|
}
|
|
|
|
/**
|
|
* Gets description for an attribute
|
|
*/
|
|
getDescriptionForAttribute(attributeName) {
|
|
const descriptions = {
|
|
'room-id': 'Unique identifier for the meeting room',
|
|
'participant-name': 'Display name for the local participant',
|
|
'leave-redirect-url': 'URL to redirect to when leaving the meeting'
|
|
};
|
|
return descriptions[attributeName] || 'No description available';
|
|
}
|
|
|
|
/**
|
|
* Generates separate documentation files
|
|
*/
|
|
generateSeparateDocuments(outputDir = './docs') {
|
|
// Ensure output directory exists
|
|
if (!fs.existsSync(outputDir)) {
|
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
}
|
|
|
|
// Header comment for all generated files
|
|
const headerComment = `<!-- This file is auto-generated. Do not edit manually. -->\n<!-- Generated by openvidu-meet/scripts/generate-webcomponent-docs.js -->\n\n`;
|
|
|
|
const eventsTable = this.generateEventsTable();
|
|
const commandsTable = this.generateCommandsTable();
|
|
const attributesTable = this.generateAttributesTable();
|
|
|
|
// Write separate files with header comments
|
|
const eventsPath = path.join(outputDir, 'webcomponent-events.md');
|
|
const commandsPath = path.join(outputDir, 'webcomponent-commands.md');
|
|
const attributesPath = path.join(outputDir, 'webcomponent-attributes.md');
|
|
|
|
fs.writeFileSync(eventsPath, headerComment + eventsTable, 'utf8');
|
|
fs.writeFileSync(commandsPath, headerComment + commandsTable, 'utf8');
|
|
fs.writeFileSync(attributesPath, headerComment + attributesTable, 'utf8');
|
|
|
|
return {
|
|
events: eventsPath,
|
|
commands: commandsPath,
|
|
attributes: attributesPath
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Saves the generated documentation to separate files
|
|
*/
|
|
saveDocumentation(outputDir = './docs') {
|
|
const files = this.generateSeparateDocuments(outputDir);
|
|
|
|
console.log('✅ Documentation generated successfully:');
|
|
console.log(`📄 Events: ${files.events}`);
|
|
console.log(`🔧 Commands: ${files.commands}`);
|
|
console.log(`⚙️ Attributes: ${files.attributes}`);
|
|
|
|
// Display summary
|
|
console.log('\n📊 Documentation Summary:');
|
|
console.log('- Only public/non-private elements included');
|
|
console.log('- Three separate markdown files generated');
|
|
console.log('- Tables only, no additional content');
|
|
}
|
|
}
|
|
|
|
// Main execution
|
|
if (require.main === module) {
|
|
const generator = new WebComponentDocGenerator();
|
|
|
|
// Parse command line arguments
|
|
const args = process.argv.slice(2);
|
|
const outputDir = args[0] || './docs';
|
|
|
|
try {
|
|
generator.saveDocumentation(outputDir);
|
|
} catch (error) {
|
|
console.error('❌ Error generating documentation:', error.message);
|
|
console.error('Stack trace:', error.stack);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
module.exports = WebComponentDocGenerator;
|