-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-videos): video upload and manage videos plugin #8621
Conversation
WalkthroughThis pull request involves a comprehensive renaming and restructuring of the video capture plugin from Changes
Possibly related PRs
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
packages/plugins/videos/src/lib/videos.plugin.ts (2)
21-21
: Consider using a structured logging library.
Usingconsole.log
here is fine, but switching to a dedicated logger (e.g., Winston or a NestJS logger) can enhance logging flexibility, verbosity levels, and better integration with production environments.
30-30
: Apply consistent log color patterns and messages for destroy lifecycle.
You may wish to align log color usage across your codebase (e.g., always using green for start logs and red for error or end logs). Consistency helps developers quickly spot plugin lifecycle transitions.packages/plugins/videos/README.md (1)
17-29
: Enhance publishing documentation with prerequisitesWhile the basic publishing instructions are present, consider adding important prerequisites and best practices:
Add the following information:
## Publishing +Before publishing: +1. Ensure you have the necessary permissions to publish to the npm registry +2. Update the version number in package.json following semver +3. Review the list of files to be published in package.json + After building your library with `yarn nx build plugin-videos`, go to the dist folder `dist/packages/plugins/videos` and run `npm publish`. + +Note: Ensure all peer dependencies are properly specified in your package.json before publishing. ## Installation
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
.deploy/api/Dockerfile
(3 hunks)apps/api/package.json
(1 hunks)apps/api/src/plugins.ts
(2 hunks)apps/server-api/src/package.json
(1 hunks)apps/server/src/package.json
(1 hunks)package.json
(2 hunks)packages/plugins/video-capture/CHANGELOG.md
(0 hunks)packages/plugins/video-capture/README.md
(0 hunks)packages/plugins/video-capture/src/index.ts
(0 hunks)packages/plugins/videos/CHANGELOG.md
(1 hunks)packages/plugins/videos/README.md
(1 hunks)packages/plugins/videos/jest.config.ts
(1 hunks)packages/plugins/videos/package.json
(3 hunks)packages/plugins/videos/project.json
(3 hunks)packages/plugins/videos/src/index.ts
(1 hunks)packages/plugins/videos/src/lib/videos.plugin.ts
(3 hunks)tsconfig.json
(1 hunks)
💤 Files with no reviewable changes (3)
- packages/plugins/video-capture/CHANGELOG.md
- packages/plugins/video-capture/README.md
- packages/plugins/video-capture/src/index.ts
✅ Files skipped from review due to trivial changes (3)
- packages/plugins/videos/CHANGELOG.md
- packages/plugins/videos/src/index.ts
- packages/plugins/videos/jest.config.ts
🧰 Additional context used
🪛 LanguageTool
packages/plugins/videos/README.md
[grammar] ~3-~3: The singular determiner ‘this’ may not agree with the plural noun ‘plugins’. Did you mean “these”?
Context: ...as generated with Nx. This plugins provides functionality to uploa...
(THIS_NNS)
[grammar] ~6-~6: The singular determiner ‘this’ may not agree with the plural noun ‘plugins’. Did you mean “these”?
Context: ... upload and manage videos ## Overview This plugins provides functionality to uploa...
(THIS_NNS)
🔇 Additional comments (19)
packages/plugins/videos/src/lib/videos.plugin.ts (1)
12-12
: Renaming to VideosPlugin
aligns with the expanded video functionality.
Great alignment with the new naming scheme. The rename from VideoCapturePlugin
to VideosPlugin
is coherent and consistent with your broader scope for video management tasks.
apps/api/src/plugins.ts (2)
14-14
: Imports updated to reflect the renamed plugin.
This import rename is consistent with the underlying plugin name changes. Confirm that all references to the old plugin have been removed to avoid confusion.
55-56
: Good integration of VideosPlugin
.
Including VideosPlugin
in the plugins
array appears correct. Ensure that any environment-specific configurations or plugin-specific hooks are still valid under the new name.
packages/plugins/videos/project.json (4)
2-2
: Project name updated to match the new plugin scope.
Renaming "plugin-video-capture"
to "plugin-videos"
is consistent with the rebranding. This will help clarify the plugin’s broader functionality.
4-4
: Source root path is correctly updated.
"sourceRoot": "packages/plugins/videos/src"
matches the new directory structure.
21-25
: Ensure your Nx build output paths match internal references.
The updated outputPath
, tsConfig
, packageJson
, main
, and assets
fields align with the renamed plugin folder. Double-check that no references to plugin-video-capture
remain in your scripts or code imports.
40-40
: Jest configuration path updated.
"jestConfig": "packages/plugins/videos/jest.config.ts"
is now consistent with the new folder structure, ensuring tests run properly.
packages/plugins/videos/package.json (4)
2-2
: Name aligned with the plugin rebrand.
Switching to "@gauzy/plugin-videos"
appropriately reflects the expanded feature set.
4-4
: Description clarifies the plugin’s broader functionality.
Replacing “continuous video recording” with “upload and manage videos” provides a clearer indication of the new scope.
24-26
: Build scripts updated to match the new project name.
Renaming the scripts to reference plugin-videos
is consistent with the project’s structure. Double-check any CI/CD scripts or Dockerfiles that might still reference plugin-video-capture
.
42-50
: Keywords comprehensively reflect the new plugin domain.
Including video-upload
, video-management
, media-upload
, and other tags improves discoverability and clarifies the plugin’s expanded scope.
apps/api/package.json (1)
56-56
: LGTM! Dependency update is consistent.
The dependency update from @gauzy/plugin-video-capture
to @gauzy/plugin-videos
aligns with the plugin renaming across the codebase.
tsconfig.json (1)
44-44
: LGTM! Path mapping is consistent.
The TypeScript path mapping update aligns with the plugin renaming and follows the project's path structure convention.
✅ Verification successful
Path mapping and directory structure are correctly aligned
The verification confirms that:
- The plugin directory exists at
packages/plugins/videos/
- The main entry point
index.ts
exists at the mapped pathpackages/plugins/videos/src/index.ts
- The directory structure follows the project's conventions with proper organization of commands, queries, and DTOs
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the existence of the new plugin directory and its index file
fd --type d "videos" packages/plugins/ && \
fd --type f "index.ts" packages/plugins/videos/src/
Length of output: 363
apps/server/src/package.json (1)
150-150
: LGTM! Local dependency path is consistent.
The dependency update to @gauzy/plugin-videos
with the local file path is consistent with the plugin renaming and follows the project's monorepo structure.
✅ Verification successful
The previous verification failed because the dist
directory might not be available in the sandbox environment. Let's check the source files and references to understand if the dependency path is correctly structured.
Local dependency path is correctly structured and consistent
The verification confirms that:
- The plugin exists at
packages/plugins/videos/
with proper package name@gauzy/plugin-videos
- The local dependency path
file:../../../dist/packages/plugins/videos
inapps/server/src/package.json
is correctly structured relative to the plugin's build output location - The plugin is properly referenced in the workspace's TypeScript configuration and is being used in the API application
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the existence of the plugin's build directory
fd --type d "videos$" dist/packages/plugins/
Length of output: 156
Script:
#!/bin/bash
# Let's first check if the plugin directory exists in the source
fd --type d "videos$" packages/plugins/
# Check the package.json in the plugin directory if it exists
fd "package.json$" packages/plugins/videos/ --exec cat {}
# Check for any references to this plugin in the workspace
rg "@gauzy/plugin-videos" -A 2 -B 2
Length of output: 4660
apps/server-api/src/package.json (1)
150-150
: LGTM! Dependency correctly added
The new videos plugin dependency is properly configured with the correct local file path, maintaining consistency with other plugin dependencies.
.deploy/api/Dockerfile (1)
163-163
: LGTM! Dockerfile changes are consistent
The COPY commands for the videos plugin are properly added in both development and production stages, maintaining consistency with other plugins' setup.
Also applies to: 236-236, 370-370
package.json (2)
159-161
: LGTM! Build scripts properly updated
The videos plugin is correctly integrated into the post-build scripts for all environments (development, production, and docker).
234-236
: Verify the build script functionality
The new build scripts for the videos plugin look correct, but let's verify they work as expected.
✅ Verification successful
Build scripts are correctly configured and plugin structure is valid
The build scripts for the plugin-videos are correctly configured and the plugin structure is valid based on the following findings:
- The plugin has a proper NX project structure with all necessary configuration files (tsconfig.json, project.json)
- The package.json contains correct build scripts that match the ones in the root package.json
- The source code structure follows the standard plugin architecture with:
- Commands and handlers for video operations
- DTOs for data transfer
- Entities and repositories
- Services and controllers
- Proper module and plugin setup
The build commands in the root package.json:
build:package:plugin:videos
build:package:plugin:videos:prod
build:package:plugin:videos:docker
align with the plugin's own build configuration and will work as expected.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the build scripts for the videos plugin
# Test: Check if the plugin can be built successfully
yarn build:package:plugin:videos 2>&1 | grep -i "error"
# Test: Verify the build output directory exists
test -d "dist/packages/plugins/videos" && echo "Build directory exists" || echo "Build directory missing"
# Test: Check for any references to the old plugin name
rg -i "video-capture" .
Length of output: 235
Script:
#!/bin/bash
# Let's verify the nx configuration and workspace setup for the videos plugin
# Check if the plugin is configured in nx.json
cat nx.json
# Check for plugin configuration in workspace.json or project.json
fd -t f "project.json|workspace.json" --exec cat {}
# Look for any existing plugin-videos related files
fd -t f "plugin-videos"
# Check package.json for related dependencies and scripts
cat package.json | grep -A 5 -B 5 "plugin-videos"
Length of output: 72228
Script:
#!/bin/bash
# Let's check the plugin-videos project configuration and source files
# Check if plugin-videos directory exists and list its contents
fd -t d "plugin-videos$" -x ls -la {}
# Check tsconfig for the plugin
fd -t f "tsconfig.lib.json" -p "plugin-videos"
# Look for the main entry point and source files
fd -t f "index.ts|main.ts" -p "plugin-videos/src"
# Check for any existing build artifacts
ls -la dist/packages/plugins/videos 2>/dev/null || echo "No build artifacts found"
Length of output: 439
Script:
#!/bin/bash
# Let's check the correct path structure for the plugin
# Find the plugin-videos directory anywhere in the repository
fd -t d "videos" -p "packages/plugins"
# Check package.json in the plugins directory
fd -t f "package.json" -p "packages/plugins/videos" -x cat {}
# Check the nx.json configuration for the plugin
cat nx.json | grep -A 10 -B 10 "plugin-videos"
# List all files related to the plugin
fd . -p "packages/plugins/videos" 2>/dev/null || echo "Plugin directory not found"
Length of output: 4554
packages/plugins/videos/README.md (1)
9-16
: LGTM! Build and test instructions are clear and accurate
The build and test instructions are well-documented and follow Nx conventions.
View your CI Pipeline Execution ↗ for commit 6107841.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/lib/database/migrations/1735058989058-CreateVideoTable.ts (1)
104-132
: Check constraint differences between Postgres and SQLite.
While Postgres usestext
forstorageProvider
, SQLite still has a check constraint enumerating allowed values (LOCAL
,S3
, etc.). This is acceptable, but ensure it’s intentional and that any code referencing these columns does not rely on an enum type being enforced across databases.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/core/src/lib/database/migrations/1735058989058-CreateVideoTable.ts
(6 hunks)packages/plugins/videos/src/lib/entities/video.entity.ts
(2 hunks)
🔇 Additional comments (6)
packages/core/src/lib/database/migrations/1735058989058-CreateVideoTable.ts (3)
62-74
: Ensure consistency for Postgres table creation.
The use of text
columns for storageProvider
, resolution
, and codec
is valid and flexible. Consider verifying that all references to these columns (e.g., in the entity definitions) accurately reflect this type in Postgres. Also, confirm that the default values align with business requirements.
83-94
: Drop constraints and indexes carefully.
The down
migration reliably reverts the created foreign key constraints and indexes. Confirm that the dropped index/constraint names match exactly the ones created in the up
migration.
141-168
: Down migration finalizes SQLite table reversal.
All indexes are dropped and the table is reverted to its prior schema. This is a standard pattern for SQLite. Confirm that no data is lost during the rename and copy steps, especially if the default values differ between versions.
packages/plugins/videos/src/lib/entities/video.entity.ts (3)
116-127
: Validate references to the storageProvider
property.
Switching from simple-enum
to text
in the database is consistent with your migration changes. Ensure that any external services or code expecting a specific enum type can still handle string values in the database.
132-142
: Confirm resolution defaults and validation.
Storing resolution
as text with a default of '1920:1080'
is suitable. The @IsEnum
constraint ensures code-level validation against VideoResolutionEnum
. Verify that new custom resolutions or future expansions won’t conflict with the text column approach.
156-160
: Codec default alignment.
Using text type and default libx264
aligns with the migration changes. Confirm that the @IsEnum(VideoCodecEnum)
usage is tested to guard against invalid codec strings at runtime.
* feat: handle dashboard subscriber * feat: dashboard service * feat: dashboard commands * feat: dashboard api and permission * [Feat] Create video plugin module (#8613) * feat: adds video model and refactors imports Introduces a new video model to support video functionalities. This includes properties for video metadata, storage information, and relationships with other models like time slots and employees. Additionally, several imports are reorganized for better code structure. * feat: adds Video entity This introduces the `Video` entity to store video-related information, including title, file path, recording date, duration, size, URL, storage provider, description, resolution, codec, frame rate, and uploader details. It includes validation and relationships with `TimeSlot` and `Employee` entities. * feat: introduces file storage path generation This change introduces a new mechanism for generating file storage paths. It uses a combination of date, tenant ID, and employee ID to create unique and organized storage locations. A factory class simplifies the creation of storage engines with this path generation logic. * feat(videos): adds DTOs for video management Introduces Data Transfer Objects (DTOs) for creating, updating, and deleting videos. Includes a FileDTO for handling video uploads and a BaseVideoDTO for common video properties. These DTOs provide type safety and validation for video-related operations. * feat: adds video repositories for MikroORM and TypeORM Introduces `MikroOrmVideoRepository` and `TypeOrmVideoRepository` to support different ORM integrations. * feat: adds video service Introduces a new service to manage video entities. It utilizes both TypeORM and MikroORM repositories for data access. * feat: add video entity and migration This commit introduces the `Video` entity and its corresponding database migration. The migration creates the `videos` table with fields for video metadata like title, file path, duration, size, storage provider, and relations to other entities such as tenant, organization, time slot, and uploading employee. It also includes indexes for efficient querying. The migration handles different database types (PostgreSQL, SQLite, Better SQLite3, MySQL) and includes specific up and down migration logic for each. * feat: adds commands and handlers for video management This commit introduces new commands and handlers for managing videos: - Creates `CreateVideoCommand` and `CreateVideoHandler` to add new videos. - Implements `UpdateVideoCommand` and `UpdateVideoHandler` to modify existing videos. - Adds `DeleteVideoCommand` and `DeleteVideoHandler` to remove videos. This change enables basic CRUD operations for videos within the application. * feat: adds queries and handlers for fetching videos This introduces new queries and handlers for retrieving video data: - `GetVideoQuery` and `GetVideoQueryHandler`: Fetch a single video by ID. - `GetVideosQuery` and `GetVideosQueryHandler`: Fetch a list of videos with pagination support. * feat: adds video subscriber for lifecycle management Implements a TypeORM subscriber for the `Video` entity to manage file storage during entity lifecycle events. - Sets the `fullUrl` property after loading a video entity by retrieving the URL from the configured storage provider. - Deletes the associated video file from storage after a video entity is deleted. This ensures consistent data and efficient storage management by automatically handling file operations related to videos. * feat(videos): implements video controller This commit introduces a new video controller feature, including: - Creating new video records with associated metadata and file uploads. - Retrieving video records by ID. - Listing all video records with pagination support. - Deleting video records. The implementation uses CQRS and leverages a file storage service for managing video files. It also includes validation and error handling for file uploads and data integrity. * feat: Implements video plugin module This commit introduces a new video plugin. It includes: - A new module for videos with controllers, services, and repositories. - Integration with TypeORM and MikroORM for database operations. - CQRS implementation for handling commands and queries. - Role-based permission management. - Routing configuration for the plugin. * feat: adds video entity and subscriber Introduces the `Video` entity and its corresponding subscriber to the core module. This lays the foundation for managing video data within the application. * feat: adds PluginModule to AppModule Registers the PluginModule in the application's root module to enable plugin functionality. * fix: cspell spelling * feat(plugin-video-capture): create library for video capture plugin * refactor: plugin video capture module & entity * fix(migration): video table for plugin video capture * fix(videos): Implement query handlers for video CRUD operations * fix(migration): refactor `video` [table] for MySQL * refactor: suggestion by coderabbit AI * fix(migration): refactor `video` [table] for DBs * fix(subscriber): video subscriber initialization and event handling * fix(cspell): typo spelling :-) --------- Co-authored-by: Rahul R. <rahulrathore576@gmail.com> * fix(docker): packages build for desktop apps * fix(plugin-videos): video upload and manage videos plugin (#8621) * fix(plugin-videos): video upload and manage videos plugin * fix(plugin-videos): updated README.md for videos plugin * fix(migration): update video table schema for PostgreSQL and SQLite * chore: optimize docker builds * chore: switch to manual postinstall scripts run * chore: forgot to copy script * fix(migration): update video table schema for DBs * chore: add description for dashboard commands * fix: add TS types * chore: fix Docker API builds * fix: postinstall script * [Feat] Dashboard Widget Entity (#8616) * feat: create dashboard widget model * feat: dashboard widget entity and migration * fix: widget size type --------- Co-authored-by: Rahul R. <rahulrathore576@gmail.com> --------- Co-authored-by: GloireMutaliko21 <mufunyig@gmail.com> Co-authored-by: Kifungo A <45813955+adkif@users.noreply.github.com> Co-authored-by: Rahul R. <rahulrathore576@gmail.com> Co-authored-by: Rahul R. <41804588+rahul-rocket@users.noreply.github.com> Co-authored-by: Gloire Mutaliko (Salva) <86450367+GloireMutaliko21@users.noreply.github.com>
PR
Please note: we will close your PR without comment if you do not check the boxes above and provide ALL requested information.
Summary by CodeRabbit
Release Notes
New Features
@gauzy/plugin-videos
for video uploading and management.Changes
videos
, affecting all related scripts and dependencies.@gauzy/plugin-videos
, including README and changelog entries.Bug Fixes